@tencent-ai/agent-sdk 0.3.252 → 0.3.253

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/cli/CHANGELOG.md +22 -0
  2. package/cli/dist/codebuddy-headless.js +73 -58
  3. package/cli/dist/codebuddy-lite-wb.mjs +96 -81
  4. package/cli/dist/lazy/{427.68132a34.js → 427.74b982af.js} +4 -4
  5. package/cli/dist/lazy-headless/{834.391fb41e.js → 834.3b674e07.js} +9 -9
  6. package/cli/dist-server/3556.codebuddy.js +1 -1
  7. package/cli/dist-server/6037.codebuddy.js +1 -1
  8. package/cli/dist-server/6784.codebuddy.js +1 -1
  9. package/cli/dist-server/codebuddy.js +45 -30
  10. package/cli/dist-server/types/node/agent/openai-agents-types.d.ts +5 -5
  11. package/cli/dist-server/types/node/mcp/mcp-sdk-values.d.ts +1 -1
  12. package/cli/dist-server/types/node/model/model-provider.d.ts +3 -1
  13. package/cli/dist-server/types/node/tools/a2a-get-task-tool.d.ts +139 -34
  14. package/cli/dist-server/types/node/tools/a2a-poll-retry.d.ts +46 -0
  15. package/cli/package.json +1 -1
  16. package/cli/product.cloudhosted.json +2 -2
  17. package/cli/product.internal.json +2 -2
  18. package/cli/product.ioa.json +2 -2
  19. package/cli/product.json +4 -4
  20. package/cli/product.selfhosted.json +2 -2
  21. package/package.json +1 -1
  22. package/cli/dist-server/types/node/acp/acp-view-rewind-to.d.ts +0 -34
  23. package/cli/dist-server/types/node/acp/acp-web-ui-client.d.ts +0 -22
  24. package/cli/dist-server/types/node/acp/usage-by-category-calculator.d.ts +0 -45
  25. package/cli/dist-server/types/node/acp/usage-by-category-char-weight.d.ts +0 -9
  26. package/cli/dist-server/types/node/acp/usage-by-category-distribute.d.ts +0 -6
  27. package/cli/dist-server/types/node/acp/usage-by-category-tools-split.d.ts +0 -11
  28. package/cli/dist-server/types/node/agent-home/agent-home-envelope-body.d.ts +0 -54
  29. package/cli/dist-server/types/node/agent-home/agent-home-inbox-events.d.ts +0 -14
  30. package/cli/dist-server/types/node/agent-home/agent-home-room-contacts.d.ts +0 -30
  31. package/cli/dist-server/types/node/agent-team/permission-bridge-client.d.ts +0 -32
  32. package/cli/dist-server/types/node/agent-team/permission-bridge-protocol.d.ts +0 -47
  33. package/cli/dist-server/types/node/agent-view/handoff-policy.d.ts +0 -80
  34. package/cli/dist-server/types/node/agent-view/job-respawn-prefs.d.ts +0 -12
  35. package/cli/dist-server/types/node/agent-view/session-handoff.d.ts +0 -161
  36. package/cli/dist-server/types/node/ask/index.d.ts +0 -3
  37. package/cli/dist-server/types/node/bash-sandbox/bash-sandbox-manager.d.ts +0 -125
  38. package/cli/dist-server/types/node/bash-sandbox/legacy-sandbox-shell-service.d.ts +0 -33
  39. package/cli/dist-server/types/node/bash-sandbox/managed-security-policy.d.ts +0 -6
  40. package/cli/dist-server/types/node/bash-sandbox/workbuddy-directory-protection.d.ts +0 -12
  41. package/cli/dist-server/types/node/checkpoint/checkpoint-service.d.ts +0 -70
  42. package/cli/dist-server/types/node/checkpoint/file-changes-controller.d.ts +0 -29
  43. package/cli/dist-server/types/node/checkpoint/file-track-service.d.ts +0 -11
  44. package/cli/dist-server/types/node/checkpoint/file-version-manager.d.ts +0 -10
  45. package/cli/dist-server/types/node/checkpoint/file-version-store.d.ts +0 -9
  46. package/cli/dist-server/types/node/checkpoint/file-version-update-strategies.d.ts +0 -62
  47. package/cli/dist-server/types/node/command/add-dir-command-executor.d.ts +0 -11
  48. package/cli/dist-server/types/node/command/agents-command-executor.d.ts +0 -9
  49. package/cli/dist-server/types/node/command/auto-compact-command-executor.d.ts +0 -20
  50. package/cli/dist-server/types/node/command/background-command-executor.d.ts +0 -29
  51. package/cli/dist-server/types/node/command/btw-command-executor.d.ts +0 -19
  52. package/cli/dist-server/types/node/command/clear-command-executor.d.ts +0 -17
  53. package/cli/dist-server/types/node/command/config-command-executor.d.ts +0 -15
  54. package/cli/dist-server/types/node/command/context-command-executor.d.ts +0 -42
  55. package/cli/dist-server/types/node/command/copy-command-executor.d.ts +0 -10
  56. package/cli/dist-server/types/node/command/cost-command-executor.d.ts +0 -13
  57. package/cli/dist-server/types/node/command/debug-command-executor.d.ts +0 -15
  58. package/cli/dist-server/types/node/command/deep-research-command-executor.d.ts +0 -25
  59. package/cli/dist-server/types/node/command/doctor-command-executor.d.ts +0 -7
  60. package/cli/dist-server/types/node/command/effort-command-executor.d.ts +0 -46
  61. package/cli/dist-server/types/node/command/exit-command-executor.d.ts +0 -14
  62. package/cli/dist-server/types/node/command/export-command-executor.d.ts +0 -7
  63. package/cli/dist-server/types/node/command/feedback-command-executor.d.ts +0 -9
  64. package/cli/dist-server/types/node/command/fork-bg-command-executor.d.ts +0 -30
  65. package/cli/dist-server/types/node/command/fork-command-executor.d.ts +0 -28
  66. package/cli/dist-server/types/node/command/goal-command-executor.d.ts +0 -50
  67. package/cli/dist-server/types/node/command/handoff-message-adapter.d.ts +0 -9
  68. package/cli/dist-server/types/node/command/help-command-executor.d.ts +0 -9
  69. package/cli/dist-server/types/node/command/hooks-command-executor.d.ts +0 -9
  70. package/cli/dist-server/types/node/command/ide-command-executor.d.ts +0 -11
  71. package/cli/dist-server/types/node/command/mcp-command-executor.d.ts +0 -15
  72. package/cli/dist-server/types/node/command/memory-command-executor.d.ts +0 -17
  73. package/cli/dist-server/types/node/command/mode-command-executor.d.ts +0 -11
  74. package/cli/dist-server/types/node/command/model-command-executor.d.ts +0 -11
  75. package/cli/dist-server/types/node/command/model-image-to-image-command-executor.d.ts +0 -17
  76. package/cli/dist-server/types/node/command/model-image-to-video-command-executor.d.ts +0 -17
  77. package/cli/dist-server/types/node/command/model-lite-command-executor.d.ts +0 -17
  78. package/cli/dist-server/types/node/command/model-reasoning-command-executor.d.ts +0 -17
  79. package/cli/dist-server/types/node/command/model-text-to-image-command-executor.d.ts +0 -17
  80. package/cli/dist-server/types/node/command/model-text-to-video-command-executor.d.ts +0 -17
  81. package/cli/dist-server/types/node/command/multitask-command-executor.d.ts +0 -9
  82. package/cli/dist-server/types/node/command/permissions-command-executor.d.ts +0 -9
  83. package/cli/dist-server/types/node/command/plan-command-executor.d.ts +0 -11
  84. package/cli/dist-server/types/node/command/plugin-command-executor.d.ts +0 -25
  85. package/cli/dist-server/types/node/command/plugin-validate-command-executor.d.ts +0 -21
  86. package/cli/dist-server/types/node/command/release-notes-command-executor.d.ts +0 -18
  87. package/cli/dist-server/types/node/command/reload-plugins-command-executor.d.ts +0 -24
  88. package/cli/dist-server/types/node/command/remote-control-command-executor.d.ts +0 -44
  89. package/cli/dist-server/types/node/command/rename-command-executor.d.ts +0 -11
  90. package/cli/dist-server/types/node/command/reset-command-executor.d.ts +0 -9
  91. package/cli/dist-server/types/node/command/resume-command-executor.d.ts +0 -21
  92. package/cli/dist-server/types/node/command/rewind-command-executor.d.ts +0 -10
  93. package/cli/dist-server/types/node/command/sandbox-command-executor.d.ts +0 -20
  94. package/cli/dist-server/types/node/command/save-workflow-command-executor.d.ts +0 -43
  95. package/cli/dist-server/types/node/command/session-reset-notifier.d.ts +0 -23
  96. package/cli/dist-server/types/node/command/skills-command-executor.d.ts +0 -9
  97. package/cli/dist-server/types/node/command/stats-command-executor.d.ts +0 -11
  98. package/cli/dist-server/types/node/command/status-command-executor.d.ts +0 -11
  99. package/cli/dist-server/types/node/command/tasks-command-executor.d.ts +0 -9
  100. package/cli/dist-server/types/node/command/terminal-setup-command-executor.d.ts +0 -7
  101. package/cli/dist-server/types/node/command/theme-command-executor.d.ts +0 -7
  102. package/cli/dist-server/types/node/command/todos-command-executor.d.ts +0 -16
  103. package/cli/dist-server/types/node/command/upgrade-command-executor.d.ts +0 -13
  104. package/cli/dist-server/types/node/command/vim-command-executor.d.ts +0 -11
  105. package/cli/dist-server/types/node/command/workflows-command-executor.d.ts +0 -26
  106. package/cli/dist-server/types/node/feedback/feedback-protocol.d.ts +0 -32
  107. package/cli/dist-server/types/node/feedback/feedback-service.d.ts +0 -19
  108. package/cli/dist-server/types/node/feedback/index.d.ts +0 -2
  109. package/cli/dist-server/types/node/goal/goal-policy.d.ts +0 -55
  110. package/cli/dist-server/types/node/goal/goal-protocol.d.ts +0 -178
  111. package/cli/dist-server/types/node/goal/goal-service.d.ts +0 -201
  112. package/cli/dist-server/types/node/goal/goal-session-start-hook.d.ts +0 -24
  113. package/cli/dist-server/types/node/hooks/parse-frontmatter-hooks.d.ts +0 -42
  114. package/cli/dist-server/types/node/install/index.d.ts +0 -6
  115. package/cli/dist-server/types/node/install/install-controller.d.ts +0 -15
  116. package/cli/dist-server/types/node/install/install-env.d.ts +0 -12
  117. package/cli/dist-server/types/node/install/install-errors.d.ts +0 -46
  118. package/cli/dist-server/types/node/install/install-protocol.d.ts +0 -83
  119. package/cli/dist-server/types/node/install/install-service.d.ts +0 -36
  120. package/cli/dist-server/types/node/install/install-utils.d.ts +0 -7
  121. package/cli/dist-server/types/node/install/releases-service.d.ts +0 -18
  122. package/cli/dist-server/types/node/install/shell-setup.d.ts +0 -36
  123. package/cli/dist-server/types/node/mcp/mcp-cancellation.d.ts +0 -65
  124. package/cli/dist-server/types/node/mcp/mcp-controller.d.ts +0 -56
  125. package/cli/dist-server/types/node/mcp/mcp-model-id-header-helper.d.ts +0 -12
  126. package/cli/dist-server/types/node/mcp/mcp-oauth-callback-html.d.ts +0 -6
  127. package/cli/dist-server/types/node/mcp/mcp-oauth-controller.d.ts +0 -26
  128. package/cli/dist-server/types/node/mcp/mcp-output-storage.d.ts +0 -57
  129. package/cli/dist-server/types/node/mcp/mcp-server-override-impl.d.ts +0 -136
  130. package/cli/dist-server/types/node/mcp/mcp-server-override.d.ts +0 -29
  131. package/cli/dist-server/types/node/mcp/mcp-tool-result-sideband.d.ts +0 -26
  132. package/cli/dist-server/types/node/mcp/mcp-validate-middleware.d.ts +0 -25
  133. package/cli/dist-server/types/node/mcp/models/mcp-server.d.ts +0 -18
  134. package/cli/dist-server/types/node/mcp/node-websocket-transport.d.ts +0 -38
  135. package/cli/dist-server/types/node/mcp/official-mcp-egress-policy.d.ts +0 -17
  136. package/cli/dist-server/types/node/mcp/sdk-mcp-server.d.ts +0 -143
  137. package/cli/dist-server/types/node/mcp/sdk-mcp-transport.d.ts +0 -97
  138. package/cli/dist-server/types/node/message-queue/followup-queue.d.ts +0 -35
  139. package/cli/dist-server/types/node/message-queue/index.d.ts +0 -11
  140. package/cli/dist-server/types/node/plugins/concurrency.d.ts +0 -1
  141. package/cli/dist-server/types/node/plugins/dependency-resolver.d.ts +0 -43
  142. package/cli/dist-server/types/node/plugins/directory-plugin-cache-projection.d.ts +0 -2
  143. package/cli/dist-server/types/node/plugins/guards/index.d.ts +0 -2
  144. package/cli/dist-server/types/node/plugins/guards/weixinpay-integrity-guard.d.ts +0 -15
  145. package/cli/dist-server/types/node/plugins/installers/git-plugin-installer.d.ts +0 -42
  146. package/cli/dist-server/types/node/plugins/installers/git-subdir-plugin-installer.d.ts +0 -19
  147. package/cli/dist-server/types/node/plugins/installers/index.d.ts +0 -4
  148. package/cli/dist-server/types/node/plugins/installers/local-plugin-installer.d.ts +0 -40
  149. package/cli/dist-server/types/node/plugins/installers/npm-plugin-installer.d.ts +0 -23
  150. package/cli/dist-server/types/node/plugins/loaders/agent-loader.d.ts +0 -43
  151. package/cli/dist-server/types/node/plugins/loaders/command-loader.d.ts +0 -37
  152. package/cli/dist-server/types/node/plugins/loaders/hook-loader.d.ts +0 -55
  153. package/cli/dist-server/types/node/plugins/loaders/index.d.ts +0 -8
  154. package/cli/dist-server/types/node/plugins/loaders/lsp-loader.d.ts +0 -47
  155. package/cli/dist-server/types/node/plugins/loaders/mcp-loader.d.ts +0 -75
  156. package/cli/dist-server/types/node/plugins/loaders/output-style-loader.d.ts +0 -49
  157. package/cli/dist-server/types/node/plugins/loaders/plugin-loader-manager.d.ts +0 -49
  158. package/cli/dist-server/types/node/plugins/loaders/skill-loader.d.ts +0 -45
  159. package/cli/dist-server/types/node/plugins/marketplace-name-validator.d.ts +0 -50
  160. package/cli/dist-server/types/node/plugins/marketplace-path-safety.d.ts +0 -86
  161. package/cli/dist-server/types/node/plugins/marketplaces/base-marketplace.d.ts +0 -43
  162. package/cli/dist-server/types/node/plugins/marketplaces/builtin-marketplace-provider.d.ts +0 -22
  163. package/cli/dist-server/types/node/plugins/marketplaces/directory-marketplace.d.ts +0 -19
  164. package/cli/dist-server/types/node/plugins/marketplaces/git-availability-detector.d.ts +0 -62
  165. package/cli/dist-server/types/node/plugins/marketplaces/git-fallback-coordinator.d.ts +0 -42
  166. package/cli/dist-server/types/node/plugins/marketplaces/git-to-zip-url-converter.d.ts +0 -50
  167. package/cli/dist-server/types/node/plugins/marketplaces/github-marketplace.d.ts +0 -41
  168. package/cli/dist-server/types/node/plugins/marketplaces/http-marketplace.d.ts +0 -47
  169. package/cli/dist-server/types/node/plugins/marketplaces/index.d.ts +0 -13
  170. package/cli/dist-server/types/node/plugins/marketplaces/marketplace-config-manager.d.ts +0 -39
  171. package/cli/dist-server/types/node/plugins/marketplaces/marketplace-factory.d.ts +0 -11
  172. package/cli/dist-server/types/node/plugins/marketplaces/marketplace-storage.d.ts +0 -141
  173. package/cli/dist-server/types/node/plugins/marketplaces/marketplace-update-checker.d.ts +0 -38
  174. package/cli/dist-server/types/node/plugins/marketplaces/workspace-project-root.d.ts +0 -14
  175. package/cli/dist-server/types/node/plugins/marketplaces/zip-marketplace.d.ts +0 -134
  176. package/cli/dist-server/types/node/plugins/mcpb-handler.d.ts +0 -29
  177. package/cli/dist-server/types/node/plugins/plugin-controller.d.ts +0 -75
  178. package/cli/dist-server/types/node/plugins/plugin-error-collector.d.ts +0 -17
  179. package/cli/dist-server/types/node/plugins/plugin-install-stats-service.d.ts +0 -20
  180. package/cli/dist-server/types/node/plugins/plugin-manager.d.ts +0 -692
  181. package/cli/dist-server/types/node/plugins/plugin-policy-service.d.ts +0 -53
  182. package/cli/dist-server/types/node/plugins/plugin-validator.d.ts +0 -48
  183. package/cli/dist-server/types/node/plugins/zip-utils.d.ts +0 -93
  184. package/cli/dist-server/types/node/remote-control/clients/liveness-watchdog.d.ts +0 -56
  185. package/cli/dist-server/types/node/remote-control/clients/wecom-bot/wecom-bot-activity.d.ts +0 -23
  186. package/cli/dist-server/types/node/remote-control/clients/wecom-bot/wecom-bot-auth.d.ts +0 -64
  187. package/cli/dist-server/types/node/remote-control/clients/wecom-bot/wecom-bot-client-factory.d.ts +0 -47
  188. package/cli/dist-server/types/node/remote-control/clients/wecom-bot/wecom-bot-client.d.ts +0 -191
  189. package/cli/dist-server/types/node/remote-control/clients/wecom-bot/wecom-bot-inbound.d.ts +0 -7
  190. package/cli/dist-server/types/node/remote-control/clients/wecom-bot/wecom-bot-interaction.d.ts +0 -142
  191. package/cli/dist-server/types/node/remote-control/clients/wecom-bot/wecom-bot-live.d.ts +0 -78
  192. package/cli/dist-server/types/node/remote-control/clients/wecom-bot/wecom-bot-media.d.ts +0 -35
  193. package/cli/dist-server/types/node/remote-control/clients/wecom-bot/wecom-bot-qr-bind.d.ts +0 -49
  194. package/cli/dist-server/types/node/remote-control/clients/wecom-bot/wecom-bot-respond-queue.d.ts +0 -33
  195. package/cli/dist-server/types/node/remote-control/clients/wecom-bot/wecom-bot-types.d.ts +0 -207
  196. package/cli/dist-server/types/node/remote-control/remote-control-protocol.d.ts +0 -288
  197. package/cli/dist-server/types/node/remote-gateway/gateway-protocol.d.ts +0 -502
  198. package/cli/dist-server/types/node/remote-gateway/utils/qrcode-utils.d.ts +0 -16
  199. package/cli/dist-server/types/node/session/session-preview-utils.d.ts +0 -30
  200. package/cli/dist-server/types/node/settings/model-setting-utils.d.ts +0 -2
  201. package/cli/dist-server/types/node/tool-control/tool-control-policy.d.ts +0 -35
  202. package/cli/dist-server/types/node/tools/auto-mode/auto-mode-critique-client.d.ts +0 -51
  203. package/cli/dist-server/types/node/tools/auto-mode/auto-mode-strategy.d.ts +0 -19
  204. package/cli/dist-server/types/node/utils/add-dir-utils.d.ts +0 -20
  205. package/cli/dist-server/types/node/utils/compress-path.source.d.ts +0 -59
  206. package/cli/dist-server/types/node/vim/index.d.ts +0 -2
  207. package/cli/dist-server/types/node/vim/vim-manager.d.ts +0 -12
  208. package/cli/dist-server/types/node/vim/vim-protocol.d.ts +0 -24
