@wrongstack/core 0.5.7 → 0.6.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 (38) hide show
  1. package/dist/coordination/index.d.ts +2 -2
  2. package/dist/coordination/index.js +40 -24
  3. package/dist/coordination/index.js.map +1 -1
  4. package/dist/defaults/index.d.ts +6 -5
  5. package/dist/defaults/index.js +608 -120
  6. package/dist/defaults/index.js.map +1 -1
  7. package/dist/execution/index.d.ts +136 -3
  8. package/dist/execution/index.js +455 -2
  9. package/dist/execution/index.js.map +1 -1
  10. package/dist/extension/index.d.ts +1 -1
  11. package/dist/extension/index.js +2 -1
  12. package/dist/extension/index.js.map +1 -1
  13. package/dist/goal-store-BQ3YX1h1.d.ts +75 -0
  14. package/dist/{index-j2WyAyML.d.ts → index-B0qTujQW.d.ts} +33 -1
  15. package/dist/{index-Bf9Bpkdc.d.ts → index-DkdRz6yK.d.ts} +1 -1
  16. package/dist/index.d.ts +8 -7
  17. package/dist/index.js +739 -163
  18. package/dist/index.js.map +1 -1
  19. package/dist/models/index.js +2 -3
  20. package/dist/models/index.js.map +1 -1
  21. package/dist/{plan-templates-Bveo2W8n.d.ts → plan-templates-CKJs_sYh.d.ts} +5 -4
  22. package/dist/sdd/index.d.ts +3 -1
  23. package/dist/sdd/index.js +102 -68
  24. package/dist/sdd/index.js.map +1 -1
  25. package/dist/security/index.js +82 -82
  26. package/dist/security/index.js.map +1 -1
  27. package/dist/skills/index.js +102 -38
  28. package/dist/skills/index.js.map +1 -1
  29. package/dist/storage/index.d.ts +2 -1
  30. package/dist/storage/index.js +131 -22
  31. package/dist/storage/index.js.map +1 -1
  32. package/dist/{tool-executor-DbAFkHdP.d.ts → tool-executor-B03CRwu-.d.ts} +1 -1
  33. package/dist/types/index.d.ts +2 -2
  34. package/dist/types/index.js +100 -102
  35. package/dist/types/index.js.map +1 -1
  36. package/dist/utils/index.js +5 -0
  37. package/dist/utils/index.js.map +1 -1
  38. package/package.json +1 -1
@@ -1,17 +1,104 @@
1
- import * as fs5 from 'fs';
2
- import * as path3 from 'path';
3
1
  import * as crypto2 from 'crypto';
4
2
  import { randomBytes, randomUUID, createCipheriv, createDecipheriv } from 'crypto';
5
3
  import * as fsp from 'fs/promises';
4
+ import * as path3 from 'path';
5
+ import * as fs5 from 'fs';
6
6
  import * as os from 'os';
7
+ import { execFile } from 'child_process';
8
+ import { promisify } from 'util';
7
9
  import { EventEmitter } from 'events';
8
10
 
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
9
13
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
10
14
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
11
15
  }) : x)(function(x) {
12
16
  if (typeof require !== "undefined") return require.apply(this, arguments);
13
17
  throw Error('Dynamic require of "' + x + '" is not supported');
14
18
  });
19
+ var __esm = (fn, res) => function __init() {
20
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
21
+ };
22
+ var __export = (target, all) => {
23
+ for (var name in all)
24
+ __defProp(target, name, { get: all[name], enumerable: true });
25
+ };
26
+
27
+ // src/utils/atomic-write.ts
28
+ var atomic_write_exports = {};
29
+ __export(atomic_write_exports, {
30
+ atomicWrite: () => atomicWrite,
31
+ ensureDir: () => ensureDir
32
+ });
33
+ async function atomicWrite(targetPath, content, opts = {}) {
34
+ const dir = path3.dirname(targetPath);
35
+ await fsp.mkdir(dir, { recursive: true });
36
+ const tmp = path3.join(dir, `.${path3.basename(targetPath)}.${randomBytes(6).toString("hex")}.tmp`);
37
+ try {
38
+ if (typeof content === "string") {
39
+ await fsp.writeFile(tmp, content, { flag: "wx", encoding: opts.encoding ?? "utf8" });
40
+ } else {
41
+ await fsp.writeFile(tmp, content, { flag: "wx" });
42
+ }
43
+ try {
44
+ const fh = await fsp.open(tmp, "r+");
45
+ try {
46
+ await fh.sync();
47
+ } finally {
48
+ await fh.close();
49
+ }
50
+ } catch {
51
+ }
52
+ let mode;
53
+ try {
54
+ const stat4 = await fsp.stat(targetPath);
55
+ mode = stat4.mode & 511;
56
+ } catch {
57
+ mode = opts.mode;
58
+ }
59
+ if (mode !== void 0) {
60
+ await fsp.chmod(tmp, mode);
61
+ }
62
+ await renameWithRetry(tmp, targetPath);
63
+ } catch (err) {
64
+ try {
65
+ await fsp.unlink(tmp);
66
+ } catch {
67
+ }
68
+ throw err;
69
+ }
70
+ }
71
+ async function ensureDir(dir) {
72
+ await fsp.mkdir(dir, { recursive: true });
73
+ }
74
+ async function renameWithRetry(from, to) {
75
+ if (process.platform !== "win32") {
76
+ await fsp.rename(from, to);
77
+ return;
78
+ }
79
+ const delays = [10, 25, 60, 120, 250];
80
+ let lastErr;
81
+ for (let i = 0; i <= delays.length; i++) {
82
+ try {
83
+ await fsp.rename(from, to);
84
+ return;
85
+ } catch (err) {
86
+ lastErr = err;
87
+ const code = err?.code;
88
+ if (!code || !TRANSIENT_RENAME_CODES.has(code) || i === delays.length) {
89
+ throw err;
90
+ }
91
+ await new Promise((resolve2) => setTimeout(resolve2, delays[i]));
92
+ }
93
+ }
94
+ throw lastErr;
95
+ }
96
+ var TRANSIENT_RENAME_CODES;
97
+ var init_atomic_write = __esm({
98
+ "src/utils/atomic-write.ts"() {
99
+ TRANSIENT_RENAME_CODES = /* @__PURE__ */ new Set(["EPERM", "EBUSY", "EACCES", "ENOTEMPTY"]);
100
+ }
101
+ });
15
102
 
16
103
  // src/utils/color.ts
17
104
  var isColorTty = () => {
@@ -132,70 +219,9 @@ function formatCtx(ctx) {
132
219
  return color.dim(String(ctx));
133
220
  }
134
221
  }
