@wrongstack/core 0.6.5 → 0.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/{agent-bridge-BBXK_ppx.d.ts → agent-bridge-BCVxmrOn.d.ts} +1 -1
  2. package/dist/{agent-subagent-runner-DsSm9lKN.d.ts → agent-subagent-runner-BTloSwjE.d.ts} +3 -3
  3. package/dist/{compactor-C8NhpSt5.d.ts → compactor-BUJ8550X.d.ts} +1 -1
  4. package/dist/{config-DfC6g6KV.d.ts → config-BHkYGzUT.d.ts} +1 -1
  5. package/dist/{context-DN5v-uQX.d.ts → context-C8mBUzBv.d.ts} +3 -5
  6. package/dist/coordination/index.d.ts +10 -10
  7. package/dist/coordination/index.js +62 -30
  8. package/dist/coordination/index.js.map +1 -1
  9. package/dist/defaults/index.d.ts +21 -21
  10. package/dist/defaults/index.js +130 -32
  11. package/dist/defaults/index.js.map +1 -1
  12. package/dist/{events-CJqwQl8G.d.ts → events-DounT6pP.d.ts} +10 -1
  13. package/dist/execution/index.d.ts +56 -14
  14. package/dist/execution/index.js +74 -18
  15. package/dist/execution/index.js.map +1 -1
  16. package/dist/extension/index.d.ts +6 -6
  17. package/dist/{goal-store-_Er467ya.d.ts → goal-store-HHgaq5ue.d.ts} +1 -1
  18. package/dist/{index-CXnWsGBp.d.ts → index-BlVITqm-.d.ts} +6 -9
  19. package/dist/{index-DcnXDPdY.d.ts → index-DiIGZh5I.d.ts} +20 -5
  20. package/dist/index.d.ts +28 -28
  21. package/dist/index.js +251 -131
  22. package/dist/index.js.map +1 -1
  23. package/dist/infrastructure/index.d.ts +6 -6
  24. package/dist/kernel/index.d.ts +9 -9
  25. package/dist/kernel/index.js.map +1 -1
  26. package/dist/{mcp-servers-CevFHHM1.d.ts → mcp-servers-CXFfDN_d.d.ts} +3 -3
  27. package/dist/models/index.d.ts +2 -2
  28. package/dist/{multi-agent-D5IbASk_.d.ts → multi-agent-Iy8YUe3v.d.ts} +4 -4
  29. package/dist/observability/index.d.ts +2 -2
  30. package/dist/{path-resolver-CBx_q1HA.d.ts → path-resolver-DwJO5XBn.d.ts} +2 -2
  31. package/dist/{plan-templates-BEOllUJV.d.ts → plan-templates-CG_pInJV.d.ts} +4 -4
  32. package/dist/{provider-runner-Byh5TcJs.d.ts → provider-runner-DoohzfyD.d.ts} +3 -3
  33. package/dist/{retry-policy-BZSIMxrJ.d.ts → retry-policy-DOnwHAyz.d.ts} +1 -1
  34. package/dist/sdd/index.d.ts +9 -4
  35. package/dist/sdd/index.js +21 -0
  36. package/dist/sdd/index.js.map +1 -1
  37. package/dist/{secret-scrubber-CT7wefiO.d.ts → secret-scrubber-C9UJxFCJ.d.ts} +1 -1
  38. package/dist/{secret-scrubber-I0QHY_ob.d.ts → secret-scrubber-DcTK9JHC.d.ts} +1 -1
  39. package/dist/security/index.d.ts +3 -3
  40. package/dist/{selector-DDb_mq9X.d.ts → selector-DVo3eT-P.d.ts} +1 -1
  41. package/dist/{session-reader-B9nVkziM.d.ts → session-reader-BXWxFAhS.d.ts} +1 -1
  42. package/dist/storage/index.d.ts +6 -6
  43. package/dist/storage/index.js +3 -2
  44. package/dist/storage/index.js.map +1 -1
  45. package/dist/{system-prompt-gL06H9P4.d.ts → system-prompt-BBGles-N.d.ts} +1 -1
  46. package/dist/{task-graph-BITvWt4t.d.ts → task-graph-D1YQbpxF.d.ts} +1 -0
  47. package/dist/{tool-executor-BF7QfYVE.d.ts → tool-executor-CwpjhwHC.d.ts} +4 -4
  48. package/dist/types/index.d.ts +16 -16
  49. package/dist/types/index.js +1 -3
  50. package/dist/types/index.js.map +1 -1
  51. package/dist/utils/index.d.ts +1 -1
  52. package/package.json +1 -1
  53. package/skills/sdd/SKILL.md +122 -106
@@ -1,42 +1,42 @@
1
1
  export { D as DefaultLogger, a as DefaultLoggerOptions } from '../logger-BH6AE0W9.js';
