Skip to content

connect: slack signs in through the browser as you - #61

Merged
AbirAbbas merged 6 commits into
feat/connect-postman-datadogfrom
feat/connect-slack
Aug 28, 2026
Merged

AbirAbbas merged 6 commits into
feat/connect-postman-datadogfrom
feat/connect-slack

Conversation

@AbirAbbas

Copy link
Copy Markdown
Collaborator

What

Slack joins Google as a browser-connected account. /connect → Slack → sign in on Slack's own page → ✓ Slack connected as <you> · <workspace>. Then four tools: slack_search, slack_read_thread, slack_list_channels, and slack_send (which asks first, like gmail_send). Any workspace, nothing registered by the person. Census 128 → 129 services, 29 → 30 in a browser.

How it signs in, and why it looks the way it does

  • One AgentField-owned Slack app, shipped as a public client. Slack has no self-registration, so the app's client id is compiled in the way Google's is (connect_defaults.go). PKCE means no secret exists — nothing to ship, nothing to rotate. SLACK_OAUTH_CLIENT / the slack app id row replace it for an organisation that wants its own (internal) app.
  • User token only ("act as you"). A loopback sign-in cannot mint a bot token, and that is the right shape anyway: everything happens as the person who signed in.
  • Two HTTPS doors instead of http://localhost. Slack refuses non-HTTPS redirect URLs on a publicly distributed app, so the app registers https://agentfield.ai/connect/slack/8765 and …/18765, which 307 straight back to http://localhost:<port>/ with the query untouched (website2.0 PR bug: task fails at run time on a project-less conversation — approve, then fail #58, live). The plug binds one fixed port at a time and presents the matching door; the :0 rung is never used for it. auth.go grows one optional interface (doored) for this; every other plug's path is unchanged.
  • Slack answers 200 {"ok":false} on failure, on the token endpoint and every method. A small transport turns an exchange refusal into the shape x/oauth2 reports, and every Web API call checks ok before decoding, so a refusal reaches the model in Slack's own word. invalid_auth / token_revoked / account_inactive are the only way a Slack user token dies (it has no expiry and no refresh), and they read as "Slack has to be connected again".
  • Bearer law. Slack's docs say token_type: user; x/oauth2 would put that word on the Authorization header verbatim. Every key set this package sends is sent as a Bearer; what the service issued is stored unchanged.
  • Search-first tools. Apps outside Slack's Marketplace are throttled on channel-history reads (1 request/minute, 15 messages), so the thread reader is one bounded call and nothing loops over history; search, listing and posting are not throttled that way.

Verified against the real app before the code

Spikes on 2026-08-27 against the registered app (token revoked at the end): the secretless PKCE exchange at oauth.v2.user.access returns a top-level access_token (token_type: Bearer, comma-separated scope); the door trip lands on the loopback listener with code and state; auth.test gives abir · Agent Field; no expires_in / refresh_token. One thing not yet exercised live: the history throttle in a workspace other than the app's home one (the home workspace showed no throttle).

Validation

Every gate in the repo's make check plus gofmt -l and strings bin/aforge | grep -c xoxp (0). go vet clean, build clean, Google/Gmail/Calendar sources byte-for-byte unchanged. internal/connect, internal/session, internal/config, internal/approval, internal/manual, internal/tui3 fully green. The full suite has seven packages red — cmd/aforge tick tests, cmd/harness-design, internal/guard, internal/plan, internal/thread, internal/tui calm-column, and the internal/session revise-verb flake — all of which reproduce identically at the base commit and pass/fail the same way without this change.

Tests are derived from the validation contract in the spec (not from the code): the public-client listing; the exchange with token_type: user sending Authorization: Bearer; a 200 ok:false exchange surfacing Slack's word and never a key; search.messages decoded from Slack's documented shape (channel: {id, name}, user, username, permalink); one conversations.replies call with limit=15; the three dead-token words and only those reading "Slack has to be connected again", unburied through every helper; both fixed-port cases and the plain busy sentence; comma-separated grants; the four-tool family and its inverse; slack_send under the acts-in-your-name floor with a consent headline that carries channel and text; Slack reads counted as knowledge for task nodes; the settings row; the manual answering "how do I connect my Slack workspace".

Two review rounds (multi-lens adversarial review with independent refuters) preceded this; the findings that survived are all in.

Commits

