@tencent-ai/agent-harness 0.2.0-beta.2 → 0.2.0-beta.4

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 (182) hide show
  1. package/CHANGELOG.md +40 -2
  2. package/cli/CHANGELOG.md +64 -0
  3. package/cli/dist-server/shared.cjs +450 -329
  4. package/cli/dist-server/types/node/acp/acp-protocol.d.ts +8 -0
  5. package/cli/dist-server/types/node/bash-sandbox/bash-sandbox-protocol.d.ts +3 -0
  6. package/cli/dist-server/types/node/cli/cli-protocol.d.ts +3 -0
  7. package/cli/dist-server/types/node/cli/stream-json-protocol.d.ts +8 -1
  8. package/cli/dist-server/types/node/loopback/server-protocol.d.ts +5 -0
  9. package/cli/dist-server/types/node/sensitive-content/sensitive-content-protocol.d.ts +7 -0
  10. package/cli/dist-server/types/node/server/boot.d.ts +7 -4
  11. package/{lib/components → cli/dist-server/types/node/server/formats}/acp/acp-error-model.d.ts +1 -1
  12. package/{lib/components → cli/dist-server/types/node/server/formats}/acp/acp-protocol.d.ts +2 -3
  13. package/cli/dist-server/types/node/server/formats/acp/index.d.ts +12 -0
  14. package/cli/dist-server/types/node/server/formats/acp/projection.d.ts +10 -0
  15. package/cli/dist-server/types/node/server/index.d.ts +1 -1
  16. package/cli/dist-server/types/node/server/sessions.d.ts +3 -2
  17. package/cli/dist-server/types/node/server/types.d.ts +59 -7
  18. package/cli/dist-server/types/node/tools/tool-protocol.d.ts +39 -24
  19. package/cli/dist-server/types/vendor/cbc-core/node/agent/agent-protocol.d.ts +31 -2
  20. package/cli/dist-server/types/vendor/cbc-core/node/agent/agent-purpose-protocol.d.ts +8 -4
  21. package/cli/dist-server/types/vendor/cbc-core/node/agent/agent-purpose-scope.d.ts +46 -0
  22. package/cli/dist-server/types/vendor/cbc-core/node/agent/agent-service.d.ts +26 -3
  23. package/cli/dist-server/types/vendor/cbc-core/node/agent/index.d.ts +3 -0
  24. package/cli/dist-server/types/vendor/cbc-core/node/agent/model-call-failure.d.ts +9 -0
  25. package/cli/dist-server/types/vendor/cbc-core/node/agent/model-step-sequence.d.ts +11 -0
  26. package/cli/dist-server/types/vendor/cbc-core/node/agent/runner-factory.d.ts +43 -9
  27. package/cli/dist-server/types/vendor/cbc-core/node/agent/tool-call-loop-guard-protocol.d.ts +1 -1
  28. package/cli/dist-server/types/vendor/cbc-core/node/agent/tool-call-loop-pattern.d.ts +9 -8
  29. package/cli/dist-server/types/vendor/cbc-core/node/context/compaction-lineage.d.ts +39 -0
  30. package/cli/dist-server/types/vendor/cbc-core/node/context/context-compact-summarizer.d.ts +2 -0
  31. package/cli/dist-server/types/vendor/cbc-core/node/context/context-protocol.d.ts +17 -0
  32. package/cli/dist-server/types/vendor/cbc-core/node/context/index.d.ts +2 -0
  33. package/cli/dist-server/types/vendor/cbc-core/node/context/mods-bridge.d.ts +115 -0
  34. package/cli/dist-server/types/vendor/cbc-core/node/context/pre-message-compact-strategy.d.ts +1 -2
  35. package/cli/dist-server/types/vendor/cbc-core/node/message-queue/followup-queue-protocol.d.ts +3 -2
  36. package/cli/dist-server/types/vendor/cbc-core/node/message-queue/followup-queue.d.ts +1 -1
  37. package/cli/dist-server/types/vendor/cbc-core/node/message-queue/steer-input-buffer-protocol.d.ts +4 -0
  38. package/cli/dist-server/types/vendor/cbc-core/node/session/can-use-tool.d.ts +4 -0
  39. package/cli/dist-server/types/vendor/cbc-core/node/session/index.d.ts +1 -0
  40. package/cli/dist-server/types/vendor/cbc-core/node/session/interruption-service.d.ts +8 -0
  41. package/cli/dist-server/types/vendor/cbc-core/node/session/model-request-retry-phase.d.ts +16 -0
  42. package/cli/dist-server/types/vendor/cbc-core/node/session/model-response-interceptors.d.ts +15 -0
  43. package/cli/dist-server/types/vendor/cbc-core/node/session/session-manager-host-protocol.d.ts +3 -2
  44. package/cli/dist-server/types/vendor/cbc-core/node/session/session-manager.d.ts +37 -3
  45. package/cli/dist-server/types/vendor/cbc-core/node/session/session-protocol.d.ts +59 -5
  46. package/cli/dist-server/types/vendor/cbc-core/node/session/session-run-state-machine-protocol.d.ts +14 -1
  47. package/cli/dist-server/types/vendor/cbc-core/node/session/stream-timeout-retry-budget.d.ts +8 -1
  48. package/cli/dist-server/types/vendor/cbc-core/node/trace/turn-context.d.ts +28 -1
  49. package/cli/dist-server/types/vendor/cbc-core/node/utils/command-message-utils.d.ts +20 -0
  50. package/cli/dist-server/types/vendor/cbc-core/node/utils/history-utils.d.ts +4 -4
  51. package/cli/dist-server/types/vendor/cbc-core/node/utils/input-item-utils.d.ts +9 -1
  52. package/cli/dist-server/types/vendor/cbc-core/node/utils/token-utils.d.ts +3 -1
  53. package/cli/dist-server/types/vendor/cbc-shared/node/agent/openai-agents-types.d.ts +1 -0
  54. package/cli/dist-server/types/vendor/cbc-shared/node/checkpoint/checkpoint-types.d.ts +6 -0
  55. package/cli/dist-server/types/vendor/cbc-shared/node/model/model-errors.d.ts +30 -2
  56. package/cli/dist-server/types/workspace/agent-client-protocol/lib/common/index.d.ts +1 -0
  57. package/cli/dist-server/types/workspace/agent-client-protocol/lib/common/prompt-codec.d.ts +4 -0
  58. package/cli/dist-server/types/workspace/agent-client-protocol/lib/common/sandbox-rule-context.d.ts +38 -0
  59. package/cli/dist-server/types/workspace/agent-client-protocol/lib/common/types.d.ts +15 -1
  60. package/cli/dist-server/types/workspace/authentication/lib/common/account-scoped-external-link-authentication-provider.d.ts +3 -3
  61. package/cli/dist-server/types/workspace/authentication/lib/common/authentication-manager.d.ts +6 -0
  62. package/cli/dist-server/types/workspace/authentication/lib/common/authentication-observation.d.ts +36 -0
  63. package/cli/dist-server/types/workspace/authentication/lib/common/authentication-protocol.d.ts +21 -0
  64. package/cli/dist-server/types/workspace/authentication/lib/common/external-link-authentication-provider.d.ts +20 -4
  65. package/cli/dist-server/types/workspace/authentication/lib/common/index.d.ts +1 -0
  66. package/cli/dist-server/types/workspace/cbc-checkpoint/lib/node/checkpoint/checkpoint-protocol.d.ts +2 -0
  67. package/cli/dist-server/types/workspace/cbc-checkpoint/lib/node/checkpoint/checkpoint-service.d.ts +1 -0
  68. package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/agent-protocol.d.ts +31 -2
  69. package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/agent-purpose-protocol.d.ts +8 -4
  70. package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/agent-purpose-scope.d.ts +46 -0
  71. package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/agent-service.d.ts +26 -3
  72. package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/index.d.ts +3 -0
  73. package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/model-call-failure.d.ts +9 -0
  74. package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/model-step-sequence.d.ts +11 -0
  75. package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/runner-factory.d.ts +43 -9
  76. package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/tool-call-loop-guard-protocol.d.ts +1 -1
  77. package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/tool-call-loop-pattern.d.ts +9 -8
  78. package/cli/dist-server/types/workspace/cbc-core/lib/node/context/compaction-lineage.d.ts +39 -0
  79. package/cli/dist-server/types/workspace/cbc-core/lib/node/context/context-compact-summarizer.d.ts +2 -0
  80. package/cli/dist-server/types/workspace/cbc-core/lib/node/context/context-protocol.d.ts +17 -0
  81. package/cli/dist-server/types/workspace/cbc-core/lib/node/context/index.d.ts +2 -0
  82. package/cli/dist-server/types/workspace/cbc-core/lib/node/context/mods-bridge.d.ts +115 -0
  83. package/cli/dist-server/types/workspace/cbc-core/lib/node/context/pre-message-compact-strategy.d.ts +1 -2
  84. package/cli/dist-server/types/workspace/cbc-core/lib/node/message-queue/followup-queue-protocol.d.ts +3 -2
  85. package/cli/dist-server/types/workspace/cbc-core/lib/node/message-queue/followup-queue.d.ts +1 -1
  86. package/cli/dist-server/types/workspace/cbc-core/lib/node/message-queue/steer-input-buffer-protocol.d.ts +4 -0
  87. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/can-use-tool.d.ts +4 -0
  88. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/index.d.ts +1 -0
  89. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/interruption-service.d.ts +8 -0
  90. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/model-request-retry-phase.d.ts +16 -0
  91. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/model-response-interceptors.d.ts +15 -0
  92. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-manager-host-protocol.d.ts +3 -2
  93. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-manager.d.ts +37 -3
  94. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-protocol.d.ts +59 -5
  95. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-run-state-machine-protocol.d.ts +14 -1
  96. package/cli/dist-server/types/workspace/cbc-core/lib/node/session/stream-timeout-retry-budget.d.ts +8 -1
  97. package/cli/dist-server/types/workspace/cbc-core/lib/node/trace/turn-context.d.ts +28 -1
  98. package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/command-message-utils.d.ts +20 -0
  99. package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/history-utils.d.ts +4 -4
  100. package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/input-item-utils.d.ts +9 -1
  101. package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/token-utils.d.ts +3 -1
  102. package/cli/dist-server/types/workspace/cbc-shared/lib/node/agent/openai-agents-types.d.ts +1 -0
  103. package/cli/dist-server/types/workspace/cbc-shared/lib/node/checkpoint/checkpoint-types.d.ts +6 -0
  104. package/cli/dist-server/types/workspace/cbc-shared/lib/node/model/model-errors.d.ts +30 -2
  105. package/cli/dist-server/types/workspace/cbc-worktree/lib/node/worktree/worktree-service.d.ts +5 -0
  106. package/cli/dist-server/types/workspace/core/lib/common/protocol.d.ts +8 -1
  107. package/cli/dist-server/types/workspace/product/lib/common/index.d.ts +1 -0
  108. package/cli/dist-server/types/workspace/product/lib/common/tencent-docs-endpoint.d.ts +37 -0
  109. package/cli/dist-server/types/workspace/product/lib/common/types/config.d.ts +12 -0
  110. package/cli/dist-server/types/workspace/product/lib/common/types/features.d.ts +17 -9
  111. package/cli/dist-server/types/workspace/product/lib/common/types/product.d.ts +15 -0
  112. package/cli/dist-server/types/workspace/prompts/lib/common/product-prompt-provider.d.ts +3 -1
  113. package/cli/dist-server/types/workspace/prompts/lib/common/prompt-protocol.d.ts +6 -0
  114. package/cli/dist-server/types/workspace/sandbox-cli/lib/common/center-protocol.generated.d.ts +5 -0
  115. package/cli/dist-server/types/workspace/sandbox-cli/lib/common/file-policy.d.ts +4 -1
  116. package/cli/dist-server/types/workspace/sandbox-cli/lib/common/http-policy.d.ts +20 -0
  117. package/cli/dist-server/types/workspace/sandbox-cli/lib/common/rule-config.d.ts +10 -0
  118. package/cli/dist-server/types/workspace/sandbox-cli/lib/node/sandbox-center-client.d.ts +3 -0
  119. package/cli/dist-server/types/workspace/telemetry/lib/common/event/types/craft.d.ts +43 -3
  120. package/cli/package.json +1 -1
  121. package/cli/product.cloudhosted.json +1 -803
  122. package/cli/product.internal.json +1 -1057
  123. package/cli/product.ioa.json +1 -1515
  124. package/cli/product.json +1 -2189
  125. package/cli/product.selfhosted.json +1 -364
  126. package/cli/vendor/shim/brokered-bin/7z +675 -0
  127. package/cli/vendor/shim/brokered-bin/7za +675 -0
  128. package/cli/vendor/shim/brokered-bin/7zz +675 -0
  129. package/cli/vendor/shim/brokered-bin/rar +675 -0
  130. package/cli/vendor/shim/brokered-bin/tar +675 -0
  131. package/cli/vendor/shim/brokered-bin/zip +187 -0
  132. package/docs/acp-v2.md +19 -0
  133. package/docs/client.md +7 -0
  134. package/docs/in-process.md +26 -2
  135. package/docs/product.md +4 -0
  136. package/docs/protocol.md +10 -2
  137. package/docs/server.md +2 -0
  138. package/lib/agent/v2.js +1 -1
  139. package/lib/application/services.js +1 -1
  140. package/lib/auth/module.d.ts +3 -1
  141. package/lib/auth/module.js +1 -1
  142. package/lib/client/client.js +1 -1
  143. package/lib/client/mcp.d.ts +1 -1
  144. package/lib/client/mcp.js +1 -1
  145. package/lib/components/acp-mcp-transport.d.mts +84 -1
  146. package/lib/components/question-elicitation.d.mts +20 -1
  147. package/lib/components/sandbox.d.mts +2 -0
  148. package/lib/components/sandbox.mjs +1 -0
  149. package/lib/components/{acp/acp-prompt-input.d.ts → session/prompt-input.d.ts} +1 -1
  150. package/lib/components/session-replay.d.mts +8 -7
  151. package/lib/components/session-replay.mjs +1 -1
  152. package/lib/effect-runtime/concurrency.d.mts +2 -4
  153. package/lib/effect-runtime/concurrency.mjs +1 -1
  154. package/lib/effect-runtime/mcp-lifecycle.mjs +1 -1
  155. package/lib/effect-runtime/process-runtime-context.d.ts +5 -1
  156. package/lib/harness/create-harness.js +1 -1
  157. package/lib/integration/agent-integration.d.ts +5 -0
  158. package/lib/protocol/acp-v2-credits.d.ts +10 -0
  159. package/lib/protocol/acp-v2-credits.js +1 -0
  160. package/lib/protocol/acp-v2-private-client.d.ts +1 -10
  161. package/lib/runtime/codebuddy-auth.d.ts +5 -3
  162. package/lib/runtime/codebuddy-auth.js +1 -1
  163. package/lib/runtime/private-runtime-role.js +1 -1
  164. package/lib/session/agent-backend.d.ts +3 -0
  165. package/lib/session/agent-backend.js +1 -1
  166. package/lib/session/config-defaults.d.ts +4 -0
  167. package/lib/session/config-defaults.js +1 -0
  168. package/lib/session/config-store.d.ts +1 -1
  169. package/lib/session/config-store.js +1 -1
  170. package/lib/session/replay.d.ts +3 -3
  171. package/lib/session/replay.js +1 -1
  172. package/lib/session/server-config.d.ts +11 -2
  173. package/lib/session/server-config.js +1 -1
  174. package/lib/session/server-events.d.ts +10 -8
  175. package/lib/session/server-events.js +1 -1
  176. package/lib/session/server-interactions.js +1 -1
  177. package/lib/session/server-mcp.js +1 -1
  178. package/lib/subagent/history.js +1 -1
  179. package/package.json +26 -20
  180. package/lib/components/acp/acp-client-channel.d.ts +0 -36
  181. package/lib/components/acp/acp-mcp-transport.d.ts +0 -84
  182. package/lib/components/acp/acp-question-elicitation.d.ts +0 -20
