@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,11 +1,11 @@
1
- export { A as ALL_FLEET_AGENTS, a as AUDIT_LOG_AGENT, b as AgentFactory, c as AgentFactoryResult, d as AgentRunnerOptions, B as BUG_HUNTER_AGENT, C as CreateDelegateToolOptions, D as DEFAULT_DIRECTOR_PREAMBLE, e as DEFAULT_SUBAGENT_BASELINE, f as DefaultMultiAgentCoordinator, g as DelegateHost, h as Director, i as DirectorPromptParts, j as DirectorSessionFactory, k as DirectorSessionFactoryOptions, F as FLEET_ROSTER, m as FleetBus, K as FleetCostCapError, n as FleetEvent, o as FleetHandler, p as FleetManager, q as FleetManagerOptions, r as FleetSpawnBudgetError, s as FleetUsage, t as FleetUsageAggregator, I as ICoordinator, u as IFleetManager, M as MultiAgentCoordinatorOptions, N as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, S as SECURITY_SCANNER_AGENT, v as SubagentPromptParts, w as SubagentUsageSnapshot, y as composeDirectorPrompt, z as composeSubagentPrompt, E as createDelegateTool, G as makeAgentSubagentRunner, H as makeDirectorSessionFactory, J as rosterSummaryFromConfigs } from '../index-Bf9Bpkdc.js';
1
+ export { A as ALL_FLEET_AGENTS, a as AUDIT_LOG_AGENT, b as AgentFactory, c as AgentFactoryResult, d as AgentRunnerOptions, B as BUG_HUNTER_AGENT, C as CreateDelegateToolOptions, D as DEFAULT_DIRECTOR_PREAMBLE, e as DEFAULT_SUBAGENT_BASELINE, f as DefaultMultiAgentCoordinator, g as DelegateHost, h as Director, i as DirectorPromptParts, j as DirectorSessionFactory, k as DirectorSessionFactoryOptions, F as FLEET_ROSTER, m as FleetBus, K as FleetCostCapError, n as FleetEvent, o as FleetHandler, p as FleetManager, q as FleetManagerOptions, r as FleetSpawnBudgetError, s as FleetUsage, t as FleetUsageAggregator, I as ICoordinator, u as IFleetManager, M as MultiAgentCoordinatorOptions, N as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, S as SECURITY_SCANNER_AGENT, v as SubagentPromptParts, w as SubagentUsageSnapshot, y as composeDirectorPrompt, z as composeSubagentPrompt, E as createDelegateTool, G as makeAgentSubagentRunner, H as makeDirectorSessionFactory, J as rosterSummaryFromConfigs } from '../index-DkdRz6yK.js';
2
2
  export { n as BudgetExceededError, o as BudgetKind, p as BudgetLimits, s as BudgetThresholdDecision, t as BudgetThresholdHandler, u as BudgetThresholdSignal, q as BudgetUsage, r as SubagentBudget } from '../multi-agent-Cpp7FXUl.js';
3
3
  export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-BKNiE1VH.js';
4
4
  import '../director-state-BmYi3DGA.js';
5
5
  import '../context-CDRyrkKQ.js';
6
6
  import '../events-DPQKFX7W.js';
7
7
  import 'node:events';
8
- import '../index-j2WyAyML.js';
8
+ import '../index-B0qTujQW.js';
9
9
  import '../logger-BMQgxvdy.js';
10
10
  import '../system-prompt-Dl2QY1_B.js';
11
11
  import '../observability-BhnVLBLS.js';
@@ -73,8 +73,6 @@ async function renameWithRetry(from, to) {
73
73
  }
74
74
  throw lastErr;
75
75
  }
