@wrongstack/core 0.119.1 → 0.148.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 (65) hide show
  1. package/dist/{agent-bridge-PRAbEX-9.d.ts → agent-bridge-r9y6gdn4.d.ts} +1 -1
  2. package/dist/{agent-subagent-runner-DXWImnNV.d.ts → agent-subagent-runner-1GeQE_L0.d.ts} +7 -7
  3. package/dist/{brain-NZZqL8sn.d.ts → brain-Cp_3GIS2.d.ts} +14 -3
  4. package/dist/{compactor-C3stu664.d.ts → compactor-BueGt7LG.d.ts} +9 -1
  5. package/dist/{config-DZV9VK9n.d.ts → config-BaVThgnT.d.ts} +1 -1
  6. package/dist/{context-hvXINa6a.d.ts → context-C7G_MtLV.d.ts} +7 -0
  7. package/dist/coordination/index.d.ts +12 -12
  8. package/dist/coordination/index.js +35 -21
  9. package/dist/coordination/index.js.map +1 -1
  10. package/dist/defaults/index.d.ts +24 -24
  11. package/dist/defaults/index.js +869 -788
  12. package/dist/defaults/index.js.map +1 -1
  13. package/dist/execution/index.d.ts +14 -14
  14. package/dist/execution/index.js +454 -321
  15. package/dist/execution/index.js.map +1 -1
  16. package/dist/extension/index.d.ts +6 -6
  17. package/dist/{goal-preamble-COpt55W8.d.ts → goal-preamble-CYJLg0wk.d.ts} +55 -17
  18. package/dist/{index-Cj3le7TI.d.ts → index-BZdezm3g.d.ts} +8 -8
  19. package/dist/{index-4VVHuTZF.d.ts → index-CPweVoFM.d.ts} +5 -5
  20. package/dist/index.d.ts +48 -48
  21. package/dist/index.js +612 -513
  22. package/dist/index.js.map +1 -1
  23. package/dist/infrastructure/index.d.ts +6 -6
  24. package/dist/infrastructure/index.js +64 -19
  25. package/dist/infrastructure/index.js.map +1 -1
  26. package/dist/kernel/index.d.ts +9 -9
  27. package/dist/kernel/index.js.map +1 -1
  28. package/dist/{llm-selector-Bmx4PsVM.d.ts → llm-selector-CP72f1lC.d.ts} +2 -2
  29. package/dist/{mcp-servers-CofNHOqn.d.ts → mcp-servers-Bl5LTvQg.d.ts} +3 -3
  30. package/dist/models/index.d.ts +5 -5
  31. package/dist/models/index.js +53 -20
  32. package/dist/models/index.js.map +1 -1
  33. package/dist/{models-registry-BzlsjKcy.d.ts → models-registry-D90K9UnM.d.ts} +1 -1
  34. package/dist/{multi-agent-coordinator-CmDmUgq2.d.ts → multi-agent-coordinator-QWEzJDlm.d.ts} +1 -1
  35. package/dist/{null-fleet-bus-CyH2YqP4.d.ts → null-fleet-bus-BUyfqh23.d.ts} +13 -10
  36. package/dist/observability/index.d.ts +2 -2
  37. package/dist/{parallel-eternal-engine-uxVm4y4V.d.ts → parallel-eternal-engine-C75QuhAI.d.ts} +33 -11
  38. package/dist/{path-resolver-gfoGxpdd.d.ts → path-resolver-DRjQBkoO.d.ts} +3 -3
  39. package/dist/{permission-DhLrgA30.d.ts → permission-B7nKnEvQ.d.ts} +1 -1
  40. package/dist/{permission-policy-DGOvne7i.d.ts → permission-policy-8-6zBmfA.d.ts} +2 -13
  41. package/dist/{pipeline-CqF7uju2.d.ts → pipeline-BG7UgbDc.d.ts} +2 -2
  42. package/dist/{plan-templates-DoKhzenv.d.ts → plan-templates-CkKNPU3I.d.ts} +5 -5
  43. package/dist/{provider-runner-BPlI5sPZ.d.ts → provider-runner-BNpuIyOL.d.ts} +3 -3
  44. package/dist/{retry-policy-B4Q-FZgE.d.ts → retry-policy-rutAfVeR.d.ts} +1 -1
  45. package/dist/sdd/index.d.ts +8 -8
  46. package/dist/sdd/index.js +10 -1
  47. package/dist/sdd/index.js.map +1 -1
  48. package/dist/{secret-vault-B7GnL6o9.d.ts → secret-vault-BTcC_T5v.d.ts} +3 -2
  49. package/dist/security/index.d.ts +5 -7
  50. package/dist/security/index.js +5 -36
  51. package/dist/security/index.js.map +1 -1
  52. package/dist/{selector-BakeMnWR.d.ts → selector-4vDFZKt3.d.ts} +1 -1
  53. package/dist/{session-event-bridge-DE5Oekwx.d.ts → session-event-bridge-DWlvglC2.d.ts} +2 -2
  54. package/dist/{session-reader-DFC81-4p.d.ts → session-reader-BAtCxdaw.d.ts} +1 -1
  55. package/dist/storage/index.d.ts +13 -13
  56. package/dist/storage/index.js +100 -103
  57. package/dist/storage/index.js.map +1 -1
  58. package/dist/types/index.d.ts +18 -18
  59. package/dist/types/index.js +276 -103
  60. package/dist/types/index.js.map +1 -1
  61. package/dist/utils/index.d.ts +37 -13
  62. package/dist/utils/index.js +63 -35
  63. package/dist/utils/index.js.map +1 -1
  64. package/package.json +2 -2
  65. package/skills/tech-stack/SKILL.md +253 -97
@@ -1,4 +1,4 @@
1
- import { M as Message } from './context-hvXINa6a.js';
1
+ import { M as Message } from './context-C7G_MtLV.js';
2
2
 
