GH-60: feat(sdk/integrations/discord): add Gateway ChatBridge + adapter#62
Merged
Conversation
Implements the Discord chat connector's second half: Gateway WS transport, core.ChatBridge bridge, and core.ChatCapable adapter. Completes 10/10 SDK connector extraction. - transport.go: GatewayClient with IDENTIFY/RESUME, heartbeat loop, reconnect with exponential backoff, wsDialer seam for tests - bridge.go: MESSAGE_CREATE → message/command events; INTERACTION_CREATE (type 3) → callback; inbound text sanitized before HandleMessage; guild+channel allowlists enforced; buttons rendered as action rows - adapter.go: Name()="discord", NewChatBridge, 3 compile-time assertions - client.go: adds GetGatewayURL (GET /gateway) used by transport - go.mod/go.sum unchanged (gorilla/websocket already present from slack)
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-60.
Closes #60
Changes
GitHub Issue #60: feat(sdk/integrations/discord): add Gateway ChatBridge + adapter
Context
Second half of the Discord chat connector (the LAST of 10 connectors) —
depends on the client/data issue. Implement the Gateway WS transport + the
core.ChatBridge/ChatCapableadapter. Source from/tmp/pilot-src/internal/adapters/discord/(transport.go,handler.go).Mirror
sdk/integrations/slack/(bridge.go + adapter.go + the WS client) and thechat contract (
.agent/system/chat-bridge-design.md).The Gateway transport uses
github.com/gorilla/websocket— already a dependency(added by slack), so
go.mod/go.sumshould NOT change andgo mod tidystaysa no-op.
sdk/{core,log,util,testutil}stay stdlib-only.Implementation
Add to
sdk/integrations/discord/:transport.go(Gateway WS client),bridge.go(core.ChatBridge),adapter.go(core.ChatCapable), + tests.github.com/qf-studio/pilot/...import; inject*slog.Logger.transport.go— Gateway WS client: connect, IDENTIFY/RESUME, heartbeat loop,reconnect, read
GatewayEvents. Usesgorilla/websocket.adapter.go:AdapterwithName() "discord"+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 Gateway loop; map events tocore.MessageEvent:MESSAGE_CREATE→Action:"message"(content with bot-mention stripped,sanitized in the loop before the handler — CRITICAL, feat(sdk/integrations/github): port client, types, converter, notifier, webhook #28-class); leading
/→Action:"command"(Command+Args, NO execution);INTERACTION_CREATE(component) →
Action:"callback"(CallbackID = interaction id/token, Data =custom_id). Enforce AllowedGuilds/AllowedChannels. ChannelID = channel id.
Send(ctx, OutboundMessage) (MessageRef, error)—SendMessage, orSendMessageWithComponentsrenderingButtonsas an action row.Edit(ctx, ref, text)—EditMessage.Ack(ctx, callbackID)—CreateInteractionResponse(deferred/ack).sdk/testutilfakes + anhttptest/fake-WS seam (no network);include an invisible-Unicode sanitize guard on inbound
Text.⛔ Touch ONLY
sdk/integrations/discord/. Do not modifysdk/core/, otherconnectors, or (expectedly)
go.mod/go.sum.Acceptance
transport.go,bridge.go,adapter.go(+ tests) exist; 3 compile-timecoreassertions;Name()returns"discord".Startmaps message/command/callback tocore.MessageEvent; inboundTextsanitized in the live loop beforeHandleMessage(grep shows the call-site).go mod tidya no-op (gorilla/websocket already present; no NEW dep);sdk/{core,log,util,testutil}stdlib-only.grep -rn "qf-studio/pilot" sdk/nothing; no command EXECUTION;SendrendersButtonsas an action row.go build ./...,go vet ./...,go test -race ./sdk/integrations/discord/...,gofmt -l sdk/all clean.