@wrongstack/core 0.77.0 → 0.82.6

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 (79) hide show
  1. package/dist/{agent-bridge-EWdqs8v6.d.ts → agent-bridge-C9P_HPez.d.ts} +2 -2
  2. package/dist/{agent-subagent-runner-D8qW8OSC.d.ts → agent-subagent-runner-2Aq0jOSj.d.ts} +107 -102
  3. package/dist/{compactor-D_ExJajC.d.ts → compactor-CJq7LQev.d.ts} +3 -3
  4. package/dist/{config-Dy0CK_o6.d.ts → config-_DZ7dN-T.d.ts} +77 -75
  5. package/dist/{context-y87Jc5ei.d.ts → context-ToHAp4-U.d.ts} +119 -90
  6. package/dist/coordination/index.d.ts +16 -16
  7. package/dist/coordination/index.js +318 -37
  8. package/dist/coordination/index.js.map +1 -1
  9. package/dist/defaults/index.d.ts +31 -31
  10. package/dist/defaults/index.js +419 -67
  11. package/dist/defaults/index.js.map +1 -1
  12. package/dist/{director-state-BmYi3DGA.d.ts → director-state-CgIc30qi.d.ts} +19 -19
  13. package/dist/{events-CYaoLN5_.d.ts → events-DnRqXaZ3.d.ts} +43 -42
  14. package/dist/execution/index.d.ts +53 -53
  15. package/dist/execution/index.js +67 -23
  16. package/dist/execution/index.js.map +1 -1
  17. package/dist/extension/index.d.ts +9 -9
  18. package/dist/extension/index.js +8 -1
  19. package/dist/extension/index.js.map +1 -1
  20. package/dist/{goal-store-C7jcumEh.d.ts → goal-store-DvWLNu52.d.ts} +4 -4
  21. package/dist/{index-DIxjTOga.d.ts → index-BNOLadHw.d.ts} +28 -28
  22. package/dist/{index-Dsda0uCn.d.ts → index-N0_c4bHQ.d.ts} +45 -45
  23. package/dist/index.d.ts +165 -165
  24. package/dist/index.js +593 -137
  25. package/dist/index.js.map +1 -1
  26. package/dist/infrastructure/index.d.ts +9 -9
  27. package/dist/infrastructure/index.js +13 -5
  28. package/dist/infrastructure/index.js.map +1 -1
  29. package/dist/kernel/index.d.ts +14 -14
  30. package/dist/kernel/index.js +7 -0
  31. package/dist/kernel/index.js.map +1 -1
  32. package/dist/logger-B72yyPc6.d.ts +12 -0
  33. package/dist/{logger-BppKxDqZ.d.ts → logger-C_27pj9i.d.ts} +6 -7
  34. package/dist/{mcp-servers-T0O6UN_w.d.ts → mcp-servers-Dck3T85_.d.ts} +20 -20
  35. package/dist/{mode-BO4SEUIv.d.ts → mode-CHo2XtHs.d.ts} +4 -4
  36. package/dist/models/index.d.ts +10 -10
  37. package/dist/models/index.js +8 -2
  38. package/dist/models/index.js.map +1 -1
  39. package/dist/{models-registry-BcYJDKLm.d.ts → models-registry-Be3osGt5.d.ts} +28 -28
  40. package/dist/{models-registry-Cuq1C8V9.d.ts → models-registry-Boz639EI.d.ts} +12 -12
  41. package/dist/{multi-agent-coordinator-DpbG3wiy.d.ts → multi-agent-coordinator-DllpCVkF.d.ts} +12 -12
  42. package/dist/{null-fleet-bus-u5ys3lW_.d.ts → null-fleet-bus-BY0AN-sr.d.ts} +121 -121
  43. package/dist/observability/index.d.ts +41 -41
  44. package/dist/observability/index.js.map +1 -1
  45. package/dist/{observability-BhnVLBLS.d.ts → observability-CoSNZdhX.d.ts} +4 -4
  46. package/dist/{parallel-eternal-engine-Dn0P8Pbj.d.ts → parallel-eternal-engine-D402RASp.d.ts} +49 -49
  47. package/dist/{path-resolver-B32v2JIq.d.ts → path-resolver-UPFTsDyD.d.ts} +6 -6
  48. package/dist/{permission-V5BLOrY6.d.ts → permission-14CChMmO.d.ts} +10 -8
  49. package/dist/{permission-policy-CBVx-d-8.d.ts → permission-policy-gW5htOo1.d.ts} +7 -7
  50. package/dist/{plan-templates-BcUwLlMQ.d.ts → plan-templates-DRvPgkfZ.d.ts} +65 -32
  51. package/dist/{provider-runner-CSi_7l0h.d.ts → provider-runner-COAJM8tC.d.ts} +6 -6
  52. package/dist/{retry-policy-CG3qvH_e.d.ts → retry-policy-DSu6O6rD.d.ts} +4 -4
  53. package/dist/sdd/index.d.ts +47 -47
  54. package/dist/sdd/index.js +47 -22
  55. package/dist/sdd/index.js.map +1 -1
  56. package/dist/security/index.d.ts +6 -6
  57. package/dist/security/index.js +7 -1
  58. package/dist/security/index.js.map +1 -1
  59. package/dist/{selector-RvBR_YRW.d.ts → selector-11-fm95U.d.ts} +2 -2
  60. package/dist/{session-event-bridge-CDHxcmQU.d.ts → session-event-bridge-D0u-x576.d.ts} +7 -7
  61. package/dist/{session-reader-BIpwM60D.d.ts → session-reader-BQU-toaN.d.ts} +23 -23
  62. package/dist/{skill-CxuWrsKK.d.ts → skill-BJeF2DwY.d.ts} +1 -1
  63. package/dist/skills/index.d.ts +9 -9
  64. package/dist/skills/index.js +15 -3
  65. package/dist/skills/index.js.map +1 -1
  66. package/dist/storage/index.d.ts +15 -15
  67. package/dist/storage/index.js +378 -76
  68. package/dist/storage/index.js.map +1 -1
  69. package/dist/{system-prompt-CA11g6Jo.d.ts → system-prompt-C0rLCeyn.d.ts} +16 -11
  70. package/dist/{task-graph-D1YQbpxF.d.ts → task-graph-CikNdRTG.d.ts} +22 -22
  71. package/dist/types/index.d.ts +25 -25
  72. package/dist/types/index.js +45 -10
  73. package/dist/types/index.js.map +1 -1
  74. package/dist/utils/index.d.ts +46 -45
  75. package/dist/utils/index.js +53 -12
  76. package/dist/utils/index.js.map +1 -1
  77. package/dist/{wstack-paths-D7evAFWM.d.ts → wstack-paths-BQMvEllz.d.ts} +2 -2
  78. package/package.json +1 -1
  79. package/dist/logger-DDd5C--Z.d.ts +0 -12
