You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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/ChatCapable adapter. Source from /tmp/pilot-src/internal/adapters/discord/ (transport.go, handler.go).
Mirror sdk/integrations/slack/ (bridge.go + adapter.go + the WS client) and the
chat 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.sum should NOT change and go mod tidy stays
a no-op. sdk/{core,log,util,testutil} stay stdlib-only.
adapter.go: Adapter with Name() "discord" + NewChatBridge(core.ChatDeps) core.ChatBridge. Compile-time: var _ core.Adapter = (*Adapter)(nil), var _ core.ChatCapable = (*Adapter)(nil), var _ core.ChatBridge = (*bridge)(nil).
bridge.go implements core.ChatBridge:
Start(ctx) — run the Gateway loop; map events to core.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, or SendMessageWithComponents rendering Buttons as an action row.
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.