@wrongstack/core 0.119.1 → 0.148.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/{agent-bridge-PRAbEX-9.d.ts → agent-bridge-r9y6gdn4.d.ts} +1 -1
  2. package/dist/{agent-subagent-runner-DXWImnNV.d.ts → agent-subagent-runner-1GeQE_L0.d.ts} +7 -7
  3. package/dist/{brain-NZZqL8sn.d.ts → brain-Cp_3GIS2.d.ts} +14 -3
  4. package/dist/{compactor-C3stu664.d.ts → compactor-BueGt7LG.d.ts} +9 -1
  5. package/dist/{config-DZV9VK9n.d.ts → config-BaVThgnT.d.ts} +1 -1
  6. package/dist/{context-hvXINa6a.d.ts → context-C7G_MtLV.d.ts} +7 -0
  7. package/dist/coordination/index.d.ts +12 -12
  8. package/dist/coordination/index.js +35 -21
  9. package/dist/coordination/index.js.map +1 -1
  10. package/dist/defaults/index.d.ts +24 -24
  11. package/dist/defaults/index.js +869 -788
  12. package/dist/defaults/index.js.map +1 -1
  13. package/dist/execution/index.d.ts +14 -14
  14. package/dist/execution/index.js +454 -321
  15. package/dist/execution/index.js.map +1 -1
  16. package/dist/extension/index.d.ts +6 -6
  17. package/dist/{goal-preamble-COpt55W8.d.ts → goal-preamble-CYJLg0wk.d.ts} +55 -17
  18. package/dist/{index-Cj3le7TI.d.ts → index-BZdezm3g.d.ts} +8 -8
  19. package/dist/{index-4VVHuTZF.d.ts → index-CPweVoFM.d.ts} +5 -5
  20. package/dist/index.d.ts +48 -48
  21. package/dist/index.js +612 -513
  22. package/dist/index.js.map +1 -1
  23. package/dist/infrastructure/index.d.ts +6 -6
  24. package/dist/infrastructure/index.js +64 -19
  25. package/dist/infrastructure/index.js.map +1 -1
  26. package/dist/kernel/index.d.ts +9 -9
  27. package/dist/kernel/index.js.map +1 -1
  28. package/dist/{llm-selector-Bmx4PsVM.d.ts → llm-selector-CP72f1lC.d.ts} +2 -2
  29. package/dist/{mcp-servers-CofNHOqn.d.ts → mcp-servers-Bl5LTvQg.d.ts} +3 -3
  30. package/dist/models/index.d.ts +5 -5
  31. package/dist/models/index.js +53 -20
  32. package/dist/models/index.js.map +1 -1
  33. package/dist/{models-registry-BzlsjKcy.d.ts → models-registry-D90K9UnM.d.ts} +1 -1
  34. package/dist/{multi-agent-coordinator-CmDmUgq2.d.ts → multi-agent-coordinator-QWEzJDlm.d.ts} +1 -1
  35. package/dist/{null-fleet-bus-CyH2YqP4.d.ts → null-fleet-bus-BUyfqh23.d.ts} +13 -10
  36. package/dist/observability/index.d.ts +2 -2
  37. package/dist/{parallel-eternal-engine-uxVm4y4V.d.ts → parallel-eternal-engine-C75QuhAI.d.ts} +33 -11
  38. package/dist/{path-resolver-gfoGxpdd.d.ts → path-resolver-DRjQBkoO.d.ts} +3 -3
  39. package/dist/{permission-DhLrgA30.d.ts → permission-B7nKnEvQ.d.ts} +1 -1
  40. package/dist/{permission-policy-DGOvne7i.d.ts → permission-policy-8-6zBmfA.d.ts} +2 -13
  41. package/dist/{pipeline-CqF7uju2.d.ts → pipeline-BG7UgbDc.d.ts} +2 -2
  42. package/dist/{plan-templates-DoKhzenv.d.ts → plan-templates-CkKNPU3I.d.ts} +5 -5
  43. package/dist/{provider-runner-BPlI5sPZ.d.ts → provider-runner-BNpuIyOL.d.ts} +3 -3
  44. package/dist/{retry-policy-B4Q-FZgE.d.ts → retry-policy-rutAfVeR.d.ts} +1 -1
  45. package/dist/sdd/index.d.ts +8 -8
  46. package/dist/sdd/index.js +10 -1
  47. package/dist/sdd/index.js.map +1 -1
  48. package/dist/{secret-vault-B7GnL6o9.d.ts → secret-vault-BTcC_T5v.d.ts} +3 -2
  49. package/dist/security/index.d.ts +5 -7
  50. package/dist/security/index.js +5 -36
  51. package/dist/security/index.js.map +1 -1
  52. package/dist/{selector-BakeMnWR.d.ts → selector-4vDFZKt3.d.ts} +1 -1
  53. package/dist/{session-event-bridge-DE5Oekwx.d.ts → session-event-bridge-DWlvglC2.d.ts} +2 -2
  54. package/dist/{session-reader-DFC81-4p.d.ts → session-reader-BAtCxdaw.d.ts} +1 -1
  55. package/dist/storage/index.d.ts +13 -13
  56. package/dist/storage/index.js +100 -103
  57. package/dist/storage/index.js.map +1 -1
  58. package/dist/types/index.d.ts +18 -18
  59. package/dist/types/index.js +276 -103
  60. package/dist/types/index.js.map +1 -1
  61. package/dist/utils/index.d.ts +37 -13
  62. package/dist/utils/index.js +63 -35
  63. package/dist/utils/index.js.map +1 -1
  64. package/package.json +2 -2
  65. package/skills/tech-stack/SKILL.md +253 -97
