@tencent-ai/agent-harness 0.2.0-beta.10 → 0.2.0-beta.11
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 +9 -0
- package/cli/CHANGELOG.md +42 -0
- package/cli/dist-server/shared.cjs +316 -315
- package/cli/dist-server/types/node/agent/agent-controller.d.ts +1 -0
- package/cli/dist-server/types/node/agent/index.d.ts +1 -0
- package/cli/dist-server/types/node/agent/interceptors/image-interceptors.d.ts +1 -2
- package/cli/dist-server/types/node/agent/interceptors/sandbox-interceptor.d.ts +1 -0
- package/cli/dist-server/types/node/agent/steer-model-input-preparer.d.ts +11 -0
- package/cli/dist-server/types/node/agent-task/agent-task.d.ts +12 -0
- package/cli/dist-server/types/node/agent-team/backends/teammate-backend-protocol.d.ts +2 -0
- package/cli/dist-server/types/node/agent-view/session-handoff.d.ts +7 -0
- package/cli/dist-server/types/node/channel/channel-protocol.d.ts +8 -8
- package/cli/dist-server/types/node/cli/cli-runtime-options.d.ts +24 -1
- package/cli/dist-server/types/node/command/clear-command-executor.d.ts +2 -0
- package/cli/dist-server/types/node/hooks/hook-protocol.d.ts +3 -67
- package/cli/dist-server/types/node/loopback/endpoint-provider.d.ts +3 -0
- package/cli/dist-server/types/node/loopback/server-protocol.d.ts +7 -0
- package/cli/dist-server/types/node/memory/memory-relevance-protocol.d.ts +6 -1
- package/cli/dist-server/types/node/memory/memory-relevance-service.d.ts +3 -2
- package/cli/dist-server/types/node/model/model-protocol.d.ts +4 -0
- package/cli/dist-server/types/node/security-review/gate.d.ts +1 -0
- package/cli/dist-server/types/node/security-review/protocol.d.ts +2 -0
- package/cli/dist-server/types/node/session/session-hook-host-adapter.d.ts +2 -2
- package/cli/dist-server/types/node/settings/current-session-model-transition.d.ts +5 -4
- package/cli/dist-server/types/node/settings/settings-protocol.d.ts +2 -0
- package/cli/dist-server/types/node/tools/a2a-cancel-task-tool.d.ts +4 -4
- package/cli/dist-server/types/node/tools/a2a-get-task-tool.d.ts +4 -4
- package/cli/dist-server/types/node/tools/audio-transcribe-tool.d.ts +1 -2
- package/cli/dist-server/types/node/tools/grep-tool.d.ts +2 -0
- package/cli/dist-server/types/node/tools/image-service.d.ts +3 -1
- package/cli/dist-server/types/node/tools/index.d.ts +1 -0
- package/cli/dist-server/types/node/tools/media-file-writer.d.ts +12 -0
- package/cli/dist-server/types/node/tools/multi-edit-tool.d.ts +4 -4
- package/cli/dist-server/types/node/tools/powershell-tool.d.ts +2 -0
- package/cli/dist-server/types/node/tools/send-message-tool.d.ts +2 -2
- package/cli/dist-server/types/node/tools/tool-hook-manager.d.ts +2 -2
- package/cli/dist-server/types/node/tools/tool-manager.d.ts +1 -0
- package/cli/dist-server/types/node/tools/tool-protocol.d.ts +2 -2
- package/cli/dist-server/types/node/tools/video-service.d.ts +2 -0
- package/cli/dist-server/types/node/tools/wecom-reply-tool.d.ts +2 -2
- package/cli/dist-server/types/vendor/cbc-core/node/agent/agent-protocol.d.ts +12 -0
- package/cli/dist-server/types/vendor/cbc-core/node/agent/agent-service.d.ts +11 -0
- package/cli/dist-server/types/vendor/cbc-core/node/agent/index.d.ts +1 -0
- package/cli/dist-server/types/vendor/cbc-core/node/agent/runner-factory.d.ts +6 -0
- package/cli/dist-server/types/vendor/cbc-core/node/context/compact-strategy-base.d.ts +17 -5
- package/cli/dist-server/types/vendor/cbc-core/node/context/pre-switch-model.d.ts +34 -0
- package/cli/dist-server/types/vendor/cbc-core/node/hooks/hook-protocol.d.ts +118 -3
- package/cli/dist-server/types/vendor/cbc-core/node/message-queue/index.d.ts +1 -0
- package/cli/dist-server/types/vendor/cbc-core/node/message-queue/injectable-content.d.ts +15 -18
- package/cli/dist-server/types/vendor/cbc-core/node/message-queue/steer-input-buffer-protocol.d.ts +12 -13
- package/cli/dist-server/types/vendor/cbc-core/node/message-queue/steer-input-buffer.d.ts +1 -2
- package/cli/dist-server/types/vendor/cbc-core/node/message-queue/steer-model-input-preparer-protocol.d.ts +13 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session/interruption-service.d.ts +11 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-fork-guard.d.ts +2 -1
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-hook-manager.d.ts +2 -2
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-manager.d.ts +9 -0
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-protocol.d.ts +9 -2
- package/cli/dist-server/types/vendor/cbc-core/node/session/session-store.d.ts +3 -3
- package/cli/dist-server/types/vendor/cbc-core/node/trace/trace-turn-gate.d.ts +13 -0
- package/cli/dist-server/types/vendor/cbc-core/node/utils/error-utils.d.ts +7 -0
- package/cli/dist-server/types/vendor/cbc-core/node/utils/index.d.ts +2 -0
- package/cli/dist-server/types/vendor/cbc-core/node/utils/markdown-code-utils.d.ts +15 -0
- package/cli/dist-server/types/vendor/cbc-core/node/utils/message-content-utils.d.ts +3 -1
- package/cli/dist-server/types/vendor/cbc-core/node/utils/responses-api-utils.d.ts +21 -0
- package/cli/dist-server/types/vendor/cbc-core/node/utils/session-utils.d.ts +20 -0
- package/cli/dist-server/types/vendor/cbc-core/node/utils/usage-utils.d.ts +18 -0
- package/cli/dist-server/types/vendor/cbc-shared/node/agent/openai-agents-types.d.ts +3 -1
- package/cli/dist-server/types/vendor/cbc-shared/node/index.d.ts +1 -0
- package/cli/dist-server/types/vendor/cbc-shared/node/logging/structured-event-log.d.ts +64 -0
- package/cli/dist-server/types/vendor/cbc-shared/node/model/model-errors.d.ts +10 -0
- package/cli/dist-server/types/workspace/authentication/lib/common/authentication-http-interceptor.d.ts +1 -15
- package/cli/dist-server/types/workspace/authentication/lib/common/authentication-manager.d.ts +13 -0
- package/cli/dist-server/types/workspace/authentication/lib/common/authentication-protocol.d.ts +7 -0
- package/cli/dist-server/types/workspace/authentication/lib/common/authentication-refresh-bypass.d.ts +9 -0
- package/cli/dist-server/types/workspace/authentication/lib/common/index.d.ts +1 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/agent-protocol.d.ts +12 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/agent-service.d.ts +11 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/index.d.ts +1 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/agent/runner-factory.d.ts +6 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/context/compact-strategy-base.d.ts +17 -5
- package/cli/dist-server/types/workspace/cbc-core/lib/node/context/pre-switch-model.d.ts +34 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/hooks/hook-protocol.d.ts +118 -3
- package/cli/dist-server/types/workspace/cbc-core/lib/node/message-queue/index.d.ts +1 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/message-queue/injectable-content.d.ts +15 -18
- package/cli/dist-server/types/workspace/cbc-core/lib/node/message-queue/steer-input-buffer-protocol.d.ts +12 -13
- package/cli/dist-server/types/workspace/cbc-core/lib/node/message-queue/steer-input-buffer.d.ts +1 -2
- package/cli/dist-server/types/workspace/cbc-core/lib/node/message-queue/steer-model-input-preparer-protocol.d.ts +13 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/interruption-service.d.ts +11 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-fork-guard.d.ts +2 -1
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-hook-manager.d.ts +2 -2
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-manager.d.ts +9 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-protocol.d.ts +9 -2
- package/cli/dist-server/types/workspace/cbc-core/lib/node/session/session-store.d.ts +3 -3
- package/cli/dist-server/types/workspace/cbc-core/lib/node/trace/trace-turn-gate.d.ts +13 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/error-utils.d.ts +7 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/index.d.ts +2 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/markdown-code-utils.d.ts +15 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/message-content-utils.d.ts +3 -1
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/responses-api-utils.d.ts +21 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/session-utils.d.ts +20 -0
- package/cli/dist-server/types/workspace/cbc-core/lib/node/utils/usage-utils.d.ts +18 -0
- package/cli/dist-server/types/workspace/cbc-daemon/lib/node/daemon/daemon-auto-restart.d.ts +2 -2
- package/cli/dist-server/types/workspace/cbc-daemon/lib/node/daemon/daemon-protocol.d.ts +17 -1
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/engine/enable-flag.d.ts +28 -24
- package/cli/dist-server/types/workspace/cbc-plugins/lib/node/mods/loader/bootstrap.d.ts +2 -2
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/agent/openai-agents-types.d.ts +3 -1
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/index.d.ts +1 -0
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/logging/structured-event-log.d.ts +64 -0
- package/cli/dist-server/types/workspace/cbc-shared/lib/node/model/model-errors.d.ts +10 -0
- package/cli/dist-server/types/workspace/core/lib/common/utils/env-utils.d.ts +12 -1
- package/cli/dist-server/types/workspace/product/lib/common/model-catalog/index.d.ts +2 -0
- package/cli/dist-server/types/workspace/product/lib/common/types/features.d.ts +36 -0
- package/cli/dist-server/types/workspace/product/lib/common/types/language-model.d.ts +7 -0
- package/cli/dist-server/types/workspace/sandbox-cli/lib/node/sandbox-center-client.d.ts +1 -1
- package/cli/dist-server/types/workspace/telemetry/lib/common/event/types/craft.d.ts +2 -1
- package/cli/dist-server/types/workspace/telemetry/lib/common/tracing/index.d.ts +2 -2
- package/cli/dist-server/types/workspace/telemetry/lib/common/tracing/otel-env.d.ts +16 -5
- package/cli/dist-server/types/workspace/telemetry/lib/common/tracing/trace-protocol.d.ts +9 -0
- package/cli/package.json +1 -1
- package/cli/product.cloudhosted.json +1 -1
- package/cli/product.internal.json +1 -1
- package/cli/product.ioa.json +1 -1
- package/cli/product.json +1 -1
- package/cli/product.selfhosted.json +1 -1
- package/cli/vendor/shim/node-safe-delete-shim.cjs +20 -3
- package/cli/vendor/shim/sitecustomize.py +17 -4
- package/docs/acp-v2.md +21 -2
- package/docs/client.md +44 -0
- package/docs/errors.md +1 -0
- package/docs/in-process.md +1 -0
- package/lib/agent/v2.js +1 -1
- package/lib/application/services.d.ts +1 -0
- package/lib/application/services.js +1 -1
- package/lib/cli/main.js +3 -3
- package/lib/cli/options.d.ts +2 -1
- package/lib/cli/options.js +4 -2
- package/lib/harness/runtime.js +1 -1
- package/lib/harness/types.d.ts +2 -0
- package/lib/runtime/component-protocol.js +1 -1
- package/package.json +9 -9
|
@@ -24,19 +24,19 @@ declare const MultiEditFileParameters: z.ZodObject<{
|
|
|
24
24
|
replace_all?: boolean | undefined;
|
|
25
25
|
}>, "many">;
|
|
26
26
|
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
file_path: string;
|
|
27
28
|
edits: {
|
|
28
29
|
new_string: string;
|
|
29
30
|
old_string: string;
|
|
30
31
|
replace_all: boolean;
|
|
31
32
|
}[];
|
|
32
|
-
file_path: string;
|
|
33
33
|
}, {
|
|
34
|
+
file_path: string;
|
|
34
35
|
edits: {
|
|
35
36
|
new_string: string;
|
|
36
37
|
old_string: string;
|
|
37
38
|
replace_all?: boolean | undefined;
|
|
38
39
|
}[];
|
|
39
|
-
file_path: string;
|
|
40
40
|
}>;
|
|
41
41
|
export declare class MultiEditTool extends SandboxPermissionFileTool implements Tool {
|
|
42
42
|
protected readonly workspace: Workspace;
|
|
@@ -62,19 +62,19 @@ export declare class MultiEditTool extends SandboxPermissionFileTool implements
|
|
|
62
62
|
replace_all?: boolean | undefined;
|
|
63
63
|
}>, "many">;
|
|
64
64
|
}, "strip", z.ZodTypeAny, {
|
|
65
|
+
file_path: string;
|
|
65
66
|
edits: {
|
|
66
67
|
new_string: string;
|
|
67
68
|
old_string: string;
|
|
68
69
|
replace_all: boolean;
|
|
69
70
|
}[];
|
|
70
|
-
file_path: string;
|
|
71
71
|
}, {
|
|
72
|
+
file_path: string;
|
|
72
73
|
edits: {
|
|
73
74
|
new_string: string;
|
|
74
75
|
old_string: string;
|
|
75
76
|
replace_all?: boolean | undefined;
|
|
76
77
|
}[];
|
|
77
|
-
file_path: string;
|
|
78
78
|
}>;
|
|
79
79
|
argumentRenderer: ToolCallArgumentRenderer;
|
|
80
80
|
resolveNeedPermissionArgs(_runContext: RunContext, input: z.infer<typeof MultiEditFileParameters>, _callId?: string): ToolArg[];
|
|
@@ -14,6 +14,8 @@ import { BaseTool } from './base-tool';
|
|
|
14
14
|
import { Tool, ToolCallArgumentRenderer, ToolResult } from './tool-protocol';
|
|
15
15
|
type ShellServiceType = import('../shell/index.js').ShellService;
|
|
16
16
|
type BashSandboxManagerType = import('../bash-sandbox/bash-sandbox-protocol.js').BashSandboxManager;
|
|
17
|
+
export declare const RESOLVED_PS_MAX_TIMEOUT_MS = 600000;
|
|
18
|
+
export declare const RESOLVED_PS_DEFAULT_TIMEOUT_MS = 120000;
|
|
17
19
|
declare const PowerShellParameters: z.ZodObject<{
|
|
18
20
|
command: z.ZodString;
|
|
19
21
|
timeout: z.ZodOptional<z.ZodNumber>;
|
|
@@ -53,15 +53,15 @@ export declare class SendMessageTool extends BaseTool implements Tool {
|
|
|
53
53
|
type: "message" | "broadcast" | "shutdown_request" | "shutdown_response" | "plan_approval_response";
|
|
54
54
|
summary?: string | undefined;
|
|
55
55
|
content?: string | undefined;
|
|
56
|
-
approve?: boolean | undefined;
|
|
57
56
|
request_id?: string | undefined;
|
|
57
|
+
approve?: boolean | undefined;
|
|
58
58
|
recipient?: string | undefined;
|
|
59
59
|
}, {
|
|
60
60
|
type: "message" | "broadcast" | "shutdown_request" | "shutdown_response" | "plan_approval_response";
|
|
61
61
|
summary?: string | undefined;
|
|
62
62
|
content?: string | undefined;
|
|
63
|
-
approve?: boolean | undefined;
|
|
64
63
|
request_id?: string | undefined;
|
|
64
|
+
approve?: boolean | undefined;
|
|
65
65
|
recipient?: string | undefined;
|
|
66
66
|
}>;
|
|
67
67
|
argumentRenderer: ToolCallArgumentRenderer;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Session } from '../../vendor/cbc-core/node/index.js';
|
|
1
|
+
import { type InternalHookContext, Session } from '../../vendor/cbc-core/node/index.js';
|
|
2
2
|
import { Logger } from '../../workspace/telemetry/lib/common/index.js';
|
|
3
3
|
import { GalileoSessionBridge } from '../galileo/galileo-session-bridge-protocol';
|
|
4
4
|
import { HookManager } from '../hooks/hook-protocol';
|
|
@@ -33,7 +33,7 @@ export declare class ToolHookManagerImpl implements ToolHookManager {
|
|
|
33
33
|
* NOTE: toolResponse should be the RAW response from the tool,
|
|
34
34
|
* not the ToolResult wrapper. This ensures Claude Code compatibility.
|
|
35
35
|
*/
|
|
36
|
-
executePostToolUseHooks(toolName: string, toolInput: Record<string, any>, toolResponse: unknown, session: Session, transcriptPath: string, cwd?: string, callId?: string): Promise<{
|
|
36
|
+
executePostToolUseHooks(toolName: string, toolInput: Record<string, any>, toolResponse: unknown, session: Session, transcriptPath: string, cwd?: string, callId?: string, internalContext?: InternalHookContext): Promise<{
|
|
37
37
|
message?: string;
|
|
38
38
|
additionalContext?: string;
|
|
39
39
|
updatedToolOutput?: unknown;
|
|
@@ -471,6 +471,7 @@ export declare class ToolManagerImpl implements ToolManager {
|
|
|
471
471
|
protected executeToolWithHooks(tool: Tool, originalExecute: (...args: any[]) => any, input: any, context?: RunContext<Session>, details?: {
|
|
472
472
|
toolCall: FunctionCallItem;
|
|
473
473
|
}, inputFormat?: 'legacy' | 'parsed'): Promise<any>;
|
|
474
|
+
private doExecuteToolWithHooks;
|
|
474
475
|
private authorizeFinalToolAction;
|
|
475
476
|
private getExecutionApprovalAdapter;
|
|
476
477
|
private recordToolRiskExecutionStatus;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BackgroundTask, PromptCacheStability, Session, SubagentLifecycleSnapshot } from '../../vendor/cbc-core/node/index.js';
|
|
1
|
+
import type { BackgroundTask, InternalHookContext, PromptCacheStability, Session, SubagentLifecycleSnapshot } from '../../vendor/cbc-core/node/index.js';
|
|
2
2
|
import { type Agent, type AgentInputItem, type ApprovalScope, type FunctionCallItem, type PermissionMode, type PermissionUpdate, type RuleValue, type RunContext, type RunToolApprovalItem, type ToolArg, type ToolExecuteArgument, type ToolPermissionResult } from '../../vendor/cbc-shared/node/index.js';
|
|
3
3
|
import type { Agent as ProductAgent, Command as ProductCommand, LanguageModel, ProductConfiguration, Skill as ProductSkill } from '../../workspace/product/lib/common/index.js';
|
|
4
4
|
import type { ToolInputParameters as AgentsCoreToolInputParameters } from '@openai/agents-core';
|
|
@@ -539,7 +539,7 @@ export interface ToolHookManager {
|
|
|
539
539
|
* @param cwd - Current working directory
|
|
540
540
|
* @returns Result with optional message and additional context
|
|
541
541
|
*/
|
|
542
|
-
executePostToolUseHooks(toolName: string, toolInput: Record<string, any>, toolResponse: unknown, session: Session, transcriptPath: string, cwd?: string, callId?: string): Promise<{
|
|
542
|
+
executePostToolUseHooks(toolName: string, toolInput: Record<string, any>, toolResponse: unknown, session: Session, transcriptPath: string, cwd?: string, callId?: string, internalContext?: InternalHookContext): Promise<{
|
|
543
543
|
message?: string;
|
|
544
544
|
additionalContext?: string;
|
|
545
545
|
updatedToolOutput?: unknown;
|
|
@@ -5,6 +5,7 @@ import { LanguageModel, ProductConfiguration, ProductManager } from '../../works
|
|
|
5
5
|
import { Logger } from '../../workspace/telemetry/lib/common/index.js';
|
|
6
6
|
import type { RunContext } from '@openai/agents';
|
|
7
7
|
import { SettingsManager } from '../settings';
|
|
8
|
+
import { MediaFileWriter } from './media-file-writer';
|
|
8
9
|
import { type VideoGenerationResult, VideoGenParams, VideoService } from './tool-protocol';
|
|
9
10
|
/**
|
|
10
11
|
* 视频服务实现
|
|
@@ -16,6 +17,7 @@ export declare class VideoServiceImpl implements VideoService {
|
|
|
16
17
|
protected readonly productManager: ProductManager;
|
|
17
18
|
protected readonly logger: Logger;
|
|
18
19
|
protected readonly settingsManager: SettingsManager;
|
|
20
|
+
protected readonly mediaFileWriter: MediaFileWriter;
|
|
19
21
|
private outputDir;
|
|
20
22
|
/**
|
|
21
23
|
* 初始化视频输出目录
|
|
@@ -33,14 +33,14 @@ export declare class WecomReplyTool extends BaseTool implements Tool {
|
|
|
33
33
|
}, "strip", z.ZodTypeAny, {
|
|
34
34
|
chat_id: string;
|
|
35
35
|
text?: string | undefined;
|
|
36
|
-
image_url?: string | undefined;
|
|
37
36
|
file_path?: string | undefined;
|
|
37
|
+
image_url?: string | undefined;
|
|
38
38
|
file_url?: string | undefined;
|
|
39
39
|
}, {
|
|
40
40
|
chat_id: string;
|
|
41
41
|
text?: string | undefined;
|
|
42
|
-
image_url?: string | undefined;
|
|
43
42
|
file_path?: string | undefined;
|
|
43
|
+
image_url?: string | undefined;
|
|
44
44
|
file_url?: string | undefined;
|
|
45
45
|
}>;
|
|
46
46
|
execute(input: {
|
|
@@ -727,6 +727,18 @@ export interface ForkedAgentOptions {
|
|
|
727
727
|
export interface OneTimeRunOptions {
|
|
728
728
|
/** X-Agent-Purpose of the call; defaults to the agent's `AGENT_PURPOSE_MAP` entry, else its name. */
|
|
729
729
|
purpose?: string;
|
|
730
|
+
/**
|
|
731
|
+
* 本次一次性调用使用的模型 id / name / alias。
|
|
732
|
+
* 解析成功时优先于会话当前模型和 agent 默认模型;解析不到时回落到原有解析。
|
|
733
|
+
* 用于切换模型后的压缩摘要:阈值按新模型,摘要请求仍走切换前的模型。
|
|
734
|
+
*/
|
|
735
|
+
model?: string;
|
|
736
|
+
/**
|
|
737
|
+
* 本次调用的 modelSettings,整体替换 run-scoped agent 的 modelSettings,不写回共享 agent。
|
|
738
|
+
* 按会话变化的参数(如 maxTokens)必须走这里:共享 agent 实例进程内各会话共用,
|
|
739
|
+
* 先写共享实例再调用会被并发会话覆盖。
|
|
740
|
+
*/
|
|
741
|
+
modelSettings?: Agent['modelSettings'];
|
|
730
742
|
}
|
|
731
743
|
export interface RunRequest {
|
|
732
744
|
prompt?: string;
|
|
@@ -213,6 +213,17 @@ export declare class AgentServiceImpl implements AgentService {
|
|
|
213
213
|
* scope instead of on the Session.
|
|
214
214
|
*/
|
|
215
215
|
private streamOneTimeText;
|
|
216
|
+
/**
|
|
217
|
+
* 辅助一次性 run(调用方没传 context、由本方法新建 session)复用「当前会话」的信任锚点:
|
|
218
|
+
* 敏感审批锚 `sensitiveGrantSessionId` 与会话级隐私锁定位。
|
|
219
|
+
*
|
|
220
|
+
* Auxiliary one-time runs inherit the main session's sensitive approval anchor so a
|
|
221
|
+
* previously admitted input remains admitted throughout the trusted call chain.
|
|
222
|
+
*
|
|
223
|
+
* 前提:调用发生在该会话的 async 链内(`getCurrent()` 读 ALS,由 SessionMiddleware
|
|
224
|
+
* 每轮 setCurrent)。纯定时器驱动的调用取不到,此时与既有行为一致地不做任何事。
|
|
225
|
+
*/
|
|
226
|
+
private inheritGrantsFromCurrentSession;
|
|
216
227
|
runOneTime<TContext = Session>(agentName: string, input: string | AgentInputItem[], options?: NonStreamRunOptions<TContext> & OneTimeRunOptions): Promise<string>;
|
|
217
228
|
runOneTime<TContext = Session>(agentName: string, input: string | AgentInputItem[], options?: StreamRunOptions<TContext> & OneTimeRunOptions): Promise<string>;
|
|
218
229
|
runReviewerOneTime(request: ReviewerOneTimeRequest): Promise<ReviewerOneTimeResult>;
|
|
@@ -24,6 +24,7 @@ export * from './interceptors/pre-message-compact-interceptor';
|
|
|
24
24
|
export * from '../tools/prompt-cache-tool-metadata';
|
|
25
25
|
export * from '../trace/turn-context';
|
|
26
26
|
export * from '../trace/trace-id-utils';
|
|
27
|
+
export * from '../trace/trace-turn-gate';
|
|
27
28
|
export * from '../file-rollback/file-rollback-service-protocol';
|
|
28
29
|
export * from '../file-rollback/file-rollback-operation-lock';
|
|
29
30
|
export * from './reviewer-recovery';
|
|
@@ -140,6 +140,12 @@ export declare class RunnerFactoryImpl implements RunnerFactory {
|
|
|
140
140
|
* of an ephemeral `callModelInputFilter` addition. The visible history stays the bare user
|
|
141
141
|
* message; it is admitted exactly once, by the stream consumer, in RunState order.
|
|
142
142
|
*/
|
|
143
|
+
/**
|
|
144
|
+
* 与普通 prompt 的图片拦截器同一实现(#140576):只加工模型输入副本(压缩 / 按模型能力过滤图片),
|
|
145
|
+
* 历史项保留原图。宿主未提供实现(精简变体)时跳过;加工失败按原内容插入,不丢消息。
|
|
146
|
+
*/
|
|
147
|
+
private prepareSteerModelInput;
|
|
148
|
+
private resolveSteerModelInputPreparer;
|
|
143
149
|
private takeSteerContinuationInput;
|
|
144
150
|
/**
|
|
145
151
|
* Visible-history + ACP admission of one drained steer group.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentInputItem } from '../../../cbc-shared/node/index.js';
|
|
1
|
+
import { type Agent, AgentInputItem } 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 { AgentManager, AgentService } from '../agent/agent-protocol';
|
|
@@ -6,6 +6,7 @@ import { HistoryReloadReason, Session, SessionHookManager, SessionManager } from
|
|
|
6
6
|
import { SessionRunStateMachine } from '../session/session-run-state-machine-protocol';
|
|
7
7
|
import { CompactBroadcast } from './context-host-protocol';
|
|
8
8
|
import { CompactStrategy, CompactStrategyContext, ContextCompactSummarizeOptions, PromptRenderer, SummaryScenario } from './context-protocol';
|
|
9
|
+
import { type CompactSummaryModel } from './pre-switch-model';
|
|
9
10
|
/**
|
|
10
11
|
* 压缩策略共享基类,封装 session 状态管理、广播、continue 消息、abort 等基础设施方法。
|
|
11
12
|
* 各具体策略通过继承获得这些能力,只需关注自己的压缩逻辑。
|
|
@@ -94,20 +95,31 @@ export declare abstract class CompactStrategyBase implements CompactStrategy {
|
|
|
94
95
|
*/
|
|
95
96
|
protected sendContinueMessage(session: Session, preCompactAgentName?: string, overrideInput?: AgentInputItem[]): Promise<boolean>;
|
|
96
97
|
/**
|
|
97
|
-
*
|
|
98
|
+
* 计算 contextSummary 本次调用的 modelSettings,由调用方经 `runOneTime({ modelSettings })` 传入。
|
|
99
|
+
* 不写共享的 contextSummary agent:serve/daemon 多会话并发压缩时,maxTokens 随会话的
|
|
100
|
+
* 切换前模型变化,写共享实例会被其他会话覆盖。
|
|
98
101
|
*
|
|
99
102
|
* contextSummary 经 `runOneTime` 调用,绕过 ModelConfigAgentRunInterceptor,
|
|
100
103
|
* 因此不会自动获得主 agent 那套采样参数(temperature / maxTokens / reasoning / text 等)。
|
|
101
104
|
*
|
|
102
105
|
* 这里做两件事:
|
|
103
106
|
* 1) 继承主 agent 当前的 modelSettings(temperature、maxTokens、reasoning、text、providerData 等),
|
|
104
|
-
* 使摘要请求与主对话使用一致的模型配置。contextSummary
|
|
107
|
+
* 使摘要请求与主对话使用一致的模型配置。contextSummary 默认继承主 agent 的模型,
|
|
105
108
|
* 故继承到的 maxTokens 已是该模型经 ModelUtils.getMaxOutputTokens 处理后的值,无需重算。
|
|
106
|
-
*
|
|
109
|
+
* 有切换前模型时,maxTokens 按那个模型重算(继承到的是新模型的输出上限)。
|
|
110
|
+
* 2) 仍缺 maxTokens(模型未配 maxOutputTokens 且未设 CODEBUDDY_CODE_MAX_OUTPUT_TOKENS,
|
|
107
111
|
* 此时主 agent 自身也不写 maxTokens)时,补摘要兜底 24k,避免请求不带 `max_tokens`
|
|
108
112
|
* 让上游网关回退到模型原生输出上限。
|
|
113
|
+
*
|
|
114
|
+
* 失败时返回 undefined,runOneTime 沿用 contextSummary agent 自身的 modelSettings。
|
|
115
|
+
*/
|
|
116
|
+
protected buildSummaryModelSettings(summaryModel?: CompactSummaryModel): Promise<Agent['modelSettings'] | undefined>;
|
|
117
|
+
/**
|
|
118
|
+
* 切换后第一次压缩的摘要模型。从历史用量推导;没有、解析不到、或窗口不比当前大时
|
|
119
|
+
* 返回 undefined,调用方保持「用当前会话模型做摘要」。预算按该模型的物理窗口,
|
|
120
|
+
* 不用新模型的档位 override。
|
|
109
121
|
*/
|
|
110
|
-
protected
|
|
122
|
+
protected resolveSummaryModel(session: Session): Promise<CompactSummaryModel | undefined>;
|
|
111
123
|
/**
|
|
112
124
|
* Render summary prompt template based on scenario.
|
|
113
125
|
*/
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { AgentInputItem } from '../../../cbc-shared/node/index.js';
|
|
2
|
+
import { type ModelContextWindowLike } from './context-protocol';
|
|
3
|
+
/** 摘要请求用切换前模型执行,inputTokens 是它预留输出后的可用输入。 */
|
|
4
|
+
export interface CompactSummaryModel {
|
|
5
|
+
id: string;
|
|
6
|
+
maxOutputTokens?: number;
|
|
7
|
+
inputTokens?: number;
|
|
8
|
+
}
|
|
9
|
+
/** 比较上下文窗口时需要的模型字段。不含会话档位 override。 */
|
|
10
|
+
export interface PreSwitchModelLike {
|
|
11
|
+
id: string;
|
|
12
|
+
maxInputTokens?: number;
|
|
13
|
+
maxOutputTokens?: number;
|
|
14
|
+
contextWindow?: ModelContextWindowLike;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 从会话历史推导切换前真正执行过的模型。
|
|
18
|
+
*
|
|
19
|
+
* 只有它能解析出来,且有效窗口大于当前模型时才返回。窗口不更大时不当作切换:
|
|
20
|
+
* Auto 路由可能让 requestModelId 和会话模型不一致,换到更大窗口也不需要强制压缩。
|
|
21
|
+
* 预算用模型自己的窗口,不用会话上的档位 override。
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveEligiblePreSwitchModel(input: {
|
|
24
|
+
session: {
|
|
25
|
+
history?: AgentInputItem[];
|
|
26
|
+
};
|
|
27
|
+
currentModel: PreSwitchModelLike;
|
|
28
|
+
resolveModel: (modelId: string) => Promise<PreSwitchModelLike | undefined>;
|
|
29
|
+
logger?: {
|
|
30
|
+
warn: (message: string) => void;
|
|
31
|
+
};
|
|
32
|
+
}): Promise<PreSwitchModelLike | undefined>;
|
|
33
|
+
/** 按切换前模型的物理窗口计算摘要预算,不用当前模型的档位 override。 */
|
|
34
|
+
export declare function buildPreSwitchSummaryModel(model: PreSwitchModelLike): CompactSummaryModel;
|
|
@@ -1,5 +1,120 @@
|
|
|
1
|
-
import type { BackgroundTaskInfo, CronTaskInfo, FinalStopReason, HookEvent, HookExecutionOptions, HookExecutionResult, HookPermissionMode, NotificationType, SessionEndReason, SessionStartSource } from '../../../cbc-shared/node/index.js';
|
|
2
|
-
import type { Session } from '../session/session-protocol';
|
|
1
|
+
import type { AgentInputItem, BackgroundTaskInfo, CronTaskInfo, FinalStopReason, HookEvent, HookExecutionOptions, HookExecutionResult, HookPermissionMode, NotificationType, SessionEndReason, SessionStartSource } from '../../../cbc-shared/node/index.js';
|
|
2
|
+
import type { InterceptorGate, Session } from '../session/session-protocol';
|
|
3
|
+
/**
|
|
4
|
+
* Internal Hook Provider interface
|
|
5
|
+
*
|
|
6
|
+
* Use @Component(Hook) to register internal hooks that execute
|
|
7
|
+
* alongside external shell hooks in HookManager.executeHooks().
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* @Component(Hook)
|
|
12
|
+
* export class MyStopHook implements Hook {
|
|
13
|
+
* readonly event = HookEvent.STOP;
|
|
14
|
+
* readonly priority = HookPriority.Normal;
|
|
15
|
+
*
|
|
16
|
+
* async execute(input: HookInput): Promise<HookExecutionResult | undefined> {
|
|
17
|
+
* // Return undefined to skip, or HookExecutionResult to participate
|
|
18
|
+
* return undefined;
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare const Hook: unique symbol;
|
|
24
|
+
/**
|
|
25
|
+
* Data available only to in-process hooks.
|
|
26
|
+
*
|
|
27
|
+
* This context is never forwarded to command, HTTP, prompt, agent, or SDK hooks.
|
|
28
|
+
* It can therefore carry process-local data that must not become part of the
|
|
29
|
+
* serializable hook input contract.
|
|
30
|
+
*/
|
|
31
|
+
export interface InternalHookContext {
|
|
32
|
+
/** Structured input items for the current user prompt. */
|
|
33
|
+
inputItems?: readonly AgentInputItem[];
|
|
34
|
+
/** Files declared by the tool invocation of a PostToolUse hook (`ToolResult.producedArtifacts`). */
|
|
35
|
+
producedArtifacts?: ReadonlyArray<{
|
|
36
|
+
/** Artifact URI or process-local path. */
|
|
37
|
+
uri: string;
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Set by the hook executor: resolves with the aggregated `allowed` verdict of
|
|
41
|
+
* every hook in this dispatch, internal ones included. A hook must not await
|
|
42
|
+
* it inside `execute` (that would wait on itself); chain work onto it instead.
|
|
43
|
+
*/
|
|
44
|
+
decision?: Promise<boolean>;
|
|
45
|
+
/**
|
|
46
|
+
* FinalStop only: the interceptor gate stamped on the run result that reached
|
|
47
|
+
* FinalStop. Unlike `session.interceptorGate`, a later result cannot replace it.
|
|
48
|
+
*/
|
|
49
|
+
interceptorGate?: InterceptorGate;
|
|
50
|
+
}
|
|
51
|
+
/** Associate local attachment paths with an input item without mutating serializable message data. */
|
|
52
|
+
export declare function setInternalInputAttachmentPaths(item: AgentInputItem, paths: readonly string[]): void;
|
|
53
|
+
/** Read process-local attachment paths associated with an input item. */
|
|
54
|
+
export declare function getInternalInputAttachmentPaths(item: unknown): readonly string[];
|
|
55
|
+
/** Carry attachment paths onto a clone or merge of input items; WeakMap entries do not survive copying. */
|
|
56
|
+
export declare function copyInternalInputAttachmentPaths(from: readonly unknown[], to: AgentInputItem): void;
|
|
57
|
+
/**
|
|
58
|
+
* Optional in-process service that keeps a private copy of a local input
|
|
59
|
+
* attachment the host deletes right after submission (TUI paste cleanup).
|
|
60
|
+
* `data` is the file content the host already read, so the copy needs no second read.
|
|
61
|
+
* Returns the copy's path, or undefined to keep the original path.
|
|
62
|
+
*/
|
|
63
|
+
export declare const InputAttachmentRetainer: unique symbol;
|
|
64
|
+
export interface InputAttachmentRetainer {
|
|
65
|
+
retain(filePath: string, data?: Uint8Array): Promise<string | undefined>;
|
|
66
|
+
}
|
|
67
|
+
export interface InputAttachmentSource {
|
|
68
|
+
path: string;
|
|
69
|
+
/** Content the host already read from `path`, if any. */
|
|
70
|
+
data?: Uint8Array;
|
|
71
|
+
}
|
|
72
|
+
/** Like {@link setInternalInputAttachmentPaths}, but lets a registered retainer copy the files first. */
|
|
73
|
+
export declare function retainInternalInputAttachmentPaths(item: AgentInputItem, attachments: readonly InputAttachmentSource[]): Promise<void>;
|
|
74
|
+
export interface Hook {
|
|
75
|
+
/**
|
|
76
|
+
* Hook event type this hook responds to
|
|
77
|
+
*/
|
|
78
|
+
readonly event: HookEvent;
|
|
79
|
+
/**
|
|
80
|
+
* Priority for execution order (lower = earlier)
|
|
81
|
+
*/
|
|
82
|
+
readonly priority: number;
|
|
83
|
+
/**
|
|
84
|
+
* Optional matcher pattern (regex) for filtering
|
|
85
|
+
* - PreToolUse/PostToolUse: matches tool_name
|
|
86
|
+
* - SessionStart: matches source
|
|
87
|
+
* - SessionEnd: matches reason
|
|
88
|
+
* - Other events: not used
|
|
89
|
+
*/
|
|
90
|
+
readonly matcher?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Execute the hook logic
|
|
93
|
+
*
|
|
94
|
+
* @param input - Serializable hook input data
|
|
95
|
+
* @param context - Optional process-local data available only to internal hooks
|
|
96
|
+
* @returns HookExecutionResult or undefined to skip
|
|
97
|
+
*/
|
|
98
|
+
execute(input: HookInput, context?: InternalHookContext): Promise<HookExecutionResult | undefined>;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Priority levels for internal hooks
|
|
102
|
+
* Lower values execute first
|
|
103
|
+
*/
|
|
104
|
+
export declare enum HookPriority {
|
|
105
|
+
/** Highest priority - runs first */
|
|
106
|
+
Highest = 0,
|
|
107
|
+
/** High priority */
|
|
108
|
+
High = 100,
|
|
109
|
+
/** Structured output processing */
|
|
110
|
+
StructuredOutput = 200,
|
|
111
|
+
/** Normal priority - default */
|
|
112
|
+
Normal = 500,
|
|
113
|
+
/** Low priority */
|
|
114
|
+
Low = 800,
|
|
115
|
+
/** Lowest priority - runs last */
|
|
116
|
+
Lowest = 1000
|
|
117
|
+
}
|
|
3
118
|
export interface HookInput {
|
|
4
119
|
/**
|
|
5
120
|
* Session identifier
|
|
@@ -312,6 +427,6 @@ export interface HookInput {
|
|
|
312
427
|
}
|
|
313
428
|
export declare const CoreHookExecutor: unique symbol;
|
|
314
429
|
export interface CoreHookExecutor {
|
|
315
|
-
executeHooks(event: HookEvent, input: HookInput, options?: HookExecutionOptions): Promise<HookExecutionResult>;
|
|
430
|
+
executeHooks(event: HookEvent, input: HookInput, options?: HookExecutionOptions, internalContext?: InternalHookContext): Promise<HookExecutionResult>;
|
|
316
431
|
hasHooks(event: HookEvent, toolName?: string): Promise<boolean>;
|
|
317
432
|
}
|
|
@@ -7,6 +7,7 @@ export * from './prompt-mid-turn-buffer';
|
|
|
7
7
|
export * from './rich-queue-manager-protocol';
|
|
8
8
|
export * from './rich-queue-manager';
|
|
9
9
|
export * from './steer-input-buffer-protocol';
|
|
10
|
+
export * from './steer-model-input-preparer-protocol';
|
|
10
11
|
export * from './steer-input-buffer';
|
|
11
12
|
export * from './followup-queue-protocol';
|
|
12
13
|
export * from './followup-queue';
|
|
@@ -4,13 +4,11 @@ import type { SteerDrainedGroup } from './steer-input-buffer-protocol';
|
|
|
4
4
|
/**
|
|
5
5
|
* 待插入内容的文本抽取与可注入性判定(#85193)。
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
* - `
|
|
9
|
-
*
|
|
7
|
+
* - `isInjectableContent`:只承载文本的 mid-turn 注入(acp-view 后台 drain 轮)。
|
|
8
|
+
* - `isSteerableContent`:steer 入口(ACP `session/steer` / `send_followup_now`)。steer 与普通 prompt
|
|
9
|
+
* 使用同一套用户输入转换,图片随消息进入模型(#140576),因此有文本**或有图片**即可。
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
* Server 的完整 user message 入口单独完成入队校验,保留图片与文件内容。
|
|
13
|
-
* 兼容 `<channel>` 包裹(channel 消息里的斜杠命令同样识别)。
|
|
11
|
+
* 两者都拒绝斜杠命令,兼容 `<channel>` 包裹(channel 消息里的斜杠命令同样识别)。
|
|
14
12
|
*/
|
|
15
13
|
/** 把一组 contentBlock 里的文本抽出并用换行拼接(string 块与 {type:'text'} 块都算,非文本块忽略)。 */
|
|
16
14
|
export declare function contentBlocksToText(contentBlocks: unknown[]): string;
|
|
@@ -18,20 +16,19 @@ export declare function contentBlocksToText(contentBlocks: unknown[]): string;
|
|
|
18
16
|
export declare function isSlashCommandText(text: string): boolean;
|
|
19
17
|
/** 一组 contentBlocks 是否可作为普通文本注入(有文本且非斜杠命令)。 */
|
|
20
18
|
export declare function isInjectableContent(contentBlocks: unknown[]): boolean;
|
|
19
|
+
/** 一组 ACP contentBlocks 是否可 steer 进当前一轮:非斜杠命令,且有文本或有图片。 */
|
|
20
|
+
export declare function isSteerableContent(contentBlocks: unknown[]): boolean;
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
* 可注入的组合并进同一个 reminder(多条按顺序保留、`\n\n` 分隔)。全部不可注入返回 undefined。
|
|
22
|
+
* 把若干组已准入的 steer 消息拼成模型输入 + 历史项 + 实时回执(#87145 / #95921 / #140576)。
|
|
24
23
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* - **实时事件 `emitInfos`**(#95921 Phase 2):仅带 `clientUserMessageId` 的组产出一条;
|
|
34
|
-
* 该 id 控制注入完成后的 pending 对账,`clientMeta` 只作为独立的不透明 metadata 随事件携带。
|
|
24
|
+
* 每组的 `messages` 与普通 prompt 一样是完整 user message(可含 `input_image`),本函数只做
|
|
25
|
+
* steer 独有的三件事,不再改写内容:
|
|
26
|
+
* - **注入项 `items`**(喂模型):每条消息原样放进 `<system-reminder data-role="message-queue">`
|
|
27
|
+
* 包装(包装文本在内容前后各一个 input_text),图片随之进入模型。
|
|
28
|
+
* - **历史项 `historyItems`**(落盘):消息对象本身(按引用,保留准入标记)。带 `clientUserMessageId`
|
|
29
|
+
* 的单消息组把它落为 item.id,保证 CLI 回放的 `user_message_chunk.messageId` 与实时回执一致;
|
|
30
|
+
* 带 `clientMeta` 时原样挂进 `providerData.clientMeta`(CLI 不解读,WorkBuddy 据此识别 steer)。
|
|
31
|
+
* - **实时回执 `emitInfos`**:仅带 `clientUserMessageId` 的组产出一条,`clientMeta` 随事件携带。
|
|
35
32
|
*/
|
|
36
33
|
export declare function buildSteerInjectionInput(groups: readonly SteerDrainedGroup[]): {
|
|
37
34
|
items: AgentInputItem[];
|
package/cli/dist-server/types/vendor/cbc-core/node/message-queue/steer-input-buffer-protocol.d.ts
CHANGED
|
@@ -32,9 +32,11 @@ export type SteerInputDisposition = 'consumed' | 'cancelled' | 'discarded';
|
|
|
32
32
|
export interface SteerDrainedGroup {
|
|
33
33
|
/** Set only after the host validates a one-time mod prompt receipt. */
|
|
34
34
|
readonly modsPromptSubmitted?: true;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
/**
|
|
36
|
+
* 待插入的用户消息,与普通 prompt 同构(可含 `input_image`,#140576)。
|
|
37
|
+
* 按引用保留,内存中的准入标记(WeakMap)随对象传递。
|
|
38
|
+
*/
|
|
39
|
+
readonly messages: readonly UserMessageItem[];
|
|
38
40
|
/**
|
|
39
41
|
* 客户端为本条用户消息提供的不透明对账 id。存在时,CLI 在真正注入后原样回贴;
|
|
40
42
|
* 同时落为历史 user item.id,保证回放身份一致;不存在时不产生实时回执。
|
|
@@ -50,7 +52,7 @@ export interface SteerDrainedGroup {
|
|
|
50
52
|
readonly clientMeta?: unknown;
|
|
51
53
|
}
|
|
52
54
|
/**
|
|
53
|
-
*
|
|
55
|
+
* pushMessages 的归属 + 客户端不透明 metadata 入参(合并为一个对象,避免参数过多)。
|
|
54
56
|
*/
|
|
55
57
|
export interface SteerPushInput {
|
|
56
58
|
/** Server-only provenance, independent of untrusted clientMeta. */
|
|
@@ -72,16 +74,13 @@ export interface SteerPushInput {
|
|
|
72
74
|
}
|
|
73
75
|
export interface SteerInputBuffer {
|
|
74
76
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
* Transfer reviewed native messages. Aborting withdraws only this submission while buffered.
|
|
81
|
-
* Drain and cancellation are synchronous, so exactly one wins. Once consumed, cancellation
|
|
82
|
-
* cannot retract the input. Clear or a stale owner discards it. The promise never rejects.
|
|
77
|
+
* 暂存一组待插入的用户消息(一次 steer 一组)。同一次请求执行里可被调用多次(用户连发多条)。
|
|
78
|
+
* 转移所有权:调用方必须先 clone / 审查,交出后不得再修改。
|
|
79
|
+
* Aborting withdraws only this submission while buffered. Drain and cancellation are
|
|
80
|
+
* synchronous, so exactly one wins. Once consumed, cancellation cannot retract the input.
|
|
81
|
+
* Clear or a stale owner discards it. The consumption promise never rejects.
|
|
83
82
|
*/
|
|
84
|
-
pushMessages(sessionId: string, messages: readonly UserMessageItem[],
|
|
83
|
+
pushMessages(sessionId: string, messages: readonly UserMessageItem[], input: SteerPushInput, signal?: AbortSignal): Promise<SteerInputDisposition>;
|
|
85
84
|
/**
|
|
86
85
|
* 取出并清空当前会话的全部待插入消息(取出即视为已消费)。
|
|
87
86
|
* 只返回归属 `currentRequestId` 的消息;归属其它请求的陈旧残留一并丢弃、不注入。
|
|
@@ -9,9 +9,8 @@ import { type SteerDrainedGroup, type SteerInputBuffer, type SteerInputDispositi
|
|
|
9
9
|
*/
|
|
10
10
|
export declare class SteerInputBufferImpl implements SteerInputBuffer {
|
|
11
11
|
private readonly store;
|
|
12
|
-
|
|
12
|
+
pushMessages(sessionId: string, messages: readonly UserMessageItem[], input: SteerPushInput, signal?: AbortSignal): Promise<SteerInputDisposition>;
|
|
13
13
|
drain(sessionId: string, currentRequestId: string | undefined): SteerDrainedGroup[];
|
|
14
|
-
pushMessages(sessionId: string, messages: readonly UserMessageItem[], ownerRequestId: string, signal?: AbortSignal): Promise<SteerInputDisposition>;
|
|
15
14
|
has(sessionId: string, currentRequestId: string | undefined): boolean;
|
|
16
15
|
clear(sessionId: string): void;
|
|
17
16
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AgentInputItem } from '../../../cbc-shared/node/index.js';
|
|
2
|
+
import type { Session } from '../session/session-protocol';
|
|
3
|
+
/**
|
|
4
|
+
* steer 插入点对**模型输入副本**的加工(#140576),由宿主(agent-cli)实现。
|
|
5
|
+
*
|
|
6
|
+
* 普通 prompt 在 run 起点由图片压缩 / 模型能力过滤拦截器处理,且只改发给模型的副本、历史保留原图;
|
|
7
|
+
* steer 在 run 中途进入 RunState,不经过这些拦截器,因此在插入点用同一份实现处理,语义保持一致。
|
|
8
|
+
*/
|
|
9
|
+
export declare const SteerModelInputPreparer: unique symbol;
|
|
10
|
+
export interface SteerModelInputPreparer {
|
|
11
|
+
/** 就地加工模型输入副本:按当前模型能力过滤图片、压缩超限图片。不得修改历史项。 */
|
|
12
|
+
prepare(session: Session, items: AgentInputItem[]): Promise<void>;
|
|
13
|
+
}
|
|
@@ -448,6 +448,17 @@ export declare class InterruptionServiceImpl implements InterruptionService {
|
|
|
448
448
|
* 此时不退回额度——新请求边界已经清零,再减一次会扣掉新链的额度。
|
|
449
449
|
*/
|
|
450
450
|
private prepareRecoveryAttempt;
|
|
451
|
+
/**
|
|
452
|
+
* reasoning-only 空流的续写前置:把模型层随错误交出的思考落史,续写请求才带得上它,
|
|
453
|
+
* 模型可以接着已有思考往下写,而不是从头审题。
|
|
454
|
+
*
|
|
455
|
+
* 只在重试已经确定发起时调用:不重试(预算耗尽、跑满上游时限、退避期间取消)时历史保持原样。
|
|
456
|
+
* 返回 `false` 时调用方退回原样重发——没有思考可接,就不能让提示说「从中断处继续」。
|
|
457
|
+
*
|
|
458
|
+
* 落史形状与 AbortedStreamDraftStore 的中途取消半成品一致(status=incomplete +
|
|
459
|
+
* isPartialAborted);发请求时由 attachOrphanedReasoningCarriers 补承载项回传给模型。
|
|
460
|
+
*/
|
|
461
|
+
private persistEmptyStreamReasoning;
|
|
451
462
|
/**
|
|
452
463
|
* CLI TUI 手打 `/compact` 裸跑成功后补发 SessionStart('compact')。
|
|
453
464
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type AgentInputItem, FinalStopReason, NotificationType, RunResult, SessionEndReason, SessionStartSource, StreamedRunResult } from '../../../cbc-shared/node/index.js';
|
|
2
2
|
import { Logger } from '../../../../workspace/telemetry/lib/common/index.js';
|
|
3
|
-
import { CoreHookExecutor as HookManager } from '../hooks/hook-protocol';
|
|
3
|
+
import { CoreHookExecutor as HookManager, type InternalHookContext } from '../hooks/hook-protocol';
|
|
4
4
|
import { SessionHookHost } from './session-hook-host-protocol';
|
|
5
5
|
import { Session, SessionHookManager, SessionStore } from './session-protocol';
|
|
6
6
|
/**
|
|
@@ -207,7 +207,7 @@ export declare class SessionHookManagerImpl implements SessionHookManager {
|
|
|
207
207
|
* final terminal state and will not continue via the current Stop hook.
|
|
208
208
|
* Does NOT support continueRequest.
|
|
209
209
|
*/
|
|
210
|
-
executeFinalStopHooks(session: Session, reason?: FinalStopReason): Promise<void>;
|
|
210
|
+
executeFinalStopHooks(session: Session, reason?: FinalStopReason, internalContext?: Pick<InternalHookContext, 'interceptorGate'>): Promise<void>;
|
|
211
211
|
/**
|
|
212
212
|
* UserPromptExpansion — Claude Code 官方事件:任何用户输入的命令/skill 展开成
|
|
213
213
|
* prompt、送进模型之前统一从这里触发,可阻断展开。`command_args` / `prompt` 按
|
|
@@ -176,6 +176,15 @@ export declare class SessionManagerImpl implements SessionManager, ApplicationLi
|
|
|
176
176
|
initRunResultHandler(session: Session): void;
|
|
177
177
|
protected handleRunResult(session: Session): Promise<void>;
|
|
178
178
|
protected handleStreamRunResult(session: Session, result: StreamedRunResult<any, any>, modelResponseMetadata: ModelResponseMetadata): Promise<void>;
|
|
179
|
+
/**
|
|
180
|
+
* Issue #65246:把 API 实际响应的物理模型 id 存到 session.meta,
|
|
181
|
+
* 供 ACP injectMeta 透传给前端,用于 auto 模式展示「推荐模型(xxx)」。
|
|
182
|
+
*/
|
|
183
|
+
private recordResponseModel;
|
|
184
|
+
/**
|
|
185
|
+
* 记录一次模型响应的 finish_reason(Chat Completions 的 choice 与 Responses API 终态事件共用)。
|
|
186
|
+
*/
|
|
187
|
+
private recordModelFinishReason;
|
|
179
188
|
/**
|
|
180
189
|
* content_filter 安全审查终止处理。
|
|
181
190
|
*
|