@wrongstack/core 0.6.6 → 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 (48) 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 +19 -19
  10. package/dist/defaults/index.js +94 -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 +20 -12
  14. package/dist/execution/index.js +59 -18
  15. package/dist/execution/index.js.map +1 -1
  16. package/dist/extension/index.d.ts +6 -6
  17. package/dist/{index-CXnWsGBp.d.ts → index-BlVITqm-.d.ts} +6 -9
  18. package/dist/{index-DcnXDPdY.d.ts → index-DiIGZh5I.d.ts} +20 -5
  19. package/dist/index.d.ts +26 -26
  20. package/dist/index.js +212 -127
  21. package/dist/index.js.map +1 -1
  22. package/dist/infrastructure/index.d.ts +6 -6
  23. package/dist/kernel/index.d.ts +9 -9
  24. package/dist/kernel/index.js.map +1 -1
  25. package/dist/{mcp-servers-CevFHHM1.d.ts → mcp-servers-CXFfDN_d.d.ts} +3 -3
  26. package/dist/models/index.d.ts +2 -2
  27. package/dist/{multi-agent-D5IbASk_.d.ts → multi-agent-Iy8YUe3v.d.ts} +4 -4
  28. package/dist/observability/index.d.ts +2 -2
  29. package/dist/{path-resolver-CBx_q1HA.d.ts → path-resolver-DwJO5XBn.d.ts} +2 -2
  30. package/dist/{plan-templates-BEOllUJV.d.ts → plan-templates-CG_pInJV.d.ts} +4 -4
  31. package/dist/{provider-runner-Byh5TcJs.d.ts → provider-runner-DoohzfyD.d.ts} +3 -3
  32. package/dist/{retry-policy-BZSIMxrJ.d.ts → retry-policy-DOnwHAyz.d.ts} +1 -1
  33. package/dist/sdd/index.d.ts +3 -3
  34. package/dist/{secret-scrubber-CT7wefiO.d.ts → secret-scrubber-C9UJxFCJ.d.ts} +1 -1
  35. package/dist/{secret-scrubber-I0QHY_ob.d.ts → secret-scrubber-DcTK9JHC.d.ts} +1 -1
  36. package/dist/security/index.d.ts +3 -3
  37. package/dist/{selector-DDb_mq9X.d.ts → selector-DVo3eT-P.d.ts} +1 -1
  38. package/dist/{session-reader-B9nVkziM.d.ts → session-reader-BXWxFAhS.d.ts} +1 -1
  39. package/dist/storage/index.d.ts +5 -5
  40. package/dist/storage/index.js +1 -1
  41. package/dist/storage/index.js.map +1 -1
  42. package/dist/{system-prompt-gL06H9P4.d.ts → system-prompt-BBGles-N.d.ts} +1 -1
  43. package/dist/{tool-executor-BF7QfYVE.d.ts → tool-executor-CwpjhwHC.d.ts} +4 -4
  44. package/dist/types/index.d.ts +15 -15
  45. package/dist/types/index.js +1 -3
  46. package/dist/types/index.js.map +1 -1
  47. package/dist/utils/index.d.ts +1 -1
  48. package/package.json +1 -1
@@ -1,37 +1,37 @@
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';
34
+ import '../selector-DVo3eT-P.js';
35
35
  import '../goal-store-HHgaq5ue.js';
36
36
  import '../skill-CxuWrsKK.js';
37
37
  import 'node:events';
@@ -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;
@@ -5593,7 +5594,12 @@ var EternalAutonomyEngine = class {
5593
5594
  emit({ phase: "sleep", ms: cycleGapMs });
5594
5595
  await sleep(cycleGapMs);
5595
5596
  if (GOAL_COMPLETE_MARKER.test(finalText)) {
5596
- 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);
5597
5603
  this.stopRequested = true;
5598
5604
  return true;
5599
5605
  }
