@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,11 +0,0 @@
1
- import { SessionManager } from '../session';
2
- import { CommandExecuteContext, CommandExecutor } from './command-protocol';
3
- import { VimManager } from '../vim';
4
- export declare class VimCommandExecutor implements CommandExecutor {
5
- name: string;
6
- message: string;
7
- autoGenerateHistory: boolean;
8
- protected readonly sessionManager: SessionManager;
9
- protected readonly vimManager: VimManager;
10
- execute(ctx: CommandExecuteContext): Promise<void>;
11
- }
@@ -1,26 +0,0 @@
1
- /**
2
- * /workflows —— 列出所有 saved + builtin workflow,以及当前 session 内运行中的 workflow run。
3
- *
4
- * 单一职责:把 WorkflowManager.listActive() + WorkflowRegistry.list() 拼成
5
- * markdown 字符串,通过标准 finalize 路径写入 session 历史。
6
- *
7
- * Batch 4 简化:不实现交互式键位(`s/p/r/x/j/k`),只输出文本列表。
8
- * 后续 UI batch 接入 Ink 组件后再补。
9
- */
10
- import { Logger } from '@genie/telemetry';
11
- import { SessionManager } from '../session';
12
- import type { WorkflowManager, WorkflowRegistry } from '@genie/cbc-workflow';
13
- import { CommandExecuteContext, CommandExecutor } from './command-protocol';
14
- export declare class WorkflowsCommandExecutor implements CommandExecutor {
15
- name: string;
16
- autoGenerateHistory: boolean;
17
- protected readonly logger: Logger;
18
- protected readonly sessionManager: SessionManager;
19
- protected readonly manager: WorkflowManager;
20
- protected readonly registry: WorkflowRegistry;
21
- execute(ctx: CommandExecuteContext): Promise<void>;
22
- private buildOutput;
23
- private renderRunningSection;
24
- private renderSavedSection;
25
- private appendHistory;
26
- }
@@ -1,32 +0,0 @@
1
- import { BehaviorSubject } from 'rxjs';
2
- import { Session } from '../session';
3
- export declare const FeedbackService: unique symbol;
4
- /**
5
- * Feedback 状态
6
- */
7
- export type FeedbackStatus = 'idle' | 'loading' | 'opening' | 'success' | 'failed' | 'not-configured';
8
- /**
9
- * Feedback 状态数据
10
- */
11
- export interface FeedbackState {
12
- status: FeedbackStatus;
13
- feedbackUrl?: string;
14
- }
15
- /**
16
- * Feedback 服务接口
17
- */
18
- export interface FeedbackService {
19
- /**
20
- * 状态 Subject,用于 UI 订阅
21
- */
22
- readonly stateSubject: BehaviorSubject<FeedbackState>;
23
- /**
24
- * 打开反馈页面
25
- * @param session 当前会话
26
- */
27
- openFeedbackPage(session: Session): Promise<void>;
28
- /**
29
- * 重置状态
30
- */
31
- reset(): void;
32
- }
@@ -1,19 +0,0 @@
1
- import { AuthenticationManager } from '@genie/authentication';
2
- import { ProductManager } from '@genie/product';
3
- import { ExternalUriOpener } from '@genie/runtime';
4
- import { BehaviorSubject } from 'rxjs';
5
- import { InstallService } from '../install';
6
- import { Session } from '../session';
7
- import { FeedbackService, FeedbackState } from './feedback-protocol';
8
- export declare class FeedbackServiceImpl implements FeedbackService {
9
- readonly stateSubject: BehaviorSubject<FeedbackState>;
10
- protected readonly productManager: ProductManager;
11
- protected readonly externalUriOpener: ExternalUriOpener;
12
- protected readonly authenticationManager: AuthenticationManager;
13
- protected readonly installService: InstallService;
14
- openFeedbackPage(session: Session): Promise<void>;
15
- reset(): void;
16
- protected buildFeedbackUrl(baseUrl: string, session: Session): Promise<string>;
17
- protected buildFeedbackBody(session: Session): Promise<string>;
18
- protected getInstallMethod(): Promise<string>;
19
- }
@@ -1,2 +0,0 @@
1
- export * from './feedback-protocol';
2
- export * from './feedback-service';
@@ -1,55 +0,0 @@
1
- /**
2
- * Goal 默认策略层:文案、prompt 模板、scope id 生成。
3
- *
4
- * 全部为纯逻辑,单测里直接 import 即可断言(不依赖 DI / Service)。
5
- * 业务侧若要定制(i18n、品牌词替换、scope 命名规则)可构造自定义
6
- * `GoalServicePolicy` 注入到 `GoalServiceImpl.configure()`。
7
- */
8
- import { ActiveGoal, GoalServicePolicy } from './goal-protocol';
9
- /**
10
- * 与 cc 二进制中的 stop-condition user message 对齐。
11
- *
12
- * 设计原因:
13
- * - JSON schema、三态语义、impossible 强约束都已在 evaluator agent 的
14
- * `prompt-hook-evaluator-instructions.tpl` 里集中说明(system prompt),
15
- * user message 只负责把"问题"抛给模型即可——避免与 system prompt 重复
16
- * 甚至产生冲突说法(之前两态 vs 三态就出过这种漂移);
17
- * - 文案与 cc 的 user message 字字对齐:"Based on the conversation
18
- * transcript above, has the following stopping condition been satisfied?
19
- * Answer based on transcript evidence only."
20
- * - prompt-hook-service 会自动把 ARGUMENTS JSON 追加到末尾,无需在此手拼。
21
- *
22
- * 评估窗口约束:当同一 session 在历史上设置过多个 goal 时,旧 goal 的
23
- * 成功响应仍留在 transcript 里。如果不告诉模型"评估窗口",它很容易把
24
- * 上一次的 "已完成" 错误地归到当前 goal 头上(实测 deepseek 等网关
25
- * 会立即返回 ok=true)。`createdAt` 以 ISO 8601 字符串注入,让 evaluator
26
- * 知道从哪个时刻起的对话才算数。
27
- */
28
- export declare function buildStopConditionPrompt(goal: ActiveGoal): string;
29
- /**
30
- * 生成 scope id:`goal:<sessionId>:<nonce>`。
31
- *
32
- * 加 nonce 后缀是为了让 onResult 回调的"防漂移"判断生效:用户用 `/goal`
33
- * 替换当前目标后,旧目标的 hook 评估回调如果延迟到达,能通过对比 scopeId
34
- * 识别出"我已经不是当前活跃的目标"并 silently ignore,避免对新目标做副作用。
35
- *
36
- * nonce 用 8 位 base36 随机数;同进程内冲突概率可忽略。
37
- */
38
- export declare function generateGoalScopeId(sessionId: string): string;
39
- /**
40
- * 构造 `/goal <condition>` 设置完成后立即发送给 agent 的"启动消息"。
41
- *
42
- * 这条消息会被 GoalServiceImpl.set() fire-and-forget 地通过 agentService.runDefault
43
- * 投递,让 agent 立刻开始工作;之后 Stop hook 会在 agent 每次自然停下来时
44
- * 评估目标是否达成。
45
- *
46
- * 文本与 Claude Code `/goal` 的注入 prompt 对齐——本质是一段 system-reminder
47
- * 风格的指令(而非普通 user 提问),目的是:
48
- * 1. 简短致意 + 立刻开始/继续工作,不要回头问用户做什么;
49
- * 2. 把 condition 本身当作"指令"消费;
50
- * 3. 解释 stop hook 的 block 语义(不会让你停下来);
51
- * 4. 解释 auto-clear 语义——达成后不要叫用户跑 `/goal clear`,
52
- * 那只用于"提前放弃"。
53
- */
54
- export declare function buildGoalKickoffMessage(condition: string): string;
55
- export declare const DEFAULT_GOAL_POLICY: GoalServicePolicy;
@@ -1,178 +0,0 @@
1
- /**
2
- * `/goal` 功能的对外契约。
3
- *
4
- * 与实现 (`goal-service.ts`) 解耦:业务侧只需要依赖本文件的 Symbol + interface
5
- * 即可注入并测试,不必拉到具体实现类(DI / mock 都更轻)。
6
- *
7
- * 模块组织(doctor / memory / checkpoint 同模式):
8
- * - goal-protocol.ts Symbol + interface + 数据契约 + 常量
9
- * - goal-policy.ts 纯文案 / prompt 模板 / 默认 policy
10
- * - goal-utils.ts 纯函数:parseActiveGoal / buildGoalPromptHook
11
- * - goal-service.ts `@Component(GoalService)` 唯一实现
12
- * - goal-session-start-hook.ts SessionStart 路径自动 restore
13
- */
14
- import { GoalResultItem } from '../agent/openai-agents-types';
15
- import { PromptHookDefinition, PromptHookResult } from '../hooks/hook-protocol';
16
- import { Session } from '../session/session-protocol';
17
- export declare const GoalService: unique symbol;
18
- export interface ActiveGoal {
19
- condition: string;
20
- /** scope id;唯一定位一次 set() 注册的 hook 实例。详见 GoalServicePolicy.scopeIdFor。 */
21
- scopeId: string;
22
- createdAt: number;
23
- /**
24
- * goal set 时的 session.usage.totalTokens 快照。
25
- * 终态时用 (当前 totalTokens - tokensAtStart) 计算 goal 期间的增量 token,
26
- * 与 cc 的 "Goal achieved (… · N tokens)" 语义对齐。
27
- * 缺省(旧 session resume 时)按 0 处理 → tokenDelta 退化为 totalTokens。
28
- */
29
- tokensAtStart?: number;
30
- /**
31
- * goal 期间已发生的 turn 数(kick-off + 每次 stop-hook 评估算一轮)。
32
- * 终态时随 GoalResultItem 一起持久化。
33
- * 该字段会被 GoalServiceImpl.setMeta 持久化到 session.meta,
34
- * 因此即便跨 hook 回调也能稳定累加。
35
- */
36
- turnCount?: number;
37
- /**
38
- * Web UI 暂停:卸掉 Stop hook,但保留 condition / createdAt。
39
- * 当前回合继续跑;暂停后不再自动续轮。
40
- */
41
- paused?: boolean;
42
- /** 点暂停时的墙钟,用来冻住 elapsed。 */
43
- pausedAt?: number;
44
- }
45
- export interface GoalService {
46
- /** 设定/替换当前 session 的目标。若已有目标则先注销并提示替换。 */
47
- set(session: Session, condition: string): Promise<void>;
48
- /** 清除当前目标,并注销已注册的 hook。 */
49
- clear(session: Session): Promise<void>;
50
- /**
51
- * 暂停目标:卸 Stop hook、冻计时,并打断当前回合(Web / 独立 TUI)。
52
- * 条还在,点继续才重新挂 hook。WorkBuddy --acp 不 abort,避免改 Desktop 语义。
53
- */
54
- pause(session: Session): Promise<void>;
55
- /**
56
- * 继续已暂停的目标:重新注册 hook。
57
- * 当前回合还在跑就只恢复续跑;空闲才 kick-off。
58
- */
59
- resume(session: Session): Promise<void>;
60
- /** 显示当前目标。无目标时输出引导文案。 */
61
- show(session: Session): Promise<void>;
62
- /**
63
- * 从 session.meta 中已存的 activeGoal 重新注册 hook(resume 路径)。
64
- * 幂等:若 scopeId 已经在 registry 内则跳过。
65
- */
66
- restoreFromMeta(session: Session): Promise<void>;
67
- /** 当前 session 是否有 active goal。 */
68
- has(session: Session): boolean;
69
- /** 当前 session 的 active goal(仅读 meta,不查 registry)。 */
70
- get(session: Session): ActiveGoal | undefined;
71
- /**
72
- * 取 session.history 中最近一次(按 append 顺序)的 goal-result 终态项。
73
- *
74
- * 用于无参 `/goal` 的 recap 面板:在没有 active goal 时把最后一次达成 /
75
- * 不可达的目标 surface 出来,对齐 cc `/goal` 的 banner 行为
76
- * (`✔ Goal achieved` + Goal: + stats,Esc to dismiss)。
77
- *
78
- * 实现层只读 history、不写副作用——便于 panel 直接订阅。
79
- */
80
- getLatestResult(session: Session): GoalResultItem | undefined;
81
- }
82
- /** condition 字符长度软上限(与 cc 文档对齐:4000 字符)。 */
83
- export declare const GOAL_CONDITION_MAX_CHARS = 4000;
84
- /** scopeId 前缀;所有 goal hook 的 scope 都以此打头。 */
85
- export declare const GOAL_SCOPE_PREFIX = "goal:";
86
- /** 已知的 goal metric 名(保持与 cc 字面对齐,便于跨工具检索)。 */
87
- export declare const GOAL_METRICS: {
88
- readonly SET: 'tengu_goal_set';
89
- readonly CLEARED: 'tengu_goal_cleared';
90
- readonly ACHIEVED: 'tengu_goal_achieved';
91
- readonly MET: 'goal_met';
92
- readonly FAILED: 'tengu_goal_failed';
93
- readonly RESTORED: 'tengu_goal_restored_on_resume';
94
- };
95
- export type GoalMetricName = typeof GOAL_METRICS[keyof typeof GOAL_METRICS];
96
- /** Goal metric 发送通道。生产由 service 注入实现,单测可换 spy。 */
97
- export interface GoalMetricSink {
98
- record(name: GoalMetricName, payload?: Record<string, unknown>): void;
99
- }
100
- /**
101
- * Goal 文案表。集中所有面向用户的英文 string 以便未来 i18n / 个性化。
102
- * 都是 `(args) => string` 形式,便于参数化。
103
- */
104
- export interface GoalMessages {
105
- usage(): string;
106
- tooLong(actual: number, max: number): string;
107
- hooksDisabled(): string;
108
- cleared(prev: string): string;
109
- set(condition: string): string;
110
- clearedOnly(prev: string): string;
111
- noGoal(): string;
112
- active(condition: string): string;
113
- paused(condition: string): string;
114
- resumed(condition: string): string;
115
- achieved(reason?: string): string;
116
- impossible(reason?: string): string;
117
- }
118
- /**
119
- * 可替换的策略层。集中所有可变常量与小算法,便于:
120
- * - 测试时注入 stub policy 控制行为;
121
- * - 未来切换文案 / scope 命名规则 / prompt 模板时不动 service。
122
- */
123
- export interface GoalServicePolicy {
124
- maxConditionChars: number;
125
- scopeIdFor(sessionId: string): string;
126
- /**
127
- * 构造发给 stop-condition evaluator 的 user prompt。
128
- *
129
- * @param goal 当前 active goal(含 condition、createdAt 等上下文)
130
- *
131
- * 接收整个 goal 而不仅是 condition,是为了让 prompt 能告知 evaluator
132
- * "评估窗口"——只看 goal 设置之后的对话,避免被同 session 中上一个 goal
133
- * 的成功响应误判(实测在国内 deepseek 等网关上很容易出现"刚 set 完
134
- * 立刻 achieved"的现象)。
135
- */
136
- buildStopConditionPrompt(goal: ActiveGoal): string;
137
- /**
138
- * 构造 `/goal <condition>` 设置完成后立即下发给 agent 的"启动消息"。
139
- *
140
- * 设计原因(与 Claude Code 行为对齐):
141
- * - cc 的 `/goal` 设置后会立即 kick off agent run,而我们之前的实现只
142
- * 注册了 Stop hook 等待用户下次输入触发 agent,导致表现"什么都没发生";
143
- * - 把启动文案抽到 policy,方便 i18n 与单测断言。
144
- *
145
- * 返回 falsy(''/null/undefined)表示"不要 kick off"——给业务侧(或测试)
146
- * 一个关闭自动启动的旁门。
147
- */
148
- buildKickoffMessage(condition: string): string;
149
- messages: GoalMessages;
150
- }
151
- /** Hook callback 类型别名,方便 utils 引用。 */
152
- export type GoalPromptHookCallback = NonNullable<PromptHookDefinition['onResult']>;
153
- /** 内部使用:onResult 收到的回调入参。 */
154
- export type GoalPromptHookResult = PromptHookResult;
155
- /**
156
- * `/goal` 命令各种状态文案的"事件类型"枚举。
157
- *
158
- * 后端 GoalServiceImpl 把每条状态文案 emit 到 history 时同时挂上结构化的
159
- * `providerData.goalStatus`,让 Web UI / 其它 ACP 客户端拿到**与 locale
160
- * 无关**的事件 + 字段,自己用 i18n 字典渲染本地化文案。
161
- *
162
- * 列表与 `GoalServicePolicy.messages` 一一对应,方便后续新增字段时机械同步。
163
- */
164
- export type GoalStatusKind = 'usage' | 'too-long' | 'hooks-disabled' | 'set' | 'set-replaced' | 'cleared' | 'no-goal' | 'active' | 'paused' | 'resumed';
165
- export interface GoalStatusPayload {
166
- kind: GoalStatusKind;
167
- /** set / set-replaced / active / paused / resumed 携带新条件 */
168
- condition?: string;
169
- /** set-replaced / cleared 携带被替换/被清除的旧条件 */
170
- prev?: string;
171
- /** too-long 错误诊断字段 */
172
- actual?: number;
173
- max?: number;
174
- /** set / active / paused 携带 goal.createdAt,给 Web UI 输入框 elapsed 用 */
175
- createdAt?: number;
176
- /** paused 携带冻结时刻,给 Web UI 冻 elapsed */
177
- pausedAt?: number;
178
- }
@@ -1,201 +0,0 @@
1
- /**
2
- * `/goal` 命令背后的 service 实现。
3
- *
4
- * Claude Code 官方文档定义:
5
- * > The /goal command is a built-in shortcut for a session-scoped
6
- * > prompt-based Stop hook.
7
- *
8
- * 实现思路:
9
- * - `/goal <condition>` 通过 ScopedHookRegistry 注册一个 prompt-type Stop hook,
10
- * scopeId 由 `policy.scopeIdFor(sessionId)` 生成(含 nonce 防漂移),
11
- * 并把 `condition` 与 scopeId 写入 `session.meta.activeGoal`。
12
- * - hook 评估返回 `{ok:true}` 则模型自然停止,输出 "Goal achieved",自动注销。
13
- * - 评估返回 `{ok:false}` 则 hook 返回 block + continueRequest,模型继续工作。
14
- * - 评估返回 `{ok:false, impossible:true}` 则视作"目标不可达",停止循环,
15
- * 输出 "Goal could not be achieved: <reason>",自动注销。
16
- * - 通过 PromptHookDefinition.onResult 回调订阅评估结果。
17
- *
18
- * 设计点(可维护性 / 可测试性):
19
- * - 所有契约都从 `goal-protocol` 引入,方便业务侧只依赖 Symbol + interface。
20
- * - 所有 mutable 副作用都封装在 protected 方法,便于子类化定制 / spy。
21
- * - `configure({ policy, metrics })` 注入测试替身,无需绕开 DI。
22
- * - onResult 回调先校验 `current.scopeId === goal.scopeId`,避免对早已被
23
- * 替换或清除的 goal 做副作用。
24
- */
25
- import { Logger } from '@genie/telemetry';
26
- import { AcpBroadcastService } from '../acp/acp-protocol';
27
- import { AgentService } from '../agent/agent-protocol';
28
- import { GoalResultItem } from '../agent/openai-agents-types';
29
- import { AcpDrainTrigger } from '../agent-task/agent-task-protocol';
30
- import { HookInput, PromptHookDefinition, PromptHookResult, ScopedHookRegistry } from '../hooks/hook-protocol';
31
- import { MessageQueueManager, Session, SessionManager } from '../session/session-protocol';
32
- import { ActiveGoal, GoalMetricSink, GoalService, GoalServicePolicy, GoalStatusPayload } from './goal-protocol';
33
- export declare class GoalServiceImpl implements GoalService {
34
- protected readonly logger: Logger;
35
- protected readonly scopedHookRegistry: ScopedHookRegistry;
36
- protected readonly sessionManager: SessionManager;
37
- /**
38
- * AgentService 用 @Optional() 注入:
39
- * - 单测里我们不挂 AgentService(kick-off 可被 stub 关闭);
40
- * - headless / 异常 IoC 场景下没有 AgentService 时 set() 仍然能完成
41
- * hook 注册,只是不会自动 kick off。
42
- */
43
- protected readonly agentService?: AgentService;
44
- protected readonly acpBroadcastService?: AcpBroadcastService;
45
- /**
46
- * ACP / Web UI 的 kick-off 不能直接 runDefault:slash `/goal` 的 prompt 马上
47
- * 就返回,createEventForwardingPromise 随之拆掉,后续模型事件到不了前端。
48
- * 入队后由 AcpView.drainQueuedMessages 带着转发链路消费。
49
- */
50
- protected readonly messageQueueManager?: MessageQueueManager;
51
- /**
52
- * HTTP PUT / 暂停后继续 走 GoalService 时,当前并不在 AcpView.executePrompt 里,
53
- * 只入队没有人 drain。注入 AcpDrainTrigger,把 kick-off 送进带转发的 drain。
54
- */
55
- protected readonly acpDrainTrigger?: AcpDrainTrigger;
56
- /**
57
- * 可注入的策略层。生产用 `DEFAULT_GOAL_POLICY`;测试可通过 configure() 替换。
58
- * 故意 protected 而非 private,方便子类化做小幅定制。
59
- */
60
- protected policy: GoalServicePolicy;
61
- /** 进行中的 Stop hook 对象,pause 时要就地关掉续跑。 */
62
- protected readonly goalHooks: Map<string, PromptHookDefinition>;
63
- /** 可注入的 metric 发送器;默认走 logger。 */
64
- protected metrics: GoalMetricSink;
65
- protected init(): void;
66
- /** 测试钩子:替换 policy / metrics(例:service.configure({ policy: stub })). */
67
- configure(opts: Partial<{
68
- policy: GoalServicePolicy;
69
- metrics: GoalMetricSink;
70
- }>): void;
71
- set(session: Session, condition: string): Promise<void>;
72
- clear(session: Session): Promise<void>;
73
- pause(session: Session): Promise<void>;
74
- resume(session: Session): Promise<void>;
75
- show(session: Session): Promise<void>;
76
- restoreFromMeta(session: Session): Promise<void>;
77
- has(session: Session): boolean;
78
- get(session: Session): ActiveGoal | undefined;
79
- /**
80
- * 倒序扫 session.history 找最近一条 goal-result 终态项。复杂度 O(n),
81
- * goal 终态项稀疏(一次 /goal 周期才一条),实测开销可忽略。
82
- *
83
- * 注意:history 直接持有 AgentInputItem 引用,调用方不应就地修改。
84
- * 这里 cast 为 GoalResultItem——`type === 'goal-result'` 已是判别量。
85
- */
86
- getLatestResult(session: Session): GoalResultItem | undefined;
87
- protected registerGoalHook(session: Session, goal: ActiveGoal): void;
88
- protected unregisterHook(scopeId: string): void;
89
- protected persistMeta(session: Session): Promise<void>;
90
- protected setMeta(session: Session, goal: ActiveGoal): void;
91
- protected clearMeta(session: Session): void;
92
- protected areHooksDisabled(): boolean;
93
- /**
94
- * `set()` 完成后的"启动 agent run"副作用。
95
- *
96
- * 抽成独立 protected 方法的好处:
97
- * - 单测可以 spy / stub 它,断言 set() 是否在正确时机触发;
98
- * - 未来切换为"通过 message queue 入队"或"延迟一个 tick"等策略时不动 set()。
99
- *
100
- * 实现细节:
101
- * - 走 policy 拿启动文案(i18n / 业务定制点);
102
- * - 把 kick-off 消息标记为 `providerData.isMeta=true`,与 cc 行为对齐:
103
- * 模型在 transcript 里能看到目标条件,但 UI 不渲染这条 user message
104
- * (`conversation-box.tsx` / `queue-display.tsx` / `structured-output-view-filter`
105
- * 均按 isMeta 过滤)。
106
- * - 走 @Optional 注入的 AgentService,若不可用(headless 极简栈 / 单测)
107
- * 则跳过 + warn,set() 仍然完成,hook 仍然注册;
108
- * - fire-and-forget;任何异常落 logger,不冒泡到调用方。
109
- */
110
- protected kickoffAgentRun(session: Session, condition: string): Promise<void>;
111
- /**
112
- * `/goal` slash 自己的 skipRun 窗口。AgentService.run() 先 RUN_PREPARING
113
- * 再进命令拦截器,这时 abort 会掐掉正在执行的这次 slash,随后 triggerDrain
114
- * 被 aborted 守卫丢掉——Web UI 手打 `/goal` 换条件会自伤。
115
- */
116
- private static readonly SLASH_OWNED_STATUSES;
117
- /**
118
- * Web UI 与独立 TUI 暂停要打断当前回合。WorkBuddy `--acp`(有 acp、无 webUiAcp)
119
- * 保持旧语义,只卸 hook。
120
- */
121
- protected shouldAbortOnPause(session: Session): boolean;
122
- protected isRunInFlight(session: Session): boolean;
123
- protected abortInFlightRun(session: Session): void;
124
- protected ensureAbortControllerReady(session: Session): void;
125
- protected replaceAbortController(session: Session): void;
126
- /**
127
- * 读取 session.usage.totalTokens 作为统计起点 / 终点。
128
- * - usage 字段在 fresh session 上是 Usage 实例(含 totalTokens 数值)。
129
- * - 单测 / 老 session 上 usage 可能不存在,按 0 处理避免 NaN。
130
- */
131
- protected readSessionTokens(session: Session): number;
132
- /**
133
- * 给当前 active goal 累加 turn 计数并持久化到 session.meta。
134
- * 防漂移:找不到 goal(已被替换 / 清除)时静默忽略。
135
- */
136
- protected bumpTurnCount(session: Session, delta: number): void;
137
- /**
138
- * 把 stdout 文本以 local-command-stdout 形式写入 session.history。
139
- *
140
- * `status` 参数可选:当 emit 的是 /goal 状态文案(set / cleared / active 等)
141
- * 时,调用方传入结构化 GoalStatusPayload。该 payload 会写到
142
- * `providerData.goalStatus`,让 ACP 转换层把它转成 `session_info_update +
143
- * _meta` 推 Web UI 用 i18n 渲染(Web UI 不依赖英文文本格式);TUI 仍按
144
- * stdout 原样渲染英文文案,与 cc parity 保持一致。
145
- */
146
- protected emit(session: Session, text: string, status?: GoalStatusPayload): Promise<void>;
147
- /**
148
- * Prompt hook 的 onResult 回调。
149
- * 注意:hook-manager 已经处理了 block / continueRequest 逻辑;这里只负责
150
- * - 在 ok:true(达成)和 impossible(不可达)两种「终态」时清理 hook + UI 提示
151
- * - ok:false(条件还没满足)维持现状,模型仍被 block 着工作
152
- *
153
- * 防御性:回调可能在用户已经手动 `/goal clear` 或替换为新 goal 之后才异步
154
- * 触发,这种情况下不应对当前 session.meta 做副作用。
155
- */
156
- protected handleHookResult(session: Session, goal: ActiveGoal, result: PromptHookResult, _input: HookInput): Promise<void>;
157
- /**
158
- * 把 stop-hook evaluator 的 reason 反馈给模型(cc parity)。
159
- *
160
- * 设计要点:
161
- * - 只在 reason 非空时 emit——空 reason 喂给模型只是噪声;
162
- * - 文本格式与 cc jsonl 严格对齐:"Stop hook feedback: [<condition>]: <reason>"
163
- * 这样模型在 transcript 里看到的格式是它训练时见过的稳定模式;
164
- * - providerData.isMeta=true 让 UI 过滤(避免用户看到内部反馈条),
165
- * 同时也能被 SystemReminderAgentRunInterceptor 等识别为非真实用户输入。
166
- * - 不参与对话链(无 parentId):这是个旁路注入,不影响树结构。
167
- */
168
- protected emitFeedbackToModel(session: Session, _goal: ActiveGoal, reason?: string): Promise<void>;
169
- /**
170
- * 把 goal 变更推给 Web UI。slash 路径还有 combineSubject,HTTP API / idle 连接只靠这里。
171
- */
172
- protected notifyAcpClients(session: Session, item?: {
173
- type?: string;
174
- providerData?: unknown;
175
- }, busy?: boolean): Promise<void>;
176
- /**
177
- * 把 goal 终态结果以 `goal-result` history item 形式写入 session.history。
178
- * 由 chat-view 的 GoalResultMessageBox 渲染为可折叠状态条(对齐 cc UI)。
179
- *
180
- * 字段语义:
181
- * - durationMs:goal.createdAt 起到现在的耗时
182
- * - turnCount:至少 1(防御 0 turn 异常 case,UI 不显示 "0 turns")
183
- * - tokenDelta:(当前 totalTokens - tokensAtStart),下界 0
184
- */
185
- protected emitGoalResult(session: Session, goal: ActiveGoal, outcome: {
186
- ok: boolean;
187
- reason?: string;
188
- }): Promise<void>;
189
- /**
190
- * 把 goal 进行中状态以 `goal-progress` history item 形式写入 session.history。
191
- * 由 chat-view 的 GoalProgressMessageBox 渲染为 cc 同款可折叠状态条
192
- * `◯ Goal not yet met… continuing`。
193
- *
194
- * 触发时机:每次 stop-condition hook 评估返回 ok:false(非 impossible),
195
- * 表示模型还要继续工作。reason 来自 evaluator 的判定理由,仅在用户
196
- * Ctrl+O 展开时才显示,避免污染对话流。
197
- *
198
- * 不参与对话链,也不喂给 LLM —— 由 CUSTOM_INPUT_ITEM_TYPES 兜底过滤。
199
- */
200
- protected emitGoalProgress(session: Session, goal: ActiveGoal, reason?: string): Promise<void>;
201
- }
@@ -1,24 +0,0 @@
1
- /**
2
- * SessionStart hook:在 session 恢复(`source === 'resume'` / `'compact'`)
3
- * 时,根据 `session.meta.activeGoal` 重新注册 prompt-type Stop hook。
4
- *
5
- * 走 internal Hook 路径而非命令拦截器,是因为:
6
- * 1. SESSION_START 事件已经是 hooks 系统的标准入口;不必为 /goal 专门接
7
- * session-manager 生命周期。
8
- * 2. Hook 自带 priority + source 匹配,与 `StructuredOutputSessionStartHook`
9
- * 模式一致,新增/移除都是局部改动,可维护。
10
- * 3. 单测时只需 mock GoalService,断言 restoreFromMeta 是否被调用。
11
- *
12
- * 不抛错 / 不阻塞:恢复失败不应阻断 session 启动,只记录 warn。
13
- */
14
- import { Logger } from '@genie/telemetry';
15
- import { Hook, HookEvent, HookExecutionResult, HookInput, HookPriority } from '../hooks/hook-protocol';
16
- import { GoalService } from './goal-protocol';
17
- export declare class GoalSessionStartHook implements Hook {
18
- readonly event = HookEvent.SESSION_START;
19
- readonly priority = HookPriority.Normal;
20
- protected readonly logger: Logger;
21
- protected readonly goalService: GoalService;
22
- protected init(): void;
23
- execute(input: HookInput): Promise<HookExecutionResult | undefined>;
24
- }
@@ -1,42 +0,0 @@
1
- /**
2
- * Frontmatter hooks 解析
3
- *
4
- * 公共解析函数,用于从 agent `.md` / skill SKILL.md 的 frontmatter.hooks
5
- * 字段解析出 HookSettings。
6
- *
7
- * 对齐 Claude Code 行为:
8
- * - `~/workspace/claude-code-source/src/tools/AgentTool/loadAgentsDir.ts:424`
9
- * - `~/workspace/claude-code-source/src/skills/loadSkillsDir.ts:136`
10
- *
11
- * CC 两侧同名 `parseHooksFromFrontmatter` 是 copy-paste 关系,cbc 抽公共函数
12
- * 避免后续维护时漂移(FEEDBACK_DUPLICATE_NORMALIZE_PARSERS_SYNC 的典型反例)。
13
- */
14
- import type { Logger } from '@genie/telemetry';
15
- import { HookConfig, HookEvent } from './hook-protocol';
16
- /**
17
- * settings.json / frontmatter 中 hooks 字段的通用结构:
18
- * ```
19
- * hooks:
20
- * PreToolUse:
21
- * - matcher: "Bash"
22
- * hooks:
23
- * - type: command
24
- * command: ./check.sh
25
- * once: true
26
- * ```
27
- */
28
- export type HookSettings = Partial<Record<HookEvent | string, HookConfig[]>>;
29
- /**
30
- * 解析 frontmatter.hooks 字段为 HookSettings。
31
- *
32
- * - `raw` 是 undefined / 非对象 → 返回 undefined(不报错,视为未配置)
33
- * - 单个 event 的 HookConfig[] 不符合 schema → logger.warn 跳过该 event,
34
- * 其他 event 正常解析(最大努力原则)
35
- * - 未知的 event key → logger.warn 跳过
36
- * - 所有 event 都解析失败 → 返回 undefined
37
- *
38
- * @param raw 原始 frontmatter.hooks 值
39
- * @param sourceLabel 用于日志的来源标签,如 "agent 'code-reviewer'"
40
- * @param logger telemetry logger
41
- */
42
- export declare function parseFrontmatterHooks(raw: unknown, sourceLabel: string, logger: Logger): HookSettings | undefined;
@@ -1,6 +0,0 @@
1
- export * from './install-controller';
2
- export * from './install-env';
3
- export * from './install-protocol';
4
- export * from './install-service';
5
- export * from './releases-service';
6
- export * from './shell-setup';
@@ -1,15 +0,0 @@
1
- import { Logger } from '@celljs/core';
2
- import { ConsoleManager } from '../console';
3
- import type { InstallOptions, InstallResult } from './install-protocol';
4
- import { InstallService } from './install-protocol';
5
- export declare class InstallController {
6
- protected readonly logger: Logger;
7
- protected readonly installer: InstallService;
8
- protected readonly consoleManager: ConsoleManager;
9
- install(options: InstallOptions): Promise<InstallResult>;
10
- private displayResult;
11
- private displaySuccess;
12
- private displayPathInstructions;
13
- private displayProgress;
14
- private displayError;
15
- }
@@ -1,12 +0,0 @@
1
- import { homedir, platform } from 'node:os';
2
- import { FileSystem } from '@genie/runtime';
3
- import { InstallEnvironment } from './install-protocol';
4
- export declare class InstallEnvironmentImpl implements InstallEnvironment {
5
- readonly fs: FileSystem;
6
- platform: typeof platform;
7
- arch: () => NodeJS.Architecture;
8
- homedir: typeof homedir;
9
- versiondir(app: string): string;
10
- bindir(app: string): string;
11
- findCmd(cmd: string): Promise<string | undefined>;
12
- }