@@ -34,6 +34,33 @@ export interface TurnContext {
34
34
  /** Canonical id assigned when the external user input is admitted. */
35
35
  conversationRequestId?: string;
36
36
  }
37
+ export interface RequestOwner {
38
+ readonly session: Session;
39
+ readonly requestId: string;
40
+ readonly turn: TurnContext;
41
+ latestExecution?: object;
42
+ }
43
+ export type RequestTerminalOutcome = 'written' | 'failed' | 'unconfirmed';
44
+ export interface RequestTerminal {
45
+ readonly attempt: object;
46
+ outcome?: RequestTerminalOutcome;
47
+ readonly completed: Promise<RequestTerminalOutcome>;
48
+ }
49
+ export declare function getRequestOwner(ref: object): RequestOwner | undefined;
50
+ export declare function getRequestExecution(ref: object): object | undefined;
51
+ export declare function associateRequestOwner(ref: object, owner: RequestOwner, execution?: object): void;
52
+ /** Carry physical execution through admission without inventing a request owner. */
53
+ export declare function associateRequestExecution(ref: object, execution: object): void;
54
+ /** Reserve completion ownership at admission, retaining the prior result if startup fails. */
55
+ export declare function beginRequestExecution(owner: RequestOwner, execution: object): void;
56
+ /** A failed startup never owns a result; restore only the execution it actually replaced. */
57
+ export declare function abandonRequestExecution(execution: object): Session['resultSubject']['value'];
58
+ export declare function getRequestTerminal(owner: RequestOwner, destination: string): RequestTerminal | undefined;
59
+ export declare function claimRequestTerminal(owner: RequestOwner, destination: string, attempt: object): boolean;
60
+ export declare function settleRequestTerminal(owner: RequestOwner, destination: string, attempt: object, outcome: RequestTerminalOutcome): void;
61
+ /** The admission boundary, not trace binding, creates a new logical request. */
62
+ export declare function admitRequestOwner(session: Session, requestId: string): RequestOwner;
63
+ export declare function runInRequestOwner<T>(owner: RequestOwner, callback: () => T): T;
37
64
  /** Transient provider-data key; stripped before history/model persistence. */