@@ -1,16 +1,16 @@
1
- import { h as Specification, S as SpecAnalysis, g as SpecValidationResult, l as TaskGraph, m as TaskNode, k as TaskFilter, p as TaskSort, o as TaskProgress, r as TaskType, n as TaskPriority, e as SpecStatus, f as SpecTemplate, b as SpecRequirement } from '../task-graph-D1YQbpxF.js';
2
- import { E as EventBus } from '../events-CYaoLN5_.js';
3
- import { D as DoneCondition, A as Agent, c as AgentFactory, X as TaskResult } from '../agent-subagent-runner-D8qW8OSC.js';
4
- import '../context-y87Jc5ei.js';
5
- import '../index-Dsda0uCn.js';
6
- import '../logger-DDd5C--Z.js';
7
- import '../system-prompt-CA11g6Jo.js';
8
- import '../config-Dy0CK_o6.js';
9
- import '../models-registry-BcYJDKLm.js';
10
- import '../observability-BhnVLBLS.js';
1
+ import { h as Specification, S as SpecAnalysis, g as SpecValidationResult, l as TaskGraph, m as TaskNode, k as TaskFilter, p as TaskSort, o as TaskProgress, r as TaskType, n as TaskPriority, e as SpecStatus, f as SpecTemplate, b as SpecRequirement } from '../task-graph-CikNdRTG.js';
2
+ import { E as EventBus } from '../events-DnRqXaZ3.js';
3
+ import { D as DoneCondition, A as Agent, c as AgentFactory, X as TaskResult } from '../agent-subagent-runner-2Aq0jOSj.js';
4
+ import '../context-ToHAp4-U.js';
5
+ import '../index-N0_c4bHQ.js';
6
+ import '../logger-B72yyPc6.js';
7
+ import '../system-prompt-C0rLCeyn.js';
8
+ import '../config-_DZ7dN-T.js';
9
+ import '../models-registry-Be3osGt5.js';
10
+ import '../observability-CoSNZdhX.js';
11
11
  import '../secret-scrubber-3MHDDAtm.js';
