qlogicagent 2.24.7 → 2.24.9
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/dist/agent.js +10 -70
- package/dist/cli.js +7 -7
- package/dist/index.js +212 -272
- package/dist/orchestration.js +14 -14
- package/dist/types/agent/tool-loop/loop-helpers.d.ts +2 -34
- package/dist/types/agent/tool-loop.d.ts +7 -58
- package/dist/types/agent/types.d.ts +5 -17
- package/dist/types/cli/core-tools/agent-tool-service.d.ts +1 -2
- package/dist/types/cli/handlers/turn-handler.d.ts +1 -1
- package/dist/types/cli/mcp-bootstrap.d.ts +1 -1
- package/dist/types/cli/stdio-acp-protocol-coordinator.d.ts +1 -1
- package/dist/types/contracts/index.d.ts +1 -1
- package/dist/types/contracts/tool-execution-evidence.d.ts +0 -12
- package/dist/types/contracts/tool-name.d.ts +0 -5
- package/dist/types/contracts/turn-event.d.ts +7 -81
- package/dist/types/orchestration/tool-loop/tool-choice-policy.d.ts +0 -1
- package/dist/types/protocol/wire/notification-payloads.d.ts +2 -0
- package/dist/types/runtime/config/tunable-defaults.d.ts +0 -23
- package/dist/types/runtime/infra/agent-project-projection.d.ts +0 -1
- package/dist/types/runtime/infra/subagent-turn-snapshot.d.ts +0 -1
- package/dist/types/runtime/ports/agent-runtime-ports.d.ts +0 -1
- package/dist/types/runtime/prompt/system-prompt-sections.d.ts +1 -14
- package/dist/types/skills/tools/agent-tool.d.ts +0 -5
- package/dist/types/skills/tools/write-tool.d.ts +3 -11
- package/package.json +3 -4
- package/dist/types/agent/tool-loop/agent-argument-normalizer.d.ts +0 -12
- package/dist/types/agent/tool-loop/artifact-final-contract.d.ts +0 -171
- package/dist/types/agent/tool-loop/budget-continuation-policy.d.ts +0 -26
- package/dist/types/agent/tool-loop/completion-action-policy.d.ts +0 -48
- package/dist/types/agent/tool-loop/completion-stop-policy.d.ts +0 -19
- package/dist/types/agent/tool-loop/direct-response-contract.d.ts +0 -12
- package/dist/types/agent/tool-loop/final-status-stream-suppressor.d.ts +0 -22
- package/dist/types/agent/tool-loop/tool-failure-policy.d.ts +0 -50
- package/dist/types/agent/tool-loop/tool-result-classification.d.ts +0 -10
- package/dist/types/agent/tool-loop.test-harness.d.ts +0 -20
- package/dist/types/cli/test-support/fs-cleanup.d.ts +0 -19
- package/dist/types/cli/test-support/tool-catalog-fixture.d.ts +0 -3
- package/dist/types/contracts/structured-planner.d.ts +0 -2
- package/dist/types/runtime/infra/token-budget.d.ts +0 -92
- package/dist/types/runtime/prompt/prompt-policy.d.ts +0 -12
- package/dist/types/test-support/global-home-setup.d.ts +0 -2
- package/dist/types/test-support/project-store-fixture.d.ts +0 -11
|
@@ -45,6 +45,10 @@ export type TurnEvent = {
|
|
|
45
45
|
type: "end";
|
|
46
46
|
turnId: string;
|
|
47
47
|
content: string;
|
|
48
|
+
/** Adapter lifecycle only; it is not a semantic task-success claim. */
|
|
49
|
+
turnStatus?: "completed" | "stopped";
|
|
50
|
+
/** Task success remains unverified unless a higher-level product workflow proves it. */
|
|
51
|
+
taskOutcome?: "unverified";
|
|
48
52
|
usage?: WireTokenUsage;
|
|
49
53
|
model?: string;
|
|
50
54
|
provider?: string;
|
|
@@ -104,17 +108,6 @@ export type TurnEvent = {
|
|
|
104
108
|
keepLength: number;
|
|
105
109
|
/** 供 UI 呈现"已重试/已重新生成"的轻量状态,以及诊断归因。 */
|
|
106
110
|
reason: string;
|
|
107
|
-
} | {
|
|
108
|
-
type: "tool_selection_policy";
|
|
109
|
-
turnId: string;
|
|
110
|
-
policyId: string;
|
|
111
|
-
intent: "benchmark_state_maintenance" | "fresh_evidence" | "verification" | "final_answer" | "tool_recovery" | "lifecycle_reconciliation";
|
|
112
|
-
reason: string;
|
|
113
|
-
availableToolNames: string[];
|
|
114
|
-
enabledToolNamesBefore: string[];
|
|
115
|
-
enabledToolNamesAfter: string[];
|
|
116
|
-
suppressedToolNames: string[];
|
|
117
|
-
nextAction: string;
|
|
118
111
|
} | {
|
|
119
112
|
type: "plan_update";
|
|
120
113
|
turnId: string;
|
|
@@ -128,10 +121,9 @@ export type TurnEvent = {
|
|
|
128
121
|
type: "tool_use_summary";
|
|
129
122
|
turnId: string;
|
|
130
123
|
telemetrySource?: "agent";
|
|
131
|
-
/** Versioned terminal ledger for per-call execution
|
|
132
|
-
ledgerSchemaVersion:
|
|
124
|
+
/** Versioned terminal ledger for per-call execution evidence. */
|
|
125
|
+
ledgerSchemaVersion: 5;
|
|
133
126
|
toolCalls: import("./tool-execution-evidence.js").ToolCallExecutionEvidence[];
|
|
134
|
-
finalAnswerEvidence: import("./tool-execution-evidence.js").FinalAnswerEvidence;
|
|
135
127
|
availableToolNames: string[];
|
|
136
128
|
enabledToolNames: string[];
|
|
137
129
|
toolCallNames: string[];
|
|
@@ -139,30 +131,13 @@ export type TurnEvent = {
|
|
|
139
131
|
name: string;
|
|
140
132
|
reason: string;
|
|
141
133
|
}>;
|
|
142
|
-
argumentCorrections?: {
|
|
143
|
-
roleAlias: number;
|
|
144
|
-
promptAlias: number;
|
|
145
|
-
backgroundAlias: number;
|
|
146
|
-
agentValue: number;
|
|
147
|
-
backgroundValue: number;
|
|
148
|
-
};
|
|
149
134
|
} | {
|
|
150
135
|
type: "lifecycle";
|
|
151
136
|
turnId: string;
|
|
152
|
-
kind: "stage" | "reopen" | "resume" | "context_compression"
|
|
137
|
+
kind: "stage" | "reopen" | "resume" | "context_compression";
|
|
153
138
|
stage?: string;
|
|
154
139
|
status?: string;
|
|
155
140
|
detail?: string;
|
|
156
|
-
reconstruction?: GoalReconstructionState;
|
|
157
|
-
observedAt?: string;
|
|
158
|
-
} | {
|
|
159
|
-
type: "document_maintenance";
|
|
160
|
-
turnId: string;
|
|
161
|
-
checkpointId: string;
|
|
162
|
-
documents: MaintainedDocumentIndex[];
|
|
163
|
-
decisionStateTable: DecisionStateRecord[];
|
|
164
|
-
readCycleFindings: Array<Record<string, unknown>>;
|
|
165
|
-
readCycleGuard: ReadCycleGuard;
|
|
166
141
|
observedAt?: string;
|
|
167
142
|
} | {
|
|
168
143
|
type: "reasoning_delta";
|
|
@@ -202,20 +177,6 @@ export type TurnEvent = {
|
|
|
202
177
|
language?: string;
|
|
203
178
|
content?: string;
|
|
204
179
|
mimeType?: string;
|
|
205
|
-
} | {
|
|
206
|
-
type: "artifact_contract";
|
|
207
|
-
turnId: string;
|
|
208
|
-
artifactRoot?: string;
|
|
209
|
-
writePaths: string[];
|
|
210
|
-
outOfRootWrites: Array<{
|
|
211
|
-
path: string;
|
|
212
|
-
artifactRoot: string;
|
|
213
|
-
toolName: string;
|
|
214
|
-
}>;
|
|
215
|
-
devServerUrls: string[];
|
|
216
|
-
browserVerified: boolean;
|
|
217
|
-
browserEvidence: string[];
|
|
218
|
-
requiresBrowserAcceptance: boolean;
|
|
219
180
|
} | {
|
|
220
181
|
type: "annotations";
|
|
221
182
|
turnId: string;
|
|
@@ -240,38 +201,3 @@ export type TurnEvent = {
|
|
|
240
201
|
outputPreview?: string;
|
|
241
202
|
error?: string;
|
|
242
203
|
};
|
|
243
|
-
export interface GoalReconstructionState {
|
|
244
|
-
goal: string;
|
|
245
|
-
artifactRoot: string;
|
|
246
|
-
decisions: string[];
|
|
247
|
-
defects: string[];
|
|
248
|
-
acceptanceCriteria: string[];
|
|
249
|
-
blockers: string[];
|
|
250
|
-
nextAction: string;
|
|
251
|
-
}
|
|
252
|
-
export interface MaintainedDocumentIndex {
|
|
253
|
-
name?: string;
|
|
254
|
-
path?: string;
|
|
255
|
-
indexed: true;
|
|
256
|
-
maintained: true;
|
|
257
|
-
indexVersion: string;
|
|
258
|
-
contentHash: string;
|
|
259
|
-
summary: string;
|
|
260
|
-
lastReviewedTurn: number;
|
|
261
|
-
fileSizeBytes: number;
|
|
262
|
-
recordCount: number;
|
|
263
|
-
}
|
|
264
|
-
export interface DecisionStateRecord {
|
|
265
|
-
id: string;
|
|
266
|
-
decision: string;
|
|
267
|
-
status: string;
|
|
268
|
-
evidence: string;
|
|
269
|
-
lastConfirmedTurn: number;
|
|
270
|
-
}
|
|
271
|
-
export interface ReadCycleGuard {
|
|
272
|
-
strategy: string;
|
|
273
|
-
nextReadPolicy: string;
|
|
274
|
-
budgetStatus: "within-budget";
|
|
275
|
-
maxReadsPerDocument: number;
|
|
276
|
-
observedReadsByPath: Record<string, number>;
|
|
277
|
-
}
|
|
@@ -34,7 +34,6 @@ export interface ApplyToolChoicePolicyInput<TTool extends ToolChoiceToolLike> {
|
|
|
34
34
|
export interface ApplyToolChoicePolicyResult<TTool extends ToolChoiceToolLike> {
|
|
35
35
|
tools: TTool[];
|
|
36
36
|
normalizedToolChoice?: ToolChoiceLike;
|
|
37
|
-
extraSystemPrompt?: string;
|
|
38
37
|
warnings: string[];
|
|
39
38
|
}
|
|
40
39
|
export declare function filterEligibleTools<TTool extends ToolChoiceToolLike>(params: {
|
|
@@ -20,6 +20,8 @@ export interface TurnTextRollbackNotification {
|
|
|
20
20
|
export interface TurnEndNotification {
|
|
21
21
|
turnId: string;
|
|
22
22
|
content: string;
|
|
23
|
+
turnStatus?: "completed" | "stopped";
|
|
24
|
+
taskOutcome?: "unverified";
|
|
23
25
|
usage?: WireTokenUsage;
|
|
24
26
|
model?: string;
|
|
25
27
|
provider?: string;
|
|
@@ -15,21 +15,8 @@
|
|
|
15
15
|
*/
|
|
16
16
|
/** Default temperature for LLM calls (0 = deterministic). */
|
|
17
17
|
export declare const DEFAULT_TEMPERATURE = 0;
|
|
18
|
-
/** Hard cap on tool calls per round (prevents runaway). */
|
|
19
|
-
export declare const MAX_TOOL_BUDGET_CAP = 100;
|
|
20
|
-
/** Default tool budget per round. Overridable via TOOL_LOOP_DEFAULT_BUDGET env. */
|
|
21
|
-
export declare const DEFAULT_TOOL_BUDGET: number;
|
|
22
18
|
/** Foreground tool execution deadline in ms. Long jobs should use background tasks. */
|
|
23
19
|
export declare const DEFAULT_TOOL_EXECUTION_TIMEOUT_MS: number;
|
|
24
|
-
/** Max consecutive tool call failures before early exit. */
|
|
25
|
-
export declare const MAX_CONSECUTIVE_FAILURES = 3;
|
|
26
|
-
/** Max times the exact same (tool_name, arguments) pair can repeat. */
|
|
27
|
-
export declare const MAX_IDENTICAL_CALL_REPEATS = 2;
|
|
28
|
-
/** Max hard failures for the same normalized target before blocking.
|
|
29
|
-
* Generic typed tools use their full canonical arguments, so a corrected schema or payload is a
|
|
30
|
-
* different invocation. Search and exec retain their domain-specific normalized target keys.
|
|
31
|
-
* Soft-empty results and rejected proposals are not executions and do not consume this budget. */
|
|
32
|
-
export declare const MAX_TOOL_VARIANT_FAILURES = 2;
|
|
33
20
|
/** Default context window size (tokens). */
|
|
34
21
|
export declare const DEFAULT_CONTEXT_WINDOW_TOKENS = 128000;
|
|
35
22
|
/** Reserved tokens for model response output. */
|
|
@@ -42,10 +29,6 @@ export declare const DEFAULT_MODEL_MAX_OUTPUT_TOKENS = 65536;
|
|
|
42
29
|
export declare const MAX_OUTPUT_TOKENS_RECOVERY_LIMIT = 3;
|
|
43
30
|
/** Escalated max output tokens during recovery (CC: 64k). */
|
|
44
31
|
export declare const ESCALATED_MAX_OUTPUT_TOKENS = 65536;
|
|
45
|
-
/** Delta threshold for "diminishing returns" detection (CC: 500). */
|
|
46
|
-
export declare const DIMINISHING_RETURNS_THRESHOLD = 500;
|
|
47
|
-
/** Min consecutive continuations before diminishing returns kicks in. */
|
|
48
|
-
export declare const DIMINISHING_RETURNS_MIN_CONTINUATIONS = 3;
|
|
49
32
|
/** Per-tool result size threshold (chars) for disk persistence. */
|
|
50
33
|
export declare const DEFAULT_MAX_RESULT_SIZE_CHARS = 50000;
|
|
51
34
|
/** Per-message aggregate tool result budget (chars). */
|
|
@@ -113,19 +96,13 @@ export declare const TASK_PANEL_GRACE_MS = 30000;
|
|
|
113
96
|
*/
|
|
114
97
|
export interface TunableDefaults {
|
|
115
98
|
defaultTemperature: number;
|
|
116
|
-
maxToolBudgetCap: number;
|
|
117
|
-
defaultToolBudget: number;
|
|
118
99
|
defaultToolExecutionTimeoutMs: number;
|
|
119
|
-
maxConsecutiveFailures: number;
|
|
120
|
-
maxIdenticalCallRepeats: number;
|
|
121
100
|
defaultContextWindowTokens: number;
|
|
122
101
|
responseBufferTokens: number;
|
|
123
102
|
defaultMaxOutputTokens: number;
|
|
124
103
|
defaultModelMaxOutputTokens: number;
|
|
125
104
|
maxOutputTokensRecoveryLimit: number;
|
|
126
105
|
escalatedMaxOutputTokens: number;
|
|
127
|
-
diminishingReturnsThreshold: number;
|
|
128
|
-
diminishingReturnsMinContinuations: number;
|
|
129
106
|
defaultMaxResultSizeChars: number;
|
|
130
107
|
maxToolResultsPerMessageChars: number;
|
|
131
108
|
toolResultPreviewBytes: number;
|
|
@@ -17,4 +17,3 @@ export type AgentProjectSnapshot = {
|
|
|
17
17
|
export declare function materializeAgentProjectProjection(projectId: string, workspaceDir: string): void;
|
|
18
18
|
export declare function readAgentProjectProjection(): AgentProjectSnapshot;
|
|
19
19
|
export declare function resetAgentProjectProjection(): void;
|
|
20
|
-
export declare function setAgentProjectProjectionForTests(next: AgentProjectSnapshot): void;
|
|
@@ -76,4 +76,3 @@ export declare function recordSubagentActivity(payload: SubagentActivitySnapshot
|
|
|
76
76
|
export declare function recordSubagentCompleted(payload: SubagentCompletedSnapshotInput): PersistedSubagentSnapshot;
|
|
77
77
|
export declare function recordSubagentDecision(payload: SubagentDecisionSnapshotInput): PersistedSubagentSnapshot | undefined;
|
|
78
78
|
export declare function subagentActivityBlock(snapshot: PersistedSubagentSnapshot): Record<string, unknown>;
|
|
79
|
-
export declare function clearSubagentTurnSnapshotsForTests(): void;
|
|
@@ -73,7 +73,6 @@ export interface ToolLoopRuntimePorts {
|
|
|
73
73
|
budget: number;
|
|
74
74
|
model: string;
|
|
75
75
|
}): RuntimeCompressionResult;
|
|
76
|
-
getBudgetContinuationMessage(usagePct: number, totalUsed: number, tokenBudget: number): string;
|
|
77
76
|
createStreamingToolExecutor(config: StreamingToolExecutorPortConfig): StreamingToolExecutorPort;
|
|
78
77
|
resolveToolEligibility(tools: ToolDefinition[], context: unknown): {
|
|
79
78
|
eligibleTools: ToolDefinition[];
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides a section-based system prompt assembly mechanism:
|
|
5
5
|
* - Memoized sections (computed once, cached until clear)
|
|
6
|
-
* - Volatile sections (recompute every turn, cache-breaking)
|
|
7
6
|
* - User-provided appendSystemPrompt / customSystemPrompt
|
|
8
7
|
* - Clear on session reset / compact
|
|
9
8
|
*
|
|
@@ -13,25 +12,15 @@ type ComputeFn = () => string | null | Promise<string | null>;
|
|
|
13
12
|
export interface SystemPromptSection {
|
|
14
13
|
name: string;
|
|
15
14
|
compute: ComputeFn;
|
|
16
|
-
/** If true, recompute every turn (breaks prompt cache). CC: cacheBreak. */
|
|
17
|
-
cacheBreak: boolean;
|
|
18
15
|
}
|
|
19
16
|
/**
|
|
20
17
|
* Create a memoized system prompt section.
|
|
21
18
|
* Computed once, cached until clearSystemPromptSections() is called.
|
|
22
19
|
*/
|
|
23
20
|
export declare function systemPromptSection(name: string, compute: ComputeFn): SystemPromptSection;
|
|
24
|
-
/**
|
|
25
|
-
* Create a volatile system prompt section that recomputes every turn.
|
|
26
|
-
* WARNING: This WILL break prompt cache when the value changes.
|
|
27
|
-
* Use sparingly — only for time-sensitive or frequently changing context.
|
|
28
|
-
*
|
|
29
|
-
* @param _reason - Why this section must be volatile (documentation only, CC parity).
|
|
30
|
-
*/
|
|
31
|
-
export declare function volatileSystemPromptSection(name: string, compute: ComputeFn, _reason?: string): SystemPromptSection;
|
|
32
21
|
/**
|
|
33
22
|
* Resolve all system prompt sections, returning non-null prompt strings.
|
|
34
|
-
* Memoized sections are cached
|
|
23
|
+
* Memoized sections are cached until the section cache is cleared.
|
|
35
24
|
*/
|
|
36
25
|
export declare function resolveSystemPromptSections(sections: SystemPromptSection[]): Promise<string[]>;
|
|
37
26
|
/**
|
|
@@ -39,8 +28,6 @@ export declare function resolveSystemPromptSections(sections: SystemPromptSectio
|
|
|
39
28
|
*/
|
|
40
29
|
export declare function clearSystemPromptSections(): void;
|
|
41
30
|
export interface SystemPromptAssemblyOptions {
|
|
42
|
-
/** Include internal prompt-policy metadata for diagnostics. Defaults to false. */
|
|
43
|
-
includePromptPolicy?: boolean;
|
|
44
31
|
/** Base system prompt (from Gateway config) */
|
|
45
32
|
basePrompt?: string;
|
|
46
33
|
/** Prepended instruction block (from INSTRUCTIONS.md files) */
|
|
@@ -47,11 +47,6 @@ export interface AgentResult {
|
|
|
47
47
|
error?: string;
|
|
48
48
|
maxTurnsReached?: boolean;
|
|
49
49
|
tokensUsed?: number;
|
|
50
|
-
uiAcceptanceEvidence?: Array<{
|
|
51
|
-
source: "fork_verify";
|
|
52
|
-
status: "passed";
|
|
53
|
-
summary: string;
|
|
54
|
-
}>;
|
|
55
50
|
}
|
|
56
51
|
/**
|
|
57
52
|
* Host-provided fork execution backend.
|
|
@@ -21,28 +21,20 @@ export declare const WRITE_TOOL_SCHEMA: {
|
|
|
21
21
|
};
|
|
22
22
|
/** Deps injected by the host runtime for file writing. */
|
|
23
23
|
export interface WriteToolDeps {
|
|
24
|
-
/**
|
|
24
|
+
/** Create a text file. Create parent dirs as needed. */
|
|
25
25
|
writeFile(path: string, content: string, options?: TextFileWriteOptions): Promise<void>;
|
|
26
26
|
/** Check whether the resolved path already exists. */
|
|
27
27
|
fileExists?(path: string): Promise<boolean> | boolean;
|
|
28
28
|
/** Resolve a relative path to absolute. */
|
|
29
29
|
resolvePath(input: string): string;
|
|
30
|
-
/**
|
|
31
|
-
* Check if file has been read before writing (first-read-then-write protection).
|
|
32
|
-
* Returns null if write is allowed, or a warning message.
|
|
33
|
-
* If not provided, no protection is applied.
|
|
34
|
-
*/
|
|
30
|
+
/** Legacy host hook; create-only writes never need an existing-file read. */
|
|
35
31
|
checkReadBeforeWrite?(path: string): string | null;
|
|
36
32
|
/**
|
|
37
33
|
* Validate write access for the given path.
|
|
38
34
|
* Returns null if allowed, or an error message if blocked.
|
|
39
35
|
*/
|
|
40
36
|
validatePath?(path: string): string | null;
|
|
41
|
-
/**
|
|
42
|
-
* Check for concurrent modification before overwriting an existing file.
|
|
43
|
-
* Returns null if safe to write, or a warning if modified since last read.
|
|
44
|
-
* If not provided, no concurrent modification check is performed.
|
|
45
|
-
*/
|
|
37
|
+
/** Legacy host hook; retained in the injected port until its consumers migrate. */
|
|
46
38
|
checkConcurrentModification?(path: string): string | null;
|
|
47
39
|
}
|
|
48
40
|
export declare function createWriteTool(deps: WriteToolDeps): PortableTool<WriteToolParams>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qlogicagent",
|
|
3
|
-
|
|
3
|
+
"version": "2.24.9",
|
|
4
4
|
"packageManager": "pnpm@10.23.0",
|
|
5
5
|
"description": "XiaozhiClaw standard ACP Agent adapter",
|
|
6
6
|
"type": "module",
|
|
@@ -53,7 +53,6 @@
|
|
|
53
53
|
"test": "vitest run",
|
|
54
54
|
"test:slow": "vitest run --config vitest.release.config.ts",
|
|
55
55
|
"test:release": "pnpm test && pnpm run test:slow",
|
|
56
|
-
"test:replay": "vitest run benchmarks/transcript-replay",
|
|
57
56
|
"benchmark:multi-session-real": "tsx benchmarks/multi-session-real/runner.ts",
|
|
58
57
|
"check": "node scripts/run-check.mjs",
|
|
59
58
|
"test:watch": "vitest",
|
|
@@ -78,8 +77,8 @@
|
|
|
78
77
|
"dependencies": {
|
|
79
78
|
"@agentclientprotocol/sdk": "^0.25.0",
|
|
80
79
|
"@napi-rs/canvas": "0.1.100",
|
|
81
|
-
"@xiaozhiclaw/module-sdk": "0.4.
|
|
82
|
-
|
|
80
|
+
"@xiaozhiclaw/module-sdk": "0.4.5",
|
|
81
|
+
"@xiaozhiclaw/provider-core": "0.1.41",
|
|
83
82
|
"ajv": "8.20.0",
|
|
84
83
|
"better-sqlite3": "^12.10.0",
|
|
85
84
|
"dotenv": "^17.3.1",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface HostToolArgumentNormalization {
|
|
2
|
-
rawArguments: string;
|
|
3
|
-
corrections: string[];
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Repairs a small, explicit set of common weak-model aliases at the host boundary.
|
|
7
|
-
*
|
|
8
|
-
* The public tool schema remains narrow. Unknown role values are copied into the
|
|
9
|
-
* canonical `agent` field so the normal tool validation rejects them instead of
|
|
10
|
-
* silently falling back to a generalist.
|
|
11
|
-
*/
|
|
12
|
-
export declare function normalizeHostToolArguments(toolName: string, rawArguments: string): HostToolArgumentNormalization;
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import type { ChatMessage } from "../types.js";
|
|
2
|
-
export interface ArtifactContractState {
|
|
3
|
-
artifactRoot?: string;
|
|
4
|
-
rootSource?: "explicit" | "inferred";
|
|
5
|
-
writePaths: string[];
|
|
6
|
-
deletedPaths: string[];
|
|
7
|
-
outOfRootWrites: Array<{
|
|
8
|
-
path: string;
|
|
9
|
-
artifactRoot: string;
|
|
10
|
-
toolName: string;
|
|
11
|
-
}>;
|
|
12
|
-
devServerUrls: string[];
|
|
13
|
-
browserVerified: boolean;
|
|
14
|
-
browserEvidence: string[];
|
|
15
|
-
browserFailureEvidence: string[];
|
|
16
|
-
/** Build/test verification: a test/build/compile command ran and passed (exit 0). */
|
|
17
|
-
buildVerified: boolean;
|
|
18
|
-
buildEvidence: string[];
|
|
19
|
-
buildFailureEvidence: string[];
|
|
20
|
-
/**
|
|
21
|
-
* Ledger sizes recovered from prior turns' history at turn start. The recovered ledger keeps
|
|
22
|
-
* cross-turn claims reconcilable (a model may legitimately cite files written last turn), but
|
|
23
|
-
* it is NOT this turn's evidence — the engine fallback block only fires on new entries.
|
|
24
|
-
*/
|
|
25
|
-
recoveredBaseline?: {
|
|
26
|
-
writePaths: number;
|
|
27
|
-
devServerUrls: number;
|
|
28
|
-
artifactRoot: boolean;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
export type UiAcceptanceEvidenceSource = "browser_automation" | "frontend_test" | "user_confirmation" | "external_benchmark" | "fork_verify";
|
|
32
|
-
export interface UiAcceptanceEvidence {
|
|
33
|
-
source: UiAcceptanceEvidenceSource;
|
|
34
|
-
status: "passed" | "failed";
|
|
35
|
-
summary: string;
|
|
36
|
-
}
|
|
37
|
-
export interface ArtifactContractEventPayload {
|
|
38
|
-
artifactRoot?: string;
|
|
39
|
-
writePaths: string[];
|
|
40
|
-
deletedPaths: string[];
|
|
41
|
-
outOfRootWrites: Array<{
|
|
42
|
-
path: string;
|
|
43
|
-
artifactRoot: string;
|
|
44
|
-
toolName: string;
|
|
45
|
-
}>;
|
|
46
|
-
devServerUrls: string[];
|
|
47
|
-
browserVerified: boolean;
|
|
48
|
-
browserEvidence: string[];
|
|
49
|
-
browserFailureEvidence: string[];
|
|
50
|
-
requiresBrowserAcceptance: boolean;
|
|
51
|
-
}
|
|
52
|
-
export interface TaskContractItem {
|
|
53
|
-
id: number;
|
|
54
|
-
title: string;
|
|
55
|
-
status: string;
|
|
56
|
-
}
|
|
57
|
-
export declare function createArtifactContractState(inputMessages: readonly ChatMessage[]): ArtifactContractState;
|
|
58
|
-
export declare function requiresBrowserAcceptance(inputMessages: readonly ChatMessage[]): boolean;
|
|
59
|
-
export declare function requiresBuildVerification(inputMessages: readonly ChatMessage[]): boolean;
|
|
60
|
-
export type FinalStatusBrowserVerdict = "verified" | "failed" | "not-run";
|
|
61
|
-
export type FinalStatusBuildVerdict = "passed" | "failed" | "not-run";
|
|
62
|
-
export interface FinalStatusClaim {
|
|
63
|
-
schema: number;
|
|
64
|
-
author?: "model" | "engine";
|
|
65
|
-
done?: string[];
|
|
66
|
-
notDone?: string[];
|
|
67
|
-
artifacts?: {
|
|
68
|
-
root?: string;
|
|
69
|
-
files?: string[];
|
|
70
|
-
urls?: string[];
|
|
71
|
-
};
|
|
72
|
-
verification?: {
|
|
73
|
-
browser?: FinalStatusBrowserVerdict;
|
|
74
|
-
build?: FinalStatusBuildVerdict;
|
|
75
|
-
};
|
|
76
|
-
sources?: {
|
|
77
|
-
cited?: string[];
|
|
78
|
-
};
|
|
79
|
-
blockers?: string[];
|
|
80
|
-
nextAction?: string;
|
|
81
|
-
}
|
|
82
|
-
export interface ParsedFinalStatusBlock {
|
|
83
|
-
/** null = a block was present but not valid schema-1 JSON (malformed). */
|
|
84
|
-
claim: FinalStatusClaim | null;
|
|
85
|
-
start: number;
|
|
86
|
-
end: number;
|
|
87
|
-
}
|
|
88
|
-
/** The final-status contract applies only to turns whose tool surface can produce artifacts or run verification. */
|
|
89
|
-
export declare function finalStatusContractApplies(toolNames: Iterable<string>): boolean;
|
|
90
|
-
export declare const FINAL_STATUS_PROMPT_CONTRACT: string;
|
|
91
|
-
/** Locate and parse the last ```final-status block. Returns null when no block exists. */
|
|
92
|
-
export declare function parseFinalStatusBlock(content: string): ParsedFinalStatusBlock | null;
|
|
93
|
-
export declare function renderFinalStatusBlock(claim: FinalStatusClaim): string;
|
|
94
|
-
export declare function toolCallWritePath(toolName: string, rawArguments: string): string | null;
|
|
95
|
-
export declare function resolveArtifactRootWriteBlock(params: {
|
|
96
|
-
state: ArtifactContractState;
|
|
97
|
-
inputMessages: readonly ChatMessage[];
|
|
98
|
-
toolName: string;
|
|
99
|
-
rawArguments: string;
|
|
100
|
-
}): {
|
|
101
|
-
path: string;
|
|
102
|
-
artifactRoot: string;
|
|
103
|
-
error: string;
|
|
104
|
-
} | null;
|
|
105
|
-
export declare function resolveReadOnlyContextPackWriteBlock(params: {
|
|
106
|
-
toolName: string;
|
|
107
|
-
rawArguments: string;
|
|
108
|
-
}): {
|
|
109
|
-
path: string;
|
|
110
|
-
error: string;
|
|
111
|
-
} | null;
|
|
112
|
-
export declare function recordArtifactRootBlock(state: ArtifactContractState, params: {
|
|
113
|
-
path: string;
|
|
114
|
-
artifactRoot: string;
|
|
115
|
-
toolName: string;
|
|
116
|
-
}): void;
|
|
117
|
-
export declare function updateArtifactContractFromToolResult(params: {
|
|
118
|
-
state: ArtifactContractState;
|
|
119
|
-
inputMessages: readonly ChatMessage[];
|
|
120
|
-
toolName: string;
|
|
121
|
-
rawArguments: string;
|
|
122
|
-
ok: boolean;
|
|
123
|
-
content: string;
|
|
124
|
-
details?: Record<string, unknown>;
|
|
125
|
-
}): void;
|
|
126
|
-
export declare function recordUiAcceptanceEvidence(state: ArtifactContractState, evidence: UiAcceptanceEvidence): void;
|
|
127
|
-
export declare function artifactContractPayload(state: ArtifactContractState, inputMessages: readonly ChatMessage[]): ArtifactContractEventPayload;
|
|
128
|
-
export declare function recoverArtifactContractState(inputMessages: readonly ChatMessage[]): ArtifactContractState;
|
|
129
|
-
export declare function updateArtifactContractFromFinalContent(state: ArtifactContractState, content: string): void;
|
|
130
|
-
export interface FinalStatusReconciliation {
|
|
131
|
-
content: string;
|
|
132
|
-
/** A ```final-status block was present but not valid schema-1 JSON (treated as absent). */
|
|
133
|
-
malformedBlock: boolean;
|
|
134
|
-
/** Internal claim corrections for telemetry/logging. Never append these to assistant prose. */
|
|
135
|
-
notices: string[];
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Locale for engine-authored final-status content. Only the fixed wording skeleton is localized;
|
|
139
|
-
* dynamic data (paths, tool names, counts, blocker reasons, evidence) is always verbatim.
|
|
140
|
-
* Model-authored claims are untouched — they already follow the conversation language.
|
|
141
|
-
*/
|
|
142
|
-
export type EngineStatusLocale = "zh" | "en";
|
|
143
|
-
/**
|
|
144
|
-
* Derive the conversation locale from the LAST user message's text. Han characters → "zh",
|
|
145
|
-
* otherwise "en" (including when no string-content user message exists). Only the newest user
|
|
146
|
-
* turn matters, so engine status follows the language the user is currently writing in.
|
|
147
|
-
*/
|
|
148
|
-
export declare function deriveConversationLocale(messages: readonly ChatMessage[]): EngineStatusLocale;
|
|
149
|
-
export declare function reconcileFinalStatus(params: {
|
|
150
|
-
content: string;
|
|
151
|
-
/** From finalStatusContractApplies() over the turn's tool surface; inactive turns pass through untouched. */
|
|
152
|
-
contractActive: boolean;
|
|
153
|
-
totalToolCallCount: number;
|
|
154
|
-
distinctToolNames: Iterable<string>;
|
|
155
|
-
visibleToolCallCount?: number;
|
|
156
|
-
visibleToolNames?: Iterable<string>;
|
|
157
|
-
artifactContract: ArtifactContractState;
|
|
158
|
-
blockedToolCalls?: ReadonlyArray<{
|
|
159
|
-
name: string;
|
|
160
|
-
reason: string;
|
|
161
|
-
}>;
|
|
162
|
-
activeTasks?: readonly TaskContractItem[];
|
|
163
|
-
/** The turn ended on a forced/failure terminal rather than a clean model stop. */
|
|
164
|
-
forcedStop?: boolean;
|
|
165
|
-
/**
|
|
166
|
-
* Conversation language for engine-authored content. Defaults to "en" so existing tests and
|
|
167
|
-
* non-Chinese sessions are unaffected. Model-authored claims ignore this — they already follow
|
|
168
|
-
* the conversation language.
|
|
169
|
-
*/
|
|
170
|
-
locale?: EngineStatusLocale;
|
|
171
|
-
}): FinalStatusReconciliation;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { AgentLogger, ThinkingBlock, TokenUsage, ToolLoopTransition } from "../types.js";
|
|
2
|
-
export interface BudgetContinuationPolicyInput {
|
|
3
|
-
tokenBudget: number | undefined;
|
|
4
|
-
totalUsage: TokenUsage;
|
|
5
|
-
budgetContinuationCount: number;
|
|
6
|
-
lastBudgetDeltaTokens: number;
|
|
7
|
-
lastBudgetGlobalTokens: number;
|
|
8
|
-
messages: unknown[];
|
|
9
|
-
finalText: string;
|
|
10
|
-
thinkingBlocks: readonly ThinkingBlock[];
|
|
11
|
-
getBudgetContinuationMessage(usagePct: number, totalUsed: number, tokenBudget?: number): string;
|
|
12
|
-
log: Pick<AgentLogger, "info">;
|
|
13
|
-
/** The loop's per-turn recovery trace (surfaced on the final `end` event). Stop
|
|
14
|
-
* reasons are recorded here as `budget_continuation_stop:<reason>` so an engine-side
|
|
15
|
-
* end of nudging is visible to callers/UI, not only in the debug log. */
|
|
16
|
-
recoveryTrace?: Map<string, number>;
|
|
17
|
-
}
|
|
18
|
-
export interface BudgetContinuationPolicyDecision {
|
|
19
|
-
messages: unknown[];
|
|
20
|
-
budgetContinuationCount: number;
|
|
21
|
-
lastBudgetDeltaTokens: number;
|
|
22
|
-
lastBudgetGlobalTokens: number;
|
|
23
|
-
recoveryDetail: string;
|
|
24
|
-
transition: ToolLoopTransition;
|
|
25
|
-
}
|
|
26
|
-
export declare function resolveBudgetContinuationPolicy(input: BudgetContinuationPolicyInput): BudgetContinuationPolicyDecision | null;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { AgentLogger, ChatMessage, ThinkingBlock, ToolLoopTransition } from "../types.js";
|
|
2
|
-
export type CompletionActionPolicyReason = "file_action_verification" | "explicit_required_file_verification" | "explicit_extra_file_verification" | "artifact_index_evidence_verification" | "multi_file_skeleton_verification" | "forbidden_file_creation" | "self_created_read_target";
|
|
3
|
-
export interface CompletionActionPolicyInput {
|
|
4
|
-
inputMessages: readonly ChatMessage[];
|
|
5
|
-
messages: unknown[];
|
|
6
|
-
finalText: string;
|
|
7
|
-
thinkingBlocks: readonly ThinkingBlock[];
|
|
8
|
-
stopHookActive: boolean | undefined;
|
|
9
|
-
totalToolCallCount: number;
|
|
10
|
-
distinctToolNames: ReadonlySet<string>;
|
|
11
|
-
log: Pick<AgentLogger, "info">;
|
|
12
|
-
}
|
|
13
|
-
export interface CompletionActionPolicyDecision {
|
|
14
|
-
reason: CompletionActionPolicyReason;
|
|
15
|
-
messages: unknown[];
|
|
16
|
-
stopHookActive: true;
|
|
17
|
-
transition: ToolLoopTransition;
|
|
18
|
-
}
|
|
19
|
-
export declare function findMissingExplicitRequiredFiles(inputMessages: readonly ChatMessage[], messages: unknown[]): string[];
|
|
20
|
-
/**
|
|
21
|
-
* Terminal-path NOTE (not a replacement): when a forced stop ends the turn with
|
|
22
|
-
* explicitly-requested output files still missing, this returns an engine-attributed
|
|
23
|
-
* note to APPEND to whatever the turn is already ending with. It used to return a
|
|
24
|
-
* "<FAIL-marker> ..." string that REPLACED the model's final text — an extraction
|
|
25
|
-
* misfire then handed the user an engine-authored FAIL verdict the model never made
|
|
26
|
-
* (2026-07-07 review, F5). The engine reports evidence; it does not speak as the model.
|
|
27
|
-
*/
|
|
28
|
-
export declare function buildMissingRequiredFilesNote(input: {
|
|
29
|
-
inputMessages: readonly ChatMessage[];
|
|
30
|
-
messages: unknown[];
|
|
31
|
-
reason: string;
|
|
32
|
-
}): string | undefined;
|
|
33
|
-
type CandidateToolCall = {
|
|
34
|
-
id: string;
|
|
35
|
-
function: {
|
|
36
|
-
name: string;
|
|
37
|
-
arguments: string;
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
export declare function buildPrematureCompletionArtifactBlock(input: {
|
|
41
|
-
inputMessages: readonly ChatMessage[];
|
|
42
|
-
messages: unknown[];
|
|
43
|
-
toolCall: CandidateToolCall;
|
|
44
|
-
}): string | undefined;
|
|
45
|
-
export declare function findForbiddenCreatedFiles(inputMessages: readonly ChatMessage[], messages: unknown[]): string[];
|
|
46
|
-
export declare function findSelfCreatedReadTargets(inputMessages: readonly ChatMessage[], messages: unknown[]): string[];
|
|
47
|
-
export declare function resolveCompletionActionPolicy(input: CompletionActionPolicyInput): CompletionActionPolicyDecision | null;
|
|
48
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { AgentLogger, HookRegistry, ThinkingBlock, ToolLoopTransition } from "../types.js";
|
|
2
|
-
export type CompletionStopPolicyDecision = {
|
|
3
|
-
action: "end";
|
|
4
|
-
content: string;
|
|
5
|
-
} | {
|
|
6
|
-
action: "continue";
|
|
7
|
-
messages: unknown[];
|
|
8
|
-
stopHookActive: true;
|
|
9
|
-
transition: ToolLoopTransition;
|
|
10
|
-
};
|
|
11
|
-
export interface CompletionStopPolicyInput {
|
|
12
|
-
hooks: HookRegistry | undefined;
|
|
13
|
-
sessionId: string;
|
|
14
|
-
messages: unknown[];
|
|
15
|
-
finalText: string;
|
|
16
|
-
thinkingBlocks: readonly ThinkingBlock[];
|
|
17
|
-
log: Pick<AgentLogger, "info">;
|
|
18
|
-
}
|
|
19
|
-
export declare function resolveCompletionStopPolicy(input: CompletionStopPolicyInput): Promise<CompletionStopPolicyDecision | null>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/** True when a no-tool answer leaked provider tool-protocol syntax as visible prose. */
|
|
2
|
-
export declare function containsToolProtocolMarkup(text: string): boolean;
|
|
3
|
-
export interface DirectResponseProtocolStreamFilter {
|
|
4
|
-
push(chunk: string): string;
|
|
5
|
-
flush(): string;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Hold only the ambiguous beginning of a direct response. Provider protocol leaks start with
|
|
9
|
-
* an opening marker; keeping that short prefix out of the UI prevents a transient tool-call
|
|
10
|
-
* trace while preserving normal token streaming as soon as the prefix is proven ordinary text.
|
|
11
|
-
*/
|
|
12
|
-
export declare function createDirectResponseProtocolStreamFilter(): DirectResponseProtocolStreamFilter;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 流式输出中的 final-status 围栏抑制。
|
|
3
|
-
*
|
|
4
|
-
* 为什么必须在**解析层**抑制而不是"先显示再回滚":final-status 是引擎内部协议块
|
|
5
|
-
* (```final-status + JSON),`reconcileFinalStatus` 会在回合末重写它。若照原样流给用户,
|
|
6
|
-
* 用户会看着一段裸 JSON 被逐字打出来,然后被终局文本替换。产品决定是内部协议文本
|
|
7
|
-
* **任何时候都不允许短暂展示**,所以它必须在进入 delta 流之前就被拦掉,回滚机制不适用于它。
|
|
8
|
-
*
|
|
9
|
-
* 关键约束:标记可能跨 chunk 边界到达("```final-" + "status\n"),因此不能逐 chunk 独立判断。
|
|
10
|
-
* 未确定安全之前必须扣住可能构成标记前缀的尾巴。
|
|
11
|
-
*
|
|
12
|
-
* 本模块只过滤**发给消费端的流**;完整原文仍照常进入 roundText/finalText,终局内容不受影响。
|
|
13
|
-
*/
|
|
14
|
-
export interface FinalStatusStreamSuppressor {
|
|
15
|
-
/** 吃进一段原文,返回此刻可安全外发的文本(可能为空)。 */
|
|
16
|
-
push(chunk: string): string;
|
|
17
|
-
/** 流结束:返回残留的安全文本。仍处于未闭合的抑制区时返回空串。 */
|
|
18
|
-
flush(): string;
|
|
19
|
-
/** 是否正处于 final-status 块内部(诊断用)。 */
|
|
20
|
-
isSuppressing(): boolean;
|
|
21
|
-
}
|
|
22
|
-
export declare function createFinalStatusStreamSuppressor(): FinalStatusStreamSuppressor;
|