135
- async function atomicWrite(targetPath, content, opts = {}) {
136
- const dir = path3.dirname(targetPath);
137
- await fsp.mkdir(dir, { recursive: true });
138
- const tmp = path3.join(dir, `.${path3.basename(targetPath)}.${randomBytes(6).toString("hex")}.tmp`);
139
- try {
140
- if (typeof content === "string") {
141
- await fsp.writeFile(tmp, content, { flag: "wx", encoding: opts.encoding ?? "utf8" });
142
- } else {
143
- await fsp.writeFile(tmp, content, { flag: "wx" });
144
- }
145
- try {
146
- const fh = await fsp.open(tmp, "r+");
147
- try {
148
- await fh.sync();
149
- } finally {
150
- await fh.close();
151
- }
152
- } catch {
153
- }
154
- let mode;
155
- try {
156
- const stat4 = await fsp.stat(targetPath);
157
- mode = stat4.mode & 511;
158
- } catch {
159
- mode = opts.mode;
160
- }
161
- if (mode !== void 0) {
162
- await fsp.chmod(tmp, mode);
163
- }
164
- await renameWithRetry(tmp, targetPath);
165
- } catch (err) {
166
- try {
167
- await fsp.unlink(tmp);
168
- } catch {
169
- }
170
- throw err;
171
- }
172
- }
173
- async function ensureDir(dir) {
174
- await fsp.mkdir(dir, { recursive: true });
175
- }
176
- var TRANSIENT_RENAME_CODES = /* @__PURE__ */ new Set(["EPERM", "EBUSY", "EACCES", "ENOTEMPTY"]);
177
- async function renameWithRetry(from, to) {
178
- if (process.platform !== "win32") {
179
- await fsp.rename(from, to);
180
- return;
181
- }
182
- const delays = [10, 25, 60, 120, 250];
183
- let lastErr;
184
- for (let i = 0; i <= delays.length; i++) {
185
- try {
186
- await fsp.rename(from, to);
187
- return;
188
- } catch (err) {
189
- lastErr = err;
190
- const code = err?.code;
191
- if (!code || !TRANSIENT_RENAME_CODES.has(code) || i === delays.length) {
192
- throw err;
193
- }
194
- await new Promise((resolve2) => setTimeout(resolve2, delays[i]));
195
- }
196
- }
197
- throw lastErr;
198
- }
222
+
223
+ // src/storage/session-store.ts
224
+ init_atomic_write();
199
225
 
200
226
  // src/utils/message-invariants.ts
201
227
  function repairToolUseAdjacency(messages) {
@@ -333,19 +359,25 @@ var DefaultSessionStore = class {
333
359
  { cause: err }
334
360
  );
335
361
  }
336
- const writer = new FileSessionWriter(
337
- id,
338
- handle,
339
- (/* @__PURE__ */ new Date()).toISOString(),
340
- {
362
+ try {
363
+ const writer = new FileSessionWriter(
341
364
  id,
342
- model: data.metadata.model,
343
- provider: data.metadata.provider
344
- },
345
- this.events,
346
- { resumed: true, dir: this.dir, filePath: file }
347
- );
348
- return { writer, data };
365
+ handle,
366
+ (/* @__PURE__ */ new Date()).toISOString(),
367
+ {
368
+ id,
369
+ model: data.metadata.model,
370
+ provider: data.metadata.provider
371
+ },
372
+ this.events,
373
+ { resumed: true, dir: this.dir, filePath: file }
374
+ );
375
+ return { writer, data };
376
+ } catch (err) {
377
+ await handle.close().catch(() => {
378
+ });
379
+ throw err;
380
+ }
349
381
  }
