@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,53 +0,0 @@
1
- import { Event, Logger } from '@celljs/core';
2
- import { BuiltInMarketPluginMerge } from '@genie/product';
3
- /**
4
- * 插件策略服务
5
- * 通过 builtInMarketPluginsMerge(由 Unleash 远程下发)控制插件的权限
6
- *
7
- * 职责:纯策略查询服务,不执行安装/卸载操作
8
- * 策略执行由 PluginManager 负责
9
- */
10
- export declare const PluginPolicyServiceSymbol: unique symbol;
11
- export interface PluginPolicyService {
12
- /** 策略变更事件 */
13
- readonly onDidChange: Event<void>;
14
- /** 获取所有合并插件策略 */
15
- getMergedPlugins(): BuiltInMarketPluginMerge[];
16
- /** 获取指定插件的合并策略 */
17
- getMergedPlugin(pluginId: string): BuiltInMarketPluginMerge | undefined;
18
- /** 插件是否不可删除 */
19
- isPluginCannotRemove(pluginId: string): boolean;
20
- /** 插件是否不可禁用 */
21
- isPluginCannotSwitchoff(pluginId: string): boolean;
22
- /** 插件是否不可编辑 */
23
- isPluginCannotEdit(pluginId: string): boolean;
24
- /** 插件是否需要自动安装(存在于 merge 列表中) */
25
- isPluginAutoInstall(pluginId: string): boolean;
26
- /** 市场是否被策略阻止(预留扩展) */
27
- isMarketplaceBlockedByPolicy(marketplaceName: string): boolean;
28
- }
29
- export declare class PluginPolicyServiceImpl implements PluginPolicyService {
30
- protected readonly logger: Logger;
31
- /** 当前生效的合并插件策略 */
32
- private mergedPlugins;
33
- /** 策略变更事件发射器 */
34
- private readonly onDidChangeEmitter;
35
- readonly onDidChange: Event<void>;
36
- protected init(): void;
37
- /**
38
- * 从产品配置加载合并插件策略
39
- * 包含格式校验 + 深比较变更检测
40
- */
41
- private loadPolicies;
42
- /**
43
- * 深比较两个策略 Map 是否有差异
44
- */
45
- private hasPluginsChanged;
46
- getMergedPlugins(): BuiltInMarketPluginMerge[];
47
- getMergedPlugin(pluginId: string): BuiltInMarketPluginMerge | undefined;
48
- isPluginCannotRemove(pluginId: string): boolean;
49
- isPluginCannotSwitchoff(pluginId: string): boolean;
50
- isPluginCannotEdit(pluginId: string): boolean;
51
- isPluginAutoInstall(pluginId: string): boolean;
52
- isMarketplaceBlockedByPolicy(_marketplaceName: string): boolean;
53
- }
@@ -1,48 +0,0 @@
1
- import { PluginValidator as IPluginValidator } from './plugin-protocol';
2
- export interface ValidationError {
3
- path: string;
4
- message: string;
5
- }
6
- export interface ValidationResult {
7
- success: boolean;
8
- errors: ValidationError[];
9
- warnings: ValidationError[];
10
- filePath: string;
11
- fileType: 'plugin' | 'marketplace';
12
- }
13
- /**
14
- * 清单验证失败错误
15
- */
16
- export declare class ManifestValidationError extends Error {
17
- filePath: string;
18
- validationResult: ValidationResult;
19
- constructor(message: string, filePath: string, validationResult: ValidationResult);
20
- }
21
- /**
22
- * 插件验证器实现
23
- * 负责验证插件和市场清单文件的有效性
24
- */
25
- export declare class PluginValidatorImpl implements IPluginValidator {
26
- /**
27
- * 验证插件或市场清单
28
- * @param inputPath 文件或目录路径
29
- */
30
- validateManifest(inputPath: string): Promise<ValidationResult>;
31
- /**
32
- * 验证目录中的清单文件
33
- */
34
- private validateDirectory;
35
- /**
36
- * 验证文件
37
- */
38
- private validateFile;
39
- /**
40
- * 验证插件清单文件
41
- */
42
- private validatePluginManifestFile;
43
- /**
44
- * 验证市场清单文件
45
- */
46
- private validateMarketplaceManifestFile;
47
- private validateDependencies;
48
- }
@@ -1,93 +0,0 @@
1
- import * as http from 'http';
2
- /**
3
- * 从 zip URL 里提取 UUID 版本号,用于内置市场更新检查。
4
- *
5
- * 命中规则:URL basename 必须是 `<name>-<UUID>.zip`,UUID 形如
6
- * `cb_teams_marketplace-e4456ec2-6d1a-4af9-86a9-83a4bea4bbda.zip`
7
- * 只接受标准 UUID v4 字面量(8-4-4-4-12),不做其他兜底解析;解析失败返回
8
- * `null`,由调用方决定是否走 ETag 兜底。
9
- *
10
- * 外部更新调度与 CLI checker 必须共用本函数;同一个 URL 若被解析成不同版本,
11
- * 两层更新判据会出现无限震荡。
12
- */
13
- export declare function parseVersionFromUrl(url: string): string | null;
14
- /**
15
- * ZIP metadata persisted after a successful install/update.
16
- * Used to decide whether a remote source has new content without re-downloading the archive.
17
- */
18
- export interface ZipMetadata {
19
- /** Source URL or local file path this archive came from. */
20
- url: string;
21
- /** Last-Modified header value returned by the server (or local file mtime). */
22
- lastModified?: string;
23
- /** ETag header value returned by the server. */
24
- etag?: string;
25
- /** ISO timestamp of when this archive was downloaded. */
26
- downloadedAt: string;
27
- /**
28
- * Indicates the install/extract step finished without error.
29
- * Absent on legacy metadata, which we treat as "unverified" and trigger re-download.
30
- */
31
- installComplete?: boolean;
32
- }
33
- /** Headers captured from a successful download response. */
34
- export interface DownloadResult {
35
- lastModified?: string;
36
- etag?: string;
37
- }
38
- /** Result of a freshness check against a remote (or local) archive source. */
39
- export interface ZipUpdateCheckResult {
40
- needsUpdate: boolean;
41
- lastModified?: string;
42
- etag?: string;
43
- }
44
- /** Resolve the metadata path for a given install location. */
45
- export declare function getMetadataPath(installLocation: string): string;
46
- /** Read metadata if it exists; returns undefined on any read/parse error. */
47
- export declare function readZipMetadata(installLocation: string): Promise<ZipMetadata | undefined>;
48
- /** Write metadata to the install location. */
49
- export declare function writeZipMetadata(installLocation: string, metadata: ZipMetadata): Promise<void>;
50
- /** A "local file path" is anything that isn't an HTTP or HTTPS URL. */
51
- export declare function isLocalFilePath(source: string): boolean;
52
- /** Detect whether a URL points to a ZIP/TGZ/TAR.GZ archive by extension. */
53
- export declare function isZipUrl(url: string): boolean;
54
- /**
55
- * Fetch headers via HEAD request, following up to `maxRedirects` redirects.
56
- * Some hosts (e.g. git archive URLs) reject HEAD; callers should fall back to
57
- * treating that as "needs update" rather than a hard failure.
58
- */
59
- export declare function getRemoteHeaders(url: string, maxRedirects?: number): Promise<http.IncomingHttpHeaders>;
60
- /**
61
- * Fetch a small UTF-8 text resource with bounded connect/read time and
62
- * redirect handling. Used for Product-declared marketplace version metadata.
63
- */
64
- export declare function fetchText(url: string, timeoutMs?: number, maxRedirects?: number): Promise<string>;
65
- /**
66
- * Download `url` to `destPath`, handling HTTP redirects.
67
- * Returns the ETag / Last-Modified headers so the caller can persist them for future freshness checks.
68
- */
69
- export declare function downloadFile(url: string, destPath: string, maxRedirects?: number): Promise<DownloadResult>;
70
- /** Copy a local archive to a destination path; mirrors downloadFile's return shape. */
71
- export declare function copyLocalFile(sourcePath: string, destPath: string): Promise<DownloadResult>;
72
- /**
73
- * Decide whether a remote ZIP needs to be re-downloaded by comparing ETag/Last-Modified.
74
- *
75
- * The precedence mirrors `agent-craft`'s implementation:
76
- * 1. No existing metadata → update (first install)
77
- * 2. `installComplete` flag missing → update (legacy or interrupted install)
78
- * 3. URL changed → update
79
- * 4. ETag available on both sides → trust ETag equality
80
- * 5. Last-Modified available on both sides → compare timestamps
81
- * 6. HEAD request failed or server returns neither header → update (safe default)
82
- */
83
- export declare function checkZipNeedsUpdate(url: string, installLocation: string, maxRedirects?: number): Promise<ZipUpdateCheckResult>;
84
- /** Decide whether a local-path ZIP has changed since last install by comparing mtime. */
85
- export declare function checkLocalZipNeedsUpdate(sourcePath: string, installLocation: string): Promise<ZipUpdateCheckResult>;
86
- /**
87
- * Extract a ZIP / TGZ / TAR.GZ archive to `targetDir`.
88
- *
89
- * @param flatten When a single top-level directory is detected in a .zip (common for
90
- * `git archive` output), move its contents up one level. Ignores `__MACOSX`.
91
- * Defaults to true.
92
- */
93
- export declare function extractZip(zipPath: string, targetDir: string, flatten?: boolean): Promise<void>;
@@ -1,56 +0,0 @@
1
- /**
2
- * Liveness Watchdog
3
- *
4
- * 定期检查"最近一次活动时间"是否陈旧,陈旧即触发 onStuck 让调用方自定义恢复。
5
- *
6
- * 主要场景:macOS 屏幕锁屏 / App Nap 会冻结进程的定时器和网络栈:
7
- * - HTTP 长轮询:fetch 卡在 await,调用方 abort 当前请求让 catch 路径恢复
8
- * - WebSocket 心跳:ping 没回 pong,调用方 ws.close() 触发 onclose → 重连
9
- *
10
- * 关键:watchdog 定时器**不能 unref()**。unref 的定时器在 App Nap 下会被冻结
11
- * 而且不会"补发"——保留 ref 后系统才会在解冻瞬间触发回调,这才是恢复的核心机制。
12
- */
13
- import type { Logger } from '@genie/telemetry';
14
- /** watchdog 默认检查间隔(30s)。 */
15
- export declare const DEFAULT_LIVENESS_CHECK_INTERVAL_MS = 30000;
16
- /**
17
- * 默认卡死阈值(90s)。
18
- * HTTP 长轮询:35s 长轮询 + 10s timeout = 45s,给一倍 buffer 应付正常网络抖动。
19
- * WebSocket:30s 心跳 + 30s 等待 = 60s,加 30s buffer。
20
- */
21
- export declare const DEFAULT_LIVENESS_STUCK_MS = 90000;
22
- export interface LivenessWatchdogDeps {
23
- /** 是否仍应继续监测。watchdog 在 false 时跳过检查(如 disconnected 状态)。 */
24
- isActive(): boolean;
25
- /** 取得最近一次活动时间戳(ms since epoch)。 */
26
- getLastActivityAt(): number;
27
- /**
28
- * 卡死时由调用方决定如何恢复:
29
- * - HTTP 长轮询场景:abort 当前请求
30
- * - WebSocket 场景:ws.close() 触发 onclose 重连
31
- * 实现内**应当**自己刷新 lastActivityAt 或确保短期不会再被 stuck 触发。
32
- * elapsedMs 是当前 stuck 持续时间,便于日志和打点。
33
- */
34
- onStuck(elapsedMs: number): void;
35
- /** 日志输出(stuck 触发时打 warn)。 */
36
- logger: Logger;
37
- /** 日志 / 异常打印用的标签,例如 'wechat-poll' / 'wecom-ws'。 */
38
- label: string;
39
- }
40
- export interface LivenessWatchdogOptions {
41
- /** 检查间隔,默认 DEFAULT_LIVENESS_CHECK_INTERVAL_MS */
42
- intervalMs?: number;
43
- /** 卡死阈值,默认 DEFAULT_LIVENESS_STUCK_MS */
44
- stuckMs?: number;
45
- }
46
- export declare class LivenessWatchdog {
47
- private readonly deps;
48
- private timer;
49
- private readonly intervalMs;
50
- private readonly stuckMs;
51
- constructor(deps: LivenessWatchdogDeps, options?: LivenessWatchdogOptions);
52
- start(): void;
53
- stop(): void;
54
- /** 单次检查(暴露用于单测,不需要等真实定时器) */
55
- tick(): void;
56
- }
@@ -1,23 +0,0 @@
1
- /**
2
- * One-line WeCom activity. Full-replace only; never a template card.
3
- * Do not leak Bash command, file contents, or Agent prompt.
4
- */
5
- export declare const WECOM_PROGRESS_MIN_INTERVAL_MS = 800;
6
- export declare const WECOM_PROGRESS_HEARTBEAT_MS = 15000;
7
- export interface WecomToolActivity {
8
- phase: 'start' | 'end';
9
- name: string;
10
- callId?: string;
11
- preview?: string;
12
- fromSubAgent: boolean;
13
- }
14
- export declare function isHiddenWecomActivityTool(name: string | undefined): boolean;
15
- export declare function stripWecomThinkBlocks(text: string): string;
16
- export declare function isWecomProgressText(text: string | undefined | null): boolean;
17
- export declare function wecomFilePreviewFromArgs(name: string, raw: unknown): string | undefined;
18
- export declare function wecomToolActivityFromEvent(event: unknown): WecomToolActivity | undefined;
19
- export declare function formatWecomActivity(tools: Array<{
20
- name: string;
21
- fromSubAgent?: boolean;
22
- preview?: string;
23
- }>, elapsedSec?: number): string;
@@ -1,64 +0,0 @@
1
- /**
2
- * WeChat Work AI Bot Credential Management
3
- *
4
- * Credentials are stored as a JSON array in a single file:
5
- * ~/.codebuddy/channels/wecom/instances.json
6
- *
7
- * Each entry: { instanceId, displayName, credentials: WecomBotCredentials }
8
- *
9
- * Environment variables (CODEBUDDY_WECOM_BOT_ID, CODEBUDDY_WECOM_BOT_SECRET)
10
- * are still supported: when instances.json is empty and env vars are set,
11
- * an instance is auto-created from them.
12
- */
13
- export interface WecomBotCredentials {
14
- botId: string;
15
- secret: string;
16
- wsUrl: string;
17
- }
18
- export interface WecomInstanceEntry {
19
- instanceId: string;
20
- displayName: string;
21
- credentials: WecomBotCredentials;
22
- /** daemon 启动时是否自动连接(默认 true) */
23
- autoConnect?: boolean;
24
- /**
25
- * Whether this bot streams assistant text into WeCom.
26
- * Omitted / true → stream; false → 2.140.0-style WeComReply only.
27
- */
28
- streaming?: boolean;
29
- /**
30
- * Whether Ask / permission / suggestion use template cards.
31
- * Omitted / true → vote cards; false → 2.140.0-style text (y/n / 编号).
32
- */
33
- cards?: boolean;
34
- }
35
- /** Streaming is on unless the instance explicitly opts out. */
36
- export declare function isWecomStreamingEnabled(streaming?: boolean): boolean;
37
- /** Cards are on unless the instance explicitly opts out. */
38
- export declare function isWecomCardsEnabled(cards?: boolean): boolean;
39
- export declare function wecomDeliveryMode(streaming?: boolean): 'stream' | 'reply';
40
- /** Load all instance entries from instances.json (with legacy migration). */
41
- export declare function loadAllInstances(): WecomInstanceEntry[];
42
- /** Load credentials for a specific instance. */
43
- export declare function loadWecomCredentials(instanceId: string): WecomBotCredentials | undefined;
44
- /** Save (upsert) credentials for an instance. Preserves streaming / cards / autoConnect. */
45
- export declare function saveWecomCredentials(credentials: WecomBotCredentials, instanceId: string, displayName?: string): void;
46
- /**
47
- * Patch instance options. If the instance has no disk row yet, upsert one when
48
- * credentials are provided or resolvable from env (env-created `default`).
49
- */
50
- export declare function updateWecomInstanceOptions(instanceId: string, patch: Partial<Pick<WecomInstanceEntry, 'streaming' | 'cards' | 'autoConnect' | 'displayName'>>, credentials?: WecomBotCredentials): WecomInstanceEntry | undefined;
51
- /** Remove credentials for an instance. */
52
- export declare function clearWecomCredentials(instanceId: string): void;
53
- /** List all saved instance IDs. */
54
- export declare function listWecomCredentialInstances(): string[];
55
- export declare function wecomInstanceIdFromBotId(botId: string): string;
56
- export declare function isWecomQrPendingInstanceId(instanceId: string): boolean;
57
- /**
58
- * Resolve credentials from environment variables or disk for a given instance.
59
- * Environment variables take priority over saved credentials.
60
- *
61
- * Env var naming: CODEBUDDY_WECOM_BOT_ID_{INSTANCE} / CODEBUDDY_WECOM_BOT_SECRET_{INSTANCE}
62
- * Legacy no-suffix env vars (CODEBUDDY_WECOM_BOT_ID) are checked for the 'default' instance.
63
- */
64
- export declare function resolveWecomCredentials(instanceId: string): WecomBotCredentials | undefined;
@@ -1,47 +0,0 @@
1
- /**
2
- * WeChat Work AI Bot Client Factory
3
- *
4
- * Creates and manages multiple WecomBotClient instances.
5
- * All instances are loaded from ~/.codebuddy/channels/wecom/instances.json on startup.
6
- * No DI singleton — all instances are managed here.
7
- */
8
- import { type WecomBotCredentials } from './wecom-bot-auth';
9
- import { WecomBotClient } from './wecom-bot-client';
10
- export declare const WecomBotClientFactory: unique symbol;
11
- export interface IWecomBotClientFactory {
12
- /** Get all instances */
13
- getAll(): WecomBotClient[];
14
- /** Get instance by instanceId */
15
- get(instanceId: string): WecomBotClient | undefined;
16
- /** Create a new instance and register it. Credentials optional — connect() will prompt if missing. */
17
- create(instanceId: string, credentials?: WecomBotCredentials, displayName?: string): WecomBotClient;
18
- /** Reuse one QR pending instance; drop extra unbound pendings. */
19
- ensureQrPending(): WecomBotClient;
20
- /** After QR bind, expose the live client under the botId-derived id. */
21
- adoptPending(pendingId: string): string | undefined;
22
- /** Remove an instance */
23
- remove(instanceId: string): void;
24
- }
25
- export declare class WecomBotClientFactoryImpl implements IWecomBotClientFactory {
26
- private readonly logger;
27
- private readonly clientRegistry;
28
- private readonly instances;
29
- protected initialize(): void;
30
- /**
31
- * Load all instances from instances.json (includes legacy migration),
32
- * then create instances from environment variables if not already present.
33
- */
34
- private loadAllSavedInstances;
35
- /**
36
- * If CODEBUDDY_WECOM_BOT_ID + CODEBUDDY_WECOM_BOT_SECRET env vars are set
37
- * and no 'default' instance exists yet, create one from the env vars.
38
- */
39
- private loadInstanceFromEnv;
40
- getAll(): WecomBotClient[];
41
- get(instanceId: string): WecomBotClient | undefined;
42
- ensureQrPending(): WecomBotClient;
43
- adoptPending(pendingId: string): string | undefined;
44
- private removeUnboundQrPendings;
45
- create(instanceId: string, credentials?: WecomBotCredentials, displayName?: string): WecomBotClient;
46
- remove(instanceId: string): void;
47
- }
@@ -1,191 +0,0 @@
1
- /**
2
- * WeChat Work AI Bot Long Connection Client
3
- *
4
- * Implements ILongConnectionClient for enterprise WeChat AI Bot WebSocket connections.
5
- * Uses the aibot WebSocket API (wss://openws.work.weixin.qq.com) with bot_id + secret auth.
6
- *
7
- * Credential resolution order:
8
- * 1. Environment variables (CODEBUDDY_WECOM_BOT_ID, CODEBUDDY_WECOM_BOT_SECRET)
9
- * 2. Saved credentials on disk (~/.codebuddy/channels/wecom/instances.json)
10
- * 3. WeCom official QR bind (same pairing page as @wecom/wecom-openclaw-cli), then hand-fill fallback
11
- *
12
- * Messages are handled via WecomBotChannelBridge (usesChannelBridge = true),
13
- * which injects them into the channel system as <channel source="wecom"> events.
14
- * Replies are sent via sendAsyncReply (aibot_send_msg proactive push).
15
- *
16
- * Features:
17
- * - WebSocket connection with aibot_subscribe authentication
18
- * - 30s heartbeat (ping)
19
- * - Exponential backoff reconnection with jitter
20
- * - Message deduplication (LRU Set)
21
- * - Proactive message push (aibot_send_msg) for channel bridge replies
22
- * - Stream reply support (aibot_respond_msg) — retained for interface compatibility
23
- * - Event handling (enter_chat welcome, disconnected_event reconnect)
24
- * - Runtime detection: uses Bun global WebSocket or Node.js ws package
25
- *
26
- * Reference: https://developer.work.weixin.qq.com/document/path/101463
27
- */
28
- import type { Logger } from '@genie/telemetry';
29
- import { Subject } from 'rxjs';
30
- import { type ILongConnectionClient, type LongConnectionMessage, type LongConnectionReplyContext, type QRAuthStatus, type RemoteControlConfig, type RemoteControlConnectionState, type RemoteControlConnectionStatus } from '../../remote-control-protocol';
31
- import { type WecomBotCredentials } from './wecom-bot-auth';
32
- import { type WecomCardClick, type WecomTemplateCard } from './wecom-bot-interaction';
33
- export declare class WecomBotClient implements ILongConnectionClient {
34
- readonly clientType = "wecom";
35
- instanceId: string;
36
- displayName?: string;
37
- readonly shouldAutoConnect = false;
38
- readonly usesChannelBridge = true;
39
- /** 扫码中的临时实例不进 /remote-control 列表,避免前端重挂载刷出一堆 connecting。 */
40
- get hidden(): boolean;
41
- readonly onMessage: Subject<LongConnectionMessage>;
42
- readonly onCardEvent: Subject<WecomCardClick>;
43
- readonly onStatusChange: Subject<RemoteControlConnectionState>;
44
- readonly onQRAuthStateChange: Subject<QRAuthStatus>;
45
- private logger;
46
- private ws;
47
- private heartbeatTimer;
48
- private reconnectTimer;
49
- private reconnectAttempts;
50
- private _status;
51
- private shouldReconnect;
52
- /**
53
- * 最近一次收到 ws 帧(消息或 pong)的时间戳。watchdog 用它判定连接是否还活着。
54
- * 必须在每条消息到达时刷新。
55
- */
56
- private lastWsActivityAt;
57
- /**
58
- * Liveness watchdog:监测心跳活动是否陈旧。
59
- *
60
- * 背景:macOS 屏幕锁屏 / App Nap 会冻结网络栈和定时器。
61
- * - heartbeatTimer 被冻结 → 不再发 ping
62
- * - 即便底层 TCP 已断(路由器空闲超时等),ws 对象的 onclose 也可能延迟很久才触发
63
- * - 解锁后我们看到的是"还连着",但其实远端早把 session 抛了
64
- *
65
- * watchdog 在解冻瞬间触发,关掉僵尸 ws → onclose → scheduleReconnect 走原有重连路径。
66
- */
67
- private watchdog;
68
- private readonly processedMsgIds;
69
- private readonly msgIdQueue;
70
- private readonly pendingResponses;
71
- private readonly respondQueue;
72
- private credentials;
73
- private credentialPromptAbort;
74
- private streamingEnabled;
75
- private cardsEnabled;
76
- get status(): RemoteControlConnectionStatus;
77
- get streaming(): boolean;
78
- setStreaming(enabled: boolean): boolean;
79
- get cards(): boolean;
80
- setCards(enabled: boolean): boolean;
81
- /** Initialize the client. Called by the factory after construction. */
82
- init(logger: Logger, instanceId: string, displayName?: string, credentials?: WecomBotCredentials | null, options?: {
83
- streaming?: boolean;
84
- cards?: boolean;
85
- }): void;
86
- /**
87
- * Configure this client for a specific instance (called by factory before connect).
88
- * @deprecated Use init() instead.
89
- */
90
- configureInstance(instanceId: string, displayName?: string, credentials?: WecomBotCredentials): void;
91
- /** Check if credentials are available and valid */
92
- isConfigured(): boolean;
93
- getCredentials(): WecomBotCredentials | null;
94
- /** Move a QR pending client onto a stable instance id after bind. */
95
- rekeyInstance(instanceId: string, displayName?: string): void;
96
- connect(_config?: RemoteControlConfig): Promise<void>;
97
- /**
98
- * Show the official WeCom pairing QR (or hand-fill instructions if generate fails).
99
- */
100
- private promptForCredentials;
101
- disconnect(): void;
102
- /** Clear in-memory credentials so next connect() triggers re-auth (interactive prompt). */
103
- clearCredentials(): void;
104
- dispose(): void;
105
- /**
106
- * Send reply via WebSocket as a single stream message with finish=true.
107
- * Retained for ILongConnectionClient interface compatibility.
108
- */
109
- sendReply(context: LongConnectionReplyContext, content: string): Promise<void>;
110
- /**
111
- * Send streaming response chunk via stream message type.
112
- * Same req_id is serialized through the respond queue.
113
- */
114
- sendStreamChunk(context: LongConnectionReplyContext, chunk: string, streamId: string, finished: boolean): Promise<void>;
115
- /** First frame: finish=false, content=`<think></think>`. */
116
- openStream(reqId: string, streamId: string): Promise<void>;
117
- /** Full-replace stream update. Empty finish is dropped so the thinking animation is not locked. */
118
- pushStream(reqId: string, streamId: string, content: string, finish: boolean): Promise<void>;
119
- /**
120
- * Send proactive message via aibot_send_msg (no stream timeout).
121
- * Used by WecomBotChannelBridge for channel bridge replies.
122
- * Only requires chatid, not the original req_id.
123
- */
124
- sendAsyncReply(context: LongConnectionReplyContext, content: string): Promise<void>;
125
- sendTemplateCard(context: LongConnectionReplyContext, card: WecomTemplateCard): Promise<void>;
126
- updateTemplateCard(reqId: string, card: WecomTemplateCard): Promise<void>;
127
- /**
128
- * Send a WebSocket frame and wait for the response with matching req_id.
129
- * Implements request-response pattern over the fire-and-forget WebSocket.
130
- */
131
- private sendFrameWithResponse;
132
- /**
133
- * Upload media file to WeCom via WebSocket chunked upload protocol.
134
- *
135
- * Protocol (3 steps):
136
- * 1. aibot_upload_media_init → returns upload_id
137
- * 2. aibot_upload_media_chunk → sends base64-encoded chunks
138
- * 3. aibot_upload_media_finish → returns media_id
139
- *
140
- * @param fileBuffer - File content as Buffer
141
- * @param options - Upload options (type, filename)
142
- * @returns Upload result with media_id
143
- */
144
- uploadMedia(fileBuffer: Buffer, options: {
145
- type: 'image' | 'file' | 'video' | 'voice';
146
- filename: string;
147
- }): Promise<{
148
- media_id: string;
149
- type: string;
150
- }>;
151
- /**
152
- * Send a media message to a chat via aibot_send_msg.
153
- *
154
- * @param chatId - Target chat ID (user ID for single, group ID for group)
155
- * @param mediaType - Media type (image, file, video, voice)
156
- * @param mediaId - The media_id from uploadMedia
157
- * @param chatType - Chat type: 1=single, 2=group (default: inferred from chatId)
158
- */
159
- sendMediaMessage(chatId: string, mediaType: 'image' | 'file' | 'video' | 'voice', mediaId: string, chatType?: 1 | 2): Promise<void>;
160
- private doConnect;
161
- private sendSubscribe;
162
- private handleFrame;
163
- private handleMsgCallback;
164
- private handleEventCallback;
165
- private handleEnterChat;
166
- private startHeartbeat;
167
- private stopHeartbeat;
168
- /**
169
- * 启动 ws liveness watchdog。详见 ../liveness-watchdog.ts。
170
- *
171
- * 策略:超过 90s 没收到任何 ws 帧 → 强制 ws.close() → 触发 onclose →
172
- * shouldReconnect=true 时进入 scheduleReconnect 走原有重连路径。
173
- * 这样 macOS 锁屏解冻后能在 ~30s 内(一个 watchdog tick)恢复,
174
- * 而不是等 TCP keepalive 或远端清理 session。
175
- */
176
- private startWatchdog;
177
- private stopWatchdog;
178
- private scheduleReconnect;
179
- private clearReconnectTimer;
180
- private isDuplicate;
181
- private recordMsgId;
182
- /**
183
- * Extract text and download media files from a WeCom AI Bot message.
184
- * Media files (image/file/voice) are downloaded to a temp directory and referenced by path.
185
- * Pattern: same as wechat-client.ts extractContent()
186
- */
187
- private extractContent;
188
- private rejectAllPendingResponses;
189
- private sendFrame;
190
- private setStatus;
191
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * Sync peek of aibot_msg_callback text so the bridge can route (permission / slash)
3
- * and open a stream before media download awaits.
4
- */
5
- import type { WecomBotMsgCallback } from './wecom-bot-types';
6
- export declare function peekWecomCallbackText(body: WecomBotMsgCallback['body']): string;
7
- export declare function composeWecomPrompt(text: string, mediaFiles: string[]): string;