@wrongstack/core 0.10.0 → 0.10.3

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.
Files changed (42) hide show
  1. package/dist/{agent-bridge-DBBGP5O4.d.ts → agent-bridge-D_XcS2HL.d.ts} +3 -1
  2. package/dist/{agent-subagent-runner-KwufTWwn.d.ts → agent-subagent-runner-DuRtZmhl.d.ts} +13 -3
  3. package/dist/coordination/index.d.ts +8 -8
  4. package/dist/coordination/index.js +83 -21
  5. package/dist/coordination/index.js.map +1 -1
  6. package/dist/defaults/index.d.ts +11 -11
  7. package/dist/defaults/index.js +89 -23
  8. package/dist/defaults/index.js.map +1 -1
  9. package/dist/{events-Bw1K5E6K.d.ts → events-BrQiweXN.d.ts} +1 -1
  10. package/dist/execution/index.d.ts +6 -6
  11. package/dist/execution/index.js +32 -10
  12. package/dist/execution/index.js.map +1 -1
  13. package/dist/extension/index.d.ts +2 -2
  14. package/dist/{index-DgQWnZxP.d.ts → index-DAHEM_II.d.ts} +1 -1
  15. package/dist/{index-DIt5TIaF.d.ts → index-DnBHrz2y.d.ts} +2 -2
  16. package/dist/index.d.ts +17 -17
  17. package/dist/index.js +226 -101
  18. package/dist/index.js.map +1 -1
  19. package/dist/infrastructure/index.d.ts +2 -2
  20. package/dist/kernel/index.d.ts +3 -3
  21. package/dist/kernel/index.js.map +1 -1
  22. package/dist/{multi-agent-C1O8EFzb.d.ts → multi-agent-C8Z1i__e.d.ts} +2 -2
  23. package/dist/{multi-agent-coordinator-DoVSBFNx.d.ts → multi-agent-coordinator-CjG-FZKj.d.ts} +8 -3
  24. package/dist/{null-fleet-bus-T-s3JaOt.d.ts → null-fleet-bus-B3WdVY9i.d.ts} +28 -23
  25. package/dist/observability/index.d.ts +1 -1
  26. package/dist/{path-resolver-BfyK-I7w.d.ts → path-resolver-DumKAi0n.d.ts} +1 -1
  27. package/dist/{plan-templates-BWs6Je7j.d.ts → plan-templates-BUP4o-ds.d.ts} +2 -2
  28. package/dist/{provider-runner-BmPe2RuU.d.ts → provider-runner-Dlv8Fvw9.d.ts} +1 -1
  29. package/dist/sdd/index.d.ts +4 -4
  30. package/dist/sdd/index.js +30 -8
  31. package/dist/sdd/index.js.map +1 -1
  32. package/dist/security/index.js +3 -3
  33. package/dist/security/index.js.map +1 -1
  34. package/dist/{session-reader-CCSBfQmd.d.ts → session-reader-bfgsy2a0.d.ts} +7 -3
  35. package/dist/storage/index.d.ts +29 -10
  36. package/dist/storage/index.js +131 -65
  37. package/dist/storage/index.js.map +1 -1
  38. package/dist/{tool-executor-D7RxLtg4.d.ts → tool-executor-D87-_5Of.d.ts} +1 -1
  39. package/dist/types/index.d.ts +8 -8
  40. package/dist/types/index.js +25 -5
  41. package/dist/types/index.js.map +1 -1
  42. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { b as BridgeTransport, B as BridgeMessage, A as AgentBridge, a as AgentBridgeConfig } from './multi-agent-C1O8EFzb.js';
1
+ import { b as BridgeTransport, B as BridgeMessage, A as AgentBridge, a as AgentBridgeConfig } from './multi-agent-C8Z1i__e.js';
2
2
 
3
3
  /**
4
4
  * In-memory pub/sub transport for agent-to-agent messaging.
@@ -21,6 +21,8 @@ declare class InMemoryAgentBridge implements AgentBridge {
21
21
  private timeoutMs;
22
22
  /** Guards request() so concurrent calls on the same id can't silently overwrite. */
23
23
  private readonly inflightGuards;
24
+ /** Stores the transport unsubscribe function so it can be called on stop(). */
25
+ private _transportUnsubscribe?;
24
26
  constructor(config: AgentBridgeConfig, transport: BridgeTransport);