@@ -1,4 +1,4 @@
1
- import { B as BridgeTransport, a as BridgeMessage, A as AgentBridge, b as AgentBridgeConfig } from './agent-subagent-runner-DXWImnNV.js';
1
+ import { B as BridgeTransport, a as BridgeMessage, A as AgentBridge, b as AgentBridgeConfig } from './agent-subagent-runner-1GeQE_L0.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-4VVHuTZF.js';
2
- import { C as Container, R as ReadonlyPipeline, a as Renderer } from './pipeline-CqF7uju2.js';
3
- import { E as EventBus, c as EventName, L as Listener } from './brain-NZZqL8sn.js';
4
- import { R as RetryPolicy, E as ErrorHandler } from './retry-policy-B4Q-FZgE.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-CPweVoFM.js';
2
+ import { C as Container, R as ReadonlyPipeline, a as Renderer } from './pipeline-BG7UgbDc.js';
3
+ import { E as EventBus, c as EventName, L as Listener } from './brain-Cp_3GIS2.js';
4
+ import { R as RetryPolicy, E as ErrorHandler } from './retry-policy-rutAfVeR.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-DhLrgA30.js';
8
- import { U as Usage, C as Context, J as JSONSchema, R as Request, b as Response, g as ContentBlock, l as TextBlock, T as Tool, P as Provider, o as RunOptions } from './context-hvXINa6a.js';
9
- import { W as WireFamily, H as HookEvent, e as HookMatcher, I as InProcessHook, h as Config } from './config-DZV9VK9n.js';
7
+ import { P as PermissionPolicy } from './permission-B7nKnEvQ.js';
8
+ import { U as Usage, C as Context, J as JSONSchema, R as Request, b as Response, g as ContentBlock, l as TextBlock, T as Tool, P as Provider, o as RunOptions } from './context-C7G_MtLV.js';
9
+ import { W as WireFamily, H as HookEvent, e as HookMatcher, I as InProcessHook, h as Config } from './config-BaVThgnT.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, j as ToolProgressEvent, T as Tool } from './context-hvXINa6a.js';
1
+ import { U as Usage, C as Context, j as ToolProgressEvent, T as Tool } from './context-C7G_MtLV.js';
2
2
 
