@tencent-ai/agent-harness 0.2.0-beta.1 → 0.2.0-beta.3

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 (226) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +1 -1
  3. package/cli/CHANGELOG.md +135 -0
  4. package/cli/dist-server/shared.cjs +455 -387
  5. package/cli/dist-server/types/node/acp/acp-protocol.d.ts +40 -12
  6. package/cli/dist-server/types/node/acp/usage-by-category-calculator.d.ts +21 -0
  7. package/cli/dist-server/types/node/bash-sandbox/bash-sandbox-protocol.d.ts +3 -0
  8. package/cli/dist-server/types/node/cli/cli-protocol.d.ts +3 -0
  9. package/cli/dist-server/types/node/cli/stream-json-protocol.d.ts +23 -2
  10. package/cli/dist-server/types/node/data-fs/index.d.ts +13 -1
  11. package/cli/dist-server/types/node/hooks/hook-protocol.d.ts +2 -2
  12. package/cli/dist-server/types/node/sensitive-content/sensitive-content-protocol.d.ts +7 -0
  13. package/cli/dist-server/types/node/server/boot.d.ts +7 -4
  14. package/{lib/components → cli/dist-server/types/node/server/formats}/acp/acp-error-model.d.ts +1 -1
  15. package/{lib/components → cli/dist-server/types/node/server/formats}/acp/acp-protocol.d.ts +2 -3
  16. package/cli/dist-server/types/node/server/formats/acp/index.d.ts +12 -0
  17. package/cli/dist-server/types/node/server/formats/acp/projection.d.ts +10 -0
  18. package/cli/dist-server/types/node/server/index.d.ts +1 -1
  19. package/cli/dist-server/types/node/server/sessions.d.ts +27 -2
  20. package/cli/dist-server/types/node/server/types.d.ts +65 -7
  21. package/cli/dist-server/types/node/settings/settings-protocol.d.ts +5 -0
  22. package/cli/dist-server/types/node/tools/tool-protocol.d.ts +128 -4
  23. package/cli/dist-server/types/vendor/cbc-core/node/agent/agent-protocol.d.ts +60 -2
  24. package/cli/dist-server/types/vendor/cbc-core/node/agent/agent-purpose-protocol.d.ts +8 -4
  25. package/cli/dist-server/types/vendor/cbc-core/node/agent/agent-purpose-scope.d.ts +46 -0
  26. package/cli/dist-server/types/vendor/cbc-core/node/agent/agent-service.d.ts +28 -3
  27. package/cli/dist-server/types/vendor/cbc-core/node/agent/index.d.ts +4 -0
  28. package/cli/dist-server/types/vendor/cbc-core/node/agent/interceptors/input-interceptors.d.ts +1 -6
  29. package/cli/dist-server/types/vendor/cbc-core/node/agent/model-call-failure.d.ts +9 -0
  30. package/cli/dist-server/types/vendor/cbc-core/node/agent/model-step-sequence.d.ts +11 -0
  31. package/cli/dist-server/types/vendor/cbc-core/node/agent/runner-factory.d.ts +56 -20
  32. package/cli/dist-server/types/vendor/cbc-core/node/agent/speaker-label.d.ts +44 -0
  33. package/cli/dist-server/types/vendor/cbc-core/node/agent/tool-call-loop-detector-service.d.ts +5 -4
  34. package/cli/dist-server/types/vendor/cbc-core/node/agent/tool-call-loop-guard-protocol.d.ts +1 -1
  35. package/cli/dist-server/types/vendor/cbc-core/node/agent/tool-call-loop-pattern.d.ts +16 -4
  36. package/cli/dist-server/types/vendor/cbc-core/node/context/compaction-lineage.d.ts +39 -0
  37. package/cli/dist-server/types/vendor/cbc-core/node/context/context-compact-summarizer.d.ts +2 -0
  38. package/cli/dist-server/types/vendor/cbc-core/node/context/context-protocol.d.ts +17 -0
  39. package/cli/dist-server/types/vendor/cbc-core/node/context/index.d.ts +1 -0
  40. package/cli/dist-server/types/vendor/cbc-core/node/context/pre-message-compact-strategy.d.ts +1 -2
  41. package/cli/dist-server/types/vendor/cbc-core/node/hooks/agent-trigger.d.ts +6 -22
  42. package/cli/dist-server/types/vendor/cbc-core/node/hooks/hook-protocol.d.ts +4 -1
  43. package/cli/dist-server/types/vendor/cbc-core/node/session/idle-queue-drain-service.d.ts +4 -56
  44. package/cli/dist-server/types/vendor/cbc-core/node/session/index.d.ts +4 -0
  45. package/cli/dist-server/types/vendor/cbc-core/node/session/interruption-service.d.ts +63 -9
  46. package/cli/dist-server/types/vendor/cbc-core/node/session/model-request-retry-phase.d.ts +16 -0
  47. package/cli/dist-server/types/vendor/cbc-core/node/session/model-response-interceptors.d.ts +33 -0
  48. package/cli/dist-server/types/vendor/cbc-core/node/session/recovery-budget.d.ts +55 -0
  49. package/cli/dist-server/types/vendor/cbc-core/node/session/session-hook-manager.d.ts +15 -0
  50. package/cli/dist-server/types/vendor/cbc-core/node/session/session-manager-host-protocol.d.ts +3 -2
  51. package/cli/dist-server/types/vendor/cbc-core/node/session/session-manager.d.ts +17 -4
  52. package/cli/dist-server/types/vendor/cbc-core/node/session/session-persistence-error.d.ts +43 -0
  53. package/cli/dist-server/types/vendor/cbc-core/node/session/session-protocol.d.ts +110 -9
  54. package/cli/dist-server/types/vendor/cbc-core/node/session/session-run-state-machine-protocol.d.ts +15 -1
  55. package/cli/dist-server/types/vendor/cbc-core/node/session/session-runtime-lifecycle.d.ts +5 -0
  56. package/cli/dist-server/types/vendor/cbc-core/node/session/session-store.d.ts +150 -4
  57. package/cli/dist-server/types/vendor/cbc-core/node/session/stream-timeout-retry-budget.d.ts +20 -1
  58. package/cli/dist-server/types/vendor/cbc-core/node/trace/turn-context.d.ts +28 -1
  59. package/cli/dist-server/types/vendor/cbc-core/node/utils/command-message-utils.d.ts +20 -0
  60. package/cli/dist-server/types/vendor/cbc-core/node/utils/history-utils.d.ts +27 -4
  61. package/cli/dist-server/types/vendor/cbc-core/node/utils/index.d.ts +1 -0
  62. package/cli/dist-server/types/vendor/cbc-core/node/utils/input-item-utils.d.ts +8 -0
  63. package/cli/dist-server/types/vendor/cbc-core/node/utils/message-utils.d.ts +12 -0
  64. package/cli/dist-server/types/vendor/cbc-core/node/utils/model-utils.d.ts +7 -0
  65. package/cli/dist-server/types/vendor/cbc-core/node/utils/queue-dispatch-utils.d.ts +24 -2
  66. package/cli/dist-server/types/vendor/cbc-core/node/utils/session-utils.d.ts +4 -1
  67. package/cli/dist-server/types/vendor/cbc-core/node/utils/string-retention-utils.d.ts +4 -0
  68. package/cli/dist-server/types/vendor/cbc-core/node/utils/token-utils.d.ts +3 -1
  69. package/cli/dist-server/types/vendor/cbc-shared/node/agent/openai-agents-types.d.ts +1 -0
  70. package/cli/dist-server/types/vendor/cbc-shared/node/checkpoint/checkpoint-types.d.ts +6 -0
  71. package/cli/dist-server/types/vendor/cbc-shared/node/hooks/hook-types.d.ts +7 -1
  72. package/cli/dist-server/types/vendor/cbc-shared/node/index.d.ts +2 -0
  73. package/cli/dist-server/types/vendor/cbc-shared/node/model/model-errors.d.ts +36 -4
  74. package/cli/dist-server/types/vendor/cbc-shared/node/tools/tool-names.d.ts +1 -0
  75. package/cli/dist-server/types/vendor/cbc-shared/node/utils/retry-backoff.d.ts +30 -0
  76. package/cli/dist-server/types/vendor/cbc-shared/node/utils/retry-policy.d.ts +26 -0
  77. package/cli/dist-server/types/workspace/agent-client-protocol/lib/common/index.d.ts +1 -0
  78. package/cli/dist-server/types/workspace/agent-client-protocol/lib/common/sandbox-rule-context.d.ts +38 -0
  79. package/cli/dist-server/types/workspace/authentication/lib/common/account-scoped-external-link-authentication-provider.d.ts +5 -5
  80. package/cli/dist-server/types/workspace/authentication/lib/common/account-utils.d.ts +25 -0
  81. package/cli/dist-server/types/workspace/authentication/lib/common/authentication-manager.d.ts +8 -2
  82. package/cli/dist-server/types/workspace/authentication/lib/common/authentication-observation.d.ts +36 -0
  83. package/cli/dist-server/types/workspace/authentication/lib/common/authentication-protocol.d.ts +40 -2
  84. package/cli/dist-server/types/workspace/authentication/lib/common/external-link-authentication-provider.d.ts +21 -5
  85. package/cli/dist-server/types/workspace/authentication/lib/common/index.d.ts +1 -0
  86. package/cli/dist-server/types/workspace/authentication/lib/common/wx-authentication-provider.d.ts +2 -2
  87. package/cli/dist-server/types/workspace/cbc-checkpoint/lib/node/checkpoint/checkpoint-protocol.d.ts +2 -0
  88. package/cli/dist-server/types/workspace/cbc-checkpoint/lib/node/checkpoint/checkpoint-service.d.ts +1 -0
  89. package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/agent-protocol.d.ts +60 -2
  90. package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/agent-purpose-protocol.d.ts +8 -4
  91. package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/agent-purpose-scope.d.ts +46 -0
  92. package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/agent-service.d.ts +28 -3
  93. package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/index.d.ts +4 -0
  94. package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/interceptors/input-interceptors.d.ts +1 -6
  95. package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/model-call-failure.d.ts +9 -0
  96. package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/model-step-sequence.d.ts +11 -0
  97. package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/runner-factory.d.ts +56 -20
  98. package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/speaker-label.d.ts +44 -0
  99. package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/tool-call-loop-detector-service.d.ts +5 -4
  100. package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/tool-call-loop-guard-protocol.d.ts +1 -1
  101. package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/tool-call-loop-pattern.d.ts +16 -4
  102. package/cli/dist-server/types/workspace/cbc-core/lib/node/context/compaction-lineage.d.ts +39 -0
  103. package/cli/dist-server/types/workspace/cbc-core/lib/node/context/context-compact-summarizer.d.ts +2 -0
  104. package/cli/dist-server/types/workspace/cbc-core/lib/node/context/context-protocol.d.ts +17 -0
  105. package/cli/dist-server/types/workspace/cbc-core/lib/node/context/index.d.ts +1 -0
  106. package/cli/dist-server/types/workspace/cbc-core/lib/node/context/pre-message-compact-strategy.d.ts +1 -2
  107. package/cli/dist-server/types/workspace/cbc-core/lib/node/hooks/agent-trigger.d.ts +6 -22
  108. package/cli/dist-server/types/workspace/cbc-core/lib/node/hooks/hook-protocol.d.ts +4 -1
  109. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/idle-queue-drain-service.d.ts +4 -56
  110. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/index.d.ts +4 -0
  111. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/interruption-service.d.ts +63 -9
  112. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/model-request-retry-phase.d.ts +16 -0
  113. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/model-response-interceptors.d.ts +33 -0
  114. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/recovery-budget.d.ts +55 -0
  115. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-hook-manager.d.ts +15 -0
  116. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-manager-host-protocol.d.ts +3 -2
  117. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-manager.d.ts +17 -4
  118. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-persistence-error.d.ts +43 -0
  119. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-protocol.d.ts +110 -9
  120. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-run-state-machine-protocol.d.ts +15 -1
  121. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-runtime-lifecycle.d.ts +5 -0
  122. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-store.d.ts +150 -4
  123. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/stream-timeout-retry-budget.d.ts +20 -1
  124. package/cli/dist-server/types/workspace/cbc-core/lib/node/trace/turn-context.d.ts +28 -1
  125. package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/command-message-utils.d.ts +20 -0
  126. package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/history-utils.d.ts +27 -4
  127. package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/index.d.ts +1 -0
  128. package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/input-item-utils.d.ts +8 -0
  129. package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/message-utils.d.ts +12 -0
  130. package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/model-utils.d.ts +7 -0
  131. package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/queue-dispatch-utils.d.ts +24 -2
  132. package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/session-utils.d.ts +4 -1
  133. package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/string-retention-utils.d.ts +4 -0
  134. package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/token-utils.d.ts +3 -1
  135. package/cli/dist-server/types/workspace/cbc-shared/lib/node/agent/openai-agents-types.d.ts +1 -0
  136. package/cli/dist-server/types/workspace/cbc-shared/lib/node/checkpoint/checkpoint-types.d.ts +6 -0
  137. package/cli/dist-server/types/workspace/cbc-shared/lib/node/hooks/hook-types.d.ts +7 -1
  138. package/cli/dist-server/types/workspace/cbc-shared/lib/node/index.d.ts +2 -0
  139. package/cli/dist-server/types/workspace/cbc-shared/lib/node/model/model-errors.d.ts +36 -4
  140. package/cli/dist-server/types/workspace/cbc-shared/lib/node/tools/tool-names.d.ts +1 -0
  141. package/cli/dist-server/types/workspace/cbc-shared/lib/node/utils/retry-backoff.d.ts +30 -0
  142. package/cli/dist-server/types/workspace/cbc-shared/lib/node/utils/retry-policy.d.ts +26 -0
  143. package/cli/dist-server/types/workspace/cbc-workflow/lib/node/workflow/workflow-execution.d.ts +14 -1
  144. package/cli/dist-server/types/workspace/cbc-workflow/lib/node/workflow/workflow-manager.d.ts +7 -0
  145. package/cli/dist-server/types/workspace/cbc-worktree/lib/node/worktree/worktree-service.d.ts +5 -0
  146. package/cli/dist-server/types/workspace/cbc-worktree/lib/node/worktree/worktree-session.d.ts +3 -0
  147. package/cli/dist-server/types/workspace/core/lib/common/protocol.d.ts +8 -1
  148. package/cli/dist-server/types/workspace/product/lib/common/cloud-product-provider.d.ts +9 -0
  149. package/cli/dist-server/types/workspace/product/lib/common/index.d.ts +2 -0
  150. package/cli/dist-server/types/workspace/product/lib/common/pick-market-skill-id.d.ts +13 -0
  151. package/cli/dist-server/types/workspace/product/lib/common/tencent-docs-endpoint.d.ts +37 -0
  152. package/cli/dist-server/types/workspace/product/lib/common/tool-control-catalog.d.ts +2 -2
  153. package/cli/dist-server/types/workspace/product/lib/common/types/config.d.ts +12 -0
  154. package/cli/dist-server/types/workspace/product/lib/common/types/features.d.ts +63 -11
  155. package/cli/dist-server/types/workspace/product/lib/common/types/language-model.d.ts +66 -0
  156. package/cli/dist-server/types/workspace/product/lib/common/types/product.d.ts +22 -1
  157. package/cli/dist-server/types/workspace/sandbox-cli/lib/common/backup-policy.d.ts +10 -1
  158. package/cli/dist-server/types/workspace/sandbox-cli/lib/common/center-protocol.generated.d.ts +375 -4
  159. package/cli/dist-server/types/workspace/sandbox-cli/lib/common/file-policy.d.ts +5 -2
  160. package/cli/dist-server/types/workspace/sandbox-cli/lib/common/http-policy.d.ts +20 -0
  161. package/cli/dist-server/types/workspace/sandbox-cli/lib/common/rule-config.d.ts +10 -0
  162. package/cli/dist-server/types/workspace/sandbox-cli/lib/node/sandbox-center-client.d.ts +219 -0
  163. package/cli/dist-server/types/workspace/telemetry/lib/common/event/types/craft.d.ts +43 -3
  164. package/cli/package.json +1 -1
  165. package/cli/product.cloudhosted.json +4 -4
  166. package/cli/product.internal.json +268 -45
  167. package/cli/product.ioa.json +354 -161
  168. package/cli/product.json +338 -352
  169. package/cli/product.selfhosted.json +2 -2
  170. package/cli/vendor/shim/brokered-bin/7z +675 -0
  171. package/cli/vendor/shim/brokered-bin/7za +675 -0
  172. package/cli/vendor/shim/brokered-bin/7zz +675 -0
  173. package/cli/vendor/shim/brokered-bin/rar +675 -0
  174. package/cli/vendor/shim/brokered-bin/tar +675 -0
  175. package/cli/vendor/shim/brokered-bin/zip +187 -0
  176. package/docs/README.md +1 -0
  177. package/docs/in-process.md +42 -2
  178. package/docs/protocol.md +7 -1
  179. package/docs/server.md +2 -0
  180. package/lib/agent/v2.js +1 -1
  181. package/lib/application/services.d.ts +3 -1
  182. package/lib/application/services.js +1 -1
  183. package/lib/client/client.js +1 -1
  184. package/lib/client/mcp.d.ts +1 -1
  185. package/lib/client/mcp.js +1 -1
  186. package/lib/components/acp-mcp-transport.d.mts +84 -1
  187. package/lib/components/question-elicitation.d.mts +20 -1
  188. package/lib/components/sandbox-center.d.mts +2 -0
  189. package/lib/components/sandbox-center.mjs +1 -0
  190. package/lib/components/{acp/acp-prompt-input.d.ts → session/prompt-input.d.ts} +1 -1
  191. package/lib/components/session-config.d.mts +2 -0
  192. package/lib/components/session-config.mjs +1 -1
  193. package/lib/components/session-replay.d.mts +6 -7
  194. package/lib/components/session-replay.mjs +1 -1
  195. package/lib/effect-runtime/mcp-lifecycle.mjs +1 -1
  196. package/lib/harness/create-harness.js +1 -1
  197. package/lib/harness/runtime.js +1 -1
  198. package/lib/harness/types.d.ts +3 -0
  199. package/lib/integration/agent-integration.d.ts +5 -0
  200. package/lib/integration/executor-supervisor.js +1 -1
  201. package/lib/public.d.ts +1 -0
  202. package/lib/runtime/private-runtime-role.js +1 -1
  203. package/lib/runtime/sandbox-center.d.ts +21 -0
  204. package/lib/runtime/sandbox-center.js +1 -0
  205. package/lib/server/public.d.ts +1 -0
  206. package/lib/session/agent-backend.d.ts +5 -0
  207. package/lib/session/agent-backend.js +1 -1
  208. package/lib/session/config-defaults.d.ts +4 -0
  209. package/lib/session/config-defaults.js +1 -0
  210. package/lib/session/config-store.d.ts +1 -1
  211. package/lib/session/config-store.js +1 -1
  212. package/lib/session/local-fs.js +1 -1
  213. package/lib/session/replay.d.ts +2 -2
  214. package/lib/session/replay.js +1 -1
  215. package/lib/session/server-config.d.ts +11 -2
  216. package/lib/session/server-config.js +1 -1
  217. package/lib/session/server-events.d.ts +10 -8
  218. package/lib/session/server-events.js +1 -1
  219. package/lib/session/server-interactions.js +1 -1
  220. package/lib/session/server-mcp.js +1 -1
  221. package/package.json +27 -16
  222. package/lib/components/acp/acp-client-channel.d.ts +0 -36
  223. package/lib/components/acp/acp-mcp-transport.d.ts +0 -84
  224. package/lib/components/acp/acp-question-elicitation.d.ts +0 -20
  225. package/lib/session/local-options.d.ts +0 -50
  226. package/lib/session/local-options.js +0 -1