38
65
  export declare const TURN_CARRIER_CANDIDATE_KEY = "codebuddy.ai/turnCarrierCandidate";
39
66
  export declare const BAGGAGE_KEY_SESSION_ID = "codebuddy.session_id";
@@ -83,7 +110,7 @@ export declare function bindCurrentTurnContext(session: Session, conversationReq
83
110
  /** Carrier for one exact admitted request; never returns the latest other turn. */
84
111
  export declare function turnCarrierForRequest(session: Session, conversationRequestId: string | undefined): W3CTraceContextMeta;
85
112
  /** Release an exact request binding. */
86
- export declare function releaseTurnContext(session: Session, conversationRequestId: string | undefined): void;
113
+ export declare function releaseTurnContext(session: Session, conversationRequestId: string | undefined, owner?: RequestOwner): void;
87
114
  /** The current turn as an injectable three-key carrier; `{}` outside a turn. */
88
115
  export declare function currentTurnCarrier(): W3CTraceContextMeta;
89
116
  /**
@@ -58,6 +58,26 @@ export declare abstract class CommandMessageUtils {
58
58
  * 解析XML格式的命令输出
59
59
  */
60
60
  static parseOutput(xmlText: string): ParseCommandMessage | undefined;
61
+ /**
62
+ * 是否为本地命令在会话历史里留下的记账项:caveat、命令回显(`<command-name>`)、
63
+ * 命令输出(`<local-command-stdout>`)、本地 bash 的输入输出、plan 输出。
64
+ *
65
+ * 这些 item 的 role 是 user、也不带 skipRun,因此按「真实用户消息」判定会命中;
66
+ * 但它们只是本地命令的痕迹,**不代表用户开启了新一轮对话**。调用方(如 TUI 的
67
+ * loading 计时器)需要区分「新一轮」和「本地命令留痕」时用这个判据。
68
+ *
69
+ * 识别口径复用 parseInput / parseOutput / parsePlanOutput,避免调用方各自
70
+ * 维护一份 XML 标签清单而漂移。
71
+ */
72
+ static isLocalCommandRecord(text: string): boolean;
73
+ /**
74
+ * {@link isLocalCommandRecord} 的 item 版本。
75
+ *
76
+ * 必须读 **原始** content:`MessageContentUtils.extractTextContent` 已经把命令 XML
77
+ * 拆开(`<command-name>/doctor</command-name>` → `/doctor`),拿它的结果再判就永远
78
+ * 判不出来。
79
+ */
80
+ static isLocalCommandRecordItem(item: UserMessageItem): boolean;
61
81
  /**
62
82
  * 解析计划输出
63
83
  */
@@ -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 是否成功"!
@@ -1,6 +1,6 @@
1
1
  import { type AcpTerminalStateItem, type AgentInputItem, type AssistantMessageItem, type CustomTitleItem, type FileHistorySnapshotItem, type FunctionCallItem, type FunctionCallResultItem, type HookBlockingDetail, HookEvent, type ResendForkNoticeItem, type UserMessageItem } from '../../../../cbc-shared/lib/node/index.js';
2
2
  type ItemStatus = 'in_progress' | 'completed' | 'incomplete';
3
- export type HookStatus = 'success' | 'blocked' | 'warning' | 'error';
3
+ export type HookStatus = 'success' | 'blocked' | 'warning' | 'error' | 'mod-log';
4
4
  interface ItemOptions {
5
5
  readonly skipRun?: boolean;
6
6
  readonly status?: ItemStatus;
@@ -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;
@@ -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
  }
@@ -20,11 +20,23 @@ export declare class StreamTimeoutError extends CustomError {
20
20
  * reasoning-only:已流出思考、finish_reason=error 且无可用输出(#63761 / #122115)。
21
21
  * no-token:finish_reason=error 到达时一个模型 token 都没有(连 reasoning 也没有)。
22
22
  *
23
- * reasoning-only 与 no-token 都是上游瞬时失败,会话层按 error 恢复预算重试;
23
+ * reasoning-only 与 no-token 按「上游瞬时失败」处理,会话层按 error 恢复预算重试——
24
+ * 但仅限流没跑太久的那些:已经烧满上游硬时限的同样形态重跑必然再次跑满,由
25
+ * `isRetryableEmptyStreamError` 按 {@link EmptyStreamError.elapsedMs} 收口(#132616)。
24
26
  * placeholder 必须与 no-token 分开——两者共用一个值时,放开 no-token 会连带
25
27
  * 推翻空 200 的终态判定。
26
28
  */
27
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` 上让两条通道读到同一个值,不再各说各话。
38
+ */
39
+ export declare const EMPTY_STREAM_ERROR_CATEGORY = "empty_model_response";
28
40
  /**
29
41
  * 空流错误
30
42
  * 语义上仍然是"上游没有提供模型输出",所以继承 StreamTimeoutError
@@ -33,10 +45,26 @@ export type EmptyStreamKind = 'placeholder' | 'reasoning-only' | 'no-token';
33
45
  * 典型触发:某些 OpenAI 兼容网关在后端异常时没有透传错误码,而是发一帧全空
34
46
  * `{"delta":{"role":"assistant","content":"","tool_calls":[],"refusal":""},"finish_reason":""}`
35
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)。
36
53
  */
37
54
  export declare class EmptyStreamError extends StreamTimeoutError {
38
55
  readonly emptyStreamKind: EmptyStreamKind;
39
- 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);
40
68
  }
41
69
  /**
42
70
  * 认证缺失错误
@@ -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 后文件系统可能尚未释放锁,
@@ -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";
@@ -24,4 +24,5 @@ export * from './abtest-feature-aliases.js';
24
24
  export * from './abtest-service.js';
25
25
  export * from './tool-control-catalog.js';
26
26
  export * from './static-resource-url.js';
27
+ export * from './tencent-docs-endpoint.js';
27
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,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;
@@ -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
  /** 生图工具超时时间(毫秒) */
@@ -340,6 +340,7 @@ export declare enum ProductFeature {
340
340
  SkillSecurityScan = "SkillSecurityScan",
341
341
  SkillRecommend = "SkillRecommend",
342
342
  BeforeConversationRecommend = "BeforeConversationRecommend",
343
+ AfterConversationRecommend = "AfterConversationRecommend",
343
344
  /**
344
345
  * 是否开启文本选择操作功能
345
346
  */
@@ -514,20 +515,12 @@ export declare enum ProductFeature {
514
515
  /**
515
516
  * 是否禁用积分入口(用户菜单「积分」项 + 设置页账户「积分」区块)
516
517
  * 设置为 true 时,完全隐藏积分入口(不展示菜单项与账户面板积分区块)。
517
- * 用于无积分体系的发行版(如海外版 workbuddy-ai)。
518
+ * 用于无积分体系的发行版(如私有化、云托管和 Custom 产品)。
518
519
  * 注意与 ShowCreditsBalance 区分:ShowCreditsBalance 控制「是否展示积分数值」,
519
520
  * 本 flag 控制「积分入口是否存在」。
520
521
  * @default false(默认有积分入口)
521
522
  */
522
523
  DisableCreditsEntry = "DisableCreditsEntry",
523
- /**
524
- * 是否禁用设置页「订阅和用量」入口
525
- * 设置为 true 时隐藏该导航项,并禁止通过 Settings hash 直达该页面。
526
- * 积分入口仍可保留;点击后回落到设置页「个人主页」。
527
- * 用于海外版等保留积分体系、但不开放订阅管理页的发行版。
528
- * @default false(默认显示)
529
- */
530
- DisableSubscriptionUsageEntry = "DisableSubscriptionUsageEntry",
531
524
  /**
532
525
  * 是否禁用侧栏「邀请好友」入口
533
526
  * 设置为 true 时隐藏入口及邀请积分弹窗。
@@ -1428,6 +1421,21 @@ export declare enum ProductFeature {
1428
1421
  * @default false
1429
1422
  */
1430
1423
  EnableClawChannelControl = "EnableClawChannelControl",
1424
+ /**
1425
+ * 是否隐藏设置面板「助理设置 → 远程渠道」整个区块(含微信助理 / 企微机器人 /
1426
+ * QQ 机器人等通道卡片与定时任务企微 bot 推送卡片)。
1427
+ *
1428
+ * 仅隐藏 UI 入口,不影响「上下文管理」(Session Management)等其他区块。
1429
+ * 专享版(Cloud-Hosted)与私有化(Self-Hosted)定制渠道不支持远程助理渠道,
1430
+ * 在 workbuddy-custom base 的 productFeatures 配置 true(私有化构建自动继承);
1431
+ * 运行期也可经 /v3/config 下发覆盖(如放开某个已部署网关的租户)。
1432
+ *
1433
+ * - 旗舰版(标准渠道):不配置该 key → 不禁用,远程渠道照常展示(fail-open)
1434
+ * - 专享版 / 私有化:配置 true → 隐藏区块;缺省(未配置)同旗舰版展示
1435
+ *
1436
+ * @default false
1437
+ */
1438
+ DisableClawRemoteChannels = "DisableClawRemoteChannels",
1431
1439
  /**
1432
1440
  * 是否启用 AI 代码入库率统计能力
1433
1441
  *
@@ -400,6 +400,21 @@ export interface ProductConfiguration {
400
400
  marketplaceVersionCheckIntervalMs?: number;
401
401
  /** 内置插件配置,用于初始化时自动安装 */
402
402
  builtInMarketPlugins?: BuiltInPluginConfig[];
403
+ /**
404
+ * 专享版/私有化插件变体映射(占位符渲染方案)。
405
+ *
406
+ * key 为 marketplace 内 plugin name,value 为同 marketplace 下变体目录名(与原插件
407
+ * source 目录同级)。**构建期**消费:`apps/workbuddy-desktop` 的
408
+ * `syncBundledRuntimeAssets()`(`scripts/exclusive-plugin-build-render.mjs`)在
409
+ * 拷贝 resources → dist 之后渲染变体内的 `${TENCENT_DOCS_DOMAIN}` 占位符为
410
+ * `privateHost.docHost ?? endpoint -docs 派生`(域名不可得时构建失败,不回填
411
+ * 默认域),再用变体内容覆盖原插件目录。运行时物化链零感知。
412
+ *
413
+ * 仅专享版/私有化打包配置写入(`build/patches/workbuddy-custom/product.json`,
414
+ * 私有化构建自动继承 base);旗舰版/C 端不写 → 字段 undefined → 构建期
415
+ * 零触发(fail-safe)。
416
+ */
417
+ exclusivePluginVariants?: Record<string, string>;
403
418
  /**
404
419
  * 内置插件合并配置(通过 Unleash 远程下发)
405
420
  * 与 product.json 和 /v3/config 的 builtInMarketPlugins 结果合并
@@ -1,9 +1,11 @@
1
1
  import { Application, ApplicationLifecycle } from '@celljs/core';
2
- import { ProductManager } from '../../../product/lib/common/index.js';
2
+ import { ProductConfigurationContext, ProductManager } from '../../../product/lib/common/index.js';
3
3
  import { BehaviorSubject } from 'rxjs';
4
4
  import { PromptProvider, PromptTemplate } from './prompt-protocol.js';
5
5
  export declare class ProductPromptProvider implements PromptProvider, ApplicationLifecycle<Application> {
6
6
  protected readonly productManager: ProductManager;
7
+ protected readonly executionConfiguration?: ProductConfigurationContext;
7
8
  productTemplateSubject: BehaviorSubject<PromptTemplate[]>;
9
+ getScopedTemplates(): PromptTemplate[] | undefined;
8
10
  initialize(): void;
9
11
  }
@@ -39,6 +39,12 @@ export interface PromptManager {
39
39
  }
40
40
  export interface PromptProvider {
41
41
  productTemplateSubject: BehaviorSubject<PromptTemplate[]>;
42
+ /**
43
+ * Replace this provider's process templates for the current execution.
44
+ * undefined uses the process snapshot; [] explicitly supplies no templates.
45
+ * The result must never be published to the shared template map.
46
+ */
47
+ getScopedTemplates?(): PromptTemplate[] | undefined;
42
48
  }
43
49
  export interface PromptEvaluator {
44
50
  priority(context: PromptRenderContext): Promise<number>;
@@ -846,6 +846,7 @@ export interface FileRuleItem {
846
846
  comment?: string;
847
847
  isDirectory: boolean;
848
848
  category?: RuleCategory;
849
+ ruleRef?: string;
849
850
  }
850
851
  /**
851
852
  * 网络端点规则(三态)。action 为 allow/deny/ask。endpoint 为 host/host:port/ip/CIDR/*。
@@ -856,6 +857,7 @@ export interface NetworkRuleItem {
856
857
  action: RuleAction;
857
858
  comment?: string;
858
859
  category?: RuleCategory;
860
+ ruleRef?: string;
859
861
  }
860
862
  /**
861
863
  * HTTP 明文拦截规则(三态)。命中 target 的明文 HTTP 请求按 action 处理。
@@ -900,6 +902,7 @@ export interface CmdRuleItem {
900
902
  comment?: string;
901
903
  reason?: string;
902
904
  category?: RuleCategory;
905
+ ruleRef?: string;
903
906
  }
904
907
  /**
905
908
  * AddFileRule 请求 data — 追加文件规则(按 category 分层存储)。category 缺省 = session(2026-08-24 R-HST-2 改定,原为 temp)。
@@ -1158,6 +1161,8 @@ export interface MatchedRuleInfo {
1158
1161
  * 失败),category 仅作审计/展示(规则列表 join key 的一部分)。
1159
1162
  */
1160
1163
  category?: RuleCategory;
1164
+ /** 宿主提供的不透明规则身份;沙箱仅随实际胜出规则透传,不用于裁决。 */
1165
+ ruleRef?: string;
1161
1166
  }
1162
1167
  /**
1163
1168
  * bidirectional:cli 侧消费 center 响应时需反序列化(ProcessExit 统一决策记录
@@ -1,5 +1,5 @@
1
1
  import { type FileRuleActions } from './file-rule-action.js';
2
- import type { SecurityCenterFileRule, SecurityCenterOrderedRuleSet } from './rule-config.js';
2
+ import { type SecurityCenterFileRule, type SecurityCenterOrderedRuleBase, type SecurityCenterOrderedRuleSet } from './rule-config.js';
3
3
  export { getLegacyFilePreset } from './legacy-file-preset.js';
4
4
  export declare const FILE_POLICY_PRESET_VERSION = 4;
5
5
  export declare function getDefaultFileRuleSet(platform: NodeJS.Platform): SecurityCenterOrderedRuleSet<SecurityCenterFileRule>;
@@ -14,11 +14,14 @@ export interface FilePolicyRule {
14
14
  isDirectory: boolean;
15
15
  action: string;
16
16
  comment?: string;
17
+ ruleRef?: string;
17
18
  }
18
19
  /** Existing Security Center storage/UI format. Conversion preserves order and actions. */
19
20
  export interface FileRuleSettings extends FileRuleActions {
20
21
  path: string;
21
22
  isDirectory?: boolean;
23
+ id?: string;
24
+ source?: SecurityCenterOrderedRuleBase['source'];
22
25
  }
23
26
  export declare const FILE_ACTION_ASK = "read=ask|write=ask|delete=ask";
24
27
  export declare const FILE_ACTION_PROTECT_MUTATION = "read=allow|write=ask|delete=ask";
@@ -31,6 +31,26 @@ export interface HttpInterceptPolicyConfig {
31
31
  }
32
32
  /** 默认 HTTP 明文请求拦截策略:远程默认询问、本地默认放行。 */
33
33
  export declare const DEFAULT_HTTP_INTERCEPT_CONFIG: HttpInterceptPolicyConfig;
34
+ /**
35
+ * 本地段枚举,对齐 `network-policy.ts` 的 `isLoopbackHost` 判定口径(仅 loopback),
36
+ * 由 http-intercept-policy.spec.ts 的对齐用例锁定。
37
+ *
38
+ * Center 侧 `handle_plain_http` 按 rules 顺序匹配 target(支持域名/IP/CIDR/`*`),
39
+ * 故把这些本地段以 `action=<local 态>` 前置于 `*` 兜底之前,使 loopback 走
40
+ * local 策略、其余走 remote 策略。Center 不内置 local/remote 语义,完全由
41
+ * 这张表表达。target 不自动覆盖子域,故 `localhost` 之外还须带 `*.localhost`
42
+ * (isLoopbackHost 把 `foo.localhost` 判为 loopback)。
43
+ *
44
+ * 「本地」口径 = 仅 loopback(产品决策:局域网/链路本地不算本地):
45
+ * - hostname `localhost` 及其子域(`*.localhost`)
46
+ * - IPv4 loopback `127.0.0.0/8`
47
+ * - IPv6 loopback `::1`
48
+ *
49
+ * **不包含**局域网私有段(10/172.16/192.168)、链路本地(169.254,含云元数据
50
+ * 169.254.169.254)、ULA(fc00::/7)等——这些按远程策略处理(默认 ask→弹窗,
51
+ * 堵 SSRF)。
52
+ */
53
+ export declare const LOCAL_HTTP_INTERCEPT_TARGETS: readonly string[];
34
54
  /** buildHttpInterceptRules 的输入:SandboxConfig 的网络子集。 */
35
55
  export interface HttpInterceptRulesInput {
36
56
  /** 用户三态配置(缺省 remote='ask' / local='allow')。 */
@@ -1,5 +1,15 @@
1
1
  export type SecurityCenterRuleSource = 'enterprise' | 'preset' | 'user';
2
2
  export type SecurityCenterRuleAction = 'allow' | 'ask' | 'deny';
3
+ /**
4
+ * 有界传输身份;原始配置ID与权限匹配语义保持不变。
5
+ *
6
+ * 不直接透传原始 id:Windows 命中身份经审计共享内存传回宿主,槽位固定为
7
+ * `rec_rule_ref[96]`(含 NUL),而企业规则 id 来自远端配置、没有长度上限,
8
+ * 截断会定位到错误规则。固定 68 字符的 hash 保证三平台都能精确定位。
9
+ * source 与 domain 参与计算,避免不同来源或类别的同名 id 被当成同一条规则。
10
+ * 仅用于展示定位,不得作为授权条件、删除键或裁决缓存键。
11
+ */
12
+ export declare function createSandboxRuleRef(domain: 'file' | 'command' | 'network', source: SecurityCenterRuleSource, originalId: string): string;
3
13
  export interface SecurityCenterOrderedRuleBase {
4
14
  id: string;
5
15
  source: SecurityCenterRuleSource;
@@ -17,12 +17,14 @@ export interface SandboxCenterRequestOptions {
17
17
  export type SandboxRulesCommand = (typeof SANDBOX_RULES_COMMANDS)[keyof typeof SANDBOX_RULES_COMMANDS];
18
18
  export type SandboxCenterCommand = SandboxCommand;
19
19
  export interface SandboxCenterFileRule {
20
+ ruleRef?: string;
20
21
  path: string;
21
22
  action: string;
22
23
  comment?: string;
23
24
  isDirectory: boolean;
24
25
  }
25
26
  export interface SandboxCenterNetworkRule {
27
+ ruleRef?: string;
26
28
  endpoint: string;
27
29
  action: string;
28
30
  comment?: string;
@@ -33,6 +35,7 @@ export interface SandboxCenterMachRule {
33
35
  comment?: string;
34
36
  }
35
37
  export interface SandboxCenterCmdRule {
38
+ ruleRef?: string;
36
39
  cmd: string;
37
40
  args: string[];
38
41
  action: string;
@@ -22,10 +22,29 @@ export interface CraftRequest {
22
22
  actionCode: string;
23
23
  }
24
24
  /**
25
- * 聊天请求发送遥测数据接口
25
+ * Role of a model call, mirroring Claude Code's `x-claude-code-request-class`: main /
26
+ * subagent / team agent loops, `compaction` summary calls, and `auxiliary` for other
27
+ * one-shot helpers (title, WebFetch analysis, ...) on any Session.
28
+ */
29
+ export type AgentType = 'main' | 'subagent' | 'team' | 'auxiliary' | 'compaction';
30
+ /**
31
+ * Compaction class, with the values of Claude Code's `x-claude-code-compaction` /
32
+ * `x-claude-code-context-compacted` headers.
33
+ */
34
+ export type CompactionKind = 'manual' | 'auto' | 'reactive';
35
+ /**
36
+ * Why the harness compacted (`blocking_limit` / `ptl` are Claude Code's terms):
37
+ *
38
+ * | trigger | kind | condition |
39
+ * |---|---|---|
40
+ * | `manual` | manual | `/compact` from any entry (TUI, IM, /server, typed command) |
41
+ * | `pre_message_threshold` | auto | before a user message, tokens ≥ `tokenUsageThresholds.inputTokens.preMessage` |
42
+ * | `cache_expired` | auto | before a user message, the used prompt cache is ≥ 1h old and tokens ≥ 50% of the budget |
43
+ * | `emergency_threshold` | auto | before a model call, tokens ≥ `tokenUsageThresholds.inputTokens.emergency`; the call is sent, then interrupted |
44
+ * | `blocking_limit` | auto | before a model call, tokens + max output would exceed the context budget; the call waits |
45
+ * | `ptl` | reactive | the model rejected the prompt as too long |
26
46
  */
27
- /** Agent 角色类型:main = 主 agent,subagent = fork 子 agent,team = 团队成员 agent */
28
- export type AgentType = 'main' | 'subagent' | 'team';
47
+ export type CompactionTrigger = 'manual' | 'pre_message_threshold' | 'cache_expired' | 'emergency_threshold' | 'blocking_limit' | 'ptl';
29
48
  export interface UserTaskFailedCreditRefundTelemetry {
30
49
  /** 用户 ID,对齐公共 userId 字段;业务侧显式传入,避免特定宿主未注入 UserinfoProvider 时缺失。 */
31
50
  userId: string;
@@ -74,6 +93,9 @@ export interface ToolCallLoopTelemetry {
74
93
  /** 重复序列的周期长度;连续同工具为 1。 */
75
94
  total: number;
76
95
  }
96
+ /**
97
+ * 聊天请求发送遥测数据接口
98
+ */
77
99
  export interface ChatRequestSendTelemetry {
78
100
  /** 聊天模式,枚举值:ask / chat */
79
101
  mode: string;
@@ -307,6 +329,20 @@ export interface ChatMessageSendTelemetry {
307
329
  isContextTruncated: boolean;
308
330
  /** 当前 stepCount 数值 */
309
331
  currentStepCount: number;
332
+ /**
333
+ * Agent-loop model call number within this conversation. Unlike
334
+ * `currentStepCount` it never resets (runs, compaction, resume); retries of
335
+ * one call share the number.
336
+ */
337
+ totalStepCount?: number;
338
+ /** Completed context compactions of this conversation when the call is sent; never resets. */
339
+ compactionCount?: number;
340
+ /** Compaction the call's context starts from (`cmp_*`, the JSONL boundary item id). */
341
+ compactionId?: string;
342
+ /** First call after a compaction: the compaction's class. */
343
+ contextCompacted?: CompactionKind;
344
+ /** Set with `contextCompacted`: why the harness compacted. */
345
+ compactionTrigger?: CompactionTrigger;
310
346
  /** 是否是自定义模型 */
311
347
  isCustomModel?: boolean;
312
348
  /**
@@ -352,6 +388,8 @@ export interface ChatMessageResponseTelemetry {
352
388
  requestId: string;
353
389
  /** 模型调用 ID */
354
390
  messageId: string;
391
+ /** Same value as the paired `chat_message_send.totalStepCount`. */
392
+ totalStepCount?: number;
355
393
  /** 模型 ID */
356
394
  requestModelId: string;
357
395
  /** 模型名称 */
@@ -425,6 +463,8 @@ export interface ChatToolActionTelemetry {
425
463
  messageId: string;
426
464
  /** 当前 stepCount 数值 */
427
465
  stepCount: number;
466
+ /** Agent-loop step (`chat_message_send.totalStepCount`) whose response requested this tool call. */
467
+ totalStepCount?: number;
428
468
  /** 工具 ID */
429
469
  toolCallId: string;
430
470
  /** 工具名称 */
package/cli/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tencent-ai/codebuddy-code",
3
- "version": "2.157.0",
3
+ "version": "2.159.0",
4
4
  "private": true,
5
5
  "description": "CodeBuddy runtime embedded in @tencent-ai/agent-harness",
6
6
  "license": "SEE LICENSE IN LICENSE.txt",