2
- export { A as AbandonedSession, a as AttachmentStoreOptions, C as ConfigLoaderOptions, b as ConfigMigration, c as ConfigMigrationError, d as ConfigSource, D as DEFAULT_CONFIG_MIGRATIONS, e as DefaultAttachmentStore, f as DefaultConfigLoader, g as DefaultConfigStore, h as DefaultMemoryStore, i as DefaultSessionStore, M as MemoryStoreOptions, j as MigrationContext, k as MigrationResult, P as PersistedQueueItem, l as PlanFile, m as PlanItem, n as PlanTemplate, Q as QueueStore, R as RecoveryLock, o as RecoveryLockOptions, S as SessionAnalyzer, p as SessionStoreOptions, T as TodosCheckpointFile, q as addPlanItem, r as attachPlanCheckpoint, s as attachTodosCheckpoint, t as clearPlan, u as deriveTodosFromPlanItem, v as emptyPlan, w as formatPlan, x as formatPlanTemplates, y as getPlanTemplate, z as listPlanTemplates, B as loadPlan, E as loadTodosCheckpoint, F as removePlanItem, G as runConfigMigrations, H as savePlan, I as saveTodosCheckpoint, J as setPlanItemStatus } from '../plan-templates-BEOllUJV.js';
3
- export { D as DefaultSessionReader } from '../session-reader-B9nVkziM.js';
2
+ export { A as AbandonedSession, a as AttachmentStoreOptions, C as ConfigLoaderOptions, b as ConfigMigration, c as ConfigMigrationError, d as ConfigSource, D as DEFAULT_CONFIG_MIGRATIONS, e as DefaultAttachmentStore, f as DefaultConfigLoader, g as DefaultConfigStore, h as DefaultMemoryStore, i as DefaultSessionStore, M as MemoryStoreOptions, j as MigrationContext, k as MigrationResult, P as PersistedQueueItem, l as PlanFile, m as PlanItem, n as PlanTemplate, Q as QueueStore, R as RecoveryLock, o as RecoveryLockOptions, S as SessionAnalyzer, p as SessionStoreOptions, T as TodosCheckpointFile, q as addPlanItem, r as attachPlanCheckpoint, s as attachTodosCheckpoint, t as clearPlan, u as deriveTodosFromPlanItem, v as emptyPlan, w as formatPlan, x as formatPlanTemplates, y as getPlanTemplate, z as listPlanTemplates, B as loadPlan, E as loadTodosCheckpoint, F as removePlanItem, G as runConfigMigrations, H as savePlan, I as saveTodosCheckpoint, J as setPlanItemStatus } from '../plan-templates-CG_pInJV.js';
3
+ export { D as DefaultSessionReader } from '../session-reader-BXWxFAhS.js';
4
4
  export { D as DirectorStateCheckpoint, a as DirectorStateSnapshot, b as DirectorSubagentState, c as DirectorTaskState, l as loadDirectorState } from '../director-state-BmYi3DGA.js';
5
- export { D as DefaultSecretScrubber, a as DefaultSecretVault, S as SecretVaultOptions, d as decryptConfigSecrets, e as encryptConfigSecrets, m as migratePlaintextSecrets, r as rewriteConfigEncrypted } from '../secret-scrubber-I0QHY_ob.js';
5
+ export { D as DefaultSecretScrubber, a as DefaultSecretVault, S as SecretVaultOptions, d as decryptConfigSecrets, e as encryptConfigSecrets, m as migratePlaintextSecrets, r as rewriteConfigEncrypted } from '../secret-scrubber-DcTK9JHC.js';
6
6
  export { AutoApprovePermissionPolicy, DefaultPermissionPolicy, PermissionPolicyOptions } from '../security/index.js';
7
- export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, T as ToolExecutor } from '../tool-executor-BF7QfYVE.js';
7
+ export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, T as ToolExecutor } from '../tool-executor-CwpjhwHC.js';
8
8
  export { AutoCompactionMiddleware, AutonomousRunner, AutonomousRunnerOptions, AutonomyPromptContributorOptions, DefaultSkillLoader, DoneCheckResult, DoneConditionChecker, EternalAutonomyEngine, EternalAutonomyOptions, EternalEngineState, IntelligentCompactor, IntelligentCompactorOptions, ParallelEngineState, ParallelEternalEngine, ParallelEternalOptions, SelectiveCompactor, SelectiveCompactorOptions, SkillLoaderOptions, buildGoalPreamble, makeAutonomyPromptContributor } from '../execution/index.js';