3
3
  type MemoryScope = 'project-agents' | 'project-memory' | 'user-memory';
4
4
  type MemoryType = 'fact' | 'decision' | 'convention' | 'preference' | 'reference' | 'anti_pattern';
@@ -168,6 +168,17 @@ interface EventMap {
168
168
  id: string;
169
169
  name: string;
170
170
  };
171
+ /**
172
+ * Fired when a single SSE event handler throws mid-stream. Best-effort: the
173
+ * malformed event is skipped and the partial response built from earlier
174
+ * events is preserved, so the stream is not aborted. `eventType` is the SSE
175
+ * event's `type`; `msg` is the handler error message.
176
+ */
177
+ 'provider.stream_error': {
178
+ ctx: Context;
179
+ eventType: string;
180
+ msg: string;
181
+ };
171
182
  /**
172
183
  * Fired before each retry of a failed provider call. `attempt` is 1-based
173
184
  * (the first retry is attempt 1, etc.). `description` is the human-readable
@@ -538,8 +549,8 @@ interface EventMap {
538
549
  name: string | undefined;
539
550
  message: string;
540
551
  stack?: string | undefined;
541
- };
542
- };
552
+ } | undefined;
553
+ } | undefined;
543
554
  };
544
555
  /**
545
556
  * Fired by the delegate tool when a subagent finishes. The agent's run
@@ -1,4 +1,4 @@
1
- import { C as Context } from './context-hvXINa6a.js';
1
+ import { C as Context } from './context-C7G_MtLV.js';
2
2
 
3
3
  interface CompactRepairReport {
4
4
  removedToolUses: string[];
@@ -31,6 +31,14 @@ interface CompactReport {
31
31
  saved: number;
32
32
  }[];
33
33
  repaired?: CompactRepairReport | undefined;
34
+ /**
35
+ * When a compactor collapses a range of ancient turns into a single digest,
36
+ * this carries the digest text so callers (e.g. the audit/session log) can
37
+ * record exactly what was collapsed. Lossless compactors preserve all
38
+ * textual content here; only raw tool I/O is dropped (it stays in the
39
+ * session log). Undefined when no range was collapsed this pass.
40
+ */
41
+ collapsedDigest?: string | undefined;
34
42
  }