25
27
  send(msg: BridgeMessage): Promise<void>;
26
28
  broadcast(msg: BridgeMessage): Promise<void>;
@@ -1,6 +1,6 @@
1
- import { c as Agent, f as AgentInput } from './index-DgQWnZxP.js';
2
- import { E as EventBus } from './events-Bw1K5E6K.js';
3
- import { n as SubagentConfig, v as TaskSpec, t as SubagentRunner } from './multi-agent-C1O8EFzb.js';
1
+ import { c as Agent, f as AgentInput } from './index-DAHEM_II.js';
2
+ import { E as EventBus } from './events-BrQiweXN.js';
3
+ import { n as SubagentConfig, v as TaskSpec, t as SubagentRunner } from './multi-agent-C8Z1i__e.js';
4
4
 
5
5
  /**
6
6
  * Single fleet-wide event with subagent attribution. Whatever a child
@@ -95,6 +95,7 @@ declare class FleetUsageAggregator {
95
95
  private readonly metaLookup?;
96
96
  private readonly perSubagent;
97
97
  private readonly total;
98
+ private readonly unsub;
98
99
  constructor(bus: FleetBus, priceLookup?: ((subagentId: string, provider?: string, model?: string) => {
99
100
  input?: number;
100
101
  output?: number;
@@ -104,6 +105,15 @@ declare class FleetUsageAggregator {
104
105
  provider?: string;
105
106
  model?: string;
106
107
  } | undefined) | undefined);
108
+ /**
109
+ * Remove a terminated subagent's data from the aggregator and subtract its
110
+ * contribution from the running totals. Call this when a subagent is removed
111
+ * from the fleet so the aggregator doesn't accumulate unbounded data for
112
+ * entities that will never emit events again.
113
+ */
114
+ removeSubagent(subagentId: string): void;
115
+ /** Disposes all fleet-bus subscriptions. Call when the aggregator is no longer needed. */
116
+ dispose(): void;
107
117
  /** Live snapshot — safe to call from a tool's execute() body. */
108
118
  snapshot(): FleetUsage;
109
119
  private ensure;
