@wrongstack/core 0.276.4 → 0.277.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/{agent-bridge-D7A-eu3C.d.ts → agent-bridge-BFJ2ODzI.d.ts} +1 -1
  2. package/dist/{agent-subagent-runner-CEuw4ATz.d.ts → agent-subagent-runner-BimKihiC.d.ts} +7 -7
  3. package/dist/{brain-BLOyN5ZP.d.ts → brain-CCfuEOdp.d.ts} +1 -1
  4. package/dist/{compactor-DcBpaJsI.d.ts → compactor-D3BGw26y.d.ts} +1 -1
  5. package/dist/{config-Bf5mj-ad.d.ts → config-DAOjriz9.d.ts} +1 -1
  6. package/dist/{context-CLnUMW5g.d.ts → context-DPlA6kid.d.ts} +5 -6
  7. package/dist/coordination/index.d.ts +17 -17
  8. package/dist/coordination/index.js +38 -14
  9. package/dist/coordination/index.js.map +1 -1
  10. package/dist/defaults/index.d.ts +27 -27
  11. package/dist/defaults/index.js +177 -93
  12. package/dist/defaults/index.js.map +1 -1
  13. package/dist/execution/index.d.ts +15 -15
  14. package/dist/execution/index.js +13 -1
  15. package/dist/execution/index.js.map +1 -1
  16. package/dist/execution/prompt-enhancer.d.ts +1 -1
  17. package/dist/extension/index.d.ts +6 -6
  18. package/dist/{global-mailbox-Iqfkgmwu.d.ts → global-mailbox-Dr4cTKqL.d.ts} +1 -1
  19. package/dist/{goal-store-DGb6b5Ed.d.ts → goal-store-C1uH4srH.d.ts} +1 -1
  20. package/dist/hq/index.d.ts +5 -5
  21. package/dist/{index-Cn0NOshr.d.ts → index-DJXj-dcr.d.ts} +5 -5
  22. package/dist/{index-L4RZN9jJ.d.ts → index-cMEmzCVN.d.ts} +23 -5
  23. package/dist/index.d.ts +41 -41
  24. package/dist/index.js +220 -111
  25. package/dist/index.js.map +1 -1
  26. package/dist/infrastructure/index.d.ts +6 -6
  27. package/dist/infrastructure/index.js +4 -1
  28. package/dist/infrastructure/index.js.map +1 -1
  29. package/dist/kernel/index.d.ts +11 -11
  30. package/dist/{mcp-servers-CuZGf9fI.d.ts → mcp-servers-CFb60-pH.d.ts} +3 -3
  31. package/dist/models/index.d.ts +5 -5
  32. package/dist/{models-registry-8XOdxWQu.d.ts → models-registry-5Ufn7f2m.d.ts} +1 -1
  33. package/dist/{multi-agent-coordinator-CiRtKVTk.d.ts → multi-agent-coordinator-CcrcncvG.d.ts} +1 -1
  34. package/dist/{null-fleet-bus-d9G-bVy9.d.ts → null-fleet-bus-C9KsYyrI.d.ts} +13 -6
  35. package/dist/observability/index.d.ts +2 -2
  36. package/dist/{path-resolver-BhIb6mtd.d.ts → path-resolver-CEeX9I7O.d.ts} +3 -3
  37. package/dist/{permission-BCbQDR2s.d.ts → permission-DbsGOA1C.d.ts} +7 -6
  38. package/dist/{permission-policy-C0ikndX_.d.ts → permission-policy-BpEea3r7.d.ts} +12 -14
  39. package/dist/{pipeline-Dl6XbfE7.d.ts → pipeline-CEjBjzVA.d.ts} +2 -2
  40. package/dist/{provider-model-resolve-B70epO19.d.ts → provider-model-resolve-BpfXp3Jj.d.ts} +3 -3
  41. package/dist/{provider-runner-DZ808MSM.d.ts → provider-runner-CnOSr5BN.d.ts} +3 -3
  42. package/dist/{retry-policy-Dt3_z8Aj.d.ts → retry-policy-Git9WF6d.d.ts} +1 -1
  43. package/dist/sdd/index.d.ts +9 -9
  44. package/dist/{secret-vault-BUJ2d1gB.d.ts → secret-vault-DDSMHqIm.d.ts} +1 -1
  45. package/dist/security/index.d.ts +5 -5
  46. package/dist/security/index.js +173 -94
  47. package/dist/security/index.js.map +1 -1
  48. package/dist/{selector-BCkWgdwy.d.ts → selector-Cq72C0Oy.d.ts} +1 -1
  49. package/dist/{session-event-bridge-CMvIO59_.d.ts → session-event-bridge-DG94B3Bk.d.ts} +1 -1
  50. package/dist/{session-reader-C8aiChUu.d.ts → session-reader-BzT-iMQT.d.ts} +1 -1
  51. package/dist/storage/index.d.ts +11 -11
  52. package/dist/{strategy-compactor-DI1OHVbB.d.ts → strategy-compactor-Bt_ZH6R0.d.ts} +10 -10
  53. package/dist/{todos-checkpoint-Ddd2CGr0.d.ts → todos-checkpoint-CH1pcua9.d.ts} +5 -5
  54. package/dist/{tool-executor-Bmd5Ygoo.d.ts → tool-executor-SVFq7IOR.d.ts} +9 -9
  55. package/dist/tools/index.d.ts +2 -2
  56. package/dist/tools/index.js +5 -6
  57. package/dist/tools/index.js.map +1 -1
  58. package/dist/types/index.d.ts +19 -19
  59. package/dist/types/index.js +13 -1
  60. package/dist/types/index.js.map +1 -1
  61. package/dist/utils/index.d.ts +17 -3
  62. package/dist/utils/index.js +5 -1
  63. package/dist/utils/index.js.map +1 -1
  64. package/dist/{worktree-manager-DBdl_5rs.d.ts → worktree-manager-C4YIf1Fa.d.ts} +1 -1
  65. package/instructions/leader-after-task.md +6 -0
  66. package/package.json +2 -2
  67. package/skills/output-standards/SKILL.md +1 -0
  68. package/skills/research-web/SKILL.md +1 -1
