@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.
- package/CHANGELOG.md +44 -0
- package/README.md +1 -1
- package/cli/CHANGELOG.md +135 -0
- package/cli/dist-server/shared.cjs +455 -387
- package/cli/dist-server/types/node/acp/acp-protocol.d.ts +40 -12
- package/cli/dist-server/types/node/acp/usage-by-category-calculator.d.ts +21 -0
- package/cli/dist-server/types/node/bash-sandbox/bash-sandbox-protocol.d.ts +3 -0
- package/cli/dist-server/types/node/cli/cli-protocol.d.ts +3 -0
- package/cli/dist-server/types/node/cli/stream-json-protocol.d.ts +23 -2
- package/cli/dist-server/types/node/data-fs/index.d.ts +13 -1
- package/cli/dist-server/types/node/hooks/hook-protocol.d.ts +2 -2
- package/cli/dist-server/types/node/sensitive-content/sensitive-content-protocol.d.ts +7 -0
- package/cli/dist-server/types/node/server/boot.d.ts +7 -4
- package/{lib/components → cli/dist-server/types/node/server/formats}/acp/acp-error-model.d.ts +1 -1
- package/{lib/components → cli/dist-server/types/node/server/formats}/acp/acp-protocol.d.ts +2 -3
- package/cli/dist-server/types/node/server/formats/acp/index.d.ts +12 -0
- package/cli/dist-server/types/node/server/formats/acp/projection.d.ts +10 -0
- package/cli/dist-server/types/node/server/index.d.ts +1 -1
- package/cli/dist-server/types/node/server/sessions.d.ts +27 -2
- package/cli/dist-server/types/node/server/types.d.ts +65 -7
- package/cli/dist-server/types/node/settings/settings-protocol.d.ts +5 -0
- package/cli/dist-server/types/node/tools/tool-protocol.d.ts +128 -4
- package/cli/dist-server/types/vendor/cbc-core/node/agent/agent-protocol.d.ts +60 -2
- package/cli/dist-server/types/vendor/cbc-core/node/agent/agent-purpose-protocol.d.ts +8 -4
- package/cli/dist-server/types/vendor/cbc-core/node/agent/agent-purpose-scope.d.ts +46 -0
- package/cli/dist-server/types/vendor/cbc-core/node/agent/agent-service.d.ts +28 -3
- package/cli/dist-server/types/vendor/cbc-core/node/agent/index.d.ts +4 -0
- package/cli/dist-server/types/vendor/cbc-core/node/agent/interceptors/input-interceptors.d.ts +1 -6
- package/cli/dist-server/types/vendor/cbc-core/node/agent/model-call-failure.d.ts +9 -0
- package/cli/dist-server/types/vendor/cbc-core/node/agent/model-step-sequence.d.ts +11 -0
- package/cli/dist-server/types/vendor/cbc-core/node/agent/runner-factory.d.ts +56 -20
- package/cli/dist-server/types/vendor/cbc-core/node/agent/speaker-label.d.ts +44 -0
- package/cli/dist-server/types/vendor/cbc-core/node/agent/tool-call-loop-detector-service.d.ts +5 -4
- package/cli/dist-server/types/vendor/cbc-core/node/agent/tool-call-loop-guard-protocol.d.ts +1 -1
- package/cli/dist-server/types/vendor/cbc-core/node/agent/tool-call-loop-pattern.d.ts +16 -4
- package/cli/dist-server/types/vendor/cbc-core/node/context/compaction-lineage.d.ts +39 -0
- package/cli/dist-server/types/vendor/cbc-core/node/context/context-compact-summarizer.d.ts +2 -0
- package/cli/dist-server/types/vendor/cbc-core/node/context/context-protocol.d.ts +17 -0
- package/cli/dist-server/types/vendor/cbc-core/node/context/index.d.ts +1 -0
- package/cli/dist-server/types/vendor/cbc-core/node/context/pre-message-compact-strategy.d.ts +1 -2
- package/cli/dist-server/types/vendor/cbc-core/node/hooks/agent-trigger.d.ts +6 -22
- package/cli/dist-server/types/vendor/cbc-core/node/hooks/hook-protocol.d.ts +4 -1
- package/cli/dist-server/types/vendor/cbc-core/node/session/idle-queue-drain-service.d.ts +4 -56
- package/cli/dist-server/types/vendor/cbc-core/node/session/index.d.ts +4 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session/interruption-service.d.ts +63 -9
- package/cli/dist-server/types/vendor/cbc-core/node/session/model-request-retry-phase.d.ts +16 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session/model-response-interceptors.d.ts +33 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session/recovery-budget.d.ts +55 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-hook-manager.d.ts +15 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-manager-host-protocol.d.ts +3 -2
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-manager.d.ts +17 -4
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-persistence-error.d.ts +43 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-protocol.d.ts +110 -9
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-run-state-machine-protocol.d.ts +15 -1
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-runtime-lifecycle.d.ts +5 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-store.d.ts +150 -4
- package/cli/dist-server/types/vendor/cbc-core/node/session/stream-timeout-retry-budget.d.ts +20 -1
- package/cli/dist-server/types/vendor/cbc-core/node/trace/turn-context.d.ts +28 -1
- package/cli/dist-server/types/vendor/cbc-core/node/utils/command-message-utils.d.ts +20 -0
- package/cli/dist-server/types/vendor/cbc-core/node/utils/history-utils.d.ts +27 -4
- package/cli/dist-server/types/vendor/cbc-core/node/utils/index.d.ts +1 -0
- package/cli/dist-server/types/vendor/cbc-core/node/utils/input-item-utils.d.ts +8 -0
- package/cli/dist-server/types/vendor/cbc-core/node/utils/message-utils.d.ts +12 -0
- package/cli/dist-server/types/vendor/cbc-core/node/utils/model-utils.d.ts +7 -0
- package/cli/dist-server/types/vendor/cbc-core/node/utils/queue-dispatch-utils.d.ts +24 -2
- package/cli/dist-server/types/vendor/cbc-core/node/utils/session-utils.d.ts +4 -1
- package/cli/dist-server/types/vendor/cbc-core/node/utils/string-retention-utils.d.ts +4 -0
- package/cli/dist-server/types/vendor/cbc-core/node/utils/token-utils.d.ts +3 -1
- package/cli/dist-server/types/vendor/cbc-shared/node/agent/openai-agents-types.d.ts +1 -0
- package/cli/dist-server/types/vendor/cbc-shared/node/checkpoint/checkpoint-types.d.ts +6 -0
- package/cli/dist-server/types/vendor/cbc-shared/node/hooks/hook-types.d.ts +7 -1
- package/cli/dist-server/types/vendor/cbc-shared/node/index.d.ts +2 -0
- package/cli/dist-server/types/vendor/cbc-shared/node/model/model-errors.d.ts +36 -4
- package/cli/dist-server/types/vendor/cbc-shared/node/tools/tool-names.d.ts +1 -0
- package/cli/dist-server/types/vendor/cbc-shared/node/utils/retry-backoff.d.ts +30 -0
- package/cli/dist-server/types/vendor/cbc-shared/node/utils/retry-policy.d.ts +26 -0
- package/cli/dist-server/types/workspace/agent-client-protocol/lib/common/index.d.ts +1 -0
- package/cli/dist-server/types/workspace/agent-client-protocol/lib/common/sandbox-rule-context.d.ts +38 -0
- package/cli/dist-server/types/workspace/authentication/lib/common/account-scoped-external-link-authentication-provider.d.ts +5 -5
- package/cli/dist-server/types/workspace/authentication/lib/common/account-utils.d.ts +25 -0
- package/cli/dist-server/types/workspace/authentication/lib/common/authentication-manager.d.ts +8 -2
- package/cli/dist-server/types/workspace/authentication/lib/common/authentication-observation.d.ts +36 -0
- package/cli/dist-server/types/workspace/authentication/lib/common/authentication-protocol.d.ts +40 -2
- package/cli/dist-server/types/workspace/authentication/lib/common/external-link-authentication-provider.d.ts +21 -5
- package/cli/dist-server/types/workspace/authentication/lib/common/index.d.ts +1 -0
- package/cli/dist-server/types/workspace/authentication/lib/common/wx-authentication-provider.d.ts +2 -2
- package/cli/dist-server/types/workspace/cbc-checkpoint/lib/node/checkpoint/checkpoint-protocol.d.ts +2 -0
- package/cli/dist-server/types/workspace/cbc-checkpoint/lib/node/checkpoint/checkpoint-service.d.ts +1 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/agent-protocol.d.ts +60 -2
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/agent-purpose-protocol.d.ts +8 -4
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/agent-purpose-scope.d.ts +46 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/agent-service.d.ts +28 -3
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/index.d.ts +4 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/interceptors/input-interceptors.d.ts +1 -6
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/model-call-failure.d.ts +9 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/model-step-sequence.d.ts +11 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/runner-factory.d.ts +56 -20
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/speaker-label.d.ts +44 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/tool-call-loop-detector-service.d.ts +5 -4
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/tool-call-loop-guard-protocol.d.ts +1 -1
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/tool-call-loop-pattern.d.ts +16 -4
- package/cli/dist-server/types/workspace/cbc-core/lib/node/context/compaction-lineage.d.ts +39 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/context/context-compact-summarizer.d.ts +2 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/context/context-protocol.d.ts +17 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/context/index.d.ts +1 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/context/pre-message-compact-strategy.d.ts +1 -2
- package/cli/dist-server/types/workspace/cbc-core/lib/node/hooks/agent-trigger.d.ts +6 -22
- package/cli/dist-server/types/workspace/cbc-core/lib/node/hooks/hook-protocol.d.ts +4 -1
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/idle-queue-drain-service.d.ts +4 -56
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/index.d.ts +4 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/interruption-service.d.ts +63 -9
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/model-request-retry-phase.d.ts +16 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/model-response-interceptors.d.ts +33 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/recovery-budget.d.ts +55 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-hook-manager.d.ts +15 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-manager-host-protocol.d.ts +3 -2
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-manager.d.ts +17 -4
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-persistence-error.d.ts +43 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-protocol.d.ts +110 -9
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-run-state-machine-protocol.d.ts +15 -1
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-runtime-lifecycle.d.ts +5 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-store.d.ts +150 -4
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/stream-timeout-retry-budget.d.ts +20 -1
- package/cli/dist-server/types/workspace/cbc-core/lib/node/trace/turn-context.d.ts +28 -1
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/command-message-utils.d.ts +20 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/history-utils.d.ts +27 -4
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/index.d.ts +1 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/input-item-utils.d.ts +8 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/message-utils.d.ts +12 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/model-utils.d.ts +7 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/queue-dispatch-utils.d.ts +24 -2
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/session-utils.d.ts +4 -1
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/string-retention-utils.d.ts +4 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/token-utils.d.ts +3 -1
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/agent/openai-agents-types.d.ts +1 -0
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/checkpoint/checkpoint-types.d.ts +6 -0
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/hooks/hook-types.d.ts +7 -1
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/index.d.ts +2 -0
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/model/model-errors.d.ts +36 -4
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/tools/tool-names.d.ts +1 -0
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/utils/retry-backoff.d.ts +30 -0
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/utils/retry-policy.d.ts +26 -0
- package/cli/dist-server/types/workspace/cbc-workflow/lib/node/workflow/workflow-execution.d.ts +14 -1
- package/cli/dist-server/types/workspace/cbc-workflow/lib/node/workflow/workflow-manager.d.ts +7 -0
- package/cli/dist-server/types/workspace/cbc-worktree/lib/node/worktree/worktree-service.d.ts +5 -0
- package/cli/dist-server/types/workspace/cbc-worktree/lib/node/worktree/worktree-session.d.ts +3 -0
- package/cli/dist-server/types/workspace/core/lib/common/protocol.d.ts +8 -1
- package/cli/dist-server/types/workspace/product/lib/common/cloud-product-provider.d.ts +9 -0
- package/cli/dist-server/types/workspace/product/lib/common/index.d.ts +2 -0
- package/cli/dist-server/types/workspace/product/lib/common/pick-market-skill-id.d.ts +13 -0
- package/cli/dist-server/types/workspace/product/lib/common/tencent-docs-endpoint.d.ts +37 -0
- package/cli/dist-server/types/workspace/product/lib/common/tool-control-catalog.d.ts +2 -2
- package/cli/dist-server/types/workspace/product/lib/common/types/config.d.ts +12 -0
- package/cli/dist-server/types/workspace/product/lib/common/types/features.d.ts +63 -11
- package/cli/dist-server/types/workspace/product/lib/common/types/language-model.d.ts +66 -0
- package/cli/dist-server/types/workspace/product/lib/common/types/product.d.ts +22 -1
- package/cli/dist-server/types/workspace/sandbox-cli/lib/common/backup-policy.d.ts +10 -1
- package/cli/dist-server/types/workspace/sandbox-cli/lib/common/center-protocol.generated.d.ts +375 -4
- package/cli/dist-server/types/workspace/sandbox-cli/lib/common/file-policy.d.ts +5 -2
- package/cli/dist-server/types/workspace/sandbox-cli/lib/common/http-policy.d.ts +20 -0
- package/cli/dist-server/types/workspace/sandbox-cli/lib/common/rule-config.d.ts +10 -0
- package/cli/dist-server/types/workspace/sandbox-cli/lib/node/sandbox-center-client.d.ts +219 -0
- package/cli/dist-server/types/workspace/telemetry/lib/common/event/types/craft.d.ts +43 -3
- package/cli/package.json +1 -1
- package/cli/product.cloudhosted.json +4 -4
- package/cli/product.internal.json +268 -45
- package/cli/product.ioa.json +354 -161
- package/cli/product.json +338 -352
- package/cli/product.selfhosted.json +2 -2
- package/cli/vendor/shim/brokered-bin/7z +675 -0
- package/cli/vendor/shim/brokered-bin/7za +675 -0
- package/cli/vendor/shim/brokered-bin/7zz +675 -0
- package/cli/vendor/shim/brokered-bin/rar +675 -0
- package/cli/vendor/shim/brokered-bin/tar +675 -0
- package/cli/vendor/shim/brokered-bin/zip +187 -0
- package/docs/README.md +1 -0
- package/docs/in-process.md +42 -2
- package/docs/protocol.md +7 -1
- package/docs/server.md +2 -0
- package/lib/agent/v2.js +1 -1
- package/lib/application/services.d.ts +3 -1
- package/lib/application/services.js +1 -1
- package/lib/client/client.js +1 -1
- package/lib/client/mcp.d.ts +1 -1
- package/lib/client/mcp.js +1 -1
- package/lib/components/acp-mcp-transport.d.mts +84 -1
- package/lib/components/question-elicitation.d.mts +20 -1
- package/lib/components/sandbox-center.d.mts +2 -0
- package/lib/components/sandbox-center.mjs +1 -0
- package/lib/components/{acp/acp-prompt-input.d.ts → session/prompt-input.d.ts} +1 -1
- package/lib/components/session-config.d.mts +2 -0
- package/lib/components/session-config.mjs +1 -1
- package/lib/components/session-replay.d.mts +6 -7
- package/lib/components/session-replay.mjs +1 -1
- package/lib/effect-runtime/mcp-lifecycle.mjs +1 -1
- package/lib/harness/create-harness.js +1 -1
- package/lib/harness/runtime.js +1 -1
- package/lib/harness/types.d.ts +3 -0
- package/lib/integration/agent-integration.d.ts +5 -0
- package/lib/integration/executor-supervisor.js +1 -1
- package/lib/public.d.ts +1 -0
- package/lib/runtime/private-runtime-role.js +1 -1
- package/lib/runtime/sandbox-center.d.ts +21 -0
- package/lib/runtime/sandbox-center.js +1 -0
- package/lib/server/public.d.ts +1 -0
- package/lib/session/agent-backend.d.ts +5 -0
- package/lib/session/agent-backend.js +1 -1
- package/lib/session/config-defaults.d.ts +4 -0
- package/lib/session/config-defaults.js +1 -0
- package/lib/session/config-store.d.ts +1 -1
- package/lib/session/config-store.js +1 -1
- package/lib/session/local-fs.js +1 -1
- package/lib/session/replay.d.ts +2 -2
- package/lib/session/replay.js +1 -1
- package/lib/session/server-config.d.ts +11 -2
- package/lib/session/server-config.js +1 -1
- package/lib/session/server-events.d.ts +10 -8
- package/lib/session/server-events.js +1 -1
- package/lib/session/server-interactions.js +1 -1
- package/lib/session/server-mcp.js +1 -1
- package/package.json +27 -16
- package/lib/components/acp/acp-client-channel.d.ts +0 -36
- package/lib/components/acp/acp-mcp-transport.d.ts +0 -84
- package/lib/components/acp/acp-question-elicitation.d.ts +0 -20
- package/lib/session/local-options.d.ts +0 -50
- package/lib/session/local-options.js +0 -1
package/cli/dist-server/types/workspace/cbc-core/lib/node/session/idle-queue-drain-service.d.ts
CHANGED
|
@@ -1,44 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* =====================
|
|
6
|
-
* 用户在 agent 还在跑(streaming 末尾、工具执行中等)时输入新消息,UI 调
|
|
7
|
-
* `agentService.run([userMsg])` 进来,`MessageQueueAgentRunInterceptor`
|
|
8
|
-
* (input-interceptors.ts:77-84) 看到 `inConversation=true`,把消息塞进
|
|
9
|
-
* `session.queue` 并设 `skipRun=true`。当前 turn 自然结束、emit `agent_end`,
|
|
10
|
-
* 但**没有任何组件**会主动调一次 `agentService.run([], session)` 来触发
|
|
11
|
-
* interceptor 的 drain 分支(input-interceptors.ts:85-103,那条分支会
|
|
12
|
-
* `mergeConsecutiveUserMessages` 把队列里的消息拍成一个新 turn)。
|
|
13
|
-
*
|
|
14
|
-
* 结果:消息僵在 `session.queue`,UI 显示"已发送",agent 永远不回。
|
|
15
|
-
*
|
|
16
|
-
* `TeamInboxDispatchService` 看起来形态对,但它只检查
|
|
17
|
-
* `RichMessageQueueManager`(团队成员消息进的那个 queue),全 codebase 只有
|
|
18
|
-
* `team-create-tool.ts:332` 一处往 rich queue 写 —— 普通 TUI 用户输入完全
|
|
19
|
-
* 走 `session.queue`,团队 dispatcher 看不到。
|
|
20
|
-
*
|
|
21
|
-
* 这个 service 就填这个空:每个 session 都订阅 `agent_end`,guard 通过后
|
|
22
|
-
* 调一次空 input 的 `agentService.run`,让现有 interceptor 自己合并消费。
|
|
23
|
-
*
|
|
24
|
-
* 与 TeamInboxDispatchService 的关系
|
|
25
|
-
* ==================================
|
|
26
|
-
* - Mode A(默认):`isDeferredDispatchEnabledSync()===false`。
|
|
27
|
-
* IdleQueueDrainService 接管 `session.queue` 的 drain;TeamInboxDispatchService
|
|
28
|
-
* 也订阅了,但它看 rich queue(一般为空)→ short-circuit。
|
|
29
|
-
* - Mode B:`isDeferredDispatchEnabledSync()===true`。
|
|
30
|
-
* IdleQueueDrainService 入口 short-circuit;TeamInboxDispatchService 走
|
|
31
|
-
* rich queue 的 immediate/pending 路径。
|
|
32
|
-
* 两 service 各自有 `dispatching` Set,最坏情况下都是 short-circuit return,
|
|
33
|
-
* 不会双重发起 run。
|
|
34
|
-
*
|
|
35
|
-
* 它不做的事
|
|
36
|
-
* ==========
|
|
37
|
-
* - 不动 `session.queue` 里的内容(让 interceptor 现有 mergeConsecutive 逻辑
|
|
38
|
-
* 作为唯一消费点,避免逻辑漂移)。
|
|
39
|
-
* - 不在 compact 中触发(`session.isCompressing` guard)。
|
|
40
|
-
* - 不在 Mode B 中触发。
|
|
41
|
-
* - 不影响 cancel 路径的 abort 行为(只在 `agent_end` 后做兜底)。
|
|
2
|
+
* Wake local queues after a turn ends. Mode A owns session.queue; Mode B tasks
|
|
3
|
+
* own its non-mirror items. Mode B main sessions remain with rich queue.
|
|
4
|
+
* MessageQueueAgentRunInterceptor remains the only dequeue/merge point.
|
|
42
5
|
*/
|
|
43
6
|
import { Logger } from '../../../../telemetry/lib/common/index.js';
|
|
44
7
|
import { AgentManager, AgentService } from '../agent/agent-protocol.js';
|
|
@@ -64,21 +27,6 @@ export declare class IdleQueueDrainServiceImpl implements IdleQueueDrainService
|
|
|
64
27
|
* 空队列直接返回。
|
|
65
28
|
*/
|
|
66
29
|
requestDrain(session: Session): void;
|
|
67
|
-
/**
|
|
68
|
-
* Guard 链 + 调 agentService.run 触发 interceptor 的 drain 分支。
|
|
69
|
-
*
|
|
70
|
-
* Guard 顺序(逐个 short-circuit return):
|
|
71
|
-
* 1. 重入:同 session 上一次 tryDrain 还没 await 完。
|
|
72
|
-
* 2. compact 中:`session.isCompressing===true`。compact 自身的
|
|
73
|
-
* continue-run 也会 emit `agent_end`,必须避让。
|
|
74
|
-
* 3. Mode B:rich queue 通道由 TeamInboxDispatchService 处理。
|
|
75
|
-
* 4. DI 兜底:headless 等变体可能没拉到 AgentService/AgentManager。
|
|
76
|
-
* 5. 空队列:没东西好 drain。
|
|
77
|
-
* 6. 取消记账在途:见下方注释。
|
|
78
|
-
*
|
|
79
|
-
* 失败回灌:interceptor 在 line 95 已经 `clearQueue`,如果后续 run 抛错,
|
|
80
|
-
* 队列里的消息会"被消费但又没真消费",相当于丢了。所以在调 run 之前
|
|
81
|
-
* 快照 queue,run 抛错时检查 queue 是否被清空、被清空就把快照灌回。
|
|
82
|
-
*/
|
|
30
|
+
/** Reuse the existing idle drain and its pre-result failure restoration. */
|
|
83
31
|
private tryDrain;
|
|
84
32
|
}
|
|
@@ -8,6 +8,7 @@ export * from './session-response-host-protocol.js';
|
|
|
8
8
|
export * from './background-task-protocol.js';
|
|
9
9
|
export * from './root-session-scope.js';
|
|
10
10
|
export * from './session-factory.js';
|
|
11
|
+
export { assertSessionRuntimeOpen, closeSessionRuntime, isSessionRuntimeClosed, sessionRuntimeSignal, } from './session-runtime-lifecycle.js';
|
|
11
12
|
export * from './session-admission-service.js';
|
|
12
13
|
export * from './session-manager.js';
|
|
13
14
|
export * from './session-store.js';
|
|
@@ -25,14 +26,17 @@ export { getSessionCanUseTool, resolveCanUseTool, resolveCanUseToolOwner, setSes
|
|
|
25
26
|
export type { CanUseTool, CanUseToolOptions, CanUseToolOwner, PermissionBehavior, PermissionDecisionClassification, PermissionResult as CanUseToolPermissionResult, PermissionRuleValue, PermissionUpdate as CanUseToolPermissionUpdate, PermissionUpdateDestination, } from './can-use-tool.js';
|
|
26
27
|
export * from './dual-channel-interaction.js';
|
|
27
28
|
export * from './session-persistence.js';
|
|
29
|
+
export * from './session-persistence-error.js';
|
|
28
30
|
export * from './session-set-current.js';
|
|
29
31
|
export * from './cancel-session-runtime-state.js';
|
|
30
32
|
export * from './user-request-boundary.js';
|
|
31
33
|
export { isTruncationRecoveryActive } from './truncation-recovery.js';
|
|
32
34
|
export * from './aborted-stream-draft-store.js';
|
|
33
35
|
export * from './stream-timeout-retry-budget.js';
|
|
36
|
+
export { consumeRecoveryRequestPending } from './recovery-budget.js';
|
|
34
37
|
export * from './session-run-state-machine-protocol.js';
|
|
35
38
|
export * from './session-run-state-machine.js';
|
|
39
|
+
export * from './model-request-retry-phase.js';
|
|
36
40
|
export * from './session-run-state-projection-service.js';
|
|
37
41
|
export * from './local-jsonl-session-store.js';
|
|
38
42
|
export * from './transcript-branch.js';
|
|
@@ -8,12 +8,44 @@ import { InterruptionService, type PendingApprovalView, Session, SessionHookMana
|
|
|
8
8
|
import { SessionRunStateMachine } from './session-run-state-machine-protocol.js';
|
|
9
9
|
type IIdleQueueDrainService = import('./session-protocol.js').IdleQueueDrainService;
|
|
10
10
|
export declare class InterruptionServiceImpl implements InterruptionService {
|
|
11
|
+
private readonly resolvedSandboxItems;
|
|
11
12
|
private pendingInterruptions;
|
|
12
13
|
private itemToSessionMap;
|
|
13
14
|
private interruptionQueues;
|
|
14
15
|
private parentIdToMainSession;
|
|
15
16
|
private childToMainSession;
|
|
16
17
|
private waitForSubscriptions;
|
|
18
|
+
private readonly approvalSources;
|
|
19
|
+
private readonly handlingStates;
|
|
20
|
+
private readonly reportedStaleStates;
|
|
21
|
+
private readonly reportedDiscardedApprovals;
|
|
22
|
+
private readonly handledResults;
|
|
23
|
+
private readonly resumeProgress;
|
|
24
|
+
/**
|
|
25
|
+
* Terminal by design: a blocked continuation already proved it cannot make
|
|
26
|
+
* progress, and a later user request arrives on a *new* RunState, so the
|
|
27
|
+
* session is never stranded.
|
|
28
|
+
*/
|
|
29
|
+
private readonly blockedResumeStates;
|
|
30
|
+
/**
|
|
31
|
+
* Deliberately not `session.meta.consecutiveEmptyDrainCount`: the idle
|
|
32
|
+
* empty-drain guard both increments that counter (tripping this
|
|
33
|
+
* continuation early, aborting a legitimate resume) and resets it
|
|
34
|
+
* (stretching the budget without bound).
|
|
35
|
+
*/
|
|
36
|
+
private readonly resumeNoProgressCount;
|
|
37
|
+
private assertApprovalSource;
|
|
38
|
+
private approveSource;
|
|
39
|
+
private awaitPermissionReply;
|
|
40
|
+
/**
|
|
41
|
+
* A decision the user actually clicked must never disappear without a word.
|
|
42
|
+
*
|
|
43
|
+
* The card is dequeued and the deferred rejected, but the run that owned it
|
|
44
|
+
* is already gone — so nothing downstream surfaces the rejection and the
|
|
45
|
+
* user is left believing the tool was approved.
|
|
46
|
+
*/
|
|
47
|
+
private reportDiscardedDecision;
|
|
48
|
+
private reportStaleSource;
|
|
17
49
|
/**
|
|
18
50
|
* 权限审批全局真相源(方案一:统一数据源)。
|
|
19
51
|
*
|
|
@@ -61,12 +93,22 @@ export declare class InterruptionServiceImpl implements InterruptionService {
|
|
|
61
93
|
protected readonly idleQueueDrainService?: IIdleQueueDrainService;
|
|
62
94
|
protected readonly traceCollector?: SessionInterruptionTraceHost;
|
|
63
95
|
protected get startupProfiler(): SessionInterruptionProfilerHost;
|
|
96
|
+
/**
|
|
97
|
+
* 标记「用户取消本轮」的拒绝项(`reject(item, { cancelTurn: true })`)。
|
|
98
|
+
* 语义是取消当前 turn,而不是「拒绝并让模型带反馈续跑」。
|
|
99
|
+
* 记在 WeakSet 而不是 `rawItem.providerData`(那会落进历史),也不改
|
|
100
|
+
* deferred 的 reject 形状(下游按 error 类型分支的逻辑保持不变)。
|
|
101
|
+
*/
|
|
102
|
+
private readonly cancelTurnItems;
|
|
103
|
+
/** Claim before calling out: sandbox callbacks can throw or synchronously re-enter. */
|
|
104
|
+
private takeSandboxResolve;
|
|
64
105
|
approve(item: RunToolApprovalItem, options?: {
|
|
65
106
|
alwaysApprove?: boolean;
|
|
66
107
|
scope?: 'session' | 'localSettings';
|
|
67
108
|
}): void;
|
|
68
109
|
reject(item: RunToolApprovalItem, options?: {
|
|
69
110
|
decision?: 'deny' | 'rejectAndExitPlan';
|
|
111
|
+
cancelTurn?: boolean;
|
|
70
112
|
}): void;
|
|
71
113
|
/**
|
|
72
114
|
* 取消指定 session 上所有未决的 interruption Deferred。
|
|
@@ -101,8 +143,9 @@ export declare class InterruptionServiceImpl implements InterruptionService {
|
|
|
101
143
|
*
|
|
102
144
|
* 幂等:未注册的 sessionId 为 no-op。
|
|
103
145
|
*/
|
|
104
|
-
releaseSession(
|
|
105
|
-
protected handleInterruptions(session: Session, interruptions: RunToolApprovalItem[]): Promise<void>;
|
|
146
|
+
releaseSession(target: string | Session): void;
|
|
147
|
+
protected handleInterruptions(session: Session, interruptions: RunToolApprovalItem[], result?: RunResult<any, any> | StreamedRunResult<any, any> | undefined): Promise<void>;
|
|
148
|
+
private processInterruptions;
|
|
106
149
|
protected executePendingManualPostCompactHook(session: Session, result: RunResult<any, any> | StreamedRunResult<any, any>): Promise<void>;
|
|
107
150
|
waitFor(session: Session): Promise<void>;
|
|
108
151
|
/**
|
|
@@ -334,15 +377,26 @@ export declare class InterruptionServiceImpl implements InterruptionService {
|
|
|
334
377
|
private static sanitizeToolNotFoundMessage;
|
|
335
378
|
private hasRecentModelErrorRetry;
|
|
336
379
|
/**
|
|
337
|
-
*
|
|
338
|
-
*
|
|
380
|
+
* 网络 / 流错误自动恢复的统一前置步骤:认领额度 → 可取消的指数退避 → 标记恢复轮。
|
|
381
|
+
*
|
|
382
|
+
* 认领放在退避之前、且晚于本 catch 里的第一个 await:session-manager 的 gate 在
|
|
383
|
+
* `result.completed` reject 后同步读取同一份预算判据,认领若早于 gate 读取,最后
|
|
384
|
+
* 一次重试会被 gate 误判为「预算已耗尽」而提前下发终态。
|
|
385
|
+
*
|
|
386
|
+
* 退避期间会话处于 RETRYING:失败的 run 与写入中断结果的 skipRun run 都已收尾回 idle,
|
|
387
|
+
* 这里重新置为 busy,TUI 继续显示进行中并响应 Esc,用户新消息进队列而不是直接起 run。
|
|
388
|
+
* 恢复 run 带 bypassMessageQueue 从 RETRYING 直接发起,中间不回 idle,不留让新 run
|
|
389
|
+
* 插入的空窗;恢复 run 收尾(AGENT_ENDED)时回 idle 并带出排队消息。
|
|
390
|
+
*
|
|
391
|
+
* 退避期间用户取消时退回额度、以 RUN_FAILED 收回 idle 并返回 `cancelled`,调用方不得
|
|
392
|
+
* 再发起。取消信号在等待前现取:写入中断结果的 skipRun run 会替换 `session.abortController`,
|
|
393
|
+
* 用户此后按下的 Stop 作用在新 controller 上;排队消息接管 owner 时,其 abort 会级联到这里。
|
|
339
394
|
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
* 将 retry marker 推出 5 条消息的窗口,导致误判为"可以再次重试"
|
|
395
|
+
* 等待结束时若状态既不是 RETRYING 也不是 idle,说明 RETRYING 被迟到的收尾事件冲掉后
|
|
396
|
+
* 已有新 run 被接纳并在执行,返回 `superseded`,否则恢复 run 会与它同时写同一个会话。
|
|
397
|
+
* 此时不退回额度——新请求边界已经清零,再减一次会扣掉新链的额度。
|
|
344
398
|
*/
|
|
345
|
-
private
|
|
399
|
+
private prepareRecoveryAttempt;
|
|
346
400
|
/**
|
|
347
401
|
* CLI TUI 手打 `/compact` 裸跑成功后补发 SessionStart('compact')。
|
|
348
402
|
*
|
package/cli/dist-server/types/workspace/cbc-core/lib/node/session/model-request-retry-phase.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AgentRetryReason, Session } from './session-protocol.js';
|
|
2
|
+
import { ModelRequestRetryPhase, SessionRunStateMachine } from './session-run-state-machine-protocol.js';
|
|
3
|
+
export declare class ModelRequestRetryPhaseImpl implements ModelRequestRetryPhase {
|
|
4
|
+
protected readonly stateMachine: SessionRunStateMachine;
|
|
5
|
+
during<T>(session: Session | undefined, reason: AgentRetryReason, wait: () => Promise<T>): Promise<T>;
|
|
6
|
+
/**
|
|
7
|
+
* 辅助型调用复用主 session 却不回送 AGENT_ENDED(#52320),不得驱动其状态;
|
|
8
|
+
* 状态已离开 MODEL_REQUESTING 说明另有路径在推进,此时不抢写。
|
|
9
|
+
*/
|
|
10
|
+
private enter;
|
|
11
|
+
/**
|
|
12
|
+
* 必须回到 MODEL_REQUESTING:RETRYING 不接收 TOOL_STARTED / MODEL_RESPONSE_DONE 等后续事件,
|
|
13
|
+
* 停留会让错误处理路径的转换被静默忽略。已被取消等事件推走时不再改写。
|
|
14
|
+
*/
|
|
15
|
+
private leave;
|
|
16
|
+
}
|
package/cli/dist-server/types/workspace/cbc-core/lib/node/session/model-response-interceptors.d.ts
CHANGED
|
@@ -29,6 +29,24 @@ export declare class finishReasonErrorInterceptor implements ModelResponseInterc
|
|
|
29
29
|
protected readonly sessionStore: SessionStore;
|
|
30
30
|
protected readonly telemetryService: TelemetryService;
|
|
31
31
|
intercept(ctx: ModelResponseInterceptorContext): Promise<boolean | void>;
|
|
32
|
+
/**
|
|
33
|
+
* 处理「已经产出实质内容之后才 `finish_reason=error`」:自动续写,最多 3 次、1s 起步 2 倍退避。
|
|
34
|
+
*
|
|
35
|
+
* 没有任何实质输出就 error 的两种形态(仅 reasoning / 零 token)在模型层被转成可重试的
|
|
36
|
+
* EmptyStreamError,走 interruption-service 的流错误恢复;三者认领同一份 error 预算。
|
|
37
|
+
*
|
|
38
|
+
* 能走到这里说明这次 run 已经结束:SDK 只要本轮还有可执行的工具调用就会继续循环,
|
|
39
|
+
* 不会把控制权交回。因此不存在「参数完整但尚未执行」的工具调用;万一出现,每次构造
|
|
40
|
+
* 请求前的 `fillFunctionCallResultHistory` 也会补齐配对,不会因孤儿调用触发上游 400。
|
|
41
|
+
* 本期只统计孤儿数量用于验证这一推论,不改补齐逻辑。
|
|
42
|
+
*
|
|
43
|
+
* 预算用尽、退避期间被取消或发起失败时都**不返回 `true`**:没有重跑在路上,本轮必须
|
|
44
|
+
* 正常收敛给上层,否则 CLI 会一直等一个不存在的 run。
|
|
45
|
+
*/
|
|
46
|
+
private handleErrorFinishReason;
|
|
47
|
+
private writeErrorTerminalMessage;
|
|
48
|
+
/** 统计本轮以 error 收尾时残留的无配对结果工具调用,用于验证「此处不应有孤儿」的推论。 */
|
|
49
|
+
private logOrphanToolCallsOnError;
|
|
32
50
|
private shouldSkipExpectedSubagentToolCalls;
|
|
33
51
|
/**
|
|
34
52
|
* 处理 length 类型的完成原因:从断点续写(#119765)。
|
|
@@ -197,6 +215,21 @@ export declare class MediaContentErrorInterceptor implements ModelResponseInterc
|
|
|
197
215
|
private static readonly MAX_RETRY_ATTEMPTS;
|
|
198
216
|
private static readonly MAX_MIME_MISMATCH_RETRY_ATTEMPTS;
|
|
199
217
|
private static readonly GIF_UNSUPPORTED_ERROR_CODES;
|
|
218
|
+
/**
|
|
219
|
+
* Gateway business codes that mean "the model refused the images in this
|
|
220
|
+
* request" (`11135 InvalidInputImage`).
|
|
221
|
+
*
|
|
222
|
+
* The code is the only stable signal. The gateway folds several unrelated
|
|
223
|
+
* upstream causes into one hard-coded English sentence and overwrites the
|
|
224
|
+
* upstream text, so `ERROR_TYPE_PATTERNS` matching that sentence breaks the
|
|
225
|
+
* moment the wording is changed or localized (`docs/error-codes.md` already
|
|
226
|
+
* ships a Chinese user-facing string for this code). The code is carried on
|
|
227
|
+
* the error object all the way here — `error-analyzer` puts the parsed body
|
|
228
|
+
* code into the response, the SDK surfaces it as `APIError.error.code`, and
|
|
229
|
+
* `ErrorUtils.extractBizCode` recovers it — so key off it and keep the
|
|
230
|
+
* phrasing match only as a fallback for gateways that send no code.
|
|
231
|
+
*/
|
|
232
|
+
private static readonly IMAGE_REJECTED_ERROR_CODES;
|
|
200
233
|
private static readonly GIF_UNSUPPORTED_PLACEHOLDER;
|
|
201
234
|
private static readonly ERROR_TYPE_PATTERNS;
|
|
202
235
|
intercept(ctx: ModelResponseInterceptorContext): Promise<boolean | void>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Session } from './session-protocol.js';
|
|
2
|
+
/**
|
|
3
|
+
* `finish_reason=error` 三种表现(已有输出 / 仅 reasoning / 零 token)共用的预算键。
|
|
4
|
+
*
|
|
5
|
+
* 三者是同一次上游故障的不同形态,而且会在恢复过程中互相转化(第一次零 token、
|
|
6
|
+
* 重试后只吐 reasoning、再重试吐了内容后又 error)。各记各的会让一次故障的总轮数
|
|
7
|
+
* 远超约定上限,所以必须认领同一个键。
|
|
8
|
+
*/
|
|
9
|
+
export declare const ERROR_RECOVERY_COUNT_META_KEY = "errorRecoveryCount";
|
|
10
|
+
/**
|
|
11
|
+
* 流开始之后的网络错误(错误仍带原始 errno)使用的预算键。
|
|
12
|
+
*
|
|
13
|
+
* 响应头之前的连接失败由模型层连接级重试处理,耗尽后被归一化成 HTTP 502 上抛,
|
|
14
|
+
* 不会再走到这里——两层不会为同一次失败接力。
|
|
15
|
+
*/
|
|
16
|
+
export declare const NETWORK_RECOVERY_COUNT_META_KEY = "networkErrorRetryCount";
|
|
17
|
+
/**
|
|
18
|
+
* `finish_reason=error` 后注入给模型的续写提示。
|
|
19
|
+
*
|
|
20
|
+
* 与截断续写(TRUNCATION_CONTINUATION_PROMPT)的区别是刻意去掉了「把剩下的工作拆小」:
|
|
21
|
+
* 那句是在修「一次输出太长」的因果,上游内部错误与输出长度无关,带上它既是错误归因,
|
|
22
|
+
* 也可能让模型把任务切碎、多烧轮次。同样不告诉模型「是服务端出错」——那会给它道歉和
|
|
23
|
+
* 复述的由头,与 no apology / no recap 自相矛盾。
|
|
24
|
+
*/
|
|
25
|
+
export declare const ERROR_RECOVERY_PROMPT: string;
|
|
26
|
+
/**
|
|
27
|
+
* 包成 error-recovery system-reminder:stream-json 等输出通道会把只含 system-reminder
|
|
28
|
+
* 的内部用户消息清空丢弃,避免恢复提示混进用户可见的对话。
|
|
29
|
+
*/
|
|
30
|
+
export declare function buildErrorRecoveryReminder(): string;
|
|
31
|
+
export declare function readRecoveryBudgetCount(session: Session, key: string): number;
|
|
32
|
+
export declare function hasExhaustedRecoveryBudget(session: Session, key: string, limit?: number): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* 同步完成「判定 + 认领」,返回本次恢复的序号(1-based);预算已用尽返回 `undefined`。
|
|
35
|
+
*
|
|
36
|
+
* 判定与消耗必须在同一个同步段里完成:分散到 `await` 两侧时,两处调用可能同时在
|
|
37
|
+
* `count = limit - 1` 通过检查,上限就不再成立。
|
|
38
|
+
*/
|
|
39
|
+
export declare function claimRecoveryBudget(session: Session, key: string, limit?: number): number | undefined;
|
|
40
|
+
/** 认领后没有真正发起恢复(退避期间被取消、发起失败)时退回额度。 */
|
|
41
|
+
export declare function releaseRecoveryBudget(session: Session, key: string): void;
|
|
42
|
+
/** 清零并返回旧值,供日志使用。 */
|
|
43
|
+
export declare function resetRecoveryBudget(session: Session, key: string): number;
|
|
44
|
+
/**
|
|
45
|
+
* 「下一个模型请求是自动恢复轮」的一次性标记。
|
|
46
|
+
*
|
|
47
|
+
* 恢复轮的首 token 时限比首次请求短(见模型层)。这个标记在发起恢复 run 前由恢复
|
|
48
|
+
* 入口显式写入,由模型层在该 run 的第一个模型请求上读取并清除——之后同一 run 的工具
|
|
49
|
+
* 循环请求回到普通时限。不能改用重试计数反推「是否恢复轮」:计数跨多个模型请求累计,
|
|
50
|
+
* 反推会让恢复链之后的所有请求都被当成恢复轮。
|
|
51
|
+
*/
|
|
52
|
+
export declare const RECOVERY_REQUEST_PENDING_META_KEY = "recoveryRequestPending";
|
|
53
|
+
export declare function markRecoveryRequestPending(session: Session): void;
|
|
54
|
+
export declare function consumeRecoveryRequestPending(session: Session | undefined): boolean;
|
|
55
|
+
export declare function clearRecoveryRequestPending(session: Session): void;
|
|
@@ -208,4 +208,19 @@ export declare class SessionHookManagerImpl implements SessionHookManager {
|
|
|
208
208
|
* Does NOT support continueRequest.
|
|
209
209
|
*/
|
|
210
210
|
executeFinalStopHooks(session: Session, reason?: FinalStopReason): Promise<void>;
|
|
211
|
+
/**
|
|
212
|
+
* UserPromptExpansion — Claude Code 官方事件:任何用户输入的命令/skill 展开成
|
|
213
|
+
* prompt、送进模型之前统一从这里触发,可阻断展开。`command_args` / `prompt` 按
|
|
214
|
+
* 官方 schema 是必填字段(无参数时发空串,而不是整个省略 key)。
|
|
215
|
+
*/
|
|
216
|
+
executeUserPromptExpansionHooks(session: Session, payload: {
|
|
217
|
+
expansionType: 'slash_command' | 'mcp_prompt' | string;
|
|
218
|
+
commandName: string;
|
|
219
|
+
commandArgs: string;
|
|
220
|
+
commandSource?: string;
|
|
221
|
+
prompt: string;
|
|
222
|
+
}): Promise<{
|
|
223
|
+
allowed: boolean;
|
|
224
|
+
message?: string;
|
|
225
|
+
}>;
|
|
211
226
|
}
|
package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-manager-host-protocol.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentInputItem } from '../../../../cbc-shared/lib/node/index.js';
|
|
2
|
-
import type { ModelResponseMetadata, Session } from './session-protocol.js';
|
|
2
|
+
import type { ModelCallGeneration, ModelResponseMetadata, Session } from './session-protocol.js';
|
|
3
3
|
export declare const SessionCheckpointHost: unique symbol;
|
|
4
4
|
export interface SessionCheckpointHost {
|
|
5
5
|
createCheckpoint(session: Session): Promise<void>;
|
|
@@ -57,7 +57,8 @@ export declare const SessionResponseTelemetryHost: unique symbol;
|
|
|
57
57
|
export interface SessionResponseTelemetryHost {
|
|
58
58
|
reportChatRequestResponseTelemetry(session: Session, result: NonNullable<Session['resultSubject']['value']>, isSuccessful: boolean, error: unknown, metadata: ModelResponseMetadata): Promise<void>;
|
|
59
59
|
reportMessageResponseTelemetryStream(session: Session, usage: SessionResponseUsage | undefined, metadata: ModelResponseMetadata, error: unknown): Promise<void>;
|
|
60
|
-
|
|
60
|
+
/** Status of one model call (`generation`); run failures no model call owns are not reported. */
|
|
61
|
+
reportChatMessageStatus(session: Session, errorCode: string, generation: ModelCallGeneration, error?: unknown): Promise<void>;
|
|
61
62
|
}
|
|
62
63
|
export type SessionResponseTelemetrySnapshot = Pick<NonNullable<Session['telemetry']>, 'modelId' | 'modelName' | 'currentTurn' | 'traceId'>;
|
|
63
64
|
export declare const SessionResponseObserver: unique symbol;
|
|
@@ -4,7 +4,7 @@ import { Logger } from '../../../../telemetry/lib/common/index.js';
|
|
|
4
4
|
import { BehaviorSubject } from 'rxjs';
|
|
5
5
|
import { SessionRequestContextHost, SessionSettingsHost as SettingsManager, SessionUsageHost as UserStateManager } from './session-host-protocol.js';
|
|
6
6
|
import { SessionBackgroundTaskHost as ToolManager, SessionCheckpointHost as CheckpointService, SessionProgressHost as ProgressSyncService, SessionResponseObserver as GalileoSessionBridge, SessionResponseTelemetryHost as TelemetryService, SessionSchedulerHost as CronSchedulerService, SessionSensitiveProjectionHost, SessionTaskLifecycleHost as AgentTaskManager } from './session-manager-host-protocol.js';
|
|
7
|
-
import { AgentInputItemProcessor, InterruptionService, ModelResponseInterceptor, ModelResponseMetadata, Session, SessionFactory, SessionGetOptions, SessionHookManager, SessionManager, SessionStore } from './session-protocol.js';
|
|
7
|
+
import { AgentInputItemProcessor, InterruptionService, ModelResponseInterceptor, ModelResponseMetadata, OverrideModelSource, Session, SessionFactory, SessionGetOptions, SessionHookManager, SessionManager, SessionStore } from './session-protocol.js';
|
|
8
8
|
import { SessionRunStateMachine } from './session-run-state-machine-protocol.js';
|
|
9
9
|
export declare class SessionManagerImpl implements SessionManager, ApplicationLifecycle<Application> {
|
|
10
10
|
protected readonly sessionFactory: SessionFactory;
|
|
@@ -33,8 +33,19 @@ export declare class SessionManagerImpl implements SessionManager, ApplicationLi
|
|
|
33
33
|
private sessionStartTimes;
|
|
34
34
|
private addHistoryLocks;
|
|
35
35
|
private resultSubscriptions;
|
|
36
|
+
private readonly resultSubscriptionOwners;
|
|
37
|
+
/**
|
|
38
|
+
* 每个 sessionId 当前活着的会话对象。身份守卫不能只认 result 订阅的登记:
|
|
39
|
+
* 订阅由调用方事后 `initRunResultHandler` 挂上(teammate / agent-task),而
|
|
40
|
+
* drain / team-inbox / turn-metrics 在 create 时就按 id 注册了,中间那段
|
|
41
|
+
* 「已注册、无订阅」的窗口里 owner 读不到,旧任务的延迟释放会摘掉同 id 后继
|
|
42
|
+
* 会话的注册。WeakRef:登记不得延长会话寿命,deref 为空即无需保护的对象。
|
|
43
|
+
*/
|
|
44
|
+
private readonly liveSessionsById;
|
|
36
45
|
private overridePermissionModes;
|
|
37
46
|
private overrideModels;
|
|
47
|
+
/** 与 overrideModels 同生命周期的意图来源(user / declared / materialized)。 */
|
|
48
|
+
private overrideModelSources;
|
|
38
49
|
/**
|
|
39
50
|
* Issue #12554:会话级 thinking override(按 sessionId 隔离)。
|
|
40
51
|
* 由 ACP setSessionConfigOption('thought_level') 或 prompt _meta 写入。
|
|
@@ -177,13 +188,15 @@ export declare class SessionManagerImpl implements SessionManager, ApplicationLi
|
|
|
177
188
|
*
|
|
178
189
|
* 幂等:未注册的 id 为 no-op;DI 容错:精简变体缺 service 时降级跳过。
|
|
179
190
|
*/
|
|
180
|
-
releaseInMemory(
|
|
191
|
+
releaseInMemory(target: string | Session): void;
|
|
181
192
|
rename(session: Session, name: string): Promise<void>;
|
|
182
193
|
setOverridePermissionMode(sessionId: string, mode: PermissionMode): void;
|
|
183
194
|
getOverridePermissionMode(sessionId: string): PermissionMode | undefined;
|
|
184
|
-
setOverrideModel(sessionId: string, model: string): void;
|
|
195
|
+
setOverrideModel(sessionId: string, model: string, source?: OverrideModelSource): void;
|
|
185
196
|
getOverrideModel(sessionId: string): string | undefined;
|
|
186
|
-
|
|
197
|
+
getOverrideModelSource(sessionId: string): OverrideModelSource | undefined;
|
|
198
|
+
clearOverrideModel(sessionId: string): void;
|
|
199
|
+
setRuntimeModel(session: Session | undefined, modelId: string, source?: OverrideModelSource): void;
|
|
187
200
|
setRuntimeOutputStyle(session: Session | undefined, style: string): void;
|
|
188
201
|
/**
|
|
189
202
|
* Issue #83229:把 settings.json 中的 model / outputStyle 读一次"钉"进 session.options,
|
package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-persistence-error.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed local-transcript I/O failure (issue #119545).
|
|
3
|
+
*
|
|
4
|
+
* The only reason this type exists: `addHistory` must be able to tell "the
|
|
5
|
+
* local JSONL copy could not be written" apart from "this turn is broken".
|
|
6
|
+
* Windows `EBUSY` on the transcript is a third-party sharing violation, and a
|
|
7
|
+
* side-channel copy must never terminate a turn that is still executing tools.
|
|
8
|
+
*
|
|
9
|
+
* Everything else about persistence stays best-effort on purpose: there is no
|
|
10
|
+
* pending queue, no cross-process outbox and no durability barrier, so nothing
|
|
11
|
+
* else in the runtime waits on, or can be vetoed by, this file.
|
|
12
|
+
*/
|
|
13
|
+
export type SessionPersistencePhase = 'open' | 'stat' | 'write' | 'close' | 'rollback';
|
|
14
|
+
export type SessionPersistenceRollbackOutcome = 'not-needed' | 'succeeded' | 'failed';
|
|
15
|
+
export interface SessionPersistenceErrorOptions {
|
|
16
|
+
phase: SessionPersistencePhase;
|
|
17
|
+
cause: unknown;
|
|
18
|
+
attempt?: number;
|
|
19
|
+
rollbackOutcome?: SessionPersistenceRollbackOutcome;
|
|
20
|
+
retryable?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Windows sharing violations and their POSIX lookalikes. `EBUSY` is the one
|
|
24
|
+
* this ticket measured (25% of appends within 10ms of the previous write);
|
|
25
|
+
* `EPERM` / `EACCES` ride along because the same scanners produce them.
|
|
26
|
+
*/
|
|
27
|
+
export declare function isRetryableSessionPersistenceError(error: unknown): boolean;
|
|
28
|
+
export declare class SessionPersistenceError extends Error {
|
|
29
|
+
readonly phase: SessionPersistencePhase;
|
|
30
|
+
readonly code?: string;
|
|
31
|
+
readonly attempt: number;
|
|
32
|
+
readonly rollbackOutcome: SessionPersistenceRollbackOutcome;
|
|
33
|
+
readonly retryable: boolean;
|
|
34
|
+
constructor(options: SessionPersistenceErrorOptions);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Duck-typed on purpose: core and the host package can each hold their own copy
|
|
38
|
+
* of this class, so `instanceof` is not reliable across the package boundary.
|
|
39
|
+
* The required fields keep a foreign error named `SessionPersistenceError` from
|
|
40
|
+
* being mistaken for one of ours — an unrecognized error still fails the run,
|
|
41
|
+
* which is the safe direction.
|
|
42
|
+
*/
|
|
43
|
+
export declare function isSessionPersistenceError(error: unknown): error is SessionPersistenceError;
|