@@ -1,14 +1,14 @@
1
- export { A as ACP_AGENTS, a as AGENTS_BY_PHASE, b as AGENT_CATALOG, c as ALL_AGENT_DEFINITIONS, d as ALL_FLEET_AGENTS, e as AUDIT_LOG_AGENT, f as AutoExtendCeiling, g as AutoExtendPolicy, B as BUG_HUNTER_AGENT, h as BugFinding, C as CollabBudgetConfig, i as CollabBudgetOverrides, j as CollabBudgetWarningPayload, k as CollabDebugReport, l as CollabSession, m as CollabSessionOptions, n as CreateDelegateToolOptions, o as CriticConcern, p as CriticEvaluation, D as DEFAULT_DIRECTOR_PREAMBLE, q as DEFAULT_SUBAGENT_BASELINE, r as DelegateHost, s as Director, t as DirectorAlert, u as DirectorAlertLevel, v as DirectorCancelCollabPayload, w as DirectorPromptParts, x as DirectorSessionFactory, y as DirectorSessionFactoryOptions, F as FLEET_ROSTER, z as FLEET_ROSTER_BUDGETS, E as FLEET_ROSTER_WITHACP, G as FleetCostCapError, H as FleetManager, I as FleetManagerOptions, J as FleetRosterBudget, K as FleetSpawnBudgetError, L as ICoordinator, M as IFleetManager, N as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, O as RefactorPhase, P as RefactorPlan, S as SECURITY_SCANNER_AGENT, Q as SharedFileEntry, T as SharedFileSnapshot, U as SubagentPromptParts, V as applyRosterBudget, W as attachAutoExtend, X as composeDirectorPrompt, Y as composeSubagentPrompt, Z as createDelegateTool, _ as getAgentDefinition, $ as makeAskTool, a0 as makeAssignTool, a1 as makeAwaitTasksTool, a2 as makeCollabDebugTool, a3 as makeDirectorSessionFactory, a4 as makeFleetEmitTool, a5 as makeFleetHealthTool, a6 as makeFleetSessionTool, a7 as makeFleetStatusTool, a8 as makeFleetUsageTool, a9 as makeRollUpTool, aa as makeSpawnTool, ab as makeTerminateTool, ac as makeWorkCompleteTool, ad as rosterSummaryFromConfigs } from '../null-fleet-bus-T-s3JaOt.js';
2
- import { b as AgentDefinition } from '../multi-agent-coordinator-DoVSBFNx.js';
3
- export { T as AGENT_TOOL_PRESETS, A as AgentBudgetTier, a as AgentCapability, c as AgentPhase, D as DEFAULT_DISPATCH_ROLE, d as DefaultMultiAgentCoordinator, e as DispatchCandidate, f as DispatchClassifier, g as DispatchMethod, h as DispatchOptions, i as DispatchResult, H as HEAVY_BUDGET, L as LIGHT_BUDGET, M as MEDIUM_BUDGET, j as MultiAgentCoordinatorOptions, k as dispatchAgent, m as makeLLMClassifier, s as scoreAgents } from '../multi-agent-coordinator-DoVSBFNx.js';
4
- export { c as BudgetExceededError, d as BudgetKind, e as BudgetLimits, f as BudgetNegotiationMode, g as BudgetThresholdDecision, h as BudgetThresholdHandler, i as BudgetThresholdSignal, j as BudgetUsage, m as SubagentBudget } from '../multi-agent-C1O8EFzb.js';
5
- export { A as AgentFactory, a as AgentFactoryResult, b as AgentRunnerOptions, F as FleetBus, c as FleetEvent, d as FleetHandler, e as FleetUsage, f as FleetUsageAggregator, S as SubagentUsageSnapshot, m as makeAgentSubagentRunner } from '../agent-subagent-runner-KwufTWwn.js';
6
- export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-DBBGP5O4.js';
1
+ export { A as ACP_AGENTS, a as AGENTS_BY_PHASE, b as AGENT_CATALOG, c as ALL_AGENT_DEFINITIONS, d as ALL_FLEET_AGENTS, e as AUDIT_LOG_AGENT, f as AutoExtendCeiling, g as AutoExtendPolicy, B as BUG_HUNTER_AGENT, h as BugFinding, C as CollabBudgetConfig, i as CollabBudgetOverrides, j as CollabBudgetWarningPayload, k as CollabDebugReport, l as CollabSession, m as CollabSessionOptions, n as CreateDelegateToolOptions, o as CriticConcern, p as CriticEvaluation, D as DEFAULT_DIRECTOR_PREAMBLE, q as DEFAULT_SUBAGENT_BASELINE, r as DelegateHost, s as Director, t as DirectorAlert, u as DirectorAlertLevel, v as DirectorCancelCollabPayload, w as DirectorPromptParts, x as DirectorSessionFactory, y as DirectorSessionFactoryOptions, F as FLEET_ROSTER, z as FLEET_ROSTER_BUDGETS, E as FLEET_ROSTER_WITHACP, G as FleetCostCapError, H as FleetManager, I as FleetManagerOptions, J as FleetRosterBudget, K as FleetSpawnBudgetError, L as ICoordinator, M as IFleetManager, N as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, O as RefactorPhase, P as RefactorPlan, S as SECURITY_SCANNER_AGENT, Q as SharedFileEntry, T as SharedFileSnapshot, U as SubagentPromptParts, V as applyRosterBudget, W as attachAutoExtend, X as composeDirectorPrompt, Y as composeSubagentPrompt, Z as createDelegateTool, _ as getAgentDefinition, $ as makeAskTool, a0 as makeAssignTool, a1 as makeAwaitTasksTool, a2 as makeCollabDebugTool, a3 as makeDirectorSessionFactory, a4 as makeFleetEmitTool, a5 as makeFleetHealthTool, a6 as makeFleetSessionTool, a7 as makeFleetStatusTool, a8 as makeFleetUsageTool, a9 as makeRollUpTool, aa as makeSpawnTool, ab as makeTerminateTool, ac as makeWorkCompleteTool, ad as rosterSummaryFromConfigs } from '../null-fleet-bus-B3WdVY9i.js';
2
+ import { b as AgentDefinition } from '../multi-agent-coordinator-CjG-FZKj.js';
3
+ export { T as AGENT_TOOL_PRESETS, A as AgentBudgetTier, a as AgentCapability, c as AgentPhase, D as DEFAULT_DISPATCH_ROLE, d as DefaultMultiAgentCoordinator, e as DispatchCandidate, f as DispatchClassifier, g as DispatchMethod, h as DispatchOptions, i as DispatchResult, H as HEAVY_BUDGET, L as LIGHT_BUDGET, M as MEDIUM_BUDGET, j as MultiAgentCoordinatorOptions, k as dispatchAgent, m as makeLLMClassifier, s as scoreAgents } from '../multi-agent-coordinator-CjG-FZKj.js';
4
+ export { c as BudgetExceededError, d as BudgetKind, e as BudgetLimits, f as BudgetNegotiationMode, g as BudgetThresholdDecision, h as BudgetThresholdHandler, i as BudgetThresholdSignal, j as BudgetUsage, m as SubagentBudget } from '../multi-agent-C8Z1i__e.js';
5
+ export { A as AgentFactory, a as AgentFactoryResult, b as AgentRunnerOptions, F as FleetBus, c as FleetEvent, d as FleetHandler, e as FleetUsage, f as FleetUsageAggregator, S as SubagentUsageSnapshot, m as makeAgentSubagentRunner } from '../agent-subagent-runner-DuRtZmhl.js';
6
+ export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-D_XcS2HL.js';
7
7
  import '../context-7u93AcGD.js';
