@akagilnc/pi-workflow-roles 0.1.5307 → 0.1.5312
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/description.js +0 -11
- package/dist/acp-host/production-host.js +440 -441
- package/dist/headless-host/description.js +0 -11
- package/dist/headless-host/production-host.js +533 -546
- package/dist/host-descriptions.js +13 -0
- package/dist/prepared-role-turn.js +4 -0
- package/dist/public-cli/machine-method-skills.js +5 -5
- package/dist/public-cli/main.js +154 -150
- package/package.json +1 -1
- package/src/acp-host/description.ts +2 -12
- package/src/acp-host/production-host.ts +3 -2
- package/src/acp-host/role-turn-host.ts +7 -42
- package/src/external-host-turn-loop.ts +36 -16
- package/src/headless-host/description.ts +3 -18
- package/src/headless-host/production-host.ts +3 -2
- package/src/headless-host/role-turn-host.ts +10 -68
- package/src/host-descriptions.ts +18 -0
- package/src/prepared-role-turn.ts +8 -0
- package/src/public-cli/machine-method-skills.ts +5 -5
|
@@ -13,11 +13,114 @@ var __export = (target, all) => {
|
|
|
13
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
+
// src/host-descriptions.ts
|
|
17
|
+
import { join } from "node:path";
|
|
18
|
+
function resolveHostBinary(description, operatorHome) {
|
|
19
|
+
return join(operatorHome, ...description.binaryFromHome);
|
|
20
|
+
}
|
|
21
|
+
function lookupHostDescription(host) {
|
|
22
|
+
return Object.hasOwn(HOST_DESCRIPTIONS, host) ? HOST_DESCRIPTIONS[host] : void 0;
|
|
23
|
+
}
|
|
24
|
+
function lookupHeadlessHostDescription(host) {
|
|
25
|
+
return Object.hasOwn(HEADLESS_HOST_DESCRIPTIONS, host) ? HEADLESS_HOST_DESCRIPTIONS[host] : void 0;
|
|
26
|
+
}
|
|
27
|
+
function lookupHostFamily(host) {
|
|
28
|
+
if (lookupHostDescription(host) !== void 0) return "acp";
|
|
29
|
+
if (lookupHeadlessHostDescription(host) !== void 0) return "headless";
|
|
30
|
+
return void 0;
|
|
31
|
+
}
|
|
32
|
+
function packagedExternalHostNames() {
|
|
33
|
+
return [...Object.keys(HOST_DESCRIPTIONS), ...Object.keys(HEADLESS_HOST_DESCRIPTIONS)];
|
|
34
|
+
}
|
|
35
|
+
function assertRegisteredHostName(host) {
|
|
36
|
+
if (host === DEFAULT_ROLE_TURN_HOST || lookupHostFamily(host) !== void 0) {
|
|
37
|
+
return host;
|
|
38
|
+
}
|
|
39
|
+
throw new Error(`unregistered host: ${host}`);
|
|
40
|
+
}
|
|
41
|
+
var DEFAULT_ROLE_TURN_HOST, HOST_DESCRIPTIONS, HEADLESS_HOST_DESCRIPTIONS;
|
|
42
|
+
var init_host_descriptions = __esm({
|
|
43
|
+
"src/host-descriptions.ts"() {
|
|
44
|
+
"use strict";
|
|
45
|
+
DEFAULT_ROLE_TURN_HOST = "pi";
|
|
46
|
+
HOST_DESCRIPTIONS = Object.freeze({
|
|
47
|
+
/** Operator home `~/.grok`, native session/load resume, `agent [--model X] stdio`. */
|
|
48
|
+
"grok-build": Object.freeze({
|
|
49
|
+
binaryFromHome: Object.freeze([".grok", "bin", "grok"]),
|
|
50
|
+
argv: Object.freeze({
|
|
51
|
+
prefix: Object.freeze(["agent"]),
|
|
52
|
+
suffix: Object.freeze(["stdio"]),
|
|
53
|
+
modelFlag: "--model"
|
|
54
|
+
}),
|
|
55
|
+
modelPassing: "argv",
|
|
56
|
+
sessionBindingFile: "grok-acp-session.json"
|
|
57
|
+
}),
|
|
58
|
+
/**
|
|
59
|
+
* Operator home `~/.hermes`, native session/load resume, `acp` subcommand.
|
|
60
|
+
* Model arrives as an ACP `session/set_model` RPC with modelId `provider:model`
|
|
61
|
+
* (seat table provider + model concatenated). Reasoning is the global
|
|
62
|
+
* `--reasoning` flag before `acp`. Soul is the seat profile SOUL.md symlink
|
|
63
|
+
* (`hermes -p ak-<role> …`); package `souls/<role>.md` is the sole source.
|
|
64
|
+
*/
|
|
65
|
+
"hermes": Object.freeze({
|
|
66
|
+
binaryFromHome: Object.freeze([".local", "bin", "hermes"]),
|
|
67
|
+
argv: Object.freeze({
|
|
68
|
+
prefix: Object.freeze(["acp"]),
|
|
69
|
+
suffix: Object.freeze([]),
|
|
70
|
+
thinkingFlag: "--reasoning"
|
|
71
|
+
}),
|
|
72
|
+
modelPassing: "set_model",
|
|
73
|
+
sessionBindingFile: "hermes-acp-session.json",
|
|
74
|
+
seatProfileSoul: Object.freeze({
|
|
75
|
+
flag: "-p",
|
|
76
|
+
namePrefix: "ak-",
|
|
77
|
+
profilesRootFromHome: Object.freeze([".hermes", "profiles"]),
|
|
78
|
+
soulFileName: "SOUL.md"
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
});
|
|
82
|
+
HEADLESS_HOST_DESCRIPTIONS = Object.freeze({
|
|
83
|
+
"claude": Object.freeze({
|
|
84
|
+
protocol: "claude-print",
|
|
85
|
+
binaryFromHome: Object.freeze([".local", "bin", "claude"]),
|
|
86
|
+
sessionBindingFile: "claude-headless-session.json",
|
|
87
|
+
fixedArgs: Object.freeze([
|
|
88
|
+
// Live NDJSON events → sitian host-session records (#811); last line is the result receipt.
|
|
89
|
+
"--output-format",
|
|
90
|
+
"stream-json",
|
|
91
|
+
// Intermediate assistant/tool/system events require verbose with stream-json.
|
|
92
|
+
"--verbose",
|
|
93
|
+
"--permission-mode",
|
|
94
|
+
"bypassPermissions"
|
|
95
|
+
]),
|
|
96
|
+
promptFlag: "-p",
|
|
97
|
+
modelFlag: "--model",
|
|
98
|
+
effortFlag: "--effort",
|
|
99
|
+
// File path keeps large role envelopes off ARG_MAX.
|
|
100
|
+
systemPromptFlag: "--system-prompt-file",
|
|
101
|
+
jsonSchemaFlag: "--json-schema",
|
|
102
|
+
mcpConfigFlag: "--mcp-config",
|
|
103
|
+
sessionIdFlag: "--session-id",
|
|
104
|
+
resumeFlag: "--resume"
|
|
105
|
+
}),
|
|
106
|
+
/**
|
|
107
|
+
* Codex headless (#646). Binary under operator home; auth stays in CODEX_HOME.
|
|
108
|
+
* Argv/parse/schema-close are codex-exec helpers — not Claude flag mapping.
|
|
109
|
+
*/
|
|
110
|
+
"codex": Object.freeze({
|
|
111
|
+
protocol: "codex-exec",
|
|
112
|
+
binaryFromHome: Object.freeze([".local", "bin", "codex"]),
|
|
113
|
+
sessionBindingFile: "codex-headless-session.json"
|
|
114
|
+
})
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
16
119
|
// src/engine-detour.ts
|
|
17
120
|
import { spawn } from "node:child_process";
|
|
18
121
|
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
19
122
|
import { tmpdir } from "node:os";
|
|
20
|
-
import { join } from "node:path";
|
|
123
|
+
import { join as join2 } from "node:path";
|
|
21
124
|
function normalizeEngineName(engine) {
|
|
22
125
|
if (engine === void 0) return void 0;
|
|
23
126
|
const trimmed = engine.trim();
|
|
@@ -118,8 +221,8 @@ async function runEngineDetourOnce(input) {
|
|
|
118
221
|
if (input.stagedPrompt === void 0) {
|
|
119
222
|
return spawnEngineDetourOnce(input);
|
|
120
223
|
}
|
|
121
|
-
const stagingDir = await mkdtemp(
|
|
122
|
-
const stagedPath =
|
|
224
|
+
const stagingDir = await mkdtemp(join2(tmpdir(), "ak-engine-detour-"));
|
|
225
|
+
const stagedPath = join2(stagingDir, "prompt.txt");
|
|
123
226
|
let result;
|
|
124
227
|
let runError;
|
|
125
228
|
try {
|
|
@@ -962,7 +1065,7 @@ __export(run_ticket_number_exports, {
|
|
|
962
1065
|
requireSafePositiveTicketNumber: () => requireSafePositiveTicketNumber
|
|
963
1066
|
});
|
|
964
1067
|
import { readFile } from "node:fs/promises";
|
|
965
|
-
import { join as
|
|
1068
|
+
import { join as join3 } from "node:path";
|
|
966
1069
|
function isEnoent(error) {
|
|
967
1070
|
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
968
1071
|
}
|
|
@@ -1002,7 +1105,7 @@ async function readJsonObject(path) {
|
|
|
1002
1105
|
}
|
|
1003
1106
|
}
|
|
1004
1107
|
async function readBoardPageTicketNumber(runDirectory, page) {
|
|
1005
|
-
const record4 = await readJsonObject(
|
|
1108
|
+
const record4 = await readJsonObject(join3(runDirectory, page));
|
|
1006
1109
|
if (record4 === void 0) return void 0;
|
|
1007
1110
|
return ticketFromRecord(record4);
|
|
1008
1111
|
}
|
|
@@ -1011,7 +1114,7 @@ async function readBoardTicketNumber(runDirectory) {
|
|
|
1011
1114
|
}
|
|
1012
1115
|
async function readMigrationDerivedTicketNumber(runDirectory) {
|
|
1013
1116
|
const record4 = await readJsonObject(
|
|
1014
|
-
|
|
1117
|
+
join3(runDirectory, MIGRATION_TICKET_DERIVATION_PAGE)
|
|
1015
1118
|
);
|
|
1016
1119
|
if (record4 === void 0) return void 0;
|
|
1017
1120
|
if (record4.derivation !== "worktree-path-basename") return void 0;
|
|
@@ -1935,7 +2038,7 @@ import {
|
|
|
1935
2038
|
statSync
|
|
1936
2039
|
} from "node:fs";
|
|
1937
2040
|
import { userInfo } from "node:os";
|
|
1938
|
-
import { basename as basename2, dirname as dirname2, isAbsolute as isAbsolute2, join as
|
|
2041
|
+
import { basename as basename2, dirname as dirname2, isAbsolute as isAbsolute2, join as join4, relative, resolve as resolve2, sep } from "node:path";
|
|
1939
2042
|
function packageMachineHome() {
|
|
1940
2043
|
return resolve2(userInfo().homedir);
|
|
1941
2044
|
}
|
|
@@ -1975,7 +2078,7 @@ function resolveActivationLedgerHomeForPath(path) {
|
|
|
1975
2078
|
return resolveActivationLedgerHome();
|
|
1976
2079
|
}
|
|
1977
2080
|
function activationBookDirectory(ledgerHome, bookKey) {
|
|
1978
|
-
return
|
|
2081
|
+
return join4(ledgerHome, "books", bookKey);
|
|
1979
2082
|
}
|
|
1980
2083
|
function pathContainedIn(root, candidate) {
|
|
1981
2084
|
const rel = relative(root, candidate);
|
|
@@ -1988,7 +2091,7 @@ function physicalPathIdentity(path) {
|
|
|
1988
2091
|
while (true) {
|
|
1989
2092
|
try {
|
|
1990
2093
|
const real = realpathSync(cursor);
|
|
1991
|
-
return missing.length === 0 ? real :
|
|
2094
|
+
return missing.length === 0 ? real : join4(real, ...missing);
|
|
1992
2095
|
} catch (error) {
|
|
1993
2096
|
if (errnoCode(error) !== "ENOENT") {
|
|
1994
2097
|
return absolute;
|
|
@@ -2088,7 +2191,7 @@ function ensureRealDirectoryTree(root, targetDir) {
|
|
|
2088
2191
|
if (part === "..") {
|
|
2089
2192
|
throw new ActivationLedgerError(`activation ledger path contains '..': ${absoluteTarget}`);
|
|
2090
2193
|
}
|
|
2091
|
-
lexicalCursor =
|
|
2194
|
+
lexicalCursor = join4(lexicalCursor, part);
|
|
2092
2195
|
let st;
|
|
2093
2196
|
try {
|
|
2094
2197
|
st = lstatSync(lexicalCursor);
|
|
@@ -2211,7 +2314,7 @@ var init_sitian_contracts = __esm({
|
|
|
2211
2314
|
// src/sitian-appender.ts
|
|
2212
2315
|
import { randomUUID } from "node:crypto";
|
|
2213
2316
|
import { appendFileSync } from "node:fs";
|
|
2214
|
-
import { dirname as dirname3, join as
|
|
2317
|
+
import { dirname as dirname3, join as join5 } from "node:path";
|
|
2215
2318
|
function appendSitianRecordBlock(input, block) {
|
|
2216
2319
|
if (block === "") return;
|
|
2217
2320
|
try {
|
|
@@ -2233,8 +2336,8 @@ function resolveSitianVolumeCategory(kind) {
|
|
|
2233
2336
|
return kind;
|
|
2234
2337
|
}
|
|
2235
2338
|
function ticketProvenanceUnderBookPaths(ledgerHome, bookKey, ticketId) {
|
|
2236
|
-
const sessionDir =
|
|
2237
|
-
return { sessionDir, recordFile:
|
|
2339
|
+
const sessionDir = join5(activationBookDirectory(ledgerHome, bookKey), ticketId);
|
|
2340
|
+
return { sessionDir, recordFile: join5(sessionDir, SITIAN_RECORDS_LEAF) };
|
|
2238
2341
|
}
|
|
2239
2342
|
function resolveSitianRecordPathInLedger(input, ledgerHome) {
|
|
2240
2343
|
const category = resolveSitianVolumeCategory(input.kind);
|
|
@@ -2251,13 +2354,13 @@ function resolveSitianRecordPathInLedger(input, ledgerHome) {
|
|
|
2251
2354
|
recordFile = paths.recordFile;
|
|
2252
2355
|
} else if (category === "ticket-provenance" && input.runDirectory !== void 0) {
|
|
2253
2356
|
sessionDir = input.runDirectory;
|
|
2254
|
-
recordFile =
|
|
2357
|
+
recordFile = join5(sessionDir, SITIAN_RECORDS_LEAF);
|
|
2255
2358
|
} else {
|
|
2256
2359
|
if (input.sessionParent === void 0 || input.sessionParent.length === 0 || !physicallyContainedIn(ledgerHome, input.sessionParent)) {
|
|
2257
2360
|
throw new Error("Sitian record ownership requires a parent session inside the ledger home");
|
|
2258
2361
|
}
|
|
2259
|
-
sessionDir =
|
|
2260
|
-
recordFile =
|
|
2362
|
+
sessionDir = join5(dirname3(input.sessionParent), category);
|
|
2363
|
+
recordFile = join5(sessionDir, SITIAN_RECORDS_LEAF);
|
|
2261
2364
|
}
|
|
2262
2365
|
if (!physicallyContainedIn(ledgerHome, sessionDir)) {
|
|
2263
2366
|
throw new Error("Sitian record ownership requires a directory inside the ledger home");
|
|
@@ -2386,7 +2489,7 @@ var init_sitian_facade = __esm({
|
|
|
2386
2489
|
|
|
2387
2490
|
// src/role-run-placement.ts
|
|
2388
2491
|
import { readdir } from "node:fs/promises";
|
|
2389
|
-
import { join as
|
|
2492
|
+
import { join as join6 } from "node:path";
|
|
2390
2493
|
function isMissingPathError(error) {
|
|
2391
2494
|
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
2392
2495
|
}
|
|
@@ -2403,13 +2506,13 @@ async function listBookRunDirectories(bookDir) {
|
|
|
2403
2506
|
}
|
|
2404
2507
|
for (const entry of entries) {
|
|
2405
2508
|
if (!entry.isDirectory()) continue;
|
|
2406
|
-
const runDir =
|
|
2509
|
+
const runDir = join6(runsDir, entry.name);
|
|
2407
2510
|
if (seen.has(runDir)) continue;
|
|
2408
2511
|
seen.add(runDir);
|
|
2409
2512
|
out.push(runDir);
|
|
2410
2513
|
}
|
|
2411
2514
|
};
|
|
2412
|
-
await collect(
|
|
2515
|
+
await collect(join6(bookDir, "runs"));
|
|
2413
2516
|
let subjects;
|
|
2414
2517
|
try {
|
|
2415
2518
|
subjects = await readdir(bookDir, { withFileTypes: true });
|
|
@@ -2419,7 +2522,7 @@ async function listBookRunDirectories(bookDir) {
|
|
|
2419
2522
|
}
|
|
2420
2523
|
for (const subject of subjects) {
|
|
2421
2524
|
if (!subject.isDirectory() || subject.name === "runs") continue;
|
|
2422
|
-
await collect(
|
|
2525
|
+
await collect(join6(bookDir, subject.name, "runs"));
|
|
2423
2526
|
}
|
|
2424
2527
|
return out.sort();
|
|
2425
2528
|
}
|
|
@@ -2428,23 +2531,23 @@ function roleRunPlacement(ledgerHome, input) {
|
|
|
2428
2531
|
input.subject.ticketNumber,
|
|
2429
2532
|
"roleRunPlacement subject.ticketNumber"
|
|
2430
2533
|
)) : "unbound";
|
|
2431
|
-
const runDirectory =
|
|
2534
|
+
const runDirectory = join6(
|
|
2432
2535
|
activationBookDirectory(ledgerHome, input.bookKey),
|
|
2433
2536
|
subjectDirectory,
|
|
2434
2537
|
"runs",
|
|
2435
2538
|
`${input.runId}@${input.role}`
|
|
2436
2539
|
);
|
|
2437
|
-
const sessionDirectory =
|
|
2540
|
+
const sessionDirectory = join6(runDirectory, "session");
|
|
2438
2541
|
return {
|
|
2439
2542
|
runDirectory,
|
|
2440
2543
|
sessionDirectory,
|
|
2441
|
-
sessionFile:
|
|
2544
|
+
sessionFile: join6(sessionDirectory, "session.jsonl"),
|
|
2442
2545
|
artifactsDirectory: roleRunArtifactsDirectory(runDirectory),
|
|
2443
|
-
attachmentsDirectory:
|
|
2546
|
+
attachmentsDirectory: join6(runDirectory, "attachments")
|
|
2444
2547
|
};
|
|
2445
2548
|
}
|
|
2446
2549
|
function roleRunArtifactsDirectory(runDirectory) {
|
|
2447
|
-
return
|
|
2550
|
+
return join6(runDirectory, "artifacts");
|
|
2448
2551
|
}
|
|
2449
2552
|
function ensureRoleRunDirectory(ledgerHome, directory) {
|
|
2450
2553
|
return ensureRealDirectoryTree(ledgerHome, directory);
|
|
@@ -2476,7 +2579,7 @@ __export(run_terminal_artifacts_exports, {
|
|
|
2476
2579
|
runIdFromRunDirectory: () => runIdFromRunDirectory
|
|
2477
2580
|
});
|
|
2478
2581
|
import { readdir as readdir2, readFile as readFile3 } from "node:fs/promises";
|
|
2479
|
-
import { basename as basename3, dirname as dirname4, join as
|
|
2582
|
+
import { basename as basename3, dirname as dirname4, join as join7 } from "node:path";
|
|
2480
2583
|
function isMissingPathError2(error) {
|
|
2481
2584
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
2482
2585
|
}
|
|
@@ -2551,7 +2654,7 @@ async function listUniqueErrorFallbackPaths(directories) {
|
|
|
2551
2654
|
}
|
|
2552
2655
|
for (const name of names.sort((a, b) => a.localeCompare(b))) {
|
|
2553
2656
|
if (!UNIQUE_ERROR_FALLBACK_NAME.test(name)) continue;
|
|
2554
|
-
found.push(
|
|
2657
|
+
found.push(join7(dir, name));
|
|
2555
2658
|
}
|
|
2556
2659
|
}
|
|
2557
2660
|
return found;
|
|
@@ -2597,11 +2700,11 @@ async function readRunTerminalArtifact(runDirectory) {
|
|
|
2597
2700
|
unreadable.push(read);
|
|
2598
2701
|
};
|
|
2599
2702
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
2600
|
-
consider(await readTerminalArtifactAtPath(
|
|
2703
|
+
consider(await readTerminalArtifactAtPath(join7(artifactsDir, file), file));
|
|
2601
2704
|
}
|
|
2602
2705
|
for (const relative4 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
2603
2706
|
consider(
|
|
2604
|
-
await readTerminalArtifactAtPath(
|
|
2707
|
+
await readTerminalArtifactAtPath(join7(runDirectory, relative4), "error.json")
|
|
2605
2708
|
);
|
|
2606
2709
|
}
|
|
2607
2710
|
for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
|
|
@@ -2663,9 +2766,9 @@ var init_cli_errors = __esm({
|
|
|
2663
2766
|
|
|
2664
2767
|
// src/typed-provider-http.ts
|
|
2665
2768
|
import { readFile as readFile4, unlink, writeFile as writeFile2 } from "node:fs/promises";
|
|
2666
|
-
import { join as
|
|
2769
|
+
import { join as join8 } from "node:path";
|
|
2667
2770
|
function typedProviderHttpPath(runDirectory) {
|
|
2668
|
-
return
|
|
2771
|
+
return join8(runDirectory, TYPED_HTTP_FILE);
|
|
2669
2772
|
}
|
|
2670
2773
|
async function clearTypedProviderHttpObservation(runDirectory) {
|
|
2671
2774
|
try {
|
|
@@ -2809,7 +2912,7 @@ __export(auditor_dossier_tool_exports, {
|
|
|
2809
2912
|
auditorRunDirectory: () => auditorRunDirectory,
|
|
2810
2913
|
createAuditorDossierTool: () => createAuditorDossierTool
|
|
2811
2914
|
});
|
|
2812
|
-
import { dirname as dirname5, join as
|
|
2915
|
+
import { dirname as dirname5, join as join9, resolve as resolve3 } from "node:path";
|
|
2813
2916
|
import { Type as Type10 } from "typebox";
|
|
2814
2917
|
function auditorRunDirectory(context) {
|
|
2815
2918
|
const sessionFile = context.sessionManager?.getSessionFile?.();
|
|
@@ -2832,9 +2935,9 @@ function createAuditorDossierTool(runDirectory) {
|
|
|
2832
2935
|
}
|
|
2833
2936
|
const details = {
|
|
2834
2937
|
runDirectory,
|
|
2835
|
-
admittedRequest:
|
|
2836
|
-
parentSessionCandidate:
|
|
2837
|
-
attachments:
|
|
2938
|
+
admittedRequest: join9(runDirectory, "admitted-request.json"),
|
|
2939
|
+
parentSessionCandidate: join9(runDirectory, "session", "session.jsonl"),
|
|
2940
|
+
attachments: join9(runDirectory, "attachments"),
|
|
2838
2941
|
artifacts: roleRunArtifactsDirectory(runDirectory)
|
|
2839
2942
|
};
|
|
2840
2943
|
return {
|
|
@@ -3250,7 +3353,7 @@ __export(session_assistant_usage_exports, {
|
|
|
3250
3353
|
sessionFileFromPublicSummon: () => sessionFileFromPublicSummon,
|
|
3251
3354
|
usageFromPublicSummon: () => usageFromPublicSummon
|
|
3252
3355
|
});
|
|
3253
|
-
import { join as
|
|
3356
|
+
import { join as join10 } from "node:path";
|
|
3254
3357
|
async function readAssistantUsageFromSessionFile(sessionFile) {
|
|
3255
3358
|
const { readFile: readFile25 } = await import("node:fs/promises");
|
|
3256
3359
|
let text;
|
|
@@ -3320,7 +3423,7 @@ async function readAssistantUsageFromSessionFile(sessionFile) {
|
|
|
3320
3423
|
}
|
|
3321
3424
|
function sessionFileFromPublicSummon(summoned) {
|
|
3322
3425
|
if (typeof summoned.runDirectory === "string" && summoned.runDirectory.trim() !== "") {
|
|
3323
|
-
return
|
|
3426
|
+
return join10(summoned.runDirectory, "session", "session.jsonl");
|
|
3324
3427
|
}
|
|
3325
3428
|
const fromArtifacts = summoned.terminal?.artifacts?.map((a) => a.path).find((p) => typeof p === "string" && p.endsWith("session.jsonl"));
|
|
3326
3429
|
if (fromArtifacts !== void 0) return fromArtifacts;
|
|
@@ -3329,7 +3432,7 @@ function sessionFileFromPublicSummon(summoned) {
|
|
|
3329
3432
|
const facts = outcome.decisiveFacts;
|
|
3330
3433
|
const pointer = facts?.runPointer;
|
|
3331
3434
|
if (typeof pointer === "string" && pointer.trim() !== "") {
|
|
3332
|
-
return
|
|
3435
|
+
return join10(pointer, "session", "session.jsonl");
|
|
3333
3436
|
}
|
|
3334
3437
|
return void 0;
|
|
3335
3438
|
}
|
|
@@ -3346,7 +3449,7 @@ var init_session_assistant_usage = __esm({
|
|
|
3346
3449
|
|
|
3347
3450
|
// src/package-resources/engine-material.ts
|
|
3348
3451
|
import { existsSync as existsSync2, readdirSync } from "node:fs";
|
|
3349
|
-
import { join as
|
|
3452
|
+
import { join as join11 } from "node:path";
|
|
3350
3453
|
function pickEngineAxis(source) {
|
|
3351
3454
|
return {
|
|
3352
3455
|
...source.engine === void 0 ? {} : { engine: source.engine },
|
|
@@ -3367,11 +3470,11 @@ function isEngineNameSyntax(name) {
|
|
|
3367
3470
|
return true;
|
|
3368
3471
|
}
|
|
3369
3472
|
function resolveEngineMaterialDirectory(packageRoot) {
|
|
3370
|
-
return
|
|
3473
|
+
return join11(packageRoot, ENGINE_MATERIAL_RELATIVE_ROOT);
|
|
3371
3474
|
}
|
|
3372
3475
|
function resolveEngineMaterialPath(packageRoot, name) {
|
|
3373
3476
|
const legal = assertLegalEngineName(name);
|
|
3374
|
-
return
|
|
3477
|
+
return join11(resolveEngineMaterialDirectory(packageRoot), `${legal}.md`);
|
|
3375
3478
|
}
|
|
3376
3479
|
function assertLegalEngineName(name) {
|
|
3377
3480
|
if (!isEngineNameSyntax(name)) {
|
|
@@ -3428,7 +3531,7 @@ __export(durable_principal_exports, {
|
|
|
3428
3531
|
issuePiDurablePrincipalCoordinates: () => issuePiDurablePrincipalCoordinates,
|
|
3429
3532
|
piDurablePrincipalAuthority: () => piDurablePrincipalAuthority
|
|
3430
3533
|
});
|
|
3431
|
-
import { join as
|
|
3534
|
+
import { join as join12 } from "node:path";
|
|
3432
3535
|
function encode(coordinates) {
|
|
3433
3536
|
return coordinates;
|
|
3434
3537
|
}
|
|
@@ -3478,7 +3581,7 @@ var init_durable_principal = __esm({
|
|
|
3478
3581
|
}
|
|
3479
3582
|
return {
|
|
3480
3583
|
sessionDirectory: record4.sessionDirectory,
|
|
3481
|
-
sessionFile: typeof record4.sessionFile === "string" && record4.sessionFile.trim() !== "" ? record4.sessionFile :
|
|
3584
|
+
sessionFile: typeof record4.sessionFile === "string" && record4.sessionFile.trim() !== "" ? record4.sessionFile : join12(record4.sessionDirectory, "session.jsonl")
|
|
3482
3585
|
};
|
|
3483
3586
|
}
|
|
3484
3587
|
};
|
|
@@ -3541,12 +3644,12 @@ __export(role_turn_host_exports, {
|
|
|
3541
3644
|
import { execFile, spawn as spawn2 } from "node:child_process";
|
|
3542
3645
|
import { constants } from "node:fs";
|
|
3543
3646
|
import { access, appendFile, readFile as readFile6, realpath } from "node:fs/promises";
|
|
3544
|
-
import { delimiter, dirname as dirname6, isAbsolute as isAbsolute3, join as
|
|
3647
|
+
import { delimiter, dirname as dirname6, isAbsolute as isAbsolute3, join as join13, resolve as resolve4 } from "node:path";
|
|
3545
3648
|
import { platform } from "node:process";
|
|
3546
3649
|
import { promisify } from "node:util";
|
|
3547
3650
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
3548
3651
|
function resolveInternalRoleEntrypoint(packageRoot) {
|
|
3549
|
-
return
|
|
3652
|
+
return join13(packageRoot, INTERNAL_ROLE_ENTRYPOINT_RELATIVE);
|
|
3550
3653
|
}
|
|
3551
3654
|
function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
|
|
3552
3655
|
return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
|
|
@@ -3842,105 +3945,6 @@ var init_role_turn_host = __esm({
|
|
|
3842
3945
|
}
|
|
3843
3946
|
});
|
|
3844
3947
|
|
|
3845
|
-
// src/host-descriptions.ts
|
|
3846
|
-
function lookupHostDescription(host) {
|
|
3847
|
-
return Object.hasOwn(HOST_DESCRIPTIONS, host) ? HOST_DESCRIPTIONS[host] : void 0;
|
|
3848
|
-
}
|
|
3849
|
-
function lookupHeadlessHostDescription(host) {
|
|
3850
|
-
return Object.hasOwn(HEADLESS_HOST_DESCRIPTIONS, host) ? HEADLESS_HOST_DESCRIPTIONS[host] : void 0;
|
|
3851
|
-
}
|
|
3852
|
-
function lookupHostFamily(host) {
|
|
3853
|
-
if (lookupHostDescription(host) !== void 0) return "acp";
|
|
3854
|
-
if (lookupHeadlessHostDescription(host) !== void 0) return "headless";
|
|
3855
|
-
return void 0;
|
|
3856
|
-
}
|
|
3857
|
-
function packagedExternalHostNames() {
|
|
3858
|
-
return [...Object.keys(HOST_DESCRIPTIONS), ...Object.keys(HEADLESS_HOST_DESCRIPTIONS)];
|
|
3859
|
-
}
|
|
3860
|
-
function assertRegisteredHostName(host) {
|
|
3861
|
-
if (host === DEFAULT_ROLE_TURN_HOST || lookupHostFamily(host) !== void 0) {
|
|
3862
|
-
return host;
|
|
3863
|
-
}
|
|
3864
|
-
throw new Error(`unregistered host: ${host}`);
|
|
3865
|
-
}
|
|
3866
|
-
var DEFAULT_ROLE_TURN_HOST, HOST_DESCRIPTIONS, HEADLESS_HOST_DESCRIPTIONS;
|
|
3867
|
-
var init_host_descriptions = __esm({
|
|
3868
|
-
"src/host-descriptions.ts"() {
|
|
3869
|
-
"use strict";
|
|
3870
|
-
DEFAULT_ROLE_TURN_HOST = "pi";
|
|
3871
|
-
HOST_DESCRIPTIONS = Object.freeze({
|
|
3872
|
-
/** Operator home `~/.grok`, native session/load resume, `agent [--model X] stdio`. */
|
|
3873
|
-
"grok-build": Object.freeze({
|
|
3874
|
-
binaryFromHome: Object.freeze([".grok", "bin", "grok"]),
|
|
3875
|
-
argv: Object.freeze({
|
|
3876
|
-
prefix: Object.freeze(["agent"]),
|
|
3877
|
-
suffix: Object.freeze(["stdio"]),
|
|
3878
|
-
modelFlag: "--model"
|
|
3879
|
-
}),
|
|
3880
|
-
modelPassing: "argv",
|
|
3881
|
-
sessionBindingFile: "grok-acp-session.json"
|
|
3882
|
-
}),
|
|
3883
|
-
/**
|
|
3884
|
-
* Operator home `~/.hermes`, native session/load resume, `acp` subcommand.
|
|
3885
|
-
* Model arrives as an ACP `session/set_model` RPC with modelId `provider:model`
|
|
3886
|
-
* (seat table provider + model concatenated). Reasoning is the global
|
|
3887
|
-
* `--reasoning` flag before `acp`. Soul is the seat profile SOUL.md symlink
|
|
3888
|
-
* (`hermes -p ak-<role> …`); package `souls/<role>.md` is the sole source.
|
|
3889
|
-
*/
|
|
3890
|
-
"hermes": Object.freeze({
|
|
3891
|
-
binaryFromHome: Object.freeze([".local", "bin", "hermes"]),
|
|
3892
|
-
argv: Object.freeze({
|
|
3893
|
-
prefix: Object.freeze(["acp"]),
|
|
3894
|
-
suffix: Object.freeze([]),
|
|
3895
|
-
thinkingFlag: "--reasoning"
|
|
3896
|
-
}),
|
|
3897
|
-
modelPassing: "set_model",
|
|
3898
|
-
sessionBindingFile: "hermes-acp-session.json",
|
|
3899
|
-
seatProfileSoul: Object.freeze({
|
|
3900
|
-
flag: "-p",
|
|
3901
|
-
namePrefix: "ak-",
|
|
3902
|
-
profilesRootFromHome: Object.freeze([".hermes", "profiles"]),
|
|
3903
|
-
soulFileName: "SOUL.md"
|
|
3904
|
-
})
|
|
3905
|
-
})
|
|
3906
|
-
});
|
|
3907
|
-
HEADLESS_HOST_DESCRIPTIONS = Object.freeze({
|
|
3908
|
-
"claude": Object.freeze({
|
|
3909
|
-
protocol: "claude-print",
|
|
3910
|
-
binaryFromHome: Object.freeze([".local", "bin", "claude"]),
|
|
3911
|
-
sessionBindingFile: "claude-headless-session.json",
|
|
3912
|
-
fixedArgs: Object.freeze([
|
|
3913
|
-
// Live NDJSON events → sitian host-session records (#811); last line is the result receipt.
|
|
3914
|
-
"--output-format",
|
|
3915
|
-
"stream-json",
|
|
3916
|
-
// Intermediate assistant/tool/system events require verbose with stream-json.
|
|
3917
|
-
"--verbose",
|
|
3918
|
-
"--permission-mode",
|
|
3919
|
-
"bypassPermissions"
|
|
3920
|
-
]),
|
|
3921
|
-
promptFlag: "-p",
|
|
3922
|
-
modelFlag: "--model",
|
|
3923
|
-
effortFlag: "--effort",
|
|
3924
|
-
// File path keeps large role envelopes off ARG_MAX.
|
|
3925
|
-
systemPromptFlag: "--system-prompt-file",
|
|
3926
|
-
jsonSchemaFlag: "--json-schema",
|
|
3927
|
-
mcpConfigFlag: "--mcp-config",
|
|
3928
|
-
sessionIdFlag: "--session-id",
|
|
3929
|
-
resumeFlag: "--resume"
|
|
3930
|
-
}),
|
|
3931
|
-
/**
|
|
3932
|
-
* Codex headless (#646). Binary under operator home; auth stays in CODEX_HOME.
|
|
3933
|
-
* Argv/parse/schema-close are codex-exec helpers — not Claude flag mapping.
|
|
3934
|
-
*/
|
|
3935
|
-
"codex": Object.freeze({
|
|
3936
|
-
protocol: "codex-exec",
|
|
3937
|
-
binaryFromHome: Object.freeze([".local", "bin", "codex"]),
|
|
3938
|
-
sessionBindingFile: "codex-headless-session.json"
|
|
3939
|
-
})
|
|
3940
|
-
});
|
|
3941
|
-
}
|
|
3942
|
-
});
|
|
3943
|
-
|
|
3944
3948
|
// src/sha256.ts
|
|
3945
3949
|
import { createHash as createHash2 } from "node:crypto";
|
|
3946
3950
|
function sha256Hex(bytes) {
|
|
@@ -4656,13 +4660,13 @@ var init_session_dialogue = __esm({
|
|
|
4656
4660
|
|
|
4657
4661
|
// src/ticket-provenance.ts
|
|
4658
4662
|
import { readFile as readFile10, unlink as unlink2 } from "node:fs/promises";
|
|
4659
|
-
import { basename as basename4, dirname as dirname8, join as
|
|
4663
|
+
import { basename as basename4, dirname as dirname8, join as join14, resolve as resolve7 } from "node:path";
|
|
4660
4664
|
function dialogueSessionSourceRoots(home) {
|
|
4661
4665
|
const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
|
|
4662
4666
|
return [
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4667
|
+
join14(machineHome, ".claude", "projects"),
|
|
4668
|
+
join14(machineHome, ".codex", "sessions"),
|
|
4669
|
+
join14(machineHome, ".pi", "agent", "sessions")
|
|
4666
4670
|
];
|
|
4667
4671
|
}
|
|
4668
4672
|
function isLedgerRoleSessionFile(absolute, home) {
|
|
@@ -4700,7 +4704,7 @@ function ticketProvenanceRecordInput(ticketNumber, cwd, home, runDirectory) {
|
|
|
4700
4704
|
};
|
|
4701
4705
|
}
|
|
4702
4706
|
async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, home) {
|
|
4703
|
-
const source =
|
|
4707
|
+
const source = join14(runDirectory, "records.jsonl");
|
|
4704
4708
|
let content;
|
|
4705
4709
|
try {
|
|
4706
4710
|
content = await readFile10(source, "utf8");
|
|
@@ -4910,7 +4914,7 @@ var init_uuidv7 = __esm({
|
|
|
4910
4914
|
});
|
|
4911
4915
|
|
|
4912
4916
|
// src/notary-source-run.ts
|
|
4913
|
-
import { dirname as dirname9, isAbsolute as isAbsolute5, join as
|
|
4917
|
+
import { dirname as dirname9, isAbsolute as isAbsolute5, join as join15, resolve as resolve8, basename as basename5 } from "node:path";
|
|
4914
4918
|
import { lstat, realpath as realpath3 } from "node:fs/promises";
|
|
4915
4919
|
async function readRetainedIdentity(runDirectory) {
|
|
4916
4920
|
try {
|
|
@@ -4967,11 +4971,11 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
4967
4971
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
4968
4972
|
const bookKey = resolveBookKeyFromGit(options.projectRoot);
|
|
4969
4973
|
const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
|
|
4970
|
-
const bookRunsRoot =
|
|
4974
|
+
const bookRunsRoot = join15(bookDirectory, "runs");
|
|
4971
4975
|
let candidate;
|
|
4972
4976
|
const bare = parseRunDirectoryName(raw);
|
|
4973
4977
|
if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
|
|
4974
|
-
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ??
|
|
4978
|
+
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join15(bookRunsRoot, `${bare.runId}@${bare.role}`);
|
|
4975
4979
|
} else {
|
|
4976
4980
|
candidate = isAbsolute5(raw) ? raw : resolve8(options.projectRoot, raw);
|
|
4977
4981
|
const identity2 = parseRunDirectoryName(basename5(candidate));
|
|
@@ -6186,7 +6190,7 @@ import {
|
|
|
6186
6190
|
writeFile as writeFile3
|
|
6187
6191
|
} from "node:fs/promises";
|
|
6188
6192
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
6189
|
-
import { basename as basename6, dirname as dirname10, isAbsolute as isAbsolute6, join as
|
|
6193
|
+
import { basename as basename6, dirname as dirname10, isAbsolute as isAbsolute6, join as join16, resolve as resolve9, sep as sep3 } from "node:path";
|
|
6190
6194
|
function issueAdmissionPlacement(authority, request) {
|
|
6191
6195
|
const ledgerHome = resolveActivationLedgerHome(request.home);
|
|
6192
6196
|
const bookKey = resolveBookKeyFromGit(request.cwd);
|
|
@@ -6240,14 +6244,14 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
|
|
|
6240
6244
|
...effectiveModelLedgerFields(effectiveModel)
|
|
6241
6245
|
};
|
|
6242
6246
|
await writeFile3(
|
|
6243
|
-
|
|
6247
|
+
join16(source.runDirectory, "invocation.json"),
|
|
6244
6248
|
`${JSON.stringify(identity, null, 2)}
|
|
6245
6249
|
`,
|
|
6246
6250
|
"utf8"
|
|
6247
6251
|
);
|
|
6248
6252
|
}
|
|
6249
6253
|
async function recordEffectiveInvocationModel(runDirectory, model, engine, host, engineModel) {
|
|
6250
|
-
const ledgerPath =
|
|
6254
|
+
const ledgerPath = join16(runDirectory, "invocation.json");
|
|
6251
6255
|
const current = JSON.parse(await readFile11(ledgerPath, "utf8"));
|
|
6252
6256
|
const next = { ...current };
|
|
6253
6257
|
if (model !== void 0) {
|
|
@@ -6280,7 +6284,7 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host,
|
|
|
6280
6284
|
);
|
|
6281
6285
|
}
|
|
6282
6286
|
async function mergeInvocationIdentityPage(runDirectory, fields) {
|
|
6283
|
-
const ledgerPath =
|
|
6287
|
+
const ledgerPath = join16(runDirectory, "invocation.json");
|
|
6284
6288
|
const current = JSON.parse(await readFile11(ledgerPath, "utf8"));
|
|
6285
6289
|
await writeFile3(
|
|
6286
6290
|
ledgerPath,
|
|
@@ -6363,7 +6367,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
6363
6367
|
const childRunIds = parentPage.childDiaristRunIds;
|
|
6364
6368
|
for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
|
|
6365
6369
|
if (typeof childRunId !== "string") continue;
|
|
6366
|
-
const childDirectory =
|
|
6370
|
+
const childDirectory = join16(dirname10(oldRunDirectory), `${childRunId}@diarist`);
|
|
6367
6371
|
if (!existsSync3(childDirectory)) continue;
|
|
6368
6372
|
const childTarget = roleRunPlacement(ledgerHome, {
|
|
6369
6373
|
bookKey: admitted.bookKey,
|
|
@@ -6420,7 +6424,7 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
|
6420
6424
|
ticketNumber,
|
|
6421
6425
|
"bindTicketNumberOnRunDirectory"
|
|
6422
6426
|
);
|
|
6423
|
-
const admittedPath =
|
|
6427
|
+
const admittedPath = join16(runDirectory, "admitted-request.json");
|
|
6424
6428
|
const admitted = JSON.parse(await readFile11(admittedPath, "utf8"));
|
|
6425
6429
|
if (admitted.ticketNumber === ticketNumber) return;
|
|
6426
6430
|
await writeFile3(
|
|
@@ -6440,7 +6444,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
6440
6444
|
async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
|
|
6441
6445
|
const rolePackageRoot = packageRoot;
|
|
6442
6446
|
const raw = JSON.parse(
|
|
6443
|
-
await readFile11(
|
|
6447
|
+
await readFile11(join16(rolePackageRoot, "package.json"), "utf8")
|
|
6444
6448
|
);
|
|
6445
6449
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
6446
6450
|
throw new Error(
|
|
@@ -6728,13 +6732,13 @@ async function removePreparedAttachmentDirectory(stagingDirectory) {
|
|
|
6728
6732
|
}
|
|
6729
6733
|
async function withPreparedAttachments(attachmentPaths, use) {
|
|
6730
6734
|
if (attachmentPaths.length === 0) return await use([]);
|
|
6731
|
-
const stagingDirectory = await mkdtemp2(
|
|
6735
|
+
const stagingDirectory = await mkdtemp2(join16(tmpdir2(), "ak-role-attachments-"));
|
|
6732
6736
|
const prepared = [];
|
|
6733
6737
|
let result;
|
|
6734
6738
|
try {
|
|
6735
6739
|
for (let index = 0; index < attachmentPaths.length; index += 1) {
|
|
6736
6740
|
const { absolute, bytes } = await readRegularFileAttachment(attachmentPaths[index]);
|
|
6737
|
-
const snapshotPath =
|
|
6741
|
+
const snapshotPath = join16(stagingDirectory, String(index).padStart(6, "0"));
|
|
6738
6742
|
await writeFile3(snapshotPath, bytes);
|
|
6739
6743
|
prepared.push({ absolute, snapshotPath });
|
|
6740
6744
|
}
|
|
@@ -6755,7 +6759,7 @@ async function withPreparedAttachments(attachmentPaths, use) {
|
|
|
6755
6759
|
return result;
|
|
6756
6760
|
}
|
|
6757
6761
|
async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, index) {
|
|
6758
|
-
const frozenPath =
|
|
6762
|
+
const frozenPath = join16(
|
|
6759
6763
|
destinationDir,
|
|
6760
6764
|
`${String(index).padStart(2, "0")}-${basename6(provenancePath)}`
|
|
6761
6765
|
);
|
|
@@ -6798,14 +6802,14 @@ async function freezeAttachments(attachmentPaths, attachmentsDirectory) {
|
|
|
6798
6802
|
async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKey = `s-${Date.now().toString(36)}`) {
|
|
6799
6803
|
if (attachmentPaths.length === 0) return [];
|
|
6800
6804
|
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
6801
|
-
const attachmentsDirectory =
|
|
6805
|
+
const attachmentsDirectory = join16(runDirectory, "attachments", summonsKey);
|
|
6802
6806
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
6803
6807
|
return freezeAttachments(attachmentPaths, attachmentsDirectory);
|
|
6804
6808
|
}
|
|
6805
6809
|
async function freezePreparedAttachmentsIntoRun(prepared, runDirectory, summonsKey) {
|
|
6806
6810
|
if (prepared.length === 0) return [];
|
|
6807
6811
|
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
6808
|
-
const attachmentsDirectory = summonsKey === void 0 ?
|
|
6812
|
+
const attachmentsDirectory = summonsKey === void 0 ? join16(runDirectory, "attachments") : join16(runDirectory, "attachments", summonsKey);
|
|
6809
6813
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
6810
6814
|
const attachments = [];
|
|
6811
6815
|
for (let index = 0; index < prepared.length; index += 1) {
|
|
@@ -6882,7 +6886,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
6882
6886
|
attachmentPaths,
|
|
6883
6887
|
...project,
|
|
6884
6888
|
placedFields: async (placed) => {
|
|
6885
|
-
const taskPath =
|
|
6889
|
+
const taskPath = join16(placed.runDirectory, "task.md");
|
|
6886
6890
|
await writeFile3(taskPath, instruction, "utf8");
|
|
6887
6891
|
return { phase, taskPath };
|
|
6888
6892
|
}
|
|
@@ -6928,7 +6932,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
6928
6932
|
placedFields: async (placed) => {
|
|
6929
6933
|
let prerequisitesPath;
|
|
6930
6934
|
if (prerequisitesSource !== void 0) {
|
|
6931
|
-
prerequisitesPath =
|
|
6935
|
+
prerequisitesPath = join16(placed.runDirectory, "prerequisites.json");
|
|
6932
6936
|
await writeFile3(
|
|
6933
6937
|
prerequisitesPath,
|
|
6934
6938
|
`${JSON.stringify(prerequisites, null, 2)}
|
|
@@ -6936,7 +6940,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
6936
6940
|
"utf8"
|
|
6937
6941
|
);
|
|
6938
6942
|
}
|
|
6939
|
-
const packetPath =
|
|
6943
|
+
const packetPath = join16(placed.runDirectory, "fix-packet.md");
|
|
6940
6944
|
await writeFile3(packetPath, instruction, "utf8");
|
|
6941
6945
|
return {
|
|
6942
6946
|
phase,
|
|
@@ -6994,7 +6998,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
6994
6998
|
placedFields: async (placed) => {
|
|
6995
6999
|
let requestManifestPath;
|
|
6996
7000
|
if (manifestCanonicalJson !== void 0) {
|
|
6997
|
-
requestManifestPath =
|
|
7001
|
+
requestManifestPath = join16(placed.runDirectory, "request-manifest.json");
|
|
6998
7002
|
await writeFile3(requestManifestPath, manifestCanonicalJson, "utf8");
|
|
6999
7003
|
}
|
|
7000
7004
|
return {
|
|
@@ -7184,7 +7188,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7184
7188
|
resolutionScope: [...derived.resolutionScope],
|
|
7185
7189
|
authorizedChecks: []
|
|
7186
7190
|
});
|
|
7187
|
-
const mergerInputPath =
|
|
7191
|
+
const mergerInputPath = join16(placed.runDirectory, "merger-input.json");
|
|
7188
7192
|
await writeFile3(
|
|
7189
7193
|
mergerInputPath,
|
|
7190
7194
|
`${JSON.stringify(mergerInput, null, 2)}
|
|
@@ -7258,7 +7262,7 @@ function persistedAttachmentRefs(attachments) {
|
|
|
7258
7262
|
}));
|
|
7259
7263
|
}
|
|
7260
7264
|
async function persistPlacedAdmission(admitted, placed, model) {
|
|
7261
|
-
const admittedRequestPath =
|
|
7265
|
+
const admittedRequestPath = join16(placed.runDirectory, "admitted-request.json");
|
|
7262
7266
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
7263
7267
|
sessionDirectory: placed.sessionDirectory,
|
|
7264
7268
|
sessionFile: placed.sessionFile
|
|
@@ -7311,7 +7315,7 @@ async function admitStandardMaterialInvocation(role, options) {
|
|
|
7311
7315
|
attachments: persistedAttachmentRefs(placed.attachments),
|
|
7312
7316
|
...placed.ticketFields
|
|
7313
7317
|
};
|
|
7314
|
-
const admittedRequestPath = defer ?
|
|
7318
|
+
const admittedRequestPath = defer ? join16(placed.runDirectory, "admitted-request.json") : await persistPlacedAdmission(admitted, placed, options.model);
|
|
7315
7319
|
return {
|
|
7316
7320
|
role,
|
|
7317
7321
|
runId: placed.runId,
|
|
@@ -7389,7 +7393,7 @@ async function materializeCountersignInvocation(admitted, options) {
|
|
|
7389
7393
|
});
|
|
7390
7394
|
const placement = placed;
|
|
7391
7395
|
admitted.runDirectory = placement.runDirectory;
|
|
7392
|
-
admitted.admittedRequestPath =
|
|
7396
|
+
admitted.admittedRequestPath = join16(
|
|
7393
7397
|
placement.runDirectory,
|
|
7394
7398
|
"admitted-request.json"
|
|
7395
7399
|
);
|
|
@@ -7416,7 +7420,7 @@ async function materializeCountersignInvocation(admitted, options) {
|
|
|
7416
7420
|
async function loadAdmittedJudgeRequest(runDirectory) {
|
|
7417
7421
|
try {
|
|
7418
7422
|
const raw = JSON.parse(
|
|
7419
|
-
await readFile11(
|
|
7423
|
+
await readFile11(join16(runDirectory, "admitted-request.json"), "utf8")
|
|
7420
7424
|
);
|
|
7421
7425
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
7422
7426
|
const record4 = raw;
|
|
@@ -7505,7 +7509,7 @@ function parseDoctorIssueNumber(raw) {
|
|
|
7505
7509
|
}
|
|
7506
7510
|
async function resolveDoctorCaseRunsPath(options) {
|
|
7507
7511
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
7508
|
-
const defaultRuns =
|
|
7512
|
+
const defaultRuns = join16(
|
|
7509
7513
|
activationBookDirectory(ledgerHome, options.bookKey),
|
|
7510
7514
|
String(options.issueNumber),
|
|
7511
7515
|
"runs"
|
|
@@ -7826,15 +7830,15 @@ var init_invocation = __esm({
|
|
|
7826
7830
|
|
|
7827
7831
|
// src/public-cli/load-production-acp-host.ts
|
|
7828
7832
|
import { existsSync as existsSync4 } from "node:fs";
|
|
7829
|
-
import { join as
|
|
7833
|
+
import { join as join17 } from "node:path";
|
|
7830
7834
|
import { pathToFileURL } from "node:url";
|
|
7831
7835
|
async function loadProductionAcpHostFactory(packageRoot, host) {
|
|
7832
7836
|
const description = lookupHostDescription(host);
|
|
7833
7837
|
if (description === void 0) {
|
|
7834
7838
|
throw new Error(`unregistered host: ${host}`);
|
|
7835
7839
|
}
|
|
7836
|
-
const built =
|
|
7837
|
-
const source =
|
|
7840
|
+
const built = join17(packageRoot, "dist/acp-host/production-host.js");
|
|
7841
|
+
const source = join17(packageRoot, "src/acp-host/production-host.ts");
|
|
7838
7842
|
const target = existsSync4(built) ? built : source;
|
|
7839
7843
|
const href = pathToFileURL(target).href;
|
|
7840
7844
|
const mod = await import(href);
|
|
@@ -7850,15 +7854,15 @@ var init_load_production_acp_host = __esm({
|
|
|
7850
7854
|
|
|
7851
7855
|
// src/public-cli/load-production-headless-host.ts
|
|
7852
7856
|
import { existsSync as existsSync5 } from "node:fs";
|
|
7853
|
-
import { join as
|
|
7857
|
+
import { join as join18 } from "node:path";
|
|
7854
7858
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
7855
7859
|
async function loadProductionHeadlessHostFactory(packageRoot, host) {
|
|
7856
7860
|
const description = lookupHeadlessHostDescription(host);
|
|
7857
7861
|
if (description === void 0) {
|
|
7858
7862
|
throw new Error(`unregistered headless host: ${host}`);
|
|
7859
7863
|
}
|
|
7860
|
-
const built =
|
|
7861
|
-
const source =
|
|
7864
|
+
const built = join18(packageRoot, "dist/headless-host/production-host.js");
|
|
7865
|
+
const source = join18(packageRoot, "src/headless-host/production-host.ts");
|
|
7862
7866
|
const target = existsSync5(built) ? built : source;
|
|
7863
7867
|
const href = pathToFileURL2(target).href;
|
|
7864
7868
|
const mod = await import(href);
|
|
@@ -7912,8 +7916,8 @@ __export(role_turn_host_resolution_exports, {
|
|
|
7912
7916
|
resolveRoleTurnHost: () => resolveRoleTurnHost,
|
|
7913
7917
|
selectRoleTurnHost: () => selectRoleTurnHost
|
|
7914
7918
|
});
|
|
7915
|
-
function formatHostSelectionFailure(
|
|
7916
|
-
return `${
|
|
7919
|
+
function formatHostSelectionFailure(failure) {
|
|
7920
|
+
return `${failure.kind}: ${failure.host}; seat=${failure.seat}; model=${failure.model}; registered: ${failure.registeredHosts.join(", ")}`;
|
|
7917
7921
|
}
|
|
7918
7922
|
function composeRoleTurnHostAdapters(env, principalAuthority) {
|
|
7919
7923
|
const piHost = env.roleTurnHost ?? createPiRoleTurnHost({
|
|
@@ -7973,9 +7977,9 @@ var init_role_turn_host_resolution = __esm({
|
|
|
7973
7977
|
init_invocation();
|
|
7974
7978
|
init_load_production_external_host();
|
|
7975
7979
|
HostSelectionError = class extends Error {
|
|
7976
|
-
constructor(
|
|
7977
|
-
super(formatHostSelectionFailure(
|
|
7978
|
-
this.failure =
|
|
7980
|
+
constructor(failure) {
|
|
7981
|
+
super(formatHostSelectionFailure(failure));
|
|
7982
|
+
this.failure = failure;
|
|
7979
7983
|
this.name = "HostSelectionError";
|
|
7980
7984
|
}
|
|
7981
7985
|
failure;
|
|
@@ -8037,7 +8041,7 @@ __export(config_exports, {
|
|
|
8037
8041
|
validatePublicCliConfigAxes: () => validatePublicCliConfigAxes
|
|
8038
8042
|
});
|
|
8039
8043
|
import { mkdir, readFile as readFile12, writeFile as writeFile4 } from "node:fs/promises";
|
|
8040
|
-
import { dirname as dirname11, join as
|
|
8044
|
+
import { dirname as dirname11, join as join19 } from "node:path";
|
|
8041
8045
|
function isGateOfficerSeat(value) {
|
|
8042
8046
|
return packagedProvinceConfig(value);
|
|
8043
8047
|
}
|
|
@@ -8045,7 +8049,7 @@ function publicCliConfigPath(home) {
|
|
|
8045
8049
|
if (typeof home !== "string" || home.trim() === "") {
|
|
8046
8050
|
throw new Error("home must be explicitly provided");
|
|
8047
8051
|
}
|
|
8048
|
-
return
|
|
8052
|
+
return join19(home, ".ak-roles", "public-cli.json");
|
|
8049
8053
|
}
|
|
8050
8054
|
async function loadPublicCliConfig(home) {
|
|
8051
8055
|
const path = publicCliConfigPath(home);
|
|
@@ -8508,7 +8512,7 @@ function credentialProvidersFromAuthData(data) {
|
|
|
8508
8512
|
}
|
|
8509
8513
|
async function loadCredentialProviders(agentDir) {
|
|
8510
8514
|
try {
|
|
8511
|
-
const raw = await readFile12(
|
|
8515
|
+
const raw = await readFile12(join19(agentDir, "auth.json"), "utf8");
|
|
8512
8516
|
return credentialProvidersFromAuthData(JSON.parse(raw));
|
|
8513
8517
|
} catch (error) {
|
|
8514
8518
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
@@ -8546,15 +8550,15 @@ __export(host_providers_exports, {
|
|
|
8546
8550
|
renderHostProvidersTable: () => renderHostProvidersTable
|
|
8547
8551
|
});
|
|
8548
8552
|
import { readFileSync } from "node:fs";
|
|
8549
|
-
import { join as
|
|
8553
|
+
import { join as join20 } from "node:path";
|
|
8550
8554
|
function hostProvidersPath(home) {
|
|
8551
8555
|
if (typeof home !== "string" || home.trim() === "") {
|
|
8552
8556
|
throw new Error("home must be explicitly provided");
|
|
8553
8557
|
}
|
|
8554
|
-
return
|
|
8558
|
+
return join20(home, ".ak-roles", "host-providers.json");
|
|
8555
8559
|
}
|
|
8556
8560
|
function hermesProviderModelsCachePath(home) {
|
|
8557
|
-
return
|
|
8561
|
+
return join20(home, ".hermes", "provider_models_cache.json");
|
|
8558
8562
|
}
|
|
8559
8563
|
function parseHostProvidersTable(value) {
|
|
8560
8564
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
@@ -8710,7 +8714,7 @@ var init_host_providers = __esm({
|
|
|
8710
8714
|
|
|
8711
8715
|
// src/analyst-gate-cycles-read.ts
|
|
8712
8716
|
import { readdir as readdir4 } from "node:fs/promises";
|
|
8713
|
-
import { join as
|
|
8717
|
+
import { join as join21 } from "node:path";
|
|
8714
8718
|
function isRecord6(value) {
|
|
8715
8719
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8716
8720
|
}
|
|
@@ -8961,7 +8965,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
|
|
|
8961
8965
|
throw error;
|
|
8962
8966
|
}
|
|
8963
8967
|
for (const name of names) {
|
|
8964
|
-
const path =
|
|
8968
|
+
const path = join21(directory, name);
|
|
8965
8969
|
const fromPointer = name.endsWith(".pointer.json");
|
|
8966
8970
|
const pointer = fromPointer ? await resolveOfficerSessionFromPointerFile(path) : void 0;
|
|
8967
8971
|
const sessionPath = pointer?.sessionFile ?? path;
|
|
@@ -9012,12 +9016,12 @@ var init_audit_escalation = __esm({
|
|
|
9012
9016
|
// src/session-opening-materials.ts
|
|
9013
9017
|
import { existsSync as existsSync6 } from "node:fs";
|
|
9014
9018
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
9015
|
-
import { dirname as dirname12, join as
|
|
9019
|
+
import { dirname as dirname12, join as join22 } from "node:path";
|
|
9016
9020
|
import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
9017
9021
|
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
9018
9022
|
let dir = dirname12(fileURLToPath(moduleUrl));
|
|
9019
9023
|
for (let i = 0; i < 8; i += 1) {
|
|
9020
|
-
if (existsSync6(
|
|
9024
|
+
if (existsSync6(join22(dir, "package.json")) && existsSync6(join22(dir, "souls"))) {
|
|
9021
9025
|
return dir;
|
|
9022
9026
|
}
|
|
9023
9027
|
const parent = dirname12(dir);
|
|
@@ -9086,7 +9090,7 @@ __export(auditor_soul_exports, {
|
|
|
9086
9090
|
resolveAuditorSubject: () => resolveAuditorSubject
|
|
9087
9091
|
});
|
|
9088
9092
|
import { readFile as readFile14 } from "node:fs/promises";
|
|
9089
|
-
import { basename as basename7, join as
|
|
9093
|
+
import { basename as basename7, join as join23 } from "node:path";
|
|
9090
9094
|
function auditorSoulRelativePath(role) {
|
|
9091
9095
|
return `souls/${role}-auditor.md`;
|
|
9092
9096
|
}
|
|
@@ -9128,7 +9132,7 @@ function subjectFromSourceDirectory(sourceRunDirectory) {
|
|
|
9128
9132
|
async function readAuditorResumeBinding(runDirectory) {
|
|
9129
9133
|
let raw;
|
|
9130
9134
|
try {
|
|
9131
|
-
raw = JSON.parse(await readFile14(
|
|
9135
|
+
raw = JSON.parse(await readFile14(join23(runDirectory, "admitted-request.json"), "utf8"));
|
|
9132
9136
|
} catch (error) {
|
|
9133
9137
|
if (error.code === "ENOENT") return void 0;
|
|
9134
9138
|
throw error;
|
|
@@ -9241,7 +9245,7 @@ var init_serialize_thrown_value = __esm({
|
|
|
9241
9245
|
// src/engine-detour-usage.ts
|
|
9242
9246
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
9243
9247
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
9244
|
-
import { dirname as dirname13, join as
|
|
9248
|
+
import { dirname as dirname13, join as join24 } from "node:path";
|
|
9245
9249
|
function engineDetourStdoutByteLength(stdout) {
|
|
9246
9250
|
return Buffer.byteLength(stdout, "utf8");
|
|
9247
9251
|
}
|
|
@@ -9378,7 +9382,7 @@ function projectEngineDetourToolUsageForPublicTerminal(usage, options) {
|
|
|
9378
9382
|
function readInvocationRecord(runDirectory) {
|
|
9379
9383
|
try {
|
|
9380
9384
|
const raw = JSON.parse(
|
|
9381
|
-
readFileSync2(
|
|
9385
|
+
readFileSync2(join24(runDirectory, "invocation.json"), "utf8")
|
|
9382
9386
|
);
|
|
9383
9387
|
return isRecord7(raw) ? raw : void 0;
|
|
9384
9388
|
} catch (error) {
|
|
@@ -9406,7 +9410,7 @@ function runDirectoryFromSessionDirectory(sessionDirectory) {
|
|
|
9406
9410
|
return dirname13(sessionDirectory);
|
|
9407
9411
|
}
|
|
9408
9412
|
function sessionFileFromSessionDirectory(sessionDirectory) {
|
|
9409
|
-
return
|
|
9413
|
+
return join24(sessionDirectory, "session.jsonl");
|
|
9410
9414
|
}
|
|
9411
9415
|
function mintEngineDetourInvocationScope(input) {
|
|
9412
9416
|
const engine = input.effectiveEngine?.trim();
|
|
@@ -9862,14 +9866,14 @@ __export(settlement_exports, {
|
|
|
9862
9866
|
});
|
|
9863
9867
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
9864
9868
|
import { appendFile as appendFile2, readFile as readFile15, readdir as readdir5, rm as rm3, writeFile as writeFile5 } from "node:fs/promises";
|
|
9865
|
-
import { dirname as dirname14, join as
|
|
9869
|
+
import { dirname as dirname14, join as join25 } from "node:path";
|
|
9866
9870
|
function sealedLedgerHome(admitted) {
|
|
9867
9871
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
9868
9872
|
}
|
|
9869
9873
|
function ledgerReadScope(admitted, scope) {
|
|
9870
9874
|
return {
|
|
9871
9875
|
home: sealedLedgerHome(admitted),
|
|
9872
|
-
sessionParent:
|
|
9876
|
+
sessionParent: join25(admitted.runDirectory, "session", "session.jsonl"),
|
|
9873
9877
|
...scope?.courtAttemptId === void 0 || scope.courtAttemptId.length === 0 ? {} : { attemptId: scope.courtAttemptId }
|
|
9874
9878
|
};
|
|
9875
9879
|
}
|
|
@@ -10001,8 +10005,8 @@ function formatCliDiagnostic(message) {
|
|
|
10001
10005
|
return `ak-role: ${message}
|
|
10002
10006
|
`;
|
|
10003
10007
|
}
|
|
10004
|
-
function formatFailureStderrDiagnostic(
|
|
10005
|
-
const text =
|
|
10008
|
+
function formatFailureStderrDiagnostic(failure) {
|
|
10009
|
+
const text = failure.diagnostic.trim().length > 0 ? failure.diagnostic : "failure";
|
|
10006
10010
|
return formatCliDiagnostic(text);
|
|
10007
10011
|
}
|
|
10008
10012
|
function formatErrorCauseDetail(cause) {
|
|
@@ -10027,10 +10031,10 @@ function presentStructuralRejection(error, io) {
|
|
|
10027
10031
|
}
|
|
10028
10032
|
io.stderr(formatCliDiagnostic(message));
|
|
10029
10033
|
}
|
|
10030
|
-
function presentControlledFailure(
|
|
10031
|
-
io.stdout(`${JSON.stringify(
|
|
10034
|
+
function presentControlledFailure(failure, io) {
|
|
10035
|
+
io.stdout(`${JSON.stringify(failure, null, 2)}
|
|
10032
10036
|
`);
|
|
10033
|
-
io.stderr(formatFailureStderrDiagnostic(
|
|
10037
|
+
io.stderr(formatFailureStderrDiagnostic(failure));
|
|
10034
10038
|
}
|
|
10035
10039
|
async function inspectJudgeSession(sessionFile) {
|
|
10036
10040
|
try {
|
|
@@ -10133,14 +10137,14 @@ function classifyThrownFailure(error) {
|
|
|
10133
10137
|
}
|
|
10134
10138
|
};
|
|
10135
10139
|
}
|
|
10136
|
-
function withKnownDetails(
|
|
10137
|
-
if (knownDetails === void 0) return
|
|
10140
|
+
function withKnownDetails(failure, knownDetails) {
|
|
10141
|
+
if (knownDetails === void 0) return failure;
|
|
10138
10142
|
const { timedOut: _knownTimedOut, ...rest } = knownDetails;
|
|
10139
10143
|
return {
|
|
10140
|
-
...
|
|
10144
|
+
...failure,
|
|
10141
10145
|
details: {
|
|
10142
10146
|
...rest,
|
|
10143
|
-
...
|
|
10147
|
+
...failure.details ?? {}
|
|
10144
10148
|
}
|
|
10145
10149
|
};
|
|
10146
10150
|
}
|
|
@@ -10233,13 +10237,13 @@ function classifyPostAdmissionFailure(input) {
|
|
|
10233
10237
|
input.knownDetails
|
|
10234
10238
|
);
|
|
10235
10239
|
}
|
|
10236
|
-
function explicitInternalKnownFailureClassificationInput(
|
|
10237
|
-
if (
|
|
10240
|
+
function explicitInternalKnownFailureClassificationInput(failure) {
|
|
10241
|
+
if (failure === void 0) return {};
|
|
10238
10242
|
return {
|
|
10239
|
-
...
|
|
10240
|
-
...
|
|
10241
|
-
...
|
|
10242
|
-
...
|
|
10243
|
+
...failure.cause === void 0 ? {} : { knownCause: failure.cause },
|
|
10244
|
+
...failure.identity === void 0 ? {} : { knownIdentity: failure.identity },
|
|
10245
|
+
...failure.diagnostic === void 0 ? {} : { knownDiagnostic: failure.diagnostic },
|
|
10246
|
+
...failure.details === void 0 ? {} : { knownDetails: failure.details }
|
|
10243
10247
|
};
|
|
10244
10248
|
}
|
|
10245
10249
|
function isMissingPathError4(error) {
|
|
@@ -10370,7 +10374,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
10370
10374
|
}
|
|
10371
10375
|
const parentId = parentEntries.find((entry) => entry.type === "session")?.id;
|
|
10372
10376
|
if (parentId === void 0) return void 0;
|
|
10373
|
-
const childDirectories = [
|
|
10377
|
+
const childDirectories = [join25(dirname14(sessionFile), "auditor-roles")];
|
|
10374
10378
|
const valid = [];
|
|
10375
10379
|
let sawAnyDirectory = false;
|
|
10376
10380
|
for (const childDirectory of childDirectories) {
|
|
@@ -10385,7 +10389,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
10385
10389
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
10386
10390
|
let entries;
|
|
10387
10391
|
try {
|
|
10388
|
-
entries = await readBoundSessionEntries(
|
|
10392
|
+
entries = await readBoundSessionEntries(join25(childDirectory, file));
|
|
10389
10393
|
} catch (error) {
|
|
10390
10394
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
10391
10395
|
}
|
|
@@ -10430,19 +10434,19 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
10430
10434
|
const entry = entries[i];
|
|
10431
10435
|
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord10(entry.data)) continue;
|
|
10432
10436
|
const parent = isRecord10(entry.data.parent) ? entry.data.parent : void 0;
|
|
10433
|
-
const
|
|
10437
|
+
const failure = isRecord10(entry.data.failure) ? entry.data.failure : void 0;
|
|
10434
10438
|
if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId) continue;
|
|
10435
|
-
if (
|
|
10436
|
-
const identity = isRecord10(
|
|
10437
|
-
const typedCause =
|
|
10439
|
+
if (failure === void 0) continue;
|
|
10440
|
+
const identity = isRecord10(failure.identity) ? failure.identity : void 0;
|
|
10441
|
+
const typedCause = failure.cause === "provider" || failure.cause === "activation" || failure.cause === "session" || failure.cause === "output" || failure.cause === "timeout" ? failure.cause : void 0;
|
|
10438
10442
|
return {
|
|
10439
10443
|
...typedCause === void 0 ? {} : { cause: typedCause },
|
|
10440
10444
|
...identity === void 0 ? {} : { identity: {
|
|
10441
10445
|
...typeof identity.name === "string" ? { name: identity.name } : {},
|
|
10442
10446
|
...typeof identity.code === "string" || typeof identity.code === "number" ? { code: identity.code } : {}
|
|
10443
10447
|
} },
|
|
10444
|
-
...typeof
|
|
10445
|
-
...isRecord10(
|
|
10448
|
+
...typeof failure.diagnostic === "string" ? { diagnostic: failure.diagnostic } : {},
|
|
10449
|
+
...isRecord10(failure.details) ? { details: failure.details } : {}
|
|
10446
10450
|
};
|
|
10447
10451
|
}
|
|
10448
10452
|
}
|
|
@@ -10514,11 +10518,11 @@ async function resolveAuditedRunnerFailureResolution(input) {
|
|
|
10514
10518
|
const auditorCompliance = await readBoundAuditorComplianceFailure(input.sessionFile);
|
|
10515
10519
|
if (auditorCompliance !== void 0) return resolutionOf(auditorCompliance);
|
|
10516
10520
|
} catch (error) {
|
|
10517
|
-
const
|
|
10521
|
+
const failure = sessionReadFailure(error, "failed to recover bound auditor failure");
|
|
10518
10522
|
return resolutionOf({
|
|
10519
10523
|
cause: "session",
|
|
10520
|
-
identity: thrownIdentity(
|
|
10521
|
-
diagnostic:
|
|
10524
|
+
identity: thrownIdentity(failure),
|
|
10525
|
+
diagnostic: failure.message || failure.name
|
|
10522
10526
|
});
|
|
10523
10527
|
}
|
|
10524
10528
|
try {
|
|
@@ -10528,11 +10532,11 @@ async function resolveAuditedRunnerFailureResolution(input) {
|
|
|
10528
10532
|
if (terminatingFailure !== void 0) return resolutionOf(terminatingFailure);
|
|
10529
10533
|
} catch (error) {
|
|
10530
10534
|
if (!isMissingPathError4(error)) {
|
|
10531
|
-
const
|
|
10535
|
+
const failure = sessionReadFailure(error, "failed to recover typed terminating-tool failure");
|
|
10532
10536
|
return resolutionOf({
|
|
10533
10537
|
cause: "session",
|
|
10534
|
-
identity: thrownIdentity(
|
|
10535
|
-
diagnostic:
|
|
10538
|
+
identity: thrownIdentity(failure),
|
|
10539
|
+
diagnostic: failure.message || failure.name
|
|
10536
10540
|
});
|
|
10537
10541
|
}
|
|
10538
10542
|
}
|
|
@@ -10540,11 +10544,11 @@ async function resolveAuditedRunnerFailureResolution(input) {
|
|
|
10540
10544
|
const auditorStop = await readBoundAuditorProviderStopFallback(input.sessionFile);
|
|
10541
10545
|
if (auditorStop !== void 0) return resolutionOf(auditorStop);
|
|
10542
10546
|
} catch (error) {
|
|
10543
|
-
const
|
|
10547
|
+
const failure = sessionReadFailure(error, "failed to recover bound auditor provider stop");
|
|
10544
10548
|
return resolutionOf({
|
|
10545
10549
|
cause: "session",
|
|
10546
|
-
identity: thrownIdentity(
|
|
10547
|
-
diagnostic:
|
|
10550
|
+
identity: thrownIdentity(failure),
|
|
10551
|
+
diagnostic: failure.message || failure.name
|
|
10548
10552
|
});
|
|
10549
10553
|
}
|
|
10550
10554
|
const parentStop = await readSessionProviderStop(input.sessionFile);
|
|
@@ -10553,12 +10557,12 @@ async function resolveAuditedRunnerFailureResolution(input) {
|
|
|
10553
10557
|
try {
|
|
10554
10558
|
httpObservation = await readLatestTypedProviderHttpObservation(input.runDirectory);
|
|
10555
10559
|
} catch (error) {
|
|
10556
|
-
const
|
|
10560
|
+
const failure = error instanceof Error ? error : new Error(String(error));
|
|
10557
10561
|
return resolutionOf(
|
|
10558
10562
|
{
|
|
10559
10563
|
cause: "session",
|
|
10560
|
-
identity: thrownIdentity(
|
|
10561
|
-
diagnostic:
|
|
10564
|
+
identity: thrownIdentity(failure),
|
|
10565
|
+
diagnostic: failure.message || failure.name
|
|
10562
10566
|
},
|
|
10563
10567
|
{ settled: true }
|
|
10564
10568
|
);
|
|
@@ -10609,12 +10613,12 @@ async function resolveControlledFailureResumeObservation(input) {
|
|
|
10609
10613
|
const typedHttp429 = await readTypedHttp429Observation(input.runDirectory);
|
|
10610
10614
|
return typedHttp429 === void 0 ? {} : { typedHttp429 };
|
|
10611
10615
|
} catch (error) {
|
|
10612
|
-
const
|
|
10616
|
+
const failure = error instanceof Error ? error : new Error(String(error));
|
|
10613
10617
|
return {
|
|
10614
10618
|
observationReadFailure: {
|
|
10615
10619
|
cause: "session",
|
|
10616
|
-
identity: thrownIdentity(
|
|
10617
|
-
diagnostic:
|
|
10620
|
+
identity: thrownIdentity(failure),
|
|
10621
|
+
diagnostic: failure.message || failure.name
|
|
10618
10622
|
}
|
|
10619
10623
|
};
|
|
10620
10624
|
}
|
|
@@ -10694,11 +10698,11 @@ async function readEngineDetourInfrastructureFailure(sessionFile) {
|
|
|
10694
10698
|
ENGINE_DETOUR_INFRASTRUCTURE_FAILURE_SPEC
|
|
10695
10699
|
);
|
|
10696
10700
|
}
|
|
10697
|
-
function knownFailureFromControlled(
|
|
10701
|
+
function knownFailureFromControlled(failure) {
|
|
10698
10702
|
return {
|
|
10699
|
-
...
|
|
10700
|
-
diagnostic:
|
|
10701
|
-
...
|
|
10703
|
+
...failure.cause === void 0 ? {} : { cause: failure.cause },
|
|
10704
|
+
diagnostic: failure.diagnostic,
|
|
10705
|
+
...failure.identity === void 0 ? {} : { identity: failure.identity }
|
|
10702
10706
|
};
|
|
10703
10707
|
}
|
|
10704
10708
|
function seatKnownFailureResolver(role) {
|
|
@@ -10861,8 +10865,8 @@ function projectTerminalGateFact(rounds) {
|
|
|
10861
10865
|
};
|
|
10862
10866
|
}
|
|
10863
10867
|
async function extractGateFactFromSessionDirectory(sessionDirectory, options = {}) {
|
|
10864
|
-
const directories = [
|
|
10865
|
-
const parentSessionFile = options.parentSessionFile ??
|
|
10868
|
+
const directories = [join25(sessionDirectory, "auditor-roles")];
|
|
10869
|
+
const parentSessionFile = options.parentSessionFile ?? join25(sessionDirectory, "session.jsonl");
|
|
10866
10870
|
const rounds = await readAnalystGateCyclesFromAuditorRoles(directories, {
|
|
10867
10871
|
parentSessionFile
|
|
10868
10872
|
});
|
|
@@ -10974,10 +10978,10 @@ async function removeFaceIfPresent(path) {
|
|
|
10974
10978
|
async function clearOppositeTerminalArtifactFace(runDirectory) {
|
|
10975
10979
|
const artifactsDir = roleRunArtifactsDirectory(runDirectory);
|
|
10976
10980
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
10977
|
-
await removeFaceIfPresent(
|
|
10981
|
+
await removeFaceIfPresent(join25(artifactsDir, file));
|
|
10978
10982
|
}
|
|
10979
10983
|
for (const relative4 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
10980
|
-
await removeFaceIfPresent(
|
|
10984
|
+
await removeFaceIfPresent(join25(runDirectory, relative4));
|
|
10981
10985
|
}
|
|
10982
10986
|
for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
|
|
10983
10987
|
await removeFaceIfPresent(path);
|
|
@@ -11006,8 +11010,8 @@ async function publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinat
|
|
|
11006
11010
|
roleOutcome
|
|
11007
11011
|
);
|
|
11008
11012
|
const artifactsDir = await ensureTerminalArtifactFace(admitted.runDirectory);
|
|
11009
|
-
const reportPath =
|
|
11010
|
-
const evidencePath =
|
|
11013
|
+
const reportPath = join25(artifactsDir, "report.json");
|
|
11014
|
+
const evidencePath = join25(artifactsDir, "evidence.json");
|
|
11011
11015
|
await writeFile5(
|
|
11012
11016
|
reportPath,
|
|
11013
11017
|
`${JSON.stringify(bodies.report, null, 2)}
|
|
@@ -11416,7 +11420,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
|
|
|
11416
11420
|
const candidates = [
|
|
11417
11421
|
...preferredCandidates,
|
|
11418
11422
|
// One unique name per fallback dir — collisions on fixed names cannot exhaust this.
|
|
11419
|
-
...uniqueFallbackDirs.map((dir) =>
|
|
11423
|
+
...uniqueFallbackDirs.map((dir) => join25(dir, `${stem}.${randomUUID4()}.json`))
|
|
11420
11424
|
];
|
|
11421
11425
|
for (let i = 0; i < candidates.length; i += 1) {
|
|
11422
11426
|
const path = candidates[i];
|
|
@@ -11446,7 +11450,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
|
|
|
11446
11450
|
error.publicationAttempts = issues;
|
|
11447
11451
|
throw error;
|
|
11448
11452
|
}
|
|
11449
|
-
async function publishFailureArtifacts(admitted,
|
|
11453
|
+
async function publishFailureArtifacts(admitted, failure, authority, onErrorPublished) {
|
|
11450
11454
|
const { sessionDirectory, sessionFile } = coordinatesFromAdmitted(authority, admitted);
|
|
11451
11455
|
const { baseDir, attempt: baseAttempt } = await resolveFailureArtifactsBase(
|
|
11452
11456
|
admitted.runDirectory
|
|
@@ -11466,7 +11470,7 @@ async function publishFailureArtifacts(admitted, failure2, authority, onErrorPub
|
|
|
11466
11470
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile }, {
|
|
11467
11471
|
kind: "failure",
|
|
11468
11472
|
role: admitted.role,
|
|
11469
|
-
...
|
|
11473
|
+
...failure
|
|
11470
11474
|
});
|
|
11471
11475
|
} catch (error) {
|
|
11472
11476
|
priorIssues.push(publicationAttemptFromError(sessionFile, error));
|
|
@@ -11477,29 +11481,29 @@ async function publishFailureArtifacts(admitted, failure2, authority, onErrorPub
|
|
|
11477
11481
|
baseDir
|
|
11478
11482
|
);
|
|
11479
11483
|
const errorCandidates = underArtifacts ? [
|
|
11480
|
-
|
|
11481
|
-
|
|
11482
|
-
|
|
11484
|
+
join25(baseDir, "error.json"),
|
|
11485
|
+
join25(baseDir, "error.settlement.json"),
|
|
11486
|
+
join25(admitted.runDirectory, "error.settlement.json")
|
|
11483
11487
|
] : [
|
|
11484
|
-
|
|
11485
|
-
|
|
11488
|
+
join25(baseDir, "error.settlement.json"),
|
|
11489
|
+
join25(baseDir, "error.json")
|
|
11486
11490
|
];
|
|
11487
11491
|
const evidenceCandidates = underArtifacts ? [
|
|
11488
|
-
|
|
11489
|
-
|
|
11490
|
-
|
|
11492
|
+
join25(baseDir, "evidence.json"),
|
|
11493
|
+
join25(baseDir, "evidence.settlement.json"),
|
|
11494
|
+
join25(admitted.runDirectory, "evidence.settlement.json")
|
|
11491
11495
|
] : [
|
|
11492
|
-
|
|
11493
|
-
|
|
11496
|
+
join25(baseDir, "evidence.settlement.json"),
|
|
11497
|
+
join25(baseDir, "evidence.json")
|
|
11494
11498
|
];
|
|
11495
11499
|
const errorPayloadBase = {
|
|
11496
11500
|
kind: "error",
|
|
11497
11501
|
role: admitted.role,
|
|
11498
11502
|
runId: admitted.runId,
|
|
11499
|
-
...
|
|
11500
|
-
diagnostic:
|
|
11501
|
-
...
|
|
11502
|
-
...
|
|
11503
|
+
...failure.cause === void 0 ? {} : { cause: failure.cause },
|
|
11504
|
+
diagnostic: failure.diagnostic,
|
|
11505
|
+
...failure.identity === void 0 ? {} : { identity: failure.identity },
|
|
11506
|
+
...failure.details === void 0 ? {} : { details: failure.details }
|
|
11503
11507
|
};
|
|
11504
11508
|
const errorWrite = await writeFailureJsonRetainingCause(
|
|
11505
11509
|
errorCandidates,
|
|
@@ -11520,7 +11524,7 @@ async function publishFailureArtifacts(admitted, failure2, authority, onErrorPub
|
|
|
11520
11524
|
sha256: a.sha256,
|
|
11521
11525
|
byteLength: a.byteLength
|
|
11522
11526
|
})),
|
|
11523
|
-
...
|
|
11527
|
+
...failure.cause === void 0 ? {} : { failureCause: failure.cause }
|
|
11524
11528
|
};
|
|
11525
11529
|
const evidenceWrite = await writeFailureJsonRetainingCause(
|
|
11526
11530
|
evidenceCandidates,
|
|
@@ -11535,10 +11539,10 @@ async function publishFailureArtifacts(admitted, failure2, authority, onErrorPub
|
|
|
11535
11539
|
{ kind: "evidence", path: evidenceWrite.path }
|
|
11536
11540
|
];
|
|
11537
11541
|
}
|
|
11538
|
-
async function settleFailureTerminalResult(admitted,
|
|
11542
|
+
async function settleFailureTerminalResult(admitted, failure, authority, options = {}) {
|
|
11539
11543
|
const coordinates = coordinatesFromAdmitted(authority, admitted);
|
|
11540
11544
|
const { sessionDirectory, sessionFile } = coordinates;
|
|
11541
|
-
if (
|
|
11545
|
+
if (failure.cause === "output") {
|
|
11542
11546
|
const entries = await readBoundSessionEntries(sessionFile).catch(() => void 0);
|
|
11543
11547
|
if (entries !== void 0) {
|
|
11544
11548
|
let attemptStart = 0;
|
|
@@ -11580,27 +11584,27 @@ async function settleFailureTerminalResult(admitted, failure2, authority, option
|
|
|
11580
11584
|
}
|
|
11581
11585
|
}
|
|
11582
11586
|
const navigator = await extractNavigatorFactFromAdmittedSession(sessionFile);
|
|
11583
|
-
const artifacts = await publishFailureArtifacts(admitted,
|
|
11587
|
+
const artifacts = await publishFailureArtifacts(admitted, failure, authority, options.onErrorPublished);
|
|
11584
11588
|
const errorPath = artifacts.find((artifact) => artifact.kind === "error")?.path;
|
|
11585
11589
|
const decisiveFacts = {
|
|
11586
|
-
...
|
|
11587
|
-
diagnostic:
|
|
11590
|
+
...failure.cause === void 0 ? {} : { cause: failure.cause },
|
|
11591
|
+
diagnostic: failure.diagnostic
|
|
11588
11592
|
};
|
|
11589
|
-
if (
|
|
11590
|
-
decisiveFacts.errorName =
|
|
11593
|
+
if (failure.identity?.name !== void 0) {
|
|
11594
|
+
decisiveFacts.errorName = failure.identity.name;
|
|
11591
11595
|
}
|
|
11592
|
-
if (
|
|
11593
|
-
decisiveFacts.errorCode =
|
|
11596
|
+
if (failure.identity?.code !== void 0) {
|
|
11597
|
+
decisiveFacts.errorCode = failure.identity.code;
|
|
11594
11598
|
}
|
|
11595
|
-
if (
|
|
11596
|
-
decisiveFacts.secondaryEvidence =
|
|
11599
|
+
if (failure.details !== void 0) {
|
|
11600
|
+
decisiveFacts.secondaryEvidence = failure.details;
|
|
11597
11601
|
}
|
|
11598
11602
|
if (options.resume !== void 0) {
|
|
11599
11603
|
const roleOutcome2 = {
|
|
11600
11604
|
kind: "failure",
|
|
11601
11605
|
role: admitted.role,
|
|
11602
|
-
...
|
|
11603
|
-
diagnostic:
|
|
11606
|
+
...failure.cause === void 0 ? {} : { cause: failure.cause },
|
|
11607
|
+
diagnostic: failure.diagnostic,
|
|
11604
11608
|
decisiveFacts
|
|
11605
11609
|
};
|
|
11606
11610
|
const terminal = await withOptionalGateProjection(
|
|
@@ -11619,8 +11623,8 @@ async function settleFailureTerminalResult(admitted, failure2, authority, option
|
|
|
11619
11623
|
const roleOutcome = {
|
|
11620
11624
|
kind: "failure",
|
|
11621
11625
|
role: admitted.role,
|
|
11622
|
-
...
|
|
11623
|
-
diagnostic:
|
|
11626
|
+
...failure.cause === void 0 ? {} : { cause: failure.cause },
|
|
11627
|
+
diagnostic: failure.diagnostic,
|
|
11624
11628
|
decisiveFacts
|
|
11625
11629
|
};
|
|
11626
11630
|
return withOptionalGateProjection(
|
|
@@ -11634,8 +11638,8 @@ async function settleFailureTerminalResult(admitted, failure2, authority, option
|
|
|
11634
11638
|
detourGateContext(admitted, options)
|
|
11635
11639
|
);
|
|
11636
11640
|
}
|
|
11637
|
-
async function settleJudgeFailureTerminalResult(admitted,
|
|
11638
|
-
return settleFailureTerminalResult(admitted,
|
|
11641
|
+
async function settleJudgeFailureTerminalResult(admitted, failure, authority, options = {}) {
|
|
11642
|
+
return settleFailureTerminalResult(admitted, failure, authority, options);
|
|
11639
11643
|
}
|
|
11640
11644
|
function presentFailureTerminal(terminal, io) {
|
|
11641
11645
|
if (terminal.roleOutcome.kind !== "failure" && terminal.roleOutcome.kind !== "no_receipt") {
|
|
@@ -11745,9 +11749,9 @@ var init_settlement = __esm({
|
|
|
11745
11749
|
|
|
11746
11750
|
// src/archivist-record-pointer.ts
|
|
11747
11751
|
import { mkdirSync as mkdirSync2, writeFileSync } from "node:fs";
|
|
11748
|
-
import { dirname as dirname15, join as
|
|
11752
|
+
import { dirname as dirname15, join as join26 } from "node:path";
|
|
11749
11753
|
function bookDirectOfficerRunPointer(options) {
|
|
11750
|
-
const nest =
|
|
11754
|
+
const nest = join26(dirname15(options.parentSessionFile), "auditor-roles");
|
|
11751
11755
|
mkdirSync2(nest, { recursive: true });
|
|
11752
11756
|
const pointer = {
|
|
11753
11757
|
version: 1,
|
|
@@ -11757,7 +11761,7 @@ function bookDirectOfficerRunPointer(options) {
|
|
|
11757
11761
|
...options.runDirectory !== void 0 && options.runDirectory.trim() !== "" ? { runDirectory: options.runDirectory } : {}
|
|
11758
11762
|
};
|
|
11759
11763
|
writeFileSync(
|
|
11760
|
-
|
|
11764
|
+
join26(nest, `${options.officer}.pointer.json`),
|
|
11761
11765
|
`${JSON.stringify(pointer)}
|
|
11762
11766
|
`,
|
|
11763
11767
|
"utf8"
|
|
@@ -11986,11 +11990,11 @@ async function requireSubmissionGate(options) {
|
|
|
11986
11990
|
continue;
|
|
11987
11991
|
}
|
|
11988
11992
|
if (gatekeeper.status === "transport_failure") {
|
|
11989
|
-
const
|
|
11993
|
+
const failure = Object.assign(new Error(gatekeeper.reason), {
|
|
11990
11994
|
name: "GatekeeperTransportFailure",
|
|
11991
11995
|
...gatekeeper.submission === void 0 ? {} : { submission: gatekeeper.submission }
|
|
11992
11996
|
});
|
|
11993
|
-
options.hostActions.failInfrastructure(
|
|
11997
|
+
options.hostActions.failInfrastructure(failure, options.context, options.toolCallId);
|
|
11994
11998
|
}
|
|
11995
11999
|
if (gatekeeper.status === "escalate") {
|
|
11996
12000
|
return {
|
|
@@ -12016,9 +12020,9 @@ var init_submission_gate = __esm({
|
|
|
12016
12020
|
|
|
12017
12021
|
// src/session-identity.ts
|
|
12018
12022
|
import { mkdir as mkdir2, readFile as readFile16, rename as rename2, writeFile as writeFile6 } from "node:fs/promises";
|
|
12019
|
-
import { dirname as dirname16, join as
|
|
12023
|
+
import { dirname as dirname16, join as join27 } from "node:path";
|
|
12020
12024
|
function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
12021
|
-
const bindingPath = (principal) =>
|
|
12025
|
+
const bindingPath = (principal) => join27(authority.decode(principal).sessionDirectory, sessionBindingFile);
|
|
12022
12026
|
return {
|
|
12023
12027
|
resolveSessionFile(principal) {
|
|
12024
12028
|
return authority.decode(principal).sessionFile;
|
|
@@ -12096,7 +12100,7 @@ import {
|
|
|
12096
12100
|
statSync as statSync3
|
|
12097
12101
|
} from "node:fs";
|
|
12098
12102
|
import { homedir } from "node:os";
|
|
12099
|
-
import { dirname as dirname17, join as
|
|
12103
|
+
import { dirname as dirname17, join as join28 } from "node:path";
|
|
12100
12104
|
function declareHostSessionFailure(error) {
|
|
12101
12105
|
const message = error instanceof Error ? error.stack || error.message : String(error);
|
|
12102
12106
|
process.stderr.write(`[host-session] Dossier record failure: ${message}
|
|
@@ -12121,7 +12125,7 @@ function findCodexRollout(sessionsDir, sessionId) {
|
|
|
12121
12125
|
return;
|
|
12122
12126
|
}
|
|
12123
12127
|
for (const entry of entries) {
|
|
12124
|
-
const fullPath =
|
|
12128
|
+
const fullPath = join28(dir, entry.name);
|
|
12125
12129
|
if (entry.isDirectory()) {
|
|
12126
12130
|
scan(fullPath, depth + 1);
|
|
12127
12131
|
} else if (entry.isFile() && entry.name.endsWith(".jsonl") && entry.name.includes(sessionId)) {
|
|
@@ -12145,25 +12149,25 @@ function sanitizeClaudeCwd(cwd) {
|
|
|
12145
12149
|
function resolveNativeSessionPath(options) {
|
|
12146
12150
|
const home = options.home || homedir();
|
|
12147
12151
|
if (options.host === "claude") {
|
|
12148
|
-
const configDir = process.env.CLAUDE_CONFIG_DIR ||
|
|
12152
|
+
const configDir = process.env.CLAUDE_CONFIG_DIR || join28(home, ".claude");
|
|
12149
12153
|
const sanitizedCwd = sanitizeClaudeCwd(options.cwd);
|
|
12150
|
-
return
|
|
12154
|
+
return join28(configDir, "projects", sanitizedCwd, `${options.sessionId}.jsonl`);
|
|
12151
12155
|
}
|
|
12152
12156
|
if (options.host === "codex") {
|
|
12153
12157
|
return findCodexRollout(codexSessionsDirectory(home), options.sessionId);
|
|
12154
12158
|
}
|
|
12155
12159
|
if (options.host === "grok-build") {
|
|
12156
|
-
const grokHome = process.env.GROK_HOME ||
|
|
12157
|
-
return
|
|
12160
|
+
const grokHome = process.env.GROK_HOME || join28(home, ".grok");
|
|
12161
|
+
return join28(grokHome, "sessions", encodeURIComponent(options.cwd), options.sessionId);
|
|
12158
12162
|
}
|
|
12159
12163
|
return void 0;
|
|
12160
12164
|
}
|
|
12161
12165
|
function codexSessionsDirectory(home) {
|
|
12162
|
-
return
|
|
12166
|
+
return join28(process.env.CODEX_HOME || join28(home || homedir(), ".codex"), "sessions");
|
|
12163
12167
|
}
|
|
12164
12168
|
function recordRunStart(runDirectory) {
|
|
12165
12169
|
try {
|
|
12166
|
-
appendFileSync2(
|
|
12170
|
+
appendFileSync2(join28(runDirectory, ".run-starts"), "\n");
|
|
12167
12171
|
} catch (error) {
|
|
12168
12172
|
declareHostSessionFailure(error);
|
|
12169
12173
|
}
|
|
@@ -12187,12 +12191,12 @@ function resolveHostDossierLandingPath(options) {
|
|
|
12187
12191
|
} catch {
|
|
12188
12192
|
}
|
|
12189
12193
|
}
|
|
12190
|
-
const startsPath =
|
|
12194
|
+
const startsPath = join28(dirname17(options.sessionDirectory), ".run-starts");
|
|
12191
12195
|
let starts = 0;
|
|
12192
12196
|
if (existsSync8(startsPath)) starts = readFileSync3(startsPath, "utf8").length;
|
|
12193
12197
|
const ordinal = Math.max(maxOrdinal + 1, starts, options.continuation.kind === "resume" ? 2 : 1);
|
|
12194
12198
|
const baseName = `${options.host}-${sanitizedModel}-${ordinal}`;
|
|
12195
|
-
const landingPath = options.host === "grok-build" ?
|
|
12199
|
+
const landingPath = options.host === "grok-build" ? join28(options.sessionDirectory, baseName) : join28(options.sessionDirectory, `${baseName}.jsonl`);
|
|
12196
12200
|
return { landingPath, ordinal, sanitizedModel };
|
|
12197
12201
|
}
|
|
12198
12202
|
function recordNativeSessionPointer(options) {
|
|
@@ -12225,18 +12229,18 @@ function copyFileCloneOrFallback(src, dest) {
|
|
|
12225
12229
|
copyFileSync(src, dest);
|
|
12226
12230
|
}
|
|
12227
12231
|
function copyGrokDossier(srcDir, destDir) {
|
|
12228
|
-
const chatHistorySrc =
|
|
12232
|
+
const chatHistorySrc = join28(srcDir, "chat_history.jsonl");
|
|
12229
12233
|
if (!existsSync8(chatHistorySrc)) {
|
|
12230
12234
|
throw new Error(`Grok native chat_history.jsonl missing at ${chatHistorySrc}`);
|
|
12231
12235
|
}
|
|
12232
12236
|
mkdirSync3(destDir, { recursive: true });
|
|
12233
|
-
const chatHistoryDest =
|
|
12237
|
+
const chatHistoryDest = join28(destDir, "chat_history.jsonl");
|
|
12234
12238
|
copyFileCloneOrFallback(chatHistorySrc, chatHistoryDest);
|
|
12235
|
-
const usageSrc =
|
|
12239
|
+
const usageSrc = join28(srcDir, "usage.json");
|
|
12236
12240
|
if (!existsSync8(usageSrc)) {
|
|
12237
12241
|
throw new Error(`Grok native usage.json missing at ${usageSrc}`);
|
|
12238
12242
|
}
|
|
12239
|
-
copyFileCloneOrFallback(usageSrc,
|
|
12243
|
+
copyFileCloneOrFallback(usageSrc, join28(destDir, "usage.json"));
|
|
12240
12244
|
}
|
|
12241
12245
|
function copyAndRecordHostDossier(options) {
|
|
12242
12246
|
if (options.host === "pi" || options.host === "hermes") {
|
|
@@ -12311,7 +12315,7 @@ function copyAndRecordHostDossier(options) {
|
|
|
12311
12315
|
}
|
|
12312
12316
|
try {
|
|
12313
12317
|
mkdirSync3(options.sessionDirectory, { recursive: true });
|
|
12314
|
-
closeSync(openSync(
|
|
12318
|
+
closeSync(openSync(join28(options.sessionDirectory, `${options.host}-${sanitizedModel}-${ordinal}.failed`), "a"));
|
|
12315
12319
|
} catch {
|
|
12316
12320
|
}
|
|
12317
12321
|
sitianReportSafe({
|
|
@@ -12345,7 +12349,7 @@ var init_host_session_record = __esm({
|
|
|
12345
12349
|
import { constants as fsConstants2 } from "node:fs";
|
|
12346
12350
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
12347
12351
|
import { lstat as lstat4, mkdir as mkdir3, open } from "node:fs/promises";
|
|
12348
|
-
import { join as
|
|
12352
|
+
import { join as join29 } from "node:path";
|
|
12349
12353
|
async function persistReturnedRunState(admitted, options) {
|
|
12350
12354
|
if (options?.lawful === true) {
|
|
12351
12355
|
await markRunTerminal(admitted.runDirectory);
|
|
@@ -12414,7 +12418,7 @@ function jsonSafeReplacer() {
|
|
|
12414
12418
|
};
|
|
12415
12419
|
}
|
|
12416
12420
|
async function writeHardenedArtifactFile(artifactsDir, namePrefix, payload) {
|
|
12417
|
-
const filePath =
|
|
12421
|
+
const filePath = join29(artifactsDir, `${namePrefix}-${randomUUID5()}.json`);
|
|
12418
12422
|
const body = `${JSON.stringify(payload, jsonSafeReplacer(), 2)}
|
|
12419
12423
|
`;
|
|
12420
12424
|
const noFollowFlag = typeof fsConstants2.O_NOFOLLOW === "number" ? fsConstants2.O_NOFOLLOW : 0;
|
|
@@ -12669,7 +12673,7 @@ var init_auto_resume = __esm({
|
|
|
12669
12673
|
// src/public-cli/post-admission.ts
|
|
12670
12674
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
12671
12675
|
import { writeFile as writeFile7 } from "node:fs/promises";
|
|
12672
|
-
import { isAbsolute as isAbsolute7, join as
|
|
12676
|
+
import { isAbsolute as isAbsolute7, join as join30, resolve as resolve12 } from "node:path";
|
|
12673
12677
|
function describeCaughtError(error) {
|
|
12674
12678
|
if (error instanceof Error) {
|
|
12675
12679
|
const code = error.code;
|
|
@@ -12765,7 +12769,7 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
12765
12769
|
try {
|
|
12766
12770
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
12767
12771
|
await writeFile7(
|
|
12768
|
-
|
|
12772
|
+
join30(artifactsDir, `post-admission-diagnostic-${randomUUID6()}.json`),
|
|
12769
12773
|
`${JSON.stringify({ version: 1, ...payload }, null, 2)}
|
|
12770
12774
|
`,
|
|
12771
12775
|
{ encoding: "utf8", flag: "wx" }
|
|
@@ -12794,7 +12798,7 @@ async function presentControlledFailure2(admitted, failureInput, adapters, autho
|
|
|
12794
12798
|
const knownFailure = failureInput.knownFailure ?? resumeObservation.observationReadFailure;
|
|
12795
12799
|
const session = !hasThrown && !failureInput.timedOut && knownFailure === void 0 && failureInput.knownCause === void 0 && admitted.principal !== void 0 ? await inspectJudgeSession(authority.decode(admitted.principal).sessionFile) : void 0;
|
|
12796
12800
|
const fromKnownFailure = explicitInternalKnownFailureClassificationInput(knownFailure);
|
|
12797
|
-
const
|
|
12801
|
+
const failure = classifyPostAdmissionFailure({
|
|
12798
12802
|
timedOut: failureInput.timedOut,
|
|
12799
12803
|
code: failureInput.code,
|
|
12800
12804
|
stderr: failureInput.stderr,
|
|
@@ -12813,7 +12817,7 @@ async function presentControlledFailure2(admitted, failureInput, adapters, autho
|
|
|
12813
12817
|
let publishedErrorPath;
|
|
12814
12818
|
let terminal;
|
|
12815
12819
|
try {
|
|
12816
|
-
const settled = await settleFailureTerminalResult(admitted,
|
|
12820
|
+
const settled = await settleFailureTerminalResult(admitted, failure, authority, {
|
|
12817
12821
|
...resumable ? { resume: { command: renderResumeCommand(admitted.runId) } } : {},
|
|
12818
12822
|
...failureInput.invocationScopeId === void 0 || failureInput.invocationScopeId.length === 0 ? {} : { invocationScopeId: failureInput.invocationScopeId },
|
|
12819
12823
|
onErrorPublished: (path) => {
|
|
@@ -12906,7 +12910,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
12906
12910
|
const rows = await readRecordedSubmissionRows(
|
|
12907
12911
|
admitted.projectRoot,
|
|
12908
12912
|
admitted.runId,
|
|
12909
|
-
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent:
|
|
12913
|
+
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent: join30(admitted.runDirectory, "session", "session.jsonl") }
|
|
12910
12914
|
);
|
|
12911
12915
|
let ticketNumber;
|
|
12912
12916
|
for (const row of rows) {
|
|
@@ -13033,7 +13037,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
13033
13037
|
let stderrLogWriteFailure;
|
|
13034
13038
|
try {
|
|
13035
13039
|
await writeFile7(
|
|
13036
|
-
|
|
13040
|
+
join30(admitted.runDirectory, "stderr.log"),
|
|
13037
13041
|
result.stderr,
|
|
13038
13042
|
"utf8"
|
|
13039
13043
|
);
|
|
@@ -13312,7 +13316,7 @@ async function dispatchAfterWriterLease(input) {
|
|
|
13312
13316
|
}
|
|
13313
13317
|
function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
|
|
13314
13318
|
const absolute = isAbsolute7(attachmentPath) ? attachmentPath : resolve12(attachmentPath);
|
|
13315
|
-
return pathContainedIn(
|
|
13319
|
+
return pathContainedIn(join30(runDirectory, "attachments"), absolute);
|
|
13316
13320
|
}
|
|
13317
13321
|
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
13318
13322
|
if (summons === void 0) return void 0;
|
|
@@ -13494,10 +13498,10 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
13494
13498
|
await presentResumeFailurePointer(
|
|
13495
13499
|
input.io,
|
|
13496
13500
|
error,
|
|
13497
|
-
(
|
|
13501
|
+
(failure) => writeResumeDiagnosticFile(
|
|
13498
13502
|
loaded.admitted.runDirectory,
|
|
13499
13503
|
loaded.admitted.runId,
|
|
13500
|
-
|
|
13504
|
+
failure,
|
|
13501
13505
|
loaded.admitted.role
|
|
13502
13506
|
)
|
|
13503
13507
|
);
|
|
@@ -13520,7 +13524,7 @@ async function pointExistingRunFailure(home, runId, authority, io, thrown) {
|
|
|
13520
13524
|
await presentResumeFailurePointer(
|
|
13521
13525
|
io,
|
|
13522
13526
|
thrown,
|
|
13523
|
-
(
|
|
13527
|
+
(failure) => writeResumeDiagnosticFile(runDirectory, runId, failure)
|
|
13524
13528
|
);
|
|
13525
13529
|
return true;
|
|
13526
13530
|
}
|
|
@@ -13528,7 +13532,7 @@ async function pointExistingRunFailure(home, runId, authority, io, thrown) {
|
|
|
13528
13532
|
await presentResumeFailurePointer(
|
|
13529
13533
|
io,
|
|
13530
13534
|
thrown,
|
|
13531
|
-
(
|
|
13535
|
+
(failure) => writeResumeDiagnosticFile(runDirectory, runId, failure, record4.role)
|
|
13532
13536
|
);
|
|
13533
13537
|
return true;
|
|
13534
13538
|
}
|
|
@@ -13544,14 +13548,14 @@ function showResumeErrorPointer(io, exitCode, terminal) {
|
|
|
13544
13548
|
if (publishedError !== void 0) writeResumeFailurePointer(io, publishedError);
|
|
13545
13549
|
}
|
|
13546
13550
|
async function presentResumeFailurePointer(io, thrown, publish) {
|
|
13547
|
-
const
|
|
13551
|
+
const failure = classifyPostAdmissionFailure({
|
|
13548
13552
|
timedOut: false,
|
|
13549
13553
|
code: null,
|
|
13550
13554
|
stderr: "",
|
|
13551
13555
|
thrown
|
|
13552
13556
|
});
|
|
13553
13557
|
try {
|
|
13554
|
-
writeResumeFailurePointer(io, await publish(
|
|
13558
|
+
writeResumeFailurePointer(io, await publish(failure));
|
|
13555
13559
|
} catch (publishError) {
|
|
13556
13560
|
const cause = {
|
|
13557
13561
|
publishError: formatErrorCauseDetail(publishError)
|
|
@@ -13565,18 +13569,18 @@ async function presentResumeFailurePointer(io, thrown, publish) {
|
|
|
13565
13569
|
}, io);
|
|
13566
13570
|
}
|
|
13567
13571
|
}
|
|
13568
|
-
async function writeResumeDiagnosticFile(runDirectory, runId,
|
|
13572
|
+
async function writeResumeDiagnosticFile(runDirectory, runId, failure, role) {
|
|
13569
13573
|
const dir = await ensureRealArtifactsDirectory(runDirectory);
|
|
13570
|
-
const path =
|
|
13574
|
+
const path = join30(dir, `resume-diagnostic-${randomUUID6()}.json`);
|
|
13571
13575
|
await writeFile7(
|
|
13572
13576
|
path,
|
|
13573
13577
|
`${JSON.stringify({
|
|
13574
13578
|
runId,
|
|
13575
13579
|
...role === void 0 ? {} : { role },
|
|
13576
|
-
diagnostic:
|
|
13577
|
-
...
|
|
13578
|
-
...
|
|
13579
|
-
...
|
|
13580
|
+
diagnostic: failure.diagnostic,
|
|
13581
|
+
...failure.cause === void 0 ? {} : { cause: failure.cause },
|
|
13582
|
+
...failure.identity === void 0 ? {} : { identity: failure.identity },
|
|
13583
|
+
...failure.details === void 0 ? {} : { details: failure.details }
|
|
13580
13584
|
}, null, 2)}
|
|
13581
13585
|
`,
|
|
13582
13586
|
{ encoding: "utf8", flag: "wx" }
|
|
@@ -13736,16 +13740,16 @@ var init_seat_ticket_binding = __esm({
|
|
|
13736
13740
|
// src/public-cli/machine-method-skills.ts
|
|
13737
13741
|
import { accessSync, constants as constants2, statSync as statSync4 } from "node:fs";
|
|
13738
13742
|
import { lstat as lstat5, mkdir as mkdir4, symlink } from "node:fs/promises";
|
|
13739
|
-
import { join as
|
|
13743
|
+
import { join as join31 } from "node:path";
|
|
13740
13744
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
13741
13745
|
function skillRoot(home) {
|
|
13742
|
-
return
|
|
13746
|
+
return join31(home, ".agents/skills");
|
|
13743
13747
|
}
|
|
13744
13748
|
function installedMethodSkillPath(home, name) {
|
|
13745
13749
|
return installedSkillPath(skillRoot(home), name);
|
|
13746
13750
|
}
|
|
13747
13751
|
function installedSkillPath(root, name) {
|
|
13748
|
-
const path =
|
|
13752
|
+
const path = join31(root, name, "SKILL.md");
|
|
13749
13753
|
try {
|
|
13750
13754
|
if (!statSync4(path).isFile()) return void 0;
|
|
13751
13755
|
accessSync(path, constants2.R_OK);
|
|
@@ -13758,9 +13762,9 @@ function installedSkillPath(root, name) {
|
|
|
13758
13762
|
}
|
|
13759
13763
|
function linkedSkillRoot(home, host) {
|
|
13760
13764
|
if (host === "claude" || host === "claude-code") {
|
|
13761
|
-
return
|
|
13765
|
+
return join31(process.env.CLAUDE_CONFIG_DIR?.trim() || join31(home, ".claude"), "skills");
|
|
13762
13766
|
}
|
|
13763
|
-
if (host === "hermes") return
|
|
13767
|
+
if (host === "hermes") return join31(home, ".hermes/skills");
|
|
13764
13768
|
return void 0;
|
|
13765
13769
|
}
|
|
13766
13770
|
async function occupied(path) {
|
|
@@ -13817,7 +13821,7 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
13817
13821
|
const missingBySource = /* @__PURE__ */ new Map();
|
|
13818
13822
|
let unsourced = false;
|
|
13819
13823
|
for (const name of packagedMethodSkillNames()) {
|
|
13820
|
-
const path =
|
|
13824
|
+
const path = join31(canonical, name);
|
|
13821
13825
|
if (await occupied(path)) {
|
|
13822
13826
|
warnOccupied(path, stdout);
|
|
13823
13827
|
continue;
|
|
@@ -13839,17 +13843,17 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
13839
13843
|
if (unsourced) return 1;
|
|
13840
13844
|
for (const host of ["claude-code", "hermes"]) {
|
|
13841
13845
|
const root = linkedSkillRoot(home, host);
|
|
13842
|
-
const
|
|
13846
|
+
const description = host === "claude-code" ? HEADLESS_HOST_DESCRIPTIONS.claude : HOST_DESCRIPTIONS.hermes;
|
|
13843
13847
|
try {
|
|
13844
|
-
accessSync(
|
|
13848
|
+
accessSync(resolveHostBinary(description, home), constants2.X_OK);
|
|
13845
13849
|
} catch (error) {
|
|
13846
13850
|
if (["ENOENT", "ENOTDIR", "EACCES"].includes(error.code ?? "")) continue;
|
|
13847
13851
|
throw error;
|
|
13848
13852
|
}
|
|
13849
13853
|
for (const name of packagedMethodSkillNames()) {
|
|
13850
|
-
const target =
|
|
13854
|
+
const target = join31(canonical, name);
|
|
13851
13855
|
if (installedMethodSkillPath(home, name) === void 0) continue;
|
|
13852
|
-
const link =
|
|
13856
|
+
const link = join31(root, name);
|
|
13853
13857
|
if (await occupied(link)) {
|
|
13854
13858
|
warnOccupied(link, stdout);
|
|
13855
13859
|
continue;
|
|
@@ -15058,10 +15062,10 @@ var init_analyst_book_key = __esm({
|
|
|
15058
15062
|
// src/atomic-write.ts
|
|
15059
15063
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
15060
15064
|
import { rename as rename3, rm as rm4, writeFile as writeFile8 } from "node:fs/promises";
|
|
15061
|
-
import { dirname as dirname19, join as
|
|
15065
|
+
import { dirname as dirname19, join as join32 } from "node:path";
|
|
15062
15066
|
async function writeFileAtomically(destination, contents) {
|
|
15063
15067
|
const parent = dirname19(destination);
|
|
15064
|
-
const temporary =
|
|
15068
|
+
const temporary = join32(parent, `.atomic-write-${randomUUID7()}.tmp`);
|
|
15065
15069
|
try {
|
|
15066
15070
|
await writeFile8(temporary, contents);
|
|
15067
15071
|
await rename3(temporary, destination);
|
|
@@ -15078,7 +15082,7 @@ var init_atomic_write = __esm({
|
|
|
15078
15082
|
|
|
15079
15083
|
// src/analyst-index.ts
|
|
15080
15084
|
import { open as open2, readFile as readFile17, unlink as unlink4 } from "node:fs/promises";
|
|
15081
|
-
import { dirname as dirname20, join as
|
|
15085
|
+
import { dirname as dirname20, join as join33 } from "node:path";
|
|
15082
15086
|
function sleep(ms) {
|
|
15083
15087
|
return new Promise((resolve22) => {
|
|
15084
15088
|
setTimeout(resolve22, ms);
|
|
@@ -15087,7 +15091,7 @@ function sleep(ms) {
|
|
|
15087
15091
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
15088
15092
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
15089
15093
|
ensureRealDirectoryTree(ledgerHome, dirname20(indexPath));
|
|
15090
|
-
const lockPath =
|
|
15094
|
+
const lockPath = join33(dirname20(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
15091
15095
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
15092
15096
|
const startedAt = Date.now();
|
|
15093
15097
|
while (true) {
|
|
@@ -15114,7 +15118,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
15114
15118
|
}
|
|
15115
15119
|
}
|
|
15116
15120
|
function analystLibraryIndexPath(ledgerHome) {
|
|
15117
|
-
return
|
|
15121
|
+
return join33(ledgerHome, "analyst", "library-index.json");
|
|
15118
15122
|
}
|
|
15119
15123
|
function rowFromIssueMetricsPage(page) {
|
|
15120
15124
|
return {
|
|
@@ -15410,7 +15414,7 @@ var init_analyst_cohort = __esm({
|
|
|
15410
15414
|
|
|
15411
15415
|
// src/analyst-ledger.ts
|
|
15412
15416
|
import { readdir as readdir6, readFile as readFile18 } from "node:fs/promises";
|
|
15413
|
-
import { basename as basename8, join as
|
|
15417
|
+
import { basename as basename8, join as join34 } from "node:path";
|
|
15414
15418
|
function isMissingPathError6(error) {
|
|
15415
15419
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
15416
15420
|
}
|
|
@@ -15439,7 +15443,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
|
|
|
15439
15443
|
}
|
|
15440
15444
|
}
|
|
15441
15445
|
async function classifyGhostCandidate(input) {
|
|
15442
|
-
const autopsy = await autopsyWriterLock(
|
|
15446
|
+
const autopsy = await autopsyWriterLock(join34(input.runDirectory, "writer.lock"));
|
|
15443
15447
|
const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
|
|
15444
15448
|
if (leaseCheck === void 0) return { kind: "live" };
|
|
15445
15449
|
return {
|
|
@@ -15468,7 +15472,7 @@ async function listLedgerBookNames(booksRoot) {
|
|
|
15468
15472
|
async function readInvocationScopeFields(runDirectory) {
|
|
15469
15473
|
let raw;
|
|
15470
15474
|
try {
|
|
15471
|
-
raw = await readFile18(
|
|
15475
|
+
raw = await readFile18(join34(runDirectory, "invocation.json"), "utf8");
|
|
15472
15476
|
} catch (error) {
|
|
15473
15477
|
if (isMissingPathError6(error)) return void 0;
|
|
15474
15478
|
throw error;
|
|
@@ -15501,7 +15505,7 @@ function decideIssueScope(input) {
|
|
|
15501
15505
|
}
|
|
15502
15506
|
async function resolveSessionFile(runDirectory) {
|
|
15503
15507
|
try {
|
|
15504
|
-
const raw = await readFile18(
|
|
15508
|
+
const raw = await readFile18(join34(runDirectory, "invocation.json"), "utf8");
|
|
15505
15509
|
const parsed = JSON.parse(raw);
|
|
15506
15510
|
if (isRecord12(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
15507
15511
|
return parsed.sessionFile;
|
|
@@ -15509,7 +15513,7 @@ async function resolveSessionFile(runDirectory) {
|
|
|
15509
15513
|
} catch (error) {
|
|
15510
15514
|
if (!isMissingPathError6(error)) throw error;
|
|
15511
15515
|
}
|
|
15512
|
-
return
|
|
15516
|
+
return join34(runDirectory, "session", "session.jsonl");
|
|
15513
15517
|
}
|
|
15514
15518
|
function attributeSessionRowsForRun(input) {
|
|
15515
15519
|
if (pathContainedIn(input.runDirectory, input.sessionFile)) {
|
|
@@ -15711,9 +15715,9 @@ async function classifyScopedRun(input) {
|
|
|
15711
15715
|
}
|
|
15712
15716
|
let gateCycles;
|
|
15713
15717
|
try {
|
|
15714
|
-
const parentSessionFile =
|
|
15718
|
+
const parentSessionFile = join34(input.runDirectory, "session", "session.jsonl");
|
|
15715
15719
|
gateCycles = await readAnalystGateCyclesFromAuditorRoles(
|
|
15716
|
-
|
|
15720
|
+
join34(input.runDirectory, "session", "auditor-roles"),
|
|
15717
15721
|
{ parentSessionFile }
|
|
15718
15722
|
);
|
|
15719
15723
|
} catch (error) {
|
|
@@ -15748,7 +15752,7 @@ async function classifyScopedRun(input) {
|
|
|
15748
15752
|
async function scanAnalystIssueRuns(input) {
|
|
15749
15753
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
15750
15754
|
const scopeTicketNumber = input.ticketNumber;
|
|
15751
|
-
const booksRoot =
|
|
15755
|
+
const booksRoot = join34(ledgerHome, "books");
|
|
15752
15756
|
let wholeBook = false;
|
|
15753
15757
|
let scopeRootIdentity;
|
|
15754
15758
|
let bookNames;
|
|
@@ -15781,7 +15785,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
15781
15785
|
const ghostLegs = [];
|
|
15782
15786
|
const scopeConflicts = [];
|
|
15783
15787
|
for (const book of bookNames) {
|
|
15784
|
-
const bookDir =
|
|
15788
|
+
const bookDir = join34(booksRoot, book);
|
|
15785
15789
|
let runDirectories;
|
|
15786
15790
|
try {
|
|
15787
15791
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
@@ -16518,7 +16522,7 @@ var init_analyst_metric_family = __esm({
|
|
|
16518
16522
|
|
|
16519
16523
|
// src/analyst-page.ts
|
|
16520
16524
|
import { createHash as createHash3 } from "node:crypto";
|
|
16521
|
-
import { dirname as dirname21, join as
|
|
16525
|
+
import { dirname as dirname21, join as join35 } from "node:path";
|
|
16522
16526
|
function analystIssuePageKey(address) {
|
|
16523
16527
|
const parts = ["book", address.bookKey];
|
|
16524
16528
|
if (address.issueNumber !== void 0) {
|
|
@@ -16529,7 +16533,7 @@ function analystIssuePageKey(address) {
|
|
|
16529
16533
|
return createHash3("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
16530
16534
|
}
|
|
16531
16535
|
function analystIssuePagePath(ledgerHome, address) {
|
|
16532
|
-
return
|
|
16536
|
+
return join35(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
16533
16537
|
}
|
|
16534
16538
|
function analystIssuePageAddressFromPage(page) {
|
|
16535
16539
|
return {
|
|
@@ -17168,7 +17172,7 @@ __export(cli_exports, {
|
|
|
17168
17172
|
runAkRole: () => runAkRole
|
|
17169
17173
|
});
|
|
17170
17174
|
import { realpath as realpath5 } from "node:fs/promises";
|
|
17171
|
-
import { join as
|
|
17175
|
+
import { join as join36 } from "node:path";
|
|
17172
17176
|
function publicSeatArgv(owner) {
|
|
17173
17177
|
return {
|
|
17174
17178
|
parse: (args) => parsePublicSeatArgv(owner, args),
|
|
@@ -17307,7 +17311,7 @@ function resolveHome(env) {
|
|
|
17307
17311
|
return env.home ?? packageMachineHome();
|
|
17308
17312
|
}
|
|
17309
17313
|
function resolveAgentDir(env, home) {
|
|
17310
|
-
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
17314
|
+
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join36(home, ".pi", "agent");
|
|
17311
17315
|
}
|
|
17312
17316
|
function parseThinking(value) {
|
|
17313
17317
|
return value;
|
|
@@ -18079,7 +18083,7 @@ __export(public_role_summons_exports, {
|
|
|
18079
18083
|
import { execFile as execFile3 } from "node:child_process";
|
|
18080
18084
|
import { existsSync as existsSync9 } from "node:fs";
|
|
18081
18085
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
18082
|
-
import { join as
|
|
18086
|
+
import { join as join37 } from "node:path";
|
|
18083
18087
|
import { promisify as promisify3 } from "node:util";
|
|
18084
18088
|
function createCapturingIo() {
|
|
18085
18089
|
const chunks = [];
|
|
@@ -18103,7 +18107,7 @@ function parentDir(path) {
|
|
|
18103
18107
|
function walkPackageRoot(start) {
|
|
18104
18108
|
let dir = start;
|
|
18105
18109
|
for (let i = 0; i < 12; i += 1) {
|
|
18106
|
-
if (existsSync9(
|
|
18110
|
+
if (existsSync9(join37(dir, "package.json")) && existsSync9(join37(dir, "souls"))) {
|
|
18107
18111
|
return dir;
|
|
18108
18112
|
}
|
|
18109
18113
|
const parent = parentDir(dir);
|
|
@@ -18153,8 +18157,8 @@ function projectSeatHost2(seat) {
|
|
|
18153
18157
|
function hostSelectionFailureFromUnknown(error) {
|
|
18154
18158
|
if (typeof error !== "object" || error === null) return void 0;
|
|
18155
18159
|
if (error.name !== "HostSelectionError") return void 0;
|
|
18156
|
-
const
|
|
18157
|
-
return
|
|
18160
|
+
const failure = error.failure;
|
|
18161
|
+
return failure;
|
|
18158
18162
|
}
|
|
18159
18163
|
async function createSummonEnv(options, afterHost) {
|
|
18160
18164
|
const [
|
|
@@ -18219,7 +18223,7 @@ async function createSummonEnv(options, afterHost) {
|
|
|
18219
18223
|
async function summonPublicRole(options) {
|
|
18220
18224
|
const packageRoot = resolveSummonsPackageRoot(options.packageRoot);
|
|
18221
18225
|
const home = await resolveSummonHome(options);
|
|
18222
|
-
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
18226
|
+
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join37(home, ".pi", "agent");
|
|
18223
18227
|
const {
|
|
18224
18228
|
loadCredentialProviders: loadCredentialProviders2,
|
|
18225
18229
|
loadPublicCliConfig: loadPublicCliConfig2,
|
|
@@ -18287,10 +18291,10 @@ async function summonPublicRole(options) {
|
|
|
18287
18291
|
}
|
|
18288
18292
|
};
|
|
18289
18293
|
} catch (error) {
|
|
18290
|
-
const
|
|
18291
|
-
if (
|
|
18294
|
+
const failure = hostSelectionFailureFromUnknown(error);
|
|
18295
|
+
if (failure !== void 0) {
|
|
18292
18296
|
const { formatHostSelectionFailure: formatHostSelectionFailure2 } = await Promise.resolve().then(() => (init_role_turn_host_resolution(), role_turn_host_resolution_exports));
|
|
18293
|
-
return { ok: false, exitCode: 1, stderr: formatHostSelectionFailure2(
|
|
18297
|
+
return { ok: false, exitCode: 1, stderr: formatHostSelectionFailure2(failure) };
|
|
18294
18298
|
}
|
|
18295
18299
|
const { CliUsageError: CliUsageError2 } = await Promise.resolve().then(() => (init_cli_errors(), cli_errors_exports));
|
|
18296
18300
|
if (error instanceof CliUsageError2) {
|
|
@@ -18386,8 +18390,8 @@ async function summonParallelReviewerLenses(options) {
|
|
|
18386
18390
|
stderr: describeFailure(error)
|
|
18387
18391
|
});
|
|
18388
18392
|
const dualFailure = (error) => {
|
|
18389
|
-
const
|
|
18390
|
-
return { completeness:
|
|
18393
|
+
const failure = failedResult(error);
|
|
18394
|
+
return { completeness: failure, correctness: failure };
|
|
18391
18395
|
};
|
|
18392
18396
|
let sourceProjectRoot;
|
|
18393
18397
|
let targetCommit;
|
|
@@ -18727,7 +18731,7 @@ var init_compliance_transport = __esm({
|
|
|
18727
18731
|
});
|
|
18728
18732
|
|
|
18729
18733
|
// src/role-run-relocation.ts
|
|
18730
|
-
import { join as
|
|
18734
|
+
import { join as join38, sep as sep5 } from "node:path";
|
|
18731
18735
|
function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
|
|
18732
18736
|
if (typeof value !== "string") return value;
|
|
18733
18737
|
if (value === oldRunDirectory) return newRunDirectory;
|
|
@@ -18855,7 +18859,7 @@ __export(run_lifecycle_exports, {
|
|
|
18855
18859
|
writeRoleRunState: () => writeRoleRunState
|
|
18856
18860
|
});
|
|
18857
18861
|
import { chmod, lstat as lstat6, open as open3, readdir as readdir7, readFile as readFile21, unlink as unlink5, writeFile as writeFile9 } from "node:fs/promises";
|
|
18858
|
-
import { basename as basename9, join as
|
|
18862
|
+
import { basename as basename9, join as join39 } from "node:path";
|
|
18859
18863
|
function buildAutoResumeContinuationPrompt(options) {
|
|
18860
18864
|
return appendEngineSessionMaterial(
|
|
18861
18865
|
[RESUME_TRANSPORT_ENVELOPE],
|
|
@@ -18881,7 +18885,7 @@ function renderResumeCommand(runId) {
|
|
|
18881
18885
|
async function writeRoleRunState(runDirectory, record4) {
|
|
18882
18886
|
const payload = { ...record4, runDirectory };
|
|
18883
18887
|
await writeFile9(
|
|
18884
|
-
|
|
18888
|
+
join39(runDirectory, RUN_STATE_FILE),
|
|
18885
18889
|
`${JSON.stringify(payload, null, 2)}
|
|
18886
18890
|
`,
|
|
18887
18891
|
"utf8"
|
|
@@ -18931,7 +18935,7 @@ function parseCurrentCourtState(raw) {
|
|
|
18931
18935
|
async function readRoleRunStateRaw(runDirectory) {
|
|
18932
18936
|
let raw;
|
|
18933
18937
|
try {
|
|
18934
|
-
raw = JSON.parse(await readFile21(
|
|
18938
|
+
raw = JSON.parse(await readFile21(join39(runDirectory, RUN_STATE_FILE), "utf8"));
|
|
18935
18939
|
} catch (error) {
|
|
18936
18940
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
18937
18941
|
throw error;
|
|
@@ -19025,7 +19029,7 @@ async function writeRoleRunStateDisk(runDirectory, disk) {
|
|
|
19025
19029
|
...disk.currentCourt === void 0 ? {} : { currentCourt: disk.currentCourt }
|
|
19026
19030
|
};
|
|
19027
19031
|
await writeFile9(
|
|
19028
|
-
|
|
19032
|
+
join39(runDirectory, RUN_STATE_FILE),
|
|
19029
19033
|
`${JSON.stringify(payload, null, 2)}
|
|
19030
19034
|
`,
|
|
19031
19035
|
"utf8"
|
|
@@ -19248,7 +19252,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
|
|
|
19248
19252
|
},
|
|
19249
19253
|
relocate(nextRunDirectory) {
|
|
19250
19254
|
currentRunDirectory = nextRunDirectory;
|
|
19251
|
-
currentLockPath =
|
|
19255
|
+
currentLockPath = join39(nextRunDirectory, WRITER_LOCK_FILE);
|
|
19252
19256
|
},
|
|
19253
19257
|
async release() {
|
|
19254
19258
|
if (released) return;
|
|
@@ -19287,10 +19291,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
19287
19291
|
};
|
|
19288
19292
|
const reportReadFailure = (error) => {
|
|
19289
19293
|
reportDiagnostic(
|
|
19290
|
-
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${
|
|
19294
|
+
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join39(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
|
|
19291
19295
|
);
|
|
19292
19296
|
};
|
|
19293
|
-
const lockPath =
|
|
19297
|
+
const lockPath = join39(runDirectory, WRITER_LOCK_FILE);
|
|
19294
19298
|
let lastAutopsy = { verdict: "absent" };
|
|
19295
19299
|
let lastReclaimFailure;
|
|
19296
19300
|
for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
|
|
@@ -19345,7 +19349,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
19345
19349
|
async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
19346
19350
|
if (runId.trim() === "") return void 0;
|
|
19347
19351
|
const ledgerHome = resolveActivationLedgerHome(home);
|
|
19348
|
-
const booksRoot =
|
|
19352
|
+
const booksRoot = join39(ledgerHome, "books");
|
|
19349
19353
|
let bookKeys;
|
|
19350
19354
|
try {
|
|
19351
19355
|
bookKeys = await readdir7(booksRoot);
|
|
@@ -19386,7 +19390,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
19386
19390
|
let raw;
|
|
19387
19391
|
try {
|
|
19388
19392
|
raw = JSON.parse(
|
|
19389
|
-
await readFile21(
|
|
19393
|
+
await readFile21(join39(runDirectory, "admitted-request.json"), "utf8")
|
|
19390
19394
|
);
|
|
19391
19395
|
} catch (error) {
|
|
19392
19396
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -19407,7 +19411,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
19407
19411
|
async function runHasFormedSessionPrincipal(runDirectory) {
|
|
19408
19412
|
const disk = await readRoleRunStateDisk(runDirectory);
|
|
19409
19413
|
if (disk === void 0) return false;
|
|
19410
|
-
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile :
|
|
19414
|
+
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : join39(disk.principalWire.sessionDirectory, "session.jsonl");
|
|
19411
19415
|
try {
|
|
19412
19416
|
const stat2 = await lstat6(sessionFile);
|
|
19413
19417
|
return stat2.isFile() && !stat2.isSymbolicLink();
|
|
@@ -19425,7 +19429,7 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
19425
19429
|
let runDirectories;
|
|
19426
19430
|
try {
|
|
19427
19431
|
runDirectories = await listBookRunDirectories(
|
|
19428
|
-
input.ticketNumber === void 0 ? bookDir :
|
|
19432
|
+
input.ticketNumber === void 0 ? bookDir : join39(bookDir, String(input.ticketNumber))
|
|
19429
19433
|
);
|
|
19430
19434
|
} catch (error) {
|
|
19431
19435
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -19623,7 +19627,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19623
19627
|
let model;
|
|
19624
19628
|
try {
|
|
19625
19629
|
const invocationRaw = JSON.parse(
|
|
19626
|
-
await readFile21(
|
|
19630
|
+
await readFile21(join39(run.runDirectory, "invocation.json"), "utf8")
|
|
19627
19631
|
);
|
|
19628
19632
|
if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
|
|
19629
19633
|
const rec = invocationRaw;
|
|
@@ -19991,7 +19995,7 @@ var init_run_lifecycle = __esm({
|
|
|
19991
19995
|
});
|
|
19992
19996
|
|
|
19993
19997
|
// src/submission-ledger.ts
|
|
19994
|
-
import { join as
|
|
19998
|
+
import { join as join40 } from "node:path";
|
|
19995
19999
|
function runIdentity(context) {
|
|
19996
20000
|
const directory = runDirectoryFromHostContext(context);
|
|
19997
20001
|
if (directory !== void 0) {
|
|
@@ -20013,7 +20017,7 @@ async function submissionRecordFile(cwd, runId, scope) {
|
|
|
20013
20017
|
if (sessionParent === void 0) {
|
|
20014
20018
|
const discoveredRun = await findRunDirectoryById(scope.home, runId);
|
|
20015
20019
|
if (discoveredRun === void 0) return void 0;
|
|
20016
|
-
sessionParent =
|
|
20020
|
+
sessionParent = join40(discoveredRun, "session", "session.jsonl");
|
|
20017
20021
|
}
|
|
20018
20022
|
return resolveSitianRecordPathInLedger({
|
|
20019
20023
|
level: "event",
|
|
@@ -20206,12 +20210,12 @@ async function restoreState(cwd, runId, scope) {
|
|
|
20206
20210
|
}
|
|
20207
20211
|
function sessionParentFromHostContext(context) {
|
|
20208
20212
|
const runDirectory = runDirectoryFromHostContext(context);
|
|
20209
|
-
if (runDirectory !== void 0) return
|
|
20213
|
+
if (runDirectory !== void 0) return join40(runDirectory, "session", "session.jsonl");
|
|
20210
20214
|
const sessionFile = context.sessionManager.getSessionFile?.();
|
|
20211
20215
|
if (typeof sessionFile === "string" && sessionFile.length > 0) return sessionFile;
|
|
20212
20216
|
const sessionDir = context.sessionManager.getSessionDir?.();
|
|
20213
20217
|
if (typeof sessionDir === "string" && sessionDir.length > 0) {
|
|
20214
|
-
return
|
|
20218
|
+
return join40(sessionDir, "session.jsonl");
|
|
20215
20219
|
}
|
|
20216
20220
|
return void 0;
|
|
20217
20221
|
}
|
|
@@ -20391,7 +20395,7 @@ var init_submission_ledger = __esm({
|
|
|
20391
20395
|
|
|
20392
20396
|
// src/archivist-record-topology.ts
|
|
20393
20397
|
import { createHash as createHash4 } from "node:crypto";
|
|
20394
|
-
import { join as
|
|
20398
|
+
import { join as join42 } from "node:path";
|
|
20395
20399
|
function resolveNavigatorWorkSubjectPlacement(input) {
|
|
20396
20400
|
let ledgerHome;
|
|
20397
20401
|
if (input.parentSessionFile !== void 0 && input.parentSessionFile.length > 0) {
|
|
@@ -20404,7 +20408,7 @@ function resolveNavigatorWorkSubjectPlacement(input) {
|
|
|
20404
20408
|
const digest = createHash4("sha256").update(input.subject).digest("hex").slice(0, 32);
|
|
20405
20409
|
return {
|
|
20406
20410
|
ledgerHome,
|
|
20407
|
-
sessionDir:
|
|
20411
|
+
sessionDir: join42(
|
|
20408
20412
|
activationBookDirectory(ledgerHome, resolveBookKeyFromGit(input.cwd)),
|
|
20409
20413
|
NAVIGATOR_RECORD_KIND,
|
|
20410
20414
|
digest
|
|
@@ -20476,10 +20480,10 @@ import {
|
|
|
20476
20480
|
statSync as statSync7,
|
|
20477
20481
|
writeFileSync as writeFileSync3
|
|
20478
20482
|
} from "node:fs";
|
|
20479
|
-
import { dirname as dirname23, resolve as resolve17, join as
|
|
20483
|
+
import { dirname as dirname23, resolve as resolve17, join as join43 } from "node:path";
|
|
20480
20484
|
import { StringDecoder } from "node:string_decoder";
|
|
20481
20485
|
function readCurrentSession(sessionDir) {
|
|
20482
|
-
const ledger =
|
|
20486
|
+
const ledger = join43(sessionDir, CURRENT_SESSION_LEDGER);
|
|
20483
20487
|
try {
|
|
20484
20488
|
const value = JSON.parse(readFileSync4(ledger, "utf8"));
|
|
20485
20489
|
if (typeof value !== "object" || value === null || typeof value.sessionFile !== "string" || value.sessionFile.length === 0) {
|
|
@@ -20494,7 +20498,7 @@ function readCurrentSession(sessionDir) {
|
|
|
20494
20498
|
}
|
|
20495
20499
|
}
|
|
20496
20500
|
function writeCurrentSession(sessionDir, sessionFile) {
|
|
20497
|
-
const ledger =
|
|
20501
|
+
const ledger = join43(sessionDir, CURRENT_SESSION_LEDGER);
|
|
20498
20502
|
try {
|
|
20499
20503
|
writeFileSync3(ledger, `${JSON.stringify({ sessionFile })}
|
|
20500
20504
|
`, { flag: "wx" });
|
|
@@ -20510,7 +20514,7 @@ function isCurrentSessionClaimRace(error) {
|
|
|
20510
20514
|
return errnoCode(error.cause) === "EEXIST";
|
|
20511
20515
|
}
|
|
20512
20516
|
function currentSessionLedgerPath(sessionDir) {
|
|
20513
|
-
return
|
|
20517
|
+
return join43(sessionDir, CURRENT_SESSION_LEDGER);
|
|
20514
20518
|
}
|
|
20515
20519
|
function readBoundedSessionHeader(filePath) {
|
|
20516
20520
|
const fd = openSync2(filePath, "r");
|
|
@@ -20597,7 +20601,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
|
|
|
20597
20601
|
const matched = [];
|
|
20598
20602
|
for (const name of names) {
|
|
20599
20603
|
if (!name.endsWith(".jsonl")) continue;
|
|
20600
|
-
const filePath =
|
|
20604
|
+
const filePath = join43(absoluteSessionDir, name);
|
|
20601
20605
|
let st;
|
|
20602
20606
|
try {
|
|
20603
20607
|
st = statSync7(filePath);
|
|
@@ -20709,7 +20713,7 @@ function createRecordSessionOpen(options, host = piRecordSessionHost) {
|
|
|
20709
20713
|
if (!physicallyContainedIn(ledgerHome, parentResolved)) {
|
|
20710
20714
|
throw new Error("Durable record ownership requires a parent session inside the ledger home");
|
|
20711
20715
|
}
|
|
20712
|
-
sessionDir =
|
|
20716
|
+
sessionDir = join43(dirname23(parentResolved), options.kind);
|
|
20713
20717
|
parentSession = parentFile;
|
|
20714
20718
|
mayResumeSameNest = options.kind === WORKER_SUBMISSION_GATE_KIND;
|
|
20715
20719
|
}
|
|
@@ -20772,6 +20776,7 @@ var init_archivist_record_entry = __esm({
|
|
|
20772
20776
|
});
|
|
20773
20777
|
|
|
20774
20778
|
// src/acp-host/production-host.ts
|
|
20779
|
+
init_host_descriptions();
|
|
20775
20780
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
20776
20781
|
|
|
20777
20782
|
// src/role-envelope.ts
|
|
@@ -20780,7 +20785,7 @@ init_packaged_role_registry();
|
|
|
20780
20785
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
20781
20786
|
import { appendFile as appendFile3, mkdir as mkdir5, writeFile as writeFile10 } from "node:fs/promises";
|
|
20782
20787
|
import { createServer } from "node:net";
|
|
20783
|
-
import { dirname as dirname25, join as
|
|
20788
|
+
import { dirname as dirname25, join as join46 } from "node:path";
|
|
20784
20789
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
20785
20790
|
|
|
20786
20791
|
// src/role-runtime.ts
|
|
@@ -20789,7 +20794,7 @@ init_sitian_facade();
|
|
|
20789
20794
|
init_submission_ledger();
|
|
20790
20795
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
20791
20796
|
import { readFileSync as readFileSync6, writeSync as writeSync2 } from "node:fs";
|
|
20792
|
-
import { join as
|
|
20797
|
+
import { join as join45 } from "node:path";
|
|
20793
20798
|
import { Value as Value4 } from "typebox/value";
|
|
20794
20799
|
|
|
20795
20800
|
// src/activation-trace.ts
|
|
@@ -21859,10 +21864,10 @@ init_packaged_role_registry();
|
|
|
21859
21864
|
init_atomic_write();
|
|
21860
21865
|
import { existsSync as existsSync10, realpathSync as realpathSync3 } from "node:fs";
|
|
21861
21866
|
import { readFile as readFile22 } from "node:fs/promises";
|
|
21862
|
-
import { basename as basename10, dirname as dirname22, join as
|
|
21867
|
+
import { basename as basename10, dirname as dirname22, join as join41, resolve as resolve16 } from "node:path";
|
|
21863
21868
|
var NAVIGATOR_WORK_CONTEXT_BASENAME = "work-context.json";
|
|
21864
21869
|
function navigatorWorkContextFile(sessionDir) {
|
|
21865
|
-
return
|
|
21870
|
+
return join41(sessionDir, NAVIGATOR_WORK_CONTEXT_BASENAME);
|
|
21866
21871
|
}
|
|
21867
21872
|
function isNavigatorWorkContextFile(path) {
|
|
21868
21873
|
const resolved = resolve16(path);
|
|
@@ -22279,12 +22284,12 @@ function createNavigatorAttendance(options) {
|
|
|
22279
22284
|
return { ...options.context, signal };
|
|
22280
22285
|
};
|
|
22281
22286
|
const unavailable = (invocationId, reason) => {
|
|
22282
|
-
const
|
|
22287
|
+
const failure = reason instanceof NavigatorUnavailableError ? reason : navigatorUnavailableError("unknown", reason);
|
|
22283
22288
|
return {
|
|
22284
22289
|
disposition: "unavailable",
|
|
22285
|
-
unavailableReason:
|
|
22286
|
-
unavailableSource:
|
|
22287
|
-
unavailableCause:
|
|
22290
|
+
unavailableReason: failure.message,
|
|
22291
|
+
unavailableSource: failure.unavailableSource,
|
|
22292
|
+
unavailableCause: failure.unavailableCause
|
|
22288
22293
|
};
|
|
22289
22294
|
};
|
|
22290
22295
|
let prepareBoundSettlement;
|
|
@@ -23710,7 +23715,7 @@ function readDiaristTicketAssertion(submitted) {
|
|
|
23710
23715
|
function readRoleRunCoordinates(ctx, label) {
|
|
23711
23716
|
const runDirectory = runDirectoryFromHostContext(ctx);
|
|
23712
23717
|
if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
|
|
23713
|
-
const admittedPath =
|
|
23718
|
+
const admittedPath = join45(runDirectory, "admitted-request.json");
|
|
23714
23719
|
const admitted = JSON.parse(readFileSync6(admittedPath, "utf8"));
|
|
23715
23720
|
if (typeof admitted.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
|
|
23716
23721
|
throw new Error(`${label} admitted-request missing projectRoot (${admittedPath})`);
|
|
@@ -24633,7 +24638,7 @@ async function prepareRoleEnvelope(options) {
|
|
|
24633
24638
|
const hostAbort = new AbortController();
|
|
24634
24639
|
const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID9();
|
|
24635
24640
|
await mkdir5(request.runDirectory, { recursive: true });
|
|
24636
|
-
let sessionFile = options.sessionFile ??
|
|
24641
|
+
let sessionFile = options.sessionFile ?? join46(request.runDirectory, "session", "session.jsonl");
|
|
24637
24642
|
await mkdir5(dirname25(sessionFile), { recursive: true });
|
|
24638
24643
|
if (request.continuation.kind !== "resume") {
|
|
24639
24644
|
try {
|
|
@@ -25298,10 +25303,6 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
25298
25303
|
init_session_identity();
|
|
25299
25304
|
|
|
25300
25305
|
// src/acp-host/description.ts
|
|
25301
|
-
import { join as join46 } from "node:path";
|
|
25302
|
-
function resolveAcpBinary(description, operatorHome) {
|
|
25303
|
-
return join46(operatorHome, ...description.binaryFromHome);
|
|
25304
|
-
}
|
|
25305
25306
|
function acpStdioArgs(description, model, seat) {
|
|
25306
25307
|
const { prefix, suffix, modelFlag, thinkingFlag } = description.argv;
|
|
25307
25308
|
const pair = (flag, value) => flag === void 0 || value === void 0 ? [] : [flag, value];
|
|
@@ -25365,6 +25366,27 @@ function raceAgainstHostAbort(work, abortSignal, message = "host aborted") {
|
|
|
25365
25366
|
);
|
|
25366
25367
|
});
|
|
25367
25368
|
}
|
|
25369
|
+
function externalHostFailure(cause, name, code, details, diagnostic) {
|
|
25370
|
+
return asFailure({
|
|
25371
|
+
cause,
|
|
25372
|
+
identity: { name, code },
|
|
25373
|
+
...diagnostic === void 0 ? {} : { diagnostic },
|
|
25374
|
+
...details === void 0 ? {} : { details }
|
|
25375
|
+
});
|
|
25376
|
+
}
|
|
25377
|
+
function withExternalHostCleanupFailure(outcome, cleanupError, name) {
|
|
25378
|
+
const message = cleanupError instanceof Error ? cleanupError.message : String(cleanupError);
|
|
25379
|
+
if (outcome.knownFailure === void 0) {
|
|
25380
|
+
return externalHostFailure("session", name, "dispose-failed", { cleanupError: message }, message);
|
|
25381
|
+
}
|
|
25382
|
+
return {
|
|
25383
|
+
...outcome,
|
|
25384
|
+
knownFailure: {
|
|
25385
|
+
...outcome.knownFailure,
|
|
25386
|
+
details: { ...outcome.knownFailure.details ?? {}, cleanupError: message }
|
|
25387
|
+
}
|
|
25388
|
+
};
|
|
25389
|
+
}
|
|
25368
25390
|
function asFailure(knownFailure, stderr = "") {
|
|
25369
25391
|
return { code: null, stderr, timedOut: false, knownFailure };
|
|
25370
25392
|
}
|
|
@@ -25436,6 +25458,10 @@ function renderAgentStartMaterials(body, materials) {
|
|
|
25436
25458
|
function renderSystemPromptOverride(authority) {
|
|
25437
25459
|
return renderAgentStartMaterials(authority.body, authority.materials);
|
|
25438
25460
|
}
|
|
25461
|
+
async function resolveBoundHostSessionId(request, identity) {
|
|
25462
|
+
const explicit = request.continuation.kind === "resume" ? request.continuation.hostSessionId : void 0;
|
|
25463
|
+
return explicit !== void 0 && explicit !== "" ? explicit : identity.load(request.principal);
|
|
25464
|
+
}
|
|
25439
25465
|
|
|
25440
25466
|
// src/acp-host/role-turn-host.ts
|
|
25441
25467
|
function acpAgentTextChunk(params) {
|
|
@@ -25473,32 +25499,6 @@ function acpAgentTextChunk(params) {
|
|
|
25473
25499
|
if (typeof textFallback === "string" && textFallback.length > 0) return textFallback;
|
|
25474
25500
|
return void 0;
|
|
25475
25501
|
}
|
|
25476
|
-
function failure(cause, name, code, details, diagnostic) {
|
|
25477
|
-
return {
|
|
25478
|
-
code: null,
|
|
25479
|
-
stderr: "",
|
|
25480
|
-
timedOut: false,
|
|
25481
|
-
knownFailure: {
|
|
25482
|
-
cause,
|
|
25483
|
-
identity: { name, code },
|
|
25484
|
-
...diagnostic === void 0 ? {} : { diagnostic },
|
|
25485
|
-
...details === void 0 ? {} : { details }
|
|
25486
|
-
}
|
|
25487
|
-
};
|
|
25488
|
-
}
|
|
25489
|
-
function withCleanupFailure(outcome, cleanupError) {
|
|
25490
|
-
const message = cleanupError instanceof Error ? cleanupError.message : String(cleanupError);
|
|
25491
|
-
if (outcome.knownFailure === void 0) {
|
|
25492
|
-
return failure("session", "AcpDisposeFailure", "dispose-failed", { cleanupError: message }, message);
|
|
25493
|
-
}
|
|
25494
|
-
return {
|
|
25495
|
-
...outcome,
|
|
25496
|
-
knownFailure: {
|
|
25497
|
-
...outcome.knownFailure,
|
|
25498
|
-
details: { ...outcome.knownFailure.details ?? {}, cleanupError: message }
|
|
25499
|
-
}
|
|
25500
|
-
};
|
|
25501
|
-
}
|
|
25502
25502
|
function acpError(code, message, cause) {
|
|
25503
25503
|
return Object.assign(new Error(message, cause === void 0 ? void 0 : { cause }), { code });
|
|
25504
25504
|
}
|
|
@@ -25612,10 +25612,10 @@ function createAcpRoleTurnHost(config) {
|
|
|
25612
25612
|
let sessionOpened = false;
|
|
25613
25613
|
let accepted = false;
|
|
25614
25614
|
const sessionParent = config.sessionIdentity.resolveSessionFile(request.principal);
|
|
25615
|
-
let outcome =
|
|
25615
|
+
let outcome = externalHostFailure("session", "AcpNoOutcome", "no-outcome");
|
|
25616
25616
|
try {
|
|
25617
25617
|
if (prepared.mcpServers.length === 0) {
|
|
25618
|
-
outcome =
|
|
25618
|
+
outcome = externalHostFailure("activation", "UncontrolledAcpSession", "ak-config-missing");
|
|
25619
25619
|
} else {
|
|
25620
25620
|
connection = await config.connect(request);
|
|
25621
25621
|
const rpc = (method, params) => connection.request(method, params);
|
|
@@ -25636,7 +25636,7 @@ function createAcpRoleTurnHost(config) {
|
|
|
25636
25636
|
const initializeMeta = initialized._meta;
|
|
25637
25637
|
const availableModels = Array.isArray(initializeMeta?.modelState?.availableModels) ? initializeMeta.modelState.availableModels : void 0;
|
|
25638
25638
|
if (request.model !== void 0 && availableModels !== void 0 && !availableModels.some((entry) => typeof entry === "object" && entry !== null && entry.modelId === acpModelId(config.modelPassing, request.model))) {
|
|
25639
|
-
outcome =
|
|
25639
|
+
outcome = externalHostFailure("activation", "AcpHostModelMismatch", "host-model-mismatch", {
|
|
25640
25640
|
provider: request.model.provider,
|
|
25641
25641
|
model: request.model.model
|
|
25642
25642
|
});
|
|
@@ -25663,14 +25663,13 @@ function createAcpRoleTurnHost(config) {
|
|
|
25663
25663
|
};
|
|
25664
25664
|
let sessionReady = true;
|
|
25665
25665
|
if (request.continuation.kind === "resume") {
|
|
25666
|
-
const
|
|
25667
|
-
const boundSessionId = explicitHostSessionId !== void 0 && explicitHostSessionId !== "" ? explicitHostSessionId : await config.sessionIdentity.load(request.principal);
|
|
25666
|
+
const boundSessionId = await resolveBoundHostSessionId(request, config.sessionIdentity);
|
|
25668
25667
|
if (boundSessionId !== void 0 && boundSessionId !== "") {
|
|
25669
25668
|
sessionId = boundSessionId;
|
|
25670
25669
|
sessionId = await loadSession(boundSessionId);
|
|
25671
25670
|
sessionOpened = true;
|
|
25672
25671
|
} else {
|
|
25673
|
-
outcome =
|
|
25672
|
+
outcome = externalHostFailure(
|
|
25674
25673
|
"session",
|
|
25675
25674
|
"AcpSessionFailure",
|
|
25676
25675
|
"session-id-missing",
|
|
@@ -25683,7 +25682,7 @@ function createAcpRoleTurnHost(config) {
|
|
|
25683
25682
|
const session = await rpc("session/new", sessionBindParams);
|
|
25684
25683
|
sessionId = typeof session.sessionId === "string" ? session.sessionId : void 0;
|
|
25685
25684
|
if (sessionId === void 0 || sessionId === "") {
|
|
25686
|
-
outcome =
|
|
25685
|
+
outcome = externalHostFailure("session", "AcpSessionFailure", "session-id-missing");
|
|
25687
25686
|
sessionReady = false;
|
|
25688
25687
|
} else {
|
|
25689
25688
|
if (config.hostName !== "hermes") recordNativeSessionPointer({
|
|
@@ -25733,7 +25732,7 @@ function createAcpRoleTurnHost(config) {
|
|
|
25733
25732
|
agentProseChunks.length = 0;
|
|
25734
25733
|
return {
|
|
25735
25734
|
status: "terminal",
|
|
25736
|
-
result:
|
|
25735
|
+
result: externalHostFailure("output", "AcpRefusal", "refusal", { sessionId })
|
|
25737
25736
|
};
|
|
25738
25737
|
}
|
|
25739
25738
|
if (prepared.terminatingToolName === NAVIGATOR_OUTPUT_TOOL_NAME) {
|
|
@@ -25784,7 +25783,7 @@ function createAcpRoleTurnHost(config) {
|
|
|
25784
25783
|
try {
|
|
25785
25784
|
await prepared.dispose?.();
|
|
25786
25785
|
} catch (cleanupError) {
|
|
25787
|
-
outcome =
|
|
25786
|
+
outcome = withExternalHostCleanupFailure(outcome, cleanupError, "AcpDisposeFailure");
|
|
25788
25787
|
}
|
|
25789
25788
|
}
|
|
25790
25789
|
return outcome;
|
|
@@ -25882,7 +25881,7 @@ function createProductionAcpRoleTurnHost(options) {
|
|
|
25882
25881
|
role: request.activation.role
|
|
25883
25882
|
});
|
|
25884
25883
|
return connectAcpStdio({
|
|
25885
|
-
binary:
|
|
25884
|
+
binary: resolveHostBinary(description, request.home),
|
|
25886
25885
|
args: acpStdioArgs(
|
|
25887
25886
|
description,
|
|
25888
25887
|
request.model,
|