@wrongstack/core 0.257.0 → 0.260.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-BrxWHEOm.d.ts → agent-bridge-BbskZ7HH.d.ts} +1 -1
  2. package/dist/{agent-subagent-runner-US741uBH.d.ts → agent-subagent-runner-BNIGZx18.d.ts} +28 -8
  3. package/dist/{brain-TjEEwSpw.d.ts → brain-C2yDd7Lw.d.ts} +58 -1
  4. package/dist/{compactor-C5sT4U7I.d.ts → compactor-t0R_AIt_.d.ts} +1 -1
  5. package/dist/{config-DuAu23zm.d.ts → config-FG6As4H5.d.ts} +1 -1
  6. package/dist/{context-CGdgA0q6.d.ts → context-JFOVvu6z.d.ts} +22 -0
  7. package/dist/coordination/index.d.ts +14 -14
  8. package/dist/coordination/index.js +195 -33
  9. package/dist/coordination/index.js.map +1 -1
  10. package/dist/defaults/index.d.ts +25 -25
  11. package/dist/defaults/index.js +908 -92
  12. package/dist/defaults/index.js.map +1 -1
  13. package/dist/execution/index.d.ts +15 -15
  14. package/dist/execution/index.js +134 -35
  15. package/dist/execution/index.js.map +1 -1
  16. package/dist/execution/prompt-enhancer.d.ts +1 -1
  17. package/dist/extension/index.d.ts +6 -6
  18. package/dist/{goal-preamble-UiEkbNmW.d.ts → goal-preamble-B1IXJtLX.d.ts} +11 -9
  19. package/dist/{goal-store-CV9Yz2X_.d.ts → goal-store-CPXz6Mml.d.ts} +4 -2
  20. package/dist/{index-CitPrI3a.d.ts → index-BPcg4N3M.d.ts} +5 -5
  21. package/dist/{index-CC0Mcm05.d.ts → index-CebbJB94.d.ts} +8 -8
  22. package/dist/index.d.ts +47 -43
  23. package/dist/index.js +1571 -284
  24. package/dist/index.js.map +1 -1
  25. package/dist/infrastructure/index.d.ts +6 -6
  26. package/dist/kernel/index.d.ts +9 -9
  27. package/dist/kernel/index.js.map +1 -1
  28. package/dist/{llm-selector-CJ4SyAFE.d.ts → llm-selector-DXxI2tlu.d.ts} +2 -2
  29. package/dist/{mcp-servers-D8YnLaEp.d.ts → mcp-servers-OwNHo43-.d.ts} +3 -3
  30. package/dist/models/index.d.ts +5 -5
  31. package/dist/{models-registry-ByZCdFuQ.d.ts → models-registry-Djlmq4uB.d.ts} +1 -1
  32. package/dist/{multi-agent-coordinator-DqTUEAeC.d.ts → multi-agent-coordinator-CEmrSCMJ.d.ts} +1 -1
  33. package/dist/{null-fleet-bus-B5mfTJXT.d.ts → null-fleet-bus-DT92xqgJ.d.ts} +13 -8
  34. package/dist/observability/index.d.ts +2 -2
  35. package/dist/{package-outdated-watcher-BSgR_kK-.d.ts → package-outdated-watcher-C70ag2G9.d.ts} +3 -3
  36. package/dist/{parallel-eternal-engine-C0juOszP.d.ts → parallel-eternal-engine-0SItuq5r.d.ts} +13 -9
  37. package/dist/{path-resolver-CbkT-RMU.d.ts → path-resolver-DKBh6Jlo.d.ts} +3 -3
  38. package/dist/{permission-CwBBpCoF.d.ts → permission-BJ7eO9Vl.d.ts} +1 -1
  39. package/dist/{permission-policy-B8rSu908.d.ts → permission-policy-DEXOfnpm.d.ts} +3 -2
  40. package/dist/{pipeline-JG8XoudC.d.ts → pipeline-zflkI2dp.d.ts} +2 -2
  41. package/dist/{plan-templates-DPiQMkBz.d.ts → plan-templates-BFXyRkEK.d.ts} +32 -11
  42. package/dist/{provider-runner-hM7EXlLI.d.ts → provider-runner-BC-uywtT.d.ts} +3 -3
  43. package/dist/{retry-policy-Tg7LXkoK.d.ts → retry-policy-Cavrzmtk.d.ts} +1 -1
  44. package/dist/sdd/index.d.ts +8 -8
  45. package/dist/sdd/index.js +20 -2
  46. package/dist/sdd/index.js.map +1 -1
  47. package/dist/{secret-vault-gxtFZYBt.d.ts → secret-vault-CDvDYXWX.d.ts} +1 -1
  48. package/dist/security/index.d.ts +4 -4
  49. package/dist/security/index.js +30 -1
  50. package/dist/security/index.js.map +1 -1
  51. package/dist/{selector-DWsqVjGf.d.ts → selector-B7AivHsu.d.ts} +1 -1
  52. package/dist/{session-event-bridge-BAFWdgQ3.d.ts → session-event-bridge-BmIDxdJd.d.ts} +1 -1
  53. package/dist/{session-reader-CqRvaL5v.d.ts → session-reader-DtofsB-2.d.ts} +1 -1
  54. package/dist/storage/index.d.ts +30 -21
  55. package/dist/storage/index.js +1264 -216
  56. package/dist/storage/index.js.map +1 -1
  57. package/dist/types/index.d.ts +19 -19
  58. package/dist/types/index.js +8 -0
  59. package/dist/types/index.js.map +1 -1
  60. package/dist/utils/index.d.ts +101 -3
  61. package/dist/utils/index.js +92 -1
  62. package/dist/utils/index.js.map +1 -1
  63. package/package.json +1 -1
  64. package/skills/output-standards/SKILL.md +14 -9
  65. package/skills/output-standards/SKILL.save.md +3 -2
