@wrongstack/core 0.63.4 → 0.66.13

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 (57) hide show
  1. package/dist/{agent-bridge-B5rxWrg3.d.ts → agent-bridge-D-j6OOBT.d.ts} +1 -1
  2. package/dist/agent-subagent-runner-DRZ9-NnR.d.ts +1042 -0
  3. package/dist/{compactor-0vjZ8KTk.d.ts → compactor-D_ExJajC.d.ts} +1 -1
  4. package/dist/{config-BdDuaZmB.d.ts → config--86aHSln.d.ts} +1 -1
  5. package/dist/{context-iFMEO2rN.d.ts → context-y87Jc5ei.d.ts} +3 -3
  6. package/dist/coordination/index.d.ts +12 -12
  7. package/dist/coordination/index.js +87 -69
  8. package/dist/coordination/index.js.map +1 -1
  9. package/dist/defaults/index.d.ts +22 -22
  10. package/dist/defaults/index.js +113 -84
  11. package/dist/defaults/index.js.map +1 -1
  12. package/dist/{events-k8CHjcrN.d.ts → events-CIplI98R.d.ts} +1 -1
  13. package/dist/execution/index.d.ts +16 -385
  14. package/dist/execution/index.js +59 -51
  15. package/dist/execution/index.js.map +1 -1
  16. package/dist/extension/index.d.ts +6 -6
  17. package/dist/goal-store-C7jcumEh.d.ts +96 -0
  18. package/dist/{index-Bc6BiP5q.d.ts → index-DKUvyTvV.d.ts} +28 -442
  19. package/dist/{index-CWdW_CJt.d.ts → index-b5uhfTSl.d.ts} +8 -8
  20. package/dist/index.d.ts +34 -32
  21. package/dist/index.js +647 -677
  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/{mcp-servers-CwqQDMYy.d.ts → mcp-servers-DwoNBf6r.d.ts} +3 -3
  26. package/dist/models/index.d.ts +2 -2
  27. package/dist/{multi-agent-coordinator-CNUJYq7U.d.ts → multi-agent-coordinator-CWnH-CiX.d.ts} +10 -2
  28. package/dist/{null-fleet-bus-DRoJ0uOY.d.ts → null-fleet-bus-VApKRxcp.d.ts} +6 -7
  29. package/dist/observability/index.d.ts +2 -2
  30. package/dist/parallel-eternal-engine-0UwotoSx.d.ts +483 -0
  31. package/dist/{path-resolver-C5sPVne8.d.ts → path-resolver-DVkEcIw8.d.ts} +2 -2
  32. package/dist/{permission-Ld-i5ugf.d.ts → permission-C1A5whY5.d.ts} +5 -1
  33. package/dist/{permission-policy-CL-mPufp.d.ts → permission-policy-B2dK-T5N.d.ts} +19 -5
  34. package/dist/{plan-templates-ThBHOjaM.d.ts → plan-templates-Bprrzhbu.d.ts} +4 -4
  35. package/dist/{provider-runner-DJQa211J.d.ts → provider-runner-mXvXGSIw.d.ts} +3 -3
  36. package/dist/{retry-policy-BfBScewS.d.ts → retry-policy-CG3qvH_e.d.ts} +1 -1
  37. package/dist/sdd/index.d.ts +8 -8
  38. package/dist/sdd/index.js +58 -51
  39. package/dist/sdd/index.js.map +1 -1
  40. package/dist/security/index.d.ts +3 -3
  41. package/dist/security/index.js +31 -22
  42. package/dist/security/index.js.map +1 -1
  43. package/dist/{selector-DxhW7ML3.d.ts → selector-RvBR_YRW.d.ts} +1 -1
  44. package/dist/session-event-bridge-CDHxcmQU.d.ts +93 -0
  45. package/dist/{session-reader-q2ThszgG.d.ts → session-reader-BIpwM60D.d.ts} +1 -1
  46. package/dist/storage/index.d.ts +7 -6
  47. package/dist/{system-prompt-7LHyBbIf.d.ts → system-prompt-b61lOd49.d.ts} +2 -2
  48. package/dist/types/index.d.ts +23 -14
  49. package/dist/types/index.js.map +1 -1
  50. package/dist/utils/index.d.ts +2 -2
  51. package/dist/utils/index.js.map +1 -1
  52. package/package.json +1 -1
  53. package/skills/multi-agent/SKILL.md +0 -2
  54. package/dist/agent-subagent-runner-Zc3f37Sg.d.ts +0 -182
  55. package/dist/goal-store-iHltMi5n.d.ts +0 -188
  56. package/dist/multi-agent-SASYOrWA.d.ts +0 -554
  57. package/dist/tool-executor-CIjpGaRA.d.ts +0 -111
