Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
02a8de8
feat: start and steer agents from Slack
fctl-sh[bot] Nov 26, 2026
ca54eb4
test: cover the Slack app's D1 side and the agent's Slack lines
fctl-sh[bot] Nov 26, 2026
5dcfb78
feat(cli): add fctl admin slack; keep Slack's fallback text inert
fctl-sh[bot] Nov 26, 2026
3a73ea2
fix(control): link no Slack account as a workspace connects Slack
fctl-sh[bot] Nov 26, 2026
a36957d
fix(control): name a thread's authors in a task from Slack, and show …
fctl-sh[bot] Nov 26, 2026
c231ed2
feat(xtask): run a Slack stand-in in cargo xtask dev
fctl-sh[bot] Nov 26, 2026
57edc99
test(domain): cover dropped Slack messages and Slack notifications
fctl-sh[bot] Nov 26, 2026
763cf8d
docs: start and steer agents from Slack
fctl-sh[bot] Nov 26, 2026
d19037f
fix: read whole Slack threads, start afresh in refused ones, and othe…
fctl-sh[bot] Nov 26, 2026
0af2ba0
docs: say webhooks and identity tokens name Slack, and address matche…
fctl-sh[bot] Nov 26, 2026
48a1749
test(xtask): keep the guide's Slack manifest fctl's
fctl-sh[bot] Nov 26, 2026
ba4c7bf
feat(xtask): stand in for Slack in cargo xtask dev
fctl-sh[bot] Nov 26, 2026
cf16e7a
feat: connect a Slack workspace again in place, and choose a project'…
fctl-sh[bot] Nov 26, 2026
80b099f
feat(web): an Integrations tab, and Slack in the web app
fctl-sh[bot] Nov 26, 2026
fba1944
fix(control): keep cargo xtask dev's Worker within its stack
fctl-sh[bot] Nov 26, 2026
63524bb
fix: publish Slack's Home tab as a home view, and name the channel of…
fctl-sh[bot] Nov 26, 2026
18c4c02
fix(xtask): list the smoke test's sessions where the API lists them
fctl-sh[bot] Nov 26, 2026
7505f4f
fix(control): tell an agent of its Slack thread from its first turn
fctl-sh[bot] Nov 26, 2026
de8ef39
fix(control): take nothing from Slack conversations that may be shared
fctl-sh[bot] Nov 26, 2026
8da6479
fix(control): never let an address take over a linked Slack account, …
fctl-sh[bot] Nov 26, 2026
61c767c
fix(control): search only channels agents may read now, and read them…
fctl-sh[bot] Nov 26, 2026
487618d
fix(control): retry Slack posts, and send what a thread won't take to…
fctl-sh[bot] Nov 26, 2026
5fcd866
fix(cli): name the events fctl projects slack takes as fctl names them
fctl-sh[bot] Nov 26, 2026
76ff8b2
fix(web): keep Tell me in Slack where none of your workspaces works i…
fctl-sh[bot] Nov 26, 2026
2e1d965
fix(control): ask to try again when Slack doesn't describe a conversa…
fctl-sh[bot] Nov 26, 2026
7376c39
fix(control): search every readable channel, and say when Slack didn'…
fctl-sh[bot] Nov 26, 2026
ff982ef
fix(control): retry a Slack post only when Slack asked to wait, and r…
fctl-sh[bot] Nov 26, 2026
e49e25a
fix(control): let an address match move to the Slack user who has the…
fctl-sh[bot] Nov 26, 2026
473291c
fix(control): send replies to the asker where admins keep fctl from p…
fctl-sh[bot] Nov 26, 2026
d2916fc
Merge main into fctl/1678-start-and-steer-agents-from-slack-with-a
fctl-sh[bot] Nov 28, 2026
99c83a5
Merge main into fctl/1678-start-and-steer-agents-from-slack-with-a
fctl-sh[bot] Nov 28, 2026
1badb13
Merge main into fctl/1678-start-and-steer-agents-from-slack-with-a
fctl-sh[bot] Nov 29, 2026
680e992
feat(control): hold what people ask in Slack to the sign-in that link…
fctl-sh[bot] Nov 29, 2026
8b6bf34
docs: say a Slack link is held to the sign-in that made it
fctl-sh[bot] Nov 29, 2026
43958a1
fix(control): ask a locked-out member to link again only where they a…
fctl-sh[bot] Nov 29, 2026
1ec4080
refactor(control): give a Slack person their link's sign-in where the…
fctl-sh[bot] Nov 29, 2026
aaa1026
Merge main into fctl/1678-start-and-steer-agents-from-slack-with-a
fctl-sh[bot] Nov 30, 2026
2e7eccb
Run the checks again
fctl-sh[bot] Nov 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ updates:
- /web
- /deploy/standalone
- /xtask/linear
- /xtask/slack
schedule:
interval: weekly
open-pull-requests-limit: 0
Expand Down
28 changes: 28 additions & 0 deletions crates/fake-claude/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
//! | a line that starts with `ask <question>` | asks the people who follow the session `<question>` (to the end of its line) with `fctl ask`, offering the answers after each ` / ` in it to click (`ask Ship it today? / Yes / Not yet`), and ends its turn, as agents do when they need a person's input |
//! | a line that starts with `fctl ticket` | runs it, as agents read and write their project's tickets (`fctl ticket view ENG-1`, `fctl ticket comment ENG-1 "On it"`) |
//! | a line that starts with `fctl id-token` | runs it, as agents prove who they are to a service (`fctl id-token -a https://api.acme.dev --claims`) |
//! | a line that starts with `fctl slack` | runs it, as agents read and post in Slack (`fctl slack thread`, `fctl slack reply "On it"`) |
//! | a line quoted with `> ` | reads as it would unquoted, as what someone asked in Slack comes quoted |
//! | `clouds` | shows the variables fctl-agent set for the project's clouds (`AWS_…`, `GOOGLE_…`, `CLOUDSDK_…`, `AZURE_…`) and the token files they name, as an agent that checks its cloud access does |
//! | `printenv` | shows the `CLAUDE_CODE_…` variables it got, its Claude token among them, in a `Bash` call, as an agent that looks at its environment does, then says the token back in pieces of five characters, as Claude streams what it writes (the host keeps the token out of both) |
//! | `retro` | records a retrospective of the turn's work with `fctl retro`, as agents do when they finish a piece of work: completed, or `partial` or `blocked` when the message says so |
Expand Down Expand Up @@ -1296,6 +1298,10 @@ impl Session {
fn turn(&mut self, text: &str, images: usize, input: &mpsc::Receiver<Value>) {
INTERRUPTED.store(false, Ordering::SeqCst);
let started = Instant::now();
// What someone asked in Slack comes quoted (`> write notes.md`):
// its lines read as if they were written here.
let unquoted = unquote(text);
let text = unquoted.as_str();
if let Some(turn) = self.replay_turn(text) {
// The message is what its first call reads anew.
self.unread += text.len() as u64 / 4;
Expand Down Expand Up @@ -1594,6 +1600,14 @@ impl Session {
{
self.bash(line, "Work with the project's tickets");
}
// And `fctl slack` commands, as agents read and post in Slack.
for line in text
.lines()
.map(str::trim)
.filter(|l| l.starts_with("fctl slack"))
{
self.bash(line, "Read the Slack thread");
}
// So do `fctl id-token` commands, as agents prove who they are.
for line in text
.lines()
Expand Down Expand Up @@ -2428,6 +2442,20 @@ fn main() {
}
}

/// `text` with each line's quote marker (`> `) gone, as a message from
/// Slack quotes what its person asked.
fn unquote(text: &str) -> String {
text.lines()
.map(|l| {
let t = l.trim_start();
t.strip_prefix("> ")
.or_else(|| t.strip_prefix('>'))
.unwrap_or(l)
})
.collect::<Vec<_>>()
.join("\n")
}

#[cfg(test)]
mod tests {

Expand Down
28 changes: 28 additions & 0 deletions crates/fctl-agent/src/prompt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,15 @@ pub fn system_prompt(
}
None => s.push_str(tracker.as_deref().unwrap_or_default()),
}
// The control plane says what the session reaches in Slack, and how
// its replies go back there (`SessionSpec::slack`).
if let Some(slack) = spec
.slack
.as_ref()
.filter(|s| !s.instructions.trim().is_empty())
{
s.push_str(&slack.instructions);
}
if let Some(extra) = spec
.project
.settings
Expand Down Expand Up @@ -1272,6 +1281,7 @@ mod tests {

fn spec() -> SessionSpec {
SessionSpec {
slack: None,
session_id: SessionId("ses_1".into()),
number: 1,
title: "Build it".into(),
Expand Down Expand Up @@ -1442,6 +1452,24 @@ mod tests {
assert!(old.contains("ask with `fctl ask"));
}

#[test]
fn sessions_from_slack_hear_how_their_replies_go_back() {
let mut s = spec();
s.slack = Some(fctl_proto::slack::SlackSpec {
thread: None,
readable: Vec::new(),
search: false,
reply: false,
instructions: "\n## Slack\n\n- This session started in Slack.\n".into(),
without_cli: None,
});
let text = system_prompt(&s, "/work", &paths(), None, None, false, false, false);
assert!(text.contains("## Slack\n\n- This session started in Slack."));
// Nothing at all without it.
let none = system_prompt(&spec(), "/work", &paths(), None, None, false, false, false);
assert!(!none.contains("## Slack"));
}

#[test]
fn says_how_long_background_work_keeps_the_session_up() {
let text = system_prompt(
Expand Down
30 changes: 25 additions & 5 deletions crates/fctl-agent/src/supervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ impl Supervisor {

fn notice(&mut self, level: NoticeLevel, code: &str, message: &str, until: Option<i64>) {
self.emit(EventBody::Notice(Notice {
slack: None,
ticket: None,
level,
code: code.into(),
Expand Down Expand Up @@ -1004,6 +1005,11 @@ impl Supervisor {
"This project's agents reach no ticket tracker: its maintainers choose one in the project's settings, under Tickets.",
));
}
AgentCall::Slack { .. } if spec.slack.as_ref().is_none_or(|s| !s.reaches()) => {
return Err(ApiError::forbidden(
"This session reaches nothing in Slack: it didn't start there, and its workspace makes no channel readable for its agents.",
));
}
// Where its project lets its agents; the control plane checks
// it again.
AgentCall::IdToken { .. } if spec.review.is_some() => {
Expand Down Expand Up @@ -1926,6 +1932,17 @@ impl Supervisor {
"This sandbox's fctl has no `fctl autopilot`, so the autopilot can't reach fctl from it. The default image, ghcr.io/hyperstructure/sandbox, has it; an image of your own needs a recent fctl on the PATH.",
);
}
// `fctl slack` reads and posts in Slack, where the sandbox's fctl
// has it; without it, the agent hears how its replies go back all
// the same.
let mut told = spec.clone();
if let Some(slack) = told.slack.as_mut() {
let can = self.session_socket.is_some() && fctl_can(&paths, "slack").await;
if !can {
slack.instructions = slack.without_cli.clone().unwrap_or_default();
}
}
let spec = &told;
let system = match &spec.review {
Some(review) => {
let previous_here = match review.previous_sha.as_deref() {
Expand Down Expand Up @@ -3546,6 +3563,7 @@ fn published_notice(file: &PublishedFile, now: i64) -> Notice {
format!("{days} days")
};
Notice {
slack: None,
ticket: None,
level: NoticeLevel::Info,
code: "screenshot_published".into(),
Expand Down Expand Up @@ -3573,6 +3591,7 @@ fn published_notice(file: &PublishedFile, now: i64) -> Notice {
/// `retrospective`.
fn kept_notices(answer: &AgentAnswer) -> Vec<Notice> {
let notice = |code: &str, message: String| Notice {
slack: None,
ticket: None,
level: NoticeLevel::Info,
code: code.into(),
Expand Down Expand Up @@ -3638,11 +3657,12 @@ fn kept_notices(answer: &AgentAnswer) -> Vec<Notice> {
summarized: Some(summarized.clone()),
..notice("pull_request_summarized", summarized_message(summarized))
}],
// The control plane adds what fctl did in the tracker itself, and
// what an autopilot did.
AgentAnswer::Ticket { .. } | AgentAnswer::Api { .. } | AgentAnswer::ApiBytes { .. } => {
vec![]
}
// The control plane adds what fctl did in the tracker and in Slack
// itself, and what an autopilot did.
AgentAnswer::Ticket { .. }
| AgentAnswer::Slack { .. }
| AgentAnswer::Api { .. }
| AgentAnswer::ApiBytes { .. } => vec![],
// What the agent asked people stays in the transcript, after the
// question itself is answered.
AgentAnswer::Asked { question: Some(q) } => vec![Notice {
Expand Down
123 changes: 123 additions & 0 deletions crates/fctl-client/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2710,6 +2710,129 @@ impl Api {
self.url("/linear/link")
}

/// The Slack workspaces a workspace works in, with what it lets people
/// and agents do there.
pub async fn workspace_slack(&self, id: &str) -> Result<fctl_proto::slack::WorkspaceSlack> {
self.get(&format!("/workspaces/{}/slack", enc(id))).await
}

/// The link to the Slack sign-in that installs fctl's app in a Slack
/// workspace and connects it to workspace `id` (its admins).
/// `team` (`T…`) has Slack's sign-in offer that Slack workspace alone.
pub async fn connect_slack(
&self,
id: &str,
team: Option<&str>,
) -> Result<fctl_proto::slack::SlackLink> {
self.post(
&format!("/workspaces/{}/slack/connect", enc(id)),
&fctl_proto::slack::ConnectSlackRequest {
team: team.map(str::to_owned),
},
)
.await
}

/// Changes what a workspace lets people and agents do in a Slack
/// workspace (its admins).
pub async fn update_slack(
&self,
id: &str,
team: &str,
req: &fctl_proto::slack::UpdateSlackRequest,
) -> Result<fctl_proto::slack::WorkspaceSlack> {
self.patch(&format!("/workspaces/{}/slack/{}", enc(id), enc(team)), req)
.await
}

/// Stops working in a Slack workspace (its admins).
pub async fn disconnect_slack(
&self,
id: &str,
team: &str,
) -> Result<fctl_proto::slack::WorkspaceSlack> {
self.delete(&format!("/workspaces/{}/slack/{}", enc(id), enc(team)))
.await
}

/// Public channels of a connected Slack workspace, for its admins to
/// choose, and for `project`'s maintainers to post its events in.
pub async fn slack_channels(
&self,
id: &str,
team: &str,
query: Option<&str>,
project: Option<&str>,
) -> Result<fctl_proto::slack::SlackChannelList> {
let q = [("query", query), ("project", project)]
.iter()
.filter_map(|(k, v)| v.map(|v| format!("{k}={}", enc(v))))
.collect::<Vec<_>>()
.join("&");
let q = if q.is_empty() { q } else { format!("?{q}") };
self.get(&format!(
"/workspaces/{}/slack/{}/channels{q}",
enc(id),
enc(team)
))
.await
}

/// Maps a channel to a project, or makes it readable (its admins).
pub async fn set_slack_channel(
&self,
id: &str,
team: &str,
channel: &str,
req: &fctl_proto::slack::SetSlackChannelRequest,
) -> Result<fctl_proto::slack::WorkspaceSlack> {
self.put(
&format!(
"/workspaces/{}/slack/{}/channels/{}",
enc(id),
enc(team),
enc(channel)
),
req,
)
.await
}

/// Your Slack accounts, which fctl knows you by.
pub async fn my_slack(&self) -> Result<fctl_proto::slack::MySlack> {
self.get("/me/slack").await
}

/// The link your browser links your Slack account with.
pub async fn link_slack(&self, team: Option<&str>) -> Result<fctl_proto::slack::SlackLink> {
let q = team
.map(|t| format!("?team={}", enc(t)))
.unwrap_or_default();
self.post(&format!("/me/slack/link{q}"), &serde_json::json!({}))
.await
}

/// Your choices in a Slack workspace: the project your direct messages
/// with fctl's app start sessions in.
pub async fn update_my_slack(
&self,
team: &str,
req: &fctl_proto::slack::UpdateMySlackRequest,
) -> Result<fctl_proto::slack::MySlack> {
self.patch(&format!("/me/slack/{}", enc(team)), req).await
}

/// Forgets your Slack account in a Slack workspace.
pub async fn unlink_slack(&self, team: &str) -> Result<fctl_proto::slack::MySlack> {
self.delete(&format!("/me/slack/{}", enc(team))).await
}

/// The instance's Slack app, and the manifest that creates one
/// (instance admins).
pub async fn admin_slack(&self) -> Result<fctl_proto::slack::AdminSlack> {
self.get("/admin/slack").await
}

/// A project's ticket tracker as it works now.
pub async fn project_tickets(&self, project: &str) -> Result<ProjectTickets> {
self.get(&format!("/projects/{}/tickets", enc(project)))
Expand Down
Loading
Loading