@@ -1375,6 +1375,7 @@ Emit each evaluation immediately. Do not wait until you have read all reports.`;
1375
1375
  }
1376
1376
  for (const dispose of this.disposers) dispose();
1377
1377
  this.disposers.length = 0;
1378
+ this.snapshot.files.length = 0;
1378
1379
  }
1379
1380
  };
1380
1381
 
@@ -1408,7 +1409,12 @@ Working rules:
1408
1409
  6. Never claim a subagent's work as your own without verifying it. If a
1409
1410
  result looks wrong, ask_subagent for clarification before passing it
1410
1411
  to the user.
1411
- 7. Wind down when satisfied. When the results are good enough, call
1412
+ 7. **Act on subagent mail immediately**. Subagent messages (result, ask,
1413
+ assign, note) are injected inline before every step \u2014 even mid-task.
1414
+ When you see one, address it before continuing: reply to asks, factor
1415
+ in results, act on assignments. Use \`mailbox action=ack\` to mark
1416
+ completed messages.
1417
+ 8. Wind down when satisfied. When the results are good enough, call
1412
1418
  work_complete \u2014 no new subagents will spawn and queued tasks complete
1413
1419
  as aborted. Running subagents finish naturally. Call terminate_subagent
1414
1420
  only for ones you need to stop immediately.`;
@@ -1425,6 +1431,13 @@ Bridge contract:
1425
1431
  structured, and self-contained \u2014 assume the Director will paste your
1426
1432
  output into its own context.
1427
1433
 