9
- import { P as ProviderRunner, R as RunProviderOptions } from '../provider-runner-Byh5TcJs.js';
10
- import { j as Response } from '../context-DN5v-uQX.js';
11
- export { A as ALL_FLEET_AGENTS, a as AUDIT_LOG_AGENT, B as BUG_HUNTER_AGENT, C as CreateDelegateToolOptions, D as DEFAULT_DIRECTOR_PREAMBLE, b as DEFAULT_SUBAGENT_BASELINE, c as DefaultMultiAgentCoordinator, d as DelegateHost, e as Director, f as DirectorPromptParts, g as DirectorSessionFactory, h as DirectorSessionFactoryOptions, F as FLEET_ROSTER, i as FLEET_ROSTER_BUDGETS, l as FleetSpawnBudgetError, I as ICoordinator, m as IFleetManager, M as MultiAgentCoordinatorOptions, N as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, S as SECURITY_SCANNER_AGENT, n as SubagentPromptParts, o as applyRosterBudget, p as composeDirectorPrompt, q as composeSubagentPrompt, r as createDelegateTool, s as makeDirectorSessionFactory, t as rosterSummaryFromConfigs } from '../index-CXnWsGBp.js';
12
- export { n as BudgetExceededError, o as BudgetKind, p as BudgetLimits, q as BudgetUsage, r as SubagentBudget } from '../multi-agent-D5IbASk_.js';
13
- 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-DsSm9lKN.js';
14
- export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-BBXK_ppx.js';
9
+ import { P as ProviderRunner, R as RunProviderOptions } from '../provider-runner-DoohzfyD.js';
10
+ import { j as Response } from '../context-C8mBUzBv.js';
11
+ export { A as ALL_FLEET_AGENTS, a as AUDIT_LOG_AGENT, B as BUG_HUNTER_AGENT, C as CreateDelegateToolOptions, D as DEFAULT_DIRECTOR_PREAMBLE, b as DEFAULT_SUBAGENT_BASELINE, c as DefaultMultiAgentCoordinator, d as DelegateHost, e as Director, f as DirectorPromptParts, g as DirectorSessionFactory, h as DirectorSessionFactoryOptions, F as FLEET_ROSTER, i as FLEET_ROSTER_BUDGETS, l as FleetSpawnBudgetError, I as ICoordinator, m as IFleetManager, M as MultiAgentCoordinatorOptions, N as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, S as SECURITY_SCANNER_AGENT, n as SubagentPromptParts, o as applyRosterBudget, p as composeDirectorPrompt, q as composeSubagentPrompt, r as createDelegateTool, s as makeDirectorSessionFactory, t as rosterSummaryFromConfigs } from '../index-BlVITqm-.js';
12
+ export { n as BudgetExceededError, o as BudgetKind, p as BudgetLimits, q as BudgetUsage, r as SubagentBudget } from '../multi-agent-Iy8YUe3v.js';
13
+ 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-BTloSwjE.js';
14
+ export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-BCVxmrOn.js';
15
15
  export { D as DefaultModelsRegistry, a as DefaultModelsRegistryOptions, c as classifyFamily } from '../models-registry-DqzwpBQy.js';
16
16
  export { DefaultModeStore, LLMSelector, LLMSelectorOptions, ModeLoaderOptions, loadProjectModes, loadUserModes } from '../models/index.js';
17
17
  export { AISpecBuilder, AISpecBuilderOptions, AISpecPhase, AISpecSession, AutoExecutor, AutoExecutorOptions, BottleneckTask, CollectedAnswer, CriticalPathAnalysis, DefaultTaskStore, ExecutionSummary, GeneratedTask, SPEC_TEMPLATES, SpecDiff, SpecDrivenDev, SpecDrivenDevOptions, SpecIndexEntry, SpecParser, SpecStore, SpecStoreOptions, SpecVersion, SpecVersioning, TaskExecutionContext, TaskExecutionResult, TaskFlow, TaskFlowEventMap, TaskFlowEventName, TaskFlowExecutionContext, TaskFlowOptions, TaskFlowPhase, TaskGenerator, TaskGeneratorOptions, TaskGraphIndexEntry, TaskGraphStore, TaskGraphStoreOptions, TaskStore, TaskTracker, TaskTrackerOptions, TaskTransition, analyzeCriticalPath, createAutoExecutor, getTemplate, listTemplates, renderProgress, renderSpecAnalysis, renderTaskGraph, renderTaskList, templateToMarkdown } from '../sdd/index.js';
18
18
  export { DefaultHealthRegistry, InMemoryMetricsSink, MetricsServerHandle, MetricsServerOptions, NoopMetricsSink, NoopTracer, OTelTracer, OtlpMetricsExporterHandle, OtlpMetricsExporterOptions, OtlpTraceExporterHandle, OtlpTraceExporterOptions, PROMETHEUS_CONTENT_TYPE, buildOtlpMetricsRequest, buildOtlpTracesRequest, renderPrometheus, startMetricsServer, startOtlpMetricsExporter, startOtlpTraceExporter, wireMetricsToEvents } from '../observability/index.js';
19
- export { C as ContextManagerAction, a as ContextManagerInput, b as ContextManagerResult, c as ContextManagerToolOptions, d as allServers, e as awsServer, f as blockServer, g as braveSearchServer, h as context7Server, i as contextManagerTool, j as createContextManagerTool, k as everArtServer, l as filesystemServer, m as githubServer, n as googleMapsServer, o as miniMaxVisionServer, s as sentinelServer, p as slackServer, z as zaiVisionServer } from '../mcp-servers-CevFHHM1.js';
19
+ export { C as ContextManagerAction, a as ContextManagerInput, b as ContextManagerResult, c as ContextManagerToolOptions, d as allServers, e as awsServer, f as blockServer, g as braveSearchServer, h as context7Server, i as contextManagerTool, j as createContextManagerTool, k as everArtServer, l as filesystemServer, m as githubServer, n as googleMapsServer, o as miniMaxVisionServer, s as sentinelServer, p as slackServer, z as zaiVisionServer } from '../mcp-servers-CXFfDN_d.js';
20
20
  import '../logger-BMQgxvdy.js';