3
3
  /**
4
4
  * Result of LLM-driven message importance analysis.
@@ -1,4 +1,4 @@
1
- import { S as SessionEvent, a as SessionWriter } from './context-hvXINa6a.js';
1
+ import { S as SessionEvent, a as SessionWriter } from './context-C7G_MtLV.js';
2
2
 
3
3
  type AuditLevel = 'minimal' | 'standard' | 'full';
4
4
  /**
@@ -66,7 +66,7 @@ declare function createSessionEventBridge(writer: SessionWriter | undefined | nu
66
66
  declare function resolveAuditLevel(cfg?: {
67
67
  session?: {
68
68
  auditLevel?: AuditLevel | undefined;
69
- };
69
+ } | undefined;
70
70
  } | null): AuditLevel;
71
71
  /**
72
72
  * Fully resolves the session logging configuration with sensible defaults.
@@ -1,4 +1,4 @@
1
- import { g as ContentBlock, S as SessionEvent, h as SessionMetadata, i as SessionStore } from './context-hvXINa6a.js';
1
+ import { g as ContentBlock, S as SessionEvent, h as SessionMetadata, i as SessionStore } from './context-C7G_MtLV.js';
2
2
 
3
3
  type AttachmentKind = 'text' | 'image' | 'file';
4
4
  interface AttachmentMeta {
@@ -1,20 +1,20 @@
1
- import { M as MemoryBackend, j as FileMemoryBackendOptions } from '../plan-templates-DoKhzenv.js';
2
- export { A as AbandonedSession, a as AttachmentStoreOptions, C as ConfigLoaderOptions, b as ConfigMigration, c as ConfigMigrationError, d as ConfigSource, D as DEFAULT_CONFIG_MIGRATIONS, e as DefaultAttachmentStore, f as DefaultConfigLoader, g as DefaultConfigStore, h as DefaultMemoryStore, i as DefaultSessionStore, F as FileMemoryBackend, k as MemoryStoreOptions, l as MigrationContext, m as MigrationResult, P as PersistedQueueItem, n as PlanFile, o as PlanItem, p as PlanTemplate, Q as QueueStore, R as RecoveryLock, q as RecoveryLockOptions, S as SessionAnalyzer, r as SessionStoreOptions, T as TodosCheckpointFile, s as addPlanItem, t as attachPlanCheckpoint, u as attachTodosCheckpoint, v as clearPlan, w as deriveTodosFromPlanItem, x as emptyPlan, y as formatPlan, z as formatPlanTemplates, B as getPlanTemplate, E as listPlanTemplates, G as loadPlan, H as loadTodosCheckpoint, I as parseEntries, J as removePlanItem, K as runConfigMigrations, L as savePlan, N as saveTodosCheckpoint, O as setPlanItemStatus } from '../plan-templates-DoKhzenv.js';
3
- import { M as MemoryScope, k as MemoryEntry, l as MemoryStore } from '../brain-NZZqL8sn.js';
4
- import { l as AgentExtension, j as AfterRunHook } from '../index-4VVHuTZF.js';
5
- import { P as Provider, R as Request, b as Response, S as SessionEvent } from '../context-hvXINa6a.js';
6
- export { D as DefaultSessionReader, f as DefaultSessionReaderOptions, S as SessionReader } from '../session-reader-DFC81-4p.js';
1
+ import { M as MemoryBackend, j as FileMemoryBackendOptions } from '../plan-templates-CkKNPU3I.js';
2
+ export { A as AbandonedSession, a as AttachmentStoreOptions, C as ConfigLoaderOptions, b as ConfigMigration, c as ConfigMigrationError, d as ConfigSource, D as DEFAULT_CONFIG_MIGRATIONS, e as DefaultAttachmentStore, f as DefaultConfigLoader, g as DefaultConfigStore, h as DefaultMemoryStore, i as DefaultSessionStore, F as FileMemoryBackend, k as MemoryStoreOptions, l as MigrationContext, m as MigrationResult, P as PersistedQueueItem, n as PlanFile, o as PlanItem, p as PlanTemplate, Q as QueueStore, R as RecoveryLock, q as RecoveryLockOptions, S as SessionAnalyzer, r as SessionStoreOptions, T as TodosCheckpointFile, s as addPlanItem, t as attachPlanCheckpoint, u as attachTodosCheckpoint, v as clearPlan, w as deriveTodosFromPlanItem, x as emptyPlan, y as formatPlan, z as formatPlanTemplates, B as getPlanTemplate, E as listPlanTemplates, G as loadPlan, H as loadTodosCheckpoint, I as parseEntries, J as removePlanItem, K as runConfigMigrations, L as savePlan, N as saveTodosCheckpoint, O as setPlanItemStatus } from '../plan-templates-CkKNPU3I.js';
3
+ import { M as MemoryScope, k as MemoryEntry, l as MemoryStore } from '../brain-Cp_3GIS2.js';
4
+ import { l as AgentExtension, j as AfterRunHook } from '../index-CPweVoFM.js';
5
+ import { P as Provider, R as Request, b as Response, S as SessionEvent } from '../context-C7G_MtLV.js';
6
+ export { D as DefaultSessionReader, f as DefaultSessionReaderOptions, S as SessionReader } from '../session-reader-BAtCxdaw.js';
7
7
  import { S as SessionRewinder, C as CheckpointInfo, a as RewindResultExtended } from '../session-rewinder-C9HnMkhP.js';
8
8
  import { T as TaskItem } from '../task-format-vGOIftmK.js';
9
9
  export { a as DirectorStateCheckpoint, D as DirectorStateSnapshot, b as DirectorSubagentState, c as DirectorTaskState, l as loadDirectorState } from '../director-state-BfeCUbmk.js';
10
10
  export { G as GoalFile, J as JournalEntry, M as MAX_JOURNAL_ENTRIES, a as MAX_PROGRESS_HISTORY, P as ProgressSnapshot, b as appendJournal, e as emptyGoal, f as formatGoal, g as goalFilePath, l as loadGoal, p as parseProgressFromText, r as recordProgress, s as saveGoal, c as setProgress, d as summarizeUsage } from '../goal-store-CV9Yz2X_.js';
11
11
  import { W as WstackPaths } from '../wstack-paths-DD50Omgn.js';
12
- import { B as SyncCategory, k as SyncConfig } from '../config-DZV9VK9n.js';
13
- export { A as AuditLevel, C as CORE_RECONSTRUCT_EVENTS, a as STANDARD_AUDIT_EVENTS, S as SessionEventBridge, b as SessionEventBridgeOptions, c as SessionSamplingOptions, T as ToolProgressSamplingOptions, d as createSessionEventBridge, r as resolveAuditLevel, e as resolveSessionLoggingConfig } from '../session-event-bridge-DE5Oekwx.js';
14
- import '../permission-DhLrgA30.js';
12
+ import { B as SyncCategory, k as SyncConfig } from '../config-BaVThgnT.js';
13
+ export { A as AuditLevel, C as CORE_RECONSTRUCT_EVENTS, a as STANDARD_AUDIT_EVENTS, S as SessionEventBridge, b as SessionEventBridgeOptions, c as SessionSamplingOptions, T as ToolProgressSamplingOptions, d as createSessionEventBridge, r as resolveAuditLevel, e as resolveSessionLoggingConfig } from '../session-event-bridge-DWlvglC2.js';
14
+ import '../permission-B7nKnEvQ.js';
15
15
  import '../secret-vault-DoISxaKO.js';
16
16
  import '../logger-B63L5bTg.js';
17
- import '../pipeline-CqF7uju2.js';
17
+ import '../pipeline-BG7UgbDc.js';
18
18
  import '../observability-D-HZN_mF.js';
19
19
  import '../task-graph-u1q9Jkyk.js';
20
20
 
@@ -24,9 +24,9 @@ interface GraphNode {
24
24
  firstSeen: string;
25
25
  count: number;
26
26
  /** Extracted metadata for fast lookup. */