@@ -1,4 +1,4 @@
1
- import { B as BridgeTransport, a as BridgeMessage, A as AgentBridge, b as AgentBridgeConfig } from './agent-subagent-runner-CEuw4ATz.js';
1
+ import { B as BridgeTransport, a as BridgeMessage, A as AgentBridge, b as AgentBridgeConfig } from './agent-subagent-runner-BimKihiC.js';
2
2
 
3
3
  /**
4
4
  * In-memory pub/sub transport for agent-to-agent messaging.
@@ -1,12 +1,12 @@
1
- import { c as ToolCallPipelinePayload, d as ToolWrapper, E as ExtensionRegistry, S as SystemPromptContributor, e as ToolRegistry, P as ProviderRegistry, A as AgentPipelines, f as ToolExecutorLike, g as AgentInit, h as AgentInput, R as RunResult } from './index-Cn0NOshr.js';
2
- import { C as Container, R as ReadonlyPipeline, a as Renderer } from './pipeline-Dl6XbfE7.js';
3
- import { E as EventBus, a as EventName, L as Listener } from './brain-BLOyN5ZP.js';
4
- import { R as RetryPolicy, E as ErrorHandler } from './retry-policy-Dt3_z8Aj.js';
1
+ import { c as ToolCallPipelinePayload, d as ToolWrapper, E as ExtensionRegistry, S as SystemPromptContributor, e as ToolRegistry, P as ProviderRegistry, A as AgentPipelines, f as ToolExecutorLike, g as AgentInit, h as AgentInput, R as RunResult } from './index-DJXj-dcr.js';
2
+ import { C as Container, R as ReadonlyPipeline, a as Renderer } from './pipeline-CEjBjzVA.js';
3
+ import { E as EventBus, a as EventName, L as Listener } from './brain-CCfuEOdp.js';
4
+ import { R as RetryPolicy, E as ErrorHandler } from './retry-policy-Git9WF6d.js';
5
5
  import { L as Logger } from './logger-B63L5bTg.js';
6
6
  import { T as Tracer } from './observability-D-HZN_mF.js';
7
- import { P as PermissionPolicy } from './permission-BCbQDR2s.js';
8
- import { U as Usage, C as Context, J as JSONSchema, c as Request, d as Response, i as ContentBlock, r as TextBlock, T as Tool, P as Provider, u as RunOptions } from './context-CLnUMW5g.js';
9
- import { W as WireFamily, H as HookEvent, f as HookMatcher, I as InProcessHook, C as Config } from './config-Bf5mj-ad.js';
7
+ import { P as PermissionPolicy } from './permission-DbsGOA1C.js';
8
+ import { U as Usage, C as Context, J as JSONSchema, c as Request, d as Response, i as ContentBlock, r as TextBlock, T as Tool, P as Provider, u as RunOptions } from './context-DPlA6kid.js';
9
+ import { W as WireFamily, H as HookEvent, f as HookMatcher, I as InProcessHook, C as Config } from './config-DAOjriz9.js';
10
10
 
11
11
  /**
12
12
  * Single fleet-wide event with subagent attribution. Whatever a child
@@ -1,4 +1,4 @@
1
- import { U as Usage, C as Context, l as ToolErrorCategory, m as ToolProgressEvent, T as Tool, n as ToolOutputMetadata } from './context-CLnUMW5g.js';
1
+ import { U as Usage, C as Context, l as ToolErrorCategory, m as ToolProgressEvent, T as Tool, n as ToolOutputMetadata } from './context-DPlA6kid.js';
2
2
 
3
3
  type MemoryScope = 'project-agents' | 'project-memory' | 'user-memory';
4
4
  type MemoryType = 'fact' | 'decision' | 'convention' | 'preference' | 'reference' | 'anti_pattern';
@@ -1,4 +1,4 @@
1
- import { C as Context } from './context-CLnUMW5g.js';
1
+ import { C as Context } from './context-DPlA6kid.js';
2
2
 
3
3
  interface CompactRepairReport {
4
4
  removedToolUses: string[];
@@ -1,4 +1,4 @@
1
- import { a as ReasoningConfig, o as Capabilities, h as Permission, p as ReasoningEffort, q as CacheTtl } from './context-CLnUMW5g.js';
1
+ import { a as ReasoningConfig, o as Capabilities, h as Permission, p as ReasoningEffort, q as CacheTtl } from './context-DPlA6kid.js';
2
2
 
3
3
  type ContextWindowModeId = 'balanced' | 'frugal' | 'deep' | 'archival';
4
4
  type ContextWindowAggressiveOn = 'hard' | 'soft' | 'warn';
@@ -413,9 +413,8 @@ declare function isSddError(err: unknown): err is SddError;
413
413
 
414
414
  type Permission = 'auto' | 'confirm' | 'deny';
415
415
  /**
416
- * Risk tier for tools in YOLO mode. YOLO auto-approves everything by default,
417
- * including destructive calls. Use `--confirm-destructive` to re-enable
418
- * confirmation prompts for destructive operations.
416
+ * Risk tier for tools in YOLO mode. YOLO auto-approves normal project work,
417
+ * while clearly destructive calls still require confirmation.
419
418
  *
420
419
  * - `safe` — read-only, no side effects (read, glob, grep, etc.)
421
420
  * - `standard` — non-destructive writes and mutations (write, edit, safe shell commands)
@@ -485,9 +484,9 @@ interface Tool<I = unknown, O = unknown> {
485
484
  mutating: boolean;
486
485
  /**
487
486
  * Risk tier for selective YOLO gating. When YOLO is active, clearly
488
- * destructive calls still emit `confirm` unless the destructive override is
489
- * set. Defaults to `standard` when omitted — callers should always check
490
- * `riskTier` after the basic permission decision.
487
+ * destructive calls still emit `confirm`. Defaults to `standard` when
488
+ * omitted — callers should always check `riskTier` after the basic
489
+ * permission decision.
491
490
  */
