@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
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 自动恢复链的统一口径:最多 3 次,1s 起步、2 倍指数退避(基准 1s → 2s → 4s)。
|
|
3
|
+
*
|
|
4
|
+
* 适用于会话层的 error / 网络 / 流超时恢复,以及模型层的连接级透明重试。
|
|
5
|
+
* 第 1 层请求级(429/502/503 等)不带网关 retry_policy 时仍保持自己的 500ms 基数,
|
|
6
|
+
* 所以这里只共享算法,基数与上限由调用方传入。
|
|
7
|
+
*/
|
|
8
|
+
export declare const MAX_RECOVERY_RETRIES = 3;
|
|
9
|
+
export declare const RECOVERY_RETRY_BASE_DELAY_MS = 1000;
|
|
10
|
+
export declare const RECOVERY_RETRY_MAX_DELAY_MS = 32000;
|
|
11
|
+
export interface ExponentialBackoffOptions {
|
|
12
|
+
baseDelayMs: number;
|
|
13
|
+
maxDelayMs: number;
|
|
14
|
+
random?: () => number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* `base * 2^(attempt-1)` 封顶到 `maxDelayMs`,再做 25% 下减抖动(区间 `[0.75x, 1x]`)。
|
|
18
|
+
*
|
|
19
|
+
* 必须下减而不是上加:上加会让实际等待越过 `maxDelayMs` 25%,调用方对封顶的承诺就不成立。
|
|
20
|
+
* `attempt` 从 1 起,小于 1 按 1 处理。
|
|
21
|
+
*/
|
|
22
|
+
export declare function computeExponentialBackoffMs(attempt: number, options: ExponentialBackoffOptions): number;
|
|
23
|
+
export declare function computeRecoveryBackoffMs(attempt: number, random?: () => number): number;
|
|
24
|
+
/**
|
|
25
|
+
* 可取消的等待。`signal` 在等待前或等待中 abort 时返回 `false`,正常等满返回 `true`。
|
|
26
|
+
*
|
|
27
|
+
* 返回布尔而不是 reject:恢复链上的调用方拿到 `false` 后要自己决定退还额度、跳过发起,
|
|
28
|
+
* 用异常表达会把「用户取消」和「真正的错误」混在一条 catch 路径里。
|
|
29
|
+
*/
|
|
30
|
+
export declare function waitForRecoveryBackoff(ms: number, signal?: AbortSignal): Promise<boolean>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 模型网关在 HTTP 错误体里下发的重试指示,与 `code` / `msg` / `displayMsg` 同层:
|
|
3
|
+
*
|
|
4
|
+
* ```json
|
|
5
|
+
* { "code": 11101, "msg": "...", "retry_policy": { "retry": false }, "displayMsg": { ... } }
|
|
6
|
+
* ```
|
|
7
|
+
*
|
|
8
|
+
* - `force-retry`:策略是普通对象且 `retry !== false`(含 `true`、缺 `retry` 键、类型异常)。
|
|
9
|
+
* 只在本地已判定可重试的范围内把请求级重试提到 3 次,不扩大可重试状态码。
|
|
10
|
+
* - `forbid-retry`:策略是普通对象且 `retry === false`。不重试、不换模型、不重放备站、不做鉴权刷新重试。
|
|
11
|
+
* - `unset`:字段缺失、`null`、数组或其他非对象形态,完全按原有逻辑处理。
|
|
12
|
+
*
|
|
13
|
+
* 只有显式 `false` 才阻断:网关形态小改动时宁可多试一次,也不要静默丧失恢复能力。
|
|
14
|
+
*/
|
|
15
|
+
export type RetryPolicyDecision = 'force-retry' | 'forbid-retry' | 'unset';
|
|
16
|
+
export declare const RETRY_POLICY_FIELD = "retry_policy";
|
|
17
|
+
/**
|
|
18
|
+
* 按固定层级找 `retry_policy` 原值,返回第一个存在的值(可能是非法形态,由调用方裁决)。
|
|
19
|
+
*
|
|
20
|
+
* 同一份策略会以三种形态出现:网关原始错误体(顶层或 `data` / `error.data`)、错误分析器
|
|
21
|
+
* 规范化后的 `{ error: { code, message, data } }`、SDK 包装后的 APIError(`error.data`,
|
|
22
|
+
* 外层再包一层时为 `error.error.data`)。层级写死、不递归,避免在任意嵌套里误捡字段。
|
|
23
|
+
*/
|
|
24
|
+
export declare function findRetryPolicy(source: unknown): unknown;
|
|
25
|
+
export declare function decideRetryPolicy(policy: unknown): RetryPolicyDecision;
|
|
26
|
+
export declare function resolveRetryPolicy(source: unknown): RetryPolicyDecision;
|
|
@@ -3,6 +3,7 @@ export * from './prompt-codec.js';
|
|
|
3
3
|
export * from './prompt-context-xml.js';
|
|
4
4
|
export * from './to-resolve-blocks.js';
|
|
5
5
|
export * from './interactive-question-tools.js';
|
|
6
|
+
export * from './sandbox-rule-context.js';
|
|
6
7
|
export * from './sdk.js';
|
|
7
8
|
export * from './transport/streamable-http.js';
|
|
8
9
|
export * from './client/index.js';
|
package/cli/dist-server/types/workspace/agent-client-protocol/lib/common/sandbox-rule-context.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export type SandboxRuleDomain = 'file' | 'command' | 'network';
|
|
2
|
+
export type SandboxRuleSource = 'enterprise' | 'preset' | 'user';
|
|
3
|
+
export type SandboxRuleCause = {
|
|
4
|
+
kind: 'ordered-rule';
|
|
5
|
+
domain: SandboxRuleDomain;
|
|
6
|
+
ruleRef: string;
|
|
7
|
+
} | {
|
|
8
|
+
kind: 'sensitive-rule';
|
|
9
|
+
ruleId: string;
|
|
10
|
+
source?: SandboxRuleSource;
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'policy';
|
|
13
|
+
code: string;
|
|
14
|
+
};
|
|
15
|
+
export interface SandboxRuleContext {
|
|
16
|
+
causes: SandboxRuleCause[];
|
|
17
|
+
}
|
|
18
|
+
export interface FileApprovalScope {
|
|
19
|
+
directory: string;
|
|
20
|
+
operation: 'read' | 'write' | 'delete';
|
|
21
|
+
recursive: boolean;
|
|
22
|
+
lifetime: 'session';
|
|
23
|
+
}
|
|
24
|
+
export declare const SANDBOX_RULE_CONTEXT_META_KEY = "codebuddy.ai/sandboxRuleContext";
|
|
25
|
+
export declare const FILE_APPROVAL_SCOPE_META_KEY = "codebuddy.ai/fileApprovalScope";
|
|
26
|
+
/** 仅复制显示所需字段,不能将归因标识作为授权凭证。 */
|
|
27
|
+
export declare function parseSandboxRuleContext(value: unknown): SandboxRuleContext | undefined;
|
|
28
|
+
export declare function parseFileApprovalScope(value: unknown): FileApprovalScope | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* 目录授权的专用应答 optionId,不出现在 requestPermission 的选项列表中。
|
|
31
|
+
* 只有展示了 fileApprovalScope 的卡片会回传它;按选项 kind 自动应答的 IM、
|
|
32
|
+
* 自动化或旧 UI 选不到它,因而无法替用户登记目录授权。
|
|
33
|
+
*/
|
|
34
|
+
export declare const FILE_DIRECTORY_APPROVAL_OPTION_ID = "allow_directory";
|
|
35
|
+
export declare function parseSandboxPermissionMetadata(meta: unknown): {
|
|
36
|
+
ruleContext?: SandboxRuleContext;
|
|
37
|
+
fileApprovalScope?: FileApprovalScope;
|
|
38
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { RestOperations } from '@celljs/http';
|
|
2
2
|
import { AuthenticationType, ClientInfoProvider, ProductConfiguration, ProductManager } from '../../../product/lib/common/index.js';
|
|
3
3
|
import { ExternalUriOpener } from '../../../runtime/lib/common/index.js';
|
|
4
|
-
import { Logger } from '../../../telemetry/lib/common/index.js';
|
|
5
|
-
import { Account, APIResult, AuthenticationProvider, AuthSession, AuthState, AuthToken, LoginContext, ProductEnvService, SignContext } from './authentication-protocol.js';
|
|
4
|
+
import { Logger, type Span } from '../../../telemetry/lib/common/index.js';
|
|
5
|
+
import { Account, APIResult, AuthenticationProvider, AuthSession, AuthState, AuthToken, LoginContext, LogoutOptions, ProductEnvService, SignContext } from './authentication-protocol.js';
|
|
6
6
|
/**
|
|
7
7
|
* External-link auth variant whose current account is scoped by the token.
|
|
8
8
|
*
|
|
@@ -26,14 +26,14 @@ export declare class AccountScopedExternalLinkAuthenticationProvider implements
|
|
|
26
26
|
checkNetworkConnectivity(): Promise<APIResult<boolean>>;
|
|
27
27
|
createSession(ctx: SignContext): Promise<AuthSession>;
|
|
28
28
|
refreshSession(session: AuthSession, ctx: SignContext): Promise<AuthSession>;
|
|
29
|
-
removeSession(): Promise<void>;
|
|
29
|
+
removeSession(_session?: AuthSession, _options?: LogoutOptions): Promise<void>;
|
|
30
30
|
switchAccount(account: Account, authSession: AuthSession, ctx: SignContext): Promise<AuthSession>;
|
|
31
31
|
private toSessionAccountLists;
|
|
32
|
-
protected openAuthUrl(authState: AuthState): Promise<void>;
|
|
32
|
+
protected openAuthUrl(authState: AuthState, handoffSpan?: Span): Promise<void>;
|
|
33
33
|
private fetchAuthState;
|
|
34
34
|
private loopGetToken;
|
|
35
35
|
private loopGetCurrentAccount;
|
|
36
|
-
protected fetchCurrentAccount(auth: AuthToken, ctx: SignContext): Promise<Account>;
|
|
36
|
+
protected fetchCurrentAccount(auth: AuthToken, ctx: SignContext, requestSpan?: Span): Promise<Account>;
|
|
37
37
|
protected enterpriseHeaders(auth?: AuthToken): Record<string, string>;
|
|
38
38
|
protected calculateExpiresAt(authToken: AuthToken): void;
|
|
39
39
|
private isAuthenticationInvalidError;
|
|
@@ -51,4 +51,29 @@ export declare function mergeCurrentAccountDetails(account: Account, accounts: A
|
|
|
51
51
|
* 仅以账号类型为准,不用 enterpriseId 反推,避免 unknown/legacy account 被误判。
|
|
52
52
|
*/
|
|
53
53
|
export declare function isPersonalAccount(account?: Pick<Account, 'type'>): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* 判断账号是否属于「个人版」这一**商业化版本**(个人版 + 个人版已订阅 Pro)。
|
|
56
|
+
*
|
|
57
|
+
* 与 {@link isPersonalAccount} 的区别,调用前请先确认要哪一个:
|
|
58
|
+
* - `isPersonalAccount`:严格的类型判定,只认 `type === 'personal'`,用于需要区分
|
|
59
|
+
* 「免费个人版」与其它一切档位的场景(如 IOA 请求头是否补默认企业 ID)。
|
|
60
|
+
* - `isPersonalEditionAccount`(本函数):版本归属判定,把 `pro`(「个人版已订阅 Pro」,
|
|
61
|
+
* 见 agent-provider `types.ts` 的 Edition 注释)也算进个人版,用于「个人版专属功能」
|
|
62
|
+
* 门禁——把付费个人用户挡在个人版功能外不符合产品预期。
|
|
63
|
+
*
|
|
64
|
+
* 判定采用**反向排除**而非 type 白名单,原因是 `Account.type` 在协议层仅声明为 `string`,
|
|
65
|
+
* 完全透传后端 `/console/accounts`,前端不做任何映射校正:
|
|
66
|
+
* - 历史上出现过空串 type,白名单写法会把付费账号整块漏掉(见 agent-provider
|
|
67
|
+
* `backend-provider.ts:getEditionDisplayType` 的同款踩坑注释);反向排除对未知值
|
|
68
|
+
* 降级为「个人版」,与该处「其余(含 type 为空串 / 未知值)按个人账号推导」一致。
|
|
69
|
+
* - `enterpriseId` 非空一律视为企业租户:它是 enterprise-policy 包区分
|
|
70
|
+
* personal / enterprise 的唯一依据(`bypass-personal` 语义),也是现有 4 处
|
|
71
|
+
* `isPersonalAccount()` 调用统一叠加 `&& !enterpriseId` 的原因。这样即便后端返回
|
|
72
|
+
* `type=personal` + 非空 enterpriseId(IOA 个人账号即属此类),也不会误放行。
|
|
73
|
+
*
|
|
74
|
+
* **未登录(`account` 为空)返回 `false`**:此时无从判断版本归属,不能因为「查不到企业
|
|
75
|
+
* 特征」就当成个人版放行个人版专属能力。这与上面对「已登录但 type 未知」降级为个人版
|
|
76
|
+
* 是两件事——后者至少确认了不是企业租户。
|
|
77
|
+
*/
|
|
78
|
+
export declare function isPersonalEditionAccount(account?: Pick<Account, 'type' | 'enterpriseId'>): boolean;
|
|
54
79
|
export {};
|
package/cli/dist-server/types/workspace/authentication/lib/common/authentication-manager.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { AuthenticationType, ProductManager } from '../../../product/lib/common/
|
|
|
5
5
|
import { Notifier } from '../../../runtime/lib/common/index.js';
|
|
6
6
|
import { EventService, Logger, TraceService } from '../../../telemetry/lib/common/index.js';
|
|
7
7
|
import { BehaviorSubject } from 'rxjs';
|
|
8
|
-
import { Account, APIResult, AuthenticationManager, AuthenticationProvider, type AuthenticationStartupGate as IAuthenticationStartupGate, AuthenticationStorage, AuthSession, LoginContext, type PrewarmActivationGate as IPrewarmActivationGate, ProductEnvService } from './authentication-protocol.js';
|
|
8
|
+
import { Account, APIResult, AuthenticationManager, AuthenticationProvider, type AuthenticationStartupGate as IAuthenticationStartupGate, AuthenticationStorage, AuthSession, LoginContext, LogoutOptions, type PrewarmActivationGate as IPrewarmActivationGate, ProductEnvService } from './authentication-protocol.js';
|
|
9
9
|
/**
|
|
10
10
|
* 注入 doInit 二级探针 sink。仅供 daemon 装配层调用,把 [AuthDoInitProbe] 复制一路
|
|
11
11
|
* 落到 daemon.log;main.log 主 sink 走 celljs Logger 不受影响。
|
|
@@ -18,6 +18,12 @@ import { Account, APIResult, AuthenticationManager, AuthenticationProvider, type
|
|
|
18
18
|
*/
|
|
19
19
|
export declare function setAuthDoInitProbeSink(sink: ((line: string) => void) | undefined): void;
|
|
20
20
|
export declare class AuthenticationManagerImpl implements AuthenticationManager {
|
|
21
|
+
/** Host observation hook, called after currentSessionSubject published the session. No-op by default. */
|
|
22
|
+
protected observeSession(_session: AuthSession | undefined, _source: string, _observation?: unknown): void;
|
|
23
|
+
/** Captures host metadata while the storage publisher's synchronous context is available. */
|
|
24
|
+
protected captureSessionObservation(): unknown;
|
|
25
|
+
private notifySessionObserver;
|
|
26
|
+
private safelyCaptureSessionObservation;
|
|
21
27
|
protected readonly productManager: ProductManager;
|
|
22
28
|
protected readonly productEnvService: ProductEnvService;
|
|
23
29
|
protected readonly authenticationProvider: Provider<AuthenticationProvider>;
|
|
@@ -97,7 +103,7 @@ export declare class AuthenticationManagerImpl implements AuthenticationManager
|
|
|
97
103
|
cancelLogin(): void;
|
|
98
104
|
private clearLastAuthUrl;
|
|
99
105
|
login(ctx?: LoginContext): Promise<boolean>;
|
|
100
|
-
logout(): Promise<void>;
|
|
106
|
+
logout(options?: LogoutOptions): Promise<void>;
|
|
101
107
|
refreshSession(): Promise<void>;
|
|
102
108
|
waitForSessionRefresh(): Promise<void>;
|
|
103
109
|
refreshSessionForAuthenticationFailure(): Promise<AuthSession>;
|
package/cli/dist-server/types/workspace/authentication/lib/common/authentication-observation.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type Span } from '../../../telemetry/lib/common/index.js';
|
|
2
|
+
/** Login observation helpers. Every export swallows its own failures; authentication never depends on them. */
|
|
3
|
+
/** W3C context for the login chain only; the shared Span.requestHeaders stay legacy-only. */
|
|
4
|
+
export declare function loginTraceCarrier(span?: Span): {
|
|
5
|
+
traceparent?: string;
|
|
6
|
+
tracestate?: string;
|
|
7
|
+
};
|
|
8
|
+
/** Only for a host that registered login observation; other products keep their legacy login trace unchanged. */
|
|
9
|
+
export declare function addLoginSpanEvent(span: Span | undefined, name: string, attributes?: Record<string, string>): void;
|
|
10
|
+
/** Host login observation context registered together with setLoginStepCallback. */
|
|
11
|
+
export interface LoginObservationContext {
|
|
12
|
+
/** Reauthentication correlation (`recovery_of_loss_id` / `previous_auth_session_id`). */
|
|
13
|
+
recovery?: Record<string, string>;
|
|
14
|
+
/** The host's login attempt ID; the web login page records it as the owner of its journey. */
|
|
15
|
+
journeyOwnerId?: string;
|
|
16
|
+
/** Entry context of the host-owned login journey. */
|
|
17
|
+
traceparent?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function setLoginObservationContext(context?: LoginObservationContext): void;
|
|
20
|
+
export declare function appendLoginTraceParams(url: URL, span?: Span): void;
|
|
21
|
+
/** Web login page parameters that join the host login journey. */
|
|
22
|
+
export declare function appendLoginObservationParams(url: URL, handoffSpan?: Span): void;
|
|
23
|
+
/** Narrow host hook: no credential/header objects or telemetry implementation cross this boundary. */
|
|
24
|
+
export interface AuthRequestObservationInput {
|
|
25
|
+
method?: string;
|
|
26
|
+
url?: string;
|
|
27
|
+
traceparent?: string;
|
|
28
|
+
}
|
|
29
|
+
export type AuthRequestObservation = (request: AuthRequestObservationInput) => ((status?: number, businessCode?: number) => void) | undefined;
|
|
30
|
+
export declare function setAuthRequestObservation(observer?: AuthRequestObservation): void;
|
|
31
|
+
export declare function observeAuthRequest(config: {
|
|
32
|
+
method?: string;
|
|
33
|
+
url?: string;
|
|
34
|
+
headers?: Record<string, unknown>;
|
|
35
|
+
}): void;
|
|
36
|
+
export declare function observeAuthResponse(config: unknown, status?: number, businessCode?: unknown): void;
|
package/cli/dist-server/types/workspace/authentication/lib/common/authentication-protocol.d.ts
CHANGED
|
@@ -67,6 +67,27 @@ export declare const HTTP_HEADER_NO_AUTHORIZATION = "X-No-Authorization";
|
|
|
67
67
|
* 用于请求发往自定义端点(如 LiteLLM 网关)时,避免携带 copilot 内部认证信息。
|
|
68
68
|
*/
|
|
69
69
|
export declare const HTTP_HEADER_SKIP_AUTH_INTERCEPTOR = "X-Skip-Auth-Interceptor";
|
|
70
|
+
/**
|
|
71
|
+
* `auth/state` 额外请求头数据源(可选 DI 依赖,中立抽象;Issue #94672)。
|
|
72
|
+
*
|
|
73
|
+
* authentication 包对具体头一无所知:只负责在登录链路的 `auth/state` 请求上
|
|
74
|
+
* 把本 provider 返回的所有 header 原样透传。**具体带哪些头、值怎么取,全部由
|
|
75
|
+
* 业务侧(WorkBuddy Desktop daemon 装配层)在实现里决定**,让上游 authentication
|
|
76
|
+
* 包无需反向依赖 Electron / Turing / qimei 等下游能力。
|
|
77
|
+
*
|
|
78
|
+
* 由宿主**可选**绑定到 CellJS 容器;未绑定(CLI / Web / headless / 单测)时按
|
|
79
|
+
* `@Optional()` 注入为 undefined,`auth/state` 不携带任何额外 header,对这些形态
|
|
80
|
+
* 零影响。
|
|
81
|
+
*
|
|
82
|
+
* 语义约定:**尽力而为、不等待、不阻断登录**。`provide()` 应立即返回当前快照
|
|
83
|
+
* (读缓存 / env),拿不到的头业务侧自己省略即可;内部异常由 authentication 包
|
|
84
|
+
* 兜底吞掉,绝不因遥测公参阻断登录。
|
|
85
|
+
*/
|
|
86
|
+
export declare const AuthStateHeaderProvider: unique symbol;
|
|
87
|
+
export interface AuthStateHeaderProvider {
|
|
88
|
+
/** 返回要附加到 `auth/state` 请求上的额外 header 集合(可能为空)。 */
|
|
89
|
+
provide(): Promise<Record<string, string>>;
|
|
90
|
+
}
|
|
70
91
|
export declare const enum Edition {
|
|
71
92
|
Pro = "pro",
|
|
72
93
|
Personal = "personal",
|
|
@@ -159,12 +180,29 @@ export interface AuthDevice {
|
|
|
159
180
|
expiresIn: number;
|
|
160
181
|
interval: number;
|
|
161
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Options shared by the logout decision point (`AuthenticationManager.logout`)
|
|
185
|
+
* and the provider hook (`AuthenticationProvider.removeSession`).
|
|
186
|
+
*/
|
|
187
|
+
export interface LogoutOptions {
|
|
188
|
+
/**
|
|
189
|
+
* Whether to revoke the session on the server (call the server logout
|
|
190
|
+
* endpoint) in addition to clearing local state.
|
|
191
|
+
*
|
|
192
|
+
* Only user-initiated ("manual") logout should set this to `true`. Passive
|
|
193
|
+
* logout (e.g. auto-logout triggered by a 401 on an auth verification path)
|
|
194
|
+
* must leave it `false`/unset: at that point the token is already rejected
|
|
195
|
+
* by the server and the endpoint/refresh-token context is unreliable, so a
|
|
196
|
+
* server revoke call would be useless noise. Defaults to `false`.
|
|
197
|
+
*/
|
|
198
|
+
revokeServerSession?: boolean;
|
|
199
|
+
}
|
|
162
200
|
export interface AuthenticationProvider {
|
|
163
201
|
getAuthenticationType(): Promise<AuthenticationType[]>;
|
|
164
202
|
support(ctx?: LoginContext): Promise<boolean>;
|
|
165
203
|
createSession(ctx: SignContext): Promise<AuthSession>;
|
|
166
204
|
refreshSession(session: AuthSession, ctx: SignContext): Promise<AuthSession>;
|
|
167
|
-
removeSession(session: AuthSession): Promise<void>;
|
|
205
|
+
removeSession(session: AuthSession, options?: LogoutOptions): Promise<void>;
|
|
168
206
|
switchAccount(account: Account, authSession: AuthSession, ctx: SignContext): Promise<AuthSession>;
|
|
169
207
|
checkNetworkConnectivity?(): Promise<APIResult<boolean>>;
|
|
170
208
|
}
|
|
@@ -217,7 +255,7 @@ export interface AuthenticationManager {
|
|
|
217
255
|
currentSessionSubject: BehaviorSubject<AuthSession | undefined>;
|
|
218
256
|
login(ctx?: LoginContext): Promise<boolean>;
|
|
219
257
|
cancelLogin(): void;
|
|
220
|
-
logout(): Promise<void>;
|
|
258
|
+
logout(options?: LogoutOptions): Promise<void>;
|
|
221
259
|
refreshSession(): Promise<void>;
|
|
222
260
|
waitForSessionRefresh(): Promise<void>;
|
|
223
261
|
/** Force one authoritative, singleflight refresh after an auth failure. */
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { RestOperations } from '@celljs/http';
|
|
2
2
|
import { AuthenticationType, ClientInfoProvider, ProductManager } from '../../../product/lib/common/index.js';
|
|
3
3
|
import { ExternalUriOpener } from '../../../runtime/lib/common/index.js';
|
|
4
|
-
import { Logger } from '../../../telemetry/lib/common/index.js';
|
|
5
|
-
import {
|
|
4
|
+
import { Logger, type Span } from '../../../telemetry/lib/common/index.js';
|
|
5
|
+
import { type LoginObservationContext } from './authentication-observation.js';
|
|
6
|
+
import { Account, APIResult, AuthenticationProvider, AuthSession, AuthStateHeaderProvider, LoginContext, LogoutOptions, ProductEnvService, SignContext, SignLicenseError } from './authentication-protocol.js';
|
|
6
7
|
/** 登录漏斗步骤回调,由外部消费者(如 workbuddy-server)注入上报逻辑。 */
|
|
7
8
|
export type LoginStepCallback = (step: string, dims: Record<string, string>) => void;
|
|
8
9
|
/**
|
|
@@ -10,9 +11,14 @@ export type LoginStepCallback = (step: string, dims: Record<string, string>) =>
|
|
|
10
11
|
* @param callback 回调函数,undefined 表示清除
|
|
11
12
|
* @param onlyIfVersion 可选,传入时只有当前 version 匹配才执行清除(防止旧轮 finally 覆盖新轮)
|
|
12
13
|
* @param loginSessionId 可选,当前登录会话 ID,供 openAuthUrl 注入到 authUrl 中传递给 Web 登录页
|
|
14
|
+
* @param observation 可选,宿主登录观测上下文,与回调同生命周期
|
|
13
15
|
* @returns 设置后的 version
|
|
14
16
|
*/
|
|
15
|
-
export declare function setLoginStepCallback(callback: LoginStepCallback | undefined, onlyIfVersion?: number, loginSessionId?: string): number;
|
|
17
|
+
export declare function setLoginStepCallback(callback: LoginStepCallback | undefined, onlyIfVersion?: number, loginSessionId?: string, observation?: LoginObservationContext): number;
|
|
18
|
+
/** Whether the host registered login observation; other products keep their login URLs unchanged. */
|
|
19
|
+
export declare function hasHostLoginObservation(): boolean;
|
|
20
|
+
/** 让 Web 登录页加入宿主登录 journey(仅国内版 workbuddy 平台);宿主未注册观测时不改 URL。 */
|
|
21
|
+
export declare function appendHostLoginJourneyParams(url: URL, platform: string | undefined, handoffSpan?: Span): void;
|
|
16
22
|
interface AuthState {
|
|
17
23
|
state: string;
|
|
18
24
|
authUrl: string;
|
|
@@ -35,6 +41,11 @@ export declare class ExternalLinkAuthenticationProvider implements Authenticatio
|
|
|
35
41
|
protected readonly restOperations: RestOperations;
|
|
36
42
|
protected readonly logger: Logger;
|
|
37
43
|
protected readonly clientInfoProvider: ClientInfoProvider;
|
|
44
|
+
/**
|
|
45
|
+
* `auth/state` 额外请求头数据源(Issue #94672)。可选依赖:仅 WorkBuddy Desktop
|
|
46
|
+
* daemon 绑定,CLI / Web / headless / 单测未绑定时为 undefined,不携带额外 header。
|
|
47
|
+
*/
|
|
48
|
+
protected readonly authStateHeaderProvider?: AuthStateHeaderProvider;
|
|
38
49
|
private configuration;
|
|
39
50
|
/**
|
|
40
51
|
* The last auth URL that was opened in the browser.
|
|
@@ -55,10 +66,15 @@ export declare class ExternalLinkAuthenticationProvider implements Authenticatio
|
|
|
55
66
|
getAuthenticationType(): Promise<AuthenticationType[]>;
|
|
56
67
|
createSession(ctx: SignContext): Promise<AuthSession>;
|
|
57
68
|
refreshSession(session: AuthSession, ctx: SignContext): Promise<AuthSession>;
|
|
58
|
-
removeSession(): Promise<void>;
|
|
69
|
+
removeSession(session?: AuthSession, options?: LogoutOptions): Promise<void>;
|
|
59
70
|
switchAccount(account: Account, authSession: AuthSession, ctx: SignContext): Promise<AuthSession>;
|
|
71
|
+
/**
|
|
72
|
+
* 取 `auth/state` 的额外请求头(Issue #94672)。provider 未绑定(CLI / Web /
|
|
73
|
+
* headless / 单测)返回空对象;实现内部任何异常都吞掉退化为空,绝不阻断登录。
|
|
74
|
+
*/
|
|
75
|
+
private resolveAuthStateExtraHeaders;
|
|
60
76
|
private fetchAuthState;
|
|
61
|
-
protected openAuthUrl(authState: AuthState): Promise<void>;
|
|
77
|
+
protected openAuthUrl(authState: AuthState, handoffSpan?: Span): Promise<void>;
|
|
62
78
|
/**
|
|
63
79
|
* 打开登录页前对 authUrl 追加环境相关参数的可覆写钩子。
|
|
64
80
|
* 基类默认不追加任何参数;子类(如 CLI IOA 分支)覆写此方法即可注入自己的 query,
|
package/cli/dist-server/types/workspace/authentication/lib/common/wx-authentication-provider.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Logger } from '@celljs/core';
|
|
2
2
|
import { RestOperations } from '@celljs/http';
|
|
3
3
|
import { AuthenticationType, ProductManager } from '../../../product/lib/common/index.js';
|
|
4
|
-
import { Account, AuthenticationProvider, AuthSession, SignContext } from './authentication-protocol.js';
|
|
4
|
+
import { Account, AuthenticationProvider, AuthSession, LogoutOptions, SignContext } from './authentication-protocol.js';
|
|
5
5
|
export declare class WxAuthenticationProvider implements AuthenticationProvider {
|
|
6
6
|
protected readonly restOperations: RestOperations;
|
|
7
7
|
protected readonly productManager: ProductManager;
|
|
@@ -12,7 +12,7 @@ export declare class WxAuthenticationProvider implements AuthenticationProvider
|
|
|
12
12
|
getAuthenticationType(): Promise<AuthenticationType[]>;
|
|
13
13
|
createSession(ctx: SignContext): Promise<AuthSession>;
|
|
14
14
|
refreshSession(session: AuthSession, ctx: SignContext): Promise<AuthSession>;
|
|
15
|
-
removeSession(): Promise<void>;
|
|
15
|
+
removeSession(_session?: AuthSession, _options?: LogoutOptions): Promise<void>;
|
|
16
16
|
switchAccount(account: Account, authSession: AuthSession, ctx: SignContext): Promise<AuthSession>;
|
|
17
17
|
private fetchTokenByTmpCode;
|
|
18
18
|
private fetchAccounts;
|
package/cli/dist-server/types/workspace/cbc-checkpoint/lib/node/checkpoint/checkpoint-protocol.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export interface CheckpointService {
|
|
|
30
30
|
* @param options.autoAddToHistory - 是否自动添加到 session history (默认 true)
|
|
31
31
|
* @param options.messageId - 快照关联的消息ID (默认为空)
|
|
32
32
|
* @param options.isSnapshotUpdate - 是否为快照更新 (默认 false)
|
|
33
|
+
* @param options.filePath - 只更新该路径的文件版本 (默认更新全部已跟踪文件)
|
|
33
34
|
* @returns 创建的 checkpoint,无需创建时返回 undefined
|
|
34
35
|
*/
|
|
35
36
|
createCheckpoint(session: Session, options?: {
|
|
@@ -37,6 +38,7 @@ export interface CheckpointService {
|
|
|
37
38
|
throwOnError?: boolean;
|
|
38
39
|
messageId?: string;
|
|
39
40
|
isSnapshotUpdate?: boolean;
|
|
41
|
+
filePath?: string;
|
|
40
42
|
}): Promise<Checkpoint | undefined>;
|
|
41
43
|
/** 回退到指定 checkpoint */
|
|
42
44
|
revertToCheckpoint(session: Session, checkpoint: Checkpoint, scope: RevertScope): Promise<void>;
|
package/cli/dist-server/types/workspace/cbc-checkpoint/lib/node/checkpoint/checkpoint-service.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export declare class CheckpointServiceImpl implements CheckpointService {
|
|
|
16
16
|
throwOnError?: boolean;
|
|
17
17
|
messageId?: string;
|
|
18
18
|
isSnapshotUpdate?: boolean;
|
|
19
|
+
filePath?: string;
|
|
19
20
|
}): Promise<Checkpoint | undefined>;
|
|
20
21
|
revertToCheckpoint(session: Session, checkpoint: Checkpoint, scope: import('./checkpoint-protocol.js').RevertScope): Promise<void>;
|
|
21
22
|
getRewindableCheckpoints(session: Session): Checkpoint[];
|
|
@@ -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 '../../../../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 {};
|