@wrongstack/core 0.6.6 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/{agent-bridge-BBXK_ppx.d.ts → agent-bridge-CrQpYjM7.d.ts} +1 -1
  2. package/dist/{compactor-C8NhpSt5.d.ts → compactor-CWV1u-IU.d.ts} +1 -1
  3. package/dist/{config-DfC6g6KV.d.ts → config-C34JRwl4.d.ts} +1 -1
  4. package/dist/{context-DN5v-uQX.d.ts → context-bmR0YgBm.d.ts} +74 -8
  5. package/dist/coordination/index.d.ts +11 -11
  6. package/dist/coordination/index.js +115 -39
  7. package/dist/coordination/index.js.map +1 -1
  8. package/dist/default-config-DvRSTELf.d.ts +20 -0
  9. package/dist/defaults/index.d.ts +20 -19
  10. package/dist/defaults/index.js +224 -64
  11. package/dist/defaults/index.js.map +1 -1
  12. package/dist/{events-CJqwQl8G.d.ts → events-CEKFTmIY.d.ts} +10 -1
  13. package/dist/execution/index.d.ts +27 -13
  14. package/dist/execution/index.js +153 -40
  15. package/dist/execution/index.js.map +1 -1
  16. package/dist/extension/index.d.ts +6 -6
  17. package/dist/extension/index.js +3 -1
  18. package/dist/extension/index.js.map +1 -1
  19. package/dist/{index-DcnXDPdY.d.ts → index-BJIFLGII.d.ts} +20 -5
  20. package/dist/{index-CXnWsGBp.d.ts → index-CZR0HjxM.d.ts} +14 -110
  21. package/dist/index.d.ts +27 -26
  22. package/dist/index.js +396 -180
  23. package/dist/index.js.map +1 -1
  24. package/dist/infrastructure/index.d.ts +6 -6
  25. package/dist/kernel/index.d.ts +9 -9
  26. package/dist/kernel/index.js +8 -4
  27. package/dist/kernel/index.js.map +1 -1
  28. package/dist/{mcp-servers-CevFHHM1.d.ts → mcp-servers-BRJicm5o.d.ts} +3 -3
  29. package/dist/models/index.d.ts +2 -2
  30. package/dist/{multi-agent-D5IbASk_.d.ts → multi-agent-Cm1wYSrw.d.ts} +9 -4
  31. package/dist/{agent-subagent-runner-DsSm9lKN.d.ts → multi-agent-coordinator-CCupVFqv.d.ts} +117 -4
  32. package/dist/observability/index.d.ts +2 -2
  33. package/dist/{path-resolver-CBx_q1HA.d.ts → path-resolver-CfT7e_HT.d.ts} +2 -2
  34. package/dist/{plan-templates-BEOllUJV.d.ts → plan-templates-Q78an-GJ.d.ts} +4 -4
  35. package/dist/{provider-runner-Byh5TcJs.d.ts → provider-runner-WDj28o7J.d.ts} +3 -3
  36. package/dist/{retry-policy-BZSIMxrJ.d.ts → retry-policy-Dpxp4SET.d.ts} +1 -1
  37. package/dist/sdd/index.d.ts +3 -3
  38. package/dist/{secret-scrubber-CT7wefiO.d.ts → secret-scrubber-C2YCYtkn.d.ts} +1 -1
  39. package/dist/{secret-scrubber-I0QHY_ob.d.ts → secret-scrubber-CowtdEF8.d.ts} +1 -1
  40. package/dist/security/index.d.ts +3 -3
  41. package/dist/{selector-DDb_mq9X.d.ts → selector-CP39HhCe.d.ts} +1 -1
  42. package/dist/{session-reader-B9nVkziM.d.ts → session-reader-Dwjn4WZR.d.ts} +1 -1
  43. package/dist/storage/index.d.ts +5 -5
  44. package/dist/storage/index.js +94 -11
  45. package/dist/storage/index.js.map +1 -1
  46. package/dist/{system-prompt-gL06H9P4.d.ts → system-prompt-CfgXqyv2.d.ts} +1 -1
  47. package/dist/{tool-executor-BF7QfYVE.d.ts → tool-executor-D5NFi_LV.d.ts} +5 -5
  48. package/dist/types/index.d.ts +16 -15
  49. package/dist/types/index.js +102 -23
  50. package/dist/types/index.js.map +1 -1
  51. package/dist/utils/index.d.ts +1 -1
  52. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -106,6 +106,53 @@ var init_atomic_write = __esm({
106
106
  });
107
107
 
108
108
  // src/types/errors.ts
109
+ var ERROR_CODES = {
110
+ // Provider
111
+ PROVIDER_RATE_LIMITED: "PROVIDER_RATE_LIMITED",
112
+ PROVIDER_AUTH_FAILED: "PROVIDER_AUTH_FAILED",
113
+ PROVIDER_OVERLOADED: "PROVIDER_OVERLOADED",
114
+ PROVIDER_INVALID_REQUEST: "PROVIDER_INVALID_REQUEST",
115
+ PROVIDER_SERVER_ERROR: "PROVIDER_SERVER_ERROR",
116
+ PROVIDER_NETWORK_ERROR: "PROVIDER_NETWORK_ERROR",
117
+ PROVIDER_CONTEXT_OVERFLOW: "PROVIDER_CONTEXT_OVERFLOW",
118
+ // Tool
119
+ TOOL_NOT_FOUND: "TOOL_NOT_FOUND",
120
+ TOOL_PERMISSION_DENIED: "TOOL_PERMISSION_DENIED",
121
+ TOOL_EXECUTION_FAILED: "TOOL_EXECUTION_FAILED",
122
+ TOOL_TIMEOUT: "TOOL_TIMEOUT",
123
+ TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID",
124
+ // Config
125
+ CONFIG_INVALID: "CONFIG_INVALID",
126
+ CONFIG_NOT_FOUND: "CONFIG_NOT_FOUND",
127
+ CONFIG_PARSE_FAILED: "CONFIG_PARSE_FAILED",
128
+ CONFIG_MIGRATION_NEEDED: "CONFIG_MIGRATION_NEEDED",
129
+ // Plugin
130
+ PLUGIN_LOAD_FAILED: "PLUGIN_LOAD_FAILED",
131
+ PLUGIN_API_MISMATCH: "PLUGIN_API_MISMATCH",
132
+ PLUGIN_MISSING_DEPENDENCY: "PLUGIN_MISSING_DEPENDENCY",
133
+ // Agent
134
+ AGENT_ITERATION_LIMIT: "AGENT_ITERATION_LIMIT",
135
+ AGENT_CONTEXT_OVERFLOW: "AGENT_CONTEXT_OVERFLOW",
136
+ AGENT_ABORTED: "AGENT_ABORTED",
137
+ AGENT_RUN_FAILED: "AGENT_RUN_FAILED",
138
+ // Session
139
+ SESSION_NOT_FOUND: "SESSION_NOT_FOUND",
140
+ SESSION_CORRUPTED: "SESSION_CORRUPTED",
141
+ SESSION_WRITE_FAILED: "SESSION_WRITE_FAILED",
142
+ // Container / Registry
143
+ CONTAINER_TOKEN_ALREADY_BOUND: "CONTAINER_TOKEN_ALREADY_BOUND",
144
+ CONTAINER_TOKEN_NOT_BOUND: "CONTAINER_TOKEN_NOT_BOUND",
145
+ REGISTRY_DUPLICATE: "REGISTRY_DUPLICATE",
146
+ REGISTRY_NOT_FOUND: "REGISTRY_NOT_FOUND",
147
+ // File system
148
+ FS_READ_FAILED: "FS_READ_FAILED",
149
+ FS_WRITE_FAILED: "FS_WRITE_FAILED",
150
+ FS_MKDIR_FAILED: "FS_MKDIR_FAILED",
151
+ FS_DELETE_FAILED: "FS_DELETE_FAILED",
152
+ FS_ATOMIC_WRITE_FAILED: "FS_ATOMIC_WRITE_FAILED",
153
+ // General
154
+ UNKNOWN: "UNKNOWN"
155
+ };
109
156
  var WrongStackError = class extends Error {
110
157
  code;
111
158
  subsystem;
@@ -171,7 +218,7 @@ var PluginError = class extends WrongStackError {
171
218
  code: opts.code,
172
219
  subsystem: "plugin",
173
220
  severity: "error",
174
- recoverable: opts.code === "PLUGIN_MISSING_DEPENDENCY",
221
+ recoverable: opts.code === ERROR_CODES.PLUGIN_MISSING_DEPENDENCY,
175
222
  context: { plugin: opts.pluginName, ...opts.context },
176
223
  cause: opts.cause
177
224
  });
@@ -185,20 +232,20 @@ var AgentError = class extends WrongStackError {
185
232
  message: opts.message,
186
233
  code: opts.code,
187
234
  subsystem: "agent",
188
- severity: opts.code === "AGENT_ABORTED" ? "warning" : "error",
189
- recoverable: opts.recoverable ?? opts.code === "AGENT_ITERATION_LIMIT",
235
+ severity: opts.code === ERROR_CODES.AGENT_ABORTED ? "warning" : "error",
236
+ recoverable: opts.recoverable ?? opts.code === ERROR_CODES.AGENT_ITERATION_LIMIT,
190
237
  context: opts.context,
191
238
  cause: opts.cause
192
239
  });
193
240
  this.name = "AgentError";
194
241
  }
195
242
  };
