@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
|
@@ -21,18 +21,18 @@ export declare const DEFAULT_SLASH_COMMAND_TOOL_CHAR_BUDGET = 8000;
|
|
|
21
21
|
export declare const DEFAULT_SKILL_TOOL_CHAR_BUDGET = 8000;
|
|
22
22
|
export declare const DEFAULT_AGENT_TOOL_CHAR_BUDGET = 30000;
|
|
23
23
|
/** Per-entry hard cap for a single skill's description */
|
|
24
|
-
export declare const MAX_SKILL_DESC_CHARS =
|
|
24
|
+
export declare const MAX_SKILL_DESC_CHARS = 200;
|
|
25
25
|
/** Minimum maxDescLen below which non-protected skills degrade to names-only (aligned with CC MIN_DESC_LENGTH=20) */
|
|
26
26
|
export declare const MIN_SKILL_DESC_LENGTH = 20;
|
|
27
27
|
/**
|
|
28
28
|
* Env name for per-skill description hard-cap overrides.
|
|
29
29
|
*
|
|
30
|
-
* By default every skill's description is hard-capped to {@link MAX_SKILL_DESC_CHARS}(
|
|
30
|
+
* By default every skill's description is hard-capped to {@link MAX_SKILL_DESC_CHARS}(200)
|
|
31
31
|
* per entry. A host can loosen (or tighten) this cap for **specific** skills — identified
|
|
32
32
|
* by skill name — without changing the global default, by exporting this env.
|
|
33
33
|
*
|
|
34
34
|
* Format: a JSON object mapping skill name → maxChars, e.g.
|
|
35
|
-
* `{"
|
|
35
|
+
* `{"workbuddy-office-routing":300,"tencent-pptx":300}`
|
|
36
36
|
* The value is the per-entry cap that fully replaces the default for the named skill.
|
|
37
37
|
* Explicitly overridden skills are also excluded from the later total-budget redistribution,
|
|
38
38
|
* so an updated bundled skill keeps the same host-selected limit when its source becomes plugin.
|
|
@@ -47,7 +47,7 @@ export declare const SKILL_DESC_MAX_OVERRIDES_ENV = "CODEBUDDY_SKILL_DESC_MAX_OV
|
|
|
47
47
|
/**
|
|
48
48
|
* Parse the {@link SKILL_DESC_MAX_OVERRIDES_ENV} raw value into a `skillName → maxChars` map.
|
|
49
49
|
*
|
|
50
|
-
* - Expects a JSON object literal, e.g. `{"
|
|
50
|
+
* - Expects a JSON object literal, e.g. `{"workbuddy-office-routing":300}`.
|
|
51
51
|
* - Returns an empty map for empty/undefined input, malformed JSON, or a non-object
|
|
52
52
|
* (array / string / number / null) top-level value — the caller decides whether to warn.
|
|
53
53
|
* - Skips any entry with an empty (post-trim) key, a value that is not a positive integer,
|
|
@@ -377,6 +377,20 @@ export interface ToolManager {
|
|
|
377
377
|
* 仅作用于 toolMap 中的内置工具;MCP 工具不走此路径。
|
|
378
378
|
*/
|
|
379
379
|
ensureBuiltinDeferIndexed(toolName: string): Promise<boolean>;
|
|
380
|
+
/**
|
|
381
|
+
* 在工具执行前创建文件备份(file-history 快照),返回被跟踪的文件路径。
|
|
382
|
+
*
|
|
383
|
+
* 直连路径由 {@link executeToolWithHooks} 内部自动调用;REPL/Code Mode 沙箱
|
|
384
|
+
* 执行路径(DeferExecuteTool.routeToolCall → executeBuiltinTool)绕过该 hook
|
|
385
|
+
* 包装,需在真正执行工具前显式调用本方法,否则沙箱内的 Edit/Write 不产生
|
|
386
|
+
* FileHistorySnapshotItem,rewind 无快照可恢复(#130664)。
|
|
387
|
+
*
|
|
388
|
+
* 依赖 FileTrackService.trackFile 幂等(文件已在当前 checkpoint 即跳过),两条
|
|
389
|
+
* 路径都触达时也只落一次快照。
|
|
390
|
+
*/
|
|
391
|
+
trackFileForToolCall(toolName: string, toolInput: unknown, session: Session, details?: {
|
|
392
|
+
toolCall: FunctionCallItem;
|
|
393
|
+
}): Promise<string | undefined>;
|
|
380
394
|
addBackgroundTask(task: BackgroundTask): void;
|
|
381
395
|
removeBackgroundTask(id: string): void;
|
|
382
396
|
getBackgroundTasks(): BackgroundTask[];
|
|
@@ -494,6 +508,7 @@ export interface ToolHookManager {
|
|
|
494
508
|
modifiedInput?: Record<string, any>;
|
|
495
509
|
message?: string;
|
|
496
510
|
permissionDecision?: 'allow' | 'deny' | 'ask';
|
|
511
|
+
preventContinuation?: boolean;
|
|
497
512
|
}>;
|
|
498
513
|
/**
|
|
499
514
|
* Execute PostToolUse hooks after a tool completes successfully
|
|
@@ -801,6 +816,8 @@ export interface ImageGenerationResult extends GenerationCreditResult {
|
|
|
801
816
|
}
|
|
802
817
|
export interface VideoGenerationResult extends GenerationCreditResult {
|
|
803
818
|
localPaths: string[];
|
|
819
|
+
/** 端上为适配模型能力做出的调整说明(如分辨率回落),供模型与用户知情 */
|
|
820
|
+
warnings?: string[];
|
|
804
821
|
}
|
|
805
822
|
/**
|
|
806
823
|
* 图片生成结果
|
|
@@ -871,6 +888,7 @@ export interface VideoGenParams {
|
|
|
871
888
|
image?: string;
|
|
872
889
|
last_image?: string;
|
|
873
890
|
resolution?: '480P' | '720P' | '1080P';
|
|
891
|
+
seconds?: number;
|
|
874
892
|
aspect_ratio?: '16:9' | '9:16' | '1:1';
|
|
875
893
|
negative_prompt?: string;
|
|
876
894
|
enable_audio?: boolean;
|
|
@@ -920,3 +938,109 @@ export interface VideoService {
|
|
|
920
938
|
/** 解析视频模型:session > env > settings > tag > fallback */
|
|
921
939
|
resolveModel(session: Session | undefined, tag: string): Promise<string>;
|
|
922
940
|
}
|
|
941
|
+
export declare const AudioTranscribeService: unique symbol;
|
|
942
|
+
/**
|
|
943
|
+
* 录音文件识别(长音频转文本)请求参数。
|
|
944
|
+
* `channel_num:1` 由 service 固定注入,不暴露给调用方。
|
|
945
|
+
*/
|
|
946
|
+
export interface AudioTranscribeOptions {
|
|
947
|
+
/** 说话人分离:0 关闭(默认)/ 1 开启(需 channel_num=1) */
|
|
948
|
+
speaker_diarization?: 0 | 1;
|
|
949
|
+
/** 临时热词表 "词|权重,..."(最多 128) */
|
|
950
|
+
hotword_list?: string;
|
|
951
|
+
/** 阿拉伯数字智能转换:0 / 1 / 3 */
|
|
952
|
+
convert_num_mode?: 0 | 1 | 3;
|
|
953
|
+
/** 脏词过滤:0 / 1 / 2 */
|
|
954
|
+
filter_dirty?: 0 | 1 | 2;
|
|
955
|
+
/** 标点过滤:0 / 1 / 2 */
|
|
956
|
+
filter_punc?: 0 | 1 | 2;
|
|
957
|
+
/** 语气词过滤:0 / 1 / 2 */
|
|
958
|
+
filter_modal?: 0 | 1 | 2;
|
|
959
|
+
/** 上游附加参数(合法 JSON 字符串),如 '{"Domain":3}' */
|
|
960
|
+
extra?: string;
|
|
961
|
+
}
|
|
962
|
+
/** service 内部解析出的音频来源(COS-only:始终为 audio_url)。 */
|
|
963
|
+
export interface AudioSource {
|
|
964
|
+
audio_url: string;
|
|
965
|
+
}
|
|
966
|
+
/** 后端预签名返回项(`support:getPresignedUrls` 契约)。 */
|
|
967
|
+
export interface AsrPresignItem {
|
|
968
|
+
object_key: string;
|
|
969
|
+
upload_url: string;
|
|
970
|
+
download_url: string;
|
|
971
|
+
}
|
|
972
|
+
/** 预签名接口响应信封。 */
|
|
973
|
+
export interface AsrPresignApiResponse {
|
|
974
|
+
code: number;
|
|
975
|
+
msg?: string;
|
|
976
|
+
message?: string;
|
|
977
|
+
requestId?: string;
|
|
978
|
+
data?: {
|
|
979
|
+
expire?: number;
|
|
980
|
+
items?: AsrPresignItem[];
|
|
981
|
+
};
|
|
982
|
+
}
|
|
983
|
+
/** 提交任务响应信封(/v2/async/tasks/create)。 */
|
|
984
|
+
export interface AsrCreateApiResponse {
|
|
985
|
+
code: number;
|
|
986
|
+
msg: string;
|
|
987
|
+
requestId: string;
|
|
988
|
+
data?: {
|
|
989
|
+
task_id?: string;
|
|
990
|
+
scene?: string;
|
|
991
|
+
status?: string;
|
|
992
|
+
created_at?: string;
|
|
993
|
+
};
|
|
994
|
+
}
|
|
995
|
+
/** 查询任务响应信封(/v2/async/tasks/query)。 */
|
|
996
|
+
export interface AsrQueryApiResponse {
|
|
997
|
+
code: number;
|
|
998
|
+
msg: string;
|
|
999
|
+
requestId: string;
|
|
1000
|
+
data?: {
|
|
1001
|
+
task_id?: string;
|
|
1002
|
+
scene?: string;
|
|
1003
|
+
status?: 'queued' | 'in_progress' | 'completed' | 'failed';
|
|
1004
|
+
created_at?: string;
|
|
1005
|
+
completed_at?: string;
|
|
1006
|
+
usage?: {
|
|
1007
|
+
credit?: number;
|
|
1008
|
+
coefficient?: number;
|
|
1009
|
+
meters?: {
|
|
1010
|
+
audio_second?: number;
|
|
1011
|
+
};
|
|
1012
|
+
};
|
|
1013
|
+
attributes?: {
|
|
1014
|
+
engine?: string;
|
|
1015
|
+
vendor_status?: string;
|
|
1016
|
+
};
|
|
1017
|
+
error?: {
|
|
1018
|
+
code?: string;
|
|
1019
|
+
message?: string;
|
|
1020
|
+
};
|
|
1021
|
+
audio_transcription?: {
|
|
1022
|
+
text?: string;
|
|
1023
|
+
};
|
|
1024
|
+
};
|
|
1025
|
+
}
|
|
1026
|
+
/** 录音文件识别结果。 */
|
|
1027
|
+
export interface AudioTranscribeResult {
|
|
1028
|
+
/** 完整转写文本(上游 Result 原样透传) */
|
|
1029
|
+
text: string;
|
|
1030
|
+
/** 任务 ID */
|
|
1031
|
+
taskId: string;
|
|
1032
|
+
/** 实际音频时长(秒),计费依据 */
|
|
1033
|
+
audioSecond?: number;
|
|
1034
|
+
/** 最终积分消耗 */
|
|
1035
|
+
credit?: number;
|
|
1036
|
+
}
|
|
1037
|
+
/**
|
|
1038
|
+
* 录音文件识别服务接口。
|
|
1039
|
+
* COS-only:本地文件先经后端预签名上传 COS,再以 audio_url 提交异步转写并轮询。
|
|
1040
|
+
*/
|
|
1041
|
+
export interface AudioTranscribeService {
|
|
1042
|
+
/**
|
|
1043
|
+
* 转写本地音频文件:预签名上传 → 提交任务 → 轮询直至终态。
|
|
1044
|
+
*/
|
|
1045
|
+
transcribe(filePath: string, options: AudioTranscribeOptions, context: RunContext<Session>): Promise<AudioTranscribeResult>;
|
|
1046
|
+
}
|
|
@@ -179,6 +179,12 @@ export declare function isBuiltinDisableableAgent(agentName: string): boolean;
|
|
|
179
179
|
* waste prompt tokens on a tool they can never legitimately call (the SendMessage
|
|
180
180
|
* tool itself returns an error when invoked outside a team context), and for
|
|
181
181
|
* structured-output agents like `compact` it can pollute the model's output.
|
|
182
|
+
*
|
|
183
|
+
* **这些名字是保留字,不得被用作子代理 / teammate 预设名**(评审 #128343):
|
|
184
|
+
* `resolveMessageSpeakerLabel` 把本名单的判定放在「子会话报自身身份」**之前**,因为历史与
|
|
185
|
+
* 用量多处按 `providerData.agent === 'compact'` 这类字符串比较判定,子会话里跑 compact 时
|
|
186
|
+
* 不能被身份名覆盖。反过来说,一旦有真实子代理取了这里的名字,它的消息会被标成生成器名
|
|
187
|
+
* 而不是自己的身份 —— 属于要靠人眼才能发现的错标。新增名字前先确认它不会与任何预设名撞。
|
|
182
188
|
*/
|
|
183
189
|
export declare const INTERNAL_GENERATOR_AGENTS: Set<string>;
|
|
184
190
|
/**
|
|
@@ -289,6 +295,13 @@ export interface AgentManager {
|
|
|
289
295
|
* 同输入逐轮返回同一对象(prompt cache 稳定);视图字节永不写回全局物化面。
|
|
290
296
|
*/
|
|
291
297
|
sessionScopedAgentView(session: Session, base: Agent): Promise<Agent>;
|
|
298
|
+
/**
|
|
299
|
+
* sandbox-agent-view:把 REPL 的动态 schema 按子代理身份重新物化一遍。Code Mode 的
|
|
300
|
+
* agent 实例进程级共享(`get('ptc')` 命中同一对象),schema 在构建期用合成会话采集 ——
|
|
301
|
+
* 继承模式的子代理(Explore 等)会看到模式的全量目录。派发侧知道身份,经此覆盖。
|
|
302
|
+
* 只克隆 REPL 一个工具,视图不进 agentMap;空身份 / 同名 / 无 REPL 时原样返回基座。
|
|
303
|
+
*/
|
|
304
|
+
sandboxScopedAgentView(base: Agent, sandboxAgentName: string): Promise<Agent>;
|
|
292
305
|
/** served 激活链的视图预热(默认 agent),派发路径是失效兜底。 */
|
|
293
306
|
prepareSessionAgentView(session: Session): Promise<void>;
|
|
294
307
|
get(agentName: string): Promise<Agent | undefined>;
|
|
@@ -537,12 +550,37 @@ export interface AgentServiceRunControlOptions {
|
|
|
537
550
|
bypassMessageQueue?: boolean;
|
|
538
551
|
/** Input is already present in Session history; do not append it again. */
|
|
539
552
|
skipAddHistory?: boolean;
|
|
553
|
+
/** Let an interactive host route external `/compact` before normal run admission. */
|
|
554
|
+
routeManualCompact?: boolean;
|
|
555
|
+
/**
|
|
556
|
+
* Per-call out-signal of `runDefault`: invoked once, synchronously, after
|
|
557
|
+
* this call passed run admission (its startup controller is installed on
|
|
558
|
+
* the Session) and before the agent is resolved. Not invoked when admission
|
|
559
|
+
* throws. It says nothing about the model having started or the run
|
|
560
|
+
* succeeding; without `bypassMessageQueue` the run may still be queued
|
|
561
|
+
* afterwards (see `onEnqueued`). A throwing callback is logged and does not
|
|
562
|
+
* affect the run. Internal re-runs pass fresh options and never carry it; it
|
|
563
|
+
* is stripped before AgentRunRequest and the SDK.
|
|
564
|
+
*/
|
|
565
|
+
onAdmitted?: () => void;
|
|
540
566
|
}
|
|
541
567
|
/** Options for an isolated run or an SDK RunState resume. */
|
|
542
568
|
export type AgentStandardRunOptions<TContext = Session> = AgentSdkRunOptions<TContext> & AgentServiceRunControlOptions & {
|
|
543
569
|
/** Process-local provenance for fresh user turns; stripped before SDK dispatch. */
|
|
544
570
|
inputOrigin?: AgentRunOrigin;
|
|
545
571
|
continuation?: never;
|
|
572
|
+
/**
|
|
573
|
+
* Per-arrival out-signal: invoked when this run was routed to the message
|
|
574
|
+
* queue (skipRun, session busy) instead of executing now. Callers that owe
|
|
575
|
+
* their caller *this* prompt's own result (print / stream-json) use it to
|
|
576
|
+
* keep waiting until the queue drains and their turn actually runs.
|
|
577
|
+
*
|
|
578
|
+
* A run-scoped callback (not a shared session flag) so concurrent arrivals
|
|
579
|
+
* cannot clobber each other's outcome.
|
|
580
|
+
*/
|
|
581
|
+
onEnqueued?: () => void;
|
|
582
|
+
/** Exact result of this arrival, including execution after a queue drain. */
|
|
583
|
+
onResult?: (result: NonNullable<Session['resultSubject']['value']>) => void;
|
|
546
584
|
};
|
|
547
585
|
/**
|
|
548
586
|
* Explicitly claim the current process-local logical turn.
|
|
@@ -558,12 +596,23 @@ export type AgentCurrentContinuationOptions = AgentSdkRunOptions<Session> & Agen
|
|
|
558
596
|
};
|
|
559
597
|
export type AgentServiceRunOptions<TContext = Session> = AgentStandardRunOptions<TContext> | AgentCurrentContinuationOptions;
|
|
560
598
|
export interface AgentService {
|
|
599
|
+
/** Atomically close a task's runtime only after its last result and queued work settle. */
|
|
600
|
+
tryCloseTaskSession?(session: Session, result: NonNullable<Session['resultSubject']['value']>): Promise<boolean>;
|
|
601
|
+
/** Stop accepting task work and join its physical runs before releasing dependencies. */
|
|
602
|
+
retireTaskSession?(session: Session): Promise<void>;
|
|
603
|
+
/**
|
|
604
|
+
* 有界等待该 session 上的物理 run 收尾(含它把最终产出写进 history)。
|
|
605
|
+
*
|
|
606
|
+
* `agent_end` 早于 run 的 finalize,所以「上一轮 history 已写完」不能靠 `agent_end`
|
|
607
|
+
* 判定;需要该因果的调用方(队列 drain)join 到这里。超时会放行并告警,不会挂死。
|
|
608
|
+
*/
|
|
609
|
+
waitForRunsSettled?(session: Session): Promise<void>;
|
|
561
610
|
run<TAgent extends Agent<any, any>>(agent: TAgent, input: string | AgentInputItem[], options: AgentCurrentContinuationOptions): Promise<void>;
|
|
562
611
|
run<TAgent extends Agent<any, any>, TContext = Session>(agent: TAgent, input: string | AgentInputItem[] | RunState<TContext, TAgent>, options?: AgentStandardRunOptions<TContext>): Promise<void>;
|
|
563
612
|
runDefault<TAgent extends Agent<any, any>>(input: string | AgentInputItem[], options: AgentCurrentContinuationOptions): Promise<void>;
|
|
564
613
|
runDefault<TAgent extends Agent<any, any>, TContext = Session>(input: string | AgentInputItem[] | RunState<TContext, TAgent>, options?: AgentStandardRunOptions<TContext>): Promise<void>;
|
|
565
|
-
runOneTime<TContext = Session>(agentName: string, input: string | AgentInputItem[], options?: NonStreamRunOptions<TContext>): Promise<string>;
|
|
566
|
-
runOneTime<TContext = Session>(agentName: string, input: string | AgentInputItem[], options?: StreamRunOptions<TContext>): Promise<string>;
|
|
614
|
+
runOneTime<TContext = Session>(agentName: string, input: string | AgentInputItem[], options?: NonStreamRunOptions<TContext> & OneTimeRunOptions): Promise<string>;
|
|
615
|
+
runOneTime<TContext = Session>(agentName: string, input: string | AgentInputItem[], options?: StreamRunOptions<TContext> & OneTimeRunOptions): Promise<string>;
|
|
567
616
|
/**
|
|
568
617
|
* Run a one-shot agent call in a forked (isolated) session that inherits
|
|
569
618
|
* the conversation history from the parent session. The forked session is
|
|
@@ -629,6 +678,11 @@ export interface ForkedAgentOptions {
|
|
|
629
678
|
/** Optional cap on number of turns (default: 1 for one-shot) */
|
|
630
679
|
maxTurns?: number;
|
|
631
680
|
}
|
|
681
|
+
/** Options of `runOneTime` on top of the SDK run options. */
|
|
682
|
+
export interface OneTimeRunOptions {
|
|
683
|
+
/** X-Agent-Purpose of the call; defaults to the agent's `AGENT_PURPOSE_MAP` entry, else its name. */
|
|
684
|
+
purpose?: string;
|
|
685
|
+
}
|
|
632
686
|
export interface RunRequest {
|
|
633
687
|
prompt?: string;
|
|
634
688
|
inputFormat?: 'text' | 'stream-json';
|
|
@@ -670,6 +724,8 @@ export interface AgentRunRequest<TContext = Session> extends SessionOptions {
|
|
|
670
724
|
skipAddHistory?: boolean;
|
|
671
725
|
bypassMessageQueue?: boolean;
|
|
672
726
|
inputOrigin?: AgentRunOrigin;
|
|
727
|
+
/** Process-local arrival callback; never passed to the SDK. */
|
|
728
|
+
onResult?: AgentStandardRunOptions['onResult'];
|
|
673
729
|
traceId?: string;
|
|
674
730
|
/**
|
|
675
731
|
* #59319-5: 普通 run 二次裁决发现 session 仍 busy 时由 AgentService 设置。
|
|
@@ -779,6 +835,8 @@ export declare enum CustomAgentSavePath {
|
|
|
779
835
|
}
|
|
780
836
|
export declare enum OutputStyleType {
|
|
781
837
|
DEFAULT = "default",
|
|
838
|
+
PROACTIVE = "proactive",
|
|
839
|
+
CONCISE = "concise",
|
|
782
840
|
EXPLANATORY = "explanatory",
|
|
783
841
|
LEARNING = "learning"
|
|
784
842
|
}
|
|
@@ -58,7 +58,9 @@ export declare enum AgentPurpose {
|
|
|
58
58
|
/** Auto mode permission risk classification (runOneTime: AUTO_MODE_CLASSIFIER) */
|
|
59
59
|
AutoModeClassifier = "auto_mode_classifier",
|
|
60
60
|
/** Automation scheduled task execution */
|
|
61
|
-
Automation = "automation"
|
|
61
|
+
Automation = "automation",
|
|
62
|
+
/** `/btw` side question on a forked Session (runForked); Claude Code's `side_question` source */
|
|
63
|
+
SideQuestion = "side_question"
|
|
62
64
|
}
|
|
63
65
|
/**
|
|
64
66
|
* Dynamic purpose prefix for built-in subagents.
|
|
@@ -127,6 +129,9 @@ export declare const AUXILIARY_PURPOSES: ReadonlySet<string>;
|
|
|
127
129
|
* 时 purpose 可能尚未设置的普通对话仍按原行为发出 MODEL_REQUEST_STARTED。
|
|
128
130
|
*/
|
|
129
131
|
export declare function isAuxiliaryPurpose(purpose?: string): boolean;
|
|
132
|
+
/** Purposes of compaction summary calls (X-Agent-Type `compaction`). */
|
|
133
|
+
export declare const COMPACTION_PURPOSES: ReadonlySet<string>;
|
|
134
|
+
export declare function isCompactionPurpose(purpose?: string): boolean;
|
|
130
135
|
/**
|
|
131
136
|
* 按 purpose 旁路 agent 生命周期事件(agent_start / agent_end / tool / handoff)。
|
|
132
137
|
*
|
|
@@ -145,9 +150,8 @@ export declare function isAuxiliaryPurpose(purpose?: string): boolean;
|
|
|
145
150
|
*
|
|
146
151
|
* 因此这里只收 PreMessage 这一种 purpose。
|
|
147
152
|
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
* 会让**主 run** 也被误旁路,反而放大本要修复的孤儿 run 问题。
|
|
153
|
+
* The purpose is scoped to the summary call (`runOneTime` → `runWithAgentPurpose`), so it
|
|
154
|
+
* cannot leak onto the pending main run.
|
|
151
155
|
*
|
|
152
156
|
* multi-session(#44317)回归时,PreMessage 承载应改回临时子 Session;本名单保留为
|
|
153
157
|
* 冗余防线即可(临时 Session 上旁路是无害的)。
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { AgentType } from '../../../../workspace/telemetry/lib/common/index.js';
|
|
2
|
+
interface PurposeCarrier {
|
|
3
|
+
agentPurpose?: string;
|
|
4
|
+
conversationRequestId?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Runs an auxiliary model call (title, summary, WebFetch analysis, ...) on a
|
|
8
|
+
* caller-owned Session without writing its purpose / request id onto the shared
|
|
9
|
+
* Session, where a concurrent main run would read and send them as its own.
|
|
10
|
+
*/
|
|
11
|
+
export declare function runWithAgentPurpose<T>(session: object, purpose: string, callback: () => T, options?: {
|
|
12
|
+
conversationRequestId?: string;
|
|
13
|
+
}): T;
|
|
14
|
+
/** True when the current async chain is an auxiliary call scoped to `session`. */
|
|
15
|
+
export declare function isInAgentPurposeScope(session: object | undefined): boolean;
|
|
16
|
+
/** Purpose of the model call running in the current async chain. */
|
|
17
|
+
export declare function getEffectiveAgentPurpose(session: PurposeCarrier | undefined): string | undefined;
|
|
18
|
+
/** Request id of the model call running in the current async chain. */
|
|
19
|
+
export declare function getEffectiveConversationRequestId(session: PurposeCarrier | undefined): string | undefined;
|
|
20
|
+
/** Purposes whose model calls are steps of a Session's own agent loop. */
|
|
21
|
+
export declare function isMainConversationPurpose(purpose: string | undefined): boolean;
|
|
22
|
+
/** True when the model call in the current async chain is a step of `session`'s agent loop. */
|
|
23
|
+
export declare function isMainLoopModelCall(session: PurposeCarrier | undefined): boolean;
|
|
24
|
+
/** True when the model call in the current async chain has an `AUXILIARY_PURPOSES` purpose. */
|
|
25
|
+
export declare function isAuxiliaryPurposeCall(session: PurposeCarrier | undefined): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Runs `callback` outside any purpose scope. A run started from a helper call's async
|
|
28
|
+
* chain (e.g. a queued message drained on its agent_end) is a new agent-loop run.
|
|
29
|
+
*/
|
|
30
|
+
export declare function runOutsideAgentPurposeScope<T>(callback: () => T): T;
|
|
31
|
+
export type ModelCallAgentType = AgentType;
|
|
32
|
+
/** Role of the Session's own agent loop, for request-level events. */
|
|
33
|
+
export declare function resolveSessionAgentType(session: {
|
|
34
|
+
meta?: Record<string, unknown>;
|
|
35
|
+
}): 'main' | 'subagent' | 'team';
|
|
36
|
+
/**
|
|
37
|
+
* Role of the model call in the current async chain (X-Agent-Type / telemetry
|
|
38
|
+
* `agentType`), mirroring Claude Code's `x-claude-code-request-class`: compaction
|
|
39
|
+
* summaries report `compaction`, other one-shot helpers (title, WebFetch analysis,
|
|
40
|
+
* ...) report `auxiliary`, whatever Session they run on. The specific helper
|
|
41
|
+
* stays in X-Agent-Purpose.
|
|
42
|
+
*/
|
|
43
|
+
export declare function resolveModelCallAgentType(session: PurposeCarrier & {
|
|
44
|
+
meta?: Record<string, unknown>;
|
|
45
|
+
}): ModelCallAgentType;
|
|
46
|
+
export {};
|
|
@@ -3,10 +3,11 @@ import { AuthenticationManager } from '../../../../workspace/authentication/lib/
|
|
|
3
3
|
import { type AbortLinkDisposer, Agent, type AgentInputItem, type NonStreamRunOptions, RunState, type StreamRunOptions } from '../../../cbc-shared/node/index.js';
|
|
4
4
|
import { type LanguageModel } from '../../../../workspace/product/lib/common/index.js';
|
|
5
5
|
import { Logger } from '../../../../workspace/telemetry/lib/common/index.js';
|
|
6
|
+
import { type ManualCompactRequestHandler as ManualCompactRequestHandlerContract } from '../context/context-protocol';
|
|
6
7
|
import { type FileRollbackOperationLock as FileRollbackOperationLockContract } from '../file-rollback/file-rollback-service-protocol';
|
|
7
8
|
import { Session, SessionManager } from '../session/session-protocol';
|
|
8
9
|
import { SessionRunStateMachine } from '../session/session-run-state-machine-protocol';
|
|
9
|
-
import { type AgentCurrentContinuationOptions, AgentManager, AgentRunInterceptor, AgentRunRequest, AgentService, type AgentStandardRunOptions, RunnerProvider } from './agent-protocol';
|
|
10
|
+
import { type AgentCurrentContinuationOptions, AgentManager, AgentRunInterceptor, AgentRunRequest, AgentService, type AgentStandardRunOptions, type OneTimeRunOptions, RunnerProvider } from './agent-protocol';
|
|
10
11
|
import { type AgentRunScope as IAgentRunScope } from './agent-run-scope';
|
|
11
12
|
import { AgentPluginRefresh, AgentRunObserver, AgentRuntimeResolver } from './agent-runtime-protocol';
|
|
12
13
|
export declare class AgentServiceImpl implements AgentService {
|
|
@@ -22,6 +23,7 @@ export declare class AgentServiceImpl implements AgentService {
|
|
|
22
23
|
protected readonly agentRunInterceptorProvider: Provider<AgentRunInterceptor>;
|
|
23
24
|
protected readonly fileRollbackOperationLock?: FileRollbackOperationLockContract;
|
|
24
25
|
protected readonly logger: Logger;
|
|
26
|
+
protected readonly manualCompactRequestHandler?: ManualCompactRequestHandlerContract;
|
|
25
27
|
/**
|
|
26
28
|
* Preserve the pre-start cancellation snapshot across runDefault's agent
|
|
27
29
|
* lookup controller and run()'s own controller. This is process-local
|
|
@@ -38,6 +40,22 @@ export declare class AgentServiceImpl implements AgentService {
|
|
|
38
40
|
*/
|
|
39
41
|
private lifecycleOwners;
|
|
40
42
|
protected getLifecycleOwners(): WeakMap<Session, AbortController>;
|
|
43
|
+
tryCloseTaskSession(session: Session, result: NonNullable<Session['resultSubject']['value']>): Promise<boolean>;
|
|
44
|
+
retireTaskSession(session: Session): Promise<void>;
|
|
45
|
+
waitForRunsSettled(session: Session): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* 有界 join:等到该 session 上的物理 run 全部交还 lifecycle owner 与 in-flight 信号。
|
|
48
|
+
*
|
|
49
|
+
* 为什么需要它而不是直接看 `agent_end`:`finalizeRun` 晚于本轮把最终产出写进
|
|
50
|
+
* history,`agent_end` 却早于 `finalizeRun`。任何依赖「上一轮 history 已写完」这个
|
|
51
|
+
* 因果的调用方(如队列 drain)必须 join 到这里。
|
|
52
|
+
*
|
|
53
|
+
* Bounded: `runSettledSubject` is optional, so a session built without
|
|
54
|
+
* one has nothing to observe and would hang the caller's cleanup — which
|
|
55
|
+
* owns hook, MCP and background-shell teardown. `agent_end` 也可能来自没有物理
|
|
56
|
+
* run 的路径(skipRun / 迟到事件),无界等待会把调用方永久挂住。
|
|
57
|
+
*/
|
|
58
|
+
private joinRunsSettled;
|
|
41
59
|
/** compare-and-delete:仅当 token 仍指向本轮 controller 时清除。 */
|
|
42
60
|
private clearLifecycleOwner;
|
|
43
61
|
/** 本轮是否是当前 lifecycle owner。 */
|
|
@@ -154,6 +172,7 @@ export declare class AgentServiceImpl implements AgentService {
|
|
|
154
172
|
protected resolveRunOneTimeModel(agentName: string, session?: Session): Promise<LanguageModel>;
|
|
155
173
|
run<TAgent extends Agent<any, any>>(agent: TAgent, input: string | AgentInputItem[], options: AgentCurrentContinuationOptions): Promise<void>;
|
|
156
174
|
run<TAgent extends Agent<any, any>, TContext = Session>(agent: TAgent, input: string | AgentInputItem[] | RunState<TContext, TAgent>, options?: AgentStandardRunOptions<TContext>): Promise<void>;
|
|
175
|
+
private runPipeline;
|
|
157
176
|
/**
|
|
158
177
|
* #59319-stream: 抽取的 physical run cleanup 逻辑。
|
|
159
178
|
* 非 stream 路径由 run() finally 同步调用;
|
|
@@ -187,8 +206,14 @@ export declare class AgentServiceImpl implements AgentService {
|
|
|
187
206
|
private prepareRunAdmission;
|
|
188
207
|
runDefault<TAgent extends Agent<any, any>>(input: string | AgentInputItem[], options: AgentCurrentContinuationOptions): Promise<void>;
|
|
189
208
|
runDefault<TAgent extends Agent<any, any>, TContext = Session>(input: string | AgentInputItem[] | RunState<TContext, TAgent>, options?: AgentStandardRunOptions<TContext>): Promise<void>;
|
|
190
|
-
|
|
191
|
-
|
|
209
|
+
/**
|
|
210
|
+
* Streams the text of a one-shot run on `session`. A reused caller Session is shared
|
|
211
|
+
* with its in-flight main run, so the call's purpose and request id live in its async
|
|
212
|
+
* scope instead of on the Session.
|
|
213
|
+
*/
|
|
214
|
+
private streamOneTimeText;
|
|
215
|
+
runOneTime<TContext = Session>(agentName: string, input: string | AgentInputItem[], options?: NonStreamRunOptions<TContext> & OneTimeRunOptions): Promise<string>;
|
|
216
|
+
runOneTime<TContext = Session>(agentName: string, input: string | AgentInputItem[], options?: StreamRunOptions<TContext> & OneTimeRunOptions): Promise<string>;
|
|
192
217
|
/**
|
|
193
218
|
* Enhanced version of runOneTime that supports per-request overrides
|
|
194
219
|
* for temperature, maxTokens, maxTurns, systemPrompt, and bypassPermissions.
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
export * from './agent-protocol';
|
|
2
2
|
export * from './agent-purpose-protocol';
|
|
3
|
+
export * from './agent-purpose-scope';
|
|
4
|
+
export * from './model-step-sequence';
|
|
5
|
+
export * from './model-call-failure';
|
|
3
6
|
export * from './agent-runtime-protocol';
|
|
4
7
|
export * from './agent-run-scope';
|
|
5
8
|
export * from './agent-service';
|
|
6
9
|
export * from './agent-factory';
|
|
7
10
|
export * from './runner-factory';
|
|
8
11
|
export * from './runner-provider';
|
|
12
|
+
export * from './speaker-label';
|
|
9
13
|
export * from './ordered-tools-agent';
|
|
10
14
|
export * from './tool-call-loop-detector-protocol';
|
|
11
15
|
export * from './tool-call-loop-detector-service';
|
package/cli/dist-server/types/vendor/cbc-core/node/agent/interceptors/input-interceptors.d.ts
CHANGED
|
@@ -17,12 +17,7 @@ export declare class MessageQueueAgentRunInterceptor implements AgentRunIntercep
|
|
|
17
17
|
protected readonly logger: Logger;
|
|
18
18
|
protected readonly stateMachine: SessionRunStateMachine;
|
|
19
19
|
intercept(request: AgentRunRequest): Promise<void>;
|
|
20
|
-
|
|
21
|
-
* 触发后不再重复打 error(防日志风暴);下次"有实际工作"分支复位 counter/flag,
|
|
22
|
-
* session 自动恢复处理能力。
|
|
23
|
-
*/
|
|
24
|
-
private trackEmptyDrainAndMaybeTripGuard;
|
|
25
|
-
private resetEmptyDrainLoopGuard;
|
|
20
|
+
private consumeQueueItems;
|
|
26
21
|
}
|
|
27
22
|
/**
|
|
28
23
|
* 用户查询包裹拦截器
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ModelCallGeneration } from '../session/session-protocol';
|
|
2
|
+
/**
|
|
3
|
+
* Marks `error` as the failure of one model call. The call's ids live in the model-call
|
|
4
|
+
* async scope, which does not reach the consumer of the SDK run stream; the error does.
|
|
5
|
+
* An error rethrown through an outer call keeps the innermost call's mark.
|
|
6
|
+
*/
|
|
7
|
+
export declare function markModelCallFailure<T>(error: T, sessionId: string, generation: ModelCallGeneration): T;
|
|
8
|
+
/** The model call of this Session that failed with `error`; undefined when the failure is not one. */
|
|
9
|
+
export declare function getFailedModelCall(error: unknown, sessionId: string): ModelCallGeneration | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Session } from '../session/session-protocol';
|
|
2
|
+
type StepSequenceSession = Pick<Session, 'id' | 'history' | 'agentPurpose' | 'modelStepSeq'>;
|
|
3
|
+
/** Latest step of the Session's agent loop, restored from persisted history after resume. */
|
|
4
|
+
export declare function currentModelStepSeq(session: StepSequenceSession): number;
|
|
5
|
+
/**
|
|
6
|
+
* Step number for the model call in the current async chain. Agent-loop calls
|
|
7
|
+
* advance the counter; auxiliary calls reuse the latest step. The counter never
|
|
8
|
+
* resets across runs, compaction continuations or teammate wake-ups.
|
|
9
|
+
*/
|
|
10
|
+
export declare function allocateModelStepSeq(session: StepSequenceSession): number;
|
|
11
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type RunConfig, Runner } from '../../../cbc-shared/node/index.js';
|
|
1
|
+
import { type AgentInputItem, type RunConfig, Runner } from '../../../cbc-shared/node/index.js';
|
|
2
2
|
import { ProductManager } from '../../../../workspace/product/lib/common/index.js';
|
|
3
3
|
import { Logger } from '../../../../workspace/telemetry/lib/common/index.js';
|
|
4
4
|
import { type NotificationInjectionBuffer as INotificationInjectionBuffer } from '../message-queue/notification-injection-buffer-protocol';
|
|
@@ -15,6 +15,15 @@ import { ToolCallLoopDetector } from './tool-call-loop-detector-protocol';
|
|
|
15
15
|
* Used by finishReasonErrorInterceptor to detect prior retries across both mechanisms.
|
|
16
16
|
*/
|
|
17
17
|
export declare const TRUNCATION_RETRY_MARKER = "Do NOT repeat the same oversized tool call. Break it into smaller operations.";
|
|
18
|
+
export interface ModelInputMemoryPressure {
|
|
19
|
+
heapUsed: number;
|
|
20
|
+
heapLimit: number;
|
|
21
|
+
headroom: number;
|
|
22
|
+
inputItems: number;
|
|
23
|
+
estimatedInputBytes?: number;
|
|
24
|
+
reject: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare function assessModelInputMemoryPressure(input: AgentInputItem[], heapUsed?: number, heapLimit?: number): ModelInputMemoryPressure;
|
|
18
27
|
/**
|
|
19
28
|
* Tool-specific hints for how to decompose a truncated tool call into smaller operations.
|
|
20
29
|
*/
|
|
@@ -72,6 +81,7 @@ export declare class RunnerFactoryImpl implements RunnerFactory {
|
|
|
72
81
|
*/
|
|
73
82
|
protected readonly acpBroadcastService?: AgentQueueOutput;
|
|
74
83
|
create(config?: Partial<RunConfig>): Promise<Runner>;
|
|
84
|
+
private assertModelInputCloneHeadroom;
|
|
75
85
|
/**
|
|
76
86
|
* 在每次模型请求前检查是否需要自动压缩。
|
|
77
87
|
* 此时所有工具都已执行完毕,可以安全地触发压缩。
|
|
@@ -80,10 +90,10 @@ export declare class RunnerFactoryImpl implements RunnerFactory {
|
|
|
80
90
|
/**
|
|
81
91
|
* Mode B:把「立即发送」队列项注入正在运行的 turn(#73022)。
|
|
82
92
|
*
|
|
83
|
-
* 调用点在 `callModelInputFilter`(见 `create()
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
93
|
+
* 调用点在 `callModelInputFilter`(见 `create()`),即**每次模型请求之前**。
|
|
94
|
+
* rich message / notification / drain prompt 仍在这里注入请求副本;真实 steer
|
|
95
|
+
* 由 `continuationInputProvider` 在 `prepareTurn` 前写入 SDK RunState,避免后续
|
|
96
|
+
* 工具 step 从权威状态重建请求时丢失。
|
|
87
97
|
*
|
|
88
98
|
* 注入内容已经进入本次模型请求,无需再为“曾经注入过”强制续圈。只有模型响应期间
|
|
89
99
|
* 新到达、尚未被取出的消息,才由 `__codebuddySteerPending` 在收尾时实时判定是否
|
|
@@ -101,6 +111,22 @@ export declare class RunnerFactoryImpl implements RunnerFactory {
|
|
|
101
111
|
* `create()` 注释)。payload 与授权同为调用局部值,天然不跨 run 共享。
|
|
102
112
|
*/
|
|
103
113
|
private injectSendNowItems;
|
|
114
|
+
/**
|
|
115
|
+
* Drain steer only at the SDK continuation boundary, before it prepares the next model step.
|
|
116
|
+
*
|
|
117
|
+
* The returned model items are installed by the SDK into RunState.generatedItems before
|
|
118
|
+
* `prepareTurn`. This makes steer authoritative input for every later tool/model step instead
|
|
119
|
+
* of an ephemeral `callModelInputFilter` addition. The visible history stays the bare user
|
|
120
|
+
* message; it is admitted exactly once, by the stream consumer, in RunState order.
|
|
121
|
+
*/
|
|
122
|
+
private takeSteerContinuationInput;
|
|
123
|
+
/**
|
|
124
|
+
* Visible-history + ACP admission of one drained steer group.
|
|
125
|
+
*
|
|
126
|
+
* Ordering is the caller's responsibility (continuation-history-queue.ts); this only performs
|
|
127
|
+
* the writes and must never throw back into the run.
|
|
128
|
+
*/
|
|
129
|
+
private admitSteerToVisibleHistory;
|
|
104
130
|
/**
|
|
105
131
|
* #100404:落定来源一(rich queue sendNow)的消费。
|
|
106
132
|
*
|
|
@@ -129,11 +155,11 @@ export declare class RunnerFactoryImpl implements RunnerFactory {
|
|
|
129
155
|
* (`session/session-manager.ts` 的 `MODEL_STREAM_STARTED`),涉及跨模块反向布线与
|
|
130
156
|
* 事件类型白名单依赖,另开 issue 跟进。
|
|
131
157
|
*
|
|
132
|
-
* **落史顺序反转(显式接受)**:`modelData.input` 的 push 顺序是来源一 →
|
|
133
|
-
* 但来源一的 `addHistory`
|
|
134
|
-
* 就地 addHistory。同一 model step 同时命中多个来源时,history
|
|
135
|
-
* steer
|
|
136
|
-
*
|
|
158
|
+
* **落史顺序反转(显式接受)**:`modelData.input` 的 filter push 顺序是来源一 → 三 → 四,
|
|
159
|
+
* 但来源一的 `addHistory` 推迟到本方法内执行,来源三/四仍在 `injectSendNowItems` 里
|
|
160
|
+
* 就地 addHistory。同一 model step 同时命中多个来源时,history 里队员消息会排在通知
|
|
161
|
+
* 之后,与模型当时看到的输入顺序相反。steer 已在更早的 SDK continuation 边界同时进入
|
|
162
|
+
* RunState 与可见历史,不参与这段反转。下游按 role/type 消费、不依赖交错位置,故接受。
|
|
137
163
|
*
|
|
138
164
|
* at-most-once 由**作用域**保证,不再依赖「commit 前清暂存」这类补偿动作:`pending` 是
|
|
139
165
|
* 单次 `callModelInputFilter` 调用的局部值,每次调用最多把它 commit 一次,也不可能被
|
|
@@ -211,10 +237,10 @@ export declare class RunnerFactoryImpl implements RunnerFactory {
|
|
|
211
237
|
* model / agent / argumentsDisplayText 等键同样会跟着走,它们是惰性字段、上游不解读,
|
|
212
238
|
* 这里不做处理;真正需要清掉的只有语义已经反转的 discard。
|
|
213
239
|
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
240
|
+
* 返回一个浅复制的新 item;providerData 仅在需要删除 discard 时 copy-on-write。
|
|
241
|
+
* session.history 与 SDK 传入的原 item 始终保持不变。
|
|
216
242
|
*/
|
|
217
|
-
private
|
|
243
|
+
private withRewrittenCallArguments;
|
|
218
244
|
/**
|
|
219
245
|
* SDK callModelInputFilter: called before every model API request within the SDK run loop.
|
|
220
246
|
*
|
|
@@ -240,13 +266,23 @@ export declare class RunnerFactoryImpl implements RunnerFactory {
|
|
|
240
266
|
* message instructing the model to break the call into smaller operations. This
|
|
241
267
|
* turns the SDK's automatic retry into a valid, useful request.
|
|
242
268
|
*
|
|
243
|
-
* Scope of the rewrite:
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
* we redo the same rewrite on every subsequent turn.
|
|
248
|
-
*
|
|
249
|
-
|
|
269
|
+
* Scope of the rewrite: this filter opts into the SDK's `preserveInputIdentity` mode,
|
|
270
|
+
* so existing history items arrive by identity and MUST remain immutable. Repairs use
|
|
271
|
+
* item-level copy-on-write and array-level shallow copies; the SDK still creates isolated
|
|
272
|
+
* model/session copies after the filter returns. `session.history` therefore keeps the
|
|
273
|
+
* malformed arguments and we redo the same rewrite on every subsequent turn. Anything
|
|
274
|
+
* reported from this path must be aggregated per turn rather than logged per call.
|
|
275
|
+
*/
|
|
276
|
+
/**
|
|
277
|
+
* 模型输入的两步修复,**顺序不能反**:
|
|
278
|
+
*
|
|
279
|
+
* 1. `filterTruncatedToolCalls` 先跑。截断(finish_reason=length)与坏 JSON 的
|
|
280
|
+
* call 正是「参数半截 + 没有任何 result」那一类;它删掉这些 call 的同时会注入
|
|
281
|
+
* 拆解引导与防循环停止标记。若先按配对摘掉它们,该分支因 `invalidCallIds` 为空
|
|
282
|
+
* 直接早退,模型拿不到任何引导,退回 #75892 那条老路,而且请求本身合法、无错可见。
|
|
283
|
+
* 2. `filterUnpairedToolCalls` 后跑,收掉剩下的孤儿(参数合法但结果丢失、重复 callId、
|
|
284
|
+
* 头部被截断留下的孤儿结果)。本地正文里的孤儿是持久化的,留着每次恢复都被上游 400。
|
|
250
285
|
*/
|
|
286
|
+
private repairModelInput;
|
|
251
287
|
private filterTruncatedToolCalls;
|
|
252
288
|
}
|