@wrongstack/core 0.5.6 → 0.5.7
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-B07AYFBk.d.ts → agent-bridge-BKNiE1VH.d.ts} +1 -1
- package/dist/{compactor-BWhJXxsW.d.ts → compactor-RIPuTtWK.d.ts} +1 -1
- package/dist/{config-BgM0BIpz.d.ts → config-BGGuP_Ar.d.ts} +1 -1
- package/dist/{context-CLZXPPYk.d.ts → context-CDRyrkKQ.d.ts} +7 -0
- package/dist/coordination/index.d.ts +9 -9
- package/dist/coordination/index.js +301 -58
- package/dist/coordination/index.js.map +1 -1
- package/dist/defaults/index.d.ts +18 -18
- package/dist/defaults/index.js +124 -61
- package/dist/defaults/index.js.map +1 -1
- package/dist/{events-qnDZbrtb.d.ts → events-DPQKFX7W.d.ts} +1 -1
- package/dist/execution/index.d.ts +18 -11
- package/dist/execution/index.js +19 -3
- package/dist/execution/index.js.map +1 -1
- package/dist/extension/index.d.ts +6 -6
- package/dist/{index-BDnUCRvL.d.ts → index-Bf9Bpkdc.d.ts} +351 -15
- package/dist/{index-DPLJw_ZI.d.ts → index-j2WyAyML.d.ts} +20 -5
- package/dist/index.d.ts +107 -27
- package/dist/index.js +417 -84
- 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-CSMfaBuL.d.ts → mcp-servers-DBdh3cee.d.ts} +3 -3
- package/dist/models/index.d.ts +2 -2
- package/dist/{multi-agent-Cv8wk47i.d.ts → multi-agent-Cpp7FXUl.d.ts} +11 -3
- package/dist/observability/index.d.ts +2 -2
- package/dist/{path-resolver-DiCUvEg6.d.ts → path-resolver--g_hKJ7V.d.ts} +2 -2
- package/dist/{plan-templates-DaxTCPfk.d.ts → plan-templates-Bveo2W8n.d.ts} +4 -4
- package/dist/{provider-runner-3SHqk9zB.d.ts → provider-runner-hl4Il3xS.d.ts} +3 -3
- package/dist/{retry-policy-LLUxJmYY.d.ts → retry-policy-LKS8MHsB.d.ts} +1 -1
- package/dist/sdd/index.d.ts +3 -3
- package/dist/{secret-scrubber-Z_VXuXQT.d.ts → secret-scrubber-BzQR5BiL.d.ts} +1 -1
- package/dist/{secret-scrubber-BhJTNr9v.d.ts → secret-scrubber-CfMdAJ_l.d.ts} +1 -1
- package/dist/security/index.d.ts +3 -3
- package/dist/{selector-DB2-byKH.d.ts → selector-C7HqnZJU.d.ts} +1 -1
- package/dist/{session-reader-4jxsYLZ8.d.ts → session-reader-CzfRA6Vk.d.ts} +1 -1
- package/dist/storage/index.d.ts +5 -5
- package/dist/{system-prompt-DI4Dtc1I.d.ts → system-prompt-Dl2QY1_B.d.ts} +1 -1
- package/dist/{tool-executor-DSvmOBe6.d.ts → tool-executor-DbAFkHdP.d.ts} +4 -4
- package/dist/types/index.d.ts +15 -15
- package/dist/utils/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { A as AfterIterationHook, p as AfterRunHook, q as AfterToolExecutionHook, s as AgentExtension, B as BeforeIterationHook, w as BeforeRunHook, x as BeforeToolExecutionHook, E as ExtensionRegistry, O as OnErrorHook, G as ProviderRunnerFn, z as ProviderRunnerWrapper } from '../index-
|
|
2
|
-
import '../context-
|
|
1
|
+
export { A as AfterIterationHook, p as AfterRunHook, q as AfterToolExecutionHook, s as AgentExtension, B as BeforeIterationHook, w as BeforeRunHook, x as BeforeToolExecutionHook, E as ExtensionRegistry, O as OnErrorHook, G as ProviderRunnerFn, z as ProviderRunnerWrapper } from '../index-j2WyAyML.js';
|
|
2
|
+
import '../context-CDRyrkKQ.js';
|
|
3
3
|
import '../logger-BMQgxvdy.js';
|
|
4
|
-
import '../system-prompt-
|
|
4
|
+
import '../system-prompt-Dl2QY1_B.js';
|
|
5
5
|
import '../observability-BhnVLBLS.js';
|
|
6
|
-
import '../events-
|
|
7
|
-
import '../secret-scrubber-
|
|
8
|
-
import '../config-
|
|
6
|
+
import '../events-DPQKFX7W.js';
|
|
7
|
+
import '../secret-scrubber-CfMdAJ_l.js';
|
|
8
|
+
import '../config-BGGuP_Ar.js';
|
|
9
9
|
import '../models-registry-Y2xbog0E.js';
|
|
@@ -1,10 +1,98 @@
|
|
|
1
1
|
import { a as DirectorStateSnapshot } from './director-state-BmYi3DGA.js';
|
|
2
|
-
import {
|
|
3
|
-
import { r as SessionWriter, v as Tool, p as SessionStore } from './context-
|
|
4
|
-
import { I as InMemoryAgentBridge } from './agent-bridge-
|
|
5
|
-
import { E as EventBus } from './events-
|
|
2
|
+
import { c as SubagentConfig, j as TaskResult, a as CoordinatorStatus, k as TaskSpec, M as MultiAgentConfig, i as SubagentRunner, b as MultiAgentCoordinator, S as SpawnResult, l as BridgeMessage, A as AgentBridge } from './multi-agent-Cpp7FXUl.js';
|
|
3
|
+
import { r as SessionWriter, v as Tool, p as SessionStore } from './context-CDRyrkKQ.js';
|
|
4
|
+
import { I as InMemoryAgentBridge } from './agent-bridge-BKNiE1VH.js';
|
|
5
|
+
import { E as EventBus } from './events-DPQKFX7W.js';
|
|
6
6
|
import { EventEmitter } from 'node:events';
|
|
7
|
-
import { r as Agent, u as AgentInput } from './index-
|
|
7
|
+
import { r as Agent, u as AgentInput } from './index-j2WyAyML.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Interface for a fleet coordinator. Implemented by both `Director`
|
|
11
|
+
* (full LLM-driven orchestration with fleet policy) and
|
|
12
|
+
* `DefaultMultiAgentCoordinator` (direct API-driven, no fleet policy).
|
|
13
|
+
*
|
|
14
|
+
* External callers — CLI slash commands, tests, the delegate tool —
|
|
15
|
+
* use this to stay agnostic to the orchestration mode.
|
|
16
|
+
*
|
|
17
|
+
* The interface captures the **orchestration contract**: spawn, assign,
|
|
18
|
+
* terminate, await, and query. Fleet-level policy (cost caps, manifest
|
|
19
|
+
* writing, checkpointing) lives behind this surface and is optional
|
|
20
|
+
* from the caller's perspective.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* let coordinator: ICoordinator = isDirectorMode
|
|
25
|
+
* ? new Director({ config, ... })
|
|
26
|
+
* : new DefaultMultiAgentCoordinator(config);
|
|
27
|
+
* const id = await coordinator.spawn({ name: 'worker', role: 'researcher' });
|
|
28
|
+
* await coordinator.assign({ id: 't-1', description: 'research X', subagentId: id });
|
|
29
|
+
* const results = await coordinator.awaitTasks(['t-1']);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
interface ICoordinator {
|
|
33
|
+
/** Stable identifier for this coordinator instance. */
|
|
34
|
+
readonly coordinatorId: string;
|
|
35
|
+
/**
|
|
36
|
+
* Spawn a new subagent and return its id. In director mode this
|
|
37
|
+
* enforces fleet-wide spawn caps and cost limits; in raw coordinator
|
|
38
|
+
* mode it is a direct pass-through.
|
|
39
|
+
*/
|
|
40
|
+
spawn(config: SubagentConfig): Promise<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Assign a task to a subagent (or to the fleet for auto-routing).
|
|
43
|
+
* Returns the assigned task id.
|
|
44
|
+
*/
|
|
45
|
+
assign(task: {
|
|
46
|
+
id: string;
|
|
47
|
+
description: string;
|
|
48
|
+
subagentId?: string;
|
|
49
|
+
}): Promise<string>;
|
|
50
|
+
/**
|
|
51
|
+
* Synchronously ask a subagent something via the in-memory bridge.
|
|
52
|
+
* The subagent must have been spawned and must handle `bridge.subscribe()`
|
|
53
|
+
* in its task loop. Returns the reply payload or throws on timeout.
|
|
54
|
+
*
|
|
55
|
+
* Only available in director mode — raw coordinator has no bridge.
|
|
56
|
+
*/
|
|
57
|
+
ask<T = unknown>(subagentId: string, payload: unknown, timeoutMs?: number): Promise<T>;
|
|
58
|
+
/**
|
|
59
|
+
* Wait for one or more tasks to complete and return their results.
|
|
60
|
+
* If a task is already done when called, returns immediately.
|
|
61
|
+
* Resolves to an array in the same order as `taskIds`.
|
|
62
|
+
*/
|
|
63
|
+
awaitTasks(taskIds: string[]): Promise<TaskResult[]>;
|
|
64
|
+
/**
|
|
65
|
+
* Gracefully stop a single subagent. The subagent finishes its current
|
|
66
|
+
* in-flight work and exits cleanly — it does not hard-kill.
|
|
67
|
+
*/
|
|
68
|
+
terminate(subagentId: string): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Stop all subagents. In-flight tasks are allowed to complete;
|
|
71
|
+
* no new tasks are dispatched.
|
|
72
|
+
*/
|
|
73
|
+
terminateAll(): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Live coordinator status — subagent list, pending task count,
|
|
76
|
+
* completed task count, iteration totals.
|
|
77
|
+
*/
|
|
78
|
+
status(): CoordinatorStatus;
|
|
79
|
+
/**
|
|
80
|
+
* Snapshot of completed task results. In director mode this returns
|
|
81
|
+
* every `TaskResult` from the fleet; in raw coordinator mode this
|
|
82
|
+
* may return an empty array if the coordinator doesn't cache results.
|
|
83
|
+
*/
|
|
84
|
+
completedResults(): TaskResult[];
|
|
85
|
+
/**
|
|
86
|
+
* Subscribe to coordinator lifecycle events. Currently supports
|
|
87
|
+
* `task.completed` — the payload carries the task spec and result.
|
|
88
|
+
*
|
|
89
|
+
* Returns a disposer function; call it to unsubscribe.
|
|
90
|
+
*/
|
|
91
|
+
on(event: 'task.completed', handler: (payload: {
|
|
92
|
+
task: TaskSpec;
|
|
93
|
+
result: TaskResult;
|
|
94
|
+
}) => void): () => void;
|
|
95
|
+
}
|
|
8
96
|
|
|
9
97
|
/**
|
|
10
98
|
* Single fleet-wide event with subagent attribution. Whatever a child
|
|
@@ -118,6 +206,215 @@ declare class FleetUsageAggregator {
|
|
|
118
206
|
private onIterationStarted;
|
|
119
207
|
}
|
|
120
208
|
|
|
209
|
+
/**
|
|
210
|
+
* Interface for fleet-level lifecycle and policy. Covers:
|
|
211
|
+
* - Spawn lifecycle hooks (canSpawn check, recordSpawn after-effects)
|
|
212
|
+
* - Budget enforcement (fleet-wide cost cap, spawn count/depth caps)
|
|
213
|
+
* - Fleet manifest assembly and writing
|
|
214
|
+
* - Subagent metadata and usage tracking
|
|
215
|
+
*
|
|
216
|
+
* `FleetBus` is pure event fan-out and implements no policy.
|
|
217
|
+
* `FleetManager` encapsulates all fleet-level policy decisions.
|
|
218
|
+
* `Director` currently owns all of this — this interface lets us
|
|
219
|
+
* extract it into a swappable component in Phase 5.
|
|
220
|
+
*/
|
|
221
|
+
interface IFleetManager {
|
|
222
|
+
/** The FleetBus this manager publishes lifecycle events to. */
|
|
223
|
+
readonly fleetBus: FleetBus;
|
|
224
|
+
/**
|
|
225
|
+
* Snapshot of fleet-wide token usage and cost rollup.
|
|
226
|
+
* Safe to call from a tool's execute() body.
|
|
227
|
+
*/
|
|
228
|
+
snapshot(): FleetUsage;
|
|
229
|
+
/**
|
|
230
|
+
* Per-subagent metadata captured at spawn time (provider/model/name).
|
|
231
|
+
* Returns undefined if the subagent is not known to this manager.
|
|
232
|
+
*/
|
|
233
|
+
getSubagentMeta(id: string): {
|
|
234
|
+
provider?: string;
|
|
235
|
+
model?: string;
|
|
236
|
+
name?: string;
|
|
237
|
+
} | undefined;
|
|
238
|
+
/**
|
|
239
|
+
* Called before a spawn is recorded. Returns a reason string if the
|
|
240
|
+
* spawn should be rejected (budget cap, depth limit, cost cap, etc.),
|
|
241
|
+
* or null to proceed. Director.spawn() calls this internally.
|
|
242
|
+
*/
|
|
243
|
+
canSpawn(config: SubagentConfig): {
|
|
244
|
+
kind: 'max_spawns' | 'max_spawn_depth' | 'max_cost_usd';
|
|
245
|
+
limit: number;
|
|
246
|
+
observed: number;
|
|
247
|
+
} | null;
|
|
248
|
+
/**
|
|
249
|
+
* Called after a spawn succeeds. Records metadata for the usage
|
|
250
|
+
* aggregator and manifest.
|
|
251
|
+
*
|
|
252
|
+
* @param priceLookup Per-token rate lookup for cost calculation.
|
|
253
|
+
* When omitted the cost column in usage snapshots stays at 0.
|
|
254
|
+
*/
|
|
255
|
+
recordSpawn(subagentId: string, config: SubagentConfig, priceLookup?: Record<string, number>): void;
|
|
256
|
+
/**
|
|
257
|
+
* Write the fleet manifest to disk. Returns the path written
|
|
258
|
+
* or null when no manifest path is configured.
|
|
259
|
+
*/
|
|
260
|
+
writeManifest(): Promise<string | null>;
|
|
261
|
+
/**
|
|
262
|
+
* Aggregate fleet-wide status: pending tasks with descriptions and
|
|
263
|
+
* live subagent snapshot from the coordinator. Used by
|
|
264
|
+
* `MultiAgentHost.status()` to eliminate host-side state duplication.
|
|
265
|
+
*/
|
|
266
|
+
getFleetStatus(): {
|
|
267
|
+
pending: {
|
|
268
|
+
taskId: string;
|
|
269
|
+
description: string;
|
|
270
|
+
subagentId: string;
|
|
271
|
+
}[];
|
|
272
|
+
live: {
|
|
273
|
+
subagentId: string;
|
|
274
|
+
status: string;
|
|
275
|
+
task?: string;
|
|
276
|
+
}[];
|
|
277
|
+
};
|
|
278
|
+
/**
|
|
279
|
+
* Register a pending task with its description. Called by
|
|
280
|
+
* `MultiAgentHost.spawn()` after `_spawnAndAssign()` returns so
|
|
281
|
+
* the description is available in `status()` without host-side storage.
|
|
282
|
+
*/
|
|
283
|
+
addPendingTask(taskId: string, subagentId: string, description: string): void;
|
|
284
|
+
/**
|
|
285
|
+
* Remove a pending task. Called when the task completes so the
|
|
286
|
+
* pending list stays accurate.
|
|
287
|
+
*/
|
|
288
|
+
removePendingTask(taskId: string): void;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** Options for constructing a FleetManager. */
|
|
292
|
+
interface FleetManagerOptions {
|
|
293
|
+
manifestPath?: string;
|
|
294
|
+
sessionsRoot?: string;
|
|
295
|
+
directorRunId?: string;
|
|
296
|
+
maxSpawns?: number;
|
|
297
|
+
maxSpawnDepth?: number;
|
|
298
|
+
spawnDepth?: number;
|
|
299
|
+
stateCheckpointPath?: string;
|
|
300
|
+
sessionWriter?: SessionWriter;
|
|
301
|
+
manifestDebounceMs?: number;
|
|
302
|
+
checkpointDebounceMs?: number;
|
|
303
|
+
directorBudget?: {
|
|
304
|
+
maxCostUsd?: number;
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Fleet-level policy container extracted from `Director`. Owns:
|
|
309
|
+
* - FleetBus + FleetUsageAggregator
|
|
310
|
+
* - Spawn caps and counters
|
|
311
|
+
* - Manifest entries and debounced writing
|
|
312
|
+
* - State checkpointing
|
|
313
|
+
*
|
|
314
|
+
* This lets the `Director` focus on orchestration (spawn/assign/await/ask)
|
|
315
|
+
* while fleet-level decisions live in one place. The class implements
|
|
316
|
+
* `IFleetManager` so it remains swappable in future.
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
* ```typescript
|
|
320
|
+
* const fm = new FleetManager({ manifestPath: '/tmp/fleet.json' });
|
|
321
|
+
* const err = fm.canSpawn({ name: 'worker' });
|
|
322
|
+
* if (!err) fm.recordSpawn('sub-1', { name: 'worker' });
|
|
323
|
+
* await fm.writeManifest();
|
|
324
|
+
* ```
|
|
325
|
+
*/
|
|
326
|
+
declare class FleetManager implements IFleetManager {
|
|
327
|
+
/** The fleet-wide event bus. */
|
|
328
|
+
readonly fleet: FleetBus;
|
|
329
|
+
/** Usage rollup across all subagents. */
|
|
330
|
+
readonly usage: FleetUsageAggregator;
|
|
331
|
+
private readonly manifestPath?;
|
|
332
|
+
private readonly sessionsRoot?;
|
|
333
|
+
private readonly directorRunId;
|
|
334
|
+
/** Spawn cap (lifetime total). Infinity means unlimited. */
|
|
335
|
+
readonly maxSpawns: number;
|
|
336
|
+
/** Nesting cap. */
|
|
337
|
+
readonly maxSpawnDepth: number;
|
|
338
|
+
/** This director's depth in a director chain. Root = 0. */
|
|
339
|
+
readonly spawnDepth: number;
|
|
340
|
+
/** Live spawn counter. */
|
|
341
|
+
private spawnCount;
|
|
342
|
+
private readonly stateCheckpoint;
|
|
343
|
+
private readonly sessionWriter;
|
|
344
|
+
private manifestTimer;
|
|
345
|
+
private readonly manifestDebounceMs;
|
|
346
|
+
/** Fleet-wide cost cap. Infinity = no cap. Distinct from SubagentBudget limits,
|
|
347
|
+
* which track per-subagent spend — this field caps the entire fleet total. */
|
|
348
|
+
private readonly maxFleetCostUsd;
|
|
349
|
+
private readonly manifestEntries;
|
|
350
|
+
/** Pending tasks with their descriptions — populated by `addPendingTask`
|
|
351
|
+
* and cleared by `removePendingTask`. Replaces the host-side `pending`
|
|
352
|
+
* Map so task descriptions live in one place (FleetManager). */
|
|
353
|
+
private readonly pendingTasks;
|
|
354
|
+
private readonly subagentMeta;
|
|
355
|
+
private readonly priceLookups;
|
|
356
|
+
constructor(opts?: FleetManagerOptions);
|
|
357
|
+
get fleetBus(): FleetBus;
|
|
358
|
+
snapshot(): FleetUsage;
|
|
359
|
+
getSubagentMeta(id: string): {
|
|
360
|
+
provider?: string;
|
|
361
|
+
model?: string;
|
|
362
|
+
name?: string;
|
|
363
|
+
} | undefined;
|
|
364
|
+
/**
|
|
365
|
+
* Returns null if the spawn is allowed, or an object describing
|
|
366
|
+
* which cap was exceeded. Does NOT throw — the caller decides
|
|
367
|
+
* how to surface the rejection.
|
|
368
|
+
*/
|
|
369
|
+
canSpawn(config: SubagentConfig): {
|
|
370
|
+
kind: 'max_spawns' | 'max_spawn_depth' | 'max_cost_usd';
|
|
371
|
+
limit: number;
|
|
372
|
+
observed: number;
|
|
373
|
+
} | null;
|
|
374
|
+
/**
|
|
375
|
+
* Records a spawn: increments counter, stores metadata, updates state checkpoint,
|
|
376
|
+
* and schedules a debounced manifest write. Call AFTER the coordinator
|
|
377
|
+
* has successfully spawned the subagent.
|
|
378
|
+
*
|
|
379
|
+
* @param subagentId The subagent's id (from coordinator.spawn result)
|
|
380
|
+
* @param config The SubagentConfig that was used
|
|
381
|
+
* @param priceLookup Optional per-subagent pricing data
|
|
382
|
+
*/
|
|
383
|
+
recordSpawn(subagentId: string, config: SubagentConfig, priceLookup?: {
|
|
384
|
+
input?: number;
|
|
385
|
+
output?: number;
|
|
386
|
+
cacheRead?: number;
|
|
387
|
+
cacheWrite?: number;
|
|
388
|
+
}): void;
|
|
389
|
+
writeManifest(): Promise<string | null>;
|
|
390
|
+
/**
|
|
391
|
+
* Attach task ids to an already-spawned subagent. Called by
|
|
392
|
+
* `Director.assign()` after the coordinator assigns a task.
|
|
393
|
+
*/
|
|
394
|
+
addTaskToSubagent(subagentId: string, taskId: string): void;
|
|
395
|
+
/**
|
|
396
|
+
* Debounced manifest write. Call after any state mutation
|
|
397
|
+
* (spawn, assign, complete) so a burst collapses into one write.
|
|
398
|
+
*/
|
|
399
|
+
scheduleManifest(): void;
|
|
400
|
+
/** Best-effort session event writer. Swallows failures. */
|
|
401
|
+
private appendSessionEvent;
|
|
402
|
+
addPendingTask(taskId: string, subagentId: string, description: string): void;
|
|
403
|
+
removePendingTask(taskId: string): void;
|
|
404
|
+
getFleetStatus(): {
|
|
405
|
+
pending: {
|
|
406
|
+
taskId: string;
|
|
407
|
+
description: string;
|
|
408
|
+
subagentId: string;
|
|
409
|
+
}[];
|
|
410
|
+
live: {
|
|
411
|
+
subagentId: string;
|
|
412
|
+
status: string;
|
|
413
|
+
task?: string;
|
|
414
|
+
}[];
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
|
|
121
418
|
/**
|
|
122
419
|
* Director — high-level orchestrator that owns a `MultiAgentCoordinator`,
|
|
123
420
|
* a `FleetBus`, and a `FleetUsageAggregator`. Exposes a small imperative
|
|
@@ -175,7 +472,7 @@ interface DirectorOptions {
|
|
|
175
472
|
* lifetime. Default: unlimited. Acts as a hard fleet-wide cost cap —
|
|
176
473
|
* a runaway leader that keeps spawning workers gets cut off cleanly
|
|
177
474
|
* instead of burning provider tokens until the user kills the
|
|
178
|
-
* process. The N+1-th spawn call rejects with a `
|
|
475
|
+
* process. The N+1-th spawn call rejects with a `FleetSpawnBudgetError`.
|
|
179
476
|
*/
|
|
180
477
|
maxSpawns?: number;
|
|
181
478
|
/**
|
|
@@ -223,8 +520,11 @@ interface DirectorOptions {
|
|
|
223
520
|
* that would push the fleet's total cost above this limit. The cap
|
|
224
521
|
* is checked BEFORE the spawn is recorded — a refused spawn must not
|
|
225
522
|
* leak partial state into the manifest or fleet bus. Let in-flight
|
|
226
|
-
* tasks complete; refuse new spawns only. When
|
|
227
|
-
*
|
|
523
|
+
* tasks complete; refuse new spawns only. When omitted or Infinity,
|
|
524
|
+
* no cost cap applies.
|
|
525
|
+
*
|
|
526
|
+
* Distinct from SubagentBudget.maxCostUsd (per-subagent spend) — this
|
|
527
|
+
* field caps the *entire fleet* total.
|
|
228
528
|
*/
|
|
229
529
|
directorBudget?: {
|
|
230
530
|
/**
|
|
@@ -263,6 +563,17 @@ interface DirectorOptions {
|
|
|
263
563
|
* JSONLs. Defaults to the director's own `id` when omitted.
|
|
264
564
|
*/
|
|
265
565
|
directorRunId?: string;
|
|
566
|
+
/**
|
|
567
|
+
* Pre-built fleet manager. When provided the Director delegates all
|
|
568
|
+
* fleet-level policy (spawn budgets, manifest assembly, checkpointing)
|
|
569
|
+
* to this instance and takes ownership of the coordinator + bridge
|
|
570
|
+
* layer only. This enables unit-testing fleet policy in isolation
|
|
571
|
+
* and swapping implementations without changing the Director surface.
|
|
572
|
+
*
|
|
573
|
+
* When omitted the Director creates its own fleet infrastructure
|
|
574
|
+
* (same behavior as before this field was added).
|
|
575
|
+
*/
|
|
576
|
+
fleetManager?: FleetManager;
|
|
266
577
|
}
|
|
267
578
|
/**
|
|
268
579
|
* Thrown by `Director.spawn()` when a configured spawn cap (`maxSpawns`,
|
|
@@ -270,7 +581,7 @@ interface DirectorOptions {
|
|
|
270
581
|
* the `spawn_subagent` tool surface — can recognize the budget case and
|
|
271
582
|
* report it cleanly instead of treating it like an unexpected failure.
|
|
272
583
|
*/
|
|
273
|
-
declare class
|
|
584
|
+
declare class FleetSpawnBudgetError extends Error {
|
|
274
585
|
readonly kind: 'max_spawns' | 'max_spawn_depth';
|
|
275
586
|
readonly limit: number;
|
|
276
587
|
readonly observed: number;
|
|
@@ -278,20 +589,36 @@ declare class DirectorBudgetError extends Error {
|
|
|
278
589
|
}
|
|
279
590
|
/**
|
|
280
591
|
* Thrown by `Director.spawn()` when the fleet-wide cost cap is exceeded.
|
|
281
|
-
* Distinct from `
|
|
592
|
+
* Distinct from `FleetSpawnBudgetError` (spawn count/depth) — this is a
|
|
282
593
|
* dollar-denominated ceiling that tracks cumulative spend across all
|
|
283
594
|
* subagents in the fleet.
|
|
284
595
|
*/
|
|
285
|
-
declare class
|
|
596
|
+
declare class FleetCostCapError extends Error {
|
|
286
597
|
readonly kind: 'max_cost_usd';
|
|
287
598
|
readonly limit: number;
|
|
288
599
|
readonly observed: number;
|
|
289
600
|
constructor(limit: number, observed: number);
|
|
290
601
|
}
|
|
291
|
-
declare class Director {
|
|
602
|
+
declare class Director implements ICoordinator {
|
|
603
|
+
/** Alias for the ICoordinator contract. `id` is retained for backward compatibility. */
|
|
604
|
+
get coordinatorId(): string;
|
|
292
605
|
readonly id: string;
|
|
606
|
+
/**
|
|
607
|
+
* The fleet event bus. Backed by `fleetManager?.fleet` when a FleetManager
|
|
608
|
+
* is injected; otherwise own FleetBus instance (preserves existing behavior).
|
|
609
|
+
*/
|
|
293
610
|
readonly fleet: FleetBus;
|
|
611
|
+
/**
|
|
612
|
+
* Usage rollup. Backed by `fleetManager?.usage` when a FleetManager is
|
|
613
|
+
* injected; otherwise own FleetUsageAggregator.
|
|
614
|
+
*/
|
|
294
615
|
readonly usage: FleetUsageAggregator;
|
|
616
|
+
/**
|
|
617
|
+
* Optional fleet-level policy container. When provided the Director
|
|
618
|
+
* delegates spawn budgeting, manifest entries, and checkpointing to it
|
|
619
|
+
* instead of managing those internally. All other behavior is unchanged.
|
|
620
|
+
*/
|
|
621
|
+
readonly fleetManager: FleetManager | undefined;
|
|
295
622
|
/**
|
|
296
623
|
* Director-side bridge endpoint. Subagents are wired to the same
|
|
297
624
|
* in-memory transport so the director can `ask()` them synchronously
|
|
@@ -342,8 +669,8 @@ declare class Director {
|
|
|
342
669
|
/** Debounce timer for periodic manifest writes. */
|
|
343
670
|
private manifestTimer;
|
|
344
671
|
private readonly manifestDebounceMs;
|
|
345
|
-
/** Fleet-wide cost cap. Infinity means no cap. */
|
|
346
|
-
private readonly
|
|
672
|
+
/** Fleet-wide cost cap (entire fleet total, distinct from SubagentBudget limits). Infinity means no cap. */
|
|
673
|
+
private readonly maxFleetCostUsd;
|
|
347
674
|
/** Max auto-extensions per subagent per budget kind before denying. */
|
|
348
675
|
private readonly maxBudgetExtensions;
|
|
349
676
|
/** Sessions root for direct subagent JSONL reads (fleet_session tool). */
|
|
@@ -1003,4 +1330,13 @@ declare function applyRosterBudget(cfg: SubagentConfig): SubagentConfig;
|
|
|
1003
1330
|
/** Quick-access list for spawning all at once. */
|
|
1004
1331
|
declare const ALL_FLEET_AGENTS: SubagentConfig[];
|
|
1005
1332
|
|
|
1006
|
-
|
|
1333
|
+
/**
|
|
1334
|
+
* A no-op FleetBus that discards all events. Used when no real fleet
|
|
1335
|
+
* bus is available (non-director mode) so the runner's `fleetBus`
|
|
1336
|
+
* field is always valid and the `attach()` call is always safe.
|
|
1337
|
+
*
|
|
1338
|
+
* One singleton instance is sufficient — it has no state to reset.
|
|
1339
|
+
*/
|
|
1340
|
+
declare const NULL_FLEET_BUS: FleetBus;
|
|
1341
|
+
|
|
1342
|
+
export { ALL_FLEET_AGENTS as A, BUG_HUNTER_AGENT as B, type CreateDelegateToolOptions as C, DEFAULT_DIRECTOR_PREAMBLE as D, createDelegateTool as E, FLEET_ROSTER as F, makeAgentSubagentRunner as G, makeDirectorSessionFactory as H, type ICoordinator as I, rosterSummaryFromConfigs as J, FleetCostCapError as K, type MultiAgentCoordinatorOptions as M, NULL_FLEET_BUS as N, REFACTOR_PLANNER_AGENT as R, SECURITY_SCANNER_AGENT as S, AUDIT_LOG_AGENT as a, type AgentFactory as b, type AgentFactoryResult as c, type AgentRunnerOptions as d, DEFAULT_SUBAGENT_BASELINE as e, DefaultMultiAgentCoordinator as f, type DelegateHost as g, Director as h, type DirectorPromptParts as i, type DirectorSessionFactory as j, type DirectorSessionFactoryOptions as k, FLEET_ROSTER_BUDGETS as l, FleetBus as m, type FleetEvent as n, type FleetHandler as o, FleetManager as p, type FleetManagerOptions as q, FleetSpawnBudgetError as r, type FleetUsage as s, FleetUsageAggregator as t, type IFleetManager as u, type SubagentPromptParts as v, type SubagentUsageSnapshot as w, applyRosterBudget as x, composeDirectorPrompt as y, composeSubagentPrompt as z };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { v as Tool, B as ToolResultBlock, T as TextBlock, a2 as Context, R as Request, j as Response, G as ToolUseBlock, g as Provider, W as WrongStackError, b as ContentBlock, aa as RunOptions, J as JSONSchema } from './context-
|
|
1
|
+
import { v as Tool, B as ToolResultBlock, T as TextBlock, a2 as Context, R as Request, j as Response, G as ToolUseBlock, g as Provider, W as WrongStackError, b as ContentBlock, aa as RunOptions, J as JSONSchema } from './context-CDRyrkKQ.js';
|
|
2
2
|
import { L as Logger } from './logger-BMQgxvdy.js';
|
|
3
|
-
import { R as Renderer, B as BuildContext, C as Container, P as Pipeline, e as ReadonlyPipeline } from './system-prompt-
|
|
3
|
+
import { R as Renderer, B as BuildContext, C as Container, P as Pipeline, e as ReadonlyPipeline } from './system-prompt-Dl2QY1_B.js';
|
|
4
4
|
import { T as Tracer } from './observability-BhnVLBLS.js';
|
|
5
|
-
import { E as EventBus, a as EventName, L as Listener } from './events-
|
|
6
|
-
import { a as PermissionPolicy, S as SecretScrubber } from './secret-scrubber-
|
|
7
|
-
import { l as ProviderConfig, a as Config } from './config-
|
|
5
|
+
import { E as EventBus, a as EventName, L as Listener } from './events-DPQKFX7W.js';
|
|
6
|
+
import { a as PermissionPolicy, S as SecretScrubber } from './secret-scrubber-CfMdAJ_l.js';
|
|
7
|
+
import { l as ProviderConfig, a as Config } from './config-BGGuP_Ar.js';
|
|
8
8
|
import { W as WireFamily } from './models-registry-Y2xbog0E.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -440,6 +440,19 @@ interface AgentInit {
|
|
|
440
440
|
* emit `iteration.limit_reached` and wait for a listener to grant/deny.
|
|
441
441
|
*/
|
|
442
442
|
autoExtendLimit?: boolean;
|
|
443
|
+
/**
|
|
444
|
+
* When true, the agent supports autonomous continuation — the model
|
|
445
|
+
* can signal "keep going" either via the `continue_to_next_iteration()`
|
|
446
|
+
* tool or by placing a `[continue]` / `[next step]` / `[proceed]` /
|
|
447
|
+
* `[done]` marker on its own line in the final text output. The agent
|
|
448
|
+
* loop re-runs without returning to the caller when `continue` is
|
|
449
|
+
* signalled, or exits with `status: 'done'` when `stop` is signalled.
|
|
450
|
+
*
|
|
451
|
+
* The text-marker parser runs in `processResponse()` before the
|
|
452
|
+
* loop-exit check so markers in the final text block are honoured
|
|
453
|
+
* even when no tool was called.
|
|
454
|
+
*/
|
|
455
|
+
autonomousContinue?: boolean;
|
|
443
456
|
/**
|
|
444
457
|
* Optional confirm handler. When set, the executor calls it synchronously
|
|
445
458
|
* when a tool needs user confirmation (CLI path). When omitted, the
|
|
@@ -507,6 +520,8 @@ declare class Agent {
|
|
|
507
520
|
private readonly plugins;
|
|
508
521
|
private readonly toolExecutor;
|
|
509
522
|
private readonly autoExtendLimit;
|
|
523
|
+
/** Enables autonomous continue: model can signal `[continue]` or call continue_to_next_iteration() to re-run. */
|
|
524
|
+
private readonly autonomousContinue;
|
|
510
525
|
private readonly tracer;
|
|
511
526
|
readonly extensions: ExtensionRegistry;
|
|
512
527
|
constructor(init: AgentInit);
|