@namzu/sdk 41.0.0 → 42.0.1
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 +233 -0
- package/dist/agents/ReactiveAgent.d.ts.map +1 -1
- package/dist/agents/ReactiveAgent.js +3 -0
- package/dist/agents/ReactiveAgent.js.map +1 -1
- package/dist/agents/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/SupervisorAgent.js +11 -0
- package/dist/agents/SupervisorAgent.js.map +1 -1
- package/dist/agents/runAgent.d.ts +14 -0
- package/dist/agents/runAgent.d.ts.map +1 -1
- package/dist/agents/runAgent.js +3 -0
- package/dist/agents/runAgent.js.map +1 -1
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +20 -0
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/manager/resident/outbox.d.ts +8 -8
- package/dist/manager/resident/store.d.ts +4 -4
- package/dist/public-runtime.d.ts +4 -1
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +13 -1
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +1 -1
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +4 -2
- package/dist/public-tools.js.map +1 -1
- package/dist/registry/tool/execute.d.ts.map +1 -1
- package/dist/registry/tool/execute.js +10 -1
- package/dist/registry/tool/execute.js.map +1 -1
- package/dist/runtime/bidi/session.d.ts +11 -0
- package/dist/runtime/bidi/session.d.ts.map +1 -1
- package/dist/runtime/bidi/session.js +2 -0
- package/dist/runtime/bidi/session.js.map +1 -1
- package/dist/runtime/query/cancelled-before-start.d.ts +34 -0
- package/dist/runtime/query/cancelled-before-start.d.ts.map +1 -0
- package/dist/runtime/query/cancelled-before-start.js +152 -0
- package/dist/runtime/query/cancelled-before-start.js.map +1 -0
- package/dist/runtime/query/checkpoint.d.ts +21 -0
- package/dist/runtime/query/checkpoint.d.ts.map +1 -1
- package/dist/runtime/query/checkpoint.js +23 -0
- package/dist/runtime/query/checkpoint.js.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.d.ts +57 -0
- package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -0
- package/dist/runtime/query/executor/tool-call-admission.js +373 -0
- package/dist/runtime/query/executor/tool-call-admission.js.map +1 -0
- package/dist/runtime/query/executor.d.ts +76 -35
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +52 -380
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/finalize-run.d.ts +55 -0
- package/dist/runtime/query/finalize-run.d.ts.map +1 -0
- package/dist/runtime/query/finalize-run.js +113 -0
- package/dist/runtime/query/finalize-run.js.map +1 -0
- package/dist/runtime/query/guardrail-presets.d.ts +187 -1
- package/dist/runtime/query/guardrail-presets.d.ts.map +1 -1
- package/dist/runtime/query/guardrail-presets.js +298 -0
- package/dist/runtime/query/guardrail-presets.js.map +1 -1
- package/dist/runtime/query/index.d.ts +18 -9
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +241 -893
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts +6 -161
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +23 -523
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/outstanding-work.d.ts +158 -0
- package/dist/runtime/query/iteration/outstanding-work.d.ts.map +1 -0
- package/dist/runtime/query/iteration/outstanding-work.js +365 -0
- package/dist/runtime/query/iteration/outstanding-work.js.map +1 -0
- package/dist/runtime/query/iteration/phases/plan.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/plan.js +13 -2
- package/dist/runtime/query/iteration/phases/plan.js.map +1 -1
- package/dist/runtime/query/iteration/step-shaping.d.ts +41 -0
- package/dist/runtime/query/iteration/step-shaping.d.ts.map +1 -0
- package/dist/runtime/query/iteration/step-shaping.js +184 -0
- package/dist/runtime/query/iteration/step-shaping.js.map +1 -0
- package/dist/runtime/query/prepare-run.d.ts +94 -0
- package/dist/runtime/query/prepare-run.d.ts.map +1 -0
- package/dist/runtime/query/prepare-run.js +589 -0
- package/dist/runtime/query/prepare-run.js.map +1 -0
- package/dist/runtime/query/release-run.d.ts +56 -0
- package/dist/runtime/query/release-run.d.ts.map +1 -0
- package/dist/runtime/query/release-run.js +101 -0
- package/dist/runtime/query/release-run.js.map +1 -0
- package/dist/runtime/query/resume-pending.d.ts +112 -1
- package/dist/runtime/query/resume-pending.d.ts.map +1 -1
- package/dist/runtime/query/resume-pending.js +133 -0
- package/dist/runtime/query/resume-pending.js.map +1 -1
- package/dist/runtime/query/tooling.d.ts +2 -0
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js +3 -0
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/store/evidence/compaction-archive.d.ts +2 -2
- package/dist/tools/coordinator/agent.d.ts.map +1 -1
- package/dist/tools/coordinator/agent.js +17 -2
- package/dist/tools/coordinator/agent.js.map +1 -1
- package/dist/tools/coordinator/index.d.ts.map +1 -1
- package/dist/tools/coordinator/index.js +17 -3
- package/dist/tools/coordinator/index.js.map +1 -1
- package/dist/tools/untrusted-envelope.d.ts +35 -0
- package/dist/tools/untrusted-envelope.d.ts.map +1 -1
- package/dist/tools/untrusted-envelope.js +91 -3
- package/dist/tools/untrusted-envelope.js.map +1 -1
- package/dist/types/agent/base.d.ts +23 -0
- package/dist/types/agent/base.d.ts.map +1 -1
- package/dist/types/agent/task.d.ts +19 -0
- package/dist/types/agent/task.d.ts.map +1 -1
- package/dist/types/run/config.d.ts +12 -5
- package/dist/types/run/config.d.ts.map +1 -1
- package/dist/types/tool/index.d.ts +19 -0
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/package.json +1 -1
- package/src/agents/ReactiveAgent.ts +3 -0
- package/src/agents/SupervisorAgent.ts +11 -0
- package/src/agents/runAgent.ts +18 -0
- package/src/manager/agent/lifecycle.ts +22 -0
- package/src/public-runtime.ts +14 -0
- package/src/public-tools.ts +8 -2
- package/src/registry/tool/execute.ts +9 -1
- package/src/runtime/bidi/session.ts +13 -0
- package/src/runtime/query/cancelled-before-start.ts +189 -0
- package/src/runtime/query/checkpoint.ts +22 -0
- package/src/runtime/query/executor/tool-call-admission.ts +473 -0
- package/src/runtime/query/executor.ts +76 -442
- package/src/runtime/query/finalize-run.ts +192 -0
- package/src/runtime/query/guardrail-presets.ts +356 -0
- package/src/runtime/query/index.ts +287 -1011
- package/src/runtime/query/iteration/index.ts +40 -586
- package/src/runtime/query/iteration/outstanding-work.ts +386 -0
- package/src/runtime/query/iteration/phases/plan.ts +18 -2
- package/src/runtime/query/iteration/step-shaping.ts +271 -0
- package/src/runtime/query/prepare-run.ts +718 -0
- package/src/runtime/query/release-run.ts +168 -0
- package/src/runtime/query/resume-pending.ts +158 -0
- package/src/runtime/query/tooling.ts +5 -0
- package/src/tools/coordinator/agent.ts +17 -2
- package/src/tools/coordinator/index.ts +17 -3
- package/src/tools/untrusted-envelope.ts +94 -3
- package/src/types/agent/base.ts +24 -0
- package/src/types/agent/task.ts +20 -0
- package/src/types/run/config.ts +12 -5
- package/src/types/tool/index.ts +20 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ToolCall } from '../../../types/message/index.js';
|
|
2
|
+
import type { ToolCallRepair } from '../../../types/tool/repair.js';
|
|
3
|
+
import type { Logger } from '../../../utils/logger.js';
|
|
4
|
+
import type { EmitEvent, PreToolHookOutcome, PreparedDirectCall, ToolExecutorConfig } from '../executor.js';
|
|
5
|
+
/**
|
|
6
|
+
* One provider tool call, from raw to admitted.
|
|
7
|
+
*
|
|
8
|
+
* The executor's job is to run tools; this is the gate every call passes
|
|
9
|
+
* before one runs. A call arrives as the model streamed it — possibly not
|
|
10
|
+
* valid JSON, possibly cut off mid-argument, possibly naming a tool that does
|
|
11
|
+
* not exist — and leaves as a prepared, plugin-approved, authorized call, or
|
|
12
|
+
* as a synthetic failure that answers the model with what was wrong. Nothing
|
|
13
|
+
* here dispatches a tool, and nothing here writes a result: that is the
|
|
14
|
+
* executor's half.
|
|
15
|
+
*
|
|
16
|
+
* The family reads exactly three things off the executor it serves, and they
|
|
17
|
+
* arrive as one value rather than as a captured reference: the tool registry
|
|
18
|
+
* config, the event sink and the logger. `config` in particular is read
|
|
19
|
+
* per call and never held — `ToolExecutor.setSandbox` REPLACES it, so a host
|
|
20
|
+
* captured once would hand the next admission a stale sandbox.
|
|
21
|
+
*/
|
|
22
|
+
export interface ToolAdmissionHost {
|
|
23
|
+
readonly config: ToolExecutorConfig;
|
|
24
|
+
readonly emitEvent: EmitEvent;
|
|
25
|
+
readonly log: Logger;
|
|
26
|
+
}
|
|
27
|
+
export declare function runPreToolHook(host: ToolAdmissionHost, toolName: string, input: unknown, signal?: AbortSignal): Promise<PreToolHookOutcome>;
|
|
28
|
+
export declare function prepareDirectCall(host: ToolAdmissionHost, toolCall: ToolCall): Promise<PreparedDirectCall>;
|
|
29
|
+
/**
|
|
30
|
+
* Turn the call the model issued into a name and a parsed input, giving
|
|
31
|
+
* a configured repairer one chance to fix it first.
|
|
32
|
+
*
|
|
33
|
+
* Exactly one chance: a repairer that produces a call which is still
|
|
34
|
+
* broken will not do better on a second look, and an unbounded loop
|
|
35
|
+
* here is a hang rather than a degradation.
|
|
36
|
+
*
|
|
37
|
+
* `invalid_json` is the ONLY failure that stops the call here, and it
|
|
38
|
+
* stopped it before this function existed too. `unknown_tool` and
|
|
39
|
+
* `schema_validation` merely OFFER the repair and otherwise fall
|
|
40
|
+
* through to the registry, which reports both with better messages —
|
|
41
|
+
* its schema error already ships a "Required: <field>: <type>" hint the
|
|
42
|
+
* model can self-correct from. So with no repairer configured this is
|
|
43
|
+
* behaviorally identical to the bare `JSON.parse` it replaced.
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolveCall(host: ToolAdmissionHost, toolCall: ToolCall): Promise<{
|
|
46
|
+
ok: true;
|
|
47
|
+
toolName: string;
|
|
48
|
+
input: unknown;
|
|
49
|
+
} | {
|
|
50
|
+
ok: false;
|
|
51
|
+
toolName: string;
|
|
52
|
+
message: string;
|
|
53
|
+
}>;
|
|
54
|
+
export declare function repairTruncatedCall(host: ToolAdmissionHost, toolCall: ToolCall, toolName: string): Promise<ToolCallRepair | null>;
|
|
55
|
+
export declare function formatFailedToolOutput(output: string | undefined, error: string | undefined): string;
|
|
56
|
+
export declare function truncatedToolInputMessage(toolName: string): string;
|
|
57
|
+
//# sourceMappingURL=tool-call-admission.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-call-admission.d.ts","sourceRoot":"","sources":["../../../../src/runtime/query/executor/tool-call-admission.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAE/D,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,+BAA+B,CAAA;AAEzF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,KAAK,EACX,SAAS,EACT,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,MAAM,gBAAgB,CAAA;AAGvB;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAA;IACnC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CACpB;AAED,wBAAsB,cAAc,CACnC,IAAI,EAAE,iBAAiB,EACvB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO,EACd,MAAM,GAAE,WAAqC,GAC3C,OAAO,CAAC,kBAAkB,CAAC,CAa7B;AAED,wBAAsB,iBAAiB,CACtC,IAAI,EAAE,iBAAiB,EACvB,QAAQ,EAAE,QAAQ,GAChB,OAAO,CAAC,kBAAkB,CAAC,CAmL7B;AAgDD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,WAAW,CAChC,IAAI,EAAE,iBAAiB,EACvB,QAAQ,EAAE,QAAQ,GAChB,OAAO,CACT;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CACjG,CA+BA;AAED,wBAAsB,mBAAmB,CACxC,IAAI,EAAE,iBAAiB,EACvB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAoBhC;AA+FD,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,KAAK,EAAE,MAAM,GAAG,SAAS,GACvB,MAAM,CAIR;AAED,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElE"}
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import { GENAI, NAMZU } from '../../../constants/telemetry/index.js';
|
|
2
|
+
import { renderToolSchema } from '../../../registry/tool/schema.js';
|
|
3
|
+
import { toErrorMessage } from '../../../utils/error.js';
|
|
4
|
+
import { skippedToolResultText } from '../plugin-hooks.js';
|
|
5
|
+
export async function runPreToolHook(host, toolName, input, signal = host.config.abortSignal) {
|
|
6
|
+
if (!host.config.pluginManager)
|
|
7
|
+
return { kind: 'continue', input, modified: false };
|
|
8
|
+
const results = await host.config.pluginManager.executeHooks('pre_tool_use', {
|
|
9
|
+
runId: host.config.runId,
|
|
10
|
+
toolName,
|
|
11
|
+
toolInput: input,
|
|
12
|
+
signal,
|
|
13
|
+
}, host.emitEvent);
|
|
14
|
+
return interpretPreToolResults(toolName, input, results);
|
|
15
|
+
}
|
|
16
|
+
export async function prepareDirectCall(host, toolCall) {
|
|
17
|
+
let toolName = toolCall.function.name;
|
|
18
|
+
const truncationRepair = toolCall.metadata?.inputTruncated === true
|
|
19
|
+
? await repairTruncatedCall(host, toolCall, toolName)
|
|
20
|
+
: null;
|
|
21
|
+
if (toolCall.metadata?.inputTruncated === true && !truncationRepair) {
|
|
22
|
+
return {
|
|
23
|
+
kind: 'synthetic',
|
|
24
|
+
toolCall,
|
|
25
|
+
toolName,
|
|
26
|
+
input: {},
|
|
27
|
+
message: truncatedToolInputMessage(toolName),
|
|
28
|
+
isError: true,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const prepare = host.config.tools.prepareExecution;
|
|
32
|
+
const executePrepared = host.config.tools.executePrepared;
|
|
33
|
+
if (typeof prepare !== 'function' || typeof executePrepared !== 'function') {
|
|
34
|
+
const resolved = await resolveCall(host, truncationRepair
|
|
35
|
+
? {
|
|
36
|
+
...toolCall,
|
|
37
|
+
function: {
|
|
38
|
+
...toolCall.function,
|
|
39
|
+
name: truncationRepair.toolName ?? toolName,
|
|
40
|
+
arguments: truncationRepair.arguments,
|
|
41
|
+
},
|
|
42
|
+
metadata: {},
|
|
43
|
+
}
|
|
44
|
+
: toolCall);
|
|
45
|
+
toolName = resolved.toolName;
|
|
46
|
+
if (!resolved.ok) {
|
|
47
|
+
return {
|
|
48
|
+
kind: 'synthetic',
|
|
49
|
+
toolCall,
|
|
50
|
+
toolName,
|
|
51
|
+
input: {},
|
|
52
|
+
message: resolved.message,
|
|
53
|
+
isError: true,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const preOutcome = await runPreToolHook(host, toolName, resolved.input);
|
|
57
|
+
if (preOutcome.kind === 'skip' || preOutcome.kind === 'error') {
|
|
58
|
+
return {
|
|
59
|
+
kind: 'synthetic',
|
|
60
|
+
toolCall,
|
|
61
|
+
toolName,
|
|
62
|
+
input: preOutcome.input,
|
|
63
|
+
message: preOutcome.output,
|
|
64
|
+
isError: preOutcome.kind === 'error',
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (!host.config.authorizationGate) {
|
|
68
|
+
return {
|
|
69
|
+
kind: 'legacy',
|
|
70
|
+
toolCall,
|
|
71
|
+
toolName,
|
|
72
|
+
input: preOutcome.input,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
kind: 'synthetic',
|
|
77
|
+
toolCall,
|
|
78
|
+
toolName,
|
|
79
|
+
input: preOutcome.input,
|
|
80
|
+
message: `Tool "${toolName}" was not executed because its registry cannot bind authorization to one prepared input.`,
|
|
81
|
+
isError: true,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
let raw = truncationRepair?.arguments ?? toolCall.function.arguments;
|
|
85
|
+
toolName = truncationRepair?.toolName ?? toolName;
|
|
86
|
+
let repairUsed = truncationRepair !== null;
|
|
87
|
+
let preparation;
|
|
88
|
+
for (;;) {
|
|
89
|
+
let parsed;
|
|
90
|
+
try {
|
|
91
|
+
parsed = parseArguments(raw);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
const message = `Error: Invalid JSON in tool arguments for "${toolName}"`;
|
|
95
|
+
const repair = !repairUsed && host.config.repairToolCall
|
|
96
|
+
? await requestRepair(host, toolCall, toolName, {
|
|
97
|
+
reason: 'invalid_json',
|
|
98
|
+
message,
|
|
99
|
+
})
|
|
100
|
+
: null;
|
|
101
|
+
if (repair) {
|
|
102
|
+
repairUsed = true;
|
|
103
|
+
toolName = repair.toolName ?? toolName;
|
|
104
|
+
raw = repair.arguments;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
return { kind: 'synthetic', toolCall, toolName, input: {}, message, isError: true };
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
preparation = prepare.call(host.config.tools, toolName, parsed);
|
|
111
|
+
}
|
|
112
|
+
catch (err) {
|
|
113
|
+
const message = `Error: Unknown or unavailable tool "${toolName}": ${toErrorMessage(err)}`;
|
|
114
|
+
const repair = !repairUsed && host.config.repairToolCall
|
|
115
|
+
? await requestRepair(host, toolCall, toolName, {
|
|
116
|
+
reason: 'unknown_tool',
|
|
117
|
+
message,
|
|
118
|
+
})
|
|
119
|
+
: null;
|
|
120
|
+
if (repair) {
|
|
121
|
+
repairUsed = true;
|
|
122
|
+
toolName = repair.toolName ?? toolName;
|
|
123
|
+
raw = repair.arguments;
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
return { kind: 'synthetic', toolCall, toolName, input: parsed, message, isError: true };
|
|
127
|
+
}
|
|
128
|
+
if (preparation.success)
|
|
129
|
+
break;
|
|
130
|
+
const message = formatFailedToolOutput(preparation.result.output, preparation.result.error);
|
|
131
|
+
const repair = !repairUsed && host.config.repairToolCall
|
|
132
|
+
? await requestRepair(host, toolCall, toolName, {
|
|
133
|
+
reason: 'schema_validation',
|
|
134
|
+
message,
|
|
135
|
+
})
|
|
136
|
+
: null;
|
|
137
|
+
if (repair) {
|
|
138
|
+
repairUsed = true;
|
|
139
|
+
toolName = repair.toolName ?? toolName;
|
|
140
|
+
raw = repair.arguments;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
kind: 'synthetic',
|
|
145
|
+
toolCall,
|
|
146
|
+
toolName,
|
|
147
|
+
input: parsed,
|
|
148
|
+
message,
|
|
149
|
+
isError: true,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
const preOutcome = await runPreToolHook(host, toolName, preparation.prepared.input);
|
|
153
|
+
if (preOutcome.kind === 'skip' || preOutcome.kind === 'error') {
|
|
154
|
+
return {
|
|
155
|
+
kind: 'synthetic',
|
|
156
|
+
toolCall,
|
|
157
|
+
toolName,
|
|
158
|
+
input: preOutcome.input,
|
|
159
|
+
message: preOutcome.output,
|
|
160
|
+
isError: preOutcome.kind === 'error',
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
if (preOutcome.modified) {
|
|
164
|
+
const modified = prepare.call(host.config.tools, toolName, preOutcome.input);
|
|
165
|
+
if (!modified.success) {
|
|
166
|
+
return {
|
|
167
|
+
kind: 'synthetic',
|
|
168
|
+
toolCall,
|
|
169
|
+
toolName,
|
|
170
|
+
input: preOutcome.input,
|
|
171
|
+
message: formatFailedToolOutput(modified.result.output, modified.result.error),
|
|
172
|
+
isError: true,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
preparation = modified;
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
kind: 'ready',
|
|
179
|
+
toolCall,
|
|
180
|
+
toolName,
|
|
181
|
+
input: preparation.prepared.input,
|
|
182
|
+
prepared: preparation.prepared,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function interpretPreToolResults(toolName, initialInput, results) {
|
|
186
|
+
let currentInput = initialInput;
|
|
187
|
+
let modified = false;
|
|
188
|
+
for (const result of results) {
|
|
189
|
+
switch (result.action) {
|
|
190
|
+
case 'continue':
|
|
191
|
+
continue;
|
|
192
|
+
case 'modify':
|
|
193
|
+
currentInput = result.input;
|
|
194
|
+
modified = true;
|
|
195
|
+
continue;
|
|
196
|
+
case 'skip':
|
|
197
|
+
return {
|
|
198
|
+
kind: 'skip',
|
|
199
|
+
input: currentInput,
|
|
200
|
+
output: skippedToolResultText(toolName, result.reason),
|
|
201
|
+
};
|
|
202
|
+
case 'error':
|
|
203
|
+
return {
|
|
204
|
+
kind: 'error',
|
|
205
|
+
input: currentInput,
|
|
206
|
+
output: `Error: ${result.message}`,
|
|
207
|
+
};
|
|
208
|
+
case 'retry':
|
|
209
|
+
case 'annotate':
|
|
210
|
+
// There is no result to replace yet. Rejecting loudly beats
|
|
211
|
+
// silently ignoring it: a hook author who returned this here
|
|
212
|
+
// meant to redact something and would otherwise watch the secret
|
|
213
|
+
// go through.
|
|
214
|
+
case 'replace':
|
|
215
|
+
throw new Error(`Plugin hook pre_tool_use returned unsupported action '${result.action}' for tool ${toolName}`);
|
|
216
|
+
default: {
|
|
217
|
+
const _exhaustive = result;
|
|
218
|
+
throw new Error(`Unknown PluginHookResult: ${JSON.stringify(_exhaustive)}`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return { kind: 'continue', input: currentInput, modified };
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Turn the call the model issued into a name and a parsed input, giving
|
|
226
|
+
* a configured repairer one chance to fix it first.
|
|
227
|
+
*
|
|
228
|
+
* Exactly one chance: a repairer that produces a call which is still
|
|
229
|
+
* broken will not do better on a second look, and an unbounded loop
|
|
230
|
+
* here is a hang rather than a degradation.
|
|
231
|
+
*
|
|
232
|
+
* `invalid_json` is the ONLY failure that stops the call here, and it
|
|
233
|
+
* stopped it before this function existed too. `unknown_tool` and
|
|
234
|
+
* `schema_validation` merely OFFER the repair and otherwise fall
|
|
235
|
+
* through to the registry, which reports both with better messages —
|
|
236
|
+
* its schema error already ships a "Required: <field>: <type>" hint the
|
|
237
|
+
* model can self-correct from. So with no repairer configured this is
|
|
238
|
+
* behaviorally identical to the bare `JSON.parse` it replaced.
|
|
239
|
+
*/
|
|
240
|
+
export async function resolveCall(host, toolCall) {
|
|
241
|
+
let toolName = toolCall.function.name;
|
|
242
|
+
let raw = toolCall.function.arguments;
|
|
243
|
+
for (let attempt = 0;; attempt++) {
|
|
244
|
+
const failure = inspectCall(host, toolName, raw);
|
|
245
|
+
if (!failure)
|
|
246
|
+
return { ok: true, toolName, input: parseArguments(raw) };
|
|
247
|
+
const repair = attempt === 0 && host.config.repairToolCall
|
|
248
|
+
? await requestRepair(host, toolCall, toolName, failure)
|
|
249
|
+
: null;
|
|
250
|
+
if (!repair) {
|
|
251
|
+
if (failure.reason === 'invalid_json') {
|
|
252
|
+
return { ok: false, toolName, message: failure.message };
|
|
253
|
+
}
|
|
254
|
+
return { ok: true, toolName, input: parseArguments(raw) };
|
|
255
|
+
}
|
|
256
|
+
host.log.info('Repaired a malformed tool call', {
|
|
257
|
+
[NAMZU.RUN_ID]: host.config.runId,
|
|
258
|
+
[GENAI.TOOL_NAME]: toolName,
|
|
259
|
+
'namzu.runtime.reason': failure.reason,
|
|
260
|
+
...(repair.toolName && repair.toolName !== toolName
|
|
261
|
+
? { 'namzu.runtime.repaired_to': repair.toolName }
|
|
262
|
+
: {}),
|
|
263
|
+
});
|
|
264
|
+
toolName = repair.toolName ?? toolName;
|
|
265
|
+
raw = repair.arguments;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
export async function repairTruncatedCall(host, toolCall, toolName) {
|
|
269
|
+
if (!host.config.repairToolCall)
|
|
270
|
+
return null;
|
|
271
|
+
// Present the PARTIAL buffer, not the normalized `"{}"` — a repairer
|
|
272
|
+
// handed an empty object has nothing to work from.
|
|
273
|
+
const partial = toolCall.metadata?.partialArguments ?? '';
|
|
274
|
+
const repair = await requestRepair(host, { ...toolCall, function: { ...toolCall.function, arguments: partial } }, toolName, { reason: 'invalid_json', message: truncatedToolInputMessage(toolName) });
|
|
275
|
+
if (repair) {
|
|
276
|
+
host.log.info('Repaired a tool call whose input stream was truncated', {
|
|
277
|
+
[NAMZU.RUN_ID]: host.config.runId,
|
|
278
|
+
[GENAI.TOOL_NAME]: toolName,
|
|
279
|
+
'namzu.runtime.partial_length': partial.length,
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
return repair;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* What is wrong with this call, or `null` if nothing is.
|
|
286
|
+
*
|
|
287
|
+
* JSON is checked before the tool is looked up: an unparseable argument
|
|
288
|
+
* string is broken regardless of which tool it was aimed at, and it is
|
|
289
|
+
* the one problem the executor itself has to answer.
|
|
290
|
+
*/
|
|
291
|
+
function inspectCall(host, toolName, raw) {
|
|
292
|
+
let parsed;
|
|
293
|
+
try {
|
|
294
|
+
parsed = parseArguments(raw);
|
|
295
|
+
}
|
|
296
|
+
catch {
|
|
297
|
+
return {
|
|
298
|
+
reason: 'invalid_json',
|
|
299
|
+
message: `Error: Invalid JSON in tool arguments for "${toolName}"`,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
const tool = host.config.tools.get?.(toolName);
|
|
303
|
+
if (!tool) {
|
|
304
|
+
// Either the model named a tool that does not exist, or this
|
|
305
|
+
// registry does not implement `get`. Both are the registry's to
|
|
306
|
+
// answer; a repairer still gets offered the `unknown_tool` case.
|
|
307
|
+
return {
|
|
308
|
+
reason: 'unknown_tool',
|
|
309
|
+
message: `Error: Unknown tool "${toolName}"`,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
// A registry that hands back a tool with no schema has nothing to
|
|
313
|
+
// validate against; that is not a repairable condition, just an
|
|
314
|
+
// unvalidatable one.
|
|
315
|
+
const validation = tool.inputSchema?.safeParse(parsed);
|
|
316
|
+
if (validation && !validation.success) {
|
|
317
|
+
return {
|
|
318
|
+
reason: 'schema_validation',
|
|
319
|
+
message: `Error: Invalid arguments for "${toolName}": ${validation.error.issues
|
|
320
|
+
.map((issue) => `${issue.path.join('.') || '(root)'}: ${issue.message}`)
|
|
321
|
+
.join('; ')}`,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
async function requestRepair(host, toolCall, toolName, failure) {
|
|
327
|
+
const repairToolCall = host.config.repairToolCall;
|
|
328
|
+
if (!repairToolCall)
|
|
329
|
+
return null;
|
|
330
|
+
const tool = host.config.tools.get(toolName);
|
|
331
|
+
try {
|
|
332
|
+
return await repairToolCall({
|
|
333
|
+
toolCall,
|
|
334
|
+
reason: failure.reason,
|
|
335
|
+
message: failure.message,
|
|
336
|
+
...(tool
|
|
337
|
+
? {
|
|
338
|
+
tool,
|
|
339
|
+
jsonSchema: tool.modelInputSchema ?? renderToolSchema(tool.inputSchema),
|
|
340
|
+
}
|
|
341
|
+
: {}),
|
|
342
|
+
availableTools: host.config.tools.listNames(),
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
catch (err) {
|
|
346
|
+
// A broken repairer must not turn a recoverable tool error into a
|
|
347
|
+
// failed run: the original error is still a perfectly good answer
|
|
348
|
+
// to give the model.
|
|
349
|
+
host.log.error('repairToolCall threw — falling back to the original error', {
|
|
350
|
+
[NAMZU.RUN_ID]: host.config.runId,
|
|
351
|
+
[GENAI.TOOL_NAME]: toolName,
|
|
352
|
+
'exception.message': toErrorMessage(err),
|
|
353
|
+
});
|
|
354
|
+
return null;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* An empty arguments string means "no arguments", not "malformed" — the
|
|
359
|
+
* shape a no-parameter tool arrives in.
|
|
360
|
+
*/
|
|
361
|
+
function parseArguments(raw) {
|
|
362
|
+
return JSON.parse(raw || '{}');
|
|
363
|
+
}
|
|
364
|
+
export function formatFailedToolOutput(output, error) {
|
|
365
|
+
const errorText = `Error: ${error ?? 'Tool execution failed'}`;
|
|
366
|
+
if (!output || output.trim().length === 0)
|
|
367
|
+
return errorText;
|
|
368
|
+
return `${output}\n\n${errorText}`;
|
|
369
|
+
}
|
|
370
|
+
export function truncatedToolInputMessage(toolName) {
|
|
371
|
+
return `Error: Tool "${toolName}" call was cut off while the model was streaming JSON arguments. The tool was NOT executed. Retry with a much shorter input. Self-budget content/new_string under 12000 characters before calling file tools. For long files, create a short opening with write and a deterministic marker, then advance that marker with bounded exact edit calls; for delegated work, pass a shared workspace filename/reference instead of embedding the content in the tool call.`;
|
|
372
|
+
}
|
|
373
|
+
//# sourceMappingURL=tool-call-admission.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-call-admission.js","sourceRoot":"","sources":["../../../../src/runtime/query/executor/tool-call-admission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,uCAAuC,CAAA;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AAInE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAQxD,OAAO,EAAE,qBAAqB,EAAE,MAAM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S,CAAA;IAC3D,OAAO,GAAG,MAAM,OAAO,SAAS,EAAE,CAAA;AACnC,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,QAAgB;IACzD,OAAO,gBAAgB,QAAQ,ucAAuc,CAAA;AACve,CAAC"}
|
|
@@ -4,21 +4,41 @@ import type { WorkingStateManager } from '../../compaction/manager.js';
|
|
|
4
4
|
import type { PluginLifecycleManager } from '../../plugin/lifecycle.js';
|
|
5
5
|
import type { ProbeEnforcement } from '../../probe/registry.js';
|
|
6
6
|
import type { ActivityStore } from '../../store/activity/memory.js';
|
|
7
|
+
import type { ToolResultGuardrailSpec } from '../../types/guardrail/index.js';
|
|
7
8
|
import type { RunId } from '../../types/ids/index.js';
|
|
8
9
|
import type { InvocationState } from '../../types/invocation/index.js';
|
|
9
|
-
import { type Message, type ToolResultContent } from '../../types/message/index.js';
|
|
10
|
+
import { type Message, type ToolCall, type ToolResultContent } from '../../types/message/index.js';
|
|
10
11
|
import type { PermissionMode } from '../../types/permission/index.js';
|
|
11
12
|
import type { ChatCompletionResponse } from '../../types/provider/index.js';
|
|
12
13
|
import type { AuditEventInput } from '../../types/run/audit.js';
|
|
13
14
|
import type { RunEvent } from '../../types/run/index.js';
|
|
14
15
|
import type { Sandbox } from '../../types/sandbox/index.js';
|
|
15
|
-
import type { FileReadTracker, RequestToolPause, SkillRegistryRef, ToolContext, ToolRegistryContract } from '../../types/tool/index.js';
|
|
16
|
+
import type { FileReadTracker, PreparedToolExecution, RequestToolPause, SkillRegistryRef, ToolContext, ToolRegistryContract } from '../../types/tool/index.js';
|
|
16
17
|
import type { RepairToolCall } from '../../types/tool/repair.js';
|
|
17
18
|
import { type BackoffPolicy } from '../../utils/backoff.js';
|
|
18
19
|
import type { Logger } from '../../utils/logger.js';
|
|
19
20
|
import { type BackgroundJobRegistry } from '../jobs/registry.js';
|
|
20
21
|
import type { ToolResultObservation } from './project-instructions.js';
|
|
21
22
|
export type EmitEvent = (event: RunEvent) => Promise<void>;
|
|
23
|
+
export type PreparedDirectCall = {
|
|
24
|
+
readonly kind: 'ready';
|
|
25
|
+
readonly toolCall: ToolCall;
|
|
26
|
+
readonly toolName: string;
|
|
27
|
+
readonly input: unknown;
|
|
28
|
+
readonly prepared: PreparedToolExecution;
|
|
29
|
+
} | {
|
|
30
|
+
readonly kind: 'legacy';
|
|
31
|
+
readonly toolCall: ToolCall;
|
|
32
|
+
readonly toolName: string;
|
|
33
|
+
readonly input: unknown;
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: 'synthetic';
|
|
36
|
+
readonly toolCall: ToolCall;
|
|
37
|
+
readonly toolName: string;
|
|
38
|
+
readonly input: unknown;
|
|
39
|
+
readonly message: string;
|
|
40
|
+
readonly isError: boolean;
|
|
41
|
+
};
|
|
22
42
|
/**
|
|
23
43
|
* Executor-owned, single-use preparation of one provider tool-call batch.
|
|
24
44
|
*
|
|
@@ -178,6 +198,11 @@ export interface ToolExecutorConfig {
|
|
|
178
198
|
maxToolOutputChars?: number;
|
|
179
199
|
/** See QueryParams.retainedToolPreviewChars; applies to the recorded host output. */
|
|
180
200
|
retainedToolPreviewChars?: number;
|
|
201
|
+
/**
|
|
202
|
+
* See QueryParams.toolResultGuardrails. Absent installs
|
|
203
|
+
* {@link DEFAULT_TOOL_RESULT_GUARDRAILS}; an empty array installs none.
|
|
204
|
+
*/
|
|
205
|
+
toolResultGuardrails?: readonly ToolResultGuardrailSpec[];
|
|
181
206
|
/**
|
|
182
207
|
* Cap on the RICH channel of a single tool result, in base64
|
|
183
208
|
* characters. `0` or absent disables it.
|
|
@@ -220,6 +245,19 @@ export interface ToolExecutorConfig {
|
|
|
220
245
|
/** Durable refusal sink paired with {@link authorizationGate}. */
|
|
221
246
|
recordAudit?: (input: AuditEventInput) => Promise<unknown>;
|
|
222
247
|
}
|
|
248
|
+
export type PreToolHookOutcome = {
|
|
249
|
+
kind: 'continue';
|
|
250
|
+
input: unknown;
|
|
251
|
+
modified: boolean;
|
|
252
|
+
} | {
|
|
253
|
+
kind: 'skip';
|
|
254
|
+
input: unknown;
|
|
255
|
+
output: string;
|
|
256
|
+
} | {
|
|
257
|
+
kind: 'error';
|
|
258
|
+
input: unknown;
|
|
259
|
+
output: string;
|
|
260
|
+
};
|
|
223
261
|
/** What one tool call produced, before it becomes a message. */
|
|
224
262
|
export interface ToolCallOutcome {
|
|
225
263
|
toolCallId: string;
|
|
@@ -328,10 +366,28 @@ export declare class ToolExecutor {
|
|
|
328
366
|
*
|
|
329
367
|
* `denials` marks ids that must NOT run: each is answered with a
|
|
330
368
|
* synthetic error result carrying the caller's reason instead of being
|
|
331
|
-
* executed.
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
369
|
+
* executed. A gate denial, a human rejection and a partial approval all
|
|
370
|
+
* leave the history valid, because there is exactly one place that turns
|
|
371
|
+
* a batch of tool calls into messages and it covers all of them.
|
|
372
|
+
*
|
|
373
|
+
* **That is a property of every path that RETURNS, not of the batch as
|
|
374
|
+
* a whole.** A per-call throw rejects the batch before the fill-the-holes
|
|
375
|
+
* loop below can run: `serial = serial.then(run)` means one rejection
|
|
376
|
+
* skips every LATER serial call, and `Promise.all([...parallel, serial])`
|
|
377
|
+
* then rejects — so this method produces no messages at all and the
|
|
378
|
+
* assistant turn keeps its `tool_use` blocks unanswered. A resume is what
|
|
379
|
+
* repairs that turn; see the `unfinished` step `iteration/index.ts`
|
|
380
|
+
* records for it.
|
|
381
|
+
*
|
|
382
|
+
* Reachable, not hypothetical, and demonstrated end to end by
|
|
383
|
+
* `a-throwing-batch-answers-nothing.test.ts`: `executeSingle` rethrows a
|
|
384
|
+
* retry's budget-admission error, and a `runPreToolHook` failure on a
|
|
385
|
+
* call whose preparation did not already run the hook.
|
|
386
|
+
*
|
|
387
|
+
* So do not read the guarantee below as covering a throw. The invariant
|
|
388
|
+
* holds for denials, for approvals, for a rejected batch and for a
|
|
389
|
+
* generation that partially failed while still returning: each of those
|
|
390
|
+
* leaves a hole that the fill-the-holes loop closes.
|
|
335
391
|
*
|
|
336
392
|
* Answering with `is_error` semantics rather than dropping the call is
|
|
337
393
|
* the universal contract across providers: an unanswered `tool_use`
|
|
@@ -448,37 +504,22 @@ export declare class ToolExecutor {
|
|
|
448
504
|
* it. A throw would end the run over one slow tool.
|
|
449
505
|
*/
|
|
450
506
|
private executeWithDeadline;
|
|
451
|
-
private runPreToolHook;
|
|
452
|
-
private prepareNestedCall;
|
|
453
|
-
private prepareDirectCall;
|
|
454
|
-
private interpretPreToolResults;
|
|
455
507
|
/**
|
|
456
|
-
*
|
|
457
|
-
*
|
|
458
|
-
*
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
-
*
|
|
463
|
-
* `
|
|
464
|
-
*
|
|
465
|
-
* `
|
|
466
|
-
*
|
|
467
|
-
*
|
|
468
|
-
* model can self-correct from. So with no repairer configured this is
|
|
469
|
-
* behaviorally identical to the bare `JSON.parse` it replaced.
|
|
508
|
+
* The three things the admission family reads off this executor.
|
|
509
|
+
*
|
|
510
|
+
* Built per call rather than held: `setSandbox` REPLACES `config`, so a
|
|
511
|
+
* host captured once would hand the next admission a stale sandbox.
|
|
512
|
+
*
|
|
513
|
+
* The one way this differs from the inline code it replaced, which
|
|
514
|
+
* re-read `this.config` at every use: an admission that spans a
|
|
515
|
+
* `setSandbox()` now finishes against the config it STARTED with rather
|
|
516
|
+
* than against the new one. Distinguishing the two readings needs
|
|
517
|
+
* `setSandbox` to be called from a hook awaited in the middle of one
|
|
518
|
+
* admission — its only call site is the run's sandbox acquisition,
|
|
519
|
+
* before the loop, so nothing in this tree can tell them apart.
|
|
470
520
|
*/
|
|
471
|
-
private
|
|
472
|
-
|
|
473
|
-
* What is wrong with this call, or `null` if nothing is.
|
|
474
|
-
*
|
|
475
|
-
* JSON is checked before the tool is looked up: an unparseable argument
|
|
476
|
-
* string is broken regardless of which tool it was aimed at, and it is
|
|
477
|
-
* the one problem the executor itself has to answer.
|
|
478
|
-
*/
|
|
479
|
-
private repairTruncatedCall;
|
|
480
|
-
private inspectCall;
|
|
481
|
-
private requestRepair;
|
|
521
|
+
private admissionHost;
|
|
522
|
+
private prepareNestedCall;
|
|
482
523
|
/**
|
|
483
524
|
* One execution attempt, with a throw materialized as an error result.
|
|
484
525
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/runtime/query/executor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAEpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAEtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAIvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/runtime/query/executor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAEpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAEtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAIvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AAGnE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAA;AAC7E,OAAO,KAAK,EAAE,KAAK,EAAa,MAAM,0BAA0B,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AACtE,OAAO,EACN,KAAK,OAAO,EACZ,KAAK,QAAQ,E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