@@ -5893,6 +5899,30 @@ ${recentJournal}` : "No prior iterations.",
5893
5899
  });
5894
5900
  await saveGoal(this.goalPath, withEntry);
5895
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
+ }
5896
5926
  async appendFailure(task, note) {
5897
5927
  await this.appendIterationEntry({ source: "manual", task, status: "failure", note });
5898
5928
  }
@@ -5960,10 +5990,10 @@ var SubagentBudget = class _SubagentBudget {
5960
5990
  * or hung listener (Director not built / event filter detached mid-run)
5961
5991
  * leaves the budget over-limit and never enforces anything, since
5962
5992
  * `checkLimit` returns synchronously via `void this.checkLimitAsync`.
5963
- * Hardcoded for now most fleets set their own per-task timeout that
5964
- * 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.
5965
5995
  */
5966
- static DECISION_TIMEOUT_MS = 3e4;
5996
+ static DECISION_TIMEOUT_MS = 6e4;
5967
5997
  /**
5968
5998
  * Injected by the runner when wiring the budget to its EventBus.
5969
5999
  * Used by `checkLimitAsync` to emit `budget.threshold_reached` events.
@@ -6494,13 +6524,19 @@ var FLEET_ROSTER = {
6494
6524
  "security-scanner": SECURITY_SCANNER_AGENT
6495
6525
  };
6496
6526
  var FLEET_ROSTER_BUDGETS = {
6497
- "audit-log": { timeoutMs: 8 * 60 * 1e3, maxIterations: 150, maxToolCalls: 500 },
6498
- "bug-hunter": { timeoutMs: 15 * 60 * 1e3, maxIterations: 200, maxToolCalls: 600 },
6499
- "refactor-planner": { timeoutMs: 12 * 60 * 1e3, maxIterations: 180, maxToolCalls: 550 },
6500
- "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
6501
6536
  };
6502
6537
  function applyRosterBudget(cfg) {
6503
- 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);
6504
6540
  if (!defaultBudget) return cfg;
6505
6541
  return {
6506
6542
  ...cfg,
@@ -6572,7 +6608,7 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
6572
6608
  // hasParentBridge() — the type now reflects this.
6573
6609
  parentBridge: null,
6574
6610
  doneCondition: this.config.doneCondition,
6575
- maxConcurrent: this.config.maxConcurrent ?? 4
6611
+ maxConcurrent: this.config.maxConcurrent ?? 16
6576
6612
  };
6577
6613
  this.subagents.set(id, {
6578
6614
  config: { ...subagent, id },
@@ -6699,7 +6735,7 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
6699
6735
  }
6700
6736
  }
6701
6737
  canDispatch() {
6702
- const max = this.config.maxConcurrent ?? 4;
6738
+ const max = this.config.maxConcurrent ?? 16;
6703
6739
  return this.inFlight < max && this.pendingTasks.length > 0;
6704
6740
  }
6705
6741
  takeNextDispatchableTask() {
@@ -6793,13 +6829,18 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
6793
6829
  task.subagentId = subagentId;
6794
6830
  subagent.context.tasks.push(task);
6795
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;
6796
6837
  const configWithRosterDefaults = applyRosterBudget(subagent.config);
6797
6838
  const budget = new SubagentBudget({
6798
- maxIterations: configWithRosterDefaults.maxIterations ?? this.config.defaultBudget?.maxIterations,
6799
- maxToolCalls: task.maxToolCalls ?? configWithRosterDefaults.maxToolCalls ?? this.config.defaultBudget?.maxToolCalls,
6800
- maxTokens: configWithRosterDefaults.maxTokens ?? this.config.defaultBudget?.maxTokens,
6801
- maxCostUsd: configWithRosterDefaults.maxCostUsd ?? this.config.defaultBudget?.maxCostUsd,
6802
- 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
6803
6844
  });
6804
6845
  subagent.activeBudget = budget;
6805
6846
  if (!this.runner) {
@@ -6870,7 +6911,7 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
6870
6911
  kind: "timeout",
6871
6912
  used: elapsed,
6872
6913
  limit,
6873
- timeoutMs: 3e4,
6914
+ timeoutMs: 6e4,
6874
6915
  extend: (extra) => resolveDecision({ extend: extra }),
6875
6916
  deny: () => resolveDecision("stop")
6876
6917
  });
@@ -7612,10 +7653,8 @@ var InMemoryAgentBridge = class {
7612
7653
  this.pendingRequests.delete(correlationId);
7613
7654
  reject(new Error(`Request ${correlationId} timed out after ${timeout}ms`));
7614
7655
  }, timeout);
7615
- if (this.stopped) {
7656
+ if (!this.inflightGuards.has(correlationId)) {
7616
7657
  clearTimeout(timer);
7617
- this.inflightGuards.delete(correlationId);
7618
- this.pendingRequests.delete(correlationId);
7619
7658
  reject(new Error("Bridge stopped"));
7620
7659
  return;
7621
7660
  }
@@ -8446,7 +8485,12 @@ var Director = class {
8446
8485
  }
8447
8486
  }
8448
8487
  }
8449
- 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
+ }
8450
8494
  if (this.fleetManager) {
8451
8495
  this.fleetManager.recordSpawn(result.subagentId, config, priceLookup);
8452
8496
  } else {
@@ -8894,7 +8938,7 @@ var Director = class {
8894
8938
  }
8895
8939
  };
8896
8940
  function createDelegateTool(opts) {
8897
- const defaultTimeoutMs = opts.defaultTimeoutMs ?? 4 * 60 * 60 * 1e3;
8941
+ const defaultTimeoutMs = opts.defaultTimeoutMs ?? 30 * 60 * 1e3;
8898
8942
  const rosterIds = opts.roster ? Object.keys(opts.roster) : [];
8899
8943
  const inputSchema = {
8900
8944
  type: "object",
@@ -8910,7 +8954,7 @@ function createDelegateTool(opts) {
8910
8954
  },
8911
8955
  name: {
8912
8956
  type: "string",
8913
- 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."
8914
8958
  },
8915
8959
  provider: {
8916
8960
  type: "string",
@@ -8941,8 +8985,8 @@ function createDelegateTool(opts) {
8941
8985
  };
8942
8986
  return {
8943
8987
  name: "delegate",
8944
- 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.",
8945
- 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.",
8946
8990
  permission: "auto",
8947
8991
  mutating: false,
8948
8992
  inputSchema,
@@ -8990,6 +9034,7 @@ function createDelegateTool(opts) {
8990
9034
  model: i.model,
8991
9035
  systemPromptOverride: i.systemPromptOverride
8992
9036
  };
9037
+ cfg = applyRosterBudget({ ...cfg, name: i.name });
8993
9038
  }
8994
9039
  if (typeof i.maxIterations === "number" && i.maxIterations > 0) {
8995
9040
  cfg.maxIterations = i.maxIterations;
@@ -8997,7 +9042,7 @@ function createDelegateTool(opts) {
8997
9042
  if (typeof i.maxToolCalls === "number" && i.maxToolCalls > 0) {
8998
9043
  cfg.maxToolCalls = i.maxToolCalls;
8999
9044
  }
9000
- const SUBAGENT_TIMEOUT_BUFFER_MS = opts.subagentTimeoutBufferMs ?? 3e4;
9045
+ const SUBAGENT_TIMEOUT_BUFFER_MS = opts.subagentTimeoutBufferMs ?? 6e4;
9001
9046
  const desiredSubTimeout = Math.max(3e4, timeoutMs - SUBAGENT_TIMEOUT_BUFFER_MS);
9002
9047
  if (!cfg.timeoutMs || cfg.timeoutMs > desiredSubTimeout) {
9003
9048
  cfg.timeoutMs = desiredSubTimeout;
@@ -9034,6 +9079,7 @@ function createDelegateTool(opts) {
9034
9079
  const errorKind = result.error?.kind;
9035
9080
  const retryable = result.error?.retryable;
9036
9081
  const backoffMs = result.error?.backoffMs;
9082
+ const summary = buildDelegateSummary(i.role, result);
9037
9083
  return {
9038
9084
  ok: result.status === "success",
9039
9085
  status: result.status,
@@ -9049,7 +9095,10 @@ function createDelegateTool(opts) {
9049
9095
  toolCalls: result.toolCalls,
9050
9096
  durationMs: result.durationMs,
9051
9097
  ...partial ? { partial } : {},
9052
- ...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
9053
9102
  };
9054
9103
  } catch (err) {
9055
9104
  return {
@@ -9062,10 +9111,11 @@ function createDelegateTool(opts) {
9062
9111
  };
9063
9112
  }
9064
9113
  function instantiateRosterConfig2(role, base) {
9114
+ const withBudget = applyRosterBudget({ ...base, role });
9065
9115
  return {
9066
- ...base,
9067
- // Roster entries are templates. Give each spawn a fresh id so
9068
- // 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.
9069
9119
  id: `${role}-${randomUUID().slice(0, 8)}`
9070
9120
  };
9071
9121
  }
@@ -9125,6 +9175,18 @@ ${partial.lastAssistantText}`;
9125
9175
  return retryable ? "Failure classified as retryable. Try again with the same input." : void 0;
9126
9176
  }
9127
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
+ }
9128
9190
  async function readSubagentPartial(opts, subagentId) {
9129
9191
  if (!opts.sessionsRoot) return void 0;
9130
9192
  const candidates = [];