350
382
  async load(id) {
351
383
  const file = path3.join(this.dir, `${id}.jsonl`);
@@ -391,7 +423,7 @@ var DefaultSessionStore = class {
391
423
  const full = path3.join(this.dir, `${id}.jsonl`);
392
424
  const stat4 = await fsp.stat(full);
393
425
  const summary = await this.summarize(id, stat4.mtime.toISOString());
394
- await fsp.writeFile(manifest, JSON.stringify(summary), { mode: 384 }).catch((err) => {
426
+ await atomicWrite(manifest, JSON.stringify(summary), { mode: 384 }).catch((err) => {
395
427
  console.warn(
396
428
  `[session-store] Failed to write manifest for "${id}":`,
397
429
  err instanceof Error ? err.message : String(err)
@@ -619,7 +651,7 @@ var FileSessionWriter = class {
619
651
  this.closed = true;
620
652
  if (this.manifestFile) {
621
653
  try {
622
- await fsp.writeFile(this.manifestFile, JSON.stringify(this.summary), { mode: 384 });
654
+ await atomicWrite(this.manifestFile, JSON.stringify(this.summary), { mode: 384 });
623
655
  } catch {
624
656
  }
625
657
  }
@@ -715,6 +747,9 @@ function userInputTitle(content) {
715
747
  const text = content.filter((b) => b.type === "text").map((b) => b.text).join(" ");
716
748
  return (text || "(non-text input)").slice(0, 60);
717
749
  }
750
+
751
+ // src/storage/queue-store.ts
752
+ init_atomic_write();
718
753
  var QueueStore = class {
719
754
  file;
720
755
  constructor(opts) {
@@ -765,6 +800,9 @@ function isPersistedQueueItem(v) {
765
800
  const o = v;
766
801
  return typeof o["displayText"] === "string" && Array.isArray(o["blocks"]);
767
802
  }
803
+
804
+ // src/storage/attachment-store.ts
805
+ init_atomic_write();
768
806
  var DEFAULT_SPOOL_THRESHOLD = 256 * 1024;
769
807
  var PLACEHOLDER_RE = /\[(pasted|image|file) #(\d+)\]/g;
770
808
  var DefaultAttachmentStore = class {
@@ -786,7 +824,9 @@ var DefaultAttachmentStore = class {
786
824
  if (this.spoolDir && bytes >= this.spoolThreshold) {
787
825
  await fsp.mkdir(this.spoolDir, { recursive: true });
788
826
  spooledPath = path3.join(this.spoolDir, `${id}.bin`);
789
- await fsp.writeFile(spooledPath, input.data, input.kind === "image" ? "base64" : "utf8");
827
+ await atomicWrite(spooledPath, input.data, {
828
+ encoding: input.kind === "image" ? "base64" : "utf8"
829
+ });
790
830
  data = void 0;
791
831
  }
792
832
  const att = {
@@ -885,6 +925,9 @@ function mergeAdjacentText(blocks) {
885
925
  }
886
926
  return out;
887
927
  }
928
+
929
+ // src/storage/memory-store.ts
930
+ init_atomic_write();
888
931
  var MAX_BYTES_TOTAL = 32e3;
889
932
  var DefaultMemoryStore = class {
890
933
  files;
@@ -897,12 +940,13 @@ var DefaultMemoryStore = class {
897
940
  * issue order. Different scopes still proceed in parallel.
898
941
  *
899
942
  * The chain tracks only the last pending write. If a write fails, its
900
- * error is caught and swallowed (line 43) so the chain stays alive for
901
- * subsequent calls. A crash between atomicWrite() and backup copy leaves
902
- * the file at its new content with no backup — acceptable for an optional
903
- * backup whose worst case is losing a memory consolidation pass.
943
+ * error is caught and swallowed so the chain stays alive for subsequent
944
+ * calls. The error is stored in `writeErrors` so callers can learn about
945
+ * it on the next read operation.
904
946
  */
905
947
  writeChain = /* @__PURE__ */ new Map();
948
+ /** Last write error per scope — surfaced as warnings on the next readAll(). */
949
+ writeErrors = /* @__PURE__ */ new Map();
906
950
  constructor(opts) {
907
951
  this.files = {
908
952
  "project-agents": opts.paths.inProjectAgentsFile,
@@ -912,10 +956,16 @@ var DefaultMemoryStore = class {
912
956
  }
913
957
  async runSerialized(scope, work) {
914
958
  const prior = this.writeChain.get(scope) ?? Promise.resolve();
959
+ prior.catch((err) => {
960
+ this.writeErrors.set(scope, err);
961
+ });
915
962
  const next = prior.catch(() => void 0).then(work);
916
963
  this.writeChain.set(scope, next);
917
964
  try {
918
965
  return await next;
966
+ } catch (err) {
967
+ this.writeErrors.set(scope, err);
968
+ throw err;
919
969
  } finally {
920
970
  if (this.writeChain.get(scope) === next) {
921
971
  this.writeChain.delete(scope);
@@ -925,6 +975,10 @@ var DefaultMemoryStore = class {
925
975
  async readAll() {
926
976
  const parts = [];
927
977
  for (const scope of ["project-agents", "project-memory", "user-memory"]) {
978
+ const writeErr = this.writeErrors.get(scope);
979
+ if (writeErr) {
980
+ parts.push(`> \u26A0\uFE0F Memory write error (${labelOf(scope)}): ${writeErr.message}`);
981
+ }
928
982
  const body = await this.read(scope);
929
983
  if (body.trim()) parts.push(`## ${labelOf(scope)}
930
984
 
@@ -1483,6 +1537,9 @@ function runConfigMigrations(input, targetVersion, migrations) {
1483
1537
  return { config: current, applied, shouldPersist };
1484
1538
  }
1485
1539
  var DEFAULT_CONFIG_MIGRATIONS = [];
1540
+
1541
+ // src/storage/recovery-lock.ts
1542
+ init_atomic_write();
1486
1543
  var LOCK_FILE = "active.json";
1487
1544
  var DEFAULT_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
1488
1545
  var RecoveryLock = class {
@@ -1999,6 +2056,9 @@ var SessionAnalyzer = class {
1999
2056
  return last - first;
2000
2057
  }
2001
2058
  };
2059
+
2060
+ // src/storage/todos-checkpoint.ts
2061
+ init_atomic_write();
2002
2062
  async function loadTodosCheckpoint(filePath) {
2003
2063
  let raw;
2004
2064
  try {
@@ -2067,6 +2127,9 @@ function attachTodosCheckpoint(state, filePath, sessionId) {
2067
2127
  }
2068
2128
  };
2069
2129
  }
2130
+
2131
+ // src/storage/plan-store.ts
2132
+ init_atomic_write();
2070
2133
  async function loadPlan(filePath) {
2071
2134
  let raw;
2072
2135
  try {
@@ -2301,6 +2364,9 @@ ${cat}:`);
2301
2364
  }
2302
2365
  return lines.join("\n");
2303
2366
  }
2367
+
2368
+ // src/storage/director-state.ts
2369
+ init_atomic_write();
2304
2370
  async function loadDirectorState(filePath) {
2305
2371
  let raw;
2306
2372
  try {
@@ -2523,15 +2589,15 @@ var PATTERNS = [
2523
2589
  { type: "redis_uri", regex: /redis:\/\/[^\s"'`]+/g },
2524
2590
  {
2525
2591
  type: "bearer_token",
2526
- // Bounded at 512 chars to prevent catastrophic backtracking on adversarial input.
2527
- // Negative lookahead is a simple single-char check no backtracking risk.
2528
- regex: /(?<![A-Za-z0-9_.~+/-])Bearer\s+[A-Za-z0-9._~+/-]{20,512}=*(?![A-Za-z0-9_.~+/-])/g
2592
+ // Anchored with alternation instead of negative lookahead avoids V8
2593
+ // backtracking risk on adversarial input. Bounded at 512 chars.
2594
+ regex: /(?:^|[^A-Za-z0-9_.~+/-])Bearer\s+[A-Za-z0-9._~+/-]{20,512}=*(?:$|[^A-Za-z0-9_.~+/-])/g
2529
2595
  },
2530
2596
  {
2531
2597
  type: "high_entropy_env",
2532
- // Value bounded at 512 chars; negative lookahead simplified to avoid
2533
- // nested quantifier backtracking on adversarial input.
2534
- regex: /\b([A-Z_]{4,}(?:KEY|TOKEN|SECRET|PASSWORD|PWD))\s*[:=]\s*['"]?([A-Za-z0-9_/+=-]{20,512})['"]?/g
2598
+ // Anchored with alternation instead of lookbehind to avoid backtracking.
2599
+ // Value bounded at 512 chars.
2600
+ regex: /(?:^|\s)([A-Z_]{4,}(?:KEY|TOKEN|SECRET|PASSWORD|PWD))\s*[:=]\s*['"]?([A-Za-z0-9_/+=-]{20,512})['"]?(?:\s|$)/g
2535
2601
  }
2536
2602
  ];
2537
2603
  var SCRUB_CHUNK_BYTES = 64 * 1024;
@@ -2588,6 +2654,7 @@ var DefaultSecretScrubber = class {
2588
2654
  var ENCRYPTED_PREFIX = "enc:v1:";
2589
2655
 
2590
2656
  // src/security/secret-vault.ts
2657
+ init_atomic_write();
2591
2658
  var KEY_BYTES = 32;
2592
2659
  var IV_BYTES = 12;
2593
2660
  var TAG_BYTES = 16;
@@ -2709,7 +2776,7 @@ async function rewriteConfigEncrypted(configPath, vault, patch) {
2709
2776
  const merged = deepMerge2(current, patch ?? {});
2710
2777
  const encrypted = encryptConfigSecrets(merged, vault);
2711
2778
  await fsp.mkdir(path3.dirname(configPath), { recursive: true });
2712
- await fsp.writeFile(configPath, JSON.stringify(encrypted, null, 2), { mode: 384 });
2779
+ await atomicWrite(configPath, JSON.stringify(encrypted, null, 2), { mode: 384 });
2713
2780
  try {
2714
2781
  await fsp.chmod(configPath, 384);
2715
2782
  } catch {
@@ -2731,7 +2798,7 @@ async function migratePlaintextSecrets(configPath, vault) {
2731
2798
  const counter = { n: 0 };
2732
2799
  const migrated = walkCount(parsed, vault, counter);
2733
2800
  if (counter.n === 0) return { migrated: 0, file: configPath };
2734
- await fsp.writeFile(configPath, JSON.stringify(migrated, null, 2), { mode: 384 });
2801
+ await atomicWrite(configPath, JSON.stringify(migrated, null, 2), { mode: 384 });
2735
2802
  try {
2736
2803
  await fsp.chmod(configPath, 384);
2737
2804
  } catch {
@@ -2780,6 +2847,9 @@ function deepMerge2(a, b) {
2780
2847
  return out;
2781
2848
  }
2782
2849
 
2850
+ // src/security/permission-policy.ts
2851
+ init_atomic_write();
2852
+
2783
2853
  // src/utils/glob-match.ts
2784
2854
  function escapeRegex(s) {
2785
2855
  return s.replace(/[.+^${}()|\\]/g, "\\$&");
@@ -3279,7 +3349,7 @@ function buildRecoveryStrategies(opts) {
3279
3349
  async attempt(err) {
3280
3350
  if (!(err instanceof ProviderError) || err.status !== 429) return null;
3281
3351
  const delayMs = err.body?.retryAfterMs ?? 5e3;
3282
- const delay = Math.max(1e3, Math.min(delayMs, 6e4));
3352
+ const delay = Math.min(6e4, Math.max(1e3, delayMs));
3283
3353
  await new Promise((r) => setTimeout(r, delay));
3284
3354
  return { action: "retry", reason: "rate_limit_backoff" };
3285
3355
  }
@@ -5157,6 +5227,399 @@ var AutonomousRunner = class {
5157
5227
  }
5158
5228
  };
5159
5229
 
5230
+ // src/storage/goal-store.ts
5231
+ init_atomic_write();
5232
+ var MAX_JOURNAL_ENTRIES = 500;
5233
+ function goalFilePath(projectRoot) {
5234
+ return path3.join(projectRoot, ".wrongstack", "goal.json");
5235
+ }
5236
+ async function loadGoal(filePath) {
5237
+ let raw;
5238
+ try {
5239
+ raw = await fsp.readFile(filePath, "utf8");
5240
+ } catch {
5241
+ return null;
5242
+ }
5243
+ try {
5244
+ const parsed = JSON.parse(raw);
5245
+ if (parsed?.version !== 1 || typeof parsed.goal !== "string" || !Array.isArray(parsed.journal)) {
5246
+ return null;
5247
+ }
5248
+ return parsed;
5249
+ } catch {
5250
+ return null;
5251
+ }
5252
+ }
5253
+ async function saveGoal(filePath, goal) {
5254
+ await atomicWrite(filePath, JSON.stringify(goal, null, 2), { mode: 384 });
5255
+ }
5256
+ function appendJournal(goal, entry) {
5257
+ const iteration = goal.iterations + 1;
5258
+ const at = (/* @__PURE__ */ new Date()).toISOString();
5259
+ const full = { ...entry, iteration, at };
5260
+ const journal = [...goal.journal, full];
5261
+ const trimmed = journal.length > MAX_JOURNAL_ENTRIES ? journal.slice(journal.length - MAX_JOURNAL_ENTRIES) : journal;
5262
+ return {
5263
+ ...goal,
5264
+ iterations: iteration,
5265
+ lastActivityAt: at,
5266
+ journal: trimmed
5267
+ };
5268
+ }
5269
+
5270
+ // src/execution/eternal-autonomy.ts
5271
+ var execFileP = promisify(execFile);
5272
+ var EternalAutonomyEngine = class {
5273
+ constructor(opts) {
5274
+ this.opts = opts;
5275
+ this.goalPath = goalFilePath(opts.projectRoot);
5276
+ }
5277
+ opts;
5278
+ state = "idle";
5279
+ stopRequested = false;
5280
+ consecutiveFailures = 0;
5281
+ currentCtrl = null;
5282
+ iterationsSinceCompact = 0;
5283
+ goalPath;
5284
+ /** Current engine state — readable for UIs. */
5285
+ get currentState() {
5286
+ return this.state;
5287
+ }
5288
+ /** Synchronously request stop. Resolves once the running iteration aborts. */
5289
+ stop() {
5290
+ this.stopRequested = true;
5291
+ this.currentCtrl?.abort();
5292
+ void this.persistEngineState("stopped").catch(() => {
5293
+ });
5294
+ this.state = "stopped";
5295
+ }
5296
+ /**
5297
+ * Mark the engine as 'running' on disk + reset stop state so a new
5298
+ * batch of `runOneIteration()` calls can proceed. Called by the REPL
5299
+ * when the user invokes `/autonomy eternal`. Idempotent.
5300
+ */
5301
+ async prime() {
5302
+ this.stopRequested = false;
5303
+ this.state = "running";
5304
+ await this.persistEngineState("running").catch(() => {
5305
+ });
5306
+ }
5307
+ /**
5308
+ * Main loop. Returns when stop() is called or the goal file is removed.
5309
+ * Does NOT throw — every iteration is wrapped to keep the loop alive.
5310
+ */
5311
+ async run() {
5312
+ this.state = "running";
5313
+ await this.persistEngineState("running");
5314
+ try {
5315
+ while (!this.stopRequested) {
5316
+ let iterationOk = false;
5317
+ try {
5318
+ iterationOk = await this.runOneIteration();
5319
+ } catch (err) {
5320
+ this.consecutiveFailures++;
5321
+ this.opts.onError?.(err instanceof Error ? err : new Error(String(err)), this.consecutiveFailures);
5322
+ await this.appendFailure("engine error", err instanceof Error ? err.message : String(err));
5323
+ }
5324
+ if (iterationOk) {
5325
+ this.consecutiveFailures = 0;
5326
+ }
5327
+ if (this.stopRequested) break;
5328
+ await sleep(this.opts.cycleGapMs ?? 1e3);
5329
+ }
5330
+ } finally {
5331
+ this.state = "stopped";
5332
+ await this.persistEngineState("stopped").catch(() => {
5333
+ });
5334
+ }
5335
+ }
5336
+ /**
5337
+ * Execute a single sense-decide-execute-reflect cycle.
5338
+ * Returns true on success, false on handled failure / no-op.
5339
+ *
5340
+ * Exposed publicly so the REPL can pace iterations from its main loop
5341
+ * — running the engine and the REPL as a single sequential consumer of
5342
+ * `agent.run()` avoids race conditions on the shared Context.
5343
+ */
5344
+ async runOneIteration() {
5345
+ const goal = await loadGoal(this.goalPath);
5346
+ if (!goal) {
5347
+ this.stopRequested = true;
5348
+ return false;
5349
+ }
5350
+ const action = await this.decide(goal);
5351
+ if (!action) {
5352
+ await sleep(5e3);
5353
+ return false;
5354
+ }
5355
+ const ctrl = new AbortController();
5356
+ this.currentCtrl = ctrl;
5357
+ const timer = setTimeout(
5358
+ () => ctrl.abort(),
5359
+ this.opts.iterationTimeoutMs ?? 5 * 6e4
5360
+ );
5361
+ let status = "success";
5362
+ let note;
5363
+ const tc = this.opts.agent.ctx?.tokenCounter;
5364
+ const beforeUsage = tc?.total?.();
5365
+ const beforeCost = tc?.estimateCost?.().total;
5366
+ try {
5367
+ const result = await this.opts.agent.run(
5368
+ [{ type: "text", text: action.directive }],
5369
+ { signal: ctrl.signal }
5370
+ );
5371
+ if (result.status === "aborted") {
5372
+ status = "aborted";
5373
+ note = "stopped by user";
5374
+ } else if (result.status === "failed") {
5375
+ status = "failure";
5376
+ note = result.error?.describe?.() ?? "agent run failed";
5377
+ } else if (result.status === "max_iterations") {
5378
+ status = "failure";
5379
+ note = `max iterations (${result.iterations})`;
5380
+ } else {
5381
+ status = "success";
5382
+ const tail = (result.finalText ?? "").slice(0, 240).replace(/\s+/g, " ").trim();
5383
+ if (tail) note = tail;
5384
+ }
5385
+ } catch (err) {
5386
+ const isAbort = err instanceof Error && (err.name === "AbortError" || err.message.includes("abort"));
5387
+ status = isAbort ? "aborted" : "failure";
5388
+ note = err instanceof Error ? err.message : String(err);
5389
+ } finally {
5390
+ clearTimeout(timer);
5391
+ this.currentCtrl = null;
5392
+ }
5393
+ const afterUsage = tc?.total?.();
5394
+ const afterCost = tc?.estimateCost?.().total;
5395
+ const tokens = beforeUsage && afterUsage ? {
5396
+ input: Math.max(0, afterUsage.input - beforeUsage.input),
5397
+ output: Math.max(0, afterUsage.output - beforeUsage.output)
5398
+ } : void 0;
5399
+ const costUsd = typeof beforeCost === "number" && typeof afterCost === "number" ? Math.max(0, afterCost - beforeCost) : void 0;
5400
+ await this.appendIterationEntry({
5401
+ source: action.source,
5402
+ task: action.task,
5403
+ status,
5404
+ note,
5405
+ tokens,
5406
+ costUsd
5407
+ });
5408
+ let iterationIndex = 0;
5409
+ try {
5410
+ const reloaded = await loadGoal(this.goalPath);
5411
+ iterationIndex = reloaded?.iterations ?? 0;
5412
+ } catch {
5413
+ }
5414
+ this.opts.onIteration?.({
5415
+ at: (this.opts.now?.() ?? /* @__PURE__ */ new Date()).toISOString(),
5416
+ iteration: iterationIndex,
5417
+ source: action.source,
5418
+ task: action.task,
5419
+ status,
5420
+ note,
5421
+ tokens,
5422
+ costUsd
5423
+ });
5424
+ if (status === "failure") {
5425
+ this.consecutiveFailures++;
5426
+ return false;
5427
+ }
5428
+ if (status === "aborted") {
5429
+ if (this.stopRequested) return false;
5430
+ this.consecutiveFailures++;
5431
+ return false;
5432
+ }
5433
+ this.iterationsSinceCompact++;
5434
+ await this.maybeCompact().catch((err) => {
5435
+ this.opts.onError?.(
5436
+ err instanceof Error ? err : new Error(String(err)),
5437
+ this.consecutiveFailures
5438
+ );
5439
+ });
5440
+ return true;
5441
+ }
5442
+ /**
5443
+ * Run compaction when either trigger fires:
5444
+ * - We've done >= compactEveryNIterations since the last compact.
5445
+ * - Current request tokens exceed aggressiveCompactRatio * maxContext.
5446
+ *
5447
+ * The second check uses *aggressive* mode to free more headroom; the
5448
+ * cadence check uses non-aggressive (cheaper).
5449
+ */
5450
+ async maybeCompact() {
5451
+ const compactor = this.opts.compactor;
5452
+ if (!compactor) return;
5453
+ const ctx = this.opts.agent.ctx;
5454
+ if (!ctx) return;
5455
+ const cadence = this.opts.compactEveryNIterations ?? 25;
5456
+ const threshold = this.opts.aggressiveCompactRatio ?? 0.85;
5457
+ const maxCtx = this.opts.maxContextTokens;
5458
+ let aggressive = false;
5459
+ let shouldRun = false;
5460
+ if (this.iterationsSinceCompact >= cadence) {
5461
+ shouldRun = true;
5462
+ }
5463
+ if (maxCtx && maxCtx > 0) {
5464
+ const used = ctx.tokenCounter?.currentRequestTokens?.();
5465
+ if (used) {
5466
+ const total = used.input + used.cacheRead;
5467
+ if (total / maxCtx >= threshold) {
5468
+ shouldRun = true;
5469
+ aggressive = true;
5470
+ }
5471
+ }
5472
+ }
5473
+ if (!shouldRun) return;
5474
+ const report = await compactor.compact(ctx, { aggressive });
5475
+ this.iterationsSinceCompact = 0;
5476
+ const saved = report.before - report.after;
5477
+ await this.appendIterationEntry({
5478
+ source: "manual",
5479
+ task: `compaction (${aggressive ? "aggressive" : "cadence"})`,
5480
+ status: "success",
5481
+ note: `saved ~${saved} tokens (${report.before}\u2192${report.after})`
5482
+ });
5483
+ }
5484
+ /**
5485
+ * Hybrid idea source.
5486
+ * 1. Pending todos on the agent's context.
5487
+ * 2. Dirty git working tree → propose a "review and finish this" task.
5488
+ * 3. Otherwise: brainstorm via the LLM against the goal.
5489
+ *
5490
+ * After failureBudget consecutive failures, force brainstorm so the
5491
+ * engine doesn't loop on the same broken todo or stuck git state.
5492
+ */
5493
+ async decide(goal) {
5494
+ const forceBrainstorm = this.consecutiveFailures >= (this.opts.failureBudget ?? 3);
5495
+ if (!forceBrainstorm) {
5496
+ const todo = this.pickPendingTodo();
5497
+ if (todo) {
5498
+ return {
5499
+ source: "todo",
5500
+ task: todo.content,
5501
+ directive: this.buildDirective(goal, "todo", todo.content)
5502
+ };
5503
+ }
5504
+ const gitTask = await this.pickGitTask();
5505
+ if (gitTask) {
5506
+ return {
5507
+ source: "git",
5508
+ task: gitTask,
5509
+ directive: this.buildDirective(goal, "git", gitTask)
5510
+ };
5511
+ }
5512
+ }
5513
+ const brainstormed = await this.brainstormTask(goal);
5514
+ if (!brainstormed) return null;
5515
+ return {
5516
+ source: "brainstorm",
5517
+ task: brainstormed,
5518
+ directive: this.buildDirective(goal, "brainstorm", brainstormed)
5519
+ };
5520
+ }
5521
+ pickPendingTodo() {
5522
+ const todos = this.opts.agent.ctx.todos;
5523
+ if (!Array.isArray(todos)) return null;
5524
+ return todos.find((t) => t.status === "pending") ?? null;
5525
+ }
5526
+ async pickGitTask() {
5527
+ let out;
5528
+ try {
5529
+ out = await (this.opts.gitStatusReader?.() ?? this.readGitStatus());
5530
+ } catch {
5531
+ return null;
5532
+ }
5533
+ const dirty = out.trim();
5534
+ if (!dirty) return null;
5535
+ const lines = dirty.split("\n").slice(0, 8);
5536
+ const preview = lines.join(", ");
5537
+ return `Inspect the dirty working tree and either finish the in-progress work or revert it. Files: ${preview}`;
5538
+ }
5539
+ async readGitStatus() {
5540
+ const { stdout } = await execFileP("git", ["status", "--porcelain"], {
5541
+ cwd: this.opts.projectRoot,
5542
+ timeout: 5e3
5543
+ });
5544
+ return stdout;
5545
+ }
5546
+ async brainstormTask(goal) {
5547
+ const lastFew = goal.journal.slice(-5).map((e) => ` - [${e.status}] ${e.task}`).join("\n");
5548
+ const directive = [
5549
+ "You are deciding the next action in an autonomous loop pursuing a long-running goal.",
5550
+ "",
5551
+ `Goal: ${goal.goal}`,
5552
+ "",
5553
+ lastFew ? `Recent iterations:
5554
+ ${lastFew}` : "No prior iterations yet.",
5555
+ "",
5556
+ "Output ONE concrete, immediately-actionable task that advances the goal.",
5557
+ "Constraints:",
5558
+ "- One sentence, imperative form, under 200 chars.",
5559
+ "- No preamble, no explanation, no markdown \u2014 just the task line.",
5560
+ "- If recent iterations show repeated failures on the same target, pivot.",
5561
+ "- If the goal appears fully accomplished, output exactly: DONE"
5562
+ ].join("\n");
5563
+ try {
5564
+ const ctrl = new AbortController();
5565
+ const timer = setTimeout(() => ctrl.abort(), 6e4);
5566
+ try {
5567
+ const result = await this.opts.agent.run(
5568
+ [{ type: "text", text: directive }],
5569
+ { signal: ctrl.signal, maxIterations: 1 }
5570
+ );
5571
+ if (result.status !== "done") return null;
5572
+ const text = (result.finalText ?? "").trim();
5573
+ if (!text || text === "DONE") return null;
5574
+ const firstLine = text.split("\n").find((l) => l.trim().length > 0)?.trim();
5575
+ if (!firstLine) return null;
5576
+ return firstLine.slice(0, 240);
5577
+ } finally {
5578
+ clearTimeout(timer);
5579
+ }
5580
+ } catch {
5581
+ return null;
5582
+ }
5583
+ }
5584
+ buildDirective(goal, source, task) {
5585
+ return [
5586
+ "[ETERNAL AUTONOMY \u2014 iteration directive]",
5587
+ "",
5588
+ `Goal: ${goal.goal}`,
5589
+ `Source: ${source}`,
5590
+ `Task: ${task}`,
5591
+ "",
5592
+ "Execute this task end-to-end using the tools available to you. Make the",
5593
+ "changes, run tests if relevant, and commit / push as appropriate. Do not",
5594
+ "ask for confirmation \u2014 YOLO mode is active. When the task is done, stop;",
5595
+ "the loop will pick the next action."
5596
+ ].join("\n");
5597
+ }
5598
+ async appendIterationEntry(entry) {
5599
+ const current = await loadGoal(this.goalPath);
5600
+ if (!current) {
5601
+ return;
5602
+ }
5603
+ const updated = appendJournal(current, entry);
5604
+ await saveGoal(this.goalPath, updated);
5605
+ }
5606
+ async appendFailure(task, note) {
5607
+ await this.appendIterationEntry({ source: "manual", task, status: "failure", note });
5608
+ }
5609
+ async persistEngineState(state) {
5610
+ const current = await loadGoal(this.goalPath);
5611
+ if (!current) return;
5612
+ if (current.engineState === state) return;
5613
+ await saveGoal(this.goalPath, { ...current, engineState: state });
5614
+ }
5615
+ };
5616
+ function sleep(ms) {
5617
+ return new Promise((resolve2) => setTimeout(resolve2, ms));
5618
+ }
5619
+
5620
+ // src/coordination/director.ts
5621
+ init_atomic_write();
5622
+
5160
5623
  // src/coordination/in-memory-transport.ts
5161
5624
  var InMemoryBridgeTransport = class {
5162
5625
  subs = /* @__PURE__ */ new Map();
@@ -6798,7 +7261,9 @@ var Director = class {
6798
7261
  }, opts.checkpointDebounceMs ?? 250) : null;
6799
7262
  this.fleetManager = opts.fleetManager;
6800
7263
  if (this.sharedScratchpadPath) {
6801
- void fsp.mkdir(this.sharedScratchpadPath, { recursive: true }).catch(() => void 0);
7264
+ void fsp.mkdir(this.sharedScratchpadPath, { recursive: true }).catch(
7265
+ (err) => this.logShutdownError("shared_scratchpad_mkdir", err)
7266
+ );
6802
7267
  }
6803
7268
  this.transport = new InMemoryBridgeTransport();
6804
7269
  this.bridge = new InMemoryAgentBridge(
@@ -6904,7 +7369,9 @@ var Director = class {
6904
7369
  if (this.manifestTimer) return;
6905
7370
  this.manifestTimer = setTimeout(() => {
6906
7371
  this.manifestTimer = null;
6907
- void this.writeManifest().catch(() => void 0);
7372
+ void this.writeManifest().catch(
7373
+ (err) => this.logShutdownError("manifest_write_debounced", err)
7374
+ );
6908
7375
  }, this.manifestDebounceMs);
6909
7376
  }
6910
7377
  /**
@@ -7095,7 +7562,7 @@ var Director = class {
7095
7562
  usage: this.usage.snapshot()
7096
7563
  };
7097
7564
  await fsp.mkdir(path3.dirname(this.manifestPath), { recursive: true });
7098
- await fsp.writeFile(this.manifestPath, JSON.stringify(manifest, null, 2), { mode: 384 });
7565
+ await atomicWrite(this.manifestPath, JSON.stringify(manifest, null, 2), { mode: 384 });
7099
7566
  return this.manifestPath;
7100
7567
  }
7101
7568
  /**
@@ -7624,9 +8091,11 @@ async function readSubagentPartial(opts, subagentId) {
7624
8091
  candidates.push(path3.join(opts.sessionsRoot, opts.directorRunId, `${subagentId}.jsonl`));
7625
8092
  } else {
7626
8093
  try {
7627
- const runDirs = await fsp.readdir(opts.sessionsRoot);
7628
- for (const r of runDirs) {
7629
- candidates.push(path3.join(opts.sessionsRoot, r, `${subagentId}.jsonl`));
8094
+ const entries = await fsp.readdir(opts.sessionsRoot, { withFileTypes: true });
8095
+ for (const entry of entries) {
8096
+ if (entry.isDirectory()) {
8097
+ candidates.push(path3.join(opts.sessionsRoot, entry.name, `${subagentId}.jsonl`));
8098
+ }
7630
8099
  }
7631
8100
  } catch {
7632
8101
  return void 0;
@@ -7824,6 +8293,9 @@ function makeDirectorSessionFactory(opts) {
7824
8293
 
7825
8294
  // src/coordination/null-fleet-bus.ts
7826
8295
  var NULL_FLEET_BUS = new FleetBus();
8296
+
8297
+ // src/models/models-registry.ts
8298
+ init_atomic_write();
7827
8299
  var DEFAULT_URL = "https://models.dev/api.json";
7828
8300
  var DEFAULT_TTL_SECONDS = 24 * 3600;
7829
8301
  var FAMILY_BY_NPM = {
@@ -7992,6 +8464,9 @@ var DefaultModelsRegistry = class {
7992
8464
  }
7993
8465
  };
7994
8466
 
8467
+ // src/models/mode-store.ts
8468
+ init_atomic_write();
8469
+
7995
8470
  // src/types/mode.ts
7996
8471
  var DEFAULT_MODES = [
7997
8472
  {
@@ -8292,10 +8767,9 @@ var DefaultModeStore = class {
8292
8767
  try {
8293
8768
  await fsp.mkdir(this.configDir, { recursive: true });
8294
8769
  const configPath = path3.join(this.configDir, "mode.json");
8295
- await fsp.writeFile(
8770
+ await atomicWrite(
8296
8771
  configPath,
8297
- JSON.stringify({ activeMode: this.activeModeId }, null, 2),
8298
- "utf8"
8772
+ JSON.stringify({ activeMode: this.activeModeId }, null, 2)
8299
8773
  );
8300
8774
  } catch {
8301
8775
  }
@@ -9219,6 +9693,9 @@ var SpecDrivenDev = class {
9219
9693
  }));
9220
9694
  }
9221
9695
  };
9696
+
9697
+ // src/sdd/spec-store.ts
9698
+ init_atomic_write();
9222
9699
  var SpecStore = class {
9223
9700
  baseDir;
9224
9701
  indexPath;
@@ -9328,6 +9805,9 @@ var SpecStore = class {
9328
9805
  await atomicWrite(this.indexPath, JSON.stringify(index, null, 2), { mode: 384 });
9329
9806
  }
9330
9807
  };
9808
+
9809
+ // src/sdd/task-graph-store.ts
9810
+ init_atomic_write();
9331
9811
  function graphToJSON(graph) {
9332
9812
  const serialisable = {
9333
9813
  ...graph,
@@ -9629,10 +10109,11 @@ var AISpecBuilder = class {
9629
10109
  async saveSession() {
9630
10110
  if (!this.sessionPath) return;
9631
10111
  try {
9632
- const fsp13 = await import('fs/promises');
9633
- const path17 = await import('path');
9634
- await fsp13.mkdir(path17.dirname(this.sessionPath), { recursive: true });
9635
- await fsp13.writeFile(this.sessionPath, JSON.stringify(this.session, null, 2), "utf8");
10112
+ const fsp14 = await import('fs/promises');
10113
+ const path18 = await import('path');
10114
+ const { atomicWrite: atomicWrite2 } = await Promise.resolve().then(() => (init_atomic_write(), atomic_write_exports));
10115
+ await fsp14.mkdir(path18.dirname(this.sessionPath), { recursive: true });
10116
+ await atomicWrite2(this.sessionPath, JSON.stringify(this.session, null, 2));
9636
10117
  } catch {
9637
10118
  }
9638
10119
  }
@@ -9640,8 +10121,8 @@ var AISpecBuilder = class {
9640
10121
  async loadSession() {
9641
10122
  if (!this.sessionPath) return false;
9642
10123
  try {
9643
- const fsp13 = await import('fs/promises');
9644
- const raw = await fsp13.readFile(this.sessionPath, "utf8");
10124
+ const fsp14 = await import('fs/promises');
10125
+ const raw = await fsp14.readFile(this.sessionPath, "utf8");
9645
10126
  const loaded = JSON.parse(raw);
9646
10127
  if (loaded?.id && loaded?.phase && loaded?.title) {
9647
10128
  this.session = loaded;
@@ -9655,14 +10136,21 @@ var AISpecBuilder = class {
9655
10136
  async deleteSession() {
9656
10137
  if (!this.sessionPath) return;
9657
10138
  try {
9658
- const fsp13 = await import('fs/promises');
9659
- await fsp13.unlink(this.sessionPath);
10139
+ const fsp14 = await import('fs/promises');
10140
+ await fsp14.unlink(this.sessionPath);
9660
10141
  } catch {
9661
10142
  }
9662
10143
  }
9663
- /** Auto-save helper — calls saveSession() but never throws. */
10144
+ /** Auto-save helper — calls saveSession() but never throws.
10145
+ * Failures are surfaced via process.emitWarning so a persistent
10146
+ * ENOSPC / EACCES doesn't silently strand session edits in memory. */
9664
10147
  autoSave() {
9665
- this.saveSession().catch(() => {
10148
+ this.saveSession().catch((err) => {
10149
+ const detail = err instanceof Error ? err.message : String(err);
10150
+ process.emitWarning(
10151
+ `SpecBuilder autoSave failed: ${detail}`,
10152
+ "SpecBuilderWarning"
10153
+ );
9666
10154
  });
9667
10155
  }
9668
10156
  // ── Session Lifecycle ─────────────────────────────────────────────────────
@@ -10334,15 +10822,15 @@ function computeCriticalPath(graph, topoOrder, blockedByMap) {
10334
10822
  maxId = id;
10335
10823
  }
10336
10824
  }
10337
- const path17 = [];
10825
+ const path18 = [];
10338
10826
  let current = maxId;
10339
10827
  const visited = /* @__PURE__ */ new Set();
10340
10828
  while (current && !visited.has(current)) {
10341
10829
  visited.add(current);
10342
- path17.unshift(current);
10830
+ path18.unshift(current);
10343
10831
  current = prev.get(current) ?? null;
10344
10832
  }
10345
- return path17;
10833
+ return path18;
10346
10834
  }
10347
10835
  function computeParallelGroups(graph, blockedByMap) {
10348
10836
  const groups = [];
@@ -11052,7 +11540,7 @@ async function startMetricsServer(opts) {
11052
11540
  const tls = opts.tls;
11053
11541
  const useHttps = !!(tls?.cert && tls?.key);
11054
11542
  const host = opts.host ?? "127.0.0.1";
11055
- const path17 = opts.path ?? "/metrics";
11543
+ const path18 = opts.path ?? "/metrics";
11056
11544
  const healthPath = opts.healthPath ?? "/healthz";
11057
11545
  const healthRegistry = opts.healthRegistry;
11058
11546
  const listener = (req, res) => {
@@ -11062,7 +11550,7 @@ async function startMetricsServer(opts) {
11062
11550
  return;
11063
11551
  }
11064
11552
  const url = req.url.split("?")[0];
11065
- if (url === path17) {
11553
+ if (url === path18) {
11066
11554
  let body;
11067
11555
  try {
11068
11556
  body = renderPrometheus(opts.sink.snapshot());
@@ -11126,7 +11614,7 @@ async function startMetricsServer(opts) {
11126
11614
  const protocol = useHttps ? "https" : "http";
11127
11615
  return {
11128
11616
  port: boundPort,
11129
- url: `${protocol}://${host}:${boundPort}${path17}`,
11617
+ url: `${protocol}://${host}:${boundPort}${path18}`,
11130
11618
  close: () => new Promise((resolve2, reject) => {
11131
11619
  server.close((err) => err ? reject(err) : resolve2());
11132
11620
  })
@@ -11743,6 +12231,6 @@ var allServers = () => ({
11743
12231
  "minimax-vision": { ...miniMaxVisionServer(), enabled: false }
11744
12232
  });
11745
12233
 
11746
- export { AISpecBuilder, ALL_FLEET_AGENTS, AUDIT_LOG_AGENT, AutoApprovePermissionPolicy, AutoCompactionMiddleware, AutoExecutor, AutonomousRunner, BUG_HUNTER_AGENT, BudgetExceededError, ConfigMigrationError, DEFAULT_CONFIG_MIGRATIONS, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_SUBAGENT_BASELINE, DefaultAttachmentStore, DefaultConfigLoader, DefaultConfigStore, DefaultErrorHandler, DefaultHealthRegistry, DefaultLogger, DefaultMemoryStore, DefaultModeStore, DefaultModelsRegistry, DefaultMultiAgentCoordinator, DefaultPermissionPolicy, DefaultProviderRunner, DefaultRetryPolicy, DefaultSecretScrubber, DefaultSecretVault, DefaultSessionReader, DefaultSessionStore, DefaultSkillLoader, DefaultTaskStore, Director, DirectorStateCheckpoint, DoneConditionChecker, FLEET_ROSTER, FLEET_ROSTER_BUDGETS, FleetBus, FleetSpawnBudgetError, FleetUsageAggregator, HybridCompactor, InMemoryAgentBridge, InMemoryBridgeTransport, InMemoryMetricsSink, IntelligentCompactor, LLMSelector, NULL_FLEET_BUS, NoopMetricsSink, NoopTracer, OTelTracer, PROMETHEUS_CONTENT_TYPE, QueueStore, REFACTOR_PLANNER_AGENT, RecoveryLock, SECURITY_SCANNER_AGENT, SPEC_TEMPLATES, SelectiveCompactor, SessionAnalyzer, SpecDrivenDev, SpecParser, SpecStore, SpecVersioning, SubagentBudget, TaskFlow, TaskGenerator, TaskGraphStore, TaskTracker, ToolExecutor, addPlanItem, allServers, analyzeCriticalPath, applyRosterBudget, attachPlanCheckpoint, attachTodosCheckpoint, awsServer, blockServer, braveSearchServer, buildOtlpMetricsRequest, buildOtlpTracesRequest, classifyFamily, clearPlan, composeDirectorPrompt, composeSubagentPrompt, context7Server, contextManagerTool, createAutoExecutor, createContextManagerTool, createDelegateTool, createMessage, decryptConfigSecrets2 as decryptConfigSecrets, deriveTodosFromPlanItem, emptyPlan, encryptConfigSecrets, everArtServer, filesystemServer, formatPlan, formatPlanTemplates, getPlanTemplate, getTemplate, githubServer, googleMapsServer, listPlanTemplates, listTemplates, loadDirectorState, loadPlan, loadProjectModes, loadTodosCheckpoint, loadUserModes, makeAgentSubagentRunner, makeDirectorSessionFactory, migratePlaintextSecrets, miniMaxVisionServer, removePlanItem, renderProgress, renderPrometheus, renderSpecAnalysis, renderTaskGraph, renderTaskList, rewriteConfigEncrypted, rosterSummaryFromConfigs, runConfigMigrations, savePlan, saveTodosCheckpoint, sentinelServer, setPlanItemStatus, slackServer, startMetricsServer, startOtlpMetricsExporter, startOtlpTraceExporter, templateToMarkdown, wireMetricsToEvents, zaiVisionServer };
12234
+ export { AISpecBuilder, ALL_FLEET_AGENTS, AUDIT_LOG_AGENT, AutoApprovePermissionPolicy, AutoCompactionMiddleware, AutoExecutor, AutonomousRunner, BUG_HUNTER_AGENT, BudgetExceededError, ConfigMigrationError, DEFAULT_CONFIG_MIGRATIONS, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_SUBAGENT_BASELINE, DefaultAttachmentStore, DefaultConfigLoader, DefaultConfigStore, DefaultErrorHandler, DefaultHealthRegistry, DefaultLogger, DefaultMemoryStore, DefaultModeStore, DefaultModelsRegistry, DefaultMultiAgentCoordinator, DefaultPermissionPolicy, DefaultProviderRunner, DefaultRetryPolicy, DefaultSecretScrubber, DefaultSecretVault, DefaultSessionReader, DefaultSessionStore, DefaultSkillLoader, DefaultTaskStore, Director, DirectorStateCheckpoint, DoneConditionChecker, EternalAutonomyEngine, FLEET_ROSTER, FLEET_ROSTER_BUDGETS, FleetBus, FleetSpawnBudgetError, FleetUsageAggregator, HybridCompactor, InMemoryAgentBridge, InMemoryBridgeTransport, InMemoryMetricsSink, IntelligentCompactor, LLMSelector, NULL_FLEET_BUS, NoopMetricsSink, NoopTracer, OTelTracer, PROMETHEUS_CONTENT_TYPE, QueueStore, REFACTOR_PLANNER_AGENT, RecoveryLock, SECURITY_SCANNER_AGENT, SPEC_TEMPLATES, SelectiveCompactor, SessionAnalyzer, SpecDrivenDev, SpecParser, SpecStore, SpecVersioning, SubagentBudget, TaskFlow, TaskGenerator, TaskGraphStore, TaskTracker, ToolExecutor, addPlanItem, allServers, analyzeCriticalPath, applyRosterBudget, attachPlanCheckpoint, attachTodosCheckpoint, awsServer, blockServer, braveSearchServer, buildOtlpMetricsRequest, buildOtlpTracesRequest, classifyFamily, clearPlan, composeDirectorPrompt, composeSubagentPrompt, context7Server, contextManagerTool, createAutoExecutor, createContextManagerTool, createDelegateTool, createMessage, decryptConfigSecrets2 as decryptConfigSecrets, deriveTodosFromPlanItem, emptyPlan, encryptConfigSecrets, everArtServer, filesystemServer, formatPlan, formatPlanTemplates, getPlanTemplate, getTemplate, githubServer, googleMapsServer, listPlanTemplates, listTemplates, loadDirectorState, loadPlan, loadProjectModes, loadTodosCheckpoint, loadUserModes, makeAgentSubagentRunner, makeDirectorSessionFactory, migratePlaintextSecrets, miniMaxVisionServer, removePlanItem, renderProgress, renderPrometheus, renderSpecAnalysis, renderTaskGraph, renderTaskList, rewriteConfigEncrypted, rosterSummaryFromConfigs, runConfigMigrations, savePlan, saveTodosCheckpoint, sentinelServer, setPlanItemStatus, slackServer, startMetricsServer, startOtlpMetricsExporter, startOtlpTraceExporter, templateToMarkdown, wireMetricsToEvents, zaiVisionServer };
11747
12235
  //# sourceMappingURL=index.js.map
11748
12236
  //# sourceMappingURL=index.js.map