@oxagen/cli 2.1.4-926 → 2.1.4-942
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/oxagen.mjs +765 -525
- package/package.json +1 -1
package/oxagen.mjs
CHANGED
|
@@ -10358,14 +10358,14 @@ function psExecWithin(timeoutMs) {
|
|
|
10358
10358
|
return (command2, args) => psExec(command2, args, timeoutMs);
|
|
10359
10359
|
}
|
|
10360
10360
|
function psExecAsync(command2, args) {
|
|
10361
|
-
return new Promise((
|
|
10361
|
+
return new Promise((resolve24) => {
|
|
10362
10362
|
execFile(
|
|
10363
10363
|
command2,
|
|
10364
10364
|
args,
|
|
10365
10365
|
{ encoding: "utf8", env: PS_ENV, timeout: PROCESS_START_TIMEOUT_MS },
|
|
10366
10366
|
(error, stdout) => {
|
|
10367
10367
|
const code = error?.code;
|
|
10368
|
-
|
|
10368
|
+
resolve24({
|
|
10369
10369
|
status: error === null ? 0 : typeof code === "number" ? code : null,
|
|
10370
10370
|
stdout: typeof stdout === "string" ? stdout : "",
|
|
10371
10371
|
stderr: ""
|
|
@@ -12309,7 +12309,7 @@ function enrollmentFromArgv(argv) {
|
|
|
12309
12309
|
return parsed2.success ? parsed2.data : void 0;
|
|
12310
12310
|
}
|
|
12311
12311
|
function postUnix(options) {
|
|
12312
|
-
return new Promise((
|
|
12312
|
+
return new Promise((resolve24, reject) => {
|
|
12313
12313
|
const req = request(
|
|
12314
12314
|
{
|
|
12315
12315
|
...options.socketPath !== void 0 ? { socketPath: options.socketPath } : { host: "127.0.0.1", port: options.loopbackPort },
|
|
@@ -12341,7 +12341,7 @@ function postUnix(options) {
|
|
|
12341
12341
|
});
|
|
12342
12342
|
res.on("end", () => {
|
|
12343
12343
|
clearTimeout(deadline);
|
|
12344
|
-
|
|
12344
|
+
resolve24({
|
|
12345
12345
|
status: res.statusCode ?? 0,
|
|
12346
12346
|
body: Buffer.concat(chunks).toString("utf8")
|
|
12347
12347
|
});
|
|
@@ -13052,7 +13052,7 @@ function readAnswer(body2) {
|
|
|
13052
13052
|
}
|
|
13053
13053
|
async function runSteerWait(deps) {
|
|
13054
13054
|
const now = deps.now ?? (() => Date.now());
|
|
13055
|
-
const sleep2 = deps.sleep ?? ((ms) => new Promise((
|
|
13055
|
+
const sleep2 = deps.sleep ?? ((ms) => new Promise((resolve24) => setTimeout(resolve24, ms)));
|
|
13056
13056
|
const post2 = deps.post ?? postUnix;
|
|
13057
13057
|
const sessionId = sessionOf(deps.stdin);
|
|
13058
13058
|
if (sessionId === void 0) return DONE;
|
|
@@ -13151,8 +13151,8 @@ async function readStdin(source = process.stdin, deadlineMs = STDIN_READ_DEADLIN
|
|
|
13151
13151
|
let bytes = 0;
|
|
13152
13152
|
let overflowed = false;
|
|
13153
13153
|
let timer;
|
|
13154
|
-
const deadline = new Promise((
|
|
13155
|
-
timer = setTimeout(() =>
|
|
13154
|
+
const deadline = new Promise((resolve24) => {
|
|
13155
|
+
timer = setTimeout(() => resolve24("timeout"), deadlineMs);
|
|
13156
13156
|
timer.unref?.();
|
|
13157
13157
|
});
|
|
13158
13158
|
const read2 = (async () => {
|
|
@@ -19564,7 +19564,7 @@ function isFileCursor(value) {
|
|
|
19564
19564
|
if (!isRecord4(value)) return false;
|
|
19565
19565
|
return typeof value.path === "string" && Number.isSafeInteger(value.offset) && value.offset >= 0 && isOptional(value.ino, (ino) => typeof ino === "number") && isOptional(value.head, (head2) => typeof head2 === "string") && isOptional(
|
|
19566
19566
|
value.refused,
|
|
19567
|
-
(
|
|
19567
|
+
(refused2) => isRecord4(refused2) && typeof refused2.count === "number" && typeof refused2.detail === "string"
|
|
19568
19568
|
) && isOptional(value.codex, isRecord4);
|
|
19569
19569
|
}
|
|
19570
19570
|
function storedCursor(value) {
|
|
@@ -19593,7 +19593,7 @@ async function statIfExists(path2) {
|
|
|
19593
19593
|
}
|
|
19594
19594
|
}
|
|
19595
19595
|
function yieldTurn() {
|
|
19596
|
-
return new Promise((
|
|
19596
|
+
return new Promise((resolve24) => setImmediate(resolve24));
|
|
19597
19597
|
}
|
|
19598
19598
|
async function readAt(path2, offset, length) {
|
|
19599
19599
|
const handle = await fs.open(path2, "r");
|
|
@@ -20268,14 +20268,14 @@ var init_transcript_tailer = __esm({
|
|
|
20268
20268
|
const pass2 = await this.feed(session, cursor, budget, sealer, subagentId);
|
|
20269
20269
|
if (cursor.refused === void 0) return pass2;
|
|
20270
20270
|
await sealer.run(() => {
|
|
20271
|
-
const
|
|
20272
|
-
if (
|
|
20271
|
+
const refused2 = cursor.refused;
|
|
20272
|
+
if (refused2 === void 0 || !sealer.current()) return;
|
|
20273
20273
|
this.sealGap(
|
|
20274
20274
|
session,
|
|
20275
20275
|
"transcript_line_refused",
|
|
20276
|
-
|
|
20276
|
+
refused2.detail,
|
|
20277
20277
|
subagentId,
|
|
20278
|
-
|
|
20278
|
+
refused2.count
|
|
20279
20279
|
);
|
|
20280
20280
|
delete cursor.refused;
|
|
20281
20281
|
this.dirty = true;
|
|
@@ -20597,7 +20597,7 @@ async function runBackfill(request3, deps) {
|
|
|
20597
20597
|
const aborted = () => deps.signal?.aborted === true;
|
|
20598
20598
|
const between = async () => {
|
|
20599
20599
|
if (aborted()) throw new Stopped();
|
|
20600
|
-
await new Promise((
|
|
20600
|
+
await new Promise((resolve24) => setImmediate(resolve24));
|
|
20601
20601
|
if (deps.now() - checkedAt < CHECK_EVERY_MS) return;
|
|
20602
20602
|
checkedAt = deps.now();
|
|
20603
20603
|
deps.progress?.({ finished: false, ...counts2() });
|
|
@@ -20619,7 +20619,7 @@ async function runBackfill(request3, deps) {
|
|
|
20619
20619
|
else pending.push(candidate);
|
|
20620
20620
|
if (aborted()) throw new Stopped();
|
|
20621
20621
|
if (index % LOCAL_CHECKS_PER_TURN === LOCAL_CHECKS_PER_TURN - 1)
|
|
20622
|
-
await new Promise((
|
|
20622
|
+
await new Promise((resolve24) => setImmediate(resolve24));
|
|
20623
20623
|
}
|
|
20624
20624
|
const server = await askServer(pending, deps);
|
|
20625
20625
|
for (const candidate of pending) {
|
|
@@ -21061,7 +21061,7 @@ async function resultAgentIds(path2) {
|
|
|
21061
21061
|
await readSlices(path2, SEAL_SLICE_BYTES, async (lines) => {
|
|
21062
21062
|
for (const line of lines)
|
|
21063
21063
|
if (line.text !== void 0) resultAgentIdsOf(line.text, out);
|
|
21064
|
-
await new Promise((
|
|
21064
|
+
await new Promise((resolve24) => setImmediate(resolve24));
|
|
21065
21065
|
});
|
|
21066
21066
|
} catch {
|
|
21067
21067
|
}
|
|
@@ -24175,9 +24175,9 @@ function failure3(problem, count12) {
|
|
|
24175
24175
|
}
|
|
24176
24176
|
function codexAppServerClient(options) {
|
|
24177
24177
|
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
24178
|
-
return (requests) => new Promise((
|
|
24178
|
+
return (requests) => new Promise((resolve24) => {
|
|
24179
24179
|
if (requests.length === 0) {
|
|
24180
|
-
|
|
24180
|
+
resolve24({ answers: [] });
|
|
24181
24181
|
return;
|
|
24182
24182
|
}
|
|
24183
24183
|
let child;
|
|
@@ -24190,7 +24190,7 @@ function codexAppServerClient(options) {
|
|
|
24190
24190
|
...invocation.windowsVerbatimArguments === true ? { windowsVerbatimArguments: true } : {}
|
|
24191
24191
|
});
|
|
24192
24192
|
} catch (error) {
|
|
24193
|
-
|
|
24193
|
+
resolve24(
|
|
24194
24194
|
failure3(
|
|
24195
24195
|
`could not run \`codex app-server\`: ${error instanceof Error ? error.message : String(error)}`,
|
|
24196
24196
|
requests.length
|
|
@@ -24215,7 +24215,7 @@ function codexAppServerClient(options) {
|
|
|
24215
24215
|
child.stdin.end();
|
|
24216
24216
|
child.kill();
|
|
24217
24217
|
const said = stderr.trim();
|
|
24218
|
-
|
|
24218
|
+
resolve24(
|
|
24219
24219
|
problem === void 0 ? { answers } : {
|
|
24220
24220
|
answers,
|
|
24221
24221
|
problem: said.length === 0 ? problem : `${problem}: ${said}`
|
|
@@ -25170,7 +25170,7 @@ import { readFileSync as readFileSync10 } from "node:fs";
|
|
|
25170
25170
|
import { dirname as dirname9, resolve as resolve3 } from "node:path";
|
|
25171
25171
|
import { fileURLToPath } from "node:url";
|
|
25172
25172
|
function readVersion() {
|
|
25173
|
-
if (true) return "2.1.4-
|
|
25173
|
+
if (true) return "2.1.4-942";
|
|
25174
25174
|
try {
|
|
25175
25175
|
const here = dirname9(fileURLToPath(import.meta.url));
|
|
25176
25176
|
const pkg = JSON.parse(
|
|
@@ -27694,7 +27694,7 @@ ${lines.join("\n")}
|
|
|
27694
27694
|
async bodiesForAsync(events) {
|
|
27695
27695
|
const found = /* @__PURE__ */ new Map();
|
|
27696
27696
|
for (let at2 = 0; at2 < events.length; at2 += BODY_READ_SLICE) {
|
|
27697
|
-
if (at2 > 0) await new Promise((
|
|
27697
|
+
if (at2 > 0) await new Promise((resolve24) => setImmediate(resolve24));
|
|
27698
27698
|
let slice = events.slice(at2, at2 + BODY_READ_SLICE);
|
|
27699
27699
|
for (let attempt = 0; attempt < 2 && slice.length > 0; attempt += 1) {
|
|
27700
27700
|
const stale = /* @__PURE__ */ new Set();
|
|
@@ -27891,7 +27891,7 @@ ${lines.join("\n")}
|
|
|
27891
27891
|
let blanked = 0;
|
|
27892
27892
|
let moved = false;
|
|
27893
27893
|
for (let next = 0; next < found.length; ) {
|
|
27894
|
-
if (next > 0) await new Promise((
|
|
27894
|
+
if (next > 0) await new Promise((resolve24) => setImmediate(resolve24));
|
|
27895
27895
|
const slice = this.blankSlice(path2, found, next, idems);
|
|
27896
27896
|
if (slice === void 0) break;
|
|
27897
27897
|
blanked += slice.blanked;
|
|
@@ -30952,7 +30952,7 @@ ${problems.map((problem) => ` ${problem}`).join("\n")}`
|
|
|
30952
30952
|
deps.out(
|
|
30953
30953
|
` adding ${added.join(", ")} to ${existing.agent_key}: revoking ${existing.host_enrollment_id} and enrolling again for ${harnesses.join(", ")} so the control plane's host record follows (device key, port and local token kept)`
|
|
30954
30954
|
);
|
|
30955
|
-
const
|
|
30955
|
+
const refused2 = [];
|
|
30956
30956
|
const revoked = await revokeOnControlPlane(
|
|
30957
30957
|
existing,
|
|
30958
30958
|
{
|
|
@@ -30960,13 +30960,13 @@ ${problems.map((problem) => ` ${problem}`).join("\n")}`
|
|
|
30960
30960
|
reason: `oxagen agent enroll --harness ${harnesses.join(",")}`
|
|
30961
30961
|
},
|
|
30962
30962
|
deps,
|
|
30963
|
-
|
|
30963
|
+
refused2
|
|
30964
30964
|
);
|
|
30965
30965
|
if (!revoked) {
|
|
30966
30966
|
deps.err(
|
|
30967
|
-
`Cannot add ${added.join(", ")}: ${existing.host_enrollment_id} could not be revoked (${
|
|
30967
|
+
`Cannot add ${added.join(", ")}: ${existing.host_enrollment_id} could not be revoked (${refused2.join("; ")}), so nothing was changed; this host still reports as ${existing.agent_key} for ${existing.harnesses.join(", ")}.`
|
|
30968
30968
|
);
|
|
30969
|
-
return { ok: false, warnings: [...warnings, ...
|
|
30969
|
+
return { ok: false, warnings: [...warnings, ...refused2] };
|
|
30970
30970
|
}
|
|
30971
30971
|
writeHostFile(deps.paths.hostFile, {
|
|
30972
30972
|
...existing,
|
|
@@ -33365,7 +33365,7 @@ function runLineOf(raw) {
|
|
|
33365
33365
|
return void 0;
|
|
33366
33366
|
}
|
|
33367
33367
|
function streamDaemon(options) {
|
|
33368
|
-
return new Promise((
|
|
33368
|
+
return new Promise((resolve24, reject) => {
|
|
33369
33369
|
const req = request2(
|
|
33370
33370
|
{
|
|
33371
33371
|
...options.socketPath !== void 0 ? { socketPath: options.socketPath } : { host: "127.0.0.1", port: options.loopbackPort },
|
|
@@ -33393,7 +33393,7 @@ function streamDaemon(options) {
|
|
|
33393
33393
|
});
|
|
33394
33394
|
res.on("end", () => {
|
|
33395
33395
|
if (buffered.length > 0) options.onLine(buffered);
|
|
33396
|
-
|
|
33396
|
+
resolve24(res.statusCode ?? 0);
|
|
33397
33397
|
});
|
|
33398
33398
|
res.on("error", reject);
|
|
33399
33399
|
}
|
|
@@ -33566,7 +33566,7 @@ function spawnAgent(command2, args, options) {
|
|
|
33566
33566
|
process.platform,
|
|
33567
33567
|
options.env
|
|
33568
33568
|
);
|
|
33569
|
-
return new Promise((
|
|
33569
|
+
return new Promise((resolve24) => {
|
|
33570
33570
|
const child = spawn2(invocation.command, invocation.args, {
|
|
33571
33571
|
cwd: options.cwd,
|
|
33572
33572
|
env: options.env,
|
|
@@ -33582,7 +33582,7 @@ function spawnAgent(command2, args, options) {
|
|
|
33582
33582
|
process.off("SIGINT", stay);
|
|
33583
33583
|
process.off("SIGTERM", forward);
|
|
33584
33584
|
process.off("SIGHUP", forward);
|
|
33585
|
-
|
|
33585
|
+
resolve24(exit);
|
|
33586
33586
|
};
|
|
33587
33587
|
if (options.onSpawn !== void 0) child.once("spawn", options.onSpawn);
|
|
33588
33588
|
child.once("error", (error) => done({ code: null, signal: null, error }));
|
|
@@ -38072,17 +38072,17 @@ async function startContainedBridge(options) {
|
|
|
38072
38072
|
"upgrade",
|
|
38073
38073
|
(_request, socket) => socket.end("HTTP/1.1 403 Forbidden\r\nConnection: close\r\n\r\n")
|
|
38074
38074
|
);
|
|
38075
|
-
await new Promise((
|
|
38075
|
+
await new Promise((resolve24, reject) => {
|
|
38076
38076
|
server.once("error", reject);
|
|
38077
38077
|
server.listen(options.socketPath, () => {
|
|
38078
38078
|
chmodSync6(options.socketPath, 384);
|
|
38079
|
-
|
|
38079
|
+
resolve24();
|
|
38080
38080
|
});
|
|
38081
38081
|
});
|
|
38082
38082
|
return {
|
|
38083
38083
|
close: async () => {
|
|
38084
38084
|
server.closeAllConnections();
|
|
38085
|
-
await new Promise((
|
|
38085
|
+
await new Promise((resolve24) => server.close(() => resolve24()));
|
|
38086
38086
|
}
|
|
38087
38087
|
};
|
|
38088
38088
|
}
|
|
@@ -38237,6 +38237,9 @@ var init_workspace = __esm({
|
|
|
38237
38237
|
});
|
|
38238
38238
|
|
|
38239
38239
|
// ../../packages/tacho/src/collector/hardened-git.ts
|
|
38240
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
38241
|
+
import { lstatSync as lstatSync7, readFileSync as readFileSync15, statSync as statSync8 } from "node:fs";
|
|
38242
|
+
import { dirname as dirname15, join as join24, resolve as resolve10 } from "node:path";
|
|
38240
38243
|
function hardenedGitArgs(cwd, args, globals = []) {
|
|
38241
38244
|
const subcommand = args[0];
|
|
38242
38245
|
const end = args.indexOf("--");
|
|
@@ -38258,7 +38261,141 @@ function hardenedGitShellPrefix() {
|
|
|
38258
38261
|
function shellQuote2(value) {
|
|
38259
38262
|
return /^[A-Za-z0-9_./=:-]+$/.test(value) ? value : `'${value.replace(/'/g, "'\\''")}'`;
|
|
38260
38263
|
}
|
|
38261
|
-
|
|
38264
|
+
function hardenedGitExecOptions(repository) {
|
|
38265
|
+
return { env: HARDENED_GIT_ENV, repository };
|
|
38266
|
+
}
|
|
38267
|
+
function gitIdentity(repository, deps = DEFAULT_IDENTITY_DEPS) {
|
|
38268
|
+
const self2 = deps.getuid();
|
|
38269
|
+
if (self2 !== 0) return { kind: "self" };
|
|
38270
|
+
const owners = [];
|
|
38271
|
+
const directory = resolve10(repository);
|
|
38272
|
+
try {
|
|
38273
|
+
owners.push(deps.stat(directory));
|
|
38274
|
+
} catch (error) {
|
|
38275
|
+
return {
|
|
38276
|
+
kind: "refuse",
|
|
38277
|
+
reason: `git did not run in ${directory}: its owner could not be read (${describe5(error)})`
|
|
38278
|
+
};
|
|
38279
|
+
}
|
|
38280
|
+
for (let at2 = directory; ; at2 = dirname15(at2)) {
|
|
38281
|
+
const marker = join24(at2, ".git");
|
|
38282
|
+
const link = tryStat(deps.lstat, marker);
|
|
38283
|
+
if (link !== void 0) {
|
|
38284
|
+
owners.push(link);
|
|
38285
|
+
const target2 = tryStat(deps.stat, marker);
|
|
38286
|
+
if (target2 !== void 0) {
|
|
38287
|
+
owners.push(target2);
|
|
38288
|
+
if (target2.isDirectory()) {
|
|
38289
|
+
const config = tryStat(deps.stat, join24(marker, "config"));
|
|
38290
|
+
if (config !== void 0) owners.push(config);
|
|
38291
|
+
}
|
|
38292
|
+
}
|
|
38293
|
+
break;
|
|
38294
|
+
}
|
|
38295
|
+
if (dirname15(at2) === at2) break;
|
|
38296
|
+
}
|
|
38297
|
+
const others = [...new Set(owners.map((found) => found.uid))].filter(
|
|
38298
|
+
(uid2) => uid2 !== 0
|
|
38299
|
+
);
|
|
38300
|
+
if (others.length === 0) return { kind: "self" };
|
|
38301
|
+
if (others.length > 1)
|
|
38302
|
+
return {
|
|
38303
|
+
kind: "refuse",
|
|
38304
|
+
reason: `git did not run in ${directory}: users ${others.join(" and ")} both own parts of it`
|
|
38305
|
+
};
|
|
38306
|
+
const uid = others[0];
|
|
38307
|
+
const entry2 = passwdEntry(deps.passwd(), uid);
|
|
38308
|
+
if (entry2 !== void 0) return { kind: "owner", uid, ...entry2 };
|
|
38309
|
+
const gid = owners.find((found) => found.uid === uid)?.gid;
|
|
38310
|
+
if (gid === void 0 || gid === 0)
|
|
38311
|
+
return {
|
|
38312
|
+
kind: "refuse",
|
|
38313
|
+
reason: `git did not run in ${directory}: user ${uid} has no group other than root's`
|
|
38314
|
+
};
|
|
38315
|
+
return { kind: "owner", uid, gid, home: NO_HOME };
|
|
38316
|
+
}
|
|
38317
|
+
function tryStat(read2, path2) {
|
|
38318
|
+
try {
|
|
38319
|
+
return read2(path2);
|
|
38320
|
+
} catch {
|
|
38321
|
+
return void 0;
|
|
38322
|
+
}
|
|
38323
|
+
}
|
|
38324
|
+
function passwdEntry(passwd, uid) {
|
|
38325
|
+
for (const line of (passwd ?? "").split("\n")) {
|
|
38326
|
+
const fields = line.split(":");
|
|
38327
|
+
if (fields.length < 7 || Number(fields[2]) !== uid) continue;
|
|
38328
|
+
const gid = Number(fields[3]);
|
|
38329
|
+
if (!Number.isSafeInteger(gid) || gid < 0) return void 0;
|
|
38330
|
+
const home = fields[5] ?? "";
|
|
38331
|
+
return { gid, home: home.startsWith("/") ? home : NO_HOME };
|
|
38332
|
+
}
|
|
38333
|
+
return void 0;
|
|
38334
|
+
}
|
|
38335
|
+
function describe5(error) {
|
|
38336
|
+
return error instanceof Error ? error.message : String(error);
|
|
38337
|
+
}
|
|
38338
|
+
function createGitExecAsync(run3 = runExecFile, deps = DEFAULT_IDENTITY_DEPS, environment = process.env) {
|
|
38339
|
+
return async (command2, args, options) => {
|
|
38340
|
+
const inherited = options?.env !== void 0 ? { env: { ...definedOnly(environment), ...options.env } } : {};
|
|
38341
|
+
const repository = options?.repository ?? (command2 === "git" && args[0] === "-C" ? args[1] : void 0);
|
|
38342
|
+
if (repository === void 0) {
|
|
38343
|
+
if (command2 === "git" && deps.getuid() === 0)
|
|
38344
|
+
return refused(
|
|
38345
|
+
"git did not run: root names no repository to run it as"
|
|
38346
|
+
);
|
|
38347
|
+
return run3(command2, args, inherited);
|
|
38348
|
+
}
|
|
38349
|
+
const identity = gitIdentity(repository, deps);
|
|
38350
|
+
if (identity.kind === "refuse") return refused(identity.reason);
|
|
38351
|
+
if (identity.kind === "self") return run3(command2, args, inherited);
|
|
38352
|
+
const env = {};
|
|
38353
|
+
for (const name of KEPT_VARIABLES) {
|
|
38354
|
+
const value = environment[name];
|
|
38355
|
+
if (value !== void 0) env[name] = value;
|
|
38356
|
+
}
|
|
38357
|
+
env["HOME"] = identity.home;
|
|
38358
|
+
return run3(command2, args, {
|
|
38359
|
+
env: { ...env, ...HARDENED_GIT_ENV, ...options?.env },
|
|
38360
|
+
uid: identity.uid,
|
|
38361
|
+
gid: identity.gid
|
|
38362
|
+
});
|
|
38363
|
+
};
|
|
38364
|
+
}
|
|
38365
|
+
function refused(reason3) {
|
|
38366
|
+
return { status: 1, stdout: "", stderr: reason3 };
|
|
38367
|
+
}
|
|
38368
|
+
function definedOnly(environment) {
|
|
38369
|
+
const out = {};
|
|
38370
|
+
for (const [name, value] of Object.entries(environment))
|
|
38371
|
+
if (value !== void 0) out[name] = value;
|
|
38372
|
+
return out;
|
|
38373
|
+
}
|
|
38374
|
+
function runExecFile(command2, args, launch) {
|
|
38375
|
+
return new Promise((settle3) => {
|
|
38376
|
+
execFile2(
|
|
38377
|
+
command2,
|
|
38378
|
+
args,
|
|
38379
|
+
{
|
|
38380
|
+
encoding: "utf8",
|
|
38381
|
+
maxBuffer: 4 * 1024 * 1024,
|
|
38382
|
+
timeout: 1e4,
|
|
38383
|
+
...launch.env !== void 0 ? { env: launch.env } : {},
|
|
38384
|
+
...launch.uid !== void 0 ? { uid: launch.uid } : {},
|
|
38385
|
+
...launch.gid !== void 0 ? { gid: launch.gid } : {}
|
|
38386
|
+
},
|
|
38387
|
+
(error, stdout, stderr) => {
|
|
38388
|
+
const code = error?.code;
|
|
38389
|
+
settle3({
|
|
38390
|
+
status: error === null ? 0 : typeof code === "number" ? code : 1,
|
|
38391
|
+
stdout: stdout ?? "",
|
|
38392
|
+
stderr: stderr ?? ""
|
|
38393
|
+
});
|
|
38394
|
+
}
|
|
38395
|
+
);
|
|
38396
|
+
});
|
|
38397
|
+
}
|
|
38398
|
+
var HARDENED_GIT_CONFIG, HARDENED_GIT_ENV, DIFF_SUBCOMMANDS, DIFF_FLAGS, NO_HOME, DEFAULT_IDENTITY_DEPS, KEPT_VARIABLES;
|
|
38262
38399
|
var init_hardened_git = __esm({
|
|
38263
38400
|
"../../packages/tacho/src/collector/hardened-git.ts"() {
|
|
38264
38401
|
"use strict";
|
|
@@ -38280,12 +38417,26 @@ var init_hardened_git = __esm({
|
|
|
38280
38417
|
};
|
|
38281
38418
|
DIFF_SUBCOMMANDS = /* @__PURE__ */ new Set(["diff", "show", "log"]);
|
|
38282
38419
|
DIFF_FLAGS = ["--no-ext-diff", "--no-textconv"];
|
|
38420
|
+
NO_HOME = "/nonexistent";
|
|
38421
|
+
DEFAULT_IDENTITY_DEPS = {
|
|
38422
|
+
getuid: () => process.getuid?.(),
|
|
38423
|
+
stat: (path2) => statSync8(path2),
|
|
38424
|
+
lstat: (path2) => lstatSync7(path2),
|
|
38425
|
+
passwd: () => {
|
|
38426
|
+
try {
|
|
38427
|
+
return readFileSync15("/etc/passwd", "utf8");
|
|
38428
|
+
} catch {
|
|
38429
|
+
return void 0;
|
|
38430
|
+
}
|
|
38431
|
+
}
|
|
38432
|
+
};
|
|
38433
|
+
KEPT_VARIABLES = ["PATH", "LANG", "LC_ALL", "LC_CTYPE", "TZ"];
|
|
38283
38434
|
}
|
|
38284
38435
|
});
|
|
38285
38436
|
|
|
38286
38437
|
// ../../packages/tacho/src/contained/profile.ts
|
|
38287
38438
|
import { createHash as createHash6 } from "node:crypto";
|
|
38288
|
-
import { isAbsolute as isAbsolute4, join as
|
|
38439
|
+
import { isAbsolute as isAbsolute4, join as join25, relative as relative3, sep as sep3 } from "node:path";
|
|
38289
38440
|
function containerPath(workspace, path2) {
|
|
38290
38441
|
const inside2 = relative3(workspace, path2);
|
|
38291
38442
|
if (inside2 === "" || isAbsolute4(inside2) || inside2 === ".." || inside2.startsWith(`..${sep3}`))
|
|
@@ -38295,7 +38446,7 @@ function containerPath(workspace, path2) {
|
|
|
38295
38446
|
return `/workspace/${inside2.split(sep3).join("/")}`;
|
|
38296
38447
|
}
|
|
38297
38448
|
function gitMountPairs(spec) {
|
|
38298
|
-
if (!spec.gitMounts.includes(
|
|
38449
|
+
if (!spec.gitMounts.includes(join25(spec.workspace, ".git")))
|
|
38299
38450
|
throw new Error(
|
|
38300
38451
|
"Contained execution must mount the repository's .git read-only"
|
|
38301
38452
|
);
|
|
@@ -38452,7 +38603,7 @@ var init_profile = __esm({
|
|
|
38452
38603
|
});
|
|
38453
38604
|
|
|
38454
38605
|
// ../../packages/tacho/src/contained/launcher.ts
|
|
38455
|
-
import { execFile as
|
|
38606
|
+
import { execFile as execFile3, spawn as spawn3 } from "node:child_process";
|
|
38456
38607
|
import { randomBytes as randomBytes8 } from "node:crypto";
|
|
38457
38608
|
import {
|
|
38458
38609
|
chmodSync as chmodSync7,
|
|
@@ -38462,7 +38613,7 @@ import {
|
|
|
38462
38613
|
writeFileSync as writeFileSync2
|
|
38463
38614
|
} from "node:fs";
|
|
38464
38615
|
import { tmpdir } from "node:os";
|
|
38465
|
-
import { isAbsolute as isAbsolute5, join as
|
|
38616
|
+
import { isAbsolute as isAbsolute5, join as join26 } from "node:path";
|
|
38466
38617
|
import { promisify } from "node:util";
|
|
38467
38618
|
function reason(error) {
|
|
38468
38619
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -38501,7 +38652,7 @@ async function launchContainedAgent(options) {
|
|
|
38501
38652
|
if (digest6 === void 0)
|
|
38502
38653
|
throw new Error("The operator's contained image is not installed");
|
|
38503
38654
|
const sessionId = `contained-${randomBytes8(16).toString("hex")}`;
|
|
38504
|
-
const directory = mkdtempSync(
|
|
38655
|
+
const directory = mkdtempSync(join26(tmpdir(), "oxagen-contained-"));
|
|
38505
38656
|
chmodSync7(directory, 448);
|
|
38506
38657
|
let prepared;
|
|
38507
38658
|
let containerCreated = false;
|
|
@@ -38522,7 +38673,7 @@ async function launchContainedAgent(options) {
|
|
|
38522
38673
|
for (const [name2, contents] of entries2) {
|
|
38523
38674
|
if (!/^[a-z0-9.-]+$/.test(name2))
|
|
38524
38675
|
throw new Error("Invalid contained configuration filename");
|
|
38525
|
-
writeFileSync2(
|
|
38676
|
+
writeFileSync2(join26(directory, name2), contents, {
|
|
38526
38677
|
mode: 256,
|
|
38527
38678
|
flag: "wx"
|
|
38528
38679
|
});
|
|
@@ -38552,7 +38703,7 @@ async function launchContainedAgent(options) {
|
|
|
38552
38703
|
admitted = true;
|
|
38553
38704
|
if (options.signal?.aborted)
|
|
38554
38705
|
throw new Error("Contained run cancelled before start");
|
|
38555
|
-
exitCode = await new Promise((
|
|
38706
|
+
exitCode = await new Promise((resolve24, reject) => {
|
|
38556
38707
|
const child = spawn3("docker", ["start", "--attach", name], {
|
|
38557
38708
|
stdio: ["ignore", "pipe", "pipe"]
|
|
38558
38709
|
});
|
|
@@ -38575,7 +38726,7 @@ async function launchContainedAgent(options) {
|
|
|
38575
38726
|
child.once("error", reject);
|
|
38576
38727
|
child.once("close", (code) => {
|
|
38577
38728
|
options.signal?.removeEventListener("abort", stop);
|
|
38578
|
-
|
|
38729
|
+
resolve24(code ?? 1);
|
|
38579
38730
|
});
|
|
38580
38731
|
});
|
|
38581
38732
|
return { sessionId, exitCode, measurement };
|
|
@@ -38606,7 +38757,7 @@ var init_launcher = __esm({
|
|
|
38606
38757
|
init_workspace();
|
|
38607
38758
|
init_hardened_git();
|
|
38608
38759
|
init_profile();
|
|
38609
|
-
exec = promisify(
|
|
38760
|
+
exec = promisify(execFile3);
|
|
38610
38761
|
imageInspectSchema = external_exports.array(external_exports.object({ Id: external_exports.string().optional() }));
|
|
38611
38762
|
}
|
|
38612
38763
|
});
|
|
@@ -38665,16 +38816,16 @@ async function startSandboxGateway(options, port = SANDBOX_GATEWAY_PORT) {
|
|
|
38665
38816
|
"upgrade",
|
|
38666
38817
|
(_request, socket) => socket.end("HTTP/1.1 403 Forbidden\r\nConnection: close\r\n\r\n")
|
|
38667
38818
|
);
|
|
38668
|
-
await new Promise((
|
|
38819
|
+
await new Promise((resolve24, reject) => {
|
|
38669
38820
|
server.once("error", reject);
|
|
38670
|
-
server.listen(port, "127.0.0.1", () =>
|
|
38821
|
+
server.listen(port, "127.0.0.1", () => resolve24());
|
|
38671
38822
|
});
|
|
38672
38823
|
const address = server.address();
|
|
38673
38824
|
return {
|
|
38674
38825
|
port: typeof address === "object" && address !== null ? address.port : port,
|
|
38675
38826
|
close: async () => {
|
|
38676
38827
|
server.closeAllConnections();
|
|
38677
|
-
await new Promise((
|
|
38828
|
+
await new Promise((resolve24) => server.close(() => resolve24()));
|
|
38678
38829
|
}
|
|
38679
38830
|
};
|
|
38680
38831
|
}
|
|
@@ -38778,7 +38929,7 @@ var init_claude_code = __esm({
|
|
|
38778
38929
|
|
|
38779
38930
|
// ../../packages/tacho/src/contained/sandbox/hooks.ts
|
|
38780
38931
|
import { createHash as createHash7 } from "node:crypto";
|
|
38781
|
-
import { dirname as
|
|
38932
|
+
import { dirname as dirname16 } from "node:path";
|
|
38782
38933
|
function sandboxHookScript(port) {
|
|
38783
38934
|
return `import { request } from "node:http";
|
|
38784
38935
|
const chunks = [];
|
|
@@ -38848,7 +38999,7 @@ function pinSandboxHooks(system, options) {
|
|
|
38848
38999
|
]
|
|
38849
39000
|
];
|
|
38850
39001
|
for (const [path2, contents] of written2) {
|
|
38851
|
-
const directory =
|
|
39002
|
+
const directory = dirname16(path2);
|
|
38852
39003
|
system.mkdir(directory, 493);
|
|
38853
39004
|
system.chown(directory, 0, 0);
|
|
38854
39005
|
system.writeFile(path2, contents, 292);
|
|
@@ -38856,7 +39007,7 @@ function pinSandboxHooks(system, options) {
|
|
|
38856
39007
|
}
|
|
38857
39008
|
const files2 = [options.nodePath, ...written2.map(([path2]) => path2)];
|
|
38858
39009
|
for (const path2 of files2)
|
|
38859
|
-
if (!rootReadOnly(system, path2, "file") || !rootReadOnly(system,
|
|
39010
|
+
if (!rootReadOnly(system, path2, "file") || !rootReadOnly(system, dirname16(path2), "directory"))
|
|
38860
39011
|
throw new Error(
|
|
38861
39012
|
`The hook file ${path2} is not root-owned and read-only; the agent was not started`
|
|
38862
39013
|
);
|
|
@@ -38921,7 +39072,7 @@ var init_privilege = __esm({
|
|
|
38921
39072
|
|
|
38922
39073
|
// ../../packages/tacho/src/contained/sandbox/launcher.ts
|
|
38923
39074
|
import { randomBytes as randomBytes9 } from "node:crypto";
|
|
38924
|
-
import { join as
|
|
39075
|
+
import { join as join27 } from "node:path";
|
|
38925
39076
|
function shellQuote3(value) {
|
|
38926
39077
|
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
38927
39078
|
}
|
|
@@ -39011,7 +39162,7 @@ async function launchSandboxAgent(options) {
|
|
|
39011
39162
|
{ ...asAgent, cwd: SANDBOX_AGENT_HOME, timeoutMs: 15 * 6e4 }
|
|
39012
39163
|
);
|
|
39013
39164
|
for (const [name, contents] of Object.entries(claudeCodeUserState())) {
|
|
39014
|
-
const path2 =
|
|
39165
|
+
const path2 = join27(SANDBOX_AGENT_HOME, name);
|
|
39015
39166
|
system.writeFile(path2, contents, 384);
|
|
39016
39167
|
system.chown(path2, SANDBOX_AGENT_UID, SANDBOX_AGENT_GID);
|
|
39017
39168
|
}
|
|
@@ -39135,14 +39286,14 @@ var init_request = __esm({
|
|
|
39135
39286
|
});
|
|
39136
39287
|
|
|
39137
39288
|
// ../../packages/tacho/src/contained/sandbox/system.ts
|
|
39138
|
-
import { execFile as
|
|
39289
|
+
import { execFile as execFile4, spawn as spawn4 } from "node:child_process";
|
|
39139
39290
|
import {
|
|
39140
39291
|
chmodSync as chmodSync8,
|
|
39141
39292
|
chownSync as chownSync2,
|
|
39142
39293
|
existsSync as existsSync17,
|
|
39143
39294
|
mkdirSync as mkdirSync5,
|
|
39144
|
-
readFileSync as
|
|
39145
|
-
statSync as
|
|
39295
|
+
readFileSync as readFileSync16,
|
|
39296
|
+
statSync as statSync9,
|
|
39146
39297
|
writeFileSync as writeFileSync3
|
|
39147
39298
|
} from "node:fs";
|
|
39148
39299
|
import { promisify as promisify2 } from "node:util";
|
|
@@ -39150,7 +39301,7 @@ var run, nodeSandboxSystem;
|
|
|
39150
39301
|
var init_system = __esm({
|
|
39151
39302
|
"../../packages/tacho/src/contained/sandbox/system.ts"() {
|
|
39152
39303
|
"use strict";
|
|
39153
|
-
run = promisify2(
|
|
39304
|
+
run = promisify2(execFile4);
|
|
39154
39305
|
nodeSandboxSystem = {
|
|
39155
39306
|
getuid: () => process.getuid?.() ?? -1,
|
|
39156
39307
|
platform: process.platform,
|
|
@@ -39173,9 +39324,9 @@ var init_system = __esm({
|
|
|
39173
39324
|
...options.env !== void 0 ? { env: options.env } : {},
|
|
39174
39325
|
stdio: ["pipe", "pipe", "inherit"]
|
|
39175
39326
|
});
|
|
39176
|
-
const exited = new Promise((
|
|
39177
|
-
child.once("error", () =>
|
|
39178
|
-
child.once("close", (code) =>
|
|
39327
|
+
const exited = new Promise((resolve24) => {
|
|
39328
|
+
child.once("error", () => resolve24(1));
|
|
39329
|
+
child.once("close", (code) => resolve24(code ?? 1));
|
|
39179
39330
|
});
|
|
39180
39331
|
return {
|
|
39181
39332
|
pid: child.pid,
|
|
@@ -39190,7 +39341,7 @@ var init_system = __esm({
|
|
|
39190
39341
|
exists: (path2) => existsSync17(path2),
|
|
39191
39342
|
stat: (path2) => {
|
|
39192
39343
|
try {
|
|
39193
|
-
const found =
|
|
39344
|
+
const found = statSync9(path2);
|
|
39194
39345
|
return {
|
|
39195
39346
|
uid: found.uid,
|
|
39196
39347
|
gid: found.gid,
|
|
@@ -39202,7 +39353,7 @@ var init_system = __esm({
|
|
|
39202
39353
|
return void 0;
|
|
39203
39354
|
}
|
|
39204
39355
|
},
|
|
39205
|
-
readFile: (path2) =>
|
|
39356
|
+
readFile: (path2) => readFileSync16(path2),
|
|
39206
39357
|
writeFile: (path2, contents, mode) => {
|
|
39207
39358
|
writeFileSync3(path2, contents, { mode });
|
|
39208
39359
|
chmodSync8(path2, mode);
|
|
@@ -39217,10 +39368,10 @@ var init_system = __esm({
|
|
|
39217
39368
|
});
|
|
39218
39369
|
|
|
39219
39370
|
// ../../packages/tacho/src/contained/runner.ts
|
|
39220
|
-
import { join as
|
|
39371
|
+
import { join as join28 } from "node:path";
|
|
39221
39372
|
function containedHookEnv(harness, workspace) {
|
|
39222
|
-
const home =
|
|
39223
|
-
return harness === "codex" ? { CODEX_HOME:
|
|
39373
|
+
const home = join28(workspace, ".oxagen-contained", "home");
|
|
39374
|
+
return harness === "codex" ? { CODEX_HOME: join28(home, ".codex") } : { CLAUDE_CONFIG_DIR: join28(home, ".claude") };
|
|
39224
39375
|
}
|
|
39225
39376
|
function containedLaunchEndpoint(host) {
|
|
39226
39377
|
const ingest = new URL(host.endpoints.ingest);
|
|
@@ -39418,7 +39569,7 @@ function createContainedRunner(options) {
|
|
|
39418
39569
|
sessionUuid2 = started.recorder.sessionUuid;
|
|
39419
39570
|
active2.set(sessionUuid2, controller);
|
|
39420
39571
|
const bridge = await startContainedBridge({
|
|
39421
|
-
socketPath:
|
|
39572
|
+
socketPath: join28(directory, "bridge.sock"),
|
|
39422
39573
|
...bridgeRoutes({
|
|
39423
39574
|
sessionId,
|
|
39424
39575
|
workspace,
|
|
@@ -39502,7 +39653,7 @@ function createContainedRunner(options) {
|
|
|
39502
39653
|
const abort = () => controller.abort();
|
|
39503
39654
|
signal?.addEventListener("abort", abort, { once: true });
|
|
39504
39655
|
if (signal?.aborted) abort();
|
|
39505
|
-
const env = { CLAUDE_CONFIG_DIR:
|
|
39656
|
+
const env = { CLAUDE_CONFIG_DIR: join28(SANDBOX_AGENT_HOME, ".claude") };
|
|
39506
39657
|
let sessionUuid2;
|
|
39507
39658
|
let launchedSessionId;
|
|
39508
39659
|
let opened = false;
|
|
@@ -39637,7 +39788,7 @@ var init_runner = __esm({
|
|
|
39637
39788
|
|
|
39638
39789
|
// ../../packages/tacho/src/collector/detector.ts
|
|
39639
39790
|
import { promises as fs3 } from "node:fs";
|
|
39640
|
-
import { basename as basename5, join as
|
|
39791
|
+
import { basename as basename5, join as join29 } from "node:path";
|
|
39641
39792
|
async function eachLimited(items, limit, task) {
|
|
39642
39793
|
let next = 0;
|
|
39643
39794
|
const workers = Array.from(
|
|
@@ -39663,7 +39814,7 @@ async function scanProject(dir) {
|
|
|
39663
39814
|
await eachLimited(names2, SCAN_CONCURRENCY, async (name) => {
|
|
39664
39815
|
const match = SESSION_FILE.exec(name);
|
|
39665
39816
|
if (match === null) return;
|
|
39666
|
-
const path2 =
|
|
39817
|
+
const path2 = join29(dir, name);
|
|
39667
39818
|
try {
|
|
39668
39819
|
const st = await fs3.stat(path2);
|
|
39669
39820
|
out.push({ sessionId: match[1], path: path2, mtimeMs: st.mtimeMs });
|
|
@@ -39704,7 +39855,7 @@ var init_detector = __esm({
|
|
|
39704
39855
|
continue;
|
|
39705
39856
|
}
|
|
39706
39857
|
await eachLimited(names2, SCAN_CONCURRENCY, async (name) => {
|
|
39707
|
-
const dir =
|
|
39858
|
+
const dir = join29(root, name);
|
|
39708
39859
|
try {
|
|
39709
39860
|
const st = await fs3.stat(dir);
|
|
39710
39861
|
if (st.isDirectory()) dirs.push({ dir, mtimeMs: st.mtimeMs });
|
|
@@ -39944,7 +40095,7 @@ var init_detector = __esm({
|
|
|
39944
40095
|
transcript_path: transcript.path,
|
|
39945
40096
|
transcript_mtime: new Date(transcript.mtimeMs).toISOString(),
|
|
39946
40097
|
claude_pids: processes.map((p) => p.pid),
|
|
39947
|
-
project: basename5(
|
|
40098
|
+
project: basename5(join29(transcript.path, ".."))
|
|
39948
40099
|
}
|
|
39949
40100
|
})
|
|
39950
40101
|
);
|
|
@@ -40029,7 +40180,7 @@ async function runGit(exec4, cwd, args) {
|
|
|
40029
40180
|
"-c",
|
|
40030
40181
|
"core.quotePath=false"
|
|
40031
40182
|
]),
|
|
40032
|
-
|
|
40183
|
+
hardenedGitExecOptions(cwd)
|
|
40033
40184
|
);
|
|
40034
40185
|
} catch (error) {
|
|
40035
40186
|
return {
|
|
@@ -40370,7 +40521,7 @@ import {
|
|
|
40370
40521
|
rm,
|
|
40371
40522
|
unlink
|
|
40372
40523
|
} from "node:fs/promises";
|
|
40373
|
-
import { dirname as
|
|
40524
|
+
import { dirname as dirname17, join as join30 } from "node:path";
|
|
40374
40525
|
function byPath(a, b3) {
|
|
40375
40526
|
return a.path < b3.path ? -1 : a.path > b3.path ? 1 : 0;
|
|
40376
40527
|
}
|
|
@@ -40413,7 +40564,7 @@ async function contentHash(absolutePath, kind, keep) {
|
|
|
40413
40564
|
if (keep !== void 0) {
|
|
40414
40565
|
try {
|
|
40415
40566
|
await mkdir(keep.dir, { recursive: true, mode: 448 });
|
|
40416
|
-
const temp2 =
|
|
40567
|
+
const temp2 = join30(keep.dir, `.partial-${randomUUID3()}`);
|
|
40417
40568
|
copy = {
|
|
40418
40569
|
temp: temp2,
|
|
40419
40570
|
handle: await open3(temp2, "wx", keep.executable ? 448 : 384)
|
|
@@ -40457,7 +40608,7 @@ async function settleCopy(temp, name) {
|
|
|
40457
40608
|
if (temp === void 0) return;
|
|
40458
40609
|
if (name !== void 0)
|
|
40459
40610
|
try {
|
|
40460
|
-
await rename(temp,
|
|
40611
|
+
await rename(temp, join30(dirname17(temp), name));
|
|
40461
40612
|
return;
|
|
40462
40613
|
} catch {
|
|
40463
40614
|
}
|
|
@@ -40473,7 +40624,7 @@ async function copiedBytes(dir) {
|
|
|
40473
40624
|
let total2 = 0;
|
|
40474
40625
|
for (const name of names2) {
|
|
40475
40626
|
try {
|
|
40476
|
-
total2 += (await lstat(
|
|
40627
|
+
total2 += (await lstat(join30(dir, name))).size;
|
|
40477
40628
|
} catch {
|
|
40478
40629
|
}
|
|
40479
40630
|
}
|
|
@@ -40489,7 +40640,7 @@ async function removeCopiesOutside(root, live) {
|
|
|
40489
40640
|
const keep = new Set(live());
|
|
40490
40641
|
await Promise.all(
|
|
40491
40642
|
names2.filter((name) => !keep.has(name)).map(
|
|
40492
|
-
(name) => rm(
|
|
40643
|
+
(name) => rm(join30(root, name), { recursive: true, force: true }).catch(
|
|
40493
40644
|
() => void 0
|
|
40494
40645
|
)
|
|
40495
40646
|
)
|
|
@@ -40511,7 +40662,7 @@ async function readPreexistingPaths(exec4, root, startedAtMs, copies) {
|
|
|
40511
40662
|
if (found === void 0) return;
|
|
40512
40663
|
if (found === "absent") {
|
|
40513
40664
|
if (!deletedIn(entry2.code)) return;
|
|
40514
|
-
const parent = await directoryChangedAt(
|
|
40665
|
+
const parent = await directoryChangedAt(dirname17(absolute));
|
|
40515
40666
|
if (parent === void 0 || parent >= startedAtMs) return;
|
|
40516
40667
|
paths[entry2.path] = null;
|
|
40517
40668
|
return;
|
|
@@ -40596,7 +40747,7 @@ async function contributionOf(exec4, cwd, root, repoRelative, entry2, copies) {
|
|
|
40596
40747
|
let copy = null;
|
|
40597
40748
|
if (entry2 !== null) {
|
|
40598
40749
|
if (copies === void 0 || !COPY_NAME.test(entry2[0])) return void 0;
|
|
40599
|
-
copy =
|
|
40750
|
+
copy = join30(copies, entry2[0]);
|
|
40600
40751
|
const kept = await statOf(copy);
|
|
40601
40752
|
if (kept === void 0 || kept === "absent" || kept.kind !== "file")
|
|
40602
40753
|
return void 0;
|
|
@@ -40998,7 +41149,7 @@ var init_session_changes = __esm({
|
|
|
40998
41149
|
});
|
|
40999
41150
|
|
|
41000
41151
|
// ../../packages/tacho/src/collector/session-commits.ts
|
|
41001
|
-
import { join as
|
|
41152
|
+
import { join as join31 } from "node:path";
|
|
41002
41153
|
function parseMeta(stdout) {
|
|
41003
41154
|
const out = [];
|
|
41004
41155
|
for (const record of stdout.split("\0")) {
|
|
@@ -41039,9 +41190,11 @@ async function patchIds(exec4, cwd, shas) {
|
|
|
41039
41190
|
const out = /* @__PURE__ */ new Map();
|
|
41040
41191
|
if (shas.length === 0) return out;
|
|
41041
41192
|
try {
|
|
41042
|
-
const result2 = await exec4(
|
|
41043
|
-
|
|
41044
|
-
|
|
41193
|
+
const result2 = await exec4(
|
|
41194
|
+
"sh",
|
|
41195
|
+
["-c", PATCH_IDS, "sh", cwd, ...shas],
|
|
41196
|
+
hardenedGitExecOptions(cwd)
|
|
41197
|
+
);
|
|
41045
41198
|
if (result2.status !== 0) return out;
|
|
41046
41199
|
for (const line of (result2.stdout ?? "").split("\n")) {
|
|
41047
41200
|
const [patchId, sha2] = line.trim().split(" ");
|
|
@@ -41121,7 +41274,7 @@ async function readSessionCommits(exec4, cwd, input) {
|
|
|
41121
41274
|
const test = input.tests[commit.sha];
|
|
41122
41275
|
const toolUseId = callAt(times.get(commit.sha), calls);
|
|
41123
41276
|
const written2 = input.written;
|
|
41124
|
-
const outside = merge || written2 === void 0 || root === void 0 ? void 0 : files2.some((file) => !written2.has(
|
|
41277
|
+
const outside = merge || written2 === void 0 || root === void 0 ? void 0 : files2.some((file) => !written2.has(join31(root, file.path)));
|
|
41125
41278
|
return {
|
|
41126
41279
|
sha: commit.sha,
|
|
41127
41280
|
parent_shas: commit.parents.slice(0, MAX_COMMIT_PARENTS),
|
|
@@ -41169,7 +41322,7 @@ var init_session_commits = __esm({
|
|
|
41169
41322
|
|
|
41170
41323
|
// ../../packages/tacho/src/collector/worktree-snapshot.ts
|
|
41171
41324
|
import { lstat as lstat2 } from "node:fs/promises";
|
|
41172
|
-
import { join as
|
|
41325
|
+
import { join as join32 } from "node:path";
|
|
41173
41326
|
function headerPath(prefix, path2) {
|
|
41174
41327
|
const name = `${prefix}${path2}`;
|
|
41175
41328
|
let quoted3 = false;
|
|
@@ -41214,6 +41367,15 @@ function relabelPreSessionPatch(patch, path2, sides) {
|
|
|
41214
41367
|
body2[0] = `Binary files ${before} and ${after} differ`;
|
|
41215
41368
|
return [...out, ...body2].join("\n");
|
|
41216
41369
|
}
|
|
41370
|
+
function remoteRepositories(origin, remotes) {
|
|
41371
|
+
const urls = (remotes ?? "").split("\n").map((line) => /^\S+\t(\S+) \((?:fetch|push)\)$/.exec(line.trim())?.[1]).filter((url) => url !== void 0);
|
|
41372
|
+
const ordered = [...origin ? [origin.trim()] : [], ...urls];
|
|
41373
|
+
return [
|
|
41374
|
+
...new Set(
|
|
41375
|
+
ordered.map((url) => safeRepositoryUrl(url)).filter((url) => url !== null)
|
|
41376
|
+
)
|
|
41377
|
+
];
|
|
41378
|
+
}
|
|
41217
41379
|
function safeRepositoryUrl(remote) {
|
|
41218
41380
|
const scp = remote.includes("://") ? null : /^(?:[^@\s/]+@)?([a-z0-9.-]+):([\w./-]+)$/i.exec(remote.trim());
|
|
41219
41381
|
try {
|
|
@@ -41244,7 +41406,7 @@ async function worktreeFingerprint(status2, root) {
|
|
|
41244
41406
|
const path2 = statusPath(record);
|
|
41245
41407
|
if (path2 === null) return "";
|
|
41246
41408
|
try {
|
|
41247
|
-
const info = await lstat2(
|
|
41409
|
+
const info = await lstat2(join32(root, path2));
|
|
41248
41410
|
return `${info.size}:${info.mtimeMs}:${info.ctimeMs}`;
|
|
41249
41411
|
} catch {
|
|
41250
41412
|
return "absent";
|
|
@@ -41280,7 +41442,7 @@ async function readWorktreeSnapshot(exec4, cwd, baseline, measured) {
|
|
|
41280
41442
|
"-c",
|
|
41281
41443
|
"core.quotePath=false"
|
|
41282
41444
|
]),
|
|
41283
|
-
|
|
41445
|
+
hardenedGitExecOptions(directory)
|
|
41284
41446
|
);
|
|
41285
41447
|
return result2.status !== null && statuses.includes(result2.status) ? result2.stdout : void 0;
|
|
41286
41448
|
} catch {
|
|
@@ -41298,9 +41460,10 @@ async function readWorktreeSnapshot(exec4, cwd, baseline, measured) {
|
|
|
41298
41460
|
"--no-renames"
|
|
41299
41461
|
]);
|
|
41300
41462
|
const stateBefore = await worktreeFingerprint(await readStatus(), root);
|
|
41301
|
-
const [headRaw, remote, untracked] = await Promise.all([
|
|
41463
|
+
const [headRaw, remote, remotes, untracked] = await Promise.all([
|
|
41302
41464
|
read2(["rev-parse", "HEAD"]),
|
|
41303
41465
|
read2(["remote", "get-url", "origin"]),
|
|
41466
|
+
read2(["remote", "-v"]),
|
|
41304
41467
|
read2(["ls-files", "--others", "--exclude-standard", "-z"])
|
|
41305
41468
|
]);
|
|
41306
41469
|
const head2 = headRaw?.trim();
|
|
@@ -41351,7 +41514,7 @@ async function readWorktreeSnapshot(exec4, cwd, baseline, measured) {
|
|
|
41351
41514
|
}
|
|
41352
41515
|
let present;
|
|
41353
41516
|
try {
|
|
41354
|
-
present = (await lstat2(
|
|
41517
|
+
present = (await lstat2(join32(root, path2))).isFile();
|
|
41355
41518
|
} catch {
|
|
41356
41519
|
present = false;
|
|
41357
41520
|
}
|
|
@@ -41424,6 +41587,7 @@ async function readWorktreeSnapshot(exec4, cwd, baseline, measured) {
|
|
|
41424
41587
|
version: 1,
|
|
41425
41588
|
root,
|
|
41426
41589
|
repository: remote ? safeRepositoryUrl(remote) : null,
|
|
41590
|
+
repositories: remoteRepositories(remote, remotes),
|
|
41427
41591
|
baseline: base2,
|
|
41428
41592
|
head: head2 && HASH.test(head2) ? head2 : null,
|
|
41429
41593
|
patch,
|
|
@@ -41453,10 +41617,10 @@ var init_worktree_snapshot = __esm({
|
|
|
41453
41617
|
});
|
|
41454
41618
|
|
|
41455
41619
|
// ../../packages/tacho/src/collector/git-lane.ts
|
|
41456
|
-
import { join as
|
|
41620
|
+
import { join as join33 } from "node:path";
|
|
41457
41621
|
function copiesDirOf(root, session) {
|
|
41458
41622
|
const uuid = session.recorder.sessionUuid;
|
|
41459
|
-
return /^[0-9a-f-]{36}$/i.test(uuid) ?
|
|
41623
|
+
return /^[0-9a-f-]{36}$/i.test(uuid) ? join33(root, uuid) : void 0;
|
|
41460
41624
|
}
|
|
41461
41625
|
function holdsBaseline(session) {
|
|
41462
41626
|
return session.baselineCommit !== void 0 || Object.keys(session.baselines ?? {}).length > 0;
|
|
@@ -41465,6 +41629,11 @@ function startedAtOf(session, at2) {
|
|
|
41465
41629
|
const started = Date.parse(session.startedAt);
|
|
41466
41630
|
return Number.isFinite(started) ? Math.min(started, at2) : at2;
|
|
41467
41631
|
}
|
|
41632
|
+
function lastRootOf(session) {
|
|
41633
|
+
if (session.baselineRoot !== void 0) return session.baselineRoot;
|
|
41634
|
+
const roots = Object.keys(session.baselines ?? {});
|
|
41635
|
+
return roots[roots.length - 1];
|
|
41636
|
+
}
|
|
41468
41637
|
function createGitLane(deps) {
|
|
41469
41638
|
const {
|
|
41470
41639
|
registry: registry2,
|
|
@@ -41493,6 +41662,13 @@ function createGitLane(deps) {
|
|
|
41493
41662
|
const GIT_READS_PER_TICK = 4;
|
|
41494
41663
|
const RECONCILE_MIN_INTERVAL_MS = 15e3;
|
|
41495
41664
|
const lastReconcileAt = /* @__PURE__ */ new Map();
|
|
41665
|
+
const MAX_OTHER_ROOTS_PER_READ = 4;
|
|
41666
|
+
const reconciledHeads = /* @__PURE__ */ new Map();
|
|
41667
|
+
function noteReconciledHead(sessionUuid2, root, head2) {
|
|
41668
|
+
const heads = reconciledHeads.get(sessionUuid2) ?? /* @__PURE__ */ new Map();
|
|
41669
|
+
heads.set(root, head2);
|
|
41670
|
+
reconciledHeads.set(sessionUuid2, heads);
|
|
41671
|
+
}
|
|
41496
41672
|
const gitReadEligibleAt = /* @__PURE__ */ new Map();
|
|
41497
41673
|
function gitReadDue(sessionUuid2) {
|
|
41498
41674
|
if (pendingSessionEnds.has(sessionUuid2)) return true;
|
|
@@ -41520,6 +41696,11 @@ function createGitLane(deps) {
|
|
|
41520
41696
|
for (const [sessionUuid2, last] of lastReconcileAt)
|
|
41521
41697
|
if (at2 - last >= RECONCILE_MIN_INTERVAL_MS)
|
|
41522
41698
|
lastReconcileAt.delete(sessionUuid2);
|
|
41699
|
+
for (const sessionUuid2 of reconciledHeads.keys()) {
|
|
41700
|
+
const session = registry2.byUuid(sessionUuid2);
|
|
41701
|
+
if (session === void 0 || session.sealed)
|
|
41702
|
+
reconciledHeads.delete(sessionUuid2);
|
|
41703
|
+
}
|
|
41523
41704
|
}
|
|
41524
41705
|
function putBack(read2) {
|
|
41525
41706
|
const sessionUuid2 = read2.session.recorder.sessionUuid;
|
|
@@ -41573,6 +41754,7 @@ function createGitLane(deps) {
|
|
|
41573
41754
|
const dir = session?.workDir ?? session?.cwd;
|
|
41574
41755
|
if (session === void 0 || session.sealed || dir === void 0 || ending?.terminal !== void 0) {
|
|
41575
41756
|
lastReconcileAt.delete(sessionUuid2);
|
|
41757
|
+
reconciledHeads.delete(sessionUuid2);
|
|
41576
41758
|
if (ending !== void 0) await settleEnding(ending, sessionUuid2);
|
|
41577
41759
|
return void 0;
|
|
41578
41760
|
}
|
|
@@ -41609,7 +41791,7 @@ function createGitLane(deps) {
|
|
|
41609
41791
|
priorReconcileAt
|
|
41610
41792
|
}) {
|
|
41611
41793
|
const copies = copiesDirOf(preSessionCopies, session);
|
|
41612
|
-
const root = await readGitRoot(execAsync, dir);
|
|
41794
|
+
const root = await readGitRoot(execAsync, dir) ?? await rootOutside(session, dir);
|
|
41613
41795
|
const cwd = root ?? dir;
|
|
41614
41796
|
const facts = await gitFactsFor(cwd, force);
|
|
41615
41797
|
if (session.gitFirstReadAt === void 0 && !holdsBaseline(session))
|
|
@@ -41642,15 +41824,56 @@ function createGitLane(deps) {
|
|
|
41642
41824
|
// so no reconciliation frame is sealed for it. A frame saying the
|
|
41643
41825
|
// worktree was clean is a claim, and nobody made the observation
|
|
41644
41826
|
// behind it.
|
|
41645
|
-
...due ? await readReconciliation(
|
|
41646
|
-
|
|
41827
|
+
...due ? await readReconciliation(
|
|
41828
|
+
session,
|
|
41829
|
+
cwd,
|
|
41830
|
+
session.baselineCommit,
|
|
41831
|
+
copies
|
|
41832
|
+
) : {},
|
|
41833
|
+
// Only beside a root with git facts: `applyRead` notes each other
|
|
41834
|
+
// root's context to seal its frame, then notes this root's again, and
|
|
41835
|
+
// without facts there is nothing to note back.
|
|
41836
|
+
others: due && root !== void 0 && facts !== void 0 ? await readOtherRoots(session, root, copies) : []
|
|
41837
|
+
};
|
|
41838
|
+
}
|
|
41839
|
+
async function rootOutside(session, dir) {
|
|
41840
|
+
const last = lastRootOf(session);
|
|
41841
|
+
if (last !== void 0) {
|
|
41842
|
+
const root = await readGitRoot(execAsync, last);
|
|
41843
|
+
if (root !== void 0) return root;
|
|
41844
|
+
}
|
|
41845
|
+
if (session.cwd === void 0 || session.cwd === dir) return void 0;
|
|
41846
|
+
return readGitRoot(execAsync, session.cwd);
|
|
41847
|
+
}
|
|
41848
|
+
async function readOtherRoots(session, current, copies) {
|
|
41849
|
+
const heads = reconciledHeads.get(session.recorder.sessionUuid);
|
|
41850
|
+
const roots = Object.keys(session.baselines ?? {}).filter((root) => root !== current).reverse();
|
|
41851
|
+
const out = [];
|
|
41852
|
+
for (const root of roots) {
|
|
41853
|
+
if (out.length >= MAX_OTHER_ROOTS_PER_READ) break;
|
|
41854
|
+
const head2 = firstLine(
|
|
41855
|
+
await git2(execAsync, root, ["rev-parse", "HEAD"])
|
|
41856
|
+
);
|
|
41857
|
+
if (head2 === void 0 || heads?.get(root) === head2) continue;
|
|
41858
|
+
const facts = await gitFactsFor(root, true);
|
|
41859
|
+
if (facts === void 0) continue;
|
|
41860
|
+
const found = await readReconciliation(
|
|
41861
|
+
session,
|
|
41862
|
+
root,
|
|
41863
|
+
session.baselines?.[root],
|
|
41864
|
+
copies
|
|
41865
|
+
);
|
|
41866
|
+
if (found.reading === void 0) continue;
|
|
41867
|
+
out.push({ root, facts, ...found, reading: found.reading });
|
|
41868
|
+
}
|
|
41869
|
+
return out;
|
|
41647
41870
|
}
|
|
41648
|
-
async function readReconciliation(session, cwd, copies) {
|
|
41871
|
+
async function readReconciliation(session, cwd, baseline, copies) {
|
|
41649
41872
|
const reading = await readSessionChanges(
|
|
41650
41873
|
execAsync,
|
|
41651
41874
|
cwd,
|
|
41652
41875
|
{
|
|
41653
|
-
baseline
|
|
41876
|
+
baseline,
|
|
41654
41877
|
firstReadAt: session.gitFirstReadAt,
|
|
41655
41878
|
ownCommits: session.sessionCommits?.[cwd],
|
|
41656
41879
|
commitFacts: session.sessionCommitFacts?.[cwd],
|
|
@@ -41662,12 +41885,7 @@ function createGitLane(deps) {
|
|
|
41662
41885
|
const [snapshot, commits] = await Promise.all([
|
|
41663
41886
|
// Each path's hunk against what its row was counted from,
|
|
41664
41887
|
// so the patch and the rows describe one change.
|
|
41665
|
-
readWorktreeSnapshot(
|
|
41666
|
-
execAsync,
|
|
41667
|
-
cwd,
|
|
41668
|
-
session.baselineCommit,
|
|
41669
|
-
reading.measured
|
|
41670
|
-
),
|
|
41888
|
+
readWorktreeSnapshot(execAsync, cwd, baseline, reading.measured),
|
|
41671
41889
|
// The commits the rule counted, which the frame seals so
|
|
41672
41890
|
// the control plane can credit each to this run
|
|
41673
41891
|
// (ADR-297). A read on the old measure counted none.
|
|
@@ -41692,6 +41910,7 @@ function createGitLane(deps) {
|
|
|
41692
41910
|
reading,
|
|
41693
41911
|
snapshot,
|
|
41694
41912
|
commits,
|
|
41913
|
+
others,
|
|
41695
41914
|
ending
|
|
41696
41915
|
}) {
|
|
41697
41916
|
if (session.sealed) return false;
|
|
@@ -41703,28 +41922,54 @@ function createGitLane(deps) {
|
|
|
41703
41922
|
});
|
|
41704
41923
|
return false;
|
|
41705
41924
|
}
|
|
41706
|
-
|
|
41707
|
-
|
|
41708
|
-
...gitContextOf(facts),
|
|
41709
|
-
worktree_path: cwd
|
|
41710
|
-
});
|
|
41925
|
+
const context = facts === void 0 ? void 0 : { ...gitContextOf(facts), worktree_path: cwd };
|
|
41926
|
+
if (context !== void 0) session.recorder.noteContext(context);
|
|
41711
41927
|
if (reading !== void 0) {
|
|
41712
41928
|
recordReconciliation(session, reading, snapshot, commits);
|
|
41713
|
-
|
|
41714
|
-
|
|
41715
|
-
|
|
41716
|
-
|
|
41717
|
-
|
|
41718
|
-
|
|
41719
|
-
|
|
41720
|
-
|
|
41721
|
-
|
|
41722
|
-
|
|
41723
|
-
|
|
41724
|
-
|
|
41929
|
+
rememberReading(session, cwd, reading, facts?.head_sha);
|
|
41930
|
+
}
|
|
41931
|
+
if (context !== void 0 && others.length > 0) {
|
|
41932
|
+
try {
|
|
41933
|
+
for (const other of others) {
|
|
41934
|
+
session.recorder.noteContext({
|
|
41935
|
+
...gitContextOf(other.facts),
|
|
41936
|
+
worktree_path: other.root
|
|
41937
|
+
});
|
|
41938
|
+
recordReconciliation(
|
|
41939
|
+
session,
|
|
41940
|
+
other.reading,
|
|
41941
|
+
other.snapshot,
|
|
41942
|
+
other.commits
|
|
41943
|
+
);
|
|
41944
|
+
rememberReading(
|
|
41945
|
+
session,
|
|
41946
|
+
other.root,
|
|
41947
|
+
other.reading,
|
|
41948
|
+
other.facts.head_sha
|
|
41949
|
+
);
|
|
41950
|
+
}
|
|
41951
|
+
} finally {
|
|
41952
|
+
session.recorder.noteContext(context);
|
|
41953
|
+
}
|
|
41725
41954
|
}
|
|
41726
41955
|
return ending !== void 0 && pendingSessionEnds.get(session.recorder.sessionUuid) === ending;
|
|
41727
41956
|
}
|
|
41957
|
+
function rememberReading(session, root, reading, head2) {
|
|
41958
|
+
if (head2 !== void 0)
|
|
41959
|
+
noteReconciledHead(session.recorder.sessionUuid, root, head2);
|
|
41960
|
+
if (reading.ownCommits.length > 0 || session.sessionCommits?.[root] !== void 0)
|
|
41961
|
+
session.sessionCommits = rememberForRoot(
|
|
41962
|
+
session.sessionCommits,
|
|
41963
|
+
root,
|
|
41964
|
+
reading.ownCommits
|
|
41965
|
+
);
|
|
41966
|
+
if (reading.commitFacts.merges.length > 0 || Object.keys(reading.commitFacts.tests).length > 0 || session.sessionCommitFacts?.[root] !== void 0)
|
|
41967
|
+
session.sessionCommitFacts = rememberForRoot(
|
|
41968
|
+
session.sessionCommitFacts,
|
|
41969
|
+
root,
|
|
41970
|
+
reading.commitFacts
|
|
41971
|
+
);
|
|
41972
|
+
}
|
|
41728
41973
|
function recordReconciliation(session, reading, snapshot, commits) {
|
|
41729
41974
|
const mark = session.recorder.markChain();
|
|
41730
41975
|
try {
|
|
@@ -41747,6 +41992,10 @@ function createGitLane(deps) {
|
|
|
41747
41992
|
...snapshot ? {
|
|
41748
41993
|
worktree_root: snapshot.root,
|
|
41749
41994
|
...snapshot.repository ? { repository_url: snapshot.repository } : {},
|
|
41995
|
+
// Every remote, so ingest can still find the linked
|
|
41996
|
+
// repository when `origin` is a mirror (#5915). A comma
|
|
41997
|
+
// never appears in a URL `safeRepositoryUrl` keeps.
|
|
41998
|
+
...snapshot.repositories !== void 0 && snapshot.repositories.length > 1 ? { repository_urls: snapshot.repositories.join(",") } : {},
|
|
41750
41999
|
...snapshot.baseline ? { diff_base_sha: snapshot.baseline } : {},
|
|
41751
42000
|
...snapshot.head ? { diff_head_sha: snapshot.head } : {},
|
|
41752
42001
|
diff_complete: String(snapshot.complete),
|
|
@@ -42255,7 +42504,7 @@ var init_interjection2 = __esm({
|
|
|
42255
42504
|
});
|
|
42256
42505
|
|
|
42257
42506
|
// ../../packages/tacho/src/collector/recall-hints.ts
|
|
42258
|
-
import { isAbsolute as isAbsolute6, relative as relative4, resolve as
|
|
42507
|
+
import { isAbsolute as isAbsolute6, relative as relative4, resolve as resolve11, sep as sep4 } from "node:path";
|
|
42259
42508
|
function retryDelay(failures) {
|
|
42260
42509
|
return Math.min(
|
|
42261
42510
|
REPOSITORY_RETRY_FIRST_MS * 2 ** (failures - 1),
|
|
@@ -42291,7 +42540,7 @@ function noteRecallHints(record, toolName3, toolInput) {
|
|
|
42291
42540
|
const value = toolInput?.[key];
|
|
42292
42541
|
if (typeof value !== "string" || value.length === 0) continue;
|
|
42293
42542
|
const cwd = record.cwd;
|
|
42294
|
-
const absolute = isAbsolute6(value) ?
|
|
42543
|
+
const absolute = isAbsolute6(value) ? resolve11(value) : cwd !== void 0 && isAbsolute6(cwd) ? resolve11(cwd, value) : void 0;
|
|
42295
42544
|
if (absolute !== void 0)
|
|
42296
42545
|
hints.paths = inFront(hints.paths, absolute, RECALL_PATHS_KEPT);
|
|
42297
42546
|
}
|
|
@@ -42405,7 +42654,7 @@ var init_policy_run = __esm({
|
|
|
42405
42654
|
|
|
42406
42655
|
// ../../packages/tacho/src/collector/hook-handler.ts
|
|
42407
42656
|
import { homedir as homedir4 } from "node:os";
|
|
42408
|
-
import { dirname as
|
|
42657
|
+
import { dirname as dirname18, isAbsolute as isAbsolute7 } from "node:path";
|
|
42409
42658
|
function containmentUnmet(view, record) {
|
|
42410
42659
|
return view.verified && view.bundle.mode === "enforce" && view.bundle.containment?.required === true && view.launchedContained?.(record.harnessSessionId) !== true;
|
|
42411
42660
|
}
|
|
@@ -43346,7 +43595,7 @@ async function routeHook(raw, env, deps, replay, harness, agent, hookId) {
|
|
|
43346
43595
|
}
|
|
43347
43596
|
function writtenDir(input) {
|
|
43348
43597
|
const path2 = writtenPath(input);
|
|
43349
|
-
return path2 === void 0 ? void 0 :
|
|
43598
|
+
return path2 === void 0 ? void 0 : dirname18(path2);
|
|
43350
43599
|
}
|
|
43351
43600
|
function writtenPath(input) {
|
|
43352
43601
|
if (input.hook_event_name !== "PreToolUse" && input.hook_event_name !== "PostToolUse")
|
|
@@ -43488,7 +43737,7 @@ var init_steer_waiters = __esm({
|
|
|
43488
43737
|
const session = this.deps.find(key);
|
|
43489
43738
|
if (session !== void 0 && (session.sealed || session.pendingTerminal === true))
|
|
43490
43739
|
return Promise.resolve({ done: true });
|
|
43491
|
-
return new Promise((
|
|
43740
|
+
return new Promise((resolve24) => {
|
|
43492
43741
|
let settled2 = false;
|
|
43493
43742
|
const timer = setTimeout(() => waiter.settle({ wait: true }), this.holdMs);
|
|
43494
43743
|
timer.unref?.();
|
|
@@ -43503,7 +43752,7 @@ var init_steer_waiters = __esm({
|
|
|
43503
43752
|
clearTimeout(timer);
|
|
43504
43753
|
signal.removeEventListener("abort", onAbort);
|
|
43505
43754
|
if (this.waiting.get(key) === waiter) this.waiting.delete(key);
|
|
43506
|
-
|
|
43755
|
+
resolve24(answer);
|
|
43507
43756
|
}
|
|
43508
43757
|
};
|
|
43509
43758
|
if (signal.aborted) {
|
|
@@ -43572,7 +43821,7 @@ var init_steer_waiters = __esm({
|
|
|
43572
43821
|
});
|
|
43573
43822
|
|
|
43574
43823
|
// ../../packages/tacho/src/collector/hook-id-journal.ts
|
|
43575
|
-
import { appendFileSync as appendFileSync3, existsSync as existsSync18, readFileSync as
|
|
43824
|
+
import { appendFileSync as appendFileSync3, existsSync as existsSync18, readFileSync as readFileSync17, rmSync as rmSync7 } from "node:fs";
|
|
43576
43825
|
function hookIdJournalEntry(session, key, at2, events) {
|
|
43577
43826
|
const highest = /* @__PURE__ */ new Map();
|
|
43578
43827
|
for (const event of events) {
|
|
@@ -43599,7 +43848,7 @@ function isEntry(value) {
|
|
|
43599
43848
|
function readHookIdJournal(path2) {
|
|
43600
43849
|
if (!existsSync18(path2)) return [];
|
|
43601
43850
|
const entries2 = [];
|
|
43602
|
-
for (const line of
|
|
43851
|
+
for (const line of readFileSync17(path2, "utf8").split("\n")) {
|
|
43603
43852
|
if (line.trim().length === 0) continue;
|
|
43604
43853
|
try {
|
|
43605
43854
|
const value = JSON.parse(line);
|
|
@@ -44068,9 +44317,9 @@ var init_inbox = __esm({
|
|
|
44068
44317
|
|
|
44069
44318
|
// ../../packages/tacho/src/collector/gateway-frame.ts
|
|
44070
44319
|
function gatewayFrameBody(call2) {
|
|
44071
|
-
const
|
|
44320
|
+
const refused2 = call2.status === "rejected";
|
|
44072
44321
|
return {
|
|
44073
|
-
kind:
|
|
44322
|
+
kind: refused2 ? "policy_decision" : "tool_call",
|
|
44074
44323
|
body: {
|
|
44075
44324
|
tool_name: call2.toolName,
|
|
44076
44325
|
tool_source: "mcp",
|
|
@@ -44086,7 +44335,7 @@ function gatewayFrameBody(call2) {
|
|
|
44086
44335
|
tool_output_digest: call2.outputDigest,
|
|
44087
44336
|
tool_output_bytes: call2.outputBytes
|
|
44088
44337
|
},
|
|
44089
|
-
...
|
|
44338
|
+
...refused2 ? {
|
|
44090
44339
|
policy_decision: "deny",
|
|
44091
44340
|
policy_source: "kernel",
|
|
44092
44341
|
policy_reason_code: "mcp_refused",
|
|
@@ -44118,7 +44367,7 @@ function recordOnChain(chain, seal2, record) {
|
|
|
44118
44367
|
}
|
|
44119
44368
|
function onSessionQueue(exclusive, session, apply) {
|
|
44120
44369
|
if (exclusive !== void 0) return exclusive(session, apply);
|
|
44121
|
-
return new Promise((
|
|
44370
|
+
return new Promise((resolve24) => resolve24(apply()));
|
|
44122
44371
|
}
|
|
44123
44372
|
var init_chain_write = __esm({
|
|
44124
44373
|
"../../packages/tacho/src/collector/chain-write.ts"() {
|
|
@@ -44130,7 +44379,7 @@ var init_chain_write = __esm({
|
|
|
44130
44379
|
import { randomBytes as randomBytes10, createHash as createHash9 } from "node:crypto";
|
|
44131
44380
|
import { Readable } from "node:stream";
|
|
44132
44381
|
import { pipeline } from "node:stream/promises";
|
|
44133
|
-
import { resolve as
|
|
44382
|
+
import { resolve as resolve12 } from "node:path";
|
|
44134
44383
|
function logLine(event, fields) {
|
|
44135
44384
|
const pairs = Object.entries(fields).filter(
|
|
44136
44385
|
(field) => field[1] !== void 0
|
|
@@ -44227,7 +44476,7 @@ function createGithubProxy(deps) {
|
|
|
44227
44476
|
}
|
|
44228
44477
|
function receiptMatches(host, repository, cwd, harness) {
|
|
44229
44478
|
return cwd !== void 0 && (host.github_repositories ?? []).some(
|
|
44230
|
-
(receipt) => receipt.repository.toLowerCase() === repository.toLowerCase() &&
|
|
44479
|
+
(receipt) => receipt.repository.toLowerCase() === repository.toLowerCase() && resolve12(receipt.cwd) === resolve12(cwd) && receipt.harness === harness
|
|
44231
44480
|
);
|
|
44232
44481
|
}
|
|
44233
44482
|
function issue(input) {
|
|
@@ -44258,7 +44507,7 @@ function createGithubProxy(deps) {
|
|
|
44258
44507
|
}
|
|
44259
44508
|
};
|
|
44260
44509
|
const matches = deps.registry.live().filter(
|
|
44261
|
-
(s2) => !s2.pendingTerminal && s2.cwd &&
|
|
44510
|
+
(s2) => !s2.pendingTerminal && s2.cwd && resolve12(s2.cwd) === resolve12(input.cwd) && deps.registry.agentOf(s2).harness === input.harness
|
|
44262
44511
|
);
|
|
44263
44512
|
if (matches.length !== 1)
|
|
44264
44513
|
return {
|
|
@@ -44724,7 +44973,7 @@ var init_hook_queues = __esm({
|
|
|
44724
44973
|
|
|
44725
44974
|
// ../../packages/tacho/src/collector/memory-capture/memory-reader.ts
|
|
44726
44975
|
import { createRequire as createRequire2 } from "node:module";
|
|
44727
|
-
import { isAbsolute as isAbsolute8, join as
|
|
44976
|
+
import { isAbsolute as isAbsolute8, join as join34, sep as sep5 } from "node:path";
|
|
44728
44977
|
function claudeCodeLocation(projectsDir, memoryDir) {
|
|
44729
44978
|
return {
|
|
44730
44979
|
harness: "claude-code",
|
|
@@ -44736,13 +44985,13 @@ function claudeCodeLocation(projectsDir, memoryDir) {
|
|
|
44736
44985
|
}
|
|
44737
44986
|
function claudeCodeMemoryLocations(configDir, projectDirs = []) {
|
|
44738
44987
|
const locations = [
|
|
44739
|
-
claudeCodeLocation(() =>
|
|
44740
|
-
claudeCodeLocation(() =>
|
|
44988
|
+
claudeCodeLocation(() => join34(configDir, "projects"), "memory"),
|
|
44989
|
+
claudeCodeLocation(() => join34(configDir, "agent-memory"), "")
|
|
44741
44990
|
];
|
|
44742
44991
|
for (const dir of projectDirs.slice(0, MEMORY_PROJECT_DIRS_MAX))
|
|
44743
44992
|
locations.push(
|
|
44744
|
-
claudeCodeLocation(() =>
|
|
44745
|
-
claudeCodeLocation(() =>
|
|
44993
|
+
claudeCodeLocation(() => join34(dir, ".claude", "agent-memory"), ""),
|
|
44994
|
+
claudeCodeLocation(() => join34(dir, ".claude", "agent-memory-local"), "")
|
|
44746
44995
|
);
|
|
44747
44996
|
return locations;
|
|
44748
44997
|
}
|
|
@@ -44927,13 +45176,13 @@ function createMemoryReader(deps) {
|
|
|
44927
45176
|
const projects = await list2(top);
|
|
44928
45177
|
let complete = projects.complete;
|
|
44929
45178
|
for (const project2 of projects.names) {
|
|
44930
|
-
const dir = location.memoryDir === "" ?
|
|
45179
|
+
const dir = location.memoryDir === "" ? join34(top, project2) : join34(top, project2, location.memoryDir);
|
|
44931
45180
|
const files2 = await list2(dir);
|
|
44932
45181
|
if (!files2.complete) complete = false;
|
|
44933
45182
|
for (const name of files2.names) {
|
|
44934
45183
|
if (!name.endsWith(location.extension)) continue;
|
|
44935
45184
|
if (location.skip.includes(name)) continue;
|
|
44936
|
-
const path2 =
|
|
45185
|
+
const path2 = join34(dir, name);
|
|
44937
45186
|
const file = await readAt2(location.harness, path2);
|
|
44938
45187
|
if (file.kind === "absent" || file.kind === "empty") continue;
|
|
44939
45188
|
paths.push(path2);
|
|
@@ -45019,8 +45268,8 @@ var init_memory_reader = __esm({
|
|
|
45019
45268
|
MEMORY_TYPE_PATTERN = /^[a-z][a-z0-9_-]{0,31}$/;
|
|
45020
45269
|
MEMORY_PROJECT_DIRS_MAX = 200;
|
|
45021
45270
|
HARNESS_MEMORY_LOCATIONS = [
|
|
45022
|
-
claudeCodeLocation((home) =>
|
|
45023
|
-
claudeCodeLocation((home) =>
|
|
45271
|
+
claudeCodeLocation((home) => join34(home, ".claude", "projects"), "memory"),
|
|
45272
|
+
claudeCodeLocation((home) => join34(home, ".claude", "agent-memory"), "")
|
|
45024
45273
|
];
|
|
45025
45274
|
FRONTMATTER = /^---[ \t]*\r?\n(?:([\s\S]*?)\r?\n)?---[ \t]*(?:\r?\n|$)/;
|
|
45026
45275
|
FRONTMATTER_LINE = /^([ \t]*)([A-Za-z_][\w-]*)[ \t]*:[ \t]*(.*)$/;
|
|
@@ -45462,10 +45711,10 @@ function createMemoryRecall(deps) {
|
|
|
45462
45711
|
if (now() < pausedUntil) return [];
|
|
45463
45712
|
const controller = new AbortController();
|
|
45464
45713
|
let timer;
|
|
45465
|
-
const timedOut = new Promise((
|
|
45714
|
+
const timedOut = new Promise((resolve24) => {
|
|
45466
45715
|
timer = setTimeout(() => {
|
|
45467
45716
|
controller.abort();
|
|
45468
|
-
|
|
45717
|
+
resolve24(
|
|
45469
45718
|
failed3(
|
|
45470
45719
|
`the control plane took longer than ${timeoutMs} ms to answer`
|
|
45471
45720
|
)
|
|
@@ -45512,27 +45761,27 @@ var init_memory_recall = __esm({
|
|
|
45512
45761
|
});
|
|
45513
45762
|
|
|
45514
45763
|
// ../../packages/tacho/src/collector/memory-capture/memory-uses.ts
|
|
45515
|
-
import { basename as basename6, dirname as
|
|
45764
|
+
import { basename as basename6, dirname as dirname19, isAbsolute as isAbsolute9, join as join35, resolve as resolve13 } from "node:path";
|
|
45516
45765
|
function memoryFileOf(path2, locations, home) {
|
|
45517
45766
|
if (!isAbsolute9(path2)) return void 0;
|
|
45518
|
-
const file =
|
|
45767
|
+
const file = resolve13(path2);
|
|
45519
45768
|
const name = basename6(file);
|
|
45520
|
-
const folder =
|
|
45769
|
+
const folder = dirname19(file);
|
|
45521
45770
|
for (const location of locations) {
|
|
45522
45771
|
if (!name.endsWith(location.extension)) continue;
|
|
45523
45772
|
if (location.skip.includes(name)) continue;
|
|
45524
|
-
const projectDir = location.memoryDir === "" ? folder :
|
|
45773
|
+
const projectDir = location.memoryDir === "" ? folder : dirname19(folder);
|
|
45525
45774
|
if (location.memoryDir !== "" && basename6(folder) !== location.memoryDir)
|
|
45526
45775
|
continue;
|
|
45527
|
-
if (
|
|
45776
|
+
if (dirname19(projectDir) !== resolve13(location.projectsDir(home))) continue;
|
|
45528
45777
|
return { harness: location.harness, path: file };
|
|
45529
45778
|
}
|
|
45530
45779
|
return void 0;
|
|
45531
45780
|
}
|
|
45532
45781
|
function pathOf(word, cwd, home) {
|
|
45533
|
-
const expanded = /^(?:~|\$HOME|\$\{HOME\})\//.test(word) ?
|
|
45782
|
+
const expanded = /^(?:~|\$HOME|\$\{HOME\})\//.test(word) ? join35(home, word.slice(word.indexOf("/") + 1)) : word;
|
|
45534
45783
|
if (isAbsolute9(expanded)) return expanded;
|
|
45535
|
-
if (cwd !== void 0 && isAbsolute9(cwd)) return
|
|
45784
|
+
if (cwd !== void 0 && isAbsolute9(cwd)) return resolve13(cwd, expanded);
|
|
45536
45785
|
return void 0;
|
|
45537
45786
|
}
|
|
45538
45787
|
function stringMember(input, key) {
|
|
@@ -45786,7 +46035,7 @@ ${use.path}`;
|
|
|
45786
46035
|
});
|
|
45787
46036
|
|
|
45788
46037
|
// ../../packages/tacho/src/collector/memory-capture/stella-store.ts
|
|
45789
|
-
import { dirname as
|
|
46038
|
+
import { dirname as dirname20, isAbsolute as isAbsolute10, join as join36, resolve as resolve14 } from "node:path";
|
|
45790
46039
|
function queryStellaStore(path2, afterSeq, limit) {
|
|
45791
46040
|
const db = new (nodeSqlite()).DatabaseSync(path2, { readOnly: true });
|
|
45792
46041
|
try {
|
|
@@ -45874,11 +46123,11 @@ function stellaRunOf(use, runs, now) {
|
|
|
45874
46123
|
}
|
|
45875
46124
|
async function stellaStoreOf(dir, exists) {
|
|
45876
46125
|
if (!isAbsolute10(dir)) return void 0;
|
|
45877
|
-
let at2 =
|
|
46126
|
+
let at2 = resolve14(dir);
|
|
45878
46127
|
for (let depth = 0; depth < WORKSPACE_SEARCH_DEPTH; depth += 1) {
|
|
45879
|
-
const candidate =
|
|
46128
|
+
const candidate = join36(at2, STELLA_CONTEXT_DB);
|
|
45880
46129
|
if (await exists(candidate)) return candidate;
|
|
45881
|
-
const up =
|
|
46130
|
+
const up = dirname20(at2);
|
|
45882
46131
|
if (up === at2) return void 0;
|
|
45883
46132
|
at2 = up;
|
|
45884
46133
|
}
|
|
@@ -45889,7 +46138,7 @@ var init_stella_store = __esm({
|
|
|
45889
46138
|
"../../packages/tacho/src/collector/memory-capture/stella-store.ts"() {
|
|
45890
46139
|
"use strict";
|
|
45891
46140
|
init_memory_reader();
|
|
45892
|
-
STELLA_CONTEXT_DB =
|
|
46141
|
+
STELLA_CONTEXT_DB = join36(".stella", "private", "context.db");
|
|
45893
46142
|
STELLA_MEMORIES_VIEW = "export_memories_v1";
|
|
45894
46143
|
STELLA_USES_VIEW = "export_memory_uses_v1";
|
|
45895
46144
|
STELLA_USES_PER_READ = 5e3;
|
|
@@ -46551,7 +46800,7 @@ var init_cloud_link = __esm({
|
|
|
46551
46800
|
|
|
46552
46801
|
// ../../packages/tacho/src/collector/local-servers/digest.ts
|
|
46553
46802
|
import { createHash as createHash10 } from "node:crypto";
|
|
46554
|
-
import { join as
|
|
46803
|
+
import { join as join37 } from "node:path";
|
|
46555
46804
|
function rememberBounded(map, key, value) {
|
|
46556
46805
|
if (!map.has(key) && map.size >= MAX_REMEMBERED_DIGESTS) {
|
|
46557
46806
|
const oldest = map.keys().next();
|
|
@@ -46588,7 +46837,7 @@ function npmNameSegment(name) {
|
|
|
46588
46837
|
return name.startsWith("@") ? `@${encodeURIComponent(name.slice(1))}` : encodeURIComponent(name);
|
|
46589
46838
|
}
|
|
46590
46839
|
async function whichOnPath(command2, pathValue, search) {
|
|
46591
|
-
const candidates = command2.includes("/") || command2.includes("\\") ? [command2] : (pathValue ?? "").split(search.delimiter).filter((dir) => dir.length > 0).map((dir) =>
|
|
46840
|
+
const candidates = command2.includes("/") || command2.includes("\\") ? [command2] : (pathValue ?? "").split(search.delimiter).filter((dir) => dir.length > 0).map((dir) => join37(dir, command2));
|
|
46592
46841
|
for (const candidate of candidates) {
|
|
46593
46842
|
for (const extension of search.extensions) {
|
|
46594
46843
|
if (await search.isExecutable(candidate + extension))
|
|
@@ -47226,8 +47475,8 @@ async function withSession(options, work) {
|
|
|
47226
47475
|
if (failure4 !== void 0) return Promise.reject(failure4);
|
|
47227
47476
|
const id2 = nextId;
|
|
47228
47477
|
nextId += 1;
|
|
47229
|
-
return new Promise((
|
|
47230
|
-
pending.set(id2, { method, resolve:
|
|
47478
|
+
return new Promise((resolve24, reject) => {
|
|
47479
|
+
pending.set(id2, { method, resolve: resolve24, reject });
|
|
47231
47480
|
send5({ id: id2, method, params });
|
|
47232
47481
|
});
|
|
47233
47482
|
}
|
|
@@ -47371,16 +47620,16 @@ var init_screen = __esm({
|
|
|
47371
47620
|
|
|
47372
47621
|
// ../../packages/tacho/src/collector/local-servers/local-servers.ts
|
|
47373
47622
|
function abortableSleep(ms, signal) {
|
|
47374
|
-
return new Promise((
|
|
47623
|
+
return new Promise((resolve24) => {
|
|
47375
47624
|
if (signal.aborted) {
|
|
47376
|
-
|
|
47625
|
+
resolve24();
|
|
47377
47626
|
return;
|
|
47378
47627
|
}
|
|
47379
47628
|
const timer = setTimeout(done, ms);
|
|
47380
47629
|
function done() {
|
|
47381
47630
|
clearTimeout(timer);
|
|
47382
47631
|
signal.removeEventListener("abort", done);
|
|
47383
|
-
|
|
47632
|
+
resolve24();
|
|
47384
47633
|
}
|
|
47385
47634
|
signal.addEventListener("abort", done, { once: true });
|
|
47386
47635
|
});
|
|
@@ -47412,7 +47661,7 @@ function createLocalServers(options) {
|
|
|
47412
47661
|
} catch {
|
|
47413
47662
|
}
|
|
47414
47663
|
}
|
|
47415
|
-
function
|
|
47664
|
+
function refused2(id2, refusal, toolsChanged = false) {
|
|
47416
47665
|
options.log(`The local gateway refused ${id2}. ${refusalText(refusal)}`);
|
|
47417
47666
|
return {
|
|
47418
47667
|
kind: "refused",
|
|
@@ -47446,7 +47695,7 @@ function createLocalServers(options) {
|
|
|
47446
47695
|
now: now(),
|
|
47447
47696
|
skewMs
|
|
47448
47697
|
});
|
|
47449
|
-
if (!check2.ok) return
|
|
47698
|
+
if (!check2.ok) return refused2(envelope2.nonce, check2.refusal);
|
|
47450
47699
|
const launch = await launchFor(delivery.launch, signal);
|
|
47451
47700
|
const result2 = await callTool(
|
|
47452
47701
|
{
|
|
@@ -47496,8 +47745,8 @@ function createLocalServers(options) {
|
|
|
47496
47745
|
return delivery.kind === "call" ? await runCall(delivery, signal, notice) : await runDiscover(delivery, signal);
|
|
47497
47746
|
} catch (error) {
|
|
47498
47747
|
if (error instanceof LocalServerError)
|
|
47499
|
-
return
|
|
47500
|
-
return
|
|
47748
|
+
return refused2(id2, error.refusal(), notice.toolsChanged);
|
|
47749
|
+
return refused2(
|
|
47501
47750
|
id2,
|
|
47502
47751
|
serverFailed(
|
|
47503
47752
|
delivery.launch.server,
|
|
@@ -47708,7 +47957,7 @@ var init_machine = __esm({
|
|
|
47708
47957
|
});
|
|
47709
47958
|
|
|
47710
47959
|
// ../../packages/tacho/src/collector/push-basis.ts
|
|
47711
|
-
import { resolve as
|
|
47960
|
+
import { resolve as resolve15 } from "node:path";
|
|
47712
47961
|
function gitPushTarget(command2) {
|
|
47713
47962
|
const tokens = tokenizeSimpleCommand(command2);
|
|
47714
47963
|
if (tokens === void 0 || tokens[0] !== "git") return void 0;
|
|
@@ -47755,7 +48004,7 @@ async function pushCredentialBasis(command2, cwd, deps) {
|
|
|
47755
48004
|
return TACHO_CREDENTIAL_HARNESS_HELD;
|
|
47756
48005
|
const target2 = gitPushTarget(command2);
|
|
47757
48006
|
if (target2 === void 0) return TACHO_CREDENTIAL_HARNESS_HELD;
|
|
47758
|
-
const dir = target2.chdir.reduce((from, to) =>
|
|
48007
|
+
const dir = target2.chdir.reduce((from, to) => resolve15(from, to), cwd);
|
|
47759
48008
|
const receipt = receiptFor(receipts, dir);
|
|
47760
48009
|
if (receipt === void 0) return TACHO_CREDENTIAL_HARNESS_HELD;
|
|
47761
48010
|
const remote = target2.remote ?? await defaultPushRemote(dir, deps);
|
|
@@ -47769,7 +48018,7 @@ function receiptFor(receipts, dir) {
|
|
|
47769
48018
|
let found;
|
|
47770
48019
|
let depth = -1;
|
|
47771
48020
|
for (const entry2 of receipts) {
|
|
47772
|
-
const root =
|
|
48021
|
+
const root = resolve15(entry2.cwd);
|
|
47773
48022
|
if (!isWithin(root, dir) || root.length <= depth) continue;
|
|
47774
48023
|
found = entry2;
|
|
47775
48024
|
depth = root.length;
|
|
@@ -47786,7 +48035,7 @@ async function containedPushBasis(command2, cwd, repository, deps) {
|
|
|
47786
48035
|
const target2 = gitPushTarget(command2);
|
|
47787
48036
|
if (cwd === void 0 || target2 === void 0)
|
|
47788
48037
|
return TACHO_CREDENTIAL_HARNESS_HELD;
|
|
47789
|
-
const dir = target2.chdir.reduce((from, to) =>
|
|
48038
|
+
const dir = target2.chdir.reduce((from, to) => resolve15(from, to), cwd);
|
|
47790
48039
|
if (!isWithin(cwd, dir)) return TACHO_CREDENTIAL_HARNESS_HELD;
|
|
47791
48040
|
const remote = target2.remote ?? await defaultPushRemote(dir, deps);
|
|
47792
48041
|
const urls = await pushUrls(dir, remote, deps);
|
|
@@ -47794,9 +48043,11 @@ async function containedPushBasis(command2, cwd, repository, deps) {
|
|
|
47794
48043
|
return urls.length > 0 && urls.every((url) => githubRepositoryOf(url) === wanted) ? TACHO_CREDENTIAL_GATEWAY_BROKERED : TACHO_CREDENTIAL_HARNESS_HELD;
|
|
47795
48044
|
}
|
|
47796
48045
|
async function gitOut(dir, args, deps) {
|
|
47797
|
-
const result2 = await deps.execAsync(
|
|
47798
|
-
|
|
47799
|
-
|
|
48046
|
+
const result2 = await deps.execAsync(
|
|
48047
|
+
"git",
|
|
48048
|
+
hardenedGitArgs(dir, args),
|
|
48049
|
+
hardenedGitExecOptions(dir)
|
|
48050
|
+
);
|
|
47800
48051
|
return result2.status === 0 ? result2.stdout.trim() : void 0;
|
|
47801
48052
|
}
|
|
47802
48053
|
async function defaultPushRemote(dir, deps) {
|
|
@@ -47882,9 +48133,9 @@ import {
|
|
|
47882
48133
|
writeFile
|
|
47883
48134
|
} from "node:fs/promises";
|
|
47884
48135
|
import { homedir as homedir5 } from "node:os";
|
|
47885
|
-
import { dirname as
|
|
48136
|
+
import { dirname as dirname21, join as join38 } from "node:path";
|
|
47886
48137
|
function stagingFolder(root, name) {
|
|
47887
|
-
return
|
|
48138
|
+
return join38(root, `.${name}${STAGING_SUFFIX}`);
|
|
47888
48139
|
}
|
|
47889
48140
|
function isStagingName(name) {
|
|
47890
48141
|
return name.startsWith(".") && name.endsWith(STAGING_SUFFIX);
|
|
@@ -47927,17 +48178,17 @@ function envDir(env, key) {
|
|
|
47927
48178
|
function skillsRoot(harness, env = process.env, home = homedir5()) {
|
|
47928
48179
|
switch (harness) {
|
|
47929
48180
|
case "claude-code":
|
|
47930
|
-
return
|
|
47931
|
-
envDir(env, "CLAUDE_CONFIG_DIR") ??
|
|
48181
|
+
return join38(
|
|
48182
|
+
envDir(env, "CLAUDE_CONFIG_DIR") ?? join38(home, ".claude"),
|
|
47932
48183
|
"skills"
|
|
47933
48184
|
);
|
|
47934
48185
|
case "codex": {
|
|
47935
48186
|
const codexHome = envDir(env, "CODEX_HOME");
|
|
47936
|
-
return codexHome === null ?
|
|
48187
|
+
return codexHome === null ? join38(home, ".agents", "skills") : join38(codexHome, "skills");
|
|
47937
48188
|
}
|
|
47938
48189
|
case "stella":
|
|
47939
|
-
return
|
|
47940
|
-
envDir(env, "STELLA_HOME") ??
|
|
48190
|
+
return join38(
|
|
48191
|
+
envDir(env, "STELLA_HOME") ?? join38(home, ".stella"),
|
|
47941
48192
|
"skills"
|
|
47942
48193
|
);
|
|
47943
48194
|
case "cursor":
|
|
@@ -47998,7 +48249,7 @@ async function readMarker(folder) {
|
|
|
47998
48249
|
if (!entries2.includes(SESSION_MARKER)) return { state: "foreign" };
|
|
47999
48250
|
try {
|
|
48000
48251
|
const parsed2 = JSON.parse(
|
|
48001
|
-
await readFile2(
|
|
48252
|
+
await readFile2(join38(folder, SESSION_MARKER), "utf8")
|
|
48002
48253
|
);
|
|
48003
48254
|
return isMarker(parsed2) ? { state: "ours", marker: parsed2 } : { state: "foreign" };
|
|
48004
48255
|
} catch {
|
|
@@ -48015,23 +48266,23 @@ function liveSessions(marker, now) {
|
|
|
48015
48266
|
return live;
|
|
48016
48267
|
}
|
|
48017
48268
|
async function writeMarker(folder, marker) {
|
|
48018
|
-
const temp =
|
|
48269
|
+
const temp = join38(folder, MARKER_TEMP);
|
|
48019
48270
|
await writeFile(temp, `${JSON.stringify(marker, null, 2)}
|
|
48020
48271
|
`);
|
|
48021
|
-
await rename2(temp,
|
|
48272
|
+
await rename2(temp, join38(folder, SESSION_MARKER));
|
|
48022
48273
|
}
|
|
48023
48274
|
async function writeSkill(root, skill, marker) {
|
|
48024
|
-
const folder =
|
|
48275
|
+
const folder = join38(root, skill.name);
|
|
48025
48276
|
const staging = stagingFolder(root, skill.name);
|
|
48026
48277
|
await rm2(folder, { recursive: true, force: true });
|
|
48027
48278
|
await rm2(staging, { recursive: true, force: true });
|
|
48028
48279
|
await mkdir2(staging);
|
|
48029
48280
|
await writeMarker(staging, { digest: UNFINISHED_DIGEST, sessions: {} });
|
|
48030
48281
|
await rename2(staging, folder);
|
|
48031
|
-
await writeFile(
|
|
48282
|
+
await writeFile(join38(folder, "SKILL.md"), skillMarkdown(skill));
|
|
48032
48283
|
for (const file of skill.files) {
|
|
48033
|
-
const target2 =
|
|
48034
|
-
await mkdir2(
|
|
48284
|
+
const target2 = join38(folder, file.path);
|
|
48285
|
+
await mkdir2(dirname21(target2), { recursive: true });
|
|
48035
48286
|
await writeFile(target2, file.content);
|
|
48036
48287
|
}
|
|
48037
48288
|
await writeMarker(folder, marker);
|
|
@@ -48059,7 +48310,7 @@ async function placeSkills(root, sessionId, skills, now = /* @__PURE__ */ new Da
|
|
|
48059
48310
|
result2.warnings.push(refusal);
|
|
48060
48311
|
continue;
|
|
48061
48312
|
}
|
|
48062
|
-
const folder =
|
|
48313
|
+
const folder = join38(root, skill.name);
|
|
48063
48314
|
if (taken.has(skill.name)) {
|
|
48064
48315
|
result2.skipped.push(skill.name);
|
|
48065
48316
|
result2.warnings.push(
|
|
@@ -48124,7 +48375,7 @@ async function removeSkills(root, sessionId, now = /* @__PURE__ */ new Date()) {
|
|
|
48124
48375
|
throw error;
|
|
48125
48376
|
}
|
|
48126
48377
|
for (const name of names2.sort(compareText)) {
|
|
48127
|
-
const folder =
|
|
48378
|
+
const folder = join38(root, name);
|
|
48128
48379
|
if (isStagingName(name)) {
|
|
48129
48380
|
await rm2(folder, { recursive: true, force: true });
|
|
48130
48381
|
continue;
|
|
@@ -48201,15 +48452,15 @@ function sessionSkills(options) {
|
|
|
48201
48452
|
async function inTurn(task) {
|
|
48202
48453
|
const before = tail;
|
|
48203
48454
|
let release2 = () => void 0;
|
|
48204
|
-
const mine = new Promise((
|
|
48205
|
-
release2 =
|
|
48455
|
+
const mine = new Promise((resolve24) => {
|
|
48456
|
+
release2 = resolve24;
|
|
48206
48457
|
});
|
|
48207
48458
|
tail = before.then(() => mine);
|
|
48208
|
-
const turn = await new Promise((
|
|
48209
|
-
const timer = setTimeout(() =>
|
|
48459
|
+
const turn = await new Promise((resolve24) => {
|
|
48460
|
+
const timer = setTimeout(() => resolve24(false), waitMs);
|
|
48210
48461
|
void before.then(() => {
|
|
48211
48462
|
clearTimeout(timer);
|
|
48212
|
-
|
|
48463
|
+
resolve24(true);
|
|
48213
48464
|
});
|
|
48214
48465
|
});
|
|
48215
48466
|
try {
|
|
@@ -49536,10 +49787,10 @@ async function readableBody(body2, encoding, maxOutputLength) {
|
|
|
49536
49787
|
if (decode === void 0) return void 0;
|
|
49537
49788
|
try {
|
|
49538
49789
|
return await new Promise(
|
|
49539
|
-
(
|
|
49790
|
+
(resolve24, reject) => decode(
|
|
49540
49791
|
body2,
|
|
49541
49792
|
{ maxOutputLength },
|
|
49542
|
-
(error, result2) => error === null ?
|
|
49793
|
+
(error, result2) => error === null ? resolve24(result2) : reject(error)
|
|
49543
49794
|
)
|
|
49544
49795
|
);
|
|
49545
49796
|
} catch {
|
|
@@ -49628,7 +49879,7 @@ function createModelProxy(deps) {
|
|
|
49628
49879
|
const observed = /* @__PURE__ */ new Map();
|
|
49629
49880
|
const priors = new RequestPrefixMemory();
|
|
49630
49881
|
let callsObserved = 0;
|
|
49631
|
-
let
|
|
49882
|
+
let refused2 = 0;
|
|
49632
49883
|
retireIdleSockets(httpAgent);
|
|
49633
49884
|
retireIdleSockets(httpsAgent);
|
|
49634
49885
|
const upstreamConnectMs = deps.upstreamConnectMs ?? DEFAULT_UPSTREAM_CONNECT_MS;
|
|
@@ -49984,7 +50235,7 @@ function createModelProxy(deps) {
|
|
|
49984
50235
|
res.end(error.body);
|
|
49985
50236
|
}
|
|
49986
50237
|
function readBody3(req, attempt) {
|
|
49987
|
-
return new Promise((
|
|
50238
|
+
return new Promise((resolve24, reject) => {
|
|
49988
50239
|
const chunks = [];
|
|
49989
50240
|
let size = 0;
|
|
49990
50241
|
let over = false;
|
|
@@ -49995,13 +50246,13 @@ function createModelProxy(deps) {
|
|
|
49995
50246
|
if (size > maxRequestBytes) {
|
|
49996
50247
|
over = true;
|
|
49997
50248
|
chunks.length = 0;
|
|
49998
|
-
|
|
50249
|
+
resolve24("too_large");
|
|
49999
50250
|
return;
|
|
50000
50251
|
}
|
|
50001
50252
|
chunks.push(chunk2);
|
|
50002
50253
|
});
|
|
50003
50254
|
req.on("end", () => {
|
|
50004
|
-
if (!over)
|
|
50255
|
+
if (!over) resolve24(Buffer.concat(chunks));
|
|
50005
50256
|
});
|
|
50006
50257
|
req.on("error", reject);
|
|
50007
50258
|
req.on("aborted", () => reject(new Error("client aborted the request")));
|
|
@@ -50012,12 +50263,12 @@ function createModelProxy(deps) {
|
|
|
50012
50263
|
if (hook === void 0) return request3;
|
|
50013
50264
|
let timer;
|
|
50014
50265
|
try {
|
|
50015
|
-
const timeout = new Promise((
|
|
50266
|
+
const timeout = new Promise((resolve24) => {
|
|
50016
50267
|
timer = setTimeout(() => {
|
|
50017
50268
|
deps.log(
|
|
50018
50269
|
`model proxy: beforeForward took over ${hookTimeoutMs}ms, sending the request as it came`
|
|
50019
50270
|
);
|
|
50020
|
-
|
|
50271
|
+
resolve24(request3);
|
|
50021
50272
|
}, hookTimeoutMs);
|
|
50022
50273
|
});
|
|
50023
50274
|
return await Promise.race([Promise.resolve(hook(request3)), timeout]);
|
|
@@ -50042,7 +50293,7 @@ function createModelProxy(deps) {
|
|
|
50042
50293
|
const secure = target2.protocol === "https:";
|
|
50043
50294
|
const sessionKey = record.recorder.sessionUuid;
|
|
50044
50295
|
const startedAt = deps.now();
|
|
50045
|
-
return new Promise((
|
|
50296
|
+
return new Promise((resolve24) => {
|
|
50046
50297
|
let done = false;
|
|
50047
50298
|
let answered = false;
|
|
50048
50299
|
let upstream;
|
|
@@ -50063,7 +50314,7 @@ function createModelProxy(deps) {
|
|
|
50063
50314
|
if (done) return;
|
|
50064
50315
|
done = true;
|
|
50065
50316
|
release2();
|
|
50066
|
-
|
|
50317
|
+
resolve24(outcome);
|
|
50067
50318
|
};
|
|
50068
50319
|
try {
|
|
50069
50320
|
upstream = (secure ? httpsRequest : httpRequest2)({
|
|
@@ -50336,7 +50587,7 @@ function createModelProxy(deps) {
|
|
|
50336
50587
|
status: credentialRefusalStatus(credential.refusal.code)
|
|
50337
50588
|
} : void 0);
|
|
50338
50589
|
if (refusal !== void 0) {
|
|
50339
|
-
|
|
50590
|
+
refused2 += 1;
|
|
50340
50591
|
const view = deps.policy();
|
|
50341
50592
|
const mark = recorder.markChain();
|
|
50342
50593
|
try {
|
|
@@ -50987,7 +51238,7 @@ function createModelProxy(deps) {
|
|
|
50987
51238
|
stats: () => {
|
|
50988
51239
|
let open6 = 0;
|
|
50989
51240
|
for (const calls of inFlight.values()) open6 += calls.size;
|
|
50990
|
-
return { callsObserved, refused, inFlight: open6 };
|
|
51241
|
+
return { callsObserved, refused: refused2, inFlight: open6 };
|
|
50991
51242
|
},
|
|
50992
51243
|
close: () => {
|
|
50993
51244
|
clearInterval(keepAliveTimer);
|
|
@@ -51103,9 +51354,9 @@ function createModelProxyListener(options) {
|
|
|
51103
51354
|
retryTimer.unref();
|
|
51104
51355
|
}
|
|
51105
51356
|
function bind() {
|
|
51106
|
-
return new Promise((
|
|
51357
|
+
return new Promise((resolve24) => {
|
|
51107
51358
|
if (closed2) {
|
|
51108
|
-
|
|
51359
|
+
resolve24();
|
|
51109
51360
|
return;
|
|
51110
51361
|
}
|
|
51111
51362
|
const next = createServer4((req, res) => options.proxy.handle(req, res));
|
|
@@ -51146,7 +51397,7 @@ function createModelProxyListener(options) {
|
|
|
51146
51397
|
scheduleRebind();
|
|
51147
51398
|
if (!settledOnce) {
|
|
51148
51399
|
settledOnce = true;
|
|
51149
|
-
|
|
51400
|
+
resolve24();
|
|
51150
51401
|
}
|
|
51151
51402
|
});
|
|
51152
51403
|
next.on("close", () => {
|
|
@@ -51165,7 +51416,7 @@ function createModelProxyListener(options) {
|
|
|
51165
51416
|
options.log(`model proxy listening on 127.0.0.1:${boundPort}`);
|
|
51166
51417
|
if (!settledOnce) {
|
|
51167
51418
|
settledOnce = true;
|
|
51168
|
-
|
|
51419
|
+
resolve24();
|
|
51169
51420
|
}
|
|
51170
51421
|
});
|
|
51171
51422
|
});
|
|
@@ -51182,8 +51433,8 @@ function createModelProxyListener(options) {
|
|
|
51182
51433
|
server = void 0;
|
|
51183
51434
|
bound = false;
|
|
51184
51435
|
if (current === void 0) return;
|
|
51185
|
-
await new Promise((
|
|
51186
|
-
current.close(() =>
|
|
51436
|
+
await new Promise((resolve24) => {
|
|
51437
|
+
current.close(() => resolve24());
|
|
51187
51438
|
current.closeAllConnections?.();
|
|
51188
51439
|
});
|
|
51189
51440
|
}
|
|
@@ -51202,14 +51453,14 @@ var init_model_proxy_listener = __esm({
|
|
|
51202
51453
|
import {
|
|
51203
51454
|
createServer as createServer5
|
|
51204
51455
|
} from "node:http";
|
|
51205
|
-
import { chmodSync as chmodSync9, existsSync as existsSync19, statSync as
|
|
51456
|
+
import { chmodSync as chmodSync9, existsSync as existsSync19, statSync as statSync10, unlinkSync as unlinkSync11 } from "node:fs";
|
|
51206
51457
|
import { randomBytes as randomBytes11, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
|
|
51207
51458
|
import { createConnection } from "node:net";
|
|
51208
51459
|
function isExportFormat(value) {
|
|
51209
51460
|
return EXPORT_FORMATS.includes(value);
|
|
51210
51461
|
}
|
|
51211
51462
|
function readBody(req) {
|
|
51212
|
-
return new Promise((
|
|
51463
|
+
return new Promise((resolve24, reject) => {
|
|
51213
51464
|
const chunks = [];
|
|
51214
51465
|
let size = 0;
|
|
51215
51466
|
let overflowed = false;
|
|
@@ -51224,7 +51475,7 @@ function readBody(req) {
|
|
|
51224
51475
|
}
|
|
51225
51476
|
chunks.push(chunk2);
|
|
51226
51477
|
});
|
|
51227
|
-
req.on("end", () =>
|
|
51478
|
+
req.on("end", () => resolve24(Buffer.concat(chunks).toString("utf8")));
|
|
51228
51479
|
req.on("error", reject);
|
|
51229
51480
|
});
|
|
51230
51481
|
}
|
|
@@ -51567,24 +51818,24 @@ function createRequestHandler(api, log, options = {}) {
|
|
|
51567
51818
|
}
|
|
51568
51819
|
async function removeStaleSocket(socketPath) {
|
|
51569
51820
|
if (!existsSync19(socketPath)) return;
|
|
51570
|
-
if (!
|
|
51821
|
+
if (!statSync10(socketPath).isSocket()) {
|
|
51571
51822
|
throw new Error(`collector socket path is not a socket: ${socketPath}`);
|
|
51572
51823
|
}
|
|
51573
|
-
const stale = await new Promise((
|
|
51824
|
+
const stale = await new Promise((resolve24, reject) => {
|
|
51574
51825
|
const probe = createConnection(socketPath);
|
|
51575
51826
|
probe.once("connect", () => {
|
|
51576
51827
|
probe.destroy();
|
|
51577
|
-
|
|
51828
|
+
resolve24(false);
|
|
51578
51829
|
});
|
|
51579
51830
|
probe.once("error", (error) => {
|
|
51580
51831
|
probe.destroy();
|
|
51581
51832
|
if (error.code === "ECONNREFUSED" || error.code === "ENOENT")
|
|
51582
|
-
|
|
51833
|
+
resolve24(true);
|
|
51583
51834
|
else reject(error);
|
|
51584
51835
|
});
|
|
51585
51836
|
probe.setTimeout(500, () => {
|
|
51586
51837
|
probe.destroy();
|
|
51587
|
-
|
|
51838
|
+
resolve24(false);
|
|
51588
51839
|
});
|
|
51589
51840
|
});
|
|
51590
51841
|
if (!stale)
|
|
@@ -51613,8 +51864,8 @@ function createCollectorServer(api, log = () => void 0) {
|
|
|
51613
51864
|
const close = async () => {
|
|
51614
51865
|
await Promise.all(
|
|
51615
51866
|
servers.map(
|
|
51616
|
-
(server) => new Promise((
|
|
51617
|
-
server.close(() =>
|
|
51867
|
+
(server) => new Promise((resolve24) => {
|
|
51868
|
+
server.close(() => resolve24());
|
|
51618
51869
|
server.closeAllConnections?.();
|
|
51619
51870
|
})
|
|
51620
51871
|
)
|
|
@@ -51629,11 +51880,11 @@ function createCollectorServer(api, log = () => void 0) {
|
|
|
51629
51880
|
let boundPort = options.port;
|
|
51630
51881
|
const tcp = createServer5((req, res) => handle(req, res, boundPort));
|
|
51631
51882
|
servers.push(tcp);
|
|
51632
|
-
await new Promise((
|
|
51883
|
+
await new Promise((resolve24, reject) => {
|
|
51633
51884
|
tcp.once("error", reject);
|
|
51634
51885
|
tcp.listen(options.port, options.host ?? "127.0.0.1", () => {
|
|
51635
51886
|
tcp.off("error", reject);
|
|
51636
|
-
|
|
51887
|
+
resolve24();
|
|
51637
51888
|
});
|
|
51638
51889
|
});
|
|
51639
51890
|
const address = tcp.address();
|
|
@@ -51644,11 +51895,11 @@ function createCollectorServer(api, log = () => void 0) {
|
|
|
51644
51895
|
await removeStaleSocket(options.socketPath);
|
|
51645
51896
|
const unix = createServer5((req, res) => handle(req, res));
|
|
51646
51897
|
servers.push(unix);
|
|
51647
|
-
await new Promise((
|
|
51898
|
+
await new Promise((resolve24, reject) => {
|
|
51648
51899
|
unix.once("error", reject);
|
|
51649
51900
|
unix.listen(options.socketPath, () => {
|
|
51650
51901
|
unix.off("error", reject);
|
|
51651
|
-
|
|
51902
|
+
resolve24();
|
|
51652
51903
|
});
|
|
51653
51904
|
});
|
|
51654
51905
|
chmodSync9(options.socketPath, 384);
|
|
@@ -51735,8 +51986,8 @@ var init_server = __esm({
|
|
|
51735
51986
|
});
|
|
51736
51987
|
|
|
51737
51988
|
// ../../packages/tacho/src/collector/spool.ts
|
|
51738
|
-
import { existsSync as existsSync20, readFileSync as
|
|
51739
|
-
import { join as
|
|
51989
|
+
import { existsSync as existsSync20, readFileSync as readFileSync18 } from "node:fs";
|
|
51990
|
+
import { join as join39 } from "node:path";
|
|
51740
51991
|
function sessionOwnedElsewhere(error) {
|
|
51741
51992
|
return error.status === 403 && error.body.includes(SESSION_OWNED_ELSEWHERE);
|
|
51742
51993
|
}
|
|
@@ -51930,7 +52181,7 @@ var init_spool = __esm({
|
|
|
51930
52181
|
* gone for good.
|
|
51931
52182
|
*/
|
|
51932
52183
|
stash(event, reason3, body2) {
|
|
51933
|
-
const path2 =
|
|
52184
|
+
const path2 = join39(
|
|
51934
52185
|
this.options.quarantineDir,
|
|
51935
52186
|
`${event.session_uuid}-${String(event.seq).padStart(8, "0")}.json`
|
|
51936
52187
|
);
|
|
@@ -51948,12 +52199,12 @@ var init_spool = __esm({
|
|
|
51948
52199
|
}
|
|
51949
52200
|
/** Add a body to a quarantine record that was written without one. */
|
|
51950
52201
|
stashBodyBeside(event, body2) {
|
|
51951
|
-
const path2 =
|
|
52202
|
+
const path2 = join39(
|
|
51952
52203
|
this.options.quarantineDir,
|
|
51953
52204
|
`${event.session_uuid}-${String(event.seq).padStart(8, "0")}.json`
|
|
51954
52205
|
);
|
|
51955
52206
|
try {
|
|
51956
|
-
const record = JSON.parse(
|
|
52207
|
+
const record = JSON.parse(readFileSync18(path2, "utf8"));
|
|
51957
52208
|
if (record["body"] !== void 0) return;
|
|
51958
52209
|
writeSensitiveFileAtomic(
|
|
51959
52210
|
path2,
|
|
@@ -52144,25 +52395,25 @@ var init_spool = __esm({
|
|
|
52144
52395
|
* so a session found in one half is not sent again in the other.
|
|
52145
52396
|
*/
|
|
52146
52397
|
async shipBatch(batch, bodies) {
|
|
52147
|
-
const
|
|
52398
|
+
const refused2 = batch.filter(
|
|
52148
52399
|
(e) => this.foreignSessions.has(e.session_uuid)
|
|
52149
52400
|
);
|
|
52150
|
-
if (
|
|
52151
|
-
for (const event of
|
|
52401
|
+
if (refused2.length === 0) return this.sendBatch(batch, bodies);
|
|
52402
|
+
for (const event of refused2)
|
|
52152
52403
|
this.stash(event, `control plane holds session under another host`);
|
|
52153
|
-
this.markShipped(
|
|
52404
|
+
this.markShipped(refused2);
|
|
52154
52405
|
this.options.log(
|
|
52155
|
-
`quarantined ${
|
|
52406
|
+
`quarantined ${refused2.length} event(s) from session(s) the control plane holds under another host`
|
|
52156
52407
|
);
|
|
52157
52408
|
const rest = batch.filter((e) => !this.foreignSessions.has(e.session_uuid));
|
|
52158
52409
|
if (rest.length === 0)
|
|
52159
52410
|
return {
|
|
52160
52411
|
shipped: 0,
|
|
52161
|
-
quarantined:
|
|
52412
|
+
quarantined: refused2.length,
|
|
52162
52413
|
reachable: this.reachable
|
|
52163
52414
|
};
|
|
52164
52415
|
const result2 = await this.sendBatch(rest, bodies);
|
|
52165
|
-
return { ...result2, quarantined: result2.quarantined +
|
|
52416
|
+
return { ...result2, quarantined: result2.quarantined + refused2.length };
|
|
52166
52417
|
}
|
|
52167
52418
|
/** Halve a refused batch and ship each half, stopping at the first that stalls. */
|
|
52168
52419
|
async bisect(batch, bodies) {
|
|
@@ -52478,15 +52729,15 @@ var init_session_heads = __esm({
|
|
|
52478
52729
|
import {
|
|
52479
52730
|
existsSync as existsSync21,
|
|
52480
52731
|
readdirSync as readdirSync12,
|
|
52481
|
-
readFileSync as
|
|
52732
|
+
readFileSync as readFileSync19,
|
|
52482
52733
|
renameSync as renameSync4,
|
|
52483
|
-
statSync as
|
|
52734
|
+
statSync as statSync11,
|
|
52484
52735
|
unlinkSync as unlinkSync12
|
|
52485
52736
|
} from "node:fs";
|
|
52486
52737
|
import { readdir as readdir3, readFile as readFile3, stat as stat2 } from "node:fs/promises";
|
|
52487
52738
|
import { homedir as homedir7, hostname as osHostname2 } from "node:os";
|
|
52488
|
-
import { dirname as
|
|
52489
|
-
import {
|
|
52739
|
+
import { dirname as dirname22, join as join40 } from "node:path";
|
|
52740
|
+
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
52490
52741
|
function cloudGatewayUpstreams(origin = CLOUD_GATEWAY_ORIGIN) {
|
|
52491
52742
|
const base2 = new URL(origin).origin;
|
|
52492
52743
|
const openai = `${base2}${CLOUD_GATEWAY_BASE_PATH}/openai/v1`;
|
|
@@ -52541,28 +52792,6 @@ function defaultExec(command2, args) {
|
|
|
52541
52792
|
stderr: result2.stderr ?? ""
|
|
52542
52793
|
};
|
|
52543
52794
|
}
|
|
52544
|
-
function defaultExecAsync(command2, args, options) {
|
|
52545
|
-
return new Promise((resolve23) => {
|
|
52546
|
-
execFile4(
|
|
52547
|
-
command2,
|
|
52548
|
-
args,
|
|
52549
|
-
{
|
|
52550
|
-
encoding: "utf8",
|
|
52551
|
-
maxBuffer: 4 * 1024 * 1024,
|
|
52552
|
-
timeout: 1e4,
|
|
52553
|
-
...options?.env !== void 0 ? { env: { ...process.env, ...options.env } } : {}
|
|
52554
|
-
},
|
|
52555
|
-
(error, stdout, stderr) => {
|
|
52556
|
-
const code = error?.code;
|
|
52557
|
-
resolve23({
|
|
52558
|
-
status: error === null ? 0 : typeof code === "number" ? code : 1,
|
|
52559
|
-
stdout: stdout ?? "",
|
|
52560
|
-
stderr: stderr ?? ""
|
|
52561
|
-
});
|
|
52562
|
-
}
|
|
52563
|
-
);
|
|
52564
|
-
});
|
|
52565
|
-
}
|
|
52566
52795
|
function defaultKill(pid, signal) {
|
|
52567
52796
|
try {
|
|
52568
52797
|
process.kill(pid, signal);
|
|
@@ -52573,28 +52802,28 @@ function defaultKill(pid, signal) {
|
|
|
52573
52802
|
}
|
|
52574
52803
|
function settleWithin(work, ms) {
|
|
52575
52804
|
if (work === void 0) return Promise.resolve(true);
|
|
52576
|
-
return new Promise((
|
|
52577
|
-
const timer = setTimeout(() =>
|
|
52805
|
+
return new Promise((resolve24) => {
|
|
52806
|
+
const timer = setTimeout(() => resolve24(false), ms);
|
|
52578
52807
|
timer.unref();
|
|
52579
52808
|
const done = () => {
|
|
52580
52809
|
clearTimeout(timer);
|
|
52581
|
-
|
|
52810
|
+
resolve24(true);
|
|
52582
52811
|
};
|
|
52583
52812
|
work.then(done, done);
|
|
52584
52813
|
});
|
|
52585
52814
|
}
|
|
52586
52815
|
function valueWithin(work, ms) {
|
|
52587
|
-
return new Promise((
|
|
52588
|
-
const timer = setTimeout(() =>
|
|
52816
|
+
return new Promise((resolve24) => {
|
|
52817
|
+
const timer = setTimeout(() => resolve24(void 0), ms);
|
|
52589
52818
|
timer.unref();
|
|
52590
52819
|
work.then(
|
|
52591
52820
|
(value) => {
|
|
52592
52821
|
clearTimeout(timer);
|
|
52593
|
-
|
|
52822
|
+
resolve24(value);
|
|
52594
52823
|
},
|
|
52595
52824
|
() => {
|
|
52596
52825
|
clearTimeout(timer);
|
|
52597
|
-
|
|
52826
|
+
resolve24(void 0);
|
|
52598
52827
|
}
|
|
52599
52828
|
);
|
|
52600
52829
|
});
|
|
@@ -52603,15 +52832,15 @@ function olderBundle(candidate, held) {
|
|
|
52603
52832
|
return candidate.version < held.version && !(Date.parse(candidate.issued_at) > Date.parse(held.issued_at));
|
|
52604
52833
|
}
|
|
52605
52834
|
function abortableSleep2(ms, signal) {
|
|
52606
|
-
return new Promise((
|
|
52835
|
+
return new Promise((resolve24) => {
|
|
52607
52836
|
if (signal.aborted) {
|
|
52608
|
-
|
|
52837
|
+
resolve24();
|
|
52609
52838
|
return;
|
|
52610
52839
|
}
|
|
52611
52840
|
const wake = () => {
|
|
52612
52841
|
clearTimeout(timer);
|
|
52613
52842
|
signal.removeEventListener("abort", wake);
|
|
52614
|
-
|
|
52843
|
+
resolve24();
|
|
52615
52844
|
};
|
|
52616
52845
|
const timer = setTimeout(wake, ms);
|
|
52617
52846
|
timer.unref();
|
|
@@ -52732,7 +52961,7 @@ async function initializeDaemon(options, server, port, ready) {
|
|
|
52732
52961
|
}) : void 0;
|
|
52733
52962
|
const memoryHome = options.home ?? homedir7();
|
|
52734
52963
|
const memoryLocations = () => claudeCodeMemoryLocations(
|
|
52735
|
-
|
|
52964
|
+
dirname22(paths.claudeProjects),
|
|
52736
52965
|
projectDirsOf(registry2.list())
|
|
52737
52966
|
);
|
|
52738
52967
|
const memoryUses = options.listen ?? true ? createMemoryUses({
|
|
@@ -52843,7 +53072,7 @@ async function initializeDaemon(options, server, port, ready) {
|
|
|
52843
53072
|
processStarts: hookProcessStarts,
|
|
52844
53073
|
adoptedChain: (sessionUuid2) => backfillLedger.chainHead(sessionUuid2)
|
|
52845
53074
|
});
|
|
52846
|
-
const priorStateWrittenAt = existsSync21(paths.daemonState) ?
|
|
53075
|
+
const priorStateWrittenAt = existsSync21(paths.daemonState) ? statSync11(paths.daemonState).mtimeMs : void 0;
|
|
52847
53076
|
const sealedState = parseSealedState(
|
|
52848
53077
|
readJsonStateFile(
|
|
52849
53078
|
paths.daemonSealedState,
|
|
@@ -52938,13 +53167,13 @@ async function initializeDaemon(options, server, port, ready) {
|
|
|
52938
53167
|
const stopping = new AbortController();
|
|
52939
53168
|
const hookExecAsync = (command2, args, execOptions) => {
|
|
52940
53169
|
if (stopping.signal.aborted) return Promise.resolve(STOPPED_EXEC);
|
|
52941
|
-
return new Promise((
|
|
52942
|
-
const abandon = () =>
|
|
53170
|
+
return new Promise((resolve24, reject) => {
|
|
53171
|
+
const abandon = () => resolve24(STOPPED_EXEC);
|
|
52943
53172
|
stopping.signal.addEventListener("abort", abandon, { once: true });
|
|
52944
53173
|
execAsync(command2, args, execOptions).then(
|
|
52945
53174
|
(result2) => {
|
|
52946
53175
|
stopping.signal.removeEventListener("abort", abandon);
|
|
52947
|
-
|
|
53176
|
+
resolve24(result2);
|
|
52948
53177
|
},
|
|
52949
53178
|
(error) => {
|
|
52950
53179
|
stopping.signal.removeEventListener("abort", abandon);
|
|
@@ -53229,7 +53458,7 @@ async function initializeDaemon(options, server, port, ready) {
|
|
|
53229
53458
|
controlReachable: lastControlAt !== void 0 && now() - lastControlAt < 2 * timers.bundleRefreshMs
|
|
53230
53459
|
};
|
|
53231
53460
|
}
|
|
53232
|
-
const bodyPurgeOwedPath =
|
|
53461
|
+
const bodyPurgeOwedPath = join40(paths.wal, "body-purge-owed");
|
|
53233
53462
|
function markBodyPurgeOwed(retention, dropped) {
|
|
53234
53463
|
try {
|
|
53235
53464
|
ensureDir(paths.wal);
|
|
@@ -53251,7 +53480,7 @@ async function initializeDaemon(options, server, port, ready) {
|
|
|
53251
53480
|
if (!existsSync21(bodyPurgeOwedPath)) return void 0;
|
|
53252
53481
|
let text5;
|
|
53253
53482
|
try {
|
|
53254
|
-
text5 =
|
|
53483
|
+
text5 = readFileSync19(bodyPurgeOwedPath, "utf8");
|
|
53255
53484
|
} catch (error) {
|
|
53256
53485
|
log(
|
|
53257
53486
|
`cannot read the owed body purge at ${bodyPurgeOwedPath}: ${error instanceof Error ? error.message : String(error)}; the retry sweeps against the clause in force. Check the file's permissions`
|
|
@@ -54004,7 +54233,7 @@ async function initializeDaemon(options, server, port, ready) {
|
|
|
54004
54233
|
async function readSpoolFile(name) {
|
|
54005
54234
|
try {
|
|
54006
54235
|
const file = parseSpoolFile(
|
|
54007
|
-
await readFile3(
|
|
54236
|
+
await readFile3(join40(paths.spool, name), "utf8")
|
|
54008
54237
|
);
|
|
54009
54238
|
spoolFacts.set(name, spoolFactsOf(file));
|
|
54010
54239
|
return file;
|
|
@@ -54027,7 +54256,9 @@ async function initializeDaemon(options, server, port, ready) {
|
|
|
54027
54256
|
}
|
|
54028
54257
|
return false;
|
|
54029
54258
|
}
|
|
54030
|
-
async function recordHookOutcome(envelope2, pendingUuid, harnessSessionId = hookInputSchema.parse(
|
|
54259
|
+
async function recordHookOutcome(envelope2, pendingUuid, harnessSessionId = hookInputSchema.parse(
|
|
54260
|
+
envelope2.payload
|
|
54261
|
+
).session_id) {
|
|
54031
54262
|
const pending = pendingUuid === void 0 ? void 0 : pendingSessionEnds.get(pendingUuid);
|
|
54032
54263
|
if (pendingUuid !== void 0 && pending?.terminal !== void 0) {
|
|
54033
54264
|
try {
|
|
@@ -54174,7 +54405,7 @@ async function initializeDaemon(options, server, port, ready) {
|
|
|
54174
54405
|
function setAsideConflictingTerminal(uuid, pending, conflict) {
|
|
54175
54406
|
const name = `${uuid}-terminal-conflict-${String(conflict.seq).padStart(8, "0")}.json`;
|
|
54176
54407
|
writeSensitiveFileAtomic(
|
|
54177
|
-
|
|
54408
|
+
join40(paths.quarantine, name),
|
|
54178
54409
|
JSON.stringify(
|
|
54179
54410
|
{
|
|
54180
54411
|
reason: conflict.message,
|
|
@@ -54254,8 +54485,8 @@ async function initializeDaemon(options, server, port, ready) {
|
|
|
54254
54485
|
function moveToFailedSpool(path2, name, reason3) {
|
|
54255
54486
|
log(`spool file ${name} moved to spool/failed/: ${reason3}`);
|
|
54256
54487
|
try {
|
|
54257
|
-
ensureDir(
|
|
54258
|
-
renameSync4(path2,
|
|
54488
|
+
ensureDir(join40(paths.spool, "failed"));
|
|
54489
|
+
renameSync4(path2, join40(paths.spool, "failed", name));
|
|
54259
54490
|
} catch (error) {
|
|
54260
54491
|
log(
|
|
54261
54492
|
`spool file ${name} could not be moved to spool/failed/: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -54308,7 +54539,7 @@ async function initializeDaemon(options, server, port, ready) {
|
|
|
54308
54539
|
continue;
|
|
54309
54540
|
}
|
|
54310
54541
|
reads += 1;
|
|
54311
|
-
const path2 =
|
|
54542
|
+
const path2 = join40(paths.spool, name);
|
|
54312
54543
|
let file;
|
|
54313
54544
|
try {
|
|
54314
54545
|
file = await readSpoolFile(name);
|
|
@@ -54593,7 +54824,7 @@ async function initializeDaemon(options, server, port, ready) {
|
|
|
54593
54824
|
const state = await readModelBaseUrlState({
|
|
54594
54825
|
home: options.home ?? homedir7(),
|
|
54595
54826
|
port: modelProxyPortFor(host),
|
|
54596
|
-
stellaHome:
|
|
54827
|
+
stellaHome: dirname22(options.paths.stellaToml),
|
|
54597
54828
|
harnesses: ["claude-code", "codex", "stella"]
|
|
54598
54829
|
});
|
|
54599
54830
|
const next = {};
|
|
@@ -55123,9 +55354,9 @@ async function initializeDaemon(options, server, port, ready) {
|
|
|
55123
55354
|
let removed = 0;
|
|
55124
55355
|
for (const name of readdirSync12(paths.quarantine)) {
|
|
55125
55356
|
if (!name.endsWith(".json")) continue;
|
|
55126
|
-
const file =
|
|
55357
|
+
const file = join40(paths.quarantine, name);
|
|
55127
55358
|
try {
|
|
55128
|
-
if (at2 -
|
|
55359
|
+
if (at2 - statSync11(file).mtimeMs < retainMs) continue;
|
|
55129
55360
|
unlinkSync12(file);
|
|
55130
55361
|
removed += 1;
|
|
55131
55362
|
} catch {
|
|
@@ -55445,7 +55676,7 @@ async function initializeDaemon(options, server, port, ready) {
|
|
|
55445
55676
|
let memoryScan;
|
|
55446
55677
|
if (options.listen ?? true) {
|
|
55447
55678
|
const codexMemories = createCodexMemoryStore({
|
|
55448
|
-
path:
|
|
55679
|
+
path: join40(dirname22(paths.codexHooks), CODEX_MEMORY_STORE_FILE),
|
|
55449
55680
|
stat: (path2) => stat2(path2),
|
|
55450
55681
|
log
|
|
55451
55682
|
});
|
|
@@ -55589,7 +55820,7 @@ async function initializeDaemon(options, server, port, ready) {
|
|
|
55589
55820
|
}
|
|
55590
55821
|
};
|
|
55591
55822
|
}
|
|
55592
|
-
var DEFAULT_TIMERS, STATIC_TOKEN_RENEWAL_CHECK_MS, MEMORY_SCAN_MS, CLOUD_GATEWAY_ORIGIN, CLOUD_GATEWAY_BASE_PATH, QUEUED_PROMPT_CLASS, RECORDER_EVENTS_KEPT, owedBodyPurgeSchema, objectSchema, spoolFileSchema, otlpResourceListSchema, otlpPayloadSchema, STOPPING, STOPPED_EXEC, STATE_WRITE_DEFER_MS;
|
|
55823
|
+
var DEFAULT_TIMERS, STATIC_TOKEN_RENEWAL_CHECK_MS, MEMORY_SCAN_MS, CLOUD_GATEWAY_ORIGIN, CLOUD_GATEWAY_BASE_PATH, QUEUED_PROMPT_CLASS, RECORDER_EVENTS_KEPT, owedBodyPurgeSchema, objectSchema, spoolFileSchema, otlpResourceListSchema, otlpPayloadSchema, defaultExecAsync, STOPPING, STOPPED_EXEC, STATE_WRITE_DEFER_MS;
|
|
55593
55824
|
var init_daemon = __esm({
|
|
55594
55825
|
"../../packages/tacho/src/collector/daemon.ts"() {
|
|
55595
55826
|
"use strict";
|
|
@@ -55625,6 +55856,7 @@ var init_daemon = __esm({
|
|
|
55625
55856
|
init_detector();
|
|
55626
55857
|
init_git_facts();
|
|
55627
55858
|
init_git_lane();
|
|
55859
|
+
init_hardened_git();
|
|
55628
55860
|
init_session_changes();
|
|
55629
55861
|
init_exporters();
|
|
55630
55862
|
init_hook_handler();
|
|
@@ -55716,6 +55948,7 @@ var init_daemon = __esm({
|
|
|
55716
55948
|
resourceSpans: otlpResourceListSchema,
|
|
55717
55949
|
resourceMetrics: otlpResourceListSchema
|
|
55718
55950
|
}).passthrough();
|
|
55951
|
+
defaultExecAsync = createGitExecAsync();
|
|
55719
55952
|
STOPPING = "tachod is stopping; tacho-hook spools this hook for the next start";
|
|
55720
55953
|
STOPPED_EXEC = {
|
|
55721
55954
|
status: null,
|
|
@@ -55727,7 +55960,7 @@ var init_daemon = __esm({
|
|
|
55727
55960
|
});
|
|
55728
55961
|
|
|
55729
55962
|
// ../../packages/tacho/src/collector/run.ts
|
|
55730
|
-
import { readFileSync as
|
|
55963
|
+
import { readFileSync as readFileSync20, unlinkSync as unlinkSync13 } from "node:fs";
|
|
55731
55964
|
function stopWithin(stop, graceMs, exit, log) {
|
|
55732
55965
|
const timer = setTimeout(() => {
|
|
55733
55966
|
log(`tachod: stop did not finish within ${graceMs} ms, exiting
|
|
@@ -55795,14 +56028,14 @@ function ownProcStart() {
|
|
|
55795
56028
|
}
|
|
55796
56029
|
function readPidFile(path2) {
|
|
55797
56030
|
try {
|
|
55798
|
-
return
|
|
56031
|
+
return readFileSync20(path2, "utf8");
|
|
55799
56032
|
} catch {
|
|
55800
56033
|
return void 0;
|
|
55801
56034
|
}
|
|
55802
56035
|
}
|
|
55803
56036
|
function releaseDaemonPid(path2, previous) {
|
|
55804
56037
|
try {
|
|
55805
|
-
if (parseDaemonPid(
|
|
56038
|
+
if (parseDaemonPid(readFileSync20(path2, "utf8"))?.pid !== process.pid) return;
|
|
55806
56039
|
if (previous === void 0) unlinkSync13(path2);
|
|
55807
56040
|
else writeSensitiveFileAtomic(path2, previous, 420);
|
|
55808
56041
|
} catch {
|
|
@@ -55944,27 +56177,27 @@ import {
|
|
|
55944
56177
|
closeSync as closeSync7,
|
|
55945
56178
|
constants as constants4,
|
|
55946
56179
|
fstatSync as fstatSync2,
|
|
55947
|
-
lstatSync as
|
|
56180
|
+
lstatSync as lstatSync8,
|
|
55948
56181
|
mkdirSync as mkdirSync6,
|
|
55949
56182
|
openSync as openSync7,
|
|
55950
56183
|
readSync as readSync4,
|
|
55951
56184
|
realpathSync as realpathSync5,
|
|
55952
56185
|
writeFileSync as writeFileSync4
|
|
55953
56186
|
} from "node:fs";
|
|
55954
|
-
import { dirname as
|
|
56187
|
+
import { dirname as dirname23, join as join41, resolve as resolve16 } from "node:path";
|
|
55955
56188
|
function bundlePath(root, relative11, create2 = false) {
|
|
55956
|
-
const absolute =
|
|
56189
|
+
const absolute = resolve16(root);
|
|
55957
56190
|
if (create2) mkdirSync6(absolute, { recursive: true, mode: 448 });
|
|
55958
|
-
if (
|
|
56191
|
+
if (lstatSync8(absolute).isSymbolicLink() || !lstatSync8(absolute).isDirectory()) {
|
|
55959
56192
|
arpFail(`The bundle root ${absolute} must be a directory, not a symlink.`);
|
|
55960
56193
|
}
|
|
55961
56194
|
const base2 = realpathSync5(absolute);
|
|
55962
56195
|
let current = base2;
|
|
55963
56196
|
const parts = relative11.split("/");
|
|
55964
56197
|
for (let i2 = 0; i2 < parts.length; i2++) {
|
|
55965
|
-
current =
|
|
56198
|
+
current = join41(current, parts[i2]);
|
|
55966
56199
|
try {
|
|
55967
|
-
const stat7 =
|
|
56200
|
+
const stat7 = lstatSync8(current);
|
|
55968
56201
|
if (stat7.isSymbolicLink() || i2 < parts.length - 1 && !stat7.isDirectory()) {
|
|
55969
56202
|
arpFail(
|
|
55970
56203
|
`The bundle path ${relative11} passes through a symlink or a file where a directory belongs.`
|
|
@@ -55976,7 +56209,7 @@ function bundlePath(root, relative11, create2 = false) {
|
|
|
55976
56209
|
else if (i2 < parts.length - 1) throw error;
|
|
55977
56210
|
}
|
|
55978
56211
|
}
|
|
55979
|
-
if (realpathSync5(
|
|
56212
|
+
if (realpathSync5(dirname23(current)) !== dirname23(current)) {
|
|
55980
56213
|
arpFail(`The bundle directory changed while ${relative11} was read.`);
|
|
55981
56214
|
}
|
|
55982
56215
|
return current;
|
|
@@ -56915,7 +57148,7 @@ import {
|
|
|
56915
57148
|
closeSync as closeSync8,
|
|
56916
57149
|
constants as constants5,
|
|
56917
57150
|
fstatSync as fstatSync3,
|
|
56918
|
-
lstatSync as
|
|
57151
|
+
lstatSync as lstatSync9,
|
|
56919
57152
|
mkdirSync as mkdirSync7,
|
|
56920
57153
|
openSync as openSync8,
|
|
56921
57154
|
readSync as readSync5,
|
|
@@ -56923,7 +57156,7 @@ import {
|
|
|
56923
57156
|
rmSync as rmSync8,
|
|
56924
57157
|
writeFileSync as writeFileSync5
|
|
56925
57158
|
} from "node:fs";
|
|
56926
|
-
import { dirname as
|
|
57159
|
+
import { dirname as dirname24, isAbsolute as isAbsolute11, join as join42, relative as relative5, resolve as resolve17, sep as sep6 } from "node:path";
|
|
56927
57160
|
function outsideProfile(path2) {
|
|
56928
57161
|
return HARNESS_CONFIG_PATH.test(path2) || CREDENTIAL_PATH.test(path2);
|
|
56929
57162
|
}
|
|
@@ -56978,10 +57211,10 @@ function within2(root, path2) {
|
|
|
56978
57211
|
return rel === "" || !isAbsolute11(rel) && rel !== ".." && !rel.startsWith(`..${sep6}`);
|
|
56979
57212
|
}
|
|
56980
57213
|
function newPath(path2) {
|
|
56981
|
-
const full =
|
|
56982
|
-
return
|
|
56983
|
-
realpathSync6(
|
|
56984
|
-
full.slice(
|
|
57214
|
+
const full = resolve17(path2);
|
|
57215
|
+
return join42(
|
|
57216
|
+
realpathSync6(dirname24(full)),
|
|
57217
|
+
full.slice(dirname24(full).length + 1)
|
|
56985
57218
|
);
|
|
56986
57219
|
}
|
|
56987
57220
|
function sourcePath(root, path2) {
|
|
@@ -56993,8 +57226,8 @@ function sourcePath(root, path2) {
|
|
|
56993
57226
|
}
|
|
56994
57227
|
let current = root;
|
|
56995
57228
|
for (const part2 of path2.split("/")) {
|
|
56996
|
-
current =
|
|
56997
|
-
if (
|
|
57229
|
+
current = join42(current, part2);
|
|
57230
|
+
if (lstatSync9(current).isSymbolicLink())
|
|
56998
57231
|
arpFail(
|
|
56999
57232
|
`${path2} is a symlink or passes through one. Symlinks require a resource adapter.`
|
|
57000
57233
|
);
|
|
@@ -57047,7 +57280,7 @@ function captureCheckpoint(options) {
|
|
|
57047
57280
|
"Pass --attest-boundary to attest that the stopped workspace matches the brief's evidence boundary."
|
|
57048
57281
|
);
|
|
57049
57282
|
const root = realpathSync6(options.workspace);
|
|
57050
|
-
if (!
|
|
57283
|
+
if (!lstatSync9(root).isDirectory())
|
|
57051
57284
|
arpFail(`The workspace ${root} is not a directory.`);
|
|
57052
57285
|
const out = newPath(options.out);
|
|
57053
57286
|
if (within2(root, out))
|
|
@@ -57260,23 +57493,23 @@ function prepareCheckpoint(options) {
|
|
|
57260
57493
|
});
|
|
57261
57494
|
mkdirSync7(destination, { mode: 448 });
|
|
57262
57495
|
try {
|
|
57263
|
-
const restored =
|
|
57496
|
+
const restored = join42(destination, "workspace");
|
|
57264
57497
|
mkdirSync7(restored, { mode: 448 });
|
|
57265
57498
|
for (const item of restore) {
|
|
57266
|
-
const path2 =
|
|
57499
|
+
const path2 = join42(restored, item.path);
|
|
57267
57500
|
if (item.kind === "directory")
|
|
57268
57501
|
mkdirSync7(path2, { recursive: true, mode: 448 });
|
|
57269
57502
|
else {
|
|
57270
|
-
mkdirSync7(
|
|
57503
|
+
mkdirSync7(dirname24(path2), { recursive: true, mode: 448 });
|
|
57271
57504
|
writeFileSync5(path2, item.bytes, {
|
|
57272
57505
|
flag: "wx",
|
|
57273
57506
|
mode: item.executable ? 448 : 384
|
|
57274
57507
|
});
|
|
57275
57508
|
}
|
|
57276
57509
|
}
|
|
57277
|
-
const promptDir =
|
|
57510
|
+
const promptDir = join42(restored, ".arp");
|
|
57278
57511
|
mkdirSync7(promptDir, { mode: 448 });
|
|
57279
|
-
const promptFile =
|
|
57512
|
+
const promptFile = join42(promptDir, "handoff.json");
|
|
57280
57513
|
const prompt = {
|
|
57281
57514
|
checkpoint_digest: checkpointDigest,
|
|
57282
57515
|
task: task.data.request,
|
|
@@ -57293,7 +57526,7 @@ function prepareCheckpoint(options) {
|
|
|
57293
57526
|
flag: "wx",
|
|
57294
57527
|
mode: 384
|
|
57295
57528
|
});
|
|
57296
|
-
const reportPath =
|
|
57529
|
+
const reportPath = join42(destination, "report.json");
|
|
57297
57530
|
writeFileSync5(
|
|
57298
57531
|
reportPath,
|
|
57299
57532
|
jcs(
|
|
@@ -57478,7 +57711,7 @@ __export(main_exports, {
|
|
|
57478
57711
|
recordedCliDeps: () => recordedCliDeps,
|
|
57479
57712
|
tokenOption: () => tokenOption
|
|
57480
57713
|
});
|
|
57481
|
-
import { readFileSync as
|
|
57714
|
+
import { readFileSync as readFileSync21 } from "node:fs";
|
|
57482
57715
|
function parsePort(value) {
|
|
57483
57716
|
const port = Number(value);
|
|
57484
57717
|
if (!/^\d+$/.test(value) || port < 1024 || port > 65535)
|
|
@@ -57515,7 +57748,7 @@ function parseOneHarness(value) {
|
|
|
57515
57748
|
throw new InvalidArgumentError("name one harness");
|
|
57516
57749
|
return harness;
|
|
57517
57750
|
}
|
|
57518
|
-
function tokenOption(opts, err2, readStdin3 = () =>
|
|
57751
|
+
function tokenOption(opts, err2, readStdin3 = () => readFileSync21(0, "utf8")) {
|
|
57519
57752
|
const flag2 = opts.token;
|
|
57520
57753
|
if (opts.tokenStdin !== true) {
|
|
57521
57754
|
if (flag2 !== void 0)
|
|
@@ -57934,7 +58167,7 @@ var init_package = __esm({
|
|
|
57934
58167
|
"package.json"() {
|
|
57935
58168
|
package_default = {
|
|
57936
58169
|
name: "@oxagen/cli",
|
|
57937
|
-
version: "2.1.4-
|
|
58170
|
+
version: "2.1.4-942",
|
|
57938
58171
|
description: "Oxagen governance CLI \u2014 spend, lineage, grounding, credentials, and audit (agentic coding lives in the stella CLI)",
|
|
57939
58172
|
type: "module",
|
|
57940
58173
|
main: "./dist/index.js",
|
|
@@ -58001,10 +58234,10 @@ var init_package = __esm({
|
|
|
58001
58234
|
|
|
58002
58235
|
// src/lib/atomic-write.ts
|
|
58003
58236
|
import { writeFileSync as writeFileSync6, renameSync as renameSync5, unlinkSync as unlinkSync14, existsSync as existsSync22 } from "node:fs";
|
|
58004
|
-
import { dirname as
|
|
58237
|
+
import { dirname as dirname25, join as join43 } from "node:path";
|
|
58005
58238
|
function atomicWriteFileSync(path2, data, mode) {
|
|
58006
|
-
const dir =
|
|
58007
|
-
const tmp =
|
|
58239
|
+
const dir = dirname25(path2);
|
|
58240
|
+
const tmp = join43(
|
|
58008
58241
|
dir,
|
|
58009
58242
|
`.${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}.tmp`
|
|
58010
58243
|
);
|
|
@@ -58029,8 +58262,8 @@ var init_atomic_write = __esm({
|
|
|
58029
58262
|
|
|
58030
58263
|
// src/lib/config.ts
|
|
58031
58264
|
import { homedir as homedir8 } from "os";
|
|
58032
|
-
import { join as
|
|
58033
|
-
import { readFileSync as
|
|
58265
|
+
import { join as join44 } from "path";
|
|
58266
|
+
import { readFileSync as readFileSync22, mkdirSync as mkdirSync8, existsSync as existsSync23, statSync as statSync12 } from "fs";
|
|
58034
58267
|
function getConfigDir() {
|
|
58035
58268
|
return CONFIG_DIR;
|
|
58036
58269
|
}
|
|
@@ -58060,7 +58293,7 @@ function parseConfig(raw) {
|
|
|
58060
58293
|
function readConfig() {
|
|
58061
58294
|
let identity;
|
|
58062
58295
|
try {
|
|
58063
|
-
const info =
|
|
58296
|
+
const info = statSync12(CONFIG_FILE);
|
|
58064
58297
|
identity = `${info.ino}:${info.size}:${info.mtimeMs}`;
|
|
58065
58298
|
} catch {
|
|
58066
58299
|
cached2 = void 0;
|
|
@@ -58068,7 +58301,7 @@ function readConfig() {
|
|
|
58068
58301
|
}
|
|
58069
58302
|
if (cached2?.identity === identity) return structuredClone(cached2.config);
|
|
58070
58303
|
try {
|
|
58071
|
-
const config = parseConfig(JSON.parse(
|
|
58304
|
+
const config = parseConfig(JSON.parse(readFileSync22(CONFIG_FILE, "utf8")));
|
|
58072
58305
|
cached2 = { identity, config };
|
|
58073
58306
|
return structuredClone(config);
|
|
58074
58307
|
} catch (err2) {
|
|
@@ -58116,8 +58349,8 @@ var CONFIG_DIR, CONFIG_FILE, STRING_FIELDS, TELEMETRY_FIELDS, cached2;
|
|
|
58116
58349
|
var init_config = __esm({
|
|
58117
58350
|
"src/lib/config.ts"() {
|
|
58118
58351
|
init_atomic_write();
|
|
58119
|
-
CONFIG_DIR =
|
|
58120
|
-
CONFIG_FILE =
|
|
58352
|
+
CONFIG_DIR = join44(homedir8(), ".config", "oxagen");
|
|
58353
|
+
CONFIG_FILE = join44(CONFIG_DIR, "config.json");
|
|
58121
58354
|
STRING_FIELDS = [
|
|
58122
58355
|
"token",
|
|
58123
58356
|
"orgSlug",
|
|
@@ -58162,16 +58395,16 @@ import {
|
|
|
58162
58395
|
writeFile as writeFile2
|
|
58163
58396
|
} from "node:fs/promises";
|
|
58164
58397
|
import { homedir as homedir9 } from "node:os";
|
|
58165
|
-
import { join as
|
|
58398
|
+
import { join as join45 } from "node:path";
|
|
58166
58399
|
function isDebugEnabled() {
|
|
58167
58400
|
const v = process.env[DEBUG_ENV];
|
|
58168
58401
|
return v === "1" || v === "true";
|
|
58169
58402
|
}
|
|
58170
58403
|
function logsDir() {
|
|
58171
|
-
return
|
|
58404
|
+
return join45(homedir9(), ".oxagen", "logs");
|
|
58172
58405
|
}
|
|
58173
58406
|
function debugLogFile() {
|
|
58174
|
-
return
|
|
58407
|
+
return join45(logsDir(), "cli.output");
|
|
58175
58408
|
}
|
|
58176
58409
|
function sanitize(value, depth = 0) {
|
|
58177
58410
|
if (value === null || value === void 0) return value;
|
|
@@ -61420,7 +61653,7 @@ var init_git = __esm({
|
|
|
61420
61653
|
signal;
|
|
61421
61654
|
};
|
|
61422
61655
|
ABSENT_STDERR = /not a valid object name|invalid object name|bad object|unknown revision|no such (?:object|ref)|could not get object info|does not exist in '|exists on disk, but not in '|not a git repository/i;
|
|
61423
|
-
execGit = (args, { cwd, timeoutMs }) => new Promise((
|
|
61656
|
+
execGit = (args, { cwd, timeoutMs }) => new Promise((resolve24, reject) => {
|
|
61424
61657
|
execFile5(
|
|
61425
61658
|
"git",
|
|
61426
61659
|
[...args],
|
|
@@ -61449,7 +61682,7 @@ var init_git = __esm({
|
|
|
61449
61682
|
);
|
|
61450
61683
|
return;
|
|
61451
61684
|
}
|
|
61452
|
-
|
|
61685
|
+
resolve24(stdout);
|
|
61453
61686
|
}
|
|
61454
61687
|
);
|
|
61455
61688
|
});
|
|
@@ -61466,9 +61699,9 @@ var init_git = __esm({
|
|
|
61466
61699
|
|
|
61467
61700
|
// ../../packages/steering-freshness/src/cache.ts
|
|
61468
61701
|
import { mkdir as mkdir4, readFile as readFile6, writeFile as writeFile4 } from "node:fs/promises";
|
|
61469
|
-
import { dirname as
|
|
61702
|
+
import { dirname as dirname26, join as join46 } from "node:path";
|
|
61470
61703
|
function stampPath(gitCommonDir) {
|
|
61471
|
-
return
|
|
61704
|
+
return join46(gitCommonDir, "oxagen", "steering-freshness.json");
|
|
61472
61705
|
}
|
|
61473
61706
|
async function readFetchStamp(gitCommonDir, io = defaultIo) {
|
|
61474
61707
|
try {
|
|
@@ -61489,7 +61722,7 @@ async function readFetchStamp(gitCommonDir, io = defaultIo) {
|
|
|
61489
61722
|
async function writeFetchStamp(gitCommonDir, stamp, io = defaultIo) {
|
|
61490
61723
|
const path2 = stampPath(gitCommonDir);
|
|
61491
61724
|
try {
|
|
61492
|
-
await io.mkdirp(
|
|
61725
|
+
await io.mkdirp(dirname26(path2));
|
|
61493
61726
|
await io.write(path2, `${JSON.stringify(stamp)}
|
|
61494
61727
|
`, "utf8");
|
|
61495
61728
|
} catch {
|
|
@@ -61520,24 +61753,24 @@ var init_cache = __esm({
|
|
|
61520
61753
|
// ../../packages/steering-freshness/src/hooks.ts
|
|
61521
61754
|
import { mkdir as mkdir5, readFile as readFile7, writeFile as writeFile5 } from "node:fs/promises";
|
|
61522
61755
|
import { homedir as homedir10 } from "node:os";
|
|
61523
|
-
import { dirname as
|
|
61756
|
+
import { dirname as dirname27, join as join47 } from "node:path";
|
|
61524
61757
|
function hookCommand(harness) {
|
|
61525
61758
|
return `oxagen steering gate --harness ${harness}`;
|
|
61526
61759
|
}
|
|
61527
61760
|
function hookConfigPath(projectRoot, harness, env = process.env, home = homedir10()) {
|
|
61528
61761
|
switch (harness) {
|
|
61529
61762
|
case "claude-code":
|
|
61530
|
-
return
|
|
61763
|
+
return join47(projectRoot, ".claude", "settings.json");
|
|
61531
61764
|
case "codex":
|
|
61532
|
-
return
|
|
61765
|
+
return join47(env["CODEX_HOME"] ?? join47(home, ".codex"), "hooks.json");
|
|
61533
61766
|
case "cursor":
|
|
61534
|
-
return
|
|
61767
|
+
return join47(home, ".cursor", "hooks.json");
|
|
61535
61768
|
case "stella":
|
|
61536
|
-
return
|
|
61769
|
+
return join47(env["STELLA_HOME"] ?? join47(home, ".stella"), "stella.toml");
|
|
61537
61770
|
}
|
|
61538
61771
|
}
|
|
61539
61772
|
function stellaJsonPath(env, home) {
|
|
61540
|
-
return
|
|
61773
|
+
return join47(env["STELLA_HOME"] ?? join47(home, ".stella"), "settings.json");
|
|
61541
61774
|
}
|
|
61542
61775
|
function isRecord7(v) {
|
|
61543
61776
|
return v !== null && typeof v === "object" && !Array.isArray(v);
|
|
@@ -61624,7 +61857,7 @@ async function installJsonGroupHook(path2, harness, entry2, io) {
|
|
|
61624
61857
|
};
|
|
61625
61858
|
}
|
|
61626
61859
|
const had = hasGroupHook(loaded.config);
|
|
61627
|
-
await io.mkdirp(
|
|
61860
|
+
await io.mkdirp(dirname27(path2));
|
|
61628
61861
|
await io.write(
|
|
61629
61862
|
path2,
|
|
61630
61863
|
`${JSON.stringify(withGroupHook(loaded.config, entry2), null, 2)}
|
|
@@ -61726,7 +61959,7 @@ async function installCursorHook(path2, io) {
|
|
|
61726
61959
|
];
|
|
61727
61960
|
const next = { ...config, hooks };
|
|
61728
61961
|
if (next.version === void 0) next.version = 1;
|
|
61729
|
-
await io.mkdirp(
|
|
61962
|
+
await io.mkdirp(dirname27(path2));
|
|
61730
61963
|
await io.write(path2, `${JSON.stringify(next, null, 2)}
|
|
61731
61964
|
`, "utf8");
|
|
61732
61965
|
return {
|
|
@@ -61909,7 +62142,7 @@ async function installStellaHook(projectRoot, io, env, home) {
|
|
|
61909
62142
|
}
|
|
61910
62143
|
const separator = base2.length === 0 ? "" : eol;
|
|
61911
62144
|
const next = `${base2}${separator}${renderStellaBlock(eol)}`;
|
|
61912
|
-
await io.mkdirp(
|
|
62145
|
+
await io.mkdirp(dirname27(path2));
|
|
61913
62146
|
await io.write(path2, next, "utf8");
|
|
61914
62147
|
return {
|
|
61915
62148
|
harness: "stella",
|
|
@@ -62085,7 +62318,7 @@ function resolveSteeringPolicy(layers, emergency = {
|
|
|
62085
62318
|
refusedExcludes: []
|
|
62086
62319
|
};
|
|
62087
62320
|
const excluded2 = new Set(ALWAYS_EXCLUDED);
|
|
62088
|
-
const
|
|
62321
|
+
const refused2 = /* @__PURE__ */ new Set();
|
|
62089
62322
|
const ordered = [...layers].sort(
|
|
62090
62323
|
(a, b3) => POLICY_SCOPES.indexOf(a.scope) - POLICY_SCOPES.indexOf(b3.scope)
|
|
62091
62324
|
);
|
|
@@ -62105,13 +62338,13 @@ function resolveSteeringPolicy(layers, emergency = {
|
|
|
62105
62338
|
}
|
|
62106
62339
|
for (const path2 of policy.exclude ?? []) {
|
|
62107
62340
|
if (!REVIEWED_EXCLUDE_SCOPES.has(scope)) {
|
|
62108
|
-
|
|
62341
|
+
refused2.add(path2);
|
|
62109
62342
|
continue;
|
|
62110
62343
|
}
|
|
62111
62344
|
excluded2.add(path2);
|
|
62112
62345
|
}
|
|
62113
62346
|
}
|
|
62114
|
-
for (const path2 of
|
|
62347
|
+
for (const path2 of refused2)
|
|
62115
62348
|
if (!excluded2.has(path2)) out.refusedExcludes.push(path2);
|
|
62116
62349
|
out.refusedExcludes.sort();
|
|
62117
62350
|
out.exclude = [...excluded2].sort();
|
|
@@ -62197,7 +62430,7 @@ var init_policy = __esm({
|
|
|
62197
62430
|
// ../../packages/steering-freshness/src/settings.ts
|
|
62198
62431
|
import { readFile as readFile8 } from "node:fs/promises";
|
|
62199
62432
|
import { homedir as homedir11 } from "node:os";
|
|
62200
|
-
import { join as
|
|
62433
|
+
import { join as join48 } from "node:path";
|
|
62201
62434
|
async function readLayer(scope, path2, read2) {
|
|
62202
62435
|
let text5;
|
|
62203
62436
|
try {
|
|
@@ -62249,14 +62482,14 @@ function parseLayer(scope, path2, text5) {
|
|
|
62249
62482
|
}
|
|
62250
62483
|
async function loadSteeringSettings({
|
|
62251
62484
|
projectRoot,
|
|
62252
|
-
userSettingsPath =
|
|
62485
|
+
userSettingsPath = join48(homedir11(), USER_SETTINGS_RELATIVE),
|
|
62253
62486
|
read: read2 = readFile8,
|
|
62254
62487
|
workspacePolicy = null
|
|
62255
62488
|
}) {
|
|
62256
62489
|
const targets = [
|
|
62257
62490
|
["user", userSettingsPath],
|
|
62258
|
-
["project",
|
|
62259
|
-
["local",
|
|
62491
|
+
["project", join48(projectRoot, PROJECT_DIR_NAME, PROJECT_SETTINGS_FILE)],
|
|
62492
|
+
["local", join48(projectRoot, PROJECT_DIR_NAME, LOCAL_SETTINGS_FILE)]
|
|
62260
62493
|
];
|
|
62261
62494
|
const layers = [];
|
|
62262
62495
|
const warnings = [];
|
|
@@ -62319,7 +62552,7 @@ var init_settings = __esm({
|
|
|
62319
62552
|
"use strict";
|
|
62320
62553
|
init_git();
|
|
62321
62554
|
init_policy();
|
|
62322
|
-
USER_SETTINGS_RELATIVE =
|
|
62555
|
+
USER_SETTINGS_RELATIVE = join48(
|
|
62323
62556
|
".config",
|
|
62324
62557
|
"oxagen",
|
|
62325
62558
|
"settings.json"
|
|
@@ -62332,7 +62565,7 @@ var init_settings = __esm({
|
|
|
62332
62565
|
|
|
62333
62566
|
// ../../packages/steering-freshness/src/check.ts
|
|
62334
62567
|
import { lstat as lstat3 } from "node:fs/promises";
|
|
62335
|
-
import { isAbsolute as isAbsolute12, join as
|
|
62568
|
+
import { isAbsolute as isAbsolute12, join as join49, resolve as resolve18 } from "node:path";
|
|
62336
62569
|
function publishedCommits(platform) {
|
|
62337
62570
|
if (platform.headCommits && platform.headCommits.length > 0)
|
|
62338
62571
|
return platform.headCommits;
|
|
@@ -62437,7 +62670,7 @@ async function checkSteeringFreshness(opts) {
|
|
|
62437
62670
|
);
|
|
62438
62671
|
}
|
|
62439
62672
|
const commonDir = allowNetwork ? await gitOrNull(repoCtx, "rev-parse", "--git-common-dir") : null;
|
|
62440
|
-
const stampDir = commonDir ? isAbsolute12(commonDir) ? commonDir :
|
|
62673
|
+
const stampDir = commonDir ? isAbsolute12(commonDir) ? commonDir : resolve18(root, commonDir) : null;
|
|
62441
62674
|
const stamp = stampDir ? await readFetchStamp(stampDir, cacheIo) : null;
|
|
62442
62675
|
const remoteContactDue = allowNetwork && shouldContactRemote(stamp, policy.fetchIntervalSeconds, now());
|
|
62443
62676
|
const branch = policy.branch ?? await defaultBranch(networkCtx(repoCtx), policy.remote, {
|
|
@@ -62669,7 +62902,7 @@ async function absentFromDisk(root, paths) {
|
|
|
62669
62902
|
const flags = await Promise.all(
|
|
62670
62903
|
paths.map(async (path2) => {
|
|
62671
62904
|
try {
|
|
62672
|
-
await lstat3(
|
|
62905
|
+
await lstat3(join49(root, path2));
|
|
62673
62906
|
return false;
|
|
62674
62907
|
} catch {
|
|
62675
62908
|
return true;
|
|
@@ -62728,7 +62961,7 @@ var init_check = __esm({
|
|
|
62728
62961
|
// ../../packages/steering-freshness/src/sync.ts
|
|
62729
62962
|
import { mkdtemp, rm as rm3, writeFile as writeFile6 } from "node:fs/promises";
|
|
62730
62963
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
62731
|
-
import { join as
|
|
62964
|
+
import { join as join50 } from "node:path";
|
|
62732
62965
|
function refuse3(refusal, message) {
|
|
62733
62966
|
return {
|
|
62734
62967
|
applied: false,
|
|
@@ -62909,9 +63142,9 @@ async function syncSteering(opts) {
|
|
|
62909
63142
|
};
|
|
62910
63143
|
}
|
|
62911
63144
|
async function commitPaths(ctx, message, paths) {
|
|
62912
|
-
const dir = await mkdtemp(
|
|
63145
|
+
const dir = await mkdtemp(join50(tmpdir2(), "oxagen-steering-sync-"));
|
|
62913
63146
|
try {
|
|
62914
|
-
const list2 =
|
|
63147
|
+
const list2 = join50(dir, "pathspec");
|
|
62915
63148
|
await writeFile6(list2, `${paths.join("\0")}\0`, "utf8");
|
|
62916
63149
|
await git3(
|
|
62917
63150
|
ctx,
|
|
@@ -63438,10 +63671,10 @@ var init_paths2 = __esm({
|
|
|
63438
63671
|
});
|
|
63439
63672
|
|
|
63440
63673
|
// src/commands/workspace-link.ts
|
|
63441
|
-
import { existsSync as existsSync24, mkdirSync as mkdirSync9, readFileSync as
|
|
63442
|
-
import { dirname as
|
|
63674
|
+
import { existsSync as existsSync24, mkdirSync as mkdirSync9, readFileSync as readFileSync23 } from "node:fs";
|
|
63675
|
+
import { dirname as dirname28, join as join51 } from "node:path";
|
|
63443
63676
|
function workspaceLinkPath(cwd) {
|
|
63444
|
-
return
|
|
63677
|
+
return join51(cwd, WORKSPACE_LINK_PATH);
|
|
63445
63678
|
}
|
|
63446
63679
|
function isRecord8(value) {
|
|
63447
63680
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -63474,7 +63707,7 @@ function readWorkspaceLink(cwd) {
|
|
|
63474
63707
|
if (!existsSync24(filePath)) return null;
|
|
63475
63708
|
let parsed2;
|
|
63476
63709
|
try {
|
|
63477
|
-
parsed2 = JSON.parse(
|
|
63710
|
+
parsed2 = JSON.parse(readFileSync23(filePath, "utf8"));
|
|
63478
63711
|
} catch (err2) {
|
|
63479
63712
|
const detail = err2 instanceof Error ? err2.message : String(err2);
|
|
63480
63713
|
process.stderr.write(
|
|
@@ -63495,7 +63728,7 @@ function readWorkspaceLink(cwd) {
|
|
|
63495
63728
|
}
|
|
63496
63729
|
function writeWorkspaceLink(cwd, link) {
|
|
63497
63730
|
const filePath = workspaceLinkPath(cwd);
|
|
63498
|
-
mkdirSync9(
|
|
63731
|
+
mkdirSync9(dirname28(filePath), { recursive: true });
|
|
63499
63732
|
atomicWriteFileSync(filePath, JSON.stringify(link, null, 2));
|
|
63500
63733
|
}
|
|
63501
63734
|
var LINK_STRING_FIELDS;
|
|
@@ -63531,7 +63764,7 @@ __export(steering_exports, {
|
|
|
63531
63764
|
});
|
|
63532
63765
|
import { execFileSync } from "node:child_process";
|
|
63533
63766
|
import { existsSync as existsSync25, realpathSync as realpathSync7 } from "node:fs";
|
|
63534
|
-
import { dirname as
|
|
63767
|
+
import { dirname as dirname29, join as join52, normalize, parse as parsePath } from "node:path";
|
|
63535
63768
|
function findProjectRoot(start) {
|
|
63536
63769
|
const { root } = parsePath(start);
|
|
63537
63770
|
const rawGitRoot = gitRootOr(start);
|
|
@@ -63540,9 +63773,9 @@ function findProjectRoot(start) {
|
|
|
63540
63773
|
if (gitRoot !== null) return gitRoot;
|
|
63541
63774
|
let dir = from;
|
|
63542
63775
|
for (; ; ) {
|
|
63543
|
-
if (existsSync25(
|
|
63776
|
+
if (existsSync25(join52(dir, PROJECT_DIR_NAME))) return dir;
|
|
63544
63777
|
if (dir === root) return from;
|
|
63545
|
-
const parent =
|
|
63778
|
+
const parent = dirname29(dir);
|
|
63546
63779
|
if (parent === dir) return from;
|
|
63547
63780
|
dir = parent;
|
|
63548
63781
|
}
|
|
@@ -63849,7 +64082,7 @@ async function resolveContext(cwd, {
|
|
|
63849
64082
|
}
|
|
63850
64083
|
};
|
|
63851
64084
|
}
|
|
63852
|
-
function
|
|
64085
|
+
function describe6(verdict, policy) {
|
|
63853
64086
|
const target2 = verdict.branch ? `${verdict.remote}/${verdict.branch}` : verdict.remote;
|
|
63854
64087
|
const lines = [];
|
|
63855
64088
|
switch (verdict.status) {
|
|
@@ -63928,7 +64161,7 @@ async function steeringStatus(opts = {}, writer = stdoutWriter, cwd = process.cw
|
|
|
63928
64161
|
});
|
|
63929
64162
|
return;
|
|
63930
64163
|
}
|
|
63931
|
-
writer.write(
|
|
64164
|
+
writer.write(describe6(verdict, ctx.policy));
|
|
63932
64165
|
}
|
|
63933
64166
|
async function steeringSync(opts = {}, writer = stdoutWriter, cwd = process.cwd()) {
|
|
63934
64167
|
const out = createOutput({ json: opts.json }, writer);
|
|
@@ -65659,6 +65892,13 @@ var init_agent_list = __esm({
|
|
|
65659
65892
|
beltSize: external_exports.number().int().nonnegative().nullable(),
|
|
65660
65893
|
/** Ledger runs plus root wrapped sessions started in the last 30 days. */
|
|
65661
65894
|
runs30d: external_exports.number().int().nonnegative(),
|
|
65895
|
+
/**
|
|
65896
|
+
* The agent's runs that are live now: open ledger runs plus root wrapped
|
|
65897
|
+
* sessions still running on a host that polled in the last five minutes
|
|
65898
|
+
* (or on no host). The same predicates as `list_runs`' live count, so the
|
|
65899
|
+
* Agents table and the Runs page's Live tile agree. Zero when none is.
|
|
65900
|
+
*/
|
|
65901
|
+
liveRuns: external_exports.number().int().nonnegative(),
|
|
65662
65902
|
/**
|
|
65663
65903
|
* The sum of the agent's priced wrapped sessions started in the last 30
|
|
65664
65904
|
* days, as the harness reported it (`client_attested`). Null when no
|
|
@@ -65710,7 +65950,7 @@ var init_agent_list = __esm({
|
|
|
65710
65950
|
agentList = registerCapability({
|
|
65711
65951
|
name: "list_agents",
|
|
65712
65952
|
domain: "agent",
|
|
65713
|
-
description: "List the agents registered in this workspace with their purpose, principal, harness, operator, status, enrollment and credential counts, live host, latest enforcement tier, active mandates, and the 30-day run, spend, token and incident figures the stores record. Retired (deregistered) agents are left out unless includeRetired is true.",
|
|
65953
|
+
description: "List the agents registered in this workspace with their purpose, principal, harness, operator, status, enrollment and credential counts, live host, live run count, latest enforcement tier, active mandates, and the 30-day run, spend, token and incident figures the stores record. Retired (deregistered) agents are left out unless includeRetired is true.",
|
|
65714
65954
|
mode: "sync",
|
|
65715
65955
|
surfaces: ["api", "mcp", "agent"],
|
|
65716
65956
|
layers: ["schema", "api", "mcp", "unit", "docs", "app"],
|
|
@@ -79980,7 +80220,7 @@ var init_secrets = __esm({
|
|
|
79980
80220
|
});
|
|
79981
80221
|
|
|
79982
80222
|
// ../../packages/steering-check/src/checks/secrets.ts
|
|
79983
|
-
function
|
|
80223
|
+
function describe7(label2) {
|
|
79984
80224
|
if (label2 === "private key block") {
|
|
79985
80225
|
return {
|
|
79986
80226
|
rule: "credential",
|
|
@@ -80049,7 +80289,7 @@ var init_secrets2 = __esm({
|
|
|
80049
80289
|
if (labels.size === 0) continue;
|
|
80050
80290
|
const lines = firstLines(text5, labels);
|
|
80051
80291
|
for (const label2 of labels) {
|
|
80052
|
-
const described =
|
|
80292
|
+
const described = describe7(label2);
|
|
80053
80293
|
if (kind === LOCK_KIND && described.rule !== "credential") continue;
|
|
80054
80294
|
findings.push(
|
|
80055
80295
|
find10({
|
|
@@ -80071,7 +80311,7 @@ function shown2(value) {
|
|
|
80071
80311
|
const text5 = value === void 0 || value === null ? "unset" : JSON.stringify(value);
|
|
80072
80312
|
return text5.length > 120 ? `${text5.slice(0, 117)}...` : text5;
|
|
80073
80313
|
}
|
|
80074
|
-
function
|
|
80314
|
+
function describe8(difference) {
|
|
80075
80315
|
const { setting: setting2, actual } = difference;
|
|
80076
80316
|
const parts = setting2.split(".");
|
|
80077
80317
|
if (setting2 === "merge_requests.required_status") {
|
|
@@ -80131,7 +80371,7 @@ var init_settings2 = __esm({
|
|
|
80131
80371
|
};
|
|
80132
80372
|
}
|
|
80133
80373
|
const findings = env.health.differences.map((difference) => {
|
|
80134
|
-
const { rule, message, fix } =
|
|
80374
|
+
const { rule, message, fix } = describe8(difference);
|
|
80135
80375
|
return find11({
|
|
80136
80376
|
rule,
|
|
80137
80377
|
path: difference.setting,
|
|
@@ -80624,10 +80864,10 @@ var init_memory_client = __esm({
|
|
|
80624
80864
|
import { readFile as readFile9 } from "node:fs/promises";
|
|
80625
80865
|
import {
|
|
80626
80866
|
basename as basename7,
|
|
80627
|
-
dirname as
|
|
80867
|
+
dirname as dirname30,
|
|
80628
80868
|
isAbsolute as isAbsolute13,
|
|
80629
80869
|
relative as relative6,
|
|
80630
|
-
resolve as
|
|
80870
|
+
resolve as resolve19,
|
|
80631
80871
|
sep as sep7
|
|
80632
80872
|
} from "node:path";
|
|
80633
80873
|
function inside(rel) {
|
|
@@ -80636,7 +80876,7 @@ function inside(rel) {
|
|
|
80636
80876
|
function importFilename(path2, folder) {
|
|
80637
80877
|
let rel = relative6(process.cwd(), path2);
|
|
80638
80878
|
if (!inside(rel) && folder !== void 0) {
|
|
80639
|
-
rel = relative6(
|
|
80879
|
+
rel = relative6(dirname30(resolve19(folder)), resolve19(path2));
|
|
80640
80880
|
}
|
|
80641
80881
|
const name = inside(rel) ? rel.split(sep7).join("/") : basename7(path2);
|
|
80642
80882
|
return name.length > 256 ? basename7(path2).slice(-256) : name;
|
|
@@ -80923,7 +81163,7 @@ __export(steering_import_exports, {
|
|
|
80923
81163
|
});
|
|
80924
81164
|
import { readdir as readdir4, realpath as realpath2, stat as stat4 } from "node:fs/promises";
|
|
80925
81165
|
import { homedir as homedir12 } from "node:os";
|
|
80926
|
-
import { basename as basename8, extname, join as
|
|
81166
|
+
import { basename as basename8, extname, join as join53, relative as relative7, sep as sep8 } from "node:path";
|
|
80927
81167
|
function envDir2(env, key) {
|
|
80928
81168
|
const value = env[key];
|
|
80929
81169
|
return value === void 0 || value.trim() === "" ? null : value;
|
|
@@ -80931,34 +81171,34 @@ function envDir2(env, key) {
|
|
|
80931
81171
|
function harnessHome(harness, env = process.env, home = homedir12()) {
|
|
80932
81172
|
switch (harness) {
|
|
80933
81173
|
case "claude-code": {
|
|
80934
|
-
const config = envDir2(env, "CLAUDE_CONFIG_DIR") ??
|
|
81174
|
+
const config = envDir2(env, "CLAUDE_CONFIG_DIR") ?? join53(home, ".claude");
|
|
80935
81175
|
return {
|
|
80936
81176
|
harness,
|
|
80937
81177
|
folders: [
|
|
80938
81178
|
{
|
|
80939
|
-
dir: skillsRoot("claude-code", env, home) ??
|
|
81179
|
+
dir: skillsRoot("claude-code", env, home) ?? join53(config, "skills"),
|
|
80940
81180
|
mount: ".claude/skills"
|
|
80941
81181
|
},
|
|
80942
|
-
{ dir:
|
|
80943
|
-
{ dir:
|
|
81182
|
+
{ dir: join53(config, "commands"), mount: ".claude/commands" },
|
|
81183
|
+
{ dir: join53(config, "agents"), mount: ".claude/agents" }
|
|
80944
81184
|
],
|
|
80945
81185
|
instructions: [
|
|
80946
|
-
{ file:
|
|
81186
|
+
{ file: join53(config, "CLAUDE.md"), filename: ".claude/CLAUDE.md" }
|
|
80947
81187
|
]
|
|
80948
81188
|
};
|
|
80949
81189
|
}
|
|
80950
81190
|
case "codex": {
|
|
80951
|
-
const codexHome = envDir2(env, "CODEX_HOME") ??
|
|
81191
|
+
const codexHome = envDir2(env, "CODEX_HOME") ?? join53(home, ".codex");
|
|
80952
81192
|
return {
|
|
80953
81193
|
harness,
|
|
80954
81194
|
folders: [
|
|
80955
81195
|
{
|
|
80956
|
-
dir: skillsRoot("codex", env, home) ??
|
|
81196
|
+
dir: skillsRoot("codex", env, home) ?? join53(home, ".agents", "skills"),
|
|
80957
81197
|
mount: ".agents/skills"
|
|
80958
81198
|
}
|
|
80959
81199
|
],
|
|
80960
81200
|
instructions: ["AGENTS.override.md", "AGENTS.md"].map((name) => ({
|
|
80961
|
-
file:
|
|
81201
|
+
file: join53(codexHome, name),
|
|
80962
81202
|
filename: `.codex/${name}`
|
|
80963
81203
|
}))
|
|
80964
81204
|
};
|
|
@@ -80967,8 +81207,8 @@ function harnessHome(harness, env = process.env, home = homedir12()) {
|
|
|
80967
81207
|
return {
|
|
80968
81208
|
harness,
|
|
80969
81209
|
folders: [
|
|
80970
|
-
{ dir:
|
|
80971
|
-
{ dir:
|
|
81210
|
+
{ dir: join53(home, ".cursor", "skills"), mount: ".cursor/skills" },
|
|
81211
|
+
{ dir: join53(home, ".cursor", "commands"), mount: ".cursor/commands" }
|
|
80972
81212
|
],
|
|
80973
81213
|
instructions: []
|
|
80974
81214
|
};
|
|
@@ -81014,7 +81254,7 @@ async function findMarkdownFiles(paths, harness) {
|
|
|
81014
81254
|
}
|
|
81015
81255
|
const found = [];
|
|
81016
81256
|
for (const entry2 of entries2.sort(byName)) {
|
|
81017
|
-
const path2 =
|
|
81257
|
+
const path2 = join53(dir, entry2.name);
|
|
81018
81258
|
if (entry2.isDirectory()) {
|
|
81019
81259
|
if (!entry2.name.startsWith(".") && entry2.name !== "node_modules")
|
|
81020
81260
|
found.push(...await filesUnder(path2, from));
|
|
@@ -81036,7 +81276,7 @@ async function findMarkdownFiles(paths, harness) {
|
|
|
81036
81276
|
const { folder } = frame;
|
|
81037
81277
|
const named = (rel) => frame.fixedNames ? { filename: rel } : {};
|
|
81038
81278
|
for (const entry2 of entries2) {
|
|
81039
|
-
const path2 =
|
|
81279
|
+
const path2 = join53(dir, entry2.name);
|
|
81040
81280
|
const rel = frame.relOf(path2);
|
|
81041
81281
|
if (entry2.isDirectory()) {
|
|
81042
81282
|
if (entry2.name === "node_modules") continue;
|
|
@@ -81095,7 +81335,7 @@ async function findMarkdownFiles(paths, harness) {
|
|
|
81095
81335
|
}
|
|
81096
81336
|
if (folderGiven) {
|
|
81097
81337
|
const catalogue = CATALOGUE_FOLDERS.has(basename8(path2));
|
|
81098
|
-
const root = catalogue ?
|
|
81338
|
+
const root = catalogue ? join53(path2, "..") : path2;
|
|
81099
81339
|
await walk2(path2, {
|
|
81100
81340
|
relOf: (p) => under(root, p),
|
|
81101
81341
|
folder: path2,
|
|
@@ -81425,7 +81665,7 @@ __export(run_exports, {
|
|
|
81425
81665
|
});
|
|
81426
81666
|
import { createHash as createHash16 } from "node:crypto";
|
|
81427
81667
|
import { createWriteStream, renameSync as renameSync6, rmSync as rmSync9 } from "node:fs";
|
|
81428
|
-
import { resolve as
|
|
81668
|
+
import { resolve as resolve20 } from "node:path";
|
|
81429
81669
|
import { Readable as Readable2 } from "node:stream";
|
|
81430
81670
|
import { pipeline as pipeline2 } from "node:stream/promises";
|
|
81431
81671
|
async function runExport(runId, opts = {}, writer = stdoutWriter) {
|
|
@@ -81523,7 +81763,7 @@ async function runDownload(exportId, opts = {}, writer = stdoutWriter) {
|
|
|
81523
81763
|
return;
|
|
81524
81764
|
}
|
|
81525
81765
|
const url = resolveDownloadUrl(status2.download.url, getApiUrl());
|
|
81526
|
-
const path2 =
|
|
81766
|
+
const path2 = resolve20(opts.out ?? `${status2.runId}-${exportId}.zip`);
|
|
81527
81767
|
const partial = `${path2}.${process.pid}.partial`;
|
|
81528
81768
|
const hash3 = createHash16("sha256");
|
|
81529
81769
|
let size = 0;
|
|
@@ -82754,12 +82994,12 @@ __export(verify_exports, {
|
|
|
82754
82994
|
readBundle: () => readBundle,
|
|
82755
82995
|
verifyBundle: () => verifyBundle3
|
|
82756
82996
|
});
|
|
82757
|
-
import { existsSync as existsSync26, readFileSync as
|
|
82758
|
-
import { join as
|
|
82997
|
+
import { existsSync as existsSync26, readFileSync as readFileSync24, statSync as statSync13 } from "node:fs";
|
|
82998
|
+
import { join as join54 } from "node:path";
|
|
82759
82999
|
function readDirectory(dir) {
|
|
82760
83000
|
const read2 = (name) => {
|
|
82761
|
-
const path2 =
|
|
82762
|
-
return existsSync26(path2) ?
|
|
83001
|
+
const path2 = join54(dir, name);
|
|
83002
|
+
return existsSync26(path2) ? readFileSync24(path2, "utf8") : void 0;
|
|
82763
83003
|
};
|
|
82764
83004
|
return assemble(read2, dir);
|
|
82765
83005
|
}
|
|
@@ -82769,7 +83009,7 @@ function isBundleEntry(name) {
|
|
|
82769
83009
|
function readZip(path2) {
|
|
82770
83010
|
let entries2;
|
|
82771
83011
|
try {
|
|
82772
|
-
entries2 = unzipSync(new Uint8Array(
|
|
83012
|
+
entries2 = unzipSync(new Uint8Array(readFileSync24(path2)), {
|
|
82773
83013
|
filter: (file) => isBundleEntry(file.name)
|
|
82774
83014
|
});
|
|
82775
83015
|
} catch (err2) {
|
|
@@ -82805,7 +83045,7 @@ function readBundle(path2) {
|
|
|
82805
83045
|
if (!existsSync26(path2)) {
|
|
82806
83046
|
throw new BundleReadError(`${path2} does not exist.`);
|
|
82807
83047
|
}
|
|
82808
|
-
return
|
|
83048
|
+
return statSync13(path2).isDirectory() ? readDirectory(path2) : readZip(path2);
|
|
82809
83049
|
}
|
|
82810
83050
|
function plural3(count12, one, many) {
|
|
82811
83051
|
return `${count12} ${count12 === 1 ? one : many}`;
|
|
@@ -83879,15 +84119,15 @@ import { createHash as createHash17, randomBytes as randomBytes12 } from "node:c
|
|
|
83879
84119
|
import {
|
|
83880
84120
|
appendFileSync as appendFileSync4,
|
|
83881
84121
|
existsSync as existsSync27,
|
|
83882
|
-
lstatSync as
|
|
84122
|
+
lstatSync as lstatSync10,
|
|
83883
84123
|
mkdirSync as mkdirSync10,
|
|
83884
|
-
readFileSync as
|
|
84124
|
+
readFileSync as readFileSync25,
|
|
83885
84125
|
readdirSync as readdirSync13,
|
|
83886
84126
|
realpathSync as realpathSync8,
|
|
83887
84127
|
writeFileSync as writeFileSync7
|
|
83888
84128
|
} from "node:fs";
|
|
83889
84129
|
import { homedir as homedir13, hostname as osHostname3 } from "node:os";
|
|
83890
|
-
import { join as
|
|
84130
|
+
import { join as join55, relative as relative8, resolve as resolve21, sep as sep9 } from "node:path";
|
|
83891
84131
|
function git4(cwd, args) {
|
|
83892
84132
|
return new Promise((done) => {
|
|
83893
84133
|
try {
|
|
@@ -83908,7 +84148,7 @@ function git4(cwd, args) {
|
|
|
83908
84148
|
}
|
|
83909
84149
|
async function projectRootFor(cwd) {
|
|
83910
84150
|
const top = await git4(cwd, ["rev-parse", "--show-toplevel"]);
|
|
83911
|
-
return top ?
|
|
84151
|
+
return top ? resolve21(top) : resolve21(cwd);
|
|
83912
84152
|
}
|
|
83913
84153
|
function parseRemoteRepository(url) {
|
|
83914
84154
|
const raw = url.trim();
|
|
@@ -83934,7 +84174,7 @@ function parseRemoteRepository(url) {
|
|
|
83934
84174
|
}
|
|
83935
84175
|
function oxagenPresent(root) {
|
|
83936
84176
|
try {
|
|
83937
|
-
return readdirSync13(
|
|
84177
|
+
return readdirSync13(join55(root, ".oxagen")).some(
|
|
83938
84178
|
(name) => name !== "workspace.json"
|
|
83939
84179
|
);
|
|
83940
84180
|
} catch {
|
|
@@ -83943,20 +84183,20 @@ function oxagenPresent(root) {
|
|
|
83943
84183
|
}
|
|
83944
84184
|
function symlinkState(root) {
|
|
83945
84185
|
try {
|
|
83946
|
-
if (!
|
|
84186
|
+
if (!lstatSync10(join55(root, ".stella")).isDirectory()) return "none";
|
|
83947
84187
|
} catch {
|
|
83948
84188
|
return "none";
|
|
83949
84189
|
}
|
|
83950
84190
|
let oxagenReal;
|
|
83951
84191
|
try {
|
|
83952
|
-
oxagenReal = realpathSync8(
|
|
84192
|
+
oxagenReal = realpathSync8(join55(root, ".oxagen"));
|
|
83953
84193
|
} catch {
|
|
83954
84194
|
return "missing";
|
|
83955
84195
|
}
|
|
83956
84196
|
for (const link of STELLA_LINKS) {
|
|
83957
|
-
const at2 =
|
|
84197
|
+
const at2 = join55(root, link);
|
|
83958
84198
|
try {
|
|
83959
|
-
if (!
|
|
84199
|
+
if (!lstatSync10(at2).isSymbolicLink()) return "missing";
|
|
83960
84200
|
const target2 = realpathSync8(at2);
|
|
83961
84201
|
if (target2 !== oxagenReal && !target2.startsWith(oxagenReal + sep9)) {
|
|
83962
84202
|
return "missing";
|
|
@@ -83968,11 +84208,11 @@ function symlinkState(root) {
|
|
|
83968
84208
|
return "linked";
|
|
83969
84209
|
}
|
|
83970
84210
|
function machineId(configDir = getConfigDir()) {
|
|
83971
|
-
const file =
|
|
84211
|
+
const file = join55(configDir, MACHINE_ID_FILE);
|
|
83972
84212
|
let secret = null;
|
|
83973
84213
|
try {
|
|
83974
84214
|
if (existsSync27(file)) {
|
|
83975
|
-
const stored =
|
|
84215
|
+
const stored = readFileSync25(file, "utf8").trim();
|
|
83976
84216
|
if (/^[0-9a-f]{64}$/.test(stored)) secret = stored;
|
|
83977
84217
|
}
|
|
83978
84218
|
if (secret === null) {
|
|
@@ -84008,7 +84248,7 @@ async function probeWorkingCopy(opts) {
|
|
|
84008
84248
|
return {
|
|
84009
84249
|
machineId: machineId(opts.configDir),
|
|
84010
84250
|
hostname: host.length > 0 ? host : "unknown",
|
|
84011
|
-
directory:
|
|
84251
|
+
directory: resolve21(root),
|
|
84012
84252
|
repository: remote ? parseRemoteRepository(remote) : null,
|
|
84013
84253
|
// `HEAD` is git's answer on a detached head.
|
|
84014
84254
|
branch: branch && branch !== "HEAD" ? branch.slice(0, 255) : null,
|
|
@@ -84041,24 +84281,24 @@ function realpathOr2(path2) {
|
|
|
84041
84281
|
try {
|
|
84042
84282
|
return realpathSync8(path2);
|
|
84043
84283
|
} catch {
|
|
84044
|
-
return
|
|
84284
|
+
return resolve21(path2);
|
|
84045
84285
|
}
|
|
84046
84286
|
}
|
|
84047
84287
|
async function ensureWorkspaceLinkIgnored(root) {
|
|
84048
84288
|
const top = await git4(root, ["rev-parse", "--show-toplevel"]);
|
|
84049
84289
|
if (!top) return null;
|
|
84050
|
-
const topDir =
|
|
84290
|
+
const topDir = resolve21(top);
|
|
84051
84291
|
const entry2 = relative8(
|
|
84052
84292
|
topDir,
|
|
84053
|
-
|
|
84293
|
+
join55(realpathOr2(root), ".oxagen", "workspace.json")
|
|
84054
84294
|
).split(sep9).join("/");
|
|
84055
84295
|
if (entry2.startsWith("../")) return null;
|
|
84056
84296
|
const rule = await git4(topDir, ["check-ignore", "--no-index", "-v", entry2]);
|
|
84057
84297
|
if (rule !== null) return null;
|
|
84058
|
-
const gitignore =
|
|
84298
|
+
const gitignore = join55(resolve21(top), ".gitignore");
|
|
84059
84299
|
let existing = "";
|
|
84060
84300
|
try {
|
|
84061
|
-
existing =
|
|
84301
|
+
existing = readFileSync25(gitignore, "utf8");
|
|
84062
84302
|
} catch {
|
|
84063
84303
|
}
|
|
84064
84304
|
const prefix = existing.length > 0 && !existing.endsWith("\n") ? "\n" : "";
|
|
@@ -84569,18 +84809,18 @@ __export(pull_exports, {
|
|
|
84569
84809
|
});
|
|
84570
84810
|
import { createHash as createHash18 } from "node:crypto";
|
|
84571
84811
|
import {
|
|
84572
|
-
lstatSync as
|
|
84812
|
+
lstatSync as lstatSync11,
|
|
84573
84813
|
mkdirSync as mkdirSync11,
|
|
84574
|
-
readFileSync as
|
|
84814
|
+
readFileSync as readFileSync26,
|
|
84575
84815
|
readdirSync as readdirSync14,
|
|
84576
84816
|
realpathSync as realpathSync9,
|
|
84577
84817
|
rmSync as rmSync10,
|
|
84578
84818
|
rmdirSync as rmdirSync7
|
|
84579
84819
|
} from "node:fs";
|
|
84580
84820
|
import {
|
|
84581
|
-
dirname as
|
|
84821
|
+
dirname as dirname31,
|
|
84582
84822
|
isAbsolute as isAbsolute14,
|
|
84583
|
-
join as
|
|
84823
|
+
join as join56,
|
|
84584
84824
|
parse as parsePath2,
|
|
84585
84825
|
posix as posix4,
|
|
84586
84826
|
sep as sep10
|
|
@@ -84689,38 +84929,38 @@ function findLinkedRoot(start) {
|
|
|
84689
84929
|
const { root } = parsePath2(start);
|
|
84690
84930
|
for (; ; ) {
|
|
84691
84931
|
try {
|
|
84692
|
-
if (
|
|
84932
|
+
if (lstatSync11(workspaceLinkPath(dir)).isFile()) return dir;
|
|
84693
84933
|
} catch {
|
|
84694
84934
|
}
|
|
84695
84935
|
if (dir === root) return null;
|
|
84696
|
-
const parent =
|
|
84936
|
+
const parent = dirname31(dir);
|
|
84697
84937
|
if (parent === dir) return null;
|
|
84698
84938
|
dir = parent;
|
|
84699
84939
|
}
|
|
84700
84940
|
}
|
|
84701
84941
|
function fsReader(root) {
|
|
84702
84942
|
return (path2) => {
|
|
84703
|
-
const abs =
|
|
84943
|
+
const abs = join56(root, ...path2.split("/"));
|
|
84704
84944
|
try {
|
|
84705
|
-
const st =
|
|
84945
|
+
const st = lstatSync11(abs);
|
|
84706
84946
|
if (!st.isFile()) return Buffer.from(`\0not-a-file:${abs}`);
|
|
84707
|
-
return
|
|
84947
|
+
return readFileSync26(abs);
|
|
84708
84948
|
} catch {
|
|
84709
84949
|
return null;
|
|
84710
84950
|
}
|
|
84711
84951
|
};
|
|
84712
84952
|
}
|
|
84713
84953
|
function assertInsideOxagen(root, path2) {
|
|
84714
|
-
const oxagenAbs =
|
|
84954
|
+
const oxagenAbs = join56(root, OXAGEN_DIR);
|
|
84715
84955
|
let oxagenReal;
|
|
84716
84956
|
try {
|
|
84717
84957
|
oxagenReal = realpathSync9(oxagenAbs);
|
|
84718
84958
|
} catch {
|
|
84719
84959
|
return;
|
|
84720
84960
|
}
|
|
84721
|
-
const abs =
|
|
84961
|
+
const abs = join56(root, ...path2.split("/"));
|
|
84722
84962
|
try {
|
|
84723
|
-
if (
|
|
84963
|
+
if (lstatSync11(abs).isSymbolicLink()) {
|
|
84724
84964
|
throw new Error(
|
|
84725
84965
|
`${path2} is a symlink, and pull does not write through one`
|
|
84726
84966
|
);
|
|
@@ -84728,7 +84968,7 @@ function assertInsideOxagen(root, path2) {
|
|
|
84728
84968
|
} catch (err2) {
|
|
84729
84969
|
if (err2.code !== "ENOENT") throw err2;
|
|
84730
84970
|
}
|
|
84731
|
-
let dir =
|
|
84971
|
+
let dir = dirname31(abs);
|
|
84732
84972
|
for (; ; ) {
|
|
84733
84973
|
let real = null;
|
|
84734
84974
|
try {
|
|
@@ -84742,14 +84982,14 @@ function assertInsideOxagen(root, path2) {
|
|
|
84742
84982
|
}
|
|
84743
84983
|
return;
|
|
84744
84984
|
}
|
|
84745
|
-
const parent =
|
|
84985
|
+
const parent = dirname31(dir);
|
|
84746
84986
|
if (parent === dir) return;
|
|
84747
84987
|
dir = parent;
|
|
84748
84988
|
}
|
|
84749
84989
|
}
|
|
84750
84990
|
function pruneEmptyDirs(root, path2) {
|
|
84751
|
-
const stop =
|
|
84752
|
-
let dir =
|
|
84991
|
+
const stop = join56(root, OXAGEN_DIR);
|
|
84992
|
+
let dir = dirname31(join56(root, ...path2.split("/")));
|
|
84753
84993
|
while (dir.startsWith(stop + sep10)) {
|
|
84754
84994
|
try {
|
|
84755
84995
|
if (readdirSync14(dir).length > 0) return;
|
|
@@ -84757,19 +84997,19 @@ function pruneEmptyDirs(root, path2) {
|
|
|
84757
84997
|
} catch {
|
|
84758
84998
|
return;
|
|
84759
84999
|
}
|
|
84760
|
-
dir =
|
|
85000
|
+
dir = dirname31(dir);
|
|
84761
85001
|
}
|
|
84762
85002
|
}
|
|
84763
85003
|
function applyPlan(root, plan) {
|
|
84764
85004
|
for (const w of plan.writes) assertInsideOxagen(root, w.path);
|
|
84765
85005
|
for (const d of plan.deletes) assertInsideOxagen(root, d);
|
|
84766
85006
|
for (const w of plan.writes) {
|
|
84767
|
-
const abs =
|
|
84768
|
-
mkdirSync11(
|
|
85007
|
+
const abs = join56(root, ...w.path.split("/"));
|
|
85008
|
+
mkdirSync11(dirname31(abs), { recursive: true });
|
|
84769
85009
|
atomicWriteFileSync(abs, w.content);
|
|
84770
85010
|
}
|
|
84771
85011
|
for (const d of plan.deletes) {
|
|
84772
|
-
rmSync10(
|
|
85012
|
+
rmSync10(join56(root, ...d.split("/")), { force: true });
|
|
84773
85013
|
pruneEmptyDirs(root, d);
|
|
84774
85014
|
}
|
|
84775
85015
|
}
|
|
@@ -85441,7 +85681,7 @@ function definitionLocationChecks(extra, repositoryFields = ["repo", "path", "re
|
|
|
85441
85681
|
)
|
|
85442
85682
|
];
|
|
85443
85683
|
}
|
|
85444
|
-
function definitionSource(type, froms,
|
|
85684
|
+
function definitionSource(type, froms, describe9) {
|
|
85445
85685
|
return withChecks(
|
|
85446
85686
|
external_exports.object({
|
|
85447
85687
|
type: external_exports.literal(type),
|
|
@@ -85451,7 +85691,7 @@ function definitionSource(type, froms, describe8) {
|
|
|
85451
85691
|
ref: gitRefSchema.optional().describe("The branch, tag, or commit to read."),
|
|
85452
85692
|
url: httpUrlSchema.optional().describe("Where Oxagen fetches the definition."),
|
|
85453
85693
|
network: networkField
|
|
85454
|
-
}).strict().describe(
|
|
85694
|
+
}).strict().describe(describe9),
|
|
85455
85695
|
definitionLocationChecks(liveReadFroms(froms))
|
|
85456
85696
|
);
|
|
85457
85697
|
}
|
|
@@ -90776,7 +91016,7 @@ function createFileRegistry(...args) {
|
|
|
90776
91016
|
if (seen.has(protoFileName)) {
|
|
90777
91017
|
continue;
|
|
90778
91018
|
}
|
|
90779
|
-
const dep =
|
|
91019
|
+
const dep = resolve24(protoFileName);
|
|
90780
91020
|
if (!dep) {
|
|
90781
91021
|
throw new Error(`Unable to resolve ${protoFileName}, imported by ${file.name}`);
|
|
90782
91022
|
}
|
|
@@ -90790,7 +91030,7 @@ function createFileRegistry(...args) {
|
|
|
90790
91030
|
return deps.concat(...deps.map(recurseDeps));
|
|
90791
91031
|
};
|
|
90792
91032
|
const input = args[0];
|
|
90793
|
-
const
|
|
91033
|
+
const resolve24 = args[1];
|
|
90794
91034
|
const seen = /* @__PURE__ */ new Set();
|
|
90795
91035
|
for (const file of [input, ...recurseDeps(input)].reverse()) {
|
|
90796
91036
|
addFile(file, registry2);
|
|
@@ -93640,7 +93880,7 @@ var require_aspromise = __commonJS({
|
|
|
93640
93880
|
var params = new Array(arguments.length - 1), offset = 0, index = 2, pending = true;
|
|
93641
93881
|
while (index < arguments.length)
|
|
93642
93882
|
params[offset++] = arguments[index++];
|
|
93643
|
-
return new Promise(function executor(
|
|
93883
|
+
return new Promise(function executor(resolve24, reject) {
|
|
93644
93884
|
params[offset] = function callback(err2) {
|
|
93645
93885
|
if (pending) {
|
|
93646
93886
|
pending = false;
|
|
@@ -93650,7 +93890,7 @@ var require_aspromise = __commonJS({
|
|
|
93650
93890
|
var params2 = new Array(arguments.length - 1), offset2 = 0;
|
|
93651
93891
|
while (offset2 < params2.length)
|
|
93652
93892
|
params2[offset2++] = arguments[offset2];
|
|
93653
|
-
|
|
93893
|
+
resolve24.apply(null, params2);
|
|
93654
93894
|
}
|
|
93655
93895
|
}
|
|
93656
93896
|
};
|
|
@@ -96205,7 +96445,7 @@ var require_path = __commonJS({
|
|
|
96205
96445
|
return prefix + parts.join("/");
|
|
96206
96446
|
}
|
|
96207
96447
|
);
|
|
96208
|
-
path2.resolve = function
|
|
96448
|
+
path2.resolve = function resolve24(originPath, includePath, alreadyNormalized) {
|
|
96209
96449
|
if (!alreadyNormalized)
|
|
96210
96450
|
includePath = normalize3(includePath);
|
|
96211
96451
|
if (isAbsolute16(includePath))
|
|
@@ -96562,7 +96802,7 @@ var require_mapfield = __commonJS({
|
|
|
96562
96802
|
keepComments ? this.comment : void 0
|
|
96563
96803
|
]);
|
|
96564
96804
|
};
|
|
96565
|
-
MapField.prototype.resolve = function
|
|
96805
|
+
MapField.prototype.resolve = function resolve24() {
|
|
96566
96806
|
if (this.resolved)
|
|
96567
96807
|
return this;
|
|
96568
96808
|
if (types.mapKey[this.keyType] === void 0)
|
|
@@ -96639,7 +96879,7 @@ var require_method = __commonJS({
|
|
|
96639
96879
|
this.parsedOptions
|
|
96640
96880
|
]);
|
|
96641
96881
|
};
|
|
96642
|
-
Method.prototype.resolve = function
|
|
96882
|
+
Method.prototype.resolve = function resolve24() {
|
|
96643
96883
|
if (this.resolved)
|
|
96644
96884
|
return this;
|
|
96645
96885
|
this.resolvedRequestType = this.parent.lookupType(this.requestType);
|
|
@@ -98252,7 +98492,7 @@ var require_field = __commonJS({
|
|
|
98252
98492
|
keepComments ? this.comment : void 0
|
|
98253
98493
|
]);
|
|
98254
98494
|
};
|
|
98255
|
-
Field.prototype.resolve = function
|
|
98495
|
+
Field.prototype.resolve = function resolve24() {
|
|
98256
98496
|
if (this.resolved)
|
|
98257
98497
|
return this;
|
|
98258
98498
|
if ((this.typeDefault = types.defaults[this.type]) === void 0) {
|
|
@@ -98525,7 +98765,7 @@ var require_object = __commonJS({
|
|
|
98525
98765
|
this.parent = null;
|
|
98526
98766
|
this.resolved = false;
|
|
98527
98767
|
};
|
|
98528
|
-
ReflectionObject.prototype.resolve = function
|
|
98768
|
+
ReflectionObject.prototype.resolve = function resolve24() {
|
|
98529
98769
|
if (this.resolved)
|
|
98530
98770
|
return this;
|
|
98531
98771
|
if (this.root instanceof Root)
|
|
@@ -102080,7 +102320,7 @@ function buildSet(input, notes) {
|
|
|
102080
102320
|
for (const [name, file] of built) {
|
|
102081
102321
|
const visible = visibility.of(name);
|
|
102082
102322
|
for (const ref2 of file.pending)
|
|
102083
|
-
|
|
102323
|
+
resolve22(ref2, name, visible, everyFile, symbols);
|
|
102084
102324
|
for (const [key, text5] of file.comments) comments.set(key, text5);
|
|
102085
102325
|
for (const option of file.customOptions) customOptions.add(option);
|
|
102086
102326
|
}
|
|
@@ -102254,7 +102494,7 @@ function remember(built, name, file) {
|
|
|
102254
102494
|
built.set(name, file);
|
|
102255
102495
|
return file.proto;
|
|
102256
102496
|
}
|
|
102257
|
-
function
|
|
102497
|
+
function resolve22(ref2, file, visible, everyFile, symbols) {
|
|
102258
102498
|
const found = symbols.lookup(ref2.ref, ref2.scope, visible);
|
|
102259
102499
|
if (found === void 0) {
|
|
102260
102500
|
const everywhere = symbols.lookup(ref2.ref, ref2.scope, everyFile);
|
|
@@ -104707,19 +104947,19 @@ function retryAfterMs(value, now) {
|
|
|
104707
104947
|
return Number.isNaN(date) ? void 0 : Math.max(0, date - now);
|
|
104708
104948
|
}
|
|
104709
104949
|
function sleep(ms, signal) {
|
|
104710
|
-
return new Promise((
|
|
104950
|
+
return new Promise((resolve24) => {
|
|
104711
104951
|
if (signal.aborted) {
|
|
104712
|
-
|
|
104952
|
+
resolve24(false);
|
|
104713
104953
|
return;
|
|
104714
104954
|
}
|
|
104715
104955
|
const onAbort = () => {
|
|
104716
104956
|
clearTimeout(timer);
|
|
104717
|
-
|
|
104957
|
+
resolve24(false);
|
|
104718
104958
|
};
|
|
104719
104959
|
const timer = setTimeout(
|
|
104720
104960
|
() => {
|
|
104721
104961
|
signal.removeEventListener("abort", onAbort);
|
|
104722
|
-
|
|
104962
|
+
resolve24(true);
|
|
104723
104963
|
},
|
|
104724
104964
|
Math.min(ms, MAX_TIMER_MS)
|
|
104725
104965
|
);
|
|
@@ -104773,13 +105013,13 @@ var init_retry = __esm({
|
|
|
104773
105013
|
else signal.addEventListener("abort", this.onAbort, { once: true });
|
|
104774
105014
|
}
|
|
104775
105015
|
race(promise) {
|
|
104776
|
-
return new Promise((
|
|
105016
|
+
return new Promise((resolve24) => {
|
|
104777
105017
|
let settled2 = false;
|
|
104778
105018
|
const settle3 = (result2) => {
|
|
104779
105019
|
if (settled2) return;
|
|
104780
105020
|
settled2 = true;
|
|
104781
105021
|
this.waiter = void 0;
|
|
104782
|
-
|
|
105022
|
+
resolve24(result2);
|
|
104783
105023
|
};
|
|
104784
105024
|
promise.then(
|
|
104785
105025
|
(value) => settle3({ kind: "value", value }),
|
|
@@ -105171,8 +105411,8 @@ function sendFailure(error, sender) {
|
|
|
105171
105411
|
};
|
|
105172
105412
|
}
|
|
105173
105413
|
function settle2(run3) {
|
|
105174
|
-
return new Promise((
|
|
105175
|
-
|
|
105414
|
+
return new Promise((resolve24) => {
|
|
105415
|
+
resolve24(run3());
|
|
105176
105416
|
});
|
|
105177
105417
|
}
|
|
105178
105418
|
async function attemptOnce(spec, deadline) {
|
|
@@ -108572,7 +108812,7 @@ var require_call_credentials = __commonJS({
|
|
|
108572
108812
|
if (isCurrentOauth2Client(googleCredentials)) {
|
|
108573
108813
|
getHeaders = googleCredentials.getRequestHeaders(options.service_url);
|
|
108574
108814
|
} else {
|
|
108575
|
-
getHeaders = new Promise((
|
|
108815
|
+
getHeaders = new Promise((resolve24, reject) => {
|
|
108576
108816
|
googleCredentials.getRequestMetadata(options.service_url, (err2, headers) => {
|
|
108577
108817
|
if (err2) {
|
|
108578
108818
|
reject(err2);
|
|
@@ -108582,7 +108822,7 @@ var require_call_credentials = __commonJS({
|
|
|
108582
108822
|
reject(new Error("Headers not set by metadata plugin"));
|
|
108583
108823
|
return;
|
|
108584
108824
|
}
|
|
108585
|
-
|
|
108825
|
+
resolve24(headers);
|
|
108586
108826
|
});
|
|
108587
108827
|
});
|
|
108588
108828
|
}
|
|
@@ -108635,10 +108875,10 @@ var require_call_credentials = __commonJS({
|
|
|
108635
108875
|
this.metadataGenerator = metadataGenerator;
|
|
108636
108876
|
}
|
|
108637
108877
|
generateMetadata(options) {
|
|
108638
|
-
return new Promise((
|
|
108878
|
+
return new Promise((resolve24, reject) => {
|
|
108639
108879
|
this.metadataGenerator(options, (err2, metadata) => {
|
|
108640
108880
|
if (metadata !== void 0) {
|
|
108641
|
-
|
|
108881
|
+
resolve24(metadata);
|
|
108642
108882
|
} else {
|
|
108643
108883
|
reject(err2);
|
|
108644
108884
|
}
|
|
@@ -108997,14 +109237,14 @@ var require_channel_credentials = __commonJS({
|
|
|
108997
109237
|
}
|
|
108998
109238
|
connect(socket) {
|
|
108999
109239
|
const tlsConnectOptions = Object.assign({ socket }, this.connectionOptions);
|
|
109000
|
-
return new Promise((
|
|
109240
|
+
return new Promise((resolve24, reject) => {
|
|
109001
109241
|
const tlsSocket = (0, tls_1.connect)(tlsConnectOptions, () => {
|
|
109002
109242
|
var _a2;
|
|
109003
109243
|
if (((_a2 = this.connectionOptions.rejectUnauthorized) !== null && _a2 !== void 0 ? _a2 : true) && !tlsSocket.authorized) {
|
|
109004
109244
|
reject(tlsSocket.authorizationError);
|
|
109005
109245
|
return;
|
|
109006
109246
|
}
|
|
109007
|
-
|
|
109247
|
+
resolve24({
|
|
109008
109248
|
socket: tlsSocket,
|
|
109009
109249
|
secure: true
|
|
109010
109250
|
});
|
|
@@ -109123,8 +109363,8 @@ var require_channel_credentials = __commonJS({
|
|
|
109123
109363
|
if (this.hasReceivedUpdates()) {
|
|
109124
109364
|
return Promise.resolve(this.getLatestSecureContext());
|
|
109125
109365
|
} else {
|
|
109126
|
-
return new Promise((
|
|
109127
|
-
this.secureContextWatchers.push(
|
|
109366
|
+
return new Promise((resolve24) => {
|
|
109367
|
+
this.secureContextWatchers.push(resolve24);
|
|
109128
109368
|
});
|
|
109129
109369
|
}
|
|
109130
109370
|
}
|
|
@@ -109157,7 +109397,7 @@ var require_channel_credentials = __commonJS({
|
|
|
109157
109397
|
this.callCredentials = callCredentials;
|
|
109158
109398
|
}
|
|
109159
109399
|
connect(socket) {
|
|
109160
|
-
return new Promise((
|
|
109400
|
+
return new Promise((resolve24, reject) => {
|
|
109161
109401
|
const secureContext = this.parent.getLatestSecureContext();
|
|
109162
109402
|
if (!secureContext) {
|
|
109163
109403
|
reject(new Error("Failed to load credentials"));
|
|
@@ -109182,7 +109422,7 @@ var require_channel_credentials = __commonJS({
|
|
|
109182
109422
|
reject(tlsSocket.authorizationError);
|
|
109183
109423
|
return;
|
|
109184
109424
|
}
|
|
109185
|
-
|
|
109425
|
+
resolve24({
|
|
109186
109426
|
socket: tlsSocket,
|
|
109187
109427
|
secure: true
|
|
109188
109428
|
});
|
|
@@ -116061,18 +116301,18 @@ var require_compression_filter = __commonJS({
|
|
|
116061
116301
|
this.maxRecvMessageLength = maxRecvMessageLength;
|
|
116062
116302
|
}
|
|
116063
116303
|
compressMessage(message) {
|
|
116064
|
-
return new Promise((
|
|
116304
|
+
return new Promise((resolve24, reject) => {
|
|
116065
116305
|
zlib.deflate(message, (err2, output) => {
|
|
116066
116306
|
if (err2) {
|
|
116067
116307
|
reject(err2);
|
|
116068
116308
|
} else {
|
|
116069
|
-
|
|
116309
|
+
resolve24(output);
|
|
116070
116310
|
}
|
|
116071
116311
|
});
|
|
116072
116312
|
});
|
|
116073
116313
|
}
|
|
116074
116314
|
decompressMessage(message) {
|
|
116075
|
-
return new Promise((
|
|
116315
|
+
return new Promise((resolve24, reject) => {
|
|
116076
116316
|
let totalLength = 0;
|
|
116077
116317
|
const messageParts = [];
|
|
116078
116318
|
const decompresser = zlib.createInflate();
|
|
@@ -116094,7 +116334,7 @@ var require_compression_filter = __commonJS({
|
|
|
116094
116334
|
}
|
|
116095
116335
|
});
|
|
116096
116336
|
decompresser.on("end", () => {
|
|
116097
|
-
|
|
116337
|
+
resolve24(Buffer.concat(messageParts));
|
|
116098
116338
|
});
|
|
116099
116339
|
decompresser.write(message);
|
|
116100
116340
|
decompresser.end();
|
|
@@ -116107,18 +116347,18 @@ var require_compression_filter = __commonJS({
|
|
|
116107
116347
|
this.maxRecvMessageLength = maxRecvMessageLength;
|
|
116108
116348
|
}
|
|
116109
116349
|
compressMessage(message) {
|
|
116110
|
-
return new Promise((
|
|
116350
|
+
return new Promise((resolve24, reject) => {
|
|
116111
116351
|
zlib.gzip(message, (err2, output) => {
|
|
116112
116352
|
if (err2) {
|
|
116113
116353
|
reject(err2);
|
|
116114
116354
|
} else {
|
|
116115
|
-
|
|
116355
|
+
resolve24(output);
|
|
116116
116356
|
}
|
|
116117
116357
|
});
|
|
116118
116358
|
});
|
|
116119
116359
|
}
|
|
116120
116360
|
decompressMessage(message) {
|
|
116121
|
-
return new Promise((
|
|
116361
|
+
return new Promise((resolve24, reject) => {
|
|
116122
116362
|
let totalLength = 0;
|
|
116123
116363
|
const messageParts = [];
|
|
116124
116364
|
const decompresser = zlib.createGunzip();
|
|
@@ -116140,7 +116380,7 @@ var require_compression_filter = __commonJS({
|
|
|
116140
116380
|
}
|
|
116141
116381
|
});
|
|
116142
116382
|
decompresser.on("end", () => {
|
|
116143
|
-
|
|
116383
|
+
resolve24(Buffer.concat(messageParts));
|
|
116144
116384
|
});
|
|
116145
116385
|
decompresser.write(message);
|
|
116146
116386
|
decompresser.end();
|
|
@@ -117495,7 +117735,7 @@ var require_http_proxy = __commonJS({
|
|
|
117495
117735
|
options.headers = headers;
|
|
117496
117736
|
const proxyAddressString = (0, subchannel_address_1.subchannelAddressToString)(address);
|
|
117497
117737
|
trace("Using proxy " + proxyAddressString + " to connect to " + options.path);
|
|
117498
|
-
return new Promise((
|
|
117738
|
+
return new Promise((resolve24, reject) => {
|
|
117499
117739
|
const request3 = http2.request(options);
|
|
117500
117740
|
request3.once("connect", (res, socket, head2) => {
|
|
117501
117741
|
request3.removeAllListeners();
|
|
@@ -117506,7 +117746,7 @@ var require_http_proxy = __commonJS({
|
|
|
117506
117746
|
socket.unshift(head2);
|
|
117507
117747
|
}
|
|
117508
117748
|
trace("Successfully established a plaintext connection to " + options.path + " through proxy " + proxyAddressString);
|
|
117509
|
-
|
|
117749
|
+
resolve24(socket);
|
|
117510
117750
|
} else {
|
|
117511
117751
|
(0, logging_1.log)(constants_1.LogVerbosity.ERROR, "Failed to connect to " + options.path + " through proxy " + proxyAddressString + " with status " + res.statusCode);
|
|
117512
117752
|
reject();
|
|
@@ -118487,7 +118727,7 @@ var require_transport = __commonJS({
|
|
|
118487
118727
|
if (secureConnectResult.socket.closed) {
|
|
118488
118728
|
return Promise.reject("Connection closed before starting HTTP/2 handshake");
|
|
118489
118729
|
}
|
|
118490
|
-
return new Promise((
|
|
118730
|
+
return new Promise((resolve24, reject) => {
|
|
118491
118731
|
var _a2, _b2, _c, _d, _e, _f, _g, _h;
|
|
118492
118732
|
let remoteName = null;
|
|
118493
118733
|
let realTarget2 = this.channelTarget;
|
|
@@ -118558,7 +118798,7 @@ var require_transport = __commonJS({
|
|
|
118558
118798
|
session.removeAllListeners();
|
|
118559
118799
|
secureConnectResult.socket.removeListener("close", closeHandler);
|
|
118560
118800
|
secureConnectResult.socket.removeListener("error", errorHandler);
|
|
118561
|
-
|
|
118801
|
+
resolve24(new Http2Transport(session, address, options, remoteName));
|
|
118562
118802
|
this.session = null;
|
|
118563
118803
|
});
|
|
118564
118804
|
session.once("close", closeHandler);
|
|
@@ -118572,7 +118812,7 @@ var require_transport = __commonJS({
|
|
|
118572
118812
|
if (proxiedSocket) {
|
|
118573
118813
|
return proxiedSocket;
|
|
118574
118814
|
} else {
|
|
118575
|
-
return new Promise((
|
|
118815
|
+
return new Promise((resolve24, reject) => {
|
|
118576
118816
|
const closeCallback = () => {
|
|
118577
118817
|
reject(new Error("Socket closed"));
|
|
118578
118818
|
};
|
|
@@ -118582,7 +118822,7 @@ var require_transport = __commonJS({
|
|
|
118582
118822
|
const socket = net.connect(address, () => {
|
|
118583
118823
|
socket.removeListener("close", closeCallback);
|
|
118584
118824
|
socket.removeListener("error", errorCallback);
|
|
118585
|
-
|
|
118825
|
+
resolve24(socket);
|
|
118586
118826
|
});
|
|
118587
118827
|
socket.once("close", closeCallback);
|
|
118588
118828
|
socket.once("error", errorCallback);
|
|
@@ -121986,7 +122226,7 @@ var require_server_interceptors = __commonJS({
|
|
|
121986
122226
|
} else {
|
|
121987
122227
|
decompresser = zlib.createGunzip();
|
|
121988
122228
|
}
|
|
121989
|
-
return new Promise((
|
|
122229
|
+
return new Promise((resolve24, reject) => {
|
|
121990
122230
|
let totalLength = 0;
|
|
121991
122231
|
const messageParts = [];
|
|
121992
122232
|
decompresser.on("error", (error) => {
|
|
@@ -122007,7 +122247,7 @@ var require_server_interceptors = __commonJS({
|
|
|
122007
122247
|
}
|
|
122008
122248
|
});
|
|
122009
122249
|
decompresser.on("end", () => {
|
|
122010
|
-
|
|
122250
|
+
resolve24(Buffer.concat(messageParts));
|
|
122011
122251
|
});
|
|
122012
122252
|
decompresser.write(messageContents);
|
|
122013
122253
|
decompresser.end();
|
|
@@ -122600,10 +122840,10 @@ var require_server = __commonJS({
|
|
|
122600
122840
|
bindOneAddress(address, boundPortObject) {
|
|
122601
122841
|
this.trace("Attempting to bind " + (0, subchannel_address_1.subchannelAddressToString)(address));
|
|
122602
122842
|
const http2Server = this.createHttp2Server(boundPortObject.credentials);
|
|
122603
|
-
return new Promise((
|
|
122843
|
+
return new Promise((resolve24, reject) => {
|
|
122604
122844
|
const onError = (err2) => {
|
|
122605
122845
|
this.trace("Failed to bind " + (0, subchannel_address_1.subchannelAddressToString)(address) + " with error " + err2.message);
|
|
122606
|
-
|
|
122846
|
+
resolve24({
|
|
122607
122847
|
port: "port" in address ? address.port : 1,
|
|
122608
122848
|
error: err2.message
|
|
122609
122849
|
});
|
|
@@ -122631,7 +122871,7 @@ var require_server = __commonJS({
|
|
|
122631
122871
|
});
|
|
122632
122872
|
boundPortObject.listeningServers.add(http2Server);
|
|
122633
122873
|
this.trace("Successfully bound " + (0, subchannel_address_1.subchannelAddressToString)(boundSubchannelAddress));
|
|
122634
|
-
|
|
122874
|
+
resolve24({
|
|
122635
122875
|
port: "port" in boundSubchannelAddress ? boundSubchannelAddress.port : 1
|
|
122636
122876
|
});
|
|
122637
122877
|
http2Server.removeListener("error", onError);
|
|
@@ -122684,7 +122924,7 @@ var require_server = __commonJS({
|
|
|
122684
122924
|
}
|
|
122685
122925
|
}
|
|
122686
122926
|
resolvePort(port) {
|
|
122687
|
-
return new Promise((
|
|
122927
|
+
return new Promise((resolve24, reject) => {
|
|
122688
122928
|
let seenResolution = false;
|
|
122689
122929
|
const resolverListener = (endpointList, attributes, serviceConfig, resolutionNote) => {
|
|
122690
122930
|
if (seenResolution) {
|
|
@@ -122700,7 +122940,7 @@ var require_server = __commonJS({
|
|
|
122700
122940
|
reject(new Error(`No addresses resolved for port ${port}`));
|
|
122701
122941
|
return true;
|
|
122702
122942
|
}
|
|
122703
|
-
|
|
122943
|
+
resolve24(addressList);
|
|
122704
122944
|
return true;
|
|
122705
122945
|
};
|
|
122706
122946
|
const resolver = (0, resolver_1.createResolver)(port, resolverListener, this.options);
|
|
@@ -127277,7 +127517,7 @@ function withServers(entry2, outcome) {
|
|
|
127277
127517
|
};
|
|
127278
127518
|
}
|
|
127279
127519
|
function nextTurn() {
|
|
127280
|
-
return new Promise((
|
|
127520
|
+
return new Promise((resolve24) => setImmediate(resolve24));
|
|
127281
127521
|
}
|
|
127282
127522
|
async function runChecksWithServers(input, options = {}) {
|
|
127283
127523
|
const done = [];
|
|
@@ -128638,13 +128878,13 @@ __export(check_exports, {
|
|
|
128638
128878
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
128639
128879
|
import { createHash as createHash20 } from "node:crypto";
|
|
128640
128880
|
import {
|
|
128641
|
-
lstatSync as
|
|
128881
|
+
lstatSync as lstatSync12,
|
|
128642
128882
|
mkdirSync as mkdirSync12,
|
|
128643
|
-
readFileSync as
|
|
128883
|
+
readFileSync as readFileSync27,
|
|
128644
128884
|
readlinkSync as readlinkSync4,
|
|
128645
|
-
statSync as
|
|
128885
|
+
statSync as statSync14
|
|
128646
128886
|
} from "node:fs";
|
|
128647
|
-
import { dirname as
|
|
128887
|
+
import { dirname as dirname32, isAbsolute as isAbsolute15, join as join57, relative as relative9, resolve as resolve23, sep as sep11 } from "node:path";
|
|
128648
128888
|
function git5(cwd, args, input) {
|
|
128649
128889
|
try {
|
|
128650
128890
|
return execFileSync2("git", args, {
|
|
@@ -128676,11 +128916,11 @@ function commitOf2(root, ref2) {
|
|
|
128676
128916
|
return sha2.length > 0 ? sha2 : null;
|
|
128677
128917
|
}
|
|
128678
128918
|
function readWorkingFile(root, path2) {
|
|
128679
|
-
const abs =
|
|
128919
|
+
const abs = join57(root, ...path2.split("/"));
|
|
128680
128920
|
try {
|
|
128681
|
-
const stat7 =
|
|
128921
|
+
const stat7 = lstatSync12(abs);
|
|
128682
128922
|
if (stat7.isSymbolicLink()) return readlinkSync4(abs, "utf8");
|
|
128683
|
-
return stat7.isFile() ?
|
|
128923
|
+
return stat7.isFile() ? readFileSync27(abs, "utf8") : null;
|
|
128684
128924
|
} catch {
|
|
128685
128925
|
return null;
|
|
128686
128926
|
}
|
|
@@ -128755,25 +128995,25 @@ function chooseBase(root, ref2) {
|
|
|
128755
128995
|
}
|
|
128756
128996
|
function isFile(path2) {
|
|
128757
128997
|
try {
|
|
128758
|
-
return
|
|
128998
|
+
return statSync14(path2).isFile();
|
|
128759
128999
|
} catch {
|
|
128760
129000
|
return false;
|
|
128761
129001
|
}
|
|
128762
129002
|
}
|
|
128763
129003
|
function isDir(path2) {
|
|
128764
129004
|
try {
|
|
128765
|
-
return
|
|
129005
|
+
return statSync14(path2).isDirectory();
|
|
128766
129006
|
} catch {
|
|
128767
129007
|
return false;
|
|
128768
129008
|
}
|
|
128769
129009
|
}
|
|
128770
129010
|
function findSteeringRoot(start) {
|
|
128771
|
-
let dir =
|
|
129011
|
+
let dir = resolve23(start);
|
|
128772
129012
|
for (; ; ) {
|
|
128773
|
-
if (isFile(
|
|
129013
|
+
if (isFile(join57(dir, WORKSPACE_TOML_PATH)) || isFile(join57(dir, AGENTS_MD_PATH)) && isDir(join57(dir, STEERING_DIR))) {
|
|
128774
129014
|
return dir;
|
|
128775
129015
|
}
|
|
128776
|
-
const parent =
|
|
129016
|
+
const parent = dirname32(dir);
|
|
128777
129017
|
if (parent === dir) return null;
|
|
128778
129018
|
dir = parent;
|
|
128779
129019
|
}
|
|
@@ -128784,7 +129024,7 @@ function within3(path2, scope) {
|
|
|
128784
129024
|
function scopesFor(root, cwd, paths, trees) {
|
|
128785
129025
|
const scopes = [];
|
|
128786
129026
|
for (const path2 of paths) {
|
|
128787
|
-
const rel = relative9(root,
|
|
129027
|
+
const rel = relative9(root, resolve23(cwd, path2));
|
|
128788
129028
|
if (rel === ".." || rel.startsWith(`..${sep11}`) || isAbsolute15(rel)) {
|
|
128789
129029
|
return { error: `${path2} is outside the steering repo at ${root}.` };
|
|
128790
129030
|
}
|
|
@@ -128850,12 +129090,12 @@ function cacheFile(cacheDir, root) {
|
|
|
128850
129090
|
key: token === void 0 ? null : createHash20("sha256").update(token).digest("hex").slice(0, 16)
|
|
128851
129091
|
};
|
|
128852
129092
|
const key = createHash20("sha256").update(JSON.stringify([root, identity])).digest("hex").slice(0, 32);
|
|
128853
|
-
return
|
|
129093
|
+
return join57(cacheDir, `${key}.json`);
|
|
128854
129094
|
}
|
|
128855
129095
|
function readCache(file, now) {
|
|
128856
129096
|
let entry2;
|
|
128857
129097
|
try {
|
|
128858
|
-
entry2 = JSON.parse(
|
|
129098
|
+
entry2 = JSON.parse(readFileSync27(file, "utf8"));
|
|
128859
129099
|
} catch {
|
|
128860
129100
|
return null;
|
|
128861
129101
|
}
|
|
@@ -128878,7 +129118,7 @@ async function publishedInputs(root, deps, refresh, out) {
|
|
|
128878
129118
|
}
|
|
128879
129119
|
if (file !== null) {
|
|
128880
129120
|
try {
|
|
128881
|
-
mkdirSync12(
|
|
129121
|
+
mkdirSync12(dirname32(file), { recursive: true });
|
|
128882
129122
|
atomicWriteFileSync(
|
|
128883
129123
|
file,
|
|
128884
129124
|
JSON.stringify({
|
|
@@ -128964,7 +129204,7 @@ function defaultDeps2() {
|
|
|
128964
129204
|
return {
|
|
128965
129205
|
fetchPublished: fetchSteeringIndex,
|
|
128966
129206
|
cedar: cedarHooks,
|
|
128967
|
-
cacheDir:
|
|
129207
|
+
cacheDir: join57(getConfigDir(), "cache", "steering-check"),
|
|
128968
129208
|
now: () => Date.now()
|
|
128969
129209
|
};
|
|
128970
129210
|
}
|
|
@@ -132847,7 +133087,7 @@ var init_src9 = __esm({
|
|
|
132847
133087
|
|
|
132848
133088
|
// src/commands/codegraph-upload/files.ts
|
|
132849
133089
|
import { readdir as readdir5, stat as stat5 } from "node:fs/promises";
|
|
132850
|
-
import { join as
|
|
133090
|
+
import { join as join58, relative as relative10, sep as sep12 } from "node:path";
|
|
132851
133091
|
function hasGlobChars(pattern) {
|
|
132852
133092
|
return /[*?[\]{}]/.test(pattern);
|
|
132853
133093
|
}
|
|
@@ -132859,7 +133099,7 @@ async function walk(root, dir, out) {
|
|
|
132859
133099
|
const entries2 = await readdir5(dir, { withFileTypes: true });
|
|
132860
133100
|
for (const entry2 of entries2) {
|
|
132861
133101
|
if (entry2.isSymbolicLink()) continue;
|
|
132862
|
-
const full =
|
|
133102
|
+
const full = join58(dir, entry2.name);
|
|
132863
133103
|
if (entry2.isDirectory()) {
|
|
132864
133104
|
if (!SKIP_DIRS.has(entry2.name)) await walk(root, full, out);
|
|
132865
133105
|
} else if (entry2.isFile()) {
|
|
@@ -132871,7 +133111,7 @@ async function expandPattern(root, pattern) {
|
|
|
132871
133111
|
const wanted = normalize2(pattern.trim());
|
|
132872
133112
|
if (!hasGlobChars(wanted)) {
|
|
132873
133113
|
try {
|
|
132874
|
-
const info = await stat5(
|
|
133114
|
+
const info = await stat5(join58(root, wanted));
|
|
132875
133115
|
return info.isFile() ? [wanted] : [];
|
|
132876
133116
|
} catch {
|
|
132877
133117
|
return [];
|
|
@@ -132948,12 +133188,12 @@ async function uploadFile(input) {
|
|
|
132948
133188
|
message: `The endpoint answered ${response.status} with a body this step does not read. Update @oxagen/cli.`
|
|
132949
133189
|
};
|
|
132950
133190
|
}
|
|
132951
|
-
const
|
|
133191
|
+
const refused2 = uploadErrorSchema.safeParse(json2);
|
|
132952
133192
|
return {
|
|
132953
133193
|
ok: false,
|
|
132954
133194
|
status: response.status,
|
|
132955
|
-
code:
|
|
132956
|
-
message:
|
|
133195
|
+
code: refused2.success ? refused2.data.error.code : `http_${response.status}`,
|
|
133196
|
+
message: refused2.success ? refused2.data.error.message : `The endpoint answered ${response.status}.`
|
|
132957
133197
|
};
|
|
132958
133198
|
}
|
|
132959
133199
|
var VERSION;
|
|
@@ -133022,7 +133262,7 @@ var init_token = __esm({
|
|
|
133022
133262
|
});
|
|
133023
133263
|
|
|
133024
133264
|
// src/commands/codegraph-upload/run.ts
|
|
133025
|
-
import { join as
|
|
133265
|
+
import { join as join59 } from "node:path";
|
|
133026
133266
|
function addDropped(into, more) {
|
|
133027
133267
|
into.sensitiveValues += more.sensitiveValues;
|
|
133028
133268
|
into.secretData += more.secretData;
|
|
@@ -133040,7 +133280,7 @@ async function uploadOne(deps, config, token, group, path2, totals2) {
|
|
|
133040
133280
|
const label2 = `${group.kind}/${group.source} ${path2}`;
|
|
133041
133281
|
let bytes;
|
|
133042
133282
|
try {
|
|
133043
|
-
bytes = await deps.readFile(
|
|
133283
|
+
bytes = await deps.readFile(join59(deps.cwd, path2));
|
|
133044
133284
|
} catch (error) {
|
|
133045
133285
|
totals2.failed += 1;
|
|
133046
133286
|
deps.log(`error: ${label2}: cannot read the file: ${error.message}`);
|
|
@@ -133318,7 +133558,7 @@ Following ${file} (Ctrl-C to stop)\u2026
|
|
|
133318
133558
|
draining = false;
|
|
133319
133559
|
}
|
|
133320
133560
|
};
|
|
133321
|
-
await new Promise((
|
|
133561
|
+
await new Promise((resolve24) => {
|
|
133322
133562
|
let watcher = null;
|
|
133323
133563
|
try {
|
|
133324
133564
|
watcher = watch(file, { persistent: true }, () => void drain());
|
|
@@ -133327,12 +133567,12 @@ Following ${file} (Ctrl-C to stop)\u2026
|
|
|
133327
133567
|
`Cannot follow ${file}: ${err2 instanceof Error ? err2.message : String(err2)}
|
|
133328
133568
|
`
|
|
133329
133569
|
);
|
|
133330
|
-
|
|
133570
|
+
resolve24();
|
|
133331
133571
|
return;
|
|
133332
133572
|
}
|
|
133333
133573
|
const stop = () => {
|
|
133334
133574
|
watcher?.close();
|
|
133335
|
-
|
|
133575
|
+
resolve24();
|
|
133336
133576
|
};
|
|
133337
133577
|
process.on("SIGINT", stop);
|
|
133338
133578
|
process.on("SIGTERM", stop);
|
|
@@ -133669,7 +133909,7 @@ async function browserLogin({
|
|
|
133669
133909
|
server.keepAliveTimeout = 1e3;
|
|
133670
133910
|
server.headersTimeout = 5e3;
|
|
133671
133911
|
server.requestTimeout = 15e3;
|
|
133672
|
-
const port = await new Promise((
|
|
133912
|
+
const port = await new Promise((resolve24, reject) => {
|
|
133673
133913
|
server.once("error", reject);
|
|
133674
133914
|
server.listen(0, "127.0.0.1", () => {
|
|
133675
133915
|
const addr = server.address();
|
|
@@ -133679,7 +133919,7 @@ async function browserLogin({
|
|
|
133679
133919
|
);
|
|
133680
133920
|
return;
|
|
133681
133921
|
}
|
|
133682
|
-
|
|
133922
|
+
resolve24(addr.port);
|
|
133683
133923
|
});
|
|
133684
133924
|
});
|
|
133685
133925
|
const redirectUri = `http://127.0.0.1:${port}/callback`;
|
|
@@ -133699,7 +133939,7 @@ async function browserLogin({
|
|
|
133699
133939
|
${authorizeUrl}`);
|
|
133700
133940
|
openBrowser(authorizeUrl);
|
|
133701
133941
|
return new Promise(
|
|
133702
|
-
(
|
|
133942
|
+
(resolve24, reject) => {
|
|
133703
133943
|
let settled2 = false;
|
|
133704
133944
|
const exchangeAbort = new AbortController();
|
|
133705
133945
|
const shutdown = () => {
|
|
@@ -133832,7 +134072,7 @@ async function browserLogin({
|
|
|
133832
134072
|
}
|
|
133833
134073
|
const data = asTokenExchangeResponse(await exchangeRes.json());
|
|
133834
134074
|
await sendRedirect(cliLoginCompleteUrl(appUrl));
|
|
133835
|
-
closeAndSettle(() =>
|
|
134075
|
+
closeAndSettle(() => resolve24(data));
|
|
133836
134076
|
} catch (err2) {
|
|
133837
134077
|
const msg = err2 instanceof Error ? err2.message : String(err2);
|
|
133838
134078
|
try {
|
|
@@ -134876,7 +135116,7 @@ __export(secret_exports, {
|
|
|
134876
135116
|
handleSecretReveal: () => handleSecretReveal,
|
|
134877
135117
|
handleSecretSet: () => handleSecretSet
|
|
134878
135118
|
});
|
|
134879
|
-
import { readFileSync as
|
|
135119
|
+
import { readFileSync as readFileSync28, writeFileSync as writeFileSync8 } from "fs";
|
|
134880
135120
|
async function readStdin2() {
|
|
134881
135121
|
const chunks = [];
|
|
134882
135122
|
for await (const chunk2 of process.stdin) chunks.push(chunk2);
|
|
@@ -134989,7 +135229,7 @@ async function handleSecretReveal(key, opts, writer = stdoutWriter) {
|
|
|
134989
135229
|
async function handleSecretImport(opts, writer = stdoutWriter) {
|
|
134990
135230
|
const out = createOutput({}, writer);
|
|
134991
135231
|
try {
|
|
134992
|
-
const text5 = opts.file ?
|
|
135232
|
+
const text5 = opts.file ? readFileSync28(opts.file, "utf8") : await readStdin2();
|
|
134993
135233
|
const environmentId = opts.env ? await resolveEnvironmentId2(opts.env) : null;
|
|
134994
135234
|
const { rows, committed } = await apiPostOrThrow("secret/import-env", { text: text5, environmentId, commit: !!opts.yes });
|
|
134995
135235
|
const newCount = rows.filter((r) => r.isNewKey).length;
|