Go 版 WorkBuddy 消息网关,已接入真实 copilot.tencent.com 登录链、registerWorkspace 凭证获取、ACP HTTP transport 切换,以及 WeCom / Wechat KF 绑定与消息收发入口,并内置一个完整测试页面。
HTTP、Auth、Session、Connector、Marketplace、ACP-RPC 能力IPC bridge、会话编排、浏览器登录、模型路由留出稳定接口Config 默认配置与标准化HTTP Clientfetch auth stateopen browserpoll tokenfetch accountfetch accountsstore sessionConversation、Connector、Plugin、Support API clientProductScenes 本地加载器骨架WeCom / Wechat KF 通道桥接骨架QQ Bot / WeCom AiBot 真长连 websocket 客户端pkg/channelws 公共包ACP-RPC 协议结构体SessionStoreAuthService、ConversationService、WeComServiceworkbuddy/ ├── cmd/workbuddy ├── docs ├── examples │ └── channelws ├── pkg │ └── channelws ├── internal │ ├── auth │ ├── browser │ ├── config │ ├── flow │ ├── gateway │ ├── protocol │ ├── session │ ├── bridge │ └── upstream ├── DESIGN.md ├── README.md ├── go.mod └── workbuddy.go
cd /mnt/workbuddy
go test ./...
go run ./cmd/workbuddy
go run ./cmd/workbuddy -listen :8080
POST /api/v1/auth/loginPOST /api/v1/auth/statePOST /api/v1/auth/exchangeGET /api/v1/auth/sessionPOST /api/v1/auth/refreshPOST /api/v1/auth/logoutGET /api/v1/scenesGET|POST /api/v1/conversationsGET|PATCH|DELETE /api/v1/conversations/{id}GET /api/v1/conversations/{id}/sessionPOST /api/v1/conversations/{id}/archiveGET /api/v1/connectors/userPATCH|DELETE /api/v1/connectors/user/{name}/*POST /api/v1/connectors/tasksGET|PATCH /api/v1/connectors/tasks/{taskId}/*GET|POST /api/v1/connectors/oauth/{provider}/*GET /api/v1/plugins/installedPOST /api/v1/plugins/installPOST /api/v1/plugins/installed/{installId}/*GET|POST /api/v1/marketplacesPOST /api/v1/marketplaces/{sourceId}/*GET /api/v1/marketplaces/{sourceId}/plugins*POST /api/v1/support/presigned-urlGET /api/v1/support/scenesPOST /api/v1/support/reportPOST /api/v1/pending-inputGET /api/v1/pending-input/{id}POST /api/v1/usage/personalPOST /api/v1/usage/enterprisePOST /api/v1/checkin/statusPOST /api/v1/checkin/claimPOST /api/v1/backend/callPOST /api/v1/wecom/register-channelGET /api/v1/wecom/runtimePOST /api/v1/wecom/runtime/hostPOST /api/v1/wecom/runtime/workspacePOST /api/v1/wecom/runtime/bootstrapPOST /api/v1/wecom/runtime/connectGET /api/v1/wecom/runtime/messagesGET /api/v1/wecom/session-idPOST /api/v1/wecom/channels/registerGET /api/v1/wecom/channels/statusGET /api/v1/wecom/channels/configsGET /api/v1/wecom/channels/{type}/responseDELETE /api/v1/wecom/channels/{type}POST /api/v1/wecom/ackPOST /api/v1/wecom/responsePOST /api/v1/wecom/pushGET|POST /api/v1/wecom/auto-replyPOST /api/v1/wecom/wechatkf/linkGET /api/v1/wecom/wechatkf/bind-statusDELETE /api/v1/wecom/wechatkf/unbindPOST /api/v1/acp/configPOST /api/v1/acp/config/from-conversationGET /api/v1/acp/statePOST /api/v1/acp/new-sessionPOST /api/v1/acp/set-session-modelPOST /api/v1/acp/promptPOST /api/v1/acp/execute-command如果魔尊要在其他 Go 项目里直接复用 QQ Bot 或 WeCom AiBot 长连接客户端,不必再 import internal/*,可以直接使用:
cnb.cool/zishuo/workbuddy/pkg/channelws模块文档与调用手册:
可运行外部示例:
go run ./examples/channelws -mode qq -qq-app-id <appId> -qq-app-secret <secret>go run ./examples/channelws -mode aibot -aibot-id <botId> -aibot-secret <secret>启动后可直接访问:
http://127.0.0.1:8080/gateway-test
页面包含:
sessionPath = ~/.workbuddy/gateway/session.jsonruntimePath = ~/.workbuddy/gateway/wecom-runtime.jsonautoReplyPath = ~/.workbuddy/gateway/auto-reply.jsonCLI 可覆盖这些路径:
go run ./cmd/workbuddy \ -listen :8080 \ -session-path /data/workbuddy/session.json \ -runtime-path /data/workbuddy/wecom-runtime.json \ -auto-reply-path /data/workbuddy/auto-reply.json \ -acp-endpoint http://127.0.0.1:8090
cd /mnt/workbuddy
go run ./cmd/workbuddy -listen :8080
curl -sS -X POST http://127.0.0.1:8080/api/v1/auth/state
返回会包含 state 与 authUrl。手动打开 authUrl 完成浏览器登录。
curl -sS -X POST http://127.0.0.1:8080/api/v1/auth/exchange \
-H 'Content-Type: application/json' \
-d '{"state":"<上一步返回的 state>"}'
hostId:curl -sS -X POST http://127.0.0.1:8080/api/v1/wecom/runtime/host \
-H 'Content-Type: application/json' \
-d '{"hostId":"demo-host"}'
credentials.url 就是类似
wss://www.codebuddy.cn/v2/agentos/localagent/workspaces/websocket 的真实长链接地址:curl -sS -X POST http://127.0.0.1:8080/api/v1/wecom/runtime/bootstrap \
-H 'Content-Type: application/json' \
-d '{"workspaceId":"demo-workspace","workspaceName":"Demo Workspace"}'
curl -sS -X POST http://127.0.0.1:8080/api/v1/wecom/wechatkf/link \
-H 'Content-Type: application/json' \
-d '{"hostId":"demo-host","workspace":"demo-workspace"}'
curl -sS 'http://127.0.0.1:8080/api/v1/wecom/runtime/messages?limit=20'
curl -sS 'http://127.0.0.1:8080/api/v1/wecom/session-id?hostId=demo-host&workspace=demo-workspace'
curl -sS -X POST http://127.0.0.1:8080/api/v1/wecom/push \
-H 'Content-Type: application/json' \
-d '{"hostId":"demo-host","workspace":"demo-workspace","title":"WorkBuddy Gateway","message":"这是一条主动推送测试消息。","success":true,"statusCode":200}'
curl -sS -X POST http://127.0.0.1:8080/api/v1/wecom/auto-reply \
-H 'Content-Type: application/json' \
-d '{"enabled":true,"autoAck":true,"ackMessage":"已收到,正在处理。","title":"WorkBuddy Auto Reply","modelId":"deepseek-r1","systemPrompt":"你是客服回复助手"}'
docs/upstream-http-openapi.yamldocs/upstream-migration-report.mddocs/upstream-lifecycle-analysis.mddocs/gateway-integration-guide.mddocs/missing-interface-audit.mdmain.log 已确认 fetch auth state -> open browser -> poll token -> get account -> get accounts -> sessionChangedmain.log 已确认 codebuddy:getProductScenes 从 .workbuddy/plugins/marketplaces/cb_teams_marketplace/scenes.json 加载main.log 已确认存在 getBindStatus -> sendAck -> sendResponse 的收发链,以及失败分支 400/403IPC 与窗口编排尚未实现,只保留桥接接口与消息模型WeCom/Wechat KF 的真实 HTTP 和 workspace websocket 已接入,但要收到真实微信消息,仍需要真人完成浏览器登录与微信绑定hostId 也会落盘,避免重启后微信绑定漂移__backend__ HTTP 兼容入口inbound -> ACP -> response 流水线AuthProvider.createSession() 之外的 GUI 回调承接__backend__ RPC 命名空间与 IPC 仿真层