@jigging/jig 0.1.0-alpha.29 → 0.1.0-alpha.33

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.
@@ -7580,7 +7580,7 @@ function readRecord(directory, name) {
7580
7580
  const parent = privateDirectory(directory);
7581
7581
  let fd;
7582
7582
  try {
7583
- fd = openSync(join(directory, name), constants.O_RDONLY | O_NOFOLLOW_ANY | O_CLOEXEC);
7583
+ fd = openSync(join(directory, name), constants.O_RDONLY | constants.O_NONBLOCK | O_NOFOLLOW_ANY | O_CLOEXEC);
7584
7584
  const before = fstatSync(fd, { bigint: true });
7585
7585
  if (!before.isFile() || before.uid !== BigInt(process.getuid?.() ?? -1) || (before.mode & 0o177n) !== 0n || before.nlink !== 1n || before.size < 1n || before.size > 1024n)
7586
7586
  throw new Error("macOS ownership journal is unsafe");
@@ -9075,19 +9075,19 @@ var init_file_input = __esm(() => {
9075
9075
 
9076
9076
  // src/installed-cli.ts
9077
9077
  import { realpath as realpath25 } from "fs/promises";
9078
- import { dirname as dirname19 } from "path";
9078
+ import { dirname as dirname20 } from "path";
9079
9079
  import { fileURLToPath as fileURLToPath5 } from "url";
9080
9080
 
9081
9081
  // src/cli.ts
9082
9082
  import { randomBytes as randomBytes7 } from "crypto";
9083
- import { lstat as lstat19 } from "fs/promises";
9084
- import { basename as basename5, resolve as resolve11 } from "path";
9083
+ import { lstat as lstat20 } from "fs/promises";
9084
+ import { basename as basename6, resolve as resolve11 } from "path";
9085
9085
  import { createInterface } from "readline";
9086
9086
  import { setTimeout as delay } from "timers/promises";
9087
9087
  // package.json
9088
9088
  var package_default = {
9089
9089
  name: "@jigging/jig",
9090
- version: "0.1.0-alpha.29",
9090
+ version: "0.1.0-alpha.33",
9091
9091
  description: "A local, secure host for admitted FLOW packages",
9092
9092
  license: "SEE LICENSE IN LICENSE.md",
9093
9093
  repository: {
@@ -15554,6 +15554,16 @@ function snapshotJson(value, label, active = new WeakSet) {
15554
15554
  }
15555
15555
  }
15556
15556
 
15557
+ // src/internal/native-agent-turn-policy.ts
15558
+ var PRIVATE_NATIVE_TURN_POLICY = Object.freeze({
15559
+ default: 1,
15560
+ minimum: 1,
15561
+ maximum: 8
15562
+ });
15563
+ function isPrivateNativeTurnAllowance(value) {
15564
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= PRIVATE_NATIVE_TURN_POLICY.minimum && value <= PRIVATE_NATIVE_TURN_POLICY.maximum;
15565
+ }
15566
+
15557
15567
  // src/project/commands.ts
15558
15568
  function projectCommandPath(value) {
15559
15569
  if (typeof value !== "string" || value.length > 256 || !/^[A-Za-z0-9_][A-Za-z0-9_./-]*$/.test(value) || value.split("/").some((part) => part === "" || part === "." || part === "..") || value.split("/").length > 16)
@@ -15645,8 +15655,8 @@ function normalizeGrant(value) {
15645
15655
  if (kind === "command")
15646
15656
  return Object.freeze({ kind, ...normalizeProjectCommand(policy) });
15647
15657
  if (kind === "acp") {
15648
- if (Object.keys(policy).some((key) => !["client", "model", "maxTurns", "retainSessions"].includes(key)) || "retainSessions" in policy && (policy.retainSessions !== true || policy.client !== "codex") || "maxTurns" in policy && (typeof policy.maxTurns !== "number" || !Number.isSafeInteger(policy.maxTurns) || policy.maxTurns < 1 || policy.maxTurns > 8) || !["codex", "claude", "pi"].includes(policy.client) || "model" in policy && (typeof policy.model !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._:/+-]{0,255}(?![\s\S])/.test(policy.model)))
15649
- throw new TypeError("ACP grant requires a supported native client, optional model, maxTurns from 1 to 8, and optional retainSessions: true for Codex");
15658
+ if (Object.keys(policy).some((key) => !["client", "model", "maxTurns", "retainSessions"].includes(key)) || "retainSessions" in policy && (policy.retainSessions !== true || policy.client !== "codex") || "maxTurns" in policy && !isPrivateNativeTurnAllowance(policy.maxTurns) || !["codex", "claude", "pi"].includes(policy.client) || "model" in policy && (typeof policy.model !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._:/+-]{0,255}(?![\s\S])/.test(policy.model)))
15659
+ throw new TypeError(`ACP grant requires a supported native client, optional model, maxTurns from ${PRIVATE_NATIVE_TURN_POLICY.minimum} to ${PRIVATE_NATIVE_TURN_POLICY.maximum}, and optional retainSessions: true for Codex`);
15650
15660
  return Object.freeze({
15651
15661
  kind,
15652
15662
  client: policy.client,
@@ -16847,7 +16857,10 @@ var clients = {
16847
16857
  codex: {
16848
16858
  name: "Codex",
16849
16859
  path: "CODEX_PATH",
16850
- installation: "Use a supported Linux x86-64 Codex installation with its required libraries and sandbox helper.",
16860
+ installation: {
16861
+ linux: "Use a supported Linux x86-64 Codex installation with its required libraries and sandbox helper.",
16862
+ darwin: "Use a supported native macOS Codex installation for this Mac's architecture, with its required libraries."
16863
+ },
16851
16864
  login: "Run codex login and use its operator-owned file-backed authentication; an expired credential needs a fresh login.",
16852
16865
  api: "Configure OPENAI_API_KEY and a model in the ACP grant or OPENAI_MODEL for Responses; OPENAI_API, if set, must be responses. Check OPENAI_BASE_URL if overridden.",
16853
16866
  model: "Set a valid model in the ACP grant, or OPENAI_MODEL for API access / CODEX_MODEL for subscription access."
@@ -16855,7 +16868,10 @@ var clients = {
16855
16868
  claude: {
16856
16869
  name: "Claude Code",
16857
16870
  path: "CLAUDE_PATH",
16858
- installation: "Use a supported Linux x86-64 native Claude Code installation with its required libraries.",
16871
+ installation: {
16872
+ linux: "Use a supported Linux x86-64 native Claude Code installation with its required libraries.",
16873
+ darwin: "Use a supported native macOS Claude Code installation for this Mac's architecture, with its required libraries."
16874
+ },
16859
16875
  login: "Configure CLAUDE_CODE_OAUTH_TOKEN with a valid Claude setup token.",
16860
16876
  api: "Set exactly one of ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN and a model in the ACP grant or ANTHROPIC_MODEL. Check ANTHROPIC_BASE_URL if overridden.",
16861
16877
  model: "Set a valid model in the ACP grant, or ANTHROPIC_MODEL for API access / CLAUDE_MODEL for subscription access."
@@ -16863,7 +16879,10 @@ var clients = {
16863
16879
  pi: {
16864
16880
  name: "Pi",
16865
16881
  path: "PI_PATH",
16866
- installation: "Use the supported standalone Linux x86-64 Pi 0.84.4 distribution with its package.json and theme directory; a Node/npm launcher is not supported.",
16882
+ installation: {
16883
+ linux: "Use the supported standalone Linux x86-64 Pi 0.84.4 distribution with its package.json and theme directory; a Node/npm launcher is not supported.",
16884
+ darwin: "Use the supported standalone macOS Pi 0.84.4 distribution for this Mac's architecture, with its package.json and theme directory; a Node/npm launcher is not supported."
16885
+ },
16867
16886
  login: "Use valid Pi subscription authentication for PI_PROVIDER in the operator auth.json; check PI_CODING_AGENT_DIR if overridden.",
16868
16887
  api: "Configure PI_PROVIDER, a model in the ACP grant or PI_MODEL, and a valid PI_API_KEY for the selected Pi API provider.",
16869
16888
  model: "Configure PI_PROVIDER and a valid model in the ACP grant or PI_MODEL."
@@ -16888,29 +16907,32 @@ var ACP_SETUP_CAUSES = Object.freeze(Object.fromEntries(Object.entries(clients).
16888
16907
  `${profile.name} is selected, but ${cause}.`
16889
16908
  ]);
16890
16909
  })));
16891
- var ACP_SETUP_HINTS = Object.freeze(Object.fromEntries(Object.entries(clients).flatMap(([client, profile]) => {
16892
- const hints = {
16893
- executable: `Select an executable ${profile.name} installation using ${profile.path} or operator PATH. Shell aliases and functions are not executable installations. An explicit ${profile.path} must be an absolute executable file and never falls back to PATH.`,
16894
- installation: profile.installation,
16895
- location: `Select a ${profile.name} installation whose executable and runtime files are outside reserved sandbox paths (/dev, /jig, /proc, /run, /sys, /tmp and /work). Use an operator-owned installation directory and update ${profile.path}.`,
16896
- wrapper: `The selected ${profile.name} launcher is an unsupported wrapper. Select the underlying supported native executable with ${profile.path}; Jig does not execute shell or npm wrappers to discover their dependencies.`,
16897
- sandbox: "Install an unprivileged Bubblewrap helper supported by the selected Codex installation; do not bypass containment.",
16898
- login: profile.login,
16899
- api: profile.api,
16900
- model: profile.model
16901
- };
16902
- return Object.entries(hints).map(([stage, hint]) => [
16903
- acpSetupCode(client, stage),
16904
- `${hint} Then retry jig review. No Flow was started by this review.`
16905
- ]);
16906
- })));
16910
+ function acpSetupHints(platform) {
16911
+ return Object.freeze(Object.fromEntries(Object.entries(clients).flatMap(([client, profile]) => {
16912
+ const hints = {
16913
+ executable: `Select an executable ${profile.name} installation using ${profile.path} or operator PATH. Shell aliases and functions are not executable installations. An explicit ${profile.path} must be an absolute executable file and never falls back to PATH.`,
16914
+ installation: profile.installation[platform],
16915
+ location: `Select a ${profile.name} installation whose executable and runtime files are outside reserved sandbox paths (/dev, /jig, /proc, /run, /sys, /tmp and /work). Use an operator-owned installation directory and update ${profile.path}.`,
16916
+ wrapper: `The selected ${profile.name} launcher is an unsupported wrapper. Select the underlying supported native executable with ${profile.path}; Jig does not execute shell or npm wrappers to discover their dependencies.`,
16917
+ sandbox: platform === "darwin" ? "Use a qualified Jig macOS host with its system /usr/bin/sandbox-exec helper intact; do not replace system helpers or bypass containment. See https://jig.md/guide/agents for supported native installations." : "Install an unprivileged Bubblewrap helper supported by the selected Codex installation; do not bypass containment.",
16918
+ login: profile.login,
16919
+ api: profile.api,
16920
+ model: profile.model
16921
+ };
16922
+ return Object.entries(hints).map(([stage, hint]) => [
16923
+ acpSetupCode(client, stage),
16924
+ `${hint} Then retry jig review. No Flow was started by this review.`
16925
+ ]);
16926
+ })));
16927
+ }
16928
+ var ACP_SETUP_HINTS = acpSetupHints(process.platform === "darwin" ? "darwin" : "linux");
16907
16929
 
16908
16930
  // src/internal/activation-admission-store.ts
16909
16931
  import { createHash as createHash13, randomUUID as randomUUID3 } from "crypto";
16910
- import { constants as constants23 } from "fs";
16932
+ import { constants as constants26 } from "fs";
16911
16933
  import { realpath as realpath17 } from "fs/promises";
16912
16934
  import { createRequire as createRequire7 } from "module";
16913
- import { join as join21 } from "path";
16935
+ import { join as join22 } from "path";
16914
16936
 
16915
16937
  // src/channel-contract.ts
16916
16938
  import { createHash } from "crypto";
@@ -26189,7 +26211,6 @@ function inputPath(destination) {
26189
26211
  }
26190
26212
 
26191
26213
  // src/internal/linux-rootless-backend.ts
26192
- init_file_input_policy();
26193
26214
  import { spawn } from "child_process";
26194
26215
  import { randomBytes as randomBytes3 } from "crypto";
26195
26216
  import { closeSync as closeSync10 } from "fs";
@@ -26212,6 +26233,7 @@ import { tmpdir as tmpdir3 } from "os";
26212
26233
  import { dirname as dirname5, extname, join as join6, posix as posix5 } from "path";
26213
26234
  import { fileURLToPath as fileURLToPath2 } from "url";
26214
26235
  import { types as utilTypes4 } from "util";
26236
+ init_file_input_policy();
26215
26237
  init_input_capture();
26216
26238
 
26217
26239
  // src/internal/installation-verification.ts
@@ -28721,34 +28743,7 @@ async function openPrivateMacosBackendState(value) {
28721
28743
  if (named.dev !== rootInfo.dev || named.ino !== rootInfo.ino || held.dev !== rootInfo.dev || held.ino !== rootInfo.ino || namedControl.dev !== controlInfo.dev || namedControl.ino !== controlInfo.ino)
28722
28744
  throw new Error("native execution allocation changed");
28723
28745
  };
28724
- const readFile3 = async (name) => {
28725
- let file;
28726
- try {
28727
- file = await openPrivateChild(control, name, constants13.O_RDONLY);
28728
- } catch (error) {
28729
- if (error.code === "ENOENT")
28730
- return;
28731
- throw error;
28732
- }
28733
- try {
28734
- const before = await file.stat({ bigint: true });
28735
- if (!before.isFile() || before.uid !== BigInt(process.getuid()) || before.nlink !== 1n || (before.mode & 0o7777n) !== 0o600n || before.size > BigInt(MAX_RECORD_BYTES2))
28736
- throw new Error("native execution record is unsafe");
28737
- const bytes = Buffer.alloc(Number(before.size));
28738
- for (let offset = 0;offset < bytes.length; ) {
28739
- const { bytesRead } = await file.read(bytes, offset, bytes.length - offset, offset);
28740
- if (!bytesRead)
28741
- throw new Error("native execution record ended early");
28742
- offset += bytesRead;
28743
- }
28744
- const after = await file.stat({ bigint: true });
28745
- if (before.size !== after.size || before.mtimeNs !== after.mtimeNs || before.ctimeNs !== after.ctimeNs || after.nlink !== 1n)
28746
- throw new Error("native execution record changed");
28747
- return bytes;
28748
- } finally {
28749
- await file.close();
28750
- }
28751
- };
28746
+ const readFile3 = (name) => readFileFrom(control, name);
28752
28747
  const read = async () => {
28753
28748
  await verify();
28754
28749
  const bytes = await readFile3("state.json");
@@ -28789,20 +28784,24 @@ async function openPrivateMacosBackendState(value) {
28789
28784
  receipt,
28790
28785
  mac: releaseSignature(allocation.ownerToken, receipt).toString("hex")
28791
28786
  });
28792
- let existing = await readFileFrom(root, "release.json");
28787
+ const existing = await readFileFrom(root, "release.json");
28788
+ if (existing !== undefined && !existing.equals(marker))
28789
+ throw new Error("native execution release marker conflicts");
28790
+ if (await readFileFrom(root, "release.pending") !== undefined)
28791
+ await unlinkPrivateFile(privateChildLocation(root, "release.pending"));
28793
28792
  if (existing === undefined) {
28794
- const file = await openPrivateChild(root, "release.json", constants13.O_WRONLY | constants13.O_CREAT | constants13.O_EXCL);
28793
+ const file = await openPrivateChild(root, "release.pending", constants13.O_WRONLY | constants13.O_CREAT | constants13.O_EXCL);
28795
28794
  try {
28796
28795
  await file.writeFile(marker);
28797
28796
  await file.sync();
28798
28797
  } finally {
28799
28798
  await file.close();
28800
28799
  }
28800
+ await verify();
28801
+ await root.sync();
28802
+ privateMacosRenameAt(root.fd, "release.pending", root.fd, "release.json", true);
28801
28803
  await root.sync();
28802
- existing = marker;
28803
28804
  }
28804
- if (!existing.equals(marker))
28805
- throw new Error("native execution release marker conflicts");
28806
28805
  privateMacosRenameAt(parent.fd, allocation.name, parent.fd, releaseName(allocation), true);
28807
28806
  await parent.sync();
28808
28807
  };
@@ -28874,7 +28873,7 @@ async function openPrivateMacosBackendState(value) {
28874
28873
  async function readFileFrom(parent, name) {
28875
28874
  let file;
28876
28875
  try {
28877
- file = await openPrivateChild(parent, name, constants13.O_RDONLY);
28876
+ file = await openPrivateChild(parent, name, constants13.O_RDONLY | constants13.O_NONBLOCK);
28878
28877
  } catch (error) {
28879
28878
  if (error.code === "ENOENT")
28880
28879
  return;
@@ -29092,7 +29091,6 @@ import { posix as posix10 } from "path";
29092
29091
  init_input_capture();
29093
29092
 
29094
29093
  // src/internal/macos-guardian-client.ts
29095
- init_input_capture();
29096
29094
  import { spawnSync } from "child_process";
29097
29095
  import { createHash as createHash10 } from "crypto";
29098
29096
  import { lstat as lstat7, mkdir as mkdir4, mkdtemp as mkdtemp3, rmdir as rmdir4, writeFile } from "fs/promises";
@@ -29100,6 +29098,18 @@ import { createServer as createServer2 } from "net";
29100
29098
  import { join as join11 } from "path";
29101
29099
  import { fileURLToPath as fileURLToPath3 } from "url";
29102
29100
 
29101
+ // src/internal/execution-process.ts
29102
+ class PrivateExecutionPreparationDeadlineError extends Error {
29103
+ code = "EXECUTION_PREPARATION_DEADLINE";
29104
+ constructor(cause) {
29105
+ super("execution preparation reached its enforced deadline", { cause });
29106
+ this.name = "PrivateExecutionPreparationDeadlineError";
29107
+ }
29108
+ }
29109
+
29110
+ // src/internal/macos-guardian-client.ts
29111
+ init_input_capture();
29112
+
29103
29113
  // src/internal/macos-control-channel.ts
29104
29114
  function privateMacosControlChannel(socket) {
29105
29115
  const messages = [];
@@ -29521,6 +29531,17 @@ async function sendPrivateMacosDescriptors(path, peer, descriptors, timeoutMs, s
29521
29531
 
29522
29532
  // src/internal/macos-guardian-diagnostics.ts
29523
29533
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
29534
+ var failureSteps = [
29535
+ "configuration",
29536
+ "admission",
29537
+ "input-transfer",
29538
+ "storage",
29539
+ "input-projection",
29540
+ "scope-preparation",
29541
+ "execution",
29542
+ "collection",
29543
+ "storage-recovery"
29544
+ ];
29524
29545
  var causes = new Map([
29525
29546
  ["macOS control channel ended", "CONTROL_EOF"],
29526
29547
  ["macOS control channel socket failed", "CONTROL_SOCKET"],
@@ -29532,15 +29553,38 @@ var causes = new Map([
29532
29553
  ["invalid macOS guardian response", "INVALID_RESPONSE"],
29533
29554
  ["macOS collector has no successful fenced owner", "INVALID_COLLECTOR"],
29534
29555
  ["macOS collector descriptor count changed", "DESCRIPTOR_COUNT"],
29535
- ["macOS guardian job removal is unconfirmed", "JOB_REMOVAL_UNCONFIRMED"]
29556
+ ["macOS guardian job removal is unconfirmed", "JOB_REMOVAL_UNCONFIRMED"],
29557
+ ["macOS guardian operation deadline expired", "OPERATION_DEADLINE"],
29558
+ ["macOS volume create failed", "VOLUME_CREATE"],
29559
+ ["macOS volume attach failed", "VOLUME_ATTACH"],
29560
+ ["macOS volume info failed", "VOLUME_INFO"],
29561
+ ["macOS volume detach failed", "VOLUME_DETACH"],
29562
+ ["macOS volume plist conversion failed", "VOLUME_PLIST"],
29563
+ ["macOS image attachment does not match its allocation", "VOLUME_IMAGE"],
29564
+ ["macOS volume device does not match its allocation", "VOLUME_DEVICE"]
29536
29565
  ]);
29566
+ function closedCause(error) {
29567
+ try {
29568
+ return error instanceof Error ? causes.get(error.message) ?? "OTHER" : "OTHER";
29569
+ } catch {
29570
+ return "OTHER";
29571
+ }
29572
+ }
29573
+ function normalizePrivateMacosGuardianFailure(value) {
29574
+ if (value === null)
29575
+ return null;
29576
+ const record3 = value;
29577
+ if (typeof value !== "object" || Array.isArray(value) || Object.keys(value).sort().join() !== "cause,step" || !failureSteps.includes(record3.step) || record3.cause !== "OTHER" && ![...causes.values()].includes(record3.cause))
29578
+ throw new Error("invalid macOS guardian response");
29579
+ return Object.freeze({ step: record3.step, cause: record3.cause });
29580
+ }
29537
29581
  var observers = new AsyncLocalStorage2;
29538
29582
  function reportPrivateMacosGuardianRecovery(phase, step, error) {
29539
29583
  try {
29540
29584
  const observer = observers.getStore();
29541
29585
  if (observer === undefined)
29542
29586
  return;
29543
- const cause = error instanceof Error ? causes.get(error.message) ?? "OTHER" : "OTHER";
29587
+ const cause = closedCause(error);
29544
29588
  observer(Object.freeze({ phase, step, cause }));
29545
29589
  } catch {}
29546
29590
  }
@@ -29565,13 +29609,14 @@ var MIB2 = 1024 * 1024;
29565
29609
  var IMAGE = "volume.dmg";
29566
29610
  var INTENT = "volume.json";
29567
29611
  var IMAGE_RECORD = "volume-image.json";
29612
+ var IMAGE_PENDING = "volume-image.pending";
29568
29613
  var RETIRE_RECORD = "storage.release.json";
29569
29614
  var RETIRE_PENDING = "storage.release.pending";
29570
- function identity2(stat3) {
29571
- return { device: String(stat3.dev), inode: String(stat3.ino) };
29615
+ function identity2(stat2) {
29616
+ return { device: String(stat2.dev), inode: String(stat2.ino) };
29572
29617
  }
29573
- function matches(stat3, value) {
29574
- return String(stat3.dev) === value.device && String(stat3.ino) === value.inode;
29618
+ function matches(stat2, value) {
29619
+ return String(stat2.dev) === value.device && String(stat2.ino) === value.inode;
29575
29620
  }
29576
29621
  function isIdentity(value) {
29577
29622
  if (value === null || typeof value !== "object")
@@ -29594,8 +29639,8 @@ async function privateDirectory3(path) {
29594
29639
  throw new Error("macOS volume directory is aliased");
29595
29640
  const directory = await open10(path, OPEN_DIRECTORY);
29596
29641
  try {
29597
- const stat3 = await directory.stat({ bigint: true });
29598
- if (!stat3.isDirectory() || stat3.uid !== BigInt(process.getuid()) || (stat3.mode & 0o777n) !== 0o700n)
29642
+ const stat2 = await directory.stat({ bigint: true });
29643
+ if (!stat2.isDirectory() || stat2.uid !== BigInt(process.getuid()) || (stat2.mode & 0o777n) !== 0o700n)
29599
29644
  throw new Error("macOS volume directory is not private");
29600
29645
  return directory;
29601
29646
  } catch (error) {
@@ -29778,8 +29823,13 @@ async function releasePrivateMacosVolume(controlPath, token, signal) {
29778
29823
  } finally {
29779
29824
  entries.closeSync();
29780
29825
  }
29781
- if (!names.every((name2) => [INTENT, IMAGE_RECORD].includes(name2)))
29826
+ if (!names.every((name2) => [INTENT, IMAGE_RECORD, IMAGE_PENDING].includes(name2)))
29782
29827
  throw new Error("macOS volume control contains unexpected state");
29828
+ if (names.includes(IMAGE_PENDING)) {
29829
+ const pending = privateMacosStatAt(control.fd, IMAGE_PENDING);
29830
+ if (!pending.isFile() || pending.uid !== BigInt(process.getuid()) || pending.nlink !== 1n || (pending.mode & 0o777n) !== 0o600n || pending.size > 4096n)
29831
+ throw new Error("macOS volume backing staging is unsafe");
29832
+ }
29783
29833
  if (retired === undefined)
29784
29834
  await writeRetirement(parent, token, allocation);
29785
29835
  if (names.includes(IMAGE_RECORD)) {
@@ -29789,6 +29839,8 @@ async function releasePrivateMacosVolume(controlPath, token, signal) {
29789
29839
  throw new Error("macOS volume backing journal is invalid");
29790
29840
  privateMacosUnlinkAt(control.fd, IMAGE_RECORD);
29791
29841
  }
29842
+ if (names.includes(IMAGE_PENDING))
29843
+ privateMacosUnlinkAt(control.fd, IMAGE_PENDING);
29792
29844
  if (intent !== undefined)
29793
29845
  privateMacosUnlinkAt(control.fd, INTENT);
29794
29846
  await control.sync();
@@ -30090,12 +30142,10 @@ async function recoverStorageWithGuardian(targetDirectory, targetToken, runtime)
30090
30142
  });
30091
30143
  recovery.stdout.resume();
30092
30144
  recovery.stderr.resume();
30093
- recovery.admit().catch(() => {
30094
- return;
30095
- });
30145
+ const admission = recovery.admit().catch((error) => error);
30096
30146
  const result2 = await recovery.completion;
30097
30147
  if (result2.recovered || result2.outputLost || result2.result !== null)
30098
- throw new Error("macOS storage recovery is unconfirmed");
30148
+ throw new Error("macOS storage recovery is unconfirmed", { cause: await admission });
30099
30149
  }
30100
30150
  async function preparePrivateMacosGuardian(input) {
30101
30151
  return prepareGuardian(input);
@@ -30288,6 +30338,7 @@ async function prepareGuardian(input) {
30288
30338
  };
30289
30339
  const completion = (async () => {
30290
30340
  let step = "receive";
30341
+ let terminalResult;
30291
30342
  try {
30292
30343
  for (;; ) {
30293
30344
  step = "receive";
@@ -30326,10 +30377,19 @@ async function prepareGuardian(input) {
30326
30377
  fenced: true,
30327
30378
  ...received === undefined ? {} : { outputFd: received.descriptors[0] }
30328
30379
  }));
30329
- } else if (message2?.type === "terminal" && Object.keys(message2).sort().join() === "outputLost,result,type" && typeof message2.outputLost === "boolean" && (message2.result === null || typeof message2.result === "object" && message2.result.fenced === true)) {
30380
+ } else if (message2?.type === "terminal" && Object.keys(message2).sort().join() === "failure,outputLost,result,type" && typeof message2.outputLost === "boolean" && (message2.result === null || typeof message2.result === "object" && message2.result.fenced === true)) {
30381
+ const failure = normalizePrivateMacosGuardianFailure(message2.failure);
30382
+ if (failure !== null && !message2.outputLost)
30383
+ throw new Error("invalid macOS guardian response");
30330
30384
  phase = "terminal";
30331
30385
  const normalizedResult = message2.result === null ? null : normalizePrivateMacosScopeResult(message2.result);
30332
- rejectReady(new Error(`macOS guardian ended before readiness (${normalizedResult?.reason ?? "recovery"})`));
30386
+ terminalResult = normalizedResult ?? undefined;
30387
+ const readinessError = new Error(`macOS guardian ended before readiness (${normalizedResult?.reason ?? "recovery"})`);
30388
+ if (failure !== null)
30389
+ Object.assign(readinessError, {
30390
+ code: `MACOS_GUARDIAN_${failure.step.replaceAll("-", "_").toUpperCase()}_${failure.cause}`
30391
+ });
30392
+ rejectReady(failure?.cause === "OPERATION_DEADLINE" ? new PrivateExecutionPreparationDeadlineError(readinessError) : readinessError);
30333
30393
  step = "terminal-cleanup";
30334
30394
  closeCollector();
30335
30395
  await cleanup();
@@ -30351,7 +30411,8 @@ async function prepareGuardian(input) {
30351
30411
  phase = "terminal";
30352
30412
  rejectReady(new Error("macOS guardian connection lost"));
30353
30413
  try {
30354
- const result2 = await recover();
30414
+ const recovered = await recover();
30415
+ const result2 = terminalResult === undefined ? recovered : Object.freeze({ ...recovered, result: terminalResult });
30355
30416
  resolveFenced(result2);
30356
30417
  return result2;
30357
30418
  } catch (error2) {
@@ -30992,7 +31053,7 @@ function normalizePrivateMacosConfirmedEnforcementReceipt(value) {
30992
31053
  "cpu_limit",
30993
31054
  "accounting_failed",
30994
31055
  "recovered"
30995
- ].includes(record3.stopReason) || record3.fenced !== true || typeof record3.outputLost !== "boolean" || typeof record3.recovered !== "boolean" || record3.recovered !== (record3.stopReason === "recovered"))
31056
+ ].includes(record3.stopReason) || record3.fenced !== true || typeof record3.outputLost !== "boolean" || typeof record3.recovered !== "boolean" || record3.stopReason === "recovered" && !record3.recovered)
30996
31057
  throw new TypeError("invalid native macOS enforcement receipt");
30997
31058
  const scope = normalizePrivateMacosScopeResult({
30998
31059
  reason: record3.stopReason === "recovered" ? "coordinator_lost" : record3.stopReason,
@@ -31169,7 +31230,7 @@ function receiptFor2(prepared, terminal) {
31169
31230
  signal: result2.signal,
31170
31231
  fenced: true,
31171
31232
  outputLost: terminal.outputLost,
31172
- recovered: false,
31233
+ recovered: terminal.recovered,
31173
31234
  evidence: result2.evidence
31174
31235
  });
31175
31236
  }
@@ -32193,7 +32254,10 @@ async function evaluateAuthorClosureBatch(options, captured, requestedEntries, s
32193
32254
  unavailable("PROJECT_EVALUATOR_SUPPORT", "cannot seal evaluator support", entryProjectPath);
32194
32255
  }
32195
32256
  const component = await privateProfileSpan("author-envelope-startup", () => launchPrivateExecution(options.backend, evaluatorLaunchPlan(installedSupport, runId, limits, inputs), signal)).catch((error) => {
32196
- return unavailable("PROJECT_EVALUATOR_LAUNCH", `cannot launch evaluator envelope: ${errorText8(error)}`, entryProjectPath);
32257
+ const deadline = error instanceof PrivateExecutionPreparationDeadlineError;
32258
+ const failure = new CheckError(deadline ? "invalid" : "unavailable", deadline ? "PROJECT_EVALUATOR_DEADLINE" : "PROJECT_EVALUATOR_LAUNCH", deadline ? "evaluator preparation reached its hard wall deadline" : "cannot launch evaluator envelope", entryProjectPath);
32259
+ failure.cause = error;
32260
+ throw failure;
32197
32261
  });
32198
32262
  const validEnvelope = component.envelope.kind === "linux-rootless-cgroup-v2-bubblewrap/1" ? component.envelope.privateProcessFilesystem && component.envelope.privateRuntimeDevices && sameEvaluatorLimits(component.envelope.limits, limits) && component.envelope.trustedCoordinatorBunDigest === installedSupport.executableDigest : component.envelope.resourceAccounting === "supervised-sampled-with-termination" && component.envelope.resourceOvershoot === true && sameEvaluatorLimits(component.envelope.limits, limits);
32199
32263
  if (!validEnvelope) {
@@ -34477,8 +34541,11 @@ function exactKeys2(value, required, optional) {
34477
34541
  throw new TypeError("invalid channel params");
34478
34542
  }
34479
34543
 
34544
+ // src/internal/bun-direct-run.ts
34545
+ init_file_input_policy();
34546
+
34480
34547
  // src/internal/private-acp-resources.ts
34481
- import { isAbsolute as isAbsolute6 } from "path";
34548
+ import { isAbsolute as isAbsolute7 } from "path";
34482
34549
 
34483
34550
  // src/internal/acp-agent-provider.ts
34484
34551
  import { constants as constants21 } from "fs";
@@ -34722,13 +34789,133 @@ async function exactFile(path2, executable, label) {
34722
34789
  }
34723
34790
 
34724
34791
  // src/internal/claude-agent-provider.ts
34725
- import { lstat as lstat14, realpath as realpath14 } from "fs/promises";
34726
- import { join as join18 } from "path";
34792
+ import { lstat as lstat15, realpath as realpath14 } from "fs/promises";
34793
+ import { join as join19 } from "path";
34727
34794
 
34728
34795
  // src/internal/native-agent-executable.ts
34796
+ import { constants as constants23 } from "fs";
34797
+ import { access as access5, lstat as lstat12, open as open13, readlink as readlink2, realpath as realpath11 } from "fs/promises";
34798
+ import { basename as basename2, delimiter, dirname as dirname10, isAbsolute as isAbsolute4, join as join17, relative as relative2, resolve as resolve7, sep } from "path";
34799
+
34800
+ // src/internal/codex-installation.ts
34729
34801
  import { constants as constants22 } from "fs";
34730
- import { access as access4, lstat as lstat11, readlink as readlink2, realpath as realpath11 } from "fs/promises";
34731
- import { basename, delimiter, dirname as dirname9, isAbsolute as isAbsolute3, join as join16, relative as relative2, resolve as resolve7, sep } from "path";
34802
+ import { access as access4, lstat as lstat11, open as open12 } from "fs/promises";
34803
+ import { basename, dirname as dirname9, isAbsolute as isAbsolute3, join as join16 } from "path";
34804
+ var MAX_METADATA_BYTES = 64 * 1024;
34805
+ var MAX_PACKAGE_ANCESTORS = 32;
34806
+ async function resolvePrivateCodexInstallation(selected, voltaHome, outsideProject) {
34807
+ try {
34808
+ let launcher = selected;
34809
+ let recordedVersion;
34810
+ if (basename(selected) === "volta-shim") {
34811
+ if (basename(dirname9(selected)) !== "bin")
34812
+ throw new Error("unsupported dispatcher layout");
34813
+ const home = voltaHome ?? dirname9(dirname9(selected));
34814
+ if (!isAbsolute3(home) || home.includes("\x00"))
34815
+ throw new Error("invalid Volta home");
34816
+ const record3 = await metadata(join16(home, "tools/user/bins/codex.json"), outsideProject);
34817
+ if (record3.name !== "codex" || record3.package !== "@openai/codex" || record3.manager !== "Npm")
34818
+ throw new Error("unsupported dispatcher selection");
34819
+ recordedVersion = version(record3.version);
34820
+ launcher = await requiredPath(join16(home, "tools/image/packages/@openai/codex/bin/codex"), outsideProject);
34821
+ }
34822
+ if (basename(launcher) !== "codex.js" || basename(dirname9(launcher)) !== "bin")
34823
+ throw new Error("unsupported npm launcher layout");
34824
+ if (await requiredPath(launcher, outsideProject) !== launcher)
34825
+ throw new Error("launcher selection changed");
34826
+ const information = await lstat11(launcher);
34827
+ if (!information.isFile() || (information.mode & 73) === 0)
34828
+ throw new Error("invalid Codex npm launcher");
34829
+ await access4(launcher, constants22.X_OK);
34830
+ const root = dirname9(dirname9(launcher));
34831
+ const manifest = await metadata(join16(root, "package.json"), outsideProject);
34832
+ const selectedVersion = version(manifest.version);
34833
+ if (manifest.name !== "@openai/codex" || object7(manifest.bin).codex !== "bin/codex.js" || recordedVersion !== undefined && recordedVersion !== selectedVersion)
34834
+ throw new Error("unsupported Codex installation");
34835
+ const platform = `${process.platform}-${process.arch}`;
34836
+ const triple = process.platform === "darwin" ? `${process.arch === "arm64" ? "aarch64" : "x86_64"}-apple-darwin` : "x86_64-unknown-linux-musl";
34837
+ if (!(process.platform === "darwin" && ["x64", "arm64"].includes(process.arch)) && !(process.platform === "linux" && process.arch === "x64"))
34838
+ throw new Error("unsupported Codex platform");
34839
+ const dependency = `@openai/codex-${platform}`;
34840
+ const nativeVersion = `${selectedVersion}-${platform}`;
34841
+ if (object7(manifest.optionalDependencies)[dependency] !== `npm:@openai/codex@${nativeVersion}`)
34842
+ throw new Error("unsupported Codex native dependency");
34843
+ let directory = dirname9(launcher);
34844
+ for (let depth = 0;depth < MAX_PACKAGE_ANCESTORS; depth++) {
34845
+ if (basename(directory) !== "node_modules") {
34846
+ const nativeRoot = join16(directory, "node_modules", dependency);
34847
+ let present2 = false;
34848
+ try {
34849
+ await requiredPath(nativeRoot, outsideProject);
34850
+ present2 = true;
34851
+ } catch (error) {
34852
+ if (!absent2(error))
34853
+ throw error;
34854
+ }
34855
+ if (present2) {
34856
+ const nativeManifest = await metadata(join16(nativeRoot, "package.json"), outsideProject);
34857
+ if (nativeManifest.name !== "@openai/codex" || nativeManifest.version !== nativeVersion || !exactArray(nativeManifest.os, process.platform) || !exactArray(nativeManifest.cpu, process.arch))
34858
+ throw new Error("mismatched Codex native dependency");
34859
+ return await requiredPath(join16(nativeRoot, "vendor", triple, "bin/codex"), outsideProject);
34860
+ }
34861
+ }
34862
+ const parent = dirname9(directory);
34863
+ if (parent === directory)
34864
+ break;
34865
+ directory = parent;
34866
+ }
34867
+ throw new Error("Codex native dependency is unavailable");
34868
+ } catch {
34869
+ throw new PrivateAcpSetupError("wrapper");
34870
+ }
34871
+ }
34872
+ async function requiredPath(path2, outsideProject) {
34873
+ const selected = await outsideProject(path2);
34874
+ if (selected === undefined)
34875
+ throw new Error("Codex installation enters the project");
34876
+ return selected;
34877
+ }
34878
+ async function metadata(path2, outsideProject) {
34879
+ const selected = await requiredPath(path2, outsideProject);
34880
+ const file = await open12(selected, constants22.O_RDONLY | constants22.O_NONBLOCK | constants22.O_NOFOLLOW);
34881
+ try {
34882
+ const before = await file.stat();
34883
+ if (!before.isFile() || before.size > MAX_METADATA_BYTES)
34884
+ throw new Error("invalid Codex installation metadata");
34885
+ const bytes = Buffer.alloc(before.size + 1);
34886
+ let used = 0;
34887
+ while (used < bytes.length) {
34888
+ const result2 = await file.read(bytes, used, bytes.length - used, used);
34889
+ if (result2.bytesRead === 0)
34890
+ break;
34891
+ used += result2.bytesRead;
34892
+ }
34893
+ const after = await file.stat();
34894
+ if (used !== before.size || before.size !== after.size || before.mtimeMs !== after.mtimeMs || before.ctimeMs !== after.ctimeMs)
34895
+ throw new Error("Codex installation metadata changed");
34896
+ return object7(JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes.subarray(0, used))));
34897
+ } finally {
34898
+ await file.close();
34899
+ }
34900
+ }
34901
+ function object7(value) {
34902
+ if (value === null || typeof value !== "object" || Array.isArray(value))
34903
+ throw new Error("invalid Codex installation record");
34904
+ return value;
34905
+ }
34906
+ function version(value) {
34907
+ if (typeof value !== "string" || value.length > 128 || !/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z.-]+)?$/.test(value))
34908
+ throw new Error("invalid Codex installation version");
34909
+ return value;
34910
+ }
34911
+ function exactArray(value, selected) {
34912
+ return Array.isArray(value) && value.length === 1 && value[0] === selected;
34913
+ }
34914
+ function absent2(error) {
34915
+ return ["ENOENT", "ENOTDIR"].includes(error.code ?? "");
34916
+ }
34917
+
34918
+ // src/internal/native-agent-executable.ts
34732
34919
  class PrivateNativeAgentExecutableUnavailableError extends Error {
34733
34920
  client;
34734
34921
  constructor(client) {
@@ -34739,16 +34926,17 @@ class PrivateNativeAgentExecutableUnavailableError extends Error {
34739
34926
  async function resolvePrivateNativeAgentExecutable(client, environment, projectDirectory = process.cwd()) {
34740
34927
  const selected = environment[`${client.toUpperCase()}_PATH`];
34741
34928
  const searchPath = environment.PATH;
34929
+ const voltaHome = environment.VOLTA_HOME;
34742
34930
  const project = resolve7(projectDirectory);
34743
34931
  try {
34744
34932
  if (selected !== undefined) {
34745
- if (!isAbsolute3(selected) || selected.includes("\x00"))
34933
+ if (!isAbsolute4(selected) || selected.includes("\x00"))
34746
34934
  throw new Error("invalid override");
34747
- return await executable(selected);
34935
+ return await selectExecutable(client, await executable(selected), voltaHome, project);
34748
34936
  }
34749
34937
  const outside = await privateNativeAgentSupportResolver(project);
34750
34938
  for (const directory of (searchPath ?? "").split(delimiter)) {
34751
- if (!isAbsolute3(directory) || directory.includes("\x00"))
34939
+ if (!isAbsolute4(directory) || directory.includes("\x00"))
34752
34940
  continue;
34753
34941
  const candidate = `${directory}${sep}${client}`;
34754
34942
  try {
@@ -34757,9 +34945,9 @@ async function resolvePrivateNativeAgentExecutable(client, environment, projectD
34757
34945
  continue;
34758
34946
  if (await executable(path2) !== path2)
34759
34947
  throw new Error("executable selection changed");
34760
- return path2;
34948
+ return await selectExecutable(client, path2, voltaHome, project, outside);
34761
34949
  } catch (error) {
34762
- if (!absent2(error) && error.code !== "EACCES")
34950
+ if (!absent3(error) && error.code !== "EACCES")
34763
34951
  throw error;
34764
34952
  }
34765
34953
  }
@@ -34775,22 +34963,22 @@ async function privateNativeAgentSupportResolver(projectDirectory) {
34775
34963
  const projectRoot = await realpath11(project);
34776
34964
  const excluded = [project, projectRoot];
34777
34965
  for (const root of [project, projectRoot]) {
34778
- for (let directory = dirname9(root);; directory = dirname9(directory)) {
34779
- const dependencies = join16(directory, "node_modules");
34966
+ for (let directory = dirname10(root);; directory = dirname10(directory)) {
34967
+ const dependencies = join17(directory, "node_modules");
34780
34968
  excluded.push(dependencies);
34781
34969
  try {
34782
34970
  excluded.push(await realpath11(dependencies));
34783
34971
  } catch (error) {
34784
- if (!absent2(error))
34972
+ if (!absent3(error))
34785
34973
  throw error;
34786
34974
  }
34787
- if (dirname9(directory) === directory)
34975
+ if (dirname10(directory) === directory)
34788
34976
  break;
34789
34977
  }
34790
34978
  }
34791
34979
  const forbidden = (path2) => excluded.some((root) => inside2(root, path2));
34792
34980
  return async (path2) => {
34793
- if (!isAbsolute3(path2) || path2.includes("\x00") || forbidden(path2))
34981
+ if (!isAbsolute4(path2) || path2.includes("\x00") || forbidden(path2))
34794
34982
  return;
34795
34983
  return await outsideProject(path2, forbidden);
34796
34984
  };
@@ -34806,11 +34994,11 @@ async function outsideProject(candidate, forbidden) {
34806
34994
  path2 = resolve7(path2, component);
34807
34995
  if (forbidden(path2))
34808
34996
  return;
34809
- if ((await lstat11(path2)).isSymbolicLink()) {
34997
+ if ((await lstat12(path2)).isSymbolicLink()) {
34810
34998
  if (++links > 40)
34811
34999
  throw new Error("too many executable symlinks");
34812
35000
  const link4 = await readlink2(path2);
34813
- const target = isAbsolute3(link4) ? link4 : `${dirname9(path2)}${sep}${link4}`;
35001
+ const target = isAbsolute4(link4) ? link4 : `${dirname10(path2)}${sep}${link4}`;
34814
35002
  if (forbidden(target))
34815
35003
  return;
34816
35004
  pending = [...target.split(sep).filter(Boolean), ...pending];
@@ -34821,31 +35009,59 @@ async function outsideProject(candidate, forbidden) {
34821
35009
  }
34822
35010
  async function executable(candidate) {
34823
35011
  const path2 = await realpath11(candidate);
34824
- if (basename(path2) === "volta-shim")
34825
- throw new PrivateAcpSetupError("wrapper");
34826
- const information = await lstat11(path2);
35012
+ const information = await lstat12(path2);
34827
35013
  if (!information.isFile() || (information.mode & 73) === 0) {
34828
35014
  throw Object.assign(new Error("not an executable file"), { code: "EACCES" });
34829
35015
  }
34830
- await access4(path2, constants22.X_OK);
35016
+ await access5(path2, constants23.X_OK);
34831
35017
  return path2;
34832
35018
  }
35019
+ async function selectExecutable(client, selected, voltaHome, project, outside) {
35020
+ const dispatcher = basename2(selected) === "volta-shim";
35021
+ if (dispatcher && client !== "codex")
35022
+ throw new PrivateAcpSetupError("wrapper");
35023
+ if (client === "codex" && (dispatcher || basename2(selected) === "codex.js" && await script(selected))) {
35024
+ try {
35025
+ const native5 = await resolvePrivateCodexInstallation(selected, voltaHome, outside ?? await privateNativeAgentSupportResolver(project));
35026
+ if (await executable(native5) !== native5)
35027
+ throw new Error("executable selection changed");
35028
+ return native5;
35029
+ } catch {
35030
+ throw new PrivateAcpSetupError("wrapper");
35031
+ }
35032
+ }
35033
+ return selected;
35034
+ }
35035
+ async function script(path2) {
35036
+ const file = await open13(path2, constants23.O_RDONLY | constants23.O_NONBLOCK | constants23.O_NOFOLLOW);
35037
+ try {
35038
+ if (!(await file.stat()).isFile())
35039
+ throw new Error("invalid executable selection");
35040
+ const magic = Buffer.alloc(2);
35041
+ await file.read(magic, 0, magic.length, 0);
35042
+ return magic.toString() === "#!";
35043
+ } finally {
35044
+ await file.close();
35045
+ }
35046
+ }
34833
35047
  function inside2(root, path2) {
34834
35048
  const child2 = relative2(root, path2);
34835
- return child2 === "" || child2 !== ".." && !child2.startsWith(`..${sep}`) && !isAbsolute3(child2);
35049
+ return child2 === "" || child2 !== ".." && !child2.startsWith(`..${sep}`) && !isAbsolute4(child2);
34836
35050
  }
34837
- function absent2(error) {
35051
+ function absent3(error) {
34838
35052
  return ["ENOENT", "ENOTDIR"].includes(error.code ?? "");
34839
35053
  }
34840
35054
 
34841
35055
  // src/internal/native-agent-runtime.ts
34842
- import { lstat as lstat13, open as open13, realpath as realpath13 } from "fs/promises";
34843
- import { dirname as dirname11, isAbsolute as isAbsolute5, join as join17, normalize as normalize2 } from "path";
35056
+ import { constants as constants25 } from "fs";
35057
+ import { lstat as lstat14, open as open15, realpath as realpath13 } from "fs/promises";
35058
+ import { dirname as dirname12, isAbsolute as isAbsolute6, join as join18, normalize as normalize2 } from "path";
34844
35059
 
34845
35060
  // src/internal/macos-agent-runtime.ts
34846
- import { lstat as lstat12, open as open12, realpath as realpath12 } from "fs/promises";
35061
+ import { constants as constants24 } from "fs";
35062
+ import { lstat as lstat13, open as open14, realpath as realpath12 } from "fs/promises";
34847
35063
  import { createRequire as createRequire6 } from "module";
34848
- import { dirname as dirname10, isAbsolute as isAbsolute4, normalize } from "path";
35064
+ import { dirname as dirname11, isAbsolute as isAbsolute5, normalize } from "path";
34849
35065
  init_macos_process_controls();
34850
35066
  async function inspectPrivateMacosAgentRuntime(executable2, projectDirectory = process.cwd()) {
34851
35067
  privateMacosCurrentProcessIdentity();
@@ -34878,28 +35094,28 @@ async function inspectPrivateMacosAgentRuntime(executable2, projectDirectory = p
34878
35094
  return;
34879
35095
  if (inspected.size >= 128)
34880
35096
  throw new Error("native Agent runtime is too large");
34881
- const information = await lstat12(path2);
35097
+ const information = await lstat13(path2);
34882
35098
  if (!information.isFile() || (information.mode & 3072) !== 0 || isMain && (information.mode & 73) === 0)
34883
35099
  throw new Error("native Agent runtime file is invalid");
34884
35100
  inspected.add(path2);
34885
35101
  if (!isMain)
34886
35102
  mounts.set(path2, Object.freeze({ source: path2, destination: path2, role: "support" }));
34887
35103
  digests.set(path2, await privateInstallationFileDigest(path2));
34888
- const metadata = await readPrivateMacosAgentMetadata(path2);
34889
- if (metadata.executable !== isMain)
35104
+ const metadata2 = await readPrivateMacosAgentMetadata(path2);
35105
+ if (metadata2.executable !== isMain)
34890
35106
  throw new Error("native Agent Mach-O file type is invalid");
34891
- if (metadata.installName !== undefined) {
34892
- const previous = loaded.get(metadata.installName);
35107
+ if (metadata2.installName !== undefined) {
35108
+ const previous = loaded.get(metadata2.installName);
34893
35109
  if (previous !== undefined && previous !== path2)
34894
35110
  throw new Error("native Agent library identity is ambiguous");
34895
- loaded.set(metadata.installName, path2);
35111
+ loaded.set(metadata2.installName, path2);
34896
35112
  }
34897
35113
  const expand = (value) => {
34898
35114
  let expanded;
34899
35115
  if (value === "@loader_path" || value.startsWith("@loader_path/"))
34900
- expanded = `${dirname10(path2)}${value.slice(12)}`;
35116
+ expanded = `${dirname11(path2)}${value.slice(12)}`;
34901
35117
  else if (value === "@executable_path" || value.startsWith("@executable_path/"))
34902
- expanded = `${dirname10(main)}${value.slice(16)}`;
35118
+ expanded = `${dirname11(main)}${value.slice(16)}`;
34903
35119
  else {
34904
35120
  requirePath(value);
34905
35121
  expanded = value;
@@ -34907,11 +35123,11 @@ async function inspectPrivateMacosAgentRuntime(executable2, projectDirectory = p
34907
35123
  requirePath(expanded, false);
34908
35124
  return expanded;
34909
35125
  };
34910
- const search = [...metadata.search.map(expand), ...inherited];
35126
+ const search = [...metadata2.search.map(expand), ...inherited];
34911
35127
  if (search.length > 128)
34912
35128
  throw new Error("native Agent library search is too large");
34913
35129
  const dependencies = [];
34914
- for (const dependency of metadata.needed) {
35130
+ for (const dependency of metadata2.needed) {
34915
35131
  const name = dependency.path;
34916
35132
  if (name.startsWith("@rpath/") && loaded.has(name))
34917
35133
  continue;
@@ -34962,9 +35178,12 @@ function privateMacosCachedLibrary(path2) {
34962
35178
  async function readPrivateMacosAgentMetadata(path2) {
34963
35179
  const systemSandbox = process.platform === "darwin" && process.arch === "arm64" && path2 === "/usr/bin/sandbox-exec";
34964
35180
  const acceptedSubtype = (value) => nativeSubtype(value) || systemSandbox && value === 2147483650;
34965
- const file = await open12(path2, "r");
35181
+ const file = await open14(path2, constants24.O_RDONLY | constants24.O_NONBLOCK);
34966
35182
  try {
34967
- const size = (await file.stat()).size;
35183
+ const information = await file.stat();
35184
+ if (!information.isFile())
35185
+ throw new Error("native Agent runtime is not a regular file");
35186
+ const size = information.size;
34968
35187
  async function read(offset2, length) {
34969
35188
  if (!Number.isSafeInteger(offset2) || !Number.isSafeInteger(length) || offset2 < 0 || length < 0 || length > 1024 * 1024 || length > size - offset2)
34970
35189
  throw new Error("invalid native Agent Mach-O bounds");
@@ -35110,7 +35329,7 @@ function nativeSubtype(value) {
35110
35329
  return value === 3 || value === 2147483651;
35111
35330
  }
35112
35331
  function requirePath(path2, canonical3 = true) {
35113
- if (!isAbsolute4(path2) || canonical3 && normalize(path2) !== path2 || path2 === "/" || Buffer.byteLength(path2) > 4096 || [...path2].some((char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127))
35332
+ if (!isAbsolute5(path2) || canonical3 && normalize(path2) !== path2 || path2 === "/" || Buffer.byteLength(path2) > 4096 || [...path2].some((char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127))
35114
35333
  throw new Error("native Agent runtime path is invalid");
35115
35334
  }
35116
35335
 
@@ -35130,7 +35349,7 @@ async function inspectPrivateNativeAgentRuntime(executable2, projectDirectory =
35130
35349
  const source = destination === executable2 ? await realpath13(destination) : await outsideProject2(destination);
35131
35350
  if (source === undefined)
35132
35351
  throw new Error("native Agent runtime enters the project");
35133
- const information = await lstat13(source);
35352
+ const information = await lstat14(source);
35134
35353
  if (!information.isFile() || (information.mode & 3072) !== 0 || executableFile && (information.mode & 73) === 0) {
35135
35354
  throw new Error("native Agent runtime file is invalid");
35136
35355
  }
@@ -35139,12 +35358,12 @@ async function inspectPrivateNativeAgentRuntime(executable2, projectDirectory =
35139
35358
  return;
35140
35359
  inspected.add(source);
35141
35360
  digests.set(source, await privateInstallationFileDigest(source));
35142
- const elf = await readElf(source);
35361
+ const elf = await readPrivateNativeAgentElfMetadata(source);
35143
35362
  if (elf === undefined) {
35144
35363
  throw new Error("native Agent runtime is not a qualified executable");
35145
35364
  }
35146
35365
  const search = elf.search.map((path2) => {
35147
- const expanded = path2.replace(/\$\{ORIGIN\}|\$ORIGIN/g, dirname11(destination));
35366
+ const expanded = path2.replace(/\$\{ORIGIN\}|\$ORIGIN/g, dirname12(destination));
35148
35367
  requirePath2(expanded);
35149
35368
  if (expanded.includes("$"))
35150
35369
  throw new Error("unsupported native Agent library search");
@@ -35154,7 +35373,7 @@ async function inspectPrivateNativeAgentRuntime(executable2, projectDirectory =
35154
35373
  const directories = [...search, ...inherited];
35155
35374
  if (elf.interpreter !== undefined) {
35156
35375
  await visit2(elf.interpreter, [], new Map, true);
35157
- directories.push(dirname11(elf.interpreter), dirname11(mounts.get(elf.interpreter).source));
35376
+ directories.push(dirname12(elf.interpreter), dirname12(mounts.get(elf.interpreter).source));
35158
35377
  }
35159
35378
  directories.push("/lib/x86_64-linux-gnu", "/usr/lib/x86_64-linux-gnu", "/lib64", "/usr/lib64", "/lib", "/usr/lib");
35160
35379
  const dependencies = [];
@@ -35169,9 +35388,9 @@ async function inspectPrivateNativeAgentRuntime(executable2, projectDirectory =
35169
35388
  }
35170
35389
  let found;
35171
35390
  for (const directory of directories) {
35172
- const candidate = join17(directory, name);
35391
+ const candidate = join18(directory, name);
35173
35392
  try {
35174
- await lstat13(candidate);
35393
+ await lstat14(candidate);
35175
35394
  found = candidate;
35176
35395
  break;
35177
35396
  } catch (error) {
@@ -35201,10 +35420,13 @@ async function inspectPrivateNativeAgentRuntime(executable2, projectDirectory =
35201
35420
  verifyProvider: (provider) => verifyPrivateAcpAgentFileDigests(provider, digests)
35202
35421
  });
35203
35422
  }
35204
- async function readElf(path2) {
35205
- const file = await open13(path2, "r");
35423
+ async function readPrivateNativeAgentElfMetadata(path2) {
35424
+ const file = await open15(path2, constants25.O_RDONLY | constants25.O_NONBLOCK);
35206
35425
  try {
35207
- const size = (await file.stat()).size;
35426
+ const information = await file.stat();
35427
+ if (!information.isFile())
35428
+ throw new Error("native Agent runtime is not a regular file");
35429
+ const size = information.size;
35208
35430
  async function read(offset, length) {
35209
35431
  if (!Number.isSafeInteger(offset) || !Number.isSafeInteger(length) || offset < 0 || length < 0 || length > 1024 * 1024 || offset + length > size) {
35210
35432
  throw new Error("invalid native Agent ELF bounds");
@@ -35316,7 +35538,7 @@ function stringAt(bytes, offset, allowEmpty = false) {
35316
35538
  return value;
35317
35539
  }
35318
35540
  function requirePath2(path2) {
35319
- if (!isAbsolute5(path2) || path2.includes("\x00") || normalize2(path2) !== path2 || path2 === "/") {
35541
+ if (!isAbsolute6(path2) || path2.includes("\x00") || normalize2(path2) !== path2 || path2 === "/") {
35320
35542
  throw new Error("native Agent runtime path is invalid");
35321
35543
  }
35322
35544
  }
@@ -35337,8 +35559,8 @@ async function openPrivateClaudeAgentProvider(releaseRoot, environment = process
35337
35559
  const executablePath = await resolvePrivateNativeAgentExecutable("claude", environment, projectDirectory);
35338
35560
  const runtime = await checkAcpSetup("installation", () => inspectPrivateNativeAgentRuntime(executablePath, projectDirectory));
35339
35561
  const support = Object.freeze({
35340
- launcherPath: join18(releaseRoot, "libexec", "agent", "claude-agent-launcher.js"),
35341
- adapterPath: join18(releaseRoot, "libexec", "agent", "claude-agent-acp.js"),
35562
+ launcherPath: join19(releaseRoot, "libexec", "agent", "claude-agent-launcher.js"),
35563
+ adapterPath: join19(releaseRoot, "libexec", "agent", "claude-agent-acp.js"),
35342
35564
  executablePath,
35343
35565
  certificatesPath: await ordinaryFile(HOST_CERTIFICATES_PATH, "host certificate bundle"),
35344
35566
  runtimeMounts: runtime.mounts
@@ -35505,7 +35727,7 @@ function frameStartupInput(value) {
35505
35727
  }
35506
35728
  async function ordinaryFile(path2, label) {
35507
35729
  const exact6 = await realpath14(path2);
35508
- const information = await lstat14(exact6);
35730
+ const information = await lstat15(exact6);
35509
35731
  if (!information.isFile() || information.isSymbolicLink()) {
35510
35732
  throw new Error(`${label} is invalid`);
35511
35733
  }
@@ -35513,9 +35735,9 @@ async function ordinaryFile(path2, label) {
35513
35735
  }
35514
35736
 
35515
35737
  // src/internal/codex-agent-provider.ts
35516
- import { lstat as lstat15, readFile as readFile4, realpath as realpath15 } from "fs/promises";
35738
+ import { lstat as lstat16, readFile as readFile4, realpath as realpath15 } from "fs/promises";
35517
35739
  import { homedir as homedir2 } from "os";
35518
- import { basename as basename2, dirname as dirname12, join as join19 } from "path";
35740
+ import { basename as basename3, dirname as dirname13, join as join20 } from "path";
35519
35741
  var CODEX_CLIENT = "openai-codex";
35520
35742
  var SANDBOX_LAUNCHER_PATH2 = "/agent/codex-agent-launcher.js";
35521
35743
  var SANDBOX_ADAPTER_PATH2 = "/agent/codex-acp.js";
@@ -35587,7 +35809,7 @@ async function openPrivateCodexAgentProvider(releaseRoot, environment = process.
35587
35809
  if (bubblewrapRuntime.pathPrefix)
35588
35810
  throw new Error("wrapped Bubblewrap is unsupported");
35589
35811
  } catch (error) {
35590
- throw new PrivateCodexRuntimeUnavailableError("the Codex sandbox runtime is unavailable", {
35812
+ throw new PrivateCodexSandboxUnavailableError("the Codex sandbox runtime is unavailable", {
35591
35813
  cause: error
35592
35814
  });
35593
35815
  }
@@ -35600,14 +35822,14 @@ async function openPrivateCodexAgentProvider(releaseRoot, environment = process.
35600
35822
  mounts.set(mount.destination, mount);
35601
35823
  }
35602
35824
  const support = Object.freeze({
35603
- launcherPath: join19(releaseRoot, "libexec", "agent", "codex-agent-launcher.js"),
35604
- adapterPath: join19(releaseRoot, "libexec", "agent", "codex-acp.js"),
35825
+ launcherPath: join20(releaseRoot, "libexec", "agent", "codex-agent-launcher.js"),
35826
+ adapterPath: join20(releaseRoot, "libexec", "agent", "codex-acp.js"),
35605
35827
  executablePath,
35606
35828
  nativeBubblewrapPath,
35607
35829
  nativeBubblewrapSource: nativeBubblewrap.source,
35608
35830
  runtimeMounts: Object.freeze([...mounts.values()]),
35609
35831
  certificatesPath: await ordinaryFile2(HOST_CERTIFICATES_PATH2, "host certificate bundle"),
35610
- requirementsPath: join19(releaseRoot, "libexec", "agent", "codex-requirements.toml")
35832
+ requirementsPath: join20(releaseRoot, "libexec", "agent", "codex-requirements.toml")
35611
35833
  });
35612
35834
  const apiKey = environment[OPENAI_API_KEY];
35613
35835
  const apiModel = environment[OPENAI_MODEL];
@@ -35632,10 +35854,10 @@ async function openPrivateCodexAgentProvider(releaseRoot, environment = process.
35632
35854
  bubblewrapRuntime.verifyProvider(provider2);
35633
35855
  return provider2;
35634
35856
  }
35635
- const sourceHome = environment.CODEX_HOME ?? join19(homedir2(), ".codex");
35857
+ const sourceHome = environment.CODEX_HOME ?? join20(homedir2(), ".codex");
35636
35858
  let credential;
35637
35859
  try {
35638
- credential = await projectPrivateCodexSubscriptionCredential(join19(sourceHome, "auth.json"));
35860
+ credential = await projectPrivateCodexSubscriptionCredential(join20(sourceHome, "auth.json"));
35639
35861
  } catch {
35640
35862
  throw new PrivateCodexLoginUnavailableError("Codex file-backed login is unavailable");
35641
35863
  }
@@ -35651,7 +35873,7 @@ async function openPrivateCodexAgentProvider(releaseRoot, environment = process.
35651
35873
  }
35652
35874
  async function projectPrivateCodexSubscriptionCredential(path2) {
35653
35875
  const exact6 = await exactFile2(path2, "Codex subscription credential");
35654
- const information = await lstat15(exact6);
35876
+ const information = await lstat16(exact6);
35655
35877
  const uid = typeof process.getuid === "function" ? process.getuid() : -1;
35656
35878
  if (information.uid !== uid || information.nlink !== 1 || (information.mode & 63) !== 0 || information.size > MAX_CREDENTIAL_BYTES) {
35657
35879
  throw new Error("Codex subscription credential is invalid");
@@ -35808,7 +36030,7 @@ function codexEnvironment(subscription, model, support) {
35808
36030
  }),
35809
36031
  CODEX_HOME: SANDBOX_CODEX_HOME,
35810
36032
  CODEX_PATH: support.executablePath,
35811
- PATH: support.nativeBubblewrapSource === "bundled" ? "/agent" : dirname12(support.nativeBubblewrapPath),
36033
+ PATH: support.nativeBubblewrapSource === "bundled" ? "/agent" : dirname13(support.nativeBubblewrapPath),
35812
36034
  CODEX_SQLITE_HOME: "/tmp/codex-state",
35813
36035
  INITIAL_AGENT_MODE: "read-only",
35814
36036
  ...subscription ? { JIG_CODEX_STARTUP_INPUT: "subscription" } : {},
@@ -35822,15 +36044,15 @@ async function nativeBubblewrapFor(executablePath, environment, projectDirectory
35822
36044
  system = await resolvePrivateNativeAgentExecutable("bwrap", environment, projectDirectory);
35823
36045
  } catch {}
35824
36046
  if (system !== undefined) {
35825
- if (((await lstat15(system)).mode & 3072) !== 0) {
36047
+ if (((await lstat16(system)).mode & 3072) !== 0) {
35826
36048
  throw new PrivateCodexSandboxUnavailableError("Codex Bubblewrap must be unprivileged");
35827
36049
  }
35828
36050
  return { path: system, source: "path" };
35829
36051
  }
35830
- const executableDirectory = dirname12(executablePath);
35831
- const adjacent = join19(executableDirectory, "codex-resources", "bwrap");
35832
- const packageResource = join19(executableDirectory, "..", "codex-resources", "bwrap");
35833
- const candidates = basename2(executableDirectory) === "bin" ? [packageResource, adjacent] : [adjacent, packageResource];
36052
+ const executableDirectory = dirname13(executablePath);
36053
+ const adjacent = join20(executableDirectory, "codex-resources", "bwrap");
36054
+ const packageResource = join20(executableDirectory, "..", "codex-resources", "bwrap");
36055
+ const candidates = basename3(executableDirectory) === "bin" ? [packageResource, adjacent] : [adjacent, packageResource];
35834
36056
  try {
35835
36057
  for (const candidate of candidates) {
35836
36058
  let path2;
@@ -35841,7 +36063,7 @@ async function nativeBubblewrapFor(executablePath, environment, projectDirectory
35841
36063
  throw error;
35842
36064
  continue;
35843
36065
  }
35844
- const information = await lstat15(path2);
36066
+ const information = await lstat16(path2);
35845
36067
  if ((information.mode & 3072) !== 0 || (information.mode & 73) === 0) {
35846
36068
  throw new PrivateCodexSandboxUnavailableError("Codex bundled Bubblewrap is invalid");
35847
36069
  }
@@ -35856,7 +36078,7 @@ async function nativeBubblewrapFor(executablePath, environment, projectDirectory
35856
36078
  }
35857
36079
  async function ordinaryFile2(path2, label) {
35858
36080
  const exact6 = await realpath15(path2);
35859
- const information = await lstat15(exact6);
36081
+ const information = await lstat16(exact6);
35860
36082
  if (!information.isFile() || information.isSymbolicLink()) {
35861
36083
  throw new Error(`${label} is invalid`);
35862
36084
  }
@@ -35901,7 +36123,7 @@ function requireSubscriptionCredential(value) {
35901
36123
  }
35902
36124
  async function exactFile2(path2, label) {
35903
36125
  const exact6 = await realpath15(path2);
35904
- const information = await lstat15(exact6);
36126
+ const information = await lstat16(exact6);
35905
36127
  if (exact6 !== path2 || !information.isFile() || information.isSymbolicLink()) {
35906
36128
  throw new Error(`${label} is invalid`);
35907
36129
  }
@@ -35957,9 +36179,9 @@ function requireBaseURL2(value) {
35957
36179
  }
35958
36180
 
35959
36181
  // src/internal/pi-agent-provider.ts
35960
- import { lstat as lstat16, readFile as readFile5, realpath as realpath16 } from "fs/promises";
36182
+ import { lstat as lstat17, readFile as readFile5, realpath as realpath16 } from "fs/promises";
35961
36183
  import { homedir as homedir3 } from "os";
35962
- import { dirname as dirname13, join as join20, resolve as resolve8 } from "path";
36184
+ import { dirname as dirname14, join as join21, resolve as resolve8 } from "path";
35963
36185
  var PI_CLIENT = "pi";
35964
36186
  var SANDBOX_LAUNCHER_PATH3 = "/agent/pi-agent-launcher.js";
35965
36187
  var SANDBOX_ADAPTER_PATH3 = "/agent/pi-acp.js";
@@ -35987,15 +36209,15 @@ async function openPrivatePiAgentProvider(releaseRoot, environment = process.env
35987
36209
  throw new Error("native Pi support enters the project");
35988
36210
  return exact6;
35989
36211
  }
35990
- const nativeRoot = dirname13(executablePath);
36212
+ const nativeRoot = dirname14(executablePath);
35991
36213
  const support = await checkAcpSetup("installation", async () => Object.freeze({
35992
- launcherPath: join20(releaseRoot, "libexec", "agent", "pi-agent-launcher.js"),
35993
- adapterPath: join20(releaseRoot, "libexec", "agent", "pi-acp.js"),
36214
+ launcherPath: join21(releaseRoot, "libexec", "agent", "pi-agent-launcher.js"),
36215
+ adapterPath: join21(releaseRoot, "libexec", "agent", "pi-acp.js"),
35994
36216
  executablePath,
35995
36217
  runtimeMounts: runtime.mounts,
35996
- manifestPath: await piManifestFile(await asset(join20(nativeRoot, "package.json"))),
35997
- darkThemePath: await ordinaryFile3(await asset(join20(nativeRoot, "theme", "dark.json")), "native Pi dark theme"),
35998
- lightThemePath: await ordinaryFile3(await asset(join20(nativeRoot, "theme", "light.json")), "native Pi light theme"),
36218
+ manifestPath: await piManifestFile(await asset(join21(nativeRoot, "package.json"))),
36219
+ darkThemePath: await ordinaryFile3(await asset(join21(nativeRoot, "theme", "dark.json")), "native Pi dark theme"),
36220
+ lightThemePath: await ordinaryFile3(await asset(join21(nativeRoot, "theme", "light.json")), "native Pi light theme"),
35999
36221
  certificatesPath: await ordinaryFile3(process.platform === "darwin" ? "/etc/ssl/cert.pem" : "/etc/ssl/certs/ca-certificates.crt", "host certificate bundle")
36000
36222
  }));
36001
36223
  const provider = environment.PI_PROVIDER;
@@ -36020,7 +36242,7 @@ async function openPrivatePiAgentProvider(releaseRoot, environment = process.env
36020
36242
  if (configuredAgentDirectory !== undefined && (configuredAgentDirectory.length === 0 || configuredAgentDirectory.includes("\x00"))) {
36021
36243
  throw new PrivateAcpSetupError("login");
36022
36244
  }
36023
- const credentialPath = join20(configuredAgentDirectory === undefined ? join20(homedir3(), ".pi", "agent") : resolve8(configuredAgentDirectory), "auth.json");
36245
+ const credentialPath = join21(configuredAgentDirectory === undefined ? join21(homedir3(), ".pi", "agent") : resolve8(configuredAgentDirectory), "auth.json");
36024
36246
  const sourceCredential = await checkAcpSetup("login", () => readCredentialFile(credentialPath));
36025
36247
  let credential;
36026
36248
  try {
@@ -36124,17 +36346,17 @@ async function createPiProvider(value) {
36124
36346
  },
36125
36347
  {
36126
36348
  source: value.support.manifestPath,
36127
- destination: join20(dirname13(value.support.executablePath), "package.json"),
36349
+ destination: join21(dirname14(value.support.executablePath), "package.json"),
36128
36350
  role: "support"
36129
36351
  },
36130
36352
  {
36131
36353
  source: value.support.darkThemePath,
36132
- destination: join20(dirname13(value.support.executablePath), "theme", "dark.json"),
36354
+ destination: join21(dirname14(value.support.executablePath), "theme", "dark.json"),
36133
36355
  role: "support"
36134
36356
  },
36135
36357
  {
36136
36358
  source: value.support.lightThemePath,
36137
- destination: join20(dirname13(value.support.executablePath), "theme", "light.json"),
36359
+ destination: join21(dirname14(value.support.executablePath), "theme", "light.json"),
36138
36360
  role: "support"
36139
36361
  }
36140
36362
  ]
@@ -36263,7 +36485,7 @@ function isRecord3(value) {
36263
36485
  }
36264
36486
  async function ordinaryFile3(path2, label) {
36265
36487
  const exact6 = await realpath16(path2);
36266
- const information = await lstat16(exact6);
36488
+ const information = await lstat17(exact6);
36267
36489
  if (!information.isFile() || information.isSymbolicLink()) {
36268
36490
  throw new Error(`${label} is invalid`);
36269
36491
  }
@@ -36284,7 +36506,7 @@ async function piManifestFile(path2) {
36284
36506
  }
36285
36507
  async function readCredentialFile(path2) {
36286
36508
  const exact6 = await realpath16(path2);
36287
- const information = await lstat16(exact6);
36509
+ const information = await lstat17(exact6);
36288
36510
  const uid = process.getuid?.();
36289
36511
  if (!information.isFile() || information.isSymbolicLink() || information.nlink !== 1 || information.size <= 0 || information.size > MAX_CREDENTIAL_BYTES2 || uid === undefined || information.uid !== uid || (information.mode & 63) !== 0) {
36290
36512
  throw new Error("Pi subscription credential projection is invalid");
@@ -36317,7 +36539,7 @@ var CLIENT_IDENTITIES = {
36317
36539
  };
36318
36540
  function openPrivateAcpResources(installedSupport, environment, projectDirectory, openClient = openQualifiedClient) {
36319
36541
  const support = requirePrivateInstalledBunSupport(installedSupport);
36320
- if (!isAbsolute6(projectDirectory) || projectDirectory.includes("\x00"))
36542
+ if (!isAbsolute7(projectDirectory) || projectDirectory.includes("\x00"))
36321
36543
  throw new TypeError("ACP resources require the fixed absolute project directory");
36322
36544
  const owner = Object.freeze({ kind: "private-acp-resources/1" });
36323
36545
  owners.set(owner, {
@@ -36364,8 +36586,8 @@ async function selectPrivateAcpResources(owner, slots, installedSupport) {
36364
36586
  return Object.freeze(selected);
36365
36587
  }
36366
36588
  async function openQualifiedClient(client, support, environment, projectDirectory, model) {
36367
- const open14 = client === "codex" ? openPrivateCodexAgentProvider : client === "claude" ? openPrivateClaudeAgentProvider : openPrivatePiAgentProvider;
36368
- return await open14(support.releaseRoot, environment, projectDirectory, model);
36589
+ const open16 = client === "codex" ? openPrivateCodexAgentProvider : client === "claude" ? openPrivateClaudeAgentProvider : openPrivatePiAgentProvider;
36590
+ return await open16(support.releaseRoot, environment, projectDirectory, model);
36369
36591
  }
36370
36592
 
36371
36593
  // src/internal/bun-direct-run.ts
@@ -36534,9 +36756,9 @@ function logicalLaunchDigest(request, execution, installedSupport, mechanism, ht
36534
36756
  bunPolicy: BUN_POLICY2,
36535
36757
  runtimePredicates: RUNTIME_PREDICATES,
36536
36758
  fileProfile: {
36537
- inputBytes: 8 * 1024 * 1024,
36538
- inputFiles: 64,
36539
- outputBytes: 16 * 1024 * 1024,
36759
+ inputBytes: PRIVATE_CAPTURE_LIMITS.input,
36760
+ inputFiles: PRIVATE_FILE_LIMITS.files,
36761
+ outputBytes: PRIVATE_CAPTURE_LIMITS.output,
36540
36762
  rootOnly: true
36541
36763
  },
36542
36764
  slots: request.slots,
@@ -36665,7 +36887,7 @@ function normalizeLock(value) {
36665
36887
  const root = exactObject2(value, [
36666
36888
  "packages",
36667
36889
  "bindings",
36668
- ...Object.hasOwn(object7(value, "lock"), "entrypoint") ? ["entrypoint"] : []
36890
+ ...Object.hasOwn(object8(value, "lock"), "entrypoint") ? ["entrypoint"] : []
36669
36891
  ], "lock");
36670
36892
  const packages = normalizePackages(root.packages);
36671
36893
  const bindings = normalizeBindings(root.bindings);
@@ -36686,7 +36908,7 @@ function normalizeLock(value) {
36686
36908
  });
36687
36909
  }
36688
36910
  function normalizePackages(value) {
36689
- const input = object7(value, "packages");
36911
+ const input = object8(value, "packages");
36690
36912
  const paths2 = Object.keys(input);
36691
36913
  assertNoProjectPathCollisions(paths2, "lock package");
36692
36914
  const output = Object.create(null);
@@ -36696,8 +36918,8 @@ function normalizePackages(value) {
36696
36918
  "digest",
36697
36919
  "directRun",
36698
36920
  "uses",
36699
- ...Object.hasOwn(object7(input[path2], `package ${path2}`), "supports") ? ["supports"] : [],
36700
- ...Object.hasOwn(object7(input[path2], `package ${path2}`), "slots") ? ["slots"] : []
36921
+ ...Object.hasOwn(object8(input[path2], `package ${path2}`), "supports") ? ["supports"] : [],
36922
+ ...Object.hasOwn(object8(input[path2], `package ${path2}`), "slots") ? ["slots"] : []
36701
36923
  ], `package ${path2}`);
36702
36924
  if (typeof item2.directRun !== "boolean") {
36703
36925
  throw new TypeError(`package ${path2} directRun must be boolean`);
@@ -36722,20 +36944,20 @@ function normalizeFeatureNames(value) {
36722
36944
  return Object.freeze([...value]);
36723
36945
  }
36724
36946
  function normalizeUses(value, label) {
36725
- const input = object7(value, `${label} uses`);
36947
+ const input = object8(value, `${label} uses`);
36726
36948
  const names = Object.keys(input);
36727
36949
  if (names.length > 256)
36728
36950
  throw new TypeError(`${label} uses exceed 256 entries`);
36729
36951
  const output = Object.create(null);
36730
36952
  for (const name of names.sort()) {
36731
36953
  localName3(name, `${label} invocation slot`);
36732
- const requirement = object7(input[name], `${label} slot ${name}`);
36954
+ const requirement = object8(input[name], `${label} slot ${name}`);
36733
36955
  output[name] = Object.keys(requirement).length === 0 ? Object.freeze({}) : normalizeInvocationRequirement(requirement);
36734
36956
  }
36735
36957
  return Object.freeze(output);
36736
36958
  }
36737
36959
  function normalizeBindings(value) {
36738
- const input = object7(value, "bindings");
36960
+ const input = object8(value, "bindings");
36739
36961
  const output = Object.create(null);
36740
36962
  for (const id of Object.keys(input).sort()) {
36741
36963
  localName3(id, `Binding ${JSON.stringify(id)}`);
@@ -36743,9 +36965,9 @@ function normalizeBindings(value) {
36743
36965
  "packagePath",
36744
36966
  "settings",
36745
36967
  "slots",
36746
- ...Object.hasOwn(object7(input[id], `Binding ${id}`), "attachments") ? ["attachments"] : []
36968
+ ...Object.hasOwn(object8(input[id], `Binding ${id}`), "attachments") ? ["attachments"] : []
36747
36969
  ], `Binding ${id}`);
36748
- const settings = object7(item2.settings, `Binding ${id} settings`);
36970
+ const settings = object8(item2.settings, `Binding ${id} settings`);
36749
36971
  const slots = normalizeSlots(item2.slots, `Binding ${id}`);
36750
36972
  output[id] = Object.freeze({
36751
36973
  packagePath: projectPath(item2.packagePath, `Binding ${id} packagePath`),
@@ -36789,14 +37011,14 @@ function validateReferences(packages, bindings) {
36789
37011
  validateChildGraph(new Map(Object.entries(bindings)), directFlows);
36790
37012
  }
36791
37013
  function normalizeSlots(value, label) {
36792
- const input = object7(value, `${label} slots`);
37014
+ const input = object8(value, `${label} slots`);
36793
37015
  const names = Object.keys(input);
36794
37016
  if (names.length > 256)
36795
37017
  throw new TypeError(`${label} slots exceed 256 entries`);
36796
37018
  const output = Object.create(null);
36797
37019
  for (const name of names.sort()) {
36798
37020
  localName3(name, `${label} slot`);
36799
- const target = object7(input[name], `${label} slot ${name}`);
37021
+ const target = object8(input[name], `${label} slot ${name}`);
36800
37022
  if (target.kind === "grant") {
36801
37023
  exactObject2(target, ["kind", "policy", ...Object.hasOwn(target, "name") ? ["name"] : []], label);
36802
37024
  output[name] = Object.freeze({
@@ -36838,14 +37060,14 @@ function digest4(value, label) {
36838
37060
  }
36839
37061
  return value;
36840
37062
  }
36841
- function object7(value, label) {
37063
+ function object8(value, label) {
36842
37064
  if (value === null || typeof value !== "object" || Array.isArray(value)) {
36843
37065
  throw new TypeError(`${label} must be an object`);
36844
37066
  }
36845
37067
  return value;
36846
37068
  }
36847
37069
  function exactObject2(value, fields, label) {
36848
- const result2 = object7(value, label);
37070
+ const result2 = object8(value, label);
36849
37071
  const actual = Object.keys(result2).sort();
36850
37072
  const expected = [...fields].sort();
36851
37073
  if (actual.length !== expected.length || actual.some((key, index) => key !== expected[index])) {
@@ -37437,8 +37659,8 @@ function normalizeEmbeddedLock(value, label, decoded) {
37437
37659
  if (!decoded) {
37438
37660
  return decodePrivateProjectLocalLock(encodePrivateProjectLocalLock(value));
37439
37661
  }
37440
- const object8 = plainObject(value, label);
37441
- return decodePrivateProjectLocalLock(encodeRecord(object8, label));
37662
+ const object9 = plainObject(value, label);
37663
+ return decodePrivateProjectLocalLock(encodeRecord(object9, label));
37442
37664
  }
37443
37665
  function samePrivateLocks(left, right) {
37444
37666
  return sameBytes2(encodePrivateProjectLocalLock(left), encodePrivateProjectLocalLock(right));
@@ -39784,8 +40006,8 @@ async function openCoordinatorLock(owner) {
39784
40006
  const directoryInformation = await owner.directory.stat({ bigint: true });
39785
40007
  const databaseInformation = await ensureDatabaseFile(databasePath, owner.directory, directoryInformation.dev, true, COORDINATOR_DATABASE_NAME);
39786
40008
  await validateSidecars(owner.directory, databaseInformation.dev, COORDINATOR_DATABASE_NAME);
39787
- const visibleStatePath = join21(await sqliteVisibleRoot(owner.root), STATE_DIRECTORY);
39788
- const visibleDatabasePath = join21(visibleStatePath, COORDINATOR_DATABASE_NAME);
40009
+ const visibleStatePath = join22(await sqliteVisibleRoot(owner.root), STATE_DIRECTORY);
40010
+ const visibleDatabasePath = join22(visibleStatePath, COORDINATOR_DATABASE_NAME);
39789
40011
  await verifyVisibleHierarchy(owner.root, visibleStatePath, directoryInformation, visibleDatabasePath, databaseInformation);
39790
40012
  const sqlite = loadSqlite();
39791
40013
  const flags = sqliteFlag(sqlite, "SQLITE_OPEN_READWRITE") | sqliteFlag(sqlite, "SQLITE_OPEN_NOFOLLOW");
@@ -39845,15 +40067,15 @@ function initializeOrVerifyCoordinatorSchema(database) {
39845
40067
  throw error;
39846
40068
  }
39847
40069
  try {
39848
- const version = pragmaInteger(database, "user_version");
40070
+ const version2 = pragmaInteger(database, "user_version");
39849
40071
  const application = pragmaInteger(database, "application_id");
39850
40072
  const existing = schemaRows(database);
39851
- if (version === 0n && application === 0n && existing.length === 0) {
40073
+ if (version2 === 0n && application === 0n && existing.length === 0) {
39852
40074
  database.exec(CREATE_COORDINATOR_LOCK);
39853
40075
  database.exec("INSERT INTO coordinator_lock(singleton) VALUES (1)");
39854
40076
  database.exec(`PRAGMA application_id=${COORDINATOR_APPLICATION_ID}`);
39855
40077
  database.exec(`PRAGMA user_version=${COORDINATOR_SCHEMA_VERSION}`);
39856
- } else if (version !== COORDINATOR_SCHEMA_VERSION || application !== COORDINATOR_APPLICATION_ID) {
40078
+ } else if (version2 !== COORDINATOR_SCHEMA_VERSION || application !== COORDINATOR_APPLICATION_ID) {
39857
40079
  invalid("COORDINATOR_SCHEMA_VERSION", "private coordinator database has an unsupported format identity");
39858
40080
  }
39859
40081
  const rows = schemaRows(database);
@@ -39998,8 +40220,8 @@ async function inspectPrivateApprovedProject(projectRoot, selector, checkEnviron
39998
40220
  await owner.dispose();
39999
40221
  }
40000
40222
  }
40001
- async function openStateOwner(projectRoot, create, access5 = "read-write") {
40002
- if (create && access5 === "read-only")
40223
+ async function openStateOwner(projectRoot, create, access6 = "read-write") {
40224
+ if (create && access6 === "read-only")
40003
40225
  throw new TypeError("read-only state cannot be created");
40004
40226
  const ownsRoot = typeof projectRoot === "string";
40005
40227
  const root = ownsRoot ? await openPrivateProjectRoot(projectRoot) : requirePrivateProjectRoot(projectRoot);
@@ -40027,15 +40249,15 @@ async function openStateOwner(projectRoot, create, access5 = "read-write") {
40027
40249
  const databaseExists = await pathExists2(databasePath);
40028
40250
  const databaseInformation = await ensureDatabaseFile(databasePath, directory, directoryInformation.dev, create && !databaseExists);
40029
40251
  await validateSidecars(directory, databaseInformation.dev);
40030
- const visibleStatePath = join21(await sqliteVisibleRoot(root), STATE_DIRECTORY);
40031
- const visibleDatabasePath = join21(visibleStatePath, DATABASE_NAME);
40252
+ const visibleStatePath = join22(await sqliteVisibleRoot(root), STATE_DIRECTORY);
40253
+ const visibleDatabasePath = join22(visibleStatePath, DATABASE_NAME);
40032
40254
  await verifyVisibleHierarchy(root, visibleStatePath, directoryInformation, visibleDatabasePath, databaseInformation);
40033
40255
  const sqlite = loadSqlite();
40034
- const flags = sqliteFlag(sqlite, access5 === "read-only" ? "SQLITE_OPEN_READONLY" : "SQLITE_OPEN_READWRITE") | sqliteFlag(sqlite, "SQLITE_OPEN_NOFOLLOW");
40256
+ const flags = sqliteFlag(sqlite, access6 === "read-only" ? "SQLITE_OPEN_READONLY" : "SQLITE_OPEN_READWRITE") | sqliteFlag(sqlite, "SQLITE_OPEN_NOFOLLOW");
40035
40257
  database = sqlite.Database.open(visibleDatabasePath, flags);
40036
40258
  await verifyVisibleHierarchy(root, visibleStatePath, directoryInformation, visibleDatabasePath, databaseInformation);
40037
40259
  configureConnection(database);
40038
- if (access5 === "read-only") {
40260
+ if (access6 === "read-only") {
40039
40261
  database.exec("PRAGMA query_only=ON; BEGIN");
40040
40262
  if (pragmaInteger(database, "user_version") !== SCHEMA_VERSION || pragmaInteger(database, "application_id") !== APPLICATION_ID) {
40041
40263
  invalid("ADMISSION_SCHEMA_VERSION", "private admission database has an unsupported format identity");
@@ -40147,7 +40369,7 @@ async function openCheckedDirectory(path2, projectDevice) {
40147
40369
  throw error;
40148
40370
  }
40149
40371
  requireStateDirectory(observed, projectDevice);
40150
- const handle = await openPrivateFile(path2, constants23.O_RDONLY | constants23.O_DIRECTORY | constants23.O_NOFOLLOW | constants23.O_NONBLOCK);
40372
+ const handle = await openPrivateFile(path2, constants26.O_RDONLY | constants26.O_DIRECTORY | constants26.O_NOFOLLOW | constants26.O_NONBLOCK);
40151
40373
  try {
40152
40374
  const information = await handle.stat({ bigint: true });
40153
40375
  requireStateDirectory(information, projectDevice);
@@ -40177,7 +40399,7 @@ async function ensureDatabaseFile(path2, directory, expectedDevice, create, data
40177
40399
  if (create) {
40178
40400
  let handle2;
40179
40401
  try {
40180
- handle2 = await openPrivateFile(path2, constants23.O_RDWR | constants23.O_CREAT | constants23.O_EXCL | constants23.O_NOFOLLOW, 384);
40402
+ handle2 = await openPrivateFile(path2, constants26.O_RDWR | constants26.O_CREAT | constants26.O_EXCL | constants26.O_NOFOLLOW, 384);
40181
40403
  await handle2.sync();
40182
40404
  await handle2.close();
40183
40405
  handle2 = undefined;
@@ -40199,7 +40421,7 @@ async function ensureDatabaseFile(path2, directory, expectedDevice, create, data
40199
40421
  throw error;
40200
40422
  }
40201
40423
  requireDatabaseFile(observed, expectedDevice);
40202
- const handle = await openPrivateFile(path2, constants23.O_RDONLY | constants23.O_NOFOLLOW | constants23.O_NONBLOCK);
40424
+ const handle = await openPrivateFile(path2, constants26.O_RDONLY | constants26.O_NOFOLLOW | constants26.O_NONBLOCK);
40203
40425
  try {
40204
40426
  const information = await handle.stat({ bigint: true });
40205
40427
  requireDatabaseFile(information, expectedDevice);
@@ -40257,10 +40479,10 @@ function initializeOrVerifySchema(database, root) {
40257
40479
  throw error;
40258
40480
  }
40259
40481
  try {
40260
- const version = pragmaInteger(database, "user_version");
40482
+ const version2 = pragmaInteger(database, "user_version");
40261
40483
  const application = pragmaInteger(database, "application_id");
40262
40484
  const existing = schemaRows(database);
40263
- if (version === 0n && application === 0n && existing.length === 0) {
40485
+ if (version2 === 0n && application === 0n && existing.length === 0) {
40264
40486
  database.exec(CREATE_CANDIDATES);
40265
40487
  database.exec(CREATE_CANDIDATE_HEAD);
40266
40488
  database.exec(CREATE_REVIEW_PLANS);
@@ -40278,7 +40500,7 @@ function initializeOrVerifySchema(database, root) {
40278
40500
  database.exec("INSERT INTO coordinator_head(singleton, epoch) VALUES (1, 0)");
40279
40501
  database.exec(`PRAGMA application_id=${APPLICATION_ID}`);
40280
40502
  database.exec(`PRAGMA user_version=${SCHEMA_VERSION}`);
40281
- } else if (version !== SCHEMA_VERSION || application !== APPLICATION_ID) {
40503
+ } else if (version2 !== SCHEMA_VERSION || application !== APPLICATION_ID) {
40282
40504
  invalid("ADMISSION_SCHEMA_VERSION", "private admission database has an unsupported format identity");
40283
40505
  }
40284
40506
  verifySchema(database, root);
@@ -40743,7 +40965,7 @@ async function observeVisibleLock(root) {
40743
40965
  const path2 = privateChildLocation(root.handle, LOCK_NAME);
40744
40966
  let handle;
40745
40967
  try {
40746
- handle = await openPrivateFile(path2, constants23.O_RDONLY | constants23.O_NOFOLLOW | constants23.O_NONBLOCK);
40968
+ handle = await openPrivateFile(path2, constants26.O_RDONLY | constants26.O_NOFOLLOW | constants26.O_NONBLOCK);
40747
40969
  } catch (error) {
40748
40970
  if (hasCode3(error, "ENOENT"))
40749
40971
  return Object.freeze({ state: "absent" });
@@ -40835,7 +41057,7 @@ async function synchronizeExactVisibleLock(owner, proposed) {
40835
41057
  const path2 = privateChildLocation(owner.root.handle, LOCK_NAME);
40836
41058
  let handle;
40837
41059
  try {
40838
- handle = await openPrivateFile(path2, constants23.O_RDONLY | constants23.O_NOFOLLOW | constants23.O_NONBLOCK);
41060
+ handle = await openPrivateFile(path2, constants26.O_RDONLY | constants26.O_NOFOLLOW | constants26.O_NONBLOCK);
40839
41061
  } catch (error) {
40840
41062
  if (hasCode3(error, "ENOENT"))
40841
41063
  stale("jig.lock disappeared before admission");
@@ -40866,7 +41088,7 @@ async function publishVisibleLock(owner, plan, proposed) {
40866
41088
  await clearSafeLockStage(owner);
40867
41089
  const stagePath = privateChildLocation(owner.directory, LOCK_STAGE_NAME);
40868
41090
  const lockPath = privateChildLocation(owner.root.handle, LOCK_NAME);
40869
- const handle = await openPrivateFile(stagePath, constants23.O_RDWR | constants23.O_CREAT | constants23.O_EXCL | constants23.O_NOFOLLOW | constants23.O_NONBLOCK, 384);
41091
+ const handle = await openPrivateFile(stagePath, constants26.O_RDWR | constants26.O_CREAT | constants26.O_EXCL | constants26.O_NOFOLLOW | constants26.O_NONBLOCK, 384);
40870
41092
  let failure;
40871
41093
  try {
40872
41094
  const opened = await handle.stat({ bigint: true });
@@ -41286,9 +41508,9 @@ function hasCode3(error, code2) {
41286
41508
 
41287
41509
  // src/internal/contract-import.ts
41288
41510
  import { randomBytes as randomBytes6 } from "crypto";
41289
- import { constants as constants24 } from "fs";
41290
- import { lstat as lstat17, open as open14, realpath as realpath18 } from "fs/promises";
41291
- import { basename as basename3, dirname as dirname14, resolve as resolve9 } from "path";
41511
+ import { constants as constants27 } from "fs";
41512
+ import { lstat as lstat18, open as open16, realpath as realpath18 } from "fs/promises";
41513
+ import { basename as basename4, dirname as dirname15, resolve as resolve9 } from "path";
41292
41514
  init_file_input();
41293
41515
  async function installedDescriptor(selector, destination) {
41294
41516
  let name;
@@ -41297,17 +41519,17 @@ async function installedDescriptor(selector, destination) {
41297
41519
  } catch {
41298
41520
  invalid("CONTRACT_IMPORT_SOURCE", "Select an exact npm package name without a version or subpath.", selector);
41299
41521
  }
41300
- let directory = dirname14(resolve9(destination));
41522
+ let directory = dirname15(resolve9(destination));
41301
41523
  for (;; ) {
41302
41524
  const packagePath = resolve9(directory, "node_modules", name);
41303
41525
  try {
41304
- await lstat17(packagePath);
41526
+ await lstat18(packagePath);
41305
41527
  return resolve9(packagePath, "FLOW.contract.json");
41306
41528
  } catch (error) {
41307
41529
  if (error.code !== "ENOENT")
41308
41530
  throw error;
41309
41531
  }
41310
- const parent = dirname14(directory);
41532
+ const parent = dirname15(directory);
41311
41533
  if (parent === directory)
41312
41534
  break;
41313
41535
  directory = parent;
@@ -41323,8 +41545,8 @@ async function importContract(source, destination, signal) {
41323
41545
  try {
41324
41546
  signal?.throwIfAborted();
41325
41547
  const selected = source.startsWith("npm:") ? await installedDescriptor(source, destination) : source;
41326
- const name = basename3(selected);
41327
- root = await open14(await realpath18(dirname14(resolve9(selected))), constants24.O_RDONLY | constants24.O_DIRECTORY | constants24.O_NOFOLLOW);
41548
+ const name = basename4(selected);
41549
+ root = await open16(await realpath18(dirname15(resolve9(selected))), constants27.O_RDONLY | constants27.O_DIRECTORY | constants27.O_NOFOLLOW);
41328
41550
  const capture = (paths3) => captureOpenedPackageDirectory(selected, root, {
41329
41551
  includes: (path2) => paths3.some((p) => p === path2 || p.startsWith(`${path2}/`)),
41330
41552
  maximumFiles: 65,
@@ -41347,12 +41569,12 @@ async function importContract(source, destination, signal) {
41347
41569
  signal?.throwIfAborted();
41348
41570
  phase = "destination";
41349
41571
  const target = resolve9(destination);
41350
- const leaf = privateFilePath(basename3(target));
41351
- parent = await open14(await realpath18(dirname14(target)), constants24.O_RDONLY | constants24.O_DIRECTORY | constants24.O_NOFOLLOW);
41572
+ const leaf = privateFilePath(basename4(target));
41573
+ parent = await open16(await realpath18(dirname15(target)), constants27.O_RDONLY | constants27.O_DIRECTORY | constants27.O_NOFOLLOW);
41352
41574
  const allocation = privateChildLocation(parent, `.jig-contract-${randomBytes6(16).toString("hex")}`);
41353
41575
  await mkdirPrivateFile(allocation);
41354
41576
  staged = allocation;
41355
- const stage = await openPrivateFile(staged, constants24.O_RDONLY | constants24.O_DIRECTORY | constants24.O_NOFOLLOW);
41577
+ const stage = await openPrivateFile(staged, constants27.O_RDONLY | constants27.O_DIRECTORY | constants27.O_NOFOLLOW);
41356
41578
  try {
41357
41579
  for (const path2 of paths2) {
41358
41580
  signal?.throwIfAborted();
@@ -41395,10 +41617,10 @@ async function writeCaptured(root, path2, bytes) {
41395
41617
  if (error.code !== "EEXIST")
41396
41618
  throw error;
41397
41619
  });
41398
- parent = await openPrivateFile(directory, constants24.O_RDONLY | constants24.O_DIRECTORY | constants24.O_NOFOLLOW);
41620
+ parent = await openPrivateFile(directory, constants27.O_RDONLY | constants27.O_DIRECTORY | constants27.O_NOFOLLOW);
41399
41621
  handles2.push(parent);
41400
41622
  }
41401
- const file = await openPrivateFile(privateChildLocation(parent, parts.at(-1)), constants24.O_WRONLY | constants24.O_CREAT | constants24.O_EXCL | constants24.O_NOFOLLOW, 384);
41623
+ const file = await openPrivateFile(privateChildLocation(parent, parts.at(-1)), constants27.O_WRONLY | constants27.O_CREAT | constants27.O_EXCL | constants27.O_NOFOLLOW, 384);
41402
41624
  try {
41403
41625
  await file.writeFile(bytes);
41404
41626
  } finally {
@@ -41414,7 +41636,7 @@ async function removeStage(location) {
41414
41636
  const visit2 = async (current2, depth) => {
41415
41637
  if (depth > 512)
41416
41638
  throw new Error("contract staging cleanup exceeds its depth bound");
41417
- const directory = await openPrivateFile(current2, constants24.O_RDONLY | constants24.O_DIRECTORY | constants24.O_NOFOLLOW);
41639
+ const directory = await openPrivateFile(current2, constants27.O_RDONLY | constants27.O_DIRECTORY | constants27.O_NOFOLLOW);
41418
41640
  try {
41419
41641
  for await (const entry of privateDirectoryEntries(directory)) {
41420
41642
  if (++entries > 65536)
@@ -41495,19 +41717,19 @@ var EVALUATOR_HINTS = Object.freeze({
41495
41717
  });
41496
41718
 
41497
41719
  // src/project-init.ts
41498
- import { constants as constants25 } from "fs";
41720
+ import { constants as constants28 } from "fs";
41499
41721
  import {
41500
- lstat as lstat18,
41722
+ lstat as lstat19,
41501
41723
  mkdir as mkdir6,
41502
41724
  mkdtemp as mkdtemp5,
41503
- open as open15,
41725
+ open as open17,
41504
41726
  readFile as readFile6,
41505
41727
  rm as rm2,
41506
41728
  rmdir as rmdir6,
41507
41729
  unlink as unlink3,
41508
41730
  writeFile as writeFile2
41509
41731
  } from "fs/promises";
41510
- import { basename as basename4, join as join22, resolve as resolve10 } from "path";
41732
+ import { basename as basename5, join as join23, resolve as resolve10 } from "path";
41511
41733
  init_file_input();
41512
41734
  var DEFAULT_FILE_SYSTEM = {
41513
41735
  mkdir: mkdir6,
@@ -41516,7 +41738,7 @@ var DEFAULT_FILE_SYSTEM = {
41516
41738
  writeFile: writeFile2
41517
41739
  };
41518
41740
  var GREETING_SDK_VERSION = "0.1.0-alpha.13";
41519
- var AGENT_ACP_VERSION = "0.1.0-alpha.7";
41741
+ var AGENT_ACP_VERSION = "0.1.0-alpha.8";
41520
41742
 
41521
41743
  class ProjectInitError extends Error {
41522
41744
  code;
@@ -41536,12 +41758,12 @@ async function createFlow(project, name, uses = [], signal) {
41536
41758
  signal?.throwIfAborted();
41537
41759
  let sdk = GREETING_SDK_VERSION;
41538
41760
  try {
41539
- const definition = await lstat18(join22(project, "jig.ts"));
41761
+ const definition = await lstat19(join23(project, "jig.ts"));
41540
41762
  if (!definition.isFile() || definition.isSymbolicLink())
41541
41763
  throw new Error("not a regular project definition");
41542
41764
  try {
41543
- const path2 = join22(project, "package.json");
41544
- const info = await lstat18(path2);
41765
+ const path2 = join23(project, "package.json");
41766
+ const info = await lstat19(path2);
41545
41767
  if (!info.isFile() || info.size > 262144)
41546
41768
  throw new Error("unsafe manifest");
41547
41769
  const manifest = JSON.parse(await readFile6(path2, "utf8"));
@@ -41558,8 +41780,8 @@ async function createFlow(project, name, uses = [], signal) {
41558
41780
  } catch {
41559
41781
  throw new ProjectInitError("invalid", "JIG_NEW_INVALID", "Run jig new from a project with a regular jig.ts and a readable, valid package.json if present. No source was evaluated.");
41560
41782
  }
41561
- const flows = join22(project, "flows");
41562
- const destination = join22(flows, name);
41783
+ const flows = join23(project, "flows");
41784
+ const destination = join23(flows, name);
41563
41785
  const created = [];
41564
41786
  let staged;
41565
41787
  let createdFlows = false, createdDestination = false;
@@ -41570,7 +41792,7 @@ async function createFlow(project, name, uses = [], signal) {
41570
41792
  } catch (error) {
41571
41793
  if (errorCode(error) !== "EEXIST")
41572
41794
  throw error;
41573
- if (!(await lstat18(flows)).isDirectory())
41795
+ if (!(await lstat19(flows)).isDirectory())
41574
41796
  throw new Error("flows must be a directory, not a link");
41575
41797
  }
41576
41798
  try {
@@ -41579,27 +41801,27 @@ async function createFlow(project, name, uses = [], signal) {
41579
41801
  createdDestination = true;
41580
41802
  } else {
41581
41803
  try {
41582
- await lstat18(destination);
41804
+ await lstat19(destination);
41583
41805
  throw Object.assign(new Error("exists"), { code: "EEXIST" });
41584
41806
  } catch (error) {
41585
41807
  if (errorCode(error) !== "ENOENT")
41586
41808
  throw error;
41587
41809
  }
41588
- staged = await mkdtemp5(join22(project, ".jig-new-"));
41810
+ staged = await mkdtemp5(join23(project, ".jig-new-"));
41589
41811
  }
41590
41812
  } catch (error) {
41591
41813
  if (errorCode(error) === "EEXIST")
41592
41814
  throw new ProjectInitError("invalid", "JIG_NEW_EXISTS", "That Flow directory already exists. Choose a different name; existing files were not changed.");
41593
41815
  throw error;
41594
41816
  }
41595
- const projectName = basename4(resolve10(project)).toLowerCase().replace(/[^a-z0-9-]/g, "-").slice(0, 64);
41817
+ const projectName = basename5(resolve10(project)).toLowerCase().replace(/[^a-z0-9-]/g, "-").slice(0, 64);
41596
41818
  const authoredAt = staged ?? destination;
41597
41819
  const declarations = Object.create(null);
41598
41820
  if (uses.length > 0)
41599
- await mkdir6(join22(authoredAt, "contracts"));
41821
+ await mkdir6(join23(authoredAt, "contracts"));
41600
41822
  for (const { slot, source } of uses) {
41601
- const imported = await importContract(source.startsWith("npm:") ? source : resolve10(project, source), join22(authoredAt, "contracts", slot), signal);
41602
- declarations[slot] = { contract: `./contracts/${slot}/${basename4(imported.descriptor)}` };
41823
+ const imported = await importContract(source.startsWith("npm:") ? source : resolve10(project, source), join23(authoredAt, "contracts", slot), signal);
41824
+ declarations[slot] = { contract: `./contracts/${slot}/${basename5(imported.descriptor)}` };
41603
41825
  }
41604
41826
  const files = {
41605
41827
  "FLOW.meta.json": `${JSON.stringify({ name, description: "Describe what this method does.", ...uses.length === 0 ? {} : { uses: declarations } }, null, 2)}
@@ -41615,18 +41837,18 @@ await handle(async (run) => {
41615
41837
  };
41616
41838
  for (const [file, content] of Object.entries(files)) {
41617
41839
  signal?.throwIfAborted();
41618
- const path2 = join22(authoredAt, file);
41840
+ const path2 = join23(authoredAt, file);
41619
41841
  await writeFile2(path2, content, { flag: "wx" });
41620
41842
  if (staged === undefined)
41621
41843
  created.push(path2);
41622
41844
  }
41623
41845
  if (staged !== undefined) {
41624
- const projectDirectory = await open15(project, constants25.O_RDONLY | constants25.O_DIRECTORY | constants25.O_NOFOLLOW);
41846
+ const projectDirectory = await open17(project, constants28.O_RDONLY | constants28.O_DIRECTORY | constants28.O_NOFOLLOW);
41625
41847
  try {
41626
- const flowsDirectory = await openPrivateChild(projectDirectory, "flows", constants25.O_RDONLY | constants25.O_DIRECTORY | constants25.O_NOFOLLOW);
41848
+ const flowsDirectory = await openPrivateChild(projectDirectory, "flows", constants28.O_RDONLY | constants28.O_DIRECTORY | constants28.O_NOFOLLOW);
41627
41849
  try {
41628
41850
  signal?.throwIfAborted();
41629
- privatePublishDirectory(flowsDirectory.fd, basename4(staged), name, projectDirectory.fd);
41851
+ privatePublishDirectory(flowsDirectory.fd, basename5(staged), name, projectDirectory.fd);
41630
41852
  staged = undefined;
41631
41853
  } finally {
41632
41854
  await flowsDirectory.close();
@@ -41670,12 +41892,12 @@ async function createProject(destination, fileSystem = DEFAULT_FILE_SYSTEM, bare
41670
41892
  }
41671
41893
  created.push({ kind: "directory", path: target });
41672
41894
  for (const name of ["flows", "bindings"]) {
41673
- const path2 = join22(target, name);
41895
+ const path2 = join23(target, name);
41674
41896
  await fileSystem.mkdir(path2);
41675
41897
  created.push({ kind: "directory", path: path2 });
41676
41898
  }
41677
41899
  if (!bare) {
41678
- const path2 = join22(target, "flows", "hello");
41900
+ const path2 = join23(target, "flows", "hello");
41679
41901
  await fileSystem.mkdir(path2);
41680
41902
  created.push({ kind: "directory", path: path2 });
41681
41903
  }
@@ -41687,7 +41909,7 @@ async function createProject(destination, fileSystem = DEFAULT_FILE_SYSTEM, bare
41687
41909
  ...agent === undefined ? [] : agentFiles(agent)
41688
41910
  ];
41689
41911
  for (const [name, contents] of files) {
41690
- const path2 = join22(target, name);
41912
+ const path2 = join23(target, name);
41691
41913
  await fileSystem.writeFile(path2, contents, {
41692
41914
  encoding: "utf8",
41693
41915
  flag: "wx"
@@ -42122,10 +42344,10 @@ async function executeCompletion(arguments_, runtime) {
42122
42344
  return 1;
42123
42345
  }
42124
42346
  }
42125
- const script = arguments_.length === 2 ? completionScript(arguments_[1]) : undefined;
42126
- if (script === undefined)
42347
+ const script2 = arguments_.length === 2 ? completionScript(arguments_[1]) : undefined;
42348
+ if (script2 === undefined)
42127
42349
  usage("completion", "Choose bash, zsh, or fish.");
42128
- await runtime.writeRecord(script);
42350
+ await runtime.writeRecord(script2);
42129
42351
  return 0;
42130
42352
  }
42131
42353
  async function executeNew(arguments_, runtime) {
@@ -42209,7 +42431,7 @@ async function executeImportContract(arguments_, runtime) {
42209
42431
  try {
42210
42432
  const result2 = await importContract(arguments_[1].startsWith("npm:") ? arguments_[1] : resolve11(runtime.currentDirectory, arguments_[1]), resolve11(runtime.currentDirectory, arguments_[2]), runtime.signal);
42211
42433
  runtime.writeOutput(`Imported ${result2.files} contract files into ${asciiJsonString(arguments_[2])}.
42212
- Use ${asciiJsonString(basename5(result2.descriptor))} in the caller's slot declaration, then review the project.
42434
+ Use ${asciiJsonString(basename6(result2.descriptor))} in the caller's slot declaration, then review the project.
42213
42435
  `);
42214
42436
  return 0;
42215
42437
  } catch (error) {
@@ -42365,7 +42587,7 @@ function shellWord(value) {
42365
42587
  async function executeReview(arguments_, runtime) {
42366
42588
  let resolutionNoticeShown = false;
42367
42589
  const parsed = parseReview(arguments_, runtime.currentDirectory);
42368
- runtime.progress.note(`Reviewing ${asciiJsonString(basename5(resolve11(runtime.currentDirectory, parsed.project)))}`);
42590
+ runtime.progress.note(`Reviewing ${asciiJsonString(basename6(resolve11(runtime.currentDirectory, parsed.project)))}`);
42369
42591
  const result2 = await withProjectSession(parsed.project, runtime, async (session) => {
42370
42592
  const plan = await privateProfileSpan("project-planning", () => session.plan({ lockMode: "update" }));
42371
42593
  runtime.progress.complete(true);
@@ -42533,7 +42755,7 @@ Check --input and the file contents. No Flow was started.`, 1);
42533
42755
  const files = new PrivateRootRunFiles(capture.attachments, parsed.output === undefined ? null : resolve11(runtime.currentDirectory, parsed.output), runtime.host.delivery);
42534
42756
  try {
42535
42757
  if (parsed.output !== undefined) {
42536
- const occupied = await lstat19(files.identity.output).then(() => true, (error) => {
42758
+ const occupied = await lstat20(files.identity.output).then(() => true, (error) => {
42537
42759
  if (error.code === "ENOENT")
42538
42760
  return false;
42539
42761
  throw new CliDiagnostic("JIG_OUTPUT_INVALID", "cannot inspect --out; check its path and directory permissions. No Flow was started.", 1);
@@ -42907,6 +43129,11 @@ function renderFailure(error, runtime) {
42907
43129
  PACKAGE_ENTRYPOINT_MISSING: "the selected package needs one exact-case FLOW.<suffix> entrypoint",
42908
43130
  PACKAGE_METADATA_OWNER: "keep Markdown frontmatter in FLOW.md; use FLOW.meta.json only with a code entrypoint",
42909
43131
  PACKAGE_SCHEMA_OWNER: "place invocation input and result schemas in FLOW.contract.json",
43132
+ SCHEMA_INVALID: error.diagnostic?.pointer === "/$schema" ? `Set the root "$schema" to "${SCHEMA_1_URI}" in the indicated file, then run jig review again.` : "Correct the indicated schema declaration using FLOW Schema/0; see https://flow.jig.md/spec/schema-files.",
43133
+ SCHEMA_INVALID_JSON: "Use valid UTF-8 JSON/0 without duplicate keys and within its value limits; see https://flow.jig.md/spec/json-values.",
43134
+ SCHEMA_KEYWORD_UNSUPPORTED: "Use only the supported FLOW Schema/0 keywords; see https://flow.jig.md/spec/schema-files.",
43135
+ SCHEMA_REFERENCE_INVALID: "Use an acyclic same-document reference spelled #/$defs/<name> to an existing root definition; see https://flow.jig.md/spec/schema-files.",
43136
+ SCHEMA_LIMIT_EXCEEDED: "Reduce schema size or validation work to the FLOW Schema/0 limits; see https://flow.jig.md/spec/schema-files.",
42910
43137
  PACKAGE_PROFILE_UNSUPPORTED: "use a runtime and single-invocation contract supported by this host",
42911
43138
  PACKAGE_METADATA_UNSUPPORTED: "this host cannot honor the indicated metadata requirement; use a qualified host or revise that requirement explicitly",
42912
43139
  PACKAGE_TOOLS_UNSUPPORTED: "the selected runtime cannot enforce this allowed-tools restriction",
@@ -42952,6 +43179,7 @@ function renderFailure(error, runtime) {
42952
43179
  PACKAGE_BUN_RESOLUTION_VERSION_UNAVAILABLE: "a requested dependency version or tag is unavailable in the registry; check package.json against published versions or use a declared local workspace dependency",
42953
43180
  PACKAGE_BUN_RESOLVED_SOURCE_UNSUPPORTED: "resolved dependencies are unsupported; requests may already have occurred; use integrity-pinned default npm registry dependencies",
42954
43181
  PACKAGE_BUN_SOURCE_UNSUPPORTED: "use default npm registry dependencies or declared workspace members; patches require workspace-root declarations and captured .patch files; overrides and other dependency sources are unsupported",
43182
+ PACKAGE_BUN_LOCK_VERSION_UNSUPPORTED: "the supplied Bun lock format is unsupported by this host; generate it explicitly with Bun 1.3.3 for Linux and Mac, or Bun 1.4.2 for Mac, then review again. Jig does not convert or replace supplied locks",
42955
43183
  PACKAGE_BUN_MANIFEST_SHAPE: "package.json must contain an object",
42956
43184
  PACKAGE_BUN_MANIFEST_FIELD: "the indicated manifest field is unsupported here; use default npm registry dependencies or declared workspace members, with patches declared only at the workspace root",
42957
43185
  PACKAGE_BUN_MANIFEST_DEPENDENCIES: "the indicated dependency section must be an object mapping package names to version requests",
@@ -43182,19 +43410,19 @@ class PrivateCliOutput {
43182
43410
  import { spawn as spawn2 } from "child_process";
43183
43411
  import { randomBytes as randomBytes9 } from "crypto";
43184
43412
  import { closeSync as closeSync14, fstatSync as fstatSync13 } from "fs";
43185
- import { open as open17 } from "fs/promises";
43413
+ import { open as open19 } from "fs/promises";
43186
43414
  import { connect, createServer as createServer3 } from "net";
43187
- import { dirname as dirname16, join as join24 } from "path";
43415
+ import { dirname as dirname17, join as join25 } from "path";
43188
43416
 
43189
43417
  // src/internal/file-delivery.ts
43190
43418
  import { randomBytes as randomBytes8 } from "crypto";
43191
- import { closeSync as closeSync13, constants as constants27, fstatSync as fstatSync11 } from "fs";
43419
+ import { closeSync as closeSync13, constants as constants30, fstatSync as fstatSync11 } from "fs";
43192
43420
  import { statfs as statfs3 } from "fs/promises";
43193
- import { basename as basename6, dirname as dirname15, resolve as resolve12 } from "path";
43421
+ import { basename as basename7, dirname as dirname16, resolve as resolve12 } from "path";
43194
43422
 
43195
43423
  // src/internal/file-delivery-storage.ts
43196
- import { constants as constants26 } from "fs";
43197
- var DIRECTORY4 = constants26.O_RDONLY | constants26.O_DIRECTORY | constants26.O_NOFOLLOW;
43424
+ import { constants as constants29 } from "fs";
43425
+ var DIRECTORY4 = constants29.O_RDONLY | constants29.O_DIRECTORY | constants29.O_NOFOLLOW;
43198
43426
  async function writePrivateDeliveryFile(root, path2, bytes, check) {
43199
43427
  const parts = path2.split("/");
43200
43428
  const handles2 = [];
@@ -43212,7 +43440,7 @@ async function writePrivateDeliveryFile(root, path2, bytes, check) {
43212
43440
  handles2.push(parent);
43213
43441
  }
43214
43442
  check();
43215
- const file = await openPrivateFile(privateChildLocation(parent, parts.at(-1)), constants26.O_WRONLY | constants26.O_CREAT | constants26.O_EXCL | constants26.O_NOFOLLOW);
43443
+ const file = await openPrivateFile(privateChildLocation(parent, parts.at(-1)), constants29.O_WRONLY | constants29.O_CREAT | constants29.O_EXCL | constants29.O_NOFOLLOW);
43216
43444
  try {
43217
43445
  await file.writeFile(bytes);
43218
43446
  } finally {
@@ -43289,7 +43517,7 @@ class PrivateFileDeliveryOwner {
43289
43517
  let parent;
43290
43518
  try {
43291
43519
  this.signal.throwIfAborted();
43292
- const destination = resolve12(directory), parentPath = dirname15(destination), leaf = privateFilePath(basename6(destination));
43520
+ const destination = resolve12(directory), parentPath = dirname16(destination), leaf = privateFilePath(basename7(destination));
43293
43521
  if (destination === parentPath || leaf.includes("/"))
43294
43522
  throw new TypeError("output requires a new directory");
43295
43523
  const selected = privateOpenFileRoot(parentPath);
@@ -43377,7 +43605,7 @@ class PrivateFileDeliveryOwner {
43377
43605
  await this.onStaged?.();
43378
43606
  checkTime();
43379
43607
  let delivery;
43380
- const stage = await openPrivateFile(location, constants27.O_RDONLY | constants27.O_DIRECTORY | constants27.O_NOFOLLOW);
43608
+ const stage = await openPrivateFile(location, constants30.O_RDONLY | constants30.O_DIRECTORY | constants30.O_NOFOLLOW);
43381
43609
  try {
43382
43610
  const opened = await stage.stat({ bigint: true });
43383
43611
  if (opened.ino !== info.ino || opened.dev !== info.dev)
@@ -43485,8 +43713,8 @@ init_file_input();
43485
43713
 
43486
43714
  // src/internal/macos-file-command.ts
43487
43715
  import { fstatSync as fstatSync12, lstatSync as lstatSync6 } from "fs";
43488
- import { mkdtemp as mkdtemp6, open as open16, rmdir as rmdir7 } from "fs/promises";
43489
- import { join as join23 } from "path";
43716
+ import { mkdtemp as mkdtemp6, open as open18, rmdir as rmdir7 } from "fs/promises";
43717
+ import { join as join24 } from "path";
43490
43718
  init_macos_descriptor_files();
43491
43719
  init_macos_process_controls();
43492
43720
  function requirePrivateMacosFilePeer(socket2, expected) {
@@ -43498,7 +43726,7 @@ function requirePrivateMacosFilePeer(socket2, expected) {
43498
43726
  async function createPrivateMacosFileCommand() {
43499
43727
  const peer = privateMacosCurrentProcessIdentity();
43500
43728
  const directory = await mkdtemp6("/private/tmp/jig-file-owner-");
43501
- const parent = await open16(directory, "r");
43729
+ const parent = await open18(directory, "r");
43502
43730
  const identity3 = await parent.stat({ bigint: true });
43503
43731
  let roots;
43504
43732
  let output;
@@ -43558,7 +43786,7 @@ async function createPrivateMacosFileCommand() {
43558
43786
  return Object.freeze({
43559
43787
  directory,
43560
43788
  peer,
43561
- socket: join23(directory, "control"),
43789
+ socket: join24(directory, "control"),
43562
43790
  close,
43563
43791
  controlReady() {
43564
43792
  const info = controlIdentity();
@@ -43924,7 +44152,7 @@ async function privateConnectFileOwner() {
43924
44152
  if (!Array.isArray(roots) || roots.length > 8)
43925
44153
  throw new TypeError("invalid input roots");
43926
44154
  const pending = request({ type: "prepare", destination: path2, rootCount: roots.length });
43927
- const transfer = roots.length ? sendPrivateMacosDescriptors(join24(dirname16(selected.socket), "fd-roots"), selected.peer, roots, 5000, cancellation.signal) : Promise.resolve();
44155
+ const transfer = roots.length ? sendPrivateMacosDescriptors(join25(dirname17(selected.socket), "fd-roots"), selected.peer, roots, 5000, cancellation.signal) : Promise.resolve();
43928
44156
  await Promise.all([pending, transfer]).catch((error) => {
43929
44157
  socket2.destroy();
43930
44158
  throw error;
@@ -43972,7 +44200,7 @@ async function privateConnectFileOwner() {
43972
44200
  },
43973
44201
  cancelled: signal?.aborted ?? false
43974
44202
  });
43975
- const transfer = selected.platform === "darwin" && transferred !== undefined ? sendPrivateMacosDescriptors(join24(dirname16(selected.socket), "fd-output"), selected.peer, [transferred.fd], 5000, cancellation.signal) : Promise.resolve();
44203
+ const transfer = selected.platform === "darwin" && transferred !== undefined ? sendPrivateMacosDescriptors(join25(dirname17(selected.socket), "fd-output"), selected.peer, [transferred.fd], 5000, cancellation.signal) : Promise.resolve();
43976
44204
  const [reply] = await Promise.all([pending, transfer]).catch((error) => {
43977
44205
  socket2.destroy();
43978
44206
  throw error;
@@ -44070,7 +44298,7 @@ async function withLinuxDirectories(pid, descriptors, maximum, work) {
44070
44298
  let result2;
44071
44299
  try {
44072
44300
  for (const fd of descriptors) {
44073
- const directory = await open17(`/proc/${pid}/fd/${fd}`, 65536);
44301
+ const directory = await open19(`/proc/${pid}/fd/${fd}`, 65536);
44074
44302
  directories.push(directory);
44075
44303
  if (!(await directory.stat()).isDirectory())
44076
44304
  throw new TypeError("file transfer requires directories");
@@ -44151,19 +44379,19 @@ async function openPrivateInstalledBunHost(location, environment = process.env,
44151
44379
  init_linux_host_paths();
44152
44380
  import { execFile as execFile2, spawn as spawn3 } from "child_process";
44153
44381
  import { randomBytes as randomBytes10 } from "crypto";
44154
- import { constants as constants28, realpathSync as realpathSync6 } from "fs";
44382
+ import { constants as constants31, realpathSync as realpathSync6 } from "fs";
44155
44383
  import {
44156
- access as access5,
44384
+ access as access6,
44157
44385
  mkdir as mkdir7,
44158
44386
  readFile as readFile7,
44159
44387
  readdir as readdir3,
44160
44388
  realpath as realpath19,
44161
- stat as stat3,
44389
+ stat as stat2,
44162
44390
  statfs as statfs4,
44163
44391
  writeFile as writeFile3
44164
44392
  } from "fs/promises";
44165
44393
  import { createServer as createServer4, connect as connect2 } from "net";
44166
- import { isAbsolute as isAbsolute7, posix as posix12 } from "path";
44394
+ import { isAbsolute as isAbsolute8, posix as posix12 } from "path";
44167
44395
  var CGROUP_ROOT2 = "/sys/fs/cgroup";
44168
44396
  var CGROUP2_SUPER_MAGIC3 = 0x6367_7270n;
44169
44397
  var CHILD_NAME = "jig";
@@ -44214,7 +44442,7 @@ async function acquireOrReexecutePrivateRootlessLinux(input = {}) {
44214
44442
  throw new Error("invalid transient scope identity");
44215
44443
  const command = requireCommand(dependencies.currentCommand(input.commandArguments ?? process.argv.slice(2)));
44216
44444
  const directory = dependencies.currentDirectory();
44217
- if (!isAbsolute7(directory) || directory.includes("\x00")) {
44445
+ if (!isAbsolute8(directory) || directory.includes("\x00")) {
44218
44446
  throw new Error("invalid current directory");
44219
44447
  }
44220
44448
  return await dependencies.reexecute(managerPath, unit, command, directory, environment, commandLifetimeMs, input.signal);
@@ -44242,10 +44470,10 @@ async function preparePrivateRootlessLinuxScope(unit, dependencies = scopeDepend
44242
44470
  if (!information.isDirectory() || information.uid !== uid) {
44243
44471
  throw new Error("the transient scope is not owned by the current user");
44244
44472
  }
44245
- await dependencies.requireAccess(scope, constants28.W_OK | constants28.X_OK);
44246
- await dependencies.requireAccess(`${scope}/cgroup.procs`, constants28.R_OK | constants28.W_OK);
44247
- await dependencies.requireAccess(`${scope}/cgroup.subtree_control`, constants28.R_OK | constants28.W_OK);
44248
- await dependencies.requireAccess(`${scope}/cgroup.kill`, constants28.W_OK);
44473
+ await dependencies.requireAccess(scope, constants31.W_OK | constants31.X_OK);
44474
+ await dependencies.requireAccess(`${scope}/cgroup.procs`, constants31.R_OK | constants31.W_OK);
44475
+ await dependencies.requireAccess(`${scope}/cgroup.subtree_control`, constants31.R_OK | constants31.W_OK);
44476
+ await dependencies.requireAccess(`${scope}/cgroup.kill`, constants31.W_OK);
44249
44477
  requireWords2(await dependencies.readText(`${scope}/cgroup.controllers`), REQUIRED_CONTROLLERS2);
44250
44478
  if ((await dependencies.listDirectories(scope)).length !== 0) {
44251
44479
  throw new Error("the transient scope already contains a child cgroup");
@@ -44301,7 +44529,7 @@ function requirePreparedObservation(observation, unit) {
44301
44529
  }
44302
44530
  }
44303
44531
  function requireCommand(command) {
44304
- if (command.length === 0 || !isAbsolute7(command[0]) || command.some((value) => value.includes("\x00"))) {
44532
+ if (command.length === 0 || !isAbsolute8(command[0]) || command.some((value) => value.includes("\x00"))) {
44305
44533
  throw new Error("the current command is invalid");
44306
44534
  }
44307
44535
  return Object.freeze([...command]);
@@ -44346,8 +44574,8 @@ async function resolveManager() {
44346
44574
  for (const candidate of MANAGER_CANDIDATES) {
44347
44575
  try {
44348
44576
  const resolved = await realpath19(candidate);
44349
- const information = await stat3(resolved);
44350
- if (isAbsolute7(resolved) && information.isFile() && (information.mode & 73) !== 0 && (information.mode & 3072) === 0) {
44577
+ const information = await stat2(resolved);
44578
+ if (isAbsolute8(resolved) && information.isFile() && (information.mode & 73) !== 0 && (information.mode & 3072) === 0) {
44351
44579
  return resolved;
44352
44580
  }
44353
44581
  } catch {}
@@ -44476,8 +44704,8 @@ async function resolveControl() {
44476
44704
  for (const candidate of CONTROL_CANDIDATES) {
44477
44705
  try {
44478
44706
  const resolved = await realpath19(candidate);
44479
- const information = await stat3(resolved);
44480
- if (isAbsolute7(resolved) && information.isFile() && (information.mode & 73) !== 0 && (information.mode & 3072) === 0) {
44707
+ const information = await stat2(resolved);
44708
+ if (isAbsolute8(resolved) && information.isFile() && (information.mode & 73) !== 0 && (information.mode & 3072) === 0) {
44481
44709
  return resolved;
44482
44710
  }
44483
44711
  } catch {}
@@ -44577,7 +44805,7 @@ async function requirePathAbsent(path2, timeoutMs) {
44577
44805
  const deadline = Date.now() + timeoutMs;
44578
44806
  for (;; ) {
44579
44807
  try {
44580
- await stat3(path2);
44808
+ await stat2(path2);
44581
44809
  } catch (error) {
44582
44810
  if (error.code === "ENOENT")
44583
44811
  return;
@@ -44789,10 +45017,10 @@ var scopeDependencies = Object.freeze({
44789
45017
  pid: () => process.pid,
44790
45018
  readText: (path2) => readFile7(path2, "utf8"),
44791
45019
  listDirectories: async (path2) => (await readdir3(path2, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name),
44792
- information: (path2) => stat3(path2),
45020
+ information: (path2) => stat2(path2),
44793
45021
  filesystemType: async (path2) => (await statfs4(path2)).type,
44794
45022
  resolve: (path2) => realpath19(path2),
44795
- requireAccess: (path2, mode) => access5(path2, mode),
45023
+ requireAccess: (path2, mode) => access6(path2, mode),
44796
45024
  makeDirectory: (path2) => mkdir7(path2, { mode: 493 }),
44797
45025
  writeText: (path2, value) => writeFile3(path2, value)
44798
45026
  });
@@ -44808,14 +45036,14 @@ var systemDependencies2 = Object.freeze({
44808
45036
  reexecute: (managerPath, unit, command, directory, environment, commandLifetimeMs, signal) => reexecutePrivateRootlessLinuxCommand(managerPath, unit, command, directory, environment, STARTUP_TIMEOUT_MS, commandLifetimeMs, signal)
44809
45037
  });
44810
45038
  function currentCommand(arguments_) {
44811
- if (process.argv[0] === process.execPath && process.argv[1]?.endsWith("/libexec/installed-cli.js") && isAbsolute7(process.argv[1]) && realpathSync6(process.argv[1]) === process.argv[1] && realpathSync6(process.execPath) === process.execPath && process.execArgv.length === BUN_POLICY3.length && process.execArgv.every((value, index) => value === BUN_POLICY3[index])) {
45039
+ if (process.argv[0] === process.execPath && process.argv[1]?.endsWith("/libexec/installed-cli.js") && isAbsolute8(process.argv[1]) && realpathSync6(process.argv[1]) === process.argv[1] && realpathSync6(process.execPath) === process.execPath && process.execArgv.length === BUN_POLICY3.length && process.execArgv.every((value, index) => value === BUN_POLICY3[index])) {
44812
45040
  return [process.execPath, ...BUN_POLICY3, process.argv[1], ...arguments_];
44813
45041
  }
44814
45042
  throw new Error("the installed Jig command cannot be reexecuted exactly");
44815
45043
  }
44816
45044
 
44817
45045
  // src/internal/project-session-controller.ts
44818
- import { constants as constants32 } from "fs";
45046
+ import { constants as constants35 } from "fs";
44819
45047
 
44820
45048
  // src/internal/bun-native-lock-policy.ts
44821
45049
  var MANIFEST_REASONS = {
@@ -44923,8 +45151,8 @@ function isExactRegistryResolution(value) {
44923
45151
  if (separator < 1)
44924
45152
  return false;
44925
45153
  const name = value.slice(0, separator);
44926
- const version = value.slice(separator + 1);
44927
- return isPackageName(name) && /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.test(version);
45154
+ const version2 = value.slice(separator + 1);
45155
+ return isPackageName(name) && /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.test(version2);
44928
45156
  }
44929
45157
  function isPackageName(value) {
44930
45158
  const valid = value.startsWith("@") ? /^@[a-z0-9][a-z0-9._~-]*\/[a-z0-9][a-z0-9._~-]*$/.test(value) : /^[a-z0-9][a-z0-9._~-]*$/.test(value);
@@ -44937,8 +45165,8 @@ function ordinaryRecord2(value) {
44937
45165
  }
44938
45166
 
44939
45167
  // src/internal/bun-native-preparation.ts
44940
- import { lstat as lstat20, mkdir as mkdir8, realpath as realpath20 } from "fs/promises";
44941
- import { join as join25 } from "path";
45168
+ import { lstat as lstat21, mkdir as mkdir8, realpath as realpath20 } from "fs/promises";
45169
+ import { join as join26 } from "path";
44942
45170
 
44943
45171
  // src/internal/bun-native-preparation-protocol.ts
44944
45172
  var MIB3 = 1024 * 1024;
@@ -45064,6 +45292,7 @@ var BUN_POLICY4 = Object.freeze(["--no-env-file", "--no-install", "--config=/dev
45064
45292
  var WORKER_FAILURE_CODES = new Set([
45065
45293
  "PACKAGE_BUN_INPUT_LIMIT",
45066
45294
  "PACKAGE_BUN_LOCK_INVALID",
45295
+ "PACKAGE_BUN_LOCK_VERSION_UNSUPPORTED",
45067
45296
  "PACKAGE_BUN_LOCK_STALE",
45068
45297
  "PACKAGE_BUN_OUTPUT_LIMIT",
45069
45298
  "PACKAGE_BUN_OUTPUT_UNSUPPORTED",
@@ -45199,7 +45428,7 @@ async function interact(component, sourceBytes, input) {
45199
45428
  throw protocolFailure();
45200
45429
  location = { path: value2.path, pointer: value2.pointer };
45201
45430
  }
45202
- terminal = new CheckError(message2.code === "PACKAGE_BUN_SOURCE_UNSUPPORTED" || message2.code === "PACKAGE_BUN_RESOLVED_SOURCE_UNSUPPORTED" || message2.code === "PACKAGE_BUN_RESOLUTION_FAILED" || message2.code === "PACKAGE_BUN_RESOLUTION_VERSION_UNAVAILABLE" || message2.code === "PACKAGE_BUN_PREPARATION_FAILED" || message2.code === "PACKAGE_BUN_OUTPUT_UNSUPPORTED" ? "unavailable" : "invalid", message2.code, boundedMessage(message2.message), location?.path ?? (message2.code.startsWith("PACKAGE_BUN_RESOL") || message2.code === "PACKAGE_BUN_INPUT_LIMIT" || message2.code === "PACKAGE_BUN_OUTPUT_LIMIT" ? "package.json" : message2.code.includes("LOCK") || message2.code.includes("SOURCE_UNSUPPORTED") ? "bun.lock" : undefined), location?.pointer);
45431
+ terminal = new CheckError(message2.code === "PACKAGE_BUN_SOURCE_UNSUPPORTED" || message2.code === "PACKAGE_BUN_LOCK_VERSION_UNSUPPORTED" || message2.code === "PACKAGE_BUN_RESOLVED_SOURCE_UNSUPPORTED" || message2.code === "PACKAGE_BUN_RESOLUTION_FAILED" || message2.code === "PACKAGE_BUN_RESOLUTION_VERSION_UNAVAILABLE" || message2.code === "PACKAGE_BUN_PREPARATION_FAILED" || message2.code === "PACKAGE_BUN_OUTPUT_UNSUPPORTED" ? "unavailable" : "invalid", message2.code, boundedMessage(message2.message), location?.path ?? (message2.code.startsWith("PACKAGE_BUN_RESOL") || message2.code === "PACKAGE_BUN_INPUT_LIMIT" || message2.code === "PACKAGE_BUN_OUTPUT_LIMIT" ? "package.json" : message2.code.includes("LOCK") || message2.code.includes("SOURCE_UNSUPPORTED") ? "bun.lock" : undefined), location?.pointer);
45203
45432
  } else {
45204
45433
  throw protocolFailure();
45205
45434
  }
@@ -45317,13 +45546,13 @@ function normalizeCheckpoint(value) {
45317
45546
  return Object.freeze({ allocation, owner, fence });
45318
45547
  }
45319
45548
  async function preparationOwnerParent(projectRoot) {
45320
- const state = await realpath20(join25(projectRoot, ".jig"));
45321
- const parent = join25(state, "private-preparation-owners");
45549
+ const state = await realpath20(join26(projectRoot, ".jig"));
45550
+ const parent = join26(state, "private-preparation-owners");
45322
45551
  await mkdir8(parent, { mode: 448 }).catch((error) => {
45323
45552
  if (!hasCode4(error, "EEXIST"))
45324
45553
  throw error;
45325
45554
  });
45326
- const information = await lstat20(parent);
45555
+ const information = await lstat21(parent);
45327
45556
  const uid = typeof process.getuid === "function" ? process.getuid() : -1;
45328
45557
  if (!information.isDirectory() || information.isSymbolicLink() || information.uid !== uid || (information.mode & 63) !== 0 || await realpath20(parent) !== parent) {
45329
45558
  throw new Error("private Bun preparation owner directory is not protected");
@@ -45684,8 +45913,9 @@ function failure(code2, message2) {
45684
45913
  }
45685
45914
 
45686
45915
  // src/internal/bun-workspace-capture.ts
45687
- import { constants as constants29 } from "fs";
45688
- import { dirname as dirname17, relative as relative3, resolve as resolve13 } from "path";
45916
+ import { constants as constants32 } from "fs";
45917
+ import { lstat as lstat22 } from "fs/promises";
45918
+ import { dirname as dirname18, relative as relative3, resolve as resolve13 } from "path";
45689
45919
  var MANIFEST_BYTES = 1024 * 1024;
45690
45920
  var MAX_MEMBERS4 = 256;
45691
45921
  var MAX_ENTRIES2 = 32768;
@@ -45701,7 +45931,18 @@ async function capturePrivateBunWorkspace(input) {
45701
45931
  if (!requiresWorkspace && Object.keys(dependencies).length === 0)
45702
45932
  return;
45703
45933
  const physical = resolve13(input.projectRoot.requestedPath, input.packagePath);
45704
- for (let path2 = physical, depth = 0;depth < MAX_DEPTH; depth++, path2 = dirname17(path2)) {
45934
+ const roots = [];
45935
+ for (let path2 = physical;roots.length < MAX_DEPTH; path2 = dirname18(path2)) {
45936
+ input.signal.throwIfAborted();
45937
+ if (path2 !== physical && (await lstat22(path2)).isSymbolicLink())
45938
+ break;
45939
+ roots.push(path2);
45940
+ if (dirname18(path2) === path2)
45941
+ break;
45942
+ }
45943
+ const projectDepth = roots.indexOf(resolve13(input.projectRoot.requestedPath));
45944
+ const paths2 = projectDepth === -1 ? roots : [...roots.slice(projectDepth + 1), ...roots.slice(1, projectDepth + 1), physical];
45945
+ for (const path2 of paths2) {
45705
45946
  input.signal.throwIfAborted();
45706
45947
  const root = await openPrivateProjectRoot(path2);
45707
45948
  try {
@@ -45730,8 +45971,6 @@ async function capturePrivateBunWorkspace(input) {
45730
45971
  } finally {
45731
45972
  await root.dispose();
45732
45973
  }
45733
- if (dirname17(path2) === path2)
45734
- break;
45735
45974
  }
45736
45975
  if (requiresWorkspace)
45737
45976
  fail("PACKAGE_BUN_WORKSPACE_MISSING", "workspace dependencies require membership in a declared ancestor workspace");
@@ -45919,9 +46158,9 @@ function runtimeDependencies(manifest) {
45919
46158
  return value;
45920
46159
  }));
45921
46160
  }
45922
- function workspaceVersionMatches(version, request) {
46161
+ function workspaceVersionMatches(version2, request) {
45923
46162
  const range = request.slice("workspace:".length);
45924
- return ["*", "^", "~"].includes(range) || typeof version === "string" && Bun.semver.satisfies(version, range);
46163
+ return ["*", "^", "~"].includes(range) || typeof version2 === "string" && Bun.semver.satisfies(version2, range);
45925
46164
  }
45926
46165
  function parseManifest(bytes) {
45927
46166
  try {
@@ -45994,7 +46233,7 @@ async function openBeneath(root, path2) {
45994
46233
  let current2 = root;
45995
46234
  try {
45996
46235
  for (const part of path2.split("/")) {
45997
- const next2 = await openPrivateChild(current2, part, constants29.O_RDONLY | constants29.O_DIRECTORY | constants29.O_NOFOLLOW | constants29.O_NONBLOCK);
46236
+ const next2 = await openPrivateChild(current2, part, constants32.O_RDONLY | constants32.O_DIRECTORY | constants32.O_NOFOLLOW | constants32.O_NONBLOCK);
45998
46237
  if (current2 !== root)
45999
46238
  await current2.close();
46000
46239
  current2 = next2;
@@ -46009,7 +46248,7 @@ async function openBeneath(root, path2) {
46009
46248
  async function readOptional(directory, name, maximum = MANIFEST_BYTES) {
46010
46249
  let handle;
46011
46250
  try {
46012
- handle = await openPrivateChild(directory, name, constants29.O_RDONLY | constants29.O_NOFOLLOW | constants29.O_NONBLOCK);
46251
+ handle = await openPrivateChild(directory, name, constants32.O_RDONLY | constants32.O_NOFOLLOW | constants32.O_NONBLOCK);
46013
46252
  } catch (error) {
46014
46253
  if (error.code === "ENOENT")
46015
46254
  return;
@@ -46086,7 +46325,7 @@ function fail(code2, message2) {
46086
46325
 
46087
46326
  // src/internal/contract-generation.ts
46088
46327
  import { createHash as createHash15, randomUUID as randomUUID4 } from "crypto";
46089
- import { constants as constants30 } from "fs";
46328
+ import { constants as constants33 } from "fs";
46090
46329
 
46091
46330
  // ../agent-method/dist/errors.js
46092
46331
  class AgentMethodError extends Error {
@@ -46173,13 +46412,13 @@ function visitJson2(value, depth, state, memberName) {
46173
46412
  }
46174
46413
  return;
46175
46414
  }
46176
- const object8 = value;
46177
- const prototype = Object.getPrototypeOf(object8);
46415
+ const object9 = value;
46416
+ const prototype = Object.getPrototypeOf(object9);
46178
46417
  if (prototype !== Object.prototype && prototype !== null) {
46179
46418
  throw new Json1Error2("object must be an ordinary record");
46180
46419
  }
46181
- const keys = Object.keys(object8);
46182
- if (Reflect.ownKeys(object8).length !== keys.length) {
46420
+ const keys = Object.keys(object9);
46421
+ if (Reflect.ownKeys(object9).length !== keys.length) {
46183
46422
  throw new Json1Error2("object members must be enumerable string data");
46184
46423
  }
46185
46424
  if (keys.length > JSON_1_LIMITS2.containerEntries) {
@@ -46189,7 +46428,7 @@ function visitJson2(value, depth, state, memberName) {
46189
46428
  for (const key of keys) {
46190
46429
  validateString2(key, JSON_1_LIMITS2.memberNameBytes);
46191
46430
  chargeEncodedBytes2(state, encodedJsonStringBytes2(key));
46192
- const field = Object.getOwnPropertyDescriptor(object8, key);
46431
+ const field = Object.getOwnPropertyDescriptor(object9, key);
46193
46432
  if (!("value" in field))
46194
46433
  throw new Json1Error2("object members must be ordinary data");
46195
46434
  visitJson2(field.value, depth + 1, state, false);
@@ -46235,8 +46474,8 @@ function canonicalText2(value) {
46235
46474
  return Object.is(value, -0) ? "0" : JSON.stringify(value);
46236
46475
  if (Array.isArray(value))
46237
46476
  return `[${value.map(canonicalText2).join(",")}]`;
46238
- const object8 = value;
46239
- const members = Object.keys(object8).sort(compareUtf162).map((key) => `${JSON.stringify(key)}:${canonicalText2(object8[key])}`);
46477
+ const object9 = value;
46478
+ const members = Object.keys(object9).sort(compareUtf162).map((key) => `${JSON.stringify(key)}:${canonicalText2(object9[key])}`);
46240
46479
  return `{${members.join(",")}}`;
46241
46480
  }
46242
46481
  function compareUtf162(left, right) {
@@ -46383,19 +46622,19 @@ var decoder11 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
46383
46622
 
46384
46623
  // src/internal/contract-authoring-client.ts
46385
46624
  import { spawn as spawn4 } from "child_process";
46386
- import { lstat as lstat21, realpath as realpath21 } from "fs/promises";
46387
- import { isAbsolute as isAbsolute8 } from "path";
46625
+ import { lstat as lstat23, realpath as realpath21 } from "fs/promises";
46626
+ import { isAbsolute as isAbsolute9 } from "path";
46388
46627
  import { fileURLToPath as fileURLToPath4 } from "url";
46389
46628
  async function generateContract(source, signal, workerPath) {
46390
46629
  signal.throwIfAborted();
46391
46630
  const override = process.env.JIG_AUTHORING_NODE_PATH;
46392
- if (override !== undefined && !isAbsolute8(override))
46631
+ if (override !== undefined && !isAbsolute9(override))
46393
46632
  unavailable("AUTHORING_NODE", "Select an absolute Node executable.");
46394
46633
  let node;
46395
46634
  for (const path2 of override ? [override] : ["/usr/bin/node", "/usr/local/bin/node", "/run/current-system/sw/bin/node"]) {
46396
46635
  try {
46397
46636
  const resolved = await realpath21(path2);
46398
- if ((await lstat21(resolved)).isFile()) {
46637
+ if ((await lstat23(resolved)).isFile()) {
46399
46638
  node = resolved;
46400
46639
  break;
46401
46640
  }
@@ -46495,15 +46734,15 @@ async function readInput(root, path2) {
46495
46734
  async function read(directory, name, limit2 = MAX_RECORD) {
46496
46735
  let file;
46497
46736
  try {
46498
- file = await openPrivateFile(privateChildLocation(directory, name), constants30.O_RDONLY | constants30.O_NOFOLLOW | constants30.O_NONBLOCK);
46737
+ file = await openPrivateFile(privateChildLocation(directory, name), constants33.O_RDONLY | constants33.O_NOFOLLOW | constants33.O_NONBLOCK);
46499
46738
  } catch (error) {
46500
46739
  if (error.code === "ENOENT")
46501
46740
  return null;
46502
46741
  return conflict(name);
46503
46742
  }
46504
46743
  try {
46505
- const stat4 = await file.stat();
46506
- if (!stat4.isFile() || stat4.nlink !== 1 || stat4.size > limit2)
46744
+ const stat3 = await file.stat();
46745
+ if (!stat3.isFile() || stat3.nlink !== 1 || stat3.size > limit2)
46507
46746
  conflict(name);
46508
46747
  const bytes = await file.readFile();
46509
46748
  if (bytes.length > limit2)
@@ -46520,7 +46759,7 @@ async function directory(parent, name, create) {
46520
46759
  throw error;
46521
46760
  });
46522
46761
  try {
46523
- return await openPrivateFile(privateChildLocation(parent, name), constants30.O_RDONLY | constants30.O_DIRECTORY | constants30.O_NOFOLLOW);
46762
+ return await openPrivateFile(privateChildLocation(parent, name), constants33.O_RDONLY | constants33.O_DIRECTORY | constants33.O_NOFOLLOW);
46524
46763
  } catch (error) {
46525
46764
  if (error.code === "ENOENT")
46526
46765
  return;
@@ -46529,7 +46768,7 @@ async function directory(parent, name, create) {
46529
46768
  }
46530
46769
  async function write(directory2, name, value) {
46531
46770
  const temporary = `.write-${randomUUID4()}`;
46532
- const file = await openPrivateFile(privateChildLocation(directory2, temporary), constants30.O_CREAT | constants30.O_EXCL | constants30.O_WRONLY | constants30.O_NOFOLLOW, 384);
46771
+ const file = await openPrivateFile(privateChildLocation(directory2, temporary), constants33.O_CREAT | constants33.O_EXCL | constants33.O_WRONLY | constants33.O_NOFOLLOW, 384);
46533
46772
  try {
46534
46773
  await file.writeFile(value);
46535
46774
  await file.sync();
@@ -46773,7 +47012,7 @@ function prepareContractGeneration(options) {
46773
47012
  // src/internal/dependency-flows.ts
46774
47013
  import { posix as posix13 } from "path";
46775
47014
  async function captureDependencyFlows(input) {
46776
- const metadata = await captureOpenedPackageDirectory("project dependency metadata", input.root.handle, {
47015
+ const metadata2 = await captureOpenedPackageDirectory("project dependency metadata", input.root.handle, {
46777
47016
  includes: (path2) => ["package.json", "bun.lock", ".npmrc"].includes(path2),
46778
47017
  maximumFiles: 3,
46779
47018
  maximumBytes: 3 * 1024 * 1024
@@ -46782,7 +47021,7 @@ async function captureDependencyFlows(input) {
46782
47021
  let prepared;
46783
47022
  const members = [];
46784
47023
  try {
46785
- const manifest = await readManifest(metadata, "package.json");
47024
+ const manifest = await readManifest(metadata2, "package.json");
46786
47025
  const declarations = manifest.dependencies;
46787
47026
  if (!declarations || typeof declarations !== "object" || Array.isArray(declarations))
46788
47027
  invalid("PROJECT_DEPENDENCY_MISSING", "npm Flow targets require project package.json dependencies", "package.json");
@@ -46794,10 +47033,10 @@ async function captureDependencyFlows(input) {
46794
47033
  workspace = await capturePrivateBunWorkspace({
46795
47034
  projectRoot: input.root,
46796
47035
  packagePath: "",
46797
- captured: metadata,
47036
+ captured: metadata2,
46798
47037
  signal: input.signal
46799
47038
  });
46800
- prepared = await input.prepare(workspace?.captured ?? metadata, workspace);
47039
+ prepared = await input.prepare(workspace?.captured ?? metadata2, workspace);
46801
47040
  for (const selector of input.selectors) {
46802
47041
  input.signal.throwIfAborted();
46803
47042
  const name = npmPackageName(selector);
@@ -46852,7 +47091,7 @@ async function captureDependencyFlows(input) {
46852
47091
  try {
46853
47092
  await workspace?.captured.dispose();
46854
47093
  } finally {
46855
- await metadata.dispose();
47094
+ await metadata2.dispose();
46856
47095
  }
46857
47096
  }
46858
47097
  }
@@ -47700,8 +47939,8 @@ function isProjectIdentityLoss(error) {
47700
47939
  }
47701
47940
 
47702
47941
  // src/internal/root-run-controller.ts
47703
- import { lstat as lstat24, mkdir as mkdir11, realpath as realpath24 } from "fs/promises";
47704
- import { join as join30 } from "path";
47942
+ import { lstat as lstat26, mkdir as mkdir11, realpath as realpath24 } from "fs/promises";
47943
+ import { join as join31 } from "path";
47705
47944
 
47706
47945
  // src/run/session.ts
47707
47946
  import { createHash as createHash16 } from "crypto";
@@ -48514,56 +48753,56 @@ function validateLimits(limits) {
48514
48753
  }
48515
48754
  }
48516
48755
  function parseEnvelope(value) {
48517
- const object8 = requireObject3(value, "JSON-RPC envelope");
48518
- if (object8.jsonrpc !== "2.0")
48756
+ const object9 = requireObject3(value, "JSON-RPC envelope");
48757
+ if (object9.jsonrpc !== "2.0")
48519
48758
  throw new Error("invalid JSON-RPC version");
48520
- const hasMethod = Object.hasOwn(object8, "method");
48521
- const hasId = Object.hasOwn(object8, "id");
48522
- const hasResult = Object.hasOwn(object8, "result");
48523
- const hasError = Object.hasOwn(object8, "error");
48759
+ const hasMethod = Object.hasOwn(object9, "method");
48760
+ const hasId = Object.hasOwn(object9, "id");
48761
+ const hasResult = Object.hasOwn(object9, "result");
48762
+ const hasError = Object.hasOwn(object9, "error");
48524
48763
  if (hasMethod) {
48525
- if (typeof object8.method !== "string")
48764
+ if (typeof object9.method !== "string")
48526
48765
  throw new Error("method must be a string");
48527
- const hasParams = Object.hasOwn(object8, "params");
48528
- if (hasParams && (object8.params === null || typeof object8.params !== "object")) {
48766
+ const hasParams = Object.hasOwn(object9, "params");
48767
+ if (hasParams && (object9.params === null || typeof object9.params !== "object")) {
48529
48768
  throw new Error("JSON-RPC params must be a structured value");
48530
48769
  }
48531
- requireExactKeys(object8, hasId ? hasParams ? ["jsonrpc", "id", "method", "params"] : ["jsonrpc", "id", "method"] : hasParams ? ["jsonrpc", "method", "params"] : ["jsonrpc", "method"]);
48770
+ requireExactKeys(object9, hasId ? hasParams ? ["jsonrpc", "id", "method", "params"] : ["jsonrpc", "id", "method"] : hasParams ? ["jsonrpc", "method", "params"] : ["jsonrpc", "method"]);
48532
48771
  if (hasId) {
48533
48772
  return {
48534
48773
  kind: "request",
48535
- id: requireWireId2(object8.id),
48536
- method: object8.method,
48537
- ...hasParams ? { params: object8.params } : {}
48774
+ id: requireWireId2(object9.id),
48775
+ method: object9.method,
48776
+ ...hasParams ? { params: object9.params } : {}
48538
48777
  };
48539
48778
  }
48540
48779
  return {
48541
48780
  kind: "notification",
48542
- method: object8.method,
48543
- ...hasParams ? { params: object8.params } : {}
48781
+ method: object9.method,
48782
+ ...hasParams ? { params: object9.params } : {}
48544
48783
  };
48545
48784
  }
48546
48785
  if (!hasId || hasResult === hasError)
48547
48786
  throw new Error("invalid response envelope");
48548
- requireExactKeys(object8, hasResult ? ["jsonrpc", "id", "result"] : ["jsonrpc", "id", "error"]);
48787
+ requireExactKeys(object9, hasResult ? ["jsonrpc", "id", "result"] : ["jsonrpc", "id", "error"]);
48549
48788
  if (hasResult) {
48550
- return { kind: "success", id: requireWireId2(object8.id), result: object8.result };
48789
+ return { kind: "success", id: requireWireId2(object9.id), result: object9.result };
48551
48790
  }
48552
- const id = object8.id === null ? null : requireWireId2(object8.id);
48553
- return { kind: "error", id, error: parseErrorPayload(object8.error) };
48791
+ const id = object9.id === null ? null : requireWireId2(object9.id);
48792
+ return { kind: "error", id, error: parseErrorPayload(object9.error) };
48554
48793
  }
48555
48794
  function parseErrorPayload(value) {
48556
- const object8 = requireObject3(value, "JSON-RPC error");
48557
- requireExactKeys(object8, Object.hasOwn(object8, "data") ? ["code", "message", "data"] : ["code", "message"]);
48558
- if (!Number.isSafeInteger(object8.code))
48795
+ const object9 = requireObject3(value, "JSON-RPC error");
48796
+ requireExactKeys(object9, Object.hasOwn(object9, "data") ? ["code", "message", "data"] : ["code", "message"]);
48797
+ if (!Number.isSafeInteger(object9.code))
48559
48798
  throw new Error("invalid error code");
48560
- if (typeof object8.message !== "string" || scalarLength3(object8.message) < 1 || scalarLength3(object8.message) > 1024) {
48799
+ if (typeof object9.message !== "string" || scalarLength3(object9.message) < 1 || scalarLength3(object9.message) > 1024) {
48561
48800
  throw new Error("invalid error message");
48562
48801
  }
48563
48802
  return {
48564
- code: object8.code,
48565
- message: object8.message,
48566
- ...Object.hasOwn(object8, "data") ? { data: object8.data } : {}
48803
+ code: object9.code,
48804
+ message: object9.message,
48805
+ ...Object.hasOwn(object9, "data") ? { data: object9.data } : {}
48567
48806
  };
48568
48807
  }
48569
48808
  function parseRootFailure(error) {
@@ -48583,9 +48822,9 @@ function parseRootFailure(error) {
48583
48822
  };
48584
48823
  }
48585
48824
  function parseRunResult(value) {
48586
- const object8 = requireObject3(value, "Run result");
48587
- requireExactKeys(object8, ["outcome", "output"]);
48588
- return { outcome: requireLocalName4(object8.outcome), output: object8.output };
48825
+ const object9 = requireObject3(value, "Run result");
48826
+ requireExactKeys(object9, ["outcome", "output"]);
48827
+ return { outcome: requireLocalName4(object9.outcome), output: object9.output };
48589
48828
  }
48590
48829
  function parseOperation2(request) {
48591
48830
  const params = requireObject3(request.params, "flow/call params");
@@ -48612,11 +48851,11 @@ function parseOperation2(request) {
48612
48851
  };
48613
48852
  }
48614
48853
  function parseChannelReferences(value) {
48615
- const object8 = requireObject3(value, "channel references");
48616
- if (Object.keys(object8).length > 256)
48854
+ const object9 = requireObject3(value, "channel references");
48855
+ if (Object.keys(object9).length > 256)
48617
48856
  throw new TypeError("too many channel references");
48618
48857
  const references2 = Object.create(null);
48619
- for (const [name, reference] of Object.entries(object8)) {
48858
+ for (const [name, reference] of Object.entries(object9)) {
48620
48859
  requireLocalName4(name);
48621
48860
  if (typeof reference !== "string" || reference.length < 1 || reference.length > 256)
48622
48861
  throw new TypeError("invalid channel reference");
@@ -48705,8 +48944,8 @@ function requireObject3(value, description) {
48705
48944
  }
48706
48945
  return value;
48707
48946
  }
48708
- function requireExactKeys(object8, expected) {
48709
- const actual = Object.keys(object8).sort();
48947
+ function requireExactKeys(object9, expected) {
48948
+ const actual = Object.keys(object9).sort();
48710
48949
  const wanted = [...expected].sort();
48711
48950
  if (actual.length !== wanted.length || actual.some((key, index) => key !== wanted[index])) {
48712
48951
  throw new Error(`unexpected object members: ${actual.join(", ")}`);
@@ -48766,8 +49005,8 @@ function privateFlowExecutionIntent(recipe, packageRoot, runId, deadlineUnixMs,
48766
49005
  }
48767
49006
 
48768
49007
  // src/internal/package-materialization.ts
48769
- import { constants as constants31 } from "fs";
48770
- import { dirname as dirname18, isAbsolute as isAbsolute9, join as join26, resolve as resolve14 } from "path";
49008
+ import { constants as constants34 } from "fs";
49009
+ import { dirname as dirname19, isAbsolute as isAbsolute10, join as join27, resolve as resolve14 } from "path";
48771
49010
  import { types as utilTypes9 } from "util";
48772
49011
  var ALLOCATION_KIND = "private-package-materialization-allocation/1";
48773
49012
  var LEASE_KIND = "private-package-materialization-lease/1";
@@ -48777,7 +49016,7 @@ var DIGEST12 = /^sha256:[0-9a-f]{64}$/;
48777
49016
  var LEAF = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
48778
49017
  var UNSIGNED_642 = /^(?:0|[1-9][0-9]{0,19})$/;
48779
49018
  var MAX_UNSIGNED_643 = (1n << 64n) - 1n;
48780
- var DIRECTORY_FLAGS = constants31.O_RDONLY | constants31.O_DIRECTORY | constants31.O_NOFOLLOW | constants31.O_NONBLOCK;
49019
+ var DIRECTORY_FLAGS = constants34.O_RDONLY | constants34.O_DIRECTORY | constants34.O_NOFOLLOW | constants34.O_NONBLOCK;
48781
49020
  async function allocatePrivatePackageMaterialization(raw) {
48782
49021
  const options = parseAllocationOptions(raw);
48783
49022
  const parent = await openProtectedParent(options.protectedParent);
@@ -48788,7 +49027,7 @@ async function allocatePrivatePackageMaterialization(raw) {
48788
49027
  kind: ALLOCATION_KIND,
48789
49028
  parent: pathIdentity(parent.path, parent.information),
48790
49029
  name: options.name,
48791
- path: join26(parent.path, options.name),
49030
+ path: join27(parent.path, options.name),
48792
49031
  packageDigest: options.packageDigest,
48793
49032
  ownerToken: options.ownerToken,
48794
49033
  ...options.aliases === undefined ? {} : { aliases: options.aliases }
@@ -49051,7 +49290,7 @@ function leaseFromObserved(allocation, transaction, packageDirectory) {
49051
49290
  kind: LEASE_KIND,
49052
49291
  allocation,
49053
49292
  transaction: pathIdentity(allocation.path, transaction),
49054
- package: pathIdentity(join26(allocation.path, PACKAGE_NAME), packageDirectory)
49293
+ package: pathIdentity(join27(allocation.path, PACKAGE_NAME), packageDirectory)
49055
49294
  });
49056
49295
  return durableLease(identity3);
49057
49296
  }
@@ -49286,7 +49525,7 @@ async function packageModesMatch(packageDirectory, files, filesystem, aliases) {
49286
49525
  const observed = await statPrivateFile(path2);
49287
49526
  if (observed.isSymbolicLink() || !observed.isFile())
49288
49527
  return false;
49289
- const handle = await openPrivateFile(path2, constants31.O_RDONLY | constants31.O_NOFOLLOW | constants31.O_NONBLOCK);
49528
+ const handle = await openPrivateFile(path2, constants34.O_RDONLY | constants34.O_NOFOLLOW | constants34.O_NONBLOCK);
49290
49529
  try {
49291
49530
  const information = await handle.stat({ bigint: true });
49292
49531
  if (!sameIdentity9(observed, information) || !information.isFile() || information.nlink !== 1n || information.uid !== filesystem.uid || information.dev !== filesystem.dev || fileMode(information) !== 0o444n)
@@ -49375,7 +49614,7 @@ async function removeTree(root, filesystem, aliases = new Map, prefix = "") {
49375
49614
  if (!observed.isFile()) {
49376
49615
  throw new Error("refusing to remove a special file from a materialization allocation");
49377
49616
  }
49378
- const file = await openPrivateFile(path2, constants31.O_RDONLY | constants31.O_NOFOLLOW | constants31.O_NONBLOCK);
49617
+ const file = await openPrivateFile(path2, constants34.O_RDONLY | constants34.O_NOFOLLOW | constants34.O_NONBLOCK);
49379
49618
  let information;
49380
49619
  try {
49381
49620
  information = await file.stat({ bigint: true });
@@ -49452,7 +49691,7 @@ function parseAllocation(value) {
49452
49691
  const path2 = normalizeAbsolutePath(root.path, "allocation path");
49453
49692
  const packageDigest2 = parseDigest(root.packageDigest);
49454
49693
  const ownerToken = normalizeOwnerToken(root.ownerToken);
49455
- if (parent.path !== normalizeParent(parent.path) || path2 !== join26(parent.path, name)) {
49694
+ if (parent.path !== normalizeParent(parent.path) || path2 !== join27(parent.path, name)) {
49456
49695
  throw new TypeError("materialization allocation paths are not canonical and correlated");
49457
49696
  }
49458
49697
  return freezeAllocation({
@@ -49476,7 +49715,7 @@ function parseLease(value) {
49476
49715
  const allocation = parseAllocation(root.allocation);
49477
49716
  const transaction = parsePathIdentity(root.transaction, "lease transaction");
49478
49717
  const packageDirectory = parsePathIdentity(root.package, "lease package");
49479
- if (transaction.path !== allocation.path || packageDirectory.path !== join26(allocation.path, PACKAGE_NAME))
49718
+ if (transaction.path !== allocation.path || packageDirectory.path !== join27(allocation.path, PACKAGE_NAME))
49480
49719
  throw new TypeError("materialization lease paths do not match their allocation");
49481
49720
  return freezeLease({
49482
49721
  kind: LEASE_KIND,
@@ -49539,7 +49778,7 @@ function normalizeParent(value) {
49539
49778
  return normalizeAbsolutePath(value, "protected materialization parent");
49540
49779
  }
49541
49780
  function normalizeAbsolutePath(value, label) {
49542
- if (typeof value !== "string" || value.length === 0 || value.includes("\x00") || !isAbsolute9(value) || resolve14(value) !== value || Buffer.byteLength(value, "utf8") > 4096)
49781
+ if (typeof value !== "string" || value.length === 0 || value.includes("\x00") || !isAbsolute10(value) || resolve14(value) !== value || Buffer.byteLength(value, "utf8") > 4096)
49543
49782
  throw new TypeError(`${label} must be a bounded canonical absolute path`);
49544
49783
  return value;
49545
49784
  }
@@ -49574,7 +49813,7 @@ function requireExpectedParent(value, expected) {
49574
49813
  }
49575
49814
  }
49576
49815
  async function copyCapturedFile(captured, logicalPath, expectedBytes, destination, filesystem) {
49577
- const handle = await openPrivateFile(destination, constants31.O_WRONLY | constants31.O_CREAT | constants31.O_EXCL | constants31.O_NOFOLLOW, 256);
49816
+ const handle = await openPrivateFile(destination, constants34.O_WRONLY | constants34.O_CREAT | constants34.O_EXCL | constants34.O_NOFOLLOW, 256);
49578
49817
  let observedBytes = 0;
49579
49818
  try {
49580
49819
  if (filesystem !== undefined) {
@@ -49686,8 +49925,8 @@ function invalidResult(terminal, message2, details) {
49686
49925
  init_input_capture();
49687
49926
 
49688
49927
  // src/internal/invocation-context.ts
49689
- import { lstat as lstat22, mkdir as mkdir9, realpath as realpath22 } from "fs/promises";
49690
- import { join as join27 } from "path";
49928
+ import { lstat as lstat24, mkdir as mkdir9, realpath as realpath22 } from "fs/promises";
49929
+ import { join as join28 } from "path";
49691
49930
  var DIGEST13 = /^sha256:[0-9a-f]{64}$/;
49692
49931
  function requireParentTarget(input) {
49693
49932
  const { parent } = input;
@@ -49749,13 +49988,13 @@ function normalizeParentFlow(value, parentOperationId, depth = 0) {
49749
49988
  });
49750
49989
  }
49751
49990
  async function protectedOwnerRoot(projectRoot) {
49752
- const state2 = await realpath22(join27(projectRoot, ".jig"));
49753
- const owners2 = join27(state2, "private-root-owners");
49991
+ const state2 = await realpath22(join28(projectRoot, ".jig"));
49992
+ const owners2 = join28(state2, "private-root-owners");
49754
49993
  await mkdir9(owners2, { mode: 448 }).catch((error) => {
49755
49994
  if (!hasCode6(error, "EEXIST"))
49756
49995
  throw error;
49757
49996
  });
49758
- const information = await lstat22(owners2);
49997
+ const information = await lstat24(owners2);
49759
49998
  const uid = typeof process.getuid === "function" ? process.getuid() : -1;
49760
49999
  if (!information.isDirectory() || information.isSymbolicLink() || information.uid !== uid || (information.mode & 63) !== 0 || await realpath22(owners2) !== owners2) {
49761
50000
  throw new Error("execution owner directory is not protected");
@@ -50255,10 +50494,10 @@ class PrivateNativeHistoryUnavailable extends TypeError {
50255
50494
  function parsePrivateNativeSessionRequest(input) {
50256
50495
  if (input === null)
50257
50496
  return;
50258
- const outer = object8(input);
50497
+ const outer = object9(input);
50259
50498
  if (Object.keys(outer).join() !== "session")
50260
50499
  invalid4();
50261
- const session = object8(outer.session);
50500
+ const session = object9(outer.session);
50262
50501
  if (session.retain === true && session.lifetime === "run" && Object.keys(session).length === 2)
50263
50502
  return { retain: true, lifetime: "run" };
50264
50503
  if (Object.keys(session).length !== 1)
@@ -50303,10 +50542,10 @@ function validatePrivateCodexSession(state2, secrets2 = []) {
50303
50542
  invalid4();
50304
50543
  throw error;
50305
50544
  }
50306
- const record3 = object8(decoded);
50545
+ const record3 = object9(decoded);
50307
50546
  if (Object.keys(record3).some((key) => !["timestamp", "ordinal", "type", "payload"].includes(key)) || typeof record3.timestamp !== "string" || record3.ordinal !== ordinal)
50308
50547
  invalid4();
50309
- const payload = object8(record3.payload);
50548
+ const payload = object9(record3.payload);
50310
50549
  if (ordinal === 0) {
50311
50550
  if (record3.type !== "session_meta" || payload.cli_version !== "0.154.0" || payload.id !== state2.nativeId || payload.session_id !== state2.nativeId || payload.cwd !== "/work" || Object.keys(payload).some((key) => ![
50312
50551
  "session_id",
@@ -50338,7 +50577,7 @@ function validatePrivateCodexSession(state2, secrets2 = []) {
50338
50577
  completions++;
50339
50578
  complete = true;
50340
50579
  } else if (payload.type === "item_completed") {
50341
- const item2 = object8(payload.item);
50580
+ const item2 = object9(payload.item);
50342
50581
  if (active === undefined || payload.turn_id !== active || payload.thread_id !== state2.nativeId || !["UserMessage", "AgentMessage", "Reasoning"].includes(String(item2.type)))
50343
50582
  invalid4();
50344
50583
  } else if (![
@@ -50354,11 +50593,11 @@ function validatePrivateCodexSession(state2, secrets2 = []) {
50354
50593
  case "response_item":
50355
50594
  if (!["message", "reasoning"].includes(String(payload.type)))
50356
50595
  invalid4();
50357
- if (payload.type === "message" && (!["system", "developer", "user", "assistant"].includes(String(payload.role)) || !Array.isArray(payload.content) || payload.content.some((part) => !["input_text", "output_text"].includes(String(object8(part).type)))))
50596
+ if (payload.type === "message" && (!["system", "developer", "user", "assistant"].includes(String(payload.role)) || !Array.isArray(payload.content) || payload.content.some((part) => !["input_text", "output_text"].includes(String(object9(part).type)))))
50358
50597
  invalid4();
50359
50598
  break;
50360
50599
  case "turn_context":
50361
- if (active === undefined || payload.turn_id !== active || payload.cwd !== "/work" || !["never", "on-request"].includes(String(payload.approval_policy)) || !supportedSandboxPolicy(object8(payload.sandbox_policy)))
50600
+ if (active === undefined || payload.turn_id !== active || payload.cwd !== "/work" || !["never", "on-request"].includes(String(payload.approval_policy)) || !supportedSandboxPolicy(object9(payload.sandbox_policy)))
50362
50601
  invalid4();
50363
50602
  break;
50364
50603
  case "world_state":
@@ -50459,8 +50698,8 @@ function privateCodexSessionSecrets(runtime, startup) {
50459
50698
  leaves(child2);
50460
50699
  };
50461
50700
  if (runtime.authentication) {
50462
- const metadata = runtime.authentication.request._meta;
50463
- leaves(metadata?.gateway?.headers);
50701
+ const metadata2 = runtime.authentication.request._meta;
50702
+ leaves(metadata2?.gateway?.headers);
50464
50703
  }
50465
50704
  if (startup?.byteLength)
50466
50705
  leaves(JSON.parse(decoder12.decode(startup.subarray(4))).tokens);
@@ -50476,7 +50715,7 @@ function privateCodexSessionBootstrap(state2) {
50476
50715
  header.writeUInt32BE(bytes.byteLength, 4);
50477
50716
  return Buffer.concat([header, path2, bytes]);
50478
50717
  }
50479
- function object8(value) {
50718
+ function object9(value) {
50480
50719
  if (value === null || typeof value !== "object" || Array.isArray(value))
50481
50720
  return invalid4();
50482
50721
  return value;
@@ -50548,12 +50787,12 @@ class PrivateFiniteAcpPolicy {
50548
50787
  updates = 0;
50549
50788
  textBytes = 0;
50550
50789
  constructor(configuration = {}) {
50551
- const policy = object9(snapshotPrivateOrdinaryJson(configuration, "finite ACP policy", invalid5));
50790
+ const policy = object10(snapshotPrivateOrdinaryJson(configuration, "finite ACP policy", invalid5));
50552
50791
  keys(policy, [], ["configuration", "modeId", "maxTurns", "restoreSessionId"]);
50553
50792
  if (Object.hasOwn(policy, "restoreSessionId"))
50554
50793
  this.restoreSessionId = identifier(policy.restoreSessionId);
50555
- const maxTurns = policy.maxTurns ?? 1;
50556
- if (typeof maxTurns !== "number" || !Number.isSafeInteger(maxTurns) || maxTurns < 1 || maxTurns > 8)
50794
+ const maxTurns = Object.hasOwn(policy, "maxTurns") ? policy.maxTurns : PRIVATE_NATIVE_TURN_POLICY.default;
50795
+ if (!isPrivateNativeTurnAllowance(maxTurns))
50557
50796
  fail2("Invalid ACP turn allowance");
50558
50797
  this.maxTurns = maxTurns;
50559
50798
  const options = Object.hasOwn(policy, "configuration") ? policy.configuration : [];
@@ -50561,7 +50800,7 @@ class PrivateFiniteAcpPolicy {
50561
50800
  fail2("Invalid finite ACP configuration");
50562
50801
  const ids = new Set;
50563
50802
  for (const item2 of options) {
50564
- const option = object9(item2);
50803
+ const option = object10(item2);
50565
50804
  keys(option, ["configId", "value"], ["type"]);
50566
50805
  const id = identifier(option.configId);
50567
50806
  if (ids.has(id))
@@ -50585,7 +50824,7 @@ class PrivateFiniteAcpPolicy {
50585
50824
  const frame = this.frame(bytes, "adapter");
50586
50825
  keys(frame, ["jsonrpc", "method", "params"], ["id"]);
50587
50826
  const method = frame.method;
50588
- const params = object9(frame.params);
50827
+ const params = object10(frame.params);
50589
50828
  if (method === CANCEL) {
50590
50829
  keys(frame, ["jsonrpc", "method", "params"]);
50591
50830
  this.ownedSession(params, []);
@@ -50609,9 +50848,9 @@ class PrivateFiniteAcpPolicy {
50609
50848
  if (params.protocolVersion !== 1)
50610
50849
  fail2("Unsupported ACP version");
50611
50850
  if (params.clientCapabilities !== undefined)
50612
- keys(object9(params.clientCapabilities), []);
50851
+ keys(object10(params.clientCapabilities), []);
50613
50852
  if (params.clientInfo !== undefined) {
50614
- const info = object9(params.clientInfo);
50853
+ const info = object10(params.clientInfo);
50615
50854
  keys(info, ["name"], ["version", "title"]);
50616
50855
  for (const value of Object.values(info))
50617
50856
  identifier(value);
@@ -50652,7 +50891,7 @@ class PrivateFiniteAcpPolicy {
50652
50891
  fail2("ACP prompt is not available");
50653
50892
  if (!Array.isArray(params.prompt) || params.prompt.length !== 1)
50654
50893
  fail2("ACP requires one text prompt");
50655
- const content = object9(params.prompt[0]);
50894
+ const content = object10(params.prompt[0]);
50656
50895
  keys(content, ["type", "text"]);
50657
50896
  if (content.type !== "text" || typeof content.text !== "string" || !content.text || content.text.includes("\x00") || content.text.trimStart().startsWith("/") || encoder11.encode(content.text).byteLength > PRIVATE_FINITE_ACP_LIMITS.promptBytes)
50658
50897
  fail2("ACP prompt exceeds its authority or bounds");
@@ -50687,7 +50926,7 @@ class PrivateFiniteAcpPolicy {
50687
50926
  if (pending === undefined || id !== pending.id || Object.hasOwn(frame, "result") === Object.hasOwn(frame, "error"))
50688
50927
  fail2("ACP response has no matching request");
50689
50928
  if (Object.hasOwn(frame, "error")) {
50690
- const error = object9(frame.error);
50929
+ const error = object10(frame.error);
50691
50930
  if (!Number.isSafeInteger(error.code) || typeof error.message !== "string")
50692
50931
  fail2("Invalid ACP error response");
50693
50932
  this.pending = undefined;
@@ -50696,7 +50935,7 @@ class PrivateFiniteAcpPolicy {
50696
50935
  toAdapter: response(id, { code: error.code, message: "Native ACP request failed" }, true)
50697
50936
  });
50698
50937
  }
50699
- const result2 = object9(frame.result);
50938
+ const result2 = object10(frame.result);
50700
50939
  if (this.notice(result2._meta))
50701
50940
  this.pendingNotice = true;
50702
50941
  let projected;
@@ -50708,10 +50947,10 @@ class PrivateFiniteAcpPolicy {
50708
50947
  const sessions = optionalObject(capabilities.sessionCapabilities);
50709
50948
  this.canClose = sessions.close !== undefined && sessions.close !== null;
50710
50949
  if (this.canClose)
50711
- object9(sessions.close);
50950
+ object10(sessions.close);
50712
50951
  this.canResume = sessions.resume !== undefined && sessions.resume !== null;
50713
50952
  if (this.canResume)
50714
- object9(sessions.resume);
50953
+ object10(sessions.resume);
50715
50954
  if (this.restoreSessionId !== undefined && !this.canResume)
50716
50955
  fail2("ACP client does not support restoration");
50717
50956
  this.initialized = true;
@@ -50738,8 +50977,8 @@ class PrivateFiniteAcpPolicy {
50738
50977
  const required = this.configuration[this.configured];
50739
50978
  if (!Array.isArray(result2.configOptions))
50740
50979
  fail2("ACP configuration was not confirmed");
50741
- const matches3 = result2.configOptions.filter((option2) => object9(option2).id === required.configId);
50742
- if (matches3.length !== 1 || object9(matches3[0]).currentValue !== required.value)
50980
+ const matches3 = result2.configOptions.filter((option2) => object10(option2).id === required.configId);
50981
+ if (matches3.length !== 1 || object10(matches3[0]).currentValue !== required.value)
50743
50982
  fail2("ACP configuration was not confirmed");
50744
50983
  const option = typeof required.value === "boolean" ? {
50745
50984
  id: required.configId,
@@ -50797,7 +51036,7 @@ class PrivateFiniteAcpPolicy {
50797
51036
  });
50798
51037
  }
50799
51038
  clientMessage(frame) {
50800
- const params = object9(frame.params);
51039
+ const params = object10(frame.params);
50801
51040
  if (frame.method === PERMISSION) {
50802
51041
  keys(frame, ["jsonrpc", "method", "params", "id"]);
50803
51042
  const id = requestId(frame.id);
@@ -50811,12 +51050,12 @@ class PrivateFiniteAcpPolicy {
50811
51050
  fail2("ACP client operation is not permitted");
50812
51051
  if (++this.updates > PRIVATE_FINITE_ACP_LIMITS.updates)
50813
51052
  fail2("ACP update capacity exceeded");
50814
- const update = object9(params.update);
51053
+ const update = object10(params.update);
50815
51054
  const notice = this.notice(update._meta);
50816
51055
  if (this.sessionId === undefined && (this.pending?.method === NEW || this.pending?.method === RESUME)) {
50817
51056
  keys(params, ["sessionId", "update"], ["_meta"]);
50818
51057
  identifier(params.sessionId);
50819
- object9(params.update);
51058
+ object10(params.update);
50820
51059
  if (notice)
50821
51060
  this.pendingNotice = true;
50822
51061
  return Object.freeze({});
@@ -50833,7 +51072,7 @@ class PrivateFiniteAcpPolicy {
50833
51072
  } else if (update.sessionUpdate === "agent_message_chunk") {
50834
51073
  if (this.pending?.method !== PROMPT)
50835
51074
  fail2("ACP text arrived outside an active turn");
50836
- const content = object9(update.content);
51075
+ const content = object10(update.content);
50837
51076
  if (content.type !== "text")
50838
51077
  return Object.freeze({});
50839
51078
  if (typeof content.text !== "string")
@@ -50852,7 +51091,7 @@ class PrivateFiniteAcpPolicy {
50852
51091
  if (!Array.isArray(update.entries))
50853
51092
  fail2("Invalid ACP plan update");
50854
51093
  const entries = update.entries.map((value) => {
50855
- const entry = object9(value);
51094
+ const entry = object10(value);
50856
51095
  if (typeof entry.content !== "string" || !["high", "medium", "low"].includes(entry.priority) || !["pending", "in_progress", "completed"].includes(entry.status))
50857
51096
  fail2("Invalid ACP plan entry");
50858
51097
  return { content: entry.content, priority: entry.priority, status: entry.status };
@@ -50882,13 +51121,13 @@ class PrivateFiniteAcpPolicy {
50882
51121
  }
50883
51122
  };
50884
51123
  }
50885
- notice(metadata) {
50886
- const air = optionalObject(optionalObject(optionalObject(metadata).jetbrains).air);
51124
+ notice(metadata2) {
51125
+ const air = optionalObject(optionalObject(optionalObject(metadata2).jetbrains).air);
50887
51126
  if (air.sessionFailure === undefined || air.sessionFailure === null)
50888
51127
  return false;
50889
51128
  if (air.version !== 1)
50890
51129
  fail2("Unsupported native ACP diagnostic version");
50891
- const notice = object9(air.sessionFailure);
51130
+ const notice = object10(air.sessionFailure);
50892
51131
  if (notice.severity === "error")
50893
51132
  throw new PrivateFiniteAcpPolicyError("Native ACP reported a session failure", "native-session");
50894
51133
  if (notice.severity !== "warning")
@@ -50918,7 +51157,7 @@ class PrivateFiniteAcpPolicy {
50918
51157
  } catch {
50919
51158
  fail2("Invalid ACP JSON frame");
50920
51159
  }
50921
- const frame = object9(value);
51160
+ const frame = object10(value);
50922
51161
  if (frame.jsonrpc !== "2.0")
50923
51162
  fail2("Invalid ACP protocol frame");
50924
51163
  return freeze4(frame);
@@ -50960,13 +51199,13 @@ function requestId(value) {
50960
51199
  return value;
50961
51200
  return identifier(value);
50962
51201
  }
50963
- function object9(value) {
51202
+ function object10(value) {
50964
51203
  if (value === null || typeof value !== "object" || Array.isArray(value))
50965
51204
  fail2("Invalid ACP object");
50966
51205
  return value;
50967
51206
  }
50968
51207
  function optionalObject(value) {
50969
- return value === undefined || value === null ? {} : object9(value);
51208
+ return value === undefined || value === null ? {} : object10(value);
50970
51209
  }
50971
51210
  function keys(value, required, optional = []) {
50972
51211
  if (required.some((key) => !Object.hasOwn(value, key)) || Object.keys(value).some((key) => !required.includes(key) && !optional.includes(key)))
@@ -50981,7 +51220,7 @@ function fail2(message2) {
50981
51220
 
50982
51221
  // src/internal/finite-acp-resource.ts
50983
51222
  import { randomUUID as randomUUID5 } from "crypto";
50984
- import { join as join28 } from "path";
51223
+ import { join as join29 } from "path";
50985
51224
  import { clearTimeout as clearTimeout2, setTimeout as setTimeout2 } from "timers";
50986
51225
 
50987
51226
  // ../agent-acp/dist/transport.js
@@ -51003,7 +51242,7 @@ class FiniteAcpTransportError extends Error {
51003
51242
  }
51004
51243
  }
51005
51244
  var encoder12 = new TextEncoder;
51006
- function object10(value) {
51245
+ function object11(value) {
51007
51246
  if (value === null || typeof value !== "object" || Array.isArray(value))
51008
51247
  invalid6("Expected an object");
51009
51248
  const prototype = Object.getPrototypeOf(value);
@@ -51051,7 +51290,7 @@ function identifier2(value) {
51051
51290
  return value;
51052
51291
  }
51053
51292
  function readFiniteAcpReady(value) {
51054
- const record3 = object10(value);
51293
+ const record3 = object11(value);
51055
51294
  exact6(record3, ["kind", "protocolVersion", "cwd", "maxTurns", "configuration"], ["modeId", "restoreSessionId"]);
51056
51295
  if (record3.kind !== "ready" || record3.protocolVersion !== 1 || record3.cwd !== "/work" || typeof record3.maxTurns !== "number" || !Number.isSafeInteger(record3.maxTurns) || record3.maxTurns < 1 || record3.maxTurns > 8 || !Array.isArray(record3.configuration) || record3.configuration.length > 16)
51057
51296
  invalid6("Invalid finite ACP ready record");
@@ -51064,7 +51303,7 @@ function readFiniteAcpReady(value) {
51064
51303
  if (!descriptor || !Object.hasOwn(descriptor, "value") || !descriptor.enumerable)
51065
51304
  invalid6("Configuration must be a dense data array");
51066
51305
  const item2 = descriptor.value;
51067
- const entry = object10(item2);
51306
+ const entry = object11(item2);
51068
51307
  exact6(entry, ["configId", "value"], ["type"]);
51069
51308
  const configId = identifier2(entry.configId);
51070
51309
  if (names2.has(configId))
@@ -51129,7 +51368,7 @@ class FiniteAcpFrames {
51129
51368
  }
51130
51369
  accept(value) {
51131
51370
  return this.guard(() => {
51132
- const record3 = object10(value);
51371
+ const record3 = object11(value);
51133
51372
  exact6(record3, ["kind", "text", "end"]);
51134
51373
  if (record3.kind !== "data" || typeof record3.end !== "boolean")
51135
51374
  invalid6("Invalid finite ACP fragment");
@@ -51334,7 +51573,7 @@ var PRIVATE_FINITE_ACP_CHANNELS = Object.freeze({
51334
51573
  contract: channel(responses_default)
51335
51574
  })
51336
51575
  });
51337
- async function runPrivateFiniteAcpResource(component, runtime, endpoints, signal, maxTurns = 1, session) {
51576
+ async function runPrivateFiniteAcpResource(component, runtime, endpoints, signal, maxTurns = PRIVATE_NATIVE_TURN_POLICY.default, session) {
51338
51577
  const local = new AbortController;
51339
51578
  const enforcement = component.enforcement.then((receipt) => receipt);
51340
51579
  const stopped = () => local.abort(signal.reason);
@@ -51387,10 +51626,10 @@ async function runPrivateFiniteAcpResource(component, runtime, endpoints, signal
51387
51626
  };
51388
51627
  const requests = async () => {
51389
51628
  for (;; ) {
51390
- const item2 = object11(await endpoints.owner.next(endpoints.requests, local.signal));
51629
+ const item2 = object12(await endpoints.owner.next(endpoints.requests, local.signal));
51391
51630
  if (Object.hasOwn(item2, "end"))
51392
51631
  break;
51393
- const text3 = frames.accept(object11(item2.item).value);
51632
+ const text3 = frames.accept(object12(item2.item).value);
51394
51633
  if (text3 === undefined)
51395
51634
  continue;
51396
51635
  if (authenticationId !== undefined)
@@ -51434,7 +51673,7 @@ async function runPrivateFiniteAcpResource(component, runtime, endpoints, signal
51434
51673
  ...native5,
51435
51674
  params: {
51436
51675
  ...native5.params,
51437
- cwd: join28(component.owner.owner.allocation.directory, "data", "work")
51676
+ cwd: join29(component.owner.owner.allocation.directory, "data", "work")
51438
51677
  }
51439
51678
  };
51440
51679
  }
@@ -51453,11 +51692,11 @@ async function runPrivateFiniteAcpResource(component, runtime, endpoints, signal
51453
51692
  };
51454
51693
  const responses = async () => {
51455
51694
  for await (const bytes of nativeFrames(component.stdout)) {
51456
- const raw = object11(decodeJson1(bytes));
51695
+ const raw = object12(decodeJson1(bytes));
51457
51696
  if (authenticationId !== undefined && raw.id === authenticationId) {
51458
51697
  if (raw.jsonrpc !== "2.0" || !Object.hasOwn(raw, "result") || Object.hasOwn(raw, "error") || Object.hasOwn(raw, "method"))
51459
51698
  invalid7("Native ACP authentication failed");
51460
- object11(raw.result);
51699
+ object12(raw.result);
51461
51700
  authenticationId = undefined;
51462
51701
  const delivery2 = initialize;
51463
51702
  initialize = undefined;
@@ -51465,8 +51704,8 @@ async function runPrivateFiniteAcpResource(component, runtime, endpoints, signal
51465
51704
  continue;
51466
51705
  }
51467
51706
  if (runtime.authentication !== undefined && isInitializeReply(raw)) {
51468
- const result2 = object11(raw.result);
51469
- if (!Array.isArray(result2.authMethods) || !result2.authMethods.some((value) => object11(value).id === runtime.authentication.request.methodId))
51707
+ const result2 = object12(raw.result);
51708
+ if (!Array.isArray(result2.authMethods) || !result2.authMethods.some((value) => object12(value).id === runtime.authentication.request.methodId))
51470
51709
  invalid7("Native ACP authentication is unavailable");
51471
51710
  initialize = policy.fromClient(bytes).toAdapter;
51472
51711
  authenticationId = `jig-auth-${randomUUID5()}`;
@@ -51499,7 +51738,7 @@ async function runPrivateFiniteAcpResource(component, runtime, endpoints, signal
51499
51738
  function isInitializeReply(value) {
51500
51739
  if (initializedReply || !Object.hasOwn(value, "result") || value.method !== undefined)
51501
51740
  return false;
51502
- const result2 = object11(value.result);
51741
+ const result2 = object12(value.result);
51503
51742
  if (result2.protocolVersion !== 1)
51504
51743
  return false;
51505
51744
  initializedReply = true;
@@ -51624,7 +51863,7 @@ async function within(pending, milliseconds, signal) {
51624
51863
  removeAbort();
51625
51864
  }
51626
51865
  }
51627
- function object11(value) {
51866
+ function object12(value) {
51628
51867
  if (value === null || typeof value !== "object" || Array.isArray(value))
51629
51868
  invalid7("Invalid native ACP frame");
51630
51869
  return value;
@@ -51675,7 +51914,7 @@ async function executePrivateRootFiniteAcp(input) {
51675
51914
  let participant;
51676
51915
  try {
51677
51916
  const terminal = await executeOwnedProvider(input, provider, recipe, {
51678
- maxTurns: route.grant.maxTurns ?? 1,
51917
+ maxTurns: route.grant.maxTurns ?? PRIVATE_NATIVE_TURN_POLICY.default,
51679
51918
  ...session === undefined ? {} : { session },
51680
51919
  digest: privateDomainDigest("JIG-Private-Finite-ACP-Request/1", {
51681
51920
  providerDigest: provider.digest,
@@ -52242,8 +52481,8 @@ function failed2(code2, message2, details) {
52242
52481
  }
52243
52482
 
52244
52483
  // src/internal/root-flow-call-controller.ts
52245
- import { lstat as lstat23, mkdir as mkdir10, realpath as realpath23 } from "fs/promises";
52246
- import { join as join29 } from "path";
52484
+ import { lstat as lstat25, mkdir as mkdir10, realpath as realpath23 } from "fs/promises";
52485
+ import { join as join30 } from "path";
52247
52486
 
52248
52487
  // src/internal/run-channels.ts
52249
52488
  class PrivateRunChannels {
@@ -52977,9 +53216,9 @@ function childIdentity(parentRunId, operationId) {
52977
53216
  }).slice("sha256:".length);
52978
53217
  }
52979
53218
  async function protectedWorkRoots(projectRoot) {
52980
- const state2 = await realpath23(join29(projectRoot, ".jig"));
52981
- const materializations = join29(state2, "private-root-materializations");
52982
- const owners3 = join29(state2, "private-root-owners");
53219
+ const state2 = await realpath23(join30(projectRoot, ".jig"));
53220
+ const materializations = join30(state2, "private-root-materializations");
53221
+ const owners3 = join30(state2, "private-root-owners");
52983
53222
  await Promise.all([ensureProtectedDirectory(materializations), ensureProtectedDirectory(owners3)]);
52984
53223
  return Object.freeze({ materializations, owners: owners3 });
52985
53224
  }
@@ -52988,7 +53227,7 @@ async function ensureProtectedDirectory(path2) {
52988
53227
  if (!hasCode7(error, "EEXIST"))
52989
53228
  throw error;
52990
53229
  });
52991
- const information = await lstat23(path2);
53230
+ const information = await lstat25(path2);
52992
53231
  const uid = typeof process.getuid === "function" ? process.getuid() : -1;
52993
53232
  if (!information.isDirectory() || information.isSymbolicLink() || information.uid !== uid || (information.mode & 63) !== 0 || await realpath23(path2) !== path2) {
52994
53233
  throw new Error("child execution owner directory is not protected");
@@ -53565,9 +53804,9 @@ async function reacquire(input) {
53565
53804
  });
53566
53805
  }
53567
53806
  async function protectedWorkRoots2(projectRoot) {
53568
- const state2 = await realpath24(join30(projectRoot, ".jig"));
53569
- const materializations = join30(state2, "private-root-materializations");
53570
- const owners3 = join30(state2, "private-root-owners");
53807
+ const state2 = await realpath24(join31(projectRoot, ".jig"));
53808
+ const materializations = join31(state2, "private-root-materializations");
53809
+ const owners3 = join31(state2, "private-root-owners");
53571
53810
  await Promise.all([ensureProtectedDirectory2(materializations), ensureProtectedDirectory2(owners3)]);
53572
53811
  return Object.freeze({ materializations, owners: owners3 });
53573
53812
  }
@@ -53576,7 +53815,7 @@ async function ensureProtectedDirectory2(path2) {
53576
53815
  if (!hasCode8(error, "EEXIST"))
53577
53816
  throw error;
53578
53817
  });
53579
- const information = await lstat24(path2);
53818
+ const information = await lstat26(path2);
53580
53819
  const uid = typeof process.getuid === "function" ? process.getuid() : -1;
53581
53820
  if (!information.isDirectory() || information.isSymbolicLink() || information.uid !== uid || (information.mode & 63) !== 0 || await realpath24(path2) !== path2) {
53582
53821
  throw new Error("private root execution work directory is not protected");
@@ -54068,7 +54307,13 @@ function closedTestErrorCauses(error) {
54068
54307
  return result2;
54069
54308
  }
54070
54309
  function closedNativeTestCause(error) {
54071
- switch (error.message) {
54310
+ let message2;
54311
+ try {
54312
+ message2 = error.message;
54313
+ } catch {
54314
+ return;
54315
+ }
54316
+ switch (message2) {
54072
54317
  case "macOS control deadline expired":
54073
54318
  return "MACOS_CONTROL_DEADLINE";
54074
54319
  case "macOS guardian bootstrap failed":
@@ -54077,12 +54322,28 @@ function closedNativeTestCause(error) {
54077
54322
  return "MACOS_GUARDIAN_CONNECTION_LOST";
54078
54323
  case "macOS guardian job removal is unconfirmed":
54079
54324
  return "MACOS_GUARDIAN_REMOVAL_UNCONFIRMED";
54325
+ case "macOS guardian job is still present":
54326
+ return "MACOS_GUARDIAN_JOB_PRESENT";
54327
+ case "macOS storage recovery guardian job is still present":
54328
+ return "MACOS_RECOVERY_JOB_PRESENT";
54329
+ case "macOS storage recovery is unconfirmed":
54330
+ return "MACOS_STORAGE_RECOVERY_UNCONFIRMED";
54331
+ case "macOS volume backing identity changed":
54332
+ return "MACOS_VOLUME_BACKING_CHANGED";
54333
+ case "macOS volume info failed":
54334
+ return "MACOS_VOLUME_INFO";
54335
+ case "macOS volume detach failed":
54336
+ return "MACOS_VOLUME_DETACH";
54337
+ case "macOS guardian contains unexpected state":
54338
+ return "MACOS_GUARDIAN_UNEXPECTED_STATE";
54339
+ case "macOS recovery slot contains unexpected state":
54340
+ return "MACOS_RECOVERY_UNEXPECTED_STATE";
54080
54341
  case "macOS prepared ownership does not match":
54081
54342
  return "MACOS_PREPARED_OWNER_MISMATCH";
54082
54343
  case "native macOS Run was cancelled before admission":
54083
54344
  return "MACOS_STARTUP_CANCELLED";
54084
54345
  default:
54085
- return error.message.startsWith("macOS guardian ended before readiness (") && error.message.endsWith(")") ? "MACOS_GUARDIAN_BEFORE_READINESS" : undefined;
54346
+ return message2.startsWith("macOS guardian ended before readiness (") && message2.endsWith(")") ? "MACOS_GUARDIAN_BEFORE_READINESS" : undefined;
54086
54347
  }
54087
54348
  }
54088
54349
  function createSession(owner, roots, packageStore, host, onOperationFailure) {
@@ -54463,7 +54724,7 @@ function createSession(owner, roots, packageStore, host, onOperationFailure) {
54463
54724
  async function preparePackageStore(owner) {
54464
54725
  await owner.verify();
54465
54726
  const statePath = privateChildLocation(owner.root.handle, ".jig");
54466
- const state2 = await openPrivateFile(statePath, constants32.O_RDONLY | constants32.O_DIRECTORY | constants32.O_NOFOLLOW | constants32.O_NONBLOCK);
54727
+ const state2 = await openPrivateFile(statePath, constants35.O_RDONLY | constants35.O_DIRECTORY | constants35.O_NOFOLLOW | constants35.O_NONBLOCK);
54467
54728
  try {
54468
54729
  const storePath = privateChildLocation(state2, PRIVATE_PACKAGE_STORE_DIRECTORY);
54469
54730
  try {
@@ -54475,7 +54736,7 @@ async function preparePackageStore(owner) {
54475
54736
  await state2.sync();
54476
54737
  const observed = await statPrivateFile(storePath);
54477
54738
  requireProtectedStore(observed, owner.root.information.dev);
54478
- const store = await openPrivateFile(storePath, constants32.O_RDONLY | constants32.O_DIRECTORY | constants32.O_NOFOLLOW | constants32.O_NONBLOCK);
54739
+ const store = await openPrivateFile(storePath, constants35.O_RDONLY | constants35.O_DIRECTORY | constants35.O_NOFOLLOW | constants35.O_NONBLOCK);
54479
54740
  try {
54480
54741
  const actual = await store.stat({ bigint: true });
54481
54742
  requireProtectedStore(actual, owner.root.information.dev);
@@ -54586,7 +54847,7 @@ function isUnavailableDiagnosticCode(code2) {
54586
54847
  "AUTHORING_INTERRUPTED",
54587
54848
  "AUTHORING_LIMIT",
54588
54849
  "AUTHORING_STATE"
54589
- ].includes(code2) || code2 === "PACKAGE_BUN_SOURCE_UNSUPPORTED" || code2 === "PACKAGE_BUN_RESOLUTION_PERMISSION_REQUIRED" || code2 === "PACKAGE_BUN_RESOLUTION_FAILED" || code2 === "PACKAGE_BUN_RESOLUTION_VERSION_UNAVAILABLE" || code2 === "PACKAGE_BUN_RESOLVED_SOURCE_UNSUPPORTED" || code2 === "PACKAGE_BUN_PREPARATION_FAILED" || code2 === "PROJECT_ACP_UNAVAILABLE" || code2 === "PROJECT_HTTP_UNAVAILABLE" || code2 === "PACKAGE_PROFILE_UNSUPPORTED" || code2 === "PACKAGE_METADATA_UNSUPPORTED" || code2 === "PACKAGE_TOOLS_UNSUPPORTED" || code2 === "PROJECT_INTERFACE_ANONYMOUS" || code2 === "PROJECT_ATTACHMENTS_UNSUPPORTED";
54850
+ ].includes(code2) || code2 === "PACKAGE_BUN_SOURCE_UNSUPPORTED" || code2 === "PACKAGE_BUN_LOCK_VERSION_UNSUPPORTED" || code2 === "PACKAGE_BUN_RESOLUTION_PERMISSION_REQUIRED" || code2 === "PACKAGE_BUN_RESOLUTION_FAILED" || code2 === "PACKAGE_BUN_RESOLUTION_VERSION_UNAVAILABLE" || code2 === "PACKAGE_BUN_RESOLVED_SOURCE_UNSUPPORTED" || code2 === "PACKAGE_BUN_PREPARATION_FAILED" || code2 === "PROJECT_ACP_UNAVAILABLE" || code2 === "PROJECT_HTTP_UNAVAILABLE" || code2 === "PACKAGE_PROFILE_UNSUPPORTED" || code2 === "PACKAGE_METADATA_UNSUPPORTED" || code2 === "PACKAGE_TOOLS_UNSUPPORTED" || code2 === "PROJECT_INTERFACE_ANONYMOUS" || code2 === "PROJECT_ATTACHMENTS_UNSUPPORTED";
54590
54851
  }
54591
54852
  function isCandidateDiagnosticCode(code2) {
54592
54853
  return ["AUTHORING_COMPILE", "AUTHORING_CONFLICT"].includes(code2) || code2.startsWith("CONTRACT_") || code2.startsWith("MARKDOWN_") || code2.startsWith("METADATA_") || code2.startsWith("SCHEMA_") || code2.startsWith("PACKAGE_BUN_") || code2.startsWith("PROJECT_BINDING_") || code2.startsWith("PROJECT_DEFAULT_") || code2.startsWith("PROJECT_PROVIDER_") || code2.startsWith("PROJECT_DEPENDENCY_") || code2.startsWith("PROJECT_GRANT") || code2.startsWith("PROJECT_DECLARATION_") || code2.startsWith("PROJECT_EVALUATION_") || code2.startsWith("PROJECT_EVALUATOR_") || code2.startsWith("PROJECT_MEMBER_") || code2.startsWith("PROJECT_SOURCE_") || [
@@ -54636,7 +54897,7 @@ var releaseRoot;
54636
54897
  var executablePath;
54637
54898
  try {
54638
54899
  installedCliPath = await realpath25(fileURLToPath5(import.meta.url));
54639
- releaseRoot = dirname19(dirname19(installedCliPath));
54900
+ releaseRoot = dirname20(dirname20(installedCliPath));
54640
54901
  executablePath = await realpath25(process.execPath);
54641
54902
  const runningExecutablePath = process.platform === "linux" ? await realpath25("/proc/self/exe") : executablePath;
54642
54903
  if (process.argv[0] !== executablePath || process.argv[1] !== installedCliPath || runningExecutablePath !== executablePath || process.execArgv.length !== BUN_POLICY5.length || process.execArgv.some((value, index) => value !== BUN_POLICY5[index])) {