@lloyal-labs/lloyal-agents 2.0.0 → 3.0.0
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/LICENSE +107 -0
- package/LICENSE-FAQ.md +256 -0
- package/README.md +31 -15
- package/dist/Agent.d.ts +15 -4
- package/dist/Agent.d.ts.map +1 -1
- package/dist/Agent.js +12 -2
- package/dist/Agent.js.map +1 -1
- package/dist/AgentPolicy.d.ts +92 -15
- package/dist/AgentPolicy.d.ts.map +1 -1
- package/dist/AgentPolicy.js +42 -14
- package/dist/AgentPolicy.js.map +1 -1
- package/dist/Tool.d.ts +45 -1
- package/dist/Tool.d.ts.map +1 -1
- package/dist/Tool.js +50 -2
- package/dist/Tool.js.map +1 -1
- package/dist/agent-pool.d.ts +4 -4
- package/dist/agent-pool.d.ts.map +1 -1
- package/dist/agent-pool.js +224 -53
- package/dist/agent-pool.js.map +1 -1
- package/dist/app-config.d.ts +50 -0
- package/dist/app-config.d.ts.map +1 -0
- package/dist/app-config.js +27 -0
- package/dist/app-config.js.map +1 -0
- package/dist/app-types.d.ts +309 -0
- package/dist/app-types.d.ts.map +1 -0
- package/dist/app-types.js +28 -0
- package/dist/app-types.js.map +1 -0
- package/dist/chunk.d.ts +118 -0
- package/dist/chunk.d.ts.map +1 -0
- package/dist/chunk.js +19 -0
- package/dist/chunk.js.map +1 -0
- package/dist/context.d.ts +76 -20
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +72 -20
- package/dist/context.js.map +1 -1
- package/dist/create-agent-pool.d.ts +18 -12
- package/dist/create-agent-pool.d.ts.map +1 -1
- package/dist/create-agent-pool.js +30 -29
- package/dist/create-agent-pool.js.map +1 -1
- package/dist/grant-store.d.ts +49 -0
- package/dist/grant-store.d.ts.map +1 -0
- package/dist/grant-store.js +33 -0
- package/dist/grant-store.js.map +1 -0
- package/dist/index.d.ts +10 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/orchestrators.d.ts +15 -8
- package/dist/orchestrators.d.ts.map +1 -1
- package/dist/orchestrators.js +10 -10
- package/dist/orchestrators.js.map +1 -1
- package/dist/replay.d.ts +19 -19
- package/dist/replay.d.ts.map +1 -1
- package/dist/replay.js +29 -29
- package/dist/replay.js.map +1 -1
- package/dist/source.d.ts +31 -1
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +32 -2
- package/dist/source.js.map +1 -1
- package/dist/spine.d.ts +100 -0
- package/dist/spine.d.ts.map +1 -0
- package/dist/{shared-root.js → spine.js} +57 -38
- package/dist/spine.js.map +1 -0
- package/dist/toolkit.d.ts +44 -17
- package/dist/toolkit.d.ts.map +1 -1
- package/dist/toolkit.js +24 -14
- package/dist/toolkit.js.map +1 -1
- package/dist/trace-types.d.ts +36 -4
- package/dist/trace-types.d.ts.map +1 -1
- package/dist/types.d.ts +46 -15
- package/dist/types.d.ts.map +1 -1
- package/dist/use-agent.d.ts +10 -5
- package/dist/use-agent.d.ts.map +1 -1
- package/dist/use-agent.js +18 -15
- package/dist/use-agent.js.map +1 -1
- package/package.json +7 -5
- package/dist/shared-root.d.ts +0 -96
- package/dist/shared-root.d.ts.map +0 -1
- package/dist/shared-root.js.map +0 -1
package/dist/AgentPolicy.d.ts
CHANGED
|
@@ -1,27 +1,49 @@
|
|
|
1
1
|
import type { Agent, ToolHistoryEntry } from './Agent';
|
|
2
|
+
import type { ToolRetryError } from './Tool';
|
|
2
3
|
import { ContextPressure } from './agent-pool';
|
|
3
4
|
import type { ParsedToolCall } from '@lloyal-labs/sdk';
|
|
4
5
|
import type { PressureThresholds } from './types';
|
|
5
6
|
/**
|
|
6
|
-
* A declarative guard that rejects tool calls based on agent
|
|
7
|
+
* A declarative guard that rejects tool calls based on agent state.
|
|
7
8
|
* Guards are checked in order before any tool is dispatched.
|
|
8
9
|
*
|
|
10
|
+
* `tools` selects which tool calls this guard sees: a `string[]` matches
|
|
11
|
+
* by exact name; the literal `'*'` matches every call (used by the
|
|
12
|
+
* framework-injected authGuard — guards that need to
|
|
13
|
+
* inspect *every* call regardless of tool name).
|
|
14
|
+
*
|
|
15
|
+
* `reject` returns `true` to reject the call with `message`. It receives
|
|
16
|
+
* the parsed args, the full agent lineage's tool history, the agent
|
|
17
|
+
* itself, `toolName` (so `tools: '*'` guards know which tool they're
|
|
18
|
+
* gating), and the pool-level `config` (so guards can consult
|
|
19
|
+
* pool-resolved state such as the protected-tool set and the session's
|
|
20
|
+
* grants — see {@link PolicyConfig}). Guards that don't need `config`
|
|
21
|
+
* simply omit the parameter.
|
|
22
|
+
*
|
|
23
|
+
* `name` is the optional guard identifier surfaced via
|
|
24
|
+
* `ProduceAction.nudge.guard` so the pool can emit per-guard trace
|
|
25
|
+
* events (e.g., `tool:authReject` for `name: 'auth_reject'`). Omit it
|
|
26
|
+
* for guards whose only observable footprint is the resulting
|
|
27
|
+
* `pool:agentNudge` event.
|
|
28
|
+
*
|
|
9
29
|
* @category Agents
|
|
10
30
|
*/
|
|
11
31
|
export interface ToolGuard {
|
|
12
|
-
/** Tool names this guard applies to */
|
|
13
|
-
tools: string[];
|
|
14
|
-
/** Return true to reject the call.
|
|
15
|
-
reject: (args: Record<string, unknown>, lineageHistory: ToolHistoryEntry[], agent: Agent) => boolean;
|
|
16
|
-
/** Error message sent back to the agent as a tool result */
|
|
32
|
+
/** Tool names this guard applies to; `'*'` matches every call. */
|
|
33
|
+
tools: string[] | '*';
|
|
34
|
+
/** Return true to reject the call. */
|
|
35
|
+
reject: (args: Record<string, unknown>, lineageHistory: ToolHistoryEntry[], agent: Agent, toolName: string, config: PolicyConfig) => boolean;
|
|
36
|
+
/** Error message sent back to the agent as a tool result. */
|
|
17
37
|
message: string;
|
|
38
|
+
/** Optional identifier surfaced via `ProduceAction.nudge.guard`. */
|
|
39
|
+
name?: string;
|
|
18
40
|
}
|
|
19
41
|
export declare const defaultToolGuards: ToolGuard[];
|
|
20
42
|
/**
|
|
21
43
|
* Why the agent entered idle status.
|
|
22
44
|
* @category Agents
|
|
23
45
|
*/
|
|
24
|
-
export type IdleReason = '
|
|
46
|
+
export type IdleReason = 'returned' | 'pressure_critical' | 'pressure_softcut' | 'pressure_settle_reject' | 'settle_stall_break' | 'max_turns' | 'free_text_stop' | 'tool_error';
|
|
25
47
|
/**
|
|
26
48
|
* Action returned by policy.onProduced — tells the pool what to do.
|
|
27
49
|
* @category Agents
|
|
@@ -30,16 +52,21 @@ export type ProduceAction = {
|
|
|
30
52
|
type: 'tool_call';
|
|
31
53
|
tc: ParsedToolCall;
|
|
32
54
|
} | {
|
|
33
|
-
type: '
|
|
55
|
+
type: 'return';
|
|
34
56
|
result: string;
|
|
35
|
-
}
|
|
57
|
+
}
|
|
58
|
+
/** `guard` carries the identifier of the rejecting `ToolGuard` — used to
|
|
59
|
+
* route `auth_reject` rejections to the `tool:authReject` trace event.
|
|
60
|
+
* Absent for nudges not produced by a guard. */
|
|
61
|
+
| {
|
|
36
62
|
type: 'nudge';
|
|
37
63
|
message: string;
|
|
64
|
+
guard?: string;
|
|
38
65
|
} | {
|
|
39
66
|
type: 'idle';
|
|
40
67
|
reason: IdleReason;
|
|
41
68
|
} | {
|
|
42
|
-
type: '
|
|
69
|
+
type: 'free_text_return';
|
|
43
70
|
content: string;
|
|
44
71
|
};
|
|
45
72
|
/**
|
|
@@ -67,6 +94,25 @@ export type RecoveryAction = {
|
|
|
67
94
|
} | {
|
|
68
95
|
type: 'skip';
|
|
69
96
|
};
|
|
97
|
+
/**
|
|
98
|
+
* Action returned by policy.onToolRetry — what to do when a tool throws
|
|
99
|
+
* {@link ToolRetryError} (transient failure, e.g. provider rate-limited).
|
|
100
|
+
*
|
|
101
|
+
* `retry` parks the agent (`awaiting_tool`, skipped by PRODUCE at zero
|
|
102
|
+
* cost — no turns, no tokens, no KV) and re-executes the same call after
|
|
103
|
+
* `afterMs` (defaults to the error's own `retryAfterMs` estimate).
|
|
104
|
+
* `fail` settles `message` (or the pool's directive default) as the tool
|
|
105
|
+
* result so the model can pivot.
|
|
106
|
+
*
|
|
107
|
+
* @category Agents
|
|
108
|
+
*/
|
|
109
|
+
export type ToolRetryAction = {
|
|
110
|
+
type: 'retry';
|
|
111
|
+
afterMs?: number;
|
|
112
|
+
} | {
|
|
113
|
+
type: 'fail';
|
|
114
|
+
message?: string;
|
|
115
|
+
};
|
|
70
116
|
/**
|
|
71
117
|
* Agent lifecycle policy — injected strategy for pressure, nudge,
|
|
72
118
|
* recursion, report timing, and result quality decisions.
|
|
@@ -154,6 +200,18 @@ export interface AgentPolicy {
|
|
|
154
200
|
* Optional — defaults to skip when absent.
|
|
155
201
|
*/
|
|
156
202
|
onRecovery?(agent: Agent, pressure: ContextPressure): RecoveryAction;
|
|
203
|
+
/**
|
|
204
|
+
* Transient tool failure (the tool threw {@link ToolRetryError}).
|
|
205
|
+
* Decide whether to park-and-retry or settle a failure result. The tool
|
|
206
|
+
* supplies a `retryAfterMs` estimate on the error; the policy may override
|
|
207
|
+
* it (`afterMs`) or refuse to wait at all — e.g. when the time budget
|
|
208
|
+
* can't afford a park.
|
|
209
|
+
*
|
|
210
|
+
* Absent → pool default: one retry at the error's own delay, then fail.
|
|
211
|
+
*
|
|
212
|
+
* @param attempt - 1 on the first failure of a call, 2 after one retry, …
|
|
213
|
+
*/
|
|
214
|
+
onToolRetry?(agent: Agent, tool: string, error: ToolRetryError, attempt: number): ToolRetryAction;
|
|
157
215
|
}
|
|
158
216
|
/**
|
|
159
217
|
* Pool-level configuration passed to policy methods.
|
|
@@ -161,8 +219,22 @@ export interface AgentPolicy {
|
|
|
161
219
|
*/
|
|
162
220
|
export interface PolicyConfig {
|
|
163
221
|
maxTurns: number;
|
|
164
|
-
|
|
222
|
+
terminalToolName?: string;
|
|
165
223
|
hasNonTerminalTools: boolean;
|
|
224
|
+
/**
|
|
225
|
+
* Tool names this pool declares `protected` (gathered from each
|
|
226
|
+
* {@link Tool.protected} flag). The authGuard gates only these; every
|
|
227
|
+
* other tool is open. Resolved once at pool setup. Undefined/empty when
|
|
228
|
+
* no tool in the pool is protected (the common case).
|
|
229
|
+
*/
|
|
230
|
+
protectedTools?: ReadonlySet<string>;
|
|
231
|
+
/**
|
|
232
|
+
* Protected tool names the session currently holds a grant for — read
|
|
233
|
+
* from {@link GrantStoreCtx} at pool setup. The authGuard allows a
|
|
234
|
+
* protected tool iff its name is in this set. Undefined/empty = no
|
|
235
|
+
* grants (fail-closed: every protected tool denied).
|
|
236
|
+
*/
|
|
237
|
+
grants?: ReadonlySet<string>;
|
|
166
238
|
}
|
|
167
239
|
/**
|
|
168
240
|
* Default policy replicating the current inline if-logic from agent-pool.ts.
|
|
@@ -178,8 +250,8 @@ export interface PolicyConfig {
|
|
|
178
250
|
* @category Agents
|
|
179
251
|
*/
|
|
180
252
|
export interface DefaultAgentPolicyOpts {
|
|
181
|
-
/** Min non-terminal tool calls before
|
|
182
|
-
|
|
253
|
+
/** Min non-terminal tool calls before a return is accepted without nudge. @default 2 */
|
|
254
|
+
minToolCallsBeforeReturn?: number;
|
|
183
255
|
/** Replace default tool guards entirely. */
|
|
184
256
|
guards?: ToolGuard[];
|
|
185
257
|
/** Append additional guards to the defaults. */
|
|
@@ -231,7 +303,10 @@ export interface DefaultAgentPolicyOpts {
|
|
|
231
303
|
/** Terminal tool name. When set, agents mid-generation of this tool are
|
|
232
304
|
* protected from shouldExit — the hard limit is deferred until the tool
|
|
233
305
|
* call completes naturally or KV pressure forces a kill. */
|
|
234
|
-
|
|
306
|
+
terminalToolName?: string;
|
|
307
|
+
/** Max park-and-retry attempts per tool call on {@link ToolRetryError}
|
|
308
|
+
* before failing the call with a directive result. @default 1 */
|
|
309
|
+
maxToolRetries?: number;
|
|
235
310
|
}
|
|
236
311
|
export declare class DefaultAgentPolicy implements AgentPolicy {
|
|
237
312
|
private _minToolCalls;
|
|
@@ -241,9 +316,11 @@ export declare class DefaultAgentPolicy implements AgentPolicy {
|
|
|
241
316
|
private _forceExploit;
|
|
242
317
|
private _recovery;
|
|
243
318
|
private _budget;
|
|
244
|
-
private
|
|
319
|
+
private _terminalToolName;
|
|
320
|
+
private _maxToolRetries;
|
|
245
321
|
private _startTime;
|
|
246
322
|
constructor(opts?: DefaultAgentPolicyOpts);
|
|
323
|
+
onToolRetry(_agent: Agent, _tool: string, _error: ToolRetryError, attempt: number): ToolRetryAction;
|
|
247
324
|
/**
|
|
248
325
|
* Elapsed wall time for *this agent* (since its first idle→active transition),
|
|
249
326
|
* falling back to the policy's own construction time when the agent hasn't
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentPolicy.d.ts","sourceRoot":"","sources":["../src/AgentPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAuBlD
|
|
1
|
+
{"version":3,"file":"AgentPolicy.d.ts","sourceRoot":"","sources":["../src/AgentPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAuBlD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,WAAW,SAAS;IACxB,kEAAkE;IAClE,KAAK,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IACtB,sCAAsC;IACtC,MAAM,EAAE,CACN,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,C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,eAAe,EACzB,MAAM,EAAE,YAAY,GACnB,YAAY;IAUf;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAEpC,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,eAAe,GAAG,OAAO;IAiB5D,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,eAAe,GAAG,OAAO;IAY/D;;;;;OAKG;IACH,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,eAAe,CAAS;IAEhC,SAAS,IAAI,IAAI;IAKjB,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,eAAe,GAAG,cAAc;CAuBpE"}
|
package/dist/AgentPolicy.js
CHANGED
|
@@ -29,6 +29,26 @@ function parseHistoryArgs(argsStr) {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
exports.defaultToolGuards = [
|
|
32
|
+
// Framework-injected authGuard. Runs FIRST so a
|
|
33
|
+
// protected-tool rejection fires before any dedup guard — the pool
|
|
34
|
+
// emits a structured `tool:authReject` event keyed off
|
|
35
|
+
// `ProduceAction.nudge.guard === 'auth_reject'` for security
|
|
36
|
+
// observability. Reads/gather tools are OPEN: the guard only fires for
|
|
37
|
+
// a `protected` tool (in `config.protectedTools`) the session has not
|
|
38
|
+
// been granted (`config.grants`). When no tools are protected — the
|
|
39
|
+
// common case — this is a no-op.
|
|
40
|
+
{
|
|
41
|
+
name: 'auth_reject',
|
|
42
|
+
tools: '*',
|
|
43
|
+
reject: (_args, _history, _agent, toolName, config) => {
|
|
44
|
+
if (!config.protectedTools?.has(toolName))
|
|
45
|
+
return false; // open by default
|
|
46
|
+
return !config.grants?.has(toolName); // protected → deny unless granted
|
|
47
|
+
},
|
|
48
|
+
message: 'This action is protected and requires authorization that has not been ' +
|
|
49
|
+
'granted for this session. Use the available read tools to gather what ' +
|
|
50
|
+
'you can, and report what blocks completion.',
|
|
51
|
+
},
|
|
32
52
|
{
|
|
33
53
|
tools: ['fetch_page'],
|
|
34
54
|
reject: (args, history) => {
|
|
@@ -57,10 +77,11 @@ class DefaultAgentPolicy {
|
|
|
57
77
|
_forceExploit = false;
|
|
58
78
|
_recovery;
|
|
59
79
|
_budget;
|
|
60
|
-
|
|
80
|
+
_terminalToolName;
|
|
81
|
+
_maxToolRetries;
|
|
61
82
|
_startTime;
|
|
62
83
|
constructor(opts) {
|
|
63
|
-
this._minToolCalls = opts?.
|
|
84
|
+
this._minToolCalls = opts?.minToolCallsBeforeReturn ?? 2;
|
|
64
85
|
this._exploreContext = opts?.shouldExplore?.context ?? 0.4;
|
|
65
86
|
this._exploreTime = opts?.shouldExplore?.time ?? 0.5;
|
|
66
87
|
this._guards = opts?.guards ?? [
|
|
@@ -69,9 +90,13 @@ class DefaultAgentPolicy {
|
|
|
69
90
|
];
|
|
70
91
|
this._recovery = opts?.recovery ?? null;
|
|
71
92
|
this._budget = opts?.budget ?? null;
|
|
72
|
-
this.
|
|
93
|
+
this._terminalToolName = opts?.terminalToolName ?? null;
|
|
94
|
+
this._maxToolRetries = opts?.maxToolRetries ?? 1;
|
|
73
95
|
this._startTime = performance.now();
|
|
74
96
|
}
|
|
97
|
+
onToolRetry(_agent, _tool, _error, attempt) {
|
|
98
|
+
return attempt <= this._maxToolRetries ? { type: 'retry' } : { type: 'fail' };
|
|
99
|
+
}
|
|
75
100
|
/**
|
|
76
101
|
* Elapsed wall time for *this agent* (since its first idle→active transition),
|
|
77
102
|
* falling back to the policy's own construction time when the agent hasn't
|
|
@@ -109,7 +134,7 @@ class DefaultAgentPolicy {
|
|
|
109
134
|
// guard — stuck agents (same query repeated past maxTurns) saw only
|
|
110
135
|
// turn-limit nudges instead of the dedup message that named the
|
|
111
136
|
// actual problem (see trace-1776819196054 agent 65539).
|
|
112
|
-
const guardRejection = this._checkGuards(tc, agent);
|
|
137
|
+
const guardRejection = this._checkGuards(tc, agent, config);
|
|
113
138
|
if (guardRejection)
|
|
114
139
|
return guardRejection;
|
|
115
140
|
if (this._isOverBudget(agent, tc, pressure, config))
|
|
@@ -120,12 +145,12 @@ class DefaultAgentPolicy {
|
|
|
120
145
|
// ── onProduced decision predicates ─────────────────────
|
|
121
146
|
_handleNoToolCall(agent, parsed) {
|
|
122
147
|
if (!agent.result && agent.toolCallCount > 0 && parsed.content) {
|
|
123
|
-
return { type: '
|
|
148
|
+
return { type: 'free_text_return', content: parsed.content };
|
|
124
149
|
}
|
|
125
150
|
return { type: 'idle', reason: 'free_text_stop' };
|
|
126
151
|
}
|
|
127
152
|
_isTerminalTool(tc, config) {
|
|
128
|
-
return !!(config.
|
|
153
|
+
return !!(config.terminalToolName && tc.name === config.terminalToolName);
|
|
129
154
|
}
|
|
130
155
|
_handleTerminalTool(tc, agent, config, pressure) {
|
|
131
156
|
const underPressure = this._isUnderPressure(agent, pressure, config);
|
|
@@ -139,7 +164,7 @@ class DefaultAgentPolicy {
|
|
|
139
164
|
catch {
|
|
140
165
|
result = tc.arguments;
|
|
141
166
|
}
|
|
142
|
-
return { type: '
|
|
167
|
+
return { type: 'return', result };
|
|
143
168
|
}
|
|
144
169
|
_isUnderPressure(agent, pressure, config) {
|
|
145
170
|
const timeSoft = this._budget?.time?.softLimit;
|
|
@@ -148,12 +173,12 @@ class DefaultAgentPolicy {
|
|
|
148
173
|
}
|
|
149
174
|
_isOverBudget(agent, tc, pressure, config) {
|
|
150
175
|
const underPressure = this._isUnderPressure(agent, pressure, config);
|
|
151
|
-
return underPressure && (!config.
|
|
176
|
+
return underPressure && (!config.terminalToolName || tc.name !== config.terminalToolName);
|
|
152
177
|
}
|
|
153
178
|
_handleOverBudget(agent, tc, pressure, config) {
|
|
154
179
|
const timeSoft = this._budget?.time?.softLimit;
|
|
155
180
|
const timeNudge = timeSoft != null && this._elapsed(agent) >= timeSoft;
|
|
156
|
-
if (config.
|
|
181
|
+
if (config.terminalToolName && agent.toolCallCount > 0 && !pressure.critical) {
|
|
157
182
|
if (!this._nudgedThisTick) {
|
|
158
183
|
this._nudgedThisTick = true;
|
|
159
184
|
// Budget the model can emit before `pressure.critical` kills it.
|
|
@@ -173,7 +198,7 @@ class DefaultAgentPolicy {
|
|
|
173
198
|
}
|
|
174
199
|
return { type: 'idle', reason: agent.turns >= config.maxTurns ? 'max_turns' : 'pressure_softcut' };
|
|
175
200
|
}
|
|
176
|
-
_checkGuards(tc, agent) {
|
|
201
|
+
_checkGuards(tc, agent, config) {
|
|
177
202
|
const lineageHistory = agent.walkAncestors(a => a.toolHistory);
|
|
178
203
|
let toolArgs;
|
|
179
204
|
try {
|
|
@@ -183,15 +208,18 @@ class DefaultAgentPolicy {
|
|
|
183
208
|
toolArgs = {};
|
|
184
209
|
}
|
|
185
210
|
for (const guard of this._guards) {
|
|
186
|
-
|
|
187
|
-
|
|
211
|
+
const applies = guard.tools === '*' || guard.tools.includes(tc.name);
|
|
212
|
+
if (!applies)
|
|
213
|
+
continue;
|
|
214
|
+
if (guard.reject(toolArgs, lineageHistory, agent, tc.name, config)) {
|
|
215
|
+
return { type: 'nudge', message: guard.message, guard: guard.name };
|
|
188
216
|
}
|
|
189
217
|
}
|
|
190
218
|
return null;
|
|
191
219
|
}
|
|
192
220
|
onSettleReject(agent, _resultTokens, pressure, config) {
|
|
193
221
|
// Nudge if possible — stateless, no escalation tracking
|
|
194
|
-
if (config.
|
|
222
|
+
if (config.terminalToolName && agent.toolCallCount > 0) {
|
|
195
223
|
const words = tokenBudgetAsWords(pressure.remaining - pressure.hardLimit);
|
|
196
224
|
return { type: 'nudge', message: `Tool result too large for remaining KV. Report your findings now within ${words} words.` };
|
|
197
225
|
}
|
|
@@ -208,7 +236,7 @@ class DefaultAgentPolicy {
|
|
|
208
236
|
// `pressure.critical` fires, the agent must yield so the pool can
|
|
209
237
|
// kill+recover before native OOM. Holding this protection through
|
|
210
238
|
// critical territory was the DOJ runaway cause (trace-1776782401659).
|
|
211
|
-
if (this.
|
|
239
|
+
if (this._terminalToolName && agent.currentTool === this._terminalToolName && !pressure.critical)
|
|
212
240
|
return false;
|
|
213
241
|
if (!pressure.critical) {
|
|
214
242
|
const timeHard = this._budget?.time?.hardLimit;
|
package/dist/AgentPolicy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentPolicy.js","sourceRoot":"","sources":["../src/AgentPolicy.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"AgentPolicy.js","sourceRoot":"","sources":["../src/AgentPolicy.ts"],"names":[],"mappings":";;;AAEA,6CAA+C;AAG/C,qCAA0C;AAE1C,2EAA2E;AAC3E,0EAA0E;AAC1E,mEAAmE;AACnE,oDAAoD;AACpD,MAAM,yBAAyB,GAAG,GAAG,CAAC;AACtC,MAAM,YAAY,GAAG,GAAG,CAAC;AAEzB;;;;;;GAMG;AACH,SAAS,kBAAkB,CAAC,YAAoB;IAC9C,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,GAAG,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;AAChE,CAAC;AA8CD,gEAAgE;AAChE,SAAS,gBAAgB,CAAC,OAAe;IACvC,IAAI,CAAC;QAAC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC;QAAC,OAAO,EAAE,CAAC;IAAC,CAAC;AAC1D,CAAC;AAEY,QAAA,iBAAiB,GAAgB;IAC5C,gDAAgD;IAChD,mEAAmE;IACnE,uDAAuD;IACvD,6DAA6D;IAC7D,uEAAuE;IACvE,sEAAsE;IACtE,oEAAoE;IACpE,iCAAiC;IACjC;QACE,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE;YACpD,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,GAAG,CAAC,QAAQ,CAAC;gBAA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C;QACjG,MAAM,MAAM,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAC;QAChD,MAAM,IAAI,GAAG,EAAE,MAAM,EAAE,CAAC;QACxB,OAAO;YACL,IAAI,EAAE,SAAS;YACf,MAAM,EAAE;gBACN,MAAM,EAAE,IAAA,uBAAc,EAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC;gBAC1D,IAAI,EAAE,IAAA,uBAAc,EAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC;aACvD;SACF,CAAC;IACJ,CAAC;CACF;AAtPD,gDAsPC"}
|
package/dist/Tool.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ import type { JsonSchema, ToolSchema, ToolContext } from './types';
|
|
|
13
13
|
* {@link runAgents}.
|
|
14
14
|
*
|
|
15
15
|
* `execute()` returns an Effection `Operation`, enabling tools to
|
|
16
|
-
* spawn sub-agents via {@link
|
|
16
|
+
* spawn sub-agents via {@link agentPool} or {@link withSpine}.
|
|
17
17
|
* For async work, wrap in `call()`. For synchronous tools, return
|
|
18
18
|
* directly from the generator body.
|
|
19
19
|
*
|
|
@@ -47,6 +47,28 @@ export declare abstract class Tool<TArgs = Record<string, unknown>> {
|
|
|
47
47
|
abstract readonly description: string;
|
|
48
48
|
/** JSON Schema describing the tool's expected arguments */
|
|
49
49
|
abstract readonly parameters: JsonSchema;
|
|
50
|
+
/**
|
|
51
|
+
* Whether invoking this tool requires authorization.
|
|
52
|
+
*
|
|
53
|
+
* **Open by default** (`false`/unset): any agent may call the tool. This
|
|
54
|
+
* is the right setting for read/gather tools — search, fetch, grep — where
|
|
55
|
+
* agents discover an app's coverage by *trying*, the frontier-agentic
|
|
56
|
+
* pattern. The spine loads every app's tools for KV amortization; an open
|
|
57
|
+
* tool is callable regardless of which app a spawn nominally belongs to.
|
|
58
|
+
*
|
|
59
|
+
* **Protected** (`true`): the tool mutates state or takes a consequential
|
|
60
|
+
* action (transfer funds, file a ticket, send a message). The framework's
|
|
61
|
+
* authGuard denies the call unless the session holds a **grant** for it
|
|
62
|
+
* (held in {@link GrantStoreCtx}, acquired via consent — the model never
|
|
63
|
+
* sees the credential). A denied attempt rejects at dispatch time and
|
|
64
|
+
* emits `tool:authReject`.
|
|
65
|
+
*
|
|
66
|
+
* Trust changes *which grants a session holds*, never tool behaviour:
|
|
67
|
+
* execution is identical for trusted and untrusted apps. An app MAY mark
|
|
68
|
+
* an exfiltration-capable "read" (one that fetches arbitrary URLs) as
|
|
69
|
+
* protected — the binary flag delegates that judgment to the app.
|
|
70
|
+
*/
|
|
71
|
+
readonly protected?: boolean;
|
|
50
72
|
/**
|
|
51
73
|
* Execute the tool with parsed arguments
|
|
52
74
|
*
|
|
@@ -86,4 +108,26 @@ export declare abstract class Tool<TArgs = Record<string, unknown>> {
|
|
|
86
108
|
*/
|
|
87
109
|
get schema(): ToolSchema;
|
|
88
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Thrown by a tool (or its backend provider) when the operation failed
|
|
113
|
+
* transiently and should be retried after a delay — rate limiting being the
|
|
114
|
+
* canonical case.
|
|
115
|
+
*
|
|
116
|
+
* The pool's DISPATCH phase catches this BEFORE the generic tool-error
|
|
117
|
+
* handler: instead of settling an error into the agent's KV, it parks the
|
|
118
|
+
* agent (`awaiting_tool` — skipped by PRODUCE at zero cost) and re-executes
|
|
119
|
+
* the same call after `retryAfterMs`. The model never sees transient
|
|
120
|
+
* infrastructure weather in its context; from its side the tool call just
|
|
121
|
+
* took longer. One retry is budgeted — a second ToolRetryError settles an
|
|
122
|
+
* honest "unavailable, use other sources" result, because at that point the
|
|
123
|
+
* outage is a fact the model needs in order to pivot.
|
|
124
|
+
*
|
|
125
|
+
* Observability: the pool emits `agent:tool_retry` (TUI) and `tool:retry`
|
|
126
|
+
* (trace) when parking, so a waiting agent is never mistaken for a hung one.
|
|
127
|
+
*/
|
|
128
|
+
export declare class ToolRetryError extends Error {
|
|
129
|
+
readonly retryAfterMs: number;
|
|
130
|
+
readonly name = "ToolRetryError";
|
|
131
|
+
constructor(message: string, retryAfterMs: number);
|
|
132
|
+
}
|
|
89
133
|
//# sourceMappingURL=Tool.d.ts.map
|
package/dist/Tool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tool.d.ts","sourceRoot":"","sources":["../src/Tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,8BAAsB,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACxD,gEAAgE;IAChE,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAC/B,oDAAoD;IACpD,QAAQ,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IACtC,2DAA2D;IAC3D,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAEzC;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC;IAExE;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI;IAEtC;;;;;;OAMG;IACH,IAAI,MAAM,IAAI,UAAU,CASvB;CACF"}
|
|
1
|
+
{"version":3,"file":"Tool.d.ts","sourceRoot":"","sources":["../src/Tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,8BAAsB,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACxD,gEAAgE;IAChE,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAC/B,oDAAoD;IACpD,QAAQ,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IACtC,2DAA2D;IAC3D,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAEzC;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAE7B;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC;IAExE;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI;IAEtC;;;;;;OAMG;IACH,IAAI,MAAM,IAAI,UAAU,CASvB;CACF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,cAAe,SAAQ,KAAK;IAEV,QAAQ,CAAC,YAAY,EAAE,MAAM;IAD1D,SAAkB,IAAI,oBAAoB;gBAC9B,OAAO,EAAE,MAAM,EAAW,YAAY,EAAE,MAAM;CAG3D"}
|
package/dist/Tool.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Tool = void 0;
|
|
3
|
+
exports.ToolRetryError = exports.Tool = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Abstract base class for tools usable by agents in the runtime
|
|
6
6
|
*
|
|
@@ -14,7 +14,7 @@ exports.Tool = void 0;
|
|
|
14
14
|
* {@link runAgents}.
|
|
15
15
|
*
|
|
16
16
|
* `execute()` returns an Effection `Operation`, enabling tools to
|
|
17
|
-
* spawn sub-agents via {@link
|
|
17
|
+
* spawn sub-agents via {@link agentPool} or {@link withSpine}.
|
|
18
18
|
* For async work, wrap in `call()`. For synchronous tools, return
|
|
19
19
|
* directly from the generator body.
|
|
20
20
|
*
|
|
@@ -42,6 +42,28 @@ exports.Tool = void 0;
|
|
|
42
42
|
* @category Agents
|
|
43
43
|
*/
|
|
44
44
|
class Tool {
|
|
45
|
+
/**
|
|
46
|
+
* Whether invoking this tool requires authorization.
|
|
47
|
+
*
|
|
48
|
+
* **Open by default** (`false`/unset): any agent may call the tool. This
|
|
49
|
+
* is the right setting for read/gather tools — search, fetch, grep — where
|
|
50
|
+
* agents discover an app's coverage by *trying*, the frontier-agentic
|
|
51
|
+
* pattern. The spine loads every app's tools for KV amortization; an open
|
|
52
|
+
* tool is callable regardless of which app a spawn nominally belongs to.
|
|
53
|
+
*
|
|
54
|
+
* **Protected** (`true`): the tool mutates state or takes a consequential
|
|
55
|
+
* action (transfer funds, file a ticket, send a message). The framework's
|
|
56
|
+
* authGuard denies the call unless the session holds a **grant** for it
|
|
57
|
+
* (held in {@link GrantStoreCtx}, acquired via consent — the model never
|
|
58
|
+
* sees the credential). A denied attempt rejects at dispatch time and
|
|
59
|
+
* emits `tool:authReject`.
|
|
60
|
+
*
|
|
61
|
+
* Trust changes *which grants a session holds*, never tool behaviour:
|
|
62
|
+
* execution is identical for trusted and untrusted apps. An app MAY mark
|
|
63
|
+
* an exfiltration-capable "read" (one that fetches arbitrary URLs) as
|
|
64
|
+
* protected — the binary flag delegates that judgment to the app.
|
|
65
|
+
*/
|
|
66
|
+
protected;
|
|
45
67
|
/**
|
|
46
68
|
* Optional reasoning probe prefilled after this tool's result settles.
|
|
47
69
|
*
|
|
@@ -75,4 +97,30 @@ class Tool {
|
|
|
75
97
|
}
|
|
76
98
|
}
|
|
77
99
|
exports.Tool = Tool;
|
|
100
|
+
/**
|
|
101
|
+
* Thrown by a tool (or its backend provider) when the operation failed
|
|
102
|
+
* transiently and should be retried after a delay — rate limiting being the
|
|
103
|
+
* canonical case.
|
|
104
|
+
*
|
|
105
|
+
* The pool's DISPATCH phase catches this BEFORE the generic tool-error
|
|
106
|
+
* handler: instead of settling an error into the agent's KV, it parks the
|
|
107
|
+
* agent (`awaiting_tool` — skipped by PRODUCE at zero cost) and re-executes
|
|
108
|
+
* the same call after `retryAfterMs`. The model never sees transient
|
|
109
|
+
* infrastructure weather in its context; from its side the tool call just
|
|
110
|
+
* took longer. One retry is budgeted — a second ToolRetryError settles an
|
|
111
|
+
* honest "unavailable, use other sources" result, because at that point the
|
|
112
|
+
* outage is a fact the model needs in order to pivot.
|
|
113
|
+
*
|
|
114
|
+
* Observability: the pool emits `agent:tool_retry` (TUI) and `tool:retry`
|
|
115
|
+
* (trace) when parking, so a waiting agent is never mistaken for a hung one.
|
|
116
|
+
*/
|
|
117
|
+
class ToolRetryError extends Error {
|
|
118
|
+
retryAfterMs;
|
|
119
|
+
name = 'ToolRetryError';
|
|
120
|
+
constructor(message, retryAfterMs) {
|
|
121
|
+
super(message);
|
|
122
|
+
this.retryAfterMs = retryAfterMs;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.ToolRetryError = ToolRetryError;
|
|
78
126
|
//# sourceMappingURL=Tool.js.map
|
package/dist/Tool.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tool.js","sourceRoot":"","sources":["../src/Tool.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAsB,IAAI;
|
|
1
|
+
{"version":3,"file":"Tool.js","sourceRoot":"","sources":["../src/Tool.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAsB,IAAI;IAQxB;;;;;;;;;;;;;;;;;;;;OAoBG;IACM,SAAS,CAAW;IAmB7B;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,OAAgB,IAAmB,OAAO,IAAI,CAAC,CAAC,CAAC;IAEvD;;;;;;OAMG;IACH,IAAI,MAAM;QACR,OAAO;YACL,IAAI,EAAE,UAAU;YAChB,QAAQ,EAAE;gBACR,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,UAAU,EAAE,IAAI,CAAC,UAAU;aAC5B;SACF,CAAC;IACJ,CAAC;CACF;AAhFD,oBAgFC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,cAAe,SAAQ,KAAK;IAED;IADpB,IAAI,GAAG,gBAAgB,CAAC;IAC1C,YAAY,OAAe,EAAW,YAAoB;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QADqB,iBAAY,GAAZ,YAAY,CAAQ;IAE1D,CAAC;CACF;AALD,wCAKC"}
|
package/dist/agent-pool.d.ts
CHANGED
|
@@ -116,17 +116,17 @@ export declare class ContextPressure {
|
|
|
116
116
|
* @param opts - Pool configuration: tasks, tools, sampling params, max turns
|
|
117
117
|
* @returns Agent pool result with per-agent findings and aggregate statistics
|
|
118
118
|
*
|
|
119
|
-
* @example
|
|
119
|
+
* @example Spine with agent pool
|
|
120
120
|
* ```typescript
|
|
121
|
-
* const pool = yield*
|
|
121
|
+
* const pool = yield* withSpine(
|
|
122
122
|
* { systemPrompt: RESEARCH_PROMPT, tools: toolsJson },
|
|
123
|
-
* function*(
|
|
123
|
+
* function*(spine) {
|
|
124
124
|
* return yield* useAgentPool({
|
|
125
125
|
* tasks: questions.map(q => ({
|
|
126
126
|
* systemPrompt: RESEARCH_PROMPT,
|
|
127
127
|
* content: q,
|
|
128
128
|
* tools: toolsJson,
|
|
129
|
-
* parent:
|
|
129
|
+
* parent: spine,
|
|
130
130
|
* })),
|
|
131
131
|
* tools: toolMap,
|
|
132
132
|
* maxTurns: 6,
|
package/dist/agent-pool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-pool.d.ts","sourceRoot":"","sources":["../src/agent-pool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzD,OAAO,
|
|
1
|
+
{"version":3,"file":"agent-pool.d.ts","sourceRoot":"","sources":["../src/agent-pool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzD,OAAO,EAA0F,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAY/I,OAAO,KAAK,EACV,kBAAkB,EAElB,gBAAgB,EAChB,eAAe,EACf,UAAU,EAEX,MAAM,SAAS,CAAC;AAsBjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,qBAAa,eAAe;IAC1B,kEAAkE;IAClE,MAAM,CAAC,QAAQ,CAAC,kBAAkB,QAAQ;IAC1C;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,kBAAkB,OAAO;IACzC;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,eAAe,OAAO;IAEtC,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,wEAAwE;IACxE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBAEf,GAAG,EAAE,cAAc,EAAE,IAAI,CAAC,EAAE,kBAAkB;IAS1D;;;;OAIG;IACH,IAAI,QAAQ,IAAI,MAAM,CAA4C;IAElE,qEAAqE;IACrE,IAAI,QAAQ,IAAI,OAAO,CAA4C;IAEnE,iEAAiE;IACjE,MAAM,CAAC,U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