@akagilnc/pi-workflow-roles 0.1.5321 → 0.1.5325
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp-host/production-host.js +256 -310
- package/dist/engine-detour.js +1 -56
- package/dist/headless-host/production-host.js +203 -257
- package/dist/migrate-book-topology.js +119594 -102066
- package/package.json +3 -3
- package/src/engine-detour.ts +7 -88
|
@@ -4538,9 +4538,6 @@ var init_session_assistant_usage = __esm({
|
|
|
4538
4538
|
|
|
4539
4539
|
// src/engine-detour.ts
|
|
4540
4540
|
import { spawn } from "node:child_process";
|
|
4541
|
-
import { mkdtemp, rm as rm2, writeFile as writeFile4 } from "node:fs/promises";
|
|
4542
|
-
import { tmpdir } from "node:os";
|
|
4543
|
-
import { join as join15 } from "node:path";
|
|
4544
4541
|
function normalizeEngineName(engine) {
|
|
4545
4542
|
if (engine === void 0) return void 0;
|
|
4546
4543
|
const trimmed = engine.trim();
|
|
@@ -4565,21 +4562,7 @@ function abortReasonError(signal) {
|
|
|
4565
4562
|
error.name = "AbortError";
|
|
4566
4563
|
return error;
|
|
4567
4564
|
}
|
|
4568
|
-
function
|
|
4569
|
-
let replaced = 0;
|
|
4570
|
-
const out = argv.map((part) => {
|
|
4571
|
-
if (part !== ENGINE_DETOUR_STAGED_PROMPT_TOKEN) return part;
|
|
4572
|
-
replaced += 1;
|
|
4573
|
-
return stagedPath;
|
|
4574
|
-
});
|
|
4575
|
-
if (replaced !== 1) {
|
|
4576
|
-
throw new Error(
|
|
4577
|
-
`\u52B3\u52A1\u5F15\u64CE stagedPrompt \u9700\u8981 argv \u4E2D\u6070\u597D\u4E00\u4E2A ${ENGINE_DETOUR_STAGED_PROMPT_TOKEN}\uFF08\u5B9E\u9645 ${replaced}\uFF09`
|
|
4578
|
-
);
|
|
4579
|
-
}
|
|
4580
|
-
return out;
|
|
4581
|
-
}
|
|
4582
|
-
async function spawnEngineDetourOnce(input) {
|
|
4565
|
+
async function runEngineDetourOnce(input) {
|
|
4583
4566
|
if (input.argv.length === 0) {
|
|
4584
4567
|
throw new Error("\u52B3\u52A1\u5F15\u64CE argv \u4E0D\u5F97\u4E3A\u7A7A");
|
|
4585
4568
|
}
|
|
@@ -4637,42 +4620,6 @@ async function spawnEngineDetourOnce(input) {
|
|
|
4637
4620
|
});
|
|
4638
4621
|
});
|
|
4639
4622
|
}
|
|
4640
|
-
async function runEngineDetourOnce(input) {
|
|
4641
|
-
if (input.stagedPrompt === void 0) {
|
|
4642
|
-
return spawnEngineDetourOnce(input);
|
|
4643
|
-
}
|
|
4644
|
-
const stagingDir = await mkdtemp(join15(tmpdir(), "ak-engine-detour-"));
|
|
4645
|
-
const stagedPath = join15(stagingDir, "prompt.txt");
|
|
4646
|
-
let result;
|
|
4647
|
-
let runError;
|
|
4648
|
-
try {
|
|
4649
|
-
await writeFile4(stagedPath, input.stagedPrompt, "utf8");
|
|
4650
|
-
const argv = resolveArgvWithStagedPrompt(input.argv, stagedPath);
|
|
4651
|
-
result = await spawnEngineDetourOnce({
|
|
4652
|
-
argv,
|
|
4653
|
-
cwd: input.cwd,
|
|
4654
|
-
...input.env === void 0 ? {} : { env: input.env },
|
|
4655
|
-
...input.signal === void 0 ? {} : { signal: input.signal }
|
|
4656
|
-
});
|
|
4657
|
-
} catch (error) {
|
|
4658
|
-
runError = error;
|
|
4659
|
-
}
|
|
4660
|
-
try {
|
|
4661
|
-
await rm2(stagingDir, { recursive: true, force: true });
|
|
4662
|
-
} catch (cleanupError) {
|
|
4663
|
-
if (runError !== void 0) {
|
|
4664
|
-
throw new Error(
|
|
4665
|
-
`\u52B3\u52A1\u5F15\u64CE stagedPrompt \u6E05\u7406\u5931\u8D25\uFF08\u539F\u8FD0\u884C\u9519\u8BEF\u4FDD\u7559\u4E3A cause\uFF09: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`,
|
|
4666
|
-
{ cause: runError }
|
|
4667
|
-
);
|
|
4668
|
-
}
|
|
4669
|
-
throw cleanupError instanceof Error ? cleanupError : new Error(String(cleanupError));
|
|
4670
|
-
}
|
|
4671
|
-
if (runError !== void 0) {
|
|
4672
|
-
throw runError instanceof Error ? runError : new Error(String(runError));
|
|
4673
|
-
}
|
|
4674
|
-
return result;
|
|
4675
|
-
}
|
|
4676
4623
|
function isEngineDetourFailure(result) {
|
|
4677
4624
|
return result.code !== 0 || result.stdout.trim() === "";
|
|
4678
4625
|
}
|
|
@@ -4707,7 +4654,7 @@ function resolveEngineModel(getFlag) {
|
|
|
4707
4654
|
if (typeof flag !== "string") return void 0;
|
|
4708
4655
|
return normalizeEngineName(flag);
|
|
4709
4656
|
}
|
|
4710
|
-
var ENGINE_DETOUR_TOOL_NAME, AK_ROLE_ENGINE_ENV, ENGINE_FLAG_NAME, ENGINE_MODEL_FLAG_NAME,
|
|
4657
|
+
var ENGINE_DETOUR_TOOL_NAME, AK_ROLE_ENGINE_ENV, ENGINE_FLAG_NAME, ENGINE_MODEL_FLAG_NAME, ENGINE_DETOUR_EMPTY_STDOUT_DIAGNOSTIC;
|
|
4711
4658
|
var init_engine_detour = __esm({
|
|
4712
4659
|
"src/engine-detour.ts"() {
|
|
4713
4660
|
"use strict";
|
|
@@ -4715,7 +4662,6 @@ var init_engine_detour = __esm({
|
|
|
4715
4662
|
AK_ROLE_ENGINE_ENV = "AK_ROLE_ENGINE";
|
|
4716
4663
|
ENGINE_FLAG_NAME = "ak-engine";
|
|
4717
4664
|
ENGINE_MODEL_FLAG_NAME = "ak-engine-model";
|
|
4718
|
-
ENGINE_DETOUR_STAGED_PROMPT_TOKEN = "<<ak-engine-staged-prompt>>";
|
|
4719
4665
|
ENGINE_DETOUR_EMPTY_STDOUT_DIAGNOSTIC = "\u52B3\u52A1\u5F15\u64CE stdout \u4E3A\u7A7A";
|
|
4720
4666
|
}
|
|
4721
4667
|
});
|
|
@@ -4776,12 +4722,12 @@ __export(role_turn_host_exports, {
|
|
|
4776
4722
|
import { execFile, spawn as spawn2 } from "node:child_process";
|
|
4777
4723
|
import { constants } from "node:fs";
|
|
4778
4724
|
import { access, appendFile, readFile as readFile9, realpath as realpath2 } from "node:fs/promises";
|
|
4779
|
-
import { delimiter, dirname as dirname10, isAbsolute as isAbsolute3, join as
|
|
4725
|
+
import { delimiter, dirname as dirname10, isAbsolute as isAbsolute3, join as join15, resolve as resolve7 } from "node:path";
|
|
4780
4726
|
import { platform } from "node:process";
|
|
4781
4727
|
import { promisify } from "node:util";
|
|
4782
4728
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
4783
4729
|
function resolveInternalRoleEntrypoint(packageRoot) {
|
|
4784
|
-
return
|
|
4730
|
+
return join15(packageRoot, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
|
|
4785
4731
|
}
|
|
4786
4732
|
function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
|
|
4787
4733
|
return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
|
|
@@ -5540,13 +5486,13 @@ var init_session_dialogue = __esm({
|
|
|
5540
5486
|
|
|
5541
5487
|
// src/ticket-provenance.ts
|
|
5542
5488
|
import { readFile as readFile12, unlink as unlink2 } from "node:fs/promises";
|
|
5543
|
-
import { basename as basename5, dirname as dirname11, join as
|
|
5489
|
+
import { basename as basename5, dirname as dirname11, join as join16, resolve as resolve9 } from "node:path";
|
|
5544
5490
|
function dialogueSessionSourceRoots(home) {
|
|
5545
5491
|
const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
|
|
5546
5492
|
return [
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
5493
|
+
join16(machineHome, ".claude", "projects"),
|
|
5494
|
+
join16(machineHome, ".codex", "sessions"),
|
|
5495
|
+
join16(machineHome, ".pi", "agent", "sessions")
|
|
5550
5496
|
];
|
|
5551
5497
|
}
|
|
5552
5498
|
function isLedgerRoleSessionFile(absolute, home) {
|
|
@@ -5584,7 +5530,7 @@ function ticketProvenanceRecordInput(ticketNumber, cwd, home, runDirectory) {
|
|
|
5584
5530
|
};
|
|
5585
5531
|
}
|
|
5586
5532
|
async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, home) {
|
|
5587
|
-
const source =
|
|
5533
|
+
const source = join16(runDirectory, "records.jsonl");
|
|
5588
5534
|
let content;
|
|
5589
5535
|
try {
|
|
5590
5536
|
content = await readFile12(source, "utf8");
|
|
@@ -5769,7 +5715,7 @@ var init_ticket_provenance = __esm({
|
|
|
5769
5715
|
});
|
|
5770
5716
|
|
|
5771
5717
|
// src/notary-source-run.ts
|
|
5772
|
-
import { dirname as dirname12, isAbsolute as isAbsolute5, join as
|
|
5718
|
+
import { dirname as dirname12, isAbsolute as isAbsolute5, join as join17, resolve as resolve10, basename as basename6 } from "node:path";
|
|
5773
5719
|
import { lstat, realpath as realpath3 } from "node:fs/promises";
|
|
5774
5720
|
async function readRetainedIdentity(runDirectory) {
|
|
5775
5721
|
try {
|
|
@@ -5826,11 +5772,11 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
5826
5772
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
5827
5773
|
const bookKey = resolveBookKeyFromGit(options.projectRoot);
|
|
5828
5774
|
const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
|
|
5829
|
-
const bookRunsRoot =
|
|
5775
|
+
const bookRunsRoot = join17(bookDirectory, "runs");
|
|
5830
5776
|
let candidate;
|
|
5831
5777
|
const bare = parseRunDirectoryName(raw);
|
|
5832
5778
|
if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
|
|
5833
|
-
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ??
|
|
5779
|
+
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join17(bookRunsRoot, `${bare.runId}@${bare.role}`);
|
|
5834
5780
|
} else {
|
|
5835
5781
|
candidate = isAbsolute5(raw) ? raw : resolve10(options.projectRoot, raw);
|
|
5836
5782
|
const identity2 = parseRunDirectoryName(basename6(candidate));
|
|
@@ -6963,15 +6909,15 @@ import { execFileSync as execFileSync2 } from "node:child_process";
|
|
|
6963
6909
|
import { existsSync as existsSync4 } from "node:fs";
|
|
6964
6910
|
import {
|
|
6965
6911
|
lstat as lstat2,
|
|
6966
|
-
mkdtemp
|
|
6912
|
+
mkdtemp,
|
|
6967
6913
|
readFile as readFile13,
|
|
6968
6914
|
realpath as realpath4,
|
|
6969
6915
|
rename as rename2,
|
|
6970
|
-
rm as
|
|
6971
|
-
writeFile as
|
|
6916
|
+
rm as rm2,
|
|
6917
|
+
writeFile as writeFile4
|
|
6972
6918
|
} from "node:fs/promises";
|
|
6973
|
-
import { tmpdir
|
|
6974
|
-
import { basename as basename7, dirname as dirname13, isAbsolute as isAbsolute6, join as
|
|
6919
|
+
import { tmpdir } from "node:os";
|
|
6920
|
+
import { basename as basename7, dirname as dirname13, isAbsolute as isAbsolute6, join as join18, resolve as resolve11, sep as sep3 } from "node:path";
|
|
6975
6921
|
function issueAdmissionPlacement(authority, request) {
|
|
6976
6922
|
const ledgerHome = resolveActivationLedgerHome(request.home);
|
|
6977
6923
|
const bookKey = resolveBookKeyFromGit(request.cwd);
|
|
@@ -6996,7 +6942,7 @@ async function writeAdmittedRequestPersistence(admittedRequestPath, body, coordi
|
|
|
6996
6942
|
sessionDirectory: coordinates.sessionDirectory,
|
|
6997
6943
|
sessionFile: coordinates.sessionFile
|
|
6998
6944
|
};
|
|
6999
|
-
await
|
|
6945
|
+
await writeFile4(
|
|
7000
6946
|
admittedRequestPath,
|
|
7001
6947
|
`${JSON.stringify(projection, null, 2)}
|
|
7002
6948
|
`,
|
|
@@ -7024,15 +6970,15 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
|
|
|
7024
6970
|
...source.ticketNumber === void 0 ? {} : { ticketNumber: source.ticketNumber },
|
|
7025
6971
|
...effectiveModelLedgerFields(effectiveModel)
|
|
7026
6972
|
};
|
|
7027
|
-
await
|
|
7028
|
-
|
|
6973
|
+
await writeFile4(
|
|
6974
|
+
join18(source.runDirectory, "invocation.json"),
|
|
7029
6975
|
`${JSON.stringify(identity, null, 2)}
|
|
7030
6976
|
`,
|
|
7031
6977
|
"utf8"
|
|
7032
6978
|
);
|
|
7033
6979
|
}
|
|
7034
6980
|
async function recordEffectiveInvocationModel(runDirectory, model, engine, host, engineModel) {
|
|
7035
|
-
const ledgerPath =
|
|
6981
|
+
const ledgerPath = join18(runDirectory, "invocation.json");
|
|
7036
6982
|
const current = JSON.parse(await readFile13(ledgerPath, "utf8"));
|
|
7037
6983
|
const next = { ...current };
|
|
7038
6984
|
if (model !== void 0) {
|
|
@@ -7057,7 +7003,7 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host,
|
|
|
7057
7003
|
if (host !== void 0) {
|
|
7058
7004
|
next.host = host;
|
|
7059
7005
|
}
|
|
7060
|
-
await
|
|
7006
|
+
await writeFile4(
|
|
7061
7007
|
ledgerPath,
|
|
7062
7008
|
`${JSON.stringify(next, null, 2)}
|
|
7063
7009
|
`,
|
|
@@ -7065,9 +7011,9 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host,
|
|
|
7065
7011
|
);
|
|
7066
7012
|
}
|
|
7067
7013
|
async function mergeInvocationIdentityPage(runDirectory, fields) {
|
|
7068
|
-
const ledgerPath =
|
|
7014
|
+
const ledgerPath = join18(runDirectory, "invocation.json");
|
|
7069
7015
|
const current = JSON.parse(await readFile13(ledgerPath, "utf8"));
|
|
7070
|
-
await
|
|
7016
|
+
await writeFile4(
|
|
7071
7017
|
ledgerPath,
|
|
7072
7018
|
`${JSON.stringify({
|
|
7073
7019
|
...current,
|
|
@@ -7090,7 +7036,7 @@ async function persistAdmittedSourceRunPath(admitted, sourceRunPath, auditorSubj
|
|
|
7090
7036
|
}
|
|
7091
7037
|
const sameSubject = auditorSubject === void 0 || current.auditorSubject === auditorSubject;
|
|
7092
7038
|
if (current.sourceRunPath === sourceRunPath && sameSubject) return;
|
|
7093
|
-
await
|
|
7039
|
+
await writeFile4(
|
|
7094
7040
|
admittedPath,
|
|
7095
7041
|
`${JSON.stringify({
|
|
7096
7042
|
...current,
|
|
@@ -7117,7 +7063,7 @@ async function recordAdmittedCorrelation(admitted, correlationId) {
|
|
|
7117
7063
|
...typeof current.correlationId === "string" && current.correlationId.trim() !== "" ? [current.correlationId] : []
|
|
7118
7064
|
];
|
|
7119
7065
|
const correlationIds = [.../* @__PURE__ */ new Set([...prior, correlationId])];
|
|
7120
|
-
await
|
|
7066
|
+
await writeFile4(
|
|
7121
7067
|
admitted.admittedRequestPath,
|
|
7122
7068
|
`${JSON.stringify({ ...current, correlationId, correlationIds }, null, 2)}
|
|
7123
7069
|
`,
|
|
@@ -7148,7 +7094,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
7148
7094
|
const childRunIds = parentPage.childDiaristRunIds;
|
|
7149
7095
|
for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
|
|
7150
7096
|
if (typeof childRunId !== "string") continue;
|
|
7151
|
-
const childDirectory =
|
|
7097
|
+
const childDirectory = join18(dirname13(oldRunDirectory), `${childRunId}@diarist`);
|
|
7152
7098
|
if (!existsSync4(childDirectory)) continue;
|
|
7153
7099
|
const childTarget = roleRunPlacement(ledgerHome, {
|
|
7154
7100
|
bookKey: admitted.bookKey,
|
|
@@ -7197,7 +7143,7 @@ async function recordChildDiaristRun(parent, childRunId) {
|
|
|
7197
7143
|
const page = JSON.parse(await readFile13(parent.admittedRequestPath, "utf8"));
|
|
7198
7144
|
const existing = Array.isArray(page.childDiaristRunIds) ? page.childDiaristRunIds.filter((runId) => typeof runId === "string") : [];
|
|
7199
7145
|
const childDiaristRunIds = existing.includes(childRunId) ? existing : [...existing, childRunId];
|
|
7200
|
-
await
|
|
7146
|
+
await writeFile4(parent.admittedRequestPath, `${JSON.stringify({ ...page, childDiaristRunIds }, null, 2)}
|
|
7201
7147
|
`, "utf8");
|
|
7202
7148
|
}
|
|
7203
7149
|
async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
@@ -7205,10 +7151,10 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
|
7205
7151
|
ticketNumber,
|
|
7206
7152
|
"bindTicketNumberOnRunDirectory"
|
|
7207
7153
|
);
|
|
7208
|
-
const admittedPath =
|
|
7154
|
+
const admittedPath = join18(runDirectory, "admitted-request.json");
|
|
7209
7155
|
const admitted = JSON.parse(await readFile13(admittedPath, "utf8"));
|
|
7210
7156
|
if (admitted.ticketNumber === ticketNumber) return;
|
|
7211
|
-
await
|
|
7157
|
+
await writeFile4(
|
|
7212
7158
|
admittedPath,
|
|
7213
7159
|
`${JSON.stringify({ ...admitted, ticketNumber }, null, 2)}
|
|
7214
7160
|
`,
|
|
@@ -7225,7 +7171,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
7225
7171
|
async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
|
|
7226
7172
|
const rolePackageRoot = packageRoot;
|
|
7227
7173
|
const raw = JSON.parse(
|
|
7228
|
-
await readFile13(
|
|
7174
|
+
await readFile13(join18(rolePackageRoot, "package.json"), "utf8")
|
|
7229
7175
|
);
|
|
7230
7176
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
7231
7177
|
throw new Error(
|
|
@@ -7509,18 +7455,18 @@ async function readRegularFileAttachment(sourcePath) {
|
|
|
7509
7455
|
}
|
|
7510
7456
|
}
|
|
7511
7457
|
async function removePreparedAttachmentDirectory(stagingDirectory) {
|
|
7512
|
-
await
|
|
7458
|
+
await rm2(stagingDirectory, { recursive: true, force: true });
|
|
7513
7459
|
}
|
|
7514
7460
|
async function withPreparedAttachments(attachmentPaths, use) {
|
|
7515
7461
|
if (attachmentPaths.length === 0) return await use([]);
|
|
7516
|
-
const stagingDirectory = await
|
|
7462
|
+
const stagingDirectory = await mkdtemp(join18(tmpdir(), "ak-role-attachments-"));
|
|
7517
7463
|
const prepared = [];
|
|
7518
7464
|
let result;
|
|
7519
7465
|
try {
|
|
7520
7466
|
for (let index = 0; index < attachmentPaths.length; index += 1) {
|
|
7521
7467
|
const { absolute, bytes } = await readRegularFileAttachment(attachmentPaths[index]);
|
|
7522
|
-
const snapshotPath =
|
|
7523
|
-
await
|
|
7468
|
+
const snapshotPath = join18(stagingDirectory, String(index).padStart(6, "0"));
|
|
7469
|
+
await writeFile4(snapshotPath, bytes);
|
|
7524
7470
|
prepared.push({ absolute, snapshotPath });
|
|
7525
7471
|
}
|
|
7526
7472
|
result = await use(prepared);
|
|
@@ -7540,11 +7486,11 @@ async function withPreparedAttachments(attachmentPaths, use) {
|
|
|
7540
7486
|
return result;
|
|
7541
7487
|
}
|
|
7542
7488
|
async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, index) {
|
|
7543
|
-
const frozenPath =
|
|
7489
|
+
const frozenPath = join18(
|
|
7544
7490
|
destinationDir,
|
|
7545
7491
|
`${String(index).padStart(2, "0")}-${basename7(provenancePath)}`
|
|
7546
7492
|
);
|
|
7547
|
-
await
|
|
7493
|
+
await writeFile4(frozenPath, bytes);
|
|
7548
7494
|
return {
|
|
7549
7495
|
provenancePath,
|
|
7550
7496
|
frozenPath,
|
|
@@ -7583,14 +7529,14 @@ async function freezeAttachments(attachmentPaths, attachmentsDirectory) {
|
|
|
7583
7529
|
async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKey = `s-${Date.now().toString(36)}`) {
|
|
7584
7530
|
if (attachmentPaths.length === 0) return [];
|
|
7585
7531
|
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
7586
|
-
const attachmentsDirectory =
|
|
7532
|
+
const attachmentsDirectory = join18(runDirectory, "attachments", summonsKey);
|
|
7587
7533
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
7588
7534
|
return freezeAttachments(attachmentPaths, attachmentsDirectory);
|
|
7589
7535
|
}
|
|
7590
7536
|
async function freezePreparedAttachmentsIntoRun(prepared, runDirectory, summonsKey) {
|
|
7591
7537
|
if (prepared.length === 0) return [];
|
|
7592
7538
|
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
7593
|
-
const attachmentsDirectory = summonsKey === void 0 ?
|
|
7539
|
+
const attachmentsDirectory = summonsKey === void 0 ? join18(runDirectory, "attachments") : join18(runDirectory, "attachments", summonsKey);
|
|
7594
7540
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
7595
7541
|
const attachments = [];
|
|
7596
7542
|
for (let index = 0; index < prepared.length; index += 1) {
|
|
@@ -7667,8 +7613,8 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7667
7613
|
attachmentPaths,
|
|
7668
7614
|
...project,
|
|
7669
7615
|
placedFields: async (placed) => {
|
|
7670
|
-
const taskPath =
|
|
7671
|
-
await
|
|
7616
|
+
const taskPath = join18(placed.runDirectory, "task.md");
|
|
7617
|
+
await writeFile4(taskPath, instruction, "utf8");
|
|
7672
7618
|
return { phase, taskPath };
|
|
7673
7619
|
}
|
|
7674
7620
|
});
|
|
@@ -7713,16 +7659,16 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7713
7659
|
placedFields: async (placed) => {
|
|
7714
7660
|
let prerequisitesPath;
|
|
7715
7661
|
if (prerequisitesSource !== void 0) {
|
|
7716
|
-
prerequisitesPath =
|
|
7717
|
-
await
|
|
7662
|
+
prerequisitesPath = join18(placed.runDirectory, "prerequisites.json");
|
|
7663
|
+
await writeFile4(
|
|
7718
7664
|
prerequisitesPath,
|
|
7719
7665
|
`${JSON.stringify(prerequisites, null, 2)}
|
|
7720
7666
|
`,
|
|
7721
7667
|
"utf8"
|
|
7722
7668
|
);
|
|
7723
7669
|
}
|
|
7724
|
-
const packetPath =
|
|
7725
|
-
await
|
|
7670
|
+
const packetPath = join18(placed.runDirectory, "fix-packet.md");
|
|
7671
|
+
await writeFile4(packetPath, instruction, "utf8");
|
|
7726
7672
|
return {
|
|
7727
7673
|
phase,
|
|
7728
7674
|
packetPath,
|
|
@@ -7779,8 +7725,8 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7779
7725
|
placedFields: async (placed) => {
|
|
7780
7726
|
let requestManifestPath;
|
|
7781
7727
|
if (manifestCanonicalJson !== void 0) {
|
|
7782
|
-
requestManifestPath =
|
|
7783
|
-
await
|
|
7728
|
+
requestManifestPath = join18(placed.runDirectory, "request-manifest.json");
|
|
7729
|
+
await writeFile4(requestManifestPath, manifestCanonicalJson, "utf8");
|
|
7784
7730
|
}
|
|
7785
7731
|
return {
|
|
7786
7732
|
...explicitPrNumber === void 0 ? {} : { prNumber: explicitPrNumber },
|
|
@@ -7969,8 +7915,8 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7969
7915
|
resolutionScope: [...derived.resolutionScope],
|
|
7970
7916
|
authorizedChecks: []
|
|
7971
7917
|
});
|
|
7972
|
-
const mergerInputPath =
|
|
7973
|
-
await
|
|
7918
|
+
const mergerInputPath = join18(placed.runDirectory, "merger-input.json");
|
|
7919
|
+
await writeFile4(
|
|
7974
7920
|
mergerInputPath,
|
|
7975
7921
|
`${JSON.stringify(mergerInput, null, 2)}
|
|
7976
7922
|
`,
|
|
@@ -8043,7 +7989,7 @@ function persistedAttachmentRefs(attachments) {
|
|
|
8043
7989
|
}));
|
|
8044
7990
|
}
|
|
8045
7991
|
async function persistPlacedAdmission(admitted, placed, model) {
|
|
8046
|
-
const admittedRequestPath =
|
|
7992
|
+
const admittedRequestPath = join18(placed.runDirectory, "admitted-request.json");
|
|
8047
7993
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
8048
7994
|
sessionDirectory: placed.sessionDirectory,
|
|
8049
7995
|
sessionFile: placed.sessionFile
|
|
@@ -8096,7 +8042,7 @@ async function admitStandardMaterialInvocation(role, options) {
|
|
|
8096
8042
|
attachments: persistedAttachmentRefs(placed.attachments),
|
|
8097
8043
|
...placed.ticketFields
|
|
8098
8044
|
};
|
|
8099
|
-
const admittedRequestPath = defer ?
|
|
8045
|
+
const admittedRequestPath = defer ? join18(placed.runDirectory, "admitted-request.json") : await persistPlacedAdmission(admitted, placed, options.model);
|
|
8100
8046
|
return {
|
|
8101
8047
|
role,
|
|
8102
8048
|
runId: placed.runId,
|
|
@@ -8174,7 +8120,7 @@ async function materializeCountersignInvocation(admitted, options) {
|
|
|
8174
8120
|
});
|
|
8175
8121
|
const placement = placed;
|
|
8176
8122
|
admitted.runDirectory = placement.runDirectory;
|
|
8177
|
-
admitted.admittedRequestPath =
|
|
8123
|
+
admitted.admittedRequestPath = join18(
|
|
8178
8124
|
placement.runDirectory,
|
|
8179
8125
|
"admitted-request.json"
|
|
8180
8126
|
);
|
|
@@ -8201,7 +8147,7 @@ async function materializeCountersignInvocation(admitted, options) {
|
|
|
8201
8147
|
async function loadAdmittedJudgeRequest(runDirectory) {
|
|
8202
8148
|
try {
|
|
8203
8149
|
const raw = JSON.parse(
|
|
8204
|
-
await readFile13(
|
|
8150
|
+
await readFile13(join18(runDirectory, "admitted-request.json"), "utf8")
|
|
8205
8151
|
);
|
|
8206
8152
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
8207
8153
|
const record4 = raw;
|
|
@@ -8290,7 +8236,7 @@ function parseDoctorIssueNumber(raw) {
|
|
|
8290
8236
|
}
|
|
8291
8237
|
async function resolveDoctorCaseRunsPath(options) {
|
|
8292
8238
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
8293
|
-
const defaultRuns =
|
|
8239
|
+
const defaultRuns = join18(
|
|
8294
8240
|
activationBookDirectory(ledgerHome, options.bookKey),
|
|
8295
8241
|
String(options.issueNumber),
|
|
8296
8242
|
"runs"
|
|
@@ -8611,15 +8557,15 @@ var init_invocation = __esm({
|
|
|
8611
8557
|
|
|
8612
8558
|
// src/public-cli/load-production-acp-host.ts
|
|
8613
8559
|
import { existsSync as existsSync5 } from "node:fs";
|
|
8614
|
-
import { join as
|
|
8560
|
+
import { join as join19 } from "node:path";
|
|
8615
8561
|
import { pathToFileURL } from "node:url";
|
|
8616
8562
|
async function loadProductionAcpHostFactory(packageRoot, host) {
|
|
8617
8563
|
const description = lookupHostDescription(host);
|
|
8618
8564
|
if (description === void 0) {
|
|
8619
8565
|
throw new Error(`unregistered host: ${host}`);
|
|
8620
8566
|
}
|
|
8621
|
-
const built =
|
|
8622
|
-
const source =
|
|
8567
|
+
const built = join19(packageRoot, "dist/acp-host/production-host.js");
|
|
8568
|
+
const source = join19(packageRoot, "src/acp-host/production-host.ts");
|
|
8623
8569
|
const target = existsSync5(built) ? built : source;
|
|
8624
8570
|
const href = pathToFileURL(target).href;
|
|
8625
8571
|
const mod = await import(href);
|
|
@@ -8635,15 +8581,15 @@ var init_load_production_acp_host = __esm({
|
|
|
8635
8581
|
|
|
8636
8582
|
// src/public-cli/load-production-headless-host.ts
|
|
8637
8583
|
import { existsSync as existsSync6 } from "node:fs";
|
|
8638
|
-
import { join as
|
|
8584
|
+
import { join as join20 } from "node:path";
|
|
8639
8585
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
8640
8586
|
async function loadProductionHeadlessHostFactory(packageRoot, host) {
|
|
8641
8587
|
const description = lookupHeadlessHostDescription(host);
|
|
8642
8588
|
if (description === void 0) {
|
|
8643
8589
|
throw new Error(`unregistered headless host: ${host}`);
|
|
8644
8590
|
}
|
|
8645
|
-
const built =
|
|
8646
|
-
const source =
|
|
8591
|
+
const built = join20(packageRoot, "dist/headless-host/production-host.js");
|
|
8592
|
+
const source = join20(packageRoot, "src/headless-host/production-host.ts");
|
|
8647
8593
|
const target = existsSync6(built) ? built : source;
|
|
8648
8594
|
const href = pathToFileURL2(target).href;
|
|
8649
8595
|
const mod = await import(href);
|
|
@@ -8782,15 +8728,15 @@ __export(host_providers_exports, {
|
|
|
8782
8728
|
renderHostProvidersTable: () => renderHostProvidersTable
|
|
8783
8729
|
});
|
|
8784
8730
|
import { readFileSync } from "node:fs";
|
|
8785
|
-
import { join as
|
|
8731
|
+
import { join as join21 } from "node:path";
|
|
8786
8732
|
function hostProvidersPath(home) {
|
|
8787
8733
|
if (typeof home !== "string" || home.trim() === "") {
|
|
8788
8734
|
throw new Error("home must be explicitly provided");
|
|
8789
8735
|
}
|
|
8790
|
-
return
|
|
8736
|
+
return join21(home, ".ak-roles", "host-providers.json");
|
|
8791
8737
|
}
|
|
8792
8738
|
function hermesProviderModelsCachePath(home) {
|
|
8793
|
-
return
|
|
8739
|
+
return join21(home, ".hermes", "provider_models_cache.json");
|
|
8794
8740
|
}
|
|
8795
8741
|
function parseHostProvidersTable(value) {
|
|
8796
8742
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
@@ -8946,7 +8892,7 @@ var init_host_providers = __esm({
|
|
|
8946
8892
|
|
|
8947
8893
|
// src/analyst-gate-cycles-read.ts
|
|
8948
8894
|
import { readdir as readdir4 } from "node:fs/promises";
|
|
8949
|
-
import { join as
|
|
8895
|
+
import { join as join22 } from "node:path";
|
|
8950
8896
|
function isRecord6(value) {
|
|
8951
8897
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8952
8898
|
}
|
|
@@ -9197,7 +9143,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
|
|
|
9197
9143
|
throw error;
|
|
9198
9144
|
}
|
|
9199
9145
|
for (const name of names) {
|
|
9200
|
-
const path =
|
|
9146
|
+
const path = join22(directory, name);
|
|
9201
9147
|
const fromPointer = name.endsWith(".pointer.json");
|
|
9202
9148
|
const pointer = fromPointer ? await resolveOfficerSessionFromPointerFile(path) : void 0;
|
|
9203
9149
|
const sessionPath = pointer?.sessionFile ?? path;
|
|
@@ -9239,7 +9185,7 @@ var init_analyst_gate_cycles_read = __esm({
|
|
|
9239
9185
|
});
|
|
9240
9186
|
|
|
9241
9187
|
// src/submission-ledger.ts
|
|
9242
|
-
import { join as
|
|
9188
|
+
import { join as join23 } from "node:path";
|
|
9243
9189
|
function runIdentity(context) {
|
|
9244
9190
|
const directory = runDirectoryFromHostContext(context);
|
|
9245
9191
|
if (directory !== void 0) {
|
|
@@ -9261,7 +9207,7 @@ async function submissionRecordFile(cwd, runId, scope) {
|
|
|
9261
9207
|
if (sessionParent === void 0) {
|
|
9262
9208
|
const discoveredRun = await findRunDirectoryById(scope.home, runId);
|
|
9263
9209
|
if (discoveredRun === void 0) return void 0;
|
|
9264
|
-
sessionParent =
|
|
9210
|
+
sessionParent = join23(discoveredRun, "session", "session.jsonl");
|
|
9265
9211
|
}
|
|
9266
9212
|
return resolveSitianRecordPathInLedger({
|
|
9267
9213
|
level: "event",
|
|
@@ -9454,12 +9400,12 @@ async function restoreState(cwd, runId, scope) {
|
|
|
9454
9400
|
}
|
|
9455
9401
|
function sessionParentFromHostContext(context) {
|
|
9456
9402
|
const runDirectory = runDirectoryFromHostContext(context);
|
|
9457
|
-
if (runDirectory !== void 0) return
|
|
9403
|
+
if (runDirectory !== void 0) return join23(runDirectory, "session", "session.jsonl");
|
|
9458
9404
|
const sessionFile = context.sessionManager.getSessionFile?.();
|
|
9459
9405
|
if (typeof sessionFile === "string" && sessionFile.length > 0) return sessionFile;
|
|
9460
9406
|
const sessionDir = context.sessionManager.getSessionDir?.();
|
|
9461
9407
|
if (typeof sessionDir === "string" && sessionDir.length > 0) {
|
|
9462
|
-
return
|
|
9408
|
+
return join23(sessionDir, "session.jsonl");
|
|
9463
9409
|
}
|
|
9464
9410
|
return void 0;
|
|
9465
9411
|
}
|
|
@@ -9647,12 +9593,12 @@ var init_audit_escalation = __esm({
|
|
|
9647
9593
|
// src/session-opening-materials.ts
|
|
9648
9594
|
import { existsSync as existsSync7 } from "node:fs";
|
|
9649
9595
|
import { readFile as readFile14 } from "node:fs/promises";
|
|
9650
|
-
import { dirname as dirname14, join as
|
|
9596
|
+
import { dirname as dirname14, join as join24 } from "node:path";
|
|
9651
9597
|
import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
9652
9598
|
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
9653
9599
|
let dir = dirname14(fileURLToPath(moduleUrl));
|
|
9654
9600
|
for (let i = 0; i < 8; i += 1) {
|
|
9655
|
-
if (existsSync7(
|
|
9601
|
+
if (existsSync7(join24(dir, "package.json")) && existsSync7(join24(dir, "souls"))) {
|
|
9656
9602
|
return dir;
|
|
9657
9603
|
}
|
|
9658
9604
|
const parent = dirname14(dir);
|
|
@@ -9721,7 +9667,7 @@ __export(auditor_soul_exports, {
|
|
|
9721
9667
|
resolveAuditorSubject: () => resolveAuditorSubject
|
|
9722
9668
|
});
|
|
9723
9669
|
import { readFile as readFile15 } from "node:fs/promises";
|
|
9724
|
-
import { basename as basename8, join as
|
|
9670
|
+
import { basename as basename8, join as join25 } from "node:path";
|
|
9725
9671
|
function auditorSoulRelativePath(role) {
|
|
9726
9672
|
return `souls/${role}-auditor.md`;
|
|
9727
9673
|
}
|
|
@@ -9763,7 +9709,7 @@ function subjectFromSourceDirectory(sourceRunDirectory) {
|
|
|
9763
9709
|
async function readAuditorResumeBinding(runDirectory) {
|
|
9764
9710
|
let raw;
|
|
9765
9711
|
try {
|
|
9766
|
-
raw = JSON.parse(await readFile15(
|
|
9712
|
+
raw = JSON.parse(await readFile15(join25(runDirectory, "admitted-request.json"), "utf8"));
|
|
9767
9713
|
} catch (error) {
|
|
9768
9714
|
if (error.code === "ENOENT") return void 0;
|
|
9769
9715
|
throw error;
|
|
@@ -9876,7 +9822,7 @@ var init_serialize_thrown_value = __esm({
|
|
|
9876
9822
|
// src/engine-detour-usage.ts
|
|
9877
9823
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
9878
9824
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
9879
|
-
import { dirname as dirname15, join as
|
|
9825
|
+
import { dirname as dirname15, join as join26 } from "node:path";
|
|
9880
9826
|
function engineDetourStdoutByteLength(stdout) {
|
|
9881
9827
|
return Buffer.byteLength(stdout, "utf8");
|
|
9882
9828
|
}
|
|
@@ -10013,7 +9959,7 @@ function projectEngineDetourToolUsageForPublicTerminal(usage, options) {
|
|
|
10013
9959
|
function readInvocationRecord(runDirectory) {
|
|
10014
9960
|
try {
|
|
10015
9961
|
const raw = JSON.parse(
|
|
10016
|
-
readFileSync2(
|
|
9962
|
+
readFileSync2(join26(runDirectory, "invocation.json"), "utf8")
|
|
10017
9963
|
);
|
|
10018
9964
|
return isRecord7(raw) ? raw : void 0;
|
|
10019
9965
|
} catch (error) {
|
|
@@ -10041,7 +9987,7 @@ function runDirectoryFromSessionDirectory(sessionDirectory) {
|
|
|
10041
9987
|
return dirname15(sessionDirectory);
|
|
10042
9988
|
}
|
|
10043
9989
|
function sessionFileFromSessionDirectory(sessionDirectory) {
|
|
10044
|
-
return
|
|
9990
|
+
return join26(sessionDirectory, "session.jsonl");
|
|
10045
9991
|
}
|
|
10046
9992
|
function mintEngineDetourInvocationScope(input) {
|
|
10047
9993
|
const engine = input.effectiveEngine?.trim();
|
|
@@ -10285,15 +10231,15 @@ __export(settlement_exports, {
|
|
|
10285
10231
|
withSubmissions: () => withSubmissions
|
|
10286
10232
|
});
|
|
10287
10233
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
10288
|
-
import { appendFile as appendFile2, readFile as readFile16, readdir as readdir5, rm as
|
|
10289
|
-
import { dirname as dirname16, join as
|
|
10234
|
+
import { appendFile as appendFile2, readFile as readFile16, readdir as readdir5, rm as rm3, writeFile as writeFile5 } from "node:fs/promises";
|
|
10235
|
+
import { dirname as dirname16, join as join27 } from "node:path";
|
|
10290
10236
|
function sealedLedgerHome(admitted) {
|
|
10291
10237
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
10292
10238
|
}
|
|
10293
10239
|
function ledgerReadScope(admitted, scope) {
|
|
10294
10240
|
return {
|
|
10295
10241
|
home: sealedLedgerHome(admitted),
|
|
10296
|
-
sessionParent:
|
|
10242
|
+
sessionParent: join27(admitted.runDirectory, "session", "session.jsonl"),
|
|
10297
10243
|
...scope?.courtAttemptId === void 0 || scope.courtAttemptId.length === 0 ? {} : { attemptId: scope.courtAttemptId }
|
|
10298
10244
|
};
|
|
10299
10245
|
}
|
|
@@ -10794,7 +10740,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
10794
10740
|
}
|
|
10795
10741
|
const parentId = parentEntries.find((entry) => entry.type === "session")?.id;
|
|
10796
10742
|
if (parentId === void 0) return void 0;
|
|
10797
|
-
const childDirectories = [
|
|
10743
|
+
const childDirectories = [join27(dirname16(sessionFile), "auditor-roles")];
|
|
10798
10744
|
const valid = [];
|
|
10799
10745
|
let sawAnyDirectory = false;
|
|
10800
10746
|
for (const childDirectory of childDirectories) {
|
|
@@ -10809,7 +10755,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
10809
10755
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
10810
10756
|
let entries;
|
|
10811
10757
|
try {
|
|
10812
|
-
entries = await readBoundSessionEntries(
|
|
10758
|
+
entries = await readBoundSessionEntries(join27(childDirectory, file));
|
|
10813
10759
|
} catch (error) {
|
|
10814
10760
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
10815
10761
|
}
|
|
@@ -11285,8 +11231,8 @@ function projectTerminalGateFact(rounds) {
|
|
|
11285
11231
|
};
|
|
11286
11232
|
}
|
|
11287
11233
|
async function extractGateFactFromSessionDirectory(sessionDirectory, options = {}) {
|
|
11288
|
-
const directories = [
|
|
11289
|
-
const parentSessionFile = options.parentSessionFile ??
|
|
11234
|
+
const directories = [join27(sessionDirectory, "auditor-roles")];
|
|
11235
|
+
const parentSessionFile = options.parentSessionFile ?? join27(sessionDirectory, "session.jsonl");
|
|
11290
11236
|
const rounds = await readAnalystGateCyclesFromAuditorRoles(directories, {
|
|
11291
11237
|
parentSessionFile
|
|
11292
11238
|
});
|
|
@@ -11389,7 +11335,7 @@ async function extractNavigatorFactFromAdmittedSession(sessionFile) {
|
|
|
11389
11335
|
}
|
|
11390
11336
|
async function removeFaceIfPresent(path) {
|
|
11391
11337
|
try {
|
|
11392
|
-
await
|
|
11338
|
+
await rm3(path, { recursive: true, force: true });
|
|
11393
11339
|
} catch (error) {
|
|
11394
11340
|
if (isAbsentFacePathError(error)) return;
|
|
11395
11341
|
throw error;
|
|
@@ -11398,10 +11344,10 @@ async function removeFaceIfPresent(path) {
|
|
|
11398
11344
|
async function clearOppositeTerminalArtifactFace(runDirectory) {
|
|
11399
11345
|
const artifactsDir = roleRunArtifactsDirectory(runDirectory);
|
|
11400
11346
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
11401
|
-
await removeFaceIfPresent(
|
|
11347
|
+
await removeFaceIfPresent(join27(artifactsDir, file));
|
|
11402
11348
|
}
|
|
11403
11349
|
for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
11404
|
-
await removeFaceIfPresent(
|
|
11350
|
+
await removeFaceIfPresent(join27(runDirectory, relative3));
|
|
11405
11351
|
}
|
|
11406
11352
|
for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
|
|
11407
11353
|
await removeFaceIfPresent(path);
|
|
@@ -11430,15 +11376,15 @@ async function publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinat
|
|
|
11430
11376
|
roleOutcome
|
|
11431
11377
|
);
|
|
11432
11378
|
const artifactsDir = await ensureTerminalArtifactFace(admitted.runDirectory);
|
|
11433
|
-
const reportPath =
|
|
11434
|
-
const evidencePath =
|
|
11435
|
-
await
|
|
11379
|
+
const reportPath = join27(artifactsDir, "report.json");
|
|
11380
|
+
const evidencePath = join27(artifactsDir, "evidence.json");
|
|
11381
|
+
await writeFile5(
|
|
11436
11382
|
reportPath,
|
|
11437
11383
|
`${JSON.stringify(bodies.report, null, 2)}
|
|
11438
11384
|
`,
|
|
11439
11385
|
"utf8"
|
|
11440
11386
|
);
|
|
11441
|
-
await
|
|
11387
|
+
await writeFile5(
|
|
11442
11388
|
evidencePath,
|
|
11443
11389
|
`${JSON.stringify(bodies.evidence, null, 2)}
|
|
11444
11390
|
`,
|
|
@@ -11840,13 +11786,13 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
|
|
|
11840
11786
|
const candidates = [
|
|
11841
11787
|
...preferredCandidates,
|
|
11842
11788
|
// One unique name per fallback dir — collisions on fixed names cannot exhaust this.
|
|
11843
|
-
...uniqueFallbackDirs.map((dir) =>
|
|
11789
|
+
...uniqueFallbackDirs.map((dir) => join27(dir, `${stem}.${randomUUID5()}.json`))
|
|
11844
11790
|
];
|
|
11845
11791
|
for (let i = 0; i < candidates.length; i += 1) {
|
|
11846
11792
|
const path = candidates[i];
|
|
11847
11793
|
const payload = issues.length === 0 ? basePayload : { ...basePayload, publicationIssues: issues };
|
|
11848
11794
|
try {
|
|
11849
|
-
await
|
|
11795
|
+
await writeFile5(
|
|
11850
11796
|
path,
|
|
11851
11797
|
`${JSON.stringify(payload, null, 2)}
|
|
11852
11798
|
`,
|
|
@@ -11901,20 +11847,20 @@ async function publishFailureArtifacts(admitted, failure, authority, onErrorPubl
|
|
|
11901
11847
|
baseDir
|
|
11902
11848
|
);
|
|
11903
11849
|
const errorCandidates = underArtifacts ? [
|
|
11904
|
-
|
|
11905
|
-
|
|
11906
|
-
|
|
11850
|
+
join27(baseDir, "error.json"),
|
|
11851
|
+
join27(baseDir, "error.settlement.json"),
|
|
11852
|
+
join27(admitted.runDirectory, "error.settlement.json")
|
|
11907
11853
|
] : [
|
|
11908
|
-
|
|
11909
|
-
|
|
11854
|
+
join27(baseDir, "error.settlement.json"),
|
|
11855
|
+
join27(baseDir, "error.json")
|
|
11910
11856
|
];
|
|
11911
11857
|
const evidenceCandidates = underArtifacts ? [
|
|
11912
|
-
|
|
11913
|
-
|
|
11914
|
-
|
|
11858
|
+
join27(baseDir, "evidence.json"),
|
|
11859
|
+
join27(baseDir, "evidence.settlement.json"),
|
|
11860
|
+
join27(admitted.runDirectory, "evidence.settlement.json")
|
|
11915
11861
|
] : [
|
|
11916
|
-
|
|
11917
|
-
|
|
11862
|
+
join27(baseDir, "evidence.settlement.json"),
|
|
11863
|
+
join27(baseDir, "evidence.json")
|
|
11918
11864
|
];
|
|
11919
11865
|
const errorPayloadBase = {
|
|
11920
11866
|
kind: "error",
|
|
@@ -12169,9 +12115,9 @@ var init_settlement = __esm({
|
|
|
12169
12115
|
|
|
12170
12116
|
// src/archivist-record-pointer.ts
|
|
12171
12117
|
import { mkdirSync as mkdirSync2, writeFileSync } from "node:fs";
|
|
12172
|
-
import { dirname as dirname17, join as
|
|
12118
|
+
import { dirname as dirname17, join as join28 } from "node:path";
|
|
12173
12119
|
function bookDirectOfficerRunPointer(options) {
|
|
12174
|
-
const nest =
|
|
12120
|
+
const nest = join28(dirname17(options.parentSessionFile), "auditor-roles");
|
|
12175
12121
|
mkdirSync2(nest, { recursive: true });
|
|
12176
12122
|
const pointer = {
|
|
12177
12123
|
version: 1,
|
|
@@ -12181,7 +12127,7 @@ function bookDirectOfficerRunPointer(options) {
|
|
|
12181
12127
|
...options.runDirectory !== void 0 && options.runDirectory.trim() !== "" ? { runDirectory: options.runDirectory } : {}
|
|
12182
12128
|
};
|
|
12183
12129
|
writeFileSync(
|
|
12184
|
-
|
|
12130
|
+
join28(nest, `${options.officer}.pointer.json`),
|
|
12185
12131
|
`${JSON.stringify(pointer)}
|
|
12186
12132
|
`,
|
|
12187
12133
|
"utf8"
|
|
@@ -12439,10 +12385,10 @@ var init_submission_gate = __esm({
|
|
|
12439
12385
|
});
|
|
12440
12386
|
|
|
12441
12387
|
// src/session-identity.ts
|
|
12442
|
-
import { mkdir as mkdir2, readFile as readFile17, rename as rename3, writeFile as
|
|
12443
|
-
import { dirname as dirname18, join as
|
|
12388
|
+
import { mkdir as mkdir2, readFile as readFile17, rename as rename3, writeFile as writeFile6 } from "node:fs/promises";
|
|
12389
|
+
import { dirname as dirname18, join as join29 } from "node:path";
|
|
12444
12390
|
function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
12445
|
-
const bindingPath = (principal) =>
|
|
12391
|
+
const bindingPath = (principal) => join29(authority.decode(principal).sessionDirectory, sessionBindingFile);
|
|
12446
12392
|
return {
|
|
12447
12393
|
resolveSessionFile(principal) {
|
|
12448
12394
|
return authority.decode(principal).sessionFile;
|
|
@@ -12463,7 +12409,7 @@ function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
|
12463
12409
|
const target = bindingPath(principal);
|
|
12464
12410
|
await mkdir2(dirname18(target), { recursive: true });
|
|
12465
12411
|
const temporary = `${target}.${process.pid}.tmp`;
|
|
12466
|
-
await
|
|
12412
|
+
await writeFile6(temporary, `${JSON.stringify({ sessionId })}
|
|
12467
12413
|
`, { encoding: "utf8", mode: 384 });
|
|
12468
12414
|
await rename3(temporary, target);
|
|
12469
12415
|
}
|
|
@@ -12520,7 +12466,7 @@ import {
|
|
|
12520
12466
|
statSync as statSync3
|
|
12521
12467
|
} from "node:fs";
|
|
12522
12468
|
import { homedir } from "node:os";
|
|
12523
|
-
import { dirname as dirname19, join as
|
|
12469
|
+
import { dirname as dirname19, join as join30 } from "node:path";
|
|
12524
12470
|
function declareHostSessionFailure(error) {
|
|
12525
12471
|
const message = error instanceof Error ? error.stack || error.message : String(error);
|
|
12526
12472
|
process.stderr.write(`[host-session] Dossier record failure: ${message}
|
|
@@ -12545,7 +12491,7 @@ function findCodexRollout(sessionsDir, sessionId) {
|
|
|
12545
12491
|
return;
|
|
12546
12492
|
}
|
|
12547
12493
|
for (const entry of entries) {
|
|
12548
|
-
const fullPath =
|
|
12494
|
+
const fullPath = join30(dir, entry.name);
|
|
12549
12495
|
if (entry.isDirectory()) {
|
|
12550
12496
|
scan(fullPath, depth + 1);
|
|
12551
12497
|
} else if (entry.isFile() && entry.name.endsWith(".jsonl") && entry.name.includes(sessionId)) {
|
|
@@ -12569,25 +12515,25 @@ function sanitizeClaudeCwd(cwd) {
|
|
|
12569
12515
|
function resolveNativeSessionPath(options) {
|
|
12570
12516
|
const home = options.home || homedir();
|
|
12571
12517
|
if (options.host === "claude") {
|
|
12572
|
-
const configDir = process.env.CLAUDE_CONFIG_DIR ||
|
|
12518
|
+
const configDir = process.env.CLAUDE_CONFIG_DIR || join30(home, ".claude");
|
|
12573
12519
|
const sanitizedCwd = sanitizeClaudeCwd(options.cwd);
|
|
12574
|
-
return
|
|
12520
|
+
return join30(configDir, "projects", sanitizedCwd, `${options.sessionId}.jsonl`);
|
|
12575
12521
|
}
|
|
12576
12522
|
if (options.host === "codex") {
|
|
12577
12523
|
return findCodexRollout(codexSessionsDirectory(home), options.sessionId);
|
|
12578
12524
|
}
|
|
12579
12525
|
if (options.host === "grok-build") {
|
|
12580
|
-
const grokHome = process.env.GROK_HOME ||
|
|
12581
|
-
return
|
|
12526
|
+
const grokHome = process.env.GROK_HOME || join30(home, ".grok");
|
|
12527
|
+
return join30(grokHome, "sessions", encodeURIComponent(options.cwd), options.sessionId);
|
|
12582
12528
|
}
|
|
12583
12529
|
return void 0;
|
|
12584
12530
|
}
|
|
12585
12531
|
function codexSessionsDirectory(home) {
|
|
12586
|
-
return
|
|
12532
|
+
return join30(process.env.CODEX_HOME || join30(home || homedir(), ".codex"), "sessions");
|
|
12587
12533
|
}
|
|
12588
12534
|
function recordRunStart(runDirectory) {
|
|
12589
12535
|
try {
|
|
12590
|
-
appendFileSync2(
|
|
12536
|
+
appendFileSync2(join30(runDirectory, ".run-starts"), "\n");
|
|
12591
12537
|
} catch (error) {
|
|
12592
12538
|
declareHostSessionFailure(error);
|
|
12593
12539
|
}
|
|
@@ -12611,12 +12557,12 @@ function resolveHostDossierLandingPath(options) {
|
|
|
12611
12557
|
} catch {
|
|
12612
12558
|
}
|
|
12613
12559
|
}
|
|
12614
|
-
const startsPath =
|
|
12560
|
+
const startsPath = join30(dirname19(options.sessionDirectory), ".run-starts");
|
|
12615
12561
|
let starts = 0;
|
|
12616
12562
|
if (existsSync9(startsPath)) starts = readFileSync3(startsPath, "utf8").length;
|
|
12617
12563
|
const ordinal = Math.max(maxOrdinal + 1, starts, options.continuation.kind === "resume" ? 2 : 1);
|
|
12618
12564
|
const baseName = `${options.host}-${sanitizedModel}-${ordinal}`;
|
|
12619
|
-
const landingPath = options.host === "grok-build" ?
|
|
12565
|
+
const landingPath = options.host === "grok-build" ? join30(options.sessionDirectory, baseName) : join30(options.sessionDirectory, `${baseName}.jsonl`);
|
|
12620
12566
|
return { landingPath, ordinal, sanitizedModel };
|
|
12621
12567
|
}
|
|
12622
12568
|
function recordNativeSessionPointer(options) {
|
|
@@ -12649,18 +12595,18 @@ function copyFileCloneOrFallback(src, dest) {
|
|
|
12649
12595
|
copyFileSync(src, dest);
|
|
12650
12596
|
}
|
|
12651
12597
|
function copyGrokDossier(srcDir, destDir) {
|
|
12652
|
-
const chatHistorySrc =
|
|
12598
|
+
const chatHistorySrc = join30(srcDir, "chat_history.jsonl");
|
|
12653
12599
|
if (!existsSync9(chatHistorySrc)) {
|
|
12654
12600
|
throw new Error(`Grok native chat_history.jsonl missing at ${chatHistorySrc}`);
|
|
12655
12601
|
}
|
|
12656
12602
|
mkdirSync3(destDir, { recursive: true });
|
|
12657
|
-
const chatHistoryDest =
|
|
12603
|
+
const chatHistoryDest = join30(destDir, "chat_history.jsonl");
|
|
12658
12604
|
copyFileCloneOrFallback(chatHistorySrc, chatHistoryDest);
|
|
12659
|
-
const usageSrc =
|
|
12605
|
+
const usageSrc = join30(srcDir, "usage.json");
|
|
12660
12606
|
if (!existsSync9(usageSrc)) {
|
|
12661
12607
|
throw new Error(`Grok native usage.json missing at ${usageSrc}`);
|
|
12662
12608
|
}
|
|
12663
|
-
copyFileCloneOrFallback(usageSrc,
|
|
12609
|
+
copyFileCloneOrFallback(usageSrc, join30(destDir, "usage.json"));
|
|
12664
12610
|
}
|
|
12665
12611
|
function copyAndRecordHostDossier(options) {
|
|
12666
12612
|
if (options.host === "pi" || options.host === "hermes") {
|
|
@@ -12735,7 +12681,7 @@ function copyAndRecordHostDossier(options) {
|
|
|
12735
12681
|
}
|
|
12736
12682
|
try {
|
|
12737
12683
|
mkdirSync3(options.sessionDirectory, { recursive: true });
|
|
12738
|
-
closeSync(openSync(
|
|
12684
|
+
closeSync(openSync(join30(options.sessionDirectory, `${options.host}-${sanitizedModel}-${ordinal}.failed`), "a"));
|
|
12739
12685
|
} catch {
|
|
12740
12686
|
}
|
|
12741
12687
|
sitianReportSafe({
|
|
@@ -12769,7 +12715,7 @@ var init_host_session_record = __esm({
|
|
|
12769
12715
|
import { constants as fsConstants2 } from "node:fs";
|
|
12770
12716
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
12771
12717
|
import { lstat as lstat4, mkdir as mkdir3, open } from "node:fs/promises";
|
|
12772
|
-
import { join as
|
|
12718
|
+
import { join as join31 } from "node:path";
|
|
12773
12719
|
async function persistReturnedRunState(admitted, options) {
|
|
12774
12720
|
if (options?.lawful === true) {
|
|
12775
12721
|
await markRunTerminal(admitted.runDirectory);
|
|
@@ -12838,7 +12784,7 @@ function jsonSafeReplacer() {
|
|
|
12838
12784
|
};
|
|
12839
12785
|
}
|
|
12840
12786
|
async function writeHardenedArtifactFile(artifactsDir, namePrefix, payload) {
|
|
12841
|
-
const filePath =
|
|
12787
|
+
const filePath = join31(artifactsDir, `${namePrefix}-${randomUUID6()}.json`);
|
|
12842
12788
|
const body = `${JSON.stringify(payload, jsonSafeReplacer(), 2)}
|
|
12843
12789
|
`;
|
|
12844
12790
|
const noFollowFlag = typeof fsConstants2.O_NOFOLLOW === "number" ? fsConstants2.O_NOFOLLOW : 0;
|
|
@@ -13092,8 +13038,8 @@ var init_auto_resume = __esm({
|
|
|
13092
13038
|
|
|
13093
13039
|
// src/public-cli/post-admission.ts
|
|
13094
13040
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
13095
|
-
import { writeFile as
|
|
13096
|
-
import { isAbsolute as isAbsolute7, join as
|
|
13041
|
+
import { writeFile as writeFile7 } from "node:fs/promises";
|
|
13042
|
+
import { isAbsolute as isAbsolute7, join as join32, resolve as resolve13 } from "node:path";
|
|
13097
13043
|
function describeCaughtError(error) {
|
|
13098
13044
|
if (error instanceof Error) {
|
|
13099
13045
|
const code = error.code;
|
|
@@ -13188,8 +13134,8 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
13188
13134
|
} catch (appendError) {
|
|
13189
13135
|
try {
|
|
13190
13136
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
13191
|
-
await
|
|
13192
|
-
|
|
13137
|
+
await writeFile7(
|
|
13138
|
+
join32(artifactsDir, `post-admission-diagnostic-${randomUUID7()}.json`),
|
|
13193
13139
|
`${JSON.stringify({ version: 1, ...payload }, null, 2)}
|
|
13194
13140
|
`,
|
|
13195
13141
|
{ encoding: "utf8", flag: "wx" }
|
|
@@ -13330,7 +13276,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
13330
13276
|
const rows = await readRecordedSubmissionRows(
|
|
13331
13277
|
admitted.projectRoot,
|
|
13332
13278
|
admitted.runId,
|
|
13333
|
-
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent:
|
|
13279
|
+
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent: join32(admitted.runDirectory, "session", "session.jsonl") }
|
|
13334
13280
|
);
|
|
13335
13281
|
let ticketNumber;
|
|
13336
13282
|
for (const row of rows) {
|
|
@@ -13456,8 +13402,8 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
13456
13402
|
}
|
|
13457
13403
|
let stderrLogWriteFailure;
|
|
13458
13404
|
try {
|
|
13459
|
-
await
|
|
13460
|
-
|
|
13405
|
+
await writeFile7(
|
|
13406
|
+
join32(admitted.runDirectory, "stderr.log"),
|
|
13461
13407
|
result.stderr,
|
|
13462
13408
|
"utf8"
|
|
13463
13409
|
);
|
|
@@ -13736,7 +13682,7 @@ async function dispatchAfterWriterLease(input) {
|
|
|
13736
13682
|
}
|
|
13737
13683
|
function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
|
|
13738
13684
|
const absolute = isAbsolute7(attachmentPath) ? attachmentPath : resolve13(attachmentPath);
|
|
13739
|
-
return pathContainedIn(
|
|
13685
|
+
return pathContainedIn(join32(runDirectory, "attachments"), absolute);
|
|
13740
13686
|
}
|
|
13741
13687
|
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
13742
13688
|
if (summons === void 0) return void 0;
|
|
@@ -13991,8 +13937,8 @@ async function presentResumeFailurePointer(io, thrown, publish) {
|
|
|
13991
13937
|
}
|
|
13992
13938
|
async function writeResumeDiagnosticFile(runDirectory, runId, failure, role) {
|
|
13993
13939
|
const dir = await ensureRealArtifactsDirectory(runDirectory);
|
|
13994
|
-
const path =
|
|
13995
|
-
await
|
|
13940
|
+
const path = join32(dir, `resume-diagnostic-${randomUUID7()}.json`);
|
|
13941
|
+
await writeFile7(
|
|
13996
13942
|
path,
|
|
13997
13943
|
`${JSON.stringify({
|
|
13998
13944
|
runId,
|
|
@@ -14160,16 +14106,16 @@ var init_seat_ticket_binding = __esm({
|
|
|
14160
14106
|
// src/public-cli/machine-method-skills.ts
|
|
14161
14107
|
import { accessSync, constants as constants2, statSync as statSync4 } from "node:fs";
|
|
14162
14108
|
import { lstat as lstat5, mkdir as mkdir4, symlink } from "node:fs/promises";
|
|
14163
|
-
import { join as
|
|
14109
|
+
import { join as join33 } from "node:path";
|
|
14164
14110
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
14165
14111
|
function skillRoot(home) {
|
|
14166
|
-
return
|
|
14112
|
+
return join33(home, ".agents/skills");
|
|
14167
14113
|
}
|
|
14168
14114
|
function installedMethodSkillPath(home, name) {
|
|
14169
14115
|
return installedSkillPath(skillRoot(home), name);
|
|
14170
14116
|
}
|
|
14171
14117
|
function installedSkillPath(root, name) {
|
|
14172
|
-
const path =
|
|
14118
|
+
const path = join33(root, name, "SKILL.md");
|
|
14173
14119
|
try {
|
|
14174
14120
|
if (!statSync4(path).isFile()) return void 0;
|
|
14175
14121
|
accessSync(path, constants2.R_OK);
|
|
@@ -14182,9 +14128,9 @@ function installedSkillPath(root, name) {
|
|
|
14182
14128
|
}
|
|
14183
14129
|
function linkedSkillRoot(home, host) {
|
|
14184
14130
|
if (host === "claude" || host === "claude-code") {
|
|
14185
|
-
return
|
|
14131
|
+
return join33(process.env.CLAUDE_CONFIG_DIR?.trim() || join33(home, ".claude"), "skills");
|
|
14186
14132
|
}
|
|
14187
|
-
if (host === "hermes") return
|
|
14133
|
+
if (host === "hermes") return join33(home, ".hermes/skills");
|
|
14188
14134
|
return void 0;
|
|
14189
14135
|
}
|
|
14190
14136
|
async function occupied(path) {
|
|
@@ -14241,7 +14187,7 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
14241
14187
|
const missingBySource = /* @__PURE__ */ new Map();
|
|
14242
14188
|
let unsourced = false;
|
|
14243
14189
|
for (const name of packagedMethodSkillNames()) {
|
|
14244
|
-
const path =
|
|
14190
|
+
const path = join33(canonical, name);
|
|
14245
14191
|
if (await occupied(path)) {
|
|
14246
14192
|
warnOccupied(path, stdout);
|
|
14247
14193
|
continue;
|
|
@@ -14271,9 +14217,9 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
14271
14217
|
throw error;
|
|
14272
14218
|
}
|
|
14273
14219
|
for (const name of packagedMethodSkillNames()) {
|
|
14274
|
-
const target =
|
|
14220
|
+
const target = join33(canonical, name);
|
|
14275
14221
|
if (installedMethodSkillPath(home, name) === void 0) continue;
|
|
14276
|
-
const link =
|
|
14222
|
+
const link = join33(root, name);
|
|
14277
14223
|
if (await occupied(link)) {
|
|
14278
14224
|
warnOccupied(link, stdout);
|
|
14279
14225
|
continue;
|
|
@@ -15474,7 +15420,7 @@ var init_analyst_book_key = __esm({
|
|
|
15474
15420
|
|
|
15475
15421
|
// src/analyst-index.ts
|
|
15476
15422
|
import { open as open2, readFile as readFile18, unlink as unlink4 } from "node:fs/promises";
|
|
15477
|
-
import { dirname as dirname21, join as
|
|
15423
|
+
import { dirname as dirname21, join as join34 } from "node:path";
|
|
15478
15424
|
function sleep(ms) {
|
|
15479
15425
|
return new Promise((resolve22) => {
|
|
15480
15426
|
setTimeout(resolve22, ms);
|
|
@@ -15483,7 +15429,7 @@ function sleep(ms) {
|
|
|
15483
15429
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
15484
15430
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
15485
15431
|
ensureRealDirectoryTree(ledgerHome, dirname21(indexPath));
|
|
15486
|
-
const lockPath =
|
|
15432
|
+
const lockPath = join34(dirname21(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
15487
15433
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
15488
15434
|
const startedAt = Date.now();
|
|
15489
15435
|
while (true) {
|
|
@@ -15510,7 +15456,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
15510
15456
|
}
|
|
15511
15457
|
}
|
|
15512
15458
|
function analystLibraryIndexPath(ledgerHome) {
|
|
15513
|
-
return
|
|
15459
|
+
return join34(ledgerHome, "analyst", "library-index.json");
|
|
15514
15460
|
}
|
|
15515
15461
|
function rowFromIssueMetricsPage(page) {
|
|
15516
15462
|
return {
|
|
@@ -15806,7 +15752,7 @@ var init_analyst_cohort = __esm({
|
|
|
15806
15752
|
|
|
15807
15753
|
// src/analyst-ledger.ts
|
|
15808
15754
|
import { readdir as readdir6, readFile as readFile19 } from "node:fs/promises";
|
|
15809
|
-
import { basename as basename9, join as
|
|
15755
|
+
import { basename as basename9, join as join35 } from "node:path";
|
|
15810
15756
|
function isMissingPathError6(error) {
|
|
15811
15757
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
15812
15758
|
}
|
|
@@ -15835,7 +15781,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
|
|
|
15835
15781
|
}
|
|
15836
15782
|
}
|
|
15837
15783
|
async function classifyGhostCandidate(input) {
|
|
15838
|
-
const autopsy = await autopsyWriterLock(
|
|
15784
|
+
const autopsy = await autopsyWriterLock(join35(input.runDirectory, "writer.lock"));
|
|
15839
15785
|
const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
|
|
15840
15786
|
if (leaseCheck === void 0) return { kind: "live" };
|
|
15841
15787
|
return {
|
|
@@ -15864,7 +15810,7 @@ async function listLedgerBookNames(booksRoot) {
|
|
|
15864
15810
|
async function readInvocationScopeFields(runDirectory) {
|
|
15865
15811
|
let raw;
|
|
15866
15812
|
try {
|
|
15867
|
-
raw = await readFile19(
|
|
15813
|
+
raw = await readFile19(join35(runDirectory, "invocation.json"), "utf8");
|
|
15868
15814
|
} catch (error) {
|
|
15869
15815
|
if (isMissingPathError6(error)) return void 0;
|
|
15870
15816
|
throw error;
|
|
@@ -15897,7 +15843,7 @@ function decideIssueScope(input) {
|
|
|
15897
15843
|
}
|
|
15898
15844
|
async function resolveSessionFile(runDirectory) {
|
|
15899
15845
|
try {
|
|
15900
|
-
const raw = await readFile19(
|
|
15846
|
+
const raw = await readFile19(join35(runDirectory, "invocation.json"), "utf8");
|
|
15901
15847
|
const parsed = JSON.parse(raw);
|
|
15902
15848
|
if (isRecord12(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
15903
15849
|
return parsed.sessionFile;
|
|
@@ -15905,7 +15851,7 @@ async function resolveSessionFile(runDirectory) {
|
|
|
15905
15851
|
} catch (error) {
|
|
15906
15852
|
if (!isMissingPathError6(error)) throw error;
|
|
15907
15853
|
}
|
|
15908
|
-
return
|
|
15854
|
+
return join35(runDirectory, "session", "session.jsonl");
|
|
15909
15855
|
}
|
|
15910
15856
|
function attributeSessionRowsForRun(input) {
|
|
15911
15857
|
if (pathContainedIn(input.runDirectory, input.sessionFile)) {
|
|
@@ -16107,9 +16053,9 @@ async function classifyScopedRun(input) {
|
|
|
16107
16053
|
}
|
|
16108
16054
|
let gateCycles;
|
|
16109
16055
|
try {
|
|
16110
|
-
const parentSessionFile =
|
|
16056
|
+
const parentSessionFile = join35(input.runDirectory, "session", "session.jsonl");
|
|
16111
16057
|
gateCycles = await readAnalystGateCyclesFromAuditorRoles(
|
|
16112
|
-
|
|
16058
|
+
join35(input.runDirectory, "session", "auditor-roles"),
|
|
16113
16059
|
{ parentSessionFile }
|
|
16114
16060
|
);
|
|
16115
16061
|
} catch (error) {
|
|
@@ -16144,7 +16090,7 @@ async function classifyScopedRun(input) {
|
|
|
16144
16090
|
async function scanAnalystIssueRuns(input) {
|
|
16145
16091
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
16146
16092
|
const scopeTicketNumber = input.ticketNumber;
|
|
16147
|
-
const booksRoot =
|
|
16093
|
+
const booksRoot = join35(ledgerHome, "books");
|
|
16148
16094
|
let wholeBook = false;
|
|
16149
16095
|
let scopeRootIdentity;
|
|
16150
16096
|
let bookNames;
|
|
@@ -16177,7 +16123,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
16177
16123
|
const ghostLegs = [];
|
|
16178
16124
|
const scopeConflicts = [];
|
|
16179
16125
|
for (const book of bookNames) {
|
|
16180
|
-
const bookDir =
|
|
16126
|
+
const bookDir = join35(booksRoot, book);
|
|
16181
16127
|
let runDirectories;
|
|
16182
16128
|
try {
|
|
16183
16129
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
@@ -16914,7 +16860,7 @@ var init_analyst_metric_family = __esm({
|
|
|
16914
16860
|
|
|
16915
16861
|
// src/analyst-page.ts
|
|
16916
16862
|
import { createHash as createHash3 } from "node:crypto";
|
|
16917
|
-
import { dirname as dirname22, join as
|
|
16863
|
+
import { dirname as dirname22, join as join36 } from "node:path";
|
|
16918
16864
|
function analystIssuePageKey(address) {
|
|
16919
16865
|
const parts = ["book", address.bookKey];
|
|
16920
16866
|
if (address.issueNumber !== void 0) {
|
|
@@ -16925,7 +16871,7 @@ function analystIssuePageKey(address) {
|
|
|
16925
16871
|
return createHash3("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
16926
16872
|
}
|
|
16927
16873
|
function analystIssuePagePath(ledgerHome, address) {
|
|
16928
|
-
return
|
|
16874
|
+
return join36(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
16929
16875
|
}
|
|
16930
16876
|
function analystIssuePageAddressFromPage(page) {
|
|
16931
16877
|
return {
|
|
@@ -17564,7 +17510,7 @@ __export(cli_exports, {
|
|
|
17564
17510
|
runAkRole: () => runAkRole
|
|
17565
17511
|
});
|
|
17566
17512
|
import { realpath as realpath5 } from "node:fs/promises";
|
|
17567
|
-
import { join as
|
|
17513
|
+
import { join as join37 } from "node:path";
|
|
17568
17514
|
function publicSeatArgv(owner) {
|
|
17569
17515
|
return {
|
|
17570
17516
|
parse: (args) => parsePublicSeatArgv(owner, args),
|
|
@@ -17703,7 +17649,7 @@ function resolveHome(env) {
|
|
|
17703
17649
|
return env.home ?? packageMachineHome();
|
|
17704
17650
|
}
|
|
17705
17651
|
function resolveAgentDir(env, home) {
|
|
17706
|
-
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
17652
|
+
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join37(home, ".pi", "agent");
|
|
17707
17653
|
}
|
|
17708
17654
|
function parseThinking(value) {
|
|
17709
17655
|
return value;
|
|
@@ -18475,7 +18421,7 @@ __export(public_role_summons_exports, {
|
|
|
18475
18421
|
import { execFile as execFile3 } from "node:child_process";
|
|
18476
18422
|
import { existsSync as existsSync10 } from "node:fs";
|
|
18477
18423
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
18478
|
-
import { join as
|
|
18424
|
+
import { join as join38 } from "node:path";
|
|
18479
18425
|
import { promisify as promisify3 } from "node:util";
|
|
18480
18426
|
function createCapturingIo() {
|
|
18481
18427
|
const chunks = [];
|
|
@@ -18499,7 +18445,7 @@ function parentDir(path) {
|
|
|
18499
18445
|
function walkPackageRoot(start) {
|
|
18500
18446
|
let dir = start;
|
|
18501
18447
|
for (let i = 0; i < 12; i += 1) {
|
|
18502
|
-
if (existsSync10(
|
|
18448
|
+
if (existsSync10(join38(dir, "package.json")) && existsSync10(join38(dir, "souls"))) {
|
|
18503
18449
|
return dir;
|
|
18504
18450
|
}
|
|
18505
18451
|
const parent = parentDir(dir);
|
|
@@ -18615,7 +18561,7 @@ async function createSummonEnv(options, afterHost) {
|
|
|
18615
18561
|
async function summonPublicRole(options) {
|
|
18616
18562
|
const packageRoot = resolveSummonsPackageRoot(options.packageRoot);
|
|
18617
18563
|
const home = await resolveSummonHome(options);
|
|
18618
|
-
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
18564
|
+
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join38(home, ".pi", "agent");
|
|
18619
18565
|
const {
|
|
18620
18566
|
loadCredentialProviders: loadCredentialProviders2,
|
|
18621
18567
|
loadPublicCliConfig: loadPublicCliConfig2,
|
|
@@ -19123,7 +19069,7 @@ var init_compliance_transport = __esm({
|
|
|
19123
19069
|
});
|
|
19124
19070
|
|
|
19125
19071
|
// src/role-run-relocation.ts
|
|
19126
|
-
import { join as
|
|
19072
|
+
import { join as join39, sep as sep5 } from "node:path";
|
|
19127
19073
|
function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
|
|
19128
19074
|
if (typeof value !== "string") return value;
|
|
19129
19075
|
if (value === oldRunDirectory) return newRunDirectory;
|
|
@@ -19250,8 +19196,8 @@ __export(run_lifecycle_exports, {
|
|
|
19250
19196
|
renderResumeCommand: () => renderResumeCommand,
|
|
19251
19197
|
writeRoleRunState: () => writeRoleRunState
|
|
19252
19198
|
});
|
|
19253
|
-
import { chmod, lstat as lstat6, open as open3, readdir as readdir7, readFile as readFile22, unlink as unlink5, writeFile as
|
|
19254
|
-
import { basename as basename10, join as
|
|
19199
|
+
import { chmod, lstat as lstat6, open as open3, readdir as readdir7, readFile as readFile22, unlink as unlink5, writeFile as writeFile8 } from "node:fs/promises";
|
|
19200
|
+
import { basename as basename10, join as join40 } from "node:path";
|
|
19255
19201
|
function buildAutoResumeContinuationPrompt(options) {
|
|
19256
19202
|
return appendEngineSessionMaterial(
|
|
19257
19203
|
[RESUME_TRANSPORT_ENVELOPE],
|
|
@@ -19276,8 +19222,8 @@ function renderResumeCommand(runId) {
|
|
|
19276
19222
|
}
|
|
19277
19223
|
async function writeRoleRunState(runDirectory, record4) {
|
|
19278
19224
|
const payload = { ...record4, runDirectory };
|
|
19279
|
-
await
|
|
19280
|
-
|
|
19225
|
+
await writeFile8(
|
|
19226
|
+
join40(runDirectory, RUN_STATE_FILE),
|
|
19281
19227
|
`${JSON.stringify(payload, null, 2)}
|
|
19282
19228
|
`,
|
|
19283
19229
|
"utf8"
|
|
@@ -19327,7 +19273,7 @@ function parseCurrentCourtState(raw) {
|
|
|
19327
19273
|
async function readRoleRunStateRaw(runDirectory) {
|
|
19328
19274
|
let raw;
|
|
19329
19275
|
try {
|
|
19330
|
-
raw = JSON.parse(await readFile22(
|
|
19276
|
+
raw = JSON.parse(await readFile22(join40(runDirectory, RUN_STATE_FILE), "utf8"));
|
|
19331
19277
|
} catch (error) {
|
|
19332
19278
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
19333
19279
|
throw error;
|
|
@@ -19420,8 +19366,8 @@ async function writeRoleRunStateDisk(runDirectory, disk) {
|
|
|
19420
19366
|
...disk.resumable === void 0 ? {} : { resumable: disk.resumable },
|
|
19421
19367
|
...disk.currentCourt === void 0 ? {} : { currentCourt: disk.currentCourt }
|
|
19422
19368
|
};
|
|
19423
|
-
await
|
|
19424
|
-
|
|
19369
|
+
await writeFile8(
|
|
19370
|
+
join40(runDirectory, RUN_STATE_FILE),
|
|
19425
19371
|
`${JSON.stringify(payload, null, 2)}
|
|
19426
19372
|
`,
|
|
19427
19373
|
"utf8"
|
|
@@ -19644,7 +19590,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
|
|
|
19644
19590
|
},
|
|
19645
19591
|
relocate(nextRunDirectory) {
|
|
19646
19592
|
currentRunDirectory = nextRunDirectory;
|
|
19647
|
-
currentLockPath =
|
|
19593
|
+
currentLockPath = join40(nextRunDirectory, WRITER_LOCK_FILE);
|
|
19648
19594
|
},
|
|
19649
19595
|
async release() {
|
|
19650
19596
|
if (released) return;
|
|
@@ -19683,10 +19629,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
19683
19629
|
};
|
|
19684
19630
|
const reportReadFailure = (error) => {
|
|
19685
19631
|
reportDiagnostic(
|
|
19686
|
-
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${
|
|
19632
|
+
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join40(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
|
|
19687
19633
|
);
|
|
19688
19634
|
};
|
|
19689
|
-
const lockPath =
|
|
19635
|
+
const lockPath = join40(runDirectory, WRITER_LOCK_FILE);
|
|
19690
19636
|
let lastAutopsy = { verdict: "absent" };
|
|
19691
19637
|
let lastReclaimFailure;
|
|
19692
19638
|
for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
|
|
@@ -19741,7 +19687,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
19741
19687
|
async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
19742
19688
|
if (runId.trim() === "") return void 0;
|
|
19743
19689
|
const ledgerHome = resolveActivationLedgerHome(home);
|
|
19744
|
-
const booksRoot =
|
|
19690
|
+
const booksRoot = join40(ledgerHome, "books");
|
|
19745
19691
|
let bookKeys;
|
|
19746
19692
|
try {
|
|
19747
19693
|
bookKeys = await readdir7(booksRoot);
|
|
@@ -19782,7 +19728,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
19782
19728
|
let raw;
|
|
19783
19729
|
try {
|
|
19784
19730
|
raw = JSON.parse(
|
|
19785
|
-
await readFile22(
|
|
19731
|
+
await readFile22(join40(runDirectory, "admitted-request.json"), "utf8")
|
|
19786
19732
|
);
|
|
19787
19733
|
} catch (error) {
|
|
19788
19734
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -19803,7 +19749,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
19803
19749
|
async function runHasFormedSessionPrincipal(runDirectory) {
|
|
19804
19750
|
const disk = await readRoleRunStateDisk(runDirectory);
|
|
19805
19751
|
if (disk === void 0) return false;
|
|
19806
|
-
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile :
|
|
19752
|
+
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : join40(disk.principalWire.sessionDirectory, "session.jsonl");
|
|
19807
19753
|
try {
|
|
19808
19754
|
const stat2 = await lstat6(sessionFile);
|
|
19809
19755
|
return stat2.isFile() && !stat2.isSymbolicLink();
|
|
@@ -19821,7 +19767,7 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
19821
19767
|
let runDirectories;
|
|
19822
19768
|
try {
|
|
19823
19769
|
runDirectories = await listBookRunDirectories(
|
|
19824
|
-
input.ticketNumber === void 0 ? bookDir :
|
|
19770
|
+
input.ticketNumber === void 0 ? bookDir : join40(bookDir, String(input.ticketNumber))
|
|
19825
19771
|
);
|
|
19826
19772
|
} catch (error) {
|
|
19827
19773
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -20019,7 +19965,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
20019
19965
|
let model;
|
|
20020
19966
|
try {
|
|
20021
19967
|
const invocationRaw = JSON.parse(
|
|
20022
|
-
await readFile22(
|
|
19968
|
+
await readFile22(join40(run.runDirectory, "invocation.json"), "utf8")
|
|
20023
19969
|
);
|
|
20024
19970
|
if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
|
|
20025
19971
|
const rec = invocationRaw;
|
|
@@ -20388,7 +20334,7 @@ var init_run_lifecycle = __esm({
|
|
|
20388
20334
|
|
|
20389
20335
|
// src/archivist-record-topology.ts
|
|
20390
20336
|
import { createHash as createHash4 } from "node:crypto";
|
|
20391
|
-
import { join as
|
|
20337
|
+
import { join as join41 } from "node:path";
|
|
20392
20338
|
function resolveNavigatorWorkSubjectPlacement(input) {
|
|
20393
20339
|
let ledgerHome;
|
|
20394
20340
|
if (input.parentSessionFile !== void 0 && input.parentSessionFile.length > 0) {
|
|
@@ -20401,7 +20347,7 @@ function resolveNavigatorWorkSubjectPlacement(input) {
|
|
|
20401
20347
|
const digest = createHash4("sha256").update(input.subject).digest("hex").slice(0, 32);
|
|
20402
20348
|
return {
|
|
20403
20349
|
ledgerHome,
|
|
20404
|
-
sessionDir:
|
|
20350
|
+
sessionDir: join41(
|
|
20405
20351
|
activationBookDirectory(ledgerHome, resolveBookKeyFromGit(input.cwd)),
|
|
20406
20352
|
NAVIGATOR_RECORD_KIND,
|
|
20407
20353
|
digest
|
|
@@ -20473,10 +20419,10 @@ import {
|
|
|
20473
20419
|
statSync as statSync6,
|
|
20474
20420
|
writeFileSync as writeFileSync2
|
|
20475
20421
|
} from "node:fs";
|
|
20476
|
-
import { dirname as dirname23, resolve as resolve16, join as
|
|
20422
|
+
import { dirname as dirname23, resolve as resolve16, join as join42 } from "node:path";
|
|
20477
20423
|
import { StringDecoder } from "node:string_decoder";
|
|
20478
20424
|
function readCurrentSession(sessionDir) {
|
|
20479
|
-
const ledger =
|
|
20425
|
+
const ledger = join42(sessionDir, CURRENT_SESSION_LEDGER);
|
|
20480
20426
|
try {
|
|
20481
20427
|
const value = JSON.parse(readFileSync4(ledger, "utf8"));
|
|
20482
20428
|
if (typeof value !== "object" || value === null || typeof value.sessionFile !== "string" || value.sessionFile.length === 0) {
|
|
@@ -20491,7 +20437,7 @@ function readCurrentSession(sessionDir) {
|
|
|
20491
20437
|
}
|
|
20492
20438
|
}
|
|
20493
20439
|
function writeCurrentSession(sessionDir, sessionFile) {
|
|
20494
|
-
const ledger =
|
|
20440
|
+
const ledger = join42(sessionDir, CURRENT_SESSION_LEDGER);
|
|
20495
20441
|
try {
|
|
20496
20442
|
writeFileSync2(ledger, `${JSON.stringify({ sessionFile })}
|
|
20497
20443
|
`, { flag: "wx" });
|
|
@@ -20507,7 +20453,7 @@ function isCurrentSessionClaimRace(error) {
|
|
|
20507
20453
|
return errnoCode(error.cause) === "EEXIST";
|
|
20508
20454
|
}
|
|
20509
20455
|
function currentSessionLedgerPath(sessionDir) {
|
|
20510
|
-
return
|
|
20456
|
+
return join42(sessionDir, CURRENT_SESSION_LEDGER);
|
|
20511
20457
|
}
|
|
20512
20458
|
function readBoundedSessionHeader(filePath) {
|
|
20513
20459
|
const fd = openSync2(filePath, "r");
|
|
@@ -20594,7 +20540,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
|
|
|
20594
20540
|
const matched = [];
|
|
20595
20541
|
for (const name of names) {
|
|
20596
20542
|
if (!name.endsWith(".jsonl")) continue;
|
|
20597
|
-
const filePath =
|
|
20543
|
+
const filePath = join42(absoluteSessionDir, name);
|
|
20598
20544
|
let st;
|
|
20599
20545
|
try {
|
|
20600
20546
|
st = statSync6(filePath);
|
|
@@ -20706,7 +20652,7 @@ function createRecordSessionOpen(options, host = piRecordSessionHost) {
|
|
|
20706
20652
|
if (!physicallyContainedIn(ledgerHome, parentResolved)) {
|
|
20707
20653
|
throw new Error("Durable record ownership requires a parent session inside the ledger home");
|
|
20708
20654
|
}
|
|
20709
|
-
sessionDir =
|
|
20655
|
+
sessionDir = join42(dirname23(parentResolved), options.kind);
|
|
20710
20656
|
parentSession = parentFile;
|
|
20711
20657
|
mayResumeSameNest = options.kind === WORKER_SUBMISSION_GATE_KIND;
|
|
20712
20658
|
}
|
|
@@ -21845,7 +21791,7 @@ init_sitian_facade();
|
|
|
21845
21791
|
init_submission_ledger();
|
|
21846
21792
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
21847
21793
|
import { readFileSync as readFileSync6, writeSync as writeSync2 } from "node:fs";
|
|
21848
|
-
import { join as
|
|
21794
|
+
import { join as join44 } from "node:path";
|
|
21849
21795
|
import { Value as Value4 } from "typebox/value";
|
|
21850
21796
|
|
|
21851
21797
|
// src/activation-trace.ts
|
|
@@ -23801,7 +23747,7 @@ function readDiaristTicketAssertion(submitted) {
|
|
|
23801
23747
|
function readRoleRunCoordinates(ctx, label) {
|
|
23802
23748
|
const runDirectory = runDirectoryFromHostContext(ctx);
|
|
23803
23749
|
if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
|
|
23804
|
-
const admittedPath =
|
|
23750
|
+
const admittedPath = join44(runDirectory, "admitted-request.json");
|
|
23805
23751
|
const admitted = JSON.parse(readFileSync6(admittedPath, "utf8"));
|
|
23806
23752
|
if (typeof admitted.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
|
|
23807
23753
|
throw new Error(`${label} admitted-request missing projectRoot (${admittedPath})`);
|
|
@@ -24729,9 +24675,9 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
24729
24675
|
init_engine_detour();
|
|
24730
24676
|
init_packaged_role_registry();
|
|
24731
24677
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
24732
|
-
import { appendFile as appendFile3, mkdir as mkdir5, writeFile as
|
|
24678
|
+
import { appendFile as appendFile3, mkdir as mkdir5, writeFile as writeFile9 } from "node:fs/promises";
|
|
24733
24679
|
import { createServer } from "node:net";
|
|
24734
|
-
import { dirname as dirname25, join as
|
|
24680
|
+
import { dirname as dirname25, join as join45 } from "node:path";
|
|
24735
24681
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
24736
24682
|
init_role_activation_flags();
|
|
24737
24683
|
init_submission_correctable_error();
|
|
@@ -24777,11 +24723,11 @@ async function prepareRoleEnvelope(options) {
|
|
|
24777
24723
|
const hostAbort = new AbortController();
|
|
24778
24724
|
const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID9();
|
|
24779
24725
|
await mkdir5(request.runDirectory, { recursive: true });
|
|
24780
|
-
let sessionFile = options.sessionFile ??
|
|
24726
|
+
let sessionFile = options.sessionFile ?? join45(request.runDirectory, "session", "session.jsonl");
|
|
24781
24727
|
await mkdir5(dirname25(sessionFile), { recursive: true });
|
|
24782
24728
|
if (request.continuation.kind !== "resume") {
|
|
24783
24729
|
try {
|
|
24784
|
-
await
|
|
24730
|
+
await writeFile9(
|
|
24785
24731
|
sessionFile,
|
|
24786
24732
|
`${JSON.stringify({
|
|
24787
24733
|
type: "session",
|
|
@@ -25300,8 +25246,8 @@ init_session_identity();
|
|
|
25300
25246
|
import { spawn as spawn3, spawnSync as spawnSync3 } from "node:child_process";
|
|
25301
25247
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
25302
25248
|
import { existsSync as existsSync15 } from "node:fs";
|
|
25303
|
-
import { writeFile as
|
|
25304
|
-
import { dirname as dirname26, isAbsolute as isAbsolute12, join as
|
|
25249
|
+
import { writeFile as writeFile10 } from "node:fs/promises";
|
|
25250
|
+
import { dirname as dirname26, isAbsolute as isAbsolute12, join as join46, resolve as resolve21 } from "node:path";
|
|
25305
25251
|
|
|
25306
25252
|
// src/external-host-turn-loop.ts
|
|
25307
25253
|
var EXTERNAL_ROLE_TURN_ROUND_LIMIT = 8;
|
|
@@ -25751,7 +25697,7 @@ function formatCodexFailurePayload(payload) {
|
|
|
25751
25697
|
function cwdIsGitWorkTree(cwd) {
|
|
25752
25698
|
let dir = cwd;
|
|
25753
25699
|
for (; ; ) {
|
|
25754
|
-
if (existsSync15(
|
|
25700
|
+
if (existsSync15(join46(dir, ".git"))) return true;
|
|
25755
25701
|
const parent = dirname26(dir);
|
|
25756
25702
|
if (parent === dir) return false;
|
|
25757
25703
|
dir = parent;
|
|
@@ -25962,14 +25908,14 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
25962
25908
|
await config.sessionIdentity.bind(request.principal, sessionId);
|
|
25963
25909
|
}
|
|
25964
25910
|
const env = { ...process.env, ...config.env ?? {} };
|
|
25965
|
-
const systemPromptPath =
|
|
25966
|
-
await
|
|
25911
|
+
const systemPromptPath = join46(request.runDirectory, "headless-system-prompt.txt");
|
|
25912
|
+
await writeFile10(systemPromptPath, systemPrompt, "utf8");
|
|
25967
25913
|
let mcpConfigPath;
|
|
25968
25914
|
let outputSchemaPath;
|
|
25969
25915
|
if (codex) {
|
|
25970
25916
|
if (prepared.terminatingToolName !== NAVIGATOR_OUTPUT_TOOL_NAME) {
|
|
25971
|
-
outputSchemaPath =
|
|
25972
|
-
await
|
|
25917
|
+
outputSchemaPath = join46(request.runDirectory, "headless-output-schema.json");
|
|
25918
|
+
await writeFile10(
|
|
25973
25919
|
outputSchemaPath,
|
|
25974
25920
|
`${JSON.stringify(closeJsonSchemaForCodex(prepared.jsonSchema), null, 2)}
|
|
25975
25921
|
`,
|
|
@@ -25977,8 +25923,8 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
25977
25923
|
);
|
|
25978
25924
|
}
|
|
25979
25925
|
} else {
|
|
25980
|
-
mcpConfigPath =
|
|
25981
|
-
await
|
|
25926
|
+
mcpConfigPath = join46(request.runDirectory, "headless-mcp-config.json");
|
|
25927
|
+
await writeFile10(
|
|
25982
25928
|
mcpConfigPath,
|
|
25983
25929
|
`${JSON.stringify(headlessMcpConfigDocument(prepared.mcpServers), null, 2)}
|
|
25984
25930
|
`,
|
|
@@ -26241,7 +26187,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
26241
26187
|
host: config.hostName,
|
|
26242
26188
|
sessionId: exitedSessionId,
|
|
26243
26189
|
cwd: request.cwd,
|
|
26244
|
-
sessionDirectory:
|
|
26190
|
+
sessionDirectory: join46(request.runDirectory, "session"),
|
|
26245
26191
|
sessionParent,
|
|
26246
26192
|
continuation: request.continuation,
|
|
26247
26193
|
...request.model !== void 0 ? { model: request.model } : {},
|