492
491
  riskTier?: RiskTier | undefined;
493
492
  /**
@@ -1,26 +1,26 @@
1
- import { E as EventBus, B as BrainArbiter, f as BrainDecisionOption, k as BrainRisk, h as BrainDecisionRequest, e as BrainDecision, i as BrainDecisionSource } from '../brain-BLOyN5ZP.js';
2
- export { g as BrainDecisionQueue, j as BrainFallback, D as DefaultBrainArbiter, l as DefaultBrainArbiterOptions, H as HumanEscalatingBrainArbiter, O as ObservableBrainArbiter, w as formatHumanPrompt } from '../brain-BLOyN5ZP.js';
3
- import { H as FleetManager, s as Director } from '../null-fleet-bus-d9G-bVy9.js';
4
- 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, 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, I as FleetManagerOptions, J as FleetRosterBudget, K as FleetSpawnBudgetError, L as ICoordinator, M as IFleetManager, N as LargeAnswerStore, O as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, P as RefactorPhase, Q as RefactorPlan, S as SECURITY_SCANNER_AGENT, T as SharedFileEntry, U as SharedFileSnapshot, V as SubagentPromptParts, W as applyRosterBudget, X as attachAutoExtend, Y as composeDirectorPrompt, Z as composeSubagentPrompt, _ as createDelegateTool, $ as getAgentDefinition, a0 as makeAskResultTool, a1 as makeAskTool, a2 as makeAssignTool, a3 as makeAwaitTasksTool, a4 as makeCollabDebugTool, a5 as makeDirectorSessionFactory, a6 as makeFleetEmitTool, a7 as makeFleetHealthTool, a7 as makeFleetSessionTool, a7 as makeFleetStatusTool, a7 as makeFleetTool, a7 as makeFleetUsageTool, a8 as makeRollUpTool, a9 as makeSpawnTool, aa as makeTerminateAllTool, ab as makeTerminateTool, ac as makeWorkCompleteTool, ad as rosterSummaryFromConfigs } from '../null-fleet-bus-d9G-bVy9.js';
5
- import { b as AgentDefinition } from '../multi-agent-coordinator-CiRtKVTk.js';
6
- export { T as AGENT_TOOL_PRESETS, c as AgentBudgetTier, d as AgentCapability, A as AgentPhase, e as DEFAULT_DISPATCH_ROLE, a as DefaultMultiAgentCoordinator, f as DispatchCandidate, D 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-CiRtKVTk.js';
7
- import { F as FleetBus } from '../agent-subagent-runner-CEuw4ATz.js';
8
- export { i as AgentFactory, w as AgentFactoryResult, x as AgentRunnerOptions, y as BudgetExceededError, z as BudgetKind, E as BudgetLimits, G as BudgetNegotiationMode, H as BudgetThresholdDecision, I as BudgetThresholdHandler, J as BudgetThresholdSignal, K as BudgetUsage, N as DECISION_TIMEOUT_MS, O as FleetEvent, Q as FleetHandler, j as FleetUsage, k as FleetUsageAggregator, R as SubagentBudget, Z as SubagentUsageSnapshot, _ as TIMEOUT_PREEMPT_FRACTION, a0 as makeAgentSubagentRunner, a1 as withDisabledToolFiltering } from '../agent-subagent-runner-CEuw4ATz.js';
9
- export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-D7A-eu3C.js';
1
+ import { E as EventBus, B as BrainArbiter, f as BrainDecisionOption, k as BrainRisk, h as BrainDecisionRequest, e as BrainDecision, i as BrainDecisionSource } from '../brain-CCfuEOdp.js';
2
+ export { g as BrainDecisionQueue, j as BrainFallback, D as DefaultBrainArbiter, l as DefaultBrainArbiterOptions, H as HumanEscalatingBrainArbiter, O as ObservableBrainArbiter, w as formatHumanPrompt } from '../brain-CCfuEOdp.js';
3
+ import { H as FleetManager, s as Director } from '../null-fleet-bus-C9KsYyrI.js';
4
+ 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, 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, I as FleetManagerOptions, J as FleetRosterBudget, K as FleetSpawnBudgetError, L as ICoordinator, M as IFleetManager, N as LargeAnswerStore, O as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, P as RefactorPhase, Q as RefactorPlan, S as SECURITY_SCANNER_AGENT, T as SharedFileEntry, U as SharedFileSnapshot, V as SubagentPromptParts, W as applyRosterBudget, X as attachAutoExtend, Y as composeDirectorPrompt, Z as composeSubagentPrompt, _ as createDelegateTool, $ as getAgentDefinition, a0 as makeAskResultTool, a1 as makeAskTool, a2 as makeAssignTool, a3 as makeAwaitTasksTool, a4 as makeCollabDebugTool, a5 as makeDirectorSessionFactory, a6 as makeFleetEmitTool, a7 as makeFleetHealthTool, a7 as makeFleetSessionTool, a7 as makeFleetStatusTool, a7 as makeFleetTool, a7 as makeFleetUsageTool, a8 as makeRollUpTool, a9 as makeSpawnTool, aa as makeTerminateAllTool, ab as makeTerminateTool, ac as makeWorkCompleteTool, ad as rosterSummaryFromConfigs } from '../null-fleet-bus-C9KsYyrI.js';
5
+ import { b as AgentDefinition } from '../multi-agent-coordinator-CcrcncvG.js';
6
+ export { T as AGENT_TOOL_PRESETS, c as AgentBudgetTier, d as AgentCapability, A as AgentPhase, e as DEFAULT_DISPATCH_ROLE, a as DefaultMultiAgentCoordinator, f as DispatchCandidate, D 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-CcrcncvG.js';
7
+ import { F as FleetBus } from '../agent-subagent-runner-BimKihiC.js';
8
+ export { i as AgentFactory, w as AgentFactoryResult, x as AgentRunnerOptions, y as BudgetExceededError, z as BudgetKind, E as BudgetLimits, G as BudgetNegotiationMode, H as BudgetThresholdDecision, I as BudgetThresholdHandler, J as BudgetThresholdSignal, K as BudgetUsage, N as DECISION_TIMEOUT_MS, O as FleetEvent, Q as FleetHandler, j as FleetUsage, k as FleetUsageAggregator, R as SubagentBudget, Z as SubagentUsageSnapshot, _ as TIMEOUT_PREEMPT_FRACTION, a0 as makeAgentSubagentRunner, a1 as withDisabledToolFiltering } from '../agent-subagent-runner-BimKihiC.js';
9
+ export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-BFJ2ODzI.js';
10
10
  import { b as Mailbox, c as MailboxSendInput, M as MailboxMessage, d as MailboxQuery, e as MailboxAckInput, f as MailboxAckBatchInput, a as MailboxAgentStatus, A as AgentRegistrationInput, g as AgentHeartbeatInput, P as PurgeOptions, j as PurgeResult, C as ClientRegistrationInput, h as ClientHeartbeatInput, i as ClientStatus } from '../mailbox-types-DTl7bRH3.js';
11
11
  export { k as ClientSource, l as MailboxMessageType, m as MailboxTaskContext, R as ReadReceipts, n as RegisteredAgent, o as normalizeRecipient } from '../mailbox-types-DTl7bRH3.js';
12
- import { G as GlobalMailbox } from '../global-mailbox-Iqfkgmwu.js';
13
- export { aw as resolveProjectDir } from '../global-mailbox-Iqfkgmwu.js';
14
- import { C as Context, T as Tool } from '../context-CLnUMW5g.js';
15
- import { A as AdaptiveConcurrencyConfig } from '../config-Bf5mj-ad.js';
12
+ import { G as GlobalMailbox } from '../global-mailbox-Dr4cTKqL.js';
13
+ export { aw as resolveProjectDir } from '../global-mailbox-Dr4cTKqL.js';
14
+ import { C as Context, T as Tool } from '../context-DPlA6kid.js';
15
+ import { A as AdaptiveConcurrencyConfig } from '../config-DAOjriz9.js';
16
16
  import 'node:events';
17
17
  import '../logger-B63L5bTg.js';
18
18
  import '../director-state-BfeCUbmk.js';
19
- import '../index-Cn0NOshr.js';
20
- import '../pipeline-Dl6XbfE7.js';
19
+ import '../index-DJXj-dcr.js';
20
+ import '../pipeline-CEjBjzVA.js';
21
21
  import '../observability-D-HZN_mF.js';
22
- import '../permission-BCbQDR2s.js';
23
- import '../retry-policy-Dt3_z8Aj.js';
22
+ import '../permission-DbsGOA1C.js';
23
+ import '../retry-policy-Git9WF6d.js';
24
24
 
25
25
  /** Phase 1 · Discovery — map the territory before any work begins. */