8
8
  import 'node:events';
9
9
  import '../director-state-BmYi3DGA.js';
10
- import '../events-Bw1K5E6K.js';
11
- import '../index-DgQWnZxP.js';
10
+ import '../events-BrQiweXN.js';
11
+ import '../index-DAHEM_II.js';
12
12
  import '../logger-DDd5C--Z.js';
13
13
  import '../system-prompt-CM6zOhd2.js';
14
14
  import '../observability-BhnVLBLS.js';
@@ -286,12 +286,14 @@ var InMemoryAgentBridge = class {
286
286
  timeoutMs;
287
287
  /** Guards request() so concurrent calls on the same id can't silently overwrite. */
288
288
  inflightGuards = /* @__PURE__ */ new Set();
289
+ /** Stores the transport unsubscribe function so it can be called on stop(). */
290
+ _transportUnsubscribe;
289
291
  constructor(config, transport) {
290
292
  this.agentId = config.agentId;
291
293
  this.coordinatorId = config.coordinatorId;
292
294
  this.transport = transport;
293
295
  this.timeoutMs = config.timeoutMs ?? 3e4;
294
- this.transport.subscribe(this.agentId, (msg) => {
296
+ this._transportUnsubscribe = this.transport.subscribe(this.agentId, (msg) => {
295
297
  if (msg.type === "heartbeat") return;
296
298
  const pending = this.pendingRequests.get(msg.id);
297
299
  if (pending) {
@@ -366,6 +368,8 @@ var InMemoryAgentBridge = class {
366
368
  this.pendingRequests.clear();
367
369
  this.inflightGuards.clear();
368
370
  this.subscriptions.clear();
371
+ this._transportUnsubscribe?.();
372
+ this._transportUnsubscribe = void 0;
369
373
  await this.transport.close(this.agentId);
370
374
  }
371
375
  };
@@ -561,14 +565,36 @@ var FleetUsageAggregator = class {
561
565
  constructor(bus, priceLookup, metaLookup) {
562
566
  this.priceLookup = priceLookup;
563
567
  this.metaLookup = metaLookup;
564
- bus.filter("provider.response", (e) => this.onProviderResponse(e));
565
- bus.filter("tool.executed", (e) => this.onToolExecuted(e));
566
- bus.filter("iteration.started", (e) => this.onIterationStarted(e));
568
+ this.unsub.push(bus.filter("provider.response", (e) => this.onProviderResponse(e)));
569
+ this.unsub.push(bus.filter("tool.executed", (e) => this.onToolExecuted(e)));
570
+ this.unsub.push(bus.filter("iteration.started", (e) => this.onIterationStarted(e)));
567
571
  }
568
572
  priceLookup;
569
573
  metaLookup;
570
574
  perSubagent = /* @__PURE__ */ new Map();
571
575
  total = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0 };
576
+ unsub = new Array();
577
+ /**
578
+ * Remove a terminated subagent's data from the aggregator and subtract its
579
+ * contribution from the running totals. Call this when a subagent is removed
580
+ * from the fleet so the aggregator doesn't accumulate unbounded data for
581
+ * entities that will never emit events again.
582
+ */
583
+ removeSubagent(subagentId) {
584
+ const snap = this.perSubagent.get(subagentId);
585
+ if (!snap) return;
586
+ this.perSubagent.delete(subagentId);
587
+ this.total.input -= snap.input;
588
+ this.total.output -= snap.output;
589
+ this.total.cacheRead -= snap.cacheRead;
590
+ this.total.cacheWrite -= snap.cacheWrite;
591
+ this.total.cost -= snap.cost;
592
+ }
593
+ /** Disposes all fleet-bus subscriptions. Call when the aggregator is no longer needed. */
594
+ dispose() {
595
+ for (const off of this.unsub) off();
596
+ this.unsub.length = 0;
597
+ }
572
598
  /** Live snapshot — safe to call from a tool's execute() body. */
573
599
  snapshot() {
574
600
  return {
@@ -998,8 +1024,9 @@ var SubagentBudget = class _SubagentBudget {
998
1024
  if (elapsedMs !== void 0) {
999
1025
  const idle = this.idleMs();
1000
1026
  if (this.limits.idleTimeoutMs !== void 0 && idle > this.limits.idleTimeoutMs) {
1001
- exceeded.push({ kind: "timeout", used: idle, limit: this.limits.idleTimeoutMs });
1002
- } else if (this.limits.timeoutMs !== void 0 && elapsedMs > this.limits.timeoutMs) {
1027
+ exceeded.push({ kind: "idle_timeout", used: idle, limit: this.limits.idleTimeoutMs });
1028
+ }
1029
+ if (this.limits.timeoutMs !== void 0 && elapsedMs > this.limits.timeoutMs) {
1003
1030
  exceeded.push({ kind: "timeout", used: elapsedMs, limit: this.limits.timeoutMs });
1004
1031
  }
1005
1032
  }
@@ -3819,10 +3846,6 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
3819
3846
  this.drainPendingAsAborted("Coordinator stopAll() drained the pending queue");
3820
3847
  await Promise.allSettled([...this.subagents.keys()].map((id) => this.stop(id)));
3821
3848
  }
3822
- async remove(subagentId) {
3823
- await this.stop(subagentId);
3824
- this.subagents.delete(subagentId);
3825
- }
3826
3849
  /**
3827
3850
  * Get current coordinator stats for monitoring/debugging.
3828
3851
  */
@@ -4088,7 +4111,7 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
4088
4111
  durationMs: Date.now() - startTime
4089
4112
  };
4090
4113
  } catch (err) {
4091
- const status = err instanceof BudgetExceededError && err.kind === "timeout" ? "timeout" : subagent.abortController.signal.aborted ? "stopped" : "failed";
4114
+ const status = err instanceof BudgetExceededError && (err.kind === "timeout" || err.kind === "idle_timeout") ? "timeout" : subagent.abortController.signal.aborted ? "stopped" : "failed";
4092
4115
  const usage = budget.usage();
4093
4116
  result = {
4094
4117
  subagentId,
@@ -4242,6 +4265,30 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
4242
4265
  });
4243
4266
  }
4244
4267
  }
4268
+ /**
4269
+ * Stop a subagent and remove it from the coordinator. Releases all
4270
+ * associated resources (AbortController, context, budget state).
4271
+ * The subagent entry is deleted so the id can be reused in a future spawn.
4272
+ */
4273
+ async remove(subagentId) {
4274
+ const subagent = this.subagents.get(subagentId);
4275
+ if (!subagent) return;
4276
+ if (subagent.status === "running" || subagent.status === "idle") {
4277
+ this.terminating.add(subagentId);
4278
+ subagent.abortController.abort();
4279
+ subagent.status = "stopped";
4280
+ }
4281
+ this.subagents.delete(subagentId);
4282
+ this.terminating.delete(subagentId);
4283
+ this.pendingTasks = this.pendingTasks.filter((t) => t.subagentId !== subagentId);
4284
+ this.fleetBus?.emit({
4285
+ subagentId,
4286
+ ts: Date.now(),
4287
+ type: "subagent.removed",
4288
+ payload: { subagentId }
4289
+ });
4290
+ this.emitCoordinatorStats();
4291
+ }
4245
4292
  isDone() {
4246
4293
  if (this.config.doneCondition.type === "all_tasks_done") {
4247
4294
  return this.pendingTasks.length === 0 && this.inFlight === 0;
@@ -4265,7 +4312,8 @@ function classifySubagentError(err, hints = {}) {
4265
4312
  tool_calls: "budget_tool_calls",
4266
4313
  tokens: "budget_tokens",
4267
4314
  cost: "budget_cost",
4268
- timeout: "budget_timeout"
4315
+ timeout: "budget_timeout",
4316
+ idle_timeout: "budget_timeout"
4269
4317
  };
4270
4318
  return {
4271
4319
  kind: map[err.kind],
@@ -5165,7 +5213,7 @@ Emit each evaluation immediately. Do not wait until you have read all reports.`;
5165
5213
  this.cancel(`Director cancelled: ${role} ${payload.kind} threshold`);
5166
5214
  return;
5167
5215
  }
5168
- if (payload.kind === "timeout") {
5216
+ if (payload.kind === "timeout" || payload.kind === "idle_timeout") {
5169
5217
  const progress = this.progressBySubagent.get(e.subagentId) ?? 0;
5170
5218
  const lastProgress = this.lastTimeoutProgress.get(e.subagentId) ?? -1;
5171
5219
  if (progress <= lastProgress) {
@@ -5903,7 +5951,7 @@ var Director = class {
5903
5951
  if (needsNickname) {
5904
5952
  const role = config.role ?? "subagent";
5905
5953
  if (this.fleetManager) {
5906
- this.fleetManager.assignNicknameAndRecord("", config, priceLookup);
5954
+ this.fleetManager.assignNicknameAndRecord(config);
5907
5955
  } else {
5908
5956
  config.name = assignNickname(role, this._usedNicknames);
5909
5957
  this._usedNicknames.add(config.name.split(" ")[0].toLowerCase().replace(/[^a-z0-9-]/g, "-"));
@@ -5911,9 +5959,7 @@ var Director = class {
5911
5959
  }
5912
5960
  result = await this.coordinator.spawn(config);
5913
5961
  if (this.fleetManager) {
5914
- if (!needsNickname) {
5915
- this.fleetManager.recordSpawn(result.subagentId, config, priceLookup);
5916
- }
5962
+ this.fleetManager.recordSpawn(result.subagentId, config, priceLookup);
5917
5963
  } else {
5918
5964
  this.spawnCount += 1;
5919
5965
  this.subagentMeta.set(result.subagentId, {
@@ -6201,6 +6247,7 @@ var Director = class {
6201
6247
  }
6202
6248
  async remove(subagentId) {
6203
6249
  await this.coordinator.remove(subagentId);
6250
+ this.usage.removeSubagent(subagentId);
6204
6251
  }
6205
6252
  status() {
6206
6253
  const base = this.coordinator.getStatus();
@@ -6536,6 +6583,7 @@ function createDelegateTool(opts) {
6536
6583
  if (timer) clearTimeout(timer);
6537
6584
  offTool();
6538
6585
  offIter();
6586
+ offProgress();
6539
6587
  resolve(value);
6540
6588
  };
6541
6589
  const arm = () => {
@@ -6547,6 +6595,7 @@ function createDelegateTool(opts) {
6547
6595
  };
6548
6596
  const offTool = dir.fleet.filter("tool.executed", bump);
6549
6597
  const offIter = dir.fleet.filter("iteration.started", bump);
6598
+ const offProgress = dir.fleet.filter("tool.progress", bump);
6550
6599
  arm();
6551
6600
  dir.awaitTasks([taskId]).then((r) => finish(r[0] ?? { __timeout: true })).catch(() => finish({ __timeout: true }));
6552
6601
  });
@@ -7578,7 +7627,8 @@ var FIELD_BY_KIND = {
7578
7627
  tool_calls: "maxToolCalls",
7579
7628
  tokens: "maxTokens",
7580
7629
  cost: "maxCostUsd",
7581
- timeout: "timeoutMs"
7630
+ timeout: "timeoutMs",
7631
+ idle_timeout: "timeoutMs"
7582
7632
  };
7583
7633
  function attachAutoExtend(events, policy = {}) {
7584
7634
  const factor = policy.factor ?? 0.5;
@@ -7596,7 +7646,7 @@ function attachAutoExtend(events, policy = {}) {
7596
7646
  }),
7597
7647
  events.on("budget.threshold_reached", (e) => {
7598
7648
  const { kind, limit, extend, deny } = e;
7599
- if (kind === "timeout") {
7649
+ if (kind === "timeout" || kind === "idle_timeout") {
7600
7650
  if (progress > lastTimeoutProgress) {
7601
7651
  lastTimeoutProgress = progress;
7602
7652
  const next2 = Math.min(Math.ceil(limit * (1 + factor)), ceiling.timeoutMs);
@@ -7763,14 +7813,18 @@ var FleetManager = class {
7763
7813
  * Call this INSTEAD of `recordSpawn` when you want automatic nicknames.
7764
7814
  * The nickname is written back to `config.name` BEFORE the coordinator
7765
7815
  * sees the config, so the manifest, logs, and fleet UI all show it.
7816
+ *
7817
+ * NOTE: This method ONLY assigns the nickname and marks it used.
7818
+ * The caller MUST call `recordSpawn(subagentId, config, priceLookup)` AFTER
7819
+ * `coordinator.spawn()` returns with the real subagentId. This is because
7820
+ * the subagentId is not known until after the coordinator creates the subagent.
7766
7821
  */
7767
- assignNicknameAndRecord(subagentId, config, priceLookup) {
7822
+ assignNicknameAndRecord(config) {
7768
7823
  const role = config.role ?? "subagent";
7769
7824
  const nickname = assignNickname(role, this._usedNicknames);
7770
7825
  const baseKey = nickname.split(" ")[0].toLowerCase().replace(/[^a-z0-9-]/g, "-");
7771
7826
  this._usedNicknames.add(baseKey);
7772
7827
  config.name = nickname;
7773
- this.recordSpawn(subagentId, config, priceLookup);
7774
7828
  return nickname;
7775
7829
  }
7776
7830
  /**
@@ -7948,6 +8002,14 @@ var FleetManager = class {
7948
8002
  }));
7949
8003
  return { pending, live: [] };
7950
8004
  }
8005
+ /** Release all resources: clear the manifest debounce timer and dispose the usage aggregator. */
8006
+ dispose() {
8007
+ if (this.manifestTimer) {
8008
+ clearTimeout(this.manifestTimer);
8009
+ this.manifestTimer = null;
8010
+ }
8011
+ this.usage.dispose();
8012
+ }
7951
8013
  };
7952
8014
 
7953
8015
  export { ACP_AGENTS, AGENTS_BY_PHASE, AGENT_CATALOG, TOOLS as AGENT_TOOL_PRESETS, ALL_AGENT_DEFINITIONS, ALL_FLEET_AGENTS, AUDIT_LOG_AGENT, BUG_HUNTER_AGENT, BUILD_AGENTS, BudgetExceededError, BudgetThresholdSignal, CollabSession, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_DISPATCH_ROLE, DEFAULT_SUBAGENT_BASELINE, DELIVERY_AGENTS, DISCOVERY_AGENTS, DOMAIN_AGENTS, DefaultMultiAgentCoordinator, Director, DirectorAlertLevel, FLEET_ROSTER, FLEET_ROSTER_BUDGETS, FLEET_ROSTER_WITHACP, FleetBus, FleetCostCapError, FleetManager, FleetSpawnBudgetError, FleetUsageAggregator, HEAVY_BUDGET, InMemoryAgentBridge, InMemoryBridgeTransport, KNOWLEDGE_AGENTS, LIGHT_BUDGET, MEDIUM_BUDGET, META_AGENTS, NULL_FLEET_BUS, PLANNING_AGENTS, REFACTOR_PLANNER_AGENT, REVIEW_AGENTS, SECURITY_SCANNER_AGENT, SubagentBudget, VERIFY_AGENTS, applyRosterBudget, attachAutoExtend, composeDirectorPrompt, composeSubagentPrompt, createDelegateTool, createMessage, dispatchAgent, getAgentDefinition, makeAgentSubagentRunner, makeAskTool, makeAssignTool, makeAwaitTasksTool, makeCollabDebugTool, makeDirectorSessionFactory, makeFleetEmitTool, makeFleetHealthTool, makeFleetSessionTool, makeFleetStatusTool, makeFleetUsageTool, makeLLMClassifier, makeRollUpTool, makeSpawnTool, makeTerminateTool, makeWorkCompleteTool, rosterSummaryFromConfigs, scoreAgents };