caveat-cli 0.16.2 → 0.16.3

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.
@@ -2721,7 +2721,7 @@ var require_dumper = __commonJS({
2721
2721
  var hasFoldableLine = false;
2722
2722
  var shouldTrackWidth = lineWidth !== -1;
2723
2723
  var previousLineBreak = -1;
2724
- var plain = isPlainSafeFirst2(string.charCodeAt(0)) && !isWhitespace2(string.charCodeAt(string.length - 1));
2724
+ var plain2 = isPlainSafeFirst2(string.charCodeAt(0)) && !isWhitespace2(string.charCodeAt(string.length - 1));
2725
2725
  if (singleLineOnly) {
2726
2726
  for (i2 = 0; i2 < string.length; i2++) {
2727
2727
  char = string.charCodeAt(i2);
@@ -2729,7 +2729,7 @@ var require_dumper = __commonJS({
2729
2729
  return STYLE_DOUBLE2;
2730
2730
  }
2731
2731
  prev_char = i2 > 0 ? string.charCodeAt(i2 - 1) : null;
2732
- plain = plain && isPlainSafe2(char, prev_char);
2732
+ plain2 = plain2 && isPlainSafe2(char, prev_char);
2733
2733
  }
2734
2734
  } else {
2735
2735
  for (i2 = 0; i2 < string.length; i2++) {
@@ -2745,12 +2745,12 @@ var require_dumper = __commonJS({
2745
2745
  return STYLE_DOUBLE2;
2746
2746
  }
2747
2747
  prev_char = i2 > 0 ? string.charCodeAt(i2 - 1) : null;
2748
- plain = plain && isPlainSafe2(char, prev_char);
2748
+ plain2 = plain2 && isPlainSafe2(char, prev_char);
2749
2749
  }
2750
2750
  hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i2 - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
2751
2751
  }
2752
2752
  if (!hasLineBreak && !hasFoldableLine) {
2753
- return plain && !testAmbiguousType(string) ? STYLE_PLAIN2 : STYLE_SINGLE2;
2753
+ return plain2 && !testAmbiguousType(string) ? STYLE_PLAIN2 : STYLE_SINGLE2;
2754
2754
  }
2755
2755
  if (indentPerLevel > 9 && needIndentIndicator2(string)) {
2756
2756
  return STYLE_DOUBLE2;
@@ -6112,7 +6112,7 @@ var require_semver2 = __commonJS({
6112
6112
  "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/index.js"(exports2, module2) {
6113
6113
  "use strict";
6114
6114
  var internalRe = require_re();
6115
- var constants = require_constants();
6115
+ var constants2 = require_constants();
6116
6116
  var SemVer = require_semver();
6117
6117
  var identifiers = require_identifiers();
6118
6118
  var parse2 = require_parse2();
@@ -6194,8 +6194,8 @@ var require_semver2 = __commonJS({
6194
6194
  re: internalRe.re,
6195
6195
  src: internalRe.src,
6196
6196
  tokens: internalRe.t,
6197
- SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
6198
- RELEASE_TYPES: constants.RELEASE_TYPES,
6197
+ SEMVER_SPEC_VERSION: constants2.SEMVER_SPEC_VERSION,
6198
+ RELEASE_TYPES: constants2.RELEASE_TYPES,
6199
6199
  compareIdentifiers: identifiers.compareIdentifiers,
6200
6200
  rcompareIdentifiers: identifiers.rcompareIdentifiers
6201
6201
  };
@@ -8367,14 +8367,14 @@ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, te
8367
8367
  var hasFoldableLine = false;
8368
8368
  var shouldTrackWidth = lineWidth !== -1;
8369
8369
  var previousLineBreak = -1;
8370
- var plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
8370
+ var plain2 = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
8371
8371
  if (singleLineOnly || forceQuotes) {
8372
8372
  for (i2 = 0; i2 < string.length; char >= 65536 ? i2 += 2 : i2++) {
8373
8373
  char = codePointAt(string, i2);
8374
8374
  if (!isPrintable(char)) {
8375
8375
  return STYLE_DOUBLE;
8376
8376
  }
8377
- plain = plain && isPlainSafe(char, prevChar, inblock);
8377
+ plain2 = plain2 && isPlainSafe(char, prevChar, inblock);
8378
8378
  prevChar = char;
8379
8379
  }
8380
8380
  } else {
@@ -8390,13 +8390,13 @@ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, te
8390
8390
  } else if (!isPrintable(char)) {
8391
8391
  return STYLE_DOUBLE;
8392
8392
  }
8393
- plain = plain && isPlainSafe(char, prevChar, inblock);
8393
+ plain2 = plain2 && isPlainSafe(char, prevChar, inblock);
8394
8394
  prevChar = char;
8395
8395
  }
8396
8396
  hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i2 - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
8397
8397
  }
8398
8398
  if (!hasLineBreak && !hasFoldableLine) {
8399
- if (plain && !forceQuotes && !testAmbiguousType(string)) {
8399
+ if (plain2 && !forceQuotes && !testAmbiguousType(string)) {
8400
8400
  return STYLE_PLAIN;
8401
8401
  }
8402
8402
  return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
@@ -8963,7 +8963,7 @@ import { readFileSync as readFileSync2, readdirSync as readdirSync2, statSync, e
8963
8963
  import { join as join2, relative } from "node:path";
8964
8964
  function scanSource(opts) {
8965
8965
  const { db, source, entriesRoot } = opts;
8966
- const now = opts.now ?? (() => (/* @__PURE__ */ new Date()).toISOString());
8966
+ const now2 = opts.now ?? (() => (/* @__PURE__ */ new Date()).toISOString());
8967
8967
  db.exec("DROP TABLE IF EXISTS temp.touched");
8968
8968
  db.exec("CREATE TEMP TABLE touched(rowid INTEGER PRIMARY KEY)");
8969
8969
  const insertTouched = db.prepare("INSERT INTO touched (rowid) VALUES (?)");
@@ -8981,7 +8981,7 @@ function scanSource(opts) {
8981
8981
  path: rel,
8982
8982
  content: src,
8983
8983
  file_mtime: mtime,
8984
- indexed_at: now()
8984
+ indexed_at: now2()
8985
8985
  });
8986
8986
  const existing = db.prepare("SELECT rowid, file_mtime, path FROM entries WHERE source = ? AND id = ?").get(source, row.id);
8987
8987
  if (existing && existing.file_mtime === mtime && existing.path === rel) {
@@ -9351,7 +9351,7 @@ async function prewarmSealedKeys(opts) {
9351
9351
  return failures;
9352
9352
  }
9353
9353
  function scanSealedSource(opts) {
9354
- const now = opts.now ?? (() => (/* @__PURE__ */ new Date()).toISOString());
9354
+ const now2 = opts.now ?? (() => (/* @__PURE__ */ new Date()).toISOString());
9355
9355
  const bundle = readFileSync3(opts.bundlePath);
9356
9356
  const { header } = readSealedHeader(bundle);
9357
9357
  const contentKey = opts.keyProvider.resolveContentKey(header.keyId, header.keyserverUrl);
@@ -9370,7 +9370,7 @@ function scanSealedSource(opts) {
9370
9370
  path: file.relPath,
9371
9371
  content: file.content.toString("utf-8"),
9372
9372
  file_mtime: bundleMtime,
9373
- indexed_at: now()
9373
+ indexed_at: now2()
9374
9374
  });
9375
9375
  const existing = opts.db.prepare("SELECT rowid FROM entries WHERE source = ? AND id = ?").get(opts.source, row.id);
9376
9376
  const rowid = upsertEntry(opts.db, row);
@@ -9496,9 +9496,9 @@ function acquireFileLock(lockFilePath) {
9496
9496
  }
9497
9497
  return tryCreateLock(lockFilePath) ? { path: lockFilePath } : null;
9498
9498
  }
9499
- function releaseFileLock(lock) {
9499
+ function releaseFileLock(lock2) {
9500
9500
  try {
9501
- unlinkSync(lock.path);
9501
+ unlinkSync(lock2.path);
9502
9502
  } catch (err) {
9503
9503
  if (err.code !== "ENOENT") throw err;
9504
9504
  }
@@ -9506,8 +9506,8 @@ function releaseFileLock(lock) {
9506
9506
  function acquireReindexLock(caveatHome) {
9507
9507
  return acquireFileLock(lockPath(caveatHome));
9508
9508
  }
9509
- function releaseReindexLock(lock) {
9510
- releaseFileLock(lock);
9509
+ function releaseReindexLock(lock2) {
9510
+ releaseFileLock(lock2);
9511
9511
  }
9512
9512
  function reindexAllSources(opts) {
9513
9513
  const { db, paths, logger, keyProvider } = opts;
@@ -14800,14 +14800,14 @@ function acquirePendingClaim(caveatHome, sessionId, key, options2 = {}) {
14800
14800
  const dir = join6(pendingDirFor(caveatHome, sessionId), ".claims");
14801
14801
  mkdirSync3(dir, { recursive: true, mode: 448 });
14802
14802
  const path = join6(dir, `${key}.claim`);
14803
- const now = options2.now ?? Date.now();
14803
+ const now2 = options2.now ?? Date.now();
14804
14804
  const ttlMs = options2.ttlMs ?? CLAIM_TTL_MS;
14805
14805
  for (let attempt = 0; attempt < 2; attempt++) {
14806
14806
  const ownerToken = randomBytes(16).toString("hex");
14807
14807
  try {
14808
14808
  const fd = openSync(path, "wx", 384);
14809
14809
  try {
14810
- writeFileSync2(fd, JSON.stringify({ ownerToken, createdAt: now }), "utf-8");
14810
+ writeFileSync2(fd, JSON.stringify({ ownerToken, createdAt: now2 }), "utf-8");
14811
14811
  } finally {
14812
14812
  closeSync(fd);
14813
14813
  }
@@ -14825,7 +14825,7 @@ function acquirePendingClaim(caveatHome, sessionId, key, options2 = {}) {
14825
14825
  if (typeof parsed.createdAt === "number") createdAt = parsed.createdAt;
14826
14826
  } catch {
14827
14827
  }
14828
- if (now - createdAt <= ttlMs) return null;
14828
+ if (now2 - createdAt <= ttlMs) return null;
14829
14829
  unlinkSync2(path);
14830
14830
  } catch (retryError) {
14831
14831
  if (retryError && typeof retryError === "object" && retryError.code === "ENOENT") continue;
@@ -14895,8 +14895,8 @@ function cleanupStalePendingDirs(caveatHome, options2 = {}) {
14895
14895
  if (staleDays < 0) {
14896
14896
  throw new Error(`cleanupStalePendingDirs: staleDays must be >= 0 (got ${staleDays})`);
14897
14897
  }
14898
- const now = options2.now ?? /* @__PURE__ */ new Date();
14899
- const cutoffMs = now.getTime() - staleDays * 24 * 60 * 60 * 1e3;
14898
+ const now2 = options2.now ?? /* @__PURE__ */ new Date();
14899
+ const cutoffMs = now2.getTime() - staleDays * 24 * 60 * 60 * 1e3;
14900
14900
  const root = join6(caveatHome, "pending");
14901
14901
  if (!existsSync6(root)) return { removed: [], kept: 0 };
14902
14902
  return withPendingQueueLock(caveatHome, () => {
@@ -14917,7 +14917,7 @@ function cleanupStalePendingDirs(caveatHome, options2 = {}) {
14917
14917
  continue;
14918
14918
  }
14919
14919
  if (!subStat.isDirectory()) continue;
14920
- if (hasNonExpiredPendingClaim(sub, now.getTime())) {
14920
+ if (hasNonExpiredPendingClaim(sub, now2.getTime())) {
14921
14921
  kept++;
14922
14922
  continue;
14923
14923
  }
@@ -14962,19 +14962,19 @@ function maybeSweepPendingDirs(caveatHome, options2 = {}) {
14962
14962
  `maybeSweepPendingDirs: debounceDays must be >= 0 (got ${debounceDays})`
14963
14963
  );
14964
14964
  }
14965
- const now = options2.now ?? /* @__PURE__ */ new Date();
14965
+ const now2 = options2.now ?? /* @__PURE__ */ new Date();
14966
14966
  const pendingRoot = join6(caveatHome, "pending");
14967
14967
  if (!existsSync6(pendingRoot)) return { skipped: "no_pending_dir" };
14968
14968
  const marker = join6(pendingRoot, ".last-sweep");
14969
14969
  try {
14970
14970
  const m = statSync5(marker);
14971
- const ageMs = now.getTime() - m.mtimeMs;
14971
+ const ageMs = now2.getTime() - m.mtimeMs;
14972
14972
  if (ageMs < debounceDays * 24 * 60 * 60 * 1e3) {
14973
14973
  return { skipped: "debounced" };
14974
14974
  }
14975
14975
  } catch {
14976
14976
  }
14977
- const result = cleanupStalePendingDirs(caveatHome, { staleDays, now });
14977
+ const result = cleanupStalePendingDirs(caveatHome, { staleDays, now: now2 });
14978
14978
  try {
14979
14979
  writeFileSync2(marker, "", "utf-8");
14980
14980
  } catch {
@@ -15532,8 +15532,8 @@ function autoSyncNotification(outcome) {
15532
15532
  }
15533
15533
  async function runAutoSync(opts) {
15534
15534
  if (process.env[CAVEAT_AUTO_SYNC_ENV] === "off") return { ran: false };
15535
- const lock = acquireFileLock(autoSyncLockPath(opts.caveatHome));
15536
- if (!lock) return { ran: false };
15535
+ const lock2 = acquireFileLock(autoSyncLockPath(opts.caveatHome));
15536
+ if (!lock2) return { ran: false };
15537
15537
  let reindexLock = null;
15538
15538
  try {
15539
15539
  reindexLock = acquireReindexLock(opts.caveatHome);
@@ -15614,7 +15614,7 @@ async function runAutoSync(opts) {
15614
15614
  }
15615
15615
  }
15616
15616
  try {
15617
- releaseFileLock(lock);
15617
+ releaseFileLock(lock2);
15618
15618
  } catch (err) {
15619
15619
  opts.logger.warn(`autosync lock release failed: ${errorMessage3(err)}`);
15620
15620
  }
@@ -16371,9 +16371,9 @@ function readCodexSessionSignals(transcriptPath) {
16371
16371
  }
16372
16372
 
16373
16373
  // ../../packages/core/dist/markHit.js
16374
- function markHit(db, keys, now = () => (/* @__PURE__ */ new Date()).toISOString()) {
16374
+ function markHit(db, keys, now2 = () => (/* @__PURE__ */ new Date()).toISOString()) {
16375
16375
  if (keys.length === 0) return;
16376
- const ts = now();
16376
+ const ts = now2();
16377
16377
  const stmt = db.prepare(
16378
16378
  "UPDATE entries SET last_hit_at = ? WHERE source = ? AND id = ?"
16379
16379
  );
@@ -16453,8 +16453,8 @@ function logHookQueryMiss(miss, dependencies = fsDependencies) {
16453
16453
  function listStale(db, opts = {}) {
16454
16454
  const days = opts.days ?? 90;
16455
16455
  const limit = opts.limit ?? 50;
16456
- const now = (opts.now ?? (() => /* @__PURE__ */ new Date()))();
16457
- const cutoff = new Date(now.getTime() - days * 24 * 60 * 60 * 1e3).toISOString();
16456
+ const now2 = (opts.now ?? (() => /* @__PURE__ */ new Date()))();
16457
+ const cutoff = new Date(now2.getTime() - days * 24 * 60 * 60 * 1e3).toISOString();
16458
16458
  const conditions = ["(last_hit_at IS NULL OR last_hit_at < ?)"];
16459
16459
  const params = [cutoff];
16460
16460
  if (opts.visibility === "public" || opts.visibility === "private") {
@@ -17241,9 +17241,321 @@ function boundedCount(value) {
17241
17241
  return Math.min(1e4, Math.max(0, Math.floor(value)));
17242
17242
  }
17243
17243
 
17244
+ // ../../packages/core/dist/runtimeErrors.js
17245
+ import { spawnSync } from "node:child_process";
17246
+ import { createHash as createHash7, randomBytes as randomBytes3 } from "node:crypto";
17247
+ import { closeSync as closeSync2, constants, existsSync as existsSync15, fstatSync, lstatSync, mkdirSync as mkdirSync9, openSync as openSync2, readFileSync as readFileSync13, renameSync as renameSync5, rmSync as rmSync6, statSync as statSync7, writeFileSync as writeFileSync9 } from "node:fs";
17248
+ import { arch as hostArch, homedir as homedir3, platform as hostPlatform } from "node:os";
17249
+ import { dirname as dirname8, join as join14 } from "node:path";
17250
+ import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
17251
+ var RUNTIME_ERRORS_SCHEMA = "caveat.runtime_errors.v1";
17252
+ var STATE_VERSION = "1.0";
17253
+ var MAX_RECORDS = 256;
17254
+ var RETENTION_MS = 30 * 864e5;
17255
+ var MAX_CONFIG_BYTES = 64 * 1024;
17256
+ var definitions = {
17257
+ "CAVEAT.DATABASE_OPEN_FAILED": { component: "database", severity: "high", template: "Caveat database open failed" },
17258
+ "CAVEAT.INDEX_FAILED": { component: "index", severity: "high", template: "Caveat index operation failed" },
17259
+ "CAVEAT.SYNC_FAILED": { component: "sync", severity: "high", template: "Caveat own sync failed" },
17260
+ "CAVEAT.MCP_SERVER_FAILED": { component: "mcp", severity: "high", template: "Caveat MCP server failed" },
17261
+ "CAVEAT.MCP_TOOL_FAILED": { component: "mcp_tool", severity: "high", template: "Caveat MCP tool handler failed" },
17262
+ "CAVEAT.CLAUDE_HOOK_FAILED": { component: "claude_hook", severity: "high", template: "Caveat Claude hook failed" },
17263
+ "CAVEAT.CODEX_HOOK_FAILED": { component: "codex_hook", severity: "high", template: "Caveat Codex hook failed" }
17264
+ };
17265
+ function normalizeOptions(options2 = {}) {
17266
+ return "env" in options2 || "configPath" in options2 || "storePath" in options2 || "version" in options2 || "isWindows" in options2 ? options2 : { env: options2 };
17267
+ }
17268
+ var plain = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
17269
+ var exact = (v, keys) => Object.keys(v).length === keys.length && keys.every((key) => Object.hasOwn(v, key));
17270
+ var validTime = (v) => typeof v === "string" && Number.isFinite(Date.parse(v)) && new Date(v).toISOString() === v;
17271
+ var validVersion = (v) => typeof v === "string" && /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(v);
17272
+ var validOs = (v) => typeof v === "string" && ["darwin", "linux", "windows"].includes(v);
17273
+ var validArch = (v) => typeof v === "string" && ["x64", "arm64", "arm", "ia32"].includes(v);
17274
+ var windows = (env) => env.OS === "Windows_NT" || hostPlatform() === "win32";
17275
+ function defaultFactoryReporterConfigPath(env = process.env) {
17276
+ const home = env.HOME || env.USERPROFILE || homedir3();
17277
+ return windows(env) ? join14(env.LOCALAPPDATA || join14(home, "AppData", "Local"), "dotagents", "factory-reporter", "config.json") : join14(env.XDG_CONFIG_HOME || join14(home, ".config"), "dotagents", "factory-reporter.json");
17278
+ }
17279
+ function runtimeErrorsStatePath(env = process.env) {
17280
+ const home = env.HOME || env.USERPROFILE || homedir3();
17281
+ return windows(env) ? join14(env.LOCALAPPDATA || join14(home, "AppData", "Local"), "caveat", "runtime-errors.json") : join14(env.XDG_STATE_HOME || join14(home, ".local", "state"), "caveat", "runtime-errors.json");
17282
+ }
17283
+ function collectionEnabled(options2 = {}) {
17284
+ const env = options2.env ?? process.env;
17285
+ try {
17286
+ const path = options2.configPath ?? defaultFactoryReporterConfigPath(env);
17287
+ const isWin = (options2.isWindows ?? windows)(env);
17288
+ const before = lstatSync(path);
17289
+ if (!before.isFile() || before.isSymbolicLink() || before.size > MAX_CONFIG_BYTES) return false;
17290
+ if (isWin) secureWindowsAcl(path, options2.aclRunner);
17291
+ else assertPosix(before, 384);
17292
+ const fd = openSync2(path, constants.O_RDONLY | constants.O_NONBLOCK | (constants.O_NOFOLLOW ?? 0));
17293
+ let text;
17294
+ try {
17295
+ const after = fstatSync(fd);
17296
+ if (before.dev !== after.dev || before.ino !== after.ino || after.size > MAX_CONFIG_BYTES) return false;
17297
+ if (!isWin) assertPosix(after, 384);
17298
+ text = readFileSync13(fd, "utf8");
17299
+ } finally {
17300
+ closeSync2(fd);
17301
+ }
17302
+ const config = JSON.parse(text);
17303
+ return plain(config) && exact(config, ["schema_version", "host", "collection", "reporting"]) && config.schema_version === "1.0" && plain(config.host) && exact(config.host, ["id", "profile"]) && typeof config.host.id === "string" && /^[a-z0-9][a-z0-9._-]{0,63}$/.test(config.host.id) && ["server", "mac", "wsl", "windows-native"].includes(config.host.profile) && plain(config.collection) && exact(config.collection, ["enabled"]) && config.collection.enabled === true && canonicalReporting(config.reporting);
17304
+ } catch {
17305
+ return false;
17306
+ }
17307
+ }
17308
+ var empty = () => ({ schema: RUNTIME_ERRORS_SCHEMA, next_sequence: 1, acknowledged_through: 0, records: [] });
17309
+ function fingerprint(code) {
17310
+ const d = definitions[code];
17311
+ return createHash7("sha256").update(`caveat\0${d.component}\0${code}\0${d.template}`).digest("hex");
17312
+ }
17313
+ function ensureSafeDir(dir, isWin, options2 = {}) {
17314
+ const existed = existsSync15(dir);
17315
+ mkdirSync9(dir, { recursive: true, mode: 448 });
17316
+ const s = lstatSync(dir);
17317
+ if (!s.isDirectory() || s.isSymbolicLink()) throw Error("store_unsafe");
17318
+ if (isWin) secureWindowsAcl(dir, options2.aclRunner, true, !existed);
17319
+ else assertPosix(s, 448);
17320
+ }
17321
+ function canonicalReporting(value) {
17322
+ if (!plain(value) || !Object.keys(value).every((key) => ["enabled", "endpoint", "credential_file"].includes(key)) || typeof value.enabled !== "boolean") return false;
17323
+ if (value.endpoint !== void 0) {
17324
+ if (typeof value.endpoint !== "string" || value.endpoint.length > 2048) return false;
17325
+ try {
17326
+ if (!["http:", "https:"].includes(new URL(value.endpoint).protocol)) return false;
17327
+ } catch {
17328
+ return false;
17329
+ }
17330
+ }
17331
+ if (value.credential_file !== void 0 && (typeof value.credential_file !== "string" || value.credential_file.length < 1 || value.credential_file.length > 4096)) return false;
17332
+ return !value.enabled || value.endpoint !== void 0 && value.credential_file !== void 0;
17333
+ }
17334
+ var WINDOWS_ACL_VERIFY = String.raw`$p=$env:CAVEAT_ACL_PATH;$isDir=$env:CAVEAT_ACL_DIRECTORY -eq '1';$sid=[System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value;$acl=if($isDir){[System.IO.Directory]::GetAccessControl($p)}else{[System.IO.File]::GetAccessControl($p)};$owner=$acl.GetOwner([System.Security.Principal.SecurityIdentifier]).Value;if($owner -ne $sid){exit 41};$rules=@($acl.GetAccessRules($true,$true,[System.Security.Principal.SecurityIdentifier]));if($rules.Count -ne 1){exit 42};$r=$rules[0];if($r.IdentityReference.Value -ne $sid -or $r.AccessControlType -ne 'Allow' -or $r.IsInherited -or ($r.FileSystemRights -band [System.Security.AccessControl.FileSystemRights]::FullControl) -ne [System.Security.AccessControl.FileSystemRights]::FullControl){exit 43}`;
17335
+ var WINDOWS_ACL_APPLY = String.raw`$p=$env:CAVEAT_ACL_PATH;$isDir=$env:CAVEAT_ACL_DIRECTORY -eq '1';$sid=[System.Security.Principal.WindowsIdentity]::GetCurrent().User;$acl=if($isDir){New-Object System.Security.AccessControl.DirectorySecurity}else{New-Object System.Security.AccessControl.FileSecurity};$acl.SetAccessRuleProtection($true,$false);$flags=if($isDir){[System.Security.AccessControl.InheritanceFlags]'ContainerInherit, ObjectInherit'}else{[System.Security.AccessControl.InheritanceFlags]::None};$rule=New-Object System.Security.AccessControl.FileSystemAccessRule($sid,'FullControl',$flags,[System.Security.AccessControl.PropagationFlags]::None,[System.Security.AccessControl.AccessControlType]::Allow);$acl.SetOwner($sid);$acl.AddAccessRule($rule);if($isDir){[System.IO.Directory]::SetAccessControl($p,$acl)}else{[System.IO.File]::SetAccessControl($p,$acl)};` + WINDOWS_ACL_VERIFY;
17336
+ function runWindowsAcl(path, directory, apply) {
17337
+ const result = spawnSync("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", apply ? WINDOWS_ACL_APPLY : WINDOWS_ACL_VERIFY], { env: { ...process.env, CAVEAT_ACL_PATH: path, CAVEAT_ACL_DIRECTORY: directory ? "1" : "0" }, stdio: "ignore", timeout: 3e3, windowsHide: true });
17338
+ if (result.status !== 0) throw Error("store_unsafe");
17339
+ }
17340
+ function secureWindowsAcl(path, runner, directory = false, apply = false) {
17341
+ try {
17342
+ (runner ?? runWindowsAcl)(path, directory, apply);
17343
+ } catch {
17344
+ throw Error("store_unsafe");
17345
+ }
17346
+ }
17347
+ function assertPosix(info, mode) {
17348
+ if ((info.mode & 511) !== mode || typeof process.getuid === "function" && info.uid !== process.getuid()) throw Error("store_unsafe");
17349
+ }
17350
+ function ensureSafeFile(path, isWin, options2 = {}) {
17351
+ const s = lstatSync(path);
17352
+ if (!s.isFile() || s.isSymbolicLink()) throw Error("store_unsafe");
17353
+ if (isWin) secureWindowsAcl(path, options2.aclRunner);
17354
+ else assertPosix(statSync7(path), 384);
17355
+ }
17356
+ function validate(store) {
17357
+ if (!plain(store) || !exact(store, ["schema", "next_sequence", "acknowledged_through", "records"])) throw Error("state_invalid");
17358
+ const checked = store;
17359
+ if (checked.schema !== RUNTIME_ERRORS_SCHEMA || !Number.isSafeInteger(checked.next_sequence) || checked.next_sequence < 1 || !Number.isSafeInteger(checked.acknowledged_through) || checked.acknowledged_through < 0 || checked.acknowledged_through >= checked.next_sequence || !Array.isArray(checked.records) || checked.records.length > MAX_RECORDS) throw Error("state_invalid");
17360
+ const seen = /* @__PURE__ */ new Set();
17361
+ let previous = 0;
17362
+ for (const record of checked.records) {
17363
+ if (!plain(record) || !exact(record, ["product", "product_version", "component", "error_code", "message_template", "severity", "fingerprint", "count", "first_seen", "last_seen", "state_schema_version", "os", "arch", "status", "resolved_at", "reason_code", "sequence"])) throw Error("state_invalid");
17364
+ const code = typeof record.error_code === "string" ? record.error_code : void 0;
17365
+ const d = code && definitions[code];
17366
+ if (!d || record.product !== "caveat" || !validVersion(record.product_version) || record.component !== d.component || record.message_template !== d.template || record.severity !== d.severity || record.fingerprint !== fingerprint(code) || seen.has(record.fingerprint) || !Number.isSafeInteger(record.count) || record.count < 1 || !validTime(record.first_seen) || !validTime(record.last_seen) || Date.parse(record.first_seen) > Date.parse(record.last_seen) || record.state_schema_version !== STATE_VERSION || !validOs(record.os) || !validArch(record.arch) || !Number.isSafeInteger(record.sequence) || record.sequence <= previous || record.sequence >= checked.next_sequence || !["open", "resolved"].includes(record.status) || record.status === "open" && (record.resolved_at !== null || record.reason_code !== null) || record.status === "resolved" && (typeof record.resolved_at !== "string" || !validTime(record.resolved_at) || Date.parse(record.resolved_at) < Date.parse(record.last_seen) || record.reason_code !== "operator_resolved")) throw Error("state_invalid");
17367
+ seen.add(record.fingerprint);
17368
+ previous = record.sequence;
17369
+ }
17370
+ }
17371
+ function readStore(path, isWin, options2 = {}) {
17372
+ if (!existsSync15(path)) return empty();
17373
+ ensureSafeFile(path, isWin, options2);
17374
+ const value = JSON.parse(readFileSync13(path, "utf8"));
17375
+ validate(value);
17376
+ return value;
17377
+ }
17378
+ function lock(path, isWin, fn, options2 = {}) {
17379
+ ensureSafeDir(dirname8(path), isWin, options2);
17380
+ const lockPath2 = `${path}.lock.sqlite`;
17381
+ let created = false;
17382
+ try {
17383
+ writeFileSync9(lockPath2, "", { mode: 384, flag: "wx" });
17384
+ created = true;
17385
+ } catch (error) {
17386
+ if (!plain(error) || error.code !== "EEXIST") throw error;
17387
+ }
17388
+ if (created) {
17389
+ if (isWin) secureWindowsAcl(lockPath2, options2.aclRunner, false, true);
17390
+ else assertPosix(statSync7(lockPath2), 384);
17391
+ } else ensureSafeFile(lockPath2, isWin, options2);
17392
+ const db = new DatabaseSync3(lockPath2);
17393
+ let begun = false;
17394
+ try {
17395
+ ensureSafeFile(lockPath2, isWin, options2);
17396
+ db.exec("PRAGMA busy_timeout=5000; PRAGMA synchronous=FULL; BEGIN IMMEDIATE");
17397
+ begun = true;
17398
+ const result = fn();
17399
+ db.exec("COMMIT");
17400
+ begun = false;
17401
+ return result;
17402
+ } finally {
17403
+ if (begun) try {
17404
+ db.exec("ROLLBACK");
17405
+ } catch {
17406
+ }
17407
+ db.close();
17408
+ }
17409
+ }
17410
+ function writeStore(path, store, isWin, options2 = {}) {
17411
+ validate(store);
17412
+ ensureSafeDir(dirname8(path), isWin, options2);
17413
+ const temporary = join14(dirname8(path), `.runtime-errors-${process.pid}-${randomBytes3(6).toString("hex")}`);
17414
+ try {
17415
+ writeFileSync9(temporary, `${JSON.stringify(store)}
17416
+ `, { mode: 384, flag: "wx" });
17417
+ if (isWin) secureWindowsAcl(temporary, options2.aclRunner, false, true);
17418
+ else assertPosix(statSync7(temporary), 384);
17419
+ renameSync5(temporary, path);
17420
+ ensureSafeFile(path, isWin, options2);
17421
+ } finally {
17422
+ rmSync6(temporary, { force: true });
17423
+ }
17424
+ }
17425
+ function now(options2) {
17426
+ const value = options2.now ? new Date(options2.now) : /* @__PURE__ */ new Date();
17427
+ if (Number.isNaN(value.valueOf())) throw Error("invalid_time");
17428
+ return value.toISOString();
17429
+ }
17430
+ function normalizeOs(value) {
17431
+ return value === "win32" ? "windows" : value;
17432
+ }
17433
+ function optionsFor(options2) {
17434
+ const env = options2.env ?? process.env;
17435
+ const isWin = (options2.isWindows ?? windows)(env);
17436
+ return { env, isWin, path: options2.storePath ?? runtimeErrorsStatePath(env) };
17437
+ }
17438
+ function requireCursor(value) {
17439
+ if (!Number.isSafeInteger(value) || value < 0) throw Error("invalid_cursor");
17440
+ }
17441
+ function requireLimit(value) {
17442
+ if (!Number.isSafeInteger(value) || value < 1 || value > MAX_RECORDS) throw Error("invalid_limit");
17443
+ }
17444
+ function snapshot(options2 = {}) {
17445
+ const afterCursor = options2.afterCursor ?? 0, limit = options2.limit ?? MAX_RECORDS;
17446
+ requireCursor(afterCursor);
17447
+ requireLimit(limit);
17448
+ const enabled = collectionEnabled(options2);
17449
+ const { path, isWin } = optionsFor(options2);
17450
+ const store = enabled ? readStore(path, isWin, options2) : empty();
17451
+ if (afterCursor > store.next_sequence - 1) throw Error("invalid_cursor");
17452
+ const all = store.records.filter((r2) => r2.sequence > afterCursor);
17453
+ const rows = all.slice(0, limit);
17454
+ return { schema: RUNTIME_ERRORS_SCHEMA, product: "caveat", version: options2.version ?? "unknown", state_schema_version: STATE_VERSION, cursor: { high_watermark: store.next_sequence - 1, acknowledged_through: store.acknowledged_through, next: rows.at(-1)?.sequence ?? afterCursor }, runtime_errors: rows.filter((r2) => r2.status === "open").map(({ error_code, component, status, severity, fingerprint: fingerprint22, message_template, count, first_seen, last_seen, state_schema_version }) => ({ error_code, component, status, severity, fingerprint: fingerprint22, message_template, occurrence_count: count, first_seen, last_seen, state_schema_version })), resolutions: rows.filter((r2) => r2.status === "resolved").map(({ fingerprint: fingerprint22, resolved_at, reason_code }) => ({ fingerprint: fingerprint22, resolved_at, reason_code })), diagnostics: { collection: enabled ? "enabled" : "disabled", status: enabled ? "ready" : "not_applicable", total_count: store.records.length, pending_count: store.records.filter((r2) => r2.sequence > store.acknowledged_through).length, truncated: all.length > rows.length } };
17455
+ }
17456
+ function runtimeErrorsDiagnostics(options2 = {}) {
17457
+ if (!collectionEnabled(options2)) return { schema: "caveat.runtime_error_diagnostics.v1", collection: "disabled", status: "not_applicable", total_count: 0, open_count: 0, pending_count: 0, high_watermark: 0, acknowledged_through: 0 };
17458
+ try {
17459
+ const { path, isWin } = optionsFor(options2);
17460
+ const store = readStore(path, isWin, options2);
17461
+ return { schema: "caveat.runtime_error_diagnostics.v1", collection: "enabled", status: "ready", total_count: store.records.length, open_count: store.records.filter((record) => record.status === "open").length, pending_count: store.records.filter((record) => record.sequence > store.acknowledged_through).length, high_watermark: store.next_sequence - 1, acknowledged_through: store.acknowledged_through };
17462
+ } catch {
17463
+ return { schema: "caveat.runtime_error_diagnostics.v1", collection: "enabled", status: "unavailable", total_count: 0, open_count: 0, pending_count: 0, high_watermark: 0, acknowledged_through: 0 };
17464
+ }
17465
+ }
17466
+ function recordRuntimeError(code, options2 = {}) {
17467
+ if (!collectionEnabled(options2)) return { status: "disabled" };
17468
+ const { path, isWin } = optionsFor(options2);
17469
+ return lock(path, isWin, () => {
17470
+ const store = readStore(path, isWin, options2);
17471
+ const definition = definitions[code];
17472
+ if (!definition) throw Error("unknown_runtime_code");
17473
+ const key = fingerprint(code);
17474
+ const sequence = store.next_sequence++;
17475
+ const time = now(options2);
17476
+ const existing = store.records.find((r2) => r2.fingerprint === key);
17477
+ const version = options2.version ?? "0.0.0";
17478
+ const os = normalizeOs(options2.os ?? hostPlatform());
17479
+ const arch = options2.arch ?? hostArch();
17480
+ if (!validVersion(version) || !validOs(os) || !validArch(arch)) throw Error("invalid_runtime_metadata");
17481
+ if (existing) {
17482
+ existing.product_version = version;
17483
+ existing.os = os;
17484
+ existing.arch = arch;
17485
+ existing.count += 1;
17486
+ existing.last_seen = time;
17487
+ existing.sequence = sequence;
17488
+ existing.status = "open";
17489
+ existing.resolved_at = null;
17490
+ existing.reason_code = null;
17491
+ } else {
17492
+ if (store.records.length >= MAX_RECORDS) throw Error("store_overflow");
17493
+ store.records.push({ product: "caveat", product_version: version, component: definition.component, error_code: code, message_template: definition.template, severity: definition.severity, fingerprint: key, count: 1, first_seen: time, last_seen: time, state_schema_version: STATE_VERSION, os, arch, status: "open", resolved_at: null, reason_code: null, sequence });
17494
+ }
17495
+ store.records.sort((a, b2) => a.sequence - b2.sequence);
17496
+ writeStore(path, store, isWin, options2);
17497
+ return { status: "recorded", fingerprint: key, sequence };
17498
+ }, options2);
17499
+ }
17500
+ function observeRuntimeError(code, options2 = {}) {
17501
+ try {
17502
+ recordRuntimeError(code, options2);
17503
+ } catch {
17504
+ try {
17505
+ process.stderr.write("[caveat:runtime-errors] store_unavailable\n");
17506
+ } catch {
17507
+ }
17508
+ }
17509
+ }
17510
+ var runtimeErrorsSnapshot = (afterCursor = 0, limit = MAX_RECORDS, options2 = {}) => snapshot({ ...normalizeOptions(options2), afterCursor, limit });
17511
+ function acknowledgeRuntimeErrors(cursor, options2 = {}) {
17512
+ const normalized = normalizeOptions(options2);
17513
+ requireCursor(cursor);
17514
+ if (!collectionEnabled(normalized)) return snapshot({ ...normalized, afterCursor: cursor });
17515
+ const { path, isWin } = optionsFor(normalized);
17516
+ lock(path, isWin, () => {
17517
+ const store = readStore(path, isWin, normalized);
17518
+ if (cursor >= store.next_sequence) throw Error("invalid_cursor");
17519
+ store.acknowledged_through = Math.max(store.acknowledged_through, cursor);
17520
+ writeStore(path, store, isWin, normalized);
17521
+ }, normalized);
17522
+ return snapshot(normalized);
17523
+ }
17524
+ function setRuntimeErrorStatus(fingerprintValue, status, options2 = {}) {
17525
+ const normalized = normalizeOptions(options2);
17526
+ if (!/^[0-9a-f]{64}$/.test(fingerprintValue)) throw Error("invalid_fingerprint");
17527
+ if (!collectionEnabled(normalized)) return snapshot(normalized);
17528
+ const { path, isWin } = optionsFor(normalized);
17529
+ lock(path, isWin, () => {
17530
+ const store = readStore(path, isWin, normalized);
17531
+ const record = store.records.find((r2) => r2.fingerprint === fingerprintValue);
17532
+ if (!record) throw Error("fingerprint_not_found");
17533
+ if (record.status === status) return;
17534
+ record.status = status;
17535
+ record.resolved_at = status === "resolved" ? now(normalized) : null;
17536
+ record.reason_code = status === "resolved" ? "operator_resolved" : null;
17537
+ record.sequence = store.next_sequence++;
17538
+ store.records.sort((a, b2) => a.sequence - b2.sequence);
17539
+ writeStore(path, store, isWin, normalized);
17540
+ }, normalized);
17541
+ return snapshot(normalized);
17542
+ }
17543
+ function compactRuntimeErrors(options2 = {}) {
17544
+ const normalized = normalizeOptions(options2);
17545
+ if (!collectionEnabled(normalized)) return snapshot(normalized);
17546
+ const { path, isWin } = optionsFor(normalized);
17547
+ lock(path, isWin, () => {
17548
+ const store = readStore(path, isWin, normalized);
17549
+ const cutoff = Date.parse(now(normalized)) - RETENTION_MS;
17550
+ store.records = store.records.filter((record) => !(record.status === "resolved" && record.sequence <= store.acknowledged_through && record.resolved_at !== null && Date.parse(record.resolved_at) <= cutoff));
17551
+ writeStore(path, store, isWin, normalized);
17552
+ }, normalized);
17553
+ return snapshot(normalized);
17554
+ }
17555
+
17244
17556
  // ../../packages/core/dist/env.js
17245
17557
  var import_semver = __toESM(require_semver2(), 1);
17246
- function fingerprint() {
17558
+ function fingerprint2() {
17247
17559
  return {
17248
17560
  os: process.platform,
17249
17561
  arch: process.arch,
@@ -17252,16 +17564,16 @@ function fingerprint() {
17252
17564
  }
17253
17565
 
17254
17566
  // ../../packages/core/dist/id.js
17255
- import { randomBytes as randomBytes3 } from "node:crypto";
17567
+ import { randomBytes as randomBytes4 } from "node:crypto";
17256
17568
  function randomHex(hexChars) {
17257
17569
  const bytes = Math.ceil(hexChars / 2);
17258
- return randomBytes3(bytes).toString("hex").slice(0, hexChars);
17570
+ return randomBytes4(bytes).toString("hex").slice(0, hexChars);
17259
17571
  }
17260
- function slugify(title, now = () => /* @__PURE__ */ new Date()) {
17572
+ function slugify(title, now2 = () => /* @__PURE__ */ new Date()) {
17261
17573
  const lowered = title.toLowerCase();
17262
17574
  const sluggy = lowered.replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
17263
17575
  if (!sluggy || !/^[a-z0-9]/.test(sluggy)) {
17264
- const d = now();
17576
+ const d = now2();
17265
17577
  const yyyy = d.getUTCFullYear().toString().padStart(4, "0");
17266
17578
  const mm = (d.getUTCMonth() + 1).toString().padStart(2, "0");
17267
17579
  const dd = d.getUTCDate().toString().padStart(2, "0");
@@ -17275,13 +17587,13 @@ function resolveCollision(baseId, exists2) {
17275
17587
  while (exists2(`${baseId}-${n}`)) n++;
17276
17588
  return `${baseId}-${n}`;
17277
17589
  }
17278
- function generateSourceSession(now = () => /* @__PURE__ */ new Date()) {
17279
- return `${now().toISOString()}/${randomHex(12)}`;
17590
+ function generateSourceSession(now2 = () => /* @__PURE__ */ new Date()) {
17591
+ return `${now2().toISOString()}/${randomHex(12)}`;
17280
17592
  }
17281
17593
 
17282
17594
  // ../../packages/core/dist/writer.js
17283
- import { existsSync as existsSync15, mkdirSync as mkdirSync9, writeFileSync as writeFileSync9 } from "node:fs";
17284
- import { dirname as dirname8 } from "node:path";
17595
+ import { existsSync as existsSync16, mkdirSync as mkdirSync10, writeFileSync as writeFileSync10 } from "node:fs";
17596
+ import { dirname as dirname9 } from "node:path";
17285
17597
  function buildEntry(frontmatter, sections) {
17286
17598
  const bodyParts = [];
17287
17599
  for (const [heading, content2] of Object.entries(sections)) {
@@ -17299,24 +17611,24 @@ ${body}${body ? "\n" : ""}`;
17299
17611
  return { content, body };
17300
17612
  }
17301
17613
  function writeEntryFile(filePath, content) {
17302
- const dir = dirname8(filePath);
17303
- if (!existsSync15(dir)) mkdirSync9(dir, { recursive: true });
17304
- writeFileSync9(filePath, content, "utf-8");
17614
+ const dir = dirname9(filePath);
17615
+ if (!existsSync16(dir)) mkdirSync10(dir, { recursive: true });
17616
+ writeFileSync10(filePath, content, "utf-8");
17305
17617
  }
17306
17618
 
17307
17619
  // ../../packages/core/dist/record.js
17308
- import { statSync as statSync7 } from "node:fs";
17309
- import { join as join14 } from "node:path";
17620
+ import { statSync as statSync8 } from "node:fs";
17621
+ import { join as join15 } from "node:path";
17310
17622
  var DEFAULT_CATEGORY = "misc";
17311
17623
  function recordEntry(input, opts) {
17312
- const now = opts.now ?? (() => /* @__PURE__ */ new Date());
17624
+ const now2 = opts.now ?? (() => /* @__PURE__ */ new Date());
17313
17625
  const source = opts.source ?? "own";
17314
- const nowDate = now();
17626
+ const nowDate = now2();
17315
17627
  const ymd = formatYmd(nowDate);
17316
- const baseId = input.id ?? slugify(input.title, now);
17628
+ const baseId = input.id ?? slugify(input.title, now2);
17317
17629
  const id = resolveCollision(baseId, (candidate) => entryExists(opts.db, source, candidate));
17318
17630
  const mergedEnv = {
17319
- ...fingerprint(),
17631
+ ...fingerprint2(),
17320
17632
  ...input.environment ?? {}
17321
17633
  };
17322
17634
  const frontmatter = {
@@ -17328,7 +17640,7 @@ function recordEntry(input, opts) {
17328
17640
  tags: input.tags ?? [],
17329
17641
  environment: mergedEnv,
17330
17642
  source_project: null,
17331
- source_session: generateSourceSession(now),
17643
+ source_session: generateSourceSession(now2),
17332
17644
  created_at: ymd,
17333
17645
  updated_at: ymd,
17334
17646
  last_verified: ymd
@@ -17342,9 +17654,9 @@ function recordEntry(input, opts) {
17342
17654
  const built = buildEntry(frontmatter, sections);
17343
17655
  const category = input.category ?? DEFAULT_CATEGORY;
17344
17656
  const relPath = `${category}/${id}.md`;
17345
- const filePath = join14(opts.entriesRoot, relPath);
17657
+ const filePath = join15(opts.entriesRoot, relPath);
17346
17658
  writeEntryFile(filePath, built.content);
17347
- const stat = statSync7(filePath);
17659
+ const stat = statSync8(filePath);
17348
17660
  upsertEntry(opts.db, {
17349
17661
  id,
17350
17662
  source,
@@ -17372,8 +17684,8 @@ function formatYmd(d) {
17372
17684
  }
17373
17685
 
17374
17686
  // ../../packages/core/dist/update.js
17375
- import { readFileSync as readFileSync13, statSync as statSync8, writeFileSync as writeFileSync10 } from "node:fs";
17376
- import { join as join15 } from "node:path";
17687
+ import { readFileSync as readFileSync14, statSync as statSync9, writeFileSync as writeFileSync11 } from "node:fs";
17688
+ import { join as join16 } from "node:path";
17377
17689
  var IMMUTABLE_KEYS = /* @__PURE__ */ new Set([
17378
17690
  "id",
17379
17691
  "created_at",
@@ -17385,15 +17697,15 @@ function updateEntry(id, patch, opts) {
17385
17697
  if (source !== "own") {
17386
17698
  throw new Error("community \u30A8\u30F3\u30C8\u30EA\u306F\u8CFC\u8AAD\u7269\u3067\u3059; \u7DE8\u96C6\u306F\u4E0A\u6D41\u3067\u884C\u3063\u3066\u304F\u3060\u3055\u3044");
17387
17699
  }
17388
- const now = opts.now ?? (() => /* @__PURE__ */ new Date());
17389
- const nowDate = now();
17700
+ const now2 = opts.now ?? (() => /* @__PURE__ */ new Date());
17701
+ const nowDate = now2();
17390
17702
  const row = opts.db.prepare("SELECT path FROM entries WHERE source = ? AND id = ?").get(source, id);
17391
17703
  if (!row) {
17392
17704
  throw new Error(`caveat not found: id=${id} source=${source}`);
17393
17705
  }
17394
17706
  const relPath = row.path;
17395
- const filePath = join15(opts.entriesRoot, relPath);
17396
- const raw = readFileSync13(filePath, "utf-8");
17707
+ const filePath = join16(opts.entriesRoot, relPath);
17708
+ const raw = readFileSync14(filePath, "utf-8");
17397
17709
  const parsed = parseMarkdown(raw);
17398
17710
  if (patch.frontmatter) {
17399
17711
  for (const key of Object.keys(patch.frontmatter)) {
@@ -17434,8 +17746,8 @@ function updateEntry(id, patch, opts) {
17434
17746
  }
17435
17747
  }
17436
17748
  const built = buildEntry(mergedFrontmatter, mergedSections);
17437
- writeFileSync10(filePath, built.content, "utf-8");
17438
- const stat = statSync8(filePath);
17749
+ writeFileSync11(filePath, built.content, "utf-8");
17750
+ const stat = statSync9(filePath);
17439
17751
  upsertEntry(opts.db, {
17440
17752
  id,
17441
17753
  source,
@@ -17459,15 +17771,15 @@ function formatYmd2(d) {
17459
17771
  }
17460
17772
 
17461
17773
  // ../../packages/core/dist/proposalEval.js
17462
- import { createHash as createHash7 } from "node:crypto";
17774
+ import { createHash as createHash8 } from "node:crypto";
17463
17775
  import { isAbsolute as isAbsolute2, relative as relative4, resolve as resolve4, sep } from "node:path";
17464
17776
 
17465
17777
  // ../../packages/core/dist/proposalExecution.js
17466
- import { createHash as createHash8 } from "node:crypto";
17778
+ import { createHash as createHash9 } from "node:crypto";
17467
17779
  import { basename as basename3, isAbsolute as isAbsolute3 } from "node:path";
17468
17780
 
17469
17781
  // ../../packages/core/dist/proposalExecutionCompiler.js
17470
- import { createHash as createHash9 } from "node:crypto";
17782
+ import { createHash as createHash10 } from "node:crypto";
17471
17783
 
17472
17784
  export {
17473
17785
  __commonJS,
@@ -17531,7 +17843,13 @@ export {
17531
17843
  decideCodexSidecarExecution,
17532
17844
  buildCodexSidecarDiagnosticsCommand,
17533
17845
  buildCodexSidecarReadOnlySmokeCommand,
17534
- buildCodexSidecarRunCommand
17846
+ buildCodexSidecarRunCommand,
17847
+ runtimeErrorsDiagnostics,
17848
+ observeRuntimeError,
17849
+ runtimeErrorsSnapshot,
17850
+ acknowledgeRuntimeErrors,
17851
+ setRuntimeErrorStatus,
17852
+ compactRuntimeErrors
17535
17853
  };
17536
17854
  /*! Bundled license information:
17537
17855
 
@@ -17554,4 +17872,4 @@ strip-bom-string/index.js:
17554
17872
  js-yaml/dist/js-yaml.mjs:
17555
17873
  (*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT *)
17556
17874
  */
17557
- //# sourceMappingURL=chunk-3MLJQLWY.js.map
17875
+ //# sourceMappingURL=chunk-PD5E6TFL.js.map