@@ -1,4 +1,4 @@
1
- import { d as Context } from './context-iFMEO2rN.js';
1
+ import { d as Context } from './context-y87Jc5ei.js';
2
2
 
3
3
  interface CompactRepairReport {
4
4
  removedToolUses: string[];
@@ -1,5 +1,5 @@
1
1
  import { W as WireFamily } from './models-registry-BcYJDKLm.js';
2
- import { a as Capabilities, P as Permission } from './context-iFMEO2rN.js';
2
+ import { a as Capabilities, P as Permission } from './context-y87Jc5ei.js';
3
3
 
4
4
  /**
5
5
  * Lifecycle hook types — the pure, serializable contract shared by the config
@@ -265,9 +265,9 @@ declare function isFsError(err: unknown): err is FsError;
265
265
 
266
266
  type Permission = 'auto' | 'confirm' | 'deny';
267
267
  /**
268
- * Risk tier for tools in YOLO mode. YOLO auto-approves normal project work,
269
- * but calls classified as clearly destructive still prompt unless
270
- * `--yolo-destructive` is set (`--force-all-yolo` is a deprecated alias).
268
+ * Risk tier for tools in YOLO mode. YOLO auto-approves everything by default,
269
+ * including destructive calls. Use `--confirm-destructive` to re-enable
270
+ * confirmation prompts for destructive operations.
271
271
  *
272
272
  * - `safe` — read-only, no side effects (read, glob, grep, etc.)
273
273
  * - `standard` — non-destructive writes and mutations (write, edit, safe shell commands)
@@ -1,21 +1,21 @@
1
- export { B as BrainArbiter, a as BrainDecision, b as BrainDecisionOption, c as BrainDecisionQueue, d as BrainDecisionRequest, e as BrainDecisionSource, f as BrainFallback, g as BrainRisk, D as DefaultBrainArbiter, h as DefaultBrainArbiterOptions, H as HumanEscalatingBrainArbiter, O as ObservableBrainArbiter, l as formatHumanPrompt } from '../events-k8CHjcrN.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-DRoJ0uOY.js';
3
- import { b as AgentDefinition } from '../multi-agent-coordinator-CNUJYq7U.js';
4
- export { T as AGENT_TOOL_PRESETS, A as AgentBudgetTier, a as AgentCapability, c as AgentPhase, D as DEFAULT_DISPATCH_ROLE, d as DefaultMultiAgentCoordinator, e as DispatchCandidate, f 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-CNUJYq7U.js';
5
- export { c as BudgetExceededError, d as BudgetKind, e as BudgetLimits, f as BudgetNegotiationMode, g as BudgetThresholdDecision, h as BudgetThresholdHandler, i as BudgetThresholdSignal, j as BudgetUsage, m as SubagentBudget } from '../multi-agent-SASYOrWA.js';
6
- 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-Zc3f37Sg.js';
7
- export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-B5rxWrg3.js';
8
- import '../context-iFMEO2rN.js';
1
+ export { B as BrainArbiter, a as BrainDecision, b as BrainDecisionOption, c as BrainDecisionQueue, d as BrainDecisionRequest, e as BrainDecisionSource, f as BrainFallback, g as BrainRisk, D as DefaultBrainArbiter, h as DefaultBrainArbiterOptions, H as HumanEscalatingBrainArbiter, O as ObservableBrainArbiter, l as formatHumanPrompt } from '../events-CIplI98R.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-VApKRxcp.js';
3
+ import { b as AgentDefinition } from '../multi-agent-coordinator-CWnH-CiX.js';
4
+ export { T as AGENT_TOOL_PRESETS, A as AgentBudgetTier, a as AgentCapability, c as AgentPhase, D as DEFAULT_DISPATCH_ROLE, d as DefaultMultiAgentCoordinator, e as DispatchCandidate, f 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-CWnH-CiX.js';
5
+ export { c as AgentFactory, d as AgentFactoryResult, e as AgentRunnerOptions, g as BudgetExceededError, h as BudgetKind, i as BudgetLimits, j as BudgetNegotiationMode, k as BudgetThresholdDecision, l as BudgetThresholdHandler, m as BudgetThresholdSignal, n as BudgetUsage, F as FleetBus, p as FleetEvent, q as FleetHandler, r as FleetUsage, s as FleetUsageAggregator, K as SubagentBudget, V as SubagentUsageSnapshot, _ as makeAgentSubagentRunner } from '../agent-subagent-runner-DRZ9-NnR.js';
6
+ export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-D-j6OOBT.js';
7
+ import '../context-y87Jc5ei.js';
9
8
  import 'node:events';
10
9
  import '../director-state-BmYi3DGA.js';
11
- import '../config-BdDuaZmB.js';
10
+ import '../config--86aHSln.js';
12
11
  import '../models-registry-BcYJDKLm.js';
13
- import '../index-Bc6BiP5q.js';
12
+ import '../index-DKUvyTvV.js';
14
13
  import '../logger-DDd5C--Z.js';
15
- import '../system-prompt-7LHyBbIf.js';
14
+ import '../system-prompt-b61lOd49.js';
16
15
  import '../observability-BhnVLBLS.js';
17
16
  import '../secret-scrubber-3MHDDAtm.js';
18
- import '../permission-Ld-i5ugf.js';
17
+ import '../permission-C1A5whY5.js';
18
+ import '../retry-policy-CG3qvH_e.js';
19
19
 
20
20
  /** Phase 1 · Discovery — map the territory before any work begins. */
21
21
  declare const DISCOVERY_AGENTS: AgentDefinition[];
@@ -1174,6 +1174,10 @@ Emit each evaluation immediately. Do not wait until you have read all reports.`;
1174
1174
  return lines.join("\n");
1175
1175
  }
1176
1176
  cleanup() {
1177
+ if (this._timeoutTimer) {
1178
+ clearTimeout(this._timeoutTimer);
1179
+ this._timeoutTimer = void 0;
1180
+ }
1177
1181
  for (const dispose of this.disposers) dispose();
1178
1182
  this.disposers.length = 0;
1179
1183
  }
@@ -4679,15 +4683,22 @@ var SubagentBudget = class _SubagentBudget {
4679
4683
  void this.checkLimits();
4680
4684
  }
4681
4685
  /**
4682
- * Wall-clock budget check. Unlike other limits, timeout is always a hard stop
4683
- * wall-clock time cannot be "extended" by the coordinator, so it throws
4684
- * synchronously rather than entering the negotiation flow.
4686
+ * Wall-clock / idle budget check. Delegates to `checkLimits(elapsed)`, so
4687
+ * `timeout` and `idle_timeout` follow the SAME negotiation path as the other
4688
+ * kinds they are NOT a special-cased hard stop. This is deliberate: a
4689
+ * heartbeat-aware policy (see `attachAutoExtend` and `CollabSession`) grants
4690
+ * a timeout extension only while the agent is making progress and denies it
4691
+ * once the agent is genuinely stuck, which is safer than an unconditional
4692
+ * hard kill of a long-but-working agent. The runner translates the resulting
4693
+ * `BudgetThresholdSignal` decision (`extend` → patch limits in place,
4694
+ * `stop` → abort) just like every other kind.
4685
4695
  *
4686
- * Decision table:
4687
- * - no `onThreshold` handler → throw `BudgetExceededError`
4688
- * - `mode === 'sync'` → throw `BudgetExceededError`
4689
- * - `mode === 'auto'` + no listener → throw `BudgetExceededError`
4690
- * - `mode === 'auto'` + listener → throw `BudgetExceededError` (timeout is not extendable)
4696
+ * Decision table (same as `checkLimits`):
4697
+ * - no `onThreshold` handler → throw `BudgetExceededError` (hard stop)
4698
+ * - `mode === 'sync'` → throw `BudgetExceededError` (hard stop)
4699
+ * - `mode === 'auto'` + no listener → throw `BudgetExceededError` (no one to ask)
4700
+ * - `mode === 'auto'` + listener → throw `BudgetThresholdSignal` (negotiated;
4701
+ * a heartbeat-aware policy may extend the timeout)
4691
4702
  */
4692
4703
  checkTimeout() {
4693
4704
  if (this.startTime === null) return;
@@ -5086,7 +5097,10 @@ var NICKNAME_POOL = {
5086
5097
  "lavoisier": { name: "Lavoisier", domain: "chemistry" },
5087
5098
  "mendeleev": { name: "Mendeleev", domain: "chemistry" }
5088
5099
  };
5089
- var ALL_NICKNAMES = Object.values(NICKNAME_POOL);
5100
+ var ALL_NICKNAMES = Object.entries(NICKNAME_POOL);
5101
+ var NAME_TO_KEY = Object.fromEntries(
5102
+ ALL_NICKNAMES.map(([key, entry]) => [entry.name, key])
5103
+ );
5090
5104
  var DOMAIN_PREFERENCES = {
5091
5105
  "security": ["shannon", "turing", "lamarr", "stallman"],
5092
5106
  "bug-hunter": ["darwin", "curie", "feynman", "fermi"],
@@ -5119,17 +5133,23 @@ function assignNickname(role, used) {
5119
5133
  for (const key of preferences) {
5120
5134
  const entry = NICKNAME_POOL[key];
5121
5135
  if (entry && !used.has(key)) {
5122
- return `${entry.name} (${formatRole(role)})`;
5136
+ return { key, display: `${entry.name} (${formatRole(role)})` };
5123
5137
  }
5124
5138
  }
5125
- for (const entry of ALL_NICKNAMES) {
5126
- const key = Object.entries(NICKNAME_POOL).find(([, v]) => v.name === entry.name)?.[0];
5127
- if (key && !used.has(key)) {
5128
- return `${entry.name} (${formatRole(role)})`;
5139
+ for (const [key, entry] of ALL_NICKNAMES) {
5140
+ if (!used.has(key)) {
5141
+ return { key, display: `${entry.name} (${formatRole(role)})` };
5129
5142
  }
5130
5143
  }
5131
5144
  const counter = used.size + 1;
5132
- return `Scientist #${counter} (${formatRole(role)})`;
5145
+ return { key: `scientist-${counter}`, display: `Scientist #${counter} (${formatRole(role)})` };
5146
+ }
5147
+ function nicknameKeyFromDisplay(display) {
5148
+ const base = display.replace(/\s*\([^)]*\)\s*$/, "").trim();
5149
+ const key = NAME_TO_KEY[base];
5150
+ if (key) return key;
5151
+ const synthesized = base.match(/^Scientist #(\d+)$/);
5152
+ return synthesized ? `scientist-${synthesized[1]}` : void 0;
5133
5153
  }
