@jigging/jig 0.1.0-alpha.27 → 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.
- package/dist/index.js +12 -2
- package/libexec/agent/claude-agent-acp.js +34 -34
- package/libexec/evaluator/project-evaluator-sdk.bundle.js +12 -2
- package/libexec/evaluator/project-evaluator-worker.js +3 -13
- package/libexec/installed-cli.js +729 -451
- package/libexec/macos-native-supervisor.js +77 -21
- package/libexec/preparation/bun-native-preparation-worker.js +12 -2
- package/package.json +1 -1
package/libexec/installed-cli.js
CHANGED
|
@@ -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
|
|
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
|
|
9084
|
-
import { basename as
|
|
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.
|
|
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 &&
|
|
15649
|
-
throw new TypeError(
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
-
|
|
16892
|
-
|
|
16893
|
-
|
|
16894
|
-
|
|
16895
|
-
|
|
16896
|
-
|
|
16897
|
-
|
|
16898
|
-
|
|
16899
|
-
|
|
16900
|
-
|
|
16901
|
-
|
|
16902
|
-
|
|
16903
|
-
|
|
16904
|
-
|
|
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
|
|
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
|
|
16935
|
+
import { join as join22 } from "path";
|
|
16914
16936
|
|
|
16915
16937
|
// src/channel-contract.ts
|
|
16916
16938
|
import { createHash } from "crypto";
|
|
@@ -26119,10 +26141,20 @@ function privateMacosExecutionPlan(intent, allocation) {
|
|
|
26119
26141
|
return value;
|
|
26120
26142
|
};
|
|
26121
26143
|
const embedded = (value) => {
|
|
26122
|
-
|
|
26123
|
-
|
|
26124
|
-
|
|
26125
|
-
|
|
26144
|
+
try {
|
|
26145
|
+
let changed = false;
|
|
26146
|
+
const parsed = JSON.parse(value, (_name, entry) => {
|
|
26147
|
+
if (typeof entry !== "string")
|
|
26148
|
+
return entry;
|
|
26149
|
+
const relocated = path(entry);
|
|
26150
|
+
if (relocated !== entry)
|
|
26151
|
+
changed = true;
|
|
26152
|
+
return relocated;
|
|
26153
|
+
});
|
|
26154
|
+
return changed ? JSON.stringify(parsed) : value;
|
|
26155
|
+
} catch {
|
|
26156
|
+
return path(value);
|
|
26157
|
+
}
|
|
26126
26158
|
};
|
|
26127
26159
|
const environment = Object.fromEntries(Object.entries(intent.environment ?? {}).map(([name, value]) => [
|
|
26128
26160
|
name,
|
|
@@ -26179,7 +26211,6 @@ function inputPath(destination) {
|
|
|
26179
26211
|
}
|
|
26180
26212
|
|
|
26181
26213
|
// src/internal/linux-rootless-backend.ts
|
|
26182
|
-
init_file_input_policy();
|
|
26183
26214
|
import { spawn } from "child_process";
|
|
26184
26215
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
26185
26216
|
import { closeSync as closeSync10 } from "fs";
|
|
@@ -26202,6 +26233,7 @@ import { tmpdir as tmpdir3 } from "os";
|
|
|
26202
26233
|
import { dirname as dirname5, extname, join as join6, posix as posix5 } from "path";
|
|
26203
26234
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
26204
26235
|
import { types as utilTypes4 } from "util";
|
|
26236
|
+
init_file_input_policy();
|
|
26205
26237
|
init_input_capture();
|
|
26206
26238
|
|
|
26207
26239
|
// src/internal/installation-verification.ts
|
|
@@ -28711,34 +28743,7 @@ async function openPrivateMacosBackendState(value) {
|
|
|
28711
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)
|
|
28712
28744
|
throw new Error("native execution allocation changed");
|
|
28713
28745
|
};
|
|
28714
|
-
const readFile3 =
|
|
28715
|
-
let file;
|
|
28716
|
-
try {
|
|
28717
|
-
file = await openPrivateChild(control, name, constants13.O_RDONLY);
|
|
28718
|
-
} catch (error) {
|
|
28719
|
-
if (error.code === "ENOENT")
|
|
28720
|
-
return;
|
|
28721
|
-
throw error;
|
|
28722
|
-
}
|
|
28723
|
-
try {
|
|
28724
|
-
const before = await file.stat({ bigint: true });
|
|
28725
|
-
if (!before.isFile() || before.uid !== BigInt(process.getuid()) || before.nlink !== 1n || (before.mode & 0o7777n) !== 0o600n || before.size > BigInt(MAX_RECORD_BYTES2))
|
|
28726
|
-
throw new Error("native execution record is unsafe");
|
|
28727
|
-
const bytes = Buffer.alloc(Number(before.size));
|
|
28728
|
-
for (let offset = 0;offset < bytes.length; ) {
|
|
28729
|
-
const { bytesRead } = await file.read(bytes, offset, bytes.length - offset, offset);
|
|
28730
|
-
if (!bytesRead)
|
|
28731
|
-
throw new Error("native execution record ended early");
|
|
28732
|
-
offset += bytesRead;
|
|
28733
|
-
}
|
|
28734
|
-
const after = await file.stat({ bigint: true });
|
|
28735
|
-
if (before.size !== after.size || before.mtimeNs !== after.mtimeNs || before.ctimeNs !== after.ctimeNs || after.nlink !== 1n)
|
|
28736
|
-
throw new Error("native execution record changed");
|
|
28737
|
-
return bytes;
|
|
28738
|
-
} finally {
|
|
28739
|
-
await file.close();
|
|
28740
|
-
}
|
|
28741
|
-
};
|
|
28746
|
+
const readFile3 = (name) => readFileFrom(control, name);
|
|
28742
28747
|
const read = async () => {
|
|
28743
28748
|
await verify();
|
|
28744
28749
|
const bytes = await readFile3("state.json");
|
|
@@ -28779,20 +28784,24 @@ async function openPrivateMacosBackendState(value) {
|
|
|
28779
28784
|
receipt,
|
|
28780
28785
|
mac: releaseSignature(allocation.ownerToken, receipt).toString("hex")
|
|
28781
28786
|
});
|
|
28782
|
-
|
|
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"));
|
|
28783
28792
|
if (existing === undefined) {
|
|
28784
|
-
const file = await openPrivateChild(root, "release.
|
|
28793
|
+
const file = await openPrivateChild(root, "release.pending", constants13.O_WRONLY | constants13.O_CREAT | constants13.O_EXCL);
|
|
28785
28794
|
try {
|
|
28786
28795
|
await file.writeFile(marker);
|
|
28787
28796
|
await file.sync();
|
|
28788
28797
|
} finally {
|
|
28789
28798
|
await file.close();
|
|
28790
28799
|
}
|
|
28800
|
+
await verify();
|
|
28801
|
+
await root.sync();
|
|
28802
|
+
privateMacosRenameAt(root.fd, "release.pending", root.fd, "release.json", true);
|
|
28791
28803
|
await root.sync();
|
|
28792
|
-
existing = marker;
|
|
28793
28804
|
}
|
|
28794
|
-
if (!existing.equals(marker))
|
|
28795
|
-
throw new Error("native execution release marker conflicts");
|
|
28796
28805
|
privateMacosRenameAt(parent.fd, allocation.name, parent.fd, releaseName(allocation), true);
|
|
28797
28806
|
await parent.sync();
|
|
28798
28807
|
};
|
|
@@ -28864,7 +28873,7 @@ async function openPrivateMacosBackendState(value) {
|
|
|
28864
28873
|
async function readFileFrom(parent, name) {
|
|
28865
28874
|
let file;
|
|
28866
28875
|
try {
|
|
28867
|
-
file = await openPrivateChild(parent, name, constants13.O_RDONLY);
|
|
28876
|
+
file = await openPrivateChild(parent, name, constants13.O_RDONLY | constants13.O_NONBLOCK);
|
|
28868
28877
|
} catch (error) {
|
|
28869
28878
|
if (error.code === "ENOENT")
|
|
28870
28879
|
return;
|
|
@@ -29082,7 +29091,6 @@ import { posix as posix10 } from "path";
|
|
|
29082
29091
|
init_input_capture();
|
|
29083
29092
|
|
|
29084
29093
|
// src/internal/macos-guardian-client.ts
|
|
29085
|
-
init_input_capture();
|
|
29086
29094
|
import { spawnSync } from "child_process";
|
|
29087
29095
|
import { createHash as createHash10 } from "crypto";
|
|
29088
29096
|
import { lstat as lstat7, mkdir as mkdir4, mkdtemp as mkdtemp3, rmdir as rmdir4, writeFile } from "fs/promises";
|
|
@@ -29090,6 +29098,18 @@ import { createServer as createServer2 } from "net";
|
|
|
29090
29098
|
import { join as join11 } from "path";
|
|
29091
29099
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
29092
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
|
+
|
|
29093
29113
|
// src/internal/macos-control-channel.ts
|
|
29094
29114
|
function privateMacosControlChannel(socket) {
|
|
29095
29115
|
const messages = [];
|
|
@@ -29511,6 +29531,17 @@ async function sendPrivateMacosDescriptors(path, peer, descriptors, timeoutMs, s
|
|
|
29511
29531
|
|
|
29512
29532
|
// src/internal/macos-guardian-diagnostics.ts
|
|
29513
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
|
+
];
|
|
29514
29545
|
var causes = new Map([
|
|
29515
29546
|
["macOS control channel ended", "CONTROL_EOF"],
|
|
29516
29547
|
["macOS control channel socket failed", "CONTROL_SOCKET"],
|
|
@@ -29522,15 +29553,38 @@ var causes = new Map([
|
|
|
29522
29553
|
["invalid macOS guardian response", "INVALID_RESPONSE"],
|
|
29523
29554
|
["macOS collector has no successful fenced owner", "INVALID_COLLECTOR"],
|
|
29524
29555
|
["macOS collector descriptor count changed", "DESCRIPTOR_COUNT"],
|
|
29525
|
-
["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"]
|
|
29526
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
|
+
}
|
|
29527
29581
|
var observers = new AsyncLocalStorage2;
|
|
29528
29582
|
function reportPrivateMacosGuardianRecovery(phase, step, error) {
|
|
29529
29583
|
try {
|
|
29530
29584
|
const observer = observers.getStore();
|
|
29531
29585
|
if (observer === undefined)
|
|
29532
29586
|
return;
|
|
29533
|
-
const cause =
|
|
29587
|
+
const cause = closedCause(error);
|
|
29534
29588
|
observer(Object.freeze({ phase, step, cause }));
|
|
29535
29589
|
} catch {}
|
|
29536
29590
|
}
|
|
@@ -29555,13 +29609,14 @@ var MIB2 = 1024 * 1024;
|
|
|
29555
29609
|
var IMAGE = "volume.dmg";
|
|
29556
29610
|
var INTENT = "volume.json";
|
|
29557
29611
|
var IMAGE_RECORD = "volume-image.json";
|
|
29612
|
+
var IMAGE_PENDING = "volume-image.pending";
|
|
29558
29613
|
var RETIRE_RECORD = "storage.release.json";
|
|
29559
29614
|
var RETIRE_PENDING = "storage.release.pending";
|
|
29560
|
-
function identity2(
|
|
29561
|
-
return { device: String(
|
|
29615
|
+
function identity2(stat2) {
|
|
29616
|
+
return { device: String(stat2.dev), inode: String(stat2.ino) };
|
|
29562
29617
|
}
|
|
29563
|
-
function matches(
|
|
29564
|
-
return String(
|
|
29618
|
+
function matches(stat2, value) {
|
|
29619
|
+
return String(stat2.dev) === value.device && String(stat2.ino) === value.inode;
|
|
29565
29620
|
}
|
|
29566
29621
|
function isIdentity(value) {
|
|
29567
29622
|
if (value === null || typeof value !== "object")
|
|
@@ -29584,8 +29639,8 @@ async function privateDirectory3(path) {
|
|
|
29584
29639
|
throw new Error("macOS volume directory is aliased");
|
|
29585
29640
|
const directory = await open10(path, OPEN_DIRECTORY);
|
|
29586
29641
|
try {
|
|
29587
|
-
const
|
|
29588
|
-
if (!
|
|
29642
|
+
const stat2 = await directory.stat({ bigint: true });
|
|
29643
|
+
if (!stat2.isDirectory() || stat2.uid !== BigInt(process.getuid()) || (stat2.mode & 0o777n) !== 0o700n)
|
|
29589
29644
|
throw new Error("macOS volume directory is not private");
|
|
29590
29645
|
return directory;
|
|
29591
29646
|
} catch (error) {
|
|
@@ -29768,8 +29823,13 @@ async function releasePrivateMacosVolume(controlPath, token, signal) {
|
|
|
29768
29823
|
} finally {
|
|
29769
29824
|
entries.closeSync();
|
|
29770
29825
|
}
|
|
29771
|
-
if (!names.every((name2) => [INTENT, IMAGE_RECORD].includes(name2)))
|
|
29826
|
+
if (!names.every((name2) => [INTENT, IMAGE_RECORD, IMAGE_PENDING].includes(name2)))
|
|
29772
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
|
+
}
|
|
29773
29833
|
if (retired === undefined)
|
|
29774
29834
|
await writeRetirement(parent, token, allocation);
|
|
29775
29835
|
if (names.includes(IMAGE_RECORD)) {
|
|
@@ -29779,6 +29839,8 @@ async function releasePrivateMacosVolume(controlPath, token, signal) {
|
|
|
29779
29839
|
throw new Error("macOS volume backing journal is invalid");
|
|
29780
29840
|
privateMacosUnlinkAt(control.fd, IMAGE_RECORD);
|
|
29781
29841
|
}
|
|
29842
|
+
if (names.includes(IMAGE_PENDING))
|
|
29843
|
+
privateMacosUnlinkAt(control.fd, IMAGE_PENDING);
|
|
29782
29844
|
if (intent !== undefined)
|
|
29783
29845
|
privateMacosUnlinkAt(control.fd, INTENT);
|
|
29784
29846
|
await control.sync();
|
|
@@ -30080,12 +30142,10 @@ async function recoverStorageWithGuardian(targetDirectory, targetToken, runtime)
|
|
|
30080
30142
|
});
|
|
30081
30143
|
recovery.stdout.resume();
|
|
30082
30144
|
recovery.stderr.resume();
|
|
30083
|
-
recovery.admit().catch(() =>
|
|
30084
|
-
return;
|
|
30085
|
-
});
|
|
30145
|
+
const admission = recovery.admit().catch((error) => error);
|
|
30086
30146
|
const result2 = await recovery.completion;
|
|
30087
30147
|
if (result2.recovered || result2.outputLost || result2.result !== null)
|
|
30088
|
-
throw new Error("macOS storage recovery is unconfirmed");
|
|
30148
|
+
throw new Error("macOS storage recovery is unconfirmed", { cause: await admission });
|
|
30089
30149
|
}
|
|
30090
30150
|
async function preparePrivateMacosGuardian(input) {
|
|
30091
30151
|
return prepareGuardian(input);
|
|
@@ -30278,6 +30338,7 @@ async function prepareGuardian(input) {
|
|
|
30278
30338
|
};
|
|
30279
30339
|
const completion = (async () => {
|
|
30280
30340
|
let step = "receive";
|
|
30341
|
+
let terminalResult;
|
|
30281
30342
|
try {
|
|
30282
30343
|
for (;; ) {
|
|
30283
30344
|
step = "receive";
|
|
@@ -30316,10 +30377,19 @@ async function prepareGuardian(input) {
|
|
|
30316
30377
|
fenced: true,
|
|
30317
30378
|
...received === undefined ? {} : { outputFd: received.descriptors[0] }
|
|
30318
30379
|
}));
|
|
30319
|
-
} 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");
|
|
30320
30384
|
phase = "terminal";
|
|
30321
30385
|
const normalizedResult = message2.result === null ? null : normalizePrivateMacosScopeResult(message2.result);
|
|
30322
|
-
|
|
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);
|
|
30323
30393
|
step = "terminal-cleanup";
|
|
30324
30394
|
closeCollector();
|
|
30325
30395
|
await cleanup();
|
|
@@ -30341,7 +30411,8 @@ async function prepareGuardian(input) {
|
|
|
30341
30411
|
phase = "terminal";
|
|
30342
30412
|
rejectReady(new Error("macOS guardian connection lost"));
|
|
30343
30413
|
try {
|
|
30344
|
-
const
|
|
30414
|
+
const recovered = await recover();
|
|
30415
|
+
const result2 = terminalResult === undefined ? recovered : Object.freeze({ ...recovered, result: terminalResult });
|
|
30345
30416
|
resolveFenced(result2);
|
|
30346
30417
|
return result2;
|
|
30347
30418
|
} catch (error2) {
|
|
@@ -30982,7 +31053,7 @@ function normalizePrivateMacosConfirmedEnforcementReceipt(value) {
|
|
|
30982
31053
|
"cpu_limit",
|
|
30983
31054
|
"accounting_failed",
|
|
30984
31055
|
"recovered"
|
|
30985
|
-
].includes(record3.stopReason) || record3.fenced !== true || typeof record3.outputLost !== "boolean" || typeof record3.recovered !== "boolean" || record3.
|
|
31056
|
+
].includes(record3.stopReason) || record3.fenced !== true || typeof record3.outputLost !== "boolean" || typeof record3.recovered !== "boolean" || record3.stopReason === "recovered" && !record3.recovered)
|
|
30986
31057
|
throw new TypeError("invalid native macOS enforcement receipt");
|
|
30987
31058
|
const scope = normalizePrivateMacosScopeResult({
|
|
30988
31059
|
reason: record3.stopReason === "recovered" ? "coordinator_lost" : record3.stopReason,
|
|
@@ -31159,7 +31230,7 @@ function receiptFor2(prepared, terminal) {
|
|
|
31159
31230
|
signal: result2.signal,
|
|
31160
31231
|
fenced: true,
|
|
31161
31232
|
outputLost: terminal.outputLost,
|
|
31162
|
-
recovered:
|
|
31233
|
+
recovered: terminal.recovered,
|
|
31163
31234
|
evidence: result2.evidence
|
|
31164
31235
|
});
|
|
31165
31236
|
}
|
|
@@ -32183,7 +32254,10 @@ async function evaluateAuthorClosureBatch(options, captured, requestedEntries, s
|
|
|
32183
32254
|
unavailable("PROJECT_EVALUATOR_SUPPORT", "cannot seal evaluator support", entryProjectPath);
|
|
32184
32255
|
}
|
|
32185
32256
|
const component = await privateProfileSpan("author-envelope-startup", () => launchPrivateExecution(options.backend, evaluatorLaunchPlan(installedSupport, runId, limits, inputs), signal)).catch((error) => {
|
|
32186
|
-
|
|
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;
|
|
32187
32261
|
});
|
|
32188
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);
|
|
32189
32263
|
if (!validEnvelope) {
|
|
@@ -34467,8 +34541,11 @@ function exactKeys2(value, required, optional) {
|
|
|
34467
34541
|
throw new TypeError("invalid channel params");
|
|
34468
34542
|
}
|
|
34469
34543
|
|
|
34544
|
+
// src/internal/bun-direct-run.ts
|
|
34545
|
+
init_file_input_policy();
|
|
34546
|
+
|
|
34470
34547
|
// src/internal/private-acp-resources.ts
|
|
34471
|
-
import { isAbsolute as
|
|
34548
|
+
import { isAbsolute as isAbsolute7 } from "path";
|
|
34472
34549
|
|
|
34473
34550
|
// src/internal/acp-agent-provider.ts
|
|
34474
34551
|
import { constants as constants21 } from "fs";
|
|
@@ -34712,14 +34789,133 @@ async function exactFile(path2, executable, label) {
|
|
|
34712
34789
|
}
|
|
34713
34790
|
|
|
34714
34791
|
// src/internal/claude-agent-provider.ts
|
|
34715
|
-
import { lstat as
|
|
34716
|
-
import { join as
|
|
34792
|
+
import { lstat as lstat15, realpath as realpath14 } from "fs/promises";
|
|
34793
|
+
import { join as join19 } from "path";
|
|
34717
34794
|
|
|
34718
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
|
|
34719
34801
|
import { constants as constants22 } from "fs";
|
|
34720
|
-
import { access as access4, lstat as lstat11,
|
|
34721
|
-
import {
|
|
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
|
+
}
|
|
34722
34917
|
|
|
34918
|
+
// src/internal/native-agent-executable.ts
|
|
34723
34919
|
class PrivateNativeAgentExecutableUnavailableError extends Error {
|
|
34724
34920
|
client;
|
|
34725
34921
|
constructor(client) {
|
|
@@ -34730,16 +34926,17 @@ class PrivateNativeAgentExecutableUnavailableError extends Error {
|
|
|
34730
34926
|
async function resolvePrivateNativeAgentExecutable(client, environment, projectDirectory = process.cwd()) {
|
|
34731
34927
|
const selected = environment[`${client.toUpperCase()}_PATH`];
|
|
34732
34928
|
const searchPath = environment.PATH;
|
|
34929
|
+
const voltaHome = environment.VOLTA_HOME;
|
|
34733
34930
|
const project = resolve7(projectDirectory);
|
|
34734
34931
|
try {
|
|
34735
34932
|
if (selected !== undefined) {
|
|
34736
|
-
if (!
|
|
34933
|
+
if (!isAbsolute4(selected) || selected.includes("\x00"))
|
|
34737
34934
|
throw new Error("invalid override");
|
|
34738
|
-
return await executable(selected);
|
|
34935
|
+
return await selectExecutable(client, await executable(selected), voltaHome, project);
|
|
34739
34936
|
}
|
|
34740
34937
|
const outside = await privateNativeAgentSupportResolver(project);
|
|
34741
34938
|
for (const directory of (searchPath ?? "").split(delimiter)) {
|
|
34742
|
-
if (!
|
|
34939
|
+
if (!isAbsolute4(directory) || directory.includes("\x00"))
|
|
34743
34940
|
continue;
|
|
34744
34941
|
const candidate = `${directory}${sep}${client}`;
|
|
34745
34942
|
try {
|
|
@@ -34748,13 +34945,15 @@ async function resolvePrivateNativeAgentExecutable(client, environment, projectD
|
|
|
34748
34945
|
continue;
|
|
34749
34946
|
if (await executable(path2) !== path2)
|
|
34750
34947
|
throw new Error("executable selection changed");
|
|
34751
|
-
return path2;
|
|
34948
|
+
return await selectExecutable(client, path2, voltaHome, project, outside);
|
|
34752
34949
|
} catch (error) {
|
|
34753
|
-
if (!
|
|
34950
|
+
if (!absent3(error) && error.code !== "EACCES")
|
|
34754
34951
|
throw error;
|
|
34755
34952
|
}
|
|
34756
34953
|
}
|
|
34757
|
-
} catch {
|
|
34954
|
+
} catch (error) {
|
|
34955
|
+
if (error instanceof PrivateAcpSetupError)
|
|
34956
|
+
throw error;
|
|
34758
34957
|
throw new PrivateNativeAgentExecutableUnavailableError(client);
|
|
34759
34958
|
}
|
|
34760
34959
|
throw new PrivateNativeAgentExecutableUnavailableError(client);
|
|
@@ -34764,22 +34963,22 @@ async function privateNativeAgentSupportResolver(projectDirectory) {
|
|
|
34764
34963
|
const projectRoot = await realpath11(project);
|
|
34765
34964
|
const excluded = [project, projectRoot];
|
|
34766
34965
|
for (const root of [project, projectRoot]) {
|
|
34767
|
-
for (let directory =
|
|
34768
|
-
const dependencies =
|
|
34966
|
+
for (let directory = dirname10(root);; directory = dirname10(directory)) {
|
|
34967
|
+
const dependencies = join17(directory, "node_modules");
|
|
34769
34968
|
excluded.push(dependencies);
|
|
34770
34969
|
try {
|
|
34771
34970
|
excluded.push(await realpath11(dependencies));
|
|
34772
34971
|
} catch (error) {
|
|
34773
|
-
if (!
|
|
34972
|
+
if (!absent3(error))
|
|
34774
34973
|
throw error;
|
|
34775
34974
|
}
|
|
34776
|
-
if (
|
|
34975
|
+
if (dirname10(directory) === directory)
|
|
34777
34976
|
break;
|
|
34778
34977
|
}
|
|
34779
34978
|
}
|
|
34780
34979
|
const forbidden = (path2) => excluded.some((root) => inside2(root, path2));
|
|
34781
34980
|
return async (path2) => {
|
|
34782
|
-
if (!
|
|
34981
|
+
if (!isAbsolute4(path2) || path2.includes("\x00") || forbidden(path2))
|
|
34783
34982
|
return;
|
|
34784
34983
|
return await outsideProject(path2, forbidden);
|
|
34785
34984
|
};
|
|
@@ -34795,11 +34994,11 @@ async function outsideProject(candidate, forbidden) {
|
|
|
34795
34994
|
path2 = resolve7(path2, component);
|
|
34796
34995
|
if (forbidden(path2))
|
|
34797
34996
|
return;
|
|
34798
|
-
if ((await
|
|
34997
|
+
if ((await lstat12(path2)).isSymbolicLink()) {
|
|
34799
34998
|
if (++links > 40)
|
|
34800
34999
|
throw new Error("too many executable symlinks");
|
|
34801
35000
|
const link4 = await readlink2(path2);
|
|
34802
|
-
const target =
|
|
35001
|
+
const target = isAbsolute4(link4) ? link4 : `${dirname10(path2)}${sep}${link4}`;
|
|
34803
35002
|
if (forbidden(target))
|
|
34804
35003
|
return;
|
|
34805
35004
|
pending = [...target.split(sep).filter(Boolean), ...pending];
|
|
@@ -34810,29 +35009,59 @@ async function outsideProject(candidate, forbidden) {
|
|
|
34810
35009
|
}
|
|
34811
35010
|
async function executable(candidate) {
|
|
34812
35011
|
const path2 = await realpath11(candidate);
|
|
34813
|
-
const information = await
|
|
35012
|
+
const information = await lstat12(path2);
|
|
34814
35013
|
if (!information.isFile() || (information.mode & 73) === 0) {
|
|
34815
35014
|
throw Object.assign(new Error("not an executable file"), { code: "EACCES" });
|
|
34816
35015
|
}
|
|
34817
|
-
await
|
|
35016
|
+
await access5(path2, constants23.X_OK);
|
|
34818
35017
|
return path2;
|
|
34819
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
|
+
}
|
|
34820
35047
|
function inside2(root, path2) {
|
|
34821
35048
|
const child2 = relative2(root, path2);
|
|
34822
|
-
return child2 === "" || child2 !== ".." && !child2.startsWith(`..${sep}`) && !
|
|
35049
|
+
return child2 === "" || child2 !== ".." && !child2.startsWith(`..${sep}`) && !isAbsolute4(child2);
|
|
34823
35050
|
}
|
|
34824
|
-
function
|
|
35051
|
+
function absent3(error) {
|
|
34825
35052
|
return ["ENOENT", "ENOTDIR"].includes(error.code ?? "");
|
|
34826
35053
|
}
|
|
34827
35054
|
|
|
34828
35055
|
// src/internal/native-agent-runtime.ts
|
|
34829
|
-
import {
|
|
34830
|
-
import {
|
|
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";
|
|
34831
35059
|
|
|
34832
35060
|
// src/internal/macos-agent-runtime.ts
|
|
34833
|
-
import {
|
|
35061
|
+
import { constants as constants24 } from "fs";
|
|
35062
|
+
import { lstat as lstat13, open as open14, realpath as realpath12 } from "fs/promises";
|
|
34834
35063
|
import { createRequire as createRequire6 } from "module";
|
|
34835
|
-
import { dirname as
|
|
35064
|
+
import { dirname as dirname11, isAbsolute as isAbsolute5, normalize } from "path";
|
|
34836
35065
|
init_macos_process_controls();
|
|
34837
35066
|
async function inspectPrivateMacosAgentRuntime(executable2, projectDirectory = process.cwd()) {
|
|
34838
35067
|
privateMacosCurrentProcessIdentity();
|
|
@@ -34865,28 +35094,28 @@ async function inspectPrivateMacosAgentRuntime(executable2, projectDirectory = p
|
|
|
34865
35094
|
return;
|
|
34866
35095
|
if (inspected.size >= 128)
|
|
34867
35096
|
throw new Error("native Agent runtime is too large");
|
|
34868
|
-
const information = await
|
|
35097
|
+
const information = await lstat13(path2);
|
|
34869
35098
|
if (!information.isFile() || (information.mode & 3072) !== 0 || isMain && (information.mode & 73) === 0)
|
|
34870
35099
|
throw new Error("native Agent runtime file is invalid");
|
|
34871
35100
|
inspected.add(path2);
|
|
34872
35101
|
if (!isMain)
|
|
34873
35102
|
mounts.set(path2, Object.freeze({ source: path2, destination: path2, role: "support" }));
|
|
34874
35103
|
digests.set(path2, await privateInstallationFileDigest(path2));
|
|
34875
|
-
const
|
|
34876
|
-
if (
|
|
35104
|
+
const metadata2 = await readPrivateMacosAgentMetadata(path2);
|
|
35105
|
+
if (metadata2.executable !== isMain)
|
|
34877
35106
|
throw new Error("native Agent Mach-O file type is invalid");
|
|
34878
|
-
if (
|
|
34879
|
-
const previous = loaded.get(
|
|
35107
|
+
if (metadata2.installName !== undefined) {
|
|
35108
|
+
const previous = loaded.get(metadata2.installName);
|
|
34880
35109
|
if (previous !== undefined && previous !== path2)
|
|
34881
35110
|
throw new Error("native Agent library identity is ambiguous");
|
|
34882
|
-
loaded.set(
|
|
35111
|
+
loaded.set(metadata2.installName, path2);
|
|
34883
35112
|
}
|
|
34884
35113
|
const expand = (value) => {
|
|
34885
35114
|
let expanded;
|
|
34886
35115
|
if (value === "@loader_path" || value.startsWith("@loader_path/"))
|
|
34887
|
-
expanded = `${
|
|
35116
|
+
expanded = `${dirname11(path2)}${value.slice(12)}`;
|
|
34888
35117
|
else if (value === "@executable_path" || value.startsWith("@executable_path/"))
|
|
34889
|
-
expanded = `${
|
|
35118
|
+
expanded = `${dirname11(main)}${value.slice(16)}`;
|
|
34890
35119
|
else {
|
|
34891
35120
|
requirePath(value);
|
|
34892
35121
|
expanded = value;
|
|
@@ -34894,11 +35123,11 @@ async function inspectPrivateMacosAgentRuntime(executable2, projectDirectory = p
|
|
|
34894
35123
|
requirePath(expanded, false);
|
|
34895
35124
|
return expanded;
|
|
34896
35125
|
};
|
|
34897
|
-
const search = [...
|
|
35126
|
+
const search = [...metadata2.search.map(expand), ...inherited];
|
|
34898
35127
|
if (search.length > 128)
|
|
34899
35128
|
throw new Error("native Agent library search is too large");
|
|
34900
35129
|
const dependencies = [];
|
|
34901
|
-
for (const dependency of
|
|
35130
|
+
for (const dependency of metadata2.needed) {
|
|
34902
35131
|
const name = dependency.path;
|
|
34903
35132
|
if (name.startsWith("@rpath/") && loaded.has(name))
|
|
34904
35133
|
continue;
|
|
@@ -34949,9 +35178,12 @@ function privateMacosCachedLibrary(path2) {
|
|
|
34949
35178
|
async function readPrivateMacosAgentMetadata(path2) {
|
|
34950
35179
|
const systemSandbox = process.platform === "darwin" && process.arch === "arm64" && path2 === "/usr/bin/sandbox-exec";
|
|
34951
35180
|
const acceptedSubtype = (value) => nativeSubtype(value) || systemSandbox && value === 2147483650;
|
|
34952
|
-
const file = await
|
|
35181
|
+
const file = await open14(path2, constants24.O_RDONLY | constants24.O_NONBLOCK);
|
|
34953
35182
|
try {
|
|
34954
|
-
const
|
|
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;
|
|
34955
35187
|
async function read(offset2, length) {
|
|
34956
35188
|
if (!Number.isSafeInteger(offset2) || !Number.isSafeInteger(length) || offset2 < 0 || length < 0 || length > 1024 * 1024 || length > size - offset2)
|
|
34957
35189
|
throw new Error("invalid native Agent Mach-O bounds");
|
|
@@ -35097,7 +35329,7 @@ function nativeSubtype(value) {
|
|
|
35097
35329
|
return value === 3 || value === 2147483651;
|
|
35098
35330
|
}
|
|
35099
35331
|
function requirePath(path2, canonical3 = true) {
|
|
35100
|
-
if (!
|
|
35332
|
+
if (!isAbsolute5(path2) || canonical3 && normalize(path2) !== path2 || path2 === "/" || Buffer.byteLength(path2) > 4096 || [...path2].some((char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127))
|
|
35101
35333
|
throw new Error("native Agent runtime path is invalid");
|
|
35102
35334
|
}
|
|
35103
35335
|
|
|
@@ -35117,7 +35349,7 @@ async function inspectPrivateNativeAgentRuntime(executable2, projectDirectory =
|
|
|
35117
35349
|
const source = destination === executable2 ? await realpath13(destination) : await outsideProject2(destination);
|
|
35118
35350
|
if (source === undefined)
|
|
35119
35351
|
throw new Error("native Agent runtime enters the project");
|
|
35120
|
-
const information = await
|
|
35352
|
+
const information = await lstat14(source);
|
|
35121
35353
|
if (!information.isFile() || (information.mode & 3072) !== 0 || executableFile && (information.mode & 73) === 0) {
|
|
35122
35354
|
throw new Error("native Agent runtime file is invalid");
|
|
35123
35355
|
}
|
|
@@ -35126,12 +35358,12 @@ async function inspectPrivateNativeAgentRuntime(executable2, projectDirectory =
|
|
|
35126
35358
|
return;
|
|
35127
35359
|
inspected.add(source);
|
|
35128
35360
|
digests.set(source, await privateInstallationFileDigest(source));
|
|
35129
|
-
const elf = await
|
|
35361
|
+
const elf = await readPrivateNativeAgentElfMetadata(source);
|
|
35130
35362
|
if (elf === undefined) {
|
|
35131
35363
|
throw new Error("native Agent runtime is not a qualified executable");
|
|
35132
35364
|
}
|
|
35133
35365
|
const search = elf.search.map((path2) => {
|
|
35134
|
-
const expanded = path2.replace(/\$\{ORIGIN\}|\$ORIGIN/g,
|
|
35366
|
+
const expanded = path2.replace(/\$\{ORIGIN\}|\$ORIGIN/g, dirname12(destination));
|
|
35135
35367
|
requirePath2(expanded);
|
|
35136
35368
|
if (expanded.includes("$"))
|
|
35137
35369
|
throw new Error("unsupported native Agent library search");
|
|
@@ -35141,7 +35373,7 @@ async function inspectPrivateNativeAgentRuntime(executable2, projectDirectory =
|
|
|
35141
35373
|
const directories = [...search, ...inherited];
|
|
35142
35374
|
if (elf.interpreter !== undefined) {
|
|
35143
35375
|
await visit2(elf.interpreter, [], new Map, true);
|
|
35144
|
-
directories.push(
|
|
35376
|
+
directories.push(dirname12(elf.interpreter), dirname12(mounts.get(elf.interpreter).source));
|
|
35145
35377
|
}
|
|
35146
35378
|
directories.push("/lib/x86_64-linux-gnu", "/usr/lib/x86_64-linux-gnu", "/lib64", "/usr/lib64", "/lib", "/usr/lib");
|
|
35147
35379
|
const dependencies = [];
|
|
@@ -35156,9 +35388,9 @@ async function inspectPrivateNativeAgentRuntime(executable2, projectDirectory =
|
|
|
35156
35388
|
}
|
|
35157
35389
|
let found;
|
|
35158
35390
|
for (const directory of directories) {
|
|
35159
|
-
const candidate =
|
|
35391
|
+
const candidate = join18(directory, name);
|
|
35160
35392
|
try {
|
|
35161
|
-
await
|
|
35393
|
+
await lstat14(candidate);
|
|
35162
35394
|
found = candidate;
|
|
35163
35395
|
break;
|
|
35164
35396
|
} catch (error) {
|
|
@@ -35188,10 +35420,13 @@ async function inspectPrivateNativeAgentRuntime(executable2, projectDirectory =
|
|
|
35188
35420
|
verifyProvider: (provider) => verifyPrivateAcpAgentFileDigests(provider, digests)
|
|
35189
35421
|
});
|
|
35190
35422
|
}
|
|
35191
|
-
async function
|
|
35192
|
-
const file = await
|
|
35423
|
+
async function readPrivateNativeAgentElfMetadata(path2) {
|
|
35424
|
+
const file = await open15(path2, constants25.O_RDONLY | constants25.O_NONBLOCK);
|
|
35193
35425
|
try {
|
|
35194
|
-
const
|
|
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;
|
|
35195
35430
|
async function read(offset, length) {
|
|
35196
35431
|
if (!Number.isSafeInteger(offset) || !Number.isSafeInteger(length) || offset < 0 || length < 0 || length > 1024 * 1024 || offset + length > size) {
|
|
35197
35432
|
throw new Error("invalid native Agent ELF bounds");
|
|
@@ -35303,7 +35538,7 @@ function stringAt(bytes, offset, allowEmpty = false) {
|
|
|
35303
35538
|
return value;
|
|
35304
35539
|
}
|
|
35305
35540
|
function requirePath2(path2) {
|
|
35306
|
-
if (!
|
|
35541
|
+
if (!isAbsolute6(path2) || path2.includes("\x00") || normalize2(path2) !== path2 || path2 === "/") {
|
|
35307
35542
|
throw new Error("native Agent runtime path is invalid");
|
|
35308
35543
|
}
|
|
35309
35544
|
}
|
|
@@ -35324,8 +35559,8 @@ async function openPrivateClaudeAgentProvider(releaseRoot, environment = process
|
|
|
35324
35559
|
const executablePath = await resolvePrivateNativeAgentExecutable("claude", environment, projectDirectory);
|
|
35325
35560
|
const runtime = await checkAcpSetup("installation", () => inspectPrivateNativeAgentRuntime(executablePath, projectDirectory));
|
|
35326
35561
|
const support = Object.freeze({
|
|
35327
|
-
launcherPath:
|
|
35328
|
-
adapterPath:
|
|
35562
|
+
launcherPath: join19(releaseRoot, "libexec", "agent", "claude-agent-launcher.js"),
|
|
35563
|
+
adapterPath: join19(releaseRoot, "libexec", "agent", "claude-agent-acp.js"),
|
|
35329
35564
|
executablePath,
|
|
35330
35565
|
certificatesPath: await ordinaryFile(HOST_CERTIFICATES_PATH, "host certificate bundle"),
|
|
35331
35566
|
runtimeMounts: runtime.mounts
|
|
@@ -35492,7 +35727,7 @@ function frameStartupInput(value) {
|
|
|
35492
35727
|
}
|
|
35493
35728
|
async function ordinaryFile(path2, label) {
|
|
35494
35729
|
const exact6 = await realpath14(path2);
|
|
35495
|
-
const information = await
|
|
35730
|
+
const information = await lstat15(exact6);
|
|
35496
35731
|
if (!information.isFile() || information.isSymbolicLink()) {
|
|
35497
35732
|
throw new Error(`${label} is invalid`);
|
|
35498
35733
|
}
|
|
@@ -35500,9 +35735,9 @@ async function ordinaryFile(path2, label) {
|
|
|
35500
35735
|
}
|
|
35501
35736
|
|
|
35502
35737
|
// src/internal/codex-agent-provider.ts
|
|
35503
|
-
import { lstat as
|
|
35738
|
+
import { lstat as lstat16, readFile as readFile4, realpath as realpath15 } from "fs/promises";
|
|
35504
35739
|
import { homedir as homedir2 } from "os";
|
|
35505
|
-
import { basename, dirname as
|
|
35740
|
+
import { basename as basename3, dirname as dirname13, join as join20 } from "path";
|
|
35506
35741
|
var CODEX_CLIENT = "openai-codex";
|
|
35507
35742
|
var SANDBOX_LAUNCHER_PATH2 = "/agent/codex-agent-launcher.js";
|
|
35508
35743
|
var SANDBOX_ADAPTER_PATH2 = "/agent/codex-acp.js";
|
|
@@ -35549,7 +35784,9 @@ async function openPrivateCodexAgentProvider(releaseRoot, environment = process.
|
|
|
35549
35784
|
let executablePath;
|
|
35550
35785
|
try {
|
|
35551
35786
|
executablePath = await resolvePrivateNativeAgentExecutable("codex", environment, projectDirectory);
|
|
35552
|
-
} catch {
|
|
35787
|
+
} catch (error) {
|
|
35788
|
+
if (error instanceof PrivateAcpSetupError)
|
|
35789
|
+
throw error;
|
|
35553
35790
|
throw new PrivateCodexExecutableUnavailableError("the native Codex executable is unavailable");
|
|
35554
35791
|
}
|
|
35555
35792
|
let runtime;
|
|
@@ -35572,7 +35809,7 @@ async function openPrivateCodexAgentProvider(releaseRoot, environment = process.
|
|
|
35572
35809
|
if (bubblewrapRuntime.pathPrefix)
|
|
35573
35810
|
throw new Error("wrapped Bubblewrap is unsupported");
|
|
35574
35811
|
} catch (error) {
|
|
35575
|
-
throw new
|
|
35812
|
+
throw new PrivateCodexSandboxUnavailableError("the Codex sandbox runtime is unavailable", {
|
|
35576
35813
|
cause: error
|
|
35577
35814
|
});
|
|
35578
35815
|
}
|
|
@@ -35585,14 +35822,14 @@ async function openPrivateCodexAgentProvider(releaseRoot, environment = process.
|
|
|
35585
35822
|
mounts.set(mount.destination, mount);
|
|
35586
35823
|
}
|
|
35587
35824
|
const support = Object.freeze({
|
|
35588
|
-
launcherPath:
|
|
35589
|
-
adapterPath:
|
|
35825
|
+
launcherPath: join20(releaseRoot, "libexec", "agent", "codex-agent-launcher.js"),
|
|
35826
|
+
adapterPath: join20(releaseRoot, "libexec", "agent", "codex-acp.js"),
|
|
35590
35827
|
executablePath,
|
|
35591
35828
|
nativeBubblewrapPath,
|
|
35592
35829
|
nativeBubblewrapSource: nativeBubblewrap.source,
|
|
35593
35830
|
runtimeMounts: Object.freeze([...mounts.values()]),
|
|
35594
35831
|
certificatesPath: await ordinaryFile2(HOST_CERTIFICATES_PATH2, "host certificate bundle"),
|
|
35595
|
-
requirementsPath:
|
|
35832
|
+
requirementsPath: join20(releaseRoot, "libexec", "agent", "codex-requirements.toml")
|
|
35596
35833
|
});
|
|
35597
35834
|
const apiKey = environment[OPENAI_API_KEY];
|
|
35598
35835
|
const apiModel = environment[OPENAI_MODEL];
|
|
@@ -35617,10 +35854,10 @@ async function openPrivateCodexAgentProvider(releaseRoot, environment = process.
|
|
|
35617
35854
|
bubblewrapRuntime.verifyProvider(provider2);
|
|
35618
35855
|
return provider2;
|
|
35619
35856
|
}
|
|
35620
|
-
const sourceHome = environment.CODEX_HOME ??
|
|
35857
|
+
const sourceHome = environment.CODEX_HOME ?? join20(homedir2(), ".codex");
|
|
35621
35858
|
let credential;
|
|
35622
35859
|
try {
|
|
35623
|
-
credential = await projectPrivateCodexSubscriptionCredential(
|
|
35860
|
+
credential = await projectPrivateCodexSubscriptionCredential(join20(sourceHome, "auth.json"));
|
|
35624
35861
|
} catch {
|
|
35625
35862
|
throw new PrivateCodexLoginUnavailableError("Codex file-backed login is unavailable");
|
|
35626
35863
|
}
|
|
@@ -35636,7 +35873,7 @@ async function openPrivateCodexAgentProvider(releaseRoot, environment = process.
|
|
|
35636
35873
|
}
|
|
35637
35874
|
async function projectPrivateCodexSubscriptionCredential(path2) {
|
|
35638
35875
|
const exact6 = await exactFile2(path2, "Codex subscription credential");
|
|
35639
|
-
const information = await
|
|
35876
|
+
const information = await lstat16(exact6);
|
|
35640
35877
|
const uid = typeof process.getuid === "function" ? process.getuid() : -1;
|
|
35641
35878
|
if (information.uid !== uid || information.nlink !== 1 || (information.mode & 63) !== 0 || information.size > MAX_CREDENTIAL_BYTES) {
|
|
35642
35879
|
throw new Error("Codex subscription credential is invalid");
|
|
@@ -35793,7 +36030,7 @@ function codexEnvironment(subscription, model, support) {
|
|
|
35793
36030
|
}),
|
|
35794
36031
|
CODEX_HOME: SANDBOX_CODEX_HOME,
|
|
35795
36032
|
CODEX_PATH: support.executablePath,
|
|
35796
|
-
PATH: support.nativeBubblewrapSource === "bundled" ? "/agent" :
|
|
36033
|
+
PATH: support.nativeBubblewrapSource === "bundled" ? "/agent" : dirname13(support.nativeBubblewrapPath),
|
|
35797
36034
|
CODEX_SQLITE_HOME: "/tmp/codex-state",
|
|
35798
36035
|
INITIAL_AGENT_MODE: "read-only",
|
|
35799
36036
|
...subscription ? { JIG_CODEX_STARTUP_INPUT: "subscription" } : {},
|
|
@@ -35807,15 +36044,15 @@ async function nativeBubblewrapFor(executablePath, environment, projectDirectory
|
|
|
35807
36044
|
system = await resolvePrivateNativeAgentExecutable("bwrap", environment, projectDirectory);
|
|
35808
36045
|
} catch {}
|
|
35809
36046
|
if (system !== undefined) {
|
|
35810
|
-
if (((await
|
|
36047
|
+
if (((await lstat16(system)).mode & 3072) !== 0) {
|
|
35811
36048
|
throw new PrivateCodexSandboxUnavailableError("Codex Bubblewrap must be unprivileged");
|
|
35812
36049
|
}
|
|
35813
36050
|
return { path: system, source: "path" };
|
|
35814
36051
|
}
|
|
35815
|
-
const executableDirectory =
|
|
35816
|
-
const adjacent =
|
|
35817
|
-
const packageResource =
|
|
35818
|
-
const candidates =
|
|
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];
|
|
35819
36056
|
try {
|
|
35820
36057
|
for (const candidate of candidates) {
|
|
35821
36058
|
let path2;
|
|
@@ -35826,7 +36063,7 @@ async function nativeBubblewrapFor(executablePath, environment, projectDirectory
|
|
|
35826
36063
|
throw error;
|
|
35827
36064
|
continue;
|
|
35828
36065
|
}
|
|
35829
|
-
const information = await
|
|
36066
|
+
const information = await lstat16(path2);
|
|
35830
36067
|
if ((information.mode & 3072) !== 0 || (information.mode & 73) === 0) {
|
|
35831
36068
|
throw new PrivateCodexSandboxUnavailableError("Codex bundled Bubblewrap is invalid");
|
|
35832
36069
|
}
|
|
@@ -35841,7 +36078,7 @@ async function nativeBubblewrapFor(executablePath, environment, projectDirectory
|
|
|
35841
36078
|
}
|
|
35842
36079
|
async function ordinaryFile2(path2, label) {
|
|
35843
36080
|
const exact6 = await realpath15(path2);
|
|
35844
|
-
const information = await
|
|
36081
|
+
const information = await lstat16(exact6);
|
|
35845
36082
|
if (!information.isFile() || information.isSymbolicLink()) {
|
|
35846
36083
|
throw new Error(`${label} is invalid`);
|
|
35847
36084
|
}
|
|
@@ -35886,7 +36123,7 @@ function requireSubscriptionCredential(value) {
|
|
|
35886
36123
|
}
|
|
35887
36124
|
async function exactFile2(path2, label) {
|
|
35888
36125
|
const exact6 = await realpath15(path2);
|
|
35889
|
-
const information = await
|
|
36126
|
+
const information = await lstat16(exact6);
|
|
35890
36127
|
if (exact6 !== path2 || !information.isFile() || information.isSymbolicLink()) {
|
|
35891
36128
|
throw new Error(`${label} is invalid`);
|
|
35892
36129
|
}
|
|
@@ -35942,9 +36179,9 @@ function requireBaseURL2(value) {
|
|
|
35942
36179
|
}
|
|
35943
36180
|
|
|
35944
36181
|
// src/internal/pi-agent-provider.ts
|
|
35945
|
-
import { lstat as
|
|
36182
|
+
import { lstat as lstat17, readFile as readFile5, realpath as realpath16 } from "fs/promises";
|
|
35946
36183
|
import { homedir as homedir3 } from "os";
|
|
35947
|
-
import { dirname as
|
|
36184
|
+
import { dirname as dirname14, join as join21, resolve as resolve8 } from "path";
|
|
35948
36185
|
var PI_CLIENT = "pi";
|
|
35949
36186
|
var SANDBOX_LAUNCHER_PATH3 = "/agent/pi-agent-launcher.js";
|
|
35950
36187
|
var SANDBOX_ADAPTER_PATH3 = "/agent/pi-acp.js";
|
|
@@ -35972,15 +36209,15 @@ async function openPrivatePiAgentProvider(releaseRoot, environment = process.env
|
|
|
35972
36209
|
throw new Error("native Pi support enters the project");
|
|
35973
36210
|
return exact6;
|
|
35974
36211
|
}
|
|
35975
|
-
const nativeRoot =
|
|
36212
|
+
const nativeRoot = dirname14(executablePath);
|
|
35976
36213
|
const support = await checkAcpSetup("installation", async () => Object.freeze({
|
|
35977
|
-
launcherPath:
|
|
35978
|
-
adapterPath:
|
|
36214
|
+
launcherPath: join21(releaseRoot, "libexec", "agent", "pi-agent-launcher.js"),
|
|
36215
|
+
adapterPath: join21(releaseRoot, "libexec", "agent", "pi-acp.js"),
|
|
35979
36216
|
executablePath,
|
|
35980
36217
|
runtimeMounts: runtime.mounts,
|
|
35981
|
-
manifestPath: await piManifestFile(await asset(
|
|
35982
|
-
darkThemePath: await ordinaryFile3(await asset(
|
|
35983
|
-
lightThemePath: await ordinaryFile3(await asset(
|
|
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"),
|
|
35984
36221
|
certificatesPath: await ordinaryFile3(process.platform === "darwin" ? "/etc/ssl/cert.pem" : "/etc/ssl/certs/ca-certificates.crt", "host certificate bundle")
|
|
35985
36222
|
}));
|
|
35986
36223
|
const provider = environment.PI_PROVIDER;
|
|
@@ -36005,7 +36242,7 @@ async function openPrivatePiAgentProvider(releaseRoot, environment = process.env
|
|
|
36005
36242
|
if (configuredAgentDirectory !== undefined && (configuredAgentDirectory.length === 0 || configuredAgentDirectory.includes("\x00"))) {
|
|
36006
36243
|
throw new PrivateAcpSetupError("login");
|
|
36007
36244
|
}
|
|
36008
|
-
const credentialPath =
|
|
36245
|
+
const credentialPath = join21(configuredAgentDirectory === undefined ? join21(homedir3(), ".pi", "agent") : resolve8(configuredAgentDirectory), "auth.json");
|
|
36009
36246
|
const sourceCredential = await checkAcpSetup("login", () => readCredentialFile(credentialPath));
|
|
36010
36247
|
let credential;
|
|
36011
36248
|
try {
|
|
@@ -36109,17 +36346,17 @@ async function createPiProvider(value) {
|
|
|
36109
36346
|
},
|
|
36110
36347
|
{
|
|
36111
36348
|
source: value.support.manifestPath,
|
|
36112
|
-
destination:
|
|
36349
|
+
destination: join21(dirname14(value.support.executablePath), "package.json"),
|
|
36113
36350
|
role: "support"
|
|
36114
36351
|
},
|
|
36115
36352
|
{
|
|
36116
36353
|
source: value.support.darkThemePath,
|
|
36117
|
-
destination:
|
|
36354
|
+
destination: join21(dirname14(value.support.executablePath), "theme", "dark.json"),
|
|
36118
36355
|
role: "support"
|
|
36119
36356
|
},
|
|
36120
36357
|
{
|
|
36121
36358
|
source: value.support.lightThemePath,
|
|
36122
|
-
destination:
|
|
36359
|
+
destination: join21(dirname14(value.support.executablePath), "theme", "light.json"),
|
|
36123
36360
|
role: "support"
|
|
36124
36361
|
}
|
|
36125
36362
|
]
|
|
@@ -36248,7 +36485,7 @@ function isRecord3(value) {
|
|
|
36248
36485
|
}
|
|
36249
36486
|
async function ordinaryFile3(path2, label) {
|
|
36250
36487
|
const exact6 = await realpath16(path2);
|
|
36251
|
-
const information = await
|
|
36488
|
+
const information = await lstat17(exact6);
|
|
36252
36489
|
if (!information.isFile() || information.isSymbolicLink()) {
|
|
36253
36490
|
throw new Error(`${label} is invalid`);
|
|
36254
36491
|
}
|
|
@@ -36269,7 +36506,7 @@ async function piManifestFile(path2) {
|
|
|
36269
36506
|
}
|
|
36270
36507
|
async function readCredentialFile(path2) {
|
|
36271
36508
|
const exact6 = await realpath16(path2);
|
|
36272
|
-
const information = await
|
|
36509
|
+
const information = await lstat17(exact6);
|
|
36273
36510
|
const uid = process.getuid?.();
|
|
36274
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) {
|
|
36275
36512
|
throw new Error("Pi subscription credential projection is invalid");
|
|
@@ -36302,7 +36539,7 @@ var CLIENT_IDENTITIES = {
|
|
|
36302
36539
|
};
|
|
36303
36540
|
function openPrivateAcpResources(installedSupport, environment, projectDirectory, openClient = openQualifiedClient) {
|
|
36304
36541
|
const support = requirePrivateInstalledBunSupport(installedSupport);
|
|
36305
|
-
if (!
|
|
36542
|
+
if (!isAbsolute7(projectDirectory) || projectDirectory.includes("\x00"))
|
|
36306
36543
|
throw new TypeError("ACP resources require the fixed absolute project directory");
|
|
36307
36544
|
const owner = Object.freeze({ kind: "private-acp-resources/1" });
|
|
36308
36545
|
owners.set(owner, {
|
|
@@ -36349,8 +36586,8 @@ async function selectPrivateAcpResources(owner, slots, installedSupport) {
|
|
|
36349
36586
|
return Object.freeze(selected);
|
|
36350
36587
|
}
|
|
36351
36588
|
async function openQualifiedClient(client, support, environment, projectDirectory, model) {
|
|
36352
|
-
const
|
|
36353
|
-
return await
|
|
36589
|
+
const open16 = client === "codex" ? openPrivateCodexAgentProvider : client === "claude" ? openPrivateClaudeAgentProvider : openPrivatePiAgentProvider;
|
|
36590
|
+
return await open16(support.releaseRoot, environment, projectDirectory, model);
|
|
36354
36591
|
}
|
|
36355
36592
|
|
|
36356
36593
|
// src/internal/bun-direct-run.ts
|
|
@@ -36519,9 +36756,9 @@ function logicalLaunchDigest(request, execution, installedSupport, mechanism, ht
|
|
|
36519
36756
|
bunPolicy: BUN_POLICY2,
|
|
36520
36757
|
runtimePredicates: RUNTIME_PREDICATES,
|
|
36521
36758
|
fileProfile: {
|
|
36522
|
-
inputBytes:
|
|
36523
|
-
inputFiles:
|
|
36524
|
-
outputBytes:
|
|
36759
|
+
inputBytes: PRIVATE_CAPTURE_LIMITS.input,
|
|
36760
|
+
inputFiles: PRIVATE_FILE_LIMITS.files,
|
|
36761
|
+
outputBytes: PRIVATE_CAPTURE_LIMITS.output,
|
|
36525
36762
|
rootOnly: true
|
|
36526
36763
|
},
|
|
36527
36764
|
slots: request.slots,
|
|
@@ -36650,7 +36887,7 @@ function normalizeLock(value) {
|
|
|
36650
36887
|
const root = exactObject2(value, [
|
|
36651
36888
|
"packages",
|
|
36652
36889
|
"bindings",
|
|
36653
|
-
...Object.hasOwn(
|
|
36890
|
+
...Object.hasOwn(object8(value, "lock"), "entrypoint") ? ["entrypoint"] : []
|
|
36654
36891
|
], "lock");
|
|
36655
36892
|
const packages = normalizePackages(root.packages);
|
|
36656
36893
|
const bindings = normalizeBindings(root.bindings);
|
|
@@ -36671,7 +36908,7 @@ function normalizeLock(value) {
|
|
|
36671
36908
|
});
|
|
36672
36909
|
}
|
|
36673
36910
|
function normalizePackages(value) {
|
|
36674
|
-
const input =
|
|
36911
|
+
const input = object8(value, "packages");
|
|
36675
36912
|
const paths2 = Object.keys(input);
|
|
36676
36913
|
assertNoProjectPathCollisions(paths2, "lock package");
|
|
36677
36914
|
const output = Object.create(null);
|
|
@@ -36681,8 +36918,8 @@ function normalizePackages(value) {
|
|
|
36681
36918
|
"digest",
|
|
36682
36919
|
"directRun",
|
|
36683
36920
|
"uses",
|
|
36684
|
-
...Object.hasOwn(
|
|
36685
|
-
...Object.hasOwn(
|
|
36921
|
+
...Object.hasOwn(object8(input[path2], `package ${path2}`), "supports") ? ["supports"] : [],
|
|
36922
|
+
...Object.hasOwn(object8(input[path2], `package ${path2}`), "slots") ? ["slots"] : []
|
|
36686
36923
|
], `package ${path2}`);
|
|
36687
36924
|
if (typeof item2.directRun !== "boolean") {
|
|
36688
36925
|
throw new TypeError(`package ${path2} directRun must be boolean`);
|
|
@@ -36707,20 +36944,20 @@ function normalizeFeatureNames(value) {
|
|
|
36707
36944
|
return Object.freeze([...value]);
|
|
36708
36945
|
}
|
|
36709
36946
|
function normalizeUses(value, label) {
|
|
36710
|
-
const input =
|
|
36947
|
+
const input = object8(value, `${label} uses`);
|
|
36711
36948
|
const names = Object.keys(input);
|
|
36712
36949
|
if (names.length > 256)
|
|
36713
36950
|
throw new TypeError(`${label} uses exceed 256 entries`);
|
|
36714
36951
|
const output = Object.create(null);
|
|
36715
36952
|
for (const name of names.sort()) {
|
|
36716
36953
|
localName3(name, `${label} invocation slot`);
|
|
36717
|
-
const requirement =
|
|
36954
|
+
const requirement = object8(input[name], `${label} slot ${name}`);
|
|
36718
36955
|
output[name] = Object.keys(requirement).length === 0 ? Object.freeze({}) : normalizeInvocationRequirement(requirement);
|
|
36719
36956
|
}
|
|
36720
36957
|
return Object.freeze(output);
|
|
36721
36958
|
}
|
|
36722
36959
|
function normalizeBindings(value) {
|
|
36723
|
-
const input =
|
|
36960
|
+
const input = object8(value, "bindings");
|
|
36724
36961
|
const output = Object.create(null);
|
|
36725
36962
|
for (const id of Object.keys(input).sort()) {
|
|
36726
36963
|
localName3(id, `Binding ${JSON.stringify(id)}`);
|
|
@@ -36728,9 +36965,9 @@ function normalizeBindings(value) {
|
|
|
36728
36965
|
"packagePath",
|
|
36729
36966
|
"settings",
|
|
36730
36967
|
"slots",
|
|
36731
|
-
...Object.hasOwn(
|
|
36968
|
+
...Object.hasOwn(object8(input[id], `Binding ${id}`), "attachments") ? ["attachments"] : []
|
|
36732
36969
|
], `Binding ${id}`);
|
|
36733
|
-
const settings =
|
|
36970
|
+
const settings = object8(item2.settings, `Binding ${id} settings`);
|
|
36734
36971
|
const slots = normalizeSlots(item2.slots, `Binding ${id}`);
|
|
36735
36972
|
output[id] = Object.freeze({
|
|
36736
36973
|
packagePath: projectPath(item2.packagePath, `Binding ${id} packagePath`),
|
|
@@ -36774,14 +37011,14 @@ function validateReferences(packages, bindings) {
|
|
|
36774
37011
|
validateChildGraph(new Map(Object.entries(bindings)), directFlows);
|
|
36775
37012
|
}
|
|
36776
37013
|
function normalizeSlots(value, label) {
|
|
36777
|
-
const input =
|
|
37014
|
+
const input = object8(value, `${label} slots`);
|
|
36778
37015
|
const names = Object.keys(input);
|
|
36779
37016
|
if (names.length > 256)
|
|
36780
37017
|
throw new TypeError(`${label} slots exceed 256 entries`);
|
|
36781
37018
|
const output = Object.create(null);
|
|
36782
37019
|
for (const name of names.sort()) {
|
|
36783
37020
|
localName3(name, `${label} slot`);
|
|
36784
|
-
const target =
|
|
37021
|
+
const target = object8(input[name], `${label} slot ${name}`);
|
|
36785
37022
|
if (target.kind === "grant") {
|
|
36786
37023
|
exactObject2(target, ["kind", "policy", ...Object.hasOwn(target, "name") ? ["name"] : []], label);
|
|
36787
37024
|
output[name] = Object.freeze({
|
|
@@ -36823,14 +37060,14 @@ function digest4(value, label) {
|
|
|
36823
37060
|
}
|
|
36824
37061
|
return value;
|
|
36825
37062
|
}
|
|
36826
|
-
function
|
|
37063
|
+
function object8(value, label) {
|
|
36827
37064
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
36828
37065
|
throw new TypeError(`${label} must be an object`);
|
|
36829
37066
|
}
|
|
36830
37067
|
return value;
|
|
36831
37068
|
}
|
|
36832
37069
|
function exactObject2(value, fields, label) {
|
|
36833
|
-
const result2 =
|
|
37070
|
+
const result2 = object8(value, label);
|
|
36834
37071
|
const actual = Object.keys(result2).sort();
|
|
36835
37072
|
const expected = [...fields].sort();
|
|
36836
37073
|
if (actual.length !== expected.length || actual.some((key, index) => key !== expected[index])) {
|
|
@@ -37422,8 +37659,8 @@ function normalizeEmbeddedLock(value, label, decoded) {
|
|
|
37422
37659
|
if (!decoded) {
|
|
37423
37660
|
return decodePrivateProjectLocalLock(encodePrivateProjectLocalLock(value));
|
|
37424
37661
|
}
|
|
37425
|
-
const
|
|
37426
|
-
return decodePrivateProjectLocalLock(encodeRecord(
|
|
37662
|
+
const object9 = plainObject(value, label);
|
|
37663
|
+
return decodePrivateProjectLocalLock(encodeRecord(object9, label));
|
|
37427
37664
|
}
|
|
37428
37665
|
function samePrivateLocks(left, right) {
|
|
37429
37666
|
return sameBytes2(encodePrivateProjectLocalLock(left), encodePrivateProjectLocalLock(right));
|
|
@@ -39769,8 +40006,8 @@ async function openCoordinatorLock(owner) {
|
|
|
39769
40006
|
const directoryInformation = await owner.directory.stat({ bigint: true });
|
|
39770
40007
|
const databaseInformation = await ensureDatabaseFile(databasePath, owner.directory, directoryInformation.dev, true, COORDINATOR_DATABASE_NAME);
|
|
39771
40008
|
await validateSidecars(owner.directory, databaseInformation.dev, COORDINATOR_DATABASE_NAME);
|
|
39772
|
-
const visibleStatePath =
|
|
39773
|
-
const visibleDatabasePath =
|
|
40009
|
+
const visibleStatePath = join22(await sqliteVisibleRoot(owner.root), STATE_DIRECTORY);
|
|
40010
|
+
const visibleDatabasePath = join22(visibleStatePath, COORDINATOR_DATABASE_NAME);
|
|
39774
40011
|
await verifyVisibleHierarchy(owner.root, visibleStatePath, directoryInformation, visibleDatabasePath, databaseInformation);
|
|
39775
40012
|
const sqlite = loadSqlite();
|
|
39776
40013
|
const flags = sqliteFlag(sqlite, "SQLITE_OPEN_READWRITE") | sqliteFlag(sqlite, "SQLITE_OPEN_NOFOLLOW");
|
|
@@ -39830,15 +40067,15 @@ function initializeOrVerifyCoordinatorSchema(database) {
|
|
|
39830
40067
|
throw error;
|
|
39831
40068
|
}
|
|
39832
40069
|
try {
|
|
39833
|
-
const
|
|
40070
|
+
const version2 = pragmaInteger(database, "user_version");
|
|
39834
40071
|
const application = pragmaInteger(database, "application_id");
|
|
39835
40072
|
const existing = schemaRows(database);
|
|
39836
|
-
if (
|
|
40073
|
+
if (version2 === 0n && application === 0n && existing.length === 0) {
|
|
39837
40074
|
database.exec(CREATE_COORDINATOR_LOCK);
|
|
39838
40075
|
database.exec("INSERT INTO coordinator_lock(singleton) VALUES (1)");
|
|
39839
40076
|
database.exec(`PRAGMA application_id=${COORDINATOR_APPLICATION_ID}`);
|
|
39840
40077
|
database.exec(`PRAGMA user_version=${COORDINATOR_SCHEMA_VERSION}`);
|
|
39841
|
-
} else if (
|
|
40078
|
+
} else if (version2 !== COORDINATOR_SCHEMA_VERSION || application !== COORDINATOR_APPLICATION_ID) {
|
|
39842
40079
|
invalid("COORDINATOR_SCHEMA_VERSION", "private coordinator database has an unsupported format identity");
|
|
39843
40080
|
}
|
|
39844
40081
|
const rows = schemaRows(database);
|
|
@@ -39983,8 +40220,8 @@ async function inspectPrivateApprovedProject(projectRoot, selector, checkEnviron
|
|
|
39983
40220
|
await owner.dispose();
|
|
39984
40221
|
}
|
|
39985
40222
|
}
|
|
39986
|
-
async function openStateOwner(projectRoot, create,
|
|
39987
|
-
if (create &&
|
|
40223
|
+
async function openStateOwner(projectRoot, create, access6 = "read-write") {
|
|
40224
|
+
if (create && access6 === "read-only")
|
|
39988
40225
|
throw new TypeError("read-only state cannot be created");
|
|
39989
40226
|
const ownsRoot = typeof projectRoot === "string";
|
|
39990
40227
|
const root = ownsRoot ? await openPrivateProjectRoot(projectRoot) : requirePrivateProjectRoot(projectRoot);
|
|
@@ -40012,15 +40249,15 @@ async function openStateOwner(projectRoot, create, access5 = "read-write") {
|
|
|
40012
40249
|
const databaseExists = await pathExists2(databasePath);
|
|
40013
40250
|
const databaseInformation = await ensureDatabaseFile(databasePath, directory, directoryInformation.dev, create && !databaseExists);
|
|
40014
40251
|
await validateSidecars(directory, databaseInformation.dev);
|
|
40015
|
-
const visibleStatePath =
|
|
40016
|
-
const visibleDatabasePath =
|
|
40252
|
+
const visibleStatePath = join22(await sqliteVisibleRoot(root), STATE_DIRECTORY);
|
|
40253
|
+
const visibleDatabasePath = join22(visibleStatePath, DATABASE_NAME);
|
|
40017
40254
|
await verifyVisibleHierarchy(root, visibleStatePath, directoryInformation, visibleDatabasePath, databaseInformation);
|
|
40018
40255
|
const sqlite = loadSqlite();
|
|
40019
|
-
const flags = sqliteFlag(sqlite,
|
|
40256
|
+
const flags = sqliteFlag(sqlite, access6 === "read-only" ? "SQLITE_OPEN_READONLY" : "SQLITE_OPEN_READWRITE") | sqliteFlag(sqlite, "SQLITE_OPEN_NOFOLLOW");
|
|
40020
40257
|
database = sqlite.Database.open(visibleDatabasePath, flags);
|
|
40021
40258
|
await verifyVisibleHierarchy(root, visibleStatePath, directoryInformation, visibleDatabasePath, databaseInformation);
|
|
40022
40259
|
configureConnection(database);
|
|
40023
|
-
if (
|
|
40260
|
+
if (access6 === "read-only") {
|
|
40024
40261
|
database.exec("PRAGMA query_only=ON; BEGIN");
|
|
40025
40262
|
if (pragmaInteger(database, "user_version") !== SCHEMA_VERSION || pragmaInteger(database, "application_id") !== APPLICATION_ID) {
|
|
40026
40263
|
invalid("ADMISSION_SCHEMA_VERSION", "private admission database has an unsupported format identity");
|
|
@@ -40132,7 +40369,7 @@ async function openCheckedDirectory(path2, projectDevice) {
|
|
|
40132
40369
|
throw error;
|
|
40133
40370
|
}
|
|
40134
40371
|
requireStateDirectory(observed, projectDevice);
|
|
40135
|
-
const handle = await openPrivateFile(path2,
|
|
40372
|
+
const handle = await openPrivateFile(path2, constants26.O_RDONLY | constants26.O_DIRECTORY | constants26.O_NOFOLLOW | constants26.O_NONBLOCK);
|
|
40136
40373
|
try {
|
|
40137
40374
|
const information = await handle.stat({ bigint: true });
|
|
40138
40375
|
requireStateDirectory(information, projectDevice);
|
|
@@ -40162,7 +40399,7 @@ async function ensureDatabaseFile(path2, directory, expectedDevice, create, data
|
|
|
40162
40399
|
if (create) {
|
|
40163
40400
|
let handle2;
|
|
40164
40401
|
try {
|
|
40165
|
-
handle2 = await openPrivateFile(path2,
|
|
40402
|
+
handle2 = await openPrivateFile(path2, constants26.O_RDWR | constants26.O_CREAT | constants26.O_EXCL | constants26.O_NOFOLLOW, 384);
|
|
40166
40403
|
await handle2.sync();
|
|
40167
40404
|
await handle2.close();
|
|
40168
40405
|
handle2 = undefined;
|
|
@@ -40184,7 +40421,7 @@ async function ensureDatabaseFile(path2, directory, expectedDevice, create, data
|
|
|
40184
40421
|
throw error;
|
|
40185
40422
|
}
|
|
40186
40423
|
requireDatabaseFile(observed, expectedDevice);
|
|
40187
|
-
const handle = await openPrivateFile(path2,
|
|
40424
|
+
const handle = await openPrivateFile(path2, constants26.O_RDONLY | constants26.O_NOFOLLOW | constants26.O_NONBLOCK);
|
|
40188
40425
|
try {
|
|
40189
40426
|
const information = await handle.stat({ bigint: true });
|
|
40190
40427
|
requireDatabaseFile(information, expectedDevice);
|
|
@@ -40242,10 +40479,10 @@ function initializeOrVerifySchema(database, root) {
|
|
|
40242
40479
|
throw error;
|
|
40243
40480
|
}
|
|
40244
40481
|
try {
|
|
40245
|
-
const
|
|
40482
|
+
const version2 = pragmaInteger(database, "user_version");
|
|
40246
40483
|
const application = pragmaInteger(database, "application_id");
|
|
40247
40484
|
const existing = schemaRows(database);
|
|
40248
|
-
if (
|
|
40485
|
+
if (version2 === 0n && application === 0n && existing.length === 0) {
|
|
40249
40486
|
database.exec(CREATE_CANDIDATES);
|
|
40250
40487
|
database.exec(CREATE_CANDIDATE_HEAD);
|
|
40251
40488
|
database.exec(CREATE_REVIEW_PLANS);
|
|
@@ -40263,7 +40500,7 @@ function initializeOrVerifySchema(database, root) {
|
|
|
40263
40500
|
database.exec("INSERT INTO coordinator_head(singleton, epoch) VALUES (1, 0)");
|
|
40264
40501
|
database.exec(`PRAGMA application_id=${APPLICATION_ID}`);
|
|
40265
40502
|
database.exec(`PRAGMA user_version=${SCHEMA_VERSION}`);
|
|
40266
|
-
} else if (
|
|
40503
|
+
} else if (version2 !== SCHEMA_VERSION || application !== APPLICATION_ID) {
|
|
40267
40504
|
invalid("ADMISSION_SCHEMA_VERSION", "private admission database has an unsupported format identity");
|
|
40268
40505
|
}
|
|
40269
40506
|
verifySchema(database, root);
|
|
@@ -40728,7 +40965,7 @@ async function observeVisibleLock(root) {
|
|
|
40728
40965
|
const path2 = privateChildLocation(root.handle, LOCK_NAME);
|
|
40729
40966
|
let handle;
|
|
40730
40967
|
try {
|
|
40731
|
-
handle = await openPrivateFile(path2,
|
|
40968
|
+
handle = await openPrivateFile(path2, constants26.O_RDONLY | constants26.O_NOFOLLOW | constants26.O_NONBLOCK);
|
|
40732
40969
|
} catch (error) {
|
|
40733
40970
|
if (hasCode3(error, "ENOENT"))
|
|
40734
40971
|
return Object.freeze({ state: "absent" });
|
|
@@ -40820,7 +41057,7 @@ async function synchronizeExactVisibleLock(owner, proposed) {
|
|
|
40820
41057
|
const path2 = privateChildLocation(owner.root.handle, LOCK_NAME);
|
|
40821
41058
|
let handle;
|
|
40822
41059
|
try {
|
|
40823
|
-
handle = await openPrivateFile(path2,
|
|
41060
|
+
handle = await openPrivateFile(path2, constants26.O_RDONLY | constants26.O_NOFOLLOW | constants26.O_NONBLOCK);
|
|
40824
41061
|
} catch (error) {
|
|
40825
41062
|
if (hasCode3(error, "ENOENT"))
|
|
40826
41063
|
stale("jig.lock disappeared before admission");
|
|
@@ -40851,7 +41088,7 @@ async function publishVisibleLock(owner, plan, proposed) {
|
|
|
40851
41088
|
await clearSafeLockStage(owner);
|
|
40852
41089
|
const stagePath = privateChildLocation(owner.directory, LOCK_STAGE_NAME);
|
|
40853
41090
|
const lockPath = privateChildLocation(owner.root.handle, LOCK_NAME);
|
|
40854
|
-
const handle = await openPrivateFile(stagePath,
|
|
41091
|
+
const handle = await openPrivateFile(stagePath, constants26.O_RDWR | constants26.O_CREAT | constants26.O_EXCL | constants26.O_NOFOLLOW | constants26.O_NONBLOCK, 384);
|
|
40855
41092
|
let failure;
|
|
40856
41093
|
try {
|
|
40857
41094
|
const opened = await handle.stat({ bigint: true });
|
|
@@ -41271,9 +41508,9 @@ function hasCode3(error, code2) {
|
|
|
41271
41508
|
|
|
41272
41509
|
// src/internal/contract-import.ts
|
|
41273
41510
|
import { randomBytes as randomBytes6 } from "crypto";
|
|
41274
|
-
import { constants as
|
|
41275
|
-
import { lstat as
|
|
41276
|
-
import { basename as
|
|
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";
|
|
41277
41514
|
init_file_input();
|
|
41278
41515
|
async function installedDescriptor(selector, destination) {
|
|
41279
41516
|
let name;
|
|
@@ -41282,17 +41519,17 @@ async function installedDescriptor(selector, destination) {
|
|
|
41282
41519
|
} catch {
|
|
41283
41520
|
invalid("CONTRACT_IMPORT_SOURCE", "Select an exact npm package name without a version or subpath.", selector);
|
|
41284
41521
|
}
|
|
41285
|
-
let directory =
|
|
41522
|
+
let directory = dirname15(resolve9(destination));
|
|
41286
41523
|
for (;; ) {
|
|
41287
41524
|
const packagePath = resolve9(directory, "node_modules", name);
|
|
41288
41525
|
try {
|
|
41289
|
-
await
|
|
41526
|
+
await lstat18(packagePath);
|
|
41290
41527
|
return resolve9(packagePath, "FLOW.contract.json");
|
|
41291
41528
|
} catch (error) {
|
|
41292
41529
|
if (error.code !== "ENOENT")
|
|
41293
41530
|
throw error;
|
|
41294
41531
|
}
|
|
41295
|
-
const parent =
|
|
41532
|
+
const parent = dirname15(directory);
|
|
41296
41533
|
if (parent === directory)
|
|
41297
41534
|
break;
|
|
41298
41535
|
directory = parent;
|
|
@@ -41308,8 +41545,8 @@ async function importContract(source, destination, signal) {
|
|
|
41308
41545
|
try {
|
|
41309
41546
|
signal?.throwIfAborted();
|
|
41310
41547
|
const selected = source.startsWith("npm:") ? await installedDescriptor(source, destination) : source;
|
|
41311
|
-
const name =
|
|
41312
|
-
root = await
|
|
41548
|
+
const name = basename4(selected);
|
|
41549
|
+
root = await open16(await realpath18(dirname15(resolve9(selected))), constants27.O_RDONLY | constants27.O_DIRECTORY | constants27.O_NOFOLLOW);
|
|
41313
41550
|
const capture = (paths3) => captureOpenedPackageDirectory(selected, root, {
|
|
41314
41551
|
includes: (path2) => paths3.some((p) => p === path2 || p.startsWith(`${path2}/`)),
|
|
41315
41552
|
maximumFiles: 65,
|
|
@@ -41332,12 +41569,12 @@ async function importContract(source, destination, signal) {
|
|
|
41332
41569
|
signal?.throwIfAborted();
|
|
41333
41570
|
phase = "destination";
|
|
41334
41571
|
const target = resolve9(destination);
|
|
41335
|
-
const leaf = privateFilePath(
|
|
41336
|
-
parent = await
|
|
41572
|
+
const leaf = privateFilePath(basename4(target));
|
|
41573
|
+
parent = await open16(await realpath18(dirname15(target)), constants27.O_RDONLY | constants27.O_DIRECTORY | constants27.O_NOFOLLOW);
|
|
41337
41574
|
const allocation = privateChildLocation(parent, `.jig-contract-${randomBytes6(16).toString("hex")}`);
|
|
41338
41575
|
await mkdirPrivateFile(allocation);
|
|
41339
41576
|
staged = allocation;
|
|
41340
|
-
const stage = await openPrivateFile(staged,
|
|
41577
|
+
const stage = await openPrivateFile(staged, constants27.O_RDONLY | constants27.O_DIRECTORY | constants27.O_NOFOLLOW);
|
|
41341
41578
|
try {
|
|
41342
41579
|
for (const path2 of paths2) {
|
|
41343
41580
|
signal?.throwIfAborted();
|
|
@@ -41380,10 +41617,10 @@ async function writeCaptured(root, path2, bytes) {
|
|
|
41380
41617
|
if (error.code !== "EEXIST")
|
|
41381
41618
|
throw error;
|
|
41382
41619
|
});
|
|
41383
|
-
parent = await openPrivateFile(directory,
|
|
41620
|
+
parent = await openPrivateFile(directory, constants27.O_RDONLY | constants27.O_DIRECTORY | constants27.O_NOFOLLOW);
|
|
41384
41621
|
handles2.push(parent);
|
|
41385
41622
|
}
|
|
41386
|
-
const file = await openPrivateFile(privateChildLocation(parent, parts.at(-1)),
|
|
41623
|
+
const file = await openPrivateFile(privateChildLocation(parent, parts.at(-1)), constants27.O_WRONLY | constants27.O_CREAT | constants27.O_EXCL | constants27.O_NOFOLLOW, 384);
|
|
41387
41624
|
try {
|
|
41388
41625
|
await file.writeFile(bytes);
|
|
41389
41626
|
} finally {
|
|
@@ -41399,7 +41636,7 @@ async function removeStage(location) {
|
|
|
41399
41636
|
const visit2 = async (current2, depth) => {
|
|
41400
41637
|
if (depth > 512)
|
|
41401
41638
|
throw new Error("contract staging cleanup exceeds its depth bound");
|
|
41402
|
-
const directory = await openPrivateFile(current2,
|
|
41639
|
+
const directory = await openPrivateFile(current2, constants27.O_RDONLY | constants27.O_DIRECTORY | constants27.O_NOFOLLOW);
|
|
41403
41640
|
try {
|
|
41404
41641
|
for await (const entry of privateDirectoryEntries(directory)) {
|
|
41405
41642
|
if (++entries > 65536)
|
|
@@ -41480,19 +41717,19 @@ var EVALUATOR_HINTS = Object.freeze({
|
|
|
41480
41717
|
});
|
|
41481
41718
|
|
|
41482
41719
|
// src/project-init.ts
|
|
41483
|
-
import { constants as
|
|
41720
|
+
import { constants as constants28 } from "fs";
|
|
41484
41721
|
import {
|
|
41485
|
-
lstat as
|
|
41722
|
+
lstat as lstat19,
|
|
41486
41723
|
mkdir as mkdir6,
|
|
41487
41724
|
mkdtemp as mkdtemp5,
|
|
41488
|
-
open as
|
|
41725
|
+
open as open17,
|
|
41489
41726
|
readFile as readFile6,
|
|
41490
41727
|
rm as rm2,
|
|
41491
41728
|
rmdir as rmdir6,
|
|
41492
41729
|
unlink as unlink3,
|
|
41493
41730
|
writeFile as writeFile2
|
|
41494
41731
|
} from "fs/promises";
|
|
41495
|
-
import { basename as
|
|
41732
|
+
import { basename as basename5, join as join23, resolve as resolve10 } from "path";
|
|
41496
41733
|
init_file_input();
|
|
41497
41734
|
var DEFAULT_FILE_SYSTEM = {
|
|
41498
41735
|
mkdir: mkdir6,
|
|
@@ -41501,7 +41738,7 @@ var DEFAULT_FILE_SYSTEM = {
|
|
|
41501
41738
|
writeFile: writeFile2
|
|
41502
41739
|
};
|
|
41503
41740
|
var GREETING_SDK_VERSION = "0.1.0-alpha.13";
|
|
41504
|
-
var AGENT_ACP_VERSION = "0.1.0-alpha.
|
|
41741
|
+
var AGENT_ACP_VERSION = "0.1.0-alpha.8";
|
|
41505
41742
|
|
|
41506
41743
|
class ProjectInitError extends Error {
|
|
41507
41744
|
code;
|
|
@@ -41521,12 +41758,12 @@ async function createFlow(project, name, uses = [], signal) {
|
|
|
41521
41758
|
signal?.throwIfAborted();
|
|
41522
41759
|
let sdk = GREETING_SDK_VERSION;
|
|
41523
41760
|
try {
|
|
41524
|
-
const definition = await
|
|
41761
|
+
const definition = await lstat19(join23(project, "jig.ts"));
|
|
41525
41762
|
if (!definition.isFile() || definition.isSymbolicLink())
|
|
41526
41763
|
throw new Error("not a regular project definition");
|
|
41527
41764
|
try {
|
|
41528
|
-
const path2 =
|
|
41529
|
-
const info = await
|
|
41765
|
+
const path2 = join23(project, "package.json");
|
|
41766
|
+
const info = await lstat19(path2);
|
|
41530
41767
|
if (!info.isFile() || info.size > 262144)
|
|
41531
41768
|
throw new Error("unsafe manifest");
|
|
41532
41769
|
const manifest = JSON.parse(await readFile6(path2, "utf8"));
|
|
@@ -41543,8 +41780,8 @@ async function createFlow(project, name, uses = [], signal) {
|
|
|
41543
41780
|
} catch {
|
|
41544
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.");
|
|
41545
41782
|
}
|
|
41546
|
-
const flows =
|
|
41547
|
-
const destination =
|
|
41783
|
+
const flows = join23(project, "flows");
|
|
41784
|
+
const destination = join23(flows, name);
|
|
41548
41785
|
const created = [];
|
|
41549
41786
|
let staged;
|
|
41550
41787
|
let createdFlows = false, createdDestination = false;
|
|
@@ -41555,7 +41792,7 @@ async function createFlow(project, name, uses = [], signal) {
|
|
|
41555
41792
|
} catch (error) {
|
|
41556
41793
|
if (errorCode(error) !== "EEXIST")
|
|
41557
41794
|
throw error;
|
|
41558
|
-
if (!(await
|
|
41795
|
+
if (!(await lstat19(flows)).isDirectory())
|
|
41559
41796
|
throw new Error("flows must be a directory, not a link");
|
|
41560
41797
|
}
|
|
41561
41798
|
try {
|
|
@@ -41564,27 +41801,27 @@ async function createFlow(project, name, uses = [], signal) {
|
|
|
41564
41801
|
createdDestination = true;
|
|
41565
41802
|
} else {
|
|
41566
41803
|
try {
|
|
41567
|
-
await
|
|
41804
|
+
await lstat19(destination);
|
|
41568
41805
|
throw Object.assign(new Error("exists"), { code: "EEXIST" });
|
|
41569
41806
|
} catch (error) {
|
|
41570
41807
|
if (errorCode(error) !== "ENOENT")
|
|
41571
41808
|
throw error;
|
|
41572
41809
|
}
|
|
41573
|
-
staged = await mkdtemp5(
|
|
41810
|
+
staged = await mkdtemp5(join23(project, ".jig-new-"));
|
|
41574
41811
|
}
|
|
41575
41812
|
} catch (error) {
|
|
41576
41813
|
if (errorCode(error) === "EEXIST")
|
|
41577
41814
|
throw new ProjectInitError("invalid", "JIG_NEW_EXISTS", "That Flow directory already exists. Choose a different name; existing files were not changed.");
|
|
41578
41815
|
throw error;
|
|
41579
41816
|
}
|
|
41580
|
-
const projectName =
|
|
41817
|
+
const projectName = basename5(resolve10(project)).toLowerCase().replace(/[^a-z0-9-]/g, "-").slice(0, 64);
|
|
41581
41818
|
const authoredAt = staged ?? destination;
|
|
41582
41819
|
const declarations = Object.create(null);
|
|
41583
41820
|
if (uses.length > 0)
|
|
41584
|
-
await mkdir6(
|
|
41821
|
+
await mkdir6(join23(authoredAt, "contracts"));
|
|
41585
41822
|
for (const { slot, source } of uses) {
|
|
41586
|
-
const imported = await importContract(source.startsWith("npm:") ? source : resolve10(project, source),
|
|
41587
|
-
declarations[slot] = { contract: `./contracts/${slot}/${
|
|
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)}` };
|
|
41588
41825
|
}
|
|
41589
41826
|
const files = {
|
|
41590
41827
|
"FLOW.meta.json": `${JSON.stringify({ name, description: "Describe what this method does.", ...uses.length === 0 ? {} : { uses: declarations } }, null, 2)}
|
|
@@ -41600,18 +41837,18 @@ await handle(async (run) => {
|
|
|
41600
41837
|
};
|
|
41601
41838
|
for (const [file, content] of Object.entries(files)) {
|
|
41602
41839
|
signal?.throwIfAborted();
|
|
41603
|
-
const path2 =
|
|
41840
|
+
const path2 = join23(authoredAt, file);
|
|
41604
41841
|
await writeFile2(path2, content, { flag: "wx" });
|
|
41605
41842
|
if (staged === undefined)
|
|
41606
41843
|
created.push(path2);
|
|
41607
41844
|
}
|
|
41608
41845
|
if (staged !== undefined) {
|
|
41609
|
-
const projectDirectory = await
|
|
41846
|
+
const projectDirectory = await open17(project, constants28.O_RDONLY | constants28.O_DIRECTORY | constants28.O_NOFOLLOW);
|
|
41610
41847
|
try {
|
|
41611
|
-
const flowsDirectory = await openPrivateChild(projectDirectory, "flows",
|
|
41848
|
+
const flowsDirectory = await openPrivateChild(projectDirectory, "flows", constants28.O_RDONLY | constants28.O_DIRECTORY | constants28.O_NOFOLLOW);
|
|
41612
41849
|
try {
|
|
41613
41850
|
signal?.throwIfAborted();
|
|
41614
|
-
privatePublishDirectory(flowsDirectory.fd,
|
|
41851
|
+
privatePublishDirectory(flowsDirectory.fd, basename5(staged), name, projectDirectory.fd);
|
|
41615
41852
|
staged = undefined;
|
|
41616
41853
|
} finally {
|
|
41617
41854
|
await flowsDirectory.close();
|
|
@@ -41655,12 +41892,12 @@ async function createProject(destination, fileSystem = DEFAULT_FILE_SYSTEM, bare
|
|
|
41655
41892
|
}
|
|
41656
41893
|
created.push({ kind: "directory", path: target });
|
|
41657
41894
|
for (const name of ["flows", "bindings"]) {
|
|
41658
|
-
const path2 =
|
|
41895
|
+
const path2 = join23(target, name);
|
|
41659
41896
|
await fileSystem.mkdir(path2);
|
|
41660
41897
|
created.push({ kind: "directory", path: path2 });
|
|
41661
41898
|
}
|
|
41662
41899
|
if (!bare) {
|
|
41663
|
-
const path2 =
|
|
41900
|
+
const path2 = join23(target, "flows", "hello");
|
|
41664
41901
|
await fileSystem.mkdir(path2);
|
|
41665
41902
|
created.push({ kind: "directory", path: path2 });
|
|
41666
41903
|
}
|
|
@@ -41672,7 +41909,7 @@ async function createProject(destination, fileSystem = DEFAULT_FILE_SYSTEM, bare
|
|
|
41672
41909
|
...agent === undefined ? [] : agentFiles(agent)
|
|
41673
41910
|
];
|
|
41674
41911
|
for (const [name, contents] of files) {
|
|
41675
|
-
const path2 =
|
|
41912
|
+
const path2 = join23(target, name);
|
|
41676
41913
|
await fileSystem.writeFile(path2, contents, {
|
|
41677
41914
|
encoding: "utf8",
|
|
41678
41915
|
flag: "wx"
|
|
@@ -42107,10 +42344,10 @@ async function executeCompletion(arguments_, runtime) {
|
|
|
42107
42344
|
return 1;
|
|
42108
42345
|
}
|
|
42109
42346
|
}
|
|
42110
|
-
const
|
|
42111
|
-
if (
|
|
42347
|
+
const script2 = arguments_.length === 2 ? completionScript(arguments_[1]) : undefined;
|
|
42348
|
+
if (script2 === undefined)
|
|
42112
42349
|
usage("completion", "Choose bash, zsh, or fish.");
|
|
42113
|
-
await runtime.writeRecord(
|
|
42350
|
+
await runtime.writeRecord(script2);
|
|
42114
42351
|
return 0;
|
|
42115
42352
|
}
|
|
42116
42353
|
async function executeNew(arguments_, runtime) {
|
|
@@ -42194,7 +42431,7 @@ async function executeImportContract(arguments_, runtime) {
|
|
|
42194
42431
|
try {
|
|
42195
42432
|
const result2 = await importContract(arguments_[1].startsWith("npm:") ? arguments_[1] : resolve11(runtime.currentDirectory, arguments_[1]), resolve11(runtime.currentDirectory, arguments_[2]), runtime.signal);
|
|
42196
42433
|
runtime.writeOutput(`Imported ${result2.files} contract files into ${asciiJsonString(arguments_[2])}.
|
|
42197
|
-
Use ${asciiJsonString(
|
|
42434
|
+
Use ${asciiJsonString(basename6(result2.descriptor))} in the caller's slot declaration, then review the project.
|
|
42198
42435
|
`);
|
|
42199
42436
|
return 0;
|
|
42200
42437
|
} catch (error) {
|
|
@@ -42350,7 +42587,7 @@ function shellWord(value) {
|
|
|
42350
42587
|
async function executeReview(arguments_, runtime) {
|
|
42351
42588
|
let resolutionNoticeShown = false;
|
|
42352
42589
|
const parsed = parseReview(arguments_, runtime.currentDirectory);
|
|
42353
|
-
runtime.progress.note(`Reviewing ${asciiJsonString(
|
|
42590
|
+
runtime.progress.note(`Reviewing ${asciiJsonString(basename6(resolve11(runtime.currentDirectory, parsed.project)))}`);
|
|
42354
42591
|
const result2 = await withProjectSession(parsed.project, runtime, async (session) => {
|
|
42355
42592
|
const plan = await privateProfileSpan("project-planning", () => session.plan({ lockMode: "update" }));
|
|
42356
42593
|
runtime.progress.complete(true);
|
|
@@ -42518,7 +42755,7 @@ Check --input and the file contents. No Flow was started.`, 1);
|
|
|
42518
42755
|
const files = new PrivateRootRunFiles(capture.attachments, parsed.output === undefined ? null : resolve11(runtime.currentDirectory, parsed.output), runtime.host.delivery);
|
|
42519
42756
|
try {
|
|
42520
42757
|
if (parsed.output !== undefined) {
|
|
42521
|
-
const occupied = await
|
|
42758
|
+
const occupied = await lstat20(files.identity.output).then(() => true, (error) => {
|
|
42522
42759
|
if (error.code === "ENOENT")
|
|
42523
42760
|
return false;
|
|
42524
42761
|
throw new CliDiagnostic("JIG_OUTPUT_INVALID", "cannot inspect --out; check its path and directory permissions. No Flow was started.", 1);
|
|
@@ -42892,6 +43129,11 @@ function renderFailure(error, runtime) {
|
|
|
42892
43129
|
PACKAGE_ENTRYPOINT_MISSING: "the selected package needs one exact-case FLOW.<suffix> entrypoint",
|
|
42893
43130
|
PACKAGE_METADATA_OWNER: "keep Markdown frontmatter in FLOW.md; use FLOW.meta.json only with a code entrypoint",
|
|
42894
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.",
|
|
42895
43137
|
PACKAGE_PROFILE_UNSUPPORTED: "use a runtime and single-invocation contract supported by this host",
|
|
42896
43138
|
PACKAGE_METADATA_UNSUPPORTED: "this host cannot honor the indicated metadata requirement; use a qualified host or revise that requirement explicitly",
|
|
42897
43139
|
PACKAGE_TOOLS_UNSUPPORTED: "the selected runtime cannot enforce this allowed-tools restriction",
|
|
@@ -42907,6 +43149,7 @@ function renderFailure(error, runtime) {
|
|
|
42907
43149
|
PROJECT_BINDING_ATTACHMENTS_INVALID: "check the Binding attachment directories: use stable project-relative regular-file trees without links, protected state or nested mounts, within the file limits",
|
|
42908
43150
|
PROJECT_BINDING_ATTACHMENT_UNDECLARED: "select only attachment names declared read-only in the Flow contract",
|
|
42909
43151
|
PROJECT_BINDING_ATTACHMENTS_NOT_CAPTURED: "the selected Binding files could not be retained consistently; review stable source directories again",
|
|
43152
|
+
PROJECT_CHECKPOINT_ATTACHMENT: "declare a read-write attachment in FLOW.contract.json for the root Flow that uses Run Checkpoint",
|
|
42910
43153
|
PROJECT_BINDING_PACKAGE_MISSING: "the Binding references a Flow not selected by jig.ts; correct the path or project membership",
|
|
42911
43154
|
PROJECT_ENTRYPOINT_INVALID: "Fix entrypoint in jig.ts: use an invokable Flow or Binding followed by valid jig run invocation arguments, project-relative paths, and declared unbound attachments or outgoing channels. Operator flags such as --verification are not project defaults.",
|
|
42912
43155
|
PROJECT_DEFAULT_MISSING: "defaultProviders in jig.ts names a missing Flow or Binding; create the selected local Binding and include its Flow in discovery, or correct the selector. Provider selection does not create Bindings",
|
|
@@ -42936,6 +43179,7 @@ function renderFailure(error, runtime) {
|
|
|
42936
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",
|
|
42937
43180
|
PACKAGE_BUN_RESOLVED_SOURCE_UNSUPPORTED: "resolved dependencies are unsupported; requests may already have occurred; use integrity-pinned default npm registry dependencies",
|
|
42938
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",
|
|
42939
43183
|
PACKAGE_BUN_MANIFEST_SHAPE: "package.json must contain an object",
|
|
42940
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",
|
|
42941
43185
|
PACKAGE_BUN_MANIFEST_DEPENDENCIES: "the indicated dependency section must be an object mapping package names to version requests",
|
|
@@ -43166,19 +43410,19 @@ class PrivateCliOutput {
|
|
|
43166
43410
|
import { spawn as spawn2 } from "child_process";
|
|
43167
43411
|
import { randomBytes as randomBytes9 } from "crypto";
|
|
43168
43412
|
import { closeSync as closeSync14, fstatSync as fstatSync13 } from "fs";
|
|
43169
|
-
import { open as
|
|
43413
|
+
import { open as open19 } from "fs/promises";
|
|
43170
43414
|
import { connect, createServer as createServer3 } from "net";
|
|
43171
|
-
import { dirname as
|
|
43415
|
+
import { dirname as dirname17, join as join25 } from "path";
|
|
43172
43416
|
|
|
43173
43417
|
// src/internal/file-delivery.ts
|
|
43174
43418
|
import { randomBytes as randomBytes8 } from "crypto";
|
|
43175
|
-
import { closeSync as closeSync13, constants as
|
|
43419
|
+
import { closeSync as closeSync13, constants as constants30, fstatSync as fstatSync11 } from "fs";
|
|
43176
43420
|
import { statfs as statfs3 } from "fs/promises";
|
|
43177
|
-
import { basename as
|
|
43421
|
+
import { basename as basename7, dirname as dirname16, resolve as resolve12 } from "path";
|
|
43178
43422
|
|
|
43179
43423
|
// src/internal/file-delivery-storage.ts
|
|
43180
|
-
import { constants as
|
|
43181
|
-
var DIRECTORY4 =
|
|
43424
|
+
import { constants as constants29 } from "fs";
|
|
43425
|
+
var DIRECTORY4 = constants29.O_RDONLY | constants29.O_DIRECTORY | constants29.O_NOFOLLOW;
|
|
43182
43426
|
async function writePrivateDeliveryFile(root, path2, bytes, check) {
|
|
43183
43427
|
const parts = path2.split("/");
|
|
43184
43428
|
const handles2 = [];
|
|
@@ -43196,7 +43440,7 @@ async function writePrivateDeliveryFile(root, path2, bytes, check) {
|
|
|
43196
43440
|
handles2.push(parent);
|
|
43197
43441
|
}
|
|
43198
43442
|
check();
|
|
43199
|
-
const file = await openPrivateFile(privateChildLocation(parent, parts.at(-1)),
|
|
43443
|
+
const file = await openPrivateFile(privateChildLocation(parent, parts.at(-1)), constants29.O_WRONLY | constants29.O_CREAT | constants29.O_EXCL | constants29.O_NOFOLLOW);
|
|
43200
43444
|
try {
|
|
43201
43445
|
await file.writeFile(bytes);
|
|
43202
43446
|
} finally {
|
|
@@ -43273,7 +43517,7 @@ class PrivateFileDeliveryOwner {
|
|
|
43273
43517
|
let parent;
|
|
43274
43518
|
try {
|
|
43275
43519
|
this.signal.throwIfAborted();
|
|
43276
|
-
const destination = resolve12(directory), parentPath =
|
|
43520
|
+
const destination = resolve12(directory), parentPath = dirname16(destination), leaf = privateFilePath(basename7(destination));
|
|
43277
43521
|
if (destination === parentPath || leaf.includes("/"))
|
|
43278
43522
|
throw new TypeError("output requires a new directory");
|
|
43279
43523
|
const selected = privateOpenFileRoot(parentPath);
|
|
@@ -43361,7 +43605,7 @@ class PrivateFileDeliveryOwner {
|
|
|
43361
43605
|
await this.onStaged?.();
|
|
43362
43606
|
checkTime();
|
|
43363
43607
|
let delivery;
|
|
43364
|
-
const stage = await openPrivateFile(location,
|
|
43608
|
+
const stage = await openPrivateFile(location, constants30.O_RDONLY | constants30.O_DIRECTORY | constants30.O_NOFOLLOW);
|
|
43365
43609
|
try {
|
|
43366
43610
|
const opened = await stage.stat({ bigint: true });
|
|
43367
43611
|
if (opened.ino !== info.ino || opened.dev !== info.dev)
|
|
@@ -43469,8 +43713,8 @@ init_file_input();
|
|
|
43469
43713
|
|
|
43470
43714
|
// src/internal/macos-file-command.ts
|
|
43471
43715
|
import { fstatSync as fstatSync12, lstatSync as lstatSync6 } from "fs";
|
|
43472
|
-
import { mkdtemp as mkdtemp6, open as
|
|
43473
|
-
import { join as
|
|
43716
|
+
import { mkdtemp as mkdtemp6, open as open18, rmdir as rmdir7 } from "fs/promises";
|
|
43717
|
+
import { join as join24 } from "path";
|
|
43474
43718
|
init_macos_descriptor_files();
|
|
43475
43719
|
init_macos_process_controls();
|
|
43476
43720
|
function requirePrivateMacosFilePeer(socket2, expected) {
|
|
@@ -43482,7 +43726,7 @@ function requirePrivateMacosFilePeer(socket2, expected) {
|
|
|
43482
43726
|
async function createPrivateMacosFileCommand() {
|
|
43483
43727
|
const peer = privateMacosCurrentProcessIdentity();
|
|
43484
43728
|
const directory = await mkdtemp6("/private/tmp/jig-file-owner-");
|
|
43485
|
-
const parent = await
|
|
43729
|
+
const parent = await open18(directory, "r");
|
|
43486
43730
|
const identity3 = await parent.stat({ bigint: true });
|
|
43487
43731
|
let roots;
|
|
43488
43732
|
let output;
|
|
@@ -43542,7 +43786,7 @@ async function createPrivateMacosFileCommand() {
|
|
|
43542
43786
|
return Object.freeze({
|
|
43543
43787
|
directory,
|
|
43544
43788
|
peer,
|
|
43545
|
-
socket:
|
|
43789
|
+
socket: join24(directory, "control"),
|
|
43546
43790
|
close,
|
|
43547
43791
|
controlReady() {
|
|
43548
43792
|
const info = controlIdentity();
|
|
@@ -43908,7 +44152,7 @@ async function privateConnectFileOwner() {
|
|
|
43908
44152
|
if (!Array.isArray(roots) || roots.length > 8)
|
|
43909
44153
|
throw new TypeError("invalid input roots");
|
|
43910
44154
|
const pending = request({ type: "prepare", destination: path2, rootCount: roots.length });
|
|
43911
|
-
const transfer = roots.length ? sendPrivateMacosDescriptors(
|
|
44155
|
+
const transfer = roots.length ? sendPrivateMacosDescriptors(join25(dirname17(selected.socket), "fd-roots"), selected.peer, roots, 5000, cancellation.signal) : Promise.resolve();
|
|
43912
44156
|
await Promise.all([pending, transfer]).catch((error) => {
|
|
43913
44157
|
socket2.destroy();
|
|
43914
44158
|
throw error;
|
|
@@ -43956,7 +44200,7 @@ async function privateConnectFileOwner() {
|
|
|
43956
44200
|
},
|
|
43957
44201
|
cancelled: signal?.aborted ?? false
|
|
43958
44202
|
});
|
|
43959
|
-
const transfer = selected.platform === "darwin" && transferred !== undefined ? sendPrivateMacosDescriptors(
|
|
44203
|
+
const transfer = selected.platform === "darwin" && transferred !== undefined ? sendPrivateMacosDescriptors(join25(dirname17(selected.socket), "fd-output"), selected.peer, [transferred.fd], 5000, cancellation.signal) : Promise.resolve();
|
|
43960
44204
|
const [reply] = await Promise.all([pending, transfer]).catch((error) => {
|
|
43961
44205
|
socket2.destroy();
|
|
43962
44206
|
throw error;
|
|
@@ -44054,7 +44298,7 @@ async function withLinuxDirectories(pid, descriptors, maximum, work) {
|
|
|
44054
44298
|
let result2;
|
|
44055
44299
|
try {
|
|
44056
44300
|
for (const fd of descriptors) {
|
|
44057
|
-
const directory = await
|
|
44301
|
+
const directory = await open19(`/proc/${pid}/fd/${fd}`, 65536);
|
|
44058
44302
|
directories.push(directory);
|
|
44059
44303
|
if (!(await directory.stat()).isDirectory())
|
|
44060
44304
|
throw new TypeError("file transfer requires directories");
|
|
@@ -44135,19 +44379,19 @@ async function openPrivateInstalledBunHost(location, environment = process.env,
|
|
|
44135
44379
|
init_linux_host_paths();
|
|
44136
44380
|
import { execFile as execFile2, spawn as spawn3 } from "child_process";
|
|
44137
44381
|
import { randomBytes as randomBytes10 } from "crypto";
|
|
44138
|
-
import { constants as
|
|
44382
|
+
import { constants as constants31, realpathSync as realpathSync6 } from "fs";
|
|
44139
44383
|
import {
|
|
44140
|
-
access as
|
|
44384
|
+
access as access6,
|
|
44141
44385
|
mkdir as mkdir7,
|
|
44142
44386
|
readFile as readFile7,
|
|
44143
44387
|
readdir as readdir3,
|
|
44144
44388
|
realpath as realpath19,
|
|
44145
|
-
stat as
|
|
44389
|
+
stat as stat2,
|
|
44146
44390
|
statfs as statfs4,
|
|
44147
44391
|
writeFile as writeFile3
|
|
44148
44392
|
} from "fs/promises";
|
|
44149
44393
|
import { createServer as createServer4, connect as connect2 } from "net";
|
|
44150
|
-
import { isAbsolute as
|
|
44394
|
+
import { isAbsolute as isAbsolute8, posix as posix12 } from "path";
|
|
44151
44395
|
var CGROUP_ROOT2 = "/sys/fs/cgroup";
|
|
44152
44396
|
var CGROUP2_SUPER_MAGIC3 = 0x6367_7270n;
|
|
44153
44397
|
var CHILD_NAME = "jig";
|
|
@@ -44198,7 +44442,7 @@ async function acquireOrReexecutePrivateRootlessLinux(input = {}) {
|
|
|
44198
44442
|
throw new Error("invalid transient scope identity");
|
|
44199
44443
|
const command = requireCommand(dependencies.currentCommand(input.commandArguments ?? process.argv.slice(2)));
|
|
44200
44444
|
const directory = dependencies.currentDirectory();
|
|
44201
|
-
if (!
|
|
44445
|
+
if (!isAbsolute8(directory) || directory.includes("\x00")) {
|
|
44202
44446
|
throw new Error("invalid current directory");
|
|
44203
44447
|
}
|
|
44204
44448
|
return await dependencies.reexecute(managerPath, unit, command, directory, environment, commandLifetimeMs, input.signal);
|
|
@@ -44226,10 +44470,10 @@ async function preparePrivateRootlessLinuxScope(unit, dependencies = scopeDepend
|
|
|
44226
44470
|
if (!information.isDirectory() || information.uid !== uid) {
|
|
44227
44471
|
throw new Error("the transient scope is not owned by the current user");
|
|
44228
44472
|
}
|
|
44229
|
-
await dependencies.requireAccess(scope,
|
|
44230
|
-
await dependencies.requireAccess(`${scope}/cgroup.procs`,
|
|
44231
|
-
await dependencies.requireAccess(`${scope}/cgroup.subtree_control`,
|
|
44232
|
-
await dependencies.requireAccess(`${scope}/cgroup.kill`,
|
|
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);
|
|
44233
44477
|
requireWords2(await dependencies.readText(`${scope}/cgroup.controllers`), REQUIRED_CONTROLLERS2);
|
|
44234
44478
|
if ((await dependencies.listDirectories(scope)).length !== 0) {
|
|
44235
44479
|
throw new Error("the transient scope already contains a child cgroup");
|
|
@@ -44285,7 +44529,7 @@ function requirePreparedObservation(observation, unit) {
|
|
|
44285
44529
|
}
|
|
44286
44530
|
}
|
|
44287
44531
|
function requireCommand(command) {
|
|
44288
|
-
if (command.length === 0 || !
|
|
44532
|
+
if (command.length === 0 || !isAbsolute8(command[0]) || command.some((value) => value.includes("\x00"))) {
|
|
44289
44533
|
throw new Error("the current command is invalid");
|
|
44290
44534
|
}
|
|
44291
44535
|
return Object.freeze([...command]);
|
|
@@ -44330,8 +44574,8 @@ async function resolveManager() {
|
|
|
44330
44574
|
for (const candidate of MANAGER_CANDIDATES) {
|
|
44331
44575
|
try {
|
|
44332
44576
|
const resolved = await realpath19(candidate);
|
|
44333
|
-
const information = await
|
|
44334
|
-
if (
|
|
44577
|
+
const information = await stat2(resolved);
|
|
44578
|
+
if (isAbsolute8(resolved) && information.isFile() && (information.mode & 73) !== 0 && (information.mode & 3072) === 0) {
|
|
44335
44579
|
return resolved;
|
|
44336
44580
|
}
|
|
44337
44581
|
} catch {}
|
|
@@ -44460,8 +44704,8 @@ async function resolveControl() {
|
|
|
44460
44704
|
for (const candidate of CONTROL_CANDIDATES) {
|
|
44461
44705
|
try {
|
|
44462
44706
|
const resolved = await realpath19(candidate);
|
|
44463
|
-
const information = await
|
|
44464
|
-
if (
|
|
44707
|
+
const information = await stat2(resolved);
|
|
44708
|
+
if (isAbsolute8(resolved) && information.isFile() && (information.mode & 73) !== 0 && (information.mode & 3072) === 0) {
|
|
44465
44709
|
return resolved;
|
|
44466
44710
|
}
|
|
44467
44711
|
} catch {}
|
|
@@ -44561,7 +44805,7 @@ async function requirePathAbsent(path2, timeoutMs) {
|
|
|
44561
44805
|
const deadline = Date.now() + timeoutMs;
|
|
44562
44806
|
for (;; ) {
|
|
44563
44807
|
try {
|
|
44564
|
-
await
|
|
44808
|
+
await stat2(path2);
|
|
44565
44809
|
} catch (error) {
|
|
44566
44810
|
if (error.code === "ENOENT")
|
|
44567
44811
|
return;
|
|
@@ -44773,10 +45017,10 @@ var scopeDependencies = Object.freeze({
|
|
|
44773
45017
|
pid: () => process.pid,
|
|
44774
45018
|
readText: (path2) => readFile7(path2, "utf8"),
|
|
44775
45019
|
listDirectories: async (path2) => (await readdir3(path2, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name),
|
|
44776
|
-
information: (path2) =>
|
|
45020
|
+
information: (path2) => stat2(path2),
|
|
44777
45021
|
filesystemType: async (path2) => (await statfs4(path2)).type,
|
|
44778
45022
|
resolve: (path2) => realpath19(path2),
|
|
44779
|
-
requireAccess: (path2, mode) =>
|
|
45023
|
+
requireAccess: (path2, mode) => access6(path2, mode),
|
|
44780
45024
|
makeDirectory: (path2) => mkdir7(path2, { mode: 493 }),
|
|
44781
45025
|
writeText: (path2, value) => writeFile3(path2, value)
|
|
44782
45026
|
});
|
|
@@ -44792,14 +45036,14 @@ var systemDependencies2 = Object.freeze({
|
|
|
44792
45036
|
reexecute: (managerPath, unit, command, directory, environment, commandLifetimeMs, signal) => reexecutePrivateRootlessLinuxCommand(managerPath, unit, command, directory, environment, STARTUP_TIMEOUT_MS, commandLifetimeMs, signal)
|
|
44793
45037
|
});
|
|
44794
45038
|
function currentCommand(arguments_) {
|
|
44795
|
-
if (process.argv[0] === process.execPath && process.argv[1]?.endsWith("/libexec/installed-cli.js") &&
|
|
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])) {
|
|
44796
45040
|
return [process.execPath, ...BUN_POLICY3, process.argv[1], ...arguments_];
|
|
44797
45041
|
}
|
|
44798
45042
|
throw new Error("the installed Jig command cannot be reexecuted exactly");
|
|
44799
45043
|
}
|
|
44800
45044
|
|
|
44801
45045
|
// src/internal/project-session-controller.ts
|
|
44802
|
-
import { constants as
|
|
45046
|
+
import { constants as constants35 } from "fs";
|
|
44803
45047
|
|
|
44804
45048
|
// src/internal/bun-native-lock-policy.ts
|
|
44805
45049
|
var MANIFEST_REASONS = {
|
|
@@ -44907,8 +45151,8 @@ function isExactRegistryResolution(value) {
|
|
|
44907
45151
|
if (separator < 1)
|
|
44908
45152
|
return false;
|
|
44909
45153
|
const name = value.slice(0, separator);
|
|
44910
|
-
const
|
|
44911
|
-
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(
|
|
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);
|
|
44912
45156
|
}
|
|
44913
45157
|
function isPackageName(value) {
|
|
44914
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);
|
|
@@ -44921,8 +45165,8 @@ function ordinaryRecord2(value) {
|
|
|
44921
45165
|
}
|
|
44922
45166
|
|
|
44923
45167
|
// src/internal/bun-native-preparation.ts
|
|
44924
|
-
import { lstat as
|
|
44925
|
-
import { join as
|
|
45168
|
+
import { lstat as lstat21, mkdir as mkdir8, realpath as realpath20 } from "fs/promises";
|
|
45169
|
+
import { join as join26 } from "path";
|
|
44926
45170
|
|
|
44927
45171
|
// src/internal/bun-native-preparation-protocol.ts
|
|
44928
45172
|
var MIB3 = 1024 * 1024;
|
|
@@ -45048,6 +45292,7 @@ var BUN_POLICY4 = Object.freeze(["--no-env-file", "--no-install", "--config=/dev
|
|
|
45048
45292
|
var WORKER_FAILURE_CODES = new Set([
|
|
45049
45293
|
"PACKAGE_BUN_INPUT_LIMIT",
|
|
45050
45294
|
"PACKAGE_BUN_LOCK_INVALID",
|
|
45295
|
+
"PACKAGE_BUN_LOCK_VERSION_UNSUPPORTED",
|
|
45051
45296
|
"PACKAGE_BUN_LOCK_STALE",
|
|
45052
45297
|
"PACKAGE_BUN_OUTPUT_LIMIT",
|
|
45053
45298
|
"PACKAGE_BUN_OUTPUT_UNSUPPORTED",
|
|
@@ -45183,7 +45428,7 @@ async function interact(component, sourceBytes, input) {
|
|
|
45183
45428
|
throw protocolFailure();
|
|
45184
45429
|
location = { path: value2.path, pointer: value2.pointer };
|
|
45185
45430
|
}
|
|
45186
|
-
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);
|
|
45187
45432
|
} else {
|
|
45188
45433
|
throw protocolFailure();
|
|
45189
45434
|
}
|
|
@@ -45301,13 +45546,13 @@ function normalizeCheckpoint(value) {
|
|
|
45301
45546
|
return Object.freeze({ allocation, owner, fence });
|
|
45302
45547
|
}
|
|
45303
45548
|
async function preparationOwnerParent(projectRoot) {
|
|
45304
|
-
const state = await realpath20(
|
|
45305
|
-
const parent =
|
|
45549
|
+
const state = await realpath20(join26(projectRoot, ".jig"));
|
|
45550
|
+
const parent = join26(state, "private-preparation-owners");
|
|
45306
45551
|
await mkdir8(parent, { mode: 448 }).catch((error) => {
|
|
45307
45552
|
if (!hasCode4(error, "EEXIST"))
|
|
45308
45553
|
throw error;
|
|
45309
45554
|
});
|
|
45310
|
-
const information = await
|
|
45555
|
+
const information = await lstat21(parent);
|
|
45311
45556
|
const uid = typeof process.getuid === "function" ? process.getuid() : -1;
|
|
45312
45557
|
if (!information.isDirectory() || information.isSymbolicLink() || information.uid !== uid || (information.mode & 63) !== 0 || await realpath20(parent) !== parent) {
|
|
45313
45558
|
throw new Error("private Bun preparation owner directory is not protected");
|
|
@@ -45668,8 +45913,9 @@ function failure(code2, message2) {
|
|
|
45668
45913
|
}
|
|
45669
45914
|
|
|
45670
45915
|
// src/internal/bun-workspace-capture.ts
|
|
45671
|
-
import { constants as
|
|
45672
|
-
import {
|
|
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";
|
|
45673
45919
|
var MANIFEST_BYTES = 1024 * 1024;
|
|
45674
45920
|
var MAX_MEMBERS4 = 256;
|
|
45675
45921
|
var MAX_ENTRIES2 = 32768;
|
|
@@ -45685,7 +45931,18 @@ async function capturePrivateBunWorkspace(input) {
|
|
|
45685
45931
|
if (!requiresWorkspace && Object.keys(dependencies).length === 0)
|
|
45686
45932
|
return;
|
|
45687
45933
|
const physical = resolve13(input.projectRoot.requestedPath, input.packagePath);
|
|
45688
|
-
|
|
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) {
|
|
45689
45946
|
input.signal.throwIfAborted();
|
|
45690
45947
|
const root = await openPrivateProjectRoot(path2);
|
|
45691
45948
|
try {
|
|
@@ -45714,8 +45971,6 @@ async function capturePrivateBunWorkspace(input) {
|
|
|
45714
45971
|
} finally {
|
|
45715
45972
|
await root.dispose();
|
|
45716
45973
|
}
|
|
45717
|
-
if (dirname17(path2) === path2)
|
|
45718
|
-
break;
|
|
45719
45974
|
}
|
|
45720
45975
|
if (requiresWorkspace)
|
|
45721
45976
|
fail("PACKAGE_BUN_WORKSPACE_MISSING", "workspace dependencies require membership in a declared ancestor workspace");
|
|
@@ -45903,9 +46158,9 @@ function runtimeDependencies(manifest) {
|
|
|
45903
46158
|
return value;
|
|
45904
46159
|
}));
|
|
45905
46160
|
}
|
|
45906
|
-
function workspaceVersionMatches(
|
|
46161
|
+
function workspaceVersionMatches(version2, request) {
|
|
45907
46162
|
const range = request.slice("workspace:".length);
|
|
45908
|
-
return ["*", "^", "~"].includes(range) || typeof
|
|
46163
|
+
return ["*", "^", "~"].includes(range) || typeof version2 === "string" && Bun.semver.satisfies(version2, range);
|
|
45909
46164
|
}
|
|
45910
46165
|
function parseManifest(bytes) {
|
|
45911
46166
|
try {
|
|
@@ -45978,7 +46233,7 @@ async function openBeneath(root, path2) {
|
|
|
45978
46233
|
let current2 = root;
|
|
45979
46234
|
try {
|
|
45980
46235
|
for (const part of path2.split("/")) {
|
|
45981
|
-
const next2 = await openPrivateChild(current2, part,
|
|
46236
|
+
const next2 = await openPrivateChild(current2, part, constants32.O_RDONLY | constants32.O_DIRECTORY | constants32.O_NOFOLLOW | constants32.O_NONBLOCK);
|
|
45982
46237
|
if (current2 !== root)
|
|
45983
46238
|
await current2.close();
|
|
45984
46239
|
current2 = next2;
|
|
@@ -45993,7 +46248,7 @@ async function openBeneath(root, path2) {
|
|
|
45993
46248
|
async function readOptional(directory, name, maximum = MANIFEST_BYTES) {
|
|
45994
46249
|
let handle;
|
|
45995
46250
|
try {
|
|
45996
|
-
handle = await openPrivateChild(directory, name,
|
|
46251
|
+
handle = await openPrivateChild(directory, name, constants32.O_RDONLY | constants32.O_NOFOLLOW | constants32.O_NONBLOCK);
|
|
45997
46252
|
} catch (error) {
|
|
45998
46253
|
if (error.code === "ENOENT")
|
|
45999
46254
|
return;
|
|
@@ -46070,7 +46325,7 @@ function fail(code2, message2) {
|
|
|
46070
46325
|
|
|
46071
46326
|
// src/internal/contract-generation.ts
|
|
46072
46327
|
import { createHash as createHash15, randomUUID as randomUUID4 } from "crypto";
|
|
46073
|
-
import { constants as
|
|
46328
|
+
import { constants as constants33 } from "fs";
|
|
46074
46329
|
|
|
46075
46330
|
// ../agent-method/dist/errors.js
|
|
46076
46331
|
class AgentMethodError extends Error {
|
|
@@ -46157,13 +46412,13 @@ function visitJson2(value, depth, state, memberName) {
|
|
|
46157
46412
|
}
|
|
46158
46413
|
return;
|
|
46159
46414
|
}
|
|
46160
|
-
const
|
|
46161
|
-
const prototype = Object.getPrototypeOf(
|
|
46415
|
+
const object9 = value;
|
|
46416
|
+
const prototype = Object.getPrototypeOf(object9);
|
|
46162
46417
|
if (prototype !== Object.prototype && prototype !== null) {
|
|
46163
46418
|
throw new Json1Error2("object must be an ordinary record");
|
|
46164
46419
|
}
|
|
46165
|
-
const keys = Object.keys(
|
|
46166
|
-
if (Reflect.ownKeys(
|
|
46420
|
+
const keys = Object.keys(object9);
|
|
46421
|
+
if (Reflect.ownKeys(object9).length !== keys.length) {
|
|
46167
46422
|
throw new Json1Error2("object members must be enumerable string data");
|
|
46168
46423
|
}
|
|
46169
46424
|
if (keys.length > JSON_1_LIMITS2.containerEntries) {
|
|
@@ -46173,7 +46428,7 @@ function visitJson2(value, depth, state, memberName) {
|
|
|
46173
46428
|
for (const key of keys) {
|
|
46174
46429
|
validateString2(key, JSON_1_LIMITS2.memberNameBytes);
|
|
46175
46430
|
chargeEncodedBytes2(state, encodedJsonStringBytes2(key));
|
|
46176
|
-
const field = Object.getOwnPropertyDescriptor(
|
|
46431
|
+
const field = Object.getOwnPropertyDescriptor(object9, key);
|
|
46177
46432
|
if (!("value" in field))
|
|
46178
46433
|
throw new Json1Error2("object members must be ordinary data");
|
|
46179
46434
|
visitJson2(field.value, depth + 1, state, false);
|
|
@@ -46219,8 +46474,8 @@ function canonicalText2(value) {
|
|
|
46219
46474
|
return Object.is(value, -0) ? "0" : JSON.stringify(value);
|
|
46220
46475
|
if (Array.isArray(value))
|
|
46221
46476
|
return `[${value.map(canonicalText2).join(",")}]`;
|
|
46222
|
-
const
|
|
46223
|
-
const members = Object.keys(
|
|
46477
|
+
const object9 = value;
|
|
46478
|
+
const members = Object.keys(object9).sort(compareUtf162).map((key) => `${JSON.stringify(key)}:${canonicalText2(object9[key])}`);
|
|
46224
46479
|
return `{${members.join(",")}}`;
|
|
46225
46480
|
}
|
|
46226
46481
|
function compareUtf162(left, right) {
|
|
@@ -46367,19 +46622,19 @@ var decoder11 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
|
|
|
46367
46622
|
|
|
46368
46623
|
// src/internal/contract-authoring-client.ts
|
|
46369
46624
|
import { spawn as spawn4 } from "child_process";
|
|
46370
|
-
import { lstat as
|
|
46371
|
-
import { isAbsolute as
|
|
46625
|
+
import { lstat as lstat23, realpath as realpath21 } from "fs/promises";
|
|
46626
|
+
import { isAbsolute as isAbsolute9 } from "path";
|
|
46372
46627
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
46373
46628
|
async function generateContract(source, signal, workerPath) {
|
|
46374
46629
|
signal.throwIfAborted();
|
|
46375
46630
|
const override = process.env.JIG_AUTHORING_NODE_PATH;
|
|
46376
|
-
if (override !== undefined && !
|
|
46631
|
+
if (override !== undefined && !isAbsolute9(override))
|
|
46377
46632
|
unavailable("AUTHORING_NODE", "Select an absolute Node executable.");
|
|
46378
46633
|
let node;
|
|
46379
46634
|
for (const path2 of override ? [override] : ["/usr/bin/node", "/usr/local/bin/node", "/run/current-system/sw/bin/node"]) {
|
|
46380
46635
|
try {
|
|
46381
46636
|
const resolved = await realpath21(path2);
|
|
46382
|
-
if ((await
|
|
46637
|
+
if ((await lstat23(resolved)).isFile()) {
|
|
46383
46638
|
node = resolved;
|
|
46384
46639
|
break;
|
|
46385
46640
|
}
|
|
@@ -46479,15 +46734,15 @@ async function readInput(root, path2) {
|
|
|
46479
46734
|
async function read(directory, name, limit2 = MAX_RECORD) {
|
|
46480
46735
|
let file;
|
|
46481
46736
|
try {
|
|
46482
|
-
file = await openPrivateFile(privateChildLocation(directory, name),
|
|
46737
|
+
file = await openPrivateFile(privateChildLocation(directory, name), constants33.O_RDONLY | constants33.O_NOFOLLOW | constants33.O_NONBLOCK);
|
|
46483
46738
|
} catch (error) {
|
|
46484
46739
|
if (error.code === "ENOENT")
|
|
46485
46740
|
return null;
|
|
46486
46741
|
return conflict(name);
|
|
46487
46742
|
}
|
|
46488
46743
|
try {
|
|
46489
|
-
const
|
|
46490
|
-
if (!
|
|
46744
|
+
const stat3 = await file.stat();
|
|
46745
|
+
if (!stat3.isFile() || stat3.nlink !== 1 || stat3.size > limit2)
|
|
46491
46746
|
conflict(name);
|
|
46492
46747
|
const bytes = await file.readFile();
|
|
46493
46748
|
if (bytes.length > limit2)
|
|
@@ -46504,7 +46759,7 @@ async function directory(parent, name, create) {
|
|
|
46504
46759
|
throw error;
|
|
46505
46760
|
});
|
|
46506
46761
|
try {
|
|
46507
|
-
return await openPrivateFile(privateChildLocation(parent, name),
|
|
46762
|
+
return await openPrivateFile(privateChildLocation(parent, name), constants33.O_RDONLY | constants33.O_DIRECTORY | constants33.O_NOFOLLOW);
|
|
46508
46763
|
} catch (error) {
|
|
46509
46764
|
if (error.code === "ENOENT")
|
|
46510
46765
|
return;
|
|
@@ -46513,7 +46768,7 @@ async function directory(parent, name, create) {
|
|
|
46513
46768
|
}
|
|
46514
46769
|
async function write(directory2, name, value) {
|
|
46515
46770
|
const temporary = `.write-${randomUUID4()}`;
|
|
46516
|
-
const file = await openPrivateFile(privateChildLocation(directory2, temporary),
|
|
46771
|
+
const file = await openPrivateFile(privateChildLocation(directory2, temporary), constants33.O_CREAT | constants33.O_EXCL | constants33.O_WRONLY | constants33.O_NOFOLLOW, 384);
|
|
46517
46772
|
try {
|
|
46518
46773
|
await file.writeFile(value);
|
|
46519
46774
|
await file.sync();
|
|
@@ -46757,7 +47012,7 @@ function prepareContractGeneration(options) {
|
|
|
46757
47012
|
// src/internal/dependency-flows.ts
|
|
46758
47013
|
import { posix as posix13 } from "path";
|
|
46759
47014
|
async function captureDependencyFlows(input) {
|
|
46760
|
-
const
|
|
47015
|
+
const metadata2 = await captureOpenedPackageDirectory("project dependency metadata", input.root.handle, {
|
|
46761
47016
|
includes: (path2) => ["package.json", "bun.lock", ".npmrc"].includes(path2),
|
|
46762
47017
|
maximumFiles: 3,
|
|
46763
47018
|
maximumBytes: 3 * 1024 * 1024
|
|
@@ -46766,7 +47021,7 @@ async function captureDependencyFlows(input) {
|
|
|
46766
47021
|
let prepared;
|
|
46767
47022
|
const members = [];
|
|
46768
47023
|
try {
|
|
46769
|
-
const manifest = await readManifest(
|
|
47024
|
+
const manifest = await readManifest(metadata2, "package.json");
|
|
46770
47025
|
const declarations = manifest.dependencies;
|
|
46771
47026
|
if (!declarations || typeof declarations !== "object" || Array.isArray(declarations))
|
|
46772
47027
|
invalid("PROJECT_DEPENDENCY_MISSING", "npm Flow targets require project package.json dependencies", "package.json");
|
|
@@ -46778,10 +47033,10 @@ async function captureDependencyFlows(input) {
|
|
|
46778
47033
|
workspace = await capturePrivateBunWorkspace({
|
|
46779
47034
|
projectRoot: input.root,
|
|
46780
47035
|
packagePath: "",
|
|
46781
|
-
captured:
|
|
47036
|
+
captured: metadata2,
|
|
46782
47037
|
signal: input.signal
|
|
46783
47038
|
});
|
|
46784
|
-
prepared = await input.prepare(workspace?.captured ??
|
|
47039
|
+
prepared = await input.prepare(workspace?.captured ?? metadata2, workspace);
|
|
46785
47040
|
for (const selector of input.selectors) {
|
|
46786
47041
|
input.signal.throwIfAborted();
|
|
46787
47042
|
const name = npmPackageName(selector);
|
|
@@ -46836,7 +47091,7 @@ async function captureDependencyFlows(input) {
|
|
|
46836
47091
|
try {
|
|
46837
47092
|
await workspace?.captured.dispose();
|
|
46838
47093
|
} finally {
|
|
46839
|
-
await
|
|
47094
|
+
await metadata2.dispose();
|
|
46840
47095
|
}
|
|
46841
47096
|
}
|
|
46842
47097
|
}
|
|
@@ -47684,8 +47939,8 @@ function isProjectIdentityLoss(error) {
|
|
|
47684
47939
|
}
|
|
47685
47940
|
|
|
47686
47941
|
// src/internal/root-run-controller.ts
|
|
47687
|
-
import { lstat as
|
|
47688
|
-
import { join as
|
|
47942
|
+
import { lstat as lstat26, mkdir as mkdir11, realpath as realpath24 } from "fs/promises";
|
|
47943
|
+
import { join as join31 } from "path";
|
|
47689
47944
|
|
|
47690
47945
|
// src/run/session.ts
|
|
47691
47946
|
import { createHash as createHash16 } from "crypto";
|
|
@@ -48498,56 +48753,56 @@ function validateLimits(limits) {
|
|
|
48498
48753
|
}
|
|
48499
48754
|
}
|
|
48500
48755
|
function parseEnvelope(value) {
|
|
48501
|
-
const
|
|
48502
|
-
if (
|
|
48756
|
+
const object9 = requireObject3(value, "JSON-RPC envelope");
|
|
48757
|
+
if (object9.jsonrpc !== "2.0")
|
|
48503
48758
|
throw new Error("invalid JSON-RPC version");
|
|
48504
|
-
const hasMethod = Object.hasOwn(
|
|
48505
|
-
const hasId = Object.hasOwn(
|
|
48506
|
-
const hasResult = Object.hasOwn(
|
|
48507
|
-
const hasError = Object.hasOwn(
|
|
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");
|
|
48508
48763
|
if (hasMethod) {
|
|
48509
|
-
if (typeof
|
|
48764
|
+
if (typeof object9.method !== "string")
|
|
48510
48765
|
throw new Error("method must be a string");
|
|
48511
|
-
const hasParams = Object.hasOwn(
|
|
48512
|
-
if (hasParams && (
|
|
48766
|
+
const hasParams = Object.hasOwn(object9, "params");
|
|
48767
|
+
if (hasParams && (object9.params === null || typeof object9.params !== "object")) {
|
|
48513
48768
|
throw new Error("JSON-RPC params must be a structured value");
|
|
48514
48769
|
}
|
|
48515
|
-
requireExactKeys(
|
|
48770
|
+
requireExactKeys(object9, hasId ? hasParams ? ["jsonrpc", "id", "method", "params"] : ["jsonrpc", "id", "method"] : hasParams ? ["jsonrpc", "method", "params"] : ["jsonrpc", "method"]);
|
|
48516
48771
|
if (hasId) {
|
|
48517
48772
|
return {
|
|
48518
48773
|
kind: "request",
|
|
48519
|
-
id: requireWireId2(
|
|
48520
|
-
method:
|
|
48521
|
-
...hasParams ? { params:
|
|
48774
|
+
id: requireWireId2(object9.id),
|
|
48775
|
+
method: object9.method,
|
|
48776
|
+
...hasParams ? { params: object9.params } : {}
|
|
48522
48777
|
};
|
|
48523
48778
|
}
|
|
48524
48779
|
return {
|
|
48525
48780
|
kind: "notification",
|
|
48526
|
-
method:
|
|
48527
|
-
...hasParams ? { params:
|
|
48781
|
+
method: object9.method,
|
|
48782
|
+
...hasParams ? { params: object9.params } : {}
|
|
48528
48783
|
};
|
|
48529
48784
|
}
|
|
48530
48785
|
if (!hasId || hasResult === hasError)
|
|
48531
48786
|
throw new Error("invalid response envelope");
|
|
48532
|
-
requireExactKeys(
|
|
48787
|
+
requireExactKeys(object9, hasResult ? ["jsonrpc", "id", "result"] : ["jsonrpc", "id", "error"]);
|
|
48533
48788
|
if (hasResult) {
|
|
48534
|
-
return { kind: "success", id: requireWireId2(
|
|
48789
|
+
return { kind: "success", id: requireWireId2(object9.id), result: object9.result };
|
|
48535
48790
|
}
|
|
48536
|
-
const id =
|
|
48537
|
-
return { kind: "error", id, error: parseErrorPayload(
|
|
48791
|
+
const id = object9.id === null ? null : requireWireId2(object9.id);
|
|
48792
|
+
return { kind: "error", id, error: parseErrorPayload(object9.error) };
|
|
48538
48793
|
}
|
|
48539
48794
|
function parseErrorPayload(value) {
|
|
48540
|
-
const
|
|
48541
|
-
requireExactKeys(
|
|
48542
|
-
if (!Number.isSafeInteger(
|
|
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))
|
|
48543
48798
|
throw new Error("invalid error code");
|
|
48544
|
-
if (typeof
|
|
48799
|
+
if (typeof object9.message !== "string" || scalarLength3(object9.message) < 1 || scalarLength3(object9.message) > 1024) {
|
|
48545
48800
|
throw new Error("invalid error message");
|
|
48546
48801
|
}
|
|
48547
48802
|
return {
|
|
48548
|
-
code:
|
|
48549
|
-
message:
|
|
48550
|
-
...Object.hasOwn(
|
|
48803
|
+
code: object9.code,
|
|
48804
|
+
message: object9.message,
|
|
48805
|
+
...Object.hasOwn(object9, "data") ? { data: object9.data } : {}
|
|
48551
48806
|
};
|
|
48552
48807
|
}
|
|
48553
48808
|
function parseRootFailure(error) {
|
|
@@ -48567,9 +48822,9 @@ function parseRootFailure(error) {
|
|
|
48567
48822
|
};
|
|
48568
48823
|
}
|
|
48569
48824
|
function parseRunResult(value) {
|
|
48570
|
-
const
|
|
48571
|
-
requireExactKeys(
|
|
48572
|
-
return { outcome: requireLocalName4(
|
|
48825
|
+
const object9 = requireObject3(value, "Run result");
|
|
48826
|
+
requireExactKeys(object9, ["outcome", "output"]);
|
|
48827
|
+
return { outcome: requireLocalName4(object9.outcome), output: object9.output };
|
|
48573
48828
|
}
|
|
48574
48829
|
function parseOperation2(request) {
|
|
48575
48830
|
const params = requireObject3(request.params, "flow/call params");
|
|
@@ -48596,11 +48851,11 @@ function parseOperation2(request) {
|
|
|
48596
48851
|
};
|
|
48597
48852
|
}
|
|
48598
48853
|
function parseChannelReferences(value) {
|
|
48599
|
-
const
|
|
48600
|
-
if (Object.keys(
|
|
48854
|
+
const object9 = requireObject3(value, "channel references");
|
|
48855
|
+
if (Object.keys(object9).length > 256)
|
|
48601
48856
|
throw new TypeError("too many channel references");
|
|
48602
48857
|
const references2 = Object.create(null);
|
|
48603
|
-
for (const [name, reference] of Object.entries(
|
|
48858
|
+
for (const [name, reference] of Object.entries(object9)) {
|
|
48604
48859
|
requireLocalName4(name);
|
|
48605
48860
|
if (typeof reference !== "string" || reference.length < 1 || reference.length > 256)
|
|
48606
48861
|
throw new TypeError("invalid channel reference");
|
|
@@ -48689,8 +48944,8 @@ function requireObject3(value, description) {
|
|
|
48689
48944
|
}
|
|
48690
48945
|
return value;
|
|
48691
48946
|
}
|
|
48692
|
-
function requireExactKeys(
|
|
48693
|
-
const actual = Object.keys(
|
|
48947
|
+
function requireExactKeys(object9, expected) {
|
|
48948
|
+
const actual = Object.keys(object9).sort();
|
|
48694
48949
|
const wanted = [...expected].sort();
|
|
48695
48950
|
if (actual.length !== wanted.length || actual.some((key, index) => key !== wanted[index])) {
|
|
48696
48951
|
throw new Error(`unexpected object members: ${actual.join(", ")}`);
|
|
@@ -48750,8 +49005,8 @@ function privateFlowExecutionIntent(recipe, packageRoot, runId, deadlineUnixMs,
|
|
|
48750
49005
|
}
|
|
48751
49006
|
|
|
48752
49007
|
// src/internal/package-materialization.ts
|
|
48753
|
-
import { constants as
|
|
48754
|
-
import { dirname as
|
|
49008
|
+
import { constants as constants34 } from "fs";
|
|
49009
|
+
import { dirname as dirname19, isAbsolute as isAbsolute10, join as join27, resolve as resolve14 } from "path";
|
|
48755
49010
|
import { types as utilTypes9 } from "util";
|
|
48756
49011
|
var ALLOCATION_KIND = "private-package-materialization-allocation/1";
|
|
48757
49012
|
var LEASE_KIND = "private-package-materialization-lease/1";
|
|
@@ -48761,7 +49016,7 @@ var DIGEST12 = /^sha256:[0-9a-f]{64}$/;
|
|
|
48761
49016
|
var LEAF = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
48762
49017
|
var UNSIGNED_642 = /^(?:0|[1-9][0-9]{0,19})$/;
|
|
48763
49018
|
var MAX_UNSIGNED_643 = (1n << 64n) - 1n;
|
|
48764
|
-
var DIRECTORY_FLAGS =
|
|
49019
|
+
var DIRECTORY_FLAGS = constants34.O_RDONLY | constants34.O_DIRECTORY | constants34.O_NOFOLLOW | constants34.O_NONBLOCK;
|
|
48765
49020
|
async function allocatePrivatePackageMaterialization(raw) {
|
|
48766
49021
|
const options = parseAllocationOptions(raw);
|
|
48767
49022
|
const parent = await openProtectedParent(options.protectedParent);
|
|
@@ -48772,7 +49027,7 @@ async function allocatePrivatePackageMaterialization(raw) {
|
|
|
48772
49027
|
kind: ALLOCATION_KIND,
|
|
48773
49028
|
parent: pathIdentity(parent.path, parent.information),
|
|
48774
49029
|
name: options.name,
|
|
48775
|
-
path:
|
|
49030
|
+
path: join27(parent.path, options.name),
|
|
48776
49031
|
packageDigest: options.packageDigest,
|
|
48777
49032
|
ownerToken: options.ownerToken,
|
|
48778
49033
|
...options.aliases === undefined ? {} : { aliases: options.aliases }
|
|
@@ -49035,7 +49290,7 @@ function leaseFromObserved(allocation, transaction, packageDirectory) {
|
|
|
49035
49290
|
kind: LEASE_KIND,
|
|
49036
49291
|
allocation,
|
|
49037
49292
|
transaction: pathIdentity(allocation.path, transaction),
|
|
49038
|
-
package: pathIdentity(
|
|
49293
|
+
package: pathIdentity(join27(allocation.path, PACKAGE_NAME), packageDirectory)
|
|
49039
49294
|
});
|
|
49040
49295
|
return durableLease(identity3);
|
|
49041
49296
|
}
|
|
@@ -49270,7 +49525,7 @@ async function packageModesMatch(packageDirectory, files, filesystem, aliases) {
|
|
|
49270
49525
|
const observed = await statPrivateFile(path2);
|
|
49271
49526
|
if (observed.isSymbolicLink() || !observed.isFile())
|
|
49272
49527
|
return false;
|
|
49273
|
-
const handle = await openPrivateFile(path2,
|
|
49528
|
+
const handle = await openPrivateFile(path2, constants34.O_RDONLY | constants34.O_NOFOLLOW | constants34.O_NONBLOCK);
|
|
49274
49529
|
try {
|
|
49275
49530
|
const information = await handle.stat({ bigint: true });
|
|
49276
49531
|
if (!sameIdentity9(observed, information) || !information.isFile() || information.nlink !== 1n || information.uid !== filesystem.uid || information.dev !== filesystem.dev || fileMode(information) !== 0o444n)
|
|
@@ -49359,7 +49614,7 @@ async function removeTree(root, filesystem, aliases = new Map, prefix = "") {
|
|
|
49359
49614
|
if (!observed.isFile()) {
|
|
49360
49615
|
throw new Error("refusing to remove a special file from a materialization allocation");
|
|
49361
49616
|
}
|
|
49362
|
-
const file = await openPrivateFile(path2,
|
|
49617
|
+
const file = await openPrivateFile(path2, constants34.O_RDONLY | constants34.O_NOFOLLOW | constants34.O_NONBLOCK);
|
|
49363
49618
|
let information;
|
|
49364
49619
|
try {
|
|
49365
49620
|
information = await file.stat({ bigint: true });
|
|
@@ -49436,7 +49691,7 @@ function parseAllocation(value) {
|
|
|
49436
49691
|
const path2 = normalizeAbsolutePath(root.path, "allocation path");
|
|
49437
49692
|
const packageDigest2 = parseDigest(root.packageDigest);
|
|
49438
49693
|
const ownerToken = normalizeOwnerToken(root.ownerToken);
|
|
49439
|
-
if (parent.path !== normalizeParent(parent.path) || path2 !==
|
|
49694
|
+
if (parent.path !== normalizeParent(parent.path) || path2 !== join27(parent.path, name)) {
|
|
49440
49695
|
throw new TypeError("materialization allocation paths are not canonical and correlated");
|
|
49441
49696
|
}
|
|
49442
49697
|
return freezeAllocation({
|
|
@@ -49460,7 +49715,7 @@ function parseLease(value) {
|
|
|
49460
49715
|
const allocation = parseAllocation(root.allocation);
|
|
49461
49716
|
const transaction = parsePathIdentity(root.transaction, "lease transaction");
|
|
49462
49717
|
const packageDirectory = parsePathIdentity(root.package, "lease package");
|
|
49463
|
-
if (transaction.path !== allocation.path || packageDirectory.path !==
|
|
49718
|
+
if (transaction.path !== allocation.path || packageDirectory.path !== join27(allocation.path, PACKAGE_NAME))
|
|
49464
49719
|
throw new TypeError("materialization lease paths do not match their allocation");
|
|
49465
49720
|
return freezeLease({
|
|
49466
49721
|
kind: LEASE_KIND,
|
|
@@ -49523,7 +49778,7 @@ function normalizeParent(value) {
|
|
|
49523
49778
|
return normalizeAbsolutePath(value, "protected materialization parent");
|
|
49524
49779
|
}
|
|
49525
49780
|
function normalizeAbsolutePath(value, label) {
|
|
49526
|
-
if (typeof value !== "string" || value.length === 0 || value.includes("\x00") || !
|
|
49781
|
+
if (typeof value !== "string" || value.length === 0 || value.includes("\x00") || !isAbsolute10(value) || resolve14(value) !== value || Buffer.byteLength(value, "utf8") > 4096)
|
|
49527
49782
|
throw new TypeError(`${label} must be a bounded canonical absolute path`);
|
|
49528
49783
|
return value;
|
|
49529
49784
|
}
|
|
@@ -49558,7 +49813,7 @@ function requireExpectedParent(value, expected) {
|
|
|
49558
49813
|
}
|
|
49559
49814
|
}
|
|
49560
49815
|
async function copyCapturedFile(captured, logicalPath, expectedBytes, destination, filesystem) {
|
|
49561
|
-
const handle = await openPrivateFile(destination,
|
|
49816
|
+
const handle = await openPrivateFile(destination, constants34.O_WRONLY | constants34.O_CREAT | constants34.O_EXCL | constants34.O_NOFOLLOW, 256);
|
|
49562
49817
|
let observedBytes = 0;
|
|
49563
49818
|
try {
|
|
49564
49819
|
if (filesystem !== undefined) {
|
|
@@ -49670,8 +49925,8 @@ function invalidResult(terminal, message2, details) {
|
|
|
49670
49925
|
init_input_capture();
|
|
49671
49926
|
|
|
49672
49927
|
// src/internal/invocation-context.ts
|
|
49673
|
-
import { lstat as
|
|
49674
|
-
import { join as
|
|
49928
|
+
import { lstat as lstat24, mkdir as mkdir9, realpath as realpath22 } from "fs/promises";
|
|
49929
|
+
import { join as join28 } from "path";
|
|
49675
49930
|
var DIGEST13 = /^sha256:[0-9a-f]{64}$/;
|
|
49676
49931
|
function requireParentTarget(input) {
|
|
49677
49932
|
const { parent } = input;
|
|
@@ -49733,13 +49988,13 @@ function normalizeParentFlow(value, parentOperationId, depth = 0) {
|
|
|
49733
49988
|
});
|
|
49734
49989
|
}
|
|
49735
49990
|
async function protectedOwnerRoot(projectRoot) {
|
|
49736
|
-
const state2 = await realpath22(
|
|
49737
|
-
const owners2 =
|
|
49991
|
+
const state2 = await realpath22(join28(projectRoot, ".jig"));
|
|
49992
|
+
const owners2 = join28(state2, "private-root-owners");
|
|
49738
49993
|
await mkdir9(owners2, { mode: 448 }).catch((error) => {
|
|
49739
49994
|
if (!hasCode6(error, "EEXIST"))
|
|
49740
49995
|
throw error;
|
|
49741
49996
|
});
|
|
49742
|
-
const information = await
|
|
49997
|
+
const information = await lstat24(owners2);
|
|
49743
49998
|
const uid = typeof process.getuid === "function" ? process.getuid() : -1;
|
|
49744
49999
|
if (!information.isDirectory() || information.isSymbolicLink() || information.uid !== uid || (information.mode & 63) !== 0 || await realpath22(owners2) !== owners2) {
|
|
49745
50000
|
throw new Error("execution owner directory is not protected");
|
|
@@ -50239,10 +50494,10 @@ class PrivateNativeHistoryUnavailable extends TypeError {
|
|
|
50239
50494
|
function parsePrivateNativeSessionRequest(input) {
|
|
50240
50495
|
if (input === null)
|
|
50241
50496
|
return;
|
|
50242
|
-
const outer =
|
|
50497
|
+
const outer = object9(input);
|
|
50243
50498
|
if (Object.keys(outer).join() !== "session")
|
|
50244
50499
|
invalid4();
|
|
50245
|
-
const session =
|
|
50500
|
+
const session = object9(outer.session);
|
|
50246
50501
|
if (session.retain === true && session.lifetime === "run" && Object.keys(session).length === 2)
|
|
50247
50502
|
return { retain: true, lifetime: "run" };
|
|
50248
50503
|
if (Object.keys(session).length !== 1)
|
|
@@ -50287,10 +50542,10 @@ function validatePrivateCodexSession(state2, secrets2 = []) {
|
|
|
50287
50542
|
invalid4();
|
|
50288
50543
|
throw error;
|
|
50289
50544
|
}
|
|
50290
|
-
const record3 =
|
|
50545
|
+
const record3 = object9(decoded);
|
|
50291
50546
|
if (Object.keys(record3).some((key) => !["timestamp", "ordinal", "type", "payload"].includes(key)) || typeof record3.timestamp !== "string" || record3.ordinal !== ordinal)
|
|
50292
50547
|
invalid4();
|
|
50293
|
-
const payload =
|
|
50548
|
+
const payload = object9(record3.payload);
|
|
50294
50549
|
if (ordinal === 0) {
|
|
50295
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) => ![
|
|
50296
50551
|
"session_id",
|
|
@@ -50322,7 +50577,7 @@ function validatePrivateCodexSession(state2, secrets2 = []) {
|
|
|
50322
50577
|
completions++;
|
|
50323
50578
|
complete = true;
|
|
50324
50579
|
} else if (payload.type === "item_completed") {
|
|
50325
|
-
const item2 =
|
|
50580
|
+
const item2 = object9(payload.item);
|
|
50326
50581
|
if (active === undefined || payload.turn_id !== active || payload.thread_id !== state2.nativeId || !["UserMessage", "AgentMessage", "Reasoning"].includes(String(item2.type)))
|
|
50327
50582
|
invalid4();
|
|
50328
50583
|
} else if (![
|
|
@@ -50338,11 +50593,11 @@ function validatePrivateCodexSession(state2, secrets2 = []) {
|
|
|
50338
50593
|
case "response_item":
|
|
50339
50594
|
if (!["message", "reasoning"].includes(String(payload.type)))
|
|
50340
50595
|
invalid4();
|
|
50341
|
-
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(
|
|
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)))))
|
|
50342
50597
|
invalid4();
|
|
50343
50598
|
break;
|
|
50344
50599
|
case "turn_context":
|
|
50345
|
-
if (active === undefined || payload.turn_id !== active || payload.cwd !== "/work" || !["never", "on-request"].includes(String(payload.approval_policy)) || !supportedSandboxPolicy(
|
|
50600
|
+
if (active === undefined || payload.turn_id !== active || payload.cwd !== "/work" || !["never", "on-request"].includes(String(payload.approval_policy)) || !supportedSandboxPolicy(object9(payload.sandbox_policy)))
|
|
50346
50601
|
invalid4();
|
|
50347
50602
|
break;
|
|
50348
50603
|
case "world_state":
|
|
@@ -50443,8 +50698,8 @@ function privateCodexSessionSecrets(runtime, startup) {
|
|
|
50443
50698
|
leaves(child2);
|
|
50444
50699
|
};
|
|
50445
50700
|
if (runtime.authentication) {
|
|
50446
|
-
const
|
|
50447
|
-
leaves(
|
|
50701
|
+
const metadata2 = runtime.authentication.request._meta;
|
|
50702
|
+
leaves(metadata2?.gateway?.headers);
|
|
50448
50703
|
}
|
|
50449
50704
|
if (startup?.byteLength)
|
|
50450
50705
|
leaves(JSON.parse(decoder12.decode(startup.subarray(4))).tokens);
|
|
@@ -50460,7 +50715,7 @@ function privateCodexSessionBootstrap(state2) {
|
|
|
50460
50715
|
header.writeUInt32BE(bytes.byteLength, 4);
|
|
50461
50716
|
return Buffer.concat([header, path2, bytes]);
|
|
50462
50717
|
}
|
|
50463
|
-
function
|
|
50718
|
+
function object9(value) {
|
|
50464
50719
|
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
50465
50720
|
return invalid4();
|
|
50466
50721
|
return value;
|
|
@@ -50532,12 +50787,12 @@ class PrivateFiniteAcpPolicy {
|
|
|
50532
50787
|
updates = 0;
|
|
50533
50788
|
textBytes = 0;
|
|
50534
50789
|
constructor(configuration = {}) {
|
|
50535
|
-
const policy =
|
|
50790
|
+
const policy = object10(snapshotPrivateOrdinaryJson(configuration, "finite ACP policy", invalid5));
|
|
50536
50791
|
keys(policy, [], ["configuration", "modeId", "maxTurns", "restoreSessionId"]);
|
|
50537
50792
|
if (Object.hasOwn(policy, "restoreSessionId"))
|
|
50538
50793
|
this.restoreSessionId = identifier(policy.restoreSessionId);
|
|
50539
|
-
const maxTurns = policy.maxTurns
|
|
50540
|
-
if (
|
|
50794
|
+
const maxTurns = Object.hasOwn(policy, "maxTurns") ? policy.maxTurns : PRIVATE_NATIVE_TURN_POLICY.default;
|
|
50795
|
+
if (!isPrivateNativeTurnAllowance(maxTurns))
|
|
50541
50796
|
fail2("Invalid ACP turn allowance");
|
|
50542
50797
|
this.maxTurns = maxTurns;
|
|
50543
50798
|
const options = Object.hasOwn(policy, "configuration") ? policy.configuration : [];
|
|
@@ -50545,7 +50800,7 @@ class PrivateFiniteAcpPolicy {
|
|
|
50545
50800
|
fail2("Invalid finite ACP configuration");
|
|
50546
50801
|
const ids = new Set;
|
|
50547
50802
|
for (const item2 of options) {
|
|
50548
|
-
const option =
|
|
50803
|
+
const option = object10(item2);
|
|
50549
50804
|
keys(option, ["configId", "value"], ["type"]);
|
|
50550
50805
|
const id = identifier(option.configId);
|
|
50551
50806
|
if (ids.has(id))
|
|
@@ -50569,7 +50824,7 @@ class PrivateFiniteAcpPolicy {
|
|
|
50569
50824
|
const frame = this.frame(bytes, "adapter");
|
|
50570
50825
|
keys(frame, ["jsonrpc", "method", "params"], ["id"]);
|
|
50571
50826
|
const method = frame.method;
|
|
50572
|
-
const params =
|
|
50827
|
+
const params = object10(frame.params);
|
|
50573
50828
|
if (method === CANCEL) {
|
|
50574
50829
|
keys(frame, ["jsonrpc", "method", "params"]);
|
|
50575
50830
|
this.ownedSession(params, []);
|
|
@@ -50593,9 +50848,9 @@ class PrivateFiniteAcpPolicy {
|
|
|
50593
50848
|
if (params.protocolVersion !== 1)
|
|
50594
50849
|
fail2("Unsupported ACP version");
|
|
50595
50850
|
if (params.clientCapabilities !== undefined)
|
|
50596
|
-
keys(
|
|
50851
|
+
keys(object10(params.clientCapabilities), []);
|
|
50597
50852
|
if (params.clientInfo !== undefined) {
|
|
50598
|
-
const info =
|
|
50853
|
+
const info = object10(params.clientInfo);
|
|
50599
50854
|
keys(info, ["name"], ["version", "title"]);
|
|
50600
50855
|
for (const value of Object.values(info))
|
|
50601
50856
|
identifier(value);
|
|
@@ -50636,7 +50891,7 @@ class PrivateFiniteAcpPolicy {
|
|
|
50636
50891
|
fail2("ACP prompt is not available");
|
|
50637
50892
|
if (!Array.isArray(params.prompt) || params.prompt.length !== 1)
|
|
50638
50893
|
fail2("ACP requires one text prompt");
|
|
50639
|
-
const content =
|
|
50894
|
+
const content = object10(params.prompt[0]);
|
|
50640
50895
|
keys(content, ["type", "text"]);
|
|
50641
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)
|
|
50642
50897
|
fail2("ACP prompt exceeds its authority or bounds");
|
|
@@ -50671,7 +50926,7 @@ class PrivateFiniteAcpPolicy {
|
|
|
50671
50926
|
if (pending === undefined || id !== pending.id || Object.hasOwn(frame, "result") === Object.hasOwn(frame, "error"))
|
|
50672
50927
|
fail2("ACP response has no matching request");
|
|
50673
50928
|
if (Object.hasOwn(frame, "error")) {
|
|
50674
|
-
const error =
|
|
50929
|
+
const error = object10(frame.error);
|
|
50675
50930
|
if (!Number.isSafeInteger(error.code) || typeof error.message !== "string")
|
|
50676
50931
|
fail2("Invalid ACP error response");
|
|
50677
50932
|
this.pending = undefined;
|
|
@@ -50680,7 +50935,7 @@ class PrivateFiniteAcpPolicy {
|
|
|
50680
50935
|
toAdapter: response(id, { code: error.code, message: "Native ACP request failed" }, true)
|
|
50681
50936
|
});
|
|
50682
50937
|
}
|
|
50683
|
-
const result2 =
|
|
50938
|
+
const result2 = object10(frame.result);
|
|
50684
50939
|
if (this.notice(result2._meta))
|
|
50685
50940
|
this.pendingNotice = true;
|
|
50686
50941
|
let projected;
|
|
@@ -50692,10 +50947,10 @@ class PrivateFiniteAcpPolicy {
|
|
|
50692
50947
|
const sessions = optionalObject(capabilities.sessionCapabilities);
|
|
50693
50948
|
this.canClose = sessions.close !== undefined && sessions.close !== null;
|
|
50694
50949
|
if (this.canClose)
|
|
50695
|
-
|
|
50950
|
+
object10(sessions.close);
|
|
50696
50951
|
this.canResume = sessions.resume !== undefined && sessions.resume !== null;
|
|
50697
50952
|
if (this.canResume)
|
|
50698
|
-
|
|
50953
|
+
object10(sessions.resume);
|
|
50699
50954
|
if (this.restoreSessionId !== undefined && !this.canResume)
|
|
50700
50955
|
fail2("ACP client does not support restoration");
|
|
50701
50956
|
this.initialized = true;
|
|
@@ -50722,8 +50977,8 @@ class PrivateFiniteAcpPolicy {
|
|
|
50722
50977
|
const required = this.configuration[this.configured];
|
|
50723
50978
|
if (!Array.isArray(result2.configOptions))
|
|
50724
50979
|
fail2("ACP configuration was not confirmed");
|
|
50725
|
-
const matches3 = result2.configOptions.filter((option2) =>
|
|
50726
|
-
if (matches3.length !== 1 ||
|
|
50980
|
+
const matches3 = result2.configOptions.filter((option2) => object10(option2).id === required.configId);
|
|
50981
|
+
if (matches3.length !== 1 || object10(matches3[0]).currentValue !== required.value)
|
|
50727
50982
|
fail2("ACP configuration was not confirmed");
|
|
50728
50983
|
const option = typeof required.value === "boolean" ? {
|
|
50729
50984
|
id: required.configId,
|
|
@@ -50781,7 +51036,7 @@ class PrivateFiniteAcpPolicy {
|
|
|
50781
51036
|
});
|
|
50782
51037
|
}
|
|
50783
51038
|
clientMessage(frame) {
|
|
50784
|
-
const params =
|
|
51039
|
+
const params = object10(frame.params);
|
|
50785
51040
|
if (frame.method === PERMISSION) {
|
|
50786
51041
|
keys(frame, ["jsonrpc", "method", "params", "id"]);
|
|
50787
51042
|
const id = requestId(frame.id);
|
|
@@ -50795,12 +51050,12 @@ class PrivateFiniteAcpPolicy {
|
|
|
50795
51050
|
fail2("ACP client operation is not permitted");
|
|
50796
51051
|
if (++this.updates > PRIVATE_FINITE_ACP_LIMITS.updates)
|
|
50797
51052
|
fail2("ACP update capacity exceeded");
|
|
50798
|
-
const update =
|
|
51053
|
+
const update = object10(params.update);
|
|
50799
51054
|
const notice = this.notice(update._meta);
|
|
50800
51055
|
if (this.sessionId === undefined && (this.pending?.method === NEW || this.pending?.method === RESUME)) {
|
|
50801
51056
|
keys(params, ["sessionId", "update"], ["_meta"]);
|
|
50802
51057
|
identifier(params.sessionId);
|
|
50803
|
-
|
|
51058
|
+
object10(params.update);
|
|
50804
51059
|
if (notice)
|
|
50805
51060
|
this.pendingNotice = true;
|
|
50806
51061
|
return Object.freeze({});
|
|
@@ -50817,7 +51072,7 @@ class PrivateFiniteAcpPolicy {
|
|
|
50817
51072
|
} else if (update.sessionUpdate === "agent_message_chunk") {
|
|
50818
51073
|
if (this.pending?.method !== PROMPT)
|
|
50819
51074
|
fail2("ACP text arrived outside an active turn");
|
|
50820
|
-
const content =
|
|
51075
|
+
const content = object10(update.content);
|
|
50821
51076
|
if (content.type !== "text")
|
|
50822
51077
|
return Object.freeze({});
|
|
50823
51078
|
if (typeof content.text !== "string")
|
|
@@ -50836,7 +51091,7 @@ class PrivateFiniteAcpPolicy {
|
|
|
50836
51091
|
if (!Array.isArray(update.entries))
|
|
50837
51092
|
fail2("Invalid ACP plan update");
|
|
50838
51093
|
const entries = update.entries.map((value) => {
|
|
50839
|
-
const entry =
|
|
51094
|
+
const entry = object10(value);
|
|
50840
51095
|
if (typeof entry.content !== "string" || !["high", "medium", "low"].includes(entry.priority) || !["pending", "in_progress", "completed"].includes(entry.status))
|
|
50841
51096
|
fail2("Invalid ACP plan entry");
|
|
50842
51097
|
return { content: entry.content, priority: entry.priority, status: entry.status };
|
|
@@ -50866,13 +51121,13 @@ class PrivateFiniteAcpPolicy {
|
|
|
50866
51121
|
}
|
|
50867
51122
|
};
|
|
50868
51123
|
}
|
|
50869
|
-
notice(
|
|
50870
|
-
const air = optionalObject(optionalObject(optionalObject(
|
|
51124
|
+
notice(metadata2) {
|
|
51125
|
+
const air = optionalObject(optionalObject(optionalObject(metadata2).jetbrains).air);
|
|
50871
51126
|
if (air.sessionFailure === undefined || air.sessionFailure === null)
|
|
50872
51127
|
return false;
|
|
50873
51128
|
if (air.version !== 1)
|
|
50874
51129
|
fail2("Unsupported native ACP diagnostic version");
|
|
50875
|
-
const notice =
|
|
51130
|
+
const notice = object10(air.sessionFailure);
|
|
50876
51131
|
if (notice.severity === "error")
|
|
50877
51132
|
throw new PrivateFiniteAcpPolicyError("Native ACP reported a session failure", "native-session");
|
|
50878
51133
|
if (notice.severity !== "warning")
|
|
@@ -50902,7 +51157,7 @@ class PrivateFiniteAcpPolicy {
|
|
|
50902
51157
|
} catch {
|
|
50903
51158
|
fail2("Invalid ACP JSON frame");
|
|
50904
51159
|
}
|
|
50905
|
-
const frame =
|
|
51160
|
+
const frame = object10(value);
|
|
50906
51161
|
if (frame.jsonrpc !== "2.0")
|
|
50907
51162
|
fail2("Invalid ACP protocol frame");
|
|
50908
51163
|
return freeze4(frame);
|
|
@@ -50944,13 +51199,13 @@ function requestId(value) {
|
|
|
50944
51199
|
return value;
|
|
50945
51200
|
return identifier(value);
|
|
50946
51201
|
}
|
|
50947
|
-
function
|
|
51202
|
+
function object10(value) {
|
|
50948
51203
|
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
50949
51204
|
fail2("Invalid ACP object");
|
|
50950
51205
|
return value;
|
|
50951
51206
|
}
|
|
50952
51207
|
function optionalObject(value) {
|
|
50953
|
-
return value === undefined || value === null ? {} :
|
|
51208
|
+
return value === undefined || value === null ? {} : object10(value);
|
|
50954
51209
|
}
|
|
50955
51210
|
function keys(value, required, optional = []) {
|
|
50956
51211
|
if (required.some((key) => !Object.hasOwn(value, key)) || Object.keys(value).some((key) => !required.includes(key) && !optional.includes(key)))
|
|
@@ -50965,7 +51220,7 @@ function fail2(message2) {
|
|
|
50965
51220
|
|
|
50966
51221
|
// src/internal/finite-acp-resource.ts
|
|
50967
51222
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
50968
|
-
import { join as
|
|
51223
|
+
import { join as join29 } from "path";
|
|
50969
51224
|
import { clearTimeout as clearTimeout2, setTimeout as setTimeout2 } from "timers";
|
|
50970
51225
|
|
|
50971
51226
|
// ../agent-acp/dist/transport.js
|
|
@@ -50987,7 +51242,7 @@ class FiniteAcpTransportError extends Error {
|
|
|
50987
51242
|
}
|
|
50988
51243
|
}
|
|
50989
51244
|
var encoder12 = new TextEncoder;
|
|
50990
|
-
function
|
|
51245
|
+
function object11(value) {
|
|
50991
51246
|
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
50992
51247
|
invalid6("Expected an object");
|
|
50993
51248
|
const prototype = Object.getPrototypeOf(value);
|
|
@@ -51035,7 +51290,7 @@ function identifier2(value) {
|
|
|
51035
51290
|
return value;
|
|
51036
51291
|
}
|
|
51037
51292
|
function readFiniteAcpReady(value) {
|
|
51038
|
-
const record3 =
|
|
51293
|
+
const record3 = object11(value);
|
|
51039
51294
|
exact6(record3, ["kind", "protocolVersion", "cwd", "maxTurns", "configuration"], ["modeId", "restoreSessionId"]);
|
|
51040
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)
|
|
51041
51296
|
invalid6("Invalid finite ACP ready record");
|
|
@@ -51048,7 +51303,7 @@ function readFiniteAcpReady(value) {
|
|
|
51048
51303
|
if (!descriptor || !Object.hasOwn(descriptor, "value") || !descriptor.enumerable)
|
|
51049
51304
|
invalid6("Configuration must be a dense data array");
|
|
51050
51305
|
const item2 = descriptor.value;
|
|
51051
|
-
const entry =
|
|
51306
|
+
const entry = object11(item2);
|
|
51052
51307
|
exact6(entry, ["configId", "value"], ["type"]);
|
|
51053
51308
|
const configId = identifier2(entry.configId);
|
|
51054
51309
|
if (names2.has(configId))
|
|
@@ -51113,7 +51368,7 @@ class FiniteAcpFrames {
|
|
|
51113
51368
|
}
|
|
51114
51369
|
accept(value) {
|
|
51115
51370
|
return this.guard(() => {
|
|
51116
|
-
const record3 =
|
|
51371
|
+
const record3 = object11(value);
|
|
51117
51372
|
exact6(record3, ["kind", "text", "end"]);
|
|
51118
51373
|
if (record3.kind !== "data" || typeof record3.end !== "boolean")
|
|
51119
51374
|
invalid6("Invalid finite ACP fragment");
|
|
@@ -51318,7 +51573,7 @@ var PRIVATE_FINITE_ACP_CHANNELS = Object.freeze({
|
|
|
51318
51573
|
contract: channel(responses_default)
|
|
51319
51574
|
})
|
|
51320
51575
|
});
|
|
51321
|
-
async function runPrivateFiniteAcpResource(component, runtime, endpoints, signal, maxTurns =
|
|
51576
|
+
async function runPrivateFiniteAcpResource(component, runtime, endpoints, signal, maxTurns = PRIVATE_NATIVE_TURN_POLICY.default, session) {
|
|
51322
51577
|
const local = new AbortController;
|
|
51323
51578
|
const enforcement = component.enforcement.then((receipt) => receipt);
|
|
51324
51579
|
const stopped = () => local.abort(signal.reason);
|
|
@@ -51371,10 +51626,10 @@ async function runPrivateFiniteAcpResource(component, runtime, endpoints, signal
|
|
|
51371
51626
|
};
|
|
51372
51627
|
const requests = async () => {
|
|
51373
51628
|
for (;; ) {
|
|
51374
|
-
const item2 =
|
|
51629
|
+
const item2 = object12(await endpoints.owner.next(endpoints.requests, local.signal));
|
|
51375
51630
|
if (Object.hasOwn(item2, "end"))
|
|
51376
51631
|
break;
|
|
51377
|
-
const text3 = frames.accept(
|
|
51632
|
+
const text3 = frames.accept(object12(item2.item).value);
|
|
51378
51633
|
if (text3 === undefined)
|
|
51379
51634
|
continue;
|
|
51380
51635
|
if (authenticationId !== undefined)
|
|
@@ -51418,7 +51673,7 @@ async function runPrivateFiniteAcpResource(component, runtime, endpoints, signal
|
|
|
51418
51673
|
...native5,
|
|
51419
51674
|
params: {
|
|
51420
51675
|
...native5.params,
|
|
51421
|
-
cwd:
|
|
51676
|
+
cwd: join29(component.owner.owner.allocation.directory, "data", "work")
|
|
51422
51677
|
}
|
|
51423
51678
|
};
|
|
51424
51679
|
}
|
|
@@ -51437,11 +51692,11 @@ async function runPrivateFiniteAcpResource(component, runtime, endpoints, signal
|
|
|
51437
51692
|
};
|
|
51438
51693
|
const responses = async () => {
|
|
51439
51694
|
for await (const bytes of nativeFrames(component.stdout)) {
|
|
51440
|
-
const raw =
|
|
51695
|
+
const raw = object12(decodeJson1(bytes));
|
|
51441
51696
|
if (authenticationId !== undefined && raw.id === authenticationId) {
|
|
51442
51697
|
if (raw.jsonrpc !== "2.0" || !Object.hasOwn(raw, "result") || Object.hasOwn(raw, "error") || Object.hasOwn(raw, "method"))
|
|
51443
51698
|
invalid7("Native ACP authentication failed");
|
|
51444
|
-
|
|
51699
|
+
object12(raw.result);
|
|
51445
51700
|
authenticationId = undefined;
|
|
51446
51701
|
const delivery2 = initialize;
|
|
51447
51702
|
initialize = undefined;
|
|
@@ -51449,8 +51704,8 @@ async function runPrivateFiniteAcpResource(component, runtime, endpoints, signal
|
|
|
51449
51704
|
continue;
|
|
51450
51705
|
}
|
|
51451
51706
|
if (runtime.authentication !== undefined && isInitializeReply(raw)) {
|
|
51452
|
-
const result2 =
|
|
51453
|
-
if (!Array.isArray(result2.authMethods) || !result2.authMethods.some((value) =>
|
|
51707
|
+
const result2 = object12(raw.result);
|
|
51708
|
+
if (!Array.isArray(result2.authMethods) || !result2.authMethods.some((value) => object12(value).id === runtime.authentication.request.methodId))
|
|
51454
51709
|
invalid7("Native ACP authentication is unavailable");
|
|
51455
51710
|
initialize = policy.fromClient(bytes).toAdapter;
|
|
51456
51711
|
authenticationId = `jig-auth-${randomUUID5()}`;
|
|
@@ -51483,7 +51738,7 @@ async function runPrivateFiniteAcpResource(component, runtime, endpoints, signal
|
|
|
51483
51738
|
function isInitializeReply(value) {
|
|
51484
51739
|
if (initializedReply || !Object.hasOwn(value, "result") || value.method !== undefined)
|
|
51485
51740
|
return false;
|
|
51486
|
-
const result2 =
|
|
51741
|
+
const result2 = object12(value.result);
|
|
51487
51742
|
if (result2.protocolVersion !== 1)
|
|
51488
51743
|
return false;
|
|
51489
51744
|
initializedReply = true;
|
|
@@ -51608,7 +51863,7 @@ async function within(pending, milliseconds, signal) {
|
|
|
51608
51863
|
removeAbort();
|
|
51609
51864
|
}
|
|
51610
51865
|
}
|
|
51611
|
-
function
|
|
51866
|
+
function object12(value) {
|
|
51612
51867
|
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
51613
51868
|
invalid7("Invalid native ACP frame");
|
|
51614
51869
|
return value;
|
|
@@ -51659,7 +51914,7 @@ async function executePrivateRootFiniteAcp(input) {
|
|
|
51659
51914
|
let participant;
|
|
51660
51915
|
try {
|
|
51661
51916
|
const terminal = await executeOwnedProvider(input, provider, recipe, {
|
|
51662
|
-
maxTurns: route.grant.maxTurns ??
|
|
51917
|
+
maxTurns: route.grant.maxTurns ?? PRIVATE_NATIVE_TURN_POLICY.default,
|
|
51663
51918
|
...session === undefined ? {} : { session },
|
|
51664
51919
|
digest: privateDomainDigest("JIG-Private-Finite-ACP-Request/1", {
|
|
51665
51920
|
providerDigest: provider.digest,
|
|
@@ -52226,8 +52481,8 @@ function failed2(code2, message2, details) {
|
|
|
52226
52481
|
}
|
|
52227
52482
|
|
|
52228
52483
|
// src/internal/root-flow-call-controller.ts
|
|
52229
|
-
import { lstat as
|
|
52230
|
-
import { join as
|
|
52484
|
+
import { lstat as lstat25, mkdir as mkdir10, realpath as realpath23 } from "fs/promises";
|
|
52485
|
+
import { join as join30 } from "path";
|
|
52231
52486
|
|
|
52232
52487
|
// src/internal/run-channels.ts
|
|
52233
52488
|
class PrivateRunChannels {
|
|
@@ -52961,9 +53216,9 @@ function childIdentity(parentRunId, operationId) {
|
|
|
52961
53216
|
}).slice("sha256:".length);
|
|
52962
53217
|
}
|
|
52963
53218
|
async function protectedWorkRoots(projectRoot) {
|
|
52964
|
-
const state2 = await realpath23(
|
|
52965
|
-
const materializations =
|
|
52966
|
-
const owners3 =
|
|
53219
|
+
const state2 = await realpath23(join30(projectRoot, ".jig"));
|
|
53220
|
+
const materializations = join30(state2, "private-root-materializations");
|
|
53221
|
+
const owners3 = join30(state2, "private-root-owners");
|
|
52967
53222
|
await Promise.all([ensureProtectedDirectory(materializations), ensureProtectedDirectory(owners3)]);
|
|
52968
53223
|
return Object.freeze({ materializations, owners: owners3 });
|
|
52969
53224
|
}
|
|
@@ -52972,7 +53227,7 @@ async function ensureProtectedDirectory(path2) {
|
|
|
52972
53227
|
if (!hasCode7(error, "EEXIST"))
|
|
52973
53228
|
throw error;
|
|
52974
53229
|
});
|
|
52975
|
-
const information = await
|
|
53230
|
+
const information = await lstat25(path2);
|
|
52976
53231
|
const uid = typeof process.getuid === "function" ? process.getuid() : -1;
|
|
52977
53232
|
if (!information.isDirectory() || information.isSymbolicLink() || information.uid !== uid || (information.mode & 63) !== 0 || await realpath23(path2) !== path2) {
|
|
52978
53233
|
throw new Error("child execution owner directory is not protected");
|
|
@@ -53549,9 +53804,9 @@ async function reacquire(input) {
|
|
|
53549
53804
|
});
|
|
53550
53805
|
}
|
|
53551
53806
|
async function protectedWorkRoots2(projectRoot) {
|
|
53552
|
-
const state2 = await realpath24(
|
|
53553
|
-
const materializations =
|
|
53554
|
-
const owners3 =
|
|
53807
|
+
const state2 = await realpath24(join31(projectRoot, ".jig"));
|
|
53808
|
+
const materializations = join31(state2, "private-root-materializations");
|
|
53809
|
+
const owners3 = join31(state2, "private-root-owners");
|
|
53555
53810
|
await Promise.all([ensureProtectedDirectory2(materializations), ensureProtectedDirectory2(owners3)]);
|
|
53556
53811
|
return Object.freeze({ materializations, owners: owners3 });
|
|
53557
53812
|
}
|
|
@@ -53560,7 +53815,7 @@ async function ensureProtectedDirectory2(path2) {
|
|
|
53560
53815
|
if (!hasCode8(error, "EEXIST"))
|
|
53561
53816
|
throw error;
|
|
53562
53817
|
});
|
|
53563
|
-
const information = await
|
|
53818
|
+
const information = await lstat26(path2);
|
|
53564
53819
|
const uid = typeof process.getuid === "function" ? process.getuid() : -1;
|
|
53565
53820
|
if (!information.isDirectory() || information.isSymbolicLink() || information.uid !== uid || (information.mode & 63) !== 0 || await realpath24(path2) !== path2) {
|
|
53566
53821
|
throw new Error("private root execution work directory is not protected");
|
|
@@ -54052,7 +54307,13 @@ function closedTestErrorCauses(error) {
|
|
|
54052
54307
|
return result2;
|
|
54053
54308
|
}
|
|
54054
54309
|
function closedNativeTestCause(error) {
|
|
54055
|
-
|
|
54310
|
+
let message2;
|
|
54311
|
+
try {
|
|
54312
|
+
message2 = error.message;
|
|
54313
|
+
} catch {
|
|
54314
|
+
return;
|
|
54315
|
+
}
|
|
54316
|
+
switch (message2) {
|
|
54056
54317
|
case "macOS control deadline expired":
|
|
54057
54318
|
return "MACOS_CONTROL_DEADLINE";
|
|
54058
54319
|
case "macOS guardian bootstrap failed":
|
|
@@ -54061,12 +54322,28 @@ function closedNativeTestCause(error) {
|
|
|
54061
54322
|
return "MACOS_GUARDIAN_CONNECTION_LOST";
|
|
54062
54323
|
case "macOS guardian job removal is unconfirmed":
|
|
54063
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";
|
|
54064
54341
|
case "macOS prepared ownership does not match":
|
|
54065
54342
|
return "MACOS_PREPARED_OWNER_MISMATCH";
|
|
54066
54343
|
case "native macOS Run was cancelled before admission":
|
|
54067
54344
|
return "MACOS_STARTUP_CANCELLED";
|
|
54068
54345
|
default:
|
|
54069
|
-
return
|
|
54346
|
+
return message2.startsWith("macOS guardian ended before readiness (") && message2.endsWith(")") ? "MACOS_GUARDIAN_BEFORE_READINESS" : undefined;
|
|
54070
54347
|
}
|
|
54071
54348
|
}
|
|
54072
54349
|
function createSession(owner, roots, packageStore, host, onOperationFailure) {
|
|
@@ -54447,7 +54724,7 @@ function createSession(owner, roots, packageStore, host, onOperationFailure) {
|
|
|
54447
54724
|
async function preparePackageStore(owner) {
|
|
54448
54725
|
await owner.verify();
|
|
54449
54726
|
const statePath = privateChildLocation(owner.root.handle, ".jig");
|
|
54450
|
-
const state2 = await openPrivateFile(statePath,
|
|
54727
|
+
const state2 = await openPrivateFile(statePath, constants35.O_RDONLY | constants35.O_DIRECTORY | constants35.O_NOFOLLOW | constants35.O_NONBLOCK);
|
|
54451
54728
|
try {
|
|
54452
54729
|
const storePath = privateChildLocation(state2, PRIVATE_PACKAGE_STORE_DIRECTORY);
|
|
54453
54730
|
try {
|
|
@@ -54459,7 +54736,7 @@ async function preparePackageStore(owner) {
|
|
|
54459
54736
|
await state2.sync();
|
|
54460
54737
|
const observed = await statPrivateFile(storePath);
|
|
54461
54738
|
requireProtectedStore(observed, owner.root.information.dev);
|
|
54462
|
-
const store = await openPrivateFile(storePath,
|
|
54739
|
+
const store = await openPrivateFile(storePath, constants35.O_RDONLY | constants35.O_DIRECTORY | constants35.O_NOFOLLOW | constants35.O_NONBLOCK);
|
|
54463
54740
|
try {
|
|
54464
54741
|
const actual = await store.stat({ bigint: true });
|
|
54465
54742
|
requireProtectedStore(actual, owner.root.information.dev);
|
|
@@ -54570,7 +54847,7 @@ function isUnavailableDiagnosticCode(code2) {
|
|
|
54570
54847
|
"AUTHORING_INTERRUPTED",
|
|
54571
54848
|
"AUTHORING_LIMIT",
|
|
54572
54849
|
"AUTHORING_STATE"
|
|
54573
|
-
].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";
|
|
54574
54851
|
}
|
|
54575
54852
|
function isCandidateDiagnosticCode(code2) {
|
|
54576
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_") || [
|
|
@@ -54596,7 +54873,8 @@ function isCandidateDiagnosticCode(code2) {
|
|
|
54596
54873
|
"PACKAGE_SPECIAL_FILE",
|
|
54597
54874
|
"PACKAGE_SYMLINK",
|
|
54598
54875
|
"PROJECT_FLOW_COLLISION",
|
|
54599
|
-
"PROJECT_FLOW_MODE_UNSUPPORTED"
|
|
54876
|
+
"PROJECT_FLOW_MODE_UNSUPPORTED",
|
|
54877
|
+
"PROJECT_CHECKPOINT_ATTACHMENT"
|
|
54600
54878
|
].includes(code2);
|
|
54601
54879
|
}
|
|
54602
54880
|
function isRootIdentityLoss(error, owner) {
|
|
@@ -54619,7 +54897,7 @@ var releaseRoot;
|
|
|
54619
54897
|
var executablePath;
|
|
54620
54898
|
try {
|
|
54621
54899
|
installedCliPath = await realpath25(fileURLToPath5(import.meta.url));
|
|
54622
|
-
releaseRoot =
|
|
54900
|
+
releaseRoot = dirname20(dirname20(installedCliPath));
|
|
54623
54901
|
executablePath = await realpath25(process.execPath);
|
|
54624
54902
|
const runningExecutablePath = process.platform === "linux" ? await realpath25("/proc/self/exe") : executablePath;
|
|
54625
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])) {
|