21
- import '../events-CJqwQl8G.js';
21
+ import '../events-DounT6pP.js';
22
22
  import '../memory-CEXuo7sz.js';
23
23
  import '../wstack-paths-86YPFktR.js';
24
- import '../config-DfC6g6KV.js';
24
+ import '../config-BHkYGzUT.js';
25
25
  import '../models-registry-Y2xbog0E.js';
26
26
  import '../secret-vault-DoISxaKO.js';
27
- import '../secret-scrubber-CT7wefiO.js';
27
+ import '../secret-scrubber-C9UJxFCJ.js';
28
28
  import '../input-reader-E-ffP2ee.js';
29
- import '../compactor-C8NhpSt5.js';
30
- import '../retry-policy-BZSIMxrJ.js';
31
- import '../index-DcnXDPdY.js';
32
- import '../system-prompt-gL06H9P4.js';
29
+ import '../compactor-BUJ8550X.js';
30
+ import '../retry-policy-DOnwHAyz.js';
31
+ import '../index-DiIGZh5I.js';
32
+ import '../system-prompt-BBGles-N.js';
33
33
  import '../observability-BhnVLBLS.js';
34
- import '../selector-DDb_mq9X.js';
35
- import '../goal-store-_Er467ya.js';
34
+ import '../selector-DVo3eT-P.js';
35
+ import '../goal-store-HHgaq5ue.js';
36
36
  import '../skill-CxuWrsKK.js';
37
37
  import 'node:events';
38
38
  import '../mode-CV077NjV.js';
39
- import '../task-graph-BITvWt4t.js';
39
+ import '../task-graph-D1YQbpxF.js';
40
40
 
41
41
  /**
42
42
  * Default ProviderRunner — thin adapter over `runProviderWithRetry`.
@@ -2531,7 +2531,7 @@ var DirectorStateCheckpoint = class {
2531
2531
  this.timer = null;
2532
2532
  }
2533
2533
  await this.persist();
2534
- if (this.rewriteRequested) {
2534
+ while (this.rewriteRequested) {
2535
2535
  this.rewriteRequested = false;
2536
2536
  await this.persist();
2537
2537
  }
@@ -5367,7 +5367,8 @@ function appendJournal(goal, entry) {
5367
5367
  // src/execution/eternal-autonomy.ts
5368
5368
  var execFileP = promisify(execFile);
5369
5369
  var BRAINSTORM_DONE = /* @__PURE__ */ Symbol("brainstorm-done");
