@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
@@ -226,10 +226,10 @@ export declare abstract class HistoryUtils {
226
226
  * <conversation_history_summary>…</conversation_history_summary> 包裹的正文)。
227
227
  *
228
228
  * 规则(与 replaceCompactWithSummary / getCompactHistory 对齐):
229
- * 1. 仅查看 `providerData.agent === AgentNames.COMPACT` 且为 assistant 的 message
230
- * 2. 从后向前扫描,命中第一条满足格式的 compact assistant 即返回
231
- * 3. "满足格式"由 `SummaryUtils.extractCompactSummaryFromText` 统一判定
232
- * (内含结构校验 + 非空正文双闸)
229
+ * 1. 查看 compact-agent assistant,或 PreMessage/MaxToken 写入的显式 compact boundary
230
+ * 2. 从后向前扫描,命中第一条可用摘要即返回
231
+ * 3. compact assistant 继续要求结构化 summary envelope;显式 boundary 同时支持
232
+ * 工程压缩的 `<cb_summary>` 与 LLM summary envelope
233
233
  * 4. 全程扫描都拿不到 → 返回 `undefined`(history 中**从未**出现过合法摘要)
234
234
  *
235
235
  * ⚠️ 不适合用于"判断本次 compact run 是否成功"!
@@ -364,6 +364,29 @@ export declare abstract class HistoryUtils {
364
364
  */
365
365
  static filterApiErrorMessages(history: AgentInputItem[]): AgentInputItem[];
366
366
  static filterRenameHistory(history: AgentInputItem[]): AgentInputItem[];
367
+ /**
368
+ * 让 model input 里的 tool_call 与 tool_result 严格一一配对(issue #119545)。
369
+ *
370
+ * 背景:工具结果丢失(状态机吞掉 TOOL_ENDED、持久化缺口、压缩切断)后,历史里会留下
371
+ * 只有 call、没有任何 result 的孤儿。上游对 tool_calls 强制配对,一条孤儿就让整个
372
+ * 请求 400,会话从此不可恢复——而本地历史里的孤儿是持久化的,每次恢复都会重现。
373
+ *
374
+ * 三类都处理,因为上游拒的是"不配对"这件事本身,方向无关:
375
+ * 1. call 没有任何同 callId 的结果项 → 丢 call;
376
+ * 2. 同一 callId 出现多条 call(重放/重试残留)→ 只留最后一条;
377
+ * 3. 结果项的 callId 没有留下来的 call(头部被截断,或 call 属于上面两类)→ 丢结果。
378
+ *
379
+ * 判据只看"存在性",不看结果的真伪:skipRun 占位/拒绝、partial aborted 等伪结果都算
380
+ * 配对,它们的取舍归 filterTruncatedToolCalls,两者职责不重叠。改写只落在当轮副本上,
381
+ * 因此日志按轮聚合成一条并截断样本。
382
+ */
383
+ static filterUnpairedToolCalls(modelData: {
384
+ input: AgentInputItem[];
385
+ instructions?: string;
386
+ }, logger?: Logger): {
387
+ input: AgentInputItem[];
388
+ instructions?: string;
389
+ };
367
390
  static getItemsNeedingFill(history: AgentInputItem[]): FunctionCallItem[];
368
391
  static getFillItemsForNeedingFill(itemsNeedingFill: FunctionCallItem[]): FunctionCallResultItem[];
369
392
  /**
@@ -23,5 +23,6 @@ export * from './queue-dispatch-utils.js';
23
23
  export * from './run-result-utils.js';
24
24
  export * from './session-utils.js';
25
25
  export * from './summary-utils.js';
26
+ export * from './string-retention-utils.js';
26
27
  export * from './token-utils.js';
27
28
  export * from './usage-utils.js';
@@ -256,6 +256,14 @@ export declare abstract class InputItemUtils {
256
256
  static isUserInterrupted(item: AgentInputItem): boolean;
257
257
  static isSuccessfulFunctionCallResultItem(item: AgentInputItem): item is FunctionCallResultItem;
258
258
  static isCompactBoundaryMessage(item: AgentInputItem): boolean;
259
+ /**
260
+ * 仅凭 providerData 结构化标记判定 compact boundary,不使用内容正则兜底。
261
+ *
262
+ * 会删除或改写消息的路径(如 replaceCompactWithSummary)必须用这个版本:
263
+ * 内容兜底会把用户粘贴的 `<cb_summary>` / `<conversation_history_summary>` 文本
264
+ * 误判为 boundary,导致真实用户输入被移除。
265
+ */
266
+ static isStructuredCompactBoundaryMessage(item: AgentInputItem): boolean;
259
267
  static isReplayRecoverableCompactMessage(item: AgentInputItem): item is UserMessageItem;
260
268
  static isCompactUserMessage(item: AgentInputItem): item is UserMessageItem;
261
269
  private static hasCompactBoundaryContent;
@@ -79,6 +79,18 @@ export declare abstract class MessageUtils {
79
79
  static createFilteredCopyForCompaction(messages: AgentInputItem[]): AgentInputItem[];
80
80
  private static filterHiddenSystemRemindersForCompaction;
81
81
  static stripSystemRemindersOutsideUserQuery(text: string): string;
82
+ /**
83
+ * 压缩链路的统计日志出口。
84
+ *
85
+ * **禁止改回 `process.stderr.write` / `process.stdout.write`**(issue #76749):
86
+ * TUI 下裸写 stderr 会破坏 Ink 帧间光标定位,导致行级 diff 错位、spinner 残留。
87
+ * 走 logger 落盘即可,既保留排查信息又不碰 TTY。
88
+ *
89
+ * `catch` 有意整段吞掉,不做分级上报:日志出口的任何失败(容器未就绪、logger 自身
90
+ * 抛错)都不得影响压缩本身;而「失败时改走 stderr 兜底」恰会在异常路径上重新引入
91
+ * 本 issue 要修掉的 TTY 裸写。统计丢失是可接受的降级。
92
+ */
93
+ private static logCompaction;
82
94
  /**
83
95
  * Microcompact: clear output of old tool results (> 1 hour) to reduce token count.
84
96
  * Modifies items in place. Should be called BEFORE createFilteredCopyForCompaction.
@@ -70,6 +70,13 @@ export declare abstract class ModelUtils {
70
70
  */
71
71
  private static readRuntimeModelId;
72
72
  static isHunyuanModel(session: Session): Promise<boolean>;
73
+ /**
74
+ * ImageGen 实际使用的图片模型是否为混元。
75
+ *
76
+ * 取「产品配置里第一个带 text-to-image tag 的模型」,与 image-service 的解析顺序一致;
77
+ * 配置里没有图片模型时会走客户端的混元兜底模型,同样按混元处理。
78
+ */
79
+ static isHunyuanImageModel(): Promise<boolean>;
73
80
  static isMandatoryApprovalTarget(session: Session, targetToolName: string): Promise<boolean>;
74
81
  }
75
82
  export {};
@@ -17,7 +17,8 @@ import type { Session } from '../session/session-protocol.js';
17
17
  * 取;CLI **不再自动 drain**。后果有两条,改这块代码前必须知道:
18
18
  * 1. `session.queue` 降级为 rich queue 的**展示镜像**(只给 CLI TUI 看),镜像段由
19
19
  * `RichMessageQueueManagerImpl.syncToSessionQueue` 整体重建;
20
- * 2. 上面列举的那些 legacy 自动 drain 路径**全部被显式短路**。
20
+ * 2. 主会话的 legacy 自动 drain 路径被短路。子任务没有客户端派发者,仍由
21
+ * MessageQueueAgentRunInterceptor 消费非镜像项(包括普通 user 消息)。
21
22
  *
22
23
  * 因此在 Mode B 下 `session.queue` 是两个所有者共用的数组:镜像段属于 rich queue,
23
24
  * 系统注入项(后台任务通知 / channel / teammate / ACP steer 等)属于各自的注入方。任何一方读写它时
@@ -63,9 +64,30 @@ export declare abstract class QueueDispatchUtils {
63
64
  * 从 `session.queue` 里挑出「自动 drain 通道」该消费的项。
64
65
  *
65
66
  * Mode A:整个队列都是待发输入,原样返回(保持既有行为)。
66
- * Mode B:只返回系统注入项,rich queue 的展示镜像不属于本通道。
67
+ * Mode B 主会话:只返回系统注入项。子任务:所有非镜像项都是真实待发输入。
67
68
  */
68
69
  static ownedQueueItems(session: Session): AgentInputItem[];
70
+ /** Task runtimes have no client queue dispatcher, including restored child sessions. */
71
+ static isTaskQueue(session: Session): boolean;
72
+ /** The legacy interceptor owns all Mode A input and Mode B task input, never rich mirrors. */
73
+ static usesLocalQueueDispatch(session: Session): boolean;
74
+ static autoDrainQueueItems(session: Session): AgentInputItem[];
75
+ /**
76
+ * Observe which items one drain invocation actually consumed.
77
+ *
78
+ * **`input` is matched by array *identity*, not contents** — a copy observes
79
+ * nothing, and the caller then reads a failed drain as having consumed
80
+ * nothing. Per instance rather than per session because a session-wide
81
+ * snapshot cannot tell this batch apart from a competing run's.
82
+ *
83
+ * @returns disposer; call it once the run settles.
84
+ */
85
+ static observeQueueDrain(input: AgentInputItem[], observer: (items: AgentInputItem[], signal?: AbortSignal) => void): () => void;
86
+ /**
87
+ * Report the items consumed for `input`. No-op when nobody observes that
88
+ * exact array instance — see {@link observeQueueDrain} for the contract.
89
+ */
90
+ static recordQueueDrain(input: AgentInputItem[], items: AgentInputItem[], signal?: AbortSignal): void;
69
91
  /**
70
92
  * Async check — reads product config when env var is not set.
71
93
  */
@@ -11,7 +11,10 @@ export declare abstract class SessionUtils {
11
11
  * session 中发生实际可见的 ID 冲突。
12
12
  */
13
13
  static subAgentId(): string;
14
- static isSubAgent(session: Session): boolean;
14
+ static isSubAgent(session: {
15
+ id?: string;
16
+ storeId?: string;
17
+ }): boolean;
15
18
  /**
16
19
  * Clone one history item for a fork without duplicating large string payloads.
17
20
  *
@@ -0,0 +1,4 @@
1
+ /** Materialize an independent string without changing its UTF-16 code units. */
2
+ export declare function copyString(value: string): string;
3
+ /** Truncate by JavaScript string length and detach the retained prefix from its parent. */
4
+ export declare function truncateAndCopyString(value: string, maxLength: number, suffix?: string): string;
@@ -64,7 +64,9 @@ export declare class TokenUtils {
64
64
  * tool call 执行后产生的 function_call_result(这些结果在 API 返回后才追加到 history)。
65
65
  * 为了更准确地判断是否需要触发压缩,需要把这部分 token 补上。
66
66
  *
67
- * 从 history 末尾往前扫描,收集连续的 function_call_result 条目直到遇到其他类型为止。
67
+ * 从 history 末尾往前扫描,只收集紧挨在末尾的连续 function_call_result。
68
+ * 一遇到非 function_call_result(含 function_call)即停止:function_call 属于上一轮
69
+ * 已经进过请求的内容,穿过它会把更早轮次的 result 重复计入 inputTokens(#133055)。
68
70
  * 注意:估算前会移除图片内容,避免 base64 图片数据导致 token 严重偏高。
69
71
  */
70
72
  static estimateTrailingToolResultTokens(history: any[]): number;
@@ -31,6 +31,7 @@ import type { AgentOutputType, getAllMcpTools as getAllMcpToolsFn, MaxTurnsExcee
31
31
  import type { TextOutput, UnknownContext, UserContent } from '@openai/agents-core/types';
32
32
  import type { AcpTerminalStateItem, FileHistorySnapshotItem, ModelUsageItem, ResendForkNoticeItem } from './custom-input-item-types.js';
33
33
  export * from './custom-input-item-types.js';
34
+ export type { RunStreamEvent } from '@openai/agents-core';
34
35
  export type Agent<TContext = UnknownContext, TOutput extends AgentOutputType = TextOutput> = AgentTypeCtor<TContext, TOutput>;
35
36
  export type RunContext<TContext = UnknownContext> = RunContextTypeCtor<TContext>;
36
37
  export type Runner = RunnerTypeCtor;
@@ -64,4 +64,10 @@ export interface CheckpointFileChangeStats {
64
64
  additions: number;
65
65
  /** 删除行数 */
66
66
  deletions: number;
67
+ /**
68
+ * 行数为近似值(PTC/Code Mode 兜底:files 来自本轮 trackFile 快照,additions/deletions
69
+ * 暂记 0)。需要精确行数的调用方(如 TUI rewind 面板)据此异步调用
70
+ * compareWithCurrentFiles 补齐后清除本标记。仅内存态,不持久化。
71
+ */
72
+ approximate?: boolean;
67
73
  }
@@ -83,7 +83,13 @@ export declare enum HookEvent {
83
83
  FILE_CHANGED = "FileChanged",
84
84
  CWD_CHANGED = "CwdChanged",
85
85
  /** Terminal event; does not support continueRequest. */
86
- FINAL_STOP = "FinalStop"
86
+ FINAL_STOP = "FinalStop",
87
+ /**
88
+ * Triggered when a user-typed command/skill expands into a prompt, before
89
+ * it reaches the model. Can block the expansion.
90
+ * Claude Code parity: matcher filters on `command_name`.
91
+ */
92
+ USER_PROMPT_EXPANSION = "UserPromptExpansion"
87
93
  }
88
94
  /** Hook script stdout payload. */
89
95
  export interface HookOutput {
@@ -1,6 +1,8 @@
1
1
  export * from './agent/openai-agents-types.js';
2
2
  export * from './agent-home/agent-home-envelope-body.js';
3
3
  export * from './utils/abort-utils.js';
4
+ export * from './utils/retry-backoff.js';
5
+ export * from './utils/retry-policy.js';
4
6
  export * from './settings/settings-types.js';
5
7
  export * from './tools/tool-permission-types.js';
6
8
  export * from './tools/tool-permission-messages.js';
@@ -17,10 +17,26 @@ export declare class StreamTimeoutError extends CustomError {
17
17
  }
18
18
  /**
19
19
  * placeholder:空 200 / 心跳占位,拦截器最多切一次备站,会话层终态。
20
- * reasoning-only:已流出思考、finish_reason=error 且无可用输出(#63761 / #122115),
21
- * 会话层允许 1 次有界重试。
20
+ * reasoning-only:已流出思考、finish_reason=error 且无可用输出(#63761 / #122115)。
21
+ * no-token:finish_reason=error 到达时一个模型 token 都没有(连 reasoning 也没有)。
22
+ *
23
+ * reasoning-only 与 no-token 按「上游瞬时失败」处理,会话层按 error 恢复预算重试——
24
+ * 但仅限流没跑太久的那些:已经烧满上游硬时限的同样形态重跑必然再次跑满,由
25
+ * `isRetryableEmptyStreamError` 按 {@link EmptyStreamError.elapsedMs} 收口(#132616)。
26
+ * placeholder 必须与 no-token 分开——两者共用一个值时,放开 no-token 会连带
27
+ * 推翻空 200 的终态判定。
28
+ */
29
+ export type EmptyStreamKind = 'placeholder' | 'reasoning-only' | 'no-token';
30
+ /**
31
+ * 空流错误的结构化 category,两条上报通道共用一个值。
32
+ *
33
+ * ACP 侧 `classifyErrorAsRequestError` 早就用它(前端按此映射业务码 3008「模型服务未返回消息」);
34
+ * stream-json 侧此前没有任何结构化维度,`errors_info` 整体缺席,sandbox-proxy 的
35
+ * `BuildErrorMessageFromCLIErrors` 只能兜底成 `category=internal`,再由
36
+ * `ClassifyInBandPromptError` 推出 `error_origin=cli`——把上游故障记成 CLI 内部错误。
37
+ * 挂到错误对象的 `data` 上让两条通道读到同一个值,不再各说各话。
22
38
  */
23
- export type EmptyStreamKind = 'placeholder' | 'reasoning-only';
39
+ export declare const EMPTY_STREAM_ERROR_CATEGORY = "empty_model_response";
24
40
  /**
25
41
  * 空流错误
26
42
  * 语义上仍然是"上游没有提供模型输出",所以继承 StreamTimeoutError
@@ -29,10 +45,26 @@ export type EmptyStreamKind = 'placeholder' | 'reasoning-only';
29
45
  * 典型触发:某些 OpenAI 兼容网关在后端异常时没有透传错误码,而是发一帧全空
30
46
  * `{"delta":{"role":"assistant","content":"","tool_calls":[],"refusal":""},"finish_reason":""}`
31
47
  * 然后直接关闭连接——用户看到的现象是 cbc 当前轮"空响应"并被 ACP 分类为 refusal。
48
+ *
49
+ * message **必须**按 kind 分开写:三种 kind 共用一句「only placeholder chunks」会谎报失败形态。
50
+ * 0924 沙箱实测的 reasoning-only 样本里上游发了 20397 帧 / 9.5 MB 真实 reasoning,
51
+ * 与「只有占位帧」正相反;而下游报表、看板、排障全靠这个字符串归因,于是把上游
52
+ * ~900s 时限问题记成了 CLI 内部错误(#132616)。
32
53
  */
33
54
  export declare class EmptyStreamError extends StreamTimeoutError {
34
55
  readonly emptyStreamKind: EmptyStreamKind;
35
- constructor(chunkCount: number, totalBytes: number, kind?: EmptyStreamKind);
56
+ /**
57
+ * 流从打开到判定空流的时长。
58
+ *
59
+ * 用来区分「上游瞬时抖动(秒级空响应)」和「跑满上游硬时限(0924 实测 ~900s)」——
60
+ * 后者重跑同一段 prompt 必然再次跑满,重试只是把静默时长翻倍,见
61
+ * `isRetryableEmptyStreamError` 的时长闸门。
62
+ */
63
+ readonly elapsedMs: number;
64
+ readonly data: Readonly<{
65
+ category: "empty_model_response";
66
+ }>;
67
+ constructor(chunkCount: number, totalBytes: number, kind?: EmptyStreamKind, elapsedMs?: number);
36
68
  }
37
69
  /**
38
70
  * 认证缺失错误
@@ -63,6 +63,7 @@ export declare enum ToolNames {
63
63
  WAIT_FOR_MCP_SERVERS = "WaitForMcpServers",
64
64
  WORKFLOW = "Workflow",
65
65
  VIDEO_GEN = "VideoGen",
66
+ AUDIO_TRANSCRIBE = "AudioTranscribe",
66
67
  REPORT_FINDINGS = "ReportFindings",
67
68
  MONITOR = "Monitor",
68
69
  LIST_AGENTS = "ListAgents",
@@ -0,0 +1,30 @@
1
+ /**
2
+ * 自动恢复链的统一口径:最多 3 次,1s 起步、2 倍指数退避(基准 1s → 2s → 4s)。
3
+ *
4
+ * 适用于会话层的 error / 网络 / 流超时恢复,以及模型层的连接级透明重试。
5
+ * 第 1 层请求级(429/502/503 等)不带网关 retry_policy 时仍保持自己的 500ms 基数,
6
+ * 所以这里只共享算法,基数与上限由调用方传入。
7
+ */
8
+ export declare const MAX_RECOVERY_RETRIES = 3;
9
+ export declare const RECOVERY_RETRY_BASE_DELAY_MS = 1000;
10
+ export declare const RECOVERY_RETRY_MAX_DELAY_MS = 32000;
11
+ export interface ExponentialBackoffOptions {
12
+ baseDelayMs: number;
13
+ maxDelayMs: number;
14
+ random?: () => number;
15
+ }
16
+ /**
17
+ * `base * 2^(attempt-1)` 封顶到 `maxDelayMs`,再做 25% 下减抖动(区间 `[0.75x, 1x]`)。
18
+ *
19
+ * 必须下减而不是上加:上加会让实际等待越过 `maxDelayMs` 25%,调用方对封顶的承诺就不成立。
20
+ * `attempt` 从 1 起,小于 1 按 1 处理。
21
+ */
22
+ export declare function computeExponentialBackoffMs(attempt: number, options: ExponentialBackoffOptions): number;
23
+ export declare function computeRecoveryBackoffMs(attempt: number, random?: () => number): number;
24
+ /**
25
+ * 可取消的等待。`signal` 在等待前或等待中 abort 时返回 `false`,正常等满返回 `true`。
26
+ *
27
+ * 返回布尔而不是 reject:恢复链上的调用方拿到 `false` 后要自己决定退还额度、跳过发起,
28
+ * 用异常表达会把「用户取消」和「真正的错误」混在一条 catch 路径里。
29
+ */
30
+ export declare function waitForRecoveryBackoff(ms: number, signal?: AbortSignal): Promise<boolean>;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * 模型网关在 HTTP 错误体里下发的重试指示,与 `code` / `msg` / `displayMsg` 同层:
3
+ *
4
+ * ```json
5
+ * { "code": 11101, "msg": "...", "retry_policy": { "retry": false }, "displayMsg": { ... } }
6
+ * ```
7
+ *
8
+ * - `force-retry`:策略是普通对象且 `retry !== false`(含 `true`、缺 `retry` 键、类型异常)。
9
+ * 只在本地已判定可重试的范围内把请求级重试提到 3 次,不扩大可重试状态码。
10
+ * - `forbid-retry`:策略是普通对象且 `retry === false`。不重试、不换模型、不重放备站、不做鉴权刷新重试。
11
+ * - `unset`:字段缺失、`null`、数组或其他非对象形态,完全按原有逻辑处理。
12
+ *
13
+ * 只有显式 `false` 才阻断:网关形态小改动时宁可多试一次,也不要静默丧失恢复能力。
14
+ */
15
+ export type RetryPolicyDecision = 'force-retry' | 'forbid-retry' | 'unset';
16
+ export declare const RETRY_POLICY_FIELD = "retry_policy";
17
+ /**
18
+ * 按固定层级找 `retry_policy` 原值,返回第一个存在的值(可能是非法形态,由调用方裁决)。
19
+ *
20
+ * 同一份策略会以三种形态出现:网关原始错误体(顶层或 `data` / `error.data`)、错误分析器
21
+ * 规范化后的 `{ error: { code, message, data } }`、SDK 包装后的 APIError(`error.data`,
22
+ * 外层再包一层时为 `error.error.data`)。层级写死、不递归,避免在任意嵌套里误捡字段。
23
+ */
24
+ export declare function findRetryPolicy(source: unknown): unknown;
25
+ export declare function decideRetryPolicy(policy: unknown): RetryPolicyDecision;
26
+ export declare function resolveRetryPolicy(source: unknown): RetryPolicyDecision;
@@ -194,7 +194,15 @@ export declare class WorkflowExecution {
194
194
  abortAgent(key: string, reason: string): boolean;
195
195
  private buildSpec;
196
196
  private makeStartedRecord;
197
- /** Prompt 截到 ≤4KB,与 resultPreview 同口径 */
197
+ /**
198
+ * Prompt 截到 ≤4KB,与 resultPreview 同口径。
199
+ *
200
+ * **OOM 防护 · 父串不钉**:agentLog 长期驻留 ≤200 条 record(每 run),
201
+ * 若这里直接 `prompt.slice(0, max)` 返回,V8 会让该 substring 共享原 `prompt`
202
+ * 的 backing buffer —— 主 chat 一段 100KB 的用户输入,只要有一条 record
203
+ * 引用 4KB slice,整段 100KB 都无法被 GC。改走 `truncateAndCopyString`
204
+ * 强制 detach 到独立 buffer,length/marker 语义保持不变。
205
+ */
198
206
  static previewPrompt(prompt: string): string;
199
207
  private handleCacheHit;
200
208
  private markFailedAndEmit;
@@ -238,6 +246,11 @@ export declare class WorkflowExecution {
238
246
  * 不至于像一坨 `{"results":[{"url":"...","title":"..."}` 横向铺满终端
239
247
  * - 失败回落到 `String()`
240
248
  * - undefined / null → undefined(让 record.resultPreview 自然缺省)
249
+ *
250
+ * **OOM 防护 · 父串不钉**:同 previewPrompt —— agentLog 长期驻留,slice
251
+ * 会共享原始文本 backing buffer,导致原本可回收的大 result 被 record 钉住。
252
+ * 走 `truncateAndCopyString` 物化有界父串(短值同样 copy),
253
+ * length/marker 语义保持不变。
241
254
  */
242
255
  static previewOf(result: unknown): string | undefined;
243
256
  }
@@ -129,6 +129,13 @@ export declare class WorkflowManagerImpl implements WorkflowManager {
129
129
  * 1. meta.description
130
130
  * 2. args 是字符串(CC v2.1 标准形态) → 直接截断
131
131
  * 3. args 是对象且有 .question(老形态兜底,保留兼容)
132
+ *
133
+ * **OOM 防护 · 父串不钉**:args/question 分支的 200 字符截断 走
134
+ * `truncateAndCopyString` —— description 会经 `initialRecord` → `finalRecord`
135
+ * → `recent[].record`(队列上限 50)长期驻留;直接 `.slice(0, 200)` 会让
136
+ * substring 共享原始 args 的 backing buffer,一段几十 KB 的用户输入被 200
137
+ * 字符预览钉住。长度语义保持不变(≤200 原样、>200 截到 200,不带 marker)。
138
+ * meta.description 走 JSDoc 元数据、既不是 slice 也无长度截断,保留原逻辑。
132
139
  */
133
140
  private deriveDescription;
134
141
  }
@@ -76,6 +76,11 @@ export declare class WorktreeServiceImpl implements IWorktreeService {
76
76
  * 删除分支(如果存在)
77
77
  */
78
78
  private deleteBranchIfExists;
79
+ /**
80
+ * 回滚失败的 git worktree add:此时 worktree 可能未完整检出,
81
+ * 不能依赖从 worktreePath 反查仓库,统一以主仓库为准清理目录、记录和分支。
82
+ */
83
+ private rollbackFailedAdd;
79
84
  /**
80
85
  * 带重试的分支删除
81
86
  * git worktree remove 后文件系统可能尚未释放锁,
@@ -22,6 +22,8 @@ export declare class WorktreeSessionManagerImpl implements IWorktreeSessionManag
22
22
  * 在进程生命周期内维护
23
23
  */
24
24
  private currentSession;
25
+ /** 当前进行中的删除操作,避免重复退出事件并发删除同一个 worktree。 */
26
+ private removeOperation;
25
27
  private setSessionProgress;
26
28
  /**
27
29
  * 创建 worktree 会话
@@ -68,6 +70,7 @@ export declare class WorktreeSessionManagerImpl implements IWorktreeSessionManag
68
70
  * 4. 清除会话状态
69
71
  */
70
72
  removeWorktree(): Promise<WorktreeExitOperationResult | undefined>;
73
+ private performRemoveWorktree;
71
74
  /**
72
75
  * 处理退出
73
76
  * 检测变更并根据情况显示退出选项或自动清理
@@ -42,8 +42,15 @@ export declare const REQUEST_ID_HEADER = "X-Request-ID";
42
42
  export declare const ROOT_REQUEST_ID_HEADER = "X-Root-Request-ID";
43
43
  /** 父会话 ID,子 Agent / team member 模型请求携带,主 Agent 不带 */
44
44
  export declare const PARENT_CONVERSATION_ID_HEADER = "X-Parent-Conversation-ID";
45
- /** Agent 角色:main / subagent / team,主 Agent 也显式携带 */
45
+ /**
46
+ * Role of the model call: main / subagent / team, `auxiliary` for one-shot helpers and
47
+ * `compaction` for compaction summaries (Claude Code `x-claude-code-request-class`).
48
+ */
46
49
  export declare const AGENT_TYPE_HEADER = "X-Agent-Type";
50
+ /** Compaction calls: class of the compaction, manual / auto / reactive (Claude Code `x-claude-code-compaction`). */
51
+ export declare const COMPACTION_HEADER = "X-Compaction";
52
+ /** First agent-loop call after a compaction: its class (Claude Code `x-claude-code-context-compacted`). */
53
+ export declare const CONTEXT_COMPACTED_HEADER = "X-Context-Compacted";
47
54
  export declare const CONVERSATION_ID_HEADER = "X-Conversation-ID";
48
55
  export declare const SESSION_ID_HEADER = "X-Session-ID";
49
56
  export declare const CONVERSATION_REQUEST_ID_HEADER = "X-Conversation-Request-ID";
@@ -15,6 +15,8 @@ export declare class CloudProductProvider implements ProductProvider {
15
15
  protected readonly cloudProductManager: CloudProductManager;
16
16
  /** Process-wide duplicate suppression for consecutive skip reasons. */
17
17
  protected lastSkipReason?: string;
18
+ /** Consecutive skips carrying {@link lastSkipReason}; drives the log schedule. */
19
+ protected consecutiveSkips: number;
18
20
  protected init(): void;
19
21
  /**
20
22
  * 记录一次「本轮没去拉云端配置」并返回空配置。
@@ -23,6 +25,13 @@ export declare class CloudProductProvider implements ProductProvider {
23
25
  * 「没去拉」与「拉失败」(#58031 因此被误判为模型未上线)。
24
26
  *
25
27
  * level:warn=非预期状态值得排查,info=按配置有意禁用,避免污染告警。
28
+ *
29
+ * 只打「同因首次」是不够的(#129839):启动期竞态下第 1 轮因登录态未就绪判
30
+ * config-disabled,第 2 轮补拉**同因再跳一次**却被整条吃掉,现场只看得到一行,
31
+ * 误以为补拉已生效,实际 /model 一直是打包内置旧清单。改为按 1/2/4/8… 的次数
32
+ * 打点并带上连续计数:既保留原有的抗刷屏意图(`provide()` 每轮都跑,历史上无
33
+ * 条件 info 影响过流水线,见 9c1d1e55df0),又让「连续跳过」这一状态始终可见,
34
+ * 且行数是 O(log n) 有界的。现场日志不采集 debug,所以不能降级为 debug。
26
35
  */
27
36
  protected skip(ctx: ProductProviderContext, reason: string, level: 'warn' | 'info'): ProductConfiguration;
28
37
  provide(ctx: ProductProviderContext): Promise<ProductConfiguration>;
@@ -1,4 +1,5 @@
1
1
  export * from './types/index.js';
2
+ export { pickMarketSkillIdFromMeta } from './pick-market-skill-id.js';
2
3
  export * from './product-protocol.js';
3
4
  export * from './repository-protocol.js';
4
5
  export * from './product-manager.js';
@@ -23,4 +24,5 @@ export * from './abtest-feature-aliases.js';
23
24
  export * from './abtest-service.js';
24
25
  export * from './tool-control-catalog.js';
25
26
  export * from './static-resource-url.js';
27
+ export * from './tencent-docs-endpoint.js';
26
28
  export { AUTO_MODEL_ID, AUTO_MODEL_IDS, AUTO_TIER_MODEL_IDS, AUTO_TIER_MODELS, expandAutoModelIds, isAutoModelId, replaceAutoModelInList, replaceAutoWithTierModels, shouldReplaceAutoWithTierModels, } from './auto-tier-models.js';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 从市场 meta(`_skillhub_meta` / `_knot_meta` / `_user_meta` / `_marketplace_meta`)
3
+ * 里取市场身份。
4
+ *
5
+ * 四级取值链取写侧最宽的那份。现实中 Knot 的 `slug` 恒非空
6
+ * (`knot.ts` 的 `metaSlug = slug || skillName || String(id)`),因此 `skill_id`
7
+ * 与 `id` 两级是防御性的;保留它们是为了让读写两侧用**同一个函数**,
8
+ * 而不是让读侧比写侧窄。
9
+ *
10
+ * 契约归属 `@genie/product`:写侧(listNonPlatformSkillBlacklistItems)与读侧
11
+ * (Skill.skillId / skill_info 遥测)必须算出同一个值,否则黑名单执法漏拦。
12
+ */
13
+ export declare function pickMarketSkillIdFromMeta(meta: Record<string, unknown> | null | undefined): string | undefined;
@@ -0,0 +1,37 @@
1
+ import type { ProductConfiguration } from './types/product.js';
2
+ /**
3
+ * 腾讯文档企业版(VPC / 专享版 / 私有化)MCP 域名派生(占位符渲染方案)。
4
+ *
5
+ * 纯函数集,从 `workbuddy-server/src/connector/enterprise-variant/default-variants.ts`
6
+ * 抽出为双 fork 共享实现:agent-cli 与 workbuddy-server 的插件物化渲染、
7
+ * `resolveTencentDocsSkillApiBase` 三处统一消费,禁止各放一份。
8
+ */
9
+ /** endpoint 首段追加该后缀派生腾讯文档 MCP 子域(与 connector variant 链路一致)。 */
10
+ export declare const TENCENT_DOCS_HOST_SUFFIX = "-docs";
11
+ /** 派生 MCP URL 的 path 部分(渲染只取 origin,path 仅为保持与 connector 派生同构)。 */
12
+ export declare const TENCENT_DOCS_MCP_PATH = "/api/v6/open/agent/mcp";
13
+ /**
14
+ * 归一化私有化 MCP host 为 origin(保留下发协议,裸 host 按 https 补全,非法值返回 undefined)。
15
+ *
16
+ * 与 `auth-service.ts::buildLexiangPrivateOrigin` 同语义:私有化下发可能是 `http://`(内网环境),
17
+ * 必须保留下发协议,不强制升 https。带路径时只取 origin。
18
+ * 安全前提:privateMcpHost 来自受信 daemon 产品配置(/v3/config),不来自用户输入。
19
+ */
20
+ export declare function buildPrivateMcpOrigin(privateMcpHost?: string): string | undefined;
21
+ export declare function deriveSubdomainBasedMcpUrl(endpoint: string | undefined, hostSuffix: string, mcpPath: string): string | undefined;
22
+ /**
23
+ * 派生腾讯文档企业版 VPC MCP URL:`privateMcpHost`(即 `privateHost.docHost`)下发即为准,
24
+ * 缺省回退 endpoint 首段 `-docs` 派生。
25
+ */
26
+ export declare function deriveTencentDocsVpcMcpUrlFromEndpoint(endpoint?: string, privateMcpHost?: string): string | undefined;
27
+ /**
28
+ * 解析插件占位符渲染用的腾讯文档 API base origin,取值优先级(与 connector variant 链路对齐):
29
+ *
30
+ * `privateHost.docHost ?? endpoint -docs 派生(取 origin) ?? undefined`
31
+ *
32
+ * - 专享版(Cloud-Hosted):不下发 docHost,值为 endpoint 派生;
33
+ * - 私有化:`/v3/config` 下发 docHost,下发即为准;
34
+ * - 公有云 / 旗舰版:endpoint 空 / 不可派生 → undefined,渲染回填默认域
35
+ * (但旗舰版根本不配置 `exclusivePluginVariants`,渲染整体不执行)。
36
+ */
37
+ export declare function resolveTencentDocsApiBase(config: ProductConfiguration | undefined): string | undefined;
@@ -5,9 +5,9 @@
5
5
  * marketplace MCP Servers must not enter the policy surface implicitly.
6
6
  */
7
7
  export declare const WORKBUDDY_PRODUCT_TOOL_NAMES: readonly ['WebFetch', 'WebSearch', 'ImageGen', 'VideoGen', 'ListMcpResources', 'ReadMcpResource', 'DelegateTool', 'WeChatReply', 'WeComReply'];
8
- export declare const WORKBUDDY_REQUIRED_TOOL_NAMES: readonly ['Read', 'Write', 'Edit', 'MultiEdit', 'Glob', 'Grep', 'Bash', 'PowerShell', 'AskUserQuestion', 'TaskCreate', 'TaskGet', 'TaskUpdate', 'TaskList', 'TaskStop', 'TaskOutput', 'Skill', 'LSP', 'Agent', 'SendMessage', 'ToolSearch', 'DeferExecuteTool', 'EnterPlanMode', 'ExitPlanMode', 'present_files', 'widget_guidelines', 'show_widget', 'TeamCreate', 'TeamDelete', 'SkillManage', 'StructuredOutput'];
8
+ export declare const WORKBUDDY_REQUIRED_TOOL_NAMES: readonly ['Read', 'Write', 'Edit', 'MultiEdit', 'Glob', 'Grep', 'Bash', 'PowerShell', 'AskUserQuestion', 'TaskCreate', 'TaskGet', 'TaskUpdate', 'TaskList', 'TaskStop', 'TaskOutput', 'Skill', 'LSP', 'Agent', 'SendMessage', 'ToolSearch', 'DeferExecuteTool', 'EnterPlanMode', 'ExitPlanMode', 'present_files', 'widget_guidelines', 'show_widget', 'TeamCreate', 'TeamDelete', 'StructuredOutput'];
9
9
  export declare const WORKBUDDY_BUNDLED_MCP_SERVERS: {
10
- readonly 'connector-proxy': readonly ['connect_cloud_service', 'connect_open_platform', 'workbuddy_sites_deploy', 'workbuddy_sites_unpublish', 'workbuddy_cloud_service', 'workbuddy_update_app_preview_entry', 'workbuddy_marketplace_skill', 'domain_search', 'automation_update', 'conversation_search', 'pick_location', 'agent_mail_upload_attachment', 'agent_mail_download_attachment', 'search_plugins', 'suggest_plugin_install'];
10
+ readonly 'connector-proxy': readonly ['connect_cloud_service', 'connect_open_platform', 'workbuddy_sites_deploy', 'workbuddy_sites_unpublish', 'workbuddy_cloud_service', 'workbuddy_update_app_preview_entry', 'search_and_install_skills', 'skill_management', 'domain_search', 'automation_update', 'conversation_search', 'pick_location', 'agent_mail_upload_attachment', 'agent_mail_download_attachment', 'search_plugins', 'suggest_plugin_install', 'list_installed_plugins', 'uninstall_plugin'];
11
11
  readonly miora: readonly ['miora_write_canvas', 'miora_open_canvas', 'miora_text_to_image', 'miora_edit_image', 'miora_text_to_video', 'miora_frame_to_video', 'miora_reference_to_video', 'miora_query_task'];
12
12
  readonly sheetagent: readonly ['resolve_local_excel', 'get_cell_ranges', 'set_cell_range', 'read_table', 'run_command', 'search_data', 'calculate_single_formula', 'calculate_formulas', 'fill_formula'];
13
13
  readonly weixinpay: readonly ['weixinpay_register', 'weixinpay_feedback', 'weixinpay_retry_pay', 'weixinpay_pay'];
@@ -63,6 +63,18 @@ export interface RemoteConfiguration {
63
63
  customAgentMaxCount?: number;
64
64
  mcpSchemaUrl?: string;
65
65
  mcpOauthTimeout?: number;
66
+ /**
67
+ * 海外桌面版内置 Outlook MCP 的 Microsoft Entra public-client 配置。
68
+ *
69
+ * clientId 不是秘密;桌面包严禁携带 client secret。OAuth 使用 PKCE +
70
+ * localhost 随机端口回调,权限 scope 由客户端代码固定,远端配置不能扩权。
71
+ */
72
+ outlookMcp?: {
73
+ enabled?: boolean;
74
+ clientId?: string;
75
+ /** common / organizations / consumers / fixed tenant UUID */
76
+ tenantId?: string;
77
+ };
66
78
  enterpriseLimitHintCN?: string;
67
79
  enterpriseLimitHint?: string;
68
80
  /** 生图工具超时时间(毫秒) */