35
43
  interface Compactor {
36
44
  compact(ctx: Context, opts?: {
@@ -1,4 +1,4 @@
1
- import { k as Capabilities, f as Permission } from './context-hvXINa6a.js';
1
+ import { k as Capabilities, f as Permission } from './context-C7G_MtLV.js';
2
2
 
3
3
  type ContextWindowModeId = 'balanced' | 'frugal' | 'deep' | 'archival';
4
4
  type ContextWindowAggressiveOn = 'hard' | 'soft' | 'warn';
@@ -722,6 +722,13 @@ type SessionEvent = {
722
722
  phase: string;
723
723
  saved: number;
724
724
  }>;
725
+ /**
726
+ * Lossless digest of the range collapsed during this compaction (text
727
+ * content preserved; raw tool I/O omitted). Captures *what* was collapsed
728
+ * for forensics. May be truncated for log size. Absent when nothing was
729
+ * collapsed (e.g. elision-only passes).
730
+ */
731
+ digest?: string | undefined;
725
732
  } | {
726
733
  type: 'error';
727
734
  ts: string;
@@ -1,19 +1,19 @@
1
- export { b as BrainArbiter, B as BrainDecision, d as BrainDecisionOption, e as BrainDecisionQueue, a as BrainDecisionRequest, f as BrainDecisionSource, g as BrainFallback, h as BrainRisk, D as DefaultBrainArbiter, i as DefaultBrainArbiterOptions, H as HumanEscalatingBrainArbiter, O as ObservableBrainArbiter, j as formatHumanPrompt } from '../brain-NZZqL8sn.js';
2
- 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 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, a8 as makeFleetSessionTool, a9 as makeFleetStatusTool, aa as makeFleetUsageTool, ab as makeRollUpTool, ac as makeSpawnTool, ad as makeTerminateTool, ae as makeWorkCompleteTool, af as rosterSummaryFromConfigs } from '../null-fleet-bus-CyH2YqP4.js';
3
- import { A as AgentDefinition } from '../multi-agent-coordinator-CmDmUgq2.js';
4
- export { T as AGENT_TOOL_PRESETS, b as AgentBudgetTier, c as AgentCapability, d 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-CmDmUgq2.js';
5
- export { h as AgentFactory, i as AgentFactoryResult, j as AgentRunnerOptions, k as BudgetExceededError, l as BudgetKind, m as BudgetLimits, n as BudgetNegotiationMode, o as BudgetThresholdDecision, p as BudgetThresholdHandler, q as BudgetThresholdSignal, r as BudgetUsage, F as FleetBus, s as FleetEvent, t as FleetHandler, u as FleetUsage, v as FleetUsageAggregator, w as SubagentBudget, x as SubagentUsageSnapshot, y as makeAgentSubagentRunner } from '../agent-subagent-runner-DXWImnNV.js';
6
- export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-PRAbEX-9.js';
7
- import '../context-hvXINa6a.js';
1
+ export { b as BrainArbiter, B as BrainDecision, d as BrainDecisionOption, e as BrainDecisionQueue, a as BrainDecisionRequest, f as BrainDecisionSource, g as BrainFallback, h as BrainRisk, D as DefaultBrainArbiter, i as DefaultBrainArbiterOptions, H as HumanEscalatingBrainArbiter, O as ObservableBrainArbiter, j as formatHumanPrompt } from '../brain-Cp_3GIS2.js';
2
+ 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 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, a8 as makeFleetSessionTool, a9 as makeFleetStatusTool, aa as makeFleetUsageTool, ab as makeRollUpTool, ac as makeSpawnTool, ad as makeTerminateTool, ae as makeWorkCompleteTool, af as rosterSummaryFromConfigs } from '../null-fleet-bus-BUyfqh23.js';
3
+ import { A as AgentDefinition } from '../multi-agent-coordinator-QWEzJDlm.js';
4
+ export { T as AGENT_TOOL_PRESETS, b as AgentBudgetTier, c as AgentCapability, d 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-QWEzJDlm.js';
5
+ export { h as AgentFactory, i as AgentFactoryResult, j as AgentRunnerOptions, k as BudgetExceededError, l as BudgetKind, m as BudgetLimits, n as BudgetNegotiationMode, o as BudgetThresholdDecision, p as BudgetThresholdHandler, q as BudgetThresholdSignal, r as BudgetUsage, F as FleetBus, s as FleetEvent, t as FleetHandler, u as FleetUsage, v as FleetUsageAggregator, w as SubagentBudget, x as SubagentUsageSnapshot, y as makeAgentSubagentRunner } from '../agent-subagent-runner-1GeQE_L0.js';
6
+ export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-r9y6gdn4.js';
7
+ import '../context-C7G_MtLV.js';
8
8
  import 'node:events';
9
9
  import '../director-state-BfeCUbmk.js';
10
- import '../config-DZV9VK9n.js';
11
- import '../index-4VVHuTZF.js';
10
+ import '../config-BaVThgnT.js';
11
+ import '../index-CPweVoFM.js';
12
12
  import '../logger-B63L5bTg.js';
13
- import '../pipeline-CqF7uju2.js';
13
+ import '../pipeline-BG7UgbDc.js';
14
14
  import '../observability-D-HZN_mF.js';
15
- import '../permission-DhLrgA30.js';
16
- import '../retry-policy-B4Q-FZgE.js';
15
+ import '../permission-B7nKnEvQ.js';
16
+ import '../retry-policy-rutAfVeR.js';
17
17
 
18
18
  /** Phase 1 · Discovery — map the territory before any work begins. */
19
19
  declare const DISCOVERY_AGENTS: AgentDefinition[];
@@ -123,6 +123,11 @@ var DefaultBrainArbiter = class {
123
123
  options: request.options,
124
124
  rationale: "Decision requires human authority or lacks a safe automatic option."
125
125
  };
126
+ default:
127
+ return {
128
+ type: "deny",
129
+ reason: `Brain could not safely decide (unknown fallback: ${String(request.fallback)}): ${request.question}`
130
+ };
126
131
  }
127
132
  }
128
133
  };