Six, each one concern and each building on its own:

  1. config: the slack application ships with the build — the shipped public client id, the slack app id row and SLACK_OAUTH_CLIENT.
  2. tui: the selected settings row stays on screen — the older settings sheet's scroll clamp (a hint taller than the frame is cut, never the row).
  3. connect: a public client, a door for vendors that refuse localhost, and the bearer law — the three registry laws, no plug yet.
  4. connect: slack, signed in as you — the plug, the four helpers, the two capabilities, census 129/30.
  5. session: four slack hands, and slack_send joins the floor — tools, capability inverse, knowledge tools, consent headline, approval floor, v3 wiring.
  6. manual: slack arrives, and the pages tell the truth about it — both pages, the permissions count, and a test that keeps the permissions page and internal/approval agreeing.

After merge

Try it: bin/aforge → /connect → Slack → browser → "search Slack for …", read a thread, list channels, send one message and expect the ask.


🤖 Generated with Claude Code

AbirAbbas and others added 6 commits August 27, 2026 22:16
Slack has no self-registration, so the Slack application aforge asks with
is registered once and its id compiled in, the way Google's is. It is a
public client — Slack's proof-key sign-in has no secret — so there is one
row and not a pair: slack_oauth_client / SLACK_OAUTH_CLIENT replaces the
shipped id for an organisation that wants its own application asking,
and shows "not set" while the shipped one is in use.

Co-Authored-By: Claude Fable 5 <[email protected]>
The older settings sheet scrolled to fit a selected row's whole hint,
which on a short screen could push the row itself — its label, its value,
its marker — above the frame. The row is the floor now: a hint taller
than the frame is cut, never the row.

Co-Authored-By: Claude Fable 5 <[email protected]>
…nd the bearer law

Three laws the registry needed before a second browser plug could exist.
A ClientCredential may be Public: a proof key per connection stands in
for the secret, so the id alone is the whole credential. A plug may be
doored: its vendor will not send a browser back to a loopback address,
so it names a registered HTTPS address for one of the two fixed ports,
which forwards the browser on to localhost with the query untouched; the
free-port rung is never offered to such a vendor. And every key set this
package sends is sent as a Bearer, whatever the vendor called it. A plug
may also supply a transport for exchanges the vendor refuses with a
success status, so the person reads the vendor's word rather than
"missing access_token". Granted permissions are read whether the vendor
separates them with spaces or commas.

Co-Authored-By: Claude Fable 5 <[email protected]>
The Slack plug: user permissions only, never a bot; the sign-in goes
through https://agentfield.ai/connect/slack/<port>, which forwards the
browser to this machine; the exchange is proof-key only. Four helpers on
the Web API — search, one bounded thread read, channel listing, posting —
every one checking Slack's ok:false, which Slack sends with a 200. The
three words that mean the key is dead read as "Slack has to be connected
again", bare, from every helper. Two capabilities, reading and sending.
Census 128 to 129, 29 to 30 in a browser.

Co-Authored-By: Claude Fable 5 <[email protected]>
slack_search, slack_read_thread, slack_list_channels and slack_send arm
when the account is picked up, in the shape the Gmail family has. The
three that read are knowledge for a task node; the one that posts leaves
in the person's name and is asked about by default, with a consent
headline that says the channel and the text. v3 hands the manager the
shipped Slack application as a public client.

Co-Authored-By: Claude Fable 5 <[email protected]>
The census, the browser list, the twelve permissions, the two fixed
addresses and what happens in a workspace that needs an admin's yes. The
paragraph that said Slack was deliberately not shipped is replaced. The
stale claim that Google needs an application id and secret in settings —
false since the build began shipping one — is fixed on both pages. The
always-ask table on the permissions page names three tools, and a test
keeps that page and internal/approval agreeing.

Co-Authored-By: Claude Fable 5 <[email protected]>
@AbirAbbas
AbirAbbas merged commit e8ab333 into feat/connect-postman-datadog Aug 28, 2026
@AbirAbbas
AbirAbbas deleted the feat/connect-slack branch August 28, 2026 12:33
@santoshkumarradha santoshkumarradha added the area:chat The v3 surface a person sits in front of (internal/tui3) label Oct 3, 2026
@santoshkumarradha santoshkumarradha added this to the Chat & connections milestone Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:chat The v3 surface a person sits in front of (internal/tui3)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants