@hasna/hooks 0.12.7 → 0.12.8

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.
package/dist/index.js CHANGED
@@ -5107,12 +5107,12 @@ import { spawnSync as spawnSync2 } from "child_process";
5107
5107
  import { closeSync as closeSync23, fstatSync as fstatSync23, openSync as openSync23, readFileSync as readFileSync22 } from "fs";
5108
5108
  import { O_NOFOLLOW as O_NOFOLLOW2, O_NONBLOCK as O_NONBLOCK2, O_RDONLY as O_RDONLY2 } from "constants";
5109
5109
  import { hostname as osHostname } from "os";
5110
- import { isAbsolute as isAbsolute8, join as join22 } from "path";
5110
+ import { isAbsolute as isAbsolute9, join as join22 } from "path";
5111
5111
  import { createRequire as createRequire2 } from "module";
5112
5112
  import { fileURLToPath as fileURLToPath22 } from "url";
5113
- import { closeSync as closeSync6, fstatSync as fstatSync5, lstatSync as lstatSync10, openSync as openSync6, readFileSync as readFileSync10, realpathSync as realpathSync13, statSync } from "fs";
5113
+ import { closeSync as closeSync6, fstatSync as fstatSync5, lstatSync as lstatSync10, openSync as openSync6, readFileSync as readFileSync10, realpathSync as realpathSync12, statSync } from "fs";
5114
5114
  import { O_NOFOLLOW, O_NONBLOCK, O_RDONLY } from "constants";
5115
- import { basename as basename7, dirname as dirname15, join as join14, relative as relative2, sep as sep4 } from "path";
5115
+ import { basename as basename8, dirname as dirname16, join as join14, relative as relative2, sep as sep4 } from "path";
5116
5116
  import { fileURLToPath as fileURLToPath4, pathToFileURL } from "url";
5117
5117
  function envToken2(name) {
5118
5118
  return name.toUpperCase().replace(/-/g, "_");
@@ -5186,7 +5186,7 @@ function o(e2, r2, t2) {
5186
5186
  }
5187
5187
  }
5188
5188
  function entryPoint(directory2) {
5189
- const root = realpathSync13(directory2);
5189
+ const root = realpathSync12(directory2);
5190
5190
  const fd = openSync6(join14(root, "package.json"), O_RDONLY | O_NOFOLLOW | O_NONBLOCK);
5191
5191
  let pkg;
5192
5192
  try {
@@ -5207,7 +5207,7 @@ function entryPoint(directory2) {
5207
5207
  if (/[\\%?#\0]/.test(target) || parts.some((part) => !part || part === "." || part === ".." || part === "node_modules")) {
5208
5208
  throw new Error("Invalid Secrets import export");
5209
5209
  }
5210
- const file2 = realpathSync13(join14(root, ...parts));
5210
+ const file2 = realpathSync12(join14(root, ...parts));
5211
5211
  const within = relative2(root, file2);
5212
5212
  if (!within || within === ".." || within.startsWith(`..${sep4}`) || !statSync(file2).isFile()) {
5213
5213
  throw new Error("Secrets import export escapes its package or is not a file");
@@ -5215,9 +5215,9 @@ function entryPoint(directory2) {
5215
5215
  return pathToFileURL(file2).href;
5216
5216
  }
5217
5217
  function resolveInstalledSecrets(parentUrl) {
5218
- let directory2 = dirname15(fileURLToPath4(parentUrl));
5218
+ let directory2 = dirname16(fileURLToPath4(parentUrl));
5219
5219
  for (;; ) {
5220
- if (basename7(directory2) !== "node_modules") {
5220
+ if (basename8(directory2) !== "node_modules") {
5221
5221
  const candidate = join14(directory2, "node_modules", PACKAGE);
5222
5222
  let absent = false;
5223
5223
  try {
@@ -5230,7 +5230,7 @@ function resolveInstalledSecrets(parentUrl) {
5230
5230
  if (!absent)
5231
5231
  return entryPoint(candidate);
5232
5232
  }
5233
- const parent = dirname15(directory2);
5233
+ const parent = dirname16(directory2);
5234
5234
  if (parent === directory2)
5235
5235
  throw new Error("Secrets SDK is not installed for this consumer");
5236
5236
  directory2 = parent;
@@ -5242,7 +5242,7 @@ function homeDir(env) {
5242
5242
  }
5243
5243
  function absoluteOverride(env, key) {
5244
5244
  const value = env[key]?.trim();
5245
- return value && isAbsolute8(value) ? value : null;
5245
+ return value && isAbsolute9(value) ? value : null;
5246
5246
  }
5247
5247
  function hasnaHomeDir(env) {
5248
5248
  const override = absoluteOverride(env, HASNA_HOME_ENV_KEY);
@@ -5314,8 +5314,8 @@ function configFileReadsCoherent(before, after) {
5314
5314
  return before.dev === after.dev && before.ino === after.ino && before.size === after.size && before.mtimeMs === after.mtimeMs && before.ctimeMs === after.ctimeMs;
5315
5315
  }
5316
5316
  function readAppConfigFile(path) {
5317
- const unsafe = (reason) => {
5318
- throw new CredentialFileUnsafeError(path, reason);
5317
+ const unsafe = (reason2) => {
5318
+ throw new CredentialFileUnsafeError(path, reason2);
5319
5319
  };
5320
5320
  let fd = -1;
5321
5321
  try {
@@ -5516,8 +5516,8 @@ function readKeychainItem(name, env, kind, options) {
5516
5516
  try {
5517
5517
  result = run(["find-generic-password", "-a", account, "-s", service, "-w"]);
5518
5518
  } catch (error61) {
5519
- const reason = keychainFailureHint(error61 instanceof Error ? error61.message : String(error61));
5520
- throw new CredentialResolutionError(name, `The Keychain lookup for ${source} could not run${reason}. A Keychain failure is never resolved ` + `around: fix the keychain, or delete the item to fall through to the credential on disk.`, [source]);
5519
+ const reason2 = keychainFailureHint(error61 instanceof Error ? error61.message : String(error61));
5520
+ throw new CredentialResolutionError(name, `The Keychain lookup for ${source} could not run${reason2}. A Keychain failure is never resolved ` + `around: fix the keychain, or delete the item to fall through to the credential on disk.`, [source]);
5521
5521
  }
5522
5522
  if (result.status === KEYCHAIN_ITEM_NOT_FOUND_STATUS)
5523
5523
  return null;
@@ -5985,8 +5985,8 @@ var init_transport = __esm(() => {
5985
5985
  };
5986
5986
  CredentialFileUnsafeError = class CredentialFileUnsafeError extends Error {
5987
5987
  path;
5988
- constructor(path, reason) {
5989
- super(`Refusing unsafe credential/config file ${path}: ${reason}.`);
5988
+ constructor(path, reason2) {
5989
+ super(`Refusing unsafe credential/config file ${path}: ${reason2}.`);
5990
5990
  this.name = "CredentialFileUnsafeError";
5991
5991
  this.path = path;
5992
5992
  }
@@ -6202,7 +6202,7 @@ var init_db_writer = __esm(() => {
6202
6202
  });
6203
6203
 
6204
6204
  // src/lib/hook-env.ts
6205
- import { dirname as dirname27, isAbsolute as isAbsolute26 } from "path";
6205
+ import { dirname as dirname28, isAbsolute as isAbsolute28 } from "path";
6206
6206
  import { existsSync as existsSync16, realpathSync as realpathSync19, statSync as statSync2 } from "fs";
6207
6207
  import { tmpdir as tmpdir2 } from "os";
6208
6208
  function isDeniedEnvName(name) {
@@ -6222,7 +6222,7 @@ function isBashFunctionEnvName(name) {
6222
6222
  return name.startsWith("BASH_FUNC_");
6223
6223
  }
6224
6224
  function isUnsafePathEntry(entry, home) {
6225
- if (entry === "" || !isAbsolute26(entry))
6225
+ if (entry === "" || !isAbsolute28(entry))
6226
6226
  return true;
6227
6227
  if (home && (entry === home || entry.startsWith(home + "/")))
6228
6228
  return true;
@@ -6230,16 +6230,16 @@ function isUnsafePathEntry(entry, home) {
6230
6230
  return true;
6231
6231
  if (entry === "/var/tmp" || entry.startsWith("/var/tmp/"))
6232
6232
  return true;
6233
- const canonical8 = (path) => {
6233
+ const canonical9 = (path) => {
6234
6234
  try {
6235
6235
  return realpathSync19(path);
6236
6236
  } catch {
6237
6237
  return path;
6238
6238
  }
6239
6239
  };
6240
- const resolved = canonical8(entry);
6240
+ const resolved = canonical9(entry);
6241
6241
  for (const root of [home, tmpdir2(), "/tmp", "/var/tmp"].filter((value) => Boolean(value))) {
6242
- const blocked = canonical8(root);
6242
+ const blocked = canonical9(root);
6243
6243
  if (resolved === blocked || resolved.startsWith(blocked + "/"))
6244
6244
  return true;
6245
6245
  }
@@ -6253,7 +6253,7 @@ function sanitizeHookPath(pathValue, home) {
6253
6253
  const baseline = PATH_BASELINE.slice();
6254
6254
  if (process.platform === "darwin" && existsSync16("/opt/homebrew/bin"))
6255
6255
  baseline.push("/opt/homebrew/bin");
6256
- const bunDir = dirname27(process.execPath);
6256
+ const bunDir = dirname28(process.execPath);
6257
6257
  const seen = new Set;
6258
6258
  const out = [];
6259
6259
  for (const dir of baseline) {
@@ -6378,9 +6378,9 @@ __export(exports_run, {
6378
6378
  });
6379
6379
  import { randomBytes as randomBytes2 } from "crypto";
6380
6380
  import { rmSync as rmSync4, writeFileSync as writeFileSync13 } from "fs";
6381
- import { basename as basename13, dirname as dirname28, isAbsolute as isAbsolute27, join as join35 } from "path";
6381
+ import { basename as basename14, dirname as dirname29, isAbsolute as isAbsolute29, join as join35 } from "path";
6382
6382
  function extensionOf(scriptPath) {
6383
- const base = basename13(scriptPath);
6383
+ const base = basename14(scriptPath);
6384
6384
  const dot = base.lastIndexOf(".");
6385
6385
  return dot > 0 ? base.slice(dot + 1) : "ts";
6386
6386
  }
@@ -6392,9 +6392,9 @@ function shebangInterpreter(firstLine) {
6392
6392
  return null;
6393
6393
  const parts = rest.split(/\s+/);
6394
6394
  if (parts[0] === "env" || parts[0] === "/usr/bin/env") {
6395
- return parts[1] && parts[1] !== "-S" ? basename13(parts[1]) : parts[2] ? basename13(parts[2]) : null;
6395
+ return parts[1] && parts[1] !== "-S" ? basename14(parts[1]) : parts[2] ? basename14(parts[2]) : null;
6396
6396
  }
6397
- return basename13(parts[0]);
6397
+ return basename14(parts[0]);
6398
6398
  }
6399
6399
  function interpreterFor(name, scriptPath, content) {
6400
6400
  const ext = extensionOf(scriptPath);
@@ -6447,7 +6447,7 @@ async function readPipeWithDeadline(stream, deadlineMs) {
6447
6447
  return chunks.join("");
6448
6448
  }
6449
6449
  async function executeVerifiedScript(options) {
6450
- const scriptDir = dirname28(options.scriptPath);
6450
+ const scriptDir = dirname29(options.scriptPath);
6451
6451
  const interpreter = interpreterFor(options.name, options.scriptPath, options.content);
6452
6452
  const tempPath = join35(scriptDir, `.hooks-verified-${randomBytes2(12).toString("hex")}.${interpreter.tempExt}`);
6453
6453
  let proc = null;
@@ -6458,7 +6458,7 @@ async function executeVerifiedScript(options) {
6458
6458
  }, options.timeout) : null;
6459
6459
  try {
6460
6460
  writeFileSync13(tempPath, options.content, { flag: "wx", mode: 384 });
6461
- proc = Bun.spawn([...interpreter.command, isAbsolute27(tempPath) ? tempPath : `./${tempPath}`, ...options.args ?? []], {
6461
+ proc = Bun.spawn([...interpreter.command, isAbsolute29(tempPath) ? tempPath : `./${tempPath}`, ...options.args ?? []], {
6462
6462
  stdin: new Response(options.stdin),
6463
6463
  stdout: "pipe",
6464
6464
  stderr: "pipe",
@@ -7572,8 +7572,8 @@ function getHook(name) {
7572
7572
  return HOOKS.find((h) => h.name === name);
7573
7573
  }
7574
7574
  // src/lib/installer.ts
7575
- import { existsSync as existsSync12, mkdirSync as mkdirSync7, readFileSync as readFileSync8, readdirSync as readdirSync4, realpathSync as realpathSync11, rmdirSync, unlinkSync as unlinkSync2, writeFileSync as writeFileSync7 } from "fs";
7576
- import { join as join12, dirname as dirname8, basename as basename4, resolve as resolve19 } from "path";
7575
+ import { existsSync as existsSync12, mkdirSync as mkdirSync7, readFileSync as readFileSync8, readdirSync as readdirSync4, realpathSync as realpathSync9, rmdirSync, unlinkSync as unlinkSync2, writeFileSync as writeFileSync7 } from "fs";
7576
+ import { join as join12, dirname as dirname9, basename as basename5, resolve as resolve21 } from "path";
7577
7577
  import { homedir as homedir7 } from "os";
7578
7578
  import { fileURLToPath as fileURLToPath3 } from "url";
7579
7579
 
@@ -8135,12 +8135,12 @@ function writeHookSettingsPreimage(path, settings, before, beforeWrite) {
8135
8135
  }
8136
8136
 
8137
8137
  // src/lib/claude-skills-coordination.ts
8138
- import { createHash as createHash8 } from "crypto";
8138
+ import { createHash as createHash9 } from "crypto";
8139
8139
  import { existsSync as existsSync11, lstatSync as lstatSync8 } from "fs";
8140
8140
  import { homedir as homedir6 } from "os";
8141
- import { join as join11, resolve as resolve8 } from "path";
8141
+ import { join as join11, resolve as resolve9 } from "path";
8142
8142
 
8143
- // ../../node_modules/.bun/@hasna+skills@0.10.47+a00d3064559565bb/node_modules/@hasna/skills/dist/index.js
8143
+ // ../../node_modules/.bun/@hasna+skills@0.10.53+a00d3064559565bb/node_modules/@hasna/skills/dist/index.js
8144
8144
  import { existsSync as existsSync10 } from "fs";
8145
8145
  import { homedir as homedir5 } from "os";
8146
8146
  import { join as join10, resolve as resolve4 } from "path";
@@ -8153,26 +8153,28 @@ import { createHash as createHash32 } from "crypto";
8153
8153
  import { createHash as createHash22 } from "crypto";
8154
8154
  import { closeSync as closeSync5, constants as constants4, fstatSync as fstatSync4, lstatSync as lstatSync32, openSync as openSync5, readSync } from "fs";
8155
8155
  import { basename as basename2, dirname as dirname32, isAbsolute as isAbsolute22, resolve as resolve22 } from "path";
8156
- import { basename as basename3, isAbsolute as isAbsolute32, join as join72, resolve as resolve32, sep as sep22 } from "path";
8157
- import { createHash as createHash23 } from "crypto";
8158
- import { lstatSync as lstatSync24, readFileSync as readFileSync19, readdirSync as readdirSync10, realpathSync as realpathSync10 } from "fs";
8159
- import { basename as basename10, dirname as dirname19, isAbsolute as isAbsolute18, join as join32, resolve as resolve18, sep as sep8 } from "path";
8156
+ import { basename as basename4, isAbsolute as isAbsolute4, join as join72, resolve as resolve42, sep as sep22 } from "path";
8157
+ import { createHash as createHash42 } from "crypto";
8158
+ import { basename as basename3, dirname as dirname42, isAbsolute as isAbsolute32, resolve as resolve32 } from "path";
8159
+ import { createHash as createHash25 } from "crypto";
8160
+ import { lstatSync as lstatSync25, readFileSync as readFileSync20, readdirSync as readdirSync10, realpathSync as realpathSync11 } from "fs";
8161
+ import { basename as basename11, dirname as dirname20, isAbsolute as isAbsolute21, join as join32, resolve as resolve20, sep as sep8 } from "path";
8160
8162
  import { isDeepStrictEqual as isDeepStrictEqual7 } from "util";
8161
- import { dirname as dirname42, isAbsolute as isAbsolute4, join as join82, resolve as resolve42 } from "path";
8163
+ import { dirname as dirname52, isAbsolute as isAbsolute5, join as join82, resolve as resolve5 } from "path";
8162
8164
  import { lstatSync as lstatSync42, readFileSync as readFileSync62, opendirSync } from "fs";
8163
- import { createHash as createHash42 } from "crypto";
8164
- import { lstatSync as lstatSync5, opendirSync as opendirSync2 } from "fs";
8165
- import { dirname as dirname52, isAbsolute as isAbsolute5, join as join92, resolve as resolve5 } from "path";
8166
8165
  import { createHash as createHash52 } from "crypto";
8167
- import { closeSync as closeSync22, constants as constants22, fstatSync as fstatSync22, lstatSync as lstatSync6, openSync as openSync22, readSync as readSync2 } from "fs";
8168
- import { dirname as dirname62, isAbsolute as isAbsolute6, resolve as resolve6 } from "path";
8166
+ import { lstatSync as lstatSync5, opendirSync as opendirSync2 } from "fs";
8167
+ import { dirname as dirname62, isAbsolute as isAbsolute6, join as join92, resolve as resolve6 } from "path";
8169
8168
  import { createHash as createHash62 } from "crypto";
8170
- import { lstatSync as lstatSync7, readlinkSync } from "fs";
8171
- import { dirname as dirname7, isAbsolute as isAbsolute7, join as join102, parse as parse2, resolve as resolve7, sep as sep32 } from "path";
8169
+ import { closeSync as closeSync22, constants as constants22, fstatSync as fstatSync22, lstatSync as lstatSync6, openSync as openSync22, readSync as readSync2 } from "fs";
8170
+ import { dirname as dirname7, isAbsolute as isAbsolute7, resolve as resolve7 } from "path";
8172
8171
  import { createHash as createHash7 } from "crypto";
8173
- import { closeSync as closeSync12, constants as constants12, fstatSync as fstatSync12, lstatSync as lstatSync22, openSync as openSync12, opendirSync as opendirSync5, readSync as readSync10 } from "fs";
8174
- import { basename as basename8, dirname as dirname17, isAbsolute as isAbsolute16, join as join31, resolve as resolve16 } from "path";
8175
- import { isAbsolute as isAbsolute15, join as join30, resolve as resolve15 } from "path";
8172
+ import { lstatSync as lstatSync7, readlinkSync } from "fs";
8173
+ import { dirname as dirname8, isAbsolute as isAbsolute8, join as join102, parse as parse2, resolve as resolve8, sep as sep32 } from "path";
8174
+ import { createHash as createHash8 } from "crypto";
8175
+ import { closeSync as closeSync13, constants as constants13, fstatSync as fstatSync13, lstatSync as lstatSync23, openSync as openSync13, opendirSync as opendirSync5, readSync as readSync10 } from "fs";
8176
+ import { basename as basename9, dirname as dirname18, isAbsolute as isAbsolute19, join as join31, resolve as resolve18 } from "path";
8177
+ import { isAbsolute as isAbsolute18, join as join30, resolve as resolve17 } from "path";
8176
8178
  import { createRequire } from "module";
8177
8179
 
8178
8180
  // ../contracts/dist/kernel-lock.js
@@ -8506,47 +8508,47 @@ class KernelLock {
8506
8508
  }
8507
8509
  }
8508
8510
 
8509
- // ../../node_modules/.bun/@hasna+skills@0.10.47+a00d3064559565bb/node_modules/@hasna/skills/dist/index.js
8511
+ // ../../node_modules/.bun/@hasna+skills@0.10.53+a00d3064559565bb/node_modules/@hasna/skills/dist/index.js
8510
8512
  import { execFileSync } from "child_process";
8511
- import { createHash as createHash11 } from "crypto";
8513
+ import { createHash as createHash12 } from "crypto";
8512
8514
  import { accessSync, constants as constants6, lstatSync as lstatSync12, readFileSync as readFileSync11, realpathSync as realpathSync32, statSync as statSync7 } from "fs";
8513
- import { basename as basename5, delimiter, dirname as dirname10, isAbsolute as isAbsolute9, join as join15, relative as relative4, resolve as resolve9, sep as sep5 } from "path";
8514
- import { basename as basename6, dirname as dirname11, join as join17, relative as relative5, resolve as resolve10, sep as sep6 } from "path";
8515
+ import { basename as basename6, delimiter, dirname as dirname11, isAbsolute as isAbsolute10, join as join15, relative as relative4, resolve as resolve10, sep as sep5 } from "path";
8516
+ import { basename as basename7, dirname as dirname12, join as join17, relative as relative5, resolve as resolve11, sep as sep6 } from "path";
8515
8517
  import { lstatSync as lstatSync13, readdirSync as readdirSync6, readlinkSync as readlinkSync3, realpathSync as realpathSync6 } from "fs";
8516
8518
  import { realpathSync as realpathSync5 } from "fs";
8517
- import { isAbsolute as isAbsolute11, normalize as normalize2 } from "path";
8518
- import { createHash as createHash13, randomUUID as randomUUID2 } from "crypto";
8519
+ import { isAbsolute as isAbsolute12, normalize as normalize2 } from "path";
8520
+ import { createHash as createHash14, randomUUID as randomUUID2 } from "crypto";
8519
8521
  import { closeSync as closeSync7, constants as constants7, fstatSync as fstatSync7, fsyncSync as fsyncSync2, lstatSync as lstatSync14, mkdirSync as mkdirSync5, openSync as openSync7, readFileSync as readFileSync12, readSync as readSync5, readlinkSync as readlinkSync4, realpathSync as realpathSync7, renameSync as renameSync22, unlinkSync as unlinkSync3, writeFileSync as writeFileSync4 } from "fs";
8520
- import { dirname as dirname12, isAbsolute as isAbsolute12, join as join18, resolve as resolve11 } from "path";
8522
+ import { dirname as dirname13, isAbsolute as isAbsolute13, join as join18, resolve as resolve12 } from "path";
8521
8523
  import { isDeepStrictEqual as isDeepStrictEqual2 } from "util";
8522
- import { createHash as createHash14 } from "crypto";
8523
- import { isDeepStrictEqual as isDeepStrictEqual3 } from "util";
8524
8524
  import { createHash as createHash15 } from "crypto";
8525
+ import { isDeepStrictEqual as isDeepStrictEqual3 } from "util";
8526
+ import { createHash as createHash16 } from "crypto";
8525
8527
  import { isDeepStrictEqual as isDeepStrictEqual4 } from "util";
8526
- import { createHash as createHash18, randomUUID as randomUUID3 } from "crypto";
8528
+ import { createHash as createHash20, randomUUID as randomUUID3 } from "crypto";
8527
8529
  import { isDeepStrictEqual as isDeepStrictEqual6 } from "util";
8528
- import { existsSync as existsSync92, lstatSync as lstatSync19, statSync as statSync9, mkdirSync as mkdirSync6, readFileSync as readFileSync14, readdirSync as readdirSync8, opendirSync as opendirSync3, readlinkSync as readlinkSync5, realpathSync as realpathSync9, renameSync as renameSync3, rmdirSync as rmdirSync2, writeFileSync as writeFileSync6, unlinkSync as unlinkSync4, chmodSync, openSync as openSync10, closeSync as closeSync10, fsyncSync as fsyncSync4, fstatSync as fstatSync10, readSync as readSync8, constants as constants10, linkSync as linkSync2 } from "fs";
8529
- import { dirname as dirname14, join as join23, resolve as resolve13, relative as relative6, isAbsolute as isAbsolute13, sep as sep7 } from "path";
8530
+ import { existsSync as existsSync92, lstatSync as lstatSync20, statSync as statSync9, mkdirSync as mkdirSync6, readFileSync as readFileSync15, readdirSync as readdirSync8, opendirSync as opendirSync3, readlinkSync as readlinkSync7, realpathSync as realpathSync10, renameSync as renameSync3, rmdirSync as rmdirSync2, writeFileSync as writeFileSync6, unlinkSync as unlinkSync4, chmodSync, openSync as openSync11, closeSync as closeSync11, fsyncSync as fsyncSync5, fstatSync as fstatSync11, readSync as readSync8, constants as constants11, linkSync as linkSync2 } from "fs";
8531
+ import { dirname as dirname15, join as join23, resolve as resolve15, relative as relative6, isAbsolute as isAbsolute16, sep as sep7 } from "path";
8530
8532
  import { homedir as homedir22 } from "os";
8531
8533
  import { closeSync as closeSync8, constants as constants8, fstatSync as fstatSync8, lstatSync as lstatSync15, openSync as openSync8, readSync as readSync6 } from "fs";
8532
8534
  import { join as join19 } from "path";
8533
- import { createHash as createHash16 } from "crypto";
8535
+ import { createHash as createHash17 } from "crypto";
8534
8536
  import { lstatSync as lstatSync16, readFileSync as readFileSync13, readdirSync as readdirSync7 } from "fs";
8535
8537
  import { join as join20 } from "path";
8536
8538
  import { existsSync as existsSync82, lstatSync as lstatSync17, realpathSync as realpathSync8 } from "fs";
8537
- import { join as join21, resolve as resolve12 } from "path";
8538
- import { closeSync as closeSync9, constants as constants9, fstatSync as fstatSync9, fsyncSync as fsyncSync3, lstatSync as lstatSync18, openSync as openSync9, readSync as readSync7, writeFileSync as writeFileSync5 } from "fs";
8539
- import { createHash as createHash17 } from "crypto";
8540
- import { dirname as dirname13 } from "path";
8541
- import { createHash as createHash19 } from "crypto";
8542
- import { constants as constants11, closeSync as closeSync11, fchmodSync, fstatSync as fstatSync11, fsyncSync as fsyncSync5, linkSync as linkSync3, lstatSync as lstatSync21, mkdirSync as mkdirSync9, openSync as openSync11, opendirSync as opendirSync4, readSync as readSync9, renameSync as renameSync5, rmdirSync as rmdirSync3, rmSync as rmSync3, unlinkSync as unlinkSync5, writeSync as writeSync2 } from "fs";
8543
- import { dirname as dirname16, isAbsolute as isAbsolute14, join as join29, parse as parse6, resolve as resolve14 } from "path";
8539
+ import { join as join21, resolve as resolve13 } from "path";
8540
+ import { closeSync as closeSync9, constants as constants9, fstatSync as fstatSync9, fsyncSync as fsyncSync3, lstatSync as lstatSync18, openSync as openSync9, readlinkSync as readlinkSync5, readSync as readSync7, writeFileSync as writeFileSync5 } from "fs";
8541
+ import { createHash as createHash18 } from "crypto";
8542
+ import { dirname as dirname14, isAbsolute as isAbsolute14, resolve as resolve14 } from "path";
8544
8543
  import { createHash as createHash21 } from "crypto";
8545
- import { closeSync as closeSync13, constants as constants13, fstatSync as fstatSync13, lstatSync as lstatSync23, openSync as openSync13, readSync as readSync11 } from "fs";
8546
- import { basename as basename9, dirname as dirname18, isAbsolute as isAbsolute17, resolve as resolve17 } from "path";
8547
- import { createHash as createHash222 } from "crypto";
8548
- import { isAbsolute as isAbsolute20 } from "path";
8549
- import { createHash as createHash27 } from "crypto";
8544
+ import { constants as constants12, closeSync as closeSync12, fchmodSync as fchmodSync2, fstatSync as fstatSync12, fsyncSync as fsyncSync6, linkSync as linkSync3, lstatSync as lstatSync22, mkdirSync as mkdirSync9, openSync as openSync12, opendirSync as opendirSync4, readSync as readSync9, renameSync as renameSync5, rmdirSync as rmdirSync3, rmSync as rmSync3, unlinkSync as unlinkSync5, writeSync as writeSync3 } from "fs";
8545
+ import { dirname as dirname17, isAbsolute as isAbsolute17, join as join29, parse as parse6, resolve as resolve16 } from "path";
8546
+ import { createHash as createHash23 } from "crypto";
8547
+ import { closeSync as closeSync14, constants as constants14, fstatSync as fstatSync14, lstatSync as lstatSync24, openSync as openSync14, readSync as readSync11 } from "fs";
8548
+ import { basename as basename10, dirname as dirname19, isAbsolute as isAbsolute20, resolve as resolve19 } from "path";
8549
+ import { createHash as createHash24 } from "crypto";
8550
+ import { isAbsolute as isAbsolute23 } from "path";
8551
+ import { createHash as createHash29 } from "crypto";
8550
8552
  var __defProp2 = Object.defineProperty;
8551
8553
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
8552
8554
  var __returnValue2 = (v) => v;
@@ -13654,8 +13656,8 @@ var require_cst_visit = __commonJS((exports) => {
13654
13656
  visit.REMOVE = REMOVE;
13655
13657
  visit.itemAtPath = (cst, path) => {
13656
13658
  let item = cst;
13657
- for (const [field, index] of path) {
13658
- const tok = item?.[field];
13659
+ for (const [field2, index] of path) {
13660
+ const tok = item?.[field2];
13659
13661
  if (tok && "items" in tok) {
13660
13662
  item = tok.items[index];
13661
13663
  } else
@@ -13665,8 +13667,8 @@ var require_cst_visit = __commonJS((exports) => {
13665
13667
  };
13666
13668
  visit.parentCollection = (cst, path) => {
13667
13669
  const parent = visit.itemAtPath(cst, path.slice(0, -1));
13668
- const field = path[path.length - 1][0];
13669
- const coll = parent?.[field];
13670
+ const field2 = path[path.length - 1][0];
13671
+ const coll = parent?.[field2];
13670
13672
  if (coll && "items" in coll)
13671
13673
  return coll;
13672
13674
  throw new Error("Parent collection not found");
@@ -13675,11 +13677,11 @@ var require_cst_visit = __commonJS((exports) => {
13675
13677
  let ctrl = visitor(item, path);
13676
13678
  if (typeof ctrl === "symbol")
13677
13679
  return ctrl;
13678
- for (const field of ["key", "value"]) {
13679
- const token = item[field];
13680
+ for (const field2 of ["key", "value"]) {
13681
+ const token = item[field2];
13680
13682
  if (token && "items" in token) {
13681
13683
  for (let i = 0;i < token.items.length; ++i) {
13682
- const ci = _visit(Object.freeze(path.concat([[field, i]])), token.items[i], visitor);
13684
+ const ci = _visit(Object.freeze(path.concat([[field2, i]])), token.items[i], visitor);
13683
13685
  if (typeof ci === "number")
13684
13686
  i = ci - 1;
13685
13687
  else if (ci === BREAK)
@@ -13689,7 +13691,7 @@ var require_cst_visit = __commonJS((exports) => {
13689
13691
  i -= 1;
13690
13692
  }
13691
13693
  }
13692
- if (typeof ctrl === "function" && field === "key")
13694
+ if (typeof ctrl === "function" && field2 === "key")
13693
13695
  ctrl = ctrl(item, path);
13694
13696
  }
13695
13697
  }
@@ -14111,9 +14113,9 @@ var require_lexer = __commonJS((exports) => {
14111
14113
  }
14112
14114
  }
14113
14115
  *parseQuotedScalar() {
14114
- const quote3 = this.charAt(0);
14115
- let end = this.buffer.indexOf(quote3, this.pos + 1);
14116
- if (quote3 === "'") {
14116
+ const quote22 = this.charAt(0);
14117
+ let end = this.buffer.indexOf(quote22, this.pos + 1);
14118
+ if (quote22 === "'") {
14117
14119
  while (end !== -1 && this.buffer[end + 1] === "'")
14118
14120
  end = this.buffer.indexOf("'", end + 2);
14119
14121
  } else {
@@ -16054,6 +16056,10 @@ function parse3(text) {
16054
16056
  need(root.entries.length <= CLAUDE_SETTINGS_WITNESS_LIMITS.rows, "exceeds its settings field limit");
16055
16057
  return root;
16056
16058
  }
16059
+ function parseNativeJsonObject(text) {
16060
+ need(typeof text === "string" && Buffer.byteLength(text) <= CLAUDE_SETTINGS_WITNESS_LIMITS.bytes, "exceeds its byte limit");
16061
+ return parse3(text);
16062
+ }
16057
16063
  var BOOLEAN_PREFERENCES = new Set([
16058
16064
  "autoScrollEnabled",
16059
16065
  "axScreenReader",
@@ -16105,6 +16111,8 @@ var BUILTIN_MODEL_SELECTIONS = new Set([
16105
16111
  "claude-opus-4-6[1m]",
16106
16112
  "claude-sonnet-4-6[1m]"
16107
16113
  ]);
16114
+ var CLAUDE_BUILTIN_THEMES = Object.freeze(["auto", "dark", "light", "dark-daltonized", "light-daltonized", "dark-ansi", "light-ansi"]);
16115
+ var BUILTIN_THEMES = new Set(CLAUDE_BUILTIN_THEMES);
16108
16116
  function canonical(value) {
16109
16117
  if (value.kind === "object")
16110
16118
  return { kind: "object", entries: value.entries.map(([key, child]) => [key, canonical(child)]).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0) };
@@ -16163,7 +16171,9 @@ function inferencePreference(key, child, version) {
16163
16171
  function settingsDigest(text, version = 1) {
16164
16172
  const value = parse3(text);
16165
16173
  value.entries = value.entries.filter(([key, child]) => {
16166
- if (version !== 1 && inferencePreference(key, child, version))
16174
+ if (version === 4 && key === "theme" && child.kind === "string" && BUILTIN_THEMES.has(child.value))
16175
+ return false;
16176
+ if (version !== 1 && inferencePreference(key, child, version === 4 ? 3 : version))
16167
16177
  return false;
16168
16178
  if (key === "model") {
16169
16179
  need(child.kind === "string", "contains an invalid model selection");
@@ -16221,6 +16231,26 @@ function upgradeClaudeSettingsWitness(previous, reviewedSettingsPath) {
16221
16231
  need(settingsDigest(before, 3) === sha256, "non-preference settings changed; explicit discovery review required");
16222
16232
  return { path: previous.path, hashMode: "claude-settings-v3", sha256 };
16223
16233
  }
16234
+ function captureClaudeSettingsV4(path, budget = { remaining: 256 * 1024 * 1024 }) {
16235
+ return { path, hashMode: "claude-settings-v4", sha256: settingsDigest(readNativeSettingsWitnessFile(path, budget), 4) };
16236
+ }
16237
+ function hashClaudeSettingsReplacementV4(text, budget) {
16238
+ need(typeof text === "string", "requires settings text");
16239
+ const bytes = Buffer.byteLength(text);
16240
+ need(bytes <= CLAUDE_SETTINGS_WITNESS_LIMITS.bytes && Number.isSafeInteger(budget.remaining) && budget.remaining >= bytes, "exceeds its byte limit");
16241
+ budget.remaining -= bytes;
16242
+ return settingsDigest(text, 4);
16243
+ }
16244
+ function upgradeClaudeSettingsWitnessV4(previous, reviewedSettingsPath) {
16245
+ need(previous && Object.keys(previous).every((key) => ["path", "hashMode", "sha256"].includes(key)) && (previous.hashMode === undefined || previous.hashMode === "bytes" || previous.hashMode === "claude-settings-v1" || previous.hashMode === "claude-settings-v2" || previous.hashMode === "claude-settings-v3") && typeof previous.sha256 === "string" && /^[a-f0-9]{64}$/.test(previous.sha256), "requires an exact prior settings witness");
16246
+ const budget = { remaining: 2 * CLAUDE_SETTINGS_WITNESS_LIMITS.bytes };
16247
+ const before = readNativeSettingsWitnessFile(reviewedSettingsPath, budget), current2 = readNativeSettingsWitnessFile(previous.path, budget);
16248
+ const beforeDigest = previous.hashMode === undefined || previous.hashMode === "bytes" ? createHash22("sha256").update(before).digest("hex") : settingsDigest(before, previous.hashMode === "claude-settings-v1" ? 1 : previous.hashMode === "claude-settings-v2" ? 2 : 3);
16249
+ need(beforeDigest === previous.sha256, "reviewed preimage does not match the prior witness");
16250
+ const sha256 = settingsDigest(current2, 4);
16251
+ need(settingsDigest(before, 4) === sha256, "non-preference settings changed; explicit discovery review required");
16252
+ return { path: previous.path, hashMode: "claude-settings-v4", sha256 };
16253
+ }
16224
16254
  function hashNativeJsonControls(text, excludedMetadata) {
16225
16255
  need(Buffer.byteLength(text) <= CLAUDE_SETTINGS_WITNESS_LIMITS.bytes, "exceeds its byte limit");
16226
16256
  const value = parse3(text);
@@ -16279,6 +16309,213 @@ function upgradeSumiSettingsWitness(previous, reviewedSettingsPath) {
16279
16309
  throw new Error("Sumi non-display settings changed; explicit discovery review required");
16280
16310
  return next;
16281
16311
  }
16312
+ var MEASURED_CODEX_CAPABILITIES = {
16313
+ "codex-cli 0.153.0": ["hooks"],
16314
+ "codex-cli 0.154.0": ["hooks"],
16315
+ "codex-cli 0.155.0": ["hooks"],
16316
+ "codex-cli 0.155.1": ["hooks"],
16317
+ "codex-cli 0.156.1": ["hooks"],
16318
+ "codex-cli 0.157.0": ["hooks"],
16319
+ "codex-cli 0.157.1": ["hooks"],
16320
+ "codex-cli 0.158.0": ["hooks"],
16321
+ "codex-cli 0.159.0": ["hooks"],
16322
+ "codex-cli 0.159.2": ["hooks", "qualified-skill-catalog"],
16323
+ "codex-cli 0.160.0": ["hooks", "qualified-skill-catalog", "installed-plugin-review"],
16324
+ "codex-cli 0.160.1": ["hooks", "qualified-skill-catalog", "installed-plugin-review"]
16325
+ };
16326
+ function supportsCodexNativeCapability(version, capability) {
16327
+ return typeof version === "string" && Object.hasOwn(MEASURED_CODEX_CAPABILITIES, version) && MEASURED_CODEX_CAPABILITIES[version].includes(capability);
16328
+ }
16329
+ var SUPPORTED_CODEX_HOOK_VERSIONS = Object.freeze(Object.keys(MEASURED_CODEX_CAPABILITIES).filter((version) => supportsCodexNativeCapability(version, "hooks")));
16330
+ var CLAUDE_MARKETPLACE_ENTRY_HASH_MODE = "claude-marketplace-entry-v1";
16331
+ var DOMAIN = "hasna.skills.claude-marketplace-entry.v1\x00";
16332
+ var PATH_CHARACTERS = 4096;
16333
+ var NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
16334
+ function need2(value, reason) {
16335
+ if (!value)
16336
+ throw new Error(`Claude marketplace entry witness ${reason}`);
16337
+ }
16338
+ var bounded = (key) => key.length > 64 ? `${key.slice(0, 64)}...` : key;
16339
+ var quote3 = (text) => JSON.stringify(text).replace(/[^\x20-\x7e]/g, (character) => `\\u${character.charCodeAt(0).toString(16).padStart(4, "0")}`);
16340
+ var child = (path, key) => path + (/^[A-Za-z0-9_$-]{1,64}$/.test(key) ? `.${key}` : `[${JSON.stringify(bounded(key))}]`);
16341
+ function unknownKey(selector, path, key) {
16342
+ throw new Error(path === null ? `${CLAUDE_MARKETPLACE_ENTRY_HASH_MODE}: unknown top-level key ${quote3(bounded(key))} in ${selector.marketplace}` : `${CLAUDE_MARKETPLACE_ENTRY_HASH_MODE}: unknown key ${quote3(child(path, key))} in ${selector.marketplace}`);
16343
+ }
16344
+ function knownKeys(object, allowed, selector, path) {
16345
+ for (const [key] of object.entries)
16346
+ if (!allowed.has(key))
16347
+ unknownKey(selector, path, key);
16348
+ }
16349
+ var reason = (error) => String(error?.message ?? error).replace(/^Claude settings witness /, "");
16350
+ var MARKETPLACE_KEYS = new Set(["$schema", "name", "owner", "plugins", "description", "version", "metadata", "forceRemoveDeletedPlugins", "allowCrossMarketplaceDependenciesOn", "renames"]);
16351
+ var MARKETPLACE_METADATA_KEYS = new Set(["description", "version", "pluginRoot"]);
16352
+ var ENTRY_BOUND_KEYS = new Set([
16353
+ "name",
16354
+ "source",
16355
+ "strict",
16356
+ "defaultEnabled",
16357
+ "dependencies",
16358
+ "relevance",
16359
+ "headers",
16360
+ "headersHelper",
16361
+ "settings",
16362
+ "userConfig",
16363
+ "types",
16364
+ "channels",
16365
+ "skills",
16366
+ "commands",
16367
+ "agents",
16368
+ "hooks",
16369
+ "mcpServers",
16370
+ "lspServers",
16371
+ "outputStyles",
16372
+ "workflows",
16373
+ "experimental",
16374
+ "themes",
16375
+ "monitors"
16376
+ ]);
16377
+ var ENTRY_OMITTED_KEYS = new Set(["$schema", "description", "version", "author", "homepage", "repository", "license", "keywords", "category", "tags", "displayName", "metadata"]);
16378
+ var EXPERIMENTAL_KEYS = new Set(["themes", "monitors", "evals"]);
16379
+ var SOURCE_KEYS = Object.freeze({
16380
+ github: ["source", "repo", "ref", "sha"],
16381
+ url: ["source", "url", "ref", "sha", "path"],
16382
+ "git-subdir": ["source", "url", "path", "ref", "sha"],
16383
+ npm: ["source", "package", "version", "registry"],
16384
+ archive: ["source", "url", "sha256"],
16385
+ command: ["source", "command", "timeout", "mode"]
16386
+ });
16387
+ var field = (object, key) => object.entries.find(([name]) => name === key)?.[1];
16388
+ var isString = (value) => value?.kind === "string";
16389
+ var isBoolean = (value) => value?.kind === "literal" && (value.value === "true" || value.value === "false");
16390
+ var stringArray = (value) => value?.kind === "array" && value.items.every(isString);
16391
+ var stringObject = (value) => value?.kind === "object" && value.entries.every(([, item]) => isString(item));
16392
+ function claudeMarketplaceEntrySourceValid(source) {
16393
+ const path = source?.path;
16394
+ return typeof path === "string" && path.length > 0 && path.length <= PATH_CHARACTERS && !/[\x00-\x1f\x7f]/.test(path) && isAbsolute32(path) && resolve32(path) === path && basename3(path) === "marketplace.json" && basename3(dirname42(path)) === ".claude-plugin" && typeof source.marketplace === "string" && NAME.test(source.marketplace) && !source.marketplace.includes("..") && typeof source.plugin === "string" && NAME.test(source.plugin);
16395
+ }
16396
+ function canonical2(value) {
16397
+ if (value.kind === "string")
16398
+ return JSON.stringify(value.value);
16399
+ if (value.kind === "number" || value.kind === "literal")
16400
+ return value.value;
16401
+ if (value.kind === "array")
16402
+ return "[" + value.items.map(canonical2).join(",") + "]";
16403
+ return "{" + [...value.entries].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, item]) => JSON.stringify(key) + ":" + canonical2(item)).join(",") + "}";
16404
+ }
16405
+ function validateMarketplace(root, selector) {
16406
+ knownKeys(root, MARKETPLACE_KEYS, selector, null);
16407
+ const name = field(root, "name");
16408
+ need2(isString(name) && name.value === selector.marketplace, "marketplace name does not match the reviewed binding");
16409
+ for (const key of ["$schema", "description", "version"]) {
16410
+ const value = field(root, key);
16411
+ need2(value === undefined || isString(value), `has an invalid marketplace ${key}`);
16412
+ }
16413
+ const owner = field(root, "owner");
16414
+ need2(owner === undefined || owner.kind === "object", "has an invalid marketplace owner");
16415
+ const metadata = field(root, "metadata");
16416
+ if (metadata !== undefined) {
16417
+ need2(metadata.kind === "object", "has an invalid marketplace metadata object");
16418
+ knownKeys(metadata, MARKETPLACE_METADATA_KEYS, selector, "metadata");
16419
+ for (const [key, value] of metadata.entries)
16420
+ need2(isString(value), `has an invalid marketplace metadata.${key}`);
16421
+ }
16422
+ const remove = field(root, "forceRemoveDeletedPlugins");
16423
+ need2(remove === undefined || isBoolean(remove), "has an invalid forceRemoveDeletedPlugins value");
16424
+ const cross = field(root, "allowCrossMarketplaceDependenciesOn");
16425
+ need2(cross === undefined || stringArray(cross), "has an invalid allowCrossMarketplaceDependenciesOn value");
16426
+ const renames = field(root, "renames");
16427
+ if (renames !== undefined) {
16428
+ need2(renames.kind === "object" && renames.entries.every(([, target]) => isString(target) || target.kind === "literal" && target.value === "null"), "has an invalid renames map");
16429
+ need2(!renames.entries.some(([from]) => from.toLowerCase() === selector.plugin.toLowerCase()), "plugin id is redirected by the marketplace renames map");
16430
+ }
16431
+ }
16432
+ function validateSource(source, selector, path) {
16433
+ if (isString(source)) {
16434
+ need2(source.value.length > 0, "has an empty plugin source");
16435
+ return;
16436
+ }
16437
+ need2(source?.kind === "object", "has an invalid plugin source");
16438
+ const type = field(source, "source");
16439
+ need2(isString(type) && Object.hasOwn(SOURCE_KEYS, type.value), "has an unreviewed plugin source type");
16440
+ knownKeys(source, new Set(SOURCE_KEYS[type.value]), selector, path);
16441
+ }
16442
+ function projectEntry(entry, selector) {
16443
+ const path = `plugins[${selector.plugin}]`;
16444
+ knownKeys(entry, { has: (key) => ENTRY_BOUND_KEYS.has(key) || ENTRY_OMITTED_KEYS.has(key) }, selector, path);
16445
+ const name = field(entry, "name");
16446
+ need2(isString(name) && name.value === selector.plugin, "selected entry name does not match");
16447
+ validateSource(field(entry, "source"), selector, `${path}.source`);
16448
+ for (const key of ["strict", "defaultEnabled"]) {
16449
+ const value = field(entry, key);
16450
+ need2(value === undefined || isBoolean(value), `has an invalid entry ${key}`);
16451
+ }
16452
+ const headersHelper = field(entry, "headersHelper");
16453
+ need2(headersHelper === undefined || isString(headersHelper), "has an invalid entry headersHelper");
16454
+ const experimental = field(entry, "experimental");
16455
+ if (experimental !== undefined) {
16456
+ need2(experimental.kind === "object", "has an invalid entry experimental object");
16457
+ knownKeys(experimental, EXPERIMENTAL_KEYS, selector, `${path}.experimental`);
16458
+ }
16459
+ for (const key of ["$schema", "description", "version", "homepage", "license", "category", "displayName"]) {
16460
+ const value = field(entry, key);
16461
+ need2(value === undefined || isString(value), `has an invalid entry ${key}`);
16462
+ }
16463
+ for (const [key, keys] of [["author", new Set(["name", "email", "url"])], ["repository", new Set(["type", "url", "directory"])]]) {
16464
+ const value = field(entry, key);
16465
+ if (value?.kind === "object")
16466
+ knownKeys(value, keys, selector, `${path}.${key}`);
16467
+ need2(value === undefined || isString(value) || stringObject(value), `has an invalid entry ${key}`);
16468
+ }
16469
+ for (const key of ["keywords", "tags"]) {
16470
+ const value = field(entry, key);
16471
+ need2(value === undefined || stringArray(value), `has an invalid entry ${key}`);
16472
+ }
16473
+ const metadata = field(entry, "metadata");
16474
+ need2(metadata === undefined || metadata.kind === "object", "has an invalid entry metadata object");
16475
+ return { kind: "object", entries: entry.entries.filter(([key]) => ENTRY_BOUND_KEYS.has(key)) };
16476
+ }
16477
+ function hashClaudeMarketplaceEntry(text, selector) {
16478
+ need2(selector && typeof selector.marketplace === "string" && NAME.test(selector.marketplace) && !selector.marketplace.includes("..") && typeof selector.plugin === "string" && NAME.test(selector.plugin), "requires an exact marketplace and plugin name");
16479
+ let root;
16480
+ try {
16481
+ root = parseNativeJsonObject(text);
16482
+ } catch (error) {
16483
+ throw new Error(`Claude marketplace entry witness cannot parse marketplace.json: ${reason(error)}`);
16484
+ }
16485
+ validateMarketplace(root, selector);
16486
+ const plugins = field(root, "plugins");
16487
+ need2(plugins?.kind === "array", "requires a plugins array");
16488
+ const entryName = (item) => {
16489
+ if (item.kind !== "object")
16490
+ return;
16491
+ const name = field(item, "name");
16492
+ return isString(name) ? name.value : undefined;
16493
+ };
16494
+ const exact = plugins.items.filter((item) => entryName(item) === selector.plugin);
16495
+ const folded = plugins.items.filter((item) => entryName(item)?.toLowerCase() === selector.plugin.toLowerCase());
16496
+ need2(exact.length > 0, "selected plugin entry is missing");
16497
+ need2(exact.length === 1 && folded.length === 1, "selected plugin entry is duplicated or ambiguous");
16498
+ const entry = projectEntry(exact[0], selector);
16499
+ const metadata = field(root, "metadata"), pluginRoot = metadata?.kind === "object" ? field(metadata, "pluginRoot") : undefined;
16500
+ const nullValue = { kind: "literal", value: "null" };
16501
+ const marketplace = { kind: "object", entries: [
16502
+ ["name", field(root, "name")],
16503
+ ["pluginRoot", pluginRoot ?? nullValue],
16504
+ ["allowCrossMarketplaceDependenciesOn", field(root, "allowCrossMarketplaceDependenciesOn") ?? nullValue]
16505
+ ] };
16506
+ const projection = { kind: "object", entries: [["marketplace", marketplace], ["plugin", entry]] };
16507
+ return createHash42("sha256").update(DOMAIN).update(canonical2(projection)).digest("hex");
16508
+ }
16509
+ function captureClaudeMarketplaceEntry(path, marketplace, plugin, budget2 = { remaining: 256 * 1024 * 1024 }) {
16510
+ need2(claudeMarketplaceEntrySourceValid({ path, marketplace, plugin }), "requires a normalized absolute .claude-plugin/marketplace.json path and exact names");
16511
+ let text;
16512
+ try {
16513
+ text = readNativeSettingsWitnessFile(path, budget2, "marketplace.json");
16514
+ } catch (error) {
16515
+ throw new Error(`Claude marketplace entry witness cannot read marketplace.json: ${reason(error)}`);
16516
+ }
16517
+ return { path, hashMode: CLAUDE_MARKETPLACE_ENTRY_HASH_MODE, marketplace, plugin, sha256: hashClaudeMarketplaceEntry(text, { marketplace, plugin }) };
16518
+ }
16282
16519
  var AGENT_POLICY_LIMITS = Object.freeze({ bytes: 1024 * 1024, agents: 16, discoverySources: 2048, discoveryRawSourceBytes: 64 * 1024 * 1024, discoveryRawTotalBytes: 256 * 1024 * 1024, discoveryPathLinks: 40, discoveryPathSteps: 256, discoveryPathSourceMetadataBytes: 64 * 1024, discoveryPathTotalMetadataBytes: 8 * 1024 * 1024, discoveryRoots: 512, discoveryDirectories: 64, discoveryDirectoryEntries: 20000, discoveryDirectoryBytes: 8 * 1024 * 1024, builtinNames: 2048, rootAliases: 2, fields: 64, pathCharacters: 4096 });
16283
16520
  function object(value) {
16284
16521
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
@@ -16332,7 +16569,7 @@ function assertAgentPolicyCollections(policy) {
16332
16569
  text(control.pluginId, 1024);
16333
16570
  text(control.namespace, 64);
16334
16571
  text(control.pluginParent);
16335
- requireBound(isAbsolute32(control.pluginParent) && resolve32(control.pluginParent) === control.pluginParent && /^[a-f0-9]{64}$/.test(control.manifestSha256));
16572
+ requireBound(isAbsolute4(control.pluginParent) && resolve42(control.pluginParent) === control.pluginParent && /^[a-f0-9]{64}$/.test(control.manifestSha256));
16336
16573
  if (control.remotePluginId !== undefined)
16337
16574
  requireBound(typeof control.remotePluginId === "string" && /^[A-Za-z0-9_~-]{1,1024}$/.test(control.remotePluginId));
16338
16575
  if (control.skillsOnly !== undefined)
@@ -16344,16 +16581,24 @@ function assertAgentPolicyCollections(policy) {
16344
16581
  }
16345
16582
  if (bridge.codexInactivePlugins !== undefined) {
16346
16583
  const controls = array(bridge.codexInactivePlugins, 4096), ids = new Set;
16347
- requireBound(controls.length === 0 || object(bridge.codexPluginSkillReview) && bridge.codexPluginSkillReview.version === "codex-cli 0.160.0" && typeof bridge.codexPluginSkillReview.catalogSha256 === "string" && /^[a-f0-9]{64}$/.test(bridge.codexPluginSkillReview.catalogSha256));
16584
+ requireBound(controls.length === 0 || object(bridge.codexPluginSkillReview) && supportsCodexNativeCapability(bridge.codexPluginSkillReview.version, "installed-plugin-review") && typeof bridge.codexPluginSkillReview.catalogSha256 === "string" && /^[a-f0-9]{64}$/.test(bridge.codexPluginSkillReview.catalogSha256));
16348
16585
  for (const control of controls) {
16349
16586
  requireBound(object(control) && Object.keys(control).every((key) => ["pluginId", "namespace", "pluginParent", "sourceType", "sourceSha256"].includes(key)));
16350
16587
  text(control.pluginId, 1024);
16351
16588
  text(control.namespace, 64);
16352
16589
  text(control.pluginParent);
16353
- requireBound(!ids.has(control.pluginId) && isAbsolute32(control.pluginParent) && resolve32(control.pluginParent) === control.pluginParent && ["local", "git", "npm"].includes(control.sourceType) && typeof control.sourceSha256 === "string" && /^[a-f0-9]{64}$/.test(control.sourceSha256));
16590
+ requireBound(!ids.has(control.pluginId) && isAbsolute4(control.pluginParent) && resolve42(control.pluginParent) === control.pluginParent && ["local", "git", "npm"].includes(control.sourceType) && typeof control.sourceSha256 === "string" && /^[a-f0-9]{64}$/.test(control.sourceSha256));
16354
16591
  ids.add(control.pluginId);
16355
16592
  }
16356
16593
  }
16594
+ if (bridge.discoveryExecutables !== undefined)
16595
+ for (const [agent, executable] of Object.entries(record(bridge.discoveryExecutables, AGENT_POLICY_LIMITS.agents))) {
16596
+ requireBound(agent === "gemini" && object(executable) && Object.keys(executable).length === 3 && executable.command === "gemini");
16597
+ for (const path of [executable.path, executable.target]) {
16598
+ text(path);
16599
+ requireBound(!/[\x00-\x1f\x7f-\x9f\u200e\u200f\u202a-\u202e\u2066-\u2069]/.test(path) && isAbsolute4(path) && resolve42(path) === path);
16600
+ }
16601
+ }
16357
16602
  if (bridge.disabledBuiltins !== undefined)
16358
16603
  for (const builtin of array(bridge.disabledBuiltins, AGENT_POLICY_LIMITS.builtinNames)) {
16359
16604
  requireBound(object(builtin));
@@ -16379,11 +16624,11 @@ function assertAgentPolicyCollections(policy) {
16379
16624
  requireBound(agent === "codex" && value.agent === "codex" && value.method === "reviewed" && Object.keys(proof).every((key) => ["roots", "parents", "directories"].includes(key)) && roots.length + parents2.length > 0 && new Set(roots).size === roots.length && new Set(parents2).size === parents2.length);
16380
16625
  for (const root of roots) {
16381
16626
  text(root);
16382
- requireBound(isAbsolute32(root) && resolve32(root) === root);
16627
+ requireBound(isAbsolute4(root) && resolve42(root) === root);
16383
16628
  }
16384
16629
  for (const parent of parents2) {
16385
16630
  text(parent);
16386
- requireBound(isAbsolute32(parent) && resolve32(parent) === parent);
16631
+ requireBound(isAbsolute4(parent) && resolve42(parent) === parent);
16387
16632
  }
16388
16633
  for (const directory of array(proof.directories, AGENT_POLICY_LIMITS.discoveryDirectories)) {
16389
16634
  requireBound(object(directory));
@@ -16396,14 +16641,14 @@ function assertAgentPolicyCollections(policy) {
16396
16641
  }
16397
16642
  if (value.codexInstallationInputs !== undefined) {
16398
16643
  const proof = record(value.codexInstallationInputs, 4), inputs = array(proof.plugins, 4096), ids = new Set;
16399
- requireBound(agent === "codex" && value.agent === "codex" && value.method === "reviewed" && proof.version === "codex-cli 0.160.0" && typeof proof.catalogSha256 === "string" && /^[a-f0-9]{64}$/.test(proof.catalogSha256) && inputs.length > 0 && object(bridge.codexPluginSkillReview) && bridge.codexPluginSkillReview.version === proof.version && bridge.codexPluginSkillReview.catalogSha256 === proof.catalogSha256);
16644
+ requireBound(agent === "codex" && value.agent === "codex" && value.method === "reviewed" && supportsCodexNativeCapability(proof.version, "installed-plugin-review") && typeof proof.catalogSha256 === "string" && /^[a-f0-9]{64}$/.test(proof.catalogSha256) && inputs.length > 0 && object(bridge.codexPluginSkillReview) && bridge.codexPluginSkillReview.version === proof.version && bridge.codexPluginSkillReview.catalogSha256 === proof.catalogSha256);
16400
16645
  for (const input of inputs) {
16401
16646
  requireBound(object(input) && Object.keys(input).every((key) => ["pluginId", "namespace", "pluginParent", "sourceRoot", "sourceSha256"].includes(key)));
16402
16647
  text(input.pluginId, 1024);
16403
16648
  text(input.namespace, 64);
16404
16649
  text(input.pluginParent);
16405
16650
  text(input.sourceRoot);
16406
- requireBound(!ids.has(input.pluginId) && [input.pluginParent, input.sourceRoot].every((path) => isAbsolute32(path) && resolve32(path) === path) && typeof input.sourceSha256 === "string" && /^[a-f0-9]{64}$/.test(input.sourceSha256));
16651
+ requireBound(!ids.has(input.pluginId) && [input.pluginParent, input.sourceRoot].every((path) => isAbsolute4(path) && resolve42(path) === path) && typeof input.sourceSha256 === "string" && /^[a-f0-9]{64}$/.test(input.sourceSha256));
16407
16652
  ids.add(input.pluginId);
16408
16653
  }
16409
16654
  if (proof.directories !== undefined)
@@ -16420,17 +16665,19 @@ function assertAgentPolicyCollections(policy) {
16420
16665
  text(source.path);
16421
16666
  requireBound(source.sha256 === null || typeof source.sha256 === "string" && /^[a-f0-9]{64}$/.test(source.sha256));
16422
16667
  if (source.hashMode !== undefined)
16423
- requireBound(["bytes", "path-bytes", "claude-plugin-manifest-v1", "claude-plugin-registry", "claude-marketplace-registry", "claude-settings-v1", "claude-settings-v2", "claude-settings-v3", "claude-marketplace-registry-v2", "codex-settings-v1", "codex-settings-v2", "codex-settings-v3", "codex-settings-v4", "sumi-settings-v1"].includes(source.hashMode) && source.format === undefined && source.fields === undefined && (source.hashMode === "bytes" || source.sha256 !== null));
16668
+ requireBound(["bytes", "path-bytes", "claude-plugin-manifest-v1", "claude-plugin-registry", "claude-marketplace-registry", "claude-settings-v1", "claude-settings-v2", "claude-settings-v3", "claude-settings-v4", "claude-marketplace-registry-v2", "codex-settings-v1", "codex-settings-v2", "codex-settings-v3", "codex-settings-v4", "sumi-settings-v1", "claude-marketplace-entry-v1"].includes(source.hashMode) && source.format === undefined && source.fields === undefined && (source.hashMode === "bytes" || source.sha256 !== null));
16424
16669
  if (source.hashMode === "claude-plugin-manifest-v1")
16425
- requireBound(agent === "claude" && value.agent === "claude" && ["automatic", "reviewed"].includes(value.method) && !/[\x00-\x1f\x7f]/.test(source.path) && isAbsolute32(source.path) && resolve32(source.path) === source.path && source.path.endsWith(join72(sep22, ".claude-plugin", "plugin.json")) && source.managedPlugins === undefined);
16670
+ requireBound(agent === "claude" && value.agent === "claude" && ["automatic", "reviewed"].includes(value.method) && !/[\x00-\x1f\x7f]/.test(source.path) && isAbsolute4(source.path) && resolve42(source.path) === source.path && source.path.endsWith(join72(sep22, ".claude-plugin", "plugin.json")) && source.managedPlugins === undefined);
16426
16671
  if (source.hashMode === "sumi-settings-v1")
16427
- requireBound(agent === "sumi" && value.agent === "sumi" && value.method === "reviewed" && !/[\x00-\x1f\x7f]/.test(source.path) && isAbsolute32(source.path) && resolve32(source.path) === source.path && basename3(source.path) === "sumi.json");
16672
+ requireBound(agent === "sumi" && value.agent === "sumi" && value.method === "reviewed" && !/[\x00-\x1f\x7f]/.test(source.path) && isAbsolute4(source.path) && resolve42(source.path) === source.path && basename4(source.path) === "sumi.json");
16428
16673
  if (source.hashMode === "codex-settings-v1" || source.hashMode === "codex-settings-v2" || (source.hashMode === "codex-settings-v3" || source.hashMode === "codex-settings-v4"))
16429
- requireBound(agent === "codex" && value.agent === "codex" && value.method === "reviewed" && !/[\x00-\x1f\x7f]/.test(source.path) && isAbsolute32(source.path) && resolve32(source.path) === source.path && basename3(source.path) === "config.toml");
16430
- if (source.hashMode === "claude-settings-v1" || source.hashMode === "claude-settings-v2" || source.hashMode === "claude-settings-v3")
16431
- requireBound(agent === "claude" && value.agent === "claude" && value.method === "reviewed" && !/[\x00-\x1f\x7f]/.test(source.path) && isAbsolute32(source.path) && resolve32(source.path) === source.path && basename3(source.path) === "settings.json");
16674
+ requireBound(agent === "codex" && value.agent === "codex" && value.method === "reviewed" && !/[\x00-\x1f\x7f]/.test(source.path) && isAbsolute4(source.path) && resolve42(source.path) === source.path && basename4(source.path) === "config.toml");
16675
+ if (source.hashMode === "claude-settings-v1" || source.hashMode === "claude-settings-v2" || (source.hashMode === "claude-settings-v3" || source.hashMode === "claude-settings-v4"))
16676
+ requireBound(agent === "claude" && value.agent === "claude" && value.method === "reviewed" && !/[\x00-\x1f\x7f]/.test(source.path) && isAbsolute4(source.path) && resolve42(source.path) === source.path && basename4(source.path) === "settings.json");
16432
16677
  if (source.hashMode === "claude-marketplace-registry" || source.hashMode === "claude-marketplace-registry-v2")
16433
- requireBound(agent === "claude" && value.agent === "claude" && value.method === "reviewed" && !/[\x00-\x1f\x7f]/.test(source.path) && isAbsolute32(source.path) && resolve32(source.path) === source.path && basename3(source.path) === "known_marketplaces.json");
16678
+ requireBound(agent === "claude" && value.agent === "claude" && value.method === "reviewed" && !/[\x00-\x1f\x7f]/.test(source.path) && isAbsolute4(source.path) && resolve42(source.path) === source.path && basename4(source.path) === "known_marketplaces.json");
16679
+ if (source.hashMode === "claude-marketplace-entry-v1")
16680
+ requireBound(agent === "claude" && value.agent === "claude" && value.method === "reviewed" && claudeMarketplaceEntrySourceValid(source));
16434
16681
  if (source.hashMode === "claude-plugin-registry") {
16435
16682
  requireBound(agent === "claude");
16436
16683
  const managed = array(source.managedPlugins, 64);
@@ -16445,8 +16692,8 @@ function assertAgentPolicyCollections(policy) {
16445
16692
  if (source.format !== undefined)
16446
16693
  requireBound(["json", "toml", "yaml"].includes(source.format));
16447
16694
  if (source.fields !== undefined)
16448
- for (const field of array(source.fields, AGENT_POLICY_LIMITS.fields))
16449
- text(field, 256);
16695
+ for (const field2 of array(source.fields, AGENT_POLICY_LIMITS.fields))
16696
+ text(field2, 256);
16450
16697
  }
16451
16698
  if (value.directories !== undefined)
16452
16699
  for (const directory of array(value.directories, AGENT_POLICY_LIMITS.discoveryDirectories)) {
@@ -16538,7 +16785,7 @@ function quoted(value) {
16538
16785
  return `'${value.replace(/'/g, `'\\''`)}'`;
16539
16786
  }
16540
16787
  function hermesHookDefinitions(supervisor2) {
16541
- if (!isAbsolute4(supervisor2.runtime) || !isAbsolute4(supervisor2.path))
16788
+ if (!isAbsolute5(supervisor2.runtime) || !isAbsolute5(supervisor2.path))
16542
16789
  throw new Error("Expected absolute Hermes supervisor paths");
16543
16790
  const entry = (event) => ({ command: `${quoted(supervisor2.runtime)} ${quoted(supervisor2.path)} --event ${event}`, timeout: 15, ...event === "pre_tool_call" ? { fail_closed: true } : {} });
16544
16791
  return { pre_llm_call: entry("pre_llm_call"), pre_tool_call: entry("pre_tool_call") };
@@ -16551,16 +16798,16 @@ function assertHermesEnvironment(home) {
16551
16798
  throw new Error(`NATIVE_SKILL_DRIFT: Hermes ${variable} requires a dedicated discovery adapter; unset it before using this adapter`);
16552
16799
  }
16553
16800
  const selected = process.env.HERMES_HOME?.trim();
16554
- if (selected && (!isAbsolute4(selected) || resolve42(selected) !== join82(resolve42(home), ".hermes")))
16801
+ if (selected && (!isAbsolute5(selected) || resolve5(selected) !== join82(resolve5(home), ".hermes")))
16555
16802
  throw new Error("NATIVE_SKILL_DRIFT: custom Hermes homes/profiles require their own reviewed bridge");
16556
16803
  if (process.env.HERMES_ENABLE_PROJECT_PLUGINS?.trim() && !["0", "false", "no", "off"].includes(process.env.HERMES_ENABLE_PROJECT_PLUGINS.trim().toLowerCase()))
16557
16804
  throw new Error("NATIVE_SKILL_DRIFT: Hermes project plugins require a dedicated discovery review");
16558
16805
  }
16559
16806
  function read(path) {
16560
- for (let current2 = path;; current2 = dirname42(current2)) {
16807
+ for (let current2 = path;; current2 = dirname52(current2)) {
16561
16808
  if (lstatSync42(current2, { throwIfNoEntry: false })?.isSymbolicLink())
16562
16809
  throw new Error("NATIVE_SKILL_DRIFT: symlink Hermes protection input");
16563
- if (dirname42(current2) === current2)
16810
+ if (dirname52(current2) === current2)
16564
16811
  break;
16565
16812
  }
16566
16813
  const stat = lstatSync42(path, { throwIfNoEntry: false });
@@ -16574,7 +16821,7 @@ function assertHermesProtection(home, config, command, profile, supervisor2) {
16574
16821
  assertHermesEnvironment(home);
16575
16822
  if (read(join82(home, ".hermes", HERMES_OPT_OUT)) === null)
16576
16823
  throw new Error("NATIVE_SKILL_DRIFT: Hermes bundled skill reseeding is not disabled; run skills hook install");
16577
- if (!supervisor2 || !isAbsolute4(supervisor2.path) || supervisor2.runtime !== process.execPath || read(supervisor2.path) !== renderHermesSupervisor(command, profile))
16824
+ if (!supervisor2 || !isAbsolute5(supervisor2.path) || supervisor2.runtime !== process.execPath || read(supervisor2.path) !== renderHermesSupervisor(command, profile))
16578
16825
  throw new Error("NATIVE_SKILL_DRIFT: Hermes owned supervisor changed; run skills hook install");
16579
16826
  const raw = read(join82(home, ".hermes/shell-hooks-allowlist.json"));
16580
16827
  let trust;
@@ -16600,10 +16847,10 @@ function assertHermesProtection(home, config, command, profile, supervisor2) {
16600
16847
  }
16601
16848
  function assertNoHermesLegacyShadow(root) {
16602
16849
  let entries = 0;
16603
- for (let cursor = resolve42(root);; cursor = dirname42(cursor)) {
16850
+ for (let cursor = resolve5(root);; cursor = dirname52(cursor)) {
16604
16851
  if (lstatSync42(cursor, { throwIfNoEntry: false })?.isSymbolicLink())
16605
16852
  throw new Error("NATIVE_SKILL_DRIFT: symlink Hermes legacy discovery root");
16606
- if (dirname42(cursor) === cursor)
16853
+ if (dirname52(cursor) === cursor)
16607
16854
  break;
16608
16855
  }
16609
16856
  function scan(path, depth) {
@@ -16624,10 +16871,10 @@ function assertNoHermesLegacyShadow(root) {
16624
16871
  const hasDescriptor = Boolean(lstatSync42(join82(path, "SKILL.md"), { throwIfNoEntry: false }));
16625
16872
  const directory = opendirSync(path);
16626
16873
  try {
16627
- for (let child = directory.readSync();child; child = directory.readSync()) {
16628
- if (hasDescriptor && ["references", "templates", "assets", "scripts"].includes(child.name))
16874
+ for (let child2 = directory.readSync();child2; child2 = directory.readSync()) {
16875
+ if (hasDescriptor && ["references", "templates", "assets", "scripts"].includes(child2.name))
16629
16876
  continue;
16630
- scan(join82(path, child.name), depth + 1);
16877
+ scan(join82(path, child2.name), depth + 1);
16631
16878
  }
16632
16879
  } finally {
16633
16880
  directory.closeSync();
@@ -16682,15 +16929,15 @@ await new Promise((resolve, reject) => process.stdout.write(JSON.stringify(outpu
16682
16929
  if (failed) process.exitCode = 2;
16683
16930
  `;
16684
16931
  }
16685
- function need2(value, message) {
16932
+ function need3(value, message) {
16686
16933
  if (!value)
16687
16934
  throw new Error(message);
16688
16935
  }
16689
16936
  function safe(path) {
16690
- need2(typeof path === "string" && path.length <= AGENT_POLICY_LIMITS.pathCharacters && isAbsolute5(path) && resolve5(path) === path && !path.includes("\x00"), "Expected a canonical absolute discovery directory path");
16691
- for (let cursor = path;; cursor = dirname52(cursor)) {
16692
- need2(!lstatSync5(cursor, { throwIfNoEntry: false })?.isSymbolicLink(), "Refusing symlink native discovery directory");
16693
- if (dirname52(cursor) === cursor)
16937
+ need3(typeof path === "string" && path.length <= AGENT_POLICY_LIMITS.pathCharacters && isAbsolute6(path) && resolve6(path) === path && !path.includes("\x00"), "Expected a canonical absolute discovery directory path");
16938
+ for (let cursor = path;; cursor = dirname62(cursor)) {
16939
+ need3(!lstatSync5(cursor, { throwIfNoEntry: false })?.isSymbolicLink(), "Refusing symlink native discovery directory");
16940
+ if (dirname62(cursor) === cursor)
16694
16941
  break;
16695
16942
  }
16696
16943
  }
@@ -16704,45 +16951,45 @@ function capture(path, budget2, excludedRoots, omittedRoots = [], rows) {
16704
16951
  const root = lstatSync5(path, { throwIfNoEntry: false });
16705
16952
  if (!root)
16706
16953
  return { path, sha256: null };
16707
- need2(root.isDirectory(), "Unsupported native discovery directory input");
16708
- const hash = createHash42("sha256");
16954
+ need3(root.isDirectory(), "Unsupported native discovery directory input");
16955
+ const hash = createHash52("sha256");
16709
16956
  function walk(current2, relative2, before, depth) {
16710
- need2(depth <= 64, "Native discovery directory depth limit exceeded");
16957
+ need3(depth <= 64, "Native discovery directory depth limit exceeded");
16711
16958
  const names = [], directory = opendirSync2(current2);
16712
16959
  try {
16713
16960
  for (let entry = directory.readSync();entry; entry = directory.readSync()) {
16714
- need2(++budget2.entries <= AGENT_POLICY_LIMITS.discoveryDirectoryEntries, "Native discovery directory entry limit exceeded");
16961
+ need3(++budget2.entries <= AGENT_POLICY_LIMITS.discoveryDirectoryEntries, "Native discovery directory entry limit exceeded");
16715
16962
  names.push(entry.name);
16716
16963
  }
16717
16964
  } finally {
16718
16965
  directory.closeSync();
16719
16966
  }
16720
- need2(new Set(names).size === names.length, "Ambiguous native discovery directory names");
16967
+ need3(new Set(names).size === names.length, "Ambiguous native discovery directory names");
16721
16968
  for (const name of names.sort()) {
16722
- const child = join92(current2, name), childRelative = relative2 ? `${relative2}/${name}` : name;
16723
- if (omittedRoots.includes(child))
16969
+ const child2 = join92(current2, name), childRelative = relative2 ? `${relative2}/${name}` : name;
16970
+ if (omittedRoots.includes(child2))
16724
16971
  continue;
16725
- need2(child.length <= AGENT_POLICY_LIMITS.pathCharacters, "Native discovery directory path limit exceeded");
16726
- const stat = lstatSync5(child);
16727
- need2(stat.isFile() || stat.isDirectory(), "Refusing symlink or special native discovery directory member");
16972
+ need3(child2.length <= AGENT_POLICY_LIMITS.pathCharacters, "Native discovery directory path limit exceeded");
16973
+ const stat = lstatSync5(child2);
16974
+ need3(stat.isFile() || stat.isDirectory(), "Refusing symlink or special native discovery directory member");
16728
16975
  const row = JSON.stringify([childRelative, stat.isDirectory() ? "directory" : "file"]) + `
16729
16976
  `;
16730
16977
  budget2.bytes += Buffer.byteLength(row);
16731
- need2(budget2.bytes <= AGENT_POLICY_LIMITS.discoveryDirectoryBytes, "Native discovery directory metadata limit exceeded");
16978
+ need3(budget2.bytes <= AGENT_POLICY_LIMITS.discoveryDirectoryBytes, "Native discovery directory metadata limit exceeded");
16732
16979
  hash.update(row);
16733
16980
  rows?.push(row);
16734
- if (stat.isDirectory() && !excludedRoots.includes(child))
16735
- walk(child, childRelative, stat, depth + 1);
16981
+ if (stat.isDirectory() && !excludedRoots.includes(child2))
16982
+ walk(child2, childRelative, stat, depth + 1);
16736
16983
  }
16737
- need2(same(before, lstatSync5(current2, { throwIfNoEntry: false })), "Native discovery directory changed while reading");
16984
+ need3(same(before, lstatSync5(current2, { throwIfNoEntry: false })), "Native discovery directory changed while reading");
16738
16985
  }
16739
16986
  walk(path, "", root, 0);
16740
16987
  safe(path);
16741
16988
  return { path, sha256: hash.digest("hex") };
16742
16989
  }
16743
16990
  function captureDiscoveryDirectoryProjection(paths, omittedRoots) {
16744
- need2(Array.isArray(paths) && paths.length <= AGENT_POLICY_LIMITS.discoveryDirectories && new Set(paths).size === paths.length, "Invalid projected discovery directory collection");
16745
- need2(omittedRoots.length <= AGENT_POLICY_LIMITS.discoveryRoots && new Set(omittedRoots).size === omittedRoots.length, "Invalid inactive discovery roots");
16991
+ need3(Array.isArray(paths) && paths.length <= AGENT_POLICY_LIMITS.discoveryDirectories && new Set(paths).size === paths.length, "Invalid projected discovery directory collection");
16992
+ need3(omittedRoots.length <= AGENT_POLICY_LIMITS.discoveryRoots && new Set(omittedRoots).size === omittedRoots.length, "Invalid inactive discovery roots");
16746
16993
  for (const root of omittedRoots)
16747
16994
  safe(root);
16748
16995
  const budget2 = { entries: 0, bytes: 0 };
@@ -16752,57 +16999,57 @@ function captureDiscoveryDirectoryProjection(paths, omittedRoots) {
16752
16999
  });
16753
17000
  }
16754
17001
  function verifyDiscoveryDirectoryProjection(directories, omittedRoots) {
16755
- need2(directories.length <= AGENT_POLICY_LIMITS.discoveryDirectories, "Invalid projected discovery directory collection");
17002
+ need3(directories.length <= AGENT_POLICY_LIMITS.discoveryDirectories, "Invalid projected discovery directory collection");
16756
17003
  let count = 0, bytes = 0;
16757
17004
  const expected = directories.map((directory) => {
16758
17005
  safe(directory.path);
16759
- need2(Array.isArray(directory.entries), "Missing reviewed directory membership inventory");
16760
- const hash = createHash42("sha256");
17006
+ need3(Array.isArray(directory.entries), "Missing reviewed directory membership inventory");
17007
+ const hash = createHash52("sha256");
16761
17008
  const kept = [];
16762
17009
  for (const row of directory.entries) {
16763
- need2(typeof row === "string" && ++count <= AGENT_POLICY_LIMITS.discoveryDirectoryEntries, "Invalid reviewed directory membership rows");
17010
+ need3(typeof row === "string" && ++count <= AGENT_POLICY_LIMITS.discoveryDirectoryEntries, "Invalid reviewed directory membership rows");
16764
17011
  bytes += Buffer.byteLength(row);
16765
- need2(bytes <= AGENT_POLICY_LIMITS.discoveryDirectoryBytes, "Reviewed directory membership byte limit exceeded");
17012
+ need3(bytes <= AGENT_POLICY_LIMITS.discoveryDirectoryBytes, "Reviewed directory membership byte limit exceeded");
16766
17013
  const value = JSON.parse(row);
16767
- need2(Array.isArray(value) && value.length === 2 && typeof value[0] === "string" && value[0] && !isAbsolute5(value[0]) && !value[0].split("/").some((part) => !part || part === "." || part === "..") && ["file", "directory"].includes(value[1]) && row === JSON.stringify(value) + `
17014
+ need3(Array.isArray(value) && value.length === 2 && typeof value[0] === "string" && value[0] && !isAbsolute6(value[0]) && !value[0].split("/").some((part) => !part || part === "." || part === "..") && ["file", "directory"].includes(value[1]) && row === JSON.stringify(value) + `
16768
17015
  `, "Invalid reviewed directory member");
16769
17016
  hash.update(row);
16770
17017
  const path = join92(directory.path, value[0]);
16771
17018
  if (!omittedRoots.some((root) => path === root || path.startsWith(root + "/")))
16772
17019
  kept.push(row);
16773
17020
  }
16774
- need2(directory.sha256 === null ? directory.entries.length === 0 : hash.digest("hex") === directory.sha256, "Reviewed directory inventory does not match its fingerprint");
17021
+ need3(directory.sha256 === null ? directory.entries.length === 0 : hash.digest("hex") === directory.sha256, "Reviewed directory inventory does not match its fingerprint");
16775
17022
  const absent = omittedRoots.some((root) => directory.path === root || directory.path.startsWith(root + "/"));
16776
- return { path: directory.path, sha256: absent || directory.sha256 === null ? null : createHash42("sha256").update(kept.join("")).digest("hex") };
17023
+ return { path: directory.path, sha256: absent || directory.sha256 === null ? null : createHash52("sha256").update(kept.join("")).digest("hex") };
16777
17024
  });
16778
17025
  const current2 = captureDiscoveryDirectoryProjection(directories.map((item) => item.path), omittedRoots);
16779
- need2(current2.every((item, index) => item.sha256 === expected[index].sha256), "Native discovery directory membership changed outside retired Codex roots");
17026
+ need3(current2.every((item, index) => item.sha256 === expected[index].sha256), "Native discovery directory membership changed outside retired Codex roots");
16780
17027
  }
16781
17028
  function captureDiscoveryDirectories(paths, excludedRoots = []) {
16782
- need2(Array.isArray(paths) && paths.length <= AGENT_POLICY_LIMITS.discoveryDirectories && new Set(paths).size === paths.length, "Invalid native discovery directory collection");
17029
+ need3(Array.isArray(paths) && paths.length <= AGENT_POLICY_LIMITS.discoveryDirectories && new Set(paths).size === paths.length, "Invalid native discovery directory collection");
16783
17030
  const budget2 = { entries: 0, bytes: 0 };
16784
17031
  for (const root of excludedRoots)
16785
17032
  safe(root);
16786
17033
  return paths.map((path) => capture(path, budget2, excludedRoots));
16787
17034
  }
16788
17035
  function verifyDiscoveryDirectories(directories, excludedRoots = []) {
16789
- need2(Array.isArray(directories) && directories.length <= AGENT_POLICY_LIMITS.discoveryDirectories, "Invalid native discovery directory collection");
17036
+ need3(Array.isArray(directories) && directories.length <= AGENT_POLICY_LIMITS.discoveryDirectories, "Invalid native discovery directory collection");
16790
17037
  for (const directory of directories)
16791
- need2(directory && typeof directory === "object" && (directory.sha256 === null || typeof directory.sha256 === "string" && /^[a-f0-9]{64}$/.test(directory.sha256)), "Invalid native discovery directory digest");
17038
+ need3(directory && typeof directory === "object" && (directory.sha256 === null || typeof directory.sha256 === "string" && /^[a-f0-9]{64}$/.test(directory.sha256)), "Invalid native discovery directory digest");
16792
17039
  const current2 = captureDiscoveryDirectories(directories.map((directory) => directory.path), excludedRoots);
16793
17040
  for (let i = 0;i < directories.length; i++)
16794
- need2(current2[i].sha256 === directories[i].sha256, `Native discovery directory membership changed; run skills hook install with a fresh discovery review: ${directories[i].path}`);
17041
+ need3(current2[i].sha256 === directories[i].sha256, `Native discovery directory membership changed; run skills hook install with a fresh discovery review: ${directories[i].path}`);
16795
17042
  }
16796
17043
  function discoveryByteBudget() {
16797
17044
  return { remaining: AGENT_POLICY_LIMITS.discoveryRawTotalBytes };
16798
17045
  }
16799
17046
  function safe2(path) {
16800
- if (typeof path !== "string" || !isAbsolute6(path) || path !== resolve6(path) || path.length > AGENT_POLICY_LIMITS.pathCharacters || path.includes("\x00"))
17047
+ if (typeof path !== "string" || !isAbsolute7(path) || path !== resolve7(path) || path.length > AGENT_POLICY_LIMITS.pathCharacters || path.includes("\x00"))
16801
17048
  throw new Error("Expected a canonical absolute raw discovery path");
16802
- for (let cursor = path;; cursor = dirname62(cursor)) {
17049
+ for (let cursor = path;; cursor = dirname7(cursor)) {
16803
17050
  if (lstatSync6(cursor, { throwIfNoEntry: false })?.isSymbolicLink())
16804
17051
  throw new Error("Refusing symlink raw discovery input");
16805
- if (dirname62(cursor) === cursor)
17052
+ if (dirname7(cursor) === cursor)
16806
17053
  break;
16807
17054
  }
16808
17055
  }
@@ -16821,7 +17068,7 @@ function hashRawDiscoveryFile(path, budget2, changes) {
16821
17068
  if (bytes > AGENT_POLICY_LIMITS.discoveryRawSourceBytes)
16822
17069
  throw new Error("Raw discovery file byte limit exceeded");
16823
17070
  consume(budget2, bytes);
16824
- return createHash52("sha256").update(text2).digest("hex");
17071
+ return createHash62("sha256").update(text2).digest("hex");
16825
17072
  }
16826
17073
  const initial = lstatSync6(path, { throwIfNoEntry: false });
16827
17074
  if (!initial)
@@ -16835,7 +17082,7 @@ function hashRawDiscoveryFile(path, budget2, changes) {
16835
17082
  const opened = fstatSync22(fd);
16836
17083
  if (!opened.isFile() || !same2(initial, opened))
16837
17084
  throw new Error("Raw discovery input changed during open");
16838
- const hash = createHash52("sha256"), buffer = Buffer.alloc(64 * 1024);
17085
+ const hash = createHash62("sha256"), buffer = Buffer.alloc(64 * 1024);
16839
17086
  let bytes = 0;
16840
17087
  while (true) {
16841
17088
  const count = readSync2(fd, buffer, 0, Math.min(buffer.length, AGENT_POLICY_LIMITS.discoveryRawSourceBytes - bytes + 1), null);
@@ -16866,12 +17113,12 @@ function identity2(stat, mutable = false) {
16866
17113
  ...mutable ? { size: String(stat.size), mtimeNs: String(stat.mtimeNs), ctimeNs: String(stat.ctimeNs) } : {}
16867
17114
  };
16868
17115
  }
16869
- function canonical2(path) {
16870
- if (typeof path !== "string" || !isAbsolute7(path) || path !== resolve7(path) || path.length > AGENT_POLICY_LIMITS.pathCharacters || path.includes("\x00") || Buffer.from(path).toString("utf8") !== path)
17116
+ function canonical3(path) {
17117
+ if (typeof path !== "string" || !isAbsolute8(path) || path !== resolve8(path) || path.length > AGENT_POLICY_LIMITS.pathCharacters || path.includes("\x00") || Buffer.from(path).toString("utf8") !== path)
16871
17118
  throw new Error("Expected a canonical absolute discovery path");
16872
17119
  }
16873
17120
  function trace(path) {
16874
- canonical2(path);
17121
+ canonical3(path);
16875
17122
  const rows = [], paths = [];
16876
17123
  let metadataBytes = 0, steps = 0, links = 0, cursor = parse2(path).root, pending = path.slice(cursor.length).split(sep32);
16877
17124
  function record2(path2, row) {
@@ -16896,7 +17143,7 @@ function trace(path) {
16896
17143
  if (!component || component === ".")
16897
17144
  continue;
16898
17145
  if (component === "..") {
16899
- cursor = dirname7(cursor);
17146
+ cursor = dirname8(cursor);
16900
17147
  continue;
16901
17148
  }
16902
17149
  const candidate = join102(cursor, component);
@@ -16916,11 +17163,11 @@ function trace(path) {
16916
17163
  if (!target || target.includes("\x00") || Buffer.byteLength(target) > AGENT_POLICY_LIMITS.pathCharacters || !after.isSymbolicLink() || JSON.stringify(identity2(stat, true)) !== JSON.stringify(identity2(after, true)))
16917
17164
  throw new Error("Discovery link changed during read");
16918
17165
  record2(candidate, { type: "link", target, ...identity2(stat, true) });
16919
- if (isAbsolute7(target)) {
17166
+ if (isAbsolute8(target)) {
16920
17167
  cursor = parse2(target).root;
16921
17168
  root();
16922
17169
  }
16923
- const remainder = isAbsolute7(target) ? target.slice(parse2(target).root.length) : target;
17170
+ const remainder = isAbsolute8(target) ? target.slice(parse2(target).root.length) : target;
16924
17171
  pending = [...remainder.split(sep32), ...pending];
16925
17172
  if (pending.length + steps > AGENT_POLICY_LIMITS.discoveryPathSteps)
16926
17173
  throw new Error("Discovery path step limit exceeded");
@@ -16963,12 +17210,12 @@ function hashDiscoveryPathFile(path, budget2, changes) {
16963
17210
  const after = trace(path);
16964
17211
  if (JSON.stringify(before.rows) !== JSON.stringify(after.rows) || before.file !== after.file)
16965
17212
  throw new Error("Discovery path input changed during read");
16966
- return createHash62("sha256").update(JSON.stringify({ version: 1, path, rows: before.rows, content })).digest("hex");
17213
+ return createHash7("sha256").update(JSON.stringify({ version: 1, path, rows: before.rows, content })).digest("hex");
16967
17214
  }
16968
17215
  var CLAUDE_PLUGIN_MANIFEST_LIMITS = Object.freeze({ bytes: 1024 * 1024, depth: 32, nodes: 65536, stringCharacters: 16384 });
16969
- function requireValue(value, reason) {
17216
+ function requireValue(value, reason2) {
16970
17217
  if (!value)
16971
- throw new Error("Claude plugin manifest " + reason);
17218
+ throw new Error("Claude plugin manifest " + reason2);
16972
17219
  }
16973
17220
  function parse32(text2) {
16974
17221
  requireValue(Buffer.byteLength(text2, "utf8") <= CLAUDE_PLUGIN_MANIFEST_LIMITS.bytes, "exceeds its byte limit");
@@ -17044,7 +17291,7 @@ function parse32(text2) {
17044
17291
  requireValue(at === text2.length && root.kind === "object", "requires a JSON object without trailing content");
17045
17292
  return root;
17046
17293
  }
17047
- function canonical3(value) {
17294
+ function canonical4(value) {
17048
17295
  if (value.kind === "string")
17049
17296
  return JSON.stringify(value.value);
17050
17297
  if (value.kind === "number")
@@ -17052,19 +17299,19 @@ function canonical3(value) {
17052
17299
  if (value.kind === "literal")
17053
17300
  return value.value;
17054
17301
  if (value.kind === "array")
17055
- return "[" + value.items.map(canonical3).join(",") + "]";
17056
- return "{" + value.entries.map(([key, item]) => JSON.stringify(key) + ":" + canonical3(item)).join(",") + "}";
17302
+ return "[" + value.items.map(canonical4).join(",") + "]";
17303
+ return "{" + value.entries.map(([key, item]) => JSON.stringify(key) + ":" + canonical4(item)).join(",") + "}";
17057
17304
  }
17058
17305
  var DESCRIPTIVE_FIELDS = new Set(["description", "version", "author", "homepage", "repository", "license", "keywords"]);
17059
- function validateText(value, field) {
17060
- requireValue(value?.kind === "string" && value.value.length <= CLAUDE_PLUGIN_MANIFEST_LIMITS.stringCharacters, "has an invalid " + field + " field");
17306
+ function validateText(value, field2) {
17307
+ requireValue(value?.kind === "string" && value.value.length <= CLAUDE_PLUGIN_MANIFEST_LIMITS.stringCharacters, "has an invalid " + field2 + " field");
17061
17308
  }
17062
17309
  function validateDescriptiveFields(manifest) {
17063
17310
  const values = new Map(manifest.entries);
17064
- for (const field of ["description", "version", "homepage", "license"]) {
17065
- const value = values.get(field);
17311
+ for (const field2 of ["description", "version", "homepage", "license"]) {
17312
+ const value = values.get(field2);
17066
17313
  if (value !== undefined)
17067
- validateText(value, field);
17314
+ validateText(value, field2);
17068
17315
  }
17069
17316
  const author = values.get("author");
17070
17317
  if (author !== undefined) {
@@ -17089,10 +17336,10 @@ function hashClaudePluginManifest(text2) {
17089
17336
  const manifest = parse32(text2);
17090
17337
  validateDescriptiveFields(manifest);
17091
17338
  const discovery = { kind: "object", entries: manifest.entries.filter(([key]) => !DESCRIPTIVE_FIELDS.has(key)) };
17092
- return createHash7("sha256").update(canonical3(discovery)).digest("hex");
17339
+ return createHash8("sha256").update(canonical4(discovery)).digest("hex");
17093
17340
  }
17094
17341
  function projectReviewedClaudePluginManifest(text2, reviewedSha256) {
17095
- if (!/^[a-f0-9]{64}$/.test(reviewedSha256) || createHash7("sha256").update(text2).digest("hex") !== reviewedSha256) {
17342
+ if (!/^[a-f0-9]{64}$/.test(reviewedSha256) || createHash8("sha256").update(text2).digest("hex") !== reviewedSha256) {
17096
17343
  throw new Error("Reviewed Claude plugin manifest changed before semantic projection");
17097
17344
  }
17098
17345
  return hashClaudePluginManifest(text2);
@@ -17348,8 +17595,8 @@ class BoundedTarReader {
17348
17595
  }
17349
17596
  }
17350
17597
  }
17351
- function tarOctal(field) {
17352
- const text2 = new TextDecoder().decode(field);
17598
+ function tarOctal(field2) {
17599
+ const text2 = new TextDecoder().decode(field2);
17353
17600
  if (!/^[0-7]+[\0 ]*$/.test(text2))
17354
17601
  invalidBundle("Invalid tar octal field");
17355
17602
  const value = Number.parseInt(text2, 8);
@@ -17387,8 +17634,8 @@ function profileDocumentBytes(value) {
17387
17634
  }
17388
17635
  class SkillSelectionError extends Error {
17389
17636
  code;
17390
- constructor(code, message) {
17391
- super(message);
17637
+ constructor(code, message, options) {
17638
+ super(message, options);
17392
17639
  this.code = code;
17393
17640
  this.name = "SkillSelectionError";
17394
17641
  }
@@ -17429,7 +17676,7 @@ function validateResolvedProfile(profile, authority) {
17429
17676
  }
17430
17677
  var package_default = {
17431
17678
  name: "@hasna/skills",
17432
- version: "0.10.47",
17679
+ version: "0.10.53",
17433
17680
  description: "Skills library for AI coding agents",
17434
17681
  type: "module",
17435
17682
  bin: {
@@ -17643,11 +17890,11 @@ var fail = () => {
17643
17890
  };
17644
17891
  function physicalTarget(path) {
17645
17892
  const suffix = [];
17646
- for (let cursor = path;; cursor = dirname10(cursor)) {
17893
+ for (let cursor = path;; cursor = dirname11(cursor)) {
17647
17894
  try {
17648
17895
  return join15(realpathSync32(cursor), ...suffix);
17649
17896
  } catch (error) {
17650
- if (error.code !== "ENOENT" || cursor === dirname10(cursor))
17897
+ if (error.code !== "ENOENT" || cursor === dirname11(cursor))
17651
17898
  throw error;
17652
17899
  try {
17653
17900
  if (lstatSync12(cursor).isSymbolicLink())
@@ -17656,14 +17903,14 @@ function physicalTarget(path) {
17656
17903
  if (statError.code !== "ENOENT")
17657
17904
  throw statError;
17658
17905
  }
17659
- suffix.unshift(basename5(cursor));
17906
+ suffix.unshift(basename6(cursor));
17660
17907
  }
17661
17908
  }
17662
17909
  }
17663
17910
  function codexCorpusRootForPath(path) {
17664
- const target = resolve9(path), physical = physicalTarget(target);
17911
+ const target = resolve10(path), physical = physicalTarget(target);
17665
17912
  const selected = process.env.CODEX_HOME;
17666
- const selectedRoots = selected && isAbsolute9(selected) ? [resolve9(selected), physicalTarget(resolve9(selected))] : [];
17913
+ const selectedRoots = selected && isAbsolute10(selected) ? [resolve10(selected), physicalTarget(resolve10(selected))] : [];
17667
17914
  const classify = (candidate) => {
17668
17915
  const checked = (root2) => {
17669
17916
  if (candidate === root2 || candidate === join15(root2, `${KEY}.flock-v1`))
@@ -17672,10 +17919,10 @@ function codexCorpusRootForPath(path) {
17672
17919
  };
17673
17920
  for (const root2 of selectedRoots) {
17674
17921
  const distance = relative4(root2, candidate);
17675
- if (distance === "" || !distance.startsWith(`..${sep5}`) && distance !== ".." && !isAbsolute9(distance))
17922
+ if (distance === "" || !distance.startsWith(`..${sep5}`) && distance !== ".." && !isAbsolute10(distance))
17676
17923
  return checked(root2);
17677
17924
  }
17678
- for (let cursor = candidate;cursor !== dirname10(cursor); cursor = dirname10(cursor)) {
17925
+ for (let cursor = candidate;cursor !== dirname11(cursor); cursor = dirname11(cursor)) {
17679
17926
  if (cursor.endsWith(`${sep5}.codex`))
17680
17927
  return checked(cursor);
17681
17928
  }
@@ -17701,10 +17948,10 @@ function executable(options) {
17701
17948
  if (typeof command !== "string" || !command || command.includes("\x00") || options.codexSha256 !== undefined && !/^[a-f0-9]{64}$/.test(options.codexSha256))
17702
17949
  return fail();
17703
17950
  let found;
17704
- if (isAbsolute9(command))
17951
+ if (isAbsolute10(command))
17705
17952
  found = command;
17706
17953
  else if (!command.includes(sep5)) {
17707
- found = (process.env.PATH ?? "").split(delimiter).filter(isAbsolute9).map((dir) => join15(dir, command)).find((candidate) => {
17954
+ found = (process.env.PATH ?? "").split(delimiter).filter(isAbsolute10).map((dir) => join15(dir, command)).find((candidate) => {
17708
17955
  try {
17709
17956
  accessSync(candidate, constants6.X_OK);
17710
17957
  return true;
@@ -17718,7 +17965,7 @@ function executable(options) {
17718
17965
  const path = realpathSync32(found), initial = statSync7(path, { bigint: true });
17719
17966
  if (!initial.isFile() || (initial.mode & 0o022n) !== 0n || (initial.mode & 0o111n) === 0n || initial.uid !== BigInt(process.getuid()) && initial.uid !== 0n)
17720
17967
  return fail();
17721
- const hash2 = () => createHash11("sha256").update(readFileSync11(path)).digest("hex");
17968
+ const hash2 = () => createHash12("sha256").update(readFileSync11(path)).digest("hex");
17722
17969
  const digest = hash2();
17723
17970
  if (options.codexSha256 && digest !== options.codexSha256)
17724
17971
  return fail();
@@ -17742,7 +17989,7 @@ function acquireCodexCorpusWrite(roots, options) {
17742
17989
  }
17743
17990
  };
17744
17991
  try {
17745
- if (roots.some((root) => typeof root !== "string" || !isAbsolute9(root) || root.includes("\x00")))
17992
+ if (roots.some((root) => typeof root !== "string" || !isAbsolute10(root) || root.includes("\x00")))
17746
17993
  fail();
17747
17994
  const inputs = [...new Set(roots)].map((input) => ({ input, root: realpathSync32(input) })).sort((a, b) => a.root.localeCompare(b.root));
17748
17995
  for (const { input, root } of inputs) {
@@ -17855,23 +18102,6 @@ function isCodexLocalStdioMcpServer(name, server) {
17855
18102
  return false;
17856
18103
  }
17857
18104
  }
17858
- var MEASURED_CODEX_CAPABILITIES = {
17859
- "codex-cli 0.153.0": ["hooks"],
17860
- "codex-cli 0.154.0": ["hooks"],
17861
- "codex-cli 0.155.0": ["hooks"],
17862
- "codex-cli 0.155.1": ["hooks"],
17863
- "codex-cli 0.156.1": ["hooks"],
17864
- "codex-cli 0.157.0": ["hooks"],
17865
- "codex-cli 0.157.1": ["hooks"],
17866
- "codex-cli 0.158.0": ["hooks"],
17867
- "codex-cli 0.159.0": ["hooks"],
17868
- "codex-cli 0.159.2": ["hooks", "qualified-skill-catalog"],
17869
- "codex-cli 0.160.0": ["hooks", "qualified-skill-catalog"]
17870
- };
17871
- function supportsCodexNativeCapability(version, capability) {
17872
- return typeof version === "string" && Object.hasOwn(MEASURED_CODEX_CAPABILITIES, version) && MEASURED_CODEX_CAPABILITIES[version].includes(capability);
17873
- }
17874
- var SUPPORTED_CODEX_HOOK_VERSIONS = Object.freeze(Object.keys(MEASURED_CODEX_CAPABILITIES).filter((version) => supportsCodexNativeCapability(version, "hooks")));
17875
18105
  function codexPluginSourceIsConfigControlled(plugin) {
17876
18106
  const remoteRealms = ["openai-curated-remote", "created-by-me-remote", "workspace-directory", "workspace-shared-with-me", "workspace-shared-with-me-private", "workspace-shared-with-me-unlisted"];
17877
18107
  return Boolean(plugin.sourceType && ["local", "git", "npm"].includes(plugin.sourceType) && plugin.sourceSha256 && /^[a-f0-9]{64}$/.test(plugin.sourceSha256) && !plugin.remotePluginId && !remoteRealms.includes(plugin.id.slice(plugin.id.lastIndexOf("@") + 1)));
@@ -17885,7 +18115,7 @@ function refuse() {
17885
18115
  var object4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
17886
18116
  var scalar = (value, max) => typeof value === "string" && value.length > 0 && value.trim() === value && Buffer.byteLength(value, "utf8") <= max && !/[\u0000-\u001f\u007f]/u.test(value);
17887
18117
  var remotePluginIdentifier = (value) => typeof value === "string" && /^[A-Za-z0-9_~-]{1,1024}$/.test(value);
17888
- var absolutePath2 = (value) => scalar(value, MAX_PATH_BYTES) && isAbsolute11(value);
18118
+ var absolutePath2 = (value) => scalar(value, MAX_PATH_BYTES) && isAbsolute12(value);
17889
18119
  function canonicalPath(path) {
17890
18120
  try {
17891
18121
  return realpathSync5(path);
@@ -17987,7 +18217,7 @@ function mcpControls(path, read2) {
17987
18217
  function isBundledCleanupHooks(root, namespace, value) {
17988
18218
  const object5 = (v) => Boolean(v && typeof v === "object" && !Array.isArray(v));
17989
18219
  const exactKeys = (v, keys) => Object.keys(v).length === keys.length && keys.every((key) => Object.hasOwn(v, key));
17990
- if (basename6(dirname11(root)) !== namespace || basename6(dirname11(dirname11(root))) !== "openai-bundled")
18220
+ if (basename7(dirname12(root)) !== namespace || basename7(dirname12(dirname12(root))) !== "openai-bundled")
17991
18221
  return false;
17992
18222
  const server = namespace === "unified-computer-use" ? "cua_repl" : ["browser", "chrome", "chrome-dev", "chrome-internal", "computer-use"].includes(namespace) ? "node_repl" : undefined;
17993
18223
  if (!server || !object5(value) || !exactKeys(value, ["hooks"]) || !object5(value.hooks))
@@ -18021,7 +18251,7 @@ function rootControls(root, read2) {
18021
18251
  }
18022
18252
  if (!manifest || typeof manifest !== "object" || Array.isArray(manifest) || !identifier2(manifest.name))
18023
18253
  refuse2();
18024
- const cacheVersion = basename6(root), declaredVersion = manifest.version === undefined ? "" : typeof manifest.version === "string" ? manifest.version.trim() : null;
18254
+ const cacheVersion = basename7(root), declaredVersion = manifest.version === undefined ? "" : typeof manifest.version === "string" ? manifest.version.trim() : null;
18025
18255
  if (declaredVersion === null || (declaredVersion ? declaredVersion !== cacheVersion : cacheVersion !== CODEX_DEFAULT_AGENT_PLUGIN_VERSION))
18026
18256
  refuse2();
18027
18257
  if (manifest.hooks !== undefined && !isBundledCleanupHooks(root, manifest.name, manifest.hooks) || manifest.commands !== undefined || manifest.mcpServers !== undefined && manifest.mcpServers !== "./.mcp.json" || manifest.apps !== undefined && manifest.apps !== "./.app.json" || lstatSync13(join17(root, "hooks"), { throwIfNoEntry: false }))
@@ -18066,7 +18296,7 @@ function documentIdentity(document2, cache, read2) {
18066
18296
  }
18067
18297
  if (!front || typeof front !== "object" || !identifier2(front.name) || typeof front.description !== "string" || !front.description.trim())
18068
18298
  refuse2();
18069
- for (let root = dirname11(document2), depth = 0;root.startsWith(cache + sep6) && depth < 12; root = dirname11(root), depth++) {
18299
+ for (let root = dirname12(document2), depth = 0;root.startsWith(cache + sep6) && depth < 12; root = dirname12(root), depth++) {
18070
18300
  const path = join17(root, ".codex-plugin", "plugin.json");
18071
18301
  if (!lstatSync13(path, { throwIfNoEntry: false }))
18072
18302
  continue;
@@ -18084,9 +18314,9 @@ function documentIdentity(document2, cache, read2) {
18084
18314
  if (!manifest || typeof manifest !== "object" || Array.isArray(manifest) || !identifier2(manifest.name))
18085
18315
  refuse2();
18086
18316
  const declaredVersion = manifest.version === undefined ? "" : typeof manifest.version === "string" ? manifest.version.trim() : null;
18087
- if (declaredVersion === null || (declaredVersion ? declaredVersion !== basename6(root) : basename6(root) !== CODEX_DEFAULT_AGENT_PLUGIN_VERSION))
18317
+ if (declaredVersion === null || (declaredVersion ? declaredVersion !== basename7(root) : basename7(root) !== CODEX_DEFAULT_AGENT_PLUGIN_VERSION))
18088
18318
  refuse2();
18089
- return { name: `${manifest.name}:${front.name}`, namespace: manifest.name, pluginParent: dirname11(root), root };
18319
+ return { name: `${manifest.name}:${front.name}`, namespace: manifest.name, pluginParent: dirname12(root), root };
18090
18320
  }
18091
18321
  refuse2();
18092
18322
  }
@@ -18115,13 +18345,13 @@ function classifyCodexPluginCacheDocument(document2, cache, read2) {
18115
18345
  function reviewedDisabledCodexPluginParent(cache, parent, controls, rules) {
18116
18346
  try {
18117
18347
  const parts = relative5(cache, parent).split(sep6), enrolled = controls.filter((control) => control.pluginParent === parent);
18118
- if (resolve10(parent) !== parent || parts.length !== 2 || parts.some((part) => !identifier2(part)) || !enrolled.length || !Array.isArray(rules))
18348
+ if (resolve11(parent) !== parent || parts.length !== 2 || parts.some((part) => !identifier2(part)) || !enrolled.length || !Array.isArray(rules))
18119
18349
  return false;
18120
- for (let cursor = parent;; cursor = dirname11(cursor)) {
18350
+ for (let cursor = parent;; cursor = dirname12(cursor)) {
18121
18351
  const stat = lstatSync13(cursor, { throwIfNoEntry: false });
18122
18352
  if (stat && (!stat.isDirectory() || stat.isSymbolicLink()))
18123
18353
  return false;
18124
- if (dirname11(cursor) === cursor)
18354
+ if (dirname12(cursor) === cursor)
18125
18355
  break;
18126
18356
  }
18127
18357
  return enrolled.every((control) => control.namespace === parts[1] && control.pluginId === `${parts[1]}@${parts[0]}` && remotePluginIdentifier(control.remotePluginId) && control.skillsOnly === true && !control.appSha256 && !control.mcpSha256 && control.name.startsWith(control.namespace + ":") && /^[a-f0-9]{64}$/.test(control.manifestSha256) && rules.some((rule) => typeof rule?.name === "string" && rule.name.trim() === control.name && rule.enabled === false) && !rules.some((rule) => (typeof rule?.name === "string" && rule.name.trim() === control.name || typeof rule?.path === "string" && (rule.path === parent || rule.path.startsWith(parent + sep6))) && rule.enabled !== false));
@@ -18134,14 +18364,14 @@ function absentDisabledCodexPluginParent(cache, parent, controls, rules) {
18134
18364
  }
18135
18365
  function reviewedRetiredCodexRoot(cache, root, controls, rules, read2, allowAbsent = false) {
18136
18366
  try {
18137
- const parent = dirname11(root), parts = relative5(cache, parent).split(sep6), enrolled = controls.filter((control) => control.pluginParent === parent);
18138
- if (resolve10(root) !== root || parts.length !== 2 || parts.some((part) => !identifier2(part)) || !basename6(root) || basename6(root) === "latest" || !enrolled.length || !Array.isArray(rules))
18367
+ const parent = dirname12(root), parts = relative5(cache, parent).split(sep6), enrolled = controls.filter((control) => control.pluginParent === parent);
18368
+ if (resolve11(root) !== root || parts.length !== 2 || parts.some((part) => !identifier2(part)) || !basename7(root) || basename7(root) === "latest" || !enrolled.length || !Array.isArray(rules))
18139
18369
  return false;
18140
- for (let cursor = root;; cursor = dirname11(cursor)) {
18370
+ for (let cursor = root;; cursor = dirname12(cursor)) {
18141
18371
  const stat = lstatSync13(cursor, { throwIfNoEntry: false });
18142
18372
  if (stat && (!stat.isDirectory() || stat.isSymbolicLink()))
18143
18373
  return false;
18144
- if (dirname11(cursor) === cursor)
18374
+ if (dirname12(cursor) === cursor)
18145
18375
  break;
18146
18376
  }
18147
18377
  if (!enrolled.every((control) => control.namespace === parts[1] && control.pluginId === `${parts[1]}@${parts[0]}` && remotePluginIdentifier(control.remotePluginId) && control.skillsOnly === true && !control.appSha256 && !control.mcpSha256 && control.name.startsWith(control.namespace + ":") && /^[a-f0-9]{64}$/.test(control.manifestSha256) && rules.some((rule) => typeof rule?.name === "string" && rule.name.trim() === control.name && rule.enabled === false) && !rules.some((rule) => (typeof rule?.name === "string" && rule.name.trim() === control.name || typeof rule?.path === "string" && (rule.path === parent || rule.path === root || rule.path.startsWith(root + sep6))) && rule.enabled !== false)))
@@ -18188,8 +18418,8 @@ function reviewedCodexPluginCapabilitiesUnchanged(cache, controls, read2, rules)
18188
18418
  for (const name of names) {
18189
18419
  let root = join17(parent, name), stat = lstatSync13(root);
18190
18420
  if (stat.isSymbolicLink()) {
18191
- const target = resolve10(parent, readlinkSync3(root));
18192
- if (name !== "latest" || dirname11(target) !== parent || !lstatSync13(target).isDirectory() || realpathSync6(target) !== target)
18421
+ const target = resolve11(parent, readlinkSync3(root));
18422
+ if (name !== "latest" || dirname12(target) !== parent || !lstatSync13(target).isDirectory() || realpathSync6(target) !== target)
18193
18423
  return false;
18194
18424
  root = target;
18195
18425
  stat = lstatSync13(root);
@@ -18209,7 +18439,7 @@ function reviewedCodexPluginCapabilitiesUnchanged(cache, controls, read2, rules)
18209
18439
  function sourceInputUnchanged(input, cache, read2) {
18210
18440
  try {
18211
18441
  const parts = relative5(cache, input.pluginParent).split(sep6);
18212
- if (parts.length !== 2 || parts.some((part) => !identifier2(part)) || parts[1] !== input.namespace || input.pluginId !== `${parts[1]}@${parts[0]}` || !codexPluginSourceIsConfigControlled({ id: input.pluginId, sourceType: "local", sourceSha256: input.sourceSha256 }) || input.sourceSha256 !== hashNativeJsonControls(JSON.stringify({ type: "local", path: input.sourceRoot })) || resolve10(input.sourceRoot) !== input.sourceRoot || !lstatSync13(input.sourceRoot).isDirectory() || realpathSync6(input.sourceRoot) !== input.sourceRoot || input.sourceRoot === cache || input.sourceRoot.startsWith(cache + sep6) || cache.startsWith(input.sourceRoot + sep6))
18442
+ if (parts.length !== 2 || parts.some((part) => !identifier2(part)) || parts[1] !== input.namespace || input.pluginId !== `${parts[1]}@${parts[0]}` || !codexPluginSourceIsConfigControlled({ id: input.pluginId, sourceType: "local", sourceSha256: input.sourceSha256 }) || input.sourceSha256 !== hashNativeJsonControls(JSON.stringify({ type: "local", path: input.sourceRoot })) || resolve11(input.sourceRoot) !== input.sourceRoot || !lstatSync13(input.sourceRoot).isDirectory() || realpathSync6(input.sourceRoot) !== input.sourceRoot || input.sourceRoot === cache || input.sourceRoot.startsWith(cache + sep6) || cache.startsWith(input.sourceRoot + sep6))
18213
18443
  return false;
18214
18444
  const path = join17(input.sourceRoot, ".codex-plugin/plugin.json"), stat = lstatSync13(path);
18215
18445
  if (!stat.isFile() || stat.size > 1024 * 1024 || realpathSync6(path) !== path)
@@ -18280,9 +18510,9 @@ function refuse3(code, detail) {
18280
18510
  throw new Error(`${code}: ${detail}`);
18281
18511
  }
18282
18512
  var object5 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
18283
- function boundedId(value, field) {
18513
+ function boundedId(value, field2) {
18284
18514
  if (typeof value !== "string" || !value || value.length > MAX_ENVELOPE_ID_LENGTH || value.trim() !== value || /[\u0000-\u001f\u007f]/.test(value))
18285
- refuse3("NATIVE_SKILL_POLICY_INVALID", `${field} must be a bounded non-empty string`);
18515
+ refuse3("NATIVE_SKILL_POLICY_INVALID", `${field2} must be a bounded non-empty string`);
18286
18516
  return value;
18287
18517
  }
18288
18518
  function parseCodexNativePolicyTrust(value) {
@@ -18305,9 +18535,9 @@ function parseCodexNativeHookEnvelope(envelope, bridgeDocument) {
18305
18535
  if (!object5(value))
18306
18536
  refuse3("NATIVE_SKILL_POLICY_INVALID", "native_skill_policy must be an object");
18307
18537
  const keys = Object.keys(value);
18308
- for (const field of POLICY_FIELDS)
18309
- if (!Object.hasOwn(value, field))
18310
- refuse3("NATIVE_SKILL_POLICY_INVALID", `native_skill_policy.${field} is missing`);
18538
+ for (const field2 of POLICY_FIELDS)
18539
+ if (!Object.hasOwn(value, field2))
18540
+ refuse3("NATIVE_SKILL_POLICY_INVALID", `native_skill_policy.${field2} is missing`);
18311
18541
  if (keys.length !== POLICY_FIELDS.length)
18312
18542
  refuse3("NATIVE_SKILL_POLICY_INVALID", "native_skill_policy carries unknown fields");
18313
18543
  if (value.capability !== CODEX_NATIVE_POLICY_CAPABILITY)
@@ -18371,19 +18601,19 @@ function readBounded(path, maximum, what) {
18371
18601
  }
18372
18602
  }
18373
18603
  function verifyCodexNativeBridgeDocument(path, expectedContent, expectedSha256) {
18374
- if (!isAbsolute12(path) || resolve11(path) !== path || !path.endsWith("/SKILL.md"))
18604
+ if (!isAbsolute13(path) || resolve12(path) !== path || !path.endsWith("/SKILL.md"))
18375
18605
  refuse3("NATIVE_SKILL_POLICY_BRIDGE_UNVERIFIED", "the bridge document path is not an exact absolute SKILL.md path");
18376
- for (let cursor = path;; cursor = dirname12(cursor)) {
18606
+ for (let cursor = path;; cursor = dirname13(cursor)) {
18377
18607
  const stat = lstatSync14(cursor, { throwIfNoEntry: false });
18378
18608
  if (!stat || stat.isSymbolicLink() || (cursor === path ? !stat.isFile() : !stat.isDirectory()))
18379
18609
  refuse3("NATIVE_SKILL_POLICY_BRIDGE_UNVERIFIED", `the bridge path has a missing, linked or unexpected component: ${cursor}`);
18380
- if (dirname12(cursor) === cursor)
18610
+ if (dirname13(cursor) === cursor)
18381
18611
  break;
18382
18612
  }
18383
18613
  if (realpathSync7.native(path) !== path)
18384
18614
  refuse3("NATIVE_SKILL_POLICY_BRIDGE_UNVERIFIED", "the bridge document real path differs from its lexical path");
18385
18615
  const bytes = readBounded(path, MAX_BRIDGE_DOCUMENT_BYTES, "the bridge document");
18386
- const sha2562 = createHash13("sha256").update(bytes).digest("hex");
18616
+ const sha2562 = createHash14("sha256").update(bytes).digest("hex");
18387
18617
  if (!bytes.equals(Buffer.from(expectedContent, "utf8")) || sha2562 !== expectedSha256)
18388
18618
  refuse3("NATIVE_SKILL_POLICY_BRIDGE_UNVERIFIED", "the bridge document bytes differ from the managed bridge");
18389
18619
  return { path, sha256: sha2562 };
@@ -18449,13 +18679,13 @@ function assertExecutableWitnessStat(stat, currentUid) {
18449
18679
  return { dev: String(stat.dev), ino: String(stat.ino), size: String(stat.size), mtimeNs: String(stat.mtimeNs), ctimeNs: String(stat.ctimeNs), uid: String(stat.uid) };
18450
18680
  }
18451
18681
  function executableWitness(path) {
18452
- if (!isAbsolute12(path) || resolve11(path) !== path)
18682
+ if (!isAbsolute13(path) || resolve12(path) !== path)
18453
18683
  refuse3("NATIVE_SKILL_POLICY_PROCESS_UNBOUND", "the consumer executable path is not an exact absolute path");
18454
- for (let cursor = dirname12(path);; cursor = dirname12(cursor)) {
18684
+ for (let cursor = dirname13(path);; cursor = dirname13(cursor)) {
18455
18685
  const stat2 = lstatSync14(cursor, { throwIfNoEntry: false });
18456
18686
  if (!stat2 || stat2.isSymbolicLink() || !stat2.isDirectory())
18457
18687
  refuse3("NATIVE_SKILL_POLICY_PROCESS_UNBOUND", `the consumer executable path has a missing, linked or unexpected component: ${cursor}`);
18458
- if (dirname12(cursor) === cursor)
18688
+ if (dirname13(cursor) === cursor)
18459
18689
  break;
18460
18690
  }
18461
18691
  const stat = lstatSync14(path, { throwIfNoEntry: false, bigint: true });
@@ -18466,7 +18696,7 @@ function executableWitness(path) {
18466
18696
  var witnessKey = (path, witness) => JSON.stringify([path, witness.dev, witness.ino, witness.size, witness.mtimeNs, witness.ctimeNs, witness.uid]);
18467
18697
  var executableDigestMemory = new Map;
18468
18698
  function executableCachePath(dataDir22) {
18469
- return join18(resolve11(dataDir22), "agent-hooks", "codex-native-policy-executable-cache.json");
18699
+ return join18(resolve12(dataDir22), "agent-hooks", "codex-native-policy-executable-cache.json");
18470
18700
  }
18471
18701
  var currentUid = () => process.getuid?.() ?? -1;
18472
18702
  function readTrustedCacheBytes(path, ownerUid) {
@@ -18511,16 +18741,16 @@ function readExecutableCache(dataDir22, ownerUid = currentUid()) {
18511
18741
  if (!object5(value) || value.schema !== CODEX_NATIVE_POLICY_EXECUTABLE_CACHE_SCHEMA || !Array.isArray(value.entries) || value.entries.length > 16)
18512
18742
  return [];
18513
18743
  const fields = ["path", "sha256", "dev", "ino", "size", "mtimeNs", "ctimeNs", "uid"];
18514
- return value.entries.filter((entry) => object5(entry) && Object.keys(entry).length === fields.length && fields.every((field) => typeof entry[field] === "string") && HEX_DIGEST.test(entry.sha256) && isAbsolute12(entry.path) && ["dev", "ino", "size", "mtimeNs", "ctimeNs", "uid"].every((field) => /^\d{1,30}$/.test(entry[field])));
18744
+ return value.entries.filter((entry) => object5(entry) && Object.keys(entry).length === fields.length && fields.every((field2) => typeof entry[field2] === "string") && HEX_DIGEST.test(entry.sha256) && isAbsolute13(entry.path) && ["dev", "ino", "size", "mtimeNs", "ctimeNs", "uid"].every((field2) => /^\d{1,30}$/.test(entry[field2])));
18515
18745
  } catch {
18516
18746
  return [];
18517
18747
  }
18518
18748
  }
18519
18749
  function writeExecutableCache(dataDir22, entries) {
18520
- const path = executableCachePath(dataDir22), directory = dirname12(path), temporary = `${path}.skills-${randomUUID2()}`;
18750
+ const path = executableCachePath(dataDir22), directory = dirname13(path), temporary = `${path}.skills-${randomUUID2()}`;
18521
18751
  let descriptor;
18522
18752
  try {
18523
- const parent = lstatSync14(dirname12(directory), { throwIfNoEntry: false });
18753
+ const parent = lstatSync14(dirname13(directory), { throwIfNoEntry: false });
18524
18754
  if (!parent || parent.isSymbolicLink() || !parent.isDirectory())
18525
18755
  return;
18526
18756
  const existing = lstatSync14(directory, { throwIfNoEntry: false });
@@ -18588,16 +18818,16 @@ function verifyCodexNativeExecutable(inspector, processId, trust, cache = {}, ex
18588
18818
  }
18589
18819
  function assertOperatorTrustRoot(dataDir22) {
18590
18820
  const check = (path, what, required) => {
18591
- if (!isAbsolute12(path) || resolve11(path) !== path)
18821
+ if (!isAbsolute13(path) || resolve12(path) !== path)
18592
18822
  refuse3("NATIVE_SKILL_POLICY_TRUST_INVALID", `${what} path is not an exact absolute path`);
18593
- for (let cursor = dirname12(path);; cursor = dirname12(cursor)) {
18823
+ for (let cursor = dirname13(path);; cursor = dirname13(cursor)) {
18594
18824
  const stat2 = lstatSync14(cursor, { throwIfNoEntry: false });
18595
18825
  if (!stat2) {
18596
18826
  if (required)
18597
18827
  refuse3("NATIVE_SKILL_POLICY_TRUST_INVALID", `${what} has a missing path component: ${cursor}`);
18598
18828
  } else if (stat2.isSymbolicLink() || !stat2.isDirectory())
18599
18829
  refuse3("NATIVE_SKILL_POLICY_TRUST_INVALID", `${what} has a linked or unexpected path component: ${cursor}`);
18600
- if (dirname12(cursor) === cursor)
18830
+ if (dirname13(cursor) === cursor)
18601
18831
  break;
18602
18832
  }
18603
18833
  const stat = lstatSync14(path, { throwIfNoEntry: false, bigint: true });
@@ -18627,9 +18857,9 @@ function assertOperatorTrustRoot(dataDir22) {
18627
18857
  if ((stat.mode & 0o022n) !== 0n)
18628
18858
  refuse3("NATIVE_SKILL_POLICY_TRUST_INVALID", `${what} is group- or world-writable`);
18629
18859
  };
18630
- checkDirectory(resolve11(dataDir22), "the Skills data directory", true);
18631
- checkDirectory(dirname12(executableCachePath(dataDir22)), "the agent-hooks directory", false);
18632
- check(join18(resolve11(dataDir22), "agent-policy.json"), "the managed policy", true);
18860
+ checkDirectory(resolve12(dataDir22), "the Skills data directory", true);
18861
+ checkDirectory(dirname13(executableCachePath(dataDir22)), "the agent-hooks directory", false);
18862
+ check(join18(resolve12(dataDir22), "agent-policy.json"), "the managed policy", true);
18633
18863
  check(executableCachePath(dataDir22), "the executable identity cache", false);
18634
18864
  }
18635
18865
  function runCodexNativePolicyHelper(request) {
@@ -18800,12 +19030,12 @@ function defaultProcessInspector() {
18800
19030
  return { platform: process.platform, arch: process.arch, pid: process.pid, parentOf: () => null, startTime: () => null, executablePath: () => null };
18801
19031
  }
18802
19032
  function codexNativePolicyReceiptPath(dataDir22) {
18803
- return join18(resolve11(dataDir22), "agent-hooks", "codex-native-policy-acceptance.json");
19033
+ return join18(resolve12(dataDir22), "agent-hooks", "codex-native-policy-acceptance.json");
18804
19034
  }
18805
19035
  function recordCodexNativePolicyAcceptance(dataDir22, verification, accepted) {
18806
- const path = codexNativePolicyReceiptPath(dataDir22), directory = dirname12(path);
19036
+ const path = codexNativePolicyReceiptPath(dataDir22), directory = dirname13(path);
18807
19037
  const acceptedCache = accepted.map((entry) => ({ path: entry.path, treeSha256: entry.treeSha256 })).sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
18808
- if (acceptedCache.some((entry) => !isAbsolute12(entry.path) || !HEX_DIGEST.test(entry.treeSha256)) || new Set(acceptedCache.map((entry) => entry.path)).size !== acceptedCache.length)
19038
+ if (acceptedCache.some((entry) => !isAbsolute13(entry.path) || !HEX_DIGEST.test(entry.treeSha256)) || new Set(acceptedCache.map((entry) => entry.path)).size !== acceptedCache.length)
18809
19039
  refuse3("NATIVE_SKILL_POLICY_RECEIPT_FAILED", "accepted cache entries must be unique absolute paths with tree digests");
18810
19040
  const value = {
18811
19041
  schema: CODEX_NATIVE_POLICY_RECEIPT_SCHEMA,
@@ -18849,10 +19079,10 @@ function recordCodexNativePolicyAcceptance(dataDir22, verification, accepted) {
18849
19079
  }
18850
19080
  return path;
18851
19081
  }
18852
- var sha = (text2) => createHash14("sha256").update(text2).digest("hex");
19082
+ var sha = (text2) => createHash15("sha256").update(text2).digest("hex");
18853
19083
  var EFFORT = new Set(["none", "minimal", "low", "medium", "high", "xhigh"]);
18854
19084
  var VERBOSITY = new Set(["low", "medium", "high"]);
18855
- function need3(value) {
19085
+ function need4(value) {
18856
19086
  if (!value)
18857
19087
  throw new Error("Invalid Codex settings witness");
18858
19088
  }
@@ -18867,14 +19097,14 @@ function numericTokens(text2) {
18867
19097
  continue;
18868
19098
  }
18869
19099
  if (char === '"' || char === "'") {
18870
- const quote3 = char, triple = text2.slice(at, at + 3) === quote3.repeat(3);
19100
+ const quote22 = char, triple = text2.slice(at, at + 3) === quote22.repeat(3);
18871
19101
  at += triple ? 3 : 1;
18872
19102
  while (at < text2.length) {
18873
- if (quote3 === '"' && text2[at] === "\\") {
19103
+ if (quote22 === '"' && text2[at] === "\\") {
18874
19104
  at += 2;
18875
19105
  continue;
18876
19106
  }
18877
- if (text2.slice(at, at + (triple ? 3 : 1)) === quote3.repeat(triple ? 3 : 1)) {
19107
+ if (text2.slice(at, at + (triple ? 3 : 1)) === quote22.repeat(triple ? 3 : 1)) {
18878
19108
  at += triple ? 3 : 1;
18879
19109
  break;
18880
19110
  }
@@ -18895,8 +19125,8 @@ function numericTokens(text2) {
18895
19125
  }
18896
19126
  return result;
18897
19127
  }
18898
- function canonical4(value, depth = 0, budget2 = { remaining: 65536 }) {
18899
- need3(depth <= 32 && --budget2.remaining >= 0);
19128
+ function canonical5(value, depth = 0, budget2 = { remaining: 65536 }) {
19129
+ need4(depth <= 32 && --budget2.remaining >= 0);
18900
19130
  if (value === null)
18901
19131
  return ["null"];
18902
19132
  if (typeof value === "string")
@@ -18904,20 +19134,20 @@ function canonical4(value, depth = 0, budget2 = { remaining: 65536 }) {
18904
19134
  if (typeof value === "boolean")
18905
19135
  return ["boolean", value];
18906
19136
  if (typeof value === "number") {
18907
- need3(Number.isFinite(value));
19137
+ need4(Number.isFinite(value));
18908
19138
  return ["number", String(value)];
18909
19139
  }
18910
19140
  if (value instanceof Date) {
18911
- need3(Number.isFinite(value.getTime()));
19141
+ need4(Number.isFinite(value.getTime()));
18912
19142
  return ["date", value.toISOString()];
18913
19143
  }
18914
19144
  if (Array.isArray(value))
18915
- return ["array", value.map((child) => canonical4(child, depth + 1, budget2))];
18916
- need3(value && typeof value === "object");
18917
- return ["object", Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, child]) => [key, canonical4(child, depth + 1, budget2)])];
19145
+ return ["array", value.map((child2) => canonical5(child2, depth + 1, budget2))];
19146
+ need4(value && typeof value === "object");
19147
+ return ["object", Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, child2]) => [key, canonical5(child2, depth + 1, budget2)])];
18918
19148
  }
18919
19149
  function hashCodexSettingsReplacement(text2, budget2 = { remaining: 256 * 1024 * 1024 }) {
18920
- need3(Buffer.byteLength(text2) <= 1024 * 1024 && budget2.remaining >= Buffer.byteLength(text2));
19150
+ need4(Buffer.byteLength(text2) <= 1024 * 1024 && budget2.remaining >= Buffer.byteLength(text2));
18921
19151
  budget2.remaining -= Buffer.byteLength(text2);
18922
19152
  let config;
18923
19153
  try {
@@ -18925,17 +19155,17 @@ function hashCodexSettingsReplacement(text2, budget2 = { remaining: 256 * 1024 *
18925
19155
  } catch {
18926
19156
  throw new Error("Invalid Codex settings witness");
18927
19157
  }
18928
- need3(config && typeof config === "object" && !Array.isArray(config));
19158
+ need4(config && typeof config === "object" && !Array.isArray(config));
18929
19159
  if (Object.hasOwn(config, "model")) {
18930
- need3(typeof config.model === "string" && /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/.test(config.model));
19160
+ need4(typeof config.model === "string" && /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/.test(config.model));
18931
19161
  delete config.model;
18932
19162
  }
18933
19163
  for (const [key, values] of [["model_reasoning_effort", EFFORT], ["model_verbosity", VERBOSITY]])
18934
19164
  if (Object.hasOwn(config, key)) {
18935
- need3(typeof config[key] === "string" && values.has(config[key]));
19165
+ need4(typeof config[key] === "string" && values.has(config[key]));
18936
19166
  delete config[key];
18937
19167
  }
18938
- return sha(`hasna.skills.codex-settings.v1\x00${JSON.stringify([canonical4(config), numericTokens(text2)])}`);
19168
+ return sha(`hasna.skills.codex-settings.v1\x00${JSON.stringify([canonical5(config), numericTokens(text2)])}`);
18939
19169
  }
18940
19170
  function captureCodexSettings(path, budget2 = { remaining: 256 * 1024 * 1024 }) {
18941
19171
  const text2 = readNativeSettingsWitnessFile(path, budget2, "config.toml");
@@ -19002,13 +19232,13 @@ function projectRegularCodexMcp(config, source) {
19002
19232
  }
19003
19233
  return { config: expected, numericSource };
19004
19234
  }
19005
- var sha2 = (text2) => createHash15("sha256").update(text2).digest("hex");
19235
+ var sha2 = (text2) => createHash16("sha256").update(text2).digest("hex");
19006
19236
  var EFFORT2 = new Set(["none", "minimal", "low", "medium", "high", "xhigh"]);
19007
19237
  var VERBOSITY2 = new Set(["low", "medium", "high"]);
19008
19238
  var MODEL = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/;
19009
19239
  var CODEX_DISCOVERY_PROJECTION_FIELDS = ["plugins", "marketplaces", "skills"];
19010
19240
  var INFERENCE = ["model", "model_reasoning_effort", "model_verbosity"];
19011
- function need4(value) {
19241
+ function need5(value) {
19012
19242
  if (!value)
19013
19243
  throw new Error("Invalid Codex settings witness");
19014
19244
  }
@@ -19029,14 +19259,14 @@ function numericTokens2(text2) {
19029
19259
  continue;
19030
19260
  }
19031
19261
  if (char === '"' || char === "'") {
19032
- const quote3 = char, triple = text2.slice(at, at + 3) === quote3.repeat(3);
19262
+ const quote22 = char, triple = text2.slice(at, at + 3) === quote22.repeat(3);
19033
19263
  at += triple ? 3 : 1;
19034
19264
  while (at < text2.length) {
19035
- if (quote3 === '"' && text2[at] === "\\") {
19265
+ if (quote22 === '"' && text2[at] === "\\") {
19036
19266
  at += 2;
19037
19267
  continue;
19038
19268
  }
19039
- if (text2.slice(at, at + (triple ? 3 : 1)) === quote3.repeat(triple ? 3 : 1)) {
19269
+ if (text2.slice(at, at + (triple ? 3 : 1)) === quote22.repeat(triple ? 3 : 1)) {
19040
19270
  at += triple ? 3 : 1;
19041
19271
  break;
19042
19272
  }
@@ -19057,8 +19287,8 @@ function numericTokens2(text2) {
19057
19287
  }
19058
19288
  return result.sort();
19059
19289
  }
19060
- function canonical5(value, depth = 0, budget2 = { remaining: 65536 }) {
19061
- need4(depth <= 32 && --budget2.remaining >= 0);
19290
+ function canonical6(value, depth = 0, budget2 = { remaining: 65536 }) {
19291
+ need5(depth <= 32 && --budget2.remaining >= 0);
19062
19292
  if (value === null)
19063
19293
  return ["null"];
19064
19294
  if (typeof value === "string")
@@ -19066,17 +19296,17 @@ function canonical5(value, depth = 0, budget2 = { remaining: 65536 }) {
19066
19296
  if (typeof value === "boolean")
19067
19297
  return ["boolean", value];
19068
19298
  if (typeof value === "number") {
19069
- need4(Number.isFinite(value));
19299
+ need5(Number.isFinite(value));
19070
19300
  return ["number", String(value)];
19071
19301
  }
19072
19302
  if (isDate(value)) {
19073
- need4(Number.isFinite(value.getTime()));
19303
+ need5(Number.isFinite(value.getTime()));
19074
19304
  return ["date", value.toISOString()];
19075
19305
  }
19076
19306
  if (Array.isArray(value))
19077
- return ["array", value.map((child) => canonical5(child, depth + 1, budget2))];
19078
- need4(isRecord3(value));
19079
- return ["object", Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, child]) => [key, canonical5(child, depth + 1, budget2)])];
19307
+ return ["array", value.map((child2) => canonical6(child2, depth + 1, budget2))];
19308
+ need5(isRecord3(value));
19309
+ return ["object", Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, child2]) => [key, canonical6(child2, depth + 1, budget2)])];
19080
19310
  }
19081
19311
  function normalize3(config, version = 2) {
19082
19312
  if (isRecord3(config.hooks)) {
@@ -19118,15 +19348,15 @@ function inference(target, version) {
19118
19348
  if (Object.hasOwn(target, key)) {
19119
19349
  const value = target[key];
19120
19350
  if (key === "model")
19121
- need4(typeof value === "string" && MODEL.test(value));
19351
+ need5(typeof value === "string" && MODEL.test(value));
19122
19352
  else if (key === "personality")
19123
- need4(typeof value === "string" && ["none", "friendly", "pragmatic"].includes(value));
19353
+ need5(typeof value === "string" && ["none", "friendly", "pragmatic"].includes(value));
19124
19354
  else if (version >= 3 && key !== "model_verbosity") {
19125
- need4(typeof value === "string" && value.length <= 128 && !/[\x00-\x1f\x7f]/.test(value));
19355
+ need5(typeof value === "string" && value.length <= 128 && !/[\x00-\x1f\x7f]/.test(value));
19126
19356
  if (key !== "service_tier")
19127
- need4(value.length > 0);
19357
+ need5(value.length > 0);
19128
19358
  } else
19129
- need4(typeof value === "string" && (key === "model_reasoning_effort" ? EFFORT2.has(value) : VERBOSITY2.has(value)));
19359
+ need5(typeof value === "string" && (key === "model_reasoning_effort" ? EFFORT2.has(value) : VERBOSITY2.has(value)));
19130
19360
  delete target[key];
19131
19361
  }
19132
19362
  }
@@ -19159,14 +19389,14 @@ function projectModelAvailabilityNux(config, text2) {
19159
19389
  continue;
19160
19390
  }
19161
19391
  if (char === '"' || char === "'") {
19162
- const quote3 = char;
19392
+ const quote22 = char;
19163
19393
  at++;
19164
19394
  while (at < span.length) {
19165
- if (quote3 === '"' && span[at] === "\\") {
19395
+ if (quote22 === '"' && span[at] === "\\") {
19166
19396
  at += 2;
19167
19397
  continue;
19168
19398
  }
19169
- if (span[at++] === quote3)
19399
+ if (span[at++] === quote22)
19170
19400
  break;
19171
19401
  }
19172
19402
  continue;
@@ -19246,14 +19476,14 @@ function settingsDigest2(text2, version = 2) {
19246
19476
  } catch {
19247
19477
  throw new Error("Invalid Codex settings witness");
19248
19478
  }
19249
- need4(isRecord3(config));
19479
+ need5(isRecord3(config));
19250
19480
  const mcp = version >= 3 ? projectRegularCodexMcp(config, text2) : { config, numericSource: text2 };
19251
19481
  const projected = version === 4 ? projectModelAvailabilityNux(mcp.config, mcp.numericSource) : mcp;
19252
19482
  normalize3(projected.config, version);
19253
- return sha2(`hasna.skills.codex-settings.v${version}\x00${JSON.stringify([canonical5(projected.config), numericTokens2(projected.numericSource)])}`);
19483
+ return sha2(`hasna.skills.codex-settings.v${version}\x00${JSON.stringify([canonical6(projected.config), numericTokens2(projected.numericSource)])}`);
19254
19484
  }
19255
19485
  function hashCodexSettingsReplacementV2(text2, budget2 = { remaining: 256 * 1024 * 1024 }) {
19256
- need4(Buffer.byteLength(text2) <= 1024 * 1024 && budget2.remaining >= Buffer.byteLength(text2));
19486
+ need5(Buffer.byteLength(text2) <= 1024 * 1024 && budget2.remaining >= Buffer.byteLength(text2));
19257
19487
  budget2.remaining -= Buffer.byteLength(text2);
19258
19488
  return settingsDigest2(text2);
19259
19489
  }
@@ -19265,17 +19495,17 @@ function readCodexSettingsPreimage(path, budget2 = { remaining: 2 * 1024 * 1024
19265
19495
  return readNativeSettingsWitnessFile(path, budget2, "config.toml");
19266
19496
  }
19267
19497
  function upgradeCodexSettingsWitness(previous, reviewedSettingsPath) {
19268
- need4(previous && Object.keys(previous).every((key) => ["path", "hashMode", "sha256"].includes(key)) && (previous.hashMode === undefined || previous.hashMode === "bytes" || previous.hashMode === "codex-settings-v1") && /^[a-f0-9]{64}$/.test(previous.sha256));
19498
+ need5(previous && Object.keys(previous).every((key) => ["path", "hashMode", "sha256"].includes(key)) && (previous.hashMode === undefined || previous.hashMode === "bytes" || previous.hashMode === "codex-settings-v1") && /^[a-f0-9]{64}$/.test(previous.sha256));
19269
19499
  const budget2 = { remaining: 2 * 1024 * 1024 };
19270
19500
  const before = readNativeSettingsWitnessFile(reviewedSettingsPath, budget2, "config.toml"), current2 = readNativeSettingsWitnessFile(previous.path, budget2, "config.toml");
19271
- need4((previous.hashMode === "codex-settings-v1" ? hashCodexSettingsReplacement(before) : sha2(before)) === previous.sha256);
19501
+ need5((previous.hashMode === "codex-settings-v1" ? hashCodexSettingsReplacement(before) : sha2(before)) === previous.sha256);
19272
19502
  const sha2562 = settingsDigest2(current2);
19273
19503
  if (settingsDigest2(before) !== sha2562)
19274
19504
  throw new Error("Codex non-preference settings changed; explicit discovery review required");
19275
19505
  return { path: previous.path, hashMode: "codex-settings-v2", sha256: sha2562 };
19276
19506
  }
19277
19507
  function hashCodexSettingsReplacementV3(text2, budget2 = { remaining: 256 * 1024 * 1024 }) {
19278
- need4(Buffer.byteLength(text2) <= 1024 * 1024 && budget2.remaining >= Buffer.byteLength(text2));
19508
+ need5(Buffer.byteLength(text2) <= 1024 * 1024 && budget2.remaining >= Buffer.byteLength(text2));
19279
19509
  budget2.remaining -= Buffer.byteLength(text2);
19280
19510
  return settingsDigest2(text2, 3);
19281
19511
  }
@@ -19283,18 +19513,18 @@ function captureCodexSettingsV3(path, budget2 = { remaining: 256 * 1024 * 1024 }
19283
19513
  return { path, hashMode: "codex-settings-v3", sha256: settingsDigest2(readNativeSettingsWitnessFile(path, budget2, "config.toml"), 3) };
19284
19514
  }
19285
19515
  function upgradeCodexSettingsWitnessV3(previous, reviewedSettingsPath) {
19286
- need4(previous && Object.keys(previous).every((key) => ["path", "hashMode", "sha256"].includes(key)) && (previous.hashMode === undefined || ["bytes", "codex-settings-v1", "codex-settings-v2"].includes(previous.hashMode)) && /^[a-f0-9]{64}$/.test(previous.sha256));
19516
+ need5(previous && Object.keys(previous).every((key) => ["path", "hashMode", "sha256"].includes(key)) && (previous.hashMode === undefined || ["bytes", "codex-settings-v1", "codex-settings-v2"].includes(previous.hashMode)) && /^[a-f0-9]{64}$/.test(previous.sha256));
19287
19517
  const budget2 = { remaining: 2 * 1024 * 1024 };
19288
19518
  const before = readNativeSettingsWitnessFile(reviewedSettingsPath, budget2, "config.toml"), current2 = readNativeSettingsWitnessFile(previous.path, budget2, "config.toml");
19289
19519
  const original = previous.hashMode === "codex-settings-v2" ? settingsDigest2(before) : previous.hashMode === "codex-settings-v1" ? hashCodexSettingsReplacement(before) : sha2(before);
19290
- need4(original === previous.sha256);
19520
+ need5(original === previous.sha256);
19291
19521
  const sha2562 = settingsDigest2(current2, 3);
19292
19522
  if (settingsDigest2(before, 3) !== sha2562)
19293
19523
  throw new Error("Codex settings outside the reviewed V3 contract changed; explicit discovery review required");
19294
19524
  return { path: previous.path, hashMode: "codex-settings-v3", sha256: sha2562 };
19295
19525
  }
19296
19526
  function hashCodexSettingsReplacementV4(text2, budget2 = { remaining: 256 * 1024 * 1024 }) {
19297
- need4(Buffer.byteLength(text2) <= 1024 * 1024 && budget2.remaining >= Buffer.byteLength(text2));
19527
+ need5(Buffer.byteLength(text2) <= 1024 * 1024 && budget2.remaining >= Buffer.byteLength(text2));
19298
19528
  budget2.remaining -= Buffer.byteLength(text2);
19299
19529
  return settingsDigest2(text2, 4);
19300
19530
  }
@@ -19302,18 +19532,18 @@ function captureCodexSettingsV4(path, budget2 = { remaining: 256 * 1024 * 1024 }
19302
19532
  return { path, hashMode: "codex-settings-v4", sha256: settingsDigest2(readNativeSettingsWitnessFile(path, budget2, "config.toml"), 4) };
19303
19533
  }
19304
19534
  function upgradeCodexSettingsWitnessV4(previous, reviewedSettingsPath) {
19305
- need4(previous && Object.keys(previous).every((key) => ["path", "hashMode", "sha256"].includes(key)) && (previous.hashMode === undefined || ["bytes", "codex-settings-v1", "codex-settings-v2", "codex-settings-v3"].includes(previous.hashMode)) && /^[a-f0-9]{64}$/.test(previous.sha256));
19535
+ need5(previous && Object.keys(previous).every((key) => ["path", "hashMode", "sha256"].includes(key)) && (previous.hashMode === undefined || ["bytes", "codex-settings-v1", "codex-settings-v2", "codex-settings-v3"].includes(previous.hashMode)) && /^[a-f0-9]{64}$/.test(previous.sha256));
19306
19536
  const budget2 = { remaining: 2 * 1024 * 1024 };
19307
19537
  const before = readNativeSettingsWitnessFile(reviewedSettingsPath, budget2, "config.toml"), current2 = readNativeSettingsWitnessFile(previous.path, budget2, "config.toml");
19308
19538
  const original = previous.hashMode === "codex-settings-v3" ? settingsDigest2(before, 3) : previous.hashMode === "codex-settings-v2" ? settingsDigest2(before, 2) : previous.hashMode === "codex-settings-v1" ? hashCodexSettingsReplacement(before) : sha2(before);
19309
- need4(original === previous.sha256);
19539
+ need5(original === previous.sha256);
19310
19540
  const sha2562 = settingsDigest2(current2, 4);
19311
19541
  if (settingsDigest2(before, 4) !== sha2562)
19312
19542
  throw new Error("Codex settings outside the reviewed V4 contract changed; explicit discovery review required");
19313
19543
  return { path: previous.path, hashMode: "codex-settings-v4", sha256: sha2562 };
19314
19544
  }
19315
- function refusal(reason = "is unreadable") {
19316
- return new SkillSelectionError("INVALID_AGENT_POLICY", `The Skills agent loading policy ${reason}; refusing legacy fallback.`);
19545
+ function refusal(reason2 = "is unreadable") {
19546
+ return new SkillSelectionError("INVALID_AGENT_POLICY", `The Skills agent loading policy ${reason2}; refusing legacy fallback.`);
19317
19547
  }
19318
19548
  function parseManagedSkillPolicy(text2) {
19319
19549
  if (Buffer.byteLength(text2) > AGENT_POLICY_LIMITS.bytes)
@@ -19398,7 +19628,7 @@ Use the Skills CLI as the skill authority for this station.
19398
19628
 
19399
19629
  This bridge contains no skill payloads. Do not copy skill content into agent-native skill directories or load other native skill copies. If a Skills command refuses authority, selection, integrity, or native drift, report that refusal and use its repair guidance; do not substitute bundled or stale local content. Explicit local draft authoring remains available.
19400
19630
  `;
19401
- var CLI_BRIDGE_DIGEST = createHash16("sha256").update(markdown).digest("hex");
19631
+ var CLI_BRIDGE_DIGEST = createHash17("sha256").update(markdown).digest("hex");
19402
19632
  var CLI_BRIDGE_FILES = Object.freeze({
19403
19633
  "SKILL.md": markdown,
19404
19634
  ".hasna-skills.json": `${JSON.stringify({ managedBy: "@hasna/skills", kind: "cli-bridge", version: CLI_BRIDGE_VERSION, protocol: "selection-v1", contentSha256: CLI_BRIDGE_DIGEST }, null, 2)}
@@ -19425,22 +19655,22 @@ function sumiConfigDirectory(home, env = process.env) {
19425
19655
  if (env[key] !== undefined)
19426
19656
  throw new Error(`Sumi ${key} requires a dedicated discovery adapter; unset it before Skills integration`);
19427
19657
  const selected = (key) => env[key]?.trim() ? env[key] : undefined;
19428
- const expand = (value) => resolve12(value === "~" ? home : value.startsWith("~/") ? join21(home, value.slice(2)) : value);
19658
+ const expand = (value) => resolve13(value === "~" ? home : value.startsWith("~/") ? join21(home, value.slice(2)) : value);
19429
19659
  const explicit = selected("SUMI_CONFIG_DIR");
19430
19660
  const xdg = selected("XDG_CONFIG_HOME");
19431
19661
  const custom2 = selected("SUMI_HOME");
19432
- const canonical6 = explicit ? expand(explicit) : xdg ? join21(expand(xdg), "sumi") : join21(custom2 ? expand(custom2) : join21(home, ".hasna-internal/sumi"), "config");
19662
+ const canonical7 = explicit ? expand(explicit) : xdg ? join21(expand(xdg), "sumi") : join21(custom2 ? expand(custom2) : join21(home, ".hasna-internal/sumi"), "config");
19433
19663
  if (explicit || xdg || custom2)
19434
- return canonical6;
19664
+ return canonical7;
19435
19665
  const legacy = join21(home, ".config/sumi");
19436
- const a = lstatSync17(canonical6, { throwIfNoEntry: false }), b = lstatSync17(legacy, { throwIfNoEntry: false });
19437
- if (a && b && realpathSync8(canonical6) !== realpathSync8(legacy))
19666
+ const a = lstatSync17(canonical7, { throwIfNoEntry: false }), b = lstatSync17(legacy, { throwIfNoEntry: false });
19667
+ if (a && b && realpathSync8(canonical7) !== realpathSync8(legacy))
19438
19668
  throw new Error("Sumi config roots conflict; complete native home adoption before Skills integration");
19439
- const path = a ? canonical6 : b ? legacy : canonical6;
19669
+ const path = a ? canonical7 : b ? legacy : canonical7;
19440
19670
  if (!existsSync82(path))
19441
19671
  return path;
19442
19672
  const physical = realpathSync8(path);
19443
- if ((a?.isSymbolicLink() || b?.isSymbolicLink()) && ![canonical6, legacy].includes(physical))
19673
+ if ((a?.isSymbolicLink() || b?.isSymbolicLink()) && ![canonical7, legacy].includes(physical))
19444
19674
  throw new Error("Sumi config alias must resolve to its canonical or legacy root");
19445
19675
  return physical;
19446
19676
  }
@@ -19538,17 +19768,20 @@ var SUMI_SKILL_PERMISSIONS = [
19538
19768
  { action: "skill", resource: "*", effect: "deny" },
19539
19769
  { action: "skill", resource: "skills-cli", effect: "allow" }
19540
19770
  ];
19541
- function need5(value, code) {
19771
+ function need6(value, code) {
19542
19772
  if (!value)
19543
19773
  throw new Error(`CODEX_HOOK_TRUST_${code}`);
19544
19774
  }
19545
19775
  var sameStat = (a, b) => ["dev", "ino", "uid", "nlink", "mode", "size", "mtimeNs", "ctimeNs"].every((key) => a[key] === b[key]);
19776
+ function trustedAncestorOwner(uid) {
19777
+ return BigInt(uid) === 0n || BigInt(uid) === BigInt(process.getuid());
19778
+ }
19546
19779
  function safeParents(file) {
19547
- for (let p = dirname13(file);; p = dirname13(p)) {
19780
+ for (let p = dirname14(file);; p = dirname14(p)) {
19548
19781
  const s = lstatSync18(p);
19549
- need5(s.isDirectory() && !s.isSymbolicLink(), "UNSAFE_PARENT");
19550
- need5((s.mode & 18) === 0 || s.uid === 0 && (s.mode & 512) !== 0, "UNSAFE_PARENT");
19551
- if (dirname13(p) === p)
19782
+ need6(s.isDirectory() && !s.isSymbolicLink() && trustedAncestorOwner(s.uid), "UNSAFE_PARENT");
19783
+ need6((s.mode & 18) === 0 || s.uid === 0 && (s.mode & 512) !== 0, "UNSAFE_PARENT");
19784
+ if (dirname14(p) === p)
19552
19785
  break;
19553
19786
  }
19554
19787
  }
@@ -19556,12 +19789,12 @@ function snapshot(file, privateFile = false, options = {}) {
19556
19789
  const readOnlyPackage = options.readOnlyPackage === true && !privateFile;
19557
19790
  safeParents(file);
19558
19791
  const initial = lstatSync18(file, { bigint: true });
19559
- need5(initial.isFile() && initial.uid === BigInt(process.getuid()) && (initial.nlink === 1n || readOnlyPackage && initial.nlink > 1n) && (initial.mode & 0o022n) === 0n && (!privateFile || (initial.mode & 0o777n) === 0o600n), "UNSAFE_FILE");
19560
- need5(initial.size <= 8n * 1024n * 1024n, "FILE_BOUND");
19792
+ need6(initial.isFile() && initial.uid === BigInt(process.getuid()) && (initial.nlink === 1n || readOnlyPackage && initial.nlink > 1n) && (initial.mode & 0o022n) === 0n && (!privateFile || (initial.mode & 0o777n) === 0o600n), "UNSAFE_FILE");
19793
+ need6(initial.size <= 8n * 1024n * 1024n, "FILE_BOUND");
19561
19794
  const fd = openSync9(file, constants9.O_RDONLY | constants9.O_NOFOLLOW | constants9.O_NONBLOCK);
19562
19795
  try {
19563
19796
  const before = fstatSync9(fd, { bigint: true });
19564
- need5(sameStat(initial, before), "INPUT_CHANGED");
19797
+ need6(sameStat(initial, before), "INPUT_CHANGED");
19565
19798
  const bytes = Buffer.alloc(Number(before.size) + 1);
19566
19799
  let length = 0;
19567
19800
  while (length < bytes.length) {
@@ -19570,18 +19803,57 @@ function snapshot(file, privateFile = false, options = {}) {
19570
19803
  break;
19571
19804
  length += n2;
19572
19805
  }
19573
- need5(length === Number(before.size) && sameStat(before, fstatSync9(fd, { bigint: true })) && sameStat(before, lstatSync18(file, { bigint: true })), "INPUT_CHANGED");
19806
+ need6(length === Number(before.size) && sameStat(before, fstatSync9(fd, { bigint: true })) && sameStat(before, lstatSync18(file, { bigint: true })), "INPUT_CHANGED");
19574
19807
  const content = bytes.subarray(0, length), text2 = new TextDecoder("utf-8", { fatal: true }).decode(content);
19575
- return { file, privateFile, readOnlyPackage, text: text2, bytes: content, stat: before, sha256: createHash17("sha256").update(content).digest("hex") };
19808
+ return { file, privateFile, readOnlyPackage, text: text2, bytes: content, stat: before, sha256: createHash18("sha256").update(content).digest("hex") };
19576
19809
  } finally {
19577
19810
  closeSync9(fd);
19578
19811
  }
19579
19812
  }
19580
19813
  function unchanged2(before) {
19581
19814
  const after = snapshot(before.file, before.privateFile, before.readOnlyPackage ? { readOnlyPackage: true } : {});
19582
- need5(sameStat(before.stat, after.stat) && after.sha256 === before.sha256, "INPUT_CHANGED");
19815
+ need6(sameStat(before.stat, after.stat) && after.sha256 === before.sha256, "INPUT_CHANGED");
19583
19816
  }
19584
- var sha3 = (data) => createHash18("sha256").update(data).digest("hex");
19817
+ var PINNED_LAUNCHER_BUN_FLAGS = ["--config=/dev/null", "--no-env-file", "--no-macros", "--no-install"];
19818
+ var PINNED_LAUNCHER_ENV_NAMES = [
19819
+ "HOME",
19820
+ "PATH",
19821
+ "TMPDIR",
19822
+ "TERM",
19823
+ "TERM_PROGRAM",
19824
+ "TERM_PROGRAM_VERSION",
19825
+ "COLORTERM",
19826
+ "LANG",
19827
+ "USER",
19828
+ "LOGNAME",
19829
+ "SHELL",
19830
+ "TZ",
19831
+ "NO_COLOR",
19832
+ "FORCE_COLOR",
19833
+ "CI",
19834
+ "COLUMNS",
19835
+ "LINES",
19836
+ "EDITOR",
19837
+ "VISUAL",
19838
+ "PAGER",
19839
+ "SSH_AUTH_SOCK",
19840
+ "DATABASE_URL",
19841
+ "TERMINAL_CWD",
19842
+ "CODEX_HOME",
19843
+ "HERMES_HOME",
19844
+ "HERMES_ENABLE_PROJECT_PLUGINS",
19845
+ "HOST",
19846
+ "PORT",
19847
+ "NODE_ENV",
19848
+ "AGENT_ID",
19849
+ "ECS_CONTAINER_METADATA_URI_V4"
19850
+ ];
19851
+ var PINNED_LAUNCHER_ENV_PREFIXES = ["HASNA", "SKILLS", "SKILL", "MCP", "XDG", "LC", "AWS"];
19852
+ var ENV_PREFIX = new RegExp(`^(${PINNED_LAUNCHER_ENV_PREFIXES.join("|")})_`);
19853
+ var ENV_EXACT = new Set(PINNED_LAUNCHER_ENV_NAMES);
19854
+ var COMMAND_LINE = new RegExp(`^set -- '([^']+)' ${PINNED_LAUNCHER_BUN_FLAGS.join(" ")} '--cwd=([^']+)' '([^']+)' "\\$@"$`, "m");
19855
+ var PINNED_LAUNCHER_MAX_BYTES = 16 * 1024;
19856
+ var sha3 = (data) => createHash20("sha256").update(data).digest("hex");
19585
19857
  var ROOTS = NATIVE_SKILL_ROOTS;
19586
19858
  function hasTrustedDarwinAcl(fd, allowDenyOnly = false) {
19587
19859
  try {
@@ -19631,12 +19903,13 @@ function isSystemRootAlias(path) {
19631
19903
  return false;
19632
19904
  const target = `/private${path}`, link = `private${path}`;
19633
19905
  const identity5 = (stat) => `${stat.dev}:${stat.ino}:${stat.ctimeNs}:${stat.uid}:${stat.mode}`;
19906
+ const directoryIdentity = (stat) => `${stat.dev}:${stat.ino}:${stat.uid}:${stat.mode}`;
19634
19907
  try {
19635
- const before = lstatSync19(path, { bigint: true });
19636
- if (!before.isSymbolicLink() || before.uid !== 0n || readlinkSync5(path) !== link)
19908
+ const before = lstatSync20(path, { bigint: true });
19909
+ if (!before.isSymbolicLink() || before.uid !== 0n || readlinkSync7(path) !== link)
19637
19910
  return false;
19638
19911
  const directories = ["/", "/private", target].map((directory) => {
19639
- const stat = lstatSync19(directory, { bigint: true });
19912
+ const stat = lstatSync20(directory, { bigint: true });
19640
19913
  if (!stat.isDirectory() || stat.uid !== 0n)
19641
19914
  throw new Error("Untrusted system alias directory");
19642
19915
  if (directory !== "/private/tmp") {
@@ -19644,34 +19917,34 @@ function isSystemRootAlias(path) {
19644
19917
  throw new Error("Writable system alias directory");
19645
19918
  } else if ((stat.mode & 0o1000n) === 0n)
19646
19919
  throw new Error("Unprotected system temporary directory");
19647
- const fd = openSync10(directory, constants10.O_RDONLY | constants10.O_DIRECTORY | constants10.O_NOFOLLOW);
19920
+ const fd = openSync11(directory, constants11.O_RDONLY | constants11.O_DIRECTORY | constants11.O_NOFOLLOW);
19648
19921
  try {
19649
- if (identity5(fstatSync10(fd, { bigint: true })) !== identity5(stat) || !hasTrustedDarwinAcl(fd) || identity5(fstatSync10(fd, { bigint: true })) !== identity5(stat))
19922
+ if (directoryIdentity(fstatSync11(fd, { bigint: true })) !== directoryIdentity(stat) || !hasTrustedDarwinAcl(fd) || directoryIdentity(fstatSync11(fd, { bigint: true })) !== directoryIdentity(stat))
19650
19923
  throw new Error("Unverified system alias directory ACL");
19651
19924
  } finally {
19652
- closeSync10(fd);
19925
+ closeSync11(fd);
19653
19926
  }
19654
- return { directory, identity: identity5(stat) };
19927
+ return { directory, identity: directoryIdentity(stat) };
19655
19928
  });
19656
- return realpathSync9(path) === target && readlinkSync5(path) === link && identity5(lstatSync19(path, { bigint: true })) === identity5(before) && directories.every((item) => identity5(lstatSync19(item.directory, { bigint: true })) === item.identity);
19929
+ return realpathSync10(path) === target && readlinkSync7(path) === link && identity5(lstatSync20(path, { bigint: true })) === identity5(before) && directories.every((item) => directoryIdentity(lstatSync20(item.directory, { bigint: true })) === item.identity);
19657
19930
  } catch {
19658
19931
  return false;
19659
19932
  }
19660
19933
  }
19661
19934
  function canonicalSystemPath(path) {
19662
- const absolute = resolve13(path), root = `/${absolute.split(sep7)[1]}`;
19663
- if (process.platform !== "darwin" || !["/var", "/tmp", "/etc"].includes(root) || !lstatSync19(root, { throwIfNoEntry: false })?.isSymbolicLink())
19935
+ const absolute = resolve15(path), root = `/${absolute.split(sep7)[1]}`;
19936
+ if (process.platform !== "darwin" || !["/var", "/tmp", "/etc"].includes(root) || !lstatSync20(root, { throwIfNoEntry: false })?.isSymbolicLink())
19664
19937
  return absolute;
19665
19938
  if (!isSystemRootAlias(root))
19666
19939
  throw new Error(`Refusing symlink path: ${root}`);
19667
19940
  return `/private${absolute}`;
19668
19941
  }
19669
19942
  function assertSafePath(path) {
19670
- let cursor = resolve13(path);
19943
+ let cursor = resolve15(path);
19671
19944
  while (true) {
19672
- if (lstatSync19(cursor, { throwIfNoEntry: false })?.isSymbolicLink() && !isSystemRootAlias(cursor))
19945
+ if (lstatSync20(cursor, { throwIfNoEntry: false })?.isSymbolicLink() && !isSystemRootAlias(cursor))
19673
19946
  throw new Error(`Refusing symlink path: ${cursor}`);
19674
- const parent = dirname14(cursor);
19947
+ const parent = dirname15(cursor);
19675
19948
  if (parent === cursor)
19676
19949
  return;
19677
19950
  cursor = parent;
@@ -19679,17 +19952,17 @@ function assertSafePath(path) {
19679
19952
  }
19680
19953
  function readRootAlias(home, agent) {
19681
19954
  assertSafePath(home);
19682
- const realHome = realpathSync9(home), alias = join23(realHome, `.${agent}`);
19683
- const stat = lstatSync19(alias, { throwIfNoEntry: false, bigint: true });
19955
+ const realHome = realpathSync10(home), alias = join23(realHome, `.${agent}`);
19956
+ const stat = lstatSync20(alias, { throwIfNoEntry: false, bigint: true });
19684
19957
  if (!stat?.isSymbolicLink())
19685
19958
  throw new Error(`Agent root alias changed after planning: ${alias}`);
19686
- const link = readlinkSync5(alias), targetPath = resolve13(dirname14(alias), link);
19959
+ const link = readlinkSync7(alias), targetPath = resolve15(dirname15(alias), link);
19687
19960
  assertSafePath(targetPath);
19688
- const targetStat = lstatSync19(targetPath, { throwIfNoEntry: false });
19961
+ const targetStat = lstatSync20(targetPath, { throwIfNoEntry: false });
19689
19962
  if (!targetStat?.isDirectory())
19690
19963
  throw new Error(`Agent root alias must target an existing directory: ${alias}`);
19691
- const target = realpathSync9(targetPath), inside = relative6(realHome, target);
19692
- if (!inside || inside === ".." || inside.startsWith(`..${sep7}`) || isAbsolute13(inside))
19964
+ const target = realpathSync10(targetPath), inside = relative6(realHome, target);
19965
+ if (!inside || inside === ".." || inside.startsWith(`..${sep7}`) || isAbsolute16(inside))
19693
19966
  throw new Error(`Agent root alias target must be inside the real home: ${alias}`);
19694
19967
  return { agent, home: realHome, alias, target, link, aliasIdentity: `${stat.dev}:${stat.ino}:${stat.ctimeNs}`, targetIdentity: `${targetStat.dev}:${targetStat.ino}` };
19695
19968
  }
@@ -19698,7 +19971,7 @@ function rootAliases(home, allowed = false) {
19698
19971
  return [];
19699
19972
  const result = [];
19700
19973
  for (const agent of ["claude", "codex"])
19701
- if (lstatSync19(join23(home, `.${agent}`), { throwIfNoEntry: false })?.isSymbolicLink())
19974
+ if (lstatSync20(join23(home, `.${agent}`), { throwIfNoEntry: false })?.isSymbolicLink())
19702
19975
  result.push(readRootAlias(home, agent));
19703
19976
  if (result.some((item, index) => result.slice(index + 1).some((other) => item.target === other.target || item.target.startsWith(other.target + sep7) || other.target.startsWith(item.target + sep7))))
19704
19977
  throw new Error("Agent root alias targets must not overlap");
@@ -19715,17 +19988,17 @@ function disabledCodexSkillPaths(config, aliases) {
19715
19988
  const rows = skills.config;
19716
19989
  if (!Array.isArray(rows))
19717
19990
  return [];
19718
- if (rows.some((entry) => !entry || typeof entry !== "object" || Array.isArray(entry) || typeof entry.enabled !== "boolean" || entry.path !== undefined === (entry.name !== undefined) || entry.path !== undefined && (typeof entry.path !== "string" || !isAbsolute13(entry.path)) || entry.name !== undefined && (typeof entry.name !== "string" || !entry.name.trim())))
19991
+ if (rows.some((entry) => !entry || typeof entry !== "object" || Array.isArray(entry) || typeof entry.enabled !== "boolean" || entry.path !== undefined === (entry.name !== undefined) || entry.path !== undefined && (typeof entry.path !== "string" || !isAbsolute16(entry.path)) || entry.name !== undefined && (typeof entry.name !== "string" || !entry.name.trim())))
19719
19992
  return [];
19720
19993
  if (rows.some((entry) => entry.name !== undefined && entry.enabled !== false))
19721
19994
  return [];
19722
19995
  const settings = new Map;
19723
19996
  for (const entry of rows) {
19724
- if (typeof entry.path !== "string" || !isAbsolute13(entry.path))
19997
+ if (typeof entry.path !== "string" || !isAbsolute16(entry.path))
19725
19998
  continue;
19726
19999
  let document2;
19727
20000
  try {
19728
- document2 = realpathSync9(canonicalAgentPath(entry.path, aliases));
20001
+ document2 = realpathSync10(canonicalAgentPath(entry.path, aliases));
19729
20002
  } catch {
19730
20003
  continue;
19731
20004
  }
@@ -19733,7 +20006,7 @@ function disabledCodexSkillPaths(config, aliases) {
19733
20006
  continue;
19734
20007
  settings.set(document2, [...settings.get(document2) ?? [], entry.enabled === false]);
19735
20008
  }
19736
- return [...settings].filter(([, values]) => values.length === 1 && values[0] === true).map(([document2]) => dirname14(document2));
20009
+ return [...settings].filter(([, values]) => values.length === 1 && values[0] === true).map(([document2]) => dirname15(document2));
19737
20010
  }
19738
20011
  function recheckRootAliases(aliases) {
19739
20012
  for (const binding of aliases) {
@@ -19746,16 +20019,16 @@ function recheckRootAliases(aliases) {
19746
20019
  }
19747
20020
  function nativeSourceDigest(path) {
19748
20021
  assertSafePath(path);
19749
- return lstatSync19(path, { throwIfNoEntry: false }) ? sha3(readNativeBytes(path, 1024 * 1024)) : null;
20022
+ return lstatSync20(path, { throwIfNoEntry: false }) ? sha3(readNativeBytes(path, 1024 * 1024)) : null;
19750
20023
  }
19751
20024
  function readNativeBytes(path, maximum = 64 * 1024 * 1024) {
19752
20025
  assertSafePath(path);
19753
- const before = lstatSync19(path);
20026
+ const before = lstatSync20(path);
19754
20027
  if (!before.isFile() || before.size > maximum)
19755
20028
  throw new Error("Unsupported or oversized native skill file");
19756
- const descriptor = openSync10(path, constants10.O_RDONLY | constants10.O_NOFOLLOW | constants10.O_NONBLOCK);
20029
+ const descriptor = openSync11(path, constants11.O_RDONLY | constants11.O_NOFOLLOW | constants11.O_NONBLOCK);
19757
20030
  try {
19758
- const opened = fstatSync10(descriptor);
20031
+ const opened = fstatSync11(descriptor);
19759
20032
  if (!opened.isFile() || opened.dev !== before.dev || opened.ino !== before.ino || opened.size !== before.size)
19760
20033
  throw new Error("Native skill file changed while reading");
19761
20034
  const bytes = Buffer.allocUnsafe(before.size + 1);
@@ -19766,19 +20039,19 @@ function readNativeBytes(path, maximum = 64 * 1024 * 1024) {
19766
20039
  break;
19767
20040
  length += count;
19768
20041
  }
19769
- const after = fstatSync10(descriptor), current2 = lstatSync19(path);
20042
+ const after = fstatSync11(descriptor), current2 = lstatSync20(path);
19770
20043
  if (current2.dev !== opened.dev || current2.ino !== opened.ino || current2.size !== after.size || current2.mtimeMs !== after.mtimeMs || current2.ctimeMs !== after.ctimeMs || length !== before.size || after.size !== before.size || after.mtimeMs !== opened.mtimeMs || after.ctimeMs !== opened.ctimeMs)
19771
20044
  throw new Error("Native skill file changed while reading");
19772
20045
  return bytes.subarray(0, length);
19773
20046
  } finally {
19774
- closeSync10(descriptor);
20047
+ closeSync11(descriptor);
19775
20048
  }
19776
20049
  }
19777
20050
  function treeHash(root) {
19778
- const hash2 = createHash18("sha256");
20051
+ const hash2 = createHash20("sha256");
19779
20052
  let bytes = 0, files = 0;
19780
20053
  function visit2(path) {
19781
- const stat = lstatSync19(path);
20054
+ const stat = lstatSync20(path);
19782
20055
  if (stat.isSymbolicLink())
19783
20056
  throw new Error(`Refusing symlink in skill: ${path}`);
19784
20057
  const rel = relative6(root, path);
@@ -19808,7 +20081,7 @@ function projectAncestorDirectories(projects) {
19808
20081
  if (depth >= 100)
19809
20082
  throw new Error("NATIVE_SKILL_DRIFT: project ancestor discovery limit exceeded");
19810
20083
  directories.add(path);
19811
- const parent = dirname14(path);
20084
+ const parent = dirname15(path);
19812
20085
  if (parent === path)
19813
20086
  break;
19814
20087
  path = parent;
@@ -19817,7 +20090,7 @@ function projectAncestorDirectories(projects) {
19817
20090
  return [...directories];
19818
20091
  }
19819
20092
  function isCodexSkillDiscoveryInput(path) {
19820
- for (let cursor = canonicalSystemPath(path);cursor !== dirname14(cursor); cursor = dirname14(cursor)) {
20093
+ for (let cursor = canonicalSystemPath(path);cursor !== dirname15(cursor); cursor = dirname15(cursor)) {
19821
20094
  if (ROOTS.some(([agent, root]) => agent === "codex" && cursor.endsWith(join23(sep7, root))))
19822
20095
  return true;
19823
20096
  }
@@ -19825,9 +20098,9 @@ function isCodexSkillDiscoveryInput(path) {
19825
20098
  }
19826
20099
  function inventoryNativeSkills(home = homedir22(), options = {}) {
19827
20100
  home = canonicalSystemPath(home);
19828
- if (options.reviewedCacheAlias !== undefined && (!options.includeVendor || !isAbsolute13(options.reviewedCacheAlias) || resolve13(options.reviewedCacheAlias) !== options.reviewedCacheAlias))
20101
+ if (options.reviewedCacheAlias !== undefined && (!options.includeVendor || !isAbsolute16(options.reviewedCacheAlias) || resolve15(options.reviewedCacheAlias) !== options.reviewedCacheAlias))
19829
20102
  throw new Error("A reviewed cache alias requires vendor inventory and an exact absolute path");
19830
- if (options.disabledVendorPaths?.some((path) => !isAbsolute13(path) || resolve13(path) !== path))
20103
+ if (options.disabledVendorPaths?.some((path) => !isAbsolute16(path) || resolve15(path) !== path))
19831
20104
  throw new Error("Disabled vendor paths must be exact absolute paths");
19832
20105
  const reviewedCacheAlias = options.reviewedCacheAlias === undefined ? undefined : canonicalSystemPath(options.reviewedCacheAlias);
19833
20106
  const disabledVendorPaths = new Set((options.disabledVendorPaths ?? []).map(canonicalSystemPath));
@@ -19846,7 +20119,7 @@ function inventoryNativeSkills(home = homedir22(), options = {}) {
19846
20119
  roots.push(["sumi", canonicalAgentPath(join23(project, directory, name), aliases)]);
19847
20120
  }
19848
20121
  const installationInputs = options.codexInstallationInputRoots ?? [];
19849
- if (installationInputs.some((input) => resolve13(input) !== input || realpathSync9(input) !== input || roots.some(([agent, path]) => agent === "codex" && (path === input || path.startsWith(input + sep7) || input.startsWith(path + sep7)))))
20122
+ if (installationInputs.some((input) => resolve15(input) !== input || realpathSync10(input) !== input || roots.some(([agent, path]) => agent === "codex" && (path === input || path.startsWith(input + sep7) || input.startsWith(path + sep7)))))
19850
20123
  throw new Error("Native installation input overlaps an unconditional skill-loading root");
19851
20124
  const entries = [], seen = new Set;
19852
20125
  const cacheScans = new Map, maxAliasProofEntries = 1e4;
@@ -19860,13 +20133,13 @@ function inventoryNativeSkills(home = homedir22(), options = {}) {
19860
20133
  }
19861
20134
  let reviewedCacheAliasFound = false;
19862
20135
  function verifiedSiblingCacheAlias(agent, path, parent) {
19863
- const link = readlinkSync5(path), lexicalTarget = resolve13(parent, link);
19864
- if (isAbsolute13(link) ? link !== lexicalTarget : dirname14(link) !== ".")
20136
+ const link = readlinkSync7(path), lexicalTarget = resolve15(parent, link);
20137
+ if (isAbsolute16(link) ? link !== lexicalTarget : dirname15(link) !== ".")
19865
20138
  return false;
19866
20139
  const target = canonicalSystemPath(lexicalTarget);
19867
- if (dirname14(target) !== parent)
20140
+ if (dirname15(target) !== parent)
19868
20141
  return false;
19869
- if (!lstatSync19(target, { throwIfNoEntry: false })?.isDirectory())
20142
+ if (!lstatSync20(target, { throwIfNoEntry: false })?.isDirectory())
19870
20143
  return false;
19871
20144
  const scan = cacheScans.get(target);
19872
20145
  if (!scan?.complete || scan.entries > maxAliasProofEntries)
@@ -19891,7 +20164,7 @@ function inventoryNativeSkills(home = homedir22(), options = {}) {
19891
20164
  return scan;
19892
20165
  if (!existsSync92(path))
19893
20166
  return scan;
19894
- const stat = lstatSync19(path);
20167
+ const stat = lstatSync20(path);
19895
20168
  if (stat.isFile()) {
19896
20169
  if (agent === "sumi" && depth === 1 && path.endsWith(".md"))
19897
20170
  throw new Error("NATIVE_SKILL_DRIFT: flat Sumi skill documents require a dedicated migration adapter");
@@ -19908,22 +20181,22 @@ function inventoryNativeSkills(home = homedir22(), options = {}) {
19908
20181
  const marker = join23(path, ".hasna-skills.json");
19909
20182
  if (existsSync92(marker)) {
19910
20183
  try {
19911
- managed = JSON.parse(readFileSync14(marker, "utf8")).managedBy === "@hasna/skills";
20184
+ managed = JSON.parse(readFileSync15(marker, "utf8")).managedBy === "@hasna/skills";
19912
20185
  } catch {}
19913
20186
  }
19914
20187
  const bridge = (!vendor || agent === "sumi") && isOwnedCliBridge(path, bridgePaths);
19915
20188
  const rootAlias = aliases.find((item) => path === item.target || path.startsWith(item.target + sep7));
19916
- entries.push({ agent, path, hash: treeHash(path), managed, vendor, ...agent === "codex" || isCodexSkillDiscoveryInput(path) ? { codexHome: process.env.CODEX_HOME ?? join23(home, ".codex") } : {}, ...agent === "codex" && path.startsWith(canonicalAgentPath(join23(home, ".codex", "skills", ".system"), aliases) + sep7) ? { system: true } : {}, ...bridge ? { bridge: true, bridgeHome: resolve13(home) } : {}, ...rootAlias ? { rootAlias } : {} });
20189
+ entries.push({ agent, path, hash: treeHash(path), managed, vendor, ...agent === "codex" || isCodexSkillDiscoveryInput(path) ? { codexHome: process.env.CODEX_HOME ?? join23(home, ".codex") } : {}, ...agent === "codex" && path.startsWith(canonicalAgentPath(join23(home, ".codex", "skills", ".system"), aliases) + sep7) ? { system: true } : {}, ...bridge ? { bridge: true, bridgeHome: resolve15(home) } : {}, ...rootAlias ? { rootAlias } : {} });
19917
20190
  return scan;
19918
20191
  }
19919
20192
  if (depth > (agent === "sumi" ? 32 : vendor ? 32 : 3))
19920
20193
  return { ...scan, complete: false };
19921
20194
  const children = [], directory = opendirSync3(path);
19922
20195
  try {
19923
- let child;
19924
- while ((child = directory.readSync()) !== null) {
19925
- admit(join23(path, child.name));
19926
- children.push(child);
20196
+ let child2;
20197
+ while ((child2 = directory.readSync()) !== null) {
20198
+ admit(join23(path, child2.name));
20199
+ children.push(child2);
19927
20200
  }
19928
20201
  } finally {
19929
20202
  directory.closeSync();
@@ -19939,15 +20212,15 @@ function inventoryNativeSkills(home = homedir22(), options = {}) {
19939
20212
  const isVendor = vendor || name === ".system";
19940
20213
  if (isVendor && !options.includeVendor)
19941
20214
  continue;
19942
- const child = join23(path, name);
19943
- if (isVendor && lstatSync19(child, { throwIfNoEntry: false })?.isSymbolicLink()) {
19944
- const target = statSync9(child, { throwIfNoEntry: false });
19945
- if (target?.isFile() || pluginCache && target?.isDirectory() && verifiedSiblingCacheAlias(agent, child, path)) {
20215
+ const child2 = join23(path, name);
20216
+ if (isVendor && lstatSync20(child2, { throwIfNoEntry: false })?.isSymbolicLink()) {
20217
+ const target = statSync9(child2, { throwIfNoEntry: false });
20218
+ if (target?.isFile() || pluginCache && target?.isDirectory() && verifiedSiblingCacheAlias(agent, child2, path)) {
19946
20219
  scan.entries++;
19947
20220
  continue;
19948
20221
  }
19949
20222
  }
19950
- const childScan = visit2(agent, child, isVendor, depth + 1, pluginCache, true, configuredRoot);
20223
+ const childScan = visit2(agent, child2, isVendor, depth + 1, pluginCache, true, configuredRoot);
19951
20224
  scan.complete &&= childScan.complete;
19952
20225
  scan.hasSkills ||= childScan.hasSkills;
19953
20226
  scan.entries += childScan.entries;
@@ -19983,7 +20256,7 @@ function inventoryNativeSkills(home = homedir22(), options = {}) {
19983
20256
  }
19984
20257
  function readOptional(path) {
19985
20258
  assertSafePath(path);
19986
- return existsSync92(path) ? readFileSync14(path, "utf8") : null;
20259
+ return existsSync92(path) ? readFileSync15(path, "utf8") : null;
19987
20260
  }
19988
20261
  function jsonObject(text2, path) {
19989
20262
  if (text2 === null)
@@ -20081,29 +20354,28 @@ function configureHooks(config, agent, command, profileId, nativeReady) {
20081
20354
  }
20082
20355
  }
20083
20356
  function claudeSettingsConsumers(home, path, discoveries, aliases) {
20084
- const canonical6 = (value) => canonicalAgentPath(value, aliases);
20357
+ const canonical7 = (value) => canonicalAgentPath(value, aliases);
20085
20358
  const containsSettings = (root) => {
20086
- const distance = relative6(canonical6(root), path);
20087
- return distance === "" || distance !== ".." && !distance.startsWith(`..${sep7}`) && !isAbsolute13(distance);
20359
+ const distance = relative6(canonical7(root), path);
20360
+ return distance === "" || distance !== ".." && !distance.startsWith(`..${sep7}`) && !isAbsolute16(distance);
20088
20361
  };
20089
- return discoveries.filter((binding) => binding.agent === "claude" || binding.agent === "opencode" || canonical6(join23(home, AGENT_ADAPTERS[binding.agent].config)) === path || binding.sources.some((source) => canonical6(source.path) === path) || binding.roots.some(containsSettings) || binding.directories?.some((directory) => containsSettings(directory.path))).map((binding) => binding.agent);
20362
+ return discoveries.filter((binding) => binding.agent === "claude" || binding.agent === "opencode" || canonical7(join23(home, AGENT_ADAPTERS[binding.agent].config)) === path || binding.sources.some((source) => canonical7(source.path) === path) || binding.roots.some(containsSettings) || binding.directories?.some((directory) => containsSettings(directory.path))).map((binding) => binding.agent);
20090
20363
  }
20091
- function verifyCoordinatedDiscovery(binding, home, aliases) {
20364
+ function verifyCoordinatedDiscovery(binding, home, aliases, executable2) {
20092
20365
  try {
20093
20366
  if (binding.method !== "automatic" && binding.method !== "reviewed")
20094
20367
  throw new Error("Invalid managed discovery method");
20095
20368
  verifyAgentDiscovery(binding);
20096
- if (binding.method === "automatic") {
20097
- const current2 = resolveAgentDiscovery({ home, agent: binding.agent, canonical: (path) => canonicalAgentPath(path, aliases) });
20098
- if (JSON.stringify(current2) !== JSON.stringify(binding))
20099
- throw new Error("Configured native discovery roots changed during Claude update");
20100
- }
20369
+ if (binding.method === "automatic")
20370
+ verifyAutomaticDiscoveryClosure(binding, { home, canonical: (path) => canonicalAgentPath(path, aliases), change: "Configured native discovery roots changed during Claude update", executable: executable2 });
20101
20371
  } catch (error) {
20372
+ if (isDiscoveryRootUnresolved(error))
20373
+ throw error;
20102
20374
  throw new Error(`NATIVE_SKILL_DRIFT: ${error.message}`);
20103
20375
  }
20104
20376
  }
20105
20377
  function planClaudeHookEventsUpdate(options) {
20106
- const home = resolve13(options.home ?? homedir22()), dataDir22 = options.dataDir ?? getDataDirReadOnly();
20378
+ const home = resolve15(options.home ?? homedir22()), dataDir22 = options.dataDir ?? getDataDirReadOnly();
20107
20379
  const policyPath = join23(dataDir22, "agent-policy.json");
20108
20380
  assertSafePath(policyPath);
20109
20381
  const snapshot2 = readManagedSkillPolicySnapshot(dataDir22);
@@ -20117,7 +20389,7 @@ function planClaudeHookEventsUpdate(options) {
20117
20389
  recheckRootAliases(aliases);
20118
20390
  const path = canonicalAgentPath(join23(home, ".claude", "settings.json"), aliases);
20119
20391
  assertSafePath(path);
20120
- const before = lstatSync19(path, { throwIfNoEntry: false }) ? new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(readNativeBytes(path, 1024 * 1024)) : null;
20392
+ const before = lstatSync20(path, { throwIfNoEntry: false }) ? new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(readNativeBytes(path, 1024 * 1024)) : null;
20121
20393
  if ((before === null ? "absent" : sha3(before)) !== options.expectedSettingsSha256)
20122
20394
  throw new Error("Claude settings preimage changed");
20123
20395
  assertClaudeHookEventsReplacement(before, options.replacement, options.events);
@@ -20129,8 +20401,9 @@ function planClaudeHookEventsUpdate(options) {
20129
20401
  });
20130
20402
  if (discoveries.length !== agents.length || !agents.includes("claude"))
20131
20403
  throw new Error("Missing managed Claude discovery coverage");
20404
+ const discoveryExecutables = bridge.discoveryExecutables;
20132
20405
  for (const binding of discoveries)
20133
- verifyCoordinatedDiscovery(binding, home, aliases);
20406
+ verifyCoordinatedDiscovery(binding, home, aliases, discoveryExecutables?.[binding.agent]);
20134
20407
  const consumers = claudeSettingsConsumers(home, path, discoveries, aliases);
20135
20408
  for (const agent of consumers)
20136
20409
  assertManagedAgentBridge(agent, { home, dataDir: dataDir22, projectDir: home });
@@ -20165,13 +20438,14 @@ function planClaudeHookEventsUpdate(options) {
20165
20438
  observedPolicy: { path: policyPath, before: snapshot2.text },
20166
20439
  discoveryBefore: discoveries,
20167
20440
  discoveryAfter,
20441
+ ...discoveryExecutables ? { discoveryExecutables } : {},
20168
20442
  rootAliases: aliases,
20169
20443
  managedAgentChecks: { home, agents: consumers }
20170
20444
  };
20171
20445
  }
20172
20446
  function atomicWrite2(path, content) {
20173
20447
  assertSafePath(path);
20174
- mkdirSync6(dirname14(path), { recursive: true, mode: 448 });
20448
+ mkdirSync6(dirname15(path), { recursive: true, mode: 448 });
20175
20449
  const temporary = `${path}.skills-${randomUUID3()}`;
20176
20450
  try {
20177
20451
  writeFileSync6(temporary, content, { mode: 384, flag: "wx" });
@@ -20184,7 +20458,9 @@ function atomicWrite2(path, content) {
20184
20458
  function planAgentSettingsWitnessUpgrade(options) {
20185
20459
  if (options.targetCodexVersion !== undefined && (options.agent !== "codex" || ![2, 3, 4].includes(options.targetCodexVersion)))
20186
20460
  throw new Error("Invalid Codex witness target version");
20187
- const home = resolve13(options.home ?? homedir22()), dataDir22 = options.dataDir ?? getDataDirReadOnly();
20461
+ if (options.targetClaudeVersion !== undefined && (options.agent !== "claude" || ![3, 4].includes(options.targetClaudeVersion)))
20462
+ throw new Error("Invalid Claude witness target version");
20463
+ const home = resolve15(options.home ?? homedir22()), dataDir22 = options.dataDir ?? getDataDirReadOnly();
20188
20464
  const snapshot2 = readManagedSkillPolicySnapshot(dataDir22);
20189
20465
  if (!snapshot2 || sha3(snapshot2.text) !== options.expectedPolicySha256)
20190
20466
  throw new Error("Managed policy preimage changed");
@@ -20231,7 +20507,7 @@ function planAgentSettingsWitnessUpgrade(options) {
20231
20507
  replaced.push(source);
20232
20508
  }
20233
20509
  }
20234
- const next = options.agent === "sumi" ? upgradeSumiSettingsWitness(previous, options.reviewedPreimage) : options.agent === "claude" ? upgradeClaudeSettingsWitness(previous, options.reviewedPreimage) : options.targetCodexVersion === 4 ? upgradeCodexSettingsWitnessV4(previous, options.reviewedPreimage) : options.targetCodexVersion === 3 ? upgradeCodexSettingsWitnessV3(previous, options.reviewedPreimage) : upgradeCodexSettingsWitness(previous, options.reviewedPreimage);
20510
+ const next = options.agent === "sumi" ? upgradeSumiSettingsWitness(previous, options.reviewedPreimage) : options.agent === "claude" ? options.targetClaudeVersion === 4 ? upgradeClaudeSettingsWitnessV4(previous, options.reviewedPreimage) : upgradeClaudeSettingsWitness(previous, options.reviewedPreimage) : options.targetCodexVersion === 4 ? upgradeCodexSettingsWitnessV4(previous, options.reviewedPreimage) : options.targetCodexVersion === 3 ? upgradeCodexSettingsWitnessV3(previous, options.reviewedPreimage) : upgradeCodexSettingsWitness(previous, options.reviewedPreimage);
20235
20511
  const rebound = [];
20236
20512
  for (const source of binding.sources) {
20237
20513
  if (!replaced.includes(source)) {
@@ -20244,7 +20520,7 @@ function planAgentSettingsWitnessUpgrade(options) {
20244
20520
  const replacement = { ...binding, sources: rebound };
20245
20521
  verifyAgentDiscovery(replacement);
20246
20522
  const after = serializeManagedSkillPolicy({ ...policy, bridge: { ...policy.bridge, discovery: { ...policy.bridge.discovery, [options.agent]: replacement } } });
20247
- return { dataDir: dataDir22, profileId: policy.profileId, changes: [{ path: join23(dataDir22, "agent-policy.json"), before: snapshot2.text, after }], nativeSkills: [], observedPolicy: { path: join23(dataDir22, "agent-policy.json"), before: snapshot2.text }, observedSettings: { path: configPath, before: settings }, discoveryBefore: [replacement], discoveryAfter: [replacement], rootAliases: aliases, managedAgentChecks: { home, agents: [options.agent] }, settingsWitnessUpgrade: { agent: options.agent, path: configPath, fromHashMode: previous.hashMode ?? "bytes", fromSha256: previous.sha256, toHashMode: next.hashMode, toSha256: next.sha256, reviewedPreimage: options.reviewedPreimage, currentSettingsSha256: options.expectedSettingsSha256, replacedWitnesses: replaced.map((source) => ({ hashMode: source.hashMode ?? "bytes", sha256: source.sha256 })) } };
20523
+ return { dataDir: dataDir22, profileId: policy.profileId, changes: [{ path: join23(dataDir22, "agent-policy.json"), before: snapshot2.text, after }], nativeSkills: [], observedPolicy: { path: join23(dataDir22, "agent-policy.json"), before: snapshot2.text }, observedSettings: { path: configPath, before: settings }, discoveryBefore: [replacement], discoveryAfter: [replacement], ...policy.bridge.discoveryExecutables ? { discoveryExecutables: policy.bridge.discoveryExecutables } : {}, rootAliases: aliases, managedAgentChecks: { home, agents: [options.agent] }, settingsWitnessUpgrade: { agent: options.agent, path: configPath, fromHashMode: previous.hashMode ?? "bytes", fromSha256: previous.sha256, toHashMode: next.hashMode, toSha256: next.sha256, reviewedPreimage: options.reviewedPreimage, currentSettingsSha256: options.expectedSettingsSha256, replacedWitnesses: replaced.map((source) => ({ hashMode: source.hashMode ?? "bytes", sha256: source.sha256 })) } };
20248
20524
  }
20249
20525
  function applyAgentIntegration(plan, options = {}) {
20250
20526
  const roots = plan.changes.flatMap((change) => {
@@ -20262,10 +20538,10 @@ function applyAgentIntegrationUnlocked(plan, options = {}, assertCurrent) {
20262
20538
  throw new Error("Native settings changed after witness planning");
20263
20539
  const policyPath = join23(plan.dataDir, "agent-policy.json");
20264
20540
  assertSafePath(policyPath);
20265
- const currentText = (path) => resolve13(path) === resolve13(policyPath) ? readManagedSkillPolicySnapshot(plan.dataDir)?.text ?? null : readOptional(path);
20541
+ const currentText = (path) => resolve15(path) === resolve15(policyPath) ? readManagedSkillPolicySnapshot(plan.dataDir)?.text ?? null : readOptional(path);
20266
20542
  readManagedSkillPolicySnapshot(plan.dataDir);
20267
20543
  for (const change of plan.changes)
20268
- if (resolve13(change.path) === resolve13(policyPath))
20544
+ if (resolve15(change.path) === resolve15(policyPath))
20269
20545
  parseManagedSkillPolicy(change.after);
20270
20546
  const aliases = plan.rootAliases ?? [];
20271
20547
  assertCurrent();
@@ -20277,7 +20553,7 @@ function applyAgentIntegrationUnlocked(plan, options = {}, assertCurrent) {
20277
20553
  const upgrade = plan.settingsWitnessUpgrade;
20278
20554
  if (!plan.managedAgentChecks || !plan.observedPolicy?.before)
20279
20555
  throw new Error("Invalid settings witness upgrade plan");
20280
- const verified = planAgentSettingsWitnessUpgrade({ agent: upgrade.agent, ...upgrade.agent === "codex" ? { targetCodexVersion: upgrade.toHashMode === "codex-settings-v4" ? 4 : upgrade.toHashMode === "codex-settings-v3" ? 3 : 2 } : {}, reviewedPreimage: upgrade.reviewedPreimage, home: plan.managedAgentChecks.home, dataDir: plan.dataDir, expectedPolicySha256: sha3(plan.observedPolicy.before), expectedSettingsSha256: upgrade.currentSettingsSha256 });
20556
+ const verified = planAgentSettingsWitnessUpgrade({ agent: upgrade.agent, ...upgrade.agent === "codex" ? { targetCodexVersion: upgrade.toHashMode === "codex-settings-v4" ? 4 : upgrade.toHashMode === "codex-settings-v3" ? 3 : 2 } : {}, ...upgrade.agent === "claude" && upgrade.toHashMode === "claude-settings-v4" ? { targetClaudeVersion: 4 } : {}, reviewedPreimage: upgrade.reviewedPreimage, home: plan.managedAgentChecks.home, dataDir: plan.dataDir, expectedPolicySha256: sha3(plan.observedPolicy.before), expectedSettingsSha256: upgrade.currentSettingsSha256 });
20281
20557
  if (JSON.stringify(verified.changes) !== JSON.stringify(plan.changes) || JSON.stringify(verified.settingsWitnessUpgrade) !== JSON.stringify(upgrade))
20282
20558
  throw new Error("Settings witness upgrade plan changed");
20283
20559
  provenDiscovery = verified.discoveryBefore[0];
@@ -20286,7 +20562,7 @@ function applyAgentIntegrationUnlocked(plan, options = {}, assertCurrent) {
20286
20562
  assertManagedAgentBridgeWithDiscovery(agent, { home: plan.managedAgentChecks.home, dataDir: plan.dataDir, projectDir: plan.managedAgentChecks.home }, provenDiscovery?.agent === agent ? provenDiscovery : undefined);
20287
20563
  for (const binding of plan.discoveryBefore ?? []) {
20288
20564
  if (plan.managedAgentChecks)
20289
- verifyCoordinatedDiscovery(binding, plan.managedAgentChecks.home, aliases);
20565
+ verifyCoordinatedDiscovery(binding, plan.managedAgentChecks.home, aliases, plan.discoveryExecutables?.[binding.agent]);
20290
20566
  else
20291
20567
  verifyAgentDiscovery(binding);
20292
20568
  }
@@ -20308,7 +20584,7 @@ function applyAgentIntegrationUnlocked(plan, options = {}, assertCurrent) {
20308
20584
  if (change.before !== null) {
20309
20585
  const backup = join23(backupRoot, `${index}-${sha3(change.path).slice(0, 12)}.backup`);
20310
20586
  writeFileSync6(backup, change.before, { mode: 384, flag: "wx" });
20311
- if (readFileSync14(backup, "utf8") !== change.before)
20587
+ if (readFileSync15(backup, "utf8") !== change.before)
20312
20588
  throw new Error("Native configuration preservation readback failed");
20313
20589
  backups.push(backup);
20314
20590
  }
@@ -20318,7 +20594,7 @@ function applyAgentIntegrationUnlocked(plan, options = {}, assertCurrent) {
20318
20594
  recheckRootAliases(aliases);
20319
20595
  if (currentText(change.path) !== change.before)
20320
20596
  throw new Error(`Configuration changed after planning: ${change.path}`);
20321
- for (let directory = dirname14(change.path);!existsSync92(directory); directory = dirname14(directory))
20597
+ for (let directory = dirname15(change.path);!existsSync92(directory); directory = dirname15(directory))
20322
20598
  createdDirectories.add(directory);
20323
20599
  const after = change.after;
20324
20600
  atomicWrite2(change.path, after);
@@ -20333,7 +20609,7 @@ function applyAgentIntegrationUnlocked(plan, options = {}, assertCurrent) {
20333
20609
  throw new Error("Native settings changed during witness application");
20334
20610
  for (const binding of plan.discoveryAfter ?? []) {
20335
20611
  if (plan.managedAgentChecks)
20336
- verifyCoordinatedDiscovery(binding, plan.managedAgentChecks.home, aliases);
20612
+ verifyCoordinatedDiscovery(binding, plan.managedAgentChecks.home, aliases, plan.discoveryExecutables?.[binding.agent]);
20337
20613
  else
20338
20614
  verifyAgentDiscovery(binding);
20339
20615
  }
@@ -20375,12 +20651,12 @@ function isInertCodexPluginCacheCopy(entry, cache, allowedHostPaths, read2) {
20375
20651
  return false;
20376
20652
  const document2 = join23(entry.path, "SKILL.md");
20377
20653
  const inside = relative6(cache, entry.path);
20378
- if (!inside || isAbsolute13(inside) || inside.split(sep7).some((segment) => segment === ".."))
20654
+ if (!inside || isAbsolute16(inside) || inside.split(sep7).some((segment) => segment === ".."))
20379
20655
  return false;
20380
20656
  assertSafePath(entry.path);
20381
- if (!lstatSync19(cache).isDirectory() || !lstatSync19(entry.path).isDirectory() || !lstatSync19(document2).isFile())
20657
+ if (!lstatSync20(cache).isDirectory() || !lstatSync20(entry.path).isDirectory() || !lstatSync20(document2).isFile())
20382
20658
  return false;
20383
- if (realpathSync9.native(cache) !== cache || realpathSync9.native(entry.path) !== entry.path || realpathSync9.native(document2) !== document2)
20659
+ if (realpathSync10.native(cache) !== cache || realpathSync10.native(entry.path) !== entry.path || realpathSync10.native(document2) !== document2)
20384
20660
  return false;
20385
20661
  if (!classifyCodexPluginCacheDocument(document2, cache, read2))
20386
20662
  return false;
@@ -20395,7 +20671,7 @@ function assertManagedAgentBridge(agent, options = {}) {
20395
20671
  assertManagedAgentBridgeWithDiscovery(agent, options);
20396
20672
  }
20397
20673
  function assertManagedAgentBridgeWithDiscovery(agent, options = {}, provenDiscovery) {
20398
- const home = resolve13(options.home ?? homedir22()), dataDir22 = options.dataDir ?? getDataDirReadOnly();
20674
+ const home = resolve15(options.home ?? homedir22()), dataDir22 = options.dataDir ?? getDataDirReadOnly();
20399
20675
  assertSafePath(join23(dataDir22, "agent-policy.json"));
20400
20676
  const snapshot2 = readManagedSkillPolicySnapshot(dataDir22);
20401
20677
  if (!snapshot2)
@@ -20493,12 +20769,11 @@ function assertManagedAgentBridgeWithDiscovery(agent, options = {}, provenDiscov
20493
20769
  verifyAgentDiscovery(agent === "codex" ? { ...discovery, codexDisabledPluginSkills: binding.codexPluginSkills ?? [] } : discovery, options.codexDiscoveryRecovery);
20494
20770
  if (agent === "sumi" && discovery.method === "reviewed")
20495
20771
  resolveAgentDiscovery({ home, agent, retainedReview: discovery, canonical: (path) => canonicalAgentPath(path, aliases) });
20496
- if (discovery.method === "automatic") {
20497
- const current2 = resolveAgentDiscovery({ home, agent, canonical: (path) => canonicalAgentPath(path, aliases) });
20498
- if (JSON.stringify(current2) !== JSON.stringify(discovery))
20499
- throw new Error("Configured native discovery roots changed");
20500
- }
20772
+ if (discovery.method === "automatic")
20773
+ verifyAutomaticDiscoveryClosure(discovery, { home, canonical: (path) => canonicalAgentPath(path, aliases), change: "Configured native discovery roots changed", executable: binding.discoveryExecutables?.[agent] });
20501
20774
  } catch (error) {
20775
+ if (isDiscoveryRootUnresolved(error))
20776
+ throw error;
20502
20777
  throw new Error(`NATIVE_SKILL_DRIFT: ${error.message}`);
20503
20778
  }
20504
20779
  let installationInputRoots = [];
@@ -20545,7 +20820,7 @@ function pluginNeed(value, message) {
20545
20820
  if (!value)
20546
20821
  pluginRefusal(message);
20547
20822
  }
20548
- var pluginHash = (bytes) => createHash19("sha256").update(bytes).digest("hex");
20823
+ var pluginHash = (bytes) => createHash21("sha256").update(bytes).digest("hex");
20549
20824
  function pluginObject(value) {
20550
20825
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
20551
20826
  }
@@ -20616,21 +20891,21 @@ function pluginFileWitnesses(entries) {
20616
20891
  return { path: item.path, mode: item.mode, size: item.bytes.byteLength, sha256: pluginHash(item.bytes) };
20617
20892
  });
20618
20893
  }
20619
- var READ_FLAGS = constants11.O_RDONLY | constants11.O_NOFOLLOW | constants11.O_NONBLOCK;
20620
- var WRITE_FLAGS = constants11.O_WRONLY | constants11.O_CREAT | constants11.O_EXCL | constants11.O_NOFOLLOW | constants11.O_NONBLOCK;
20894
+ var READ_FLAGS = constants12.O_RDONLY | constants12.O_NOFOLLOW | constants12.O_NONBLOCK;
20895
+ var WRITE_FLAGS = constants12.O_WRONLY | constants12.O_CREAT | constants12.O_EXCL | constants12.O_NOFOLLOW | constants12.O_NONBLOCK;
20621
20896
  var uid = () => typeof process.getuid === "function" ? BigInt(process.getuid()) : undefined;
20622
20897
  var missing = (error) => Boolean(error && typeof error === "object" && "code" in error && error.code === "ENOENT");
20623
20898
  function stat(path) {
20624
20899
  try {
20625
- return lstatSync21(path, { bigint: true });
20900
+ return lstatSync22(path, { bigint: true });
20626
20901
  } catch (error) {
20627
20902
  if (missing(error))
20628
20903
  return null;
20629
20904
  return pluginRefusal("Cannot inspect plugin filesystem entry");
20630
20905
  }
20631
20906
  }
20632
- function canonical6(path) {
20633
- pluginNeed(typeof path === "string" && path.length <= 8192 && isAbsolute14(path) && resolve14(path) === path && !/[\x00-\x1f\x7f]/.test(path), "Plugin storage paths must be canonical absolute paths");
20907
+ function canonical7(path) {
20908
+ pluginNeed(typeof path === "string" && path.length <= 8192 && isAbsolute17(path) && resolve16(path) === path && !/[\x00-\x1f\x7f]/.test(path), "Plugin storage paths must be canonical absolute paths");
20634
20909
  }
20635
20910
  function owner(stats, system = false) {
20636
20911
  const current2 = uid();
@@ -20640,8 +20915,8 @@ function same3(left, right, identityOnly = false) {
20640
20915
  pluginNeed(right && left.dev === right.dev && left.ino === right.ino && left.mode === right.mode && left.uid === right.uid && left.gid === right.gid && (identityOnly || left.size === right.size && left.nlink === right.nlink && left.mtimeNs === right.mtimeNs && left.ctimeNs === right.ctimeNs), "Plugin filesystem entry changed during access");
20641
20916
  }
20642
20917
  function ancestors(path, create = false) {
20643
- canonical6(path);
20644
- const result = [], parent = dirname16(path), filesystemRoot = parse6(parent).root;
20918
+ canonical7(path);
20919
+ const result = [], parent = dirname17(path), filesystemRoot = parse6(parent).root;
20645
20920
  let current2 = filesystemRoot;
20646
20921
  for (const segment of ["", ...parent.slice(filesystemRoot.length).split("/").filter(Boolean)]) {
20647
20922
  if (segment)
@@ -20691,8 +20966,8 @@ function readBytes(path, maximum, kind) {
20691
20966
  fileShape(before, maximum, kind);
20692
20967
  let fd;
20693
20968
  try {
20694
- fd = openSync11(path, READ_FLAGS);
20695
- const opened = fstatSync11(fd, { bigint: true });
20969
+ fd = openSync12(path, READ_FLAGS);
20970
+ const opened = fstatSync12(fd, { bigint: true });
20696
20971
  same3(before, opened);
20697
20972
  fileShape(opened, maximum, kind);
20698
20973
  const bytes = new Uint8Array(Number(opened.size));
@@ -20703,7 +20978,7 @@ function readBytes(path, maximum, kind) {
20703
20978
  offset += count;
20704
20979
  }
20705
20980
  pluginNeed(readSync9(fd, new Uint8Array(1), 0, 1, null) === 0, "Plugin file grew while being read");
20706
- same3(opened, fstatSync11(fd, { bigint: true }));
20981
+ same3(opened, fstatSync12(fd, { bigint: true }));
20707
20982
  same3(opened, stat(path));
20708
20983
  verifyAncestors(chain);
20709
20984
  return bytes;
@@ -20713,7 +20988,7 @@ function readBytes(path, maximum, kind) {
20713
20988
  return pluginRefusal("Cannot safely read plugin file");
20714
20989
  } finally {
20715
20990
  if (fd !== undefined)
20716
- closeSync11(fd);
20991
+ closeSync12(fd);
20717
20992
  }
20718
20993
  }
20719
20994
  function exactPaths(entries) {
@@ -20842,7 +21117,7 @@ function validatePluginTarget(value) {
20842
21117
  for (const registration of value.registrations) {
20843
21118
  pluginKeys(registration, ["scope", "projectPath"]);
20844
21119
  pluginNeed(registration.scope === "user" || registration.scope === "project", "Unsupported plugin registration scope");
20845
- pluginNeed(registration.scope === "user" ? registration.projectPath === null : typeof registration.projectPath === "string" && isAbsolute15(registration.projectPath) && resolve15(registration.projectPath) === registration.projectPath, "Plugin scope requires its exact project path");
21120
+ pluginNeed(registration.scope === "user" ? registration.projectPath === null : typeof registration.projectPath === "string" && isAbsolute18(registration.projectPath) && resolve17(registration.projectPath) === registration.projectPath, "Plugin scope requires its exact project path");
20846
21121
  const key = JSON.stringify([registration.scope, registration.projectPath]);
20847
21122
  pluginNeed(!scopes.has(key), "Duplicate plugin registration scope");
20848
21123
  scopes.add(key);
@@ -20850,7 +21125,7 @@ function validatePluginTarget(value) {
20850
21125
  for (const key of ["native", "resolver"]) {
20851
21126
  pluginKeys(value[key], key === "native" ? ["version", "executable", "digest"] : ["executable", "digest"]);
20852
21127
  pluginText(value[key].executable);
20853
- pluginNeed(isAbsolute15(value[key].executable) && resolve15(value[key].executable) === value[key].executable, "Plugin executable must have a canonical absolute path");
21128
+ pluginNeed(isAbsolute18(value[key].executable) && resolve17(value[key].executable) === value[key].executable, "Plugin executable must have a canonical absolute path");
20854
21129
  pluginDigest(value[key].digest);
20855
21130
  }
20856
21131
  pluginNeed(["2.1.274", "2.1.276"].includes(value.native.version), "Plugin admission requires a certified Claude command-source runtime (2.1.274 or 2.1.276)");
@@ -20988,10 +21263,10 @@ function validatePlan(value) {
20988
21263
  pluginNeed(observedEvidenceDigest(plan.observation) === plan.evidenceDigest, "Plugin receipt observed evidence changed");
20989
21264
  pluginNeed(identityDigest(plan) === plan.planDigest, "Plugin receipt immutable identity changed");
20990
21265
  }
20991
- var quote3 = (value) => `'${value.replaceAll("'", "'\\''")}'`;
21266
+ var quote22 = (value) => `'${value.replaceAll("'", "'\\''")}'`;
20992
21267
  var resolverGuard = 'exec 9<"$1"; actual=$(/usr/bin/sha256sum /proc/self/fd/9); actual=${actual%% *}; [ "sha256:$actual" = "$2" ]; exec /proc/self/fd/9 integration plugin resolve --binding "$3"';
20993
21268
  function pluginResolverCommand(binding) {
20994
- return `${quote3("/bin/sh")} -eu -c ${quote3(resolverGuard)} plugin-resolver ${quote3(binding.target.resolver.executable)} ${quote3(binding.target.resolver.digest)} ${quote3(bindingId(binding))}`;
21269
+ return `${quote22("/bin/sh")} -eu -c ${quote22(resolverGuard)} plugin-resolver ${quote22(binding.target.resolver.executable)} ${quote22(binding.target.resolver.digest)} ${quote22(bindingId(binding))}`;
20995
21270
  }
20996
21271
  function pluginBindingPath(storeRoot, id) {
20997
21272
  pluginNeed(/^[a-f0-9]{64}$/.test(id), "Invalid plugin binding identifier");
@@ -21033,25 +21308,25 @@ function validateManagedPluginWitnesses(value) {
21033
21308
  pluginNeed(typeof item.bindingId === "string" && /^[a-f0-9]{64}$/.test(item.bindingId) && !seen.has(item.bindingId), "Invalid or duplicate managed plugin witness");
21034
21309
  seen.add(item.bindingId);
21035
21310
  pluginText(item.storeRoot);
21036
- pluginNeed(isAbsolute16(item.storeRoot) && resolve16(item.storeRoot) === item.storeRoot, "Invalid plugin receipt store path");
21311
+ pluginNeed(isAbsolute19(item.storeRoot) && resolve18(item.storeRoot) === item.storeRoot, "Invalid plugin receipt store path");
21037
21312
  }
21038
21313
  }
21039
21314
  function safe3(path) {
21040
21315
  pluginText(path);
21041
- pluginNeed(isAbsolute16(path) && resolve16(path) === path, "Invalid plugin registry path");
21042
- for (let at = path;; at = dirname17(at)) {
21043
- pluginNeed(!lstatSync22(at, { throwIfNoEntry: false })?.isSymbolicLink(), "Plugin registry path traverses a symlink");
21044
- if (at === dirname17(at))
21316
+ pluginNeed(isAbsolute19(path) && resolve18(path) === path, "Invalid plugin registry path");
21317
+ for (let at = path;; at = dirname18(at)) {
21318
+ pluginNeed(!lstatSync23(at, { throwIfNoEntry: false })?.isSymbolicLink(), "Plugin registry path traverses a symlink");
21319
+ if (at === dirname18(at))
21045
21320
  break;
21046
21321
  }
21047
21322
  }
21048
21323
  function readRegistry(path) {
21049
21324
  safe3(path);
21050
- const initial = lstatSync22(path);
21325
+ const initial = lstatSync23(path);
21051
21326
  pluginNeed(initial.isFile() && initial.size <= 1024 * 1024, "Plugin registry is not a bounded regular file");
21052
- const fd = openSync12(path, constants12.O_RDONLY | constants12.O_NOFOLLOW | constants12.O_NONBLOCK);
21327
+ const fd = openSync13(path, constants13.O_RDONLY | constants13.O_NOFOLLOW | constants13.O_NONBLOCK);
21053
21328
  try {
21054
- const opened = fstatSync12(fd);
21329
+ const opened = fstatSync13(fd);
21055
21330
  pluginNeed(opened.isFile() && opened.ino === initial.ino && opened.dev === initial.dev, "Plugin registry changed during open");
21056
21331
  const bytes = Buffer.alloc(1024 * 1024 + 1);
21057
21332
  let length = 0;
@@ -21061,7 +21336,7 @@ function readRegistry(path) {
21061
21336
  break;
21062
21337
  length += count;
21063
21338
  }
21064
- const after = fstatSync12(fd), current2 = lstatSync22(path);
21339
+ const after = fstatSync13(fd), current2 = lstatSync23(path);
21065
21340
  safe3(path);
21066
21341
  pluginNeed(length <= 1024 * 1024 && length === opened.size && after.size === opened.size && after.mtimeMs === opened.mtimeMs && after.ctimeMs === opened.ctimeMs && current2.dev === opened.dev && current2.ino === opened.ino && current2.mtimeMs === opened.mtimeMs && current2.ctimeMs === opened.ctimeMs, "Plugin registry changed during read");
21067
21342
  let value;
@@ -21073,7 +21348,7 @@ function readRegistry(path) {
21073
21348
  pluginNeed(pluginObject(value) && value.version === 2 && pluginObject(value.plugins), "Unsupported native plugin registry schema");
21074
21349
  return { value, rawDigest: pluginHash(bytes.subarray(0, length)) };
21075
21350
  } finally {
21076
- closeSync12(fd);
21351
+ closeSync13(fd);
21077
21352
  }
21078
21353
  }
21079
21354
  function nativeVersionMatches(version, receipt) {
@@ -21091,7 +21366,7 @@ function hashManagedPluginRegistry(path, managed) {
21091
21366
  seen.add(target.pluginId);
21092
21367
  const rows = plugins[target.pluginId];
21093
21368
  pluginNeed(Array.isArray(rows) && rows.length === target.registrations.length, "Managed plugin registration membership changed");
21094
- const [name, market] = target.pluginId.split("@"), cacheRoot = join31(dirname17(path), "cache", market, name);
21369
+ const [name, market] = target.pluginId.split("@"), cacheRoot = join31(dirname18(path), "cache", market, name);
21095
21370
  const scopes = new Set, approvals = new Map, currentFiles = new Map;
21096
21371
  plugins[target.pluginId] = rows.map((row) => {
21097
21372
  pluginNeed(pluginObject(row), "Invalid managed plugin registration");
@@ -21107,7 +21382,7 @@ function hashManagedPluginRegistry(path, managed) {
21107
21382
  pluginNeed(/^(?:[A-Za-z0-9][A-Za-z0-9._+-]*-)?[a-f0-9]{12}$/.test(row.version) && row.installPath === join31(cacheRoot, row.version), "Managed plugin cache path or version is outside its registration");
21108
21383
  const approval = (producer) => {
21109
21384
  pluginText(producer);
21110
- const digest = `sha256:${basename8(producer)}`;
21385
+ const digest = `sha256:${basename9(producer)}`;
21111
21386
  const receipt2 = readPluginAdmissionReceipt(witness.storeRoot, witness.bindingId, digest);
21112
21387
  pluginNeed(receipt2.materializedPath === producer, "Managed producer path is not an approved immutable projection");
21113
21388
  if (!verified.has(producer)) {
@@ -21134,7 +21409,7 @@ function hashManagedPluginRegistry(path, managed) {
21134
21409
  return Object.fromEntries(Object.entries(row).filter(([key]) => !["version", "installPath", "sourceProducerPath", "previousProducerPaths", "lastUpdated"].includes(key)));
21135
21410
  });
21136
21411
  safe3(cacheRoot);
21137
- const before = lstatSync22(cacheRoot);
21412
+ const before = lstatSync23(cacheRoot);
21138
21413
  pluginNeed(before.isDirectory(), "Invalid managed plugin cache root");
21139
21414
  const directory = opendirSync5(cacheRoot), names = [];
21140
21415
  try {
@@ -21157,7 +21432,7 @@ function hashManagedPluginRegistry(path, managed) {
21157
21432
  }
21158
21433
  for (const row of rows)
21159
21434
  pluginNeed(names.includes(row.version), "Managed native plugin installation is missing");
21160
- const after = lstatSync22(cacheRoot);
21435
+ const after = lstatSync23(cacheRoot);
21161
21436
  safe3(cacheRoot);
21162
21437
  pluginNeed(before.dev === after.dev && before.ino === after.ino && before.mtimeMs === after.mtimeMs && before.ctimeMs === after.ctimeMs, "Managed cache version membership changed during verification");
21163
21438
  }
@@ -21165,35 +21440,35 @@ function hashManagedPluginRegistry(path, managed) {
21165
21440
  return pluginHash(JSON.stringify(snapshot2.value));
21166
21441
  }
21167
21442
  var CLAUDE_MARKETPLACE_REGISTRY_LIMITS = Object.freeze({ bytes: 1024 * 1024, rows: 1024, depth: 32, nodes: 65536, stringCharacters: 16384, pathCharacters: 4096 });
21168
- function need6(value, reason) {
21443
+ function need7(value, reason2) {
21169
21444
  if (!value)
21170
- throw new Error(`Claude marketplace registry ${reason}`);
21445
+ throw new Error(`Claude marketplace registry ${reason2}`);
21171
21446
  }
21172
21447
  function absolutePath3(value) {
21173
- need6(typeof value === "string" && value.length > 0 && value.length <= CLAUDE_MARKETPLACE_REGISTRY_LIMITS.pathCharacters && !/[\x00-\x1f\x7f]/.test(value) && isAbsolute17(value) && resolve17(value) === value, "requires a normalized absolute path");
21448
+ need7(typeof value === "string" && value.length > 0 && value.length <= CLAUDE_MARKETPLACE_REGISTRY_LIMITS.pathCharacters && !/[\x00-\x1f\x7f]/.test(value) && isAbsolute20(value) && resolve19(value) === value, "requires a normalized absolute path");
21174
21449
  }
21175
21450
  var sameFile2 = (a, b) => a.dev === b.dev && a.ino === b.ino && a.mode === b.mode && a.uid === b.uid && a.gid === b.gid && a.nlink === b.nlink && a.size === b.size && a.mtimeNs === b.mtimeNs && a.ctimeNs === b.ctimeNs;
21176
21451
  function parents2(path) {
21177
21452
  const result = [];
21178
- for (let at = dirname18(path);; at = dirname18(at)) {
21179
- const stat2 = lstatSync23(at, { bigint: true });
21180
- need6(stat2.isDirectory() && !stat2.isSymbolicLink(), "path traverses a symlink or non-directory");
21453
+ for (let at = dirname19(path);; at = dirname19(at)) {
21454
+ const stat2 = lstatSync24(at, { bigint: true });
21455
+ need7(stat2.isDirectory() && !stat2.isSymbolicLink(), "path traverses a symlink or non-directory");
21181
21456
  result.push([at, stat2]);
21182
- if (at === dirname18(at))
21457
+ if (at === dirname19(at))
21183
21458
  return result;
21184
21459
  }
21185
21460
  }
21186
21461
  function readRegistry2(path, budget2) {
21187
21462
  absolutePath3(path);
21188
- need6(basename9(path) === "known_marketplaces.json", "requires known_marketplaces.json");
21189
- need6(Number.isSafeInteger(budget2.remaining) && budget2.remaining >= 0, "has an invalid byte budget");
21190
- const ancestors2 = parents2(path), initial = lstatSync23(path, { bigint: true });
21191
- need6(initial.isFile() && !initial.isSymbolicLink() && initial.size <= BigInt(CLAUDE_MARKETPLACE_REGISTRY_LIMITS.bytes), "is not a bounded regular file");
21192
- need6(initial.size <= BigInt(budget2.remaining), "exceeds its aggregate byte limit");
21193
- const fd = openSync13(path, constants13.O_RDONLY | constants13.O_NOFOLLOW | constants13.O_NONBLOCK);
21463
+ need7(basename10(path) === "known_marketplaces.json", "requires known_marketplaces.json");
21464
+ need7(Number.isSafeInteger(budget2.remaining) && budget2.remaining >= 0, "has an invalid byte budget");
21465
+ const ancestors2 = parents2(path), initial = lstatSync24(path, { bigint: true });
21466
+ need7(initial.isFile() && !initial.isSymbolicLink() && initial.size <= BigInt(CLAUDE_MARKETPLACE_REGISTRY_LIMITS.bytes), "is not a bounded regular file");
21467
+ need7(initial.size <= BigInt(budget2.remaining), "exceeds its aggregate byte limit");
21468
+ const fd = openSync14(path, constants14.O_RDONLY | constants14.O_NOFOLLOW | constants14.O_NONBLOCK);
21194
21469
  try {
21195
- const opened = fstatSync13(fd, { bigint: true });
21196
- need6(opened.isFile() && sameFile2(initial, opened), "changed during open");
21470
+ const opened = fstatSync14(fd, { bigint: true });
21471
+ need7(opened.isFile() && sameFile2(initial, opened), "changed during open");
21197
21472
  const bytes = Buffer.alloc(Number(opened.size) + 1);
21198
21473
  let length = 0;
21199
21474
  while (length < bytes.length) {
@@ -21202,11 +21477,11 @@ function readRegistry2(path, budget2) {
21202
21477
  break;
21203
21478
  length += count;
21204
21479
  }
21205
- const after = fstatSync13(fd, { bigint: true }), current2 = lstatSync23(path, { bigint: true });
21206
- need6(current2.isFile() && sameFile2(opened, after) && sameFile2(after, current2) && BigInt(length) === opened.size, "changed during read");
21480
+ const after = fstatSync14(fd, { bigint: true }), current2 = lstatSync24(path, { bigint: true });
21481
+ need7(current2.isFile() && sameFile2(opened, after) && sameFile2(after, current2) && BigInt(length) === opened.size, "changed during read");
21207
21482
  for (const [ancestor, before] of ancestors2) {
21208
- const now = lstatSync23(ancestor, { bigint: true });
21209
- need6(now.isDirectory() && before.dev === now.dev && before.ino === now.ino && before.mode === now.mode, "parent changed during read");
21483
+ const now = lstatSync24(ancestor, { bigint: true });
21484
+ need7(now.isDirectory() && before.dev === now.dev && before.ino === now.ino && before.mode === now.mode, "parent changed during read");
21210
21485
  }
21211
21486
  budget2.remaining -= length;
21212
21487
  try {
@@ -21215,7 +21490,7 @@ function readRegistry2(path, budget2) {
21215
21490
  throw new Error("Claude marketplace registry is not strict UTF-8");
21216
21491
  }
21217
21492
  } finally {
21218
- closeSync13(fd);
21493
+ closeSync14(fd);
21219
21494
  }
21220
21495
  }
21221
21496
  function parse7(text2) {
@@ -21226,7 +21501,7 @@ function parse7(text2) {
21226
21501
  at++;
21227
21502
  };
21228
21503
  function string() {
21229
- need6(text2[at] === '"', "contains invalid JSON");
21504
+ need7(text2[at] === '"', "contains invalid JSON");
21230
21505
  const start = at++;
21231
21506
  while (at < text2.length) {
21232
21507
  const character = text2[at++];
@@ -21237,7 +21512,7 @@ function parse7(text2) {
21237
21512
  } catch {
21238
21513
  throw new Error("Claude marketplace registry contains invalid JSON string");
21239
21514
  }
21240
- need6(value2.length <= CLAUDE_MARKETPLACE_REGISTRY_LIMITS.stringCharacters, "exceeds its string limit");
21515
+ need7(value2.length <= CLAUDE_MARKETPLACE_REGISTRY_LIMITS.stringCharacters, "exceeds its string limit");
21241
21516
  return value2;
21242
21517
  }
21243
21518
  if (character === "\\")
@@ -21246,7 +21521,7 @@ function parse7(text2) {
21246
21521
  throw new Error("Claude marketplace registry contains an unterminated JSON string");
21247
21522
  }
21248
21523
  function value(depth) {
21249
- need6(depth <= CLAUDE_MARKETPLACE_REGISTRY_LIMITS.depth && ++nodes <= CLAUDE_MARKETPLACE_REGISTRY_LIMITS.nodes, "exceeds its nesting or node limit");
21524
+ need7(depth <= CLAUDE_MARKETPLACE_REGISTRY_LIMITS.depth && ++nodes <= CLAUDE_MARKETPLACE_REGISTRY_LIMITS.nodes, "exceeds its nesting or node limit");
21250
21525
  space();
21251
21526
  const character = text2[at];
21252
21527
  if (character === '"')
@@ -21260,17 +21535,17 @@ function parse7(text2) {
21260
21535
  if (object6) {
21261
21536
  space();
21262
21537
  const key = string();
21263
- need6(!keys.has(key), "contains a duplicate JSON key");
21538
+ need7(!keys.has(key), "contains a duplicate JSON key");
21264
21539
  keys.add(key);
21265
21540
  space();
21266
- need6(text2[at++] === ":", "contains invalid JSON");
21541
+ need7(text2[at++] === ":", "contains invalid JSON");
21267
21542
  entries.push([key, value(depth + 1)]);
21268
21543
  } else
21269
21544
  items.push(value(depth + 1));
21270
21545
  space();
21271
21546
  if (text2[at] === end)
21272
21547
  break;
21273
- need6(text2[at++] === ",", "contains invalid JSON");
21548
+ need7(text2[at++] === ",", "contains invalid JSON");
21274
21549
  }
21275
21550
  at++;
21276
21551
  return object6 ? { kind: "object", entries } : { kind: "array", items };
@@ -21282,73 +21557,73 @@ function parse7(text2) {
21282
21557
  }
21283
21558
  numberPattern.lastIndex = at;
21284
21559
  const number = numberPattern.exec(text2);
21285
- need6(number, "contains invalid JSON");
21560
+ need7(number, "contains invalid JSON");
21286
21561
  at += number[0].length;
21287
21562
  return { kind: "number", value: number[0] };
21288
21563
  }
21289
21564
  const root2 = value(0);
21290
21565
  space();
21291
- need6(at === text2.length && root2.kind === "object", "requires a JSON object without trailing content");
21292
- need6(root2.entries.length <= CLAUDE_MARKETPLACE_REGISTRY_LIMITS.rows, "exceeds its marketplace row limit");
21566
+ need7(at === text2.length && root2.kind === "object", "requires a JSON object without trailing content");
21567
+ need7(root2.entries.length <= CLAUDE_MARKETPLACE_REGISTRY_LIMITS.rows, "exceeds its marketplace row limit");
21293
21568
  return root2;
21294
21569
  }
21295
21570
  function exactKeys(value, keys) {
21296
21571
  return value?.kind === "object" && value.entries.length === keys.length && value.entries.every(([key]) => keys.includes(key));
21297
21572
  }
21298
- var field = (object6, key) => object6.entries.find(([name]) => name === key)?.[1];
21573
+ var field2 = (object6, key) => object6.entries.find(([name]) => name === key)?.[1];
21299
21574
  function textField(value) {
21300
- need6(value?.kind === "string" && value.value.length > 0 && !/[\x00-\x1f\x7f]/.test(value.value), "contains an invalid recognized field");
21575
+ need7(value?.kind === "string" && value.value.length > 0 && !/[\x00-\x1f\x7f]/.test(value.value), "contains an invalid recognized field");
21301
21576
  return value.value;
21302
21577
  }
21303
21578
  function normalizeRow(row, version = 1) {
21304
21579
  if (!exactKeys(row, ["source", "installLocation", "lastUpdated"])) {
21305
21580
  if (version !== 2 || !exactKeys(row, ["source", "installLocation", "lastUpdated", "autoUpdate"]))
21306
21581
  return;
21307
- const autoUpdate = field(row, "autoUpdate");
21308
- need6(autoUpdate?.kind === "literal" && (autoUpdate.value === "true" || autoUpdate.value === "false"), "contains an invalid automatic-update preference");
21582
+ const autoUpdate = field2(row, "autoUpdate");
21583
+ need7(autoUpdate?.kind === "literal" && (autoUpdate.value === "true" || autoUpdate.value === "false"), "contains an invalid automatic-update preference");
21309
21584
  }
21310
- const source = field(row, "source");
21585
+ const source = field2(row, "source");
21311
21586
  if (source?.kind !== "object")
21312
21587
  return;
21313
- const type = field(source, "source");
21588
+ const type = field2(source, "source");
21314
21589
  if (type?.kind !== "string" || !["github", "directory"].includes(type.value))
21315
21590
  return;
21316
21591
  const location = type.value === "github" ? "repo" : "path";
21317
21592
  if (!exactKeys(source, ["source", location]))
21318
21593
  return;
21319
- const sourceLocation = textField(field(source, location));
21594
+ const sourceLocation = textField(field2(source, location));
21320
21595
  if (type.value === "directory")
21321
21596
  absolutePath3(sourceLocation);
21322
- absolutePath3(textField(field(row, "installLocation")));
21323
- const updated = textField(field(row, "lastUpdated"));
21324
- need6(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(updated), "contains an invalid recognized update timestamp");
21597
+ absolutePath3(textField(field2(row, "installLocation")));
21598
+ const updated = textField(field2(row, "lastUpdated"));
21599
+ need7(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(updated), "contains an invalid recognized update timestamp");
21325
21600
  const millis = Date.parse(updated);
21326
- need6(Number.isFinite(millis) && new Date(millis).toISOString() === updated, "contains an invalid recognized update timestamp");
21601
+ need7(Number.isFinite(millis) && new Date(millis).toISOString() === updated, "contains an invalid recognized update timestamp");
21327
21602
  row.entries = row.entries.map(([key, value]) => [key, key === "lastUpdated" ? { kind: "validated-update-time" } : value]);
21328
21603
  }
21329
21604
  function captureClaudeMarketplaceRegistry(path, budget2 = { remaining: 256 * 1024 * 1024 }) {
21330
21605
  const value = parse7(readRegistry2(path, budget2));
21331
21606
  for (const [, row] of value.entries)
21332
21607
  normalizeRow(row);
21333
- const sha2562 = createHash21("sha256").update("hasna.skills.claude-marketplace-registry.v1\x00").update(JSON.stringify(value)).digest("hex");
21334
- return { path, hashMode: "claude-marketplace-registry", sha256: sha2562 };
21608
+ const sha2563 = createHash23("sha256").update("hasna.skills.claude-marketplace-registry.v1\x00").update(JSON.stringify(value)).digest("hex");
21609
+ return { path, hashMode: "claude-marketplace-registry", sha256: sha2563 };
21335
21610
  }
21336
21611
  function captureClaudeMarketplaceRegistryV2(path, budget2 = { remaining: 256 * 1024 * 1024 }) {
21337
21612
  const value = parse7(readRegistry2(path, budget2));
21338
21613
  for (const [, row] of value.entries)
21339
21614
  normalizeRow(row, 2);
21340
- const sha2562 = createHash21("sha256").update("hasna.skills.claude-marketplace-registry.v2\x00").update(JSON.stringify(value)).digest("hex");
21341
- return { path, hashMode: "claude-marketplace-registry-v2", sha256: sha2562 };
21615
+ const sha2563 = createHash23("sha256").update("hasna.skills.claude-marketplace-registry.v2\x00").update(JSON.stringify(value)).digest("hex");
21616
+ return { path, hashMode: "claude-marketplace-registry-v2", sha256: sha2563 };
21342
21617
  }
21343
21618
  var events = { UserPromptSubmit: ["userPromptSubmit", "user_prompt_submit"], SessionStart: ["sessionStart", "session_start"], SubagentStart: ["subagentStart", "subagent_start"] };
21344
21619
  var matchedEvents = { ...events, PreToolUse: ["preToolUse", "pre_tool_use"] };
21345
21620
  var proofs = new WeakMap;
21346
- var sha4 = (text2) => createHash222("sha256").update(text2).digest("hex");
21621
+ var sha4 = (text2) => createHash24("sha256").update(text2).digest("hex");
21347
21622
  var fields = [...CODEX_DISCOVERY_PROJECTION_FIELDS];
21348
21623
  var proofs2 = new WeakMap;
21349
21624
  function assertCodexHookDiscoveryRecovery(binding, witness) {
21350
21625
  const proof = proofs2.get(witness);
21351
- need5(!!proof && binding.agent === "codex" && witness.discoverySha256 === sha4(JSON.stringify(binding)), "RECONCILE_DISCOVERY_RECOVERY_CHANGED");
21626
+ need6(!!proof && binding.agent === "codex" && witness.discoverySha256 === sha4(JSON.stringify(binding)), "RECONCILE_DISCOVERY_RECOVERY_CHANGED");
21352
21627
  unchanged2(proof.before);
21353
21628
  unchanged2(proof.current);
21354
21629
  proof.recheckAdditions();
@@ -21357,10 +21632,41 @@ function verifiesCodexHookDiscoverySource(binding, source, currentDigest, witnes
21357
21632
  if (!witness || source.path !== witness.configPath || source.hashMode !== "bytes")
21358
21633
  return false;
21359
21634
  assertCodexHookDiscoveryRecovery(binding, witness);
21360
- need5(source.sha256 === witness.beforeSha256 && currentDigest === witness.currentSha256, "RECONCILE_DISCOVERY_RECOVERY_CHANGED");
21635
+ need6(source.sha256 === witness.beforeSha256 && currentDigest === witness.currentSha256, "RECONCILE_DISCOVERY_RECOVERY_CHANGED");
21361
21636
  return true;
21362
21637
  }
21363
- var digest = (text2) => createHash23("sha256").update(text2).digest("hex");
21638
+ var DISCOVERY_RUNTIME_COMMANDS = Object.freeze({ gemini: "gemini" });
21639
+ var DISCOVERY_ROOT_UNRESOLVED = "DISCOVERY_ROOT_UNRESOLVED";
21640
+ function discoveryRootUnresolved(agent, command, detail) {
21641
+ return new Error(`${DISCOVERY_ROOT_UNRESOLVED}: ${agent} discovery cannot resolve its "${command}" executable: ${detail}. The reviewed discovery is unchanged; this is an environment gap, not drift.`);
21642
+ }
21643
+ function isDiscoveryRootUnresolved(error) {
21644
+ return error instanceof Error && error.message.startsWith(`${DISCOVERY_ROOT_UNRESOLVED}: `);
21645
+ }
21646
+ var quotedPath = (path) => JSON.stringify(path).replace(/[^\x20-\x7e]/g, (character) => `\\u${character.charCodeAt(0).toString(16).padStart(4, "0")}`);
21647
+ var realpathOrNull = (path) => {
21648
+ try {
21649
+ return realpathSync11(path);
21650
+ } catch {
21651
+ return null;
21652
+ }
21653
+ };
21654
+ function discoveryExecutable(agent) {
21655
+ const command = DISCOVERY_RUNTIME_COMMANDS[agent];
21656
+ const found = command ? Bun.which(command) : null;
21657
+ if (!command || !found)
21658
+ return null;
21659
+ const path = resolve20(found), target = realpathOrNull(path);
21660
+ return target === null ? null : { command, path, target };
21661
+ }
21662
+ function recordedDiscoveryExecutable(agent, recorded) {
21663
+ const command = DISCOVERY_RUNTIME_COMMANDS[agent];
21664
+ if (!command || recorded.command !== command)
21665
+ throw new Error(`Recorded ${agent} discovery executable names another command`);
21666
+ const target = realpathOrNull(recorded.path);
21667
+ return target === null ? null : { command, path: recorded.path, target };
21668
+ }
21669
+ var digest = (text2) => createHash25("sha256").update(text2).digest("hex");
21364
21670
  function parseConfig(text2, path, toml = false) {
21365
21671
  try {
21366
21672
  const value = toml ? Bun.TOML.parse(text2) : JSON.parse(text2);
@@ -21372,12 +21678,12 @@ function parseConfig(text2, path, toml = false) {
21372
21678
  }
21373
21679
  }
21374
21680
  function safe4(path) {
21375
- if (!isAbsolute18(path) || path.includes("\x00"))
21681
+ if (!isAbsolute21(path) || path.includes("\x00"))
21376
21682
  throw new Error("Expected an absolute native discovery path");
21377
- for (let cursor = path;; cursor = dirname19(cursor)) {
21378
- if (lstatSync24(cursor, { throwIfNoEntry: false })?.isSymbolicLink())
21683
+ for (let cursor = path;; cursor = dirname20(cursor)) {
21684
+ if (lstatSync25(cursor, { throwIfNoEntry: false })?.isSymbolicLink())
21379
21685
  throw new Error(`Refusing symlink native discovery input: ${cursor}`);
21380
- if (dirname19(cursor) === cursor)
21686
+ if (dirname20(cursor) === cursor)
21381
21687
  break;
21382
21688
  }
21383
21689
  }
@@ -21385,18 +21691,18 @@ function read2(path, changes) {
21385
21691
  safe4(path);
21386
21692
  if (changes?.has(path))
21387
21693
  return changes.get(path);
21388
- const stat2 = lstatSync24(path, { throwIfNoEntry: false });
21694
+ const stat2 = lstatSync25(path, { throwIfNoEntry: false });
21389
21695
  if (!stat2)
21390
21696
  return null;
21391
21697
  if (!stat2.isFile() || stat2.size > 16 * 1024 * 1024)
21392
21698
  throw new Error(`Unsupported or oversized native discovery input: ${path}`);
21393
- return readFileSync19(path, "utf8");
21699
+ return readFileSync20(path, "utf8");
21394
21700
  }
21395
21701
  function projectNativeDiscoveryFields(text2, format, fields2, path) {
21396
21702
  const object6 = format === "yaml" ? parseHermesConfig(text2) : parseConfig(text2, path, format === "toml");
21397
21703
  if (!object6 || typeof object6 !== "object" || Array.isArray(object6))
21398
21704
  throw new Error("Expected native discovery configuration object");
21399
- return digest(JSON.stringify(Object.fromEntries(fields2.map((field2) => [field2, object6[field2] ?? null]))));
21705
+ return digest(JSON.stringify(Object.fromEntries(fields2.map((field3) => [field3, object6[field3] ?? null]))));
21400
21706
  }
21401
21707
  function isSupersededSettingsProjection(agent, configPath, source) {
21402
21708
  if (agent === "sumi")
@@ -21425,21 +21731,29 @@ function projected(source, changes, budget2 = discoveryByteBudget()) {
21425
21731
  throw new Error(`Native discovery input changed; run skills hook install with a fresh discovery review: ${source.path}`);
21426
21732
  return changes?.has(source.path) ? (source.hashMode === "codex-settings-v4" ? hashCodexSettingsReplacementV4 : source.hashMode === "codex-settings-v3" ? hashCodexSettingsReplacementV3 : source.hashMode === "codex-settings-v2" ? hashCodexSettingsReplacementV2 : hashCodexSettingsReplacement)(changes.get(source.path), budget2) : current2;
21427
21733
  }
21428
- if (source.hashMode === "claude-settings-v1" || source.hashMode === "claude-settings-v2" || source.hashMode === "claude-settings-v3") {
21734
+ if (source.hashMode === "claude-settings-v1" || source.hashMode === "claude-settings-v2" || (source.hashMode === "claude-settings-v3" || source.hashMode === "claude-settings-v4")) {
21429
21735
  if (source.format !== undefined || source.fields !== undefined || source.managedPlugins !== undefined || typeof source.sha256 !== "string" || !/^[a-f0-9]{64}$/.test(source.sha256))
21430
21736
  throw new Error("Claude settings witnesses require exact typed metadata");
21431
- const current2 = (source.hashMode === "claude-settings-v3" ? captureClaudeSettingsV3 : source.hashMode === "claude-settings-v2" ? captureClaudeSettingsV2 : captureClaudeSettings)(source.path, budget2).sha256;
21737
+ const current2 = (source.hashMode === "claude-settings-v4" ? captureClaudeSettingsV4 : source.hashMode === "claude-settings-v3" ? captureClaudeSettingsV3 : source.hashMode === "claude-settings-v2" ? captureClaudeSettingsV2 : captureClaudeSettings)(source.path, budget2).sha256;
21432
21738
  if (current2 !== source.sha256)
21433
21739
  throw new Error(`Native discovery input changed; run skills hook install with a fresh discovery review: ${source.path}`);
21434
- return changes?.has(source.path) ? (source.hashMode === "claude-settings-v3" ? hashClaudeSettingsReplacementV3 : source.hashMode === "claude-settings-v2" ? hashClaudeSettingsReplacementV2 : hashClaudeSettingsReplacement)(changes.get(source.path), budget2) : current2;
21740
+ return changes?.has(source.path) ? (source.hashMode === "claude-settings-v4" ? hashClaudeSettingsReplacementV4 : source.hashMode === "claude-settings-v3" ? hashClaudeSettingsReplacementV3 : source.hashMode === "claude-settings-v2" ? hashClaudeSettingsReplacementV2 : hashClaudeSettingsReplacement)(changes.get(source.path), budget2) : current2;
21435
21741
  }
21436
21742
  if (source.hashMode === "claude-marketplace-registry" || source.hashMode === "claude-marketplace-registry-v2") {
21437
21743
  if (source.format !== undefined || source.fields !== undefined || source.managedPlugins !== undefined || typeof source.sha256 !== "string" || !/^[a-f0-9]{64}$/.test(source.sha256) || changes?.has(source.path))
21438
21744
  throw new Error("Claude marketplace witnesses require an exact reviewed registry without synthetic changes");
21439
- const sha2562 = (source.hashMode === "claude-marketplace-registry-v2" ? captureClaudeMarketplaceRegistryV2 : captureClaudeMarketplaceRegistry)(source.path, budget2).sha256;
21440
- if (sha2562 !== source.sha256)
21745
+ const sha2563 = (source.hashMode === "claude-marketplace-registry-v2" ? captureClaudeMarketplaceRegistryV2 : captureClaudeMarketplaceRegistry)(source.path, budget2).sha256;
21746
+ if (sha2563 !== source.sha256)
21441
21747
  throw new Error(`Native discovery input changed; run skills hook install with a fresh discovery review: ${source.path}`);
21442
- return sha2562;
21748
+ return sha2563;
21749
+ }
21750
+ if (source.hashMode === "claude-marketplace-entry-v1") {
21751
+ if (source.format !== undefined || source.fields !== undefined || source.managedPlugins !== undefined || typeof source.sha256 !== "string" || !/^[a-f0-9]{64}$/.test(source.sha256) || changes?.has(source.path) || !claudeMarketplaceEntrySourceValid(source))
21752
+ throw new Error("Claude marketplace entry witnesses require an exact reviewed entry without synthetic changes");
21753
+ const sha2563 = captureClaudeMarketplaceEntry(source.path, source.marketplace, source.plugin, budget2).sha256;
21754
+ if (sha2563 !== source.sha256)
21755
+ throw new Error(`Native discovery input changed; run skills hook install with a fresh discovery review: ${source.path}`);
21756
+ return sha2563;
21443
21757
  }
21444
21758
  if (source.hashMode === "claude-plugin-registry") {
21445
21759
  if (source.format !== undefined || source.fields !== undefined || !source.managedPlugins || changes?.has(source.path))
@@ -21476,9 +21790,9 @@ function absentCodexSkillRoots(binding) {
21476
21790
  return [];
21477
21791
  if (binding.agent !== "codex" || !Array.isArray(controls) || controls.length > 4096)
21478
21792
  throw new Error("Invalid disabled Codex discovery proof");
21479
- if (binding.method !== "reviewed" || controls.every((control) => lstatSync24(control.pluginParent, { throwIfNoEntry: false })))
21793
+ if (binding.method !== "reviewed" || controls.every((control) => lstatSync25(control.pluginParent, { throwIfNoEntry: false })))
21480
21794
  return [];
21481
- const cache = dirname19(dirname19(controls[0].pluginParent)), config = join32(dirname19(dirname19(cache)), "config.toml");
21795
+ const cache = dirname20(dirname20(controls[0].pluginParent)), config = join32(dirname20(dirname20(cache)), "config.toml");
21482
21796
  const source = binding.sources.find((source2) => source2.path === config && source2.sha256 !== null && source2.format === undefined && source2.fields === undefined);
21483
21797
  if (!source || projected(source) !== source.sha256)
21484
21798
  throw new Error("Missing current disabled Codex configuration witness");
@@ -21486,7 +21800,7 @@ function absentCodexSkillRoots(binding) {
21486
21800
  return [...new Set(controls.map((control) => control.pluginParent))].filter((parent) => !codexDirectHookSelects(cache, parent) && absentDisabledCodexPluginParent(cache, parent, controls, rules));
21487
21801
  }
21488
21802
  function codexDirectHookSelects(cache, root2) {
21489
- const codex = dirname19(dirname19(cache)), config = Bun.TOML.parse(read2(join32(codex, "config.toml")) ?? "");
21803
+ const codex = dirname20(dirname20(cache)), config = Bun.TOML.parse(read2(join32(codex, "config.toml")) ?? "");
21490
21804
  const hooks = read2(join32(codex, "hooks.json"));
21491
21805
  if (hooks !== null)
21492
21806
  hashNativeJsonControls(hooks);
@@ -21499,7 +21813,7 @@ function retiredCodexRoots(binding) {
21499
21813
  const controls = binding.codexDisabledPluginSkills;
21500
21814
  if (binding.agent !== "codex" || binding.method !== "reviewed" || !Array.isArray(controls) || !controls.length || !Array.isArray(proof.roots) || proof.roots.length > AGENT_POLICY_LIMITS.discoveryRoots || new Set(proof.roots).size !== proof.roots.length || !Array.isArray(proof.directories) || proof.parents !== undefined && (!Array.isArray(proof.parents) || proof.parents.length > AGENT_POLICY_LIMITS.discoveryRoots || new Set(proof.parents).size !== proof.parents.length) || !proof.roots.length && !proof.parents?.length)
21501
21815
  throw new Error("Invalid retired Codex materialization proof");
21502
- const cache = dirname19(dirname19(controls[0].pluginParent)), config = join32(dirname19(dirname19(cache)), "config.toml");
21816
+ const cache = dirname20(dirname20(controls[0].pluginParent)), config = join32(dirname20(dirname20(cache)), "config.toml");
21503
21817
  const source = binding.sources.find((source2) => source2.path === config && source2.sha256 !== null && source2.format === undefined && source2.fields === undefined);
21504
21818
  if (!source || projected(source) !== source.sha256)
21505
21819
  throw new Error("Missing current retired Codex configuration witness");
@@ -21528,9 +21842,9 @@ function absentRetiredClaudeRoots(binding) {
21528
21842
  continue;
21529
21843
  const root2 = join32(cache, ...parts.slice(0, 3));
21530
21844
  safe4(root2);
21531
- if (lstatSync24(root2, { throwIfNoEntry: false }))
21845
+ if (lstatSync25(root2, { throwIfNoEntry: false }))
21532
21846
  continue;
21533
- const claude = dirname19(dirname19(cache)), settings = join32(claude, "settings.json"), registry = join32(claude, "plugins/installed_plugins.json");
21847
+ const claude = dirname20(dirname20(cache)), settings = join32(claude, "settings.json"), registry = join32(claude, "plugins/installed_plugins.json");
21534
21848
  const full = (path) => binding.sources.find((item) => item.path === path && item.sha256 !== null && item.format === undefined && item.fields === undefined);
21535
21849
  const configSource = full(settings), registrySource = full(registry);
21536
21850
  if (!configSource || !registrySource || projected(configSource) !== configSource.sha256 || projected(registrySource) !== registrySource.sha256)
@@ -21543,17 +21857,41 @@ function absentRetiredClaudeRoots(binding) {
21543
21857
  continue;
21544
21858
  if (JSON.stringify(config.hooks ?? {}).includes(root2))
21545
21859
  continue;
21860
+ const registrationScope = (row) => {
21861
+ if (!row || typeof row !== "object" || Array.isArray(row))
21862
+ return null;
21863
+ const value = row;
21864
+ if (typeof value.installPath !== "string" || /[\x00-\x1f\x7f]/.test(value.installPath) || !isAbsolute21(value.installPath) || resolve20(value.installPath) !== value.installPath || value.installPath.length > AGENT_POLICY_LIMITS.pathCharacters)
21865
+ return null;
21866
+ if (value.scope === "user")
21867
+ return value.projectPath === undefined || value.projectPath === null ? "user\x00" : null;
21868
+ if (value.scope === "project")
21869
+ return typeof value.projectPath === "string" && !/[\x00-\x1f\x7f]/.test(value.projectPath) && value.projectPath.length <= AGENT_POLICY_LIMITS.pathCharacters && isAbsolute21(value.projectPath) && resolve20(value.projectPath) === value.projectPath ? `project\x00${value.projectPath}` : null;
21870
+ return null;
21871
+ };
21872
+ if (Object.values(installed.plugins).some((value) => !Array.isArray(value) || value.some((row) => !row || typeof row.installPath !== "string" || row.installPath === root2 || row.installPath.startsWith(root2 + sep8) || root2.startsWith(row.installPath + sep8))))
21873
+ continue;
21546
21874
  const rows = installed.plugins[id];
21547
- if (!Array.isArray(rows) || rows.length !== 1 || rows[0]?.scope !== "user" || typeof rows[0]?.installPath !== "string")
21875
+ if (!Array.isArray(rows) || rows.length < 1)
21876
+ continue;
21877
+ const targetScopes = new Set;
21878
+ let targetValid = true;
21879
+ for (const row of rows) {
21880
+ const scope = registrationScope(row), value = row;
21881
+ if (scope === null || targetScopes.has(scope) || value?.installPath !== rows[0]?.installPath || value?.version !== rows[0]?.version) {
21882
+ targetValid = false;
21883
+ break;
21884
+ }
21885
+ targetScopes.add(scope);
21886
+ }
21887
+ if (!targetValid || !targetScopes.has("user\x00"))
21548
21888
  continue;
21549
- const active = rows[0].installPath;
21550
- if (rows[0].version !== basename10(active) || resolve18(active) !== active || dirname19(active) !== dirname19(root2) || active === root2 || !lstatSync24(active, { throwIfNoEntry: false })?.isDirectory() || realpathSync10(active) !== active)
21889
+ const active = rows[0]?.installPath;
21890
+ if (typeof active !== "string" || rows[0]?.version !== basename11(active) || dirname20(active) !== dirname20(root2) || active === root2 || !lstatSync25(active, { throwIfNoEntry: false })?.isDirectory() || realpathSync11(active) !== active)
21551
21891
  continue;
21552
21892
  const activeManifest = full(join32(active, ".claude-plugin/plugin.json"));
21553
21893
  if (!activeManifest || projected(activeManifest) !== activeManifest.sha256)
21554
21894
  continue;
21555
- if (Object.values(installed.plugins).some((value) => !Array.isArray(value) || value.some((row) => !row || typeof row.installPath !== "string" || row.installPath === root2 || row.installPath.startsWith(root2 + sep8) || root2.startsWith(row.installPath + sep8))))
21556
- continue;
21557
21895
  result.add(root2);
21558
21896
  }
21559
21897
  return [...result];
@@ -21578,7 +21916,7 @@ function verifyAgentDiscovery(binding, codexRecovery) {
21578
21916
  const projection = binding.codexRetiredMaterializations.directories;
21579
21917
  if (projection.length !== ordinary.length || projection.some((item, index) => item.path !== ordinary[index]?.path))
21580
21918
  throw new Error("Missing retired Codex directory projection");
21581
- const omitted = [...retiredRoots, ...(binding.codexRetiredMaterializations.parents ?? []).filter((parent) => !lstatSync24(parent, { throwIfNoEntry: false }))];
21919
+ const omitted = [...retiredRoots, ...(binding.codexRetiredMaterializations.parents ?? []).filter((parent) => !lstatSync25(parent, { throwIfNoEntry: false }))];
21582
21920
  if (projection.every((item) => Array.isArray(item.entries)))
21583
21921
  verifyDiscoveryDirectoryProjection(projection, omitted);
21584
21922
  else {
@@ -21592,13 +21930,13 @@ function verifyAgentDiscovery(binding, codexRecovery) {
21592
21930
  verifyDiscoveryDirectories(ordinary);
21593
21931
  verifyDiscoveryDirectories(projected2, installationRoots);
21594
21932
  }
21595
- const absentRoots = [...absentCodexSkillRoots(binding), ...absentRetiredClaudeRoots(binding), ...retiredRoots.filter((root2) => !lstatSync24(root2, { throwIfNoEntry: false }))];
21933
+ const absentRoots = [...absentCodexSkillRoots(binding), ...absentRetiredClaudeRoots(binding), ...retiredRoots.filter((root2) => !lstatSync25(root2, { throwIfNoEntry: false }))];
21596
21934
  const budget2 = discoveryByteBudget();
21597
21935
  for (const source of binding.sources) {
21598
21936
  assertMarketplaceBinding(binding, source);
21599
21937
  if (source.hashMode === "claude-plugin-registry" && binding.agent !== "claude")
21600
21938
  throw new Error("Managed Claude registry witnesses cannot apply to another agent");
21601
- if (source.format !== undefined && (!["json", "toml", "yaml"].includes(source.format) || !Array.isArray(source.fields) || !source.fields.length || source.fields.length > 64 || source.fields.some((field2) => typeof field2 !== "string" || !field2)))
21939
+ if (source.format !== undefined && (!["json", "toml", "yaml"].includes(source.format) || !Array.isArray(source.fields) || !source.fields.length || source.fields.length > 64 || source.fields.some((field3) => typeof field3 !== "string" || !field3)))
21602
21940
  throw new Error("Invalid native discovery projection");
21603
21941
  if (source.sha256 !== null && !/^[a-f0-9]{64}$/.test(source.sha256))
21604
21942
  throw new Error("Invalid native discovery digest");
@@ -21618,7 +21956,7 @@ function verifyAgentDiscovery(binding, codexRecovery) {
21618
21956
  safe4(root2);
21619
21957
  for (const root2 of absentRoots) {
21620
21958
  safe4(root2);
21621
- if (lstatSync24(root2, { throwIfNoEntry: false }))
21959
+ if (lstatSync25(root2, { throwIfNoEntry: false }))
21622
21960
  throw new Error("Retired native materialization changed during discovery verification");
21623
21961
  }
21624
21962
  }
@@ -21626,15 +21964,15 @@ function codexInstallationRoots(binding) {
21626
21964
  const proof = binding.codexInstallationInputs;
21627
21965
  if (proof === undefined)
21628
21966
  return [];
21629
- if (binding.agent !== "codex" || binding.method !== "reviewed" || proof.version !== "codex-cli 0.160.0" || !/^[a-f0-9]{64}$/.test(proof.catalogSha256) || !Array.isArray(proof.plugins) || !proof.plugins.length)
21967
+ if (binding.agent !== "codex" || binding.method !== "reviewed" || !supportsCodexNativeCapability(proof.version, "installed-plugin-review") || !/^[a-f0-9]{64}$/.test(proof.catalogSha256) || !Array.isArray(proof.plugins) || !proof.plugins.length)
21630
21968
  throw new Error("Invalid native installation input proof");
21631
- const cache = dirname19(dirname19(proof.plugins[0].pluginParent));
21632
- const config = join32(dirname19(dirname19(cache)), "config.toml"), home = dirname19(dirname19(dirname19(cache)));
21969
+ const cache = dirname20(dirname20(proof.plugins[0].pluginParent));
21970
+ const config = join32(dirname20(dirname20(cache)), "config.toml"), home = dirname20(dirname20(dirname20(cache)));
21633
21971
  const configSource = binding.sources.find((source) => source.path === config && source.sha256 !== null && (!source.format || source.format === "toml" && source.fields?.includes("plugins")));
21634
21972
  const nativeRoots = NATIVE_SKILL_ROOTS.filter(([agent]) => agent === "codex").map(([, path]) => join32(home, path));
21635
- if (!configSource || proof.plugins.some((input) => nativeRoots.some((root2) => root2 === input.sourceRoot || root2.startsWith(input.sourceRoot + sep8) || input.sourceRoot.startsWith(root2 + sep8)) || binding.sources.some((source) => basename10(source.path) === "config.toml" && (source.path === input.sourceRoot || source.path.startsWith(input.sourceRoot + sep8)))))
21973
+ if (!configSource || proof.plugins.some((input) => nativeRoots.some((root2) => root2 === input.sourceRoot || root2.startsWith(input.sourceRoot + sep8) || input.sourceRoot.startsWith(root2 + sep8)) || binding.sources.some((source) => basename11(source.path) === "config.toml" && (source.path === input.sourceRoot || source.path.startsWith(input.sourceRoot + sep8)))))
21636
21974
  throw new Error("Native installation input overlaps configuration or loading roots");
21637
- if (proof.plugins.some((input) => dirname19(dirname19(input.pluginParent)) !== cache || !binding.sources.some((source) => source.path === join32(input.sourceRoot, ".codex-plugin/plugin.json") && source.sha256 !== null && source.format === undefined && source.fields === undefined)))
21975
+ if (proof.plugins.some((input) => dirname20(dirname20(input.pluginParent)) !== cache || !binding.sources.some((source) => source.path === join32(input.sourceRoot, ".codex-plugin/plugin.json") && source.sha256 !== null && source.format === undefined && source.fields === undefined)))
21638
21976
  throw new Error("Missing native installation input source witness");
21639
21977
  return reviewedCodexPluginSourceRoots(cache, proof.plugins, (path) => {
21640
21978
  const text2 = read2(path);
@@ -21644,40 +21982,42 @@ function codexInstallationRoots(binding) {
21644
21982
  });
21645
21983
  }
21646
21984
  function assertMarketplaceBinding(binding, source) {
21647
- if (source.hashMode === "claude-plugin-manifest-v1" && (binding.agent !== "claude" || basename10(source.path) !== "plugin.json" || !source.path.endsWith(join32(sep8, ".claude-plugin", "plugin.json"))))
21985
+ if (source.hashMode === "claude-plugin-manifest-v1" && (binding.agent !== "claude" || basename11(source.path) !== "plugin.json" || !source.path.endsWith(join32(sep8, ".claude-plugin", "plugin.json"))))
21648
21986
  throw new Error("Claude plugin manifest witnesses require Claude plugin discovery");
21649
- if (source.hashMode === "sumi-settings-v1" && (binding.agent !== "sumi" || binding.method !== "reviewed" || basename10(source.path) !== "sumi.json"))
21987
+ if (source.hashMode === "sumi-settings-v1" && (binding.agent !== "sumi" || binding.method !== "reviewed" || basename11(source.path) !== "sumi.json"))
21650
21988
  throw new Error("Sumi settings witnesses require explicit reviewed Sumi configuration");
21651
- if ((source.hashMode === "codex-settings-v1" || source.hashMode === "codex-settings-v2" || (source.hashMode === "codex-settings-v3" || source.hashMode === "codex-settings-v4")) && (binding.agent !== "codex" || binding.method !== "reviewed" || basename10(source.path) !== "config.toml"))
21989
+ if ((source.hashMode === "codex-settings-v1" || source.hashMode === "codex-settings-v2" || (source.hashMode === "codex-settings-v3" || source.hashMode === "codex-settings-v4")) && (binding.agent !== "codex" || binding.method !== "reviewed" || basename11(source.path) !== "config.toml"))
21652
21990
  throw new Error("Codex settings witnesses require explicit reviewed Codex configuration");
21653
- if ((source.hashMode === "claude-settings-v1" || source.hashMode === "claude-settings-v2" || source.hashMode === "claude-settings-v3") && (binding.agent !== "claude" || binding.method !== "reviewed" || basename10(source.path) !== "settings.json"))
21991
+ if ((source.hashMode === "claude-settings-v1" || source.hashMode === "claude-settings-v2" || (source.hashMode === "claude-settings-v3" || source.hashMode === "claude-settings-v4")) && (binding.agent !== "claude" || binding.method !== "reviewed" || basename11(source.path) !== "settings.json"))
21654
21992
  throw new Error("Claude settings witnesses require explicit reviewed Claude configuration");
21655
21993
  if ((source.hashMode === "claude-marketplace-registry" || source.hashMode === "claude-marketplace-registry-v2") && (binding.agent !== "claude" || binding.method !== "reviewed"))
21656
21994
  throw new Error("Claude marketplace witnesses require explicit reviewed Claude discovery");
21995
+ if (source.hashMode === "claude-marketplace-entry-v1" && (binding.agent !== "claude" || binding.method !== "reviewed" || !claudeMarketplaceEntrySourceValid(source)))
21996
+ throw new Error("Claude marketplace entry witnesses require explicit reviewed Claude discovery of one named entry");
21657
21997
  }
21658
21998
  function rebindAgentDiscovery(binding, changes) {
21659
21999
  const budget2 = discoveryByteBudget();
21660
- const installationRoots = codexInstallationRoots(binding), absentRoots = [...absentCodexSkillRoots(binding), ...absentRetiredClaudeRoots(binding), ...retiredCodexRoots(binding).filter((root2) => !lstatSync24(root2, { throwIfNoEntry: false }))];
22000
+ const installationRoots = codexInstallationRoots(binding), absentRoots = [...absentCodexSkillRoots(binding), ...absentRetiredClaudeRoots(binding), ...retiredCodexRoots(binding).filter((root2) => !lstatSync25(root2, { throwIfNoEntry: false }))];
21661
22001
  const rebound = { ...binding, sources: binding.sources.map((source) => {
21662
22002
  assertMarketplaceBinding(binding, source);
21663
22003
  if (!changes.has(source.path) && (installationRoots.some((root2) => source.path.startsWith(root2 + sep8)) || absentRoots.some((root2) => source.path.startsWith(root2 + sep8)) && source.format === undefined && source.fields === undefined && source.managedPlugins === undefined && [undefined, "bytes"].includes(source.hashMode)))
21664
22004
  return source;
21665
- const sha2562 = projected(source, changes, budget2);
21666
- if (!changes.has(source.path) && sha2562 !== source.sha256)
22005
+ const sha2563 = projected(source, changes, budget2);
22006
+ if (!changes.has(source.path) && sha2563 !== source.sha256)
21667
22007
  throw new Error(`Native discovery input changed; run skills hook install with a fresh discovery review: ${source.path}`);
21668
- return { ...source, sha256: sha2562 };
22008
+ return { ...source, sha256: sha2563 };
21669
22009
  }) };
21670
22010
  for (const root2 of absentRoots) {
21671
22011
  safe4(root2);
21672
- if (lstatSync24(root2, { throwIfNoEntry: false }))
22012
+ if (lstatSync25(root2, { throwIfNoEntry: false }))
21673
22013
  throw new Error("Retired native materialization changed during discovery rebinding");
21674
22014
  }
21675
22015
  return rebound;
21676
22016
  }
21677
- function assertProjectDiscovery(agent, directories, home, canonical7 = resolve18, reviewed) {
21678
- const homeConfigPath = canonical7(agentDiscoveryConfigPath(home, agent));
22017
+ function assertProjectDiscovery(agent, directories, home, canonical8 = resolve20, reviewed) {
22018
+ const homeConfigPath = canonical8(agentDiscoveryConfigPath(home, agent));
21679
22019
  for (const directory of directories) {
21680
- const isHome = resolve18(directory) === resolve18(home);
22020
+ const isHome = resolve20(directory) === resolve20(home);
21681
22021
  if (agent === "hermes") {
21682
22022
  assertHermesEnvironment(home);
21683
22023
  continue;
@@ -21686,7 +22026,7 @@ function assertProjectDiscovery(agent, directories, home, canonical7 = resolve18
21686
22026
  continue;
21687
22027
  const paths = agent === "claude" ? [...isHome ? [] : [".claude/settings.json"], ".claude/settings.local.json"] : agent === "codex" ? [".codex/config.toml"] : agent === "gemini" ? [".gemini/settings.json"] : agent === "opencode" ? ["opencode.json", "opencode.jsonc", ".opencode/opencode.json", ".opencode/opencode.jsonc"] : agent === "sumi" ? ["sumi.json", "sumi.jsonc", ".sumi/sumi.json", ".sumi/sumi.jsonc"] : [".cursor/hooks.json"];
21688
22028
  for (const suffix of paths) {
21689
- const path = canonical7(join32(directory, suffix)), raw = read2(path);
22029
+ const path = canonical8(join32(directory, suffix)), raw = read2(path);
21690
22030
  if (raw === null)
21691
22031
  continue;
21692
22032
  const isRootAliasedHomeConfig = agent === "claude" && suffix === ".claude/settings.json" || agent === "codex" && suffix === ".codex/config.toml";
@@ -21702,7 +22042,7 @@ function assertProjectDiscovery(agent, directories, home, canonical7 = resolve18
21702
22042
  const managed = reviewed.sources.flatMap((source) => source.hashMode === "claude-plugin-registry" ? source.managedPlugins ?? [] : []);
21703
22043
  if (exact && projected(exact) === exact.sha256 && managed.length) {
21704
22044
  const bindings = managed.map((item) => readPluginBinding(item.storeRoot, item.bindingId));
21705
- admittedPlugins = Object.entries(config.enabledPlugins).every(([id, enabled]) => typeof enabled === "boolean" && bindings.some((binding) => binding.target.pluginId === id && binding.target.registrations.some((scope) => scope.scope === "project" && scope.projectPath === canonical7(directory))));
22045
+ admittedPlugins = Object.entries(config.enabledPlugins).every(([id, enabled]) => typeof enabled === "boolean" && bindings.some((binding) => binding.target.pluginId === id && binding.target.registrations.some((scope) => scope.scope === "project" && scope.projectPath === canonical8(directory))));
21706
22046
  }
21707
22047
  }
21708
22048
  if (keys.some((key) => config[key] !== undefined && !(key === "enabledPlugins" && admittedPlugins)) || config.disableAllHooks === true || config.disableBundledSkills === false || config.hooksConfig?.enabled === false || config.permission?.skill !== undefined || config.permissions?.deny?.some((rule) => typeof rule === "string" && /^Skill(?:\(|$)/.test(rule)))
@@ -21710,15 +22050,15 @@ function assertProjectDiscovery(agent, directories, home, canonical7 = resolve18
21710
22050
  }
21711
22051
  if (agent === "sumi")
21712
22052
  for (const name of ["plugin", "plugins"]) {
21713
- const path = canonical7(join32(directory, ".sumi", name));
22053
+ const path = canonical8(join32(directory, ".sumi", name));
21714
22054
  safe4(path);
21715
- if (lstatSync24(path, { throwIfNoEntry: false })?.isDirectory() && readdirSync10(path).length)
22055
+ if (lstatSync25(path, { throwIfNoEntry: false })?.isDirectory() && readdirSync10(path).length)
21716
22056
  throw new Error(`NATIVE_SKILL_DRIFT: project Sumi plugins require a dedicated discovery review: ${path}`);
21717
22057
  }
21718
22058
  if (agent === "claude") {
21719
- const commands = canonical7(join32(directory, ".claude/commands"));
22059
+ const commands = canonical8(join32(directory, ".claude/commands"));
21720
22060
  safe4(commands);
21721
- if (lstatSync24(commands, { throwIfNoEntry: false })?.isDirectory() && readdirSync10(commands).length)
22061
+ if (lstatSync25(commands, { throwIfNoEntry: false })?.isDirectory() && readdirSync10(commands).length)
21722
22062
  throw new Error("NATIVE_SKILL_DRIFT: legacy project command discovery requires a dedicated format adapter");
21723
22063
  }
21724
22064
  }
@@ -21728,11 +22068,37 @@ function agentDiscoveryConfigPath(home, agent) {
21728
22068
  return sumiConfigPath(home);
21729
22069
  return join32(home, agent === "hermes" ? ".hermes/config.yaml" : agent === "opencode" ? ".config/opencode/opencode.json" : `.${agent}/${agent === "codex" ? "config.toml" : agent === "cursor" ? "hooks.json" : "settings.json"}`);
21730
22070
  }
22071
+ function verifyAutomaticDiscoveryClosure(binding, options) {
22072
+ const command = DISCOVERY_RUNTIME_COMMANDS[binding.agent], recorded = options.executable;
22073
+ const onPath = discoveryExecutable(binding.agent);
22074
+ let runtime, gap;
22075
+ if (recorded) {
22076
+ runtime = recordedDiscoveryExecutable(binding.agent, recorded);
22077
+ if (runtime && runtime.target !== recorded.target)
22078
+ throw new Error(`${options.change}: the recorded ${binding.agent} executable now resolves to ${quotedPath(runtime.target)}, not the reviewed ${quotedPath(recorded.target)}`);
22079
+ if (onPath && onPath.target !== recorded.target)
22080
+ throw new Error(`${options.change}: the "${command}" on this process's PATH resolves to ${quotedPath(onPath.target)}, not the reviewed ${quotedPath(recorded.target)}`);
22081
+ if (!runtime)
22082
+ gap = `the recorded executable ${quotedPath(recorded.path)} no longer resolves. Restore it, or review the change with skills hook install`;
22083
+ } else {
22084
+ runtime = onPath;
22085
+ if (!runtime)
22086
+ gap = "it is not on this process's PATH, and the reviewed policy has no recorded executable path. Run with the PATH used for the review, or run skills hook install there to record it";
22087
+ }
22088
+ const current2 = resolveAgentDiscovery({ home: options.home, agent: binding.agent, canonical: options.canonical, executable: runtime });
22089
+ if (JSON.stringify(current2) === JSON.stringify(binding))
22090
+ return;
22091
+ const reviewedWithRuntime = (binding.builtinNames?.length ?? 0) > 0 || binding.sources.some((source) => basename11(source.path) === "package.json");
22092
+ const otherwiseCurrent = current2.method === binding.method && JSON.stringify(current2.roots) === JSON.stringify(binding.roots) && JSON.stringify(current2.directories) === JSON.stringify(binding.directories) && current2.sources.every((source) => binding.sources.some((saved) => isDeepStrictEqual7(saved, source)));
22093
+ if (command && gap && runtime === null && reviewedWithRuntime && otherwiseCurrent)
22094
+ throw discoveryRootUnresolved(binding.agent, command, gap);
22095
+ throw new Error(options.change);
22096
+ }
21731
22097
  function resolveAgentDiscovery(options) {
21732
- const canonical7 = options.canonical ?? resolve18, home = resolve18(options.home), agent = options.agent;
22098
+ const canonical8 = options.canonical ?? resolve20, home = resolve20(options.home), agent = options.agent;
21733
22099
  const sources = [], roots = new Set, builtinNames = [];
21734
22100
  const witness = (path, format, fields2, hashMode) => {
21735
- const source = { path: canonical7(path), sha256: null, ...format ? { format, fields: fields2 } : {}, ...hashMode ? { hashMode } : {} };
22101
+ const source = { path: canonical8(path), sha256: null, ...format ? { format, fields: fields2 } : {}, ...hashMode ? { hashMode } : {} };
21736
22102
  source.sha256 = projected(source);
21737
22103
  sources.push(source);
21738
22104
  return read2(source.path);
@@ -21754,13 +22120,13 @@ function resolveAgentDiscovery(options) {
21754
22120
  unresolved("JSONC configuration requires a supported format adapter");
21755
22121
  for (const root2 of [directory, join32(home, ".claude"), join32(home, ".agents")])
21756
22122
  for (const name of ["skill", "skills"])
21757
- roots.add(canonical7(join32(root2, name)));
22123
+ roots.add(canonical8(join32(root2, name)));
21758
22124
  if (config.skills !== undefined && (!Array.isArray(config.skills) || config.skills.some((path) => typeof path !== "string")))
21759
22125
  unresolved("skills must be a string array");
21760
22126
  for (const value of config.skills ?? []) {
21761
- if (typeof value !== "string" || /[\0$]/.test(value) || !value || !(isAbsolute18(value) || value.startsWith("~/")))
22127
+ if (typeof value !== "string" || /[\0$]/.test(value) || !value || !(isAbsolute21(value) || value.startsWith("~/")))
21762
22128
  unresolved("remote or relative skill sources need a dedicated discovery adapter");
21763
- roots.add(canonical7(value.startsWith("~/") ? join32(home, value.slice(2)) : value));
22129
+ roots.add(canonical8(value.startsWith("~/") ? join32(home, value.slice(2)) : value));
21764
22130
  }
21765
22131
  for (const key of ["plugin", "plugins"])
21766
22132
  if (config[key] !== undefined && !Array.isArray(config[key]))
@@ -21768,19 +22134,19 @@ function resolveAgentDiscovery(options) {
21768
22134
  const plugins = [join32(directory, "plugin"), join32(directory, "plugins")];
21769
22135
  for (const path of plugins) {
21770
22136
  safe4(path);
21771
- if (lstatSync24(path, { throwIfNoEntry: false })?.isDirectory())
22137
+ if (lstatSync25(path, { throwIfNoEntry: false })?.isDirectory())
21772
22138
  for (const name of readdirSync10(path).sort()) {
21773
22139
  if (name === "skills-cli.js" && path === plugins[1])
21774
22140
  continue;
21775
22141
  const target = join32(path, name);
21776
- if (!lstatSync24(target).isFile())
22142
+ if (!lstatSync25(target).isFile())
21777
22143
  unresolved("local plugin packages need a dedicated discovery adapter");
21778
22144
  witness(target);
21779
22145
  }
21780
22146
  }
21781
22147
  for (const root2 of roots) {
21782
22148
  safe4(root2);
21783
- if (lstatSync24(root2, { throwIfNoEntry: false })?.isDirectory() && readdirSync10(root2).some((name) => name.endsWith(".md")))
22149
+ if (lstatSync25(root2, { throwIfNoEntry: false })?.isDirectory() && readdirSync10(root2).some((name) => name.endsWith(".md")))
21784
22150
  unresolved("flat markdown skills require a dedicated native migration adapter");
21785
22151
  }
21786
22152
  }
@@ -21799,30 +22165,30 @@ function resolveAgentDiscovery(options) {
21799
22165
  continue;
21800
22166
  if (normalized.startsWith("~") && normalized !== "~" && !normalized.startsWith("~/"))
21801
22167
  unresolved("user-specific tilde expansion requires a separate discovery adapter");
21802
- const path = normalized === "~" ? home : normalized.startsWith("~/") ? join32(home, normalized.slice(2)) : resolve18(home, ".hermes", normalized);
22168
+ const path = normalized === "~" ? home : normalized.startsWith("~/") ? join32(home, normalized.slice(2)) : resolve20(home, ".hermes", normalized);
21803
22169
  safe4(path);
21804
22170
  roots.add(path);
21805
22171
  }
21806
22172
  }
21807
22173
  if (agent === "gemini") {
21808
- const executable2 = Bun.which("gemini");
22174
+ const executable2 = options.executable === undefined ? discoveryExecutable(agent) : options.executable;
21809
22175
  if (executable2) {
21810
22176
  let packageRoot;
21811
- for (let directory = dirname19(realpathSync10(executable2)), depth = 0;depth < 8; directory = dirname19(directory), depth++) {
22177
+ for (let directory = dirname20(executable2.target), depth = 0;depth < 8; directory = dirname20(directory), depth++) {
21812
22178
  const path = join32(directory, "package.json"), raw = read2(path);
21813
22179
  if (raw !== null && parseConfig(raw, path).name === "@google/gemini-cli") {
21814
22180
  packageRoot = directory;
21815
22181
  witness(path);
21816
22182
  break;
21817
22183
  }
21818
- if (dirname19(directory) === directory)
22184
+ if (dirname20(directory) === directory)
21819
22185
  break;
21820
22186
  }
21821
22187
  if (!packageRoot)
21822
22188
  unresolved("installed Gemini package layout is not recognized");
21823
22189
  const builtinRoot = join32(packageRoot, "bundle/builtin");
21824
22190
  safe4(builtinRoot);
21825
- if (!lstatSync24(builtinRoot, { throwIfNoEntry: false })?.isDirectory())
22191
+ if (!lstatSync25(builtinRoot, { throwIfNoEntry: false })?.isDirectory())
21826
22192
  unresolved("installed Gemini builtin root is missing");
21827
22193
  for (const name of readdirSync10(builtinRoot).sort()) {
21828
22194
  const text2 = witness(join32(builtinRoot, name, "SKILL.md"));
@@ -21838,11 +22204,11 @@ function resolveAgentDiscovery(options) {
21838
22204
  if (retained.agent !== agent || retained.method !== "reviewed")
21839
22205
  unresolved("invalid retained review");
21840
22206
  verifyAgentDiscovery(retained);
21841
- if (!retained.sources.some((source) => source.path === canonical7(configPath) && source.format === undefined && source.fields === undefined))
22207
+ if (!retained.sources.some((source) => source.path === canonical8(configPath) && source.format === undefined && source.fields === undefined))
21842
22208
  unresolved("retained review is missing the full agent configuration source");
21843
- if (retained.sources.some((source) => (source.hashMode === "sumi-settings-v1" || source.hashMode === "claude-settings-v1" || source.hashMode === "claude-settings-v2" || (source.hashMode === "claude-settings-v3" || (source.hashMode === "codex-settings-v1" || source.hashMode === "codex-settings-v2" || (source.hashMode === "codex-settings-v3" || source.hashMode === "codex-settings-v4")))) && source.path !== canonical7(configPath)))
22209
+ if (retained.sources.some((source) => (source.hashMode === "sumi-settings-v1" || source.hashMode === "claude-settings-v1" || source.hashMode === "claude-settings-v2" || (source.hashMode === "claude-settings-v3" || source.hashMode === "claude-settings-v4" || (source.hashMode === "codex-settings-v1" || source.hashMode === "codex-settings-v2" || (source.hashMode === "codex-settings-v3" || source.hashMode === "codex-settings-v4")))) && source.path !== canonical8(configPath)))
21844
22210
  unresolved("retained settings witness names another configuration source");
21845
- const covered = supersedesSettingsProjection(agent, retained.sources, canonical7(configPath)) ? sources.filter((source) => !isSupersededSettingsProjection(agent, canonical7(configPath), source)) : sources;
22211
+ const covered = supersedesSettingsProjection(agent, retained.sources, canonical8(configPath)) ? sources.filter((source) => !isSupersededSettingsProjection(agent, canonical8(configPath), source)) : sources;
21846
22212
  if (covered.some((source) => !retained.sources.some((saved) => isDeepStrictEqual7(saved, source))) || [...roots].some((root2) => !retained.roots.includes(root2)) || agent === "gemini" && JSON.stringify(retained.builtinNames) !== JSON.stringify(builtinNames))
21847
22213
  unresolved("retained review is missing current runtime discovery coverage");
21848
22214
  return retained;
@@ -21854,16 +22220,16 @@ function resolveAgentDiscovery(options) {
21854
22220
  if (review.sources.some((source) => source.format !== undefined || source.fields !== undefined))
21855
22221
  throw new Error("Explicit discovery reviews require full source-file hashes");
21856
22222
  verifyAgentDiscovery(supplied);
21857
- if (review.sources.some((source) => (source.hashMode === "sumi-settings-v1" || source.hashMode === "claude-settings-v1" || source.hashMode === "claude-settings-v2" || (source.hashMode === "claude-settings-v3" || (source.hashMode === "codex-settings-v1" || source.hashMode === "codex-settings-v2" || (source.hashMode === "codex-settings-v3" || source.hashMode === "codex-settings-v4")))) && source.path !== canonical7(configPath)))
22223
+ if (review.sources.some((source) => (source.hashMode === "sumi-settings-v1" || source.hashMode === "claude-settings-v1" || source.hashMode === "claude-settings-v2" || (source.hashMode === "claude-settings-v3" || source.hashMode === "claude-settings-v4" || (source.hashMode === "codex-settings-v1" || source.hashMode === "codex-settings-v2" || (source.hashMode === "codex-settings-v3" || source.hashMode === "codex-settings-v4")))) && source.path !== canonical8(configPath)))
21858
22224
  throw new Error("Semantic settings witnesses must name the configured agent configuration source");
21859
- if (!review.sources.some((source) => source.path === canonical7(configPath)))
22225
+ if (!review.sources.some((source) => source.path === canonical8(configPath)))
21860
22226
  throw new Error("Discovery review must include the agent configuration source");
21861
- const reviewedSources = supersedesSettingsProjection(agent, review.sources, canonical7(configPath)) ? sources.filter((source) => !isSupersededSettingsProjection(agent, canonical7(configPath), source)) : sources;
22227
+ const reviewedSources = supersedesSettingsProjection(agent, review.sources, canonical8(configPath)) ? sources.filter((source) => !isSupersededSettingsProjection(agent, canonical8(configPath), source)) : sources;
21862
22228
  const reviewedSourcesWithManifestProjection = review.sources.map((source) => {
21863
- if (agent !== "claude" || source.format !== undefined || source.fields !== undefined || source.managedPlugins !== undefined || source.hashMode !== undefined && source.hashMode !== "bytes" || basename10(source.path) !== "plugin.json" || !source.path.endsWith(join32(sep8, ".claude-plugin", "plugin.json")))
22229
+ if (agent !== "claude" || source.sha256 === null || source.format !== undefined || source.fields !== undefined || source.managedPlugins !== undefined || source.hashMode !== undefined && source.hashMode !== "bytes" || basename11(source.path) !== "plugin.json" || !source.path.endsWith(join32(sep8, ".claude-plugin", "plugin.json")))
21864
22230
  return source;
21865
- const pluginRoot = dirname19(dirname19(source.path)), hooksPath = join32(pluginRoot, "hooks/hooks.json");
21866
- const hookStat = lstatSync24(hooksPath, { throwIfNoEntry: false });
22231
+ const pluginRoot = dirname20(dirname20(source.path)), hooksPath = join32(pluginRoot, "hooks/hooks.json");
22232
+ const hookStat = lstatSync25(hooksPath, { throwIfNoEntry: false });
21867
22233
  const text2 = read2(source.path);
21868
22234
  if (text2 === null)
21869
22235
  throw new Error("Reviewed Claude plugin manifest is missing");
@@ -21877,13 +22243,13 @@ function resolveAgentDiscovery(options) {
21877
22243
  if (manifest.hooks !== undefined) {
21878
22244
  if (typeof manifest.hooks !== "string")
21879
22245
  throw new Error("Reviewed Claude plugin manifest has an unsupported hooks target");
21880
- const declaredHookPath = resolve18(pluginRoot, manifest.hooks);
22246
+ const declaredHookPath = resolve20(pluginRoot, manifest.hooks);
21881
22247
  if (!declaredHookPath.startsWith(pluginRoot + sep8))
21882
22248
  throw new Error("Reviewed Claude plugin hooks target escapes its root");
21883
22249
  reviewedHookPaths.add(declaredHookPath);
21884
22250
  }
21885
22251
  for (const hooksFile of reviewedHookPaths)
21886
- if (!review.sources.some((hook) => hook.path === canonical7(hooksFile) && hook.sha256 !== null && hook.format === undefined && hook.fields === undefined && hook.managedPlugins === undefined && (hook.hashMode === undefined || hook.hashMode === "bytes")))
22252
+ if (!review.sources.some((hook) => hook.path === canonical8(hooksFile) && hook.sha256 !== null && hook.format === undefined && hook.fields === undefined && hook.managedPlugins === undefined && (hook.hashMode === undefined || hook.hashMode === "bytes")))
21887
22253
  throw new Error("Reviewed Claude plugin manifest requires separately reviewed exact hook file sources");
21888
22254
  return { path: source.path, sha256: manifestSha256, hashMode: "claude-plugin-manifest-v1" };
21889
22255
  });
@@ -21892,7 +22258,7 @@ function resolveAgentDiscovery(options) {
21892
22258
  return { ...supplied, roots: [...new Set([...roots, ...supplied.roots])].sort(), sources: unique, ...agent === "gemini" ? { builtinNames } : {} };
21893
22259
  }
21894
22260
  function plugin(root2) {
21895
- root2 = canonical7(root2);
22261
+ root2 = canonical8(root2);
21896
22262
  safe4(root2);
21897
22263
  const manifestPath = join32(root2, agent === "claude" ? ".claude-plugin/plugin.json" : ".codex-plugin/plugin.json");
21898
22264
  const raw = witness(manifestPath, undefined, undefined, agent === "claude" ? "claude-plugin-manifest-v1" : undefined);
@@ -21904,7 +22270,7 @@ function resolveAgentDiscovery(options) {
21904
22270
  unresolved("plugin hooks require a separate no-skill-injection review");
21905
22271
  const commands = join32(root2, "commands");
21906
22272
  safe4(commands);
21907
- if (agent === "claude" && (manifest.commands !== undefined || lstatSync24(commands, { throwIfNoEntry: false })?.isDirectory() && readdirSync10(commands).length))
22273
+ if (agent === "claude" && (manifest.commands !== undefined || lstatSync25(commands, { throwIfNoEntry: false })?.isDirectory() && readdirSync10(commands).length))
21908
22274
  unresolved("legacy command discovery requires retirement or a dedicated format adapter");
21909
22275
  const rootSkill = witness(join32(root2, "SKILL.md"));
21910
22276
  if (rootSkill !== null)
@@ -21915,18 +22281,18 @@ function resolveAgentDiscovery(options) {
21915
22281
  if (agent === "claude")
21916
22282
  roots.add(join32(root2, "skills"));
21917
22283
  for (const value of declared) {
21918
- const path = resolve18(root2, value);
22284
+ const path = resolve20(root2, value);
21919
22285
  if (path !== root2 && !path.startsWith(root2 + sep8))
21920
22286
  unresolved("plugin skill path escapes its root");
21921
- roots.add(path.endsWith(`${sep8}SKILL.md`) ? dirname19(path) : path);
22287
+ roots.add(path.endsWith(`${sep8}SKILL.md`) ? dirname20(path) : path);
21922
22288
  }
21923
22289
  }
21924
22290
  if (agent === "claude") {
21925
22291
  const registrations = witness(join32(home, ".claude/plugins/installed_plugins.json"));
21926
22292
  const installed = registrations === null ? {} : parseConfig(registrations, join32(home, ".claude/plugins/installed_plugins.json")).plugins;
21927
- const commands = canonical7(join32(home, ".claude/commands"));
22293
+ const commands = canonical8(join32(home, ".claude/commands"));
21928
22294
  safe4(commands);
21929
- if (lstatSync24(commands, { throwIfNoEntry: false })?.isDirectory() && readdirSync10(commands).length)
22295
+ if (lstatSync25(commands, { throwIfNoEntry: false })?.isDirectory() && readdirSync10(commands).length)
21930
22296
  unresolved("legacy home command discovery requires a dedicated format adapter");
21931
22297
  for (const [id, enabled] of Object.entries(config.enabledPlugins ?? {})) {
21932
22298
  if (enabled === false)
@@ -21946,7 +22312,7 @@ function resolveAgentDiscovery(options) {
21946
22312
  unresolved("unsupported plugin enablement");
21947
22313
  const split = id.lastIndexOf("@"), name = id.slice(0, split), marketplace = id.slice(split + 1);
21948
22314
  const market = config.marketplaces?.[marketplace] ?? (marketplace === "personal" ? { source_type: "local", source: home } : undefined);
21949
- if (split < 1 || market?.source_type !== "local" || typeof market.source !== "string" || !isAbsolute18(market.source))
22315
+ if (split < 1 || market?.source_type !== "local" || typeof market.source !== "string" || !isAbsolute21(market.source))
21950
22316
  unresolved("enabled plugin marketplace is not an explicit local source");
21951
22317
  const catalogText = witness(join32(market.source, ".agents/plugins/marketplace.json"));
21952
22318
  if (catalogText === null)
@@ -21954,7 +22320,7 @@ function resolveAgentDiscovery(options) {
21954
22320
  const catalog = parseConfig(catalogText, join32(market.source, ".agents/plugins/marketplace.json")), matches = Array.isArray(catalog.plugins) ? catalog.plugins.filter((item) => item.name === name) : [];
21955
22321
  if (matches.length !== 1 || matches[0]?.source?.source !== "local" || typeof matches[0]?.source?.path !== "string")
21956
22322
  unresolved("plugin catalog source is missing or ambiguous");
21957
- plugin(resolve18(market.source, matches[0].source.path));
22323
+ plugin(resolve20(market.source, matches[0].source.path));
21958
22324
  }
21959
22325
  } else if (agent === "opencode") {
21960
22326
  if (witness(join32(home, ".config/opencode/opencode.jsonc")) !== null || witness(join32(home, ".config/opencode/config.json")) !== null)
@@ -21962,21 +22328,21 @@ function resolveAgentDiscovery(options) {
21962
22328
  if ((config.plugin?.length ?? 0) > 0 || config.skills?.urls?.length)
21963
22329
  unresolved("external plugin or remote skill source");
21964
22330
  for (const path of config.skills?.paths ?? []) {
21965
- if (typeof path !== "string" || !isAbsolute18(path))
22331
+ if (typeof path !== "string" || !isAbsolute21(path))
21966
22332
  unresolved("relative or malformed added skill root");
21967
22333
  roots.add(path);
21968
22334
  }
21969
22335
  const localPlugins = join32(home, ".config/opencode/plugins");
21970
22336
  safe4(localPlugins);
21971
- if (lstatSync24(localPlugins, { throwIfNoEntry: false }) && readdirSync10(localPlugins).some((name) => name !== "skills-cli.js"))
22337
+ if (lstatSync25(localPlugins, { throwIfNoEntry: false }) && readdirSync10(localPlugins).some((name) => name !== "skills-cli.js"))
21972
22338
  unresolved("additional local plugin hooks require review");
21973
22339
  } else if (agent === "sumi") {
21974
- if ((config.plugin?.length ?? 0) > 0 || (config.plugins?.length ?? 0) > 0 || sources.some((source) => source.path !== canonical7(configPath) && source.path !== canonical7(join32(sumiConfigDirectory(home), "sumi.jsonc")) && source.sha256 !== null))
22340
+ if ((config.plugin?.length ?? 0) > 0 || (config.plugins?.length ?? 0) > 0 || sources.some((source) => source.path !== canonical8(configPath) && source.path !== canonical8(join32(sumiConfigDirectory(home), "sumi.jsonc")) && source.sha256 !== null))
21975
22341
  unresolved("external or foreign local plugins require review");
21976
22342
  } else if (agent === "hermes") {
21977
22343
  for (const directory of [join32(home, ".hermes/plugins"), join32(home, ".hermes/hermes-agent")]) {
21978
22344
  safe4(directory);
21979
- if (lstatSync24(directory, { throwIfNoEntry: false }))
22345
+ if (lstatSync25(directory, { throwIfNoEntry: false }))
21980
22346
  unresolved("installed runtime/plugin discovery requires reviewed source bindings");
21981
22347
  }
21982
22348
  if (Bun.which("hermes") || Object.keys(config.plugins ?? {}).length)
@@ -21986,11 +22352,11 @@ function resolveAgentDiscovery(options) {
21986
22352
  unresolved("custom extension or skill paths");
21987
22353
  const directory = join32(home, ".gemini/extensions");
21988
22354
  safe4(directory);
21989
- if (lstatSync24(directory, { throwIfNoEntry: false }))
22355
+ if (lstatSync25(directory, { throwIfNoEntry: false }))
21990
22356
  for (const name of readdirSync10(directory)) {
21991
22357
  const root2 = join32(directory, name);
21992
22358
  safe4(root2);
21993
- if (!lstatSync24(root2)?.isDirectory())
22359
+ if (!lstatSync25(root2)?.isDirectory())
21994
22360
  continue;
21995
22361
  const raw = witness(join32(root2, "gemini-extension.json"));
21996
22362
  if (raw === null)
@@ -22001,7 +22367,7 @@ function resolveAgentDiscovery(options) {
22001
22367
  roots.add(join32(root2, "skills"));
22002
22368
  }
22003
22369
  }
22004
- return { agent, roots: [...roots].sort(), sources, method: "automatic", ...agent === "gemini" ? { builtinNames } : {}, ...agent === "hermes" ? { directories: captureDiscoveryDirectories([join32(home, ".hermes/plugins"), join32(home, ".hermes/hermes-agent")].map((path) => canonical7(path))) } : {} };
22370
+ return { agent, roots: [...roots].sort(), sources, method: "automatic", ...agent === "gemini" ? { builtinNames } : {}, ...agent === "hermes" ? { directories: captureDiscoveryDirectories([join32(home, ".hermes/plugins"), join32(home, ".hermes/hermes-agent")].map((path) => canonical8(path))) } : {} };
22005
22371
  }
22006
22372
  var NATIVE_DISCOVERY_ROOTS = NATIVE_SKILL_ROOTS.map(([, path]) => path.split("/"));
22007
22373
  var OFFICIAL_SKILL_NAMES = new Set(SKILLS.map((skill) => skill.name));
@@ -25452,14 +25818,14 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
25452
25818
  const shape = zod.def.shape;
25453
25819
  const propValues = {};
25454
25820
  for (const key in shape) {
25455
- const field2 = shape[key]._zod;
25456
- if (field2.values) {
25821
+ const field3 = shape[key]._zod;
25822
+ if (field3.values) {
25457
25823
  if (!Object.prototype.hasOwnProperty.call(propValues, key)) {
25458
25824
  assignProp(propValues, key, new Set);
25459
25825
  }
25460
- for (const v of field2.values)
25826
+ for (const v of field3.values)
25461
25827
  propValues[key].add(v);
25462
- if (field2.optin !== undefined)
25828
+ if (field3.optin !== undefined)
25463
25829
  propValues[key].add(undefined);
25464
25830
  }
25465
25831
  }
@@ -26872,8 +27238,8 @@ function isRecursive(inst, stack) {
26872
27238
  return true;
26873
27239
  stack.add(inst);
26874
27240
  let result = false;
26875
- const check = (child) => {
26876
- if (!result && child?._zod && isRecursive(child, stack))
27241
+ const check = (child2) => {
27242
+ if (!result && child2?._zod && isRecursive(child2, stack))
26877
27243
  result = true;
26878
27244
  };
26879
27245
  const def = inst._zod.def;
@@ -37581,11 +37947,11 @@ var objectProcessor = (schema, ctx, _json, params) => {
37581
37947
  }
37582
37948
  const allKeys = new Set(Object.keys(shape));
37583
37949
  const requiredKeys = new Set([...allKeys].filter((key) => {
37584
- const field2 = def.shape[key];
37950
+ const field3 = def.shape[key];
37585
37951
  if (ctx.io === "input") {
37586
- return inputOptin(field2) === undefined;
37952
+ return inputOptin(field3) === undefined;
37587
37953
  } else {
37588
- return field2._zod.optout === undefined;
37954
+ return field3._zod.optout === undefined;
37589
37955
  }
37590
37956
  }));
37591
37957
  if (requiredKeys.size > 0) {
@@ -40979,7 +41345,7 @@ var hash3 = (v) => typeof v === "string" && /^[a-f0-9]{64}$/.test(v);
40979
41345
  var record9 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
40980
41346
  var exact = (v, keys) => record9(v) && Object.keys(v).sort().join(",") === keys.sort().join(",");
40981
41347
  var date5 = (v) => typeof v === "string" && /^\d{4}-\d\d-\d\dT[0-9:.]+(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/.test(v) && Number.isFinite(Date.parse(v));
40982
- var publicationSha256 = (bytes) => createHash27("sha256").update(bytes).digest("hex");
41348
+ var publicationSha256 = (bytes) => createHash29("sha256").update(bytes).digest("hex");
40983
41349
  function checkedPublicationDeclaration(value) {
40984
41350
  if (!exact(value, ["idempotencyKey", "version", "expectedCurrentVersionId", "manifestText", "archiveSha256", "archiveByteSize"]) || !publicationUuid(value.idempotencyKey) || !(value.expectedCurrentVersionId === null || publicationUuid(value.expectedCurrentVersionId)) || typeof value.version !== "string" || !value.version || value.version.length > 128 || /[\p{Cc}\p{Cs}]/u.test(value.version) || typeof value.manifestText !== "string" || Buffer.byteLength(value.manifestText) > 16384 || !hash3(value.archiveSha256) || !Number.isSafeInteger(value.archiveByteSize) || Number(value.archiveByteSize) < 1 || Number(value.archiveByteSize) > PRIVATE_PUBLICATION_MAX_BYTES)
40985
41351
  return bad();
@@ -41224,12 +41590,12 @@ class RemotePrivatePublicationsClient {
41224
41590
  previous = view;
41225
41591
  if (!["queued", "verifying"].includes(view.state) || Date.now() >= until)
41226
41592
  return view;
41227
- await new Promise((resolve21) => {
41593
+ await new Promise((resolve23) => {
41228
41594
  const timer = setTimeout(done, Math.min(1000, until - Date.now()));
41229
41595
  function done() {
41230
41596
  clearTimeout(timer);
41231
41597
  options.signal?.removeEventListener("abort", done);
41232
- resolve21();
41598
+ resolve23();
41233
41599
  }
41234
41600
  options.signal?.addEventListener("abort", done, { once: true });
41235
41601
  });
@@ -41265,7 +41631,7 @@ var stateSchema = exports_external2.object({
41265
41631
  var uuid13 = exports_external2.string().regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/);
41266
41632
  var context = { userId: uuid13.optional(), membershipId: uuid13.optional() };
41267
41633
  var page2 = { limit: exports_external2.number().int().min(1).max(100).optional(), cursor: exports_external2.string().min(1).max(2048).optional() };
41268
- var directory = exports_external2.string().max(4096).refine(isAbsolute20, "Use an absolute recovery directory");
41634
+ var directory = exports_external2.string().max(4096).refine(isAbsolute23, "Use an absolute recovery directory");
41269
41635
  var email4 = exports_external2.string().trim().toLowerCase().email().max(254);
41270
41636
  var code = exports_external2.string().regex(/^\d{6}$/);
41271
41637
  var recurringSurfaceSchemas = {
@@ -42394,6 +42760,8 @@ var STATION_SNAPSHOT_PRODUCER = { name: "@hasna/skills", version: package_defaul
42394
42760
  var STATION_HYDRATION_PRODUCER = { name: "@hasna/skills", version: package_default.version };
42395
42761
  var MANIFEST_HASH_KEY_SEP = String.fromCharCode(0);
42396
42762
  var SESSION_RECONCILIATION_PLAN_TTL_MS = 5 * 60 * 1000;
42763
+ var SESSION_RENEWAL_REFUSAL_TTL_MS = 5 * 60 * 1000;
42764
+ var SESSION_RENEWAL_REFUSAL_MAX_BYTES = 4 * 1024;
42397
42765
 
42398
42766
  // src/lib/claude-skills-coordination.ts
42399
42767
  class ClaudeSettingsRefusal extends Error {
@@ -42433,7 +42801,7 @@ function claudeSkillsUsage(before, home) {
42433
42801
  function skillsPolicyLocations(dataDir3) {
42434
42802
  const state = (path) => existsSync11(path) ? "present" : "absent";
42435
42803
  if (dataDir3 !== undefined)
42436
- return [`${join11(resolve8(dataDir3), "agent-policy.json")} (explicit data directory, absent)`];
42804
+ return [`${join11(resolve9(dataDir3), "agent-policy.json")} (explicit data directory, absent)`];
42437
42805
  const env = process.env, home = env.HOME || env.USERPROFILE || homedir6() || "/tmp", searched = [];
42438
42806
  let selected = false;
42439
42807
  for (const key of ["HASNA_SKILLS_DIR", "HASNA_SKILLS_HOME", "SKILLS_HOME"]) {
@@ -42444,7 +42812,7 @@ function skillsPolicyLocations(dataDir3) {
42444
42812
  searched.push(`$${key} (unset)`);
42445
42813
  else {
42446
42814
  selected = true;
42447
- searched.push(`$${key} -> ${join11(resolve8(value), "agent-policy.json")} (selected, absent)`);
42815
+ searched.push(`$${key} -> ${join11(resolve9(value), "agent-policy.json")} (selected, absent)`);
42448
42816
  }
42449
42817
  }
42450
42818
  const override = env.HASNA_DATA_HOME;
@@ -42470,7 +42838,7 @@ function planCoordinatedClaudeSettings(before, replacement, options) {
42470
42838
  const plan = planClaudeHookEventsUpdate({
42471
42839
  ...options,
42472
42840
  events: selected,
42473
- expectedSettingsSha256: before === null ? "absent" : createHash8("sha256").update(before).digest("hex"),
42841
+ expectedSettingsSha256: before === null ? "absent" : createHash9("sha256").update(before).digest("hex"),
42474
42842
  replacement
42475
42843
  });
42476
42844
  if (!plan) {
@@ -42490,7 +42858,7 @@ function coordinateClaudeSettings(before, replacement, options, beforeWrite) {
42490
42858
  }
42491
42859
 
42492
42860
  // src/lib/installer.ts
42493
- var __dirname2 = dirname8(fileURLToPath3(import.meta.url));
42861
+ var __dirname2 = dirname9(fileURLToPath3(import.meta.url));
42494
42862
  var HOOKS_DIR = existsSync12(join12(__dirname2, "..", "..", "hooks", "hook-gitguard")) ? join12(__dirname2, "..", "..", "hooks") : join12(__dirname2, "..", "hooks");
42495
42863
  function normalizeHookName(name) {
42496
42864
  return name.startsWith("hook-") ? name : `hook-${name}`;
@@ -42561,9 +42929,9 @@ function getTargetSettingsDir(target) {
42561
42929
  }
42562
42930
  function getGlobalSettingsPathOverride(target) {
42563
42931
  if (target === "codex")
42564
- return process.env.HASNA_HOOKS_CODEX_SETTINGS_PATH ?? (process.env.CODEX_HOME ? resolve19(process.env.CODEX_HOME, "hooks.json") : undefined);
42932
+ return process.env.HASNA_HOOKS_CODEX_SETTINGS_PATH ?? (process.env.CODEX_HOME ? resolve21(process.env.CODEX_HOME, "hooks.json") : undefined);
42565
42933
  if (target === "claude")
42566
- return process.env.HASNA_HOOKS_CLAUDE_SETTINGS_PATH ?? (process.env.CLAUDE_CONFIG_DIR ? resolve19(process.env.CLAUDE_CONFIG_DIR, "settings.json") : undefined);
42934
+ return process.env.HASNA_HOOKS_CLAUDE_SETTINGS_PATH ?? (process.env.CLAUDE_CONFIG_DIR ? resolve21(process.env.CLAUDE_CONFIG_DIR, "settings.json") : undefined);
42567
42935
  if (target === "gemini")
42568
42936
  return process.env.HASNA_HOOKS_GEMINI_SETTINGS_PATH;
42569
42937
  return;
@@ -42601,29 +42969,29 @@ function readSettings(scope = "global", target = "claude") {
42601
42969
  const path = getSettingsPath(scope, target);
42602
42970
  if (target === "codex")
42603
42971
  return readCodexSettings(path);
42604
- let reason = "cannot be read";
42972
+ let reason2 = "cannot be read";
42605
42973
  try {
42606
42974
  if (existsSync12(path)) {
42607
42975
  const text3 = readFileSync8(path, "utf-8");
42608
- reason = "is not valid JSON";
42976
+ reason2 = "is not valid JSON";
42609
42977
  const value = JSON.parse(text3);
42610
- reason = "does not hold a JSON object";
42978
+ reason2 = "does not hold a JSON object";
42611
42979
  if (!value || typeof value !== "object" || Array.isArray(value))
42612
- throw new TypeError(reason);
42980
+ throw new TypeError(reason2);
42613
42981
  settingsPreimages.set(value, { path, text: text3 });
42614
42982
  return value;
42615
42983
  }
42616
42984
  } catch (error61) {
42617
42985
  const code2 = error61?.code;
42618
- if (reason === "cannot be read" && typeof code2 === "string")
42619
- reason += ` (${code2})`;
42986
+ if (reason2 === "cannot be read" && typeof code2 === "string")
42987
+ reason2 += ` (${code2})`;
42620
42988
  console.warn("[hooks] Cannot read hook settings; repair the selected file before installation.");
42621
42989
  }
42622
42990
  const empty = {};
42623
42991
  if (!existsSync12(path))
42624
42992
  settingsPreimages.set(empty, { path, text: null });
42625
42993
  else
42626
- unreadableSettings.set(empty, { path, reason });
42994
+ unreadableSettings.set(empty, { path, reason: reason2 });
42627
42995
  return empty;
42628
42996
  }
42629
42997
  function unreadableSettingsRefusal(settings, path) {
@@ -42631,13 +42999,13 @@ function unreadableSettingsRefusal(settings, path) {
42631
42999
  if (captured?.path === path && captured.text !== null || !existsSync12(path))
42632
43000
  return;
42633
43001
  const failed = unreadableSettings.get(settings);
42634
- const reason = captured?.path === path ? "was created after Hooks read the settings" : failed?.path === path ? failed.reason : "was not read as a settings object";
42635
- return new ClaudeSettingsRefusal("settings_unreadable", `${path} ${reason}, so Hooks wrote nothing. Repair the file or move it aside, then retry.`);
43002
+ const reason2 = captured?.path === path ? "was created after Hooks read the settings" : failed?.path === path ? failed.reason : "was not read as a settings object";
43003
+ return new ClaudeSettingsRefusal("settings_unreadable", `${path} ${reason2}, so Hooks wrote nothing. Repair the file or move it aside, then retry.`);
42636
43004
  }
42637
43005
  function settingsIdentity(path) {
42638
43006
  if (existsSync12(path))
42639
- return realpathSync11(path);
42640
- return existsSync12(dirname8(path)) ? join12(realpathSync11(dirname8(path)), basename4(path)) : resolve19(path);
43007
+ return realpathSync9(path);
43008
+ return existsSync12(dirname9(path)) ? join12(realpathSync9(dirname9(path)), basename5(path)) : resolve21(path);
42641
43009
  }
42642
43010
  function coordinatesWithSkills(path, target) {
42643
43011
  return target === "claude" && settingsIdentity(path) === settingsIdentity(join12(homedir7(), ".claude/settings.json"));
@@ -42676,7 +43044,7 @@ function writeSettings(settings, scope = "global", target = "claude", expectedSe
42676
43044
  if (expectedSettingsSha256 !== undefined)
42677
43045
  return writeHookSettingsPreimage(path, settings, captured.text, beforeWrite);
42678
43046
  beforeWrite?.();
42679
- const dir = dirname8(path);
43047
+ const dir = dirname9(path);
42680
43048
  if (!existsSync12(dir)) {
42681
43049
  mkdirSync7(dir, { recursive: true });
42682
43050
  }
@@ -42783,7 +43151,7 @@ function readCodewithConfig(scope, configPath) {
42783
43151
  }
42784
43152
  function appendCodewithFragment(fragment, scope, configPath) {
42785
43153
  const path = getSettingsPath(scope, "codewith", configPath);
42786
- const dir = dirname8(path);
43154
+ const dir = dirname9(path);
42787
43155
  if (!existsSync12(dir))
42788
43156
  mkdirSync7(dir, { recursive: true });
42789
43157
  const existing = existsSync12(path) ? readFileSync8(path, "utf-8") : "";
@@ -43330,18 +43698,18 @@ function uninstallHook(name, scope = "global", target = "claude") {
43330
43698
  // src/index.ts
43331
43699
  init_profiles();
43332
43700
  init_config();
43333
- import { existsSync as existsSync17, readFileSync as readFileSync28 } from "fs";
43701
+ import { existsSync as existsSync17, readFileSync as readFileSync25 } from "fs";
43334
43702
 
43335
43703
  // src/lib/transport.ts
43336
43704
  init_transport();
43337
43705
  init_config();
43338
43706
  init_local_opt_in();
43339
43707
  var localNoticePrinted = false;
43340
- function announceLocal(notice, reason) {
43708
+ function announceLocal(notice, reason2) {
43341
43709
  if (localNoticePrinted)
43342
43710
  return;
43343
43711
  localNoticePrinted = true;
43344
- const line = `hooks: LOCAL mode \u2014 ${reason}; using the bundled registry and the local store at ` + `${getHooksDataDir()}, not a remote registry. Set HASNA_HOOKS_API_KEY (or the Keychain item ` + `hasna.credentials.hooks.api-key / ~/.hasna/hooks/config/credentials) to go remote.`;
43712
+ const line = `hooks: LOCAL mode \u2014 ${reason2}; using the bundled registry and the local store at ` + `${getHooksDataDir()}, not a remote registry. Set HASNA_HOOKS_API_KEY (or the Keychain item ` + `hasna.credentials.hooks.api-key / ~/.hasna/hooks/config/credentials) to go remote.`;
43345
43713
  if (notice)
43346
43714
  notice(line);
43347
43715
  else if (typeof process !== "undefined")
@@ -43470,7 +43838,7 @@ init_manifest();
43470
43838
  // src/lib/custom-install.ts
43471
43839
  init_config();
43472
43840
  init_manifest();
43473
- import { existsSync as existsSync14, mkdirSync as mkdirSync12, mkdtempSync, readFileSync as readFileSync15, rmSync as rmSync2 } from "fs";
43841
+ import { existsSync as existsSync14, mkdirSync as mkdirSync12, mkdtempSync, readFileSync as readFileSync14, rmSync as rmSync2 } from "fs";
43474
43842
  import { join as join16 } from "path";
43475
43843
  import { tmpdir } from "os";
43476
43844
  function manifestAt(dir) {
@@ -43478,7 +43846,7 @@ function manifestAt(dir) {
43478
43846
  if (!existsSync14(path))
43479
43847
  return;
43480
43848
  try {
43481
- return parseManifest(readFileSync15(path, "utf-8"));
43849
+ return parseManifest(readFileSync14(path, "utf-8"));
43482
43850
  } catch {
43483
43851
  return;
43484
43852
  }
@@ -43539,7 +43907,7 @@ async function installCustomSource(source) {
43539
43907
  throw new Error(`No such local path: ${source}`);
43540
43908
  }
43541
43909
  if (source.endsWith("manifest.json")) {
43542
- const manifest = parseManifest(readFileSync15(source, "utf-8"));
43910
+ const manifest = parseManifest(readFileSync14(source, "utf-8"));
43543
43911
  return writeFromManifest(manifest, source.substring(0, source.lastIndexOf("/")), source, "local");
43544
43912
  }
43545
43913
  return copyManifestDir(source, source, "local");
@@ -43569,16 +43937,16 @@ async function installManifestUrl(url2) {
43569
43937
  return { name, version: manifest.version, kind: "url", source: url2, dir, scriptPath };
43570
43938
  }
43571
43939
  // src/lib/sync.ts
43572
- import { createHash as createHash10 } from "crypto";
43573
- import { readFileSync as readFileSync17 } from "fs";
43940
+ import { createHash as createHash11 } from "crypto";
43941
+ import { readFileSync as readFileSync16 } from "fs";
43574
43942
  init_db();
43575
43943
  init_store();
43576
43944
  init_manifest();
43577
43945
  function sha256OfText(text3) {
43578
- return createHash10("sha256").update(text3).digest("hex");
43946
+ return createHash11("sha256").update(text3).digest("hex");
43579
43947
  }
43580
43948
  function sha256OfPath(path) {
43581
- return createHash10("sha256").update(readFileSync17(path)).digest("hex");
43949
+ return createHash11("sha256").update(readFileSync16(path)).digest("hex");
43582
43950
  }
43583
43951
  function collectBundledCatalog() {
43584
43952
  const out = [];
@@ -43879,8 +44247,8 @@ async function installPinnedFromBundled(name, version2) {
43879
44247
  // src/serve.ts
43880
44248
  init_manifest();
43881
44249
  init_store();
43882
- import { readFileSync as readFileSync18 } from "fs";
43883
- import { dirname as dirname20, join as join24 } from "path";
44250
+ import { readFileSync as readFileSync17 } from "fs";
44251
+ import { dirname as dirname21, join as join24 } from "path";
43884
44252
  import { fileURLToPath as fileURLToPath5 } from "url";
43885
44253
 
43886
44254
  // src/lib/secure-compare.ts
@@ -44255,8 +44623,8 @@ var SERVE_HOST = "127.0.0.1";
44255
44623
  var SERVE_SERVICE_NAME = "hooks-registry";
44256
44624
  function packageVersion() {
44257
44625
  try {
44258
- const pkgPath = join24(dirname20(fileURLToPath5(import.meta.url)), "..", "package.json");
44259
- return JSON.parse(readFileSync18(pkgPath, "utf-8")).version || "0.0.0";
44626
+ const pkgPath = join24(dirname21(fileURLToPath5(import.meta.url)), "..", "package.json");
44627
+ return JSON.parse(readFileSync17(pkgPath, "utf-8")).version || "0.0.0";
44260
44628
  } catch {
44261
44629
  return "0.0.0";
44262
44630
  }
@@ -44501,16 +44869,16 @@ async function provisionCloudflareResources(options) {
44501
44869
  return result;
44502
44870
  }
44503
44871
  // src/lib/codex-safety-trust.ts
44504
- import { createHash as createHash20, randomUUID as randomUUID4 } from "crypto";
44505
- import { constants as constants16, closeSync as closeSync17, fsyncSync as fsyncSync6, fstatSync as fstatSync16, lstatSync as lstatSync25, mkdirSync as mkdirSync14, openSync as openSync17, readFileSync as readFileSync25, realpathSync as realpathSync16, writeFileSync as writeFileSync11 } from "fs";
44506
- import { dirname as dirname24, isAbsolute as isAbsolute21, join as join27, relative as relative3 } from "path";
44872
+ import { createHash as createHash19, randomUUID as randomUUID4 } from "crypto";
44873
+ import { constants as constants15, closeSync as closeSync17, fsyncSync as fsyncSync4, fstatSync as fstatSync15, lstatSync as lstatSync21, mkdirSync as mkdirSync14, openSync as openSync17, readFileSync as readFileSync21, realpathSync as realpathSync16, writeFileSync as writeFileSync11 } from "fs";
44874
+ import { dirname as dirname25, isAbsolute as isAbsolute24, join as join27, relative as relative3 } from "path";
44507
44875
  import { homedir as homedir9 } from "os";
44508
44876
 
44509
44877
  // src/lib/codex-safety-check.ts
44510
44878
  import { spawn as spawn2, execFile as execFile2 } from "child_process";
44511
- import { createHash as createHash12 } from "crypto";
44512
- import { constants as constants14, openSync as openSync16, closeSync as closeSync16, fstatSync as fstatSync14, lstatSync as lstatSync20, readFileSync as readFileSync23, realpathSync as realpathSync15 } from "fs";
44513
- import { dirname as dirname23, isAbsolute as isAbsolute19, resolve as resolve23 } from "path";
44879
+ import { createHash as createHash13 } from "crypto";
44880
+ import { constants as constants10, openSync as openSync15, closeSync as closeSync15, fstatSync as fstatSync10, lstatSync as lstatSync19, readFileSync as readFileSync19, realpathSync as realpathSync15 } from "fs";
44881
+ import { dirname as dirname24, isAbsolute as isAbsolute15, resolve as resolve24 } from "path";
44514
44882
  import { promisify } from "util";
44515
44883
 
44516
44884
  // src/lib/native-child-env.ts
@@ -44557,35 +44925,35 @@ function nativeChildEnv(source, explicit = {}, inherit = () => false) {
44557
44925
 
44558
44926
  // src/native-safety.ts
44559
44927
  import { execFile } from "child_process";
44560
- import { closeSync as closeSync14, constants as constants5, existsSync as existsSync15, fstatSync as fstatSync6, fsyncSync, linkSync, lstatSync as lstatSync11, mkdirSync as mkdirSync13, openSync as openSync14, readFileSync as readFileSync20, realpathSync as realpathSync14, renameSync as renameSync4, unlinkSync as unlinkSync6, writeFileSync as writeFileSync10 } from "fs";
44928
+ import { closeSync as closeSync10, constants as constants5, existsSync as existsSync15, fstatSync as fstatSync6, fsyncSync, linkSync, lstatSync as lstatSync11, mkdirSync as mkdirSync13, openSync as openSync10, readFileSync as readFileSync18, realpathSync as realpathSync14, renameSync as renameSync4, unlinkSync as unlinkSync6, writeFileSync as writeFileSync10 } from "fs";
44561
44929
  import { homedir as homedir8 } from "os";
44562
- import { dirname as dirname22, isAbsolute as isAbsolute10, join as join26, resolve as resolve21 } from "path";
44930
+ import { dirname as dirname23, isAbsolute as isAbsolute11, join as join26, resolve as resolve23 } from "path";
44563
44931
  class NativeSafetyError extends Error {
44564
44932
  code;
44565
44933
  reason;
44566
- constructor(code2, reason) {
44934
+ constructor(code2, reason2) {
44567
44935
  super(`Native deletion safety refused (${code2}). Run the reviewed Hooks safety setup before using shell or patch tools.`);
44568
44936
  this.code = code2;
44569
- this.reason = reason;
44937
+ this.reason = reason2;
44570
44938
  this.name = "NativeSafetyError";
44571
44939
  }
44572
44940
  }
44573
44941
  var executionSchema = "hasna.hooks.execution.v1";
44574
44942
  var owner2 = (uid2) => uid2 === 0 || uid2 === process.getuid?.();
44575
44943
  function safeDirectory(path) {
44576
- for (let cursor = path;; cursor = dirname22(cursor)) {
44944
+ for (let cursor = path;; cursor = dirname23(cursor)) {
44577
44945
  const stat2 = lstatSync11(cursor);
44578
44946
  if (!stat2.isDirectory() || !owner2(stat2.uid) || stat2.mode & 18)
44579
44947
  throw new NativeSafetyError("binding_invalid");
44580
- if (dirname22(cursor) === cursor)
44948
+ if (dirname23(cursor) === cursor)
44581
44949
  return;
44582
44950
  }
44583
44951
  }
44584
44952
  function canonicalHome(home) {
44585
- if (!isAbsolute10(home) || home.includes("\x00") || realpathSync14(home) !== resolve21(home))
44953
+ if (!isAbsolute11(home) || home.includes("\x00") || realpathSync14(home) !== resolve23(home))
44586
44954
  throw new NativeSafetyError("binding_invalid");
44587
44955
  safeDirectory(home);
44588
- return resolve21(home);
44956
+ return resolve23(home);
44589
44957
  }
44590
44958
  function parseRecord(text3, home) {
44591
44959
  const record4 = JSON.parse(text3);
@@ -44597,21 +44965,21 @@ function parseRecord(text3, home) {
44597
44965
  return record4;
44598
44966
  }
44599
44967
  async function evaluateRecord(event, record4, signal, executionAgent) {
44600
- if (!event || event.hook_event_name !== "PreToolUse" || !["Bash", "apply_patch"].includes(event.tool_name) || typeof event.cwd !== "string" || !isAbsolute10(event.cwd) || !event.tool_input || typeof event.tool_input !== "object" || Array.isArray(event.tool_input))
44968
+ if (!event || event.hook_event_name !== "PreToolUse" || !["Bash", "apply_patch"].includes(event.tool_name) || typeof event.cwd !== "string" || !isAbsolute11(event.cwd) || !event.tool_input || typeof event.tool_input !== "object" || Array.isArray(event.tool_input))
44601
44969
  throw new NativeSafetyError("input_invalid");
44602
44970
  const input2 = JSON.stringify(executionAgent === undefined ? event : { ...event, hasna_execution: { schema: executionSchema, agent: executionAgent } });
44603
44971
  if (Buffer.byteLength(input2) > 1048576)
44604
44972
  throw new NativeSafetyError("input_invalid");
44605
44973
  const output2 = await new Promise((accept, reject) => {
44606
- const child = execFile("/bin/sh", ["-c", record4.command], { cwd: "/", env: {}, encoding: "utf8", timeout: 8000, maxBuffer: 1048576, signal }, (error61, stdout, stderr) => {
44974
+ const child2 = execFile("/bin/sh", ["-c", record4.command], { cwd: "/", env: {}, encoding: "utf8", timeout: 8000, maxBuffer: 1048576, signal }, (error61, stdout, stderr) => {
44607
44975
  if (error61 || stderr) {
44608
44976
  reject(new NativeSafetyError("guard_failed"));
44609
44977
  return;
44610
44978
  }
44611
44979
  accept(stdout);
44612
44980
  });
44613
- child.stdin?.on("error", () => {});
44614
- child.stdin?.end(input2);
44981
+ child2.stdin?.on("error", () => {});
44982
+ child2.stdin?.end(input2);
44615
44983
  });
44616
44984
  if (!output2)
44617
44985
  return { decision: "continue" };
@@ -44638,7 +45006,7 @@ async function verifyNativeSafetyCommand(command, home = homedir8()) {
44638
45006
  }
44639
45007
 
44640
45008
  // src/lib/codex-safety-check.ts
44641
- var SUPPORTED_CODEX_SAFETY_VERSIONS = ["codex-cli 0.153.0", "codex-cli 0.154.0", "codex-cli 0.154.0-alpha.6.1", "codex-cli 0.155.0", "codex-cli 0.155.1", "codex-cli 0.156.1", "codex-cli 0.157.0", "codex-cli 0.157.1", "codex-cli 0.158.0", "codex-cli 0.159.0", "codex-cli 0.159.2", "codex-cli 0.159.3", "codex-cli 0.160.0", "codex-cli 0.160.1"];
45009
+ var SUPPORTED_CODEX_SAFETY_VERSIONS = ["codex-cli 0.153.0", "codex-cli 0.154.0", "codex-cli 0.154.0-alpha.6.1", "codex-cli 0.155.0", "codex-cli 0.155.1", "codex-cli 0.156.1", "codex-cli 0.157.0", "codex-cli 0.157.1", "codex-cli 0.158.0", "codex-cli 0.159.0", "codex-cli 0.159.2", "codex-cli 0.159.3", "codex-cli 0.160.0", "codex-cli 0.160.1", "codex-cli 0.161.0"];
44642
45010
  var versions = new Set(SUPPORTED_CODEX_SAFETY_VERSIONS);
44643
45011
  var matcher = "^(Bash|apply_patch|ApplyPatch|functions\\.apply_patch)$";
44644
45012
 
@@ -44650,11 +45018,11 @@ class CodexSafetyError extends Error {
44650
45018
  this.name = "CodexSafetyError";
44651
45019
  }
44652
45020
  }
44653
- function need7(condition, code2) {
45021
+ function need8(condition, code2) {
44654
45022
  if (!condition)
44655
45023
  throw new CodexSafetyError(code2);
44656
45024
  }
44657
- var digest3 = (bytes) => createHash12("sha256").update(bytes).digest("hex");
45025
+ var digest3 = (bytes) => createHash13("sha256").update(bytes).digest("hex");
44658
45026
  function nativeHeader(bytes) {
44659
45027
  if (bytes.length < 64 || !["arm64", "x64"].includes(process.arch))
44660
45028
  return false;
@@ -44669,26 +45037,26 @@ function nativeHeader(bytes) {
44669
45037
  return false;
44670
45038
  }
44671
45039
  function executable2(command) {
44672
- const found = isAbsolute19(command) ? command : Bun.which(command);
44673
- need7(found, "native_unavailable");
45040
+ const found = isAbsolute15(command) ? command : Bun.which(command);
45041
+ need8(found, "native_unavailable");
44674
45042
  try {
44675
45043
  const path = realpathSync15(found);
44676
- for (let parent = dirname23(path);; parent = dirname23(parent)) {
44677
- const stat2 = lstatSync20(parent);
44678
- need7(stat2.isDirectory() && [0, process.getuid?.()].includes(stat2.uid) && !(stat2.mode & 18), "native_unsafe_executable");
44679
- if (parent === dirname23(parent))
45044
+ for (let parent = dirname24(path);; parent = dirname24(parent)) {
45045
+ const stat2 = lstatSync19(parent);
45046
+ need8(stat2.isDirectory() && [0, process.getuid?.()].includes(stat2.uid) && !(stat2.mode & 18), "native_unsafe_executable");
45047
+ if (parent === dirname24(parent))
44680
45048
  break;
44681
45049
  }
44682
- const fd = openSync16(path, constants14.O_RDONLY | constants14.O_NOFOLLOW | constants14.O_NONBLOCK);
45050
+ const fd = openSync15(path, constants10.O_RDONLY | constants10.O_NOFOLLOW | constants10.O_NONBLOCK);
44683
45051
  try {
44684
- const stat2 = fstatSync14(fd);
44685
- need7(stat2.isFile() && [0, process.getuid?.()].includes(stat2.uid) && !(stat2.mode & 18) && !!(stat2.mode & 64) && stat2.size <= 256000000, "native_unsafe_executable");
44686
- const bytes = readFileSync23(fd);
44687
- need7(bytes.length <= 256000000, "native_unavailable");
44688
- need7(nativeHeader(bytes), "native_executable_required");
45052
+ const stat2 = fstatSync10(fd);
45053
+ need8(stat2.isFile() && [0, process.getuid?.()].includes(stat2.uid) && !(stat2.mode & 18) && !!(stat2.mode & 64) && stat2.size <= 256000000, "native_unsafe_executable");
45054
+ const bytes = readFileSync19(fd);
45055
+ need8(bytes.length <= 256000000, "native_unavailable");
45056
+ need8(nativeHeader(bytes), "native_executable_required");
44689
45057
  return { path, sha256: digest3(bytes) };
44690
45058
  } finally {
44691
- closeSync16(fd);
45059
+ closeSync15(fd);
44692
45060
  }
44693
45061
  } catch (error61) {
44694
45062
  if (error61 instanceof CodexSafetyError)
@@ -44705,9 +45073,9 @@ async function connectCodexSafety(options) {
44705
45073
  } catch {
44706
45074
  throw new CodexSafetyError("native_unavailable");
44707
45075
  }
44708
- need7(versions.has(version2), "native_unsupported");
44709
- need7(JSON.stringify(executable2(command)) === JSON.stringify(before), "guard_changed");
44710
- const child = spawn2(before.path, ["app-server", "--strict-config", "--stdio"], { env, cwd: options.home, stdio: ["pipe", "pipe", "pipe"] });
45076
+ need8(versions.has(version2), "native_unsupported");
45077
+ need8(JSON.stringify(executable2(command)) === JSON.stringify(before), "guard_changed");
45078
+ const child2 = spawn2(before.path, ["app-server", "--strict-config", "--stdio"], { env, cwd: options.home, stdio: ["pipe", "pipe", "pipe"] });
44711
45079
  let stopped = false, buffer = Buffer.alloc(0), total = 0, nextId = 1;
44712
45080
  const pending = new Map;
44713
45081
  const fail2 = () => {
@@ -44718,34 +45086,34 @@ async function connectCodexSafety(options) {
44718
45086
  };
44719
45087
  const deadline = setTimeout(() => {
44720
45088
  fail2();
44721
- child.kill("SIGKILL");
45089
+ child2.kill("SIGKILL");
44722
45090
  }, 15000);
44723
45091
  const exited = new Promise((done) => {
44724
- child.once("exit", () => {
45092
+ child2.once("exit", () => {
44725
45093
  fail2();
44726
45094
  clearTimeout(deadline);
44727
45095
  done();
44728
45096
  });
44729
- child.once("error", () => {
45097
+ child2.once("error", () => {
44730
45098
  fail2();
44731
45099
  clearTimeout(deadline);
44732
45100
  done();
44733
45101
  });
44734
45102
  });
44735
- child.stdin.on("error", fail2);
45103
+ child2.stdin.on("error", fail2);
44736
45104
  const account = (length) => {
44737
45105
  total += length;
44738
45106
  if (total > 8388608) {
44739
45107
  fail2();
44740
- child.kill("SIGKILL");
45108
+ child2.kill("SIGKILL");
44741
45109
  return false;
44742
45110
  }
44743
45111
  return true;
44744
45112
  };
44745
- child.stderr.on("data", (bytes) => {
45113
+ child2.stderr.on("data", (bytes) => {
44746
45114
  account(bytes.length);
44747
45115
  });
44748
- child.stdout.on("data", (bytes) => {
45116
+ child2.stdout.on("data", (bytes) => {
44749
45117
  if (stopped || !account(bytes.length))
44750
45118
  return;
44751
45119
  buffer = Buffer.concat([buffer, bytes]);
@@ -44771,7 +45139,7 @@ async function connectCodexSafety(options) {
44771
45139
  waiter.resolve(value.result);
44772
45140
  } catch {
44773
45141
  fail2();
44774
- child.kill("SIGKILL");
45142
+ child2.kill("SIGKILL");
44775
45143
  return;
44776
45144
  }
44777
45145
  }
@@ -44783,7 +45151,7 @@ async function connectCodexSafety(options) {
44783
45151
  }
44784
45152
  const id = nextId++;
44785
45153
  pending.set(id, { resolve: accept, reject });
44786
- child.stdin.write(JSON.stringify({ id, method, params }) + `
45154
+ child2.stdin.write(JSON.stringify({ id, method, params }) + `
44787
45155
  `);
44788
45156
  });
44789
45157
  const rpc = {
@@ -44791,17 +45159,17 @@ async function connectCodexSafety(options) {
44791
45159
  request,
44792
45160
  async close() {
44793
45161
  fail2();
44794
- child.stdin.end();
44795
- const force = setTimeout(() => child.kill("SIGKILL"), 1000);
45162
+ child2.stdin.end();
45163
+ const force = setTimeout(() => child2.kill("SIGKILL"), 1000);
44796
45164
  await exited;
44797
45165
  clearTimeout(force);
44798
45166
  clearTimeout(deadline);
44799
- need7(JSON.stringify(executable2(command)) === JSON.stringify(before), "guard_changed");
45167
+ need8(JSON.stringify(executable2(command)) === JSON.stringify(before), "guard_changed");
44800
45168
  }
44801
45169
  };
44802
45170
  try {
44803
45171
  await request("initialize", { clientInfo: { name: "hooks-safety-check", version: "1" }, capabilities: { experimentalApi: true } });
44804
- child.stdin.write(`{"method":"initialized"}
45172
+ child2.stdin.write(`{"method":"initialized"}
44805
45173
  `);
44806
45174
  return rpc;
44807
45175
  } catch {
@@ -44818,9 +45186,9 @@ function supportedDiscoveryWarnings(hooks, warnings) {
44818
45186
  const sources = new Set(hooks.map((hook) => JSON.stringify([hook?.source, hook?.sourcePath])));
44819
45187
  for (const hook of hooks) {
44820
45188
  const path = hook?.sourcePath;
44821
- if (typeof path !== "string" || path.length > 4096 || !isAbsolute19(path) || path !== resolve23(dirname23(path), "hooks.json") || !["user", "project"].includes(hook.source))
45189
+ if (typeof path !== "string" || path.length > 4096 || !isAbsolute15(path) || path !== resolve24(dirname24(path), "hooks.json") || !["user", "project"].includes(hook.source))
44822
45190
  continue;
44823
- const toml = resolve23(dirname23(path), "config.toml");
45191
+ const toml = resolve24(dirname24(path), "config.toml");
44824
45192
  if (sources.has(JSON.stringify([hook.source, toml]))) {
44825
45193
  allowed.add(`loading hooks from both ${path} and ${toml}; prefer a single representation for this layer`);
44826
45194
  }
@@ -44829,32 +45197,32 @@ function supportedDiscoveryWarnings(hooks, warnings) {
44829
45197
  }
44830
45198
  function selectCodexSafety(discovery, configuration, home, cwd, featureEnabled, requireReady = true, readiness = false) {
44831
45199
  const data = discovery?.data;
44832
- need7(Array.isArray(data) && data.length === 1 && data[0]?.cwd === cwd && Array.isArray(data[0]?.hooks) && data[0].hooks.length <= 1e4 && Array.isArray(data[0].errors) && data[0].errors.length === 0 && Array.isArray(data[0].warnings) && supportedDiscoveryWarnings(data[0].hooks, data[0].warnings), "native_discovery_failed");
45200
+ need8(Array.isArray(data) && data.length === 1 && data[0]?.cwd === cwd && Array.isArray(data[0]?.hooks) && data[0].hooks.length <= 1e4 && Array.isArray(data[0].errors) && data[0].errors.length === 0 && Array.isArray(data[0].warnings) && supportedDiscoveryWarnings(data[0].hooks, data[0].warnings), "native_discovery_failed");
44833
45201
  const config2 = configuration?.config;
44834
- need7(config2 && typeof config2 === "object" && !Array.isArray(config2), "native_discovery_failed");
44835
- need7((config2.features?.hooks ?? featureEnabled) === true, "hooks_disabled");
45202
+ need8(config2 && typeof config2 === "object" && !Array.isArray(config2), "native_discovery_failed");
45203
+ need8((config2.features?.hooks ?? featureEnabled) === true, "hooks_disabled");
44836
45204
  for (const hook2 of data[0].hooks)
44837
45205
  if (typeof hook2?.command === "string") {
44838
45206
  if (/\bhasna-native-safety-v\d+\b/.test(hook2.command))
44839
- need7(nativeSafetyCommandBinding(hook2.command), "guard_definition_invalid");
44840
- need7(!/^(?:hooks run trash-guard|hook-trash-guard)(?:\s|$)/.test(hook2.command.trim()), "guard_definition_invalid");
45207
+ need8(nativeSafetyCommandBinding(hook2.command), "guard_definition_invalid");
45208
+ need8(!/^(?:hooks run trash-guard|hook-trash-guard)(?:\s|$)/.test(hook2.command.trim()), "guard_definition_invalid");
44841
45209
  if (readiness && hook2.command.includes("hasna-native-readiness-v"))
44842
- need7(nativeReadinessCommandBinding(hook2.command), "guard_definition_invalid");
45210
+ need8(nativeReadinessCommandBinding(hook2.command), "guard_definition_invalid");
44843
45211
  }
44844
45212
  const selected = data[0].hooks.filter((hook2) => typeof hook2?.command === "string" && (readiness ? !!nativeReadinessCommandBinding(hook2.command) : nativeSafetyCommandBinding(hook2.command)?.name === "trash-guard"));
44845
- need7(selected.length !== 0, "guard_missing");
44846
- need7(selected.length === 1, "guard_ambiguous");
45213
+ need8(selected.length !== 0, "guard_missing");
45214
+ need8(selected.length === 1, "guard_ambiguous");
44847
45215
  const hook = selected[0], binding = readiness ? nativeReadinessCommandBinding(hook.command) : nativeSafetyCommandBinding(hook.command);
44848
- need7(binding.home === home && (!readiness || binding?.provider === "codex") && hook.eventName === (readiness ? "sessionStart" : "preToolUse") && hook.handlerType === "command" && hook.matcher === (readiness ? "^(startup|resume|clear|fork)$" : matcher) && hook.timeoutSec === (readiness ? TRASH_READINESS_NATIVE_TIMEOUT_SECONDS : 10) && hook.async === false && hook.statusMessage === null && hook.additionalContextLimit === null && typeof hook.key === "string" && hook.key.length <= 4096 && typeof hook.sourcePath === "string" && isAbsolute19(hook.sourcePath) && hook.pluginId === null && hook.isManaged === false && ["user", "project"].includes(hook.source) && typeof hook.currentHash === "string" && /^sha256:[a-f0-9]{64}$/.test(hook.currentHash), "guard_definition_invalid");
44849
- need7(typeof hook.enabled === "boolean" && ["trusted", "untrusted", "modified"].includes(hook.trustStatus), "guard_definition_invalid");
45216
+ need8(binding.home === home && (!readiness || binding?.provider === "codex") && hook.eventName === (readiness ? "sessionStart" : "preToolUse") && hook.handlerType === "command" && hook.matcher === (readiness ? "^(startup|resume|clear|fork)$" : matcher) && hook.timeoutSec === (readiness ? TRASH_READINESS_NATIVE_TIMEOUT_SECONDS : 10) && hook.async === false && hook.statusMessage === null && hook.additionalContextLimit === null && typeof hook.key === "string" && hook.key.length <= 4096 && typeof hook.sourcePath === "string" && isAbsolute15(hook.sourcePath) && hook.pluginId === null && hook.isManaged === false && ["user", "project"].includes(hook.source) && typeof hook.currentHash === "string" && /^sha256:[a-f0-9]{64}$/.test(hook.currentHash), "guard_definition_invalid");
45217
+ need8(typeof hook.enabled === "boolean" && ["trusted", "untrusted", "modified"].includes(hook.trustStatus), "guard_definition_invalid");
44850
45218
  if (requireReady) {
44851
- need7(hook.enabled === true, "guard_disabled");
44852
- need7(hook.trustStatus === "trusted", "guard_untrusted");
45219
+ need8(hook.enabled === true, "guard_disabled");
45220
+ need8(hook.trustStatus === "trusted", "guard_untrusted");
44853
45221
  }
44854
45222
  return { key: hook.key, command: hook.command, currentHash: hook.currentHash, sourcePath: hook.sourcePath, enabled: hook.enabled, trustStatus: hook.trustStatus };
44855
45223
  }
44856
45224
  async function readCodexSafety(rpc, home, cwd, options = {}) {
44857
- need7(versions.has(rpc.version), "native_unsupported");
45225
+ need8(versions.has(rpc.version), "native_unsupported");
44858
45226
  const hooks = await rpc.request("hooks/list", { cwds: [cwd] });
44859
45227
  const configuration = await rpc.request("config/read", { cwd, includeLayers: options.includeLayers ?? false });
44860
45228
  let enabled;
@@ -44863,17 +45231,17 @@ async function readCodexSafety(rpc, home, cwd, options = {}) {
44863
45231
  const seen = new Set;
44864
45232
  do {
44865
45233
  const page3 = await rpc.request("experimentalFeature/list", { cursor, limit: 100 });
44866
- need7(Array.isArray(page3?.data) && page3.data.length <= 100 && (page3.nextCursor === null || typeof page3.nextCursor === "string"), "native_discovery_failed");
45234
+ need8(Array.isArray(page3?.data) && page3.data.length <= 100 && (page3.nextCursor === null || typeof page3.nextCursor === "string"), "native_discovery_failed");
44867
45235
  count += page3.data.length;
44868
- need7(count <= 1000, "native_discovery_failed");
45236
+ need8(count <= 1000, "native_discovery_failed");
44869
45237
  for (const feature of page3.data)
44870
45238
  if (feature?.name === "hooks") {
44871
- need7(enabled === undefined && typeof feature.enabled === "boolean", "native_discovery_failed");
45239
+ need8(enabled === undefined && typeof feature.enabled === "boolean", "native_discovery_failed");
44872
45240
  enabled = feature.enabled;
44873
45241
  }
44874
45242
  cursor = page3.nextCursor;
44875
45243
  if (cursor !== null) {
44876
- need7(cursor.length > 0 && cursor.length <= 4096 && !seen.has(cursor) && page3.data.length > 0, "native_discovery_failed");
45244
+ need8(cursor.length > 0 && cursor.length <= 4096 && !seen.has(cursor) && page3.data.length > 0, "native_discovery_failed");
44877
45245
  seen.add(cursor);
44878
45246
  }
44879
45247
  } while (cursor !== null);
@@ -44894,16 +45262,16 @@ class CodexTrustError extends Error {
44894
45262
  this.name = "CodexTrustError";
44895
45263
  }
44896
45264
  }
44897
- function need9(value, code2 = "native_changed") {
45265
+ function need10(value, code2 = "native_changed") {
44898
45266
  if (!value)
44899
45267
  throw new CodexTrustError(code2);
44900
45268
  }
44901
- var sha6 = (value) => createHash20("sha256").update(value).digest("hex");
44902
- function canonical7(value) {
45269
+ var sha6 = (value) => createHash19("sha256").update(value).digest("hex");
45270
+ function canonical8(value) {
44903
45271
  if (Array.isArray(value))
44904
- return "[" + value.map(canonical7).join(",") + "]";
45272
+ return "[" + value.map(canonical8).join(",") + "]";
44905
45273
  if (value !== null && typeof value === "object")
44906
- return "{" + Object.keys(value).sort().map((key) => JSON.stringify(key) + ":" + canonical7(value[key])).join(",") + "}";
45274
+ return "{" + Object.keys(value).sort().map((key) => JSON.stringify(key) + ":" + canonical8(value[key])).join(",") + "}";
44907
45275
  return JSON.stringify(value);
44908
45276
  }
44909
45277
  function mergedConfiguration(value) {
@@ -44927,63 +45295,63 @@ function mergedConfiguration(value) {
44927
45295
  copy.hooks[event] = [];
44928
45296
  }
44929
45297
  }
44930
- return canonical7(copy);
45298
+ return canonical8(copy);
44931
45299
  }
44932
45300
  function safeDirectory2(path) {
44933
- for (let p = path;; p = dirname24(p)) {
44934
- const s = lstatSync25(p);
44935
- need9(s.isDirectory() && [0, process.getuid?.()].includes(s.uid) && !(s.mode & 18), "preimage_unsafe");
44936
- if (dirname24(p) === p)
45301
+ for (let p = path;; p = dirname25(p)) {
45302
+ const s = lstatSync21(p);
45303
+ need10(s.isDirectory() && [0, process.getuid?.()].includes(s.uid) && !(s.mode & 18), "preimage_unsafe");
45304
+ if (dirname25(p) === p)
44937
45305
  return;
44938
45306
  }
44939
45307
  }
44940
45308
  function readPrivate(path) {
44941
- safeDirectory2(dirname24(path));
44942
- const fd = openSync17(path, constants16.O_RDONLY | constants16.O_NOFOLLOW | constants16.O_NONBLOCK);
45309
+ safeDirectory2(dirname25(path));
45310
+ const fd = openSync17(path, constants15.O_RDONLY | constants15.O_NOFOLLOW | constants15.O_NONBLOCK);
44943
45311
  try {
44944
- const s = fstatSync16(fd);
44945
- need9(s.isFile() && s.uid === process.getuid?.() && !(s.mode & 63) && s.size <= 4194304, "preimage_unsafe");
44946
- const bytes = readFileSync25(fd);
44947
- need9(bytes.length <= 4194304, "preimage_unsafe");
45312
+ const s = fstatSync15(fd);
45313
+ need10(s.isFile() && s.uid === process.getuid?.() && !(s.mode & 63) && s.size <= 4194304, "preimage_unsafe");
45314
+ const bytes = readFileSync21(fd);
45315
+ need10(bytes.length <= 4194304, "preimage_unsafe");
44948
45316
  return bytes;
44949
45317
  } finally {
44950
45318
  closeSync17(fd);
44951
45319
  }
44952
45320
  }
44953
45321
  function syncDirectory(path) {
44954
- const fd = openSync17(path, constants16.O_RDONLY | constants16.O_DIRECTORY | constants16.O_NOFOLLOW);
45322
+ const fd = openSync17(path, constants15.O_RDONLY | constants15.O_DIRECTORY | constants15.O_NOFOLLOW);
44955
45323
  try {
44956
- fsyncSync6(fd);
45324
+ fsyncSync4(fd);
44957
45325
  } finally {
44958
45326
  closeSync17(fd);
44959
45327
  }
44960
45328
  }
44961
45329
  function exclusive(path, bytes) {
44962
- const fd = openSync17(path, constants16.O_CREAT | constants16.O_EXCL | constants16.O_WRONLY | constants16.O_NOFOLLOW, 384);
45330
+ const fd = openSync17(path, constants15.O_CREAT | constants15.O_EXCL | constants15.O_WRONLY | constants15.O_NOFOLLOW, 384);
44963
45331
  try {
44964
45332
  writeFileSync11(fd, bytes);
44965
- fsyncSync6(fd);
45333
+ fsyncSync4(fd);
44966
45334
  } finally {
44967
45335
  closeSync17(fd);
44968
45336
  }
44969
- syncDirectory(dirname24(path));
45337
+ syncDirectory(dirname25(path));
44970
45338
  }
44971
45339
  async function inspect(rpc, home, cwd, readiness = false) {
44972
45340
  const observed = await readCodexSafety(rpc, home, cwd, { includeLayers: true, requireReady: false, readiness });
44973
45341
  const { guard, configuration, discovery } = observed;
44974
45342
  const layers = configuration?.layers;
44975
- need9(Array.isArray(layers) && layers.length <= 1000, "native_config_invalid");
45343
+ need10(Array.isArray(layers) && layers.length <= 1000, "native_config_invalid");
44976
45344
  const userLayers = layers.filter((layer2) => layer2?.name?.type === "user" && layer2.name.profile === null);
44977
- need9(userLayers.length === 1, "native_config_invalid");
45345
+ need10(userLayers.length === 1, "native_config_invalid");
44978
45346
  const layer = userLayers[0], path = layer.name.file;
44979
- need9(typeof path === "string" && isAbsolute21(path) && typeof layer.version === "string" && /^sha256:[a-f0-9]{64}$/.test(layer.version), "native_config_invalid");
45347
+ need10(typeof path === "string" && isAbsolute24(path) && typeof layer.version === "string" && /^sha256:[a-f0-9]{64}$/.test(layer.version), "native_config_invalid");
44980
45348
  const canonicalPath2 = realpathSync16(path), inside = relative3(home, canonicalPath2);
44981
- need9(inside !== "" && !inside.startsWith("..") && !isAbsolute21(inside), "native_config_invalid");
45349
+ need10(inside !== "" && !inside.startsWith("..") && !isAbsolute24(inside), "native_config_invalid");
44982
45350
  const definition = discovery.data[0].hooks.find((h) => h.key === guard.key);
44983
- need9(definition.source === "user", "native_config_invalid");
45351
+ need10(definition.source === "user", "native_config_invalid");
44984
45352
  const before = readPrivate(canonicalPath2);
44985
45353
  const rawState = layer.config?.hooks?.state?.[guard.key];
44986
- need9(rawState === undefined || rawState && typeof rawState === "object" && !Array.isArray(rawState), "native_config_invalid");
45354
+ need10(rawState === undefined || rawState && typeof rawState === "object" && !Array.isArray(rawState), "native_config_invalid");
44987
45355
  const desired = { ...rawState, enabled: true, trusted_hash: guard.currentHash };
44988
45356
  const planBase = {
44989
45357
  schema: readiness ? "hasna.hooks.codex-readiness-trust/v1" : "hasna.hooks.codex-safety-trust/v1",
@@ -44998,17 +45366,17 @@ async function inspect(rpc, home, cwd, readiness = false) {
44998
45366
  ...readiness ? { readinessRunnerVerified: true } : {},
44999
45367
  nativeAdoptionVerified: false
45000
45368
  };
45001
- const plan = { ...planBase, planDigest: sha6(canonical7({ planBase, configuration, discovery, raw: sha6(before) })) };
45369
+ const plan = { ...planBase, planDigest: sha6(canonical8({ planBase, configuration, discovery, raw: sha6(before) })) };
45002
45370
  return { ...observed, layer, layers, canonicalPath: canonicalPath2, before, desired, plan };
45003
45371
  }
45004
45372
  async function context2(options, dependencies) {
45005
45373
  const home = realpathSync16(options.home ?? homedir9()), cwd = realpathSync16(options.cwd ?? process.cwd());
45006
- need9(isAbsolute21(home) && isAbsolute21(cwd), "input_invalid");
45374
+ need10(isAbsolute24(home) && isAbsolute24(cwd), "input_invalid");
45007
45375
  return { home, cwd, rpc: await (dependencies.connect ?? connectCodexSafety)({ ...options, home }) };
45008
45376
  }
45009
45377
  async function verify(command, home, readiness, dependencies) {
45010
45378
  if (readiness)
45011
- need9(nativeReadinessCommandVerified(command));
45379
+ need10(nativeReadinessCommandVerified(command));
45012
45380
  else
45013
45381
  await (dependencies.verify ?? verifyNativeSafetyCommand)(command, home);
45014
45382
  }
@@ -45017,21 +45385,21 @@ async function planTrust(options = {}, dependencies = {}) {
45017
45385
  try {
45018
45386
  const before = await inspect(rpc, home, cwd, options.readiness);
45019
45387
  await verify(before.guard.command, home, !!options.readiness, dependencies);
45020
- need9((await inspect(rpc, home, cwd, options.readiness)).plan.planDigest === before.plan.planDigest);
45388
+ need10((await inspect(rpc, home, cwd, options.readiness)).plan.planDigest === before.plan.planDigest);
45021
45389
  return before.plan;
45022
45390
  } finally {
45023
45391
  await rpc.close();
45024
45392
  }
45025
45393
  }
45026
45394
  async function applyTrust(options, dependencies = {}) {
45027
- need9(/^[a-f0-9]{64}$/.test(options.expectedPlanDigest), "input_invalid");
45395
+ need10(/^[a-f0-9]{64}$/.test(options.expectedPlanDigest), "input_invalid");
45028
45396
  const selected = { ...options }, { home, cwd, rpc } = await context2(selected, dependencies);
45029
45397
  let operationId, journal, requested = false;
45030
45398
  try {
45031
45399
  const before = await inspect(rpc, home, cwd, selected.readiness);
45032
- need9(before.plan.planDigest === selected.expectedPlanDigest);
45400
+ need10(before.plan.planDigest === selected.expectedPlanDigest);
45033
45401
  await verify(before.guard.command, home, !!selected.readiness, dependencies);
45034
- need9((await inspect(rpc, home, cwd, selected.readiness)).plan.planDigest === before.plan.planDigest);
45402
+ need10((await inspect(rpc, home, cwd, selected.readiness)).plan.planDigest === before.plan.planDigest);
45035
45403
  if (before.plan.action === "unchanged")
45036
45404
  return { ok: true, changed: false, ...before.plan };
45037
45405
  const expectedConfiguration = structuredClone(before.configuration);
@@ -45051,7 +45419,7 @@ async function applyTrust(options, dependencies = {}) {
45051
45419
  directory2 = join27(directory2, part);
45052
45420
  try {
45053
45421
  mkdirSync14(directory2, { mode: 448 });
45054
- syncDirectory(dirname24(directory2));
45422
+ syncDirectory(dirname25(directory2));
45055
45423
  } catch (error61) {
45056
45424
  if (error61.code !== "EEXIST")
45057
45425
  throw error61;
@@ -45062,7 +45430,7 @@ async function applyTrust(options, dependencies = {}) {
45062
45430
  exclusive(join27(directory2, "intent.json"), JSON.stringify({ operationId, plan: before.plan, configSHA256: sha6(before.before) }) + `
45063
45431
  `);
45064
45432
  journal = directory2;
45065
- need9(sha6(readPrivate(before.canonicalPath)) === sha6(before.before));
45433
+ need10(sha6(readPrivate(before.canonicalPath)) === sha6(before.before));
45066
45434
  requested = true;
45067
45435
  const result = await rpc.request("config/batchWrite", {
45068
45436
  filePath: before.plan.configPath,
@@ -45070,10 +45438,10 @@ async function applyTrust(options, dependencies = {}) {
45070
45438
  reloadUserConfig: true,
45071
45439
  edits: [{ keyPath: "hooks.state." + JSON.stringify(before.guard.key), value: before.desired, mergeStrategy: "replace" }]
45072
45440
  });
45073
- need9(result?.status === "ok" && result.filePath === before.plan.configPath && result.overriddenMetadata === null && /^sha256:[a-f0-9]{64}$/.test(result.version));
45441
+ need10(result?.status === "ok" && result.filePath === before.plan.configPath && result.overriddenMetadata === null && /^sha256:[a-f0-9]{64}$/.test(result.version));
45074
45442
  const after = await inspect(rpc, home, cwd, selected.readiness);
45075
45443
  expectedLayer.version = result.version;
45076
- need9(after.layer.version === result.version && after.plan.action === "unchanged" && mergedConfiguration(after.configuration.config) === mergedConfiguration(expectedConfiguration.config) && canonical7(after.configuration.layers) === canonical7(expectedConfiguration.layers) && canonical7(after.discovery) === canonical7(expectedDiscovery));
45444
+ need10(after.layer.version === result.version && after.plan.action === "unchanged" && mergedConfiguration(after.configuration.config) === mergedConfiguration(expectedConfiguration.config) && canonical8(after.configuration.layers) === canonical8(expectedConfiguration.layers) && canonical8(after.discovery) === canonical8(expectedDiscovery));
45077
45445
  const receipt = {
45078
45446
  ok: true,
45079
45447
  changed: true,
@@ -45112,9 +45480,9 @@ async function applyTrust(options, dependencies = {}) {
45112
45480
  var planCodexSafetyTrust = (options = {}, dependencies = {}) => planTrust({ ...options, readiness: false }, dependencies);
45113
45481
  var applyCodexSafetyTrust = (options, dependencies = {}) => applyTrust({ ...options, readiness: false }, dependencies);
45114
45482
  // src/lib/claude-safety-check.ts
45115
- import { constants as constants17, closeSync as closeSync18, fstatSync as fstatSync17, lstatSync as lstatSync27, openSync as openSync18, readFileSync as readFileSync26, realpathSync as realpathSync17 } from "fs";
45116
- import { createHash as createHash24 } from "crypto";
45117
- import { dirname as dirname25, isAbsolute as isAbsolute23, join as join28, resolve as resolve25 } from "path";
45483
+ import { constants as constants17, closeSync as closeSync18, fstatSync as fstatSync17, lstatSync as lstatSync26, openSync as openSync18, readFileSync as readFileSync23, realpathSync as realpathSync17 } from "fs";
45484
+ import { createHash as createHash26 } from "crypto";
45485
+ import { dirname as dirname26, isAbsolute as isAbsolute26, join as join28, resolve as resolve25 } from "path";
45118
45486
  import { homedir as homedir10 } from "os";
45119
45487
  class ClaudeSafetyError extends Error {
45120
45488
  code;
@@ -45124,26 +45492,26 @@ class ClaudeSafetyError extends Error {
45124
45492
  this.name = "ClaudeSafetyError";
45125
45493
  }
45126
45494
  }
45127
- function need10(value, code2) {
45495
+ function need11(value, code2) {
45128
45496
  if (!value)
45129
45497
  throw new ClaudeSafetyError(code2);
45130
45498
  }
45131
- var sha8 = (value) => createHash24("sha256").update(value).digest("hex");
45499
+ var sha8 = (value) => createHash26("sha256").update(value).digest("hex");
45132
45500
  function read3(path) {
45133
45501
  try {
45134
45502
  const resolved = realpathSync17(path);
45135
- for (let parent = dirname25(resolved);; parent = dirname25(parent)) {
45136
- const s = lstatSync27(parent);
45137
- need10(s.isDirectory() && [0, process.getuid?.()].includes(s.uid) && !(s.mode & 18), "settings_unsafe");
45138
- if (dirname25(parent) === parent)
45503
+ for (let parent = dirname26(resolved);; parent = dirname26(parent)) {
45504
+ const s = lstatSync26(parent);
45505
+ need11(s.isDirectory() && [0, process.getuid?.()].includes(s.uid) && !(s.mode & 18), "settings_unsafe");
45506
+ if (dirname26(parent) === parent)
45139
45507
  break;
45140
45508
  }
45141
45509
  const fd = openSync18(resolved, constants17.O_RDONLY | constants17.O_NOFOLLOW | constants17.O_NONBLOCK);
45142
45510
  try {
45143
45511
  const s = fstatSync17(fd);
45144
- need10(s.isFile() && [0, process.getuid?.()].includes(s.uid) && !(s.mode & 18) && s.size <= 1048576, "settings_unsafe");
45145
- const raw = readFileSync26(fd, "utf8");
45146
- need10(Buffer.byteLength(raw) <= 1048576, "settings_unsafe");
45512
+ need11(s.isFile() && [0, process.getuid?.()].includes(s.uid) && !(s.mode & 18) && s.size <= 1048576, "settings_unsafe");
45513
+ const raw = readFileSync23(fd, "utf8");
45514
+ need11(Buffer.byteLength(raw) <= 1048576, "settings_unsafe");
45147
45515
  return { path, resolved, sha256: sha8(raw), raw };
45148
45516
  } finally {
45149
45517
  closeSync18(fd);
@@ -45163,7 +45531,7 @@ async function verifyClaudeSafetyConfiguration(options = {}, dependencies = {})
45163
45531
  join28(cwd, ".claude/settings.json"),
45164
45532
  options.localSettingsPath ?? join28(cwd, ".claude/settings.local.json")
45165
45533
  ];
45166
- need10(paths.every((path) => isAbsolute23(path) && resolve25(path) === path), "settings_unsafe");
45534
+ need11(paths.every((path) => isAbsolute26(path) && resolve25(path) === path), "settings_unsafe");
45167
45535
  const inspect2 = () => [...new Set(paths)].map(read3);
45168
45536
  const before = inspect2(), unique = [...new Map(before.filter((file2) => file2.resolved !== null).map((file2) => [file2.resolved, file2])).values()];
45169
45537
  const guards = [];
@@ -45174,40 +45542,40 @@ async function verifyClaudeSafetyConfiguration(options = {}, dependencies = {})
45174
45542
  } catch {
45175
45543
  throw new ClaudeSafetyError("settings_invalid");
45176
45544
  }
45177
- need10(settings && typeof settings === "object" && !Array.isArray(settings), "settings_invalid");
45178
- need10(settings.disableAllHooks === undefined || settings.disableAllHooks === false, "hooks_disabled");
45545
+ need11(settings && typeof settings === "object" && !Array.isArray(settings), "settings_invalid");
45546
+ need11(settings.disableAllHooks === undefined || settings.disableAllHooks === false, "hooks_disabled");
45179
45547
  if (settings.hooks === undefined)
45180
45548
  continue;
45181
- need10(settings.hooks && typeof settings.hooks === "object" && !Array.isArray(settings.hooks), "settings_invalid");
45549
+ need11(settings.hooks && typeof settings.hooks === "object" && !Array.isArray(settings.hooks), "settings_invalid");
45182
45550
  let count = 0;
45183
45551
  for (const [event, groups] of Object.entries(settings.hooks)) {
45184
- need10(Array.isArray(groups), "settings_invalid");
45552
+ need11(Array.isArray(groups), "settings_invalid");
45185
45553
  for (const group of groups) {
45186
- need10(group && Array.isArray(group.hooks), "settings_invalid");
45554
+ need11(group && Array.isArray(group.hooks), "settings_invalid");
45187
45555
  for (const handler of group.hooks) {
45188
- need10(++count <= 1e4 && handler && typeof handler === "object", "settings_invalid");
45556
+ need11(++count <= 1e4 && handler && typeof handler === "object", "settings_invalid");
45189
45557
  if (typeof handler.command !== "string")
45190
45558
  continue;
45191
45559
  const binding = nativeSafetyCommandBinding(handler.command);
45192
45560
  if (/\bhasna-native-safety-v\d+\b/.test(handler.command))
45193
- need10(binding, "guard_definition_invalid");
45194
- need10(!/^(?:hooks run trash-guard|hook-trash-guard)(?:\s|$)/.test(handler.command.trim()), "guard_definition_invalid");
45561
+ need11(binding, "guard_definition_invalid");
45562
+ need11(!/^(?:hooks run trash-guard|hook-trash-guard)(?:\s|$)/.test(handler.command.trim()), "guard_definition_invalid");
45195
45563
  if (binding?.name !== "trash-guard")
45196
45564
  continue;
45197
- need10(binding.home === home && event === "PreToolUse" && handler.type === "command" && group.matcher === CLAUDE_TRASH_GUARD_MATCHER && handler.timeout === 10 && (handler.async === undefined || handler.async === false) && handler.asyncRewake !== true, "guard_definition_invalid");
45565
+ need11(binding.home === home && event === "PreToolUse" && handler.type === "command" && group.matcher === CLAUDE_TRASH_GUARD_MATCHER && handler.timeout === 10 && (handler.async === undefined || handler.async === false) && handler.asyncRewake !== true, "guard_definition_invalid");
45198
45566
  guards.push({ command: handler.command, path: file2.path });
45199
45567
  }
45200
45568
  }
45201
45569
  }
45202
45570
  }
45203
- need10(guards.length !== 0, "guard_missing");
45204
- need10(guards.length === 1, "guard_ambiguous");
45571
+ need11(guards.length !== 0, "guard_missing");
45572
+ need11(guards.length === 1, "guard_ambiguous");
45205
45573
  try {
45206
45574
  await (dependencies.verify ?? verifyNativeSafetyCommand)(guards[0].command, home);
45207
45575
  } catch {
45208
45576
  throw new ClaudeSafetyError("guard_failed");
45209
45577
  }
45210
- need10(JSON.stringify(inspect2()) === JSON.stringify(before), "settings_changed");
45578
+ need11(JSON.stringify(inspect2()) === JSON.stringify(before), "settings_changed");
45211
45579
  return {
45212
45580
  ok: true,
45213
45581
  target: "claude",
@@ -45222,9 +45590,9 @@ async function verifyClaudeSafetyConfiguration(options = {}, dependencies = {})
45222
45590
  };
45223
45591
  }
45224
45592
  // src/lib/native-safety-registration.ts
45225
- import { createHash as createHash26, randomUUID as randomUUID6 } from "crypto";
45226
- import { constants as constants18, closeSync as closeSync19, fstatSync as fstatSync18, fsyncSync as fsyncSync8, lstatSync as lstatSync28, mkdirSync as mkdirSync15, openSync as openSync19, readFileSync as readFileSync27, realpathSync as realpathSync18, writeFileSync as writeFileSync12 } from "fs";
45227
- import { basename as basename11, dirname as dirname26, isAbsolute as isAbsolute25, join as join33, relative as relative7, resolve as resolve26 } from "path";
45593
+ import { createHash as createHash28, randomUUID as randomUUID6 } from "crypto";
45594
+ import { constants as constants18, closeSync as closeSync19, fstatSync as fstatSync18, fsyncSync as fsyncSync7, lstatSync as lstatSync28, mkdirSync as mkdirSync15, openSync as openSync19, readFileSync as readFileSync24, realpathSync as realpathSync18, writeFileSync as writeFileSync12 } from "fs";
45595
+ import { basename as basename12, dirname as dirname27, isAbsolute as isAbsolute27, join as join33, relative as relative7, resolve as resolve26 } from "path";
45228
45596
  import { homedir as homedir11 } from "os";
45229
45597
  class NativeRegistrationError extends Error {
45230
45598
  code;
@@ -45238,23 +45606,23 @@ class NativeRegistrationError extends Error {
45238
45606
  this.name = "NativeRegistrationError";
45239
45607
  }
45240
45608
  }
45241
- var need11 = (value, code2) => {
45609
+ var need12 = (value, code2) => {
45242
45610
  if (!value)
45243
45611
  throw new NativeRegistrationError(code2);
45244
45612
  };
45245
- var sha9 = (value) => createHash26("sha256").update(value).digest("hex");
45246
- function canonical9(value) {
45613
+ var sha9 = (value) => createHash28("sha256").update(value).digest("hex");
45614
+ function canonical10(value) {
45247
45615
  if (Array.isArray(value))
45248
- return "[" + value.map(canonical9).join(",") + "]";
45616
+ return "[" + value.map(canonical10).join(",") + "]";
45249
45617
  if (value !== null && typeof value === "object")
45250
- return "{" + Object.keys(value).sort().map((key) => JSON.stringify(key) + ":" + canonical9(value[key])).join(",") + "}";
45618
+ return "{" + Object.keys(value).sort().map((key) => JSON.stringify(key) + ":" + canonical10(value[key])).join(",") + "}";
45251
45619
  return JSON.stringify(value);
45252
45620
  }
45253
45621
  function safeDirectory3(path) {
45254
- for (let p = path;; p = dirname26(p)) {
45622
+ for (let p = path;; p = dirname27(p)) {
45255
45623
  const s = lstatSync28(p);
45256
- need11(s.isDirectory() && [0, process.getuid?.()].includes(s.uid) && !(s.mode & 18), "settings_unsafe");
45257
- if (dirname26(p) === p)
45624
+ need12(s.isDirectory() && [0, process.getuid?.()].includes(s.uid) && !(s.mode & 18), "settings_unsafe");
45625
+ if (dirname27(p) === p)
45258
45626
  return;
45259
45627
  }
45260
45628
  }
@@ -45272,14 +45640,14 @@ function read5(path) {
45272
45640
  if (missing2.code !== "ENOENT")
45273
45641
  throw missing2;
45274
45642
  }
45275
- let ancestor = dirname26(path);
45276
- const suffix = [basename11(path)];
45643
+ let ancestor = dirname27(path);
45644
+ const suffix = [basename12(path)];
45277
45645
  for (;; ) {
45278
45646
  try {
45279
45647
  resolved = join33(realpathSync18(ancestor), ...suffix);
45280
45648
  break;
45281
45649
  } catch (missing2) {
45282
- if (missing2.code !== "ENOENT" || dirname26(ancestor) === ancestor || suffix.length >= 64)
45650
+ if (missing2.code !== "ENOENT" || dirname27(ancestor) === ancestor || suffix.length >= 64)
45283
45651
  throw new NativeRegistrationError("settings_unsafe");
45284
45652
  try {
45285
45653
  lstatSync28(ancestor);
@@ -45288,14 +45656,14 @@ function read5(path) {
45288
45656
  if (absent.code !== "ENOENT")
45289
45657
  throw absent;
45290
45658
  }
45291
- suffix.unshift(basename11(ancestor));
45292
- ancestor = dirname26(ancestor);
45659
+ suffix.unshift(basename12(ancestor));
45660
+ ancestor = dirname27(ancestor);
45293
45661
  }
45294
45662
  }
45295
45663
  safeDirectory3(realpathSync18(ancestor));
45296
45664
  return { resolved, raw: null, sha256: "absent" };
45297
45665
  }
45298
- safeDirectory3(dirname26(resolved));
45666
+ safeDirectory3(dirname27(resolved));
45299
45667
  let fd;
45300
45668
  try {
45301
45669
  fd = openSync19(resolved, constants18.O_RDONLY | constants18.O_NOFOLLOW | constants18.O_NONBLOCK);
@@ -45306,11 +45674,11 @@ function read5(path) {
45306
45674
  }
45307
45675
  try {
45308
45676
  const s = fstatSync18(fd);
45309
- need11(s.isFile() && s.uid === process.getuid?.() && !(s.mode & 18) && s.nlink === 1 && s.size <= 1048576, "settings_unsafe");
45310
- const bytes = readFileSync27(fd);
45311
- need11(bytes.length <= 1048576, "settings_unsafe");
45677
+ need12(s.isFile() && s.uid === process.getuid?.() && !(s.mode & 18) && s.nlink === 1 && s.size <= 1048576, "settings_unsafe");
45678
+ const bytes = readFileSync24(fd);
45679
+ need12(bytes.length <= 1048576, "settings_unsafe");
45312
45680
  const raw = bytes.toString("utf8");
45313
- need11(Buffer.from(raw).equals(bytes), "settings_invalid");
45681
+ need12(Buffer.from(raw).equals(bytes), "settings_invalid");
45314
45682
  return { resolved, raw, sha256: sha9(bytes) };
45315
45683
  } finally {
45316
45684
  closeSync19(fd);
@@ -45321,7 +45689,7 @@ function assertLosslessJson(raw) {
45321
45689
  const stack = [];
45322
45690
  function decimal(text3) {
45323
45691
  const match = /^(-?)([0-9]+)(?:\.([0-9]+))?(?:[eE]([+-]?[0-9]+))?$/.exec(text3);
45324
- need11((match[4]?.replace(/^[+-]/, "").length ?? 0) <= 6, "settings_invalid");
45692
+ need12((match[4]?.replace(/^[+-]/, "").length ?? 0) <= 6, "settings_invalid");
45325
45693
  let digits = (match[2] + (match[3] ?? "")).replace(/^0+/, "");
45326
45694
  if (!digits)
45327
45695
  return match[1] ? "-0" : "0";
@@ -45344,12 +45712,12 @@ function assertLosslessJson(raw) {
45344
45712
  current2.key = true;
45345
45713
  else if (token.startsWith('"') && current2?.kind === "object" && current2.key) {
45346
45714
  const key = JSON.parse(token);
45347
- need11(!current2.names.has(key), "settings_invalid");
45715
+ need12(!current2.names.has(key), "settings_invalid");
45348
45716
  current2.names.add(key);
45349
45717
  current2.key = false;
45350
45718
  } else if (/^-?[0-9]/.test(token)) {
45351
45719
  const parsed = Number(token);
45352
- need11(Number.isFinite(parsed) && decimal(token) === decimal(JSON.stringify(parsed)), "settings_invalid");
45720
+ need12(Number.isFinite(parsed) && decimal(token) === decimal(JSON.stringify(parsed)), "settings_invalid");
45353
45721
  }
45354
45722
  }
45355
45723
  }
@@ -45360,19 +45728,19 @@ function validateSettings(raw) {
45360
45728
  } catch {
45361
45729
  throw new NativeRegistrationError("settings_invalid");
45362
45730
  }
45363
- need11(settings && typeof settings === "object" && !Array.isArray(settings), "settings_invalid");
45731
+ need12(settings && typeof settings === "object" && !Array.isArray(settings), "settings_invalid");
45364
45732
  assertLosslessJson(raw ?? "{}");
45365
- need11(settings.disableAllHooks === undefined || settings.disableAllHooks === false, "hooks_disabled");
45733
+ need12(settings.disableAllHooks === undefined || settings.disableAllHooks === false, "hooks_disabled");
45366
45734
  if (settings.hooks !== undefined) {
45367
- need11(settings.hooks && typeof settings.hooks === "object" && !Array.isArray(settings.hooks), "settings_invalid");
45735
+ need12(settings.hooks && typeof settings.hooks === "object" && !Array.isArray(settings.hooks), "settings_invalid");
45368
45736
  for (const groups of Object.values(settings.hooks)) {
45369
- need11(Array.isArray(groups), "settings_invalid");
45737
+ need12(Array.isArray(groups), "settings_invalid");
45370
45738
  for (const group of groups) {
45371
- need11(group && Array.isArray(group.hooks), "settings_invalid");
45739
+ need12(group && Array.isArray(group.hooks), "settings_invalid");
45372
45740
  for (const hook of group.hooks) {
45373
- need11(hook && typeof hook === "object", "settings_invalid");
45741
+ need12(hook && typeof hook === "object", "settings_invalid");
45374
45742
  if (["trash-guard", "trash-readiness"].includes(registrationName(hook.command) ?? "")) {
45375
- need11((hook.async === undefined || hook.async === false) && hook.asyncRewake !== true, "registration_conflict");
45743
+ need12((hook.async === undefined || hook.async === false) && hook.asyncRewake !== true, "registration_conflict");
45376
45744
  }
45377
45745
  }
45378
45746
  }
@@ -45381,17 +45749,17 @@ function validateSettings(raw) {
45381
45749
  return settings;
45382
45750
  }
45383
45751
  function inspect2(options) {
45384
- need11(options?.target === "codex" || options?.target === "claude", "input_invalid");
45752
+ need12(options?.target === "codex" || options?.target === "claude", "input_invalid");
45385
45753
  const home = realpathSync18(homedir11()), path = getSettingsPath("global", options.target);
45386
- need11(isAbsolute25(path) && resolve26(path) === path, "input_invalid");
45754
+ need12(isAbsolute27(path) && resolve26(path) === path, "input_invalid");
45387
45755
  const nativeHome = options.target === "codex" ? process.env.CODEX_HOME : process.env.CLAUDE_CONFIG_DIR;
45388
45756
  if (nativeHome !== undefined) {
45389
- need11(nativeHome.length > 0 && isAbsolute25(nativeHome), "input_invalid");
45757
+ need12(nativeHome.length > 0 && isAbsolute27(nativeHome), "input_invalid");
45390
45758
  const selectedNative = read5(resolve26(nativeHome, options.target === "codex" ? "hooks.json" : "settings.json"));
45391
- need11(read5(path).resolved === selectedNative.resolved, "input_invalid");
45759
+ need12(read5(path).resolved === selectedNative.resolved, "input_invalid");
45392
45760
  }
45393
45761
  const before = read5(path), inside = relative7(home, before.resolved);
45394
- need11(inside !== "" && !inside.startsWith("..") && !isAbsolute25(inside), "settings_unsafe");
45762
+ need12(inside !== "" && !inside.startsWith("..") && !isAbsolute27(inside), "settings_unsafe");
45395
45763
  const parsed = validateSettings(before.raw);
45396
45764
  let preview2;
45397
45765
  try {
@@ -45399,9 +45767,9 @@ function inspect2(options) {
45399
45767
  } catch {
45400
45768
  throw new NativeRegistrationError("registration_conflict");
45401
45769
  }
45402
- need11(preview2.before === before.raw, "settings_changed");
45770
+ need12(preview2.before === before.raw, "settings_changed");
45403
45771
  validateSettings(preview2.after);
45404
- const changed = canonical9(parsed) !== canonical9(JSON.parse(preview2.after));
45772
+ const changed = canonical10(parsed) !== canonical10(JSON.parse(preview2.after));
45405
45773
  const base = {
45406
45774
  schema: options.readiness ? "hasna.hooks.native-readiness-registration/v1" : "hasna.hooks.native-safety-registration/v1",
45407
45775
  target: options.target,
@@ -45415,14 +45783,14 @@ function inspect2(options) {
45415
45783
  ...options.readiness ? { readinessRunnerVerified: true } : {},
45416
45784
  nativeAdoptionVerified: false
45417
45785
  };
45418
- const plan = { ...base, planDigest: sha9(canonical9(base)) };
45419
- need11(canonical9(read5(path)) === canonical9(before), "settings_changed");
45786
+ const plan = { ...base, planDigest: sha9(canonical10(base)) };
45787
+ need12(canonical10(read5(path)) === canonical10(before), "settings_changed");
45420
45788
  return { home, before, preview: preview2, plan };
45421
45789
  }
45422
45790
  function syncDirectory2(path) {
45423
45791
  const fd = openSync19(path, constants18.O_RDONLY | constants18.O_DIRECTORY | constants18.O_NOFOLLOW);
45424
45792
  try {
45425
- fsyncSync8(fd);
45793
+ fsyncSync7(fd);
45426
45794
  } finally {
45427
45795
  closeSync19(fd);
45428
45796
  }
@@ -45431,11 +45799,11 @@ function exclusive2(path, bytes) {
45431
45799
  const fd = openSync19(path, constants18.O_CREAT | constants18.O_EXCL | constants18.O_WRONLY | constants18.O_NOFOLLOW, 384);
45432
45800
  try {
45433
45801
  writeFileSync12(fd, bytes);
45434
- fsyncSync8(fd);
45802
+ fsyncSync7(fd);
45435
45803
  } finally {
45436
45804
  closeSync19(fd);
45437
45805
  }
45438
- syncDirectory2(dirname26(path));
45806
+ syncDirectory2(dirname27(path));
45439
45807
  }
45440
45808
  function refusalOf(error61) {
45441
45809
  const code2 = error61?.code;
@@ -45464,7 +45832,7 @@ async function planRegistration(options, dependencies = {}) {
45464
45832
  const selected = { ...options }, before = inspect2(selected);
45465
45833
  try {
45466
45834
  if (selected.readiness)
45467
- need11(nativeReadinessCommandVerified(before.preview.command), "guard_failed");
45835
+ need12(nativeReadinessCommandVerified(before.preview.command), "guard_failed");
45468
45836
  else
45469
45837
  await (dependencies.verify ?? verifyNativeSafetyCommand)(before.preview.command, before.home);
45470
45838
  } catch {
@@ -45472,16 +45840,16 @@ async function planRegistration(options, dependencies = {}) {
45472
45840
  }
45473
45841
  if (before.plan.action === "register")
45474
45842
  assertWriterAccepts(selected, before.preview);
45475
- need11(inspect2(selected).plan.planDigest === before.plan.planDigest, "settings_changed");
45843
+ need12(inspect2(selected).plan.planDigest === before.plan.planDigest, "settings_changed");
45476
45844
  return before.plan;
45477
45845
  }
45478
45846
  async function applyRegistration(options, dependencies = {}) {
45479
45847
  const selected = { ...options };
45480
- need11(/^[a-f0-9]{64}$/.test(selected.expectedPlanDigest), "input_invalid");
45848
+ need12(/^[a-f0-9]{64}$/.test(selected.expectedPlanDigest), "input_invalid");
45481
45849
  const plan = await planRegistration(selected, dependencies);
45482
- need11(plan.planDigest === selected.expectedPlanDigest, "settings_changed");
45850
+ need12(plan.planDigest === selected.expectedPlanDigest, "settings_changed");
45483
45851
  const before = inspect2(selected);
45484
- need11(before.plan.planDigest === plan.planDigest, "settings_changed");
45852
+ need12(before.plan.planDigest === plan.planDigest, "settings_changed");
45485
45853
  if (plan.action === "unchanged")
45486
45854
  return { ok: true, changed: false, ...plan };
45487
45855
  const operationId = randomUUID6();
@@ -45490,7 +45858,7 @@ async function applyRegistration(options, dependencies = {}) {
45490
45858
  directory2 = join33(directory2, part);
45491
45859
  try {
45492
45860
  mkdirSync15(directory2, { mode: 448 });
45493
- syncDirectory2(dirname26(directory2));
45861
+ syncDirectory2(dirname27(directory2));
45494
45862
  } catch (error61) {
45495
45863
  if (error61.code !== "EEXIST")
45496
45864
  throw new NativeRegistrationError("settings_unsafe");
@@ -45506,7 +45874,7 @@ async function applyRegistration(options, dependencies = {}) {
45506
45874
  writeMayHaveStarted = true;
45507
45875
  };
45508
45876
  try {
45509
- need11(inspect2(selected).plan.planDigest === plan.planDigest, "settings_changed");
45877
+ need12(inspect2(selected).plan.planDigest === plan.planDigest, "settings_changed");
45510
45878
  if (selected.readiness)
45511
45879
  installNativeReadinessRegistration(selected.target, plan.beforeSHA256, beforeWrite);
45512
45880
  else {
@@ -45516,7 +45884,7 @@ async function applyRegistration(options, dependencies = {}) {
45516
45884
  }
45517
45885
  writeMayHaveStarted = true;
45518
45886
  const after = inspect2(selected);
45519
- need11(after.before.sha256 === plan.desiredSHA256 && after.plan.resolvedPath === plan.resolvedPath && after.plan.action === "unchanged" && after.plan.commandSHA256 === plan.commandSHA256, "apply_outcome_uncertain");
45887
+ need12(after.before.sha256 === plan.desiredSHA256 && after.plan.resolvedPath === plan.resolvedPath && after.plan.action === "unchanged" && after.plan.commandSHA256 === plan.commandSHA256, "apply_outcome_uncertain");
45520
45888
  const receipt = {
45521
45889
  ok: true,
45522
45890
  changed: true,
@@ -45564,7 +45932,7 @@ async function runHook(name, input2, options = {}) {
45564
45932
  if (!script)
45565
45933
  throw new Error(`Hook script not found: ${name}`);
45566
45934
  const { sha256Of: sha256Of2, checkScriptHash: checkScriptHash2 } = await Promise.resolve().then(() => (init_store(), exports_store));
45567
- const content = readFileSync28(script);
45935
+ const content = readFileSync25(script);
45568
45936
  const check2 = checkScriptHash2(name, sha256Of2(content));
45569
45937
  if (!check2.ok) {
45570
45938
  throw new Error(`Hook '${name}' script changed since it was trusted (sha256 ${check2.expected} != ${check2.actual}). Run 'hooks trust ${name}' to trust the new content.`);