5370
- var GOAL_COMPLETE_MARKER = /^\s*\[goal[_\s-]?complete\]\s*$/im;
5370
+ var GOAL_COMPLETE_MARKER = /^\s*\[goal[_\s-]*complete\]\s*$/im;
5371
+ var GOAL_CLEAR_MARKER = /^\s*\[\/?goal\s*clear\]\s*$/im;
5371
5372
  var EternalAutonomyEngine = class {
5372
5373
  constructor(opts) {
5373
5374
  this.opts = opts;
@@ -5449,23 +5450,33 @@ var EternalAutonomyEngine = class {
5449
5450
  * `agent.run()` avoids race conditions on the shared Context.
5450
5451
  */
5451
5452
  async runOneIteration() {
5453
+ const emit = (stage) => {
5454
+ this.opts.onStage?.(stage);
5455
+ };
5452
5456
  const goal = await loadGoal(this.goalPath);
5453
5457
  if (!goal) {
5458
+ emit({ phase: "stopped" });
5454
5459
  this.stopRequested = true;
5455
5460
  return false;
5456
5461
  }
5457
5462
  const missionState = goal.goalState ?? "active";
5458
5463
  if (missionState !== "active") {
5464
+ emit({ phase: missionState === "paused" ? "paused" : "stopped" });
5459
5465
  this.stopRequested = true;
5460
5466
  return false;
5461
5467
  }
5468
+ emit({ phase: "decide", reason: "picking next task" });
5462
5469
  const action = await this.decide(goal);
5463
5470
  if (!action) {
5464
5471
  if (!this.stopRequested) {
5472
+ emit({ phase: "sleep", ms: 5e3 });
5465
5473
  await sleep(5e3);
5474
+ } else {
5475
+ emit({ phase: "stopped" });
5466
5476
  }
5467
5477
  return false;
5468
5478
  }
5479
+ emit({ phase: "execute", task: action.task });
5469
5480
  const ctrl = new AbortController();
5470
5481
  this.currentCtrl = ctrl;
5471
5482
  const timer = setTimeout(
@@ -5543,6 +5554,7 @@ var EternalAutonomyEngine = class {
5543
5554
  tokens,
5544
5555
  costUsd
5545
5556
  });
5557
+ emit({ phase: "reflect", status, note });
5546
5558
  let iterationIndex = 0;
5547
5559
  try {
5548
5560
  const reloaded = await loadGoal(this.goalPath);
@@ -5564,6 +5576,7 @@ var EternalAutonomyEngine = class {
5564
5576
  this.consecutiveTransientRetries++;
5565
5577
  const delay = this.computeTransientBackoffMs();
5566
5578
  if (delay > 0) {
5579
+ emit({ phase: "sleep", ms: delay });
5567
5580
  await this.sleepInterruptible(delay);
5568
5581
  }
5569
5582
  return false;
@@ -5577,8 +5590,16 @@ var EternalAutonomyEngine = class {
5577
5590
  return false;
5578
5591
  }
5579
5592
  this.consecutiveTransientRetries = 0;
5593
+ const cycleGapMs = this.opts.cycleGapMs ?? 1e3;
5594
+ emit({ phase: "sleep", ms: cycleGapMs });
5595
+ await sleep(cycleGapMs);
5580
5596
  if (GOAL_COMPLETE_MARKER.test(finalText)) {
5581
- await this.markGoalCompleted(action, finalText);
5597
+ await this.clearGoalManually(finalText);
5598
+ this.stopRequested = true;
5599
+ return true;
5600
+ }
5601
+ if (GOAL_CLEAR_MARKER.test(finalText)) {
5602
+ await this.clearGoalManually(finalText);
5582
5603
  this.stopRequested = true;
5583
5604
  return true;
5584
5605
  }
@@ -5878,6 +5899,30 @@ ${recentJournal}` : "No prior iterations.",
5878
5899
  });
5879
5900
  await saveGoal(this.goalPath, withEntry);
5880
5901
  }
5902
+ /**
5903
+ * Manually clear the goal — equivalent to `/goal clear` typed by the user.
5904
+ * Sets goalState to `abandoned`, removes the goal file, and fires
5905
+ * `onEternalStop` so the REPL returns to normal mode.
5906
+ */
5907
+ async clearGoalManually(note) {
5908
+ const current = await loadGoal(this.goalPath);
5909
+ if (current) {
5910
+ const abandoned = { ...current, goalState: "abandoned" };
5911
+ await saveGoal(this.goalPath, abandoned);
5912
+ }
5913
+ try {
5914
+ const { unlink: unlink9 } = await import('fs/promises');
5915
+ await unlink9(this.goalPath);
5916
+ } catch {
5917
+ }
5918
+ this.opts.onEternalStop?.();
5919
+ void this.appendIterationEntry({
5920
+ source: "manual",
5921
+ task: "goal cleared",
5922
+ status: "success",
5923
+ note: note.slice(0, 240)
5924
+ });
5925
+ }
5881
5926
  async appendFailure(task, note) {
5882
5927
  await this.appendIterationEntry({ source: "manual", task, status: "failure", note });
5883
5928
  }
@@ -5945,10 +5990,10 @@ var SubagentBudget = class _SubagentBudget {
5945
5990
  * or hung listener (Director not built / event filter detached mid-run)
5946
5991
  * leaves the budget over-limit and never enforces anything, since
5947
5992
  * `checkLimit` returns synchronously via `void this.checkLimitAsync`.
5948
- * Hardcoded for now most fleets set their own per-task timeout that
5949
- * dwarfs this anyway. 30 s matches the existing event-emit timeoutMs.
5993
+ * Raised from 30s to 60s to give subagents more headroom before
5994
+ * the threshold negotiation times out and triggers a hard stop.
5950
5995
  */
5951
- static DECISION_TIMEOUT_MS = 3e4;
5996
+ static DECISION_TIMEOUT_MS = 6e4;
5952
5997
  /**
5953
5998
  * Injected by the runner when wiring the budget to its EventBus.
5954
5999
  * Used by `checkLimitAsync` to emit `budget.threshold_reached` events.
@@ -6479,13 +6524,19 @@ var FLEET_ROSTER = {
6479
6524
  "security-scanner": SECURITY_SCANNER_AGENT
6480
6525
  };
6481
6526
  var FLEET_ROSTER_BUDGETS = {
6482
- "audit-log": { timeoutMs: 8 * 60 * 1e3, maxIterations: 150, maxToolCalls: 500 },
6483
- "bug-hunter": { timeoutMs: 15 * 60 * 1e3, maxIterations: 200, maxToolCalls: 600 },
6484
- "refactor-planner": { timeoutMs: 12 * 60 * 1e3, maxIterations: 180, maxToolCalls: 550 },
6485
- "security-scanner": { timeoutMs: 15 * 60 * 1e3, maxIterations: 200, maxToolCalls: 600 }
6527
+ "audit-log": { timeoutMs: 7.5 * 60 * 60 * 1e3, maxIterations: 5e3, maxToolCalls: 15e3 },
6528
+ "bug-hunter": { timeoutMs: 10 * 60 * 60 * 1e3, maxIterations: 8e3, maxToolCalls: 2e4 },
6529
+ "refactor-planner": { timeoutMs: 7.5 * 60 * 60 * 1e3, maxIterations: 6e3, maxToolCalls: 18e3 },
6530
+ "security-scanner": { timeoutMs: 10 * 60 * 60 * 1e3, maxIterations: 8e3, maxToolCalls: 2e4 }
6531
+ };
6532
+ var GENERIC_SUBAGENT_BUDGET = {
6533
+ timeoutMs: 3 * 60 * 60 * 1e3,
6534
+ maxIterations: 5e3,
6535
+ maxToolCalls: 15e3
6486
6536
  };
6487
6537
  function applyRosterBudget(cfg) {
6488
- const defaultBudget = FLEET_ROSTER_BUDGETS[cfg.role ?? ""];
6538
+ const roleBudget = cfg.role ? FLEET_ROSTER_BUDGETS[cfg.role] : void 0;
6539
+ const defaultBudget = roleBudget ?? (cfg.name ? GENERIC_SUBAGENT_BUDGET : void 0);
6489
6540
  if (!defaultBudget) return cfg;
6490
6541
  return {
6491
6542
  ...cfg,
@@ -6557,7 +6608,7 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
6557
6608
  // hasParentBridge() — the type now reflects this.
6558
6609
  parentBridge: null,
6559
6610
  doneCondition: this.config.doneCondition,
6560
- maxConcurrent: this.config.maxConcurrent ?? 4
6611
+ maxConcurrent: this.config.maxConcurrent ?? 16
6561
6612
  };
6562
6613
  this.subagents.set(id, {
6563
6614
  config: { ...subagent, id },
@@ -6684,7 +6735,7 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
6684
6735
  }
6685
6736
  }
6686
6737
  canDispatch() {
6687
- const max = this.config.maxConcurrent ?? 4;
6738
+ const max = this.config.maxConcurrent ?? 16;
6688
6739
  return this.inFlight < max && this.pendingTasks.length > 0;
6689
6740
  }
6690
6741
  takeNextDispatchableTask() {
@@ -6778,13 +6829,18 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
6778
6829
  task.subagentId = subagentId;
6779
6830
  subagent.context.tasks.push(task);
6780
6831
  this.emit("task.assigned", { task, subagentId });
6832
+ const rawMaxIterations = subagent.config.maxIterations;
6833
+ const rawMaxToolCalls = subagent.config.maxToolCalls;
6834
+ const rawMaxTokens = subagent.config.maxTokens;
6835
+ const rawMaxCostUsd = subagent.config.maxCostUsd;
6836
+ const rawTimeoutMs = subagent.config.timeoutMs;
6781
6837
  const configWithRosterDefaults = applyRosterBudget(subagent.config);
6782
6838
  const budget = new SubagentBudget({
6783
- maxIterations: configWithRosterDefaults.maxIterations ?? this.config.defaultBudget?.maxIterations,
6784
- maxToolCalls: task.maxToolCalls ?? configWithRosterDefaults.maxToolCalls ?? this.config.defaultBudget?.maxToolCalls,
6785
- maxTokens: configWithRosterDefaults.maxTokens ?? this.config.defaultBudget?.maxTokens,
6786
- maxCostUsd: configWithRosterDefaults.maxCostUsd ?? this.config.defaultBudget?.maxCostUsd,
6787
- timeoutMs: task.timeoutMs ?? configWithRosterDefaults.timeoutMs ?? this.config.defaultBudget?.timeoutMs
6839
+ maxIterations: rawMaxIterations ?? this.config.defaultBudget?.maxIterations ?? configWithRosterDefaults.maxIterations,
6840
+ maxToolCalls: rawMaxToolCalls ?? this.config.defaultBudget?.maxToolCalls ?? configWithRosterDefaults.maxToolCalls,
6841
+ maxTokens: rawMaxTokens ?? this.config.defaultBudget?.maxTokens ?? configWithRosterDefaults.maxTokens,
6842
+ maxCostUsd: rawMaxCostUsd ?? this.config.defaultBudget?.maxCostUsd ?? configWithRosterDefaults.maxCostUsd,
6843
+ timeoutMs: rawTimeoutMs ?? this.config.defaultBudget?.timeoutMs ?? configWithRosterDefaults.timeoutMs
6788
6844
  });
6789
6845
  subagent.activeBudget = budget;
6790
6846
  if (!this.runner) {
@@ -6855,7 +6911,7 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
6855
6911
  kind: "timeout",
6856
6912
  used: elapsed,
6857
6913
  limit,
6858
- timeoutMs: 3e4,
6914
+ timeoutMs: 6e4,
6859
6915
  extend: (extra) => resolveDecision({ extend: extra }),
6860
6916
  deny: () => resolveDecision("stop")
6861
6917
  });
@@ -7597,10 +7653,8 @@ var InMemoryAgentBridge = class {
7597
7653
  this.pendingRequests.delete(correlationId);
7598
7654
  reject(new Error(`Request ${correlationId} timed out after ${timeout}ms`));
7599
7655
  }, timeout);
7600
- if (this.stopped) {
7656
+ if (!this.inflightGuards.has(correlationId)) {
7601
7657
  clearTimeout(timer);
7602
- this.inflightGuards.delete(correlationId);
7603
- this.pendingRequests.delete(correlationId);
7604
7658
  reject(new Error("Bridge stopped"));
7605
7659
  return;
7606
7660
  }
@@ -8431,7 +8485,12 @@ var Director = class {
8431
8485
  }
8432
8486
  }
8433
8487
  }
8434
- const result = await this.coordinator.spawn(config);
8488
+ let result;
8489
+ try {
8490
+ result = await this.coordinator.spawn(config);
8491
+ } catch (err) {
8492
+ throw err;
8493
+ }
8435
8494
  if (this.fleetManager) {
8436
8495
  this.fleetManager.recordSpawn(result.subagentId, config, priceLookup);
8437
8496
  } else {
@@ -8879,7 +8938,7 @@ var Director = class {
8879
8938
  }
8880
8939
  };
8881
8940
  function createDelegateTool(opts) {
8882
- const defaultTimeoutMs = opts.defaultTimeoutMs ?? 4 * 60 * 60 * 1e3;
8941
+ const defaultTimeoutMs = opts.defaultTimeoutMs ?? 30 * 60 * 1e3;
8883
8942
  const rosterIds = opts.roster ? Object.keys(opts.roster) : [];
8884
8943
  const inputSchema = {
8885
8944
  type: "object",
@@ -8895,7 +8954,7 @@ function createDelegateTool(opts) {
8895
8954
  },
8896
8955
  name: {
8897
8956
  type: "string",
8898
- description: "Display name for the subagent when not using a roster role. Required when `role` is omitted."
8957
+ description: "Display name for free-form subagents (not using a roster role). The subagent gets a large default budget (3h, 5000 iter, 15000 tool calls). Required when `role` is omitted."
8899
8958
  },
8900
8959
  provider: {
8901
8960
  type: "string",
@@ -8926,8 +8985,8 @@ function createDelegateTool(opts) {
8926
8985
  };
8927
8986
  return {
8928
8987
  name: "delegate",
8929
- description: "Hand a discrete piece of work to a dedicated subagent and wait for its result. The subagent has its own context, its own LLM call, and its own budget \u2014 use this when a task is self-contained, would otherwise blow up your context, or benefits from a specialized role (bug-hunter, security-scanner, refactor-planner, audit-log). YOU decide how big the budget is: pass `timeoutMs`, `maxIterations`, and `maxToolCalls` sized to the actual work. There is no hidden cap forcing a 3-minute / 80-iteration limit \u2014 if a monorepo audit needs 2 hours and 500 tool calls, ask for that. Call multiple delegates in parallel through the provider's parallel-tool-call surface to fan work out across roles.",
8930
- usageHint: "Set `task` to a complete instruction. Either pick `role` from the roster or pass `name` + `provider` + `model`. For non-trivial work, also pass `timeoutMs` (the wall-clock budget you actually need), `maxIterations`, and `maxToolCalls` \u2014 defaults are intentionally generous (4 hours) but the right values depend on scope. Returns the subagent's `TaskResult` \u2014 including the textual `result`, iteration count, tool count, and duration. Auto-promotes the host into director mode on first call.",
8988
+ description: "Hand a discrete piece of work to a dedicated subagent and wait for its result. The subagent has its own context, its own LLM call, and its own budget \u2014 use this when a task is self-contained, would otherwise blow up your context, or benefits from a specialized role (bug-hunter, security-scanner, refactor-planner, audit-log). For free-form coding tasks (not tied to a pre-defined role), pass `name` + `task` \u2014 the subagent runs as a general-purpose coding agent with a large default budget. YOU decide how big the budget is: pass `timeoutMs`, `maxIterations`, and `maxToolCalls` sized to the actual work. There is no hidden cap forcing a 3-minute / 80-iteration limit \u2014 if a monorepo audit needs 2 hours and 500 tool calls, ask for that. Call multiple delegates in parallel through the provider's parallel-tool-call surface to fan work out across roles.",
8989
+ usageHint: "Set `task` to a complete instruction. Either pick `role` from the roster (audit-log, bug-hunter, refactor-planner, security-scanner) or pass `name` to run a free-form coding agent. For non-trivial work, also pass `timeoutMs`, `maxIterations`, and `maxToolCalls`. Returns the subagent's `TaskResult` \u2014 including the textual `result`, iteration count, tool count, and duration. Auto-promotes the host into director mode on first call.",
8931
8990
  permission: "auto",
8932
8991
  mutating: false,
8933
8992
  inputSchema,
@@ -8975,6 +9034,7 @@ function createDelegateTool(opts) {
8975
9034
  model: i.model,
8976
9035
  systemPromptOverride: i.systemPromptOverride
8977
9036
  };
9037
+ cfg = applyRosterBudget({ ...cfg, name: i.name });
8978
9038
  }
8979
9039
  if (typeof i.maxIterations === "number" && i.maxIterations > 0) {
8980
9040
  cfg.maxIterations = i.maxIterations;
@@ -8982,7 +9042,7 @@ function createDelegateTool(opts) {
8982
9042
  if (typeof i.maxToolCalls === "number" && i.maxToolCalls > 0) {
8983
9043
  cfg.maxToolCalls = i.maxToolCalls;
8984
9044
  }
8985
- const SUBAGENT_TIMEOUT_BUFFER_MS = opts.subagentTimeoutBufferMs ?? 3e4;
9045
+ const SUBAGENT_TIMEOUT_BUFFER_MS = opts.subagentTimeoutBufferMs ?? 6e4;
8986
9046
  const desiredSubTimeout = Math.max(3e4, timeoutMs - SUBAGENT_TIMEOUT_BUFFER_MS);
8987
9047
  if (!cfg.timeoutMs || cfg.timeoutMs > desiredSubTimeout) {
8988
9048
  cfg.timeoutMs = desiredSubTimeout;
@@ -9019,6 +9079,7 @@ function createDelegateTool(opts) {
9019
9079
  const errorKind = result.error?.kind;
9020
9080
  const retryable = result.error?.retryable;
9021
9081
  const backoffMs = result.error?.backoffMs;
9082
+ const summary = buildDelegateSummary(i.role, result);
9022
9083
  return {
9023
9084
  ok: result.status === "success",
9024
9085
  status: result.status,
@@ -9034,7 +9095,10 @@ function createDelegateTool(opts) {
9034
9095
  toolCalls: result.toolCalls,
9035
9096
  durationMs: result.durationMs,
9036
9097
  ...partial ? { partial } : {},
9037
- ...hintForKind(errorKind, retryable, backoffMs, partial) ? { hint: hintForKind(errorKind, retryable, backoffMs, partial) } : {}
9098
+ ...hintForKind(errorKind, retryable, backoffMs, partial) ? { hint: hintForKind(errorKind, retryable, backoffMs, partial) } : {},
9099
+ // Summary is included so callers (TUI, CLI renderer) can surface
9100
+ // it as a chat history line — the LLM also sees it for continuity.
9101
+ summary
9038
9102
  };
9039
9103
  } catch (err) {
9040
9104
  return {
@@ -9047,10 +9111,11 @@ function createDelegateTool(opts) {
9047
9111
  };
9048
9112
  }
9049
9113
  function instantiateRosterConfig2(role, base) {
9114
+ const withBudget = applyRosterBudget({ ...base, role });
9050
9115
  return {
9051
- ...base,
9052
- // Roster entries are templates. Give each spawn a fresh id so
9053
- // parallel or repeated delegates can use the same role safely.
9116
+ ...withBudget,
9117
+ // Give each spawn a fresh id so parallel or repeated delegates
9118
+ // can use the same role safely.
9054
9119
  id: `${role}-${randomUUID().slice(0, 8)}`
9055
9120
  };
9056
9121
  }
@@ -9110,6 +9175,18 @@ ${partial.lastAssistantText}`;
9110
9175
  return retryable ? "Failure classified as retryable. Try again with the same input." : void 0;
9111
9176
  }
9112
9177
  }
9178
+ function buildDelegateSummary(role, result) {
9179
+ const roleLabel = role ?? "subagent";
9180
+ const ms = result.durationMs;
9181
+ const duration = ms < 6e4 ? `${Math.round(ms / 1e3)}s` : ms < 36e5 ? `${Math.round(ms / 6e4)}m` : `${(ms / 36e5).toFixed(1)}h`;
9182
+ if (result.status === "success") {
9183
+ const preview = typeof result.result === "string" ? result.result.trim().slice(0, 120).replace(/\n+/g, " ") : null;
9184
+ const tail = preview ? ` \u2014 ${preview}` : "";
9185
+ return `[${roleLabel}] done in ${duration} (${result.iterations} iter, ${result.toolCalls} tools)${tail}`;
9186
+ }
9187
+ const errLabel = result.error?.kind ?? result.status;
9188
+ return `[${roleLabel}] ${result.status} after ${duration} (${result.iterations} iter, ${result.toolCalls} tools) \u2014 ${errLabel}`;
9189
+ }
9113
9190
  async function readSubagentPartial(opts, subagentId) {
9114
9191
  if (!opts.sessionsRoot) return void 0;
9115
9192
  const candidates = [];
@@ -10247,6 +10324,10 @@ var TaskTracker = class {
10247
10324
  node.updatedAt = now;
10248
10325
  if (status === "completed") {
10249
10326
  node.completedAt = now;
10327
+ node.startedAt = node.startedAt ?? now;
10328
+ }
10329
+ if (status === "in_progress") {
10330
+ node.startedAt = now;
10250
10331
  }
10251
10332
  this.transitions.push({ from, to: status, timestamp: now, reason });
10252
10333
  if (status === "completed") {
@@ -10258,6 +10339,23 @@ var TaskTracker = class {
10258
10339
  this.graph.updatedAt = now;
10259
10340
  this.persist();
10260
10341
  }
10342
+ /**
10343
+ * Update node fields (title, description, priority, estimateHours, tags).
10344
+ * Does NOT change status. Use updateNodeStatus for status changes.
10345
+ */
10346
+ updateNode(id, patch) {
10347
+ if (!this.graph) throw new Error("No graph loaded");
10348
+ const node = this.graph.nodes.get(id);
10349
+ if (!node) throw new Error(`Node ${id} not found`);
10350
+ if (patch.title !== void 0) node.title = patch.title;
10351
+ if (patch.description !== void 0) node.description = patch.description;
10352
+ if (patch.priority !== void 0) node.priority = patch.priority;
10353
+ if (patch.estimateHours !== void 0) node.estimateHours = patch.estimateHours;
10354
+ if (patch.tags !== void 0) node.tags = patch.tags;
10355
+ node.updatedAt = Date.now();
10356
+ this.graph.updatedAt = node.updatedAt;
10357
+ this.persist();
10358
+ }
10261
10359
  getNode(id) {
10262
10360
  return this.graph?.nodes.get(id);
10263
10361
  }