27
- type?: MemoryEntry['type'];
28
- tags?: string[];
29
- priority?: MemoryEntry['priority'];
27
+ type?: MemoryEntry['type'] | undefined;
28
+ tags?: string[] | undefined;
29
+ priority?: MemoryEntry['priority'] | undefined;
30
30
  }
31
31
  interface GraphEdge {
32
32
  from: string;
@@ -1,6 +1,7 @@
1
1
  import { randomBytes, randomUUID, createHash } from 'crypto';
2
2
  import * as fsp from 'fs/promises';
3
- import * as path12 from 'path';
3
+ import * as path13 from 'path';
4
+ import 'fs';
4
5
  import * as os from 'os';
5
6
  import { hostname } from 'os';
6
7
 
@@ -12,9 +13,9 @@ function expectDefined(value, label) {
12
13
  return value;
13
14
  }
14
15
  async function atomicWrite(targetPath, content, opts = {}) {
15
- const dir = path12.dirname(targetPath);
16
+ const dir = path13.dirname(targetPath);
16
17
  await fsp.mkdir(dir, { recursive: true });
17
- const tmp = path12.join(dir, `.${path12.basename(targetPath)}.${randomBytes(6).toString("hex")}.tmp`);
18
+ const tmp = path13.join(dir, `.${path13.basename(targetPath)}.${randomBytes(6).toString("hex")}.tmp`);
18
19
  try {
19
20
  if (typeof content === "string") {
20
21
  await fsp.writeFile(tmp, content, { flag: "wx", encoding: opts.encoding ?? "utf8" });
@@ -53,9 +54,9 @@ async function ensureDir(dir) {
53
54
  await fsp.mkdir(dir, { recursive: true });
54
55
  }
55
56
  async function withFileLock(targetPath, fn, opts = {}) {
56
- const dir = path12.dirname(targetPath);
57
+ const dir = path13.dirname(targetPath);
57
58
  await fsp.mkdir(dir, { recursive: true });
58
- const lockPath = path12.join(dir, `.${path12.basename(targetPath)}.lock`);
59
+ const lockPath = path13.join(dir, `.${path13.basename(targetPath)}.lock`);
59
60
  const timeoutMs = opts.timeoutMs ?? 5e3;
60
61
  const staleMs = opts.staleMs ?? 3e4;
61
62
  const started = Date.now();
@@ -233,11 +234,11 @@ var DefaultSessionStore = class _DefaultSessionStore {
233
234
  }
234
235
  /** Absolute path to the session index file. */
235
236
  get indexFile() {
236
- return path12.join(this.dir, "_index.jsonl");
237
+ return path13.join(this.dir, "_index.jsonl");
237
238
  }
238
239
  /** Join session ID to its absolute path within the store directory. */
239
240
  sessionPath(id, ext) {
240
- return path12.join(this.dir, `${id}${ext}`);
241
+ return path13.join(this.dir, `${id}${ext}`);
241
242
  }
242
243
  /**
243
244
  * Ensure the directory implied by the session ID exists. When the ID
@@ -245,7 +246,7 @@ var DefaultSessionStore = class _DefaultSessionStore {
245
246
  * subdirectory so sessions group naturally by day.
246
247
  */
247
248
  async ensureShardDir(id) {
248
- const dirPath = path12.dirname(path12.join(this.dir, id));
249
+ const dirPath = path13.dirname(path13.join(this.dir, id));
249
250
  await ensureDir(dirPath);
250
251
  return dirPath;
251
252
  }
@@ -253,7 +254,7 @@ var DefaultSessionStore = class _DefaultSessionStore {
253
254
  const startedAt = (/* @__PURE__ */ new Date()).toISOString();
254
255
  const id = meta.id && meta.id.length > 0 ? meta.id : generateSessionId(startedAt, meta.model ?? meta.provider);
255
256
  const shardDir = await this.ensureShardDir(id);
256
- const file = path12.join(shardDir, `${path12.basename(id)}.jsonl`);
257
+ const file = path13.join(shardDir, `${path13.basename(id)}.jsonl`);
257
258
  let handle;
258
259
  try {
259
260
  handle = await fsp.open(file, "a", 384);
@@ -271,8 +272,7 @@ var DefaultSessionStore = class _DefaultSessionStore {
271
272
  onClose: (s) => this.appendToIndex(s)
272
273
  });
273
274
  } catch (err) {
274
- await handle.close().catch(() => {
275
- });
275
+ await handle.close().catch((e) => console.warn(`[session-store] handle.close() failed: ${e}`));
276
276
  throw err;
277
277
  }
278
278
  }
@@ -303,8 +303,7 @@ var DefaultSessionStore = class _DefaultSessionStore {
303
303
  );
304
304
  return { writer, data };
305
305
  } catch (err) {
306
- await handle.close().catch(() => {
307
- });
306
+ await handle.close().catch((e) => console.warn(`[session-store] handle.close() failed: ${e}`));
308
307
  throw err;
309
308
  }
310
309
  }
@@ -461,7 +460,7 @@ var DefaultSessionStore = class _DefaultSessionStore {
461
460
  continue;
462
461
  if (entry.isDirectory()) {
463
462
  const childPrefix = depth === 0 ? entry.name : `${prefix}/${entry.name}`;
464
- ids.push(...await this.collectSessionIds(path12.join(dir, entry.name), childPrefix, depth + 1));
463
+ ids.push(...await this.collectSessionIds(path13.join(dir, entry.name), childPrefix, depth + 1));
465
464
  } else if (entry.isFile() && entry.name.endsWith(".jsonl")) {
466
465
  if (entry.name === "_index.jsonl") continue;
467
466
  const base = entry.name.replace(/\.jsonl$/, "");
@@ -493,15 +492,15 @@ var DefaultSessionStore = class _DefaultSessionStore {
493
492
  * sidecars, and the session directory (fleet.json, shared/, subagents/).
494
493
  */
495
494
  async deleteSession(id) {
496
- await fsp.unlink(this.sessionPath(id, ".jsonl")).catch(() => void 0);
497
- await fsp.unlink(this.sessionPath(id, ".summary.json")).catch(() => void 0);
498
- const shardDir = path12.dirname(path12.join(this.dir, id));
499
- const base = path12.basename(id);
495
+ await fsp.unlink(this.sessionPath(id, ".jsonl")).catch((err) => console.warn(`[session-store] delete .jsonl failed: ${err}`));
496
+ await fsp.unlink(this.sessionPath(id, ".summary.json")).catch((err) => console.warn(`[session-store] delete .summary.json failed: ${err}`));
497
+ const shardDir = path13.dirname(path13.join(this.dir, id));
498
+ const base = path13.basename(id);
500
499
  for (const ext of [".plan.json", ".todos.json"]) {
501
- await fsp.unlink(path12.join(shardDir, `${base}${ext}`)).catch(() => void 0);
500
+ await fsp.unlink(path13.join(shardDir, `${base}${ext}`)).catch((err) => console.warn(`[session-store] delete ${ext} failed: ${err}`));
502
501
  }
503
- const sessDir = path12.join(shardDir, base);
504
- await fsp.rm(sessDir, { recursive: true, force: true }).catch(() => void 0);
502
+ const sessDir = path13.join(shardDir, base);
503
+ await fsp.rm(sessDir, { recursive: true, force: true }).catch((err) => console.warn(`[session-store] delete session dir failed: ${err}`));
505
504
  await this.writeTombstone(id);
506
505
  }
507
506
  async delete(id) {
@@ -512,7 +511,7 @@ var DefaultSessionStore = class _DefaultSessionStore {
512
511
  let deleted = 0;
513
512
  let activeSessionId = null;
514
513
  try {
515
- const raw = await fsp.readFile(path12.join(this.dir, "active.json"), "utf8");
514
+ const raw = await fsp.readFile(path13.join(this.dir, "active.json"), "utf8");
516
515
  const active = JSON.parse(raw);
517
516
  activeSessionId = active.sessionId ?? null;
518
517
  } catch {
@@ -520,11 +519,11 @@ var DefaultSessionStore = class _DefaultSessionStore {
520
519
  const entries = await fsp.readdir(this.dir, { withFileTypes: true }).catch(() => []);
521
520
  for (const entry of entries) {
522
521
  if (!entry.isDirectory()) continue;
523
- const dateDir = path12.join(this.dir, entry.name);
522
+ const dateDir = path13.join(this.dir, entry.name);
524
523
  const files = await fsp.readdir(dateDir, { withFileTypes: true }).catch(() => []);
525
524
  for (const file of files) {
526
525
  if (!file.isFile() || !file.name.endsWith(".jsonl")) continue;
527
- const jsonlPath = path12.join(dateDir, file.name);
526
+ const jsonlPath = path13.join(dateDir, file.name);
528
527
  try {
529
528
  const stat5 = await fsp.stat(jsonlPath);
530
529
  if (stat5.mtimeMs >= cutoff) continue;
@@ -542,7 +541,7 @@ var DefaultSessionStore = class _DefaultSessionStore {
542
541
  }
543
542
  for (const entry of entries) {
544
543
  if (!entry.isDirectory()) continue;
545
- const dateDir = path12.join(this.dir, entry.name);
544
+ const dateDir = path13.join(this.dir, entry.name);
546
545
  try {
547
546
  const remaining = await fsp.readdir(dateDir);
548
547
  if (remaining.length === 0) {
@@ -578,7 +577,7 @@ var DefaultSessionStore = class _DefaultSessionStore {
578
577
  let toolErrorCount = 0;
579
578
  let fileChangeCount = 0;
580
579
  const toolBreakdown = {};
581
- let outcome = void 0;
580
+ let outcome;
582
581
  const lastEvent = data.events[data.events.length - 1];
583
582
  for (const e of data.events) {
584
583
  if (e.type === "in_flight_start") iterationCount++;
@@ -707,7 +706,7 @@ var FileSessionWriter = class {
707
706
  this.meta = meta;
708
707
  this.events = events;
709
708
  this.resumed = opts.resumed ?? false;
710
- this.manifestFile = opts.dir ? path12.join(opts.dir, `${path12.basename(id)}.summary.json`) : "";
709
+ this.manifestFile = opts.dir ? path13.join(opts.dir, `${path13.basename(id)}.summary.json`) : "";
711
710
  this.filePath = opts.filePath ?? "";
712
711
  this.secretScrubber = opts.secretScrubber;
713
712
  this.onCloseCb = opts.onClose;
@@ -1027,7 +1026,7 @@ function userInputTitle(content) {
1027
1026
  var QueueStore = class {
1028
1027
  file;
1029
1028
  constructor(opts) {
1030
- this.file = path12.join(opts.dir, "queue.json");
1029
+ this.file = path13.join(opts.dir, "queue.json");
1031
1030
  }
1032
1031
  async write(items) {
1033
1032
  if (items.length === 0) {
@@ -1094,7 +1093,7 @@ var DefaultAttachmentStore = class {
1094
1093
  let data = input.data;
1095
1094
  if (this.spoolDir && bytes >= this.spoolThreshold) {
1096
1095
  await fsp.mkdir(this.spoolDir, { recursive: true });
1097
- spooledPath = path12.join(this.spoolDir, `${id}.bin`);
1096
+ spooledPath = path13.join(this.spoolDir, `${id}.bin`);
1098
1097
  await atomicWrite(spooledPath, input.data, {
1099
1098
  encoding: input.kind === "image" ? "base64" : "utf8"
1100
1099
  });
@@ -1305,7 +1304,7 @@ var FileMemoryBackend = class {
1305
1304
  }
1306
1305
  async remember(scope, entry, filePath) {
1307
1306
  const file = this.resolveFile(filePath, scope);
1308
- await ensureDir(path12.dirname(file));
1307
+ await ensureDir(path13.dirname(file));
1309
1308
  let existing = "";
1310
1309
  try {
1311
1310
  existing = await fsp.readFile(file, "utf8");
@@ -1717,8 +1716,8 @@ ${body.trim()}`);
1717
1716
  if (!this.persistBackup || scope === "project-agents") return;
1718
1717
  try {
1719
1718
  const content = await this.backend.readAll(scope, this.files[scope]);
1720
- const { writeFile: writeFile6, mkdir: mkdir5 } = await import('fs/promises');
1721
- await mkdir5(this.backupDir, { recursive: true });
1719
+ const { writeFile: writeFile6, mkdir: mkdir6 } = await import('fs/promises');
1720
+ await mkdir6(this.backupDir, { recursive: true });
1722
1721
  await writeFile6(`${this.backupDir}/${scope}.md`, content, "utf8");
1723
1722
  } catch {
1724
1723
  }
@@ -2174,16 +2173,14 @@ function deepFreeze(obj) {
2174
2173
  }
2175
2174
  return Object.freeze(obj);
2176
2175
  }
2177
-
2178
- // src/security/config-secrets.ts
2179
- function decryptConfigSecrets(cfg, vault) {
2176
+ function decryptConfigSecrets(cfg, vault, opts) {
2177
+ const warn = ((msg) => console.warn(msg));
2180
2178
  return walk(cfg, vault, (v, key) => {
2181
2179
  try {
2182
2180
  return vault.decrypt(v);
2183
2181
  } catch (err) {
2184
- console.warn(
2185
- `[secret-vault] Failed to decrypt "${key}":`,
2186
- err instanceof Error ? err.message : err
2182
+ warn(
2183
+ `[secret-vault] Failed to decrypt "${key}": ${err instanceof Error ? err.message : err}`
2187
2184
  );
2188
2185
  return "";
2189
2186
  }
@@ -2647,7 +2644,7 @@ var RecoveryLock = class {
2647
2644
  sessionStore;
2648
2645
  probe;
2649
2646
  constructor(opts) {
2650
- this.file = path12.join(opts.dir, LOCK_FILE);
2647
+ this.file = path13.join(opts.dir, LOCK_FILE);
2651
2648
  this.pid = opts.pid ?? process.pid;
2652
2649
  this.hostname = opts.hostname ?? os.hostname();
2653
2650
  this.maxAgeMs = opts.maxAgeMs ?? DEFAULT_MAX_AGE_MS;
@@ -2705,7 +2702,7 @@ var RecoveryLock = class {
2705
2702
  * null return before calling this.
2706
2703
  */
2707
2704
  async write(sessionId) {
2708
- await ensureDir(path12.dirname(this.file));
2705
+ await ensureDir(path13.dirname(this.file));
2709
2706
  const lock = {
2710
2707
  v: 1,
2711
2708
  sessionId,
@@ -3192,7 +3189,7 @@ var AnnotationsStore = class {
3192
3189
  if (!sessionId || sessionId.includes("/") || sessionId.includes("\\") || sessionId.includes("..")) {
3193
3190
  throw new Error(`Invalid sessionId: ${sessionId}`);
3194
3191
  }
3195
- return path12.join(this.dir, `${sessionId}.annotations.json`);
3192
+ return path13.join(this.dir, `${sessionId}.annotations.json`);
3196
3193
  }
3197
3194
  async readFile(sessionId) {
3198
3195
  const fp = this.filePath(sessionId);
@@ -3349,7 +3346,7 @@ var ReplayLogStore = class {
3349
3346
  out.push({
3350
3347
  sessionId,
3351
3348
  entryCount: all.length,
3352
- path: path12.join(this.dir, name)
3349
+ path: path13.join(this.dir, name)
3353
3350
  });
3354
3351
  }
3355
3352
  return out.sort((a, b) => a.sessionId.localeCompare(b.sessionId));
@@ -3359,7 +3356,7 @@ var ReplayLogStore = class {
3359
3356
  if (!sessionId || sessionId.includes("/") || sessionId.includes("\\") || sessionId.includes("..")) {
3360
3357
  throw new Error(`Invalid sessionId: ${sessionId}`);
3361
3358
  }
3362
- return path12.join(this.dir, `${sessionId}.replay.jsonl`);
3359
+ return path13.join(this.dir, `${sessionId}.replay.jsonl`);
3363
3360
  }
3364
3361
  async readAll(sessionId) {
3365
3362
  const fp = this.filePath(sessionId);
@@ -3548,7 +3545,7 @@ var SessionRecovery = class {
3548
3545
  if (!sessionId || sessionId.includes("/") || sessionId.includes("\\") || sessionId.includes("..")) {
3549
3546
  throw new Error(`Invalid sessionId: ${sessionId}`);
3550
3547
  }
3551
- return path12.join(this.dir, `${sessionId}.jsonl`);
3548
+ return path13.join(this.dir, `${sessionId}.jsonl`);
3552
3549
  }
3553
3550
  };
3554
3551
  var GENESIS_PREV = "0".repeat(64);
@@ -3671,7 +3668,7 @@ var ToolAuditLog = class {
3671
3668
  if (!sessionId || sessionId.includes("/") || sessionId.includes("\\") || sessionId.includes("..")) {
3672
3669
  throw new Error(`Invalid sessionId: ${sessionId}`);
3673
3670
  }
3674
- return path12.join(this.dir, `${sessionId}.audit.jsonl`);
3671
+ return path13.join(this.dir, `${sessionId}.audit.jsonl`);
3675
3672
  }
3676
3673
  async readAll(sessionId) {
3677
3674
  const fp = this.filePath(sessionId);
@@ -3856,7 +3853,7 @@ var DefaultSessionRewinder = class {
3856
3853
  sessionsDir;
3857
3854
  projectRoot;
3858
3855
  async listCheckpoints(sessionId) {
3859
- const file = path12.join(this.sessionsDir, `${sessionId}.jsonl`);
3856
+ const file = path13.join(this.sessionsDir, `${sessionId}.jsonl`);
3860
3857
  const raw = await fsp.readFile(file, "utf8");
3861
3858
  const events = parseEvents(raw);
3862
3859
  const fileCountMap = /* @__PURE__ */ new Map();
@@ -3881,7 +3878,7 @@ var DefaultSessionRewinder = class {
3881
3878
  return checkpoints;
3882
3879
  }
3883
3880
  async rewindToCheckpoint(sessionId, checkpointIndex) {
3884
- const file = path12.join(this.sessionsDir, `${sessionId}.jsonl`);
3881
+ const file = path13.join(this.sessionsDir, `${sessionId}.jsonl`);
3885
3882
  const raw = await fsp.readFile(file, "utf8");
3886
3883
  const events = parseEvents(raw);
3887
3884
  let targetIdx = -1;
@@ -3916,7 +3913,7 @@ var DefaultSessionRewinder = class {
3916
3913
  return { ...result, toPromptIndex: checkpointIndex, removedEvents };
3917
3914
  }
3918
3915
  async rewindLastN(sessionId, n) {
3919
- const file = path12.join(this.sessionsDir, `${sessionId}.jsonl`);
3916
+ const file = path13.join(this.sessionsDir, `${sessionId}.jsonl`);
3920
3917
  const raw = await fsp.readFile(file, "utf8");
3921
3918
  const events = parseEvents(raw);
3922
3919
  const checkpoints = [];
@@ -3945,7 +3942,7 @@ var DefaultSessionRewinder = class {
3945
3942
  return { ...result, toPromptIndex: targetIndex, removedEvents: snapshotsToRevert.length };
3946
3943
  }
3947
3944
  async rewindToStart(sessionId) {
3948
- const file = path12.join(this.sessionsDir, `${sessionId}.jsonl`);
3945
+ const file = path13.join(this.sessionsDir, `${sessionId}.jsonl`);
3949
3946
  const raw = await fsp.readFile(file, "utf8");
3950
3947
  const events = parseEvents(raw);
3951
3948
  const allSnapshots = [];
@@ -3981,10 +3978,10 @@ async function revertSnapshots(snapshots, projectRoot) {
3981
3978
  for (const snapshot of snapshots) {
3982
3979
  for (const file of snapshot.files) {
3983
3980
  try {
3984
- const absPath = path12.resolve(file.path);
3985
- const root = path12.resolve(projectRoot);
3986
- const rel = path12.relative(root, absPath);
3987
- if (rel.startsWith("..") || path12.isAbsolute(rel)) {
3981
+ const absPath = path13.resolve(file.path);
3982
+ const root = path13.resolve(projectRoot);
3983
+ const rel = path13.relative(root, absPath);
3984
+ if (rel.startsWith("..") || path13.isAbsolute(rel)) {
3988
3985
  errors.push(`${file.path}: path resolves outside project root \u2014 skipping`);
3989
3986
  continue;
3990
3987
  }
@@ -4565,11 +4562,11 @@ var color = {
4565
4562
  bgGreen: wrap("42", "49")
4566
4563
  };
4567
4564
  function projectHash(absRoot) {
4568
- return createHash("sha256").update(path12.resolve(absRoot)).digest("hex").slice(0, 12);
4565
+ return createHash("sha256").update(path13.resolve(absRoot)).digest("hex").slice(0, 12);
4569
4566
  }
4570
4567
  function projectSlug(absRoot) {
4571
- const base = slugify(path12.basename(absRoot));
4572
- const hash = createHash("sha256").update(path12.resolve(absRoot)).digest("hex").slice(0, 6);
4568
+ const base = slugify(path13.basename(absRoot));
4569
+ const hash = createHash("sha256").update(path13.resolve(absRoot)).digest("hex").slice(0, 6);
4573
4570
  return `${base}-${hash}`;
4574
4571
  }
4575
4572
  function slugify(name) {
@@ -4577,43 +4574,43 @@ function slugify(name) {
4577
4574
  }
4578
4575
  function resolveWstackPaths(opts) {
4579
4576
  const home = opts.userHome ?? os.homedir();
4580
- const globalRoot = opts.globalRoot ?? path12.join(home, ".wrongstack");
4577
+ const globalRoot = opts.globalRoot ?? path13.join(home, ".wrongstack");
4581
4578
  const hash = projectHash(opts.projectRoot);
4582
4579
  const slug = projectSlug(opts.projectRoot);
4583
- const projectDir = path12.join(globalRoot, "projects", slug);
4580
+ const projectDir = path13.join(globalRoot, "projects", slug);
4584
4581
  return {
4585
4582
  globalRoot,
4586
4583
  configDir: globalRoot,
4587
- globalConfig: path12.join(globalRoot, "config.json"),
4588
- secretsKey: path12.join(globalRoot, ".key"),
4589
- globalMemory: path12.join(globalRoot, "memory.md"),
4590
- globalSkills: path12.join(globalRoot, "skills"),
4591
- globalPrompts: path12.join(globalRoot, "prompts"),
4592
- cacheDir: path12.join(globalRoot, "cache"),
4593
- modelsCache: path12.join(globalRoot, "cache", "models.dev.json"),
4594
- modelsOverlayCache: path12.join(globalRoot, "cache", "models-overlay.json"),
4595
- historyFile: path12.join(globalRoot, "history"),
4596
- logFile: path12.join(globalRoot, "logs", "wrongstack.log"),
4584
+ globalConfig: path13.join(globalRoot, "config.json"),
4585
+ secretsKey: path13.join(globalRoot, ".key"),
4586
+ globalMemory: path13.join(globalRoot, "memory.md"),
4587
+ globalSkills: path13.join(globalRoot, "skills"),
4588
+ globalPrompts: path13.join(globalRoot, "prompts"),
4589
+ cacheDir: path13.join(globalRoot, "cache"),
4590
+ modelsCache: path13.join(globalRoot, "cache", "models.dev.json"),
4591
+ modelsOverlayCache: path13.join(globalRoot, "cache", "models-overlay.json"),
4592
+ historyFile: path13.join(globalRoot, "history"),
4593
+ logFile: path13.join(globalRoot, "logs", "wrongstack.log"),
4597
4594
  projectDir,
4598
- projectCodebaseIndex: path12.join(projectDir, "codebase-index"),
4599
- projectMemory: path12.join(projectDir, "memory.md"),
4600
- projectSessions: path12.join(projectDir, "sessions"),
4601
- projectTrust: path12.join(projectDir, "trust.json"),
4602
- projectMeta: path12.join(projectDir, "meta.json"),
4603
- projectLocalConfig: path12.join(projectDir, "config.local.json"),
4604
- inProjectConfig: path12.join(opts.projectRoot, ".wrongstack", "config.json"),
4605
- inProjectAgentsFile: path12.join(opts.projectRoot, ".wrongstack", "AGENTS.md"),
4606
- inProjectSkills: path12.join(opts.projectRoot, ".wrongstack", "skills"),
4607
- inProjectWorktrees: path12.join(opts.projectRoot, ".wrongstack", "worktrees"),
4595
+ projectCodebaseIndex: path13.join(projectDir, "codebase-index"),
4596
+ projectMemory: path13.join(projectDir, "memory.md"),
4597
+ projectSessions: path13.join(projectDir, "sessions"),
4598
+ projectTrust: path13.join(projectDir, "trust.json"),
4599
+ projectMeta: path13.join(projectDir, "meta.json"),
4600
+ projectLocalConfig: path13.join(projectDir, "config.local.json"),
4601
+ inProjectConfig: path13.join(opts.projectRoot, ".wrongstack", "config.json"),
4602
+ inProjectAgentsFile: path13.join(opts.projectRoot, ".wrongstack", "AGENTS.md"),
4603
+ inProjectSkills: path13.join(opts.projectRoot, ".wrongstack", "skills"),
4604
+ inProjectWorktrees: path13.join(opts.projectRoot, ".wrongstack", "worktrees"),
4608
4605
  projectHash: hash,
4609
4606
  projectSlug: slug,
4610
- projectGoal: path12.join(projectDir, "goal.json"),
4611
- projectSpecs: path12.join(projectDir, "specs"),
4612
- projectTaskGraphs: path12.join(projectDir, "task-graphs"),
4613
- projectSddSession: path12.join(projectDir, "sdd-session.json"),
4614
- projectPlan: path12.join(projectDir, "plan.json"),
4615
- projectAutophase: path12.join(projectDir, "autophase"),
4616
- syncConfig: path12.join(globalRoot, "sync.json")
4607
+ projectGoal: path13.join(projectDir, "goal.json"),
4608
+ projectSpecs: path13.join(projectDir, "specs"),
4609
+ projectTaskGraphs: path13.join(projectDir, "task-graphs"),
4610
+ projectSddSession: path13.join(projectDir, "sdd-session.json"),
4611
+ projectPlan: path13.join(projectDir, "plan.json"),
4612
+ projectAutophase: path13.join(projectDir, "autophase"),
4613
+ syncConfig: path13.join(globalRoot, "sync.json")
4617
4614
  };
4618
4615
  }
4619
4616
 
@@ -4813,12 +4810,12 @@ function formatGoal(goal, journalLimit = 10) {
4813
4810
  return lines.join("\n");
4814
4811
  }
4815
4812
  function parseProgressFromText(text) {
4816
- const re = /\[progress:\s*(\d{1,3})%\]\s*(?:[—\-]\s*(.+))?/i;
4813
+ const re = /\[progress:\s*(\d{1,3})%\]\s*(?:[—-]\s*(.+))?/i;
4817
4814
  const m = text.match(re);
4818
4815
  if (!m) return null;
4819
- const progress = Math.min(100, Math.max(0, Number.parseInt(m[1], 10)));
4816
+ const progress = Math.min(100, Math.max(0, Number.parseInt(m[1] ?? "0", 10)));
4820
4817
  const note = m[2]?.trim() || void 0;
4821
- return { progress, note };
4818
+ return note === void 0 ? { progress } : { progress, note };
4822
4819
  }
4823
4820
  function recordProgress(goal, progress, note) {
4824
4821
  const clamped = Math.min(100, Math.max(0, progress));
@@ -4860,7 +4857,7 @@ var DefaultPromptStore = class {
4860
4857
  if (!file.endsWith(".json")) continue;
4861
4858
  try {
4862
4859
  const raw = JSON.parse(
4863
- await fsp.readFile(path12.join(this.dir, file), "utf8")
4860
+ await fsp.readFile(path13.join(this.dir, file), "utf8")
4864
4861
  );
4865
4862
  entries.push(raw.entry);
4866
4863
  } catch {
@@ -4873,7 +4870,7 @@ var DefaultPromptStore = class {
4873
4870
  );
4874
4871
  }
4875
4872
  async get(id) {
4876
- const file = path12.join(this.dir, `${id}.json`);
4873
+ const file = path13.join(this.dir, `${id}.json`);
4877
4874
  try {
4878
4875
  const raw = JSON.parse(await fsp.readFile(file, "utf8"));
4879
4876
  return raw.entry;
@@ -4883,12 +4880,12 @@ var DefaultPromptStore = class {
4883
4880
  }
4884
4881
  async save(entry) {
4885
4882
  await ensureDir(this.dir);
4886
- const file = path12.join(this.dir, `${entry.id}.json`);
4883
+ const file = path13.join(this.dir, `${entry.id}.json`);
4887
4884
  const raw = { version: 1, entry };
4888
4885
  await atomicWrite(file, JSON.stringify(raw, null, 2));
4889
4886
  }
4890
4887
  async delete(id) {
4891
- const file = path12.join(this.dir, `${id}.json`);
4888
+ const file = path13.join(this.dir, `${id}.json`);
4892
4889
  try {
4893
4890
  await fsp.unlink(file);
4894
4891
  return true;
@@ -4922,7 +4919,7 @@ var CloudSync = class {
4922
4919
  this.paths = paths;
4923
4920
  this.getConfig = getConfig;
4924
4921
  this.setConfig = setConfig;
4925
- this.statePath = path12.join(paths.globalRoot, "sync-state.json");
4922
+ this.statePath = path13.join(paths.globalRoot, "sync-state.json");
4926
4923
  }
4927
4924
  paths;
4928
4925
  getConfig;
@@ -5029,7 +5026,7 @@ var CloudSync = class {
5029
5026
  const rel = segments.slice(2).join("/");
5030
5027
  const destPath = resolvePulledCategoryPath(cat, localPath, rel, entry.path);
5031
5028
  const blobData = await this.getBlob(token, owner, repoName, entry.sha);
5032
- await fsp.mkdir(path12.dirname(destPath), { recursive: true });
5029
+ await fsp.mkdir(path13.dirname(destPath), { recursive: true });
5033
5030
  await fsp.writeFile(destPath, Buffer.from(blobData, "base64"));
5034
5031
  }
5035
5032
  const localRev = await this.hashLocalCategories(cfg.categories);
@@ -5136,7 +5133,7 @@ var CloudSync = class {
5136
5133
  const files = await this.walkDir(localPath, localPath);
5137
5134
  for (const file of files) {
5138
5135
  const content = await fsp.readFile(file, "utf8");
5139
- const rel = path12.relative(localPath, file).replace(/\\/g, "/");
5136
+ const rel = path13.relative(localPath, file).replace(/\\/g, "/");
5140
5137
  entries.push({ path: `data/${cat}/${rel}`, content, mode: "100644" });
5141
5138
  hashes.push(content);
5142
5139
  }
@@ -5193,7 +5190,7 @@ var CloudSync = class {
5193
5190
  const results = [];
5194
5191
  const entries = await fsp.readdir(dir, { withFileTypes: true });
5195
5192
  for (const entry of entries) {
5196
- const full = path12.join(dir, entry.name);
5193
+ const full = path13.join(dir, entry.name);
5197
5194
  if (entry.isDirectory()) {
5198
5195
  results.push(...await this.walkDir(full, base));
5199
5196
  } else {
@@ -5210,15 +5207,15 @@ function resolvePulledCategoryPath(cat, localPath, rel, remotePath) {
5210
5207
  return localPath;
5211
5208
  }
5212
5209
  if (!rel) return localPath;
5213
- const normalizedRel = path12.normalize(rel);
5214
- const traversesUp = normalizedRel === ".." || normalizedRel.startsWith(`..${path12.sep}`);
5215
- if (path12.isAbsolute(normalizedRel) || traversesUp) {
5210
+ const normalizedRel = path13.normalize(rel);
5211
+ const traversesUp = normalizedRel === ".." || normalizedRel.startsWith(`..${path13.sep}`);
5212
+ if (path13.isAbsolute(normalizedRel) || traversesUp) {
5216
5213
  throw new Error(`Refusing CloudSync path traversal: ${remotePath}`);
5217
5214
  }
5218
- const dest = path12.resolve(localPath, normalizedRel);
5219
- const root = path12.resolve(localPath);
5220
- const relative3 = path12.relative(root, dest);
5221
- if (relative3.startsWith("..") || path12.isAbsolute(relative3)) {
5215
+ const dest = path13.resolve(localPath, normalizedRel);
5216
+ const root = path13.resolve(localPath);
5217
+ const relative3 = path13.relative(root, dest);
5218
+ if (relative3.startsWith("..") || path13.isAbsolute(relative3)) {
5222
5219
  throw new Error(`Refusing CloudSync path outside category root: ${remotePath}`);
5223
5220
  }
5224
5221
  return dest;