@wrongstack/core 0.63.4 → 0.66.13
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-bridge-B5rxWrg3.d.ts → agent-bridge-D-j6OOBT.d.ts} +1 -1
- package/dist/agent-subagent-runner-DRZ9-NnR.d.ts +1042 -0
- package/dist/{compactor-0vjZ8KTk.d.ts → compactor-D_ExJajC.d.ts} +1 -1
- package/dist/{config-BdDuaZmB.d.ts → config--86aHSln.d.ts} +1 -1
- package/dist/{context-iFMEO2rN.d.ts → context-y87Jc5ei.d.ts} +3 -3
- package/dist/coordination/index.d.ts +12 -12
- package/dist/coordination/index.js +87 -69
- package/dist/coordination/index.js.map +1 -1
- package/dist/defaults/index.d.ts +22 -22
- package/dist/defaults/index.js +113 -84
- package/dist/defaults/index.js.map +1 -1
- package/dist/{events-k8CHjcrN.d.ts → events-CIplI98R.d.ts} +1 -1
- package/dist/execution/index.d.ts +16 -385
- package/dist/execution/index.js +59 -51
- package/dist/execution/index.js.map +1 -1
- package/dist/extension/index.d.ts +6 -6
- package/dist/goal-store-C7jcumEh.d.ts +96 -0
- package/dist/{index-Bc6BiP5q.d.ts → index-DKUvyTvV.d.ts} +28 -442
- package/dist/{index-CWdW_CJt.d.ts → index-b5uhfTSl.d.ts} +8 -8
- package/dist/index.d.ts +34 -32
- package/dist/index.js +647 -677
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.d.ts +6 -6
- package/dist/kernel/index.d.ts +9 -9
- package/dist/{mcp-servers-CwqQDMYy.d.ts → mcp-servers-DwoNBf6r.d.ts} +3 -3
- package/dist/models/index.d.ts +2 -2
- package/dist/{multi-agent-coordinator-CNUJYq7U.d.ts → multi-agent-coordinator-CWnH-CiX.d.ts} +10 -2
- package/dist/{null-fleet-bus-DRoJ0uOY.d.ts → null-fleet-bus-VApKRxcp.d.ts} +6 -7
- package/dist/observability/index.d.ts +2 -2
- package/dist/parallel-eternal-engine-0UwotoSx.d.ts +483 -0
- package/dist/{path-resolver-C5sPVne8.d.ts → path-resolver-DVkEcIw8.d.ts} +2 -2
- package/dist/{permission-Ld-i5ugf.d.ts → permission-C1A5whY5.d.ts} +5 -1
- package/dist/{permission-policy-CL-mPufp.d.ts → permission-policy-B2dK-T5N.d.ts} +19 -5
- package/dist/{plan-templates-ThBHOjaM.d.ts → plan-templates-Bprrzhbu.d.ts} +4 -4
- package/dist/{provider-runner-DJQa211J.d.ts → provider-runner-mXvXGSIw.d.ts} +3 -3
- package/dist/{retry-policy-BfBScewS.d.ts → retry-policy-CG3qvH_e.d.ts} +1 -1
- package/dist/sdd/index.d.ts +8 -8
- package/dist/sdd/index.js +58 -51
- package/dist/sdd/index.js.map +1 -1
- package/dist/security/index.d.ts +3 -3
- package/dist/security/index.js +31 -22
- package/dist/security/index.js.map +1 -1
- package/dist/{selector-DxhW7ML3.d.ts → selector-RvBR_YRW.d.ts} +1 -1
- package/dist/session-event-bridge-CDHxcmQU.d.ts +93 -0
- package/dist/{session-reader-q2ThszgG.d.ts → session-reader-BIpwM60D.d.ts} +1 -1
- package/dist/storage/index.d.ts +7 -6
- package/dist/{system-prompt-7LHyBbIf.d.ts → system-prompt-b61lOd49.d.ts} +2 -2
- package/dist/types/index.d.ts +23 -14
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/multi-agent/SKILL.md +0 -2
- package/dist/agent-subagent-runner-Zc3f37Sg.d.ts +0 -182
- package/dist/goal-store-iHltMi5n.d.ts +0 -188
- package/dist/multi-agent-SASYOrWA.d.ts +0 -554
- package/dist/tool-executor-CIjpGaRA.d.ts +0 -111
|
@@ -1,554 +0,0 @@
|
|
|
1
|
-
import { $ as Usage } from './context-iFMEO2rN.js';
|
|
2
|
-
import { E as EventBus } from './events-k8CHjcrN.js';
|
|
3
|
-
|
|
4
|
-
type BridgeMessageType = 'task' | 'result' | 'progress' | 'error' | 'heartbeat' | 'stop' | 'delegate' | 'budget_threshold';
|
|
5
|
-
interface BridgeMessage<T = unknown> {
|
|
6
|
-
id: string;
|
|
7
|
-
type: BridgeMessageType;
|
|
8
|
-
from: string;
|
|
9
|
-
to?: string;
|
|
10
|
-
payload: T;
|
|
11
|
-
timestamp: number;
|
|
12
|
-
priority?: 'low' | 'normal' | 'high' | 'critical';
|
|
13
|
-
}
|
|
14
|
-
interface AgentBridgeConfig {
|
|
15
|
-
agentId: string;
|
|
16
|
-
coordinatorId: string;
|
|
17
|
-
timeoutMs?: number;
|
|
18
|
-
bufferSize?: number;
|
|
19
|
-
}
|
|
20
|
-
interface AgentBridge {
|
|
21
|
-
readonly agentId: string;
|
|
22
|
-
readonly coordinatorId: string;
|
|
23
|
-
send(msg: BridgeMessage): Promise<void>;
|
|
24
|
-
broadcast(msg: BridgeMessage): Promise<void>;
|
|
25
|
-
subscribe(handler: (msg: BridgeMessage) => void | Promise<void>): () => void;
|
|
26
|
-
request<T>(msg: BridgeMessage, timeoutMs?: number): Promise<BridgeMessage<T>>;
|
|
27
|
-
stop(): Promise<void>;
|
|
28
|
-
}
|
|
29
|
-
interface BridgeTransport {
|
|
30
|
-
send(msg: BridgeMessage, to: string): Promise<void>;
|
|
31
|
-
subscribe(agentId: string, handler: (msg: BridgeMessage) => void | Promise<void>): () => void;
|
|
32
|
-
close(agentId: string): Promise<void>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
type BudgetKind = 'tool_calls' | 'iterations' | 'tokens' | 'timeout' | 'idle_timeout' | 'cost';
|
|
36
|
-
declare class BudgetExceededError extends Error {
|
|
37
|
-
readonly kind: BudgetKind;
|
|
38
|
-
readonly limit: number;
|
|
39
|
-
readonly observed: number;
|
|
40
|
-
constructor(kind: BudgetKind, limit: number, observed: number);
|
|
41
|
-
}
|
|
42
|
-
interface BudgetLimits {
|
|
43
|
-
maxIterations?: number;
|
|
44
|
-
maxToolCalls?: number;
|
|
45
|
-
maxTokens?: number;
|
|
46
|
-
/** Estimated USD cost ceiling. */
|
|
47
|
-
maxCostUsd?: number;
|
|
48
|
-
/**
|
|
49
|
-
* Hard wall-clock timeout measured from `start()`. Off by default — set it
|
|
50
|
-
* explicitly only when a task must finish within an absolute window. For
|
|
51
|
-
* the everyday "don't kill an agent that's still working" guard, prefer
|
|
52
|
-
* `idleTimeoutMs`, which resets on activity.
|
|
53
|
-
*/
|
|
54
|
-
timeoutMs?: number;
|
|
55
|
-
/**
|
|
56
|
-
* Idle timeout: the maximum gap (ms) between activity signals (iterations,
|
|
57
|
-
* tool calls, token usage, streamed progress) before the subagent is
|
|
58
|
-
* considered hung and reaped. Unlike `timeoutMs`, an actively-working
|
|
59
|
-
* agent continuously resets this clock via `markActivity()`, so it never
|
|
60
|
-
* trips on a long-but-productive run — only on a genuine stall.
|
|
61
|
-
*/
|
|
62
|
-
idleTimeoutMs?: number;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Controls how the budget behaves when `onThreshold` is set and a limit is hit.
|
|
66
|
-
*
|
|
67
|
-
* `'auto'` — emit `budget.threshold_reached` on the EventBus and wait for a
|
|
68
|
-
* coordinator response (extend/stop). If no listener responds within
|
|
69
|
-
* `DECISION_TIMEOUT_MS` the decision defaults to `'stop'`.
|
|
70
|
-
* `'sync'` — do not emit any event; treat the threshold as a hard stop and
|
|
71
|
-
* throw `BudgetExceededError` synchronously. Useful for fire-and-forget
|
|
72
|
-
* subagents that have an `onThreshold` handler for logging/metrics but are
|
|
73
|
-
* not wired into a coordinator.
|
|
74
|
-
*
|
|
75
|
-
* @default 'auto'
|
|
76
|
-
*/
|
|
77
|
-
type BudgetNegotiationMode = 'auto' | 'sync';
|
|
78
|
-
interface BudgetUsage {
|
|
79
|
-
iterations: number;
|
|
80
|
-
toolCalls: number;
|
|
81
|
-
tokens: {
|
|
82
|
-
input: number;
|
|
83
|
-
output: number;
|
|
84
|
-
total: number;
|
|
85
|
-
};
|
|
86
|
-
costUsd: number;
|
|
87
|
-
elapsedMs: number;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Thrown by `SubagentBudget.record*` when a soft limit is hit and
|
|
91
|
-
* an `onThreshold` handler is configured that wants to ask the
|
|
92
|
-
* coordinator (via `budget.threshold_reached` event). The runner
|
|
93
|
-
* catches this and awaits the embedded `decision` promise to get
|
|
94
|
-
* the coordinator's extend/stop decision.
|
|
95
|
-
*
|
|
96
|
-
* Distinct from `BudgetExceededError` which is a hard stop.
|
|
97
|
-
*/
|
|
98
|
-
declare class BudgetThresholdSignal extends Error {
|
|
99
|
-
readonly kind: BudgetKind;
|
|
100
|
-
readonly limit: number;
|
|
101
|
-
readonly used: number;
|
|
102
|
-
/** Resolves to 'extend' (with optional new limits) or 'stop' */
|
|
103
|
-
readonly decision: Promise<BudgetThresholdDecision>;
|
|
104
|
-
constructor(kind: BudgetKind, limit: number, used: number, decision: Promise<BudgetThresholdDecision>);
|
|
105
|
-
}
|
|
106
|
-
type BudgetThresholdDecision = 'stop' | {
|
|
107
|
-
extend: Partial<BudgetLimits>;
|
|
108
|
-
};
|
|
109
|
-
/**
|
|
110
|
-
* Callback invoked when a budget limit is about to be exceeded.
|
|
111
|
-
* Return 'throw' for hard stop (default — throws BudgetExceededError).
|
|
112
|
-
* Return 'continue' to allow one more unit and re-check next time.
|
|
113
|
-
* Return a Promise to ask the coordinator via `budget.threshold_reached`
|
|
114
|
-
* event (uses the same grant/deny pattern as `iteration.limit_reached`).
|
|
115
|
-
*/
|
|
116
|
-
type BudgetThresholdHandler = (info: {
|
|
117
|
-
kind: BudgetKind;
|
|
118
|
-
used: number;
|
|
119
|
-
limit: number;
|
|
120
|
-
requestDecision: () => Promise<BudgetThresholdDecision>;
|
|
121
|
-
}) => 'throw' | 'continue' | Promise<BudgetThresholdDecision>;
|
|
122
|
-
/**
|
|
123
|
-
* Per-subagent budget enforcement. Each subagent gets its own instance so a
|
|
124
|
-
* runaway agent can't drain the cost ceiling of its siblings. All record/check
|
|
125
|
-
* methods are O(1) and safe to call from hot paths.
|
|
126
|
-
*
|
|
127
|
-
* Behavior without `onThreshold`: hard stops synchronously on every limit hit.
|
|
128
|
-
*
|
|
129
|
-
* Behavior with `onThreshold` and `_mode === 'auto'`: emits `budget.threshold_reached`
|
|
130
|
-
* on the EventBus and throws `BudgetThresholdSignal`. The coordinator's verdict
|
|
131
|
-
* (extend/stop) resolves the embedded promise. If no listener responds within
|
|
132
|
-
* `DECISION_TIMEOUT_MS` the decision defaults to `'stop'`.
|
|
133
|
-
*
|
|
134
|
-
* Behavior with `onThreshold` and `_mode === 'sync'`: throws `BudgetExceededError`
|
|
135
|
-
* synchronously regardless of EventBus state or listener presence. This is useful
|
|
136
|
-
* for fire-and-forget subagents that have an `onThreshold` handler for logging/metrics
|
|
137
|
-
* but are not wired into a coordinator — the `'sync'` mode makes the hard-stop
|
|
138
|
-
* behavior explicit and means tests can use `expect().toThrow()` even without
|
|
139
|
-
* a fully-wired EventBus.
|
|
140
|
-
*/
|
|
141
|
-
declare class SubagentBudget {
|
|
142
|
-
readonly limits: Readonly<BudgetLimits>;
|
|
143
|
-
private iterations;
|
|
144
|
-
private toolCalls;
|
|
145
|
-
private tokenInput;
|
|
146
|
-
private tokenOutput;
|
|
147
|
-
private costUsd;
|
|
148
|
-
private startTime;
|
|
149
|
-
/**
|
|
150
|
-
* Timestamp of the most recent activity (iteration / tool call / token
|
|
151
|
-
* usage / streamed progress). Drives the idle timeout — reset by
|
|
152
|
-
* `markActivity()`. Initialised to `start()` time so a never-active agent
|
|
153
|
-
* still eventually trips its idle window.
|
|
154
|
-
*/
|
|
155
|
-
private lastActivityTime;
|
|
156
|
-
private _onThreshold;
|
|
157
|
-
/**
|
|
158
|
-
* Hard cap on how long `_negotiateExtension` waits for the coordinator to
|
|
159
|
-
* respond before defaulting to 'stop'. Without this fallback an absent
|
|
160
|
-
* or hung listener (Director not built / event filter detached mid-run)
|
|
161
|
-
* leaves the budget over-limit and never enforces anything.
|
|
162
|
-
*/
|
|
163
|
-
private static readonly DECISION_TIMEOUT_MS;
|
|
164
|
-
/**
|
|
165
|
-
* Injected by the runner when wiring the budget to its EventBus.
|
|
166
|
-
* Used to emit `budget.threshold_reached` events in `'auto'` mode.
|
|
167
|
-
*/
|
|
168
|
-
_events?: EventBus;
|
|
169
|
-
/**
|
|
170
|
-
* Negotiation mode — controls whether a threshold hit tries to emit
|
|
171
|
-
* `budget.threshold_reached` and wait for a coordinator decision, or
|
|
172
|
-
* falls straight through to a synchronous hard stop.
|
|
173
|
-
*
|
|
174
|
-
* `'auto'` (default) — emit on the EventBus and wait; times out to 'stop'.
|
|
175
|
-
* `'sync'` — throw `BudgetExceededError` immediately regardless of listeners.
|
|
176
|
-
*/
|
|
177
|
-
private _mode;
|
|
178
|
-
/**
|
|
179
|
-
* Optional callback for soft-limit handling. When set, the budget will
|
|
180
|
-
* invoke it rather than throw immediately. The handler decides whether to
|
|
181
|
-
* throw synchronously, continue, or ask the coordinator for an extension.
|
|
182
|
-
*/
|
|
183
|
-
get onThreshold(): BudgetThresholdHandler | undefined;
|
|
184
|
-
set onThreshold(fn: BudgetThresholdHandler | undefined);
|
|
185
|
-
/** Returns the current negotiation mode. */
|
|
186
|
-
get mode(): BudgetNegotiationMode;
|
|
187
|
-
constructor(limits?: BudgetLimits, mode?: BudgetNegotiationMode);
|
|
188
|
-
start(): void;
|
|
189
|
-
/**
|
|
190
|
-
* Reset the idle clock. Called on any sign of forward progress —
|
|
191
|
-
* iterations, tool calls, token usage, and streamed tool/text progress —
|
|
192
|
-
* so a long-but-productive subagent never trips its `idleTimeoutMs`.
|
|
193
|
-
*/
|
|
194
|
-
markActivity(): void;
|
|
195
|
-
/**
|
|
196
|
-
* Milliseconds since the last activity signal. Returns 0 before `start()`
|
|
197
|
-
* (nothing to measure yet). Used by the coordinator watchdog to decide
|
|
198
|
-
* whether to re-arm (still active) or reap (genuinely idle).
|
|
199
|
-
*/
|
|
200
|
-
idleMs(): number;
|
|
201
|
-
/** Returns true if we're within 10% of any limit — useful for pre-flight checks. */
|
|
202
|
-
isNearLimit(): boolean;
|
|
203
|
-
/**
|
|
204
|
-
* Synchronous budget check. Always throws synchronously so callers (especially
|
|
205
|
-
* test event handlers using `expect().toThrow()`) get an unhandled rejection
|
|
206
|
-
* when the budget is exceeded without a handler.
|
|
207
|
-
*
|
|
208
|
-
* Decision table:
|
|
209
|
-
* - no `onThreshold` handler → throw `BudgetExceededError` (hard stop, always)
|
|
210
|
-
* - `mode === 'sync'` → throw `BudgetExceededError` (hard stop, always)
|
|
211
|
-
* - `mode === 'auto'` + no listener → throw `BudgetExceededError` (hard stop; no one to ask)
|
|
212
|
-
* - `mode === 'auto'` + listener → throw `BudgetThresholdSignal` with async decision promise
|
|
213
|
-
*/
|
|
214
|
-
/**
|
|
215
|
-
* Collects all exceeded budget kinds into a single NOOP-free negotiation.
|
|
216
|
-
* Called by recordIteration / recordToolCall / recordUsage — each may call
|
|
217
|
-
* this for its own kind. The first call starts the negotiation and stores
|
|
218
|
-
* the Promise in _pendingNegotiation. Subsequent calls for DIFFERENT
|
|
219
|
-
* kinds (while a negotiation is in flight) are NOOPs — they don't start
|
|
220
|
-
* new conversations with the coordinator. This prevents an EventBus flood
|
|
221
|
-
* when multiple budget kinds are exceeded simultaneously in one iteration.
|
|
222
|
-
*
|
|
223
|
-
* Returns the kinds that were found to be exceeded (for logging/debugging).
|
|
224
|
-
*/
|
|
225
|
-
private checkLimits;
|
|
226
|
-
/**
|
|
227
|
-
* Per-kind in-flight negotiation Promises. Each budget kind can have its
|
|
228
|
-
* own concurrent negotiation — e.g. iterations and timeout can both
|
|
229
|
-
* be exceeded simultaneously without blocking each other. The same kind
|
|
230
|
-
* cannot start two concurrent negotiations (dedup guard).
|
|
231
|
-
* Cleared in `_negotiateExtension`'s `finally` block.
|
|
232
|
-
*/
|
|
233
|
-
private _pendingNegotiations;
|
|
234
|
-
/**
|
|
235
|
-
* Drive the threshold handler to a decision. Resolves with `'stop'`
|
|
236
|
-
* (signal the runner to abort) or `{ extend: ... }` (limits already
|
|
237
|
-
* patched in-place; the runner should not abort). Clears the
|
|
238
|
-
* per-kind slot in `_pendingNegotiations` in `finally`.
|
|
239
|
-
*
|
|
240
|
-
* The 'continue' return from a sync handler is treated as
|
|
241
|
-
* `{ extend: {} }` — keep going without patching; next overrun fires
|
|
242
|
-
* a fresh signal.
|
|
243
|
-
*/
|
|
244
|
-
private _negotiateExtension;
|
|
245
|
-
recordIteration(): void;
|
|
246
|
-
recordToolCall(): void;
|
|
247
|
-
recordUsage(usage: Usage, costUsd?: number): void;
|
|
248
|
-
/**
|
|
249
|
-
* Wall-clock budget check. Unlike other limits, timeout is always a hard stop
|
|
250
|
-
* — wall-clock time cannot be "extended" by the coordinator, so it throws
|
|
251
|
-
* synchronously rather than entering the negotiation flow.
|
|
252
|
-
*
|
|
253
|
-
* Decision table:
|
|
254
|
-
* - no `onThreshold` handler → throw `BudgetExceededError`
|
|
255
|
-
* - `mode === 'sync'` → throw `BudgetExceededError`
|
|
256
|
-
* - `mode === 'auto'` + no listener → throw `BudgetExceededError`
|
|
257
|
-
* - `mode === 'auto'` + listener → throw `BudgetExceededError` (timeout is not extendable)
|
|
258
|
-
*/
|
|
259
|
-
checkTimeout(): void;
|
|
260
|
-
/** Returns true if a wall-clock or idle timeout has occurred without throwing. */
|
|
261
|
-
isTimedOut(): boolean;
|
|
262
|
-
usage(): BudgetUsage;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
interface SubagentConfig {
|
|
266
|
-
id?: string;
|
|
267
|
-
name: string;
|
|
268
|
-
role?: string;
|
|
269
|
-
prompt?: string;
|
|
270
|
-
maxIterations?: number;
|
|
271
|
-
maxToolCalls?: number;
|
|
272
|
-
maxTokens?: number;
|
|
273
|
-
maxCostUsd?: number;
|
|
274
|
-
/** Hard wall-clock cap (ms) from start. Opt-in; prefer `idleTimeoutMs`. */
|
|
275
|
-
timeoutMs?: number;
|
|
276
|
-
/**
|
|
277
|
-
* Idle timeout (ms): reap the subagent only after this long with no
|
|
278
|
-
* activity. Resets on every iteration / tool call / streamed progress, so
|
|
279
|
-
* an actively-working agent runs until its task naturally ends. This is the
|
|
280
|
-
* default reaper for delegated subagents (see `applyRosterBudget`).
|
|
281
|
-
*/
|
|
282
|
-
idleTimeoutMs?: number;
|
|
283
|
-
tools?: string[];
|
|
284
|
-
model?: string;
|
|
285
|
-
priority?: number;
|
|
286
|
-
/**
|
|
287
|
-
* Working directory for this subagent's tools. Defaults to the factory's
|
|
288
|
-
* cwd. AutoPhase sets this to a per-phase git worktree so parallel phases
|
|
289
|
-
* edit isolated checkouts instead of clobbering one shared working tree.
|
|
290
|
-
* `projectRoot` is intentionally left unchanged — tools resolve the
|
|
291
|
-
* worktree's `.git` gitlink from `cwd` while staying bounded to the repo.
|
|
292
|
-
*/
|
|
293
|
-
cwd?: string;
|
|
294
|
-
/**
|
|
295
|
-
* Provider registry id (e.g. `'anthropic'`, `'openai'`, `'google'`).
|
|
296
|
-
* Allows a director to mix providers across siblings — one subagent on
|
|
297
|
-
* Sonnet, another on GPT-5, another on Haiku. Falls back to the
|
|
298
|
-
* factory's default provider when omitted, which is the legacy
|
|
299
|
-
* single-provider behavior.
|
|
300
|
-
*/
|
|
301
|
-
provider?: string;
|
|
302
|
-
/**
|
|
303
|
-
* Per-subagent session JSONL path. When omitted the orchestrator-
|
|
304
|
-
* supplied factory derives a path under `<sessionRoot>/<runId>/`.
|
|
305
|
-
* Override to redirect the transcript elsewhere (long-term storage,
|
|
306
|
-
* a different filesystem, etc.).
|
|
307
|
-
*/
|
|
308
|
-
sessionPath?: string;
|
|
309
|
-
/**
|
|
310
|
-
* Additional text appended to the role's base system prompt. Does not
|
|
311
|
-
* replace it. Useful for last-mile guidance like "you may only call
|
|
312
|
-
* read tools, never write" or "respond in JSON only".
|
|
313
|
-
*/
|
|
314
|
-
systemPromptOverride?: string;
|
|
315
|
-
/**
|
|
316
|
-
* Routing for streaming output. `'director'` (default) forwards
|
|
317
|
-
* text/tool events to the parent's FleetBus so the director can read
|
|
318
|
-
* the subagent's stream. `'silent'` keeps everything subagent-local;
|
|
319
|
-
* the director only sees the final task result. `'user'` forwards
|
|
320
|
-
* direct to the user-facing renderer (gate this behind an explicit
|
|
321
|
-
* config flag — it can confuse the chat surface).
|
|
322
|
-
*/
|
|
323
|
-
textStream?: 'director' | 'silent' | 'user';
|
|
324
|
-
toolStream?: 'director' | 'silent' | 'user';
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Discriminator for every distinct failure mode a subagent can hit. The
|
|
328
|
-
* coordinator's classifier (`classifySubagentError` in
|
|
329
|
-
* coordination/multi-agent-coordinator.ts) maps raw exceptions to one of
|
|
330
|
-
* these — callers (delegate tool, /agents UI, retry policies) can then
|
|
331
|
-
* branch on `kind` instead of grepping `error.message`. Each kind
|
|
332
|
-
* documents its retryability so an orchestrator can act on it without
|
|
333
|
-
* extra knowledge.
|
|
334
|
-
*/
|
|
335
|
-
type SubagentErrorKind =
|
|
336
|
-
/** Provider returned 5xx. Transient server-side issue — safe to retry with backoff. */
|
|
337
|
-
'provider_5xx'
|
|
338
|
-
/** Provider returned 429. Rate-limited — retry with `backoffMs` delay. */
|
|
339
|
-
| 'provider_rate_limit'
|
|
340
|
-
/** Provider call timed out at the network layer (TCP / TLS / read). Retry safe. */
|
|
341
|
-
| 'provider_timeout'
|
|
342
|
-
/** Provider rejected the credentials (401/403). NOT retryable — config fix required. */
|
|
343
|
-
| 'provider_auth'
|
|
344
|
-
/** Model returned a "context length exceeded" error. Retrying without trimming will fail again. */
|
|
345
|
-
| 'context_overflow'
|
|
346
|
-
/** A tool's `execute()` returned `ok:false`. Logical task failure, not a crash. */
|
|
347
|
-
| 'tool_failed'
|
|
348
|
-
/** A tool's `execute()` threw an exception. Often retryable but cause-dependent. */
|
|
349
|
-
| 'tool_threw'
|
|
350
|
-
/** Hit the per-subagent `maxIterations` budget. Either raise budget or narrow task. */
|
|
351
|
-
| 'budget_iterations'
|
|
352
|
-
/** Hit the per-subagent `maxToolCalls` budget. Either raise budget or narrow task. */
|
|
353
|
-
| 'budget_tool_calls'
|
|
354
|
-
/** Hit the per-subagent `maxTokens` budget. */
|
|
355
|
-
| 'budget_tokens'
|
|
356
|
-
/** Hit the per-subagent `maxCostUsd` budget. */
|
|
357
|
-
| 'budget_cost'
|
|
358
|
-
/** Hit the per-subagent `timeoutMs` wall-clock budget. */
|
|
359
|
-
| 'budget_timeout'
|
|
360
|
-
/** Parent agent's AbortController fired (user Ctrl+C, parent unwound, sibling failure cascade). */
|
|
361
|
-
| 'aborted_by_parent'
|
|
362
|
-
/** LLM returned end_turn with no textual content. Often a prompt issue. */
|
|
363
|
-
| 'empty_response'
|
|
364
|
-
/** Parent-child bridge transport failed (rare — IPC / writer crash). */
|
|
365
|
-
| 'bridge_failed'
|
|
366
|
-
/** Everything else. Classifier fallback — should narrow over time as new modes appear. */
|
|
367
|
-
| 'unknown';
|
|
368
|
-
/**
|
|
369
|
-
* Structured failure envelope. Replaces the prior `error?: string` so
|
|
370
|
-
* callers can switch on `kind`, respect `retryable`, and apply
|
|
371
|
-
* provider-suggested `backoffMs` instead of guessing from substring
|
|
372
|
-
* matches on the message.
|
|
373
|
-
*/
|
|
374
|
-
interface SubagentError {
|
|
375
|
-
/** Discriminator — see SubagentErrorKind doc strings for semantics. */
|
|
376
|
-
kind: SubagentErrorKind;
|
|
377
|
-
/** Human-readable summary, suitable for direct UI display. Always populated. */
|
|
378
|
-
message: string;
|
|
379
|
-
/** True if the operation can be retried as-is (possibly with backoff). */
|
|
380
|
-
retryable: boolean;
|
|
381
|
-
/** Suggested backoff before retry, in ms. Set for `provider_rate_limit` and `provider_5xx`. */
|
|
382
|
-
backoffMs?: number;
|
|
383
|
-
/** Original cause snapshot for diagnostics — never used for control flow. */
|
|
384
|
-
cause?: {
|
|
385
|
-
name: string;
|
|
386
|
-
message: string;
|
|
387
|
-
stack?: string;
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
interface TaskResult<T = unknown> {
|
|
391
|
-
subagentId: string;
|
|
392
|
-
taskId: string;
|
|
393
|
-
status: 'success' | 'failed' | 'timeout' | 'stopped';
|
|
394
|
-
result?: T;
|
|
395
|
-
/**
|
|
396
|
-
* Structured failure envelope. Populated whenever `status !== 'success'`.
|
|
397
|
-
* Prefer reading `error.kind` over substring-matching `error.message`.
|
|
398
|
-
*/
|
|
399
|
-
error?: SubagentError;
|
|
400
|
-
iterations: number;
|
|
401
|
-
toolCalls: number;
|
|
402
|
-
durationMs: number;
|
|
403
|
-
}
|
|
404
|
-
interface TaskSpec {
|
|
405
|
-
id: string;
|
|
406
|
-
description: string;
|
|
407
|
-
subagentId?: string;
|
|
408
|
-
priority?: number;
|
|
409
|
-
maxToolCalls?: number;
|
|
410
|
-
timeoutMs?: number;
|
|
411
|
-
context?: Record<string, unknown>;
|
|
412
|
-
}
|
|
413
|
-
interface DoneCondition {
|
|
414
|
-
type: 'iterations' | 'tool_calls' | 'output_match' | 'custom' | 'all_tasks_done' | 'directive';
|
|
415
|
-
maxIterations?: number;
|
|
416
|
-
maxToolCalls?: number;
|
|
417
|
-
pattern?: string;
|
|
418
|
-
predicate?: string;
|
|
419
|
-
/**
|
|
420
|
-
* For `directive` type — stop when model emits [done] and keep going
|
|
421
|
-
* on [continue]/[next step]/[proceed] WITHOUT returning to the outer runner.
|
|
422
|
-
* When false (default), the runner behaves normally (one agent.run per loop).
|
|
423
|
-
* When true, the runner passes `autonomousContinue: true` to the agent and
|
|
424
|
-
* re-runs internally when the model signals continue.
|
|
425
|
-
*/
|
|
426
|
-
autonomous?: boolean;
|
|
427
|
-
}
|
|
428
|
-
interface MultiAgentConfig {
|
|
429
|
-
coordinatorId: string;
|
|
430
|
-
leaderSystemPrompt?: string;
|
|
431
|
-
subagents?: SubagentConfig[];
|
|
432
|
-
maxConcurrent?: number;
|
|
433
|
-
doneCondition: DoneCondition;
|
|
434
|
-
timeoutMs?: number;
|
|
435
|
-
/**
|
|
436
|
-
* Optional default budget applied to every spawned subagent. Per-subagent
|
|
437
|
-
* fields in `SubagentConfig` override these. Coordinator enforces them by
|
|
438
|
-
* constructing a `SubagentBudget` per spawn — see `SubagentRunContext.budget`.
|
|
439
|
-
*/
|
|
440
|
-
defaultBudget?: {
|
|
441
|
-
maxIterations?: number;
|
|
442
|
-
maxToolCalls?: number;
|
|
443
|
-
maxTokens?: number;
|
|
444
|
-
maxCostUsd?: number;
|
|
445
|
-
timeoutMs?: number;
|
|
446
|
-
idleTimeoutMs?: number;
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
interface SpawnResult {
|
|
450
|
-
subagentId: string;
|
|
451
|
-
agentId: string;
|
|
452
|
-
}
|
|
453
|
-
interface TaskDelegation {
|
|
454
|
-
task: TaskSpec;
|
|
455
|
-
subagentId: string;
|
|
456
|
-
}
|
|
457
|
-
interface CoordinatorEvents {
|
|
458
|
-
'task.assigned': {
|
|
459
|
-
task: TaskSpec;
|
|
460
|
-
subagentId: string;
|
|
461
|
-
};
|
|
462
|
-
'task.completed': {
|
|
463
|
-
task: TaskSpec;
|
|
464
|
-
result: TaskResult;
|
|
465
|
-
};
|
|
466
|
-
'subagent.started': {
|
|
467
|
-
subagent: SubagentConfig;
|
|
468
|
-
};
|
|
469
|
-
'subagent.stopped': {
|
|
470
|
-
subagentId: string;
|
|
471
|
-
reason: string;
|
|
472
|
-
};
|
|
473
|
-
done: {
|
|
474
|
-
results: TaskResult[];
|
|
475
|
-
totalIterations: number;
|
|
476
|
-
};
|
|
477
|
-
}
|
|
478
|
-
interface MultiAgentCoordinator {
|
|
479
|
-
readonly coordinatorId: string;
|
|
480
|
-
readonly config: MultiAgentConfig;
|
|
481
|
-
spawn(subagent: SubagentConfig): Promise<SpawnResult>;
|
|
482
|
-
assign(task: TaskSpec): Promise<void>;
|
|
483
|
-
delegate(to: string, msg: BridgeMessage): Promise<void>;
|
|
484
|
-
stop(subagentId: string): Promise<void>;
|
|
485
|
-
stopAll(): Promise<void>;
|
|
486
|
-
/**
|
|
487
|
-
* Stop a subagent and remove it from the coordinator. Releases all
|
|
488
|
-
* associated resources. The subagent id can be reused in a future spawn.
|
|
489
|
-
*/
|
|
490
|
-
remove(subagentId: string): Promise<void>;
|
|
491
|
-
getStatus(): CoordinatorStatus;
|
|
492
|
-
/**
|
|
493
|
-
* Wait for one or more tasks to complete and return their results.
|
|
494
|
-
* If a task is already done when called, returns immediately.
|
|
495
|
-
* Resolves to an array in the same order as `taskIds`.
|
|
496
|
-
*/
|
|
497
|
-
awaitTasks(taskIds: string[]): Promise<TaskResult[]>;
|
|
498
|
-
/** Snapshot of completed task results. */
|
|
499
|
-
results(): readonly TaskResult[];
|
|
500
|
-
}
|
|
501
|
-
/**
|
|
502
|
-
* Caller-supplied runner that actually executes a task. The coordinator
|
|
503
|
-
* provides isolated state (own budget, own AbortSignal, own bridge handle)
|
|
504
|
-
* and enforces concurrency limits — the runner just runs the task and reports
|
|
505
|
-
* the outcome. This is the injection seam that decouples the coordinator
|
|
506
|
-
* from `Agent` so it can be tested with mocks and reused for non-Agent
|
|
507
|
-
* subagents (workers, MCP-driven subagents, etc.).
|
|
508
|
-
*/
|
|
509
|
-
type SubagentRunner = (task: TaskSpec, ctx: SubagentRunContext) => Promise<SubagentRunOutcome>;
|
|
510
|
-
interface SubagentRunContext {
|
|
511
|
-
subagentId: string;
|
|
512
|
-
config: SubagentConfig;
|
|
513
|
-
budget: SubagentBudget;
|
|
514
|
-
signal: AbortSignal;
|
|
515
|
-
/** Null until `setSubagentBridge` is called for this subagent. */
|
|
516
|
-
bridge: AgentBridge | null;
|
|
517
|
-
}
|
|
518
|
-
interface SubagentRunOutcome {
|
|
519
|
-
result?: unknown;
|
|
520
|
-
iterations: number;
|
|
521
|
-
toolCalls: number;
|
|
522
|
-
}
|
|
523
|
-
interface CoordinatorStatus {
|
|
524
|
-
coordinatorId: string;
|
|
525
|
-
subagents: {
|
|
526
|
-
id: string;
|
|
527
|
-
name: string;
|
|
528
|
-
status: 'running' | 'idle' | 'stopped' | 'error';
|
|
529
|
-
currentTask?: string;
|
|
530
|
-
/** Cumulative budget auto-extensions granted to this subagent, when the
|
|
531
|
-
* status is produced by a Director that tracks them. */
|
|
532
|
-
extensions?: number;
|
|
533
|
-
}[];
|
|
534
|
-
pendingTasks: number;
|
|
535
|
-
completedTasks: number;
|
|
536
|
-
totalIterations: number;
|
|
537
|
-
done: boolean;
|
|
538
|
-
}
|
|
539
|
-
interface SubagentContext {
|
|
540
|
-
subagentId: string;
|
|
541
|
-
tasks: TaskSpec[];
|
|
542
|
-
/**
|
|
543
|
-
* Two-phase initialization: `spawn()` creates the subagent before the
|
|
544
|
-
* bridge is wired (`setSubagentBridge()`), so `parentBridge` is nullable
|
|
545
|
-
* by design. Readers must `hasParentBridge()`-guard or null-check before
|
|
546
|
-
* use; the prior `null as unknown as AgentBridge` cast was a type lie
|
|
547
|
-
* that hid this from the compiler.
|
|
548
|
-
*/
|
|
549
|
-
parentBridge: AgentBridge | null;
|
|
550
|
-
doneCondition: DoneCondition;
|
|
551
|
-
maxConcurrent: number;
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
export { type AgentBridge as A, type BridgeMessage as B, type CoordinatorEvents as C, type DoneCondition as D, type MultiAgentConfig as M, type SpawnResult as S, type TaskDelegation as T, type AgentBridgeConfig as a, type BridgeTransport as b, BudgetExceededError as c, type BudgetKind as d, type BudgetLimits as e, type BudgetNegotiationMode as f, type BudgetThresholdDecision as g, type BudgetThresholdHandler as h, BudgetThresholdSignal as i, type BudgetUsage as j, type CoordinatorStatus as k, type MultiAgentCoordinator as l, SubagentBudget as m, type SubagentConfig as n, type SubagentContext as o, type SubagentError as p, type SubagentErrorKind as q, type SubagentRunContext as r, type SubagentRunOutcome as s, type SubagentRunner as t, type TaskResult as u, type TaskSpec as v };
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { d as Context, n as ProviderError, Q as Tool, _ as ToolUseBlock, Y as ToolResultBlock } from './context-iFMEO2rN.js';
|
|
2
|
-
import { a as Compactor, C as CompactReport } from './compactor-0vjZ8KTk.js';
|
|
3
|
-
import { R as RecoveryDecision, E as ErrorHandler, a as RetryPolicy } from './retry-policy-BfBScewS.js';
|
|
4
|
-
import { b as ModelsRegistry } from './models-registry-BcYJDKLm.js';
|
|
5
|
-
import { G as ToolExecutorOptions, I as ToolExecutorStrategy, T as ToolBatchResult } from './index-Bc6BiP5q.js';
|
|
6
|
-
|
|
7
|
-
interface CompactorOptions {
|
|
8
|
-
preserveK?: number;
|
|
9
|
-
eliseThreshold?: number;
|
|
10
|
-
estimator?: (text: string) => number;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
declare class HybridCompactor implements Compactor {
|
|
14
|
-
private readonly preserveK;
|
|
15
|
-
private readonly eliseThreshold;
|
|
16
|
-
private readonly estimator;
|
|
17
|
-
constructor(opts?: CompactorOptions);
|
|
18
|
-
compact(ctx: Context, opts?: {
|
|
19
|
-
aggressive?: boolean;
|
|
20
|
-
}): Promise<CompactReport>;
|
|
21
|
-
/**
|
|
22
|
-
* Estimate the full API request token count: messages + systemPrompt + toolDefs.
|
|
23
|
-
* This is the accurate figure for context-window pressure monitoring.
|
|
24
|
-
*/
|
|
25
|
-
private estimateFullRequest;
|
|
26
|
-
private eliseOldToolResults;
|
|
27
|
-
private collapseAncientTurns;
|
|
28
|
-
private estimateMessages;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Tiered error recovery strategies.
|
|
33
|
-
* Each strategy is attempted in order until one returns a decision.
|
|
34
|
-
*/
|
|
35
|
-
interface RecoveryStrategy {
|
|
36
|
-
/** Human-readable label for logs. */
|
|
37
|
-
label: string;
|
|
38
|
-
/** Optional compactor for context_overflow recovery. */
|
|
39
|
-
compactor?: Compactor;
|
|
40
|
-
/** Returns an explicit recovery decision, or null to fall through. */
|
|
41
|
-
attempt: (err: unknown, ctx: Context) => Promise<RecoveryDecision | null>;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Builds the ordered list of recovery strategies used by DefaultErrorHandler.
|
|
45
|
-
* Exported so callers can customise or extend the strategy chain.
|
|
46
|
-
*/
|
|
47
|
-
declare function buildRecoveryStrategies(opts?: {
|
|
48
|
-
compactor?: Compactor;
|
|
49
|
-
modelsRegistry?: ModelsRegistry;
|
|
50
|
-
}): RecoveryStrategy[];
|
|
51
|
-
declare const DEFAULT_RECOVERY_STRATEGIES: RecoveryStrategy[];
|
|
52
|
-
declare class DefaultErrorHandler implements ErrorHandler {
|
|
53
|
-
private readonly strategies;
|
|
54
|
-
constructor(strategies?: RecoveryStrategy[]);
|
|
55
|
-
classify(err: unknown): {
|
|
56
|
-
kind: 'rate_limit' | 'overloaded' | 'server' | 'client' | 'network' | 'abort' | 'context_overflow' | 'unknown';
|
|
57
|
-
retryable: boolean;
|
|
58
|
-
};
|
|
59
|
-
recover(err: unknown, ctx: Context): Promise<RecoveryDecision | null>;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
declare class DefaultRetryPolicy implements RetryPolicy {
|
|
63
|
-
shouldRetry(err: Error | ProviderError, attempt: number): boolean;
|
|
64
|
-
maxAttempts(err: Error | ProviderError): number;
|
|
65
|
-
delayMs(attempt: number): number;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
declare class ToolExecutor {
|
|
69
|
-
private readonly registry;
|
|
70
|
-
private opts;
|
|
71
|
-
private readonly serializer;
|
|
72
|
-
private readonly iterationTimeoutMs;
|
|
73
|
-
constructor(registry: {
|
|
74
|
-
get(name: string): Tool | undefined;
|
|
75
|
-
list(): Tool[];
|
|
76
|
-
}, opts: ToolExecutorOptions);
|
|
77
|
-
/**
|
|
78
|
-
* Clear the interactive confirm awaiter so the executor returns
|
|
79
|
-
* `ToolConfirmPendingResult` instead of blocking on stdin. Used by
|
|
80
|
-
* the CLI to switch from inline prompts (REPL) to event-driven
|
|
81
|
-
* confirmation (TUI) at runtime.
|
|
82
|
-
*/
|
|
83
|
-
clearConfirmAwaiter(): void;
|
|
84
|
-
/**
|
|
85
|
-
* Execute a batch of tool uses using the configured strategy.
|
|
86
|
-
* Returns the execution results and the remaining output budget.
|
|
87
|
-
*/
|
|
88
|
-
executeBatch(toolUses: ToolUseBlock[], ctx: Context, strategy: ToolExecutorStrategy): Promise<ToolBatchResult>;
|
|
89
|
-
/**
|
|
90
|
-
* Execute a single tool with timeout, permission check, and output capping.
|
|
91
|
-
* Emits `tool.started` via the injected EventBus (if any) right before
|
|
92
|
-
* invoking the tool — closes the observability gap between "model decided
|
|
93
|
-
* to call a tool" and "tool.executed".
|
|
94
|
-
*/
|
|
95
|
-
executeTool(tool: Tool, use: ToolUseBlock, ctx: Context, budget: number): Promise<ToolResultBlock>;
|
|
96
|
-
private runWithTimeout;
|
|
97
|
-
private runStreamedTool;
|
|
98
|
-
private unknownToolResult;
|
|
99
|
-
private malformedInputResult;
|
|
100
|
-
private deniedResult;
|
|
101
|
-
private blockedByHookResult;
|
|
102
|
-
private decrementBudget;
|
|
103
|
-
/**
|
|
104
|
-
* Compute the suggestedPattern string for a tool+input pair.
|
|
105
|
-
* Matches the logic in DefaultPermissionPolicy so the TUI shows the
|
|
106
|
-
* same subject that the trust file would use.
|
|
107
|
-
*/
|
|
108
|
-
private subjectFor;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export { type CompactorOptions as C, DEFAULT_RECOVERY_STRATEGIES as D, HybridCompactor as H, type RecoveryStrategy as R, ToolExecutor as T, DefaultErrorHandler as a, DefaultRetryPolicy as b, buildRecoveryStrategies as c };
|