1434
+ CRITICAL CONSTRAINT \u2014 NO FURTHER DELEGATION:
1435
+ - You MUST NOT call the \`delegate\` tool or attempt to spawn subagents.
1436
+ - You MUST NOT use \`spawn_subagent\`, \`assign_task\`, or any equivalent.
1437
+ - Your role is to execute the assigned task yourself, not to orchestrate.
1438
+ - If a subtask is too complex, report back to the Director with what you
1439
+ found and let the Director decide how to decompose.
1440
+
1428
1441
  Inter-agent mailbox (if you have the \`mail_send\`/\`mail_inbox\`/\`mailbox\` tools):
1429
1442
  - You are part of a project-wide fleet that may span other terminals and
1430
1443
  WebUIs. Your mailbox identity is \`<your-name>@<session-tag>\` (unique
@@ -1439,7 +1452,12 @@ Inter-agent mailbox (if you have the \`mail_send\`/\`mail_inbox\`/\`mailbox\` to
1439
1452
  their exact id instead of doing everything yourself. Discover ids with
1440
1453
  \`mailbox action=online\`.
1441
1454
  - Answer your mail: reply to the sender's exact \`from\` id. When done with
1442
- an assigned task, post a \`result\` back to whoever assigned it.`;
1455
+ an assigned task, post a \`result\` back to whoever assigned it.
1456
+ - **Mail to the leader is always seen**: when you send \`ask\`, \`result\`,
1457
+ or \`assign\` to the director/leader, the message is injected inline into
1458
+ the leader's conversation before their next step \u2014 even if the leader is
1459
+ mid-task. Use \`mail_send\` to reliably reach the leader instead of
1460
+ waiting for them to check in.`;
1443
1461
  function composeDirectorPrompt(parts = {}) {
1444
1462
  const sections = [];
1445
1463
  const preamble = parts.directorPreamble ?? DEFAULT_DIRECTOR_PREAMBLE;
@@ -4119,17 +4137,17 @@ function normalize(text) {
4119
4137
  return ` ${text.toLowerCase().replace(/[^a-z0-9]+/g, " ").trim()} `;
4120
4138
  }
4121
4139
  function scoreAgents(task, catalog = AGENT_CATALOG) {
4122
- const hay = normalize(task);
4140
+ const haySet = new Set(normalize(task).split(/\s+/).filter(Boolean));
4123
4141
  const out = [];
4124
4142
  for (const def of Object.values(catalog)) {
4125
4143
  if (!def?.config?.role) continue;
4126
4144
  let score = 0;
4127
4145
  const matched = [];
4128
4146
  for (const kw of def.capability.keywords) {
4129
- const needle = normalize(kw);
4130
- if (hay.includes(needle.trimEnd() + " ") || hay.includes(" " + needle.trimStart())) {
4131
- const words = kw.trim().split(/\s+/).length;
4132
- score += words;
4147
+ const needleWords = normalize(kw).split(/\s+/).filter(Boolean);
4148
+ const allPresent = needleWords.every((w) => haySet.has(w));
4149
+ if (allPresent) {
4150
+ score += needleWords.length;
4133
4151
  matched.push(kw);
4134
4152
  }
4135
4153
  }
@@ -8160,6 +8178,20 @@ async function readSubagentPartial(opts, subagentId) {
8160
8178
  }
8161
8179
 
8162
8180
  // src/coordination/agent-subagent-runner.ts
8181
+ function withDisabledToolFiltering(factory) {
8182
+ return async (config) => {
8183
+ const result = await factory(config);
8184
+ const disabled = config.disabledTools ?? [];
8185
+ if (disabled.length === 0) return result;
8186
+ const registry = result.agent.tools;
8187
+ if (registry && typeof registry.unregister === "function") {
8188
+ for (const toolName of disabled) {
8189
+ registry.unregister(toolName);
8190
+ }
8191
+ }
8192
+ return result;
8193
+ };
8194
+ }
8163
8195
  function makeAgentSubagentRunner(opts) {
8164
8196
  const format = opts.formatTaskInput ?? defaultFormatTaskInput;
8165
8197
  return async (task, ctx) => {
@@ -8470,6 +8502,40 @@ var DefaultSessionStore = class _DefaultSessionStore {
8470
8502
  this.events = opts.events;
8471
8503
  this.secretScrubber = opts.secretScrubber;
8472
8504
  }
8505
+ // ── Storage event helpers ───────────────────────────────────────────────────
8506
+ emitRead(sessionId, filePath, operation, outcome, durationMs, error) {
8507
+ this.events?.emit("storage.read", {
8508
+ sessionId,
8509
+ store: "session",
8510
+ filePath,
8511
+ operation,
8512
+ outcome,
8513
+ durationMs,
8514
+ ...error !== void 0 ? { error } : {}
8515
+ });
8516
+ }
8517
+ emitWrite(sessionId, filePath, operation, outcome, durationMs, eventCount, error) {
8518
+ this.events?.emit("storage.write", {
8519
+ sessionId,
8520
+ store: "session",
8521
+ filePath,
8522
+ operation,
8523
+ outcome,
8524
+ durationMs,
8525
+ ...eventCount !== void 0 ? { eventCount } : {},
8526
+ ...error !== void 0 ? { error } : {}
8527
+ });
8528
+ }
8529
+ emitError(sessionId, filePath, operation, error, recoverable) {
8530
+ this.events?.emit("storage.error", {
8531
+ sessionId,
8532
+ store: "session",
8533
+ filePath,
8534
+ operation,
8535
+ error,
8536
+ recoverable
8537
+ });
8538
+ }
8473
8539
  /** Absolute path to the session index file. */
8474
8540
  get indexFile() {
8475
8541
  return path4.join(this.dir, "_index.jsonl");
@@ -8493,22 +8559,26 @@ var DefaultSessionStore = class _DefaultSessionStore {
8493
8559
  const id = meta.id && meta.id.length > 0 ? meta.id : generateSessionId(startedAt, meta.model ?? meta.provider);
8494
8560
  const shardDir = await this.ensureShardDir(id);
8495
8561
  const file = path4.join(shardDir, `${path4.basename(id)}.jsonl`);
8562
+ const t0 = Date.now();
8496
8563
  let handle;
8497
8564
  try {
8498
8565
  handle = await fsp6.open(file, "a", 384);
8499
8566
  } catch (err) {
8567
+ this.emitError(id, file, "create", err instanceof Error ? err.message : String(err), false);
8500
8568
  throw new Error(
8501
8569
  `Failed to open session file: ${err instanceof Error ? err.message : String(err)}`,
8502
8570
  { cause: err }
8503
8571
  );
8504
8572
  }
8505
8573
  try {
8506
- return new FileSessionWriter(id, handle, startedAt, meta, this.events, {
8574
+ const writer = new FileSessionWriter(id, handle, startedAt, meta, this.events, {
8507
8575
  dir: shardDir,
8508
8576
  filePath: file,
8509
8577
  secretScrubber: this.secretScrubber,
8510
8578
  onClose: (s) => this.appendToIndex(s)
8511
8579
  });
8580
+ this.emitWrite(id, file, "create", "success", Date.now() - t0);
8581
+ return writer;
8512
8582
  } catch (err) {
8513
8583
  await handle.close().catch((e) => console.warn(JSON.stringify({
8514
8584
  level: "warn",
@@ -8516,16 +8586,19 @@ var DefaultSessionStore = class _DefaultSessionStore {
8516
8586
  message: e instanceof Error ? e.message : String(e),
8517
8587
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
8518
8588
  })));
8589
+ this.emitError(id, file, "create", err instanceof Error ? err.message : String(err), true);
8519
8590
  throw err;
8520
8591
  }
8521
8592
  }
8522
8593
  async resume(id) {
8523
8594
  const file = this.sessionPath(id, ".jsonl");
8595
+ const t0 = Date.now();
8524
8596
  const data = await this.load(id);
8525
8597
  let handle;
8526
8598
  try {
8527
8599
  handle = await fsp6.open(file, "a", 384);
8528
8600
  } catch (err) {
8601
+ this.emitError(id, file, "resume", err instanceof Error ? err.message : String(err), false);
8529
8602
  throw new Error(
8530
8603
  `Failed to open session "${id}" for append: ${err instanceof Error ? err.message : String(err)}`,
8531
8604
  { cause: err }
@@ -8553,6 +8626,7 @@ var DefaultSessionStore = class _DefaultSessionStore {
8553
8626
  onClose: (s) => this.appendToIndex(s)
8554
8627
  }
8555
8628
  );
8629
+ this.emitWrite(id, file, "resume", "success", Date.now() - t0);
8556
8630
  return { writer, data };
8557
8631
  } catch (err) {
8558
8632
  await handle.close().catch((e) => console.warn(JSON.stringify({
@@ -8561,27 +8635,39 @@ var DefaultSessionStore = class _DefaultSessionStore {
8561
8635
  message: e instanceof Error ? e.message : String(e),
8562
8636
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
8563
8637
  })));
8638
+ this.emitError(id, file, "resume", err instanceof Error ? err.message : String(err), true);
8564
8639
  throw err;
8565
8640
  }
8566
8641
  }
8567
8642
  async load(id) {
8568
8643
  const file = this.sessionPath(id, ".jsonl");
8569
- const raw = await fsp6.readFile(file, "utf8");
8570
- const lines = raw.split("\n").filter((l) => l.trim());
8571
- const events = [];
8572
- for (const line of lines) {
8573
- try {
8574
- const parsed = JSON.parse(line);
8575
- if (parsed !== null && typeof parsed === "object" && typeof parsed.type === "string" && typeof parsed.ts === "string") {
8576
- events.push(parsed);
8644
+ const t0 = Date.now();
8645
+ let outcome = "success";
8646
+ let errorMsg;
8647
+ try {
8648
+ const raw = await fsp6.readFile(file, "utf8");
8649
+ const lines = raw.split("\n").filter((l) => l.trim());
8650
+ const events = [];
8651
+ for (const line of lines) {
8652
+ try {
8653
+ const parsed = JSON.parse(line);
8654
+ if (parsed !== null && typeof parsed === "object" && typeof parsed.type === "string" && typeof parsed.ts === "string") {
8655
+ events.push(parsed);
8656
+ }
8657
+ } catch {
8577
8658
  }
8578
- } catch {
8579
8659
  }
8660
+ const meta = this.metaFromEvents(id, events);
8661
+ const { messages, usage } = this.replay(events, id);
8662
+ const toolCallEnds = extractToolCallEnds(events);
8663
+ return { metadata: meta, events, messages, usage, toolCallEnds };
8664
+ } catch (err) {
8665
+ outcome = "failure";
8666
+ errorMsg = err instanceof Error ? err.message : String(err);
8667
+ throw err;
8668
+ } finally {
8669
+ this.emitRead(id, file, "load", outcome, Date.now() - t0, errorMsg);
8580
8670
  }
8581
- const meta = this.metaFromEvents(id, events);
8582
- const { messages, usage } = this.replay(events, id);
8583
- const toolCallEnds = extractToolCallEnds(events);
8584
- return { metadata: meta, events, messages, usage, toolCallEnds };
8585
8671
  }
8586
8672
  async list(limit = 20) {
8587
8673
  try {
@@ -8648,12 +8734,22 @@ var DefaultSessionStore = class _DefaultSessionStore {
8648
8734
  * (keep latest per session), and rewrite. Atomic via temp+rename.
8649
8735
  */
8650
8736
  async compactIndex() {
8651
- const entries = await this.readIndex();
8652
- if (entries.length === 0) return;
8653
- const tmp = `${this.indexFile}.compact.tmp`;
8654
- const lines = entries.map((s) => JSON.stringify(s)).join("\n") + "\n";
8655
- await fsp6.writeFile(tmp, lines, "utf8");
8656
- await fsp6.rename(tmp, this.indexFile);
8737
+ const t0 = Date.now();
8738
+ let outcome = "success";
8739
+ let errorMsg;
8740
+ try {
8741
+ const entries = await this.readIndex();
8742
+ if (entries.length === 0) return;
8743
+ const tmp = `${this.indexFile}.compact.tmp`;
8744
+ const lines = entries.map((s) => JSON.stringify(s)).join("\n") + "\n";
8745
+ await fsp6.writeFile(tmp, lines, "utf8");
8746
+ await fsp6.rename(tmp, this.indexFile);
8747
+ } catch (err) {
8748
+ outcome = "failure";
8749
+ errorMsg = err instanceof Error ? err.message : String(err);
8750
+ } finally {
8751
+ this.emitWrite("~compact~", this.indexFile, "compact", outcome, Date.now() - t0, void 0, errorMsg);
8752
+ }
8657
8753
  }
8658
8754
  /**
8659
8755
  * Read the index file and return deduplicated session summaries.
@@ -8729,22 +8825,31 @@ var DefaultSessionStore = class _DefaultSessionStore {
8729
8825
  }
8730
8826
  async summaryFor(id) {
8731
8827
  const manifest = this.sessionPath(id, ".summary.json");
8828
+ const t0 = Date.now();
8829
+ let outcome = "success";
8830
+ let errorMsg;
8732
8831
  try {
8733
8832
  const raw = await fsp6.readFile(manifest, "utf8");
8833
+ this.emitRead(id, manifest, "summary", "success", Date.now() - t0);
8734
8834
  return JSON.parse(raw);
8735
8835
  } catch {
8736
8836
  const full = this.sessionPath(id, ".jsonl");
8737
8837
  const stat5 = await fsp6.stat(full);
8738
8838
  const summary = await this.summarize(id, stat5.mtime.toISOString());
8739
8839
  await atomicWrite(manifest, JSON.stringify(summary), { mode: 384 }).catch((err) => {
8840
+ const msg = err instanceof Error ? err.message : String(err);
8841
+ this.emitError(id, manifest, "summary_fallback", msg, true);
8740
8842
  console.warn(JSON.stringify({
8741
8843
  level: "warn",
8742
8844
  event: "session_store.manifest_write_failed",
8743
8845
  sessionId: id,
8744
- message: err instanceof Error ? err.message : String(err),
8846
+ message: msg,
8745
8847
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
8746
8848
  }));
8747
8849
  });
8850
+ outcome = "failure";
8851
+ errorMsg = "summary fallback \u2014 manifest rebuilt";
8852
+ this.emitRead(id, manifest, "summary", outcome, Date.now() - t0, errorMsg);
8748
8853
  return summary;
8749
8854
  }
8750
8855
  }
@@ -9010,7 +9115,7 @@ function extractToolCallEnds(events) {
9010
9115
  return result;
9011
9116
  }
9012
9117
  var FileSessionWriter = class _FileSessionWriter {
9013
- constructor(id, handle, startedAt, meta, events, opts = {}) {
9118
+ constructor(id, handle, startedAt, meta, events, opts = {}, traceId) {
9014
9119
  this.id = id;
9015
9120
  this.handle = handle;
9016
9121
  this.startedAt = startedAt;
@@ -9029,6 +9134,7 @@ var FileSessionWriter = class _FileSessionWriter {
9029
9134
  provider: meta.provider ?? "unknown",
9030
9135
  tokenTotal: 0
9031
9136
  };
9137
+ this.traceId = traceId;
9032
9138
  }
9033
9139
  id;
9034
9140
  handle;
@@ -9061,6 +9167,8 @@ var FileSessionWriter = class _FileSessionWriter {
9061
9167
  lastAppendWarnAt = 0;
9062
9168
  secretScrubber;
9063
9169
  onCloseCb;
9170
+ /** Implements SessionWriter.traceId — propagated from ContextInit.traceId. */
9171
+ traceId;
9064
9172
  // ── Write buffer — batches events to reduce per-event disk I/O ─────────
9065
9173
  //
9066
9174
  // Every append() pushes the scrubbed event into an in-memory buffer instead
@@ -9214,9 +9322,14 @@ var FileSessionWriter = class _FileSessionWriter {
9214
9322
  const eventCount = this.writeBuffer.length;
9215
9323
  const batch = this.writeBuffer.map((e) => JSON.stringify(e)).join("\n") + "\n";
9216
9324
  this.writeBuffer = [];
9325
+ const t0 = Date.now();
9326
+ let outcome = "success";
9327
+ let errorMsg;
9217
9328
  try {
9218
9329
  await this.enqueueWrite(batch);
9219
9330
  } catch (err) {
9331
+ outcome = "failure";
9332
+ errorMsg = err instanceof Error ? err.message : String(err);
9220
9333
  this.appendFailCount += eventCount;
9221
9334
  const now = Date.now();
9222
9335
  if (now - this.lastAppendWarnAt > 5e3) {
@@ -9230,6 +9343,18 @@ var FileSessionWriter = class _FileSessionWriter {
9230
9343
  this.lastAppendWarnAt = now;
9231
9344
  this.appendFailCount = 0;
9232
9345
  }
9346
+ } finally {
9347
+ this.events?.emit("storage.write", {
9348
+ sessionId: this.id,
9349
+ store: "session",
9350
+ filePath: this.filePath,
9351
+ operation: "flush",
9352
+ outcome,
9353
+ durationMs: Date.now() - t0,
9354
+ ...errorMsg !== void 0 ? { error: errorMsg } : {},
9355
+ ...eventCount !== void 0 ? { eventCount } : {},
9356
+ ...this.traceId !== void 0 ? { traceId: this.traceId } : {}
9357
+ });
9233
9358
  }
9234
9359
  }
9235
9360
  observeForSummary(event) {
@@ -9295,14 +9420,46 @@ var FileSessionWriter = class _FileSessionWriter {
9295
9420
  outcome: this.outcome ?? "completed"
9296
9421
  };
9297
9422
  if (this.manifestFile) {
9423
+ const t0 = Date.now();
9424
+ let outcome = "success";
9425
+ let errorMsg;
9298
9426
  try {
9299
9427
  await atomicWrite(this.manifestFile, JSON.stringify(this.summary), { mode: 384 });
9300
- } catch {
9428
+ } catch (err) {
9429
+ outcome = "failure";
9430
+ errorMsg = err instanceof Error ? err.message : String(err);
9431
+ } finally {
9432
+ this.events?.emit("storage.write", {
9433
+ sessionId: this.id,
9434
+ store: "session",
9435
+ filePath: this.manifestFile,
9436
+ operation: "close",
9437
+ outcome,
9438
+ durationMs: Date.now() - t0,
9439
+ ...errorMsg !== void 0 ? { error: errorMsg } : {},
9440
+ ...this.traceId !== void 0 ? { traceId: this.traceId } : {}
9441
+ });
9301
9442
  }
9302
9443
  }
9444
+ const idxT0 = Date.now();
9445
+ let idxOutcome = "success";
9446
+ let idxError;
9303
9447
  try {
9304
9448
  await this.onCloseCb?.(this.summary);
9305
- } catch {
9449
+ } catch (err) {
9450
+ idxOutcome = "failure";
9451
+ idxError = err instanceof Error ? err.message : String(err);
9452
+ } finally {
9453
+ this.events?.emit("storage.write", {
9454
+ sessionId: this.summary.id,
9455
+ store: "session",
9456
+ filePath: this.filePath,
9457
+ operation: "index_append",
9458
+ outcome: idxOutcome,
9459
+ durationMs: Date.now() - idxT0,
9460
+ ...idxError !== void 0 ? { error: idxError } : {},
9461
+ ...this.traceId !== void 0 ? { traceId: this.traceId } : {}
9462
+ });
9306
9463
  }
9307
9464
  try {
9308
9465
  await this.handle.close();
@@ -9463,6 +9620,7 @@ function userInputTitle(content) {
9463
9620
  // src/coordination/director-session.ts
9464
9621
  function makeDirectorSessionFactory(opts) {
9465
9622
  const runId = opts.directorRunId ?? `${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}-director`;
9623
+ const { traceId } = opts;
9466
9624
  let store;
9467
9625
  let dir;
9468
9626
  if (opts.store) {
@@ -9478,12 +9636,16 @@ function makeDirectorSessionFactory(opts) {
9478
9636
  dir,
9479
9637
  directorRunId: runId,
9480
9638
  async createSubagentSession({ subagentId, provider, model, title }) {
9481
- return store.create({
9639
+ const writer = await store.create({
9482
9640
  id: subagentId,
9483
9641
  title: title ?? subagentId,
9484
9642
  provider: provider ?? "unknown",
9485
9643
  model: model ?? "unknown"
9486
9644
  });
9645
+ if (traceId !== void 0) {
9646
+ writer.traceId = traceId;
9647
+ }
9648
+ return writer;
9487
9649
  }
9488
9650
  };
9489
9651
  }
@@ -11554,6 +11716,6 @@ mvn versions:use-latest-versions`;
11554
11716
  }
11555
11717
  }
11556
11718
 
11557
- export { ACP_AGENTS, AGENTS_BY_PHASE, AGENT_CATALOG, TOOLS as AGENT_TOOL_PRESETS, ALL_AGENT_DEFINITIONS, ALL_FLEET_AGENTS, AUDIT_LOG_AGENT, BUG_HUNTER_AGENT, BUILD_AGENTS, BrainDecisionQueue, BrainMonitor, BudgetExceededError, BudgetThresholdSignal, CollabSession, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_DISPATCH_ROLE, DEFAULT_SUBAGENT_BASELINE, DELIVERY_AGENTS, DEPENDENCY_FILE_PATTERNS, DISCOVERY_AGENTS, DOMAIN_AGENTS, DefaultBrainArbiter, DefaultMailbox, DefaultMultiAgentCoordinator, Director, DirectorAlertLevel, FLEET_ROSTER, FLEET_ROSTER_BUDGETS, FLEET_ROSTER_WITHACP, FleetBus, FleetCostCapError, FleetManager, FleetSpawnBudgetError, FleetUsageAggregator, GlobalMailbox, HEAVY_BUDGET, HumanEscalatingBrainArbiter, InMemoryAgentBridge, InMemoryBridgeTransport, KNOWLEDGE_AGENTS, LIGHT_BUDGET, LargeAnswerStore, MEDIUM_BUDGET, META_AGENTS, NULL_FLEET_BUS, ObservableBrainArbiter, PLANNING_AGENTS, REFACTOR_PLANNER_AGENT, REVIEW_AGENTS, SECURITY_SCANNER_AGENT, SubagentBudget, VERIFY_AGENTS, applyRosterBudget, attachAutoExtend, attachDepWatcherBridge, composeDirectorPrompt, composeSubagentPrompt, createDelegateTool, createMailboxHooks, createMessage, detectEcosystem, dispatchAgent, formatHumanPrompt, getAgentDefinition, getFullPackageLog, getManifestPackages, getPackageAuthor, getPackagesByAgent, mailboxSessionTag, makeAgentSubagentRunner, makeAskResultTool, makeAskTool, makeAssignTool, makeAwaitTasksTool, makeCollabDebugTool, makeDependencyWatcherConfig, makeDirectorSessionFactory, makeFleetEmitTool, makeFleetHealthTool, makeFleetSessionTool, makeFleetStatusTool, makeFleetUsageTool, makeLLMClassifier, makeMailInboxTool, makeMailSendTool, makeMailboxTool, makeRollUpTool, makeSpawnTool, makeTerminateTool, makeWorkCompleteTool, normalizeRecipient, recordPackageAction, resolveMailboxIdentity, resolveProjectDir, rosterSummaryFromConfigs, scoreAgents, startPackageOutdatedWatcher, updatePackageOutdatedStatus };
11719
+ export { ACP_AGENTS, AGENTS_BY_PHASE, AGENT_CATALOG, TOOLS as AGENT_TOOL_PRESETS, ALL_AGENT_DEFINITIONS, ALL_FLEET_AGENTS, AUDIT_LOG_AGENT, BUG_HUNTER_AGENT, BUILD_AGENTS, BrainDecisionQueue, BrainMonitor, BudgetExceededError, BudgetThresholdSignal, CollabSession, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_DISPATCH_ROLE, DEFAULT_SUBAGENT_BASELINE, DELIVERY_AGENTS, DEPENDENCY_FILE_PATTERNS, DISCOVERY_AGENTS, DOMAIN_AGENTS, DefaultBrainArbiter, DefaultMailbox, DefaultMultiAgentCoordinator, Director, DirectorAlertLevel, FLEET_ROSTER, FLEET_ROSTER_BUDGETS, FLEET_ROSTER_WITHACP, FleetBus, FleetCostCapError, FleetManager, FleetSpawnBudgetError, FleetUsageAggregator, GlobalMailbox, HEAVY_BUDGET, HumanEscalatingBrainArbiter, InMemoryAgentBridge, InMemoryBridgeTransport, KNOWLEDGE_AGENTS, LIGHT_BUDGET, LargeAnswerStore, MEDIUM_BUDGET, META_AGENTS, NULL_FLEET_BUS, ObservableBrainArbiter, PLANNING_AGENTS, REFACTOR_PLANNER_AGENT, REVIEW_AGENTS, SECURITY_SCANNER_AGENT, SubagentBudget, VERIFY_AGENTS, applyRosterBudget, attachAutoExtend, attachDepWatcherBridge, composeDirectorPrompt, composeSubagentPrompt, createDelegateTool, createMailboxHooks, createMessage, detectEcosystem, dispatchAgent, formatHumanPrompt, getAgentDefinition, getFullPackageLog, getManifestPackages, getPackageAuthor, getPackagesByAgent, mailboxSessionTag, makeAgentSubagentRunner, makeAskResultTool, makeAskTool, makeAssignTool, makeAwaitTasksTool, makeCollabDebugTool, makeDependencyWatcherConfig, makeDirectorSessionFactory, makeFleetEmitTool, makeFleetHealthTool, makeFleetSessionTool, makeFleetStatusTool, makeFleetUsageTool, makeLLMClassifier, makeMailInboxTool, makeMailSendTool, makeMailboxTool, makeRollUpTool, makeSpawnTool, makeTerminateTool, makeWorkCompleteTool, normalizeRecipient, recordPackageAction, resolveMailboxIdentity, resolveProjectDir, rosterSummaryFromConfigs, scoreAgents, startPackageOutdatedWatcher, updatePackageOutdatedStatus, withDisabledToolFiltering };
11558
11720
  //# sourceMappingURL=index.js.map
11559
11721
  //# sourceMappingURL=index.js.map