@@ -614,7 +619,7 @@ async function expandGlob(pattern) {
614
619
  } catch {
615
620
  return;
616
621
  }
617
- const firstGlob = pat.search(/[*?[\[]/);
622
+ const firstGlob = pat.search(/[*?[[]/);
618
623
  if (firstGlob < 0) {
619
624
  const re = globToRegex(pat);
620
625
  for (const e of entries) {
@@ -680,7 +685,7 @@ var CollabSession = class extends EventEmitter {
680
685
  bugs = /* @__PURE__ */ new Map();
681
686
  plans = /* @__PURE__ */ new Map();
682
687
  evaluations = /* @__PURE__ */ new Map();
683
- disposers = new Array();
688
+ disposers = [];
684
689
  settled = false;
685
690
  timeoutMs;
686
691
  cancelled = false;
@@ -4494,7 +4499,7 @@ var FleetUsageAggregator = class {
4494
4499
  metaLookup;
4495
4500
  perSubagent = /* @__PURE__ */ new Map();
4496
4501
  total = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0 };
4497
- unsub = new Array();
4502
+ unsub = [];
4498
4503
  /**
4499
4504
  * Remove a terminated subagent's data from the aggregator and subtract its
4500
4505
  * contribution from the running totals. Call this when a subagent is removed
@@ -6478,7 +6483,10 @@ var Director = class _Director {
6478
6483
  workCompleteFlag = false;
6479
6484
  /** Pending /btw notes stashed by the leader agent (see setLeaderBtwNote). */
6480
6485
  _leaderBtwNotes = [];
6481
- /** Active collab sessions tracked by sessionId (see spawnCollab). */
6486
+ /** Active collab sessions tracked by sessionId (see spawnCollab).
6487
+ * The tuple holds the session and its Director-registered listener unsubs.
6488
+ * Calling the unsubs on cancel/premature-cleanup prevents listener accumulation
6489
+ * on CollabSession (EventEmitter) across many spawnCollab() calls. */
6482
6490
  _activeCollabSessions = /* @__PURE__ */ new Map();
6483
6491
  /** Prevents large `ask_subagent` answers from bloating the leader's context window. */
6484
6492
  largeAnswerStore;
@@ -6808,11 +6816,13 @@ var Director = class _Director {
6808
6816
  * The CollabDebugReport will reflect 'cancelled' disposition when awaited.
6809
6817
  */
6810
6818
  cancelCollabSession(sessionId, reason = "Director cancelled") {
6811
- const session = this._activeCollabSessions.get(sessionId);
6812
- if (!session || session.isCancelled()) return;
6813
- session.cancel(reason);
6814
- for (const [_role, subagentId] of session.getSubagentIds()) {
6815
- this.coordinator.stop(subagentId).catch(() => {
6819
+ const entry = this._activeCollabSessions.get(sessionId);
6820
+ if (!entry || entry.session.isCancelled()) return;
6821
+ for (const unsub of entry.unsubs) unsub();
6822
+ entry.session.cancel(reason);
6823
+ for (const [_role, subagentId] of entry.session.getSubagentIds()) {
6824
+ this.coordinator.stop(subagentId).catch((err) => {
6825
+ console.debug(`[director] stop subagent ${subagentId} failed (may have already completed): ${err}`);
6816
6826
  });
6817
6827
  }
6818
6828
  }
@@ -7460,9 +7470,15 @@ var Director = class _Director {
7460
7470
  return options.onBudgetWarning?.(alert) ?? "ignore";
7461
7471
  }
7462
7472
  });
7463
- this._activeCollabSessions.set(session.sessionId, session);
7464
- session.on("session.done", () => this._activeCollabSessions.delete(session.sessionId));
7465
- session.on("session.error", () => this._activeCollabSessions.delete(session.sessionId));
7473
+ const doneHandler = () => this._activeCollabSessions.delete(session.sessionId);
7474
+ const errorHandler = () => this._activeCollabSessions.delete(session.sessionId);
7475
+ session.on("session.done", doneHandler);
7476
+ session.on("session.error", errorHandler);
7477
+ const unsubs = [
7478
+ () => session.off("session.done", doneHandler),
7479
+ () => session.off("session.error", errorHandler)
7480
+ ];
7481
+ this._activeCollabSessions.set(session.sessionId, { session, unsubs });
7466
7482
  return session.start();
7467
7483
  }
7468
7484
  /**
@@ -8208,8 +8224,7 @@ var DefaultSessionStore = class _DefaultSessionStore {
8208
8224
  onClose: (s) => this.appendToIndex(s)
8209
8225
  });
8210
8226
  } catch (err) {
8211
- await handle.close().catch(() => {
8212
- });
8227
+ await handle.close().catch((e) => console.warn(`[session-store] handle.close() failed: ${e}`));
8213
8228
  throw err;
8214
8229
  }
8215
8230
  }
@@ -8240,8 +8255,7 @@ var DefaultSessionStore = class _DefaultSessionStore {
8240
8255
  );
8241
8256
  return { writer, data };
8242
8257
  } catch (err) {
8243
- await handle.close().catch(() => {
8244
- });
8258
+ await handle.close().catch((e) => console.warn(`[session-store] handle.close() failed: ${e}`));
8245
8259
  throw err;
8246
8260
  }
8247
8261
  }
@@ -8430,15 +8444,15 @@ var DefaultSessionStore = class _DefaultSessionStore {
8430
8444
  * sidecars, and the session directory (fleet.json, shared/, subagents/).
8431
8445
  */
8432
8446
  async deleteSession(id) {
8433
- await fsp6.unlink(this.sessionPath(id, ".jsonl")).catch(() => void 0);
8434
- await fsp6.unlink(this.sessionPath(id, ".summary.json")).catch(() => void 0);
8447
+ await fsp6.unlink(this.sessionPath(id, ".jsonl")).catch((err) => console.warn(`[session-store] delete .jsonl failed: ${err}`));
8448
+ await fsp6.unlink(this.sessionPath(id, ".summary.json")).catch((err) => console.warn(`[session-store] delete .summary.json failed: ${err}`));
8435
8449
  const shardDir = path4.dirname(path4.join(this.dir, id));
8436
8450
  const base = path4.basename(id);
8437
8451
  for (const ext of [".plan.json", ".todos.json"]) {
8438
- await fsp6.unlink(path4.join(shardDir, `${base}${ext}`)).catch(() => void 0);
8452
+ await fsp6.unlink(path4.join(shardDir, `${base}${ext}`)).catch((err) => console.warn(`[session-store] delete ${ext} failed: ${err}`));
8439
8453
  }
8440
8454
  const sessDir = path4.join(shardDir, base);
8441
- await fsp6.rm(sessDir, { recursive: true, force: true }).catch(() => void 0);
8455
+ await fsp6.rm(sessDir, { recursive: true, force: true }).catch((err) => console.warn(`[session-store] delete session dir failed: ${err}`));
8442
8456
  await this.writeTombstone(id);
8443
8457
  }
8444
8458
  async delete(id) {
@@ -8515,7 +8529,7 @@ var DefaultSessionStore = class _DefaultSessionStore {
8515
8529
  let toolErrorCount = 0;
8516
8530
  let fileChangeCount = 0;
8517
8531
  const toolBreakdown = {};
8518
- let outcome = void 0;
8532
+ let outcome;
8519
8533
  const lastEvent = data.events[data.events.length - 1];
8520
8534
  for (const e of data.events) {
8521
8535
  if (e.type === "in_flight_start") iterationCount++;