GH-55: feat(sdk/integrations/slack): add Socket Mode ChatBridge + adapter (first ext dep: gorilla/websocket)#58
Merged
Merged
Conversation
Implements core.ChatBridge and core.ChatCapable for Slack via Socket Mode.
- socketmode.go: WebSocket client (SocketModeClient + SocketModeHandler);
handles connect/reconnect via apps.connections.open, ping/pong heartbeat,
envelope ack, and all envelope types (events_api, interactive, slash_commands).
First SDK runtime external dep: github.com/gorilla/websocket v1.5.3.
- bridge.go: core.ChatBridge implementation; maps events_api message/app_mention
to Action:"message" (sanitized) or Action:"command" for /- prefixed text;
maps interactive block_actions to Action:"callback" (CallbackID=action_id,
Data=value); enforces AllowedChannels/AllowedUsers; renders Buttons as Block
Kit actions block in Send; Edit via chat.update; Ack is no-op (WS-level ack
handled automatically by SocketModeHandler).
- adapter.go: Adapter with Name()="slack", NewChatBridge, and three compile-time
core interface assertions.
- types.go: add ThreadTS to InteractiveMessage for threaded sends.
- go.mod + go.sum: gorilla/websocket v1.5.3 (direct dep).
sdk/{core,log,util,testutil} remain stdlib-only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Automated PR created by Pilot for task GH-55.
Closes #55
Changes
GitHub Issue #55: feat(sdk/integrations/slack): add Socket Mode ChatBridge + adapter (first ext dep: gorilla/websocket)
Context
Second half of the Slack chat connector — depends on the client/data issue.
Implement the Socket Mode listener + the
core.ChatBridge/ChatCapableadapter.Source from
/tmp/pilot-src/internal/adapters/slack/(socket_mode.go,socketmode.go,handler.go). Mirrorsdk/integrations/telegram/(bridge.go +adapter.go) and the chat contract (
.agent/system/chat-bridge-design.md).This is the first SDK runtime external dependency — Socket Mode needs a
WebSocket client (
github.com/gorilla/websocket, as in Pilot).go.modrequirego.sumappear in the repo for the first time → runmake tidyand commitboth
go.modandgo.sum.sdk/{core,log,util,testutil}stay stdlib-only.Implementation
Add to
sdk/integrations/slack/:socketmode.go(WS client),bridge.go(
core.ChatBridge),adapter.go(core.ChatCapable), + tests. Transformations:github.com/qf-studio/pilot/...import; inject*slog.Logger.apps.connections.open,hello/authenticate, heartbeat, read envelopes, ack). Uses
gorilla/websocket.adapter.go:AdapterwithName() "slack"+NewChatBridge(core.ChatDeps) core.ChatBridge. Compile-time:var _ core.Adapter = (*Adapter)(nil),var _ core.ChatCapable = (*Adapter)(nil),var _ core.ChatBridge = (*bridge)(nil).bridge.goimplementscore.ChatBridge:Start(ctx)— run the Socket Mode loop; for each inbound envelope map to acore.MessageEvent:message/app_mention→Action:"message"(text withbot-mention stripped, sanitized in the loop before the handler — CRITICAL,
the feat(sdk/integrations/github): port client, types, converter, notifier, webhook #28-class rule); leading
/→Action:"command"(Command+Args, noexecution);
block_actions→Action:"callback"(CallbackID = action_id,Data = value). Enforce AllowedChannels/AllowedUsers. ChannelID = channel,
ThreadID = thread_ts.
Send(ctx, OutboundMessage) (MessageRef, error)—PostMessage, orPostInteractiveMessagerenderingOutboundMessage.Buttonsas a Block Kitactions block. MessageRef = {ChannelID, MessageID: ts, ThreadID}.
Edit(ctx, ref, text)—UpdateMessageby ts.Ack(ctx, callbackID)— ack the Socket Mode envelope for that interaction.sdk/testutilfakes; include a guard that inboundTextwithinvisible-Unicode smuggling is sanitized before the handler sees it. Use an
httptest/fake-WS seam so tests don't hit the network.⛔ Touch ONLY
sdk/integrations/slack/and the top-levelgo.mod/go.sumforthe new dep. Do not modify
sdk/core/or other connectors.Acceptance
socketmode.go,bridge.go,adapter.go(+ tests) exist; the 3 compile-timecoreassertions present;Name()returns"slack".Startmaps message/command/callback (block_actions) tocore.MessageEvent; inboundTextsanitized in the live loop beforeHandleMessage(grep shows the call-site).go.mod+go.sumcommitted (gorilla/websocket);go mod tidya no-op when re-run;sdk/{core,log,util,testutil}still stdlib-only.grep -rn "qf-studio/pilot" sdk/nothing; no command EXECUTION;SendrendersButtonsas Block Kit.go build ./...,go vet ./...,go test -race ./sdk/integrations/slack/...,gofmt -l sdk/all clean.