76
-
77
- // src/storage/director-state.ts
78
76
  async function acquireDirectorStateLock(lockPath, processId = process.pid) {
79
77
  let existing;
80
78
  try {
@@ -1982,7 +1980,9 @@ var Director = class {
1982
1980
  }, opts.checkpointDebounceMs ?? 250) : null;
1983
1981
  this.fleetManager = opts.fleetManager;
1984
1982
  if (this.sharedScratchpadPath) {
1985
- void fsp4.mkdir(this.sharedScratchpadPath, { recursive: true }).catch(() => void 0);
1983
+ void fsp4.mkdir(this.sharedScratchpadPath, { recursive: true }).catch(
1984
+ (err) => this.logShutdownError("shared_scratchpad_mkdir", err)
1985
+ );
1986
1986
  }
1987
1987
  this.transport = new InMemoryBridgeTransport();
1988
1988
  this.bridge = new InMemoryAgentBridge(
@@ -2088,7 +2088,9 @@ var Director = class {
2088
2088
  if (this.manifestTimer) return;
2089
2089
  this.manifestTimer = setTimeout(() => {
2090
2090
  this.manifestTimer = null;
2091
- void this.writeManifest().catch(() => void 0);
2091
+ void this.writeManifest().catch(
2092
+ (err) => this.logShutdownError("manifest_write_debounced", err)
2093
+ );
2092
2094
  }, this.manifestDebounceMs);
2093
2095
  }
2094
2096
  /**
@@ -2279,7 +2281,7 @@ var Director = class {
2279
2281
  usage: this.usage.snapshot()
2280
2282
  };
2281
2283
  await fsp4.mkdir(path4.dirname(this.manifestPath), { recursive: true });
2282
- await fsp4.writeFile(this.manifestPath, JSON.stringify(manifest, null, 2), { mode: 384 });
2284
+ await atomicWrite(this.manifestPath, JSON.stringify(manifest, null, 2), { mode: 384 });
2283
2285
  return this.manifestPath;
2284
2286
  }
2285
2287
  /**
@@ -2808,9 +2810,11 @@ async function readSubagentPartial(opts, subagentId) {
2808
2810
  candidates.push(path4.join(opts.sessionsRoot, opts.directorRunId, `${subagentId}.jsonl`));
2809
2811
  } else {
2810
2812
  try {
2811
- const runDirs = await fsp4.readdir(opts.sessionsRoot);
2812
- for (const r of runDirs) {
2813
- candidates.push(path4.join(opts.sessionsRoot, r, `${subagentId}.jsonl`));
2813
+ const entries = await fsp4.readdir(opts.sessionsRoot, { withFileTypes: true });
2814
+ for (const entry of entries) {
2815
+ if (entry.isDirectory()) {
2816
+ candidates.push(path4.join(opts.sessionsRoot, entry.name, `${subagentId}.jsonl`));
2817
+ }
2814
2818
  }
2815
2819
  } catch {
2816
2820
  return void 0;
@@ -3116,19 +3120,25 @@ var DefaultSessionStore = class {
3116
3120
  { cause: err }
3117
3121
  );
3118
3122
  }
3119
- const writer = new FileSessionWriter(
3120
- id,
3121
- handle,
3122
- (/* @__PURE__ */ new Date()).toISOString(),
3123
- {
3123
+ try {
3124
+ const writer = new FileSessionWriter(
3124
3125
  id,
3125
- model: data.metadata.model,
3126
- provider: data.metadata.provider
3127
- },
3128
- this.events,
3129
- { resumed: true, dir: this.dir, filePath: file }
3130
- );
3131
- return { writer, data };
3126
+ handle,
3127
+ (/* @__PURE__ */ new Date()).toISOString(),
3128
+ {
3129
+ id,
3130
+ model: data.metadata.model,
3131
+ provider: data.metadata.provider
3132
+ },
3133
+ this.events,
3134
+ { resumed: true, dir: this.dir, filePath: file }
3135
+ );
3136
+ return { writer, data };
3137
+ } catch (err) {
3138
+ await handle.close().catch(() => {
3139
+ });
3140
+ throw err;
3141
+ }
3132
3142
  }
3133
3143
  async load(id) {
3134
3144
  const file = path4.join(this.dir, `${id}.jsonl`);
@@ -3174,7 +3184,7 @@ var DefaultSessionStore = class {
3174
3184
  const full = path4.join(this.dir, `${id}.jsonl`);
3175
3185
  const stat3 = await fsp4.stat(full);
3176
3186
  const summary = await this.summarize(id, stat3.mtime.toISOString());
3177
- await fsp4.writeFile(manifest, JSON.stringify(summary), { mode: 384 }).catch((err) => {
3187
+ await atomicWrite(manifest, JSON.stringify(summary), { mode: 384 }).catch((err) => {
3178
3188
  console.warn(
3179
3189
  `[session-store] Failed to write manifest for "${id}":`,
3180
3190
  err instanceof Error ? err.message : String(err)
@@ -3402,7 +3412,7 @@ var FileSessionWriter = class {
3402
3412
  this.closed = true;
3403
3413
  if (this.manifestFile) {
3404
3414
  try {
3405
- await fsp4.writeFile(this.manifestFile, JSON.stringify(this.summary), { mode: 384 });
3415
+ await atomicWrite(this.manifestFile, JSON.stringify(this.summary), { mode: 384 });
3406
3416
  } catch {
3407
3417
  }
3408
3418
  }
@@ -3676,7 +3686,7 @@ var FleetManager = class {
3676
3686
  usage: this.usage.snapshot()
3677
3687
  };
3678
3688
  await fsp4.mkdir(path4.dirname(this.manifestPath), { recursive: true });
3679
- await fsp4.writeFile(this.manifestPath, JSON.stringify(manifest, null, 2), { mode: 384 });
3689
+ await atomicWrite(this.manifestPath, JSON.stringify(manifest, null, 2), { mode: 384 });
3680
3690
  return this.manifestPath;
3681
3691
  }
3682
3692
  /**
@@ -3696,7 +3706,13 @@ var FleetManager = class {
3696
3706
  if (this.manifestTimer) return;
3697
3707
  this.manifestTimer = setTimeout(() => {
3698
3708
  this.manifestTimer = null;
3699
- void this.writeManifest().catch(() => void 0);
3709
+ void this.writeManifest().catch((err) => {
3710
+ const detail = err instanceof Error ? err.message : String(err);
3711
+ process.emitWarning(
3712
+ `FleetManager manifest write failed: ${detail}`,
3713
+ "FleetManagerWarning"
3714
+ );
3715
+ });
3700
3716
  }, this.manifestDebounceMs);
3701
3717
  }
3702
3718
  /** Best-effort session event writer. Swallows failures. */