26
26
  declare const DISCOVERY_AGENTS: AgentDefinition[];
@@ -5819,6 +5819,7 @@ var Director = class _Director {
5819
5819
  sessionIdSource;
5820
5820
  /** Debounce timer for periodic manifest writes. */
5821
5821
  manifestTimer = null;
5822
+ manifestWriteChain = Promise.resolve();
5822
5823
  manifestDebounceMs;
5823
5824
  /** Fleet-wide cost cap (entire fleet total, distinct from SubagentBudget limits). Infinity means no cap. */
5824
5825
  maxFleetCostUsd;
@@ -5995,7 +5996,7 @@ var Director = class _Director {
5995
5996
  }
5996
5997
  );
5997
5998
  if (this.fleetManager) {
5998
- this.fleetManager.flushManifest();
5999
+ void this.fleetManager.flushManifest();
5999
6000
  } else {
6000
6001
  this.scheduleManifest();
6001
6002
  }
@@ -6274,6 +6275,7 @@ var Director = class _Director {
6274
6275
  return;
6275
6276
  }
6276
6277
  if (this.manifestDebounceMs < 0) return;
6278
+ if (this.manifestTimer) return;
6277
6279
  this.manifestTimer = setTimeout(() => {
6278
6280
  this.manifestTimer = null;
6279
6281
  void this.writeManifest().catch(
@@ -6281,6 +6283,11 @@ var Director = class _Director {
6281
6283
  );
6282
6284
  }, this.manifestDebounceMs);
6283
6285
  }
