Repository navigation
feat: start and steer agents from Slack - #660
fctl-sh[bot] wants to merge 38 commits into
Conversation
The control plane's side of fctl's Slack app (fctl#620): its wire types, the D1 tables, installing it per workspace with OAuth, linking people with Sign in with Slack, sessions from mentions, direct messages, /fctl and Send to fctl…, the card each keeps current in its thread, replies, questions with answer buttons, fctl slack for agents, Socket Mode, the Home tab, notifications as direct messages, projects' events in a channel, and dropping Slack from transcripts once sessions end where a workspace asks for that.
Also: /fctl's form starts its thread in its channel, expired requests count their month from when they expired, and clippy's lints hold for the new code.
fctl admin slack shows how the instance's Slack app stands and prints its manifest. Every message's fallback text is escaped and its mentions defused, as its blocks are; Send to fctl… keeps the message it sends from Slack's payload, and reads a thread only where the message has one.
The admin who installs fctl's app links their own Slack account as everyone does, with Sign in with Slack and confirming it's them where the instance asks.
…private notes where Slack does
cargo xtask dev starts xtask/slack beside Linear's stand-in, points the control plane's Slack app at it, connects the dev workspace to its Acme, maps #web-team to Playground, makes #incidents readable and links the dev owner's account. cargo xtask slack acts as people there do and follows fctl's answers; --smoke runs a mention to its card and reply. fake-claude reads quoted lines as Slack's asks come, and runs fctl slack lines.
A page for people and admins (docs/slack.md), the architecture's Slack section, connecting a Slack app on a self-hosted instance with its manifest, the CLI and API, security, development's stand-in, and ADR 0102.
…r fixes from the docs' review - Threads are read page by page, what's new first, as Slack's 15 a page for unlisted apps needs. - A refused or expired thread takes a new request from whoever mentions fctl there; Send to fctl… into a thread fctl knows says so. - Slack's stop button stops the agent only for someone fctl knows who may message the session. - An account matched by its address counts only while that's allowed. - Webhooks' sessions name their Slack thread, fctl webhooks takes --started-by slack, and identity tokens say slack. - slack_asked and slack_failed notices; guests are refused before they're asked to link; the person who asked in a thread isn't also notified by DM; Slack's working status is said again within the hour; channel names go bare in examples, as a shell takes # for a comment.
Acme's Slack, with its people, channels and threads: Slack's install and sign-in pages, its Web API as fctl calls it, and the events, interactions and commands it signs, with Slack's limits on blocks, retries and rate limits to check fctl against. cargo xtask slack follows a direct message's thread too.
…s Slack from the CLI Connect again installs fctl's app in the Slack workspace whose access it lost (fctl workspaces slack connect --team), and the way back names the Slack workspace connected. A project's maintainers search Slack's public channels for the one its events go to, where the workspace lets projects post there, and fctl projects slack shows and changes what a project does with Slack.
GitHub, Linear and Slack move into one Integrations tab on the workspace page, each a tile that says how it stands; their old addresses still lead there. Slack's page introduces it with a drawn thread, connects a Slack workspace, and keeps what the workspace allows there, its channels and each project's choice, read-only for members. Settings gains your Slack accounts and notifications in Slack, projects their Slack settings, admins the app's setup and manifest, and sessions show where in Slack they started, with Slack's messages and notices in the transcript.
Unoptimized, the router's frame keeps a slot for each route's future: 742 KB on main, 796 KB with Slack's routes, and hashing a password under it overflowed the Worker's 1 MiB stack, so cargo xtask dev's setup failed with 'memory access out of bounds'. The routes now come in two halves tried one after the other, with Slack's as one route, which brings the deepest frame to 414 KB.
… replies and answers views.publish takes a view, not its blocks: Slack refused fctl's Home tab. Replies and answers from Slack now say which channel they came from in the transcript. cargo xtask slack follows only what fctl posts after the action, prints what fctl shows one person alone, and takes '#channel' before a mention's text, as its docs say; the smoke test opens the Home tab too.
A session from Slack could reach a runner before fctl marked its thread started, and its agent then heard nothing of the thread: neither that its replies go there nor about fctl slack thread. The thread is now marked as the session starts, before it's queued.
This comment has been minimized.
This comment has been minimized.
/fctl and its form posted the task in the channel before checking it, and a Slack lookup that failed skipped the checks for guests and Slack Connect channels. Every channel is now checked before fctl posts in it or takes from it: one shared with another organization is refused, and so is a conversation fctl can't see, which may be; Send to fctl… says so before its form, and a guest check Slack doesn't answer refuses too.
…nor name unseen projects Matching by address now leaves anyone fctl knows in that Slack workspace already, so another Slack user with their address can't take their link over. A workspace's Slack answer names only the projects the caller sees for its channels.
… when ranking misses Search checks each readable channel with Slack as history does, so one made private, shared or archived since isn't searched, and falls back to reading the channels when Slack's ranking returns nothing readable. Project settings that don't parse keep agents off Slack's channels.
… the asker The agent's reply and question are posted again while Slack asks fctl to wait or doesn't answer, and where the thread takes nothing (fctl left the channel, it was archived) they go to the direct messages of the person who asked, with why. A question that reaches nobody leaves a notice in the session.
|
The finding in the review's summary, unreadable project settings turn Slack channel reading back on, was right: 61c767c sets |
This comment has been minimized.
This comment has been minimized.
…tion A rate limit or an outage of conversations.info read as 'fctl can't see this conversation' and told people to invite fctl to a channel it was in. Only Slack's channel_not_found and not_in_channel say that now; anything else asks them to try again in a minute.
…t answer Real-time Search's results count from every readable channel again, each checked with Slack once as it comes up, and only reading the channels themselves stops at ten, saying so. A channel Slack didn't describe just now is left out with a note rather than taken for one agents may no longer read.
…edirect only gone threads A post Slack didn't answer may have gone through, so it isn't tried again, which could post a reply twice. Only channel_not_found, not_in_channel, is_archived and thread_not_found send the reply or question to the asker's direct messages.
… address now Only a Slack account someone linked keeps an address from matching them: one an earlier match found moves, as when they come back as a new Slack user.
This comment has been minimized.
This comment has been minimized.
…osting in the thread Slack's restricted_action codes (a read-only channel, a locked thread) say the thread takes no posts from fctl, as a gone channel does, so the agent's reply or question goes to the asker's direct messages there too. fctl_domain::slack::thread_refuses names those codes, with a test.
docs/llms.txt: main tagged the diagram's code fence as text and said setup scripts mint identity tokens; this branch adds Slack to the diagram and fctl slack to the in-sandbox commands. Both are kept.
Main's workspace sign-in requirement (#659) took migration 0077 and ADR 0103, so this branch's Slack migration becomes 0078 (it never shipped) and its ADR 0104, with the links that name it. The workspace page keeps both sides' imports.
This comment has been minimized.
This comment has been minimized.
|
The merge of main brought in #659 (a workspace can require its members at its domains to sign in with Google), and fctl's review rightly points out that it doesn't hold Slack: the rule closes a workspace to a request according to how that request's sign-in was made (
Which should it be? |
…s made What someone asks fctl in Slack is held to that sign-in, as an access token is (hyperstructure/fctl#660), so the policy says fctl keeps how it was made, and that signing out everywhere, or sign-in rules that no longer let it in, end the link.
…ed their account A request from Slack carried no fctl sign-in, so a workspace's own Google requirement (#659) and the instance's sign-in rules held none of it: a member who signs in with a password could link Slack and start and steer the workspace's sessions from it. A link now keeps how the browser that made it signed in (slack_accounts.auth_method and auth_domain, as tokens keep it), and its requests carry it: - a workspace's requirement closes its projects to a link made another way, and fctl asks the person in Slack to sign in with Google and link again, keeping their request or reply until they do; - the instance's rules end a link they don't let in, at its next request and as they're saved, as they end such tokens; - signing out everywhere unlinks it, so that nothing made while someone else held the account outlasts it; - an address match is no sign-in, and meets no rule.
This comment has been minimized.
This comment has been minimized.
…sk fctl something A member whose Slack link doesn't meet a workspace's sign-in requirement was prompted for every message they wrote in a session's thread, and the last was kept as theirs: only a mention of fctl or the thread author's reply is now, as for people fctl doesn't know. A form's prompt no longer says fctl keeps the request, which it doesn't: it says to ask again. The retention of Slack links in the security page and ADR 0104 now says what ends them.
…y're read person() now sets UserRow::request_sign_in itself, from how the Slack account was linked (none for an address match), and says whether it's an address match, so no caller can get someone from Slack without the sign-in a workspace's requirement checks. who() builds on it.
## Summary
An autopilot can now manage the sessions people start in its places as
it does its own. A new power, `others` (*Manage people's sessions* on
the Autopilot tab, `fctl autopilot set --powers …,others`), does the
following:
- **Wakes:** fctl wakes the autopilot a minute after one of those
sessions ends a turn, asks something or fails, or a pull request of one
that's resting merges. Their merged pull requests' checks on the base
branch wake it too, as its own sessions' do.
- **Brief and wakes:** they're listed apart from its own sessions, with
who started each, what each said as its turn ended and what people wrote
to it.
- **Acting:** it can message those sessions (with files) and resume one
that failed, so it can see their pull requests updated, merged and
deployed along with its own work. A session it resumes carries on on its
people's Claude connection, as one a message resumes does, and only
while its person may still run it there.
Without the power nothing changes: people's sessions stay theirs, and
the autopilot asks before helping, as before.
Those sessions stay their people's. They run on their own Claude
subscriptions, don't count toward the autopilot's limits (so its
messages to them are never held), and keep notifying the people who
follow them. The autopilot can't interrupt, stop, rename or archive
them, and it leaves one its people stopped alone: it can't message or
resume it, since that would start the session again. Its briefing says
the starter's word wins over its own, and the session's agent is told
the same: a session whose sandbox starts while it's managed gets a line
in its system prompt (`SessionSpec.managed_by`). One that started
earlier sees each autopilot message prefixed with which autopilot wrote
it and that its people's word wins. ADR 0105 records the design.
**Verified** with:
- Unit tests:
- domain: gate, briefing, brief and wake message
- fctl-agent: the prompt line and the message prefix
- CLI: powers parsing
- web: settings dialog and wake text
- Control-plane tests against the D1 stand-in: which autopilot manages a
session, what the brief and wakes list, merge checks.
- `cargo xtask check lint`.
- An end-to-end run in `cargo xtask dev` with fake-claude. With the
power on, a person's session ending its turn woke the autopilot ("Woke
for people's session #2"), and the wake message and brief listed it with
what it said and what its starter wrote to it. The autopilot's `fctl
send playground#2 …` reached that session, its agent saw "The autopilot
wrote:" and had the new system-prompt line, and `fctl stop playground#2`
was refused.
## The dev stack's Worker stack
In the unoptimized dev Worker, the router's frame is within about 600
bytes of the 1 MiB wasm stack on main. This change's new
`AutopilotWake.others` list grew every event by enough to break the dev
stack's setup, so `UserMessage.wake` is now boxed; the JSON is the same,
and the router's frames measure the same as main's again. Separately,
relayed autopilot calls (route → relay → dispatch) already overflow that
stack in main's dev build. I ran the end-to-end check with an optimized
Worker for that reason; production builds aren't affected. #660 splits
the router, which fixes both.
## Screenshots
*What it may do*, in the settings dialog, before and after (light, then
dark): the new power sits right under *Start and steer sessions*.



*How it works*, before and after (light, then dark): with the power, it
gets a line of its own.



## Related
- hyperstructure/design#85
## Worth confirming
- **Decision:** it's a power rather than a separate setting, so it sits
in *What it may do*. It's the only power a new autopilot doesn't get by
default, and `--powers all` leaves it out too.
- **Decision:** giving it the power counts as changing how much it
works, because it adds a wake for each person's session. When someone
other than the owner turns it on, the autopilot moves to their
subscription, unless the owner keeps it on theirs.
- **Decision:** it may message people's sessions, and resume one that
failed, but not interrupt, stop, rename or archive them, nor message or
resume one its people stopped. A stop counts as theirs when fctl gave
the reason for a person's stop, which also covers fctl stopping it
because its people lost their Claude connection or workspace place, and
when the host forced the stop (which can also end an idle stop, erring
toward leaving the session alone). One stopped after its idle timeout or
a drain still takes a message, which resumes it on its people's plan.
- **Decision:** a session has at most one manager: its project's own
autopilot (if that one isn't off and has the power), otherwise the
workspace's autopilot. So a project autopilot without the power leaves
that project's people's sessions to a workspace autopilot that has it.
- **Assumption:** every non-review session people start now keeps the
short `said`, `heard` and `silence` excerpts in its D1 row, as crew
sessions already did, so that a session already running when the power
is turned on has them. These are excerpts of what the transcript already
holds, and they're deleted with the session.
- **Assumption:** the autopilot's messages to someone's session spend
that person's Claude plan, and choosing the power is accepting that.
[fctl session](https://app.fctl.sh/s/ses_01M8P2ZXHFYBPBG932N58K0E0N)
<!-- FCTL_REVIEW_SUMMARY -->
---
> [!NOTE]
> **Medium risk.** It lets an autopilot message and resume sessions that
people started, running on their Claude plans, behind a new
off-by-default power. It touches permission gating and session resume.
>
> **What it does.** Adds an `others` power so an autopilot can manage
the sessions people start in its places: it is woken when they end a
turn or fail, sees them in its brief, and can message them and resume
ones that failed. Those sessions stay their people's: they run on their
own plans, count toward none of the autopilot's limits, and one its
people stopped is left alone. Since the last review, resuming a managed
session also checks that its person may still run it on their
connection, and a forced stop counts as the person's.
>
> **Spends people's plans.** Autopilot messages and resumes of people's
sessions run on those people's Claude subscriptions, and the power is
off by default and left out of `--powers all`.
>
> <sub>[fctl
review](https://app.fctl.sh/s/ses_01M8P7V63B795JW9D4XS54NHEG)'s first
look at
[`975155d`](975155d)
· 30 files, +1536 −151 · [Review agent
settings](https://app.fctl.sh/p/fctl?tab=reviews)</sub>
<!-- /FCTL_REVIEW_SUMMARY -->
---------
Co-authored-by: fctl-sh[bot] <fctl-sh[bot]@users.noreply.github.com>
Main's autopilots managing people's sessions (#661) took ADR 0105, after this branch's 0104: the index keeps both rows. Its boxed UserMessage.wake and this branch's Slack fields build together, and with this branch's router split the dev Worker's deepest router frame is 408 KB, under the 1 MiB stack that #661 found main's relayed autopilot calls overflow.
Summary
A workspace now connects a Slack workspace, and people there start and steer its agents from Slack: by mentioning fctl in a channel, writing to it in its messages (Slack's agent view),
/fctl <task>, Send to fctl… on any message, or Start a session on its Home tab. Each session runs as the person who asked, on their Claude subscription, once they link their Slack account (one link per Slack workspace, so someone in several has several). fctl posts the session's card in the thread and keeps it current (status, plan, pull request and checks), replies with each turn's last message (streamed into direct messages), asks the agent's questions with a button per answer, passes replies from people who may message the session on to the agent, and Slack's stop button interrupts the turn. People can get their notifications as direct messages, and projects can post chosen events to a channel. All three of the issue's phases are in; phase 3 is a workspace's choice to drop what Slack's messages said from transcripts once a session ends.Agents never hold a Slack token:
fctl slack thread|read|history|search|replygoes through the control plane, which checks each conversation with Slack and lets agents read only their session's own thread (in a channel, a private channel or a direct message) and the public channels the workspace's admins made readable, where the project reads them: never anyone's direct messages with fctl, other messages of private channels, or Slack Connect channels. Each workspace chooses what it allows on Slack's page of a new Integrations tab, which now also holds GitHub and Linear (their old addresses lead there): mentions, direct messages, which channel starts sessions in which project, readable channels and search, agents' own replies, notifications, project events, knowing people by their address (only where the instance's admins allow it) and keeping Slack's words in transcripts. Enterprise Grid org-wide installs, Slack Connect channels and Slack's guests are refused, and the docs say they aren't supported yet. A Slack link keeps how the browser that made it signed in, as access tokens do, and what people ask in Slack is held to it: a workspace's Google requirement (fctl#659) and the instance's sign-in rules apply, signing out everywhere unlinks it, and an address match meets no rule, as Carl Oscar Aaro chose.cargo xtask check, and end to end incargo xtask devagainst a new stand-in for Slack (xtask/slack, driven withcargo xtask slack …), which checks every call fctl makes against Slack's documented limits: mentions in public and private channels, direct messages, replies from linked and unlinked people, a guest, a Slack Connect channel, questions and answers,/fctl, the Home tab, stop, and agents reading a readable channel, being refused another, and searching. That run found the Home tab's malformedviews.publish, fixed here.cargo xtask dev --smokenow also mentions fctl in Slack and opens its Home tab.SlackObject(Socket Mode; wrangler migration v7). app.fctl.sh needs its Slack app created from the manifest (Admin → Slack, orfctl admin slack --manifest yaml), thenSLACK_CLIENT_ID,SLACK_CLIENT_SECRETandSLACK_SIGNING_SECRETas Cloudflare secrets;SLACK_APP_TOKEN(Socket Mode) is only for instances Slack can't reach. Agents getfctl slackwith the release after this merges, through the sandbox image; an agent whose sandbox's fctl lacks it is told that its turns' last messages andfctl askreach the thread all the same.cargo xtask devbuilds the Worker, its frame kept a slot for every route's future (742 KB on main), and Slack's routes pushed a password hash under it past the Worker's 1 MiB stack ("memory access out of bounds" at setup). The deepest frame is now 414 KB.The decisions are recorded in ADR 0104, and docs/slack.md documents it for people, with docs/self-hosting.md's manifest kept equal to fctl's by a test.
Screenshots
At the head of this branch, in
cargo xtask devagainst the Slack stand-in, 1440 px wide unless they say otherwise.The workspace page: GitHub and Linear had a tab each (before); Integrations now holds them with Slack, each saying how it stands (after).
Slack before a workspace connects it: what it leads to, what agents read and never reach, and a drawn thread (dark and light).
Connected: what agents read there, first, then the workspace's choices (light and dark, the whole page).
On a phone (390 px): connected, and the intro.
A project's settings under Slack: whether its agents read the readable channels, and the channel its events go to, with the line it posts.
Settings → Slack (your Slack accounts) and Settings → Notifications (Tell me in Slack, with the direct message drawn).
A session started in #web-team: the question asked there, the answer clicked in Slack with who and where, fctl's replies as notices, and Slack in the details rail.
Admin → Slack: the app's state, the addresses Slack calls, the manifest, where it's installed, and knowing people by their address.
Worth confirming
/fctlthere starts the session in the person's direct messages with fctl.Related
Fixes #620
fctl session
Warning
High risk. It adds a new way to sign in as a person and start agents on their subscription, new stored data (migration 0078) and a new Durable Object class, and it reshapes the router that every request goes through.
What it does. Lets people start and steer a workspace's agents from Slack by mention, direct message,
/fctl, a message shortcut or the Home tab. Sessions run as the person who linked their Slack account, fctl keeps the session's card and replies in the thread, and agents read Slack only throughfctl slackcalls that the control plane checks. It adds an Integrations tab for each workspace's Slack choices, admin setup for the Slack app, and ADR 0104 with docs.Deploy steps. Migration 0078 and the new
SlackObjectDurable Object (wrangler migration v7) ship with it, and app.fctl.sh needs its Slack app created andSLACK_CLIENT_ID,SLACK_CLIENT_SECRETandSLACK_SIGNING_SECRETset as secrets.fctl review's first look at
2e7eccb· 213 files, +32146 −219 · Review agent settings