196
- function toWrongStackError(err, code = "AGENT_RUN_FAILED") {
243
+ function toWrongStackError(err, code = ERROR_CODES.AGENT_RUN_FAILED) {
197
244
  if (err instanceof WrongStackError) return err;
198
245
  const message = err instanceof Error ? err.message : String(err);
199
246
  return new AgentError({
200
247
  message,
201
- code: code === "UNKNOWN" ? "AGENT_RUN_FAILED" : code,
248
+ code: code === "UNKNOWN" ? ERROR_CODES.AGENT_RUN_FAILED : code,
202
249
  cause: err
203
250
  });
204
251
  }
@@ -209,8 +256,8 @@ var SessionError = class extends WrongStackError {
209
256
  message: opts.message,
210
257
  code: opts.code,
211
258
  subsystem: "session",
212
- severity: opts.code === "SESSION_WRITE_FAILED" ? "error" : "warning",
213
- recoverable: opts.code !== "SESSION_CORRUPTED",
259
+ severity: opts.code === ERROR_CODES.SESSION_WRITE_FAILED ? "error" : "warning",
260
+ recoverable: opts.code !== ERROR_CODES.SESSION_CORRUPTED,
214
261
  context: { sessionId: opts.sessionId, ...opts.context },
215
262
  cause: opts.cause
216
263
  });
@@ -218,6 +265,22 @@ var SessionError = class extends WrongStackError {
218
265
  this.sessionId = opts.sessionId;
219
266
  }
220
267
  };
268
+ var FsError = class extends WrongStackError {
269
+ path;
270
+ constructor(opts) {
271
+ super({
272
+ message: opts.message,
273
+ code: opts.code,
274
+ subsystem: "fs",
275
+ severity: "error",
276
+ recoverable: opts.code !== ERROR_CODES.FS_READ_FAILED,
277
+ context: { path: opts.path, ...opts.context },
278
+ cause: opts.cause
279
+ });
280
+ this.name = "FsError";
281
+ this.path = opts.path;
282
+ }
283
+ };
221
284
  function isWrongStackError(err) {
222
285
  return err instanceof WrongStackError;
223
286
  }