5134
5154
  function formatRole(role) {
5135
5155
  return role.split(/[-_]/).map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
@@ -5216,11 +5236,10 @@ var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends E
5216
5236
  const name = subagent.name?.trim() ?? "";
5217
5237
  const isPlaceholder = name === "" || name.toLowerCase() === role.toLowerCase() || name === "subagent" || name === "adhoc" || name === "generic" || /^slot-/.test(name);
5218
5238
  if (!isPlaceholder) return subagent;
5219
- const nickname = assignNickname(role, this.usedNicknames);
5220
- const baseKey = nickname.split(" ")[0].toLowerCase().replace(/[^a-z0-9-]/g, "-");
5221
- this.usedNicknames.add(baseKey);
5222
- this.subagentNicknames.set(subagentId, baseKey);
5223
- return { ...subagent, name: nickname };
5239
+ const { key, display } = assignNickname(role, this.usedNicknames);
5240
+ this.usedNicknames.add(key);
5241
+ this.subagentNicknames.set(subagentId, key);
5242
+ return { ...subagent, name: display };
5224
5243
  }
5225
5244
  async spawn(subagent) {
5226
5245
  const id = subagent.id || randomUUID();
@@ -5472,23 +5491,32 @@ var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends E
5472
5491
  */
5473
5492
  drainPendingAsAborted(message) {
5474
5493
  const dropped = this.pendingTasks.splice(0, this.pendingTasks.length);
5475
- for (const t of dropped) {
5476
- const synthetic = {
5477
- subagentId: t.subagentId ?? "unassigned",
5478
- taskId: t.id,
5479
- status: "stopped",
5480
- error: {
5481
- kind: "aborted_by_parent",
5482
- message,
5483
- retryable: false
5484
- },
5485
- iterations: 0,
5486
- toolCalls: 0,
5487
- durationMs: 0
5488
- };
5489
- this.completedResults.push(synthetic);
5490
- this.emit("task.completed", { task: t, result: synthetic });
5491
- }
5494
+ for (const t of dropped) this.emitPendingAborted(t, message);
5495
+ }
5496
+ /**
5497
+ * Emit a synthetic `stopped`/`aborted_by_parent` completion for a single
5498
+ * PENDING task — one that was never counted in `inFlight`. This MUST bypass
5499
+ * `recordCompletion`: that path does `inFlight--`, which for a pending task
5500
+ * steals a decrement from a genuinely in-flight task and trips the underflow
5501
+ * guard — suppressing that real task's `task.completed` and hanging its
5502
+ * `awaitTasks()` caller. Pushes the result and fires the event directly.
5503
+ */
5504
+ emitPendingAborted(task, message) {
5505
+ const synthetic = {
5506
+ subagentId: task.subagentId ?? "unassigned",
5507
+ taskId: task.id,
5508
+ status: "stopped",
5509
+ error: {
5510
+ kind: "aborted_by_parent",
5511
+ message,
5512
+ retryable: false
5513
+ },
5514
+ iterations: 0,
5515
+ toolCalls: 0,
5516
+ durationMs: 0
5517
+ };
5518
+ this.completedResults.push(synthetic);
5519
+ this.emit("task.completed", { task, result: synthetic });
5492
5520
  }
5493
5521
  async runDispatched(subagentId, task) {
5494
5522
  const subagent = this.subagents.get(subagentId);
@@ -5749,20 +5777,10 @@ var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends E
5749
5777
  const orphaned = this.pendingTasks.filter((t) => t.subagentId === subagentId);
5750
5778
  this.pendingTasks = this.pendingTasks.filter((t) => t.subagentId !== subagentId);
5751
5779
  for (const t of orphaned) {
5752
- const synthetic = {
5753
- subagentId,
5754
- taskId: t.id,
5755
- status: "stopped",
5756
- error: {
5757
- kind: "aborted_by_parent",
5758
- message: `Subagent "${subagentId}" was removed while task "${t.id}" was pending`,
5759
- retryable: false
5760
- },
5761
- iterations: 0,
5762
- toolCalls: 0,
5763
- durationMs: 0
5764
- };
5765
- this.recordCompletion(synthetic);
5780
+ this.emitPendingAborted(
5781
+ t,
5782
+ `Subagent "${subagentId}" was removed while task "${t.id}" was pending`
5783
+ );
5766
5784
  }
5767
5785
  this.fleetBus?.emit({
5768
5786
  subagentId,
@@ -6188,18 +6206,20 @@ var Director = class _Director {
6188
6206
  if (e.subagentId.startsWith("bug-hunter-") || e.subagentId.startsWith("refactor-planner-") || e.subagentId.startsWith("critic-")) {
6189
6207
  return;
6190
6208
  }
6191
- if (payload.kind === "timeout") {
6209
+ if (payload.kind === "timeout" || payload.kind === "idle_timeout") {
6210
+ const heartbeatKey = `${e.subagentId}:${payload.kind}`;
6192
6211
  const progress = progressBySubagent.get(e.subagentId) ?? 0;
6193
- const lastProgress = lastTimeoutProgress.get(e.subagentId) ?? -1;
6212
+ const lastProgress = lastTimeoutProgress.get(heartbeatKey) ?? -1;
6194
6213
  if (progress <= lastProgress) {
6195
6214
  payload.deny();
6196
6215
  return;
6197
6216
  }
6198
- lastTimeoutProgress.set(e.subagentId, progress);
6217
+ lastTimeoutProgress.set(heartbeatKey, progress);
6218
+ const field = payload.kind === "timeout" ? "timeoutMs" : "idleTimeoutMs";
6199
6219
  setImmediate(() => {
6200
6220
  const newLimit = Math.min(Math.ceil(payload.limit * 2), 24 * 60 * 6e4);
6201
- this.recordExtension(e.subagentId, e.taskId, "timeout", newLimit);
6202
- payload.extend({ timeoutMs: newLimit });
6221
+ this.recordExtension(e.subagentId, e.taskId, payload.kind, newLimit);
6222
+ payload.extend({ [field]: newLimit });
6203
6223
  });
6204
6224
  return;
6205
6225
  }
@@ -6515,10 +6535,9 @@ var Director = class _Director {
6515
6535
  if (this.fleetManager) {
6516
6536
  this.fleetManager.assignNicknameAndRecord(config);
6517
6537
  } else {
6518
- config.name = assignNickname(role, this._usedNicknames);
6519
- this._usedNicknames.add(
6520
- config.name.split(" ")[0].toLowerCase().replace(/[^a-z0-9-]/g, "-")
6521
- );
6538
+ const { key, display } = assignNickname(role, this._usedNicknames);
6539
+ config.name = display;
6540
+ this._usedNicknames.add(key);
6522
6541
  }
6523
6542
  }
6524
6543
  result = await this.coordinator.spawn(config);
@@ -6840,8 +6859,8 @@ var Director = class _Director {
6840
6859
  } else {
6841
6860
  const entry = this.manifestEntries.get(subagentId);
6842
6861
  if (entry?.name) {
6843
- const nicknameKey = entry.name.split(" ")[0].toLowerCase().replace(/[^a-z0-9-]/g, "-");
6844
- this._usedNicknames.delete(nicknameKey);
6862
+ const nicknameKey = nicknameKeyFromDisplay(entry.name);
6863
+ if (nicknameKey) this._usedNicknames.delete(nicknameKey);
6845
6864
  }
6846
6865
  }
6847
6866
  this.manifestEntries.delete(subagentId);
@@ -8453,11 +8472,10 @@ var FleetManager = class {
8453
8472
  */
8454
8473
  assignNicknameAndRecord(config) {
8455
8474
  const role = config.role ?? "subagent";
8456
- const nickname = assignNickname(role, this._usedNicknames);
8457
- const baseKey = nickname.split(" ")[0].toLowerCase().replace(/[^a-z0-9-]/g, "-");
8458
- this._usedNicknames.add(baseKey);
8459
- config.name = nickname;
8460
- return nickname;
8475
+ const { key, display } = assignNickname(role, this._usedNicknames);
8476
+ this._usedNicknames.add(key);
8477
+ config.name = display;
8478
+ return display;
8461
8479
  }
8462
8480
  /**
8463
8481
  * Returns the set of already-assigned nickname keys — useful for debugging
@@ -8642,8 +8660,8 @@ var FleetManager = class {
8642
8660
  removeSubagent(subagentId) {
8643
8661
  const entry = this.manifestEntries.get(subagentId);
8644
8662
  if (entry?.name) {
8645
- const nicknameKey = entry.name.split(" ")[0].toLowerCase().replace(/[^a-z0-9-]/g, "-");
8646
- this._usedNicknames.delete(nicknameKey);
8663
+ const nicknameKey = nicknameKeyFromDisplay(entry.name);
8664
+ if (nicknameKey) this._usedNicknames.delete(nicknameKey);
8647
8665
  }
8648
8666
  for (const [taskId, task] of this.pendingTasks) {
8649
8667
  if (task.subagentId === subagentId) {