@akagilnc/pi-workflow-roles 0.1.5323 → 0.1.5357
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/package.json +1 -1
- package/src/engine-detour.ts +7 -88
|
@@ -118,9 +118,6 @@ var init_host_descriptions = __esm({
|
|
|
118
118
|
|
|
119
119
|
// src/engine-detour.ts
|
|
120
120
|
import { spawn } from "node:child_process";
|
|
121
|
-
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
122
|
-
import { tmpdir } from "node:os";
|
|
123
|
-
import { join as join2 } from "node:path";
|
|
124
121
|
function normalizeEngineName(engine) {
|
|
125
122
|
if (engine === void 0) return void 0;
|
|
126
123
|
const trimmed = engine.trim();
|
|
@@ -145,21 +142,7 @@ function abortReasonError(signal) {
|
|
|
145
142
|
error.name = "AbortError";
|
|
146
143
|
return error;
|
|
147
144
|
}
|
|
148
|
-
function
|
|
149
|
-
let replaced = 0;
|
|
150
|
-
const out = argv.map((part) => {
|
|
151
|
-
if (part !== ENGINE_DETOUR_STAGED_PROMPT_TOKEN) return part;
|
|
152
|
-
replaced += 1;
|
|
153
|
-
return stagedPath;
|
|
154
|
-
});
|
|
155
|
-
if (replaced !== 1) {
|
|
156
|
-
throw new Error(
|
|
157
|
-
`\u52B3\u52A1\u5F15\u64CE stagedPrompt \u9700\u8981 argv \u4E2D\u6070\u597D\u4E00\u4E2A ${ENGINE_DETOUR_STAGED_PROMPT_TOKEN}\uFF08\u5B9E\u9645 ${replaced}\uFF09`
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
return out;
|
|
161
|
-
}
|
|
162
|
-
async function spawnEngineDetourOnce(input) {
|
|
145
|
+
async function runEngineDetourOnce(input) {
|
|
163
146
|
if (input.argv.length === 0) {
|
|
164
147
|
throw new Error("\u52B3\u52A1\u5F15\u64CE argv \u4E0D\u5F97\u4E3A\u7A7A");
|
|
165
148
|
}
|
|
@@ -217,42 +200,6 @@ async function spawnEngineDetourOnce(input) {
|
|
|
217
200
|
});
|
|
218
201
|
});
|
|
219
202
|
}
|
|
220
|
-
async function runEngineDetourOnce(input) {
|
|
221
|
-
if (input.stagedPrompt === void 0) {
|
|
222
|
-
return spawnEngineDetourOnce(input);
|
|
223
|
-
}
|
|
224
|
-
const stagingDir = await mkdtemp(join2(tmpdir(), "ak-engine-detour-"));
|
|
225
|
-
const stagedPath = join2(stagingDir, "prompt.txt");
|
|
226
|
-
let result;
|
|
227
|
-
let runError;
|
|
228
|
-
try {
|
|
229
|
-
await writeFile(stagedPath, input.stagedPrompt, "utf8");
|
|
230
|
-
const argv = resolveArgvWithStagedPrompt(input.argv, stagedPath);
|
|
231
|
-
result = await spawnEngineDetourOnce({
|
|
232
|
-
argv,
|
|
233
|
-
cwd: input.cwd,
|
|
234
|
-
...input.env === void 0 ? {} : { env: input.env },
|
|
235
|
-
...input.signal === void 0 ? {} : { signal: input.signal }
|
|
236
|
-
});
|
|
237
|
-
} catch (error) {
|
|
238
|
-
runError = error;
|
|
239
|
-
}
|
|
240
|
-
try {
|
|
241
|
-
await rm(stagingDir, { recursive: true, force: true });
|
|
242
|
-
} catch (cleanupError) {
|
|
243
|
-
if (runError !== void 0) {
|
|
244
|
-
throw new Error(
|
|
245
|
-
`\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)}`,
|
|
246
|
-
{ cause: runError }
|
|
247
|
-
);
|
|
248
|
-
}
|
|
249
|
-
throw cleanupError instanceof Error ? cleanupError : new Error(String(cleanupError));
|
|
250
|
-
}
|
|
251
|
-
if (runError !== void 0) {
|
|
252
|
-
throw runError instanceof Error ? runError : new Error(String(runError));
|
|
253
|
-
}
|
|
254
|
-
return result;
|
|
255
|
-
}
|
|
256
203
|
function isEngineDetourFailure(result) {
|
|
257
204
|
return result.code !== 0 || result.stdout.trim() === "";
|
|
258
205
|
}
|
|
@@ -287,7 +234,7 @@ function resolveEngineModel(getFlag) {
|
|
|
287
234
|
if (typeof flag !== "string") return void 0;
|
|
288
235
|
return normalizeEngineName(flag);
|
|
289
236
|
}
|
|
290
|
-
var ENGINE_DETOUR_TOOL_NAME, AK_ROLE_ENGINE_ENV, ENGINE_FLAG_NAME, ENGINE_MODEL_FLAG_NAME,
|
|
237
|
+
var ENGINE_DETOUR_TOOL_NAME, AK_ROLE_ENGINE_ENV, ENGINE_FLAG_NAME, ENGINE_MODEL_FLAG_NAME, ENGINE_DETOUR_EMPTY_STDOUT_DIAGNOSTIC;
|
|
291
238
|
var init_engine_detour = __esm({
|
|
292
239
|
"src/engine-detour.ts"() {
|
|
293
240
|
"use strict";
|
|
@@ -295,7 +242,6 @@ var init_engine_detour = __esm({
|
|
|
295
242
|
AK_ROLE_ENGINE_ENV = "AK_ROLE_ENGINE";
|
|
296
243
|
ENGINE_FLAG_NAME = "ak-engine";
|
|
297
244
|
ENGINE_MODEL_FLAG_NAME = "ak-engine-model";
|
|
298
|
-
ENGINE_DETOUR_STAGED_PROMPT_TOKEN = "<<ak-engine-staged-prompt>>";
|
|
299
245
|
ENGINE_DETOUR_EMPTY_STDOUT_DIAGNOSTIC = "\u52B3\u52A1\u5F15\u64CE stdout \u4E3A\u7A7A";
|
|
300
246
|
}
|
|
301
247
|
});
|
|
@@ -1065,7 +1011,7 @@ __export(run_ticket_number_exports, {
|
|
|
1065
1011
|
requireSafePositiveTicketNumber: () => requireSafePositiveTicketNumber
|
|
1066
1012
|
});
|
|
1067
1013
|
import { readFile } from "node:fs/promises";
|
|
1068
|
-
import { join as
|
|
1014
|
+
import { join as join2 } from "node:path";
|
|
1069
1015
|
function isEnoent(error) {
|
|
1070
1016
|
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
1071
1017
|
}
|
|
@@ -1105,7 +1051,7 @@ async function readJsonObject(path) {
|
|
|
1105
1051
|
}
|
|
1106
1052
|
}
|
|
1107
1053
|
async function readBoardPageTicketNumber(runDirectory, page) {
|
|
1108
|
-
const record4 = await readJsonObject(
|
|
1054
|
+
const record4 = await readJsonObject(join2(runDirectory, page));
|
|
1109
1055
|
if (record4 === void 0) return void 0;
|
|
1110
1056
|
return ticketFromRecord(record4);
|
|
1111
1057
|
}
|
|
@@ -1114,7 +1060,7 @@ async function readBoardTicketNumber(runDirectory) {
|
|
|
1114
1060
|
}
|
|
1115
1061
|
async function readMigrationDerivedTicketNumber(runDirectory) {
|
|
1116
1062
|
const record4 = await readJsonObject(
|
|
1117
|
-
|
|
1063
|
+
join2(runDirectory, MIGRATION_TICKET_DERIVATION_PAGE)
|
|
1118
1064
|
);
|
|
1119
1065
|
if (record4 === void 0) return void 0;
|
|
1120
1066
|
if (record4.derivation !== "worktree-path-basename") return void 0;
|
|
@@ -2038,7 +1984,7 @@ import {
|
|
|
2038
1984
|
statSync
|
|
2039
1985
|
} from "node:fs";
|
|
2040
1986
|
import { userInfo } from "node:os";
|
|
2041
|
-
import { basename as basename2, dirname as dirname2, isAbsolute as isAbsolute2, join as
|
|
1987
|
+
import { basename as basename2, dirname as dirname2, isAbsolute as isAbsolute2, join as join3, relative, resolve as resolve2, sep } from "node:path";
|
|
2042
1988
|
function packageMachineHome() {
|
|
2043
1989
|
return resolve2(userInfo().homedir);
|
|
2044
1990
|
}
|
|
@@ -2078,7 +2024,7 @@ function resolveActivationLedgerHomeForPath(path) {
|
|
|
2078
2024
|
return resolveActivationLedgerHome();
|
|
2079
2025
|
}
|
|
2080
2026
|
function activationBookDirectory(ledgerHome, bookKey) {
|
|
2081
|
-
return
|
|
2027
|
+
return join3(ledgerHome, "books", bookKey);
|
|
2082
2028
|
}
|
|
2083
2029
|
function pathContainedIn(root, candidate) {
|
|
2084
2030
|
const rel = relative(root, candidate);
|
|
@@ -2091,7 +2037,7 @@ function physicalPathIdentity(path) {
|
|
|
2091
2037
|
while (true) {
|
|
2092
2038
|
try {
|
|
2093
2039
|
const real = realpathSync(cursor);
|
|
2094
|
-
return missing.length === 0 ? real :
|
|
2040
|
+
return missing.length === 0 ? real : join3(real, ...missing);
|
|
2095
2041
|
} catch (error) {
|
|
2096
2042
|
if (errnoCode(error) !== "ENOENT") {
|
|
2097
2043
|
return absolute;
|
|
@@ -2191,7 +2137,7 @@ function ensureRealDirectoryTree(root, targetDir) {
|
|
|
2191
2137
|
if (part === "..") {
|
|
2192
2138
|
throw new ActivationLedgerError(`activation ledger path contains '..': ${absoluteTarget}`);
|
|
2193
2139
|
}
|
|
2194
|
-
lexicalCursor =
|
|
2140
|
+
lexicalCursor = join3(lexicalCursor, part);
|
|
2195
2141
|
let st;
|
|
2196
2142
|
try {
|
|
2197
2143
|
st = lstatSync(lexicalCursor);
|
|
@@ -2314,7 +2260,7 @@ var init_sitian_contracts = __esm({
|
|
|
2314
2260
|
// src/sitian-appender.ts
|
|
2315
2261
|
import { randomUUID } from "node:crypto";
|
|
2316
2262
|
import { appendFileSync } from "node:fs";
|
|
2317
|
-
import { dirname as dirname3, join as
|
|
2263
|
+
import { dirname as dirname3, join as join4 } from "node:path";
|
|
2318
2264
|
function appendSitianRecordBlock(input, block) {
|
|
2319
2265
|
if (block === "") return;
|
|
2320
2266
|
try {
|
|
@@ -2336,8 +2282,8 @@ function resolveSitianVolumeCategory(kind) {
|
|
|
2336
2282
|
return kind;
|
|
2337
2283
|
}
|
|
2338
2284
|
function ticketProvenanceUnderBookPaths(ledgerHome, bookKey, ticketId) {
|
|
2339
|
-
const sessionDir =
|
|
2340
|
-
return { sessionDir, recordFile:
|
|
2285
|
+
const sessionDir = join4(activationBookDirectory(ledgerHome, bookKey), ticketId);
|
|
2286
|
+
return { sessionDir, recordFile: join4(sessionDir, SITIAN_RECORDS_LEAF) };
|
|
2341
2287
|
}
|
|
2342
2288
|
function resolveSitianRecordPathInLedger(input, ledgerHome) {
|
|
2343
2289
|
const category = resolveSitianVolumeCategory(input.kind);
|
|
@@ -2354,13 +2300,13 @@ function resolveSitianRecordPathInLedger(input, ledgerHome) {
|
|
|
2354
2300
|
recordFile = paths.recordFile;
|
|
2355
2301
|
} else if (category === "ticket-provenance" && input.runDirectory !== void 0) {
|
|
2356
2302
|
sessionDir = input.runDirectory;
|
|
2357
|
-
recordFile =
|
|
2303
|
+
recordFile = join4(sessionDir, SITIAN_RECORDS_LEAF);
|
|
2358
2304
|
} else {
|
|
2359
2305
|
if (input.sessionParent === void 0 || input.sessionParent.length === 0 || !physicallyContainedIn(ledgerHome, input.sessionParent)) {
|
|
2360
2306
|
throw new Error("Sitian record ownership requires a parent session inside the ledger home");
|
|
2361
2307
|
}
|
|
2362
|
-
sessionDir =
|
|
2363
|
-
recordFile =
|
|
2308
|
+
sessionDir = join4(dirname3(input.sessionParent), category);
|
|
2309
|
+
recordFile = join4(sessionDir, SITIAN_RECORDS_LEAF);
|
|
2364
2310
|
}
|
|
2365
2311
|
if (!physicallyContainedIn(ledgerHome, sessionDir)) {
|
|
2366
2312
|
throw new Error("Sitian record ownership requires a directory inside the ledger home");
|
|
@@ -2489,7 +2435,7 @@ var init_sitian_facade = __esm({
|
|
|
2489
2435
|
|
|
2490
2436
|
// src/role-run-placement.ts
|
|
2491
2437
|
import { readdir } from "node:fs/promises";
|
|
2492
|
-
import { join as
|
|
2438
|
+
import { join as join5 } from "node:path";
|
|
2493
2439
|
function isMissingPathError(error) {
|
|
2494
2440
|
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
2495
2441
|
}
|
|
@@ -2506,13 +2452,13 @@ async function listBookRunDirectories(bookDir) {
|
|
|
2506
2452
|
}
|
|
2507
2453
|
for (const entry of entries) {
|
|
2508
2454
|
if (!entry.isDirectory()) continue;
|
|
2509
|
-
const runDir =
|
|
2455
|
+
const runDir = join5(runsDir, entry.name);
|
|
2510
2456
|
if (seen.has(runDir)) continue;
|
|
2511
2457
|
seen.add(runDir);
|
|
2512
2458
|
out.push(runDir);
|
|
2513
2459
|
}
|
|
2514
2460
|
};
|
|
2515
|
-
await collect(
|
|
2461
|
+
await collect(join5(bookDir, "runs"));
|
|
2516
2462
|
let subjects;
|
|
2517
2463
|
try {
|
|
2518
2464
|
subjects = await readdir(bookDir, { withFileTypes: true });
|
|
@@ -2522,7 +2468,7 @@ async function listBookRunDirectories(bookDir) {
|
|
|
2522
2468
|
}
|
|
2523
2469
|
for (const subject of subjects) {
|
|
2524
2470
|
if (!subject.isDirectory() || subject.name === "runs") continue;
|
|
2525
|
-
await collect(
|
|
2471
|
+
await collect(join5(bookDir, subject.name, "runs"));
|
|
2526
2472
|
}
|
|
2527
2473
|
return out.sort();
|
|
2528
2474
|
}
|
|
@@ -2531,23 +2477,23 @@ function roleRunPlacement(ledgerHome, input) {
|
|
|
2531
2477
|
input.subject.ticketNumber,
|
|
2532
2478
|
"roleRunPlacement subject.ticketNumber"
|
|
2533
2479
|
)) : "unbound";
|
|
2534
|
-
const runDirectory =
|
|
2480
|
+
const runDirectory = join5(
|
|
2535
2481
|
activationBookDirectory(ledgerHome, input.bookKey),
|
|
2536
2482
|
subjectDirectory,
|
|
2537
2483
|
"runs",
|
|
2538
2484
|
`${input.runId}@${input.role}`
|
|
2539
2485
|
);
|
|
2540
|
-
const sessionDirectory =
|
|
2486
|
+
const sessionDirectory = join5(runDirectory, "session");
|
|
2541
2487
|
return {
|
|
2542
2488
|
runDirectory,
|
|
2543
2489
|
sessionDirectory,
|
|
2544
|
-
sessionFile:
|
|
2490
|
+
sessionFile: join5(sessionDirectory, "session.jsonl"),
|
|
2545
2491
|
artifactsDirectory: roleRunArtifactsDirectory(runDirectory),
|
|
2546
|
-
attachmentsDirectory:
|
|
2492
|
+
attachmentsDirectory: join5(runDirectory, "attachments")
|
|
2547
2493
|
};
|
|
2548
2494
|
}
|
|
2549
2495
|
function roleRunArtifactsDirectory(runDirectory) {
|
|
2550
|
-
return
|
|
2496
|
+
return join5(runDirectory, "artifacts");
|
|
2551
2497
|
}
|
|
2552
2498
|
function ensureRoleRunDirectory(ledgerHome, directory) {
|
|
2553
2499
|
return ensureRealDirectoryTree(ledgerHome, directory);
|
|
@@ -2579,7 +2525,7 @@ __export(run_terminal_artifacts_exports, {
|
|
|
2579
2525
|
runIdFromRunDirectory: () => runIdFromRunDirectory
|
|
2580
2526
|
});
|
|
2581
2527
|
import { readdir as readdir2, readFile as readFile3 } from "node:fs/promises";
|
|
2582
|
-
import { basename as basename3, dirname as dirname4, join as
|
|
2528
|
+
import { basename as basename3, dirname as dirname4, join as join6 } from "node:path";
|
|
2583
2529
|
function isMissingPathError2(error) {
|
|
2584
2530
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
2585
2531
|
}
|
|
@@ -2654,7 +2600,7 @@ async function listUniqueErrorFallbackPaths(directories) {
|
|
|
2654
2600
|
}
|
|
2655
2601
|
for (const name of names.sort((a, b) => a.localeCompare(b))) {
|
|
2656
2602
|
if (!UNIQUE_ERROR_FALLBACK_NAME.test(name)) continue;
|
|
2657
|
-
found.push(
|
|
2603
|
+
found.push(join6(dir, name));
|
|
2658
2604
|
}
|
|
2659
2605
|
}
|
|
2660
2606
|
return found;
|
|
@@ -2700,11 +2646,11 @@ async function readRunTerminalArtifact(runDirectory) {
|
|
|
2700
2646
|
unreadable.push(read);
|
|
2701
2647
|
};
|
|
2702
2648
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
2703
|
-
consider(await readTerminalArtifactAtPath(
|
|
2649
|
+
consider(await readTerminalArtifactAtPath(join6(artifactsDir, file), file));
|
|
2704
2650
|
}
|
|
2705
2651
|
for (const relative4 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
2706
2652
|
consider(
|
|
2707
|
-
await readTerminalArtifactAtPath(
|
|
2653
|
+
await readTerminalArtifactAtPath(join6(runDirectory, relative4), "error.json")
|
|
2708
2654
|
);
|
|
2709
2655
|
}
|
|
2710
2656
|
for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
|
|
@@ -2765,10 +2711,10 @@ var init_cli_errors = __esm({
|
|
|
2765
2711
|
});
|
|
2766
2712
|
|
|
2767
2713
|
// src/typed-provider-http.ts
|
|
2768
|
-
import { readFile as readFile4, unlink, writeFile
|
|
2769
|
-
import { join as
|
|
2714
|
+
import { readFile as readFile4, unlink, writeFile } from "node:fs/promises";
|
|
2715
|
+
import { join as join7 } from "node:path";
|
|
2770
2716
|
function typedProviderHttpPath(runDirectory) {
|
|
2771
|
-
return
|
|
2717
|
+
return join7(runDirectory, TYPED_HTTP_FILE);
|
|
2772
2718
|
}
|
|
2773
2719
|
async function clearTypedProviderHttpObservation(runDirectory) {
|
|
2774
2720
|
try {
|
|
@@ -2789,7 +2735,7 @@ async function recordTypedProviderHttpStatus(runDirectory, observation) {
|
|
|
2789
2735
|
httpStatus: observation.httpStatus,
|
|
2790
2736
|
provider: observation.provider
|
|
2791
2737
|
};
|
|
2792
|
-
await
|
|
2738
|
+
await writeFile(
|
|
2793
2739
|
typedProviderHttpPath(runDirectory),
|
|
2794
2740
|
`${JSON.stringify(body)}
|
|
2795
2741
|
`,
|
|
@@ -2912,7 +2858,7 @@ __export(auditor_dossier_tool_exports, {
|
|
|
2912
2858
|
auditorRunDirectory: () => auditorRunDirectory,
|
|
2913
2859
|
createAuditorDossierTool: () => createAuditorDossierTool
|
|
2914
2860
|
});
|
|
2915
|
-
import { dirname as dirname5, join as
|
|
2861
|
+
import { dirname as dirname5, join as join8, resolve as resolve3 } from "node:path";
|
|
2916
2862
|
import { Type as Type10 } from "typebox";
|
|
2917
2863
|
function auditorRunDirectory(context) {
|
|
2918
2864
|
const sessionFile = context.sessionManager?.getSessionFile?.();
|
|
@@ -2935,9 +2881,9 @@ function createAuditorDossierTool(runDirectory) {
|
|
|
2935
2881
|
}
|
|
2936
2882
|
const details = {
|
|
2937
2883
|
runDirectory,
|
|
2938
|
-
admittedRequest:
|
|
2939
|
-
parentSessionCandidate:
|
|
2940
|
-
attachments:
|
|
2884
|
+
admittedRequest: join8(runDirectory, "admitted-request.json"),
|
|
2885
|
+
parentSessionCandidate: join8(runDirectory, "session", "session.jsonl"),
|
|
2886
|
+
attachments: join8(runDirectory, "attachments"),
|
|
2941
2887
|
artifacts: roleRunArtifactsDirectory(runDirectory)
|
|
2942
2888
|
};
|
|
2943
2889
|
return {
|
|
@@ -3353,7 +3299,7 @@ __export(session_assistant_usage_exports, {
|
|
|
3353
3299
|
sessionFileFromPublicSummon: () => sessionFileFromPublicSummon,
|
|
3354
3300
|
usageFromPublicSummon: () => usageFromPublicSummon
|
|
3355
3301
|
});
|
|
3356
|
-
import { join as
|
|
3302
|
+
import { join as join9 } from "node:path";
|
|
3357
3303
|
async function readAssistantUsageFromSessionFile(sessionFile) {
|
|
3358
3304
|
const { readFile: readFile25 } = await import("node:fs/promises");
|
|
3359
3305
|
let text;
|
|
@@ -3423,7 +3369,7 @@ async function readAssistantUsageFromSessionFile(sessionFile) {
|
|
|
3423
3369
|
}
|
|
3424
3370
|
function sessionFileFromPublicSummon(summoned) {
|
|
3425
3371
|
if (typeof summoned.runDirectory === "string" && summoned.runDirectory.trim() !== "") {
|
|
3426
|
-
return
|
|
3372
|
+
return join9(summoned.runDirectory, "session", "session.jsonl");
|
|
3427
3373
|
}
|
|
3428
3374
|
const fromArtifacts = summoned.terminal?.artifacts?.map((a) => a.path).find((p) => typeof p === "string" && p.endsWith("session.jsonl"));
|
|
3429
3375
|
if (fromArtifacts !== void 0) return fromArtifacts;
|
|
@@ -3432,7 +3378,7 @@ function sessionFileFromPublicSummon(summoned) {
|
|
|
3432
3378
|
const facts = outcome.decisiveFacts;
|
|
3433
3379
|
const pointer = facts?.runPointer;
|
|
3434
3380
|
if (typeof pointer === "string" && pointer.trim() !== "") {
|
|
3435
|
-
return
|
|
3381
|
+
return join9(pointer, "session", "session.jsonl");
|
|
3436
3382
|
}
|
|
3437
3383
|
return void 0;
|
|
3438
3384
|
}
|
|
@@ -3449,7 +3395,7 @@ var init_session_assistant_usage = __esm({
|
|
|
3449
3395
|
|
|
3450
3396
|
// src/package-resources/engine-material.ts
|
|
3451
3397
|
import { existsSync as existsSync2, readdirSync } from "node:fs";
|
|
3452
|
-
import { join as
|
|
3398
|
+
import { join as join10 } from "node:path";
|
|
3453
3399
|
function pickEngineAxis(source) {
|
|
3454
3400
|
return {
|
|
3455
3401
|
...source.engine === void 0 ? {} : { engine: source.engine },
|
|
@@ -3470,11 +3416,11 @@ function isEngineNameSyntax(name) {
|
|
|
3470
3416
|
return true;
|
|
3471
3417
|
}
|
|
3472
3418
|
function resolveEngineMaterialDirectory(packageRoot) {
|
|
3473
|
-
return
|
|
3419
|
+
return join10(packageRoot, ENGINE_MATERIAL_RELATIVE_ROOT);
|
|
3474
3420
|
}
|
|
3475
3421
|
function resolveEngineMaterialPath(packageRoot, name) {
|
|
3476
3422
|
const legal = assertLegalEngineName(name);
|
|
3477
|
-
return
|
|
3423
|
+
return join10(resolveEngineMaterialDirectory(packageRoot), `${legal}.md`);
|
|
3478
3424
|
}
|
|
3479
3425
|
function assertLegalEngineName(name) {
|
|
3480
3426
|
if (!isEngineNameSyntax(name)) {
|
|
@@ -3531,7 +3477,7 @@ __export(durable_principal_exports, {
|
|
|
3531
3477
|
issuePiDurablePrincipalCoordinates: () => issuePiDurablePrincipalCoordinates,
|
|
3532
3478
|
piDurablePrincipalAuthority: () => piDurablePrincipalAuthority
|
|
3533
3479
|
});
|
|
3534
|
-
import { join as
|
|
3480
|
+
import { join as join11 } from "node:path";
|
|
3535
3481
|
function encode(coordinates) {
|
|
3536
3482
|
return coordinates;
|
|
3537
3483
|
}
|
|
@@ -3581,7 +3527,7 @@ var init_durable_principal = __esm({
|
|
|
3581
3527
|
}
|
|
3582
3528
|
return {
|
|
3583
3529
|
sessionDirectory: record4.sessionDirectory,
|
|
3584
|
-
sessionFile: typeof record4.sessionFile === "string" && record4.sessionFile.trim() !== "" ? record4.sessionFile :
|
|
3530
|
+
sessionFile: typeof record4.sessionFile === "string" && record4.sessionFile.trim() !== "" ? record4.sessionFile : join11(record4.sessionDirectory, "session.jsonl")
|
|
3585
3531
|
};
|
|
3586
3532
|
}
|
|
3587
3533
|
};
|
|
@@ -3644,12 +3590,12 @@ __export(role_turn_host_exports, {
|
|
|
3644
3590
|
import { execFile, spawn as spawn2 } from "node:child_process";
|
|
3645
3591
|
import { constants } from "node:fs";
|
|
3646
3592
|
import { access, appendFile, readFile as readFile6, realpath } from "node:fs/promises";
|
|
3647
|
-
import { delimiter, dirname as dirname6, isAbsolute as isAbsolute3, join as
|
|
3593
|
+
import { delimiter, dirname as dirname6, isAbsolute as isAbsolute3, join as join12, resolve as resolve4 } from "node:path";
|
|
3648
3594
|
import { platform } from "node:process";
|
|
3649
3595
|
import { promisify } from "node:util";
|
|
3650
3596
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
3651
3597
|
function resolveInternalRoleEntrypoint(packageRoot) {
|
|
3652
|
-
return
|
|
3598
|
+
return join12(packageRoot, INTERNAL_ROLE_ENTRYPOINT_RELATIVE);
|
|
3653
3599
|
}
|
|
3654
3600
|
function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
|
|
3655
3601
|
return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
|
|
@@ -4660,13 +4606,13 @@ var init_session_dialogue = __esm({
|
|
|
4660
4606
|
|
|
4661
4607
|
// src/ticket-provenance.ts
|
|
4662
4608
|
import { readFile as readFile10, unlink as unlink2 } from "node:fs/promises";
|
|
4663
|
-
import { basename as basename4, dirname as dirname8, join as
|
|
4609
|
+
import { basename as basename4, dirname as dirname8, join as join13, resolve as resolve7 } from "node:path";
|
|
4664
4610
|
function dialogueSessionSourceRoots(home) {
|
|
4665
4611
|
const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
|
|
4666
4612
|
return [
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4613
|
+
join13(machineHome, ".claude", "projects"),
|
|
4614
|
+
join13(machineHome, ".codex", "sessions"),
|
|
4615
|
+
join13(machineHome, ".pi", "agent", "sessions")
|
|
4670
4616
|
];
|
|
4671
4617
|
}
|
|
4672
4618
|
function isLedgerRoleSessionFile(absolute, home) {
|
|
@@ -4704,7 +4650,7 @@ function ticketProvenanceRecordInput(ticketNumber, cwd, home, runDirectory) {
|
|
|
4704
4650
|
};
|
|
4705
4651
|
}
|
|
4706
4652
|
async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, home) {
|
|
4707
|
-
const source =
|
|
4653
|
+
const source = join13(runDirectory, "records.jsonl");
|
|
4708
4654
|
let content;
|
|
4709
4655
|
try {
|
|
4710
4656
|
content = await readFile10(source, "utf8");
|
|
@@ -4914,7 +4860,7 @@ var init_uuidv7 = __esm({
|
|
|
4914
4860
|
});
|
|
4915
4861
|
|
|
4916
4862
|
// src/notary-source-run.ts
|
|
4917
|
-
import { dirname as dirname9, isAbsolute as isAbsolute5, join as
|
|
4863
|
+
import { dirname as dirname9, isAbsolute as isAbsolute5, join as join14, resolve as resolve8, basename as basename5 } from "node:path";
|
|
4918
4864
|
import { lstat, realpath as realpath3 } from "node:fs/promises";
|
|
4919
4865
|
async function readRetainedIdentity(runDirectory) {
|
|
4920
4866
|
try {
|
|
@@ -4971,11 +4917,11 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
4971
4917
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
4972
4918
|
const bookKey = resolveBookKeyFromGit(options.projectRoot);
|
|
4973
4919
|
const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
|
|
4974
|
-
const bookRunsRoot =
|
|
4920
|
+
const bookRunsRoot = join14(bookDirectory, "runs");
|
|
4975
4921
|
let candidate;
|
|
4976
4922
|
const bare = parseRunDirectoryName(raw);
|
|
4977
4923
|
if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
|
|
4978
|
-
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ??
|
|
4924
|
+
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join14(bookRunsRoot, `${bare.runId}@${bare.role}`);
|
|
4979
4925
|
} else {
|
|
4980
4926
|
candidate = isAbsolute5(raw) ? raw : resolve8(options.projectRoot, raw);
|
|
4981
4927
|
const identity2 = parseRunDirectoryName(basename5(candidate));
|
|
@@ -6182,15 +6128,15 @@ import { execFileSync as execFileSync2 } from "node:child_process";
|
|
|
6182
6128
|
import { existsSync as existsSync3 } from "node:fs";
|
|
6183
6129
|
import {
|
|
6184
6130
|
lstat as lstat2,
|
|
6185
|
-
mkdtemp
|
|
6131
|
+
mkdtemp,
|
|
6186
6132
|
readFile as readFile11,
|
|
6187
6133
|
realpath as realpath4,
|
|
6188
6134
|
rename,
|
|
6189
|
-
rm
|
|
6190
|
-
writeFile as
|
|
6135
|
+
rm,
|
|
6136
|
+
writeFile as writeFile2
|
|
6191
6137
|
} from "node:fs/promises";
|
|
6192
|
-
import { tmpdir
|
|
6193
|
-
import { basename as basename6, dirname as dirname10, isAbsolute as isAbsolute6, join as
|
|
6138
|
+
import { tmpdir } from "node:os";
|
|
6139
|
+
import { basename as basename6, dirname as dirname10, isAbsolute as isAbsolute6, join as join15, resolve as resolve9, sep as sep3 } from "node:path";
|
|
6194
6140
|
function issueAdmissionPlacement(authority, request) {
|
|
6195
6141
|
const ledgerHome = resolveActivationLedgerHome(request.home);
|
|
6196
6142
|
const bookKey = resolveBookKeyFromGit(request.cwd);
|
|
@@ -6215,7 +6161,7 @@ async function writeAdmittedRequestPersistence(admittedRequestPath, body, coordi
|
|
|
6215
6161
|
sessionDirectory: coordinates.sessionDirectory,
|
|
6216
6162
|
sessionFile: coordinates.sessionFile
|
|
6217
6163
|
};
|
|
6218
|
-
await
|
|
6164
|
+
await writeFile2(
|
|
6219
6165
|
admittedRequestPath,
|
|
6220
6166
|
`${JSON.stringify(projection, null, 2)}
|
|
6221
6167
|
`,
|
|
@@ -6243,15 +6189,15 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
|
|
|
6243
6189
|
...source.ticketNumber === void 0 ? {} : { ticketNumber: source.ticketNumber },
|
|
6244
6190
|
...effectiveModelLedgerFields(effectiveModel)
|
|
6245
6191
|
};
|
|
6246
|
-
await
|
|
6247
|
-
|
|
6192
|
+
await writeFile2(
|
|
6193
|
+
join15(source.runDirectory, "invocation.json"),
|
|
6248
6194
|
`${JSON.stringify(identity, null, 2)}
|
|
6249
6195
|
`,
|
|
6250
6196
|
"utf8"
|
|
6251
6197
|
);
|
|
6252
6198
|
}
|
|
6253
6199
|
async function recordEffectiveInvocationModel(runDirectory, model, engine, host, engineModel) {
|
|
6254
|
-
const ledgerPath =
|
|
6200
|
+
const ledgerPath = join15(runDirectory, "invocation.json");
|
|
6255
6201
|
const current = JSON.parse(await readFile11(ledgerPath, "utf8"));
|
|
6256
6202
|
const next = { ...current };
|
|
6257
6203
|
if (model !== void 0) {
|
|
@@ -6276,7 +6222,7 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host,
|
|
|
6276
6222
|
if (host !== void 0) {
|
|
6277
6223
|
next.host = host;
|
|
6278
6224
|
}
|
|
6279
|
-
await
|
|
6225
|
+
await writeFile2(
|
|
6280
6226
|
ledgerPath,
|
|
6281
6227
|
`${JSON.stringify(next, null, 2)}
|
|
6282
6228
|
`,
|
|
@@ -6284,9 +6230,9 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host,
|
|
|
6284
6230
|
);
|
|
6285
6231
|
}
|
|
6286
6232
|
async function mergeInvocationIdentityPage(runDirectory, fields) {
|
|
6287
|
-
const ledgerPath =
|
|
6233
|
+
const ledgerPath = join15(runDirectory, "invocation.json");
|
|
6288
6234
|
const current = JSON.parse(await readFile11(ledgerPath, "utf8"));
|
|
6289
|
-
await
|
|
6235
|
+
await writeFile2(
|
|
6290
6236
|
ledgerPath,
|
|
6291
6237
|
`${JSON.stringify({
|
|
6292
6238
|
...current,
|
|
@@ -6309,7 +6255,7 @@ async function persistAdmittedSourceRunPath(admitted, sourceRunPath, auditorSubj
|
|
|
6309
6255
|
}
|
|
6310
6256
|
const sameSubject = auditorSubject === void 0 || current.auditorSubject === auditorSubject;
|
|
6311
6257
|
if (current.sourceRunPath === sourceRunPath && sameSubject) return;
|
|
6312
|
-
await
|
|
6258
|
+
await writeFile2(
|
|
6313
6259
|
admittedPath,
|
|
6314
6260
|
`${JSON.stringify({
|
|
6315
6261
|
...current,
|
|
@@ -6336,7 +6282,7 @@ async function recordAdmittedCorrelation(admitted, correlationId) {
|
|
|
6336
6282
|
...typeof current.correlationId === "string" && current.correlationId.trim() !== "" ? [current.correlationId] : []
|
|
6337
6283
|
];
|
|
6338
6284
|
const correlationIds = [.../* @__PURE__ */ new Set([...prior, correlationId])];
|
|
6339
|
-
await
|
|
6285
|
+
await writeFile2(
|
|
6340
6286
|
admitted.admittedRequestPath,
|
|
6341
6287
|
`${JSON.stringify({ ...current, correlationId, correlationIds }, null, 2)}
|
|
6342
6288
|
`,
|
|
@@ -6367,7 +6313,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
6367
6313
|
const childRunIds = parentPage.childDiaristRunIds;
|
|
6368
6314
|
for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
|
|
6369
6315
|
if (typeof childRunId !== "string") continue;
|
|
6370
|
-
const childDirectory =
|
|
6316
|
+
const childDirectory = join15(dirname10(oldRunDirectory), `${childRunId}@diarist`);
|
|
6371
6317
|
if (!existsSync3(childDirectory)) continue;
|
|
6372
6318
|
const childTarget = roleRunPlacement(ledgerHome, {
|
|
6373
6319
|
bookKey: admitted.bookKey,
|
|
@@ -6416,7 +6362,7 @@ async function recordChildDiaristRun(parent, childRunId) {
|
|
|
6416
6362
|
const page = JSON.parse(await readFile11(parent.admittedRequestPath, "utf8"));
|
|
6417
6363
|
const existing = Array.isArray(page.childDiaristRunIds) ? page.childDiaristRunIds.filter((runId) => typeof runId === "string") : [];
|
|
6418
6364
|
const childDiaristRunIds = existing.includes(childRunId) ? existing : [...existing, childRunId];
|
|
6419
|
-
await
|
|
6365
|
+
await writeFile2(parent.admittedRequestPath, `${JSON.stringify({ ...page, childDiaristRunIds }, null, 2)}
|
|
6420
6366
|
`, "utf8");
|
|
6421
6367
|
}
|
|
6422
6368
|
async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
@@ -6424,10 +6370,10 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
|
6424
6370
|
ticketNumber,
|
|
6425
6371
|
"bindTicketNumberOnRunDirectory"
|
|
6426
6372
|
);
|
|
6427
|
-
const admittedPath =
|
|
6373
|
+
const admittedPath = join15(runDirectory, "admitted-request.json");
|
|
6428
6374
|
const admitted = JSON.parse(await readFile11(admittedPath, "utf8"));
|
|
6429
6375
|
if (admitted.ticketNumber === ticketNumber) return;
|
|
6430
|
-
await
|
|
6376
|
+
await writeFile2(
|
|
6431
6377
|
admittedPath,
|
|
6432
6378
|
`${JSON.stringify({ ...admitted, ticketNumber }, null, 2)}
|
|
6433
6379
|
`,
|
|
@@ -6444,7 +6390,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
6444
6390
|
async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
|
|
6445
6391
|
const rolePackageRoot = packageRoot;
|
|
6446
6392
|
const raw = JSON.parse(
|
|
6447
|
-
await readFile11(
|
|
6393
|
+
await readFile11(join15(rolePackageRoot, "package.json"), "utf8")
|
|
6448
6394
|
);
|
|
6449
6395
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
6450
6396
|
throw new Error(
|
|
@@ -6728,18 +6674,18 @@ async function readRegularFileAttachment(sourcePath) {
|
|
|
6728
6674
|
}
|
|
6729
6675
|
}
|
|
6730
6676
|
async function removePreparedAttachmentDirectory(stagingDirectory) {
|
|
6731
|
-
await
|
|
6677
|
+
await rm(stagingDirectory, { recursive: true, force: true });
|
|
6732
6678
|
}
|
|
6733
6679
|
async function withPreparedAttachments(attachmentPaths, use) {
|
|
6734
6680
|
if (attachmentPaths.length === 0) return await use([]);
|
|
6735
|
-
const stagingDirectory = await
|
|
6681
|
+
const stagingDirectory = await mkdtemp(join15(tmpdir(), "ak-role-attachments-"));
|
|
6736
6682
|
const prepared = [];
|
|
6737
6683
|
let result;
|
|
6738
6684
|
try {
|
|
6739
6685
|
for (let index = 0; index < attachmentPaths.length; index += 1) {
|
|
6740
6686
|
const { absolute, bytes } = await readRegularFileAttachment(attachmentPaths[index]);
|
|
6741
|
-
const snapshotPath =
|
|
6742
|
-
await
|
|
6687
|
+
const snapshotPath = join15(stagingDirectory, String(index).padStart(6, "0"));
|
|
6688
|
+
await writeFile2(snapshotPath, bytes);
|
|
6743
6689
|
prepared.push({ absolute, snapshotPath });
|
|
6744
6690
|
}
|
|
6745
6691
|
result = await use(prepared);
|
|
@@ -6759,11 +6705,11 @@ async function withPreparedAttachments(attachmentPaths, use) {
|
|
|
6759
6705
|
return result;
|
|
6760
6706
|
}
|
|
6761
6707
|
async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, index) {
|
|
6762
|
-
const frozenPath =
|
|
6708
|
+
const frozenPath = join15(
|
|
6763
6709
|
destinationDir,
|
|
6764
6710
|
`${String(index).padStart(2, "0")}-${basename6(provenancePath)}`
|
|
6765
6711
|
);
|
|
6766
|
-
await
|
|
6712
|
+
await writeFile2(frozenPath, bytes);
|
|
6767
6713
|
return {
|
|
6768
6714
|
provenancePath,
|
|
6769
6715
|
frozenPath,
|
|
@@ -6802,14 +6748,14 @@ async function freezeAttachments(attachmentPaths, attachmentsDirectory) {
|
|
|
6802
6748
|
async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKey = `s-${Date.now().toString(36)}`) {
|
|
6803
6749
|
if (attachmentPaths.length === 0) return [];
|
|
6804
6750
|
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
6805
|
-
const attachmentsDirectory =
|
|
6751
|
+
const attachmentsDirectory = join15(runDirectory, "attachments", summonsKey);
|
|
6806
6752
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
6807
6753
|
return freezeAttachments(attachmentPaths, attachmentsDirectory);
|
|
6808
6754
|
}
|
|
6809
6755
|
async function freezePreparedAttachmentsIntoRun(prepared, runDirectory, summonsKey) {
|
|
6810
6756
|
if (prepared.length === 0) return [];
|
|
6811
6757
|
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
6812
|
-
const attachmentsDirectory = summonsKey === void 0 ?
|
|
6758
|
+
const attachmentsDirectory = summonsKey === void 0 ? join15(runDirectory, "attachments") : join15(runDirectory, "attachments", summonsKey);
|
|
6813
6759
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
6814
6760
|
const attachments = [];
|
|
6815
6761
|
for (let index = 0; index < prepared.length; index += 1) {
|
|
@@ -6886,8 +6832,8 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
6886
6832
|
attachmentPaths,
|
|
6887
6833
|
...project,
|
|
6888
6834
|
placedFields: async (placed) => {
|
|
6889
|
-
const taskPath =
|
|
6890
|
-
await
|
|
6835
|
+
const taskPath = join15(placed.runDirectory, "task.md");
|
|
6836
|
+
await writeFile2(taskPath, instruction, "utf8");
|
|
6891
6837
|
return { phase, taskPath };
|
|
6892
6838
|
}
|
|
6893
6839
|
});
|
|
@@ -6932,16 +6878,16 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
6932
6878
|
placedFields: async (placed) => {
|
|
6933
6879
|
let prerequisitesPath;
|
|
6934
6880
|
if (prerequisitesSource !== void 0) {
|
|
6935
|
-
prerequisitesPath =
|
|
6936
|
-
await
|
|
6881
|
+
prerequisitesPath = join15(placed.runDirectory, "prerequisites.json");
|
|
6882
|
+
await writeFile2(
|
|
6937
6883
|
prerequisitesPath,
|
|
6938
6884
|
`${JSON.stringify(prerequisites, null, 2)}
|
|
6939
6885
|
`,
|
|
6940
6886
|
"utf8"
|
|
6941
6887
|
);
|
|
6942
6888
|
}
|
|
6943
|
-
const packetPath =
|
|
6944
|
-
await
|
|
6889
|
+
const packetPath = join15(placed.runDirectory, "fix-packet.md");
|
|
6890
|
+
await writeFile2(packetPath, instruction, "utf8");
|
|
6945
6891
|
return {
|
|
6946
6892
|
phase,
|
|
6947
6893
|
packetPath,
|
|
@@ -6998,8 +6944,8 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
6998
6944
|
placedFields: async (placed) => {
|
|
6999
6945
|
let requestManifestPath;
|
|
7000
6946
|
if (manifestCanonicalJson !== void 0) {
|
|
7001
|
-
requestManifestPath =
|
|
7002
|
-
await
|
|
6947
|
+
requestManifestPath = join15(placed.runDirectory, "request-manifest.json");
|
|
6948
|
+
await writeFile2(requestManifestPath, manifestCanonicalJson, "utf8");
|
|
7003
6949
|
}
|
|
7004
6950
|
return {
|
|
7005
6951
|
...explicitPrNumber === void 0 ? {} : { prNumber: explicitPrNumber },
|
|
@@ -7188,8 +7134,8 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7188
7134
|
resolutionScope: [...derived.resolutionScope],
|
|
7189
7135
|
authorizedChecks: []
|
|
7190
7136
|
});
|
|
7191
|
-
const mergerInputPath =
|
|
7192
|
-
await
|
|
7137
|
+
const mergerInputPath = join15(placed.runDirectory, "merger-input.json");
|
|
7138
|
+
await writeFile2(
|
|
7193
7139
|
mergerInputPath,
|
|
7194
7140
|
`${JSON.stringify(mergerInput, null, 2)}
|
|
7195
7141
|
`,
|
|
@@ -7262,7 +7208,7 @@ function persistedAttachmentRefs(attachments) {
|
|
|
7262
7208
|
}));
|
|
7263
7209
|
}
|
|
7264
7210
|
async function persistPlacedAdmission(admitted, placed, model) {
|
|
7265
|
-
const admittedRequestPath =
|
|
7211
|
+
const admittedRequestPath = join15(placed.runDirectory, "admitted-request.json");
|
|
7266
7212
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
7267
7213
|
sessionDirectory: placed.sessionDirectory,
|
|
7268
7214
|
sessionFile: placed.sessionFile
|
|
@@ -7315,7 +7261,7 @@ async function admitStandardMaterialInvocation(role, options) {
|
|
|
7315
7261
|
attachments: persistedAttachmentRefs(placed.attachments),
|
|
7316
7262
|
...placed.ticketFields
|
|
7317
7263
|
};
|
|
7318
|
-
const admittedRequestPath = defer ?
|
|
7264
|
+
const admittedRequestPath = defer ? join15(placed.runDirectory, "admitted-request.json") : await persistPlacedAdmission(admitted, placed, options.model);
|
|
7319
7265
|
return {
|
|
7320
7266
|
role,
|
|
7321
7267
|
runId: placed.runId,
|
|
@@ -7393,7 +7339,7 @@ async function materializeCountersignInvocation(admitted, options) {
|
|
|
7393
7339
|
});
|
|
7394
7340
|
const placement = placed;
|
|
7395
7341
|
admitted.runDirectory = placement.runDirectory;
|
|
7396
|
-
admitted.admittedRequestPath =
|
|
7342
|
+
admitted.admittedRequestPath = join15(
|
|
7397
7343
|
placement.runDirectory,
|
|
7398
7344
|
"admitted-request.json"
|
|
7399
7345
|
);
|
|
@@ -7420,7 +7366,7 @@ async function materializeCountersignInvocation(admitted, options) {
|
|
|
7420
7366
|
async function loadAdmittedJudgeRequest(runDirectory) {
|
|
7421
7367
|
try {
|
|
7422
7368
|
const raw = JSON.parse(
|
|
7423
|
-
await readFile11(
|
|
7369
|
+
await readFile11(join15(runDirectory, "admitted-request.json"), "utf8")
|
|
7424
7370
|
);
|
|
7425
7371
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
7426
7372
|
const record4 = raw;
|
|
@@ -7509,7 +7455,7 @@ function parseDoctorIssueNumber(raw) {
|
|
|
7509
7455
|
}
|
|
7510
7456
|
async function resolveDoctorCaseRunsPath(options) {
|
|
7511
7457
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
7512
|
-
const defaultRuns =
|
|
7458
|
+
const defaultRuns = join15(
|
|
7513
7459
|
activationBookDirectory(ledgerHome, options.bookKey),
|
|
7514
7460
|
String(options.issueNumber),
|
|
7515
7461
|
"runs"
|
|
@@ -7830,15 +7776,15 @@ var init_invocation = __esm({
|
|
|
7830
7776
|
|
|
7831
7777
|
// src/public-cli/load-production-acp-host.ts
|
|
7832
7778
|
import { existsSync as existsSync4 } from "node:fs";
|
|
7833
|
-
import { join as
|
|
7779
|
+
import { join as join16 } from "node:path";
|
|
7834
7780
|
import { pathToFileURL } from "node:url";
|
|
7835
7781
|
async function loadProductionAcpHostFactory(packageRoot, host) {
|
|
7836
7782
|
const description = lookupHostDescription(host);
|
|
7837
7783
|
if (description === void 0) {
|
|
7838
7784
|
throw new Error(`unregistered host: ${host}`);
|
|
7839
7785
|
}
|
|
7840
|
-
const built =
|
|
7841
|
-
const source =
|
|
7786
|
+
const built = join16(packageRoot, "dist/acp-host/production-host.js");
|
|
7787
|
+
const source = join16(packageRoot, "src/acp-host/production-host.ts");
|
|
7842
7788
|
const target = existsSync4(built) ? built : source;
|
|
7843
7789
|
const href = pathToFileURL(target).href;
|
|
7844
7790
|
const mod = await import(href);
|
|
@@ -7854,15 +7800,15 @@ var init_load_production_acp_host = __esm({
|
|
|
7854
7800
|
|
|
7855
7801
|
// src/public-cli/load-production-headless-host.ts
|
|
7856
7802
|
import { existsSync as existsSync5 } from "node:fs";
|
|
7857
|
-
import { join as
|
|
7803
|
+
import { join as join17 } from "node:path";
|
|
7858
7804
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
7859
7805
|
async function loadProductionHeadlessHostFactory(packageRoot, host) {
|
|
7860
7806
|
const description = lookupHeadlessHostDescription(host);
|
|
7861
7807
|
if (description === void 0) {
|
|
7862
7808
|
throw new Error(`unregistered headless host: ${host}`);
|
|
7863
7809
|
}
|
|
7864
|
-
const built =
|
|
7865
|
-
const source =
|
|
7810
|
+
const built = join17(packageRoot, "dist/headless-host/production-host.js");
|
|
7811
|
+
const source = join17(packageRoot, "src/headless-host/production-host.ts");
|
|
7866
7812
|
const target = existsSync5(built) ? built : source;
|
|
7867
7813
|
const href = pathToFileURL2(target).href;
|
|
7868
7814
|
const mod = await import(href);
|
|
@@ -8040,8 +7986,8 @@ __export(config_exports, {
|
|
|
8040
7986
|
setPersistentSeatHost: () => setPersistentSeatHost,
|
|
8041
7987
|
validatePublicCliConfigAxes: () => validatePublicCliConfigAxes
|
|
8042
7988
|
});
|
|
8043
|
-
import { mkdir, readFile as readFile12, writeFile as
|
|
8044
|
-
import { dirname as dirname11, join as
|
|
7989
|
+
import { mkdir, readFile as readFile12, writeFile as writeFile3 } from "node:fs/promises";
|
|
7990
|
+
import { dirname as dirname11, join as join18 } from "node:path";
|
|
8045
7991
|
function isGateOfficerSeat(value) {
|
|
8046
7992
|
return packagedProvinceConfig(value);
|
|
8047
7993
|
}
|
|
@@ -8049,7 +7995,7 @@ function publicCliConfigPath(home) {
|
|
|
8049
7995
|
if (typeof home !== "string" || home.trim() === "") {
|
|
8050
7996
|
throw new Error("home must be explicitly provided");
|
|
8051
7997
|
}
|
|
8052
|
-
return
|
|
7998
|
+
return join18(home, ".ak-roles", "public-cli.json");
|
|
8053
7999
|
}
|
|
8054
8000
|
async function loadPublicCliConfig(home) {
|
|
8055
8001
|
const path = publicCliConfigPath(home);
|
|
@@ -8067,7 +8013,7 @@ async function savePublicCliConfig(config, home) {
|
|
|
8067
8013
|
const path = publicCliConfigPath(home);
|
|
8068
8014
|
await mkdir(dirname11(path), { recursive: true });
|
|
8069
8015
|
const normalized = parsePublicCliConfig(config);
|
|
8070
|
-
await
|
|
8016
|
+
await writeFile3(
|
|
8071
8017
|
path,
|
|
8072
8018
|
`${JSON.stringify(serializePublicCliConfig(normalized), null, 2)}
|
|
8073
8019
|
`,
|
|
@@ -8512,7 +8458,7 @@ function credentialProvidersFromAuthData(data) {
|
|
|
8512
8458
|
}
|
|
8513
8459
|
async function loadCredentialProviders(agentDir) {
|
|
8514
8460
|
try {
|
|
8515
|
-
const raw = await readFile12(
|
|
8461
|
+
const raw = await readFile12(join18(agentDir, "auth.json"), "utf8");
|
|
8516
8462
|
return credentialProvidersFromAuthData(JSON.parse(raw));
|
|
8517
8463
|
} catch (error) {
|
|
8518
8464
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
@@ -8550,15 +8496,15 @@ __export(host_providers_exports, {
|
|
|
8550
8496
|
renderHostProvidersTable: () => renderHostProvidersTable
|
|
8551
8497
|
});
|
|
8552
8498
|
import { readFileSync } from "node:fs";
|
|
8553
|
-
import { join as
|
|
8499
|
+
import { join as join19 } from "node:path";
|
|
8554
8500
|
function hostProvidersPath(home) {
|
|
8555
8501
|
if (typeof home !== "string" || home.trim() === "") {
|
|
8556
8502
|
throw new Error("home must be explicitly provided");
|
|
8557
8503
|
}
|
|
8558
|
-
return
|
|
8504
|
+
return join19(home, ".ak-roles", "host-providers.json");
|
|
8559
8505
|
}
|
|
8560
8506
|
function hermesProviderModelsCachePath(home) {
|
|
8561
|
-
return
|
|
8507
|
+
return join19(home, ".hermes", "provider_models_cache.json");
|
|
8562
8508
|
}
|
|
8563
8509
|
function parseHostProvidersTable(value) {
|
|
8564
8510
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
@@ -8714,7 +8660,7 @@ var init_host_providers = __esm({
|
|
|
8714
8660
|
|
|
8715
8661
|
// src/analyst-gate-cycles-read.ts
|
|
8716
8662
|
import { readdir as readdir4 } from "node:fs/promises";
|
|
8717
|
-
import { join as
|
|
8663
|
+
import { join as join20 } from "node:path";
|
|
8718
8664
|
function isRecord6(value) {
|
|
8719
8665
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8720
8666
|
}
|
|
@@ -8965,7 +8911,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
|
|
|
8965
8911
|
throw error;
|
|
8966
8912
|
}
|
|
8967
8913
|
for (const name of names) {
|
|
8968
|
-
const path =
|
|
8914
|
+
const path = join20(directory, name);
|
|
8969
8915
|
const fromPointer = name.endsWith(".pointer.json");
|
|
8970
8916
|
const pointer = fromPointer ? await resolveOfficerSessionFromPointerFile(path) : void 0;
|
|
8971
8917
|
const sessionPath = pointer?.sessionFile ?? path;
|
|
@@ -9016,12 +8962,12 @@ var init_audit_escalation = __esm({
|
|
|
9016
8962
|
// src/session-opening-materials.ts
|
|
9017
8963
|
import { existsSync as existsSync6 } from "node:fs";
|
|
9018
8964
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
9019
|
-
import { dirname as dirname12, join as
|
|
8965
|
+
import { dirname as dirname12, join as join21 } from "node:path";
|
|
9020
8966
|
import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
9021
8967
|
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
9022
8968
|
let dir = dirname12(fileURLToPath(moduleUrl));
|
|
9023
8969
|
for (let i = 0; i < 8; i += 1) {
|
|
9024
|
-
if (existsSync6(
|
|
8970
|
+
if (existsSync6(join21(dir, "package.json")) && existsSync6(join21(dir, "souls"))) {
|
|
9025
8971
|
return dir;
|
|
9026
8972
|
}
|
|
9027
8973
|
const parent = dirname12(dir);
|
|
@@ -9090,7 +9036,7 @@ __export(auditor_soul_exports, {
|
|
|
9090
9036
|
resolveAuditorSubject: () => resolveAuditorSubject
|
|
9091
9037
|
});
|
|
9092
9038
|
import { readFile as readFile14 } from "node:fs/promises";
|
|
9093
|
-
import { basename as basename7, join as
|
|
9039
|
+
import { basename as basename7, join as join22 } from "node:path";
|
|
9094
9040
|
function auditorSoulRelativePath(role) {
|
|
9095
9041
|
return `souls/${role}-auditor.md`;
|
|
9096
9042
|
}
|
|
@@ -9132,7 +9078,7 @@ function subjectFromSourceDirectory(sourceRunDirectory) {
|
|
|
9132
9078
|
async function readAuditorResumeBinding(runDirectory) {
|
|
9133
9079
|
let raw;
|
|
9134
9080
|
try {
|
|
9135
|
-
raw = JSON.parse(await readFile14(
|
|
9081
|
+
raw = JSON.parse(await readFile14(join22(runDirectory, "admitted-request.json"), "utf8"));
|
|
9136
9082
|
} catch (error) {
|
|
9137
9083
|
if (error.code === "ENOENT") return void 0;
|
|
9138
9084
|
throw error;
|
|
@@ -9245,7 +9191,7 @@ var init_serialize_thrown_value = __esm({
|
|
|
9245
9191
|
// src/engine-detour-usage.ts
|
|
9246
9192
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
9247
9193
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
9248
|
-
import { dirname as dirname13, join as
|
|
9194
|
+
import { dirname as dirname13, join as join23 } from "node:path";
|
|
9249
9195
|
function engineDetourStdoutByteLength(stdout) {
|
|
9250
9196
|
return Buffer.byteLength(stdout, "utf8");
|
|
9251
9197
|
}
|
|
@@ -9382,7 +9328,7 @@ function projectEngineDetourToolUsageForPublicTerminal(usage, options) {
|
|
|
9382
9328
|
function readInvocationRecord(runDirectory) {
|
|
9383
9329
|
try {
|
|
9384
9330
|
const raw = JSON.parse(
|
|
9385
|
-
readFileSync2(
|
|
9331
|
+
readFileSync2(join23(runDirectory, "invocation.json"), "utf8")
|
|
9386
9332
|
);
|
|
9387
9333
|
return isRecord7(raw) ? raw : void 0;
|
|
9388
9334
|
} catch (error) {
|
|
@@ -9410,7 +9356,7 @@ function runDirectoryFromSessionDirectory(sessionDirectory) {
|
|
|
9410
9356
|
return dirname13(sessionDirectory);
|
|
9411
9357
|
}
|
|
9412
9358
|
function sessionFileFromSessionDirectory(sessionDirectory) {
|
|
9413
|
-
return
|
|
9359
|
+
return join23(sessionDirectory, "session.jsonl");
|
|
9414
9360
|
}
|
|
9415
9361
|
function mintEngineDetourInvocationScope(input) {
|
|
9416
9362
|
const engine = input.effectiveEngine?.trim();
|
|
@@ -9865,15 +9811,15 @@ __export(settlement_exports, {
|
|
|
9865
9811
|
withSubmissions: () => withSubmissions
|
|
9866
9812
|
});
|
|
9867
9813
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
9868
|
-
import { appendFile as appendFile2, readFile as readFile15, readdir as readdir5, rm as
|
|
9869
|
-
import { dirname as dirname14, join as
|
|
9814
|
+
import { appendFile as appendFile2, readFile as readFile15, readdir as readdir5, rm as rm2, writeFile as writeFile4 } from "node:fs/promises";
|
|
9815
|
+
import { dirname as dirname14, join as join24 } from "node:path";
|
|
9870
9816
|
function sealedLedgerHome(admitted) {
|
|
9871
9817
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
9872
9818
|
}
|
|
9873
9819
|
function ledgerReadScope(admitted, scope) {
|
|
9874
9820
|
return {
|
|
9875
9821
|
home: sealedLedgerHome(admitted),
|
|
9876
|
-
sessionParent:
|
|
9822
|
+
sessionParent: join24(admitted.runDirectory, "session", "session.jsonl"),
|
|
9877
9823
|
...scope?.courtAttemptId === void 0 || scope.courtAttemptId.length === 0 ? {} : { attemptId: scope.courtAttemptId }
|
|
9878
9824
|
};
|
|
9879
9825
|
}
|
|
@@ -10374,7 +10320,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
10374
10320
|
}
|
|
10375
10321
|
const parentId = parentEntries.find((entry) => entry.type === "session")?.id;
|
|
10376
10322
|
if (parentId === void 0) return void 0;
|
|
10377
|
-
const childDirectories = [
|
|
10323
|
+
const childDirectories = [join24(dirname14(sessionFile), "auditor-roles")];
|
|
10378
10324
|
const valid = [];
|
|
10379
10325
|
let sawAnyDirectory = false;
|
|
10380
10326
|
for (const childDirectory of childDirectories) {
|
|
@@ -10389,7 +10335,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
10389
10335
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
10390
10336
|
let entries;
|
|
10391
10337
|
try {
|
|
10392
|
-
entries = await readBoundSessionEntries(
|
|
10338
|
+
entries = await readBoundSessionEntries(join24(childDirectory, file));
|
|
10393
10339
|
} catch (error) {
|
|
10394
10340
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
10395
10341
|
}
|
|
@@ -10865,8 +10811,8 @@ function projectTerminalGateFact(rounds) {
|
|
|
10865
10811
|
};
|
|
10866
10812
|
}
|
|
10867
10813
|
async function extractGateFactFromSessionDirectory(sessionDirectory, options = {}) {
|
|
10868
|
-
const directories = [
|
|
10869
|
-
const parentSessionFile = options.parentSessionFile ??
|
|
10814
|
+
const directories = [join24(sessionDirectory, "auditor-roles")];
|
|
10815
|
+
const parentSessionFile = options.parentSessionFile ?? join24(sessionDirectory, "session.jsonl");
|
|
10870
10816
|
const rounds = await readAnalystGateCyclesFromAuditorRoles(directories, {
|
|
10871
10817
|
parentSessionFile
|
|
10872
10818
|
});
|
|
@@ -10969,7 +10915,7 @@ async function extractNavigatorFactFromAdmittedSession(sessionFile) {
|
|
|
10969
10915
|
}
|
|
10970
10916
|
async function removeFaceIfPresent(path) {
|
|
10971
10917
|
try {
|
|
10972
|
-
await
|
|
10918
|
+
await rm2(path, { recursive: true, force: true });
|
|
10973
10919
|
} catch (error) {
|
|
10974
10920
|
if (isAbsentFacePathError(error)) return;
|
|
10975
10921
|
throw error;
|
|
@@ -10978,10 +10924,10 @@ async function removeFaceIfPresent(path) {
|
|
|
10978
10924
|
async function clearOppositeTerminalArtifactFace(runDirectory) {
|
|
10979
10925
|
const artifactsDir = roleRunArtifactsDirectory(runDirectory);
|
|
10980
10926
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
10981
|
-
await removeFaceIfPresent(
|
|
10927
|
+
await removeFaceIfPresent(join24(artifactsDir, file));
|
|
10982
10928
|
}
|
|
10983
10929
|
for (const relative4 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
10984
|
-
await removeFaceIfPresent(
|
|
10930
|
+
await removeFaceIfPresent(join24(runDirectory, relative4));
|
|
10985
10931
|
}
|
|
10986
10932
|
for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
|
|
10987
10933
|
await removeFaceIfPresent(path);
|
|
@@ -11010,15 +10956,15 @@ async function publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinat
|
|
|
11010
10956
|
roleOutcome
|
|
11011
10957
|
);
|
|
11012
10958
|
const artifactsDir = await ensureTerminalArtifactFace(admitted.runDirectory);
|
|
11013
|
-
const reportPath =
|
|
11014
|
-
const evidencePath =
|
|
11015
|
-
await
|
|
10959
|
+
const reportPath = join24(artifactsDir, "report.json");
|
|
10960
|
+
const evidencePath = join24(artifactsDir, "evidence.json");
|
|
10961
|
+
await writeFile4(
|
|
11016
10962
|
reportPath,
|
|
11017
10963
|
`${JSON.stringify(bodies.report, null, 2)}
|
|
11018
10964
|
`,
|
|
11019
10965
|
"utf8"
|
|
11020
10966
|
);
|
|
11021
|
-
await
|
|
10967
|
+
await writeFile4(
|
|
11022
10968
|
evidencePath,
|
|
11023
10969
|
`${JSON.stringify(bodies.evidence, null, 2)}
|
|
11024
10970
|
`,
|
|
@@ -11420,13 +11366,13 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
|
|
|
11420
11366
|
const candidates = [
|
|
11421
11367
|
...preferredCandidates,
|
|
11422
11368
|
// One unique name per fallback dir — collisions on fixed names cannot exhaust this.
|
|
11423
|
-
...uniqueFallbackDirs.map((dir) =>
|
|
11369
|
+
...uniqueFallbackDirs.map((dir) => join24(dir, `${stem}.${randomUUID4()}.json`))
|
|
11424
11370
|
];
|
|
11425
11371
|
for (let i = 0; i < candidates.length; i += 1) {
|
|
11426
11372
|
const path = candidates[i];
|
|
11427
11373
|
const payload = issues.length === 0 ? basePayload : { ...basePayload, publicationIssues: issues };
|
|
11428
11374
|
try {
|
|
11429
|
-
await
|
|
11375
|
+
await writeFile4(
|
|
11430
11376
|
path,
|
|
11431
11377
|
`${JSON.stringify(payload, null, 2)}
|
|
11432
11378
|
`,
|
|
@@ -11481,20 +11427,20 @@ async function publishFailureArtifacts(admitted, failure, authority, onErrorPubl
|
|
|
11481
11427
|
baseDir
|
|
11482
11428
|
);
|
|
11483
11429
|
const errorCandidates = underArtifacts ? [
|
|
11484
|
-
|
|
11485
|
-
|
|
11486
|
-
|
|
11430
|
+
join24(baseDir, "error.json"),
|
|
11431
|
+
join24(baseDir, "error.settlement.json"),
|
|
11432
|
+
join24(admitted.runDirectory, "error.settlement.json")
|
|
11487
11433
|
] : [
|
|
11488
|
-
|
|
11489
|
-
|
|
11434
|
+
join24(baseDir, "error.settlement.json"),
|
|
11435
|
+
join24(baseDir, "error.json")
|
|
11490
11436
|
];
|
|
11491
11437
|
const evidenceCandidates = underArtifacts ? [
|
|
11492
|
-
|
|
11493
|
-
|
|
11494
|
-
|
|
11438
|
+
join24(baseDir, "evidence.json"),
|
|
11439
|
+
join24(baseDir, "evidence.settlement.json"),
|
|
11440
|
+
join24(admitted.runDirectory, "evidence.settlement.json")
|
|
11495
11441
|
] : [
|
|
11496
|
-
|
|
11497
|
-
|
|
11442
|
+
join24(baseDir, "evidence.settlement.json"),
|
|
11443
|
+
join24(baseDir, "evidence.json")
|
|
11498
11444
|
];
|
|
11499
11445
|
const errorPayloadBase = {
|
|
11500
11446
|
kind: "error",
|
|
@@ -11749,9 +11695,9 @@ var init_settlement = __esm({
|
|
|
11749
11695
|
|
|
11750
11696
|
// src/archivist-record-pointer.ts
|
|
11751
11697
|
import { mkdirSync as mkdirSync2, writeFileSync } from "node:fs";
|
|
11752
|
-
import { dirname as dirname15, join as
|
|
11698
|
+
import { dirname as dirname15, join as join25 } from "node:path";
|
|
11753
11699
|
function bookDirectOfficerRunPointer(options) {
|
|
11754
|
-
const nest =
|
|
11700
|
+
const nest = join25(dirname15(options.parentSessionFile), "auditor-roles");
|
|
11755
11701
|
mkdirSync2(nest, { recursive: true });
|
|
11756
11702
|
const pointer = {
|
|
11757
11703
|
version: 1,
|
|
@@ -11761,7 +11707,7 @@ function bookDirectOfficerRunPointer(options) {
|
|
|
11761
11707
|
...options.runDirectory !== void 0 && options.runDirectory.trim() !== "" ? { runDirectory: options.runDirectory } : {}
|
|
11762
11708
|
};
|
|
11763
11709
|
writeFileSync(
|
|
11764
|
-
|
|
11710
|
+
join25(nest, `${options.officer}.pointer.json`),
|
|
11765
11711
|
`${JSON.stringify(pointer)}
|
|
11766
11712
|
`,
|
|
11767
11713
|
"utf8"
|
|
@@ -12019,10 +11965,10 @@ var init_submission_gate = __esm({
|
|
|
12019
11965
|
});
|
|
12020
11966
|
|
|
12021
11967
|
// src/session-identity.ts
|
|
12022
|
-
import { mkdir as mkdir2, readFile as readFile16, rename as rename2, writeFile as
|
|
12023
|
-
import { dirname as dirname16, join as
|
|
11968
|
+
import { mkdir as mkdir2, readFile as readFile16, rename as rename2, writeFile as writeFile5 } from "node:fs/promises";
|
|
11969
|
+
import { dirname as dirname16, join as join26 } from "node:path";
|
|
12024
11970
|
function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
12025
|
-
const bindingPath = (principal) =>
|
|
11971
|
+
const bindingPath = (principal) => join26(authority.decode(principal).sessionDirectory, sessionBindingFile);
|
|
12026
11972
|
return {
|
|
12027
11973
|
resolveSessionFile(principal) {
|
|
12028
11974
|
return authority.decode(principal).sessionFile;
|
|
@@ -12043,7 +11989,7 @@ function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
|
12043
11989
|
const target = bindingPath(principal);
|
|
12044
11990
|
await mkdir2(dirname16(target), { recursive: true });
|
|
12045
11991
|
const temporary = `${target}.${process.pid}.tmp`;
|
|
12046
|
-
await
|
|
11992
|
+
await writeFile5(temporary, `${JSON.stringify({ sessionId })}
|
|
12047
11993
|
`, { encoding: "utf8", mode: 384 });
|
|
12048
11994
|
await rename2(temporary, target);
|
|
12049
11995
|
}
|
|
@@ -12100,7 +12046,7 @@ import {
|
|
|
12100
12046
|
statSync as statSync3
|
|
12101
12047
|
} from "node:fs";
|
|
12102
12048
|
import { homedir } from "node:os";
|
|
12103
|
-
import { dirname as dirname17, join as
|
|
12049
|
+
import { dirname as dirname17, join as join27 } from "node:path";
|
|
12104
12050
|
function declareHostSessionFailure(error) {
|
|
12105
12051
|
const message = error instanceof Error ? error.stack || error.message : String(error);
|
|
12106
12052
|
process.stderr.write(`[host-session] Dossier record failure: ${message}
|
|
@@ -12125,7 +12071,7 @@ function findCodexRollout(sessionsDir, sessionId) {
|
|
|
12125
12071
|
return;
|
|
12126
12072
|
}
|
|
12127
12073
|
for (const entry of entries) {
|
|
12128
|
-
const fullPath =
|
|
12074
|
+
const fullPath = join27(dir, entry.name);
|
|
12129
12075
|
if (entry.isDirectory()) {
|
|
12130
12076
|
scan(fullPath, depth + 1);
|
|
12131
12077
|
} else if (entry.isFile() && entry.name.endsWith(".jsonl") && entry.name.includes(sessionId)) {
|
|
@@ -12149,25 +12095,25 @@ function sanitizeClaudeCwd(cwd) {
|
|
|
12149
12095
|
function resolveNativeSessionPath(options) {
|
|
12150
12096
|
const home = options.home || homedir();
|
|
12151
12097
|
if (options.host === "claude") {
|
|
12152
|
-
const configDir = process.env.CLAUDE_CONFIG_DIR ||
|
|
12098
|
+
const configDir = process.env.CLAUDE_CONFIG_DIR || join27(home, ".claude");
|
|
12153
12099
|
const sanitizedCwd = sanitizeClaudeCwd(options.cwd);
|
|
12154
|
-
return
|
|
12100
|
+
return join27(configDir, "projects", sanitizedCwd, `${options.sessionId}.jsonl`);
|
|
12155
12101
|
}
|
|
12156
12102
|
if (options.host === "codex") {
|
|
12157
12103
|
return findCodexRollout(codexSessionsDirectory(home), options.sessionId);
|
|
12158
12104
|
}
|
|
12159
12105
|
if (options.host === "grok-build") {
|
|
12160
|
-
const grokHome = process.env.GROK_HOME ||
|
|
12161
|
-
return
|
|
12106
|
+
const grokHome = process.env.GROK_HOME || join27(home, ".grok");
|
|
12107
|
+
return join27(grokHome, "sessions", encodeURIComponent(options.cwd), options.sessionId);
|
|
12162
12108
|
}
|
|
12163
12109
|
return void 0;
|
|
12164
12110
|
}
|
|
12165
12111
|
function codexSessionsDirectory(home) {
|
|
12166
|
-
return
|
|
12112
|
+
return join27(process.env.CODEX_HOME || join27(home || homedir(), ".codex"), "sessions");
|
|
12167
12113
|
}
|
|
12168
12114
|
function recordRunStart(runDirectory) {
|
|
12169
12115
|
try {
|
|
12170
|
-
appendFileSync2(
|
|
12116
|
+
appendFileSync2(join27(runDirectory, ".run-starts"), "\n");
|
|
12171
12117
|
} catch (error) {
|
|
12172
12118
|
declareHostSessionFailure(error);
|
|
12173
12119
|
}
|
|
@@ -12191,12 +12137,12 @@ function resolveHostDossierLandingPath(options) {
|
|
|
12191
12137
|
} catch {
|
|
12192
12138
|
}
|
|
12193
12139
|
}
|
|
12194
|
-
const startsPath =
|
|
12140
|
+
const startsPath = join27(dirname17(options.sessionDirectory), ".run-starts");
|
|
12195
12141
|
let starts = 0;
|
|
12196
12142
|
if (existsSync8(startsPath)) starts = readFileSync3(startsPath, "utf8").length;
|
|
12197
12143
|
const ordinal = Math.max(maxOrdinal + 1, starts, options.continuation.kind === "resume" ? 2 : 1);
|
|
12198
12144
|
const baseName = `${options.host}-${sanitizedModel}-${ordinal}`;
|
|
12199
|
-
const landingPath = options.host === "grok-build" ?
|
|
12145
|
+
const landingPath = options.host === "grok-build" ? join27(options.sessionDirectory, baseName) : join27(options.sessionDirectory, `${baseName}.jsonl`);
|
|
12200
12146
|
return { landingPath, ordinal, sanitizedModel };
|
|
12201
12147
|
}
|
|
12202
12148
|
function recordNativeSessionPointer(options) {
|
|
@@ -12229,18 +12175,18 @@ function copyFileCloneOrFallback(src, dest) {
|
|
|
12229
12175
|
copyFileSync(src, dest);
|
|
12230
12176
|
}
|
|
12231
12177
|
function copyGrokDossier(srcDir, destDir) {
|
|
12232
|
-
const chatHistorySrc =
|
|
12178
|
+
const chatHistorySrc = join27(srcDir, "chat_history.jsonl");
|
|
12233
12179
|
if (!existsSync8(chatHistorySrc)) {
|
|
12234
12180
|
throw new Error(`Grok native chat_history.jsonl missing at ${chatHistorySrc}`);
|
|
12235
12181
|
}
|
|
12236
12182
|
mkdirSync3(destDir, { recursive: true });
|
|
12237
|
-
const chatHistoryDest =
|
|
12183
|
+
const chatHistoryDest = join27(destDir, "chat_history.jsonl");
|
|
12238
12184
|
copyFileCloneOrFallback(chatHistorySrc, chatHistoryDest);
|
|
12239
|
-
const usageSrc =
|
|
12185
|
+
const usageSrc = join27(srcDir, "usage.json");
|
|
12240
12186
|
if (!existsSync8(usageSrc)) {
|
|
12241
12187
|
throw new Error(`Grok native usage.json missing at ${usageSrc}`);
|
|
12242
12188
|
}
|
|
12243
|
-
copyFileCloneOrFallback(usageSrc,
|
|
12189
|
+
copyFileCloneOrFallback(usageSrc, join27(destDir, "usage.json"));
|
|
12244
12190
|
}
|
|
12245
12191
|
function copyAndRecordHostDossier(options) {
|
|
12246
12192
|
if (options.host === "pi" || options.host === "hermes") {
|
|
@@ -12315,7 +12261,7 @@ function copyAndRecordHostDossier(options) {
|
|
|
12315
12261
|
}
|
|
12316
12262
|
try {
|
|
12317
12263
|
mkdirSync3(options.sessionDirectory, { recursive: true });
|
|
12318
|
-
closeSync(openSync(
|
|
12264
|
+
closeSync(openSync(join27(options.sessionDirectory, `${options.host}-${sanitizedModel}-${ordinal}.failed`), "a"));
|
|
12319
12265
|
} catch {
|
|
12320
12266
|
}
|
|
12321
12267
|
sitianReportSafe({
|
|
@@ -12349,7 +12295,7 @@ var init_host_session_record = __esm({
|
|
|
12349
12295
|
import { constants as fsConstants2 } from "node:fs";
|
|
12350
12296
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
12351
12297
|
import { lstat as lstat4, mkdir as mkdir3, open } from "node:fs/promises";
|
|
12352
|
-
import { join as
|
|
12298
|
+
import { join as join28 } from "node:path";
|
|
12353
12299
|
async function persistReturnedRunState(admitted, options) {
|
|
12354
12300
|
if (options?.lawful === true) {
|
|
12355
12301
|
await markRunTerminal(admitted.runDirectory);
|
|
@@ -12418,7 +12364,7 @@ function jsonSafeReplacer() {
|
|
|
12418
12364
|
};
|
|
12419
12365
|
}
|
|
12420
12366
|
async function writeHardenedArtifactFile(artifactsDir, namePrefix, payload) {
|
|
12421
|
-
const filePath =
|
|
12367
|
+
const filePath = join28(artifactsDir, `${namePrefix}-${randomUUID5()}.json`);
|
|
12422
12368
|
const body = `${JSON.stringify(payload, jsonSafeReplacer(), 2)}
|
|
12423
12369
|
`;
|
|
12424
12370
|
const noFollowFlag = typeof fsConstants2.O_NOFOLLOW === "number" ? fsConstants2.O_NOFOLLOW : 0;
|
|
@@ -12672,8 +12618,8 @@ var init_auto_resume = __esm({
|
|
|
12672
12618
|
|
|
12673
12619
|
// src/public-cli/post-admission.ts
|
|
12674
12620
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
12675
|
-
import { writeFile as
|
|
12676
|
-
import { isAbsolute as isAbsolute7, join as
|
|
12621
|
+
import { writeFile as writeFile6 } from "node:fs/promises";
|
|
12622
|
+
import { isAbsolute as isAbsolute7, join as join29, resolve as resolve12 } from "node:path";
|
|
12677
12623
|
function describeCaughtError(error) {
|
|
12678
12624
|
if (error instanceof Error) {
|
|
12679
12625
|
const code = error.code;
|
|
@@ -12768,8 +12714,8 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
12768
12714
|
} catch (appendError) {
|
|
12769
12715
|
try {
|
|
12770
12716
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
12771
|
-
await
|
|
12772
|
-
|
|
12717
|
+
await writeFile6(
|
|
12718
|
+
join29(artifactsDir, `post-admission-diagnostic-${randomUUID6()}.json`),
|
|
12773
12719
|
`${JSON.stringify({ version: 1, ...payload }, null, 2)}
|
|
12774
12720
|
`,
|
|
12775
12721
|
{ encoding: "utf8", flag: "wx" }
|
|
@@ -12910,7 +12856,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
12910
12856
|
const rows = await readRecordedSubmissionRows(
|
|
12911
12857
|
admitted.projectRoot,
|
|
12912
12858
|
admitted.runId,
|
|
12913
|
-
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent:
|
|
12859
|
+
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent: join29(admitted.runDirectory, "session", "session.jsonl") }
|
|
12914
12860
|
);
|
|
12915
12861
|
let ticketNumber;
|
|
12916
12862
|
for (const row of rows) {
|
|
@@ -13036,8 +12982,8 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
13036
12982
|
}
|
|
13037
12983
|
let stderrLogWriteFailure;
|
|
13038
12984
|
try {
|
|
13039
|
-
await
|
|
13040
|
-
|
|
12985
|
+
await writeFile6(
|
|
12986
|
+
join29(admitted.runDirectory, "stderr.log"),
|
|
13041
12987
|
result.stderr,
|
|
13042
12988
|
"utf8"
|
|
13043
12989
|
);
|
|
@@ -13316,7 +13262,7 @@ async function dispatchAfterWriterLease(input) {
|
|
|
13316
13262
|
}
|
|
13317
13263
|
function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
|
|
13318
13264
|
const absolute = isAbsolute7(attachmentPath) ? attachmentPath : resolve12(attachmentPath);
|
|
13319
|
-
return pathContainedIn(
|
|
13265
|
+
return pathContainedIn(join29(runDirectory, "attachments"), absolute);
|
|
13320
13266
|
}
|
|
13321
13267
|
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
13322
13268
|
if (summons === void 0) return void 0;
|
|
@@ -13571,8 +13517,8 @@ async function presentResumeFailurePointer(io, thrown, publish) {
|
|
|
13571
13517
|
}
|
|
13572
13518
|
async function writeResumeDiagnosticFile(runDirectory, runId, failure, role) {
|
|
13573
13519
|
const dir = await ensureRealArtifactsDirectory(runDirectory);
|
|
13574
|
-
const path =
|
|
13575
|
-
await
|
|
13520
|
+
const path = join29(dir, `resume-diagnostic-${randomUUID6()}.json`);
|
|
13521
|
+
await writeFile6(
|
|
13576
13522
|
path,
|
|
13577
13523
|
`${JSON.stringify({
|
|
13578
13524
|
runId,
|
|
@@ -13740,16 +13686,16 @@ var init_seat_ticket_binding = __esm({
|
|
|
13740
13686
|
// src/public-cli/machine-method-skills.ts
|
|
13741
13687
|
import { accessSync, constants as constants2, statSync as statSync4 } from "node:fs";
|
|
13742
13688
|
import { lstat as lstat5, mkdir as mkdir4, symlink } from "node:fs/promises";
|
|
13743
|
-
import { join as
|
|
13689
|
+
import { join as join30 } from "node:path";
|
|
13744
13690
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
13745
13691
|
function skillRoot(home) {
|
|
13746
|
-
return
|
|
13692
|
+
return join30(home, ".agents/skills");
|
|
13747
13693
|
}
|
|
13748
13694
|
function installedMethodSkillPath(home, name) {
|
|
13749
13695
|
return installedSkillPath(skillRoot(home), name);
|
|
13750
13696
|
}
|
|
13751
13697
|
function installedSkillPath(root, name) {
|
|
13752
|
-
const path =
|
|
13698
|
+
const path = join30(root, name, "SKILL.md");
|
|
13753
13699
|
try {
|
|
13754
13700
|
if (!statSync4(path).isFile()) return void 0;
|
|
13755
13701
|
accessSync(path, constants2.R_OK);
|
|
@@ -13762,9 +13708,9 @@ function installedSkillPath(root, name) {
|
|
|
13762
13708
|
}
|
|
13763
13709
|
function linkedSkillRoot(home, host) {
|
|
13764
13710
|
if (host === "claude" || host === "claude-code") {
|
|
13765
|
-
return
|
|
13711
|
+
return join30(process.env.CLAUDE_CONFIG_DIR?.trim() || join30(home, ".claude"), "skills");
|
|
13766
13712
|
}
|
|
13767
|
-
if (host === "hermes") return
|
|
13713
|
+
if (host === "hermes") return join30(home, ".hermes/skills");
|
|
13768
13714
|
return void 0;
|
|
13769
13715
|
}
|
|
13770
13716
|
async function occupied(path) {
|
|
@@ -13821,7 +13767,7 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
13821
13767
|
const missingBySource = /* @__PURE__ */ new Map();
|
|
13822
13768
|
let unsourced = false;
|
|
13823
13769
|
for (const name of packagedMethodSkillNames()) {
|
|
13824
|
-
const path =
|
|
13770
|
+
const path = join30(canonical, name);
|
|
13825
13771
|
if (await occupied(path)) {
|
|
13826
13772
|
warnOccupied(path, stdout);
|
|
13827
13773
|
continue;
|
|
@@ -13851,9 +13797,9 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
13851
13797
|
throw error;
|
|
13852
13798
|
}
|
|
13853
13799
|
for (const name of packagedMethodSkillNames()) {
|
|
13854
|
-
const target =
|
|
13800
|
+
const target = join30(canonical, name);
|
|
13855
13801
|
if (installedMethodSkillPath(home, name) === void 0) continue;
|
|
13856
|
-
const link =
|
|
13802
|
+
const link = join30(root, name);
|
|
13857
13803
|
if (await occupied(link)) {
|
|
13858
13804
|
warnOccupied(link, stdout);
|
|
13859
13805
|
continue;
|
|
@@ -15054,16 +15000,16 @@ var init_analyst_book_key = __esm({
|
|
|
15054
15000
|
|
|
15055
15001
|
// src/atomic-write.ts
|
|
15056
15002
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
15057
|
-
import { rename as rename3, rm as
|
|
15058
|
-
import { dirname as dirname19, join as
|
|
15003
|
+
import { rename as rename3, rm as rm3, writeFile as writeFile7 } from "node:fs/promises";
|
|
15004
|
+
import { dirname as dirname19, join as join31 } from "node:path";
|
|
15059
15005
|
async function writeFileAtomically(destination, contents) {
|
|
15060
15006
|
const parent = dirname19(destination);
|
|
15061
|
-
const temporary =
|
|
15007
|
+
const temporary = join31(parent, `.atomic-write-${randomUUID7()}.tmp`);
|
|
15062
15008
|
try {
|
|
15063
|
-
await
|
|
15009
|
+
await writeFile7(temporary, contents);
|
|
15064
15010
|
await rename3(temporary, destination);
|
|
15065
15011
|
} catch (error) {
|
|
15066
|
-
await
|
|
15012
|
+
await rm3(temporary, { force: true }).catch(() => void 0);
|
|
15067
15013
|
throw error;
|
|
15068
15014
|
}
|
|
15069
15015
|
}
|
|
@@ -15075,7 +15021,7 @@ var init_atomic_write = __esm({
|
|
|
15075
15021
|
|
|
15076
15022
|
// src/analyst-index.ts
|
|
15077
15023
|
import { open as open2, readFile as readFile17, unlink as unlink4 } from "node:fs/promises";
|
|
15078
|
-
import { dirname as dirname20, join as
|
|
15024
|
+
import { dirname as dirname20, join as join32 } from "node:path";
|
|
15079
15025
|
function sleep(ms) {
|
|
15080
15026
|
return new Promise((resolve22) => {
|
|
15081
15027
|
setTimeout(resolve22, ms);
|
|
@@ -15084,7 +15030,7 @@ function sleep(ms) {
|
|
|
15084
15030
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
15085
15031
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
15086
15032
|
ensureRealDirectoryTree(ledgerHome, dirname20(indexPath));
|
|
15087
|
-
const lockPath =
|
|
15033
|
+
const lockPath = join32(dirname20(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
15088
15034
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
15089
15035
|
const startedAt = Date.now();
|
|
15090
15036
|
while (true) {
|
|
@@ -15111,7 +15057,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
15111
15057
|
}
|
|
15112
15058
|
}
|
|
15113
15059
|
function analystLibraryIndexPath(ledgerHome) {
|
|
15114
|
-
return
|
|
15060
|
+
return join32(ledgerHome, "analyst", "library-index.json");
|
|
15115
15061
|
}
|
|
15116
15062
|
function rowFromIssueMetricsPage(page) {
|
|
15117
15063
|
return {
|
|
@@ -15407,7 +15353,7 @@ var init_analyst_cohort = __esm({
|
|
|
15407
15353
|
|
|
15408
15354
|
// src/analyst-ledger.ts
|
|
15409
15355
|
import { readdir as readdir6, readFile as readFile18 } from "node:fs/promises";
|
|
15410
|
-
import { basename as basename8, join as
|
|
15356
|
+
import { basename as basename8, join as join33 } from "node:path";
|
|
15411
15357
|
function isMissingPathError6(error) {
|
|
15412
15358
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
15413
15359
|
}
|
|
@@ -15436,7 +15382,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
|
|
|
15436
15382
|
}
|
|
15437
15383
|
}
|
|
15438
15384
|
async function classifyGhostCandidate(input) {
|
|
15439
|
-
const autopsy = await autopsyWriterLock(
|
|
15385
|
+
const autopsy = await autopsyWriterLock(join33(input.runDirectory, "writer.lock"));
|
|
15440
15386
|
const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
|
|
15441
15387
|
if (leaseCheck === void 0) return { kind: "live" };
|
|
15442
15388
|
return {
|
|
@@ -15465,7 +15411,7 @@ async function listLedgerBookNames(booksRoot) {
|
|
|
15465
15411
|
async function readInvocationScopeFields(runDirectory) {
|
|
15466
15412
|
let raw;
|
|
15467
15413
|
try {
|
|
15468
|
-
raw = await readFile18(
|
|
15414
|
+
raw = await readFile18(join33(runDirectory, "invocation.json"), "utf8");
|
|
15469
15415
|
} catch (error) {
|
|
15470
15416
|
if (isMissingPathError6(error)) return void 0;
|
|
15471
15417
|
throw error;
|
|
@@ -15498,7 +15444,7 @@ function decideIssueScope(input) {
|
|
|
15498
15444
|
}
|
|
15499
15445
|
async function resolveSessionFile(runDirectory) {
|
|
15500
15446
|
try {
|
|
15501
|
-
const raw = await readFile18(
|
|
15447
|
+
const raw = await readFile18(join33(runDirectory, "invocation.json"), "utf8");
|
|
15502
15448
|
const parsed = JSON.parse(raw);
|
|
15503
15449
|
if (isRecord12(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
15504
15450
|
return parsed.sessionFile;
|
|
@@ -15506,7 +15452,7 @@ async function resolveSessionFile(runDirectory) {
|
|
|
15506
15452
|
} catch (error) {
|
|
15507
15453
|
if (!isMissingPathError6(error)) throw error;
|
|
15508
15454
|
}
|
|
15509
|
-
return
|
|
15455
|
+
return join33(runDirectory, "session", "session.jsonl");
|
|
15510
15456
|
}
|
|
15511
15457
|
function attributeSessionRowsForRun(input) {
|
|
15512
15458
|
if (pathContainedIn(input.runDirectory, input.sessionFile)) {
|
|
@@ -15708,9 +15654,9 @@ async function classifyScopedRun(input) {
|
|
|
15708
15654
|
}
|
|
15709
15655
|
let gateCycles;
|
|
15710
15656
|
try {
|
|
15711
|
-
const parentSessionFile =
|
|
15657
|
+
const parentSessionFile = join33(input.runDirectory, "session", "session.jsonl");
|
|
15712
15658
|
gateCycles = await readAnalystGateCyclesFromAuditorRoles(
|
|
15713
|
-
|
|
15659
|
+
join33(input.runDirectory, "session", "auditor-roles"),
|
|
15714
15660
|
{ parentSessionFile }
|
|
15715
15661
|
);
|
|
15716
15662
|
} catch (error) {
|
|
@@ -15745,7 +15691,7 @@ async function classifyScopedRun(input) {
|
|
|
15745
15691
|
async function scanAnalystIssueRuns(input) {
|
|
15746
15692
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
15747
15693
|
const scopeTicketNumber = input.ticketNumber;
|
|
15748
|
-
const booksRoot =
|
|
15694
|
+
const booksRoot = join33(ledgerHome, "books");
|
|
15749
15695
|
let wholeBook = false;
|
|
15750
15696
|
let scopeRootIdentity;
|
|
15751
15697
|
let bookNames;
|
|
@@ -15778,7 +15724,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
15778
15724
|
const ghostLegs = [];
|
|
15779
15725
|
const scopeConflicts = [];
|
|
15780
15726
|
for (const book of bookNames) {
|
|
15781
|
-
const bookDir =
|
|
15727
|
+
const bookDir = join33(booksRoot, book);
|
|
15782
15728
|
let runDirectories;
|
|
15783
15729
|
try {
|
|
15784
15730
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
@@ -16515,7 +16461,7 @@ var init_analyst_metric_family = __esm({
|
|
|
16515
16461
|
|
|
16516
16462
|
// src/analyst-page.ts
|
|
16517
16463
|
import { createHash as createHash3 } from "node:crypto";
|
|
16518
|
-
import { dirname as dirname21, join as
|
|
16464
|
+
import { dirname as dirname21, join as join34 } from "node:path";
|
|
16519
16465
|
function analystIssuePageKey(address) {
|
|
16520
16466
|
const parts = ["book", address.bookKey];
|
|
16521
16467
|
if (address.issueNumber !== void 0) {
|
|
@@ -16526,7 +16472,7 @@ function analystIssuePageKey(address) {
|
|
|
16526
16472
|
return createHash3("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
16527
16473
|
}
|
|
16528
16474
|
function analystIssuePagePath(ledgerHome, address) {
|
|
16529
|
-
return
|
|
16475
|
+
return join34(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
16530
16476
|
}
|
|
16531
16477
|
function analystIssuePageAddressFromPage(page) {
|
|
16532
16478
|
return {
|
|
@@ -17165,7 +17111,7 @@ __export(cli_exports, {
|
|
|
17165
17111
|
runAkRole: () => runAkRole
|
|
17166
17112
|
});
|
|
17167
17113
|
import { realpath as realpath5 } from "node:fs/promises";
|
|
17168
|
-
import { join as
|
|
17114
|
+
import { join as join35 } from "node:path";
|
|
17169
17115
|
function publicSeatArgv(owner) {
|
|
17170
17116
|
return {
|
|
17171
17117
|
parse: (args) => parsePublicSeatArgv(owner, args),
|
|
@@ -17304,7 +17250,7 @@ function resolveHome(env) {
|
|
|
17304
17250
|
return env.home ?? packageMachineHome();
|
|
17305
17251
|
}
|
|
17306
17252
|
function resolveAgentDir(env, home) {
|
|
17307
|
-
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
17253
|
+
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join35(home, ".pi", "agent");
|
|
17308
17254
|
}
|
|
17309
17255
|
function parseThinking(value) {
|
|
17310
17256
|
return value;
|
|
@@ -18076,7 +18022,7 @@ __export(public_role_summons_exports, {
|
|
|
18076
18022
|
import { execFile as execFile3 } from "node:child_process";
|
|
18077
18023
|
import { existsSync as existsSync9 } from "node:fs";
|
|
18078
18024
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
18079
|
-
import { join as
|
|
18025
|
+
import { join as join36 } from "node:path";
|
|
18080
18026
|
import { promisify as promisify3 } from "node:util";
|
|
18081
18027
|
function createCapturingIo() {
|
|
18082
18028
|
const chunks = [];
|
|
@@ -18100,7 +18046,7 @@ function parentDir(path) {
|
|
|
18100
18046
|
function walkPackageRoot(start) {
|
|
18101
18047
|
let dir = start;
|
|
18102
18048
|
for (let i = 0; i < 12; i += 1) {
|
|
18103
|
-
if (existsSync9(
|
|
18049
|
+
if (existsSync9(join36(dir, "package.json")) && existsSync9(join36(dir, "souls"))) {
|
|
18104
18050
|
return dir;
|
|
18105
18051
|
}
|
|
18106
18052
|
const parent = parentDir(dir);
|
|
@@ -18216,7 +18162,7 @@ async function createSummonEnv(options, afterHost) {
|
|
|
18216
18162
|
async function summonPublicRole(options) {
|
|
18217
18163
|
const packageRoot = resolveSummonsPackageRoot(options.packageRoot);
|
|
18218
18164
|
const home = await resolveSummonHome(options);
|
|
18219
|
-
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
18165
|
+
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join36(home, ".pi", "agent");
|
|
18220
18166
|
const {
|
|
18221
18167
|
loadCredentialProviders: loadCredentialProviders2,
|
|
18222
18168
|
loadPublicCliConfig: loadPublicCliConfig2,
|
|
@@ -18724,7 +18670,7 @@ var init_compliance_transport = __esm({
|
|
|
18724
18670
|
});
|
|
18725
18671
|
|
|
18726
18672
|
// src/role-run-relocation.ts
|
|
18727
|
-
import { join as
|
|
18673
|
+
import { join as join37, sep as sep5 } from "node:path";
|
|
18728
18674
|
function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
|
|
18729
18675
|
if (typeof value !== "string") return value;
|
|
18730
18676
|
if (value === oldRunDirectory) return newRunDirectory;
|
|
@@ -18851,8 +18797,8 @@ __export(run_lifecycle_exports, {
|
|
|
18851
18797
|
renderResumeCommand: () => renderResumeCommand,
|
|
18852
18798
|
writeRoleRunState: () => writeRoleRunState
|
|
18853
18799
|
});
|
|
18854
|
-
import { chmod, lstat as lstat6, open as open3, readdir as readdir7, readFile as readFile21, unlink as unlink5, writeFile as
|
|
18855
|
-
import { basename as basename9, join as
|
|
18800
|
+
import { chmod, lstat as lstat6, open as open3, readdir as readdir7, readFile as readFile21, unlink as unlink5, writeFile as writeFile8 } from "node:fs/promises";
|
|
18801
|
+
import { basename as basename9, join as join38 } from "node:path";
|
|
18856
18802
|
function buildAutoResumeContinuationPrompt(options) {
|
|
18857
18803
|
return appendEngineSessionMaterial(
|
|
18858
18804
|
[RESUME_TRANSPORT_ENVELOPE],
|
|
@@ -18877,8 +18823,8 @@ function renderResumeCommand(runId) {
|
|
|
18877
18823
|
}
|
|
18878
18824
|
async function writeRoleRunState(runDirectory, record4) {
|
|
18879
18825
|
const payload = { ...record4, runDirectory };
|
|
18880
|
-
await
|
|
18881
|
-
|
|
18826
|
+
await writeFile8(
|
|
18827
|
+
join38(runDirectory, RUN_STATE_FILE),
|
|
18882
18828
|
`${JSON.stringify(payload, null, 2)}
|
|
18883
18829
|
`,
|
|
18884
18830
|
"utf8"
|
|
@@ -18928,7 +18874,7 @@ function parseCurrentCourtState(raw) {
|
|
|
18928
18874
|
async function readRoleRunStateRaw(runDirectory) {
|
|
18929
18875
|
let raw;
|
|
18930
18876
|
try {
|
|
18931
|
-
raw = JSON.parse(await readFile21(
|
|
18877
|
+
raw = JSON.parse(await readFile21(join38(runDirectory, RUN_STATE_FILE), "utf8"));
|
|
18932
18878
|
} catch (error) {
|
|
18933
18879
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
18934
18880
|
throw error;
|
|
@@ -19021,8 +18967,8 @@ async function writeRoleRunStateDisk(runDirectory, disk) {
|
|
|
19021
18967
|
...disk.resumable === void 0 ? {} : { resumable: disk.resumable },
|
|
19022
18968
|
...disk.currentCourt === void 0 ? {} : { currentCourt: disk.currentCourt }
|
|
19023
18969
|
};
|
|
19024
|
-
await
|
|
19025
|
-
|
|
18970
|
+
await writeFile8(
|
|
18971
|
+
join38(runDirectory, RUN_STATE_FILE),
|
|
19026
18972
|
`${JSON.stringify(payload, null, 2)}
|
|
19027
18973
|
`,
|
|
19028
18974
|
"utf8"
|
|
@@ -19245,7 +19191,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
|
|
|
19245
19191
|
},
|
|
19246
19192
|
relocate(nextRunDirectory) {
|
|
19247
19193
|
currentRunDirectory = nextRunDirectory;
|
|
19248
|
-
currentLockPath =
|
|
19194
|
+
currentLockPath = join38(nextRunDirectory, WRITER_LOCK_FILE);
|
|
19249
19195
|
},
|
|
19250
19196
|
async release() {
|
|
19251
19197
|
if (released) return;
|
|
@@ -19284,10 +19230,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
19284
19230
|
};
|
|
19285
19231
|
const reportReadFailure = (error) => {
|
|
19286
19232
|
reportDiagnostic(
|
|
19287
|
-
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${
|
|
19233
|
+
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join38(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
|
|
19288
19234
|
);
|
|
19289
19235
|
};
|
|
19290
|
-
const lockPath =
|
|
19236
|
+
const lockPath = join38(runDirectory, WRITER_LOCK_FILE);
|
|
19291
19237
|
let lastAutopsy = { verdict: "absent" };
|
|
19292
19238
|
let lastReclaimFailure;
|
|
19293
19239
|
for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
|
|
@@ -19342,7 +19288,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
19342
19288
|
async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
19343
19289
|
if (runId.trim() === "") return void 0;
|
|
19344
19290
|
const ledgerHome = resolveActivationLedgerHome(home);
|
|
19345
|
-
const booksRoot =
|
|
19291
|
+
const booksRoot = join38(ledgerHome, "books");
|
|
19346
19292
|
let bookKeys;
|
|
19347
19293
|
try {
|
|
19348
19294
|
bookKeys = await readdir7(booksRoot);
|
|
@@ -19383,7 +19329,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
19383
19329
|
let raw;
|
|
19384
19330
|
try {
|
|
19385
19331
|
raw = JSON.parse(
|
|
19386
|
-
await readFile21(
|
|
19332
|
+
await readFile21(join38(runDirectory, "admitted-request.json"), "utf8")
|
|
19387
19333
|
);
|
|
19388
19334
|
} catch (error) {
|
|
19389
19335
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -19404,7 +19350,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
19404
19350
|
async function runHasFormedSessionPrincipal(runDirectory) {
|
|
19405
19351
|
const disk = await readRoleRunStateDisk(runDirectory);
|
|
19406
19352
|
if (disk === void 0) return false;
|
|
19407
|
-
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile :
|
|
19353
|
+
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : join38(disk.principalWire.sessionDirectory, "session.jsonl");
|
|
19408
19354
|
try {
|
|
19409
19355
|
const stat2 = await lstat6(sessionFile);
|
|
19410
19356
|
return stat2.isFile() && !stat2.isSymbolicLink();
|
|
@@ -19422,7 +19368,7 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
19422
19368
|
let runDirectories;
|
|
19423
19369
|
try {
|
|
19424
19370
|
runDirectories = await listBookRunDirectories(
|
|
19425
|
-
input.ticketNumber === void 0 ? bookDir :
|
|
19371
|
+
input.ticketNumber === void 0 ? bookDir : join38(bookDir, String(input.ticketNumber))
|
|
19426
19372
|
);
|
|
19427
19373
|
} catch (error) {
|
|
19428
19374
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -19620,7 +19566,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19620
19566
|
let model;
|
|
19621
19567
|
try {
|
|
19622
19568
|
const invocationRaw = JSON.parse(
|
|
19623
|
-
await readFile21(
|
|
19569
|
+
await readFile21(join38(run.runDirectory, "invocation.json"), "utf8")
|
|
19624
19570
|
);
|
|
19625
19571
|
if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
|
|
19626
19572
|
const rec = invocationRaw;
|
|
@@ -19988,7 +19934,7 @@ var init_run_lifecycle = __esm({
|
|
|
19988
19934
|
});
|
|
19989
19935
|
|
|
19990
19936
|
// src/submission-ledger.ts
|
|
19991
|
-
import { join as
|
|
19937
|
+
import { join as join39 } from "node:path";
|
|
19992
19938
|
function runIdentity(context) {
|
|
19993
19939
|
const directory = runDirectoryFromHostContext(context);
|
|
19994
19940
|
if (directory !== void 0) {
|
|
@@ -20010,7 +19956,7 @@ async function submissionRecordFile(cwd, runId, scope) {
|
|
|
20010
19956
|
if (sessionParent === void 0) {
|
|
20011
19957
|
const discoveredRun = await findRunDirectoryById(scope.home, runId);
|
|
20012
19958
|
if (discoveredRun === void 0) return void 0;
|
|
20013
|
-
sessionParent =
|
|
19959
|
+
sessionParent = join39(discoveredRun, "session", "session.jsonl");
|
|
20014
19960
|
}
|
|
20015
19961
|
return resolveSitianRecordPathInLedger({
|
|
20016
19962
|
level: "event",
|
|
@@ -20203,12 +20149,12 @@ async function restoreState(cwd, runId, scope) {
|
|
|
20203
20149
|
}
|
|
20204
20150
|
function sessionParentFromHostContext(context) {
|
|
20205
20151
|
const runDirectory = runDirectoryFromHostContext(context);
|
|
20206
|
-
if (runDirectory !== void 0) return
|
|
20152
|
+
if (runDirectory !== void 0) return join39(runDirectory, "session", "session.jsonl");
|
|
20207
20153
|
const sessionFile = context.sessionManager.getSessionFile?.();
|
|
20208
20154
|
if (typeof sessionFile === "string" && sessionFile.length > 0) return sessionFile;
|
|
20209
20155
|
const sessionDir = context.sessionManager.getSessionDir?.();
|
|
20210
20156
|
if (typeof sessionDir === "string" && sessionDir.length > 0) {
|
|
20211
|
-
return
|
|
20157
|
+
return join39(sessionDir, "session.jsonl");
|
|
20212
20158
|
}
|
|
20213
20159
|
return void 0;
|
|
20214
20160
|
}
|
|
@@ -20388,7 +20334,7 @@ var init_submission_ledger = __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 statSync7,
|
|
20474
20420
|
writeFileSync as writeFileSync3
|
|
20475
20421
|
} from "node:fs";
|
|
20476
|
-
import { dirname as dirname23, resolve as resolve17, join as
|
|
20422
|
+
import { dirname as dirname23, resolve as resolve17, 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
|
writeFileSync3(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 = statSync7(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
|
}
|
|
@@ -20776,9 +20722,9 @@ import { randomUUID as randomUUID10 } from "node:crypto";
|
|
|
20776
20722
|
init_engine_detour();
|
|
20777
20723
|
init_packaged_role_registry();
|
|
20778
20724
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
20779
|
-
import { appendFile as appendFile3, mkdir as mkdir5, writeFile as
|
|
20725
|
+
import { appendFile as appendFile3, mkdir as mkdir5, writeFile as writeFile9 } from "node:fs/promises";
|
|
20780
20726
|
import { createServer } from "node:net";
|
|
20781
|
-
import { dirname as dirname25, join as
|
|
20727
|
+
import { dirname as dirname25, join as join45 } from "node:path";
|
|
20782
20728
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
20783
20729
|
|
|
20784
20730
|
// src/role-runtime.ts
|
|
@@ -20787,7 +20733,7 @@ init_sitian_facade();
|
|
|
20787
20733
|
init_submission_ledger();
|
|
20788
20734
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
20789
20735
|
import { readFileSync as readFileSync6, writeSync as writeSync2 } from "node:fs";
|
|
20790
|
-
import { join as
|
|
20736
|
+
import { join as join44 } from "node:path";
|
|
20791
20737
|
import { Value as Value4 } from "typebox/value";
|
|
20792
20738
|
|
|
20793
20739
|
// src/activation-trace.ts
|
|
@@ -21857,10 +21803,10 @@ init_packaged_role_registry();
|
|
|
21857
21803
|
init_atomic_write();
|
|
21858
21804
|
import { existsSync as existsSync10, realpathSync as realpathSync3 } from "node:fs";
|
|
21859
21805
|
import { readFile as readFile22 } from "node:fs/promises";
|
|
21860
|
-
import { basename as basename10, dirname as dirname22, join as
|
|
21806
|
+
import { basename as basename10, dirname as dirname22, join as join40, resolve as resolve16 } from "node:path";
|
|
21861
21807
|
var NAVIGATOR_WORK_CONTEXT_BASENAME = "work-context.json";
|
|
21862
21808
|
function navigatorWorkContextFile(sessionDir) {
|
|
21863
|
-
return
|
|
21809
|
+
return join40(sessionDir, NAVIGATOR_WORK_CONTEXT_BASENAME);
|
|
21864
21810
|
}
|
|
21865
21811
|
function isNavigatorWorkContextFile(path) {
|
|
21866
21812
|
const resolved = resolve16(path);
|
|
@@ -23708,7 +23654,7 @@ function readDiaristTicketAssertion(submitted) {
|
|
|
23708
23654
|
function readRoleRunCoordinates(ctx, label) {
|
|
23709
23655
|
const runDirectory = runDirectoryFromHostContext(ctx);
|
|
23710
23656
|
if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
|
|
23711
|
-
const admittedPath =
|
|
23657
|
+
const admittedPath = join44(runDirectory, "admitted-request.json");
|
|
23712
23658
|
const admitted = JSON.parse(readFileSync6(admittedPath, "utf8"));
|
|
23713
23659
|
if (typeof admitted.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
|
|
23714
23660
|
throw new Error(`${label} admitted-request missing projectRoot (${admittedPath})`);
|
|
@@ -24632,11 +24578,11 @@ async function prepareRoleEnvelope(options) {
|
|
|
24632
24578
|
const hostAbort = new AbortController();
|
|
24633
24579
|
const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID9();
|
|
24634
24580
|
await mkdir5(request.runDirectory, { recursive: true });
|
|
24635
|
-
let sessionFile = options.sessionFile ??
|
|
24581
|
+
let sessionFile = options.sessionFile ?? join45(request.runDirectory, "session", "session.jsonl");
|
|
24636
24582
|
await mkdir5(dirname25(sessionFile), { recursive: true });
|
|
24637
24583
|
if (request.continuation.kind !== "resume") {
|
|
24638
24584
|
try {
|
|
24639
|
-
await
|
|
24585
|
+
await writeFile9(
|
|
24640
24586
|
sessionFile,
|
|
24641
24587
|
`${JSON.stringify({
|
|
24642
24588
|
type: "session",
|
|
@@ -25314,7 +25260,7 @@ function acpModelId(modelPassing, model) {
|
|
|
25314
25260
|
}
|
|
25315
25261
|
|
|
25316
25262
|
// src/acp-host/role-turn-host.ts
|
|
25317
|
-
import { join as
|
|
25263
|
+
import { join as join46 } from "node:path";
|
|
25318
25264
|
import { spawn as spawn3 } from "node:child_process";
|
|
25319
25265
|
import { createInterface } from "node:readline";
|
|
25320
25266
|
|
|
@@ -25767,7 +25713,7 @@ function createAcpRoleTurnHost(config) {
|
|
|
25767
25713
|
host: config.hostName,
|
|
25768
25714
|
sessionId,
|
|
25769
25715
|
cwd: request.cwd,
|
|
25770
|
-
sessionDirectory:
|
|
25716
|
+
sessionDirectory: join46(request.runDirectory, "session"),
|
|
25771
25717
|
sessionParent,
|
|
25772
25718
|
continuation: request.continuation,
|
|
25773
25719
|
...request.model !== void 0 ? { model: request.model } : {},
|
|
@@ -25787,12 +25733,12 @@ function createAcpRoleTurnHost(config) {
|
|
|
25787
25733
|
// src/acp-host/seat-profile-soul.ts
|
|
25788
25734
|
import { constants as constants3 } from "node:fs";
|
|
25789
25735
|
import { access as access3, copyFile, lstat as lstat7, mkdir as mkdir6, readlink, symlink as symlink2, unlink as unlink6 } from "node:fs/promises";
|
|
25790
|
-
import { dirname as dirname26, join as
|
|
25736
|
+
import { dirname as dirname26, join as join47, relative as relative3, resolve as resolve21 } from "node:path";
|
|
25791
25737
|
function seatProfileName(spec, role) {
|
|
25792
25738
|
return `${spec.namePrefix}${role}`;
|
|
25793
25739
|
}
|
|
25794
25740
|
function packageRoleSoulPath(packageRoot, role) {
|
|
25795
|
-
return
|
|
25741
|
+
return join47(packageRoot, "souls", `${role}.md`);
|
|
25796
25742
|
}
|
|
25797
25743
|
async function pathExists2(path) {
|
|
25798
25744
|
try {
|
|
@@ -25809,16 +25755,16 @@ async function ensureSeatProfileSoul(options) {
|
|
|
25809
25755
|
if (!await pathExists2(soulTarget)) {
|
|
25810
25756
|
throw new Error(`packaged role soul missing: ${soulTarget}`);
|
|
25811
25757
|
}
|
|
25812
|
-
const profilesRoot =
|
|
25813
|
-
const profileDir =
|
|
25758
|
+
const profilesRoot = join47(operatorHome, ...spec.profilesRootFromHome);
|
|
25759
|
+
const profileDir = join47(profilesRoot, profileName);
|
|
25814
25760
|
const hostRoot = dirname26(profilesRoot);
|
|
25815
|
-
const soulPath =
|
|
25761
|
+
const soulPath = join47(profileDir, spec.soulFileName);
|
|
25816
25762
|
if (!await pathExists2(profileDir)) {
|
|
25817
25763
|
await mkdir6(profileDir, { recursive: true });
|
|
25818
25764
|
for (const name of ["auth.json", ".env", "config.yaml"]) {
|
|
25819
|
-
const source =
|
|
25765
|
+
const source = join47(hostRoot, name);
|
|
25820
25766
|
if (!await pathExists2(source)) continue;
|
|
25821
|
-
await copyFile(source,
|
|
25767
|
+
await copyFile(source, join47(profileDir, name));
|
|
25822
25768
|
}
|
|
25823
25769
|
} else {
|
|
25824
25770
|
await mkdir6(profileDir, { recursive: true });
|