@@ -3,13 +3,12 @@ import type { Agent, AgentSideConnection, AuthenticateRequest, AuthenticateRespo
3
3
  import type { Deferred } from '@celljs/core';
4
4
  import type { ModelInfo, SetSessionModelRequest, SetSessionModelResponse } from '../../workspace/agent-client-protocol/lib/common/index.js';
5
5
  import type { CheckpointBroadcastEvent, CheckpointBroadcastInfo } from '../../workspace/cbc-checkpoint/lib/node/index.js';
6
+ import type { Session } from '../../vendor/cbc-core/node/index.js';
7
+ import type { PermissionMode, RunToolApprovalItem } from '../../vendor/cbc-shared/node/index.js';
6
8
  import type { W3CTraceContextMeta } from '../../workspace/telemetry/lib/common/index.js';
7
9
  import type { Subject } from 'rxjs';
8
- import type { RunToolApprovalItem } from '../../vendor/cbc-shared/node/index.js';
9
10
  import type { CommonRequest } from '../loopback/server-protocol';
10
11
  import type { McpFirstRunStatusEvent } from '../mcp/mcp-first-run-status-protocol';
11
- import type { Session } from '../../vendor/cbc-core/node/index.js';
12
- import type { PermissionMode } from '../../vendor/cbc-shared/node/index.js';
13
12
  export * from './acp-kernel-protocol';
14
13
  /**
15
14
  * 上下文消耗 5 类目细拆 schema。
@@ -409,9 +408,26 @@ export interface AcpBroadcastService {
409
408
  * scopeId / createdAt 等实现细节给前端。
410
409
  */
411
410
  export interface GoalRecapPayload {
411
+ /**
412
+ * 本次 recap 的生成时间:宿主用它区分「新一次查询」与「同一条重复下发」
413
+ * (关掉后同一次不再弹;再问一次 /goal 会拿到新的 at,应该重新弹)。
414
+ */
415
+ at?: number;
416
+ /**
417
+ * 进行中目标的状态:除条件 / 暂停态外,带上无参 /goal 要展示的详细项
418
+ * (运行时长 / 评估 turn 数 / Token 消耗 / 最近一次评估原因)。
419
+ */
412
420
  active?: {
413
421
  condition: string;
414
422
  paused?: boolean;
423
+ /** 已运行时长(暂停态冻在 pausedAt)。 */
424
+ durationMs?: number;
425
+ /** 已评估轮次(Stop hook 评估次数)。 */
426
+ turnCount?: number;
427
+ /** 目标期间累计消耗的 token(当前会话用量 - 目标起点用量)。 */
428
+ tokenDelta?: number;
429
+ /** 最近一次 Stop hook 的评估原因(goal-progress 项的 reason)。 */
430
+ reason?: string;
415
431
  };
416
432
  latest?: {
417
433
  ok: boolean;
@@ -764,6 +780,17 @@ export declare const ACP_CANCEL_REASON_TOOL_CALL_LOOP_STOPPED: "tool_call_loop_s
764
780
  /** `codebuddy.ai/interceptType` 取值:疑似工具调用循环,请用户决定继续还是停止。 */
765
781
  export declare const TOOL_CALL_LOOP_INTERCEPT_TYPE: "tool-call-loop";
766
782
  export declare const ACP_META_SENSITIVE_INPUT_DECISION: "codebuddy.ai/sensitiveInputDecision";
783
+ /**
784
+ * `_codebuddy.ai/goalControl` 扩展方法名(宿主目标控制通道)。
785
+ *
786
+ * 必须与 workbuddy-core 的 `ConversationAcpMethod.GoalControl` 完全一致。
787
+ *
788
+ * 常量放在协议面而不是 acp-goal-control(控制实现)里:acp-stream-manager 只需要这个
789
+ * 字符串来判定 unary JSON 交付,若从实现文件取,冷启动链就会静态挂上整个控制实现
790
+ * (GoalService / broadcast / SDK 面),实现里任何新 import 都会静默落到 standby
791
+ * 冷启动路径上 —— bundle-lite-wb-prewarm-memory 卡点就是这么被顶穿的。
792
+ */
793
+ export declare const GOAL_CONTROL_METHOD: "_codebuddy.ai/goalControl";
767
794
  /**
768
795
  * Cancel 事件
769
796
  * 用于 AcpAgent 向 AcpView 传递取消指令
@@ -947,22 +974,23 @@ export interface AcpAgentManager {
947
974
  * 事件触发,**会被 250ms 节流合并**,避免高频累加 usage 时刷屏。
948
975
  * - 其它来源全部**立即推送**(绕过节流):
949
976
  * - `'new_session'` / `'load_session'` / `'resume_session'`:首发,让客户端在第一帧就拿到 0% / 模型 size
977
+ * - `'prompt_start'`:prompt 刚开始、模型思考/写文件尚未返回真实 usage 的窗口,用本地估算
978
+ * 的输入 token 推一帧占位(used 估算 + byCategory),避免上下文环空白;随后由 stream/prompt_end 校准
950
979
  * - `'prompt_end'`:prompt 出口(无论 stopReason),保证终值正确
980
+ * - `'compacted'`:压缩(自动/手动)完成后立即推一帧(used = 压缩后 history 估算),环即刻降到新值
981
+ * 而非等下一轮 prompt;publisher 同时重置 turn 高水位,使这次真实下降不被单调约束挡住
951
982
  * - `'model_changed'`:分母切换
952
983
  * - `'cancel'`:用户取消快照
953
984
  *
954
- * compact 完成不再触发 `usage_update`;上下文环数值由用户下一次 prompt 走
955
- * `combineSubject(input)` 节流路径自然回填真实 inputTokens。
956
- *
957
985
  * usageByCategory 触发拍:
958
- * - `ACP_USAGE_CATEGORY_SNAPSHOT_SOURCES` 中的路径在推送时附带
986
+ * - `ACP_USAGE_CATEGORY_SNAPSHOT_SOURCES` 中的路径走**全量**计算并附带
959
987
  * `_meta['codebuddy.ai/usageByCategory']`,sum(usageByCategory) 严格 === update.used。
960
- * - `'stream'` / `'model_changed'` 路径**不写**该字段,客户端复用上一次缓存值;
961
- * model_changed 只同步新的 context size,避免派生统计重跑动态 agent instructions
962
- * 并阻塞 set_model 控制 RPC。下一次 prompt_end 会刷新 category。
988
+ * - `'stream'` 路径走**turn 级增量**(见 usage-by-category-incremental),同样附带 usageByCategory,
989
+ * 让「对话进行中」也能实时展示 5 类明细,且不重跑动态 agent instructions(规避控制面阻塞)。
990
+ * - `'model_changed'` 路径**不写**该字段(只同步 context size),客户端复用上次缓存,下次 prompt_end 全量校准。
963
991
  * - calculator 计算异常时 publisher 也不写该字段(降级),不影响 used/size/cost 推送。
964
992
  */
965
- export type AcpUsageUpdateSource = 'new_session' | 'load_session' | 'resume_session' | 'prompt_end' | 'model_changed' | 'cancel' | 'stream';
993
+ export type AcpUsageUpdateSource = 'new_session' | 'load_session' | 'resume_session' | 'prompt_start' | 'prompt_end' | 'compacted' | 'model_changed' | 'cancel' | 'stream';
966
994
  /**
967
995
  * 附带 `usageByCategory` 语义快照的推送来源(排除语义见上方
968
996
  * `AcpUsageUpdateSource` 注释)。publisher 与其 spec 共用此唯一事实源;
@@ -1007,7 +1035,7 @@ export interface AcpUsagePublisher {
1007
1035
  * 方案 Z(终版决议,2026-05-20):移除 options.hintUsed 参数 —— compact 完成路径不
1008
1036
  * 再主动推送,由下次 prompt 走 combineSubject(input) 自然回填真实 inputTokens。
1009
1037
  */
1010
- publish(sessionId: string, source: AcpUsageUpdateSource, carrier?: W3CTraceContextMeta): Promise<void>;
1038
+ publish(sessionId: string, source: AcpUsageUpdateSource, carrier?: W3CTraceContextMeta, pendingInputText?: string): Promise<void>;
1011
1039
  /**
1012
1040
  * 推送生成工具实际消耗。调用方只提供工具执行事实,publisher 统一复用
1013
1041
  * ACP usage_update.cost.amount 链路,并在内部做 session / stageId 幂等。
@@ -40,6 +40,27 @@ export interface UsageByCategoryInput {
40
40
  /** ACP usage_update.used,作为最终归一化的总分母。 */
41
41
  totalTokens: number;
42
42
  }
43
+ export declare const IMAGE_TOKEN_PER_PIECE = 85;
43
44
  export declare class UsageByCategoryCalculator {
44
45
  static compute(input: UsageByCategoryInput): UsageByCategory;
45
46
  }
47
+ export declare function zeroUsageByCategory(): UsageByCategory;
48
+ /**
49
+ * 单条 history item 对 systemPrompt / conversation / 图片张数的字符贡献。
50
+ *
51
+ * SSOT:全量 `compute` 与增量 publisher 共用本函数,保证「进行中增量」与
52
+ * 「prompt_end 全量」的类目结果严格一致(`weighted` 逐字符可加,item 边界不切
53
+ * 代理对,故 `weighted(Σparts) === Σ weighted(part)`)。
54
+ *
55
+ * - systemPrompt 贡献:仅 user message 的 hidden context block 第一个子 section
56
+ * (UserInfoSection 等价物);解析失败/无 hidden block 时为空,整条 user 文本
57
+ * 由 conversation 承接。
58
+ * - conversation 贡献:user/assistant 文本(user 去掉第一个 hidden section)
59
+ * + function_call 的 JSON.stringify + function_call_result 的 output 文本。
60
+ * - 图片不计字符权重,按张数单独累加(由调用方 ×IMAGE_TOKEN_PER_PIECE)。
61
+ */
62
+ export declare function collectHistoryItemChars(item: unknown): {
63
+ systemPromptChars: string;
64
+ conversationChars: string;
65
+ imagePieces: number;
66
+ };
@@ -33,6 +33,7 @@ export declare function resolveProgramBlacklistForPlatform(configuredPrograms: r
33
33
  * Bash 沙箱配置接口
34
34
  * 基于 SandboxRuntimeConfig,添加了额外的 CLI 特定配置
35
35
  */
36
+ export type MacOSUnlinkPolicy = 'allow' | 'ask' | 'deny';
36
37
  export interface SandboxConfig {
37
38
  /** 是否启用沙箱 */
38
39
  enabled?: boolean;
@@ -98,6 +99,8 @@ export interface SandboxConfig {
98
99
  systemToolPolicy?: SystemToolPolicy;
99
100
  /** 实验功能:工作空间内文件版本管理 */
100
101
  versionControl?: boolean;
102
+ /** macOS 非白名单直接 unlink 的自动兜底动作;历史缺省为 ask。 */
103
+ macosUnlinkPolicy?: MacOSUnlinkPolicy;
101
104
  /** 实验功能:工作空间内删除进回收站 */
102
105
  deleteProtection?: boolean;
103
106
  /** 实验功能:运行时删除回收站保护(Node/Python/Git Bash 注入) */
@@ -2,6 +2,9 @@ import { Command } from 'commander';
2
2
  export declare const CliDispatcher: unique symbol;
3
3
  export declare const CliProvider: unique symbol;
4
4
  export declare const DispatchStrategy: unique symbol;
5
+ /** Request-local controller/view handoff; never part of a wire message or Session. */
6
+ export declare const STREAM_JSON_RUN_RESULT = "codebuddy.streamJsonRunResult";
7
+ export declare const STREAM_JSON_COMPLETED_REQUEST = "codebuddy.streamJsonCompletedRequest";
5
8
  export interface CliDispatcher {
6
9
  dispatch(): Promise<void>;
7
10
  }
@@ -270,6 +270,20 @@ export interface ResultUsageExtension {
270
270
  modelUsage?: Record<string, ModelUsage>;
271
271
  _meta?: Record<string, unknown>;
272
272
  }
273
+ /**
274
+ * 这一轮为什么结束,取值对齐 Claude Code 的 `terminal_reason`。
275
+ *
276
+ * 目前只在被取消的一轮上给出:
277
+ * - `aborted_streaming`:中止时没有未完成的工具调用(停在模型输出上);
278
+ * - `aborted_tools`:中止时还有工具调用没执行完。
279
+ *
280
+ * 取消不是错误,所以取消的终态是 `subtype=success`、`is_error=false`,
281
+ * 消费方要靠这个字段把它与正常完成区分开,不要去匹配任何文案。
282
+ */
283
+ export type TerminalReason = 'aborted_streaming' | 'aborted_tools';
284
+ export interface ResultTerminalExtension {
285
+ terminal_reason?: TerminalReason;
286
+ }
273
287
  /** Mirrors the Claude Agent SDK's SDKPermissionDenial (E20 alignment gate). */
274
288
  export interface PermissionDenial {
275
289
  tool_name: string;
@@ -433,7 +447,14 @@ export type ResultMessage = ({
433
447
  * - 字段全部可选:`status` (HTTP 状态码)、`code` (SDK/业务码)、`category`
434
448
  * (与 acp-agent.ts `classifyErrorAsRequestError` 分类对齐)、`details` (脱敏文案)。
435
449
  *
436
- * 详见 `result-message-utils.ts` 的 `buildErrorsInfo` / `extractStructuredErrorInfo`。
450
+ * 例外(`is_error: true` 的终态):抛出物本身没有文案时(裸 `throw`、空 message 的
451
+ * `Error`、无 message 的对象),该槽位不再是 `null`,而是带
452
+ * `code: 'cbc_empty_error'` + 兜底 `details`。否则 `errors[i]` 与 `errors_info[i]`
453
+ * 同时为空,下游 `BuildErrorMessageFromCLIErrors` 会整条丢掉错误 `_meta`,
454
+ * 终态在观测侧退化为不可归因的 `stop_reason=refusal` + `error=""`。
455
+ *
456
+ * 详见 `result-message-utils.ts` 的 `buildErrorTerminalFields` /
457
+ * `buildErrorsInfo` / `extractStructuredErrorInfo`。
437
458
  */
438
459
  errors_info?: Array<{
439
460
  status?: number;
@@ -441,7 +462,7 @@ export type ResultMessage = ({
441
462
  category?: string;
442
463
  details?: string;
443
464
  } | null>;
444
- }) & ResultUsageExtension;
465
+ }) & ResultUsageExtension & ResultTerminalExtension;
445
466
  type ApiKeySource = string;
446
467
  export interface SystemMessage {
447
468
  type: 'system';
@@ -38,6 +38,9 @@ export interface FileSystem {
38
38
  writeFile(path: string, content: string | Uint8Array): Promise<void>;
39
39
  exists(path: string): Promise<boolean>;
40
40
  stat(path: string): Promise<FileSystemStat>;
41
+ /** Optional metadata for filesystems that can identify linked paths. */
42
+ lstat?(path: string): Promise<FileSystemStat>;
43
+ realpath?(path: string): Promise<string>;
41
44
  mkdir(path: string, options?: {
42
45
  recursive?: boolean;
43
46
  }): Promise<void>;
@@ -82,6 +85,8 @@ export interface DataFs {
82
85
  withFileTypes: true;
83
86
  }): Promise<DataFsDirent[]>;
84
87
  stat(path: string): Promise<DataFsStats>;
88
+ lstat?(path: string): Promise<DataFsStats>;
89
+ realpath?(path: string): Promise<string>;
85
90
  rm(path: string, options?: {
86
91
  recursive?: boolean;
87
92
  force?: boolean;
@@ -141,7 +146,14 @@ export interface ScannedFile {
141
146
  fileName: string;
142
147
  relativePath: string;
143
148
  }
144
- export declare function scanFilesByExtension(baseDir: string, extension: string, maxDepth?: number): Promise<ScannedFile[]>;
149
+ export interface ScanFilesOptions {
150
+ maxEntries?: number;
151
+ onError?: (error: Error, path: string) => void;
152
+ signal?: AbortSignal;
153
+ /** Filesystems with link metadata can supply realpath for cycle and alias detection. */
154
+ canonicalizeDirectory?: (path: string) => Promise<string>;
155
+ }
156
+ export declare function scanFilesByExtension(baseDir: string, extension: string, maxDepth?: number, options?: ScanFilesOptions): Promise<ScannedFile[]>;
145
157
  /**
146
158
  * Wrap a config-face filesystem into the node:fs/promises-shaped provider:
147
159
  * Stats/Dirent booleans become methods, Uint8Array becomes Buffer, errno
@@ -2,6 +2,7 @@
2
2
  * Hook mechanism protocol definitions
3
3
  * Compatible with Claude Code hooks specification
4
4
  */
5
+ import type { HookInput } from '../../vendor/cbc-core/node/index.js';
5
6
  import { HookEvent, type HookExecutionOptions, type HookExecutionResult, type PromptHookResult } from '../../vendor/cbc-shared/node/index.js';
6
7
  export { HookBlockedError, HookEvent, NotificationType } from '../../vendor/cbc-shared/node/index.js';
7
8
  export type { BackgroundTaskInfo, CronTaskInfo, FinalStopReason, HookBlockingDetail, HookExecutionOptions, HookExecutionResult, HookOutput, HookPermissionMode, PromptHookResult, SessionEndReason, SessionStartSource, } from '../../vendor/cbc-shared/node/index.js';
@@ -240,8 +241,7 @@ export type HookDefinition = CommandHookDefinition | PromptHookDefinition | Agen
240
241
  * Input data passed to hook script via stdin
241
242
  * Format matches Claude Code hooks specification exactly
242
243
  */
243
- export type { HookInput } from "../../vendor/cbc-core/node/index.js";
244
- import type { HookInput } from "../../vendor/cbc-core/node/index.js";
244
+ export type { HookInput } from '../../vendor/cbc-core/node/index.js';
245
245
  /**
246
246
  * Hook Manager interface
247
247
  */
@@ -1,3 +1,4 @@
1
+ import type { SandboxRuleContext } from '../../workspace/agent-client-protocol/lib/common/index.js';
1
2
  export declare const SensitiveDecisionMediation: unique symbol;
2
3
  export declare const SensitiveContentMediation: unique symbol;
3
4
  export declare const SensitiveToolEgressGuard: unique symbol;
@@ -245,6 +246,11 @@ export type SensitiveDetectionOutcome = {
245
246
  } | {
246
247
  kind: 'detected';
247
248
  detectionRef: string;
249
+ ruleContext?: SandboxRuleContext;
250
+ ruleMatches?: Array<{
251
+ plaintext: string;
252
+ ruleContext: SandboxRuleContext;
253
+ }>;
248
254
  plaintexts: string[];
249
255
  /** 无可用密文条目的命中,仅作疑似提示展示,不参与加密/替换。 */
250
256
  unprotectablePlaintexts?: string[];
@@ -291,6 +297,7 @@ export interface SandboxCenterPort {
291
297
  export interface SensitiveApprovalPort {
292
298
  requestApproval(request: {
293
299
  detectionRef: string;
300
+ ruleContext?: SandboxRuleContext;
294
301
  direction: SensitiveReviewRequest['direction'];
295
302
  source: SensitiveReviewRequest['source'];
296
303
  allowedChoices: SensitiveApprovalChoice[];
@@ -1,15 +1,18 @@
1
1
  import 'reflect-metadata';
2
2
  import type { ProductConfiguration } from '../../workspace/product/lib/common/index.js';
3
+ declare module '@celljs/core/lib/common/container/dynamic-container' {
4
+ function createContainer(): Promise<import('@celljs/core').Container>;
5
+ }
3
6
  /**
4
- * Lazy 单次 boot;幂等。首个 start()/verb 驱动(ensureStarted 收口)。
7
+ * 每次生命周期内惰性且幂等。首个 start()/verb 驱动(ensureStarted 收口)。
5
8
  * boot 失败即出队:best-effort 释放半装配态后清缓存,下一次调用真重试——
6
9
  * rejected promise 常驻会把一次瞬时失败固化成进程终身拒绝(lamp 毒 pod
7
10
  * 判例:boot 崩一次后每个会话都撞 already-started,pod 成毒丸)。
8
11
  */
9
12
  export declare function ensureBoot(product?: ProductConfiguration): Promise<void>;
10
13
  /**
11
- * stop() 收尾的容器释放:Application.stop() 生命周期 + unbindAllAsync 归还
12
- * 内存给嵌入宿主。runtime 维持已停终态(verbs 继续按 stopped 拒绝);释放
13
- * 失败不阻断关停。
14
+ * stop() 收尾:Application.stop() → unbindAllAsync → Effect.dispose。
15
+ * 成功后可由新的显式 start() 构造全新容器;失败仍尝试全部阶段,但拒绝
16
+ * 再次 boot,避免旧 finalizer 与新实例共享进程级适配器。
14
17
  */
15
18
  export declare function releaseContainer(): Promise<void>;
@@ -1,4 +1,4 @@
1
- import { type PromptResponse, RequestError } from '@agentclientprotocol/sdk';
1
+ import { type PromptResponse, RequestError } from '@agentclientprotocol/sdk-server';
2
2
  export declare const CODEBUDDY_ERROR_META_KEY = "codebuddy.ai/error";
3
3
  export declare const CODEBUDDY_ERROR_UPDATE_TYPE = "_codebuddy.ai/error";
4
4
  /**
@@ -1,6 +1,5 @@
1
- export type * from '@agentclientprotocol/sdk';
2
- export type { AcpClientChannel } from './acp-client-channel.js';
3
- export type { McpUiBroadcastPayload, ModelInfo } from '../../../cli/dist-server/types/node/acp/acp-protocol.js';
1
+ export type * from '@agentclientprotocol/sdk-server';
2
+ export type { McpUiBroadcastPayload, ModelInfo } from '../../../acp/acp-protocol';
4
3
  export interface AcpConnectionProfile {
5
4
  endpoint: 'canonical' | 'compatibility';
6
5
  compatibilityExtensions: boolean;
@@ -0,0 +1,12 @@
1
+ import type { FormattedSessionEvent, SessionSourceEvent } from '../../types';
2
+ /** Protocol presentation only. The Server remains the owner of run settlement. */
3
+ export declare class AcpSessionFormatter {
4
+ private readonly version;
5
+ private readonly lanes;
6
+ private readonly compactions;
7
+ private readonly streamedV1Messages;
8
+ constructor(version: 'acp-v1' | 'acp-v2');
9
+ format(source: SessionSourceEvent): Promise<FormattedSessionEvent<'acp-v1' | 'acp-v2'>[]>;
10
+ private wrap;
11
+ private model;
12
+ }
@@ -0,0 +1,10 @@
1
+ import type { SessionNotification } from '@agentclientprotocol/sdk-server';
2
+ import type { UpdateSessionNotification } from '@agentclientprotocol/sdk-server/experimental/v2';
3
+ import type { AgentInputItem } from '../../../../vendor/cbc-shared/node/index.js';
4
+ import type { AgentEvent } from '../../types';
5
+ export declare function itemNotifications(sessionId: string, item: AgentInputItem, replay: boolean, readFile?: (path: string) => Promise<Uint8Array>): Promise<SessionNotification[]>;
6
+ /** Live complete items and replay share content, tool and identity projection. */
7
+ export declare const projectAgentItem: (sessionId: string, item: AgentInputItem) => Promise<UpdateSessionNotification[]>;
8
+ /** Reuse the CLI's ACP extension vocabulary; the Agent only exports kernel facts. */
9
+ export declare const projectNativeEvent: (frame: AgentEvent) => Promise<SessionNotification[]>;
10
+ export declare function projectAgentEvent(frame: AgentEvent): Promise<UpdateSessionNotification[]>;
@@ -15,7 +15,7 @@ export { start } from './start';
15
15
  export { readSession } from './read-session';
16
16
  export { readSessionCatalog } from './read-session-catalog';
17
17
  export { createSession } from './create-session';
18
- export type { ReadSessionCatalogOptions, ReloadOptions, CreateSessionOptions, ConfigChange, NotifyConfigChangeOptions, AgentEvent, AgentDefinition, HookCallback, HookCallbackMatcher, HookEvent, HookInput, HookJSONOutput, QueryHooks, OrphanedExecSettlement, QueryOptions, QueryResult, QueryTicket, QueryInput, ReadSessionOptions, RewindOptions, RewindResult, RunAccount, RunAuth, RunCompletedEvent, RunStartedEvent, Sandbox, SandboxCapabilities, SandboxDriver, SandboxFactory, SandboxFileStat, SandboxShellResult, Server, SessionEvent, SessionCatalog, SessionEventOrigin, SessionEventListener, SessionSubscription, SessionSubscriptionExit, SessionSnapshot, SessionKey, SessionStore, SessionStoreEntry, StartOptions, StopReason, SteerOptions, SteerResult, } from './types';
18
+ export type { ReadSessionCatalogOptions, ReloadOptions, CreateSessionOptions, ConfigChange, NotifyConfigChangeOptions, AgentEvent, AgentDefinition, HookCallback, HookCallbackMatcher, HookEvent, HookInput, HookJSONOutput, QueryHooks, OrphanedExecSettlement, QueryOptions, QueryResult, QueryTicket, QueryInput, ReadSessionOptions, RewindOptions, RewindResult, RunAccount, RunAuth, RunCompletedEvent, RunStartedEvent, Sandbox, SandboxCapabilities, SandboxDriver, SandboxFactory, SandboxFileStat, SandboxShellResult, Server, SessionEvent, FormattedSessionEvent, SessionOutputFormat, SubscribeOptions, NativeSessionEvent, AgentSdkEvent, AcpSessionEvent, SessionCatalog, SessionEventOrigin, SessionEventListener, SessionSubscription, SessionSubscriptionExit, SessionSnapshot, SessionKey, SessionStore, SessionStoreEntry, StartOptions, StopReason, SteerOptions, SteerResult, } from './types';
19
19
  export { InMemorySessionStore } from './in-memory-session-store';
20
20
  export { WORKBUDDY_TOOLS } from './tool-presets';
21
21
  export { InMemoryFs, MountableFs, OverlayFs, ReadWriteFs } from './fs-kit';
@@ -1,4 +1,9 @@
1
- import type { QueryInput, QueryOptions, QueryTicket, ReloadOptions, RewindOptions, RewindResult, SessionEventListener, SessionSubscription, SteerOptions, SteerResult } from './types';
1
+ import { Session } from '../../vendor/cbc-core/node/index.js';
2
+ import type { FormattedSessionEvent, QueryInput, QueryOptions, QueryTicket, ReloadOptions, RewindOptions, RewindResult, SessionOutputFormat, SessionSubscription, SteerOptions, SteerResult, SubscribeOptions } from './types';
3
+ interface SettleOutcome {
4
+ assistantText: string;
5
+ completedError?: unknown;
6
+ }
2
7
  /**
3
8
  * Submit input or a maintenance operation: creates the session on first touch, resumes it
4
9
  * otherwise. The ticket carries the run id synchronously — it is the kernel
@@ -9,6 +14,24 @@ export declare function query(sessionId: string, input: QueryInput, options?: Qu
9
14
  export declare function reload(sessionId: string, options?: ReloadOptions): void;
10
15
  /** Add input to an existing query. Rejection never creates or activates a session. */
11
16
  export declare function steer(sessionId: string, input: string | unknown[], options: SteerOptions): Promise<SteerResult>;
17
+ /**
18
+ * Settlement discipline (ordered signal): the primary lane subscribes to the
19
+ * kernel's combine result/interrupt_result events, emitted only AFTER the
20
+ * run's bookkeeping (error item into history, Stop hooks); retried failures
21
+ * are suppressed and the recovery run emits its own (#64101, same gate
22
+ * discipline as stream-json-view). Each result is judged by its stamped
23
+ * interceptorGate — willRetry (and not __cancelNudge) means not terminal.
24
+ * interrupt_result settles immediately without awaiting `completed` (it may
25
+ * never resolve on that path). The completed-promise loop remains as a raced,
26
+ * stale-aware fallback with a grace window for terminal or pre-dispatch
27
+ * failures. A gate that promises continuation must instead await an actual
28
+ * result or ordered interrupt; a pending permission is not a timeout failure.
29
+ * Never pump the item stream here; the kernel's per-session subscription is
30
+ * its consumer.
31
+ */
32
+ export declare function beginSettle(session: Session, isInterrupted: () => boolean): {
33
+ wait(): Promise<SettleOutcome>;
34
+ };
12
35
  /**
13
36
  * Turn-level cancellation: the in-flight ticket resolves normally with
14
37
  * stopReason 'aborted', never rejects. Resolves after the run state settles.
@@ -23,7 +46,8 @@ export declare function interrupt(sessionId: string): Promise<void>;
23
46
  * whose queue exceeds the high-water mark is evicted — recover by
24
47
  * re-subscribing and catching up from the session store.
25
48
  */
26
- export declare function subscribe(sessionId: string, listener: SessionEventListener): SessionSubscription;
49
+ export declare function subscribe(sessionId: string, listener: (event: FormattedSessionEvent) => void | Promise<void>): SessionSubscription;
50
+ export declare function subscribe<F extends SessionOutputFormat>(sessionId: string, listener: (event: FormattedSessionEvent<F>) => void | Promise<void>, options: SubscribeOptions<F>): SessionSubscription;
27
51
  /**
28
52
  * Passivation hint. Optional, and never a terminal state: closing equals an
29
53
  * orderly crash, and any verb reactivates the session from storage.
@@ -35,3 +59,4 @@ export declare function close(sessionId: string): Promise<void>;
35
59
  * Does not emit a query lifecycle or discard existing subscriptions.
36
60
  */
37
61
  export declare function rewind(sessionId: string, options: RewindOptions): Promise<RewindResult>;
62
+ export {};
@@ -4,8 +4,11 @@
4
4
  * docs/cloud-native/agent-cli-server.md): the SessionStore
5
5
  * adapter contract, the Sandbox family, and the stream-json event union.
6
6
  */
7
- import type { AgentPhaseInfo, CanUseTool, CombineEvent, SubagentEventReference, SubagentTokenUsageSnapshot, TranscriptStore as SessionStore } from '../../vendor/cbc-core/node/index.js';
8
- import type { ProductConfiguration } from '../../workspace/product/lib/common/index.js';
7
+ import type { SessionNotification } from '@agentclientprotocol/sdk-server';
8
+ import type { UpdateSessionNotification } from '@agentclientprotocol/sdk-server/experimental/v2';
9
+ import type { AgentPhaseInfo, CanUseTool, CombineEvent, SessionKey, SubagentEventReference, SubagentTokenUsageSnapshot, TranscriptStore as SessionStore } from '../../vendor/cbc-core/node/index.js';
10
+ import type { AgentInputItem, ResponseStreamEvent, RunStreamEvent } from '../../vendor/cbc-shared/node/index.js';
11
+ import type { Command, ProductConfiguration, Skill } from '../../workspace/product/lib/common/index.js';
9
12
  import type { RunAccount, RunAuth } from '../authentication/run-context';
10
13
  import type { Message } from '../cli/stream-json-protocol';
11
14
  import type { FileSystem, InitialFiles } from '../data-fs';
@@ -39,6 +42,7 @@ export interface StartOptions {
39
42
  * CODEBUDDY_AUTH_TOKEN / CODEBUDDY_SESSION_SKILL_DIRS)拒绝:凭据只认
40
43
  * query options(auth)与 start({ apiKey })。会话级差异走
41
44
  * `query({ settings: { env } })`——ALS 会话档,并行 run 各自解析无竞态。
45
+ * stop 或启动失败后恢复本次覆盖的环境值;宿主期间主动修改的值保留。
42
46
  */
43
47
  env?: Record<string, string>;
44
48
  /** Global SessionStore adapter (SDK shape). Durable events append here on settle. */
@@ -84,6 +88,7 @@ export interface StartOptions {
84
88
  * `stop()` drains in-flight work, then disconnects persistence. Supports
85
89
  * `await using`; deliberately no synchronous dispose — graceful shutdown is
86
90
  * inherently async.
91
+ * Await successful stop before starting a new runtime in the same process.
87
92
  */
88
93
  export interface Server {
89
94
  stop(): Promise<void>;
@@ -115,13 +120,15 @@ export interface RewindResult {
115
120
  }
116
121
  /** Durable Agent items, including message identities and conversation facts. */
117
122
  export interface SessionSnapshot {
123
+ /** Persisted standing Agent, independent of current Product defaults. */
124
+ mainAgent?: string;
118
125
  sessionId: string;
119
126
  cwd: string;
120
- history: import('../../vendor/cbc-shared/node/index.js').AgentInputItem[];
127
+ history: AgentInputItem[];
121
128
  /** Store-owned locators. Pass a key to readSession to read that child lazily. */
122
129
  subagents?: Array<{
123
130
  sessionId: string;
124
- key: import('../../vendor/cbc-core/node/index.js').SessionKey;
131
+ key: SessionKey;
125
132
  }>;
126
133
  }
127
134
  /**
@@ -159,6 +166,12 @@ export interface QueryOptions {
159
166
  multitask?: boolean;
160
167
  /** Enable the host's local sandbox. Changes apply when the session has no background work. */
161
168
  sandboxEnabled?: boolean;
169
+ /**
170
+ * Request a PTY for Bash executions, or false for separate stdout/stderr pipes.
171
+ * Omitted preserves the session's current selection and existing CLI defaults.
172
+ * Execution drivers may require pipes; this does not change sandbox permissions.
173
+ */
174
+ usePty?: boolean;
162
175
  /**
163
176
  * 会话级自定义 agent 定义(#108461 D6,形态对齐 stream-json `initialize.agents`
164
177
  * / SDK `--agents`):名字 → 定义(`prompt`/`description`/`tools`/`model`/
@@ -390,7 +403,7 @@ export type SteerResult = {
390
403
  */
391
404
  export type SessionEvent = (Message | RunStartedEvent | RunCompletedEvent | AgentEvent) & {
392
405
  /** Complete Agent item behind a message frame, shared with readSession(). */
393
- readonly item?: import('../../vendor/cbc-shared/node/index.js').AgentInputItem;
406
+ readonly item?: AgentInputItem;
394
407
  /** Producer-owned identity. Background and child events retain their original run. */
395
408
  readonly origin?: SessionEventOrigin;
396
409
  };
@@ -429,13 +442,19 @@ export interface AgentEvent {
429
442
  } | {
430
443
  readonly type: 'catalog';
431
444
  readonly data: SessionCatalog;
445
+ } | {
446
+ readonly type: 'title';
447
+ readonly data: string;
448
+ } | {
449
+ readonly type: 'error';
450
+ readonly data: unknown;
432
451
  };
433
452
  readonly _requestId?: string;
434
453
  readonly _meta?: Record<string, unknown> | null;
435
454
  }
436
455
  export interface SessionCatalog {
437
- readonly commands: Array<Pick<import('../../workspace/product/lib/common/index.js').Command, 'name' | 'description' | 'argumentHint' | 'tags'>>;
438
- readonly skills: Array<Pick<import('../../workspace/product/lib/common/index.js').Skill, 'name' | 'description' | 'source' | 'userInvocable' | 'disableModelInvocation' | 'pluginInfo'>>;
456
+ readonly commands: Array<Pick<Command, 'name' | 'description' | 'argumentHint' | 'tags'>>;
457
+ readonly skills: Array<Pick<Skill, 'name' | 'description' | 'source' | 'userInvocable' | 'disableModelInvocation' | 'pluginInfo'>>;
439
458
  readonly skillOverrides?: Settings['skillOverrides'];
440
459
  }
441
460
  /** Refresh resident components before the next queued turn (including continuations).
@@ -463,6 +482,45 @@ export interface RunCompletedEvent extends QueryResult {
463
482
  readonly session_id: string;
464
483
  readonly _meta?: Record<string, unknown> | null;
465
484
  }
485
+ /** Selects only presentation; query lifecycle and persistence are shared. */
486
+ export type SessionOutputFormat = 'openai' | 'messages' | 'acp-v1' | 'acp-v2';
487
+ export interface SubscribeOptions<F extends SessionOutputFormat = 'messages'> {
488
+ readonly format: F;
489
+ }
490
+ /** All SDK stream event variants, with the original object as data (no JSON conversion). */
491
+ export interface AgentSdkEvent {
492
+ readonly type: 'agent_sdk';
493
+ readonly parentToolUseId?: string;
494
+ readonly session_id: string;
495
+ readonly data: RunStreamEvent;
496
+ readonly origin?: SessionEventOrigin;
497
+ readonly _meta?: Record<string, unknown> | null;
498
+ }
499
+ /** Native model facts used by formatters, never stream-json intermediates. */
500
+ export interface AgentModelEvent {
501
+ readonly type: 'agent_model';
502
+ readonly parentToolUseId?: string;
503
+ readonly session_id: string;
504
+ readonly data: ResponseStreamEvent;
505
+ readonly origin?: SessionEventOrigin;
506
+ readonly _meta?: Record<string, unknown> | null;
507
+ }
508
+ export interface AcpSessionEvent<F extends 'acp-v1' | 'acp-v2'> {
509
+ readonly type: 'acp_update';
510
+ readonly notification: F extends 'acp-v1' ? SessionNotification : UpdateSessionNotification;
511
+ readonly item?: AgentInputItem;
512
+ readonly origin?: SessionEventOrigin;
513
+ readonly _meta?: Record<string, unknown> | null;
514
+ }
515
+ export type NativeSessionEvent = (AgentSdkEvent | AgentEvent | RunStartedEvent | RunCompletedEvent) & {
516
+ readonly origin?: SessionEventOrigin;
517
+ };
518
+ export type FormattedSessionEvent<F extends SessionOutputFormat = 'messages'> = (F extends 'messages' ? SessionEvent : F extends 'acp-v1' | 'acp-v2' ? AcpSessionEvent<F> | AgentEvent | RunStartedEvent | RunCompletedEvent : NativeSessionEvent) & {
519
+ readonly origin?: SessionEventOrigin;
520
+ readonly item?: AgentInputItem;
521
+ };
522
+ /** Internal source union. ACP never consumes stream-json messages. */
523
+ export type SessionSourceEvent = SessionEvent | AgentSdkEvent | AgentModelEvent;
466
524
  export type SessionEventListener = (event: SessionEvent) => void | Promise<void>;
467
525
  export type SessionSubscriptionExit = {
468
526
  readonly reason: 'unsubscribed';
@@ -92,6 +92,7 @@ export declare const ENV_KEY_CODEBUDDY_IMAGE_TO_VIDEO_MODEL = "CODEBUDDY_IMAGE_T
92
92
  export declare const ENV_KEY_CODEBUDDY_IMAGE_GEN_ENABLED = "CODEBUDDY_IMAGE_GEN_ENABLED";
93
93
  export declare const ENV_KEY_CODEBUDDY_IMAGE_EDIT_ENABLED = "CODEBUDDY_IMAGE_EDIT_ENABLED";
94
94
  export declare const ENV_KEY_CODEBUDDY_VIDEO_GEN_ENABLED = "CODEBUDDY_VIDEO_GEN_ENABLED";
95
+ export declare const ENV_KEY_CODEBUDDY_AUDIO_TRANSCRIBE_ENABLED = "CODEBUDDY_AUDIO_TRANSCRIBE_ENABLED";
95
96
  export declare const ENV_KEY_CODEBUDDY_HIGH_CREDIT_APPROVAL_ENABLED = "CODEBUDDY_HIGH_CREDIT_APPROVAL_ENABLED";
96
97
  export declare const ENV_KEY_CODEBUDDY_ARTIFACT_ENABLED = "CODEBUDDY_ARTIFACT_ENABLED";
97
98
  /** @deprecated 兼容保留,请改用 CODEBUDDY_ARTIFACT_ENABLED(新名优先,旧名兜底)。 */
@@ -413,6 +414,8 @@ export interface CodebuddySettings {
413
414
  agentHome?: {
414
415
  enabled?: boolean;
415
416
  orchestration?: boolean;
417
+ /** 自动投递到主 Agent 的任务完成回执。默认 all。 */
418
+ taskReceipts?: 'all' | 'batch' | 'off';
416
419
  };
417
420
  /**
418
421
  * Web 输入框在 agent 忙碌时的发送方式(仅 agent-cli Web;不进 WorkBuddy overlay)。
@@ -643,6 +646,8 @@ export interface Hooks {
643
646
  CwdChanged?: HookConfig[];
644
647
  /** Internal-only hooks triggered when agent truly stops */
645
648
  FinalStop?: HookConfig[];
649
+ /** Hooks triggered when a user-typed command/skill expands into a prompt (matcher on command_name) */
650
+ UserPromptExpansion?: HookConfig[];
646
651
  }
647
652
  export interface StatusLine {
648
653
  /** 类型 */