@@ -1,288 +0,0 @@
1
- /**
2
- * Remote Control Module Protocol
3
- *
4
- * 定义远程控制模块的所有类型、接口和 DI Symbols
5
- * 参考 genie-ide/src/vs/platform/wecom/common/wecom.ts
6
- */
7
- import { Subject } from 'rxjs';
8
- export declare const RemoteControlService: unique symbol;
9
- export declare const RemoteControlApiClient: unique symbol;
10
- export declare const RemoteControlCentrifugoClient: unique symbol;
11
- export declare const RemoteControlMessageHandler: unique symbol;
12
- export declare const LongConnectionClientRegistry: unique symbol;
13
- export declare const ENV_KEY_REMOTE_CONTROL_API_KEY = "CODEBUDDY_REMOTE_CONTROL_API_KEY";
14
- export declare const ENV_KEY_REMOTE_CONTROL_BASE_URL = "CODEBUDDY_REMOTE_CONTROL_BASE_URL";
15
- /** Set to '1' or 'true' to auto-connect ALL channel types (wecom + wechat) on startup */
16
- export declare const ENV_KEY_CHANNEL_AUTO_CONNECT = "CODEBUDDY_CHANNEL_AUTO_CONNECT";
17
- /** Set to '1' or 'true' to auto-connect WeCom instances on startup */
18
- export declare const ENV_KEY_WECOM_AUTO_CONNECT = "CODEBUDDY_WECOM_AUTO_CONNECT";
19
- /** Set to '1' or 'true' to auto-connect WeChat instances on startup */
20
- export declare const ENV_KEY_WECHAT_AUTO_CONNECT = "CODEBUDDY_WECHAT_AUTO_CONNECT";
21
- export interface RemoteControlConfig {
22
- /** 是否启用远程控制 */
23
- enabled: boolean;
24
- /** AgentOS 服务基础 URL */
25
- baseUrl: string;
26
- /** API Key(可选,不提供则使用 Bearer token) */
27
- apiKey?: string;
28
- /** LocalAgent 类型标识:cli, ide, workbuddy */
29
- localAgentType: string;
30
- /** 主机唯一标识 */
31
- hostId: string;
32
- /** 是否使用摘要模式 */
33
- useSummary: boolean;
34
- /** 是否复用 UI 当前 session(默认 true) */
35
- reuseUISession?: boolean;
36
- }
37
- export type RemoteControlConnectionStatus = 'disconnected' | 'connecting' | 'connected' | 'error';
38
- export interface RemoteControlConnectionState {
39
- status: RemoteControlConnectionStatus;
40
- serverUrl?: string;
41
- connectedAt?: number;
42
- error?: string;
43
- }
44
- export interface RegisterWorkspaceRequest {
45
- /** 用户 ID(可选,使用 Bearer token 时由服务端解析) */
46
- userId?: string;
47
- /** LocalAgent 类型:cli, ide, workbuddy */
48
- localAgentType: string;
49
- /** 主机 ID */
50
- hostId: string;
51
- /** 工作区 ID */
52
- workspaceId: string;
53
- /** 工作区名称(可选,用于增加可读性) */
54
- workspaceName?: string;
55
- /** IM 账号标识,如企微客服号 accountId(可选,用于多客服号场景下过滤 workspace 列表) */
56
- accountId?: string;
57
- }
58
- export interface RegisterWorkspaceResponse {
59
- /** Centrifugo WebSocket URL */
60
- url: string;
61
- /** 连接令牌 */
62
- connectionToken: string;
63
- /** 订阅令牌 */
64
- subscriptionToken: string;
65
- /** 订阅频道 */
66
- channel: string;
67
- }
68
- export interface WorkspaceSubscription {
69
- workspaceId: string;
70
- workspaceName: string;
71
- channel: string;
72
- subscriptionToken: string;
73
- }
74
- export interface RemoteControlTaskMessage {
75
- /** 请求唯一标识 */
76
- requestId: string;
77
- /** 任务提示词 */
78
- prompt: string | Array<{
79
- type: string;
80
- text?: string;
81
- }>;
82
- /** 附加元数据 */
83
- metadata?: Record<string, unknown>;
84
- }
85
- export interface RemoteControlResponse {
86
- /** 响应类型 */
87
- type: 'COPILOT_RESPONSE';
88
- /** 消息 ID(对应 requestId) */
89
- msgId: string;
90
- /** 会话 ID */
91
- chatId: string;
92
- /** 是否成功 */
93
- success: boolean;
94
- /** 响应消息 */
95
- message: string;
96
- /** 元数据 */
97
- metadata?: {
98
- sessionId?: string;
99
- state?: 'completed' | 'error';
100
- error?: string;
101
- fullOutputLength?: number;
102
- /** 标记 session 是否被复用 */
103
- uiSessionReused?: boolean;
104
- };
105
- }
106
- export interface IRemoteControlService {
107
- /** 状态变更事件 */
108
- readonly onStatusChange: Subject<RemoteControlConnectionStatus>;
109
- /** 消息接收事件 */
110
- readonly onMessage: Subject<{
111
- channel: string;
112
- data: RemoteControlTaskMessage;
113
- }>;
114
- /** 启动服务(启动所有 shouldAutoConnect 的客户端) */
115
- start(): Promise<void>;
116
- /** 停止服务(停止所有客户端) */
117
- stop(): Promise<void>;
118
- /** 获取当前状态 */
119
- getStatus(): RemoteControlConnectionStatus;
120
- /** 按类型启动单个长连接客户端 */
121
- startClient(clientType: string): Promise<void>;
122
- /** 按类型停止单个长连接客户端 */
123
- stopClient(clientType: string): Promise<void>;
124
- /** 发送响应 */
125
- sendResponse(response: RemoteControlResponse): Promise<void>;
126
- /** 释放资源 */
127
- dispose(): void;
128
- }
129
- export interface IRemoteControlApiClient {
130
- /** 设置配置 */
131
- setConfig(config: RemoteControlConfig): void;
132
- /** 注册工作区 */
133
- registerWorkspace(request: RegisterWorkspaceRequest): Promise<RegisterWorkspaceResponse>;
134
- /** 发送响应 */
135
- sendResponse(response: RemoteControlResponse): Promise<void>;
136
- }
137
- export interface IRemoteControlCentrifugoClient {
138
- /** 当前状态 */
139
- readonly status: RemoteControlConnectionStatus;
140
- /** 消息事件 */
141
- readonly onMessage: Subject<{
142
- channel: string;
143
- data: RemoteControlTaskMessage;
144
- }>;
145
- /** 状态变更事件 */
146
- readonly onStatusChange: Subject<RemoteControlConnectionState>;
147
- /** 连接到服务器 */
148
- connect(url: string, connectionToken: string, getToken?: () => Promise<string>): Promise<void>;
149
- /** 订阅频道 */
150
- subscribeChannel(subscription: WorkspaceSubscription, getSubToken?: () => Promise<string>): Promise<void>;
151
- /** 取消订阅频道 */
152
- unsubscribeChannel(channel: string): void;
153
- /** 断开连接 */
154
- disconnect(): void;
155
- /** 销毁 */
156
- dispose(): void;
157
- }
158
- export interface IRemoteControlMessageHandler {
159
- /** 处理消息(Centrifugo 原有流程,保留兼容) */
160
- handleMessage(message: RemoteControlTaskMessage, workspaceId: string, config: RemoteControlConfig, hostId: string): Promise<RemoteControlResponse>;
161
- /**
162
- * 快速检测并执行本地命令(不涉及 session 复用,用于 Service 层快速判断)。
163
- * 如果是本地命令,直接执行并返回结果;
164
- * 如果不是本地命令,返回 undefined(继续走 agent 管道)。
165
- */
166
- tryExecuteLocalCommandQuickly(promptText: string): Promise<string | undefined>;
167
- /**
168
- * 公共执行方法:接收消息文本 → 获取/创建 session → 执行 agent → 等待回复。
169
- * 供所有长连接客户端统一调用。
170
- */
171
- executeAndWaitForReply(promptText: string, conversationId: string, requestId: string): Promise<string>;
172
- /** 取消任务 */
173
- cancelTask(requestId: string): boolean;
174
- }
175
- /** QR code authentication status (for clients that use QR scan-to-login) */
176
- export interface QRAuthStatus {
177
- type: 'fetching' | 'qr_ready' | 'scanned' | 'expired' | 'confirmed' | 'error';
178
- message: string;
179
- /** UTF-8 rendered QR code text for terminal display */
180
- qrText?: string;
181
- /** Original QR code URL (fallback for manual open) */
182
- qrUrl?: string;
183
- }
184
- /**
185
- * Long connection client interface.
186
- * Different message channels (Centrifugo, wecom, etc.) implement this interface.
187
- */
188
- export interface ILongConnectionClient {
189
- /** Client type identifier (e.g. 'centrifugo', 'wecom') */
190
- readonly clientType: string;
191
- /** Instance identifier for multi-instance support (e.g. 'default', 'mybot') */
192
- readonly instanceId: string;
193
- /** Display name for UI (e.g. 'wecom:bot1'). Defaults to clientType:instanceId */
194
- readonly displayName?: string;
195
- /** Current connection status */
196
- readonly status: RemoteControlConnectionStatus;
197
- /** Message event (emitted when a user message is received, in unified LongConnectionMessage format) */
198
- readonly onMessage: Subject<LongConnectionMessage>;
199
- /** Status change event */
200
- readonly onStatusChange: Subject<RemoteControlConnectionState>;
201
- /** Whether this client should auto-connect when Service.start() is called */
202
- readonly shouldAutoConnect: boolean;
203
- /** Whether this client should be hidden from the /remote-control UI panel */
204
- readonly hidden?: boolean;
205
- /**
206
- * WeCom: whether assistant text is streamed into the IM bubble.
207
- * Omitted / true → stream; false → WeComReply-only (2.140.0).
208
- */
209
- readonly streaming?: boolean;
210
- /** Persist the WeCom streaming preference for this instance. Returns false if persist failed. */
211
- setStreaming?(enabled: boolean): boolean | void;
212
- /**
213
- * WeCom: whether Ask / permission / suggestion use template cards.
214
- * Omitted / true → cards; false → text replies (2.140.0).
215
- */
216
- readonly cards?: boolean;
217
- /** Persist the WeCom card-interaction preference. Returns false if persist failed. */
218
- setCards?(enabled: boolean): boolean | void;
219
- /**
220
- * When true, messages are handled via the channel system (WechatChannelBridge etc.)
221
- * and RemoteControlService skips its executeAndWaitForReply pipeline for this client.
222
- */
223
- readonly usesChannelBridge?: boolean;
224
- /** QR auth state change event (for clients that use QR scan-to-login) */
225
- readonly onQRAuthStateChange?: Subject<QRAuthStatus>;
226
- /** Start connection */
227
- connect(config: RemoteControlConfig): Promise<void>;
228
- /** Disconnect */
229
- disconnect(): void;
230
- /** Dispose resources */
231
- dispose(): void;
232
- /**
233
- * Send reply to message source.
234
- * Each long connection type has a different reply mechanism:
235
- * - Centrifugo: delegates to RemoteControlApiClient HTTP callback
236
- * - wecom: sends aibot_respond_msg via WebSocket
237
- */
238
- sendReply(context: LongConnectionReplyContext, content: string): Promise<void>;
239
- /**
240
- * Send streaming response chunk (optional).
241
- * Long connections that support streaming (e.g. wecom stream message type) can implement this.
242
- */
243
- sendStreamChunk?(context: LongConnectionReplyContext, chunk: string, streamId: string, finished: boolean): Promise<void>;
244
- /**
245
- * Send proactive/async reply (optional).
246
- * Unlike sendReply (which uses the callback req_id and is subject to stream timeout),
247
- * this uses a proactive push mechanism (e.g. wecom aibot_send_msg) that is not
248
- * bound by stream timeout. Suitable for long-running Agent tasks.
249
- */
250
- sendAsyncReply?(context: LongConnectionReplyContext, content: string): Promise<void>;
251
- }
252
- /** Unified message format (from all long connections → Service) */
253
- export interface LongConnectionMessage {
254
- /** Unique message ID */
255
- requestId: string;
256
- /** User message text */
257
- prompt: string;
258
- /** Reply context metadata (passed back to client when replying) */
259
- replyContext: LongConnectionReplyContext;
260
- /** Whether this is an event (not a user message) */
261
- isEvent?: boolean;
262
- /** Event type (if isEvent is true) */
263
- eventType?: string;
264
- }
265
- /** Reply context (travels with message, returned to client for reply routing) */
266
- export interface LongConnectionReplyContext {
267
- /** Client type */
268
- clientType: string;
269
- /** User/session identifier (for building chatId) */
270
- userId: string;
271
- /** Conversation ID */
272
- conversationId: string;
273
- /** Platform-specific data (e.g. wecom's req_id, chatid, chattype) */
274
- platformData?: Record<string, unknown>;
275
- }
276
- /** Long connection client registry interface */
277
- export interface ILongConnectionClientRegistry {
278
- /** Register a client (key = clientType:instanceId) */
279
- register(client: ILongConnectionClient): void;
280
- /** Unregister a client */
281
- unregister(clientType: string, instanceId: string): void;
282
- /** Get all registered clients */
283
- getAll(): ILongConnectionClient[];
284
- /** Get all clients of a given type */
285
- getByType(clientType: string): ILongConnectionClient[];
286
- /** Get a specific client by type and instanceId */
287
- get(clientType: string, instanceId?: string): ILongConnectionClient | undefined;
288
- }