6286
+ clearManifestTimer() {
6287
+ if (!this.manifestTimer) return;
6288
+ clearTimeout(this.manifestTimer);
6289
+ this.manifestTimer = null;
6290
+ }
6284
6291
  /**
6285
6292
  * Spawn a subagent. Identical to the coordinator's `spawn()` but
6286
6293
  * captures provider/model metadata for the usage aggregator and
@@ -6503,6 +6510,13 @@ var Director = class _Director {
6503
6510
  * replay an entire director run.
6504
6511
  */
6505
6512
  async writeManifest() {
6513
+ if (!this.manifestPath) return null;
6514
+ this.clearManifestTimer();
6515
+ const write = this.manifestWriteChain.catch(() => void 0).then(() => this.writeManifestNow());
6516
+ this.manifestWriteChain = write.catch(() => void 0);
6517
+ return write;
6518
+ }
6519
+ async writeManifestNow() {
6506
6520
  if (!this.manifestPath) return null;
6507
6521
  const manifest = {
6508
6522
  directorRunId: this.id,
@@ -6535,10 +6549,7 @@ var Director = class _Director {
6535
6549
  * — calling shutdown twice is a no-op on the second invocation.
6536
6550
  */
6537
6551
  async shutdown() {
6538
- if (this.manifestTimer) {
6539
- clearTimeout(this.manifestTimer);
6540
- this.manifestTimer = null;
6541
- }
6552
+ this.clearManifestTimer();
6542
6553
  if (this.taskCompletedListener) {
6543
6554
  this.coordinator.off("task.completed", this.taskCompletedListener);
6544
6555
  this.taskCompletedListener = null;
@@ -6557,8 +6568,11 @@ var Director = class _Director {
6557
6568
  }
6558
6569
  this.subagentBridges.clear();
6559
6570
  await this.bridge.stop().catch((err) => this.logShutdownError("director_bridge_stop", err));
6560
- if (this.manifestPath)
6571
+ if (this.fleetManager) {
6572
+ await this.fleetManager.flushManifest().catch((err) => this.logShutdownError("fleet_manifest_flush", err));
6573
+ } else if (this.manifestPath) {
6561
6574
  await this.writeManifest().catch((err) => this.logShutdownError("manifest_write", err));
6575
+ }
6562
6576
  if (this.stateCheckpoint) {
6563
6577
  this.stateCheckpoint.setUsage(this.usage.snapshot());
6564
6578
  await this.stateCheckpoint.flush().catch((err) => this.logShutdownError("state_checkpoint_flush", err));
@@ -9431,6 +9445,8 @@ var FleetManager = class {
9431
9445
  stateCheckpoint;
9432
9446
  sessionWriter;
9433
9447
  manifestTimer = null;
9448
+ manifestWriteChain = Promise.resolve();
9449
+ disposed = false;
9434
9450
  manifestDebounceMs;
9435
9451
  /** Fleet-wide cost cap. Infinity = no cap. Distinct from SubagentBudget limits,
9436
9452
  * which track per-subagent spend — this field caps the entire fleet total. */
@@ -9619,6 +9635,13 @@ var FleetManager = class {
9619
9635
  this.scheduleManifest();
9620
9636
  }
9621
9637
  async writeManifest() {
9638
+ if (!this.manifestPath) return null;
9639
+ this.clearManifestTimer();
9640
+ const write = this.manifestWriteChain.catch(() => void 0).then(() => this.writeManifestNow());
9641
+ this.manifestWriteChain = write.catch(() => void 0);
9642
+ return write;
9643
+ }
9644
+ async writeManifestNow() {
9622
9645
  if (!this.manifestPath) return null;
9623
9646
  const manifest = {
9624
9647
  version: 1,
@@ -9652,6 +9675,7 @@ var FleetManager = class {
9652
9675
  * When `manifestDebounceMs` is 0, writes are synchronous (no debounce).
9653
9676
  */
9654
9677
  scheduleManifest() {
9678
+ if (this.disposed) return;
9655
9679
  if (!this.manifestPath) return;
9656
9680
  if (this.manifestDebounceMs === 0) {
9657
9681
  void this.writeManifest().catch((err) => {
@@ -9682,10 +9706,7 @@ var FleetManager = class {
9682
9706
  */
9683
9707
  async flushManifest() {
9684
9708
  if (!this.manifestPath) return;
9685
- if (this.manifestTimer) {
9686
- clearTimeout(this.manifestTimer);
9687
- this.manifestTimer = null;
9688
- }
9709
+ this.clearManifestTimer();
9689
9710
  await this.writeManifest().catch((err) => {
9690
9711
  const detail = toErrorMessage(err);
9691
9712
  process.emitWarning(
@@ -9694,6 +9715,11 @@ var FleetManager = class {
9694
9715
  );
9695
9716
  });
9696
9717
  }
9718
+ clearManifestTimer() {
9719
+ if (!this.manifestTimer) return;
9720
+ clearTimeout(this.manifestTimer);
9721
+ this.manifestTimer = null;
9722
+ }
9697
9723
  /** Best-effort session event writer. Swallows failures. */
9698
9724
  async appendSessionEvent(event) {
9699
9725
  if (!this.sessionWriter) return;
@@ -9763,10 +9789,8 @@ var FleetManager = class {
9763
9789
  }
9764
9790
  /** Release all resources: clear the manifest debounce timer and dispose the usage aggregator. */
9765
9791
  dispose() {
9766
- if (this.manifestTimer) {
9767
- clearTimeout(this.manifestTimer);
9768
- this.manifestTimer = null;
9769
- }
9792
+ this.disposed = true;
9793
+ this.clearManifestTimer();
9770
9794
  this.usage.dispose();
9771
9795
  }
9772
9796
  };