12
- import '../permission-V5BLOrY6.js';
13
- import '../retry-policy-CG3qvH_e.js';
12
+ import '../permission-14CChMmO.js';
13
+ import '../retry-policy-DSu6O6rD.js';
14
14
 
15
15
  declare class SpecParser {
16
16
  parse(content: string): Specification;
@@ -43,13 +43,13 @@ interface TaskTrackerOptions {
43
43
  * fire-and-forget their writes; without this, a failing store silently
44
44
  * loses graph mutations. Defaults to a console.warn.
45
45
  */
46
- onPersistError?: (err: unknown) => void;
46
+ onPersistError?: (((err: unknown) => void)) | undefined;
47
47
  }
48
48
  interface TaskTransition {
49
49
  from: TaskNode['status'];
50
50
  to: TaskNode['status'];
51
51
  timestamp: number;
52
- reason?: string;
52
+ reason?: string | undefined;
53
53
  }
54
54
  declare class TaskTracker {
55
55
  private readonly opts;
@@ -90,13 +90,13 @@ interface TaskGeneratorOptions {
90
90
  taskTracker: TaskTracker;
91
91
  }
92
92
  interface GeneratedTask {
93
- specRequirementId?: string;
93
+ specRequirementId?: string | undefined;
94
94
  title: string;
95
95
  description: string;
96
96
  type: TaskType;
97
97
  priority: TaskPriority;
98
- estimateHours?: number;
99
- tags?: string[];
98
+ estimateHours?: number | undefined;
99
+ tags?: string[] | undefined;
100
100
  }
101
101
  declare class TaskGenerator {
102
102
  private readonly opts;
@@ -138,7 +138,7 @@ interface TaskFlowEventMap {
138
138
  };
139
139
  'task.completed': {
140
140
  taskId: string;
141
- result?: unknown;
141
+ result?: unknown | undefined;
142
142
  };
143
143
  'task.failed': {
144
144
  taskId: string;
@@ -167,13 +167,13 @@ type TaskFlowEventName = keyof TaskFlowEventMap;
167
167
  interface TaskFlowOptions {
168
168
  tracker: TaskTracker;
169
169
  events: EventBus;
170
- doneCondition?: DoneCondition;
171
- maxConcurrent?: number;
170
+ doneCondition?: DoneCondition | undefined;
171
+ maxConcurrent?: number | undefined;
172
172
  }
173
173
  interface TaskFlowExecutionContext {
174
174
  executeTask: (task: TaskNode) => Promise<unknown>;
175
- onTaskComplete?: (task: TaskNode, result: unknown) => void;
176
- onTaskFail?: (task: TaskNode, error: Error) => void;
175
+ onTaskComplete?: (task: TaskNode | undefined, result: unknown) => void;
176
+ onTaskFail?: (task: TaskNode | undefined, error: Error) => void;
177
177
  }
178
178
  declare class TaskFlow {
179
179
  private readonly opts;
@@ -199,7 +199,7 @@ declare class TaskFlow {
199
199
  interface SpecDrivenDevOptions {
200
200
  workingDirectory: string;
201
201
  events: EventBus;
202
- doneCondition?: DoneCondition;
202
+ doneCondition?: DoneCondition | undefined;
203
203
  }
204
204
  declare class SpecDrivenDev {
205
205
  private store;
@@ -298,9 +298,9 @@ interface AISpecSession {
298
298
  projectContext: string;
299
299
  answers: CollectedAnswer[];
300
300
  questionCount: number;
301
- spec?: Specification;
302
- implementation?: string;
303
- taskGraphId?: string;
301
+ spec?: Specification | undefined;
302
+ implementation?: string | undefined;
303
+ taskGraphId?: string | undefined;
304
304
  approved: boolean;
305
305
  createdAt: number;
306
306
  updatedAt: number;
@@ -308,13 +308,13 @@ interface AISpecSession {
308
308
  interface AISpecBuilderOptions {
309
309
  store: SpecStore;
310
310
  /** Minimum questions the AI should ask. Default: 2 */
311
- minQuestions?: number;
311
+ minQuestions?: number | undefined;
312
312
  /** Maximum questions before forcing spec generation. Default: 10 */
313
- maxQuestions?: number;
313
+ maxQuestions?: number | undefined;
314
314
  /** Project context string (package.json, file structure, etc.) */
315
- projectContext?: string;
315
+ projectContext?: string | undefined;
316
316
  /** Path to persist session state. If set, session survives process restarts. */
317
- sessionPath?: string;
317
+ sessionPath?: string | undefined;
318
318
  }
319
319
  /**
320
320
  * AI-driven specification builder. Instead of static questions, this builder
@@ -446,7 +446,7 @@ declare function templateToMarkdown(template: SpecTemplate, title?: string): str
446
446
  * Render a task graph as ASCII art for terminal display.
447
447
  */
448
448
  declare function renderTaskGraph(graph: TaskGraph, opts?: {
449
- compact?: boolean;
449
+ compact?: boolean | undefined;
450
450
  }): string;
451
451
  /**
452
452
  * Render a progress bar.
@@ -505,7 +505,7 @@ interface SpecVersion {
505
505
  version: string;
506
506
  spec: Specification;
507
507
  timestamp: number;
508
- changeDescription?: string;
508
+ changeDescription?: string | undefined;
509
509
  }
510
510
  interface SpecDiff {
511
511
  added: SpecRequirement[];
@@ -552,19 +552,19 @@ interface AutoExecutorOptions {
552
552
  tracker: TaskTracker;
553
553
  events: EventBus;
554
554
  /** Maximum concurrent tasks. Defaults to 1 (sequential). */
555
- maxConcurrent?: number;
555
+ maxConcurrent?: number | undefined;
556
556
  /** Maximum retry attempts for failed tasks. */
557
- maxRetries?: number;
557
+ maxRetries?: number | undefined;
558
558
  /** Custom task executor function. */
559
559
  executeTask: (task: TaskNode, context: TaskExecutionContext) => Promise<TaskExecutionResult>;
560
560
  /** Called before each task starts. */
561
- onTaskStart?: (task: TaskNode) => void;
561
+ onTaskStart?: (((task: TaskNode) => void)) | undefined;
562
562
  /** Called after each task completes. */
563
563
  onTaskComplete?: (task: TaskNode, result: TaskExecutionResult) => void;
564
564
  /** Called when a task fails. */
565
565
  onTaskFail?: (task: TaskNode, error: Error, retryCount: number) => void;
566
566
  /** Called when all tasks are done or no more can execute. */
567
- onDone?: (summary: ExecutionSummary) => void;
567
+ onDone?: (((summary: ExecutionSummary) => void)) | undefined;
568
568
  }
569
569
  interface TaskExecutionContext {
570
570
  /** The spec being implemented. */
@@ -582,10 +582,10 @@ interface TaskExecutionContext {
582
582
  }
583
583
  interface TaskExecutionResult {
584
584
  success: boolean;
585
- output?: string;
586
- error?: string;
585
+ output?: string | undefined;
586
+ error?: string | undefined;
587
587
  /** If true, the task will be retried. */
588
- retry?: boolean;
588
+ retry?: boolean | undefined;
589
589
  }
590
590
  interface ExecutionSummary {
591
591
  total: number;
@@ -629,8 +629,8 @@ declare function createAutoExecutor(opts: {
629
629
  tracker: TaskTracker;
630
630
  events: EventBus;
631
631
  executeTask: AutoExecutorOptions['executeTask'];
632
- maxConcurrent?: number;
633
- maxRetries?: number;
632
+ maxConcurrent?: number | undefined;
633
+ maxRetries?: number | undefined;
634
634
  }): AutoExecutor;
635
635
 
636
636
  /**
@@ -661,7 +661,7 @@ declare function createAutoExecutor(opts: {
661
661
 
662
662
  interface SddTaskDecomposerOptions {
663
663
  /** Max tasks per batch. Default: 4. Range 1–16. */
664
- parallelSlots?: number;
664
+ parallelSlots?: number | undefined;
665
665
  }
666
666
  interface TaskBatch {
667
667
  /** Tasks ready to execute in this wave. */
@@ -738,15 +738,15 @@ interface SddParallelRunOptions {
738
738
  /** Project root (used for coordinator id). */
739
739
  projectRoot: string;
740
740
  /** Override default parallel slots (1–16). Default: 4. */
741
- parallelSlots?: number;
741
+ parallelSlots?: number | undefined;
742
742
  /** Per-task timeout in ms. Default: 300_000 (5 min). */
743
- taskTimeoutMs?: number;
743
+ taskTimeoutMs?: number | undefined;
744
744
  /** Override the default agent factory. */
745
- subagentFactory?: AgentFactory;
745
+ subagentFactory?: AgentFactory | undefined;
746
746
  /** Called after each wave completes. */
747
- onWave?: (wave: WaveResult) => void;
747
+ onWave?: ((wave: WaveResult) => void) | undefined;
748
748
  /** Called with progress stats every ~2s during execution. */
749
- onProgress?: (progress: SddProgress) => void;
749
+ onProgress?: ((progress: SddProgress) => void) | undefined;
750
750
  }
751
751
  interface SddProgress {
752
752
  wave: number;
package/dist/sdd/index.js CHANGED
@@ -686,7 +686,7 @@ var TaskTracker = class {
686
686
  if (filter.type?.length && !filter.type.includes(n.type)) return false;
687
687
  if (filter.assignee?.length && n.assignee && !filter.assignee.includes(n.assignee))
688
688
  return false;
689
- if (filter.tags?.length && n.tags && !n.tags.some((t) => filter.tags.includes(t)))
689
+ if (filter.tags?.length && n.tags && !n.tags.some((t) => filter.tags?.includes(t)))
690
690
  return false;
691
691
  if (filter.specRequirementId && n.specRequirementId !== filter.specRequirementId)
692
692
  return false;
@@ -1200,6 +1200,12 @@ var TaskGraphStore = class {
1200
1200
  };
1201
1201
 
1202
1202
  // src/sdd/spec-builder.ts
1203
+ function expectDefined(value) {
1204
+ if (value === null || value === void 0) {
1205
+ throw new Error("Expected value to be defined");
1206
+ }
1207
+ return value;
1208
+ }
1203
1209
  function buildQuestioningPrompt(session, min, max) {
1204
1210
  const answered = session.answers.length;
1205
1211
  const remaining = Math.max(0, min - answered);
@@ -1245,7 +1251,7 @@ function buildQuestioningPrompt(session, min, max) {
1245
1251
  if (answered > 0) {
1246
1252
  lines.push("", "**Conversation so far:**");
1247
1253
  for (let i = 0; i < answered; i++) {
1248
- const a = session.answers[i];
1254
+ const a = expectDefined(session.answers[i]);
1249
1255
  lines.push(``, `Q${i + 1}: ${a.question}`, `A${i + 1}: ${a.answer}`);
1250
1256
  }
1251
1257
  }
@@ -1987,6 +1993,12 @@ function truncate(str, maxLen) {
1987
1993
  }
1988
1994
 
1989
1995
  // src/sdd/critical-path.ts
1996
+ function expectDefined2(value) {
1997
+ if (value === null || value === void 0) {
1998
+ throw new Error("Expected value to be defined");
1999
+ }
2000
+ return value;
2001
+ }
1990
2002
  function analyzeCriticalPath(graph) {
1991
2003
  const nodes = Array.from(graph.nodes.values());
1992
2004
  const topoOrder = topologicalSort(graph);
@@ -1995,9 +2007,9 @@ function analyzeCriticalPath(graph) {
1995
2007
  for (const edge of graph.edges) {
1996
2008
  if (edge.type === "depends_on") {
1997
2009
  if (!blockedByMap.has(edge.from)) blockedByMap.set(edge.from, /* @__PURE__ */ new Set());
1998
- blockedByMap.get(edge.from).add(edge.to);
2010
+ blockedByMap.get(edge.from)?.add(edge.to);
1999
2011
  if (!blocksMap.has(edge.to)) blocksMap.set(edge.to, /* @__PURE__ */ new Set());
2000
- blocksMap.get(edge.to).add(edge.from);
2012
+ blocksMap.get(edge.to)?.add(edge.from);
2001
2013
  }
2002
2014
  }
2003
2015
  const readyTasks = [];
@@ -2062,7 +2074,7 @@ function getTransitiveBlocked(_graph, taskId, blocksMap) {
2062
2074
  const visited = /* @__PURE__ */ new Set();
2063
2075
  const queue = [taskId];
2064
2076
  while (queue.length > 0) {
2065
- const current = queue.shift();
2077
+ const current = expectDefined2(queue.shift());
2066
2078
  const blocked = blocksMap.get(current);
2067
2079
  if (!blocked) continue;
2068
2080
  for (const id of blocked) {
@@ -2087,7 +2099,7 @@ function computeCriticalPath(graph, _topoOrder, blockedByMap) {
2087
2099
  for (const [taskId, blockers] of blockedByMap) {
2088
2100
  for (const blockerId of blockers) {
2089
2101
  if (!blocksMap.has(blockerId)) blocksMap.set(blockerId, /* @__PURE__ */ new Set());
2090
- blocksMap.get(blockerId).add(taskId);
2102
+ blocksMap.get(blockerId)?.add(taskId);
2091
2103
  }
2092
2104
  }
2093
2105
  const n = allIds.length;
@@ -2108,7 +2120,7 @@ function computeCriticalPath(graph, _topoOrder, blockedByMap) {
2108
2120
  if (!changed) break;
2109
2121
  }
2110
2122
  let maxDist = 0;
2111
- let maxId = allIds[0];
2123
+ let maxId = expectDefined2(allIds[0]);
2112
2124
  for (const id of allIds) {
2113
2125
  const d = dist.get(id) ?? 0;
2114
2126
  if (d > maxDist) {
@@ -2740,16 +2752,16 @@ var SubagentBudget = class _SubagentBudget {
2740
2752
  }
2741
2753
  if (exceeded.length === 0) return [];
2742
2754
  if (!this._onThreshold) {
2743
- const first2 = exceeded[0];
2755
+ const first2 = exceeded[0] ?? { kind: "iterations", limit: 0, used: 0 };
2744
2756
  throw new BudgetExceededError(first2.kind, first2.limit, first2.used);
2745
2757
  }
2746
2758
  if (this._mode === "sync") {
2747
- const first2 = exceeded[0];
2759
+ const first2 = exceeded[0] ?? { kind: "iterations", limit: 0, used: 0 };
2748
2760
  throw new BudgetExceededError(first2.kind, first2.limit, first2.used);
2749
2761
  }
2750
2762
  const bus = this._events;
2751
2763
  if (!bus || !bus.hasListenerFor("budget.threshold_reached")) {
2752
- const first2 = exceeded[0];
2764
+ const first2 = exceeded[0] ?? { kind: "iterations", limit: 0, used: 0 };
2753
2765
  throw new BudgetExceededError(first2.kind, first2.limit, first2.used);
2754
2766
  }
2755
2767
  for (const entry of exceeded) {
@@ -2757,8 +2769,9 @@ var SubagentBudget = class _SubagentBudget {
2757
2769
  const decision2 = this._negotiateExtension(entry.kind, exceeded);
2758
2770
  this._pendingNegotiations.set(entry.kind, decision2);
2759
2771
  }
2760
- const first = exceeded[0];
2772
+ const first = exceeded[0] ?? { kind: "iterations", limit: 0, used: 0 };
2761
2773
  const decision = this._pendingNegotiations.get(first.kind);
2774
+ if (!decision) throw new Error(`No pending negotiation for ${first.kind}`);
2762
2775
  throw new BudgetThresholdSignal(first.kind, first.limit, first.used, decision);
2763
2776
  }
2764
2777
  /**
@@ -2780,8 +2793,11 @@ var SubagentBudget = class _SubagentBudget {
2780
2793
  * a fresh signal.
2781
2794
  */
2782
2795
  async _negotiateExtension(kind, exceeded) {
2796
+ if (!this._onThreshold) {
2797
+ return "stop";
2798
+ }
2783
2799
  try {
2784
- const first = exceeded[0];
2800
+ const first = exceeded[0] ?? { kind: "iterations", limit: 0, used: 0 };
2785
2801
  const result = this._onThreshold({
2786
2802
  kind: first.kind,
2787
2803
  used: first.used,
@@ -5920,6 +5936,7 @@ var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends E
5920
5936
  takeNextDispatchableTask() {
5921
5937
  for (let i = 0; i < this.pendingTasks.length; i++) {
5922
5938
  const task = this.pendingTasks[i];
5939
+ if (!task) continue;
5923
5940
  const subagentId = task.subagentId ? this.isIdleSubagent(task.subagentId) ? task.subagentId : null : this.findIdleSubagent();
5924
5941
  if (!subagentId) continue;
5925
5942
  this.pendingTasks.splice(i, 1);
@@ -6111,14 +6128,14 @@ var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends E
6111
6128
  const idleExceeded = idleLimit !== void 0 && budget.idleMs() >= idleLimit;
6112
6129
  if (idleExceeded && !wallExceeded) {
6113
6130
  this.subagents.get(ctx.subagentId)?.abortController.abort();
6114
- reject(new BudgetExceededError("timeout", idleLimit, budget.idleMs()));
6131
+ reject(new BudgetExceededError("timeout", idleLimit ?? 0, budget.idleMs()));
6115
6132
  return;
6116
6133
  }
6117
6134
  if (!wallExceeded) {
6118
6135
  scheduleNext();
6119
6136
  return;
6120
6137
  }
6121
- const limit = wallLimit;
6138
+ const limit = wallLimit ?? 0;
6122
6139
  if (!budget.onThreshold) {
6123
6140
  this.subagents.get(ctx.subagentId)?.abortController.abort();
6124
6141
  reject(new BudgetExceededError("timeout", limit, elapsed));
@@ -6277,6 +6294,12 @@ var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends E
6277
6294
  };
6278
6295
 
6279
6296
  // src/sdd/sdd-parallel-run.ts
6297
+ function expectDefined3(value) {
6298
+ if (value === null || value === void 0) {
6299
+ throw new Error("Expected value to be defined");
6300
+ }
6301
+ return value;
6302
+ }
6280
6303
  var SddParallelRun = class {
6281
6304
  constructor(opts) {
6282
6305
  this.opts = opts;
@@ -6377,8 +6400,10 @@ var SddParallelRun = class {
6377
6400
  "\u2022 Do not ask before routine in-project tool use; if a permission gate appears, wait for that flow.",
6378
6401
  "\u2022 Keep output concise \u2014 summarize changes, do not transcribe files."
6379
6402
  ].join("\n");
6403
+ if (!this.coordinator) throw new Error("SDD parallel runner requires a coordinator");
6404
+ const coordinator = this.coordinator;
6380
6405
  const spawns = subagentIds.map(
6381
- (subagentId) => this.coordinator.spawn({
6406
+ (subagentId) => coordinator.spawn({
6382
6407
  id: subagentId,
6383
6408
  name: subagentId,
6384
6409
  role: "executor",
@@ -6386,12 +6411,12 @@ var SddParallelRun = class {
6386
6411
  })
6387
6412
  );
6388
6413
  const spawnResults = await Promise.all(spawns);
6389
- if (!spawnResults.every((r) => r.subagentId)) {
6414
+ if (!spawnResults.every((r) => Boolean(r.subagentId))) {
6390
6415
  throw new Error("One or more subagent spawns failed");
6391
6416
  }
6392
6417
  const assignPromises = tasks.map((task, i) => {
6393
6418
  const spec = {
6394
- id: taskIds[i],
6419
+ id: taskIds[i] ?? task.id,
6395
6420
  description: [
6396
6421
  directivePreamble,
6397
6422
  "",
@@ -6400,15 +6425,15 @@ var SddParallelRun = class {
6400
6425
  "",
6401
6426
  task.description
6402
6427
  ].join("\n"),
6403
- subagentId: subagentIds[i],
6428
+ subagentId: subagentIds[i] ?? spawnResults[i]?.subagentId ?? task.id,
6404
6429
  timeoutMs: this.timeoutMs
6405
6430
  };
6406
- return this.coordinator.assign(spec);
6431
+ return this.coordinator?.assign(spec);
6407
6432
  });
6408
6433
  await Promise.all(assignPromises);
6409
6434
  let results;
6410
6435
  try {
6411
- results = await this.coordinator.awaitTasks(taskIds);
6436
+ results = await coordinator.awaitTasks(taskIds);
6412
6437
  } catch (err) {
6413
6438
  results = taskIds.map((id) => ({
6414
6439
  subagentId: "",
@@ -6423,8 +6448,8 @@ var SddParallelRun = class {
6423
6448
  const successCount = results.filter((r) => r.status === "success").length;
6424
6449
  const failCount = results.length - successCount;
6425
6450
  for (let i = 0; i < results.length; i++) {
6426
- const result = results[i];
6427
- const taskId = taskIds[i];
6451
+ const result = expectDefined3(results[i]);
6452
+ const taskId = expectDefined3(taskIds[i]);
6428
6453
  if (result.status === "success") {
6429
6454
  this.opts.tracker.updateNodeStatus(taskId, "completed");
6430
6455
  } else {