@@ -236,6 +299,9 @@ function isSessionError(err) {
236
299
  function isAgentError(err) {
237
300
  return err instanceof AgentError;
238
301
  }
302
+ function isFsError(err) {
303
+ return err instanceof FsError;
304
+ }
239
305
 
240
306
  // src/kernel/container.ts
241
307
  var Container = class {
@@ -244,7 +310,7 @@ var Container = class {
244
310
  if (this.entries.has(token)) {
245
311
  throw new WrongStackError({
246
312
  message: `Container: token "${token.description ?? "unknown"}" already bound`,
247
- code: "CONTAINER_TOKEN_ALREADY_BOUND",
313
+ code: ERROR_CODES.CONTAINER_TOKEN_ALREADY_BOUND,
248
314
  subsystem: "container",
249
315
  context: { token: token.description }
250
316
  });
@@ -261,7 +327,7 @@ var Container = class {
261
327
  if (!existing) {
262
328
  throw new WrongStackError({
263
329
  message: `Container: cannot override "${token.description ?? "unknown"}" \u2014 not bound`,
264
- code: "CONTAINER_TOKEN_NOT_BOUND",
330
+ code: ERROR_CODES.CONTAINER_TOKEN_NOT_BOUND,
265
331
  subsystem: "container",
266
332
  context: { token: token.description }
267
333
  });
@@ -278,7 +344,7 @@ var Container = class {
278
344
  if (!existing) {
279
345
  throw new WrongStackError({
280
346
  message: `Container: cannot decorate "${token.description ?? "unknown"}" \u2014 not bound`,
281
- code: "CONTAINER_TOKEN_NOT_BOUND",
347
+ code: ERROR_CODES.CONTAINER_TOKEN_NOT_BOUND,
282
348
  subsystem: "container",
283
349
  context: { token: token.description }
284
350
  });
@@ -292,7 +358,7 @@ var Container = class {
292
358
  if (!entry) {
293
359
  throw new WrongStackError({
294
360
  message: `Container: token "${token.description ?? "unknown"}" not bound`,
295
- code: "CONTAINER_TOKEN_NOT_BOUND",
361
+ code: ERROR_CODES.CONTAINER_TOKEN_NOT_BOUND,
296
362
  subsystem: "container",
297
363
  context: { token: token.description }
298
364
  });
@@ -895,16 +961,30 @@ function truncate(s, n) {
895
961
  return s.length <= n ? s : `${s.slice(0, n - 1)}\u2026`;
896
962
  }
897
963
  function providerStatusToCode(status, type) {
898
- if (status === 0) return "PROVIDER_NETWORK_ERROR";
899
- if (type === "rate_limit_error" || status === 429) return "PROVIDER_RATE_LIMITED";
900
- if (type === "authentication_error" || status === 401) return "PROVIDER_AUTH_FAILED";
901
- if (type === "overloaded_error" || status === 529) return "PROVIDER_OVERLOADED";
902
- if (type === "invalid_request_error" || status === 400) return "PROVIDER_INVALID_REQUEST";
903
- if (status === 408) return "PROVIDER_NETWORK_ERROR";
904
- if (status >= 500) return "PROVIDER_SERVER_ERROR";
905
- return "PROVIDER_INVALID_REQUEST";
964
+ if (status === 0) return ERROR_CODES.PROVIDER_NETWORK_ERROR;
965
+ if (type === "rate_limit_error" || status === 429) return ERROR_CODES.PROVIDER_RATE_LIMITED;
966
+ if (type === "authentication_error" || status === 401) return ERROR_CODES.PROVIDER_AUTH_FAILED;
967
+ if (type === "overloaded_error" || status === 529) return ERROR_CODES.PROVIDER_OVERLOADED;
968
+ if (type === "invalid_request_error" || status === 400) return ERROR_CODES.PROVIDER_INVALID_REQUEST;
969
+ if (status === 408) return ERROR_CODES.PROVIDER_NETWORK_ERROR;
970
+ if (status >= 500) return ERROR_CODES.PROVIDER_SERVER_ERROR;
971
+ return ERROR_CODES.PROVIDER_INVALID_REQUEST;
906
972
  }
907
973
 
974
+ // src/types/default-config.ts
975
+ var DEFAULT_TOOLS_CONFIG = Object.freeze({
976
+ defaultExecutionStrategy: "smart",
977
+ maxIterations: 100,
978
+ iterationTimeoutMs: 3e5,
979
+ sessionTimeoutMs: 18e5,
980
+ perIterationOutputCapBytes: 1e5,
981
+ autoExtendLimit: true
982
+ });
983
+ var DEFAULT_CONTEXT_CONFIG = Object.freeze({
984
+ preserveK: 10,
985
+ eliseThreshold: 2e3
986
+ });
987
+
908
988
  // src/types/secret-vault.ts
909
989
  var ENCRYPTED_PREFIX = "enc:v1:";
910
990
 
@@ -1736,9 +1816,11 @@ var DefaultPathResolver = class {
1736
1816
  }
1737
1817
  };
1738
1818
 
1819
+ // src/execution/regex-patterns.ts
1820
+ var NETWORK_ERR_RE = /ECONN|ETIMEDOUT|ETIME|ENOTFOUND|EAI_AGAIN|fetch failed/i;
1821
+
1739
1822
  // src/execution/error-handler.ts
1740
1823
  var CONTEXT_OVERFLOW_RE = /context|too long|tokens/i;
1741
- var NETWORK_ERR_RE = /ECONN|ETIMEDOUT|ETIME|ENOTFOUND|EAI_AGAIN|fetch failed/i;
1742
1824
  function buildRecoveryStrategies(opts) {
1743
1825
  return [
1744
1826
  {
@@ -1845,15 +1927,14 @@ var DefaultErrorHandler = class {
1845
1927
  };
1846
1928
 
1847
1929
  // src/execution/retry-policy.ts
1848
- var DefaultRetryPolicy = class _DefaultRetryPolicy {
1849
- static NETWORK_ERR_RE = /ECONN|ETIMEDOUT|ETIME|ENOTFOUND|EAI_AGAIN|fetch failed/i;
1930
+ var DefaultRetryPolicy = class {
1850
1931
  shouldRetry(err, attempt) {
1851
1932
  if (err instanceof ProviderError) {
1852
1933
  if (!err.retryable) return false;
1853
1934
  return attempt < this.maxAttempts(err);
1854
1935
  }
1855
1936
  const msg = err.message ?? "";
1856
- const isNetwork = _DefaultRetryPolicy.NETWORK_ERR_RE.test(msg);
1937
+ const isNetwork = NETWORK_ERR_RE.test(msg);
1857
1938
  if (isNetwork) return attempt < 2;
1858
1939
  return false;
1859
1940
  }
@@ -2558,10 +2639,8 @@ var InMemoryAgentBridge = class {
2558
2639
  this.pendingRequests.delete(correlationId);
2559
2640
  reject(new Error(`Request ${correlationId} timed out after ${timeout}ms`));
2560
2641
  }, timeout);
2561
- if (this.stopped) {
2642
+ if (!this.inflightGuards.has(correlationId)) {
2562
2643
  clearTimeout(timer);
2563
- this.inflightGuards.delete(correlationId);
2564
- this.pendingRequests.delete(correlationId);
2565
2644
  reject(new Error("Bridge stopped"));
2566
2645
  return;
2567
2646
  }
@@ -3924,8 +4003,16 @@ var DefaultSessionStore = class {
3924
4003
  }
3925
4004
  }
3926
4005
  async resume(id) {
3927
- const data = await this.load(id);
3928
4006
  const file = path6.join(this.dir, `${id}.jsonl`);
4007
+ try {
4008
+ await fsp2.access(file, fsp2.constants.R_OK);
4009
+ } catch {
4010
+ throw new Error(
4011
+ `Session "${id}" not found \u2014 the session file does not exist or was deleted.`,
4012
+ { cause: new Error("ENOENT") }
4013
+ );
4014
+ }
4015
+ const data = await this.load(id);
3929
4016
  let handle;
3930
4017
  try {
3931
4018
  handle = await fsp2.open(file, "a", 384);
@@ -4822,16 +4909,16 @@ var BEHAVIOR_DEFAULTS = {
4822
4909
  softThreshold: 0.75,
4823
4910
  hardThreshold: 0.9,
4824
4911
  autoCompact: true,
4825
- preserveK: 10,
4826
- eliseThreshold: 2e3
4912
+ preserveK: DEFAULT_CONTEXT_CONFIG.preserveK,
4913
+ eliseThreshold: DEFAULT_CONTEXT_CONFIG.eliseThreshold
4827
4914
  },
4828
4915
  tools: {
4829
- defaultExecutionStrategy: "smart",
4830
- maxIterations: 100,
4831
- iterationTimeoutMs: 3e5,
4832
- sessionTimeoutMs: 18e5,
4833
- perIterationOutputCapBytes: 1e5,
4834
- autoExtendLimit: true
4916
+ defaultExecutionStrategy: DEFAULT_TOOLS_CONFIG.defaultExecutionStrategy,
4917
+ maxIterations: DEFAULT_TOOLS_CONFIG.maxIterations,
4918
+ iterationTimeoutMs: DEFAULT_TOOLS_CONFIG.iterationTimeoutMs,
4919
+ sessionTimeoutMs: DEFAULT_TOOLS_CONFIG.sessionTimeoutMs,
4920
+ perIterationOutputCapBytes: DEFAULT_TOOLS_CONFIG.perIterationOutputCapBytes,
4921
+ autoExtendLimit: DEFAULT_TOOLS_CONFIG.autoExtendLimit
4835
4922
  },
4836
4923
  log: { level: "info" },
4837
4924
  features: {
@@ -5745,7 +5832,7 @@ var DirectorStateCheckpoint = class {
5745
5832
  this.timer = null;
5746
5833
  }
5747
5834
  await this.persist();
5748
- if (this.rewriteRequested) {
5835
+ while (this.rewriteRequested) {
5749
5836
  this.rewriteRequested = false;
5750
5837
  await this.persist();
5751
5838
  }
@@ -7175,7 +7262,7 @@ var AutoCompactionMiddleware = class {
7175
7262
  if (fatal) {
7176
7263
  throw new AgentError({
7177
7264
  message: `Auto-compaction failed at ${pressure.level} threshold`,
7178
- code: "AGENT_CONTEXT_OVERFLOW",
7265
+ code: ERROR_CODES.AGENT_CONTEXT_OVERFLOW,
7179
7266
  recoverable: true,
7180
7267
  context: {
7181
7268
  level: pressure.level,
@@ -7378,7 +7465,16 @@ async function loadGoal(filePath) {
7378
7465
  }
7379
7466
  }
7380
7467
  async function saveGoal(filePath, goal) {
7381
- await atomicWrite(filePath, JSON.stringify(goal, null, 2), { mode: 384 });
7468
+ try {
7469
+ await atomicWrite(filePath, JSON.stringify(goal, null, 2), { mode: 384 });
7470
+ } catch (err) {
7471
+ throw new FsError({
7472
+ message: err instanceof Error ? err.message : String(err),
7473
+ code: ERROR_CODES.FS_ATOMIC_WRITE_FAILED,
7474
+ path: filePath,
7475
+ cause: err
7476
+ });
7477
+ }
7382
7478
  }
7383
7479
  function emptyGoal(goal) {
7384
7480
  const now = (/* @__PURE__ */ new Date()).toISOString();
@@ -7454,7 +7550,8 @@ function formatGoal(goal, journalLimit = 10) {
7454
7550
  // src/execution/eternal-autonomy.ts
7455
7551
  var execFileP = promisify(execFile);
7456
7552
  var BRAINSTORM_DONE = /* @__PURE__ */ Symbol("brainstorm-done");
7457
- var GOAL_COMPLETE_MARKER = /^\s*\[goal[_\s-]?complete\]\s*$/im;
7553
+ var GOAL_COMPLETE_MARKER = /^\s*\[goal[_\s-]*complete\]\s*$/im;
7554
+ var GOAL_CLEAR_MARKER = /^\s*\[\/?goal\s*clear\]\s*$/im;
7458
7555
  var EternalAutonomyEngine = class {
7459
7556
  constructor(opts) {
7460
7557
  this.opts = opts;
@@ -7592,7 +7689,7 @@ var EternalAutonomyEngine = class {
7592
7689
  // Cap the inner loop so a runaway agent.run can't burn through
7593
7690
  // the iteration timeout — the engine's own outer loop is the
7594
7691
  // long-running thing, each tick should be bounded.
7595
- maxIterations: this.opts.iterationMaxAgentSteps ?? 50
7692
+ maxIterations: this.opts.iterationMaxAgentSteps ?? 500
7596
7693
  }
7597
7694
  );
7598
7695
  if (result.status === "aborted") {
@@ -7680,7 +7777,12 @@ var EternalAutonomyEngine = class {
7680
7777
  emit({ phase: "sleep", ms: cycleGapMs });
7681
7778
  await sleep(cycleGapMs);
7682
7779
  if (GOAL_COMPLETE_MARKER.test(finalText)) {
7683
- await this.markGoalCompleted(action, finalText);
7780
+ await this.clearGoalManually(finalText);
7781
+ this.stopRequested = true;
7782
+ return true;
7783
+ }
7784
+ if (GOAL_CLEAR_MARKER.test(finalText)) {
7785
+ await this.clearGoalManually(finalText);
7684
7786
  this.stopRequested = true;
7685
7787
  return true;
7686
7788
  }
@@ -7980,6 +8082,30 @@ ${recentJournal}` : "No prior iterations.",
7980
8082
  });
7981
8083
  await saveGoal(this.goalPath, withEntry);
7982
8084
  }
8085
+ /**
8086
+ * Manually clear the goal — equivalent to `/goal clear` typed by the user.
8087
+ * Sets goalState to `abandoned`, removes the goal file, and fires
8088
+ * `onEternalStop` so the REPL returns to normal mode.
8089
+ */
8090
+ async clearGoalManually(note) {
8091
+ const current = await loadGoal(this.goalPath);
8092
+ if (current) {
8093
+ const abandoned = { ...current, goalState: "abandoned" };
8094
+ await saveGoal(this.goalPath, abandoned);
8095
+ }
8096
+ try {
8097
+ const { unlink: unlink10 } = await import('fs/promises');
8098
+ await unlink10(this.goalPath);
8099
+ } catch {
8100
+ }
8101
+ this.opts.onEternalStop?.();
8102
+ void this.appendIterationEntry({
8103
+ source: "manual",
8104
+ task: "goal cleared",
8105
+ status: "success",
8106
+ note: note.slice(0, 240)
8107
+ });
8108
+ }
7983
8109
  async appendFailure(task, note) {
7984
8110
  await this.appendIterationEntry({ source: "manual", task, status: "failure", note });
7985
8111
  }
@@ -8047,10 +8173,10 @@ var SubagentBudget = class _SubagentBudget {
8047
8173
  * or hung listener (Director not built / event filter detached mid-run)
8048
8174
  * leaves the budget over-limit and never enforces anything, since
8049
8175
  * `checkLimit` returns synchronously via `void this.checkLimitAsync`.
8050
- * Hardcoded for now most fleets set their own per-task timeout that
8051
- * dwarfs this anyway. 30 s matches the existing event-emit timeoutMs.
8176
+ * Raised from 30s to 60s to give subagents more headroom before
8177
+ * the threshold negotiation times out and triggers a hard stop.
8052
8178
  */
8053
- static DECISION_TIMEOUT_MS = 3e4;
8179
+ static DECISION_TIMEOUT_MS = 6e4;
8054
8180
  /**
8055
8181
  * Injected by the runner when wiring the budget to its EventBus.
8056
8182
  * Used by `checkLimitAsync` to emit `budget.threshold_reached` events.
@@ -8581,13 +8707,19 @@ var FLEET_ROSTER = {
8581
8707
  "security-scanner": SECURITY_SCANNER_AGENT
8582
8708
  };
8583
8709
  var FLEET_ROSTER_BUDGETS = {
8584
- "audit-log": { timeoutMs: 8 * 60 * 1e3, maxIterations: 150, maxToolCalls: 500 },
8585
- "bug-hunter": { timeoutMs: 15 * 60 * 1e3, maxIterations: 200, maxToolCalls: 600 },
8586
- "refactor-planner": { timeoutMs: 12 * 60 * 1e3, maxIterations: 180, maxToolCalls: 550 },
8587
- "security-scanner": { timeoutMs: 15 * 60 * 1e3, maxIterations: 200, maxToolCalls: 600 }
8710
+ "audit-log": { timeoutMs: 7.5 * 60 * 60 * 1e3, maxIterations: 5e3, maxToolCalls: 15e3 },
8711
+ "bug-hunter": { timeoutMs: 10 * 60 * 60 * 1e3, maxIterations: 8e3, maxToolCalls: 2e4 },
8712
+ "refactor-planner": { timeoutMs: 7.5 * 60 * 60 * 1e3, maxIterations: 6e3, maxToolCalls: 18e3 },
8713
+ "security-scanner": { timeoutMs: 10 * 60 * 60 * 1e3, maxIterations: 8e3, maxToolCalls: 2e4 }
8714
+ };
8715
+ var GENERIC_SUBAGENT_BUDGET = {
8716
+ timeoutMs: 3 * 60 * 60 * 1e3,
8717
+ maxIterations: 5e3,
8718
+ maxToolCalls: 15e3
8588
8719
  };
8589
8720
  function applyRosterBudget(cfg) {
8590
- const defaultBudget = FLEET_ROSTER_BUDGETS[cfg.role ?? ""];
8721
+ const roleBudget = cfg.role ? FLEET_ROSTER_BUDGETS[cfg.role] : void 0;
8722
+ const defaultBudget = roleBudget ?? (cfg.name ? GENERIC_SUBAGENT_BUDGET : void 0);
8591
8723
  if (!defaultBudget) return cfg;
8592
8724
  return {
8593
8725
  ...cfg,
@@ -8659,7 +8791,7 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
8659
8791
  // hasParentBridge() — the type now reflects this.
8660
8792
  parentBridge: null,
8661
8793
  doneCondition: this.config.doneCondition,
8662
- maxConcurrent: this.config.maxConcurrent ?? 4
8794
+ maxConcurrent: this.config.maxConcurrent ?? 16
8663
8795
  };
8664
8796
  this.subagents.set(id, {
8665
8797
  config: { ...subagent, id },
@@ -8705,6 +8837,30 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
8705
8837
  this.drainPendingAsAborted("Coordinator stopAll() drained the pending queue");
8706
8838
  await Promise.allSettled([...this.subagents.keys()].map((id) => this.stop(id)));
8707
8839
  }
8840
+ async remove(subagentId) {
8841
+ await this.stop(subagentId);
8842
+ this.subagents.delete(subagentId);
8843
+ }
8844
+ /**
8845
+ * Get current coordinator stats for monitoring/debugging.
8846
+ */
8847
+ getStats() {
8848
+ let running = 0, idle = 0, stopped = 0;
8849
+ for (const [, entry] of this.subagents) {
8850
+ if (entry.status === "running") running++;
8851
+ else if (entry.status === "idle") idle++;
8852
+ else stopped++;
8853
+ }
8854
+ return {
8855
+ total: this.subagents.size,
8856
+ running,
8857
+ idle,
8858
+ stopped,
8859
+ inFlight: this.inFlight,
8860
+ pending: this.pendingTasks.length,
8861
+ completed: this.completedResults.length
8862
+ };
8863
+ }
8708
8864
  getStatus() {
8709
8865
  return {
8710
8866
  coordinatorId: this.coordinatorId,
@@ -8786,7 +8942,7 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
8786
8942
  }
8787
8943
  }
8788
8944
  canDispatch() {
8789
- const max = this.config.maxConcurrent ?? 4;
8945
+ const max = this.config.maxConcurrent ?? 16;
8790
8946
  return this.inFlight < max && this.pendingTasks.length > 0;
8791
8947
  }
8792
8948
  takeNextDispatchableTask() {
@@ -8880,13 +9036,18 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
8880
9036
  task.subagentId = subagentId;
8881
9037
  subagent.context.tasks.push(task);
8882
9038
  this.emit("task.assigned", { task, subagentId });
9039
+ const rawMaxIterations = subagent.config.maxIterations;
9040
+ const rawMaxToolCalls = subagent.config.maxToolCalls;
9041
+ const rawMaxTokens = subagent.config.maxTokens;
9042
+ const rawMaxCostUsd = subagent.config.maxCostUsd;
9043
+ const rawTimeoutMs = subagent.config.timeoutMs;
8883
9044
  const configWithRosterDefaults = applyRosterBudget(subagent.config);
8884
9045
  const budget = new SubagentBudget({
8885
- maxIterations: configWithRosterDefaults.maxIterations ?? this.config.defaultBudget?.maxIterations,
8886
- maxToolCalls: task.maxToolCalls ?? configWithRosterDefaults.maxToolCalls ?? this.config.defaultBudget?.maxToolCalls,
8887
- maxTokens: configWithRosterDefaults.maxTokens ?? this.config.defaultBudget?.maxTokens,
8888
- maxCostUsd: configWithRosterDefaults.maxCostUsd ?? this.config.defaultBudget?.maxCostUsd,
8889
- timeoutMs: task.timeoutMs ?? configWithRosterDefaults.timeoutMs ?? this.config.defaultBudget?.timeoutMs
9046
+ maxIterations: rawMaxIterations ?? this.config.defaultBudget?.maxIterations ?? configWithRosterDefaults.maxIterations,
9047
+ maxToolCalls: rawMaxToolCalls ?? this.config.defaultBudget?.maxToolCalls ?? configWithRosterDefaults.maxToolCalls,
9048
+ maxTokens: rawMaxTokens ?? this.config.defaultBudget?.maxTokens ?? configWithRosterDefaults.maxTokens,
9049
+ maxCostUsd: rawMaxCostUsd ?? this.config.defaultBudget?.maxCostUsd ?? configWithRosterDefaults.maxCostUsd,
9050
+ timeoutMs: rawTimeoutMs ?? this.config.defaultBudget?.timeoutMs ?? configWithRosterDefaults.timeoutMs
8890
9051
  });
8891
9052
  subagent.activeBudget = budget;
8892
9053
  if (!this.runner) {
@@ -8957,7 +9118,7 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
8957
9118
  kind: "timeout",
8958
9119
  used: elapsed,
8959
9120
  limit,
8960
- timeoutMs: 3e4,
9121
+ timeoutMs: 6e4,
8961
9122
  extend: (extra) => resolveDecision({ extend: extra }),
8962
9123
  deny: () => resolveDecision("stop")
8963
9124
  });
@@ -9167,6 +9328,12 @@ var ParallelEternalEngine = class {
9167
9328
  get currentState() {
9168
9329
  return this.state;
9169
9330
  }
9331
+ /**
9332
+ * Get the underlying coordinator for stats/monitoring.
9333
+ */
9334
+ getCoordinator() {
9335
+ return this.coordinator;
9336
+ }
9170
9337
  stop() {
9171
9338
  this.stopRequested = true;
9172
9339
  void this.persistState("stopped").catch(() => {
@@ -9303,8 +9470,8 @@ Task: ${task}
9303
9470
  await coordinator.spawn({
9304
9471
  id: subagentId,
9305
9472
  name: `slot-${subagentId.slice(-6)}`,
9306
- maxIterations: 50,
9307
- maxToolCalls: 200,
9473
+ // Let the coordinator apply its default budget (from roster or generic).
9474
+ // Hardcoding low limits here defeats the x10 budget improvement.
9308
9475
  timeoutMs: this.timeoutMs
9309
9476
  });
9310
9477
  subagentIds.push(subagentId);
@@ -9321,7 +9488,7 @@ Task: ${task}
9321
9488
  let results = [];
9322
9489
  try {
9323
9490
  const ctrl = new AbortController();
9324
- const timer = setTimeout(() => ctrl.abort(), this.timeoutMs + 6e4);
9491
+ const timer = setTimeout(() => ctrl.abort(), Math.max(this.timeoutMs * 2, 72e5));
9325
9492
  try {
9326
9493
  results = await coordinator.awaitTasks(taskIds);
9327
9494
  } finally {
@@ -10387,7 +10554,12 @@ var Director = class {
10387
10554
  }
10388
10555
  }
10389
10556
  }
10390
- const result = await this.coordinator.spawn(config);
10557
+ let result;
10558
+ try {
10559
+ result = await this.coordinator.spawn(config);
10560
+ } catch (err) {
10561
+ throw err;
10562
+ }
10391
10563
  if (this.fleetManager) {
10392
10564
  this.fleetManager.recordSpawn(result.subagentId, config, priceLookup);
10393
10565
  } else {
@@ -10655,6 +10827,9 @@ var Director = class {
10655
10827
  async terminateAll() {
10656
10828
  await this.coordinator.stopAll();
10657
10829
  }
10830
+ async remove(subagentId) {
10831
+ await this.coordinator.remove(subagentId);
10832
+ }
10658
10833
  status() {
10659
10834
  return this.coordinator.getStatus();
10660
10835
  }
@@ -10835,7 +11010,7 @@ var Director = class {
10835
11010
  }
10836
11011
  };
10837
11012
  function createDelegateTool(opts) {
10838
- const defaultTimeoutMs = opts.defaultTimeoutMs ?? 4 * 60 * 60 * 1e3;
11013
+ const defaultTimeoutMs = opts.defaultTimeoutMs ?? 30 * 60 * 1e3;
10839
11014
  const rosterIds = opts.roster ? Object.keys(opts.roster) : [];
10840
11015
  const inputSchema = {
10841
11016
  type: "object",
@@ -10851,7 +11026,7 @@ function createDelegateTool(opts) {
10851
11026
  },
10852
11027
  name: {
10853
11028
  type: "string",
10854
- description: "Display name for the subagent when not using a roster role. Required when `role` is omitted."
11029
+ 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."
10855
11030
  },
10856
11031
  provider: {
10857
11032
  type: "string",
@@ -10882,8 +11057,8 @@ function createDelegateTool(opts) {
10882
11057
  };
10883
11058
  return {
10884
11059
  name: "delegate",
10885
- 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.",
10886
- 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.",
11060
+ 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.",
11061
+ 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.",
10887
11062
  permission: "auto",
10888
11063
  mutating: false,
10889
11064
  inputSchema,
@@ -10931,6 +11106,7 @@ function createDelegateTool(opts) {
10931
11106
  model: i.model,
10932
11107
  systemPromptOverride: i.systemPromptOverride
10933
11108
  };
11109
+ cfg = applyRosterBudget({ ...cfg, name: i.name });
10934
11110
  }
10935
11111
  if (typeof i.maxIterations === "number" && i.maxIterations > 0) {
10936
11112
  cfg.maxIterations = i.maxIterations;
@@ -10938,7 +11114,7 @@ function createDelegateTool(opts) {
10938
11114
  if (typeof i.maxToolCalls === "number" && i.maxToolCalls > 0) {
10939
11115
  cfg.maxToolCalls = i.maxToolCalls;
10940
11116
  }
10941
- const SUBAGENT_TIMEOUT_BUFFER_MS = opts.subagentTimeoutBufferMs ?? 3e4;
11117
+ const SUBAGENT_TIMEOUT_BUFFER_MS = opts.subagentTimeoutBufferMs ?? 6e4;
10942
11118
  const desiredSubTimeout = Math.max(3e4, timeoutMs - SUBAGENT_TIMEOUT_BUFFER_MS);
10943
11119
  if (!cfg.timeoutMs || cfg.timeoutMs > desiredSubTimeout) {
10944
11120
  cfg.timeoutMs = desiredSubTimeout;
@@ -10975,6 +11151,7 @@ function createDelegateTool(opts) {
10975
11151
  const errorKind = result.error?.kind;
10976
11152
  const retryable = result.error?.retryable;
10977
11153
  const backoffMs = result.error?.backoffMs;
11154
+ const summary = buildDelegateSummary(i.role, result);
10978
11155
  return {
10979
11156
  ok: result.status === "success",
10980
11157
  status: result.status,
@@ -10990,7 +11167,10 @@ function createDelegateTool(opts) {
10990
11167
  toolCalls: result.toolCalls,
10991
11168
  durationMs: result.durationMs,
10992
11169
  ...partial ? { partial } : {},
10993
- ...hintForKind(errorKind, retryable, backoffMs, partial) ? { hint: hintForKind(errorKind, retryable, backoffMs, partial) } : {}
11170
+ ...hintForKind(errorKind, retryable, backoffMs, partial) ? { hint: hintForKind(errorKind, retryable, backoffMs, partial) } : {},
11171
+ // Summary is included so callers (TUI, CLI renderer) can surface
11172
+ // it as a chat history line — the LLM also sees it for continuity.
11173
+ summary
10994
11174
  };
10995
11175
  } catch (err) {
10996
11176
  return {
@@ -11003,10 +11183,11 @@ function createDelegateTool(opts) {
11003
11183
  };
11004
11184
  }
11005
11185
  function instantiateRosterConfig2(role, base) {
11186
+ const withBudget = applyRosterBudget({ ...base, role });
11006
11187
  return {
11007
- ...base,
11008
- // Roster entries are templates. Give each spawn a fresh id so
11009
- // parallel or repeated delegates can use the same role safely.
11188
+ ...withBudget,
11189
+ // Give each spawn a fresh id so parallel or repeated delegates
11190
+ // can use the same role safely.
11010
11191
  id: `${role}-${randomUUID().slice(0, 8)}`
11011
11192
  };
11012
11193
  }
@@ -11066,6 +11247,18 @@ ${partial.lastAssistantText}`;
11066
11247
  return retryable ? "Failure classified as retryable. Try again with the same input." : void 0;
11067
11248
  }
11068
11249
  }
11250
+ function buildDelegateSummary(role, result) {
11251
+ const roleLabel = role ?? "subagent";
11252
+ const ms = result.durationMs;
11253
+ const duration = ms < 6e4 ? `${Math.round(ms / 1e3)}s` : ms < 36e5 ? `${Math.round(ms / 6e4)}m` : `${(ms / 36e5).toFixed(1)}h`;
11254
+ if (result.status === "success") {
11255
+ const preview = typeof result.result === "string" ? result.result.trim().slice(0, 120).replace(/\n+/g, " ") : null;
11256
+ const tail = preview ? ` \u2014 ${preview}` : "";
11257
+ return `[${roleLabel}] done in ${duration} (${result.iterations} iter, ${result.toolCalls} tools)${tail}`;
11258
+ }
11259
+ const errLabel = result.error?.kind ?? result.status;
11260
+ return `[${roleLabel}] ${result.status} after ${duration} (${result.iterations} iter, ${result.toolCalls} tools) \u2014 ${errLabel}`;
11261
+ }
11069
11262
  async function readSubagentPartial(opts, subagentId) {
11070
11263
  if (!opts.sessionsRoot) return void 0;
11071
11264
  const candidates = [];
@@ -11106,6 +11299,7 @@ async function readSubagentPartial(opts, subagentId) {
11106
11299
  }
11107
11300
  }
11108
11301
  } catch {
11302
+ continue;
11109
11303
  }
11110
11304
  }
11111
11305
  return {
@@ -16363,7 +16557,6 @@ var defaultGitignoreUpdater = new GitignoreUpdater();
16363
16557
 
16364
16558
  // src/security-scanner/orchestrator.ts
16365
16559
  init_atomic_write();
16366
- var NETWORK_ERR_RE2 = /ECONN|ETIMEDOUT|ETIME|ENOTFOUND|EAI_AGAIN|fetch failed/i;
16367
16560
  var SecurityScannerOrchestrator = class {
16368
16561
  constructor(retryPolicy, errorHandler) {
16369
16562
  this.retryPolicy = retryPolicy;
@@ -16386,7 +16579,7 @@ var SecurityScannerOrchestrator = class {
16386
16579
  const isProviderErr = err instanceof ProviderError;
16387
16580
  const policy = this.retryPolicy;
16388
16581
  const errAsErr = isProviderErr ? err : err instanceof Error ? err : new Error(String(err));
16389
- if (!policy || !isProviderErr && !NETWORK_ERR_RE2.test(errAsErr.message)) {
16582
+ if (!policy || !isProviderErr && !NETWORK_ERR_RE.test(errAsErr.message)) {
16390
16583
  throw err;
16391
16584
  }
16392
16585
  const canRetry = policy.shouldRetry(errAsErr, attempt);
@@ -17583,7 +17776,7 @@ var ExtensionRegistry = class {
17583
17776
  if (this.extensions.some((e) => e.name === ext.name)) {
17584
17777
  throw new WrongStackError({
17585
17778
  message: `Extension "${ext.name}" already registered`,
17586
- code: "REGISTRY_DUPLICATE",
17779
+ code: ERROR_CODES.REGISTRY_DUPLICATE,
17587
17780
  subsystem: "container",
17588
17781
  context: { extension: ext.name }
17589
17782
  });
@@ -17987,10 +18180,15 @@ var Agent = class {
17987
18180
  });
17988
18181
  let finalText = "";
17989
18182
  let iterations = 0;
18183
+ const delegateSummaries = [];
17990
18184
  let effectiveLimit = opts.maxIterations ?? this.maxIterations;
17991
18185
  const hasHardLimit = effectiveLimit > 0 && Number.isFinite(effectiveLimit);
17992
18186
  let recoveryRetries = 0;
17993
18187
  const autonomousContinue = opts.autonomousContinue ?? this.autonomousContinue;
18188
+ const onSubagentDone = ({ summary, ok }) => {
18189
+ delegateSummaries.push({ summary, ok });
18190
+ };
18191
+ const offSubagentDone = this.events.on("subagent.done", onSubagentDone);
17994
18192
  const diRunner = this.container.has(TOKENS.ProviderRunner) ? this.container.resolve(TOKENS.ProviderRunner) : null;
17995
18193
  const baseRunner = diRunner ? (ctx, req) => diRunner.run({
17996
18194
  provider: ctx.provider,
@@ -18012,116 +18210,122 @@ var Agent = class {
18012
18210
  tracer: this.tracer
18013
18211
  });
18014
18212
  const customRunner = this.extensions.wrapProviderRunner(baseRunner);
18015
- for (let i = 0; ; i++) {
18016
- iterations = i + 1;
18017
- if (controller.signal.aborted) {
18018
- return { status: "aborted", iterations };
18019
- }
18020
- if (autonomousContinue) {
18021
- consumeAutonomousContinue(this.ctx);
18022
- }
18023
- const limitCheck = await this.checkIterationLimit(
18024
- i,
18025
- effectiveLimit,
18026
- hasHardLimit,
18027
- iterations
18028
- );
18029
- effectiveLimit = limitCheck.limit;
18030
- if (limitCheck.exit) {
18031
- return { ...limitCheck.exit, finalText };
18032
- }
18033
- await this.extensions.runBeforeIteration(this.ctx, i);
18034
- this.events.emit("iteration.started", { ctx: this.ctx, index: i });
18035
- const req = await this.buildAndRunRequestPipeline(opts);
18036
- let res;
18037
- try {
18038
- res = await customRunner(this.ctx, req);
18039
- recoveryRetries = 0;
18040
- } catch (err) {
18213
+ try {
18214
+ for (let i = 0; ; i++) {
18215
+ iterations = i + 1;
18041
18216
  if (controller.signal.aborted) {
18042
- this.events.emit("error", { err: toError(err), phase: "provider" });
18043
- return { status: "aborted", iterations, error: toWrongStackError(err, "AGENT_ABORTED") };
18217
+ return { status: "aborted", iterations };
18218
+ }
18219
+ if (autonomousContinue) {
18220
+ consumeAutonomousContinue(this.ctx);
18221
+ }
18222
+ const limitCheck = await this.checkIterationLimit(
18223
+ i,
18224
+ effectiveLimit,
18225
+ hasHardLimit,
18226
+ iterations,
18227
+ delegateSummaries
18228
+ );
18229
+ effectiveLimit = limitCheck.limit;
18230
+ if (limitCheck.exit) {
18231
+ return { ...limitCheck.exit, finalText };
18044
18232
  }
18045
- const extDecision = await this.extensions.runOnError(this.ctx, err, "provider", i);
18046
- if (extDecision) {
18047
- if (extDecision.action === "fail") {
18233
+ await this.extensions.runBeforeIteration(this.ctx, i);
18234
+ this.events.emit("iteration.started", { ctx: this.ctx, index: i });
18235
+ const req = await this.buildAndRunRequestPipeline(opts);
18236
+ let res;
18237
+ try {
18238
+ res = await customRunner(this.ctx, req);
18239
+ recoveryRetries = 0;
18240
+ } catch (err) {
18241
+ if (controller.signal.aborted) {
18048
18242
  this.events.emit("error", { err: toError(err), phase: "provider" });
18049
- return { status: "failed", iterations, error: toWrongStackError(err) };
18243
+ return { status: "aborted", iterations, error: toWrongStackError(err, "AGENT_ABORTED") };
18050
18244
  }
18051
- if (extDecision.action === "continue") {
18052
- await this.extensions.runAfterIteration(this.ctx, i);
18053
- continue;
18245
+ const extDecision = await this.extensions.runOnError(this.ctx, err, "provider", i);
18246
+ if (extDecision) {
18247
+ if (extDecision.action === "fail") {
18248
+ this.events.emit("error", { err: toError(err), phase: "provider" });
18249
+ return { status: "failed", iterations, error: toWrongStackError(err), delegateSummaries };
18250
+ }
18251
+ if (extDecision.action === "continue") {
18252
+ await this.extensions.runAfterIteration(this.ctx, i);
18253
+ continue;
18254
+ }
18255
+ if (extDecision.action === "retry") {
18256
+ recoveryRetries++;
18257
+ if (recoveryRetries > 2) {
18258
+ this.events.emit("error", { err: toError(err), phase: "provider" });
18259
+ return { status: "failed", iterations, error: toWrongStackError(err), delegateSummaries };
18260
+ }
18261
+ if (extDecision.model) this.ctx.model = extDecision.model;
18262
+ this.logger.info("Extension requested retry; retrying turn");
18263
+ continue;
18264
+ }
18054
18265
  }
18055
- if (extDecision.action === "retry") {
18266
+ const recovered = await this.errorHandler.recover(err, this.ctx);
18267
+ if (!recovered || recovered.action === "fail") {
18268
+ this.events.emit("error", { err: toError(err), phase: "provider" });
18269
+ return {
18270
+ status: "failed",
18271
+ iterations,
18272
+ error: toWrongStackError(recovered?.error ?? err),
18273
+ delegateSummaries
18274
+ };
18275
+ }
18276
+ if (recovered.action === "retry") {
18056
18277
  recoveryRetries++;
18057
18278
  if (recoveryRetries > 2) {
18058
18279
  this.events.emit("error", { err: toError(err), phase: "provider" });
18059
18280
  return { status: "failed", iterations, error: toWrongStackError(err) };
18060
18281
  }
18061
- if (extDecision.model) this.ctx.model = extDecision.model;
18062
- this.logger.info("Extension requested retry; retrying turn");
18282
+ if (recovered.model) this.ctx.model = recovered.model;
18283
+ this.logger.info(`Recovered provider error via ${recovered.reason}; retrying turn`);
18063
18284
  continue;
18064
18285
  }
18286
+ recoveryRetries = 0;
18287
+ res = recovered.response;
18065
18288
  }
18066
- const recovered = await this.errorHandler.recover(err, this.ctx);
18067
- if (!recovered || recovered.action === "fail") {
18068
- this.events.emit("error", { err: toError(err), phase: "provider" });
18069
- return {
18070
- status: "failed",
18071
- iterations,
18072
- error: toWrongStackError(recovered?.error ?? err)
18073
- };
18289
+ const responseResult = await this.processResponse(res, req);
18290
+ if (responseResult.aborted) {
18291
+ return { status: "aborted", iterations, finalText: responseResult.finalText, delegateSummaries };
18074
18292
  }
18075
- if (recovered.action === "retry") {
18076
- recoveryRetries++;
18077
- if (recoveryRetries > 2) {
18078
- this.events.emit("error", { err: toError(err), phase: "provider" });
18079
- return { status: "failed", iterations, error: toWrongStackError(err) };
18293
+ if (responseResult.done) {
18294
+ return { status: "done", iterations, finalText: responseResult.finalText, delegateSummaries };
18295
+ }
18296
+ finalText = responseResult.finalText;
18297
+ const toolUses = res.content.filter(isToolUseBlock);
18298
+ if (toolUses.length === 0) {
18299
+ this.events.emit("iteration.completed", { ctx: this.ctx, index: i });
18300
+ if (autonomousContinue && responseResult.directive === "continue") {
18301
+ await this.compactContextIfNeeded();
18302
+ await this.extensions.runAfterIteration(this.ctx, i);
18303
+ continue;
18080
18304
  }
18081
- if (recovered.model) this.ctx.model = recovered.model;
18082
- this.logger.info(`Recovered provider error via ${recovered.reason}; retrying turn`);
18083
- continue;
18305
+ if (autonomousContinue && responseResult.directive === "stop") {
18306
+ return { status: "done", iterations, finalText, delegateSummaries };
18307
+ }
18308
+ return { status: "done", iterations, finalText, delegateSummaries };
18084
18309
  }
18085
- recoveryRetries = 0;
18086
- res = recovered.response;
18087
- }
18088
- const responseResult = await this.processResponse(res, req);
18089
- if (responseResult.aborted) {
18090
- return { status: "aborted", iterations, finalText: responseResult.finalText };
18091
- }
18092
- if (responseResult.done) {
18093
- return { status: "done", iterations, finalText: responseResult.finalText };
18094
- }
18095
- finalText = responseResult.finalText;
18096
- const toolUses = res.content.filter(isToolUseBlock);
18097
- if (toolUses.length === 0) {
18098
- this.events.emit("iteration.completed", { ctx: this.ctx, index: i });
18099
- if (autonomousContinue && responseResult.directive === "continue") {
18310
+ await this.executeTools(toolUses);
18311
+ if (autonomousContinue && consumeAutonomousContinue(this.ctx)) {
18312
+ this.events.emit("iteration.completed", { ctx: this.ctx, index: i });
18100
18313
  await this.compactContextIfNeeded();
18101
18314
  await this.extensions.runAfterIteration(this.ctx, i);
18102
18315
  continue;
18103
18316
  }
18104
- if (autonomousContinue && responseResult.directive === "stop") {
18105
- return { status: "done", iterations, finalText };
18106
- }
18107
- return { status: "done", iterations, finalText };
18108
- }
18109
- await this.executeTools(toolUses);
18110
- if (autonomousContinue && consumeAutonomousContinue(this.ctx)) {
18111
18317
  this.events.emit("iteration.completed", { ctx: this.ctx, index: i });
18112
18318
  await this.compactContextIfNeeded();
18113
18319
  await this.extensions.runAfterIteration(this.ctx, i);
18114
- continue;
18115
- }
18116
- this.events.emit("iteration.completed", { ctx: this.ctx, index: i });
18117
- await this.compactContextIfNeeded();
18118
- await this.extensions.runAfterIteration(this.ctx, i);
18119
- if (autonomousContinue && responseResult.directive === "continue") {
18120
- continue;
18121
- }
18122
- if (autonomousContinue && responseResult.directive === "stop") {
18123
- return { status: "done", iterations, finalText };
18320
+ if (autonomousContinue && responseResult.directive === "continue") {
18321
+ continue;
18322
+ }
18323
+ if (autonomousContinue && responseResult.directive === "stop") {
18324
+ return { status: "done", iterations, finalText, delegateSummaries };
18325
+ }
18124
18326
  }
18327
+ } finally {
18328
+ offSubagentDone();
18125
18329
  }
18126
18330
  }
18127
18331
  /**
@@ -18130,7 +18334,7 @@ var Agent = class {
18130
18334
  * the loop should exit. Returns `{ limit }` with no result when the
18131
18335
  * iteration may proceed.
18132
18336
  */
18133
- async checkIterationLimit(iterationIndex, limit, hasHardLimit, currentIterations) {
18337
+ async checkIterationLimit(iterationIndex, limit, hasHardLimit, currentIterations, delegateSummaries) {
18134
18338
  if (hasHardLimit && iterationIndex >= limit) {
18135
18339
  const extendBy = await requestLimitExtension({
18136
18340
  events: this.events,
@@ -18143,7 +18347,7 @@ var Agent = class {
18143
18347
  this.logger.info(`Iteration limit extended by ${extendBy} (new limit: ${newLimit})`);
18144
18348
  return { limit: newLimit };
18145
18349
  }
18146
- return { limit, exit: { status: "max_iterations", iterations: currentIterations } };
18350
+ return { limit, exit: { status: "max_iterations", iterations: currentIterations, delegateSummaries } };
18147
18351
  }
18148
18352
  return { limit };
18149
18353
  }
@@ -18550,11 +18754,9 @@ var Context = class {
18550
18754
  return this._state;
18551
18755
  }
18552
18756
  /**
18553
- * Register a teardown hook tied to the current run's abort signal. The
18554
- * hook fires when the run aborts or ends normally Agent.run wires this
18555
- * through a RunController. Hooks registered before a run starts are stored
18556
- * and fired when the next run ends; there is no "immediate fire" when no
18557
- * run is active.
18757
+ * Register a teardown hook tied to the current run's abort signal.
18758
+ * Hooks registered before a run starts are stored and fired when the
18759
+ * next run ends; there is no immediate fire when no run is active.
18558
18760
  *
18559
18761
  * **Scope:** these hooks fire on the **whole agent run's** abort, not on
18560
18762
  * an individual tool call. For per-tool teardown of resources owned by
@@ -19133,13 +19335,13 @@ ${mem}`);
19133
19335
  };
19134
19336
 
19135
19337
  // src/registry/tool-registry.ts
19136
- var ToolRegistry = class {
19338
+ var ToolRegistry = class _ToolRegistry {
19137
19339
  tools = /* @__PURE__ */ new Map();
19138
19340
  register(tool, owner = "core") {
19139
19341
  if (this.tools.has(tool.name)) {
19140
19342
  throw new WrongStackError({
19141
19343
  message: `Tool "${tool.name}" already registered`,
19142
- code: "REGISTRY_DUPLICATE",
19344
+ code: ERROR_CODES.REGISTRY_DUPLICATE,
19143
19345
  subsystem: "container",
19144
19346
  context: { tool: tool.name }
19145
19347
  });
@@ -19191,7 +19393,7 @@ var ToolRegistry = class {
19191
19393
  if (!this.tools.has(name)) {
19192
19394
  throw new WrongStackError({
19193
19395
  message: `Tool "${name}" not registered; cannot override`,
19194
- code: "REGISTRY_NOT_FOUND",
19396
+ code: ERROR_CODES.REGISTRY_NOT_FOUND,
19195
19397
  subsystem: "container",
19196
19398
  context: { tool: name }
19197
19399
  });
@@ -19214,7 +19416,7 @@ var ToolRegistry = class {
19214
19416
  if (!entry) {
19215
19417
  throw new WrongStackError({
19216
19418
  message: `Tool "${name}" not registered; cannot wrap`,
19217
- code: "REGISTRY_NOT_FOUND",
19419
+ code: ERROR_CODES.REGISTRY_NOT_FOUND,
19218
19420
  subsystem: "container",
19219
19421
  context: { tool: name }
19220
19422
  });
@@ -19255,6 +19457,15 @@ var ToolRegistry = class {
19255
19457
  clear() {
19256
19458
  this.tools.clear();
19257
19459
  }
19460
+ /**
19461
+ * Return a new ToolRegistry with the same registered tools and owners.
19462
+ * Useful for creating filtered copies in multi-agent scenarios.
19463
+ */
19464
+ clone() {
19465
+ const copy = new _ToolRegistry();
19466
+ for (const { tool, owner } of this.listWithOwner()) copy.register(tool, owner);
19467
+ return copy;
19468
+ }
19258
19469
  };
19259
19470
 
19260
19471
  // src/registry/provider-registry.ts
@@ -19587,7 +19798,7 @@ function topoSort(plugins) {
19587
19798
  if (visiting.has(p.name)) {
19588
19799
  throw new PluginError({
19589
19800
  message: `Plugin dependency cycle: ${[...stack, p.name].join(" -> ")}`,
19590
- code: "PLUGIN_LOAD_FAILED",
19801
+ code: ERROR_CODES.PLUGIN_LOAD_FAILED,
19591
19802
  pluginName: p.name
19592
19803
  });
19593
19804
  }
@@ -19598,7 +19809,7 @@ function topoSort(plugins) {
19598
19809
  if (!d) {
19599
19810
  throw new PluginError({
19600
19811
  message: `Plugin "${p.name}" depends on missing plugin "${dep.name}"`,
19601
- code: "PLUGIN_MISSING_DEPENDENCY",
19812
+ code: ERROR_CODES.PLUGIN_MISSING_DEPENDENCY,
19602
19813
  pluginName: p.name,
19603
19814
  context: { dependency: dep.name }
19604
19815
  });
@@ -19606,7 +19817,7 @@ function topoSort(plugins) {
19606
19817
  if (dep.version && d.version && !satisfies(dep.version, d.version)) {
19607
19818
  throw new PluginError({
19608
19819
  message: `Plugin "${p.name}" requires "${dep.name}@${dep.version}", found ${d.version}`,
19609
- code: "PLUGIN_LOAD_FAILED",
19820
+ code: ERROR_CODES.PLUGIN_LOAD_FAILED,
19610
19821
  pluginName: p.name,
19611
19822
  context: { dependency: dep.name, required: dep.version, found: d.version }
19612
19823
  });
@@ -19620,7 +19831,7 @@ function topoSort(plugins) {
19620
19831
  if (dep.version && d.version && !satisfies(dep.version, d.version)) {
19621
19832
  throw new PluginError({
19622
19833
  message: `Plugin "${p.name}" optional dep "${dep.name}@${dep.version}" found ${d.version}`,
19623
- code: "PLUGIN_LOAD_FAILED",
19834
+ code: ERROR_CODES.PLUGIN_LOAD_FAILED,
19624
19835
  pluginName: p.name,
19625
19836
  context: { dependency: dep.name, required: dep.version, found: d.version }
19626
19837
  });
@@ -19645,7 +19856,7 @@ async function loadPlugins(plugins, opts) {
19645
19856
  if (names.has(c)) {
19646
19857
  throw new PluginError({
19647
19858
  message: `Plugin "${p.name}" conflicts with loaded plugin "${c}"`,
19648
- code: "PLUGIN_LOAD_FAILED",
19859
+ code: ERROR_CODES.PLUGIN_LOAD_FAILED,
19649
19860
  pluginName: p.name,
19650
19861
  context: { conflictsWith: c }
19651
19862
  });
@@ -19663,7 +19874,7 @@ async function loadPlugins(plugins, opts) {
19663
19874
  if (!satisfies(plugin.apiVersion, kernelVersion)) {
19664
19875
  const err = new PluginError({
19665
19876
  message: `Plugin "${plugin.name}" requires apiVersion ${plugin.apiVersion}; kernel is ${kernelVersion}`,
19666
- code: "PLUGIN_API_MISMATCH",
19877
+ code: ERROR_CODES.PLUGIN_API_MISMATCH,
19667
19878
  pluginName: plugin.name,
19668
19879
  context: { required: plugin.apiVersion, kernel: kernelVersion }
19669
19880
  });
@@ -19685,7 +19896,7 @@ async function loadPlugins(plugins, opts) {
19685
19896
  const detail = firstErr ? `${firstErr.path}: ${firstErr.message}` : "config invalid";
19686
19897
  const err = new PluginError({
19687
19898
  message: `Plugin "${plugin.name}" config invalid \u2014 ${detail}`,
19688
- code: "PLUGIN_LOAD_FAILED",
19899
+ code: ERROR_CODES.PLUGIN_LOAD_FAILED,
19689
19900
  pluginName: plugin.name,
19690
19901
  context: { errors: result.errors }
19691
19902
  });
@@ -19714,7 +19925,12 @@ async function unloadPlugins(loadedPlugins, opts) {
19714
19925
  for (const plugin of ordered) {
19715
19926
  if (typeof plugin.teardown !== "function") continue;
19716
19927
  try {
19717
- const api = pluginApiMap.get(plugin) ?? opts.apiFactory(plugin);
19928
+ const api = pluginApiMap.get(plugin);
19929
+ if (!api) {
19930
+ throw new Error(
19931
+ `Plugin "${plugin.name}" API not found in pluginApiMap \u2014 was setup() called?`
19932
+ );
19933
+ }
19718
19934
  await plugin.teardown(api);
19719
19935
  pluginApiMap.delete(plugin);
19720
19936
  opts.log.info(`Plugin "${plugin.name}" torn down`);
@@ -19730,7 +19946,7 @@ function wrapApiForCapabilityCheck(plugin, api, log, enforce = false) {
19730
19946
  if (enforce) {
19731
19947
  throw new PluginError({
19732
19948
  message: msg,
19733
- code: "PLUGIN_LOAD_FAILED",
19949
+ code: ERROR_CODES.PLUGIN_LOAD_FAILED,
19734
19950
  pluginName: plugin.name,
19735
19951
  context: { subsystem, detail }
19736
19952
  });
@@ -19803,6 +20019,6 @@ function wrapApiForCapabilityCheck(plugin, api, log, enforce = false) {
19803
20019
  });
19804
20020
  }
19805
20021
 
19806
- export { AISpecBuilder, ALL_FLEET_AGENTS, AUDIT_LOG_AGENT, Agent, AgentError, AutoApprovePermissionPolicy, AutoCompactionMiddleware, AutoExecutor, AutonomousRunner, BUG_HUNTER_AGENT, BudgetExceededError, CONTEXT_WINDOW_MODES, ConfigError, ConfigMigrationError, Container, Context, ConversationState, DEFAULT_CONFIG_MIGRATIONS, DEFAULT_CONTEXT_WINDOW_MODE_ID, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_MAX_ITERATIONS, DEFAULT_MODES, DEFAULT_RECOVERY_STRATEGIES, DEFAULT_SPEC_TEMPLATE, DEFAULT_SUBAGENT_BASELINE, DefaultAttachmentStore, DefaultConfigLoader, DefaultConfigStore, DefaultErrorHandler, DefaultHealthRegistry, DefaultLogger, DefaultMemoryStore, DefaultModeStore, DefaultModelsRegistry, DefaultMultiAgentCoordinator, DefaultPathResolver, DefaultPermissionPolicy, DefaultPluginAPI, DefaultProviderRunner, DefaultRetryPolicy, DefaultSecretScrubber, DefaultSecretVault, DefaultSessionReader, DefaultSessionRewinder, DefaultSessionStore, DefaultSkillLoader, DefaultSystemPromptBuilder, DefaultTaskStore, DefaultTokenCounter, Director, DirectorStateCheckpoint, DoneConditionChecker, EternalAutonomyEngine, EventBus, ExtensionRegistry, FLEET_ROSTER, FLEET_ROSTER_BUDGETS, FleetBus, FleetManager, FleetSpawnBudgetError, FleetUsageAggregator, GitignoreUpdater, HybridCompactor, InMemoryAgentBridge, InMemoryBridgeTransport, InMemoryMetricsSink, InputBuilder, IntelligentCompactor, KERNEL_API_VERSION, LAYER_1_IDENTITY, LLMSelector, MAX_JOURNAL_ENTRIES, NULL_FLEET_BUS, NoopMetricsSink, NoopTracer, OTelTracer, PROMETHEUS_CONTENT_TYPE, ParallelEternalEngine, Pipeline, PluginError, ProviderError, ProviderRegistry, QueueStore, REFACTOR_PLANNER_AGENT, RecoveryLock, ReportGenerator, RunController, SECURITY_SCANNER_AGENT, SPEC_TEMPLATES, ScopedEventBus, SecurityScanner, SecurityScannerOrchestrator, SelectiveCompactor, SessionAnalyzer, SessionError, SkillGenerator, SkillInstaller, SkillManifestStore, SlashCommandRegistry, SpecDrivenDev, SpecParser, SpecStore, SpecVersioning, SubagentBudget, TOKENS, TaskFlow, TaskGenerator, TaskGraphStore, TaskTracker, TechStackDetector, ToolError, ToolExecutor, ToolRegistry, WrongStackError, addPlanItem, allServers, analyzeCriticalPath, appendJournal, applyRosterBudget, asBlocks, asText, atomicWrite, attachPlanCheckpoint, attachTodosCheckpoint, awsServer, blockServer, braveSearchServer, buildChildEnv, buildGoalPreamble, buildOtlpMetricsRequest, buildOtlpTracesRequest, buildRecoveryStrategies, classifyFamily, clearPlan, color, compileGlob, compileUserRegex, composeDirectorPrompt, composeSubagentPrompt, computeTaskProgress, context7Server, contextManagerTool, createAutoExecutor, createContextManagerTool, createDefaultPipelines, createDelegateTool, createMcpControlTool, createMessage, createSecuritySlashCommand, createToolOutputSerializer, decryptConfigSecrets, defaultGitignoreUpdater, defaultOrchestrator, defaultReportGenerator, defaultSecurityScanner, defaultSkillGenerator, defaultTechStackDetector, deriveTodosFromPlanItem, detectNewlineStyle, downloadGitHubTarball, emptyGoal, emptyPlan, encryptConfigSecrets, ensureDir, estimateRequestTokens, estimateTextTokens, estimateToolDefTokens, estimateToolInputTokens, estimateToolResultTokens, everArtServer, extractRunEnv, filesystemServer, findCriticalPath, formatContextWindowModeList, formatGoal, formatPlan, formatPlanTemplates, formatTodosList, getContextWindowMode, getPlanTemplate, getTemplate, githubServer, goalFilePath, googleMapsServer, isAgentError, isConfigError, isContextWindowModeId, isImageBlock, isPluginError, isSessionError, isTextBlock, isThinkingBlock, isToolError, isToolResultBlock, isToolUseBlock, isWrongStackError, listContextWindowModes, listPlanTemplates, listTemplates, loadDirectorState, loadGoal, loadPlan, loadPlugins, loadProjectModes, loadTodosCheckpoint, loadUserModes, makeAgentSubagentRunner, makeAutonomyPromptContributor, makeContinueToNextIterationTool, makeDirectorSessionFactory, matchAny, matchGlob, migratePlaintextSecrets, miniMaxVisionServer, normalizeToLf, parseContinueDirective, parseSkillRef, projectHash, removePlanItem, renderProgress, renderPrometheus, renderSpecAnalysis, renderTaskGraph, renderTaskList, repairToolUseAdjacency, resolveContextWindowPolicy, resolveWstackPaths, rewriteConfigEncrypted, rosterSummaryFromConfigs, runConfigMigrations, safeParse, safeStringify, sanitizeJsonString, saveGoal, savePlan, saveTodosCheckpoint, securitySlashCommand, sentinelServer, setPlanItemStatus, slackServer, startMetricsServer, startOtlpMetricsExporter, startOtlpTraceExporter, stripAnsi, summarizeUsage, templateToMarkdown, toStyle, toWrongStackError, topologicalSort, unifiedDiff, unloadPlugins, validateAgainstSchema, wireMetricsToEvents, wrapAsState, zaiVisionServer };
20022
+ export { AISpecBuilder, ALL_FLEET_AGENTS, AUDIT_LOG_AGENT, Agent, AgentError, AutoApprovePermissionPolicy, AutoCompactionMiddleware, AutoExecutor, AutonomousRunner, BUG_HUNTER_AGENT, BudgetExceededError, CONTEXT_WINDOW_MODES, ConfigError, ConfigMigrationError, Container, Context, ConversationState, DEFAULT_CONFIG_MIGRATIONS, DEFAULT_CONTEXT_CONFIG, DEFAULT_CONTEXT_WINDOW_MODE_ID, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_MAX_ITERATIONS, DEFAULT_MODES, DEFAULT_RECOVERY_STRATEGIES, DEFAULT_SPEC_TEMPLATE, DEFAULT_SUBAGENT_BASELINE, DEFAULT_TOOLS_CONFIG, DefaultAttachmentStore, DefaultConfigLoader, DefaultConfigStore, DefaultErrorHandler, DefaultHealthRegistry, DefaultLogger, DefaultMemoryStore, DefaultModeStore, DefaultModelsRegistry, DefaultMultiAgentCoordinator, DefaultPathResolver, DefaultPermissionPolicy, DefaultPluginAPI, DefaultProviderRunner, DefaultRetryPolicy, DefaultSecretScrubber, DefaultSecretVault, DefaultSessionReader, DefaultSessionRewinder, DefaultSessionStore, DefaultSkillLoader, DefaultSystemPromptBuilder, DefaultTaskStore, DefaultTokenCounter, Director, DirectorStateCheckpoint, DoneConditionChecker, ERROR_CODES, EternalAutonomyEngine, EventBus, ExtensionRegistry, FLEET_ROSTER, FLEET_ROSTER_BUDGETS, FleetBus, FleetManager, FleetSpawnBudgetError, FleetUsageAggregator, FsError, GitignoreUpdater, HybridCompactor, InMemoryAgentBridge, InMemoryBridgeTransport, InMemoryMetricsSink, InputBuilder, IntelligentCompactor, KERNEL_API_VERSION, LAYER_1_IDENTITY, LLMSelector, MAX_JOURNAL_ENTRIES, NULL_FLEET_BUS, NoopMetricsSink, NoopTracer, OTelTracer, PROMETHEUS_CONTENT_TYPE, ParallelEternalEngine, Pipeline, PluginError, ProviderError, ProviderRegistry, QueueStore, REFACTOR_PLANNER_AGENT, RecoveryLock, ReportGenerator, RunController, SECURITY_SCANNER_AGENT, SPEC_TEMPLATES, ScopedEventBus, SecurityScanner, SecurityScannerOrchestrator, SelectiveCompactor, SessionAnalyzer, SessionError, SkillGenerator, SkillInstaller, SkillManifestStore, SlashCommandRegistry, SpecDrivenDev, SpecParser, SpecStore, SpecVersioning, SubagentBudget, TOKENS, TaskFlow, TaskGenerator, TaskGraphStore, TaskTracker, TechStackDetector, ToolError, ToolExecutor, ToolRegistry, WrongStackError, addPlanItem, allServers, analyzeCriticalPath, appendJournal, applyRosterBudget, asBlocks, asText, atomicWrite, attachPlanCheckpoint, attachTodosCheckpoint, awsServer, blockServer, braveSearchServer, buildChildEnv, buildGoalPreamble, buildOtlpMetricsRequest, buildOtlpTracesRequest, buildRecoveryStrategies, classifyFamily, clearPlan, color, compileGlob, compileUserRegex, composeDirectorPrompt, composeSubagentPrompt, computeTaskProgress, context7Server, contextManagerTool, createAutoExecutor, createContextManagerTool, createDefaultPipelines, createDelegateTool, createMcpControlTool, createMessage, createSecuritySlashCommand, createToolOutputSerializer, decryptConfigSecrets, defaultGitignoreUpdater, defaultOrchestrator, defaultReportGenerator, defaultSecurityScanner, defaultSkillGenerator, defaultTechStackDetector, deriveTodosFromPlanItem, detectNewlineStyle, downloadGitHubTarball, emptyGoal, emptyPlan, encryptConfigSecrets, ensureDir, estimateRequestTokens, estimateTextTokens, estimateToolDefTokens, estimateToolInputTokens, estimateToolResultTokens, everArtServer, extractRunEnv, filesystemServer, findCriticalPath, formatContextWindowModeList, formatGoal, formatPlan, formatPlanTemplates, formatTodosList, getContextWindowMode, getPlanTemplate, getTemplate, githubServer, goalFilePath, googleMapsServer, isAgentError, isConfigError, isContextWindowModeId, isFsError, isImageBlock, isPluginError, isSessionError, isTextBlock, isThinkingBlock, isToolError, isToolResultBlock, isToolUseBlock, isWrongStackError, listContextWindowModes, listPlanTemplates, listTemplates, loadDirectorState, loadGoal, loadPlan, loadPlugins, loadProjectModes, loadTodosCheckpoint, loadUserModes, makeAgentSubagentRunner, makeAutonomyPromptContributor, makeContinueToNextIterationTool, makeDirectorSessionFactory, matchAny, matchGlob, migratePlaintextSecrets, miniMaxVisionServer, normalizeToLf, parseContinueDirective, parseSkillRef, projectHash, removePlanItem, renderProgress, renderPrometheus, renderSpecAnalysis, renderTaskGraph, renderTaskList, repairToolUseAdjacency, resolveContextWindowPolicy, resolveWstackPaths, rewriteConfigEncrypted, rosterSummaryFromConfigs, runConfigMigrations, safeParse, safeStringify, sanitizeJsonString, saveGoal, savePlan, saveTodosCheckpoint, securitySlashCommand, sentinelServer, setPlanItemStatus, slackServer, startMetricsServer, startOtlpMetricsExporter, startOtlpTraceExporter, stripAnsi, summarizeUsage, templateToMarkdown, toStyle, toWrongStackError, topologicalSort, unifiedDiff, unloadPlugins, validateAgainstSchema, wireMetricsToEvents, wrapAsState, zaiVisionServer };
19807
20023
  //# sourceMappingURL=index.js.map
19808
20024
  //# sourceMappingURL=index.js.map