@akagilnc/pi-workflow-roles 0.1.5307 → 0.1.5314
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/souls/fixer.md +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,6 +13,109 @@ 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/sha256.ts
|
|
17
120
|
import { createHash } from "node:crypto";
|
|
18
121
|
function sha256Hex(bytes) {
|
|
@@ -789,7 +892,7 @@ __export(run_ticket_number_exports, {
|
|
|
789
892
|
requireSafePositiveTicketNumber: () => requireSafePositiveTicketNumber
|
|
790
893
|
});
|
|
791
894
|
import { readFile } from "node:fs/promises";
|
|
792
|
-
import { join } from "node:path";
|
|
895
|
+
import { join as join2 } from "node:path";
|
|
793
896
|
function isEnoent(error) {
|
|
794
897
|
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
795
898
|
}
|
|
@@ -829,7 +932,7 @@ async function readJsonObject(path) {
|
|
|
829
932
|
}
|
|
830
933
|
}
|
|
831
934
|
async function readBoardPageTicketNumber(runDirectory, page) {
|
|
832
|
-
const record4 = await readJsonObject(
|
|
935
|
+
const record4 = await readJsonObject(join2(runDirectory, page));
|
|
833
936
|
if (record4 === void 0) return void 0;
|
|
834
937
|
return ticketFromRecord(record4);
|
|
835
938
|
}
|
|
@@ -838,7 +941,7 @@ async function readBoardTicketNumber(runDirectory) {
|
|
|
838
941
|
}
|
|
839
942
|
async function readMigrationDerivedTicketNumber(runDirectory) {
|
|
840
943
|
const record4 = await readJsonObject(
|
|
841
|
-
|
|
944
|
+
join2(runDirectory, MIGRATION_TICKET_DERIVATION_PAGE)
|
|
842
945
|
);
|
|
843
946
|
if (record4 === void 0) return void 0;
|
|
844
947
|
if (record4.derivation !== "worktree-path-basename") return void 0;
|
|
@@ -2004,7 +2107,7 @@ import {
|
|
|
2004
2107
|
statSync
|
|
2005
2108
|
} from "node:fs";
|
|
2006
2109
|
import { userInfo } from "node:os";
|
|
2007
|
-
import { basename, dirname as dirname2, isAbsolute, join as
|
|
2110
|
+
import { basename, dirname as dirname2, isAbsolute, join as join3, relative as relative2, resolve as resolve2, sep as sep2 } from "node:path";
|
|
2008
2111
|
function packageMachineHome() {
|
|
2009
2112
|
return resolve2(userInfo().homedir);
|
|
2010
2113
|
}
|
|
@@ -2044,7 +2147,7 @@ function resolveActivationLedgerHomeForPath(path) {
|
|
|
2044
2147
|
return resolveActivationLedgerHome();
|
|
2045
2148
|
}
|
|
2046
2149
|
function activationBookDirectory(ledgerHome, bookKey) {
|
|
2047
|
-
return
|
|
2150
|
+
return join3(ledgerHome, "books", bookKey);
|
|
2048
2151
|
}
|
|
2049
2152
|
function pathContainedIn(root, candidate) {
|
|
2050
2153
|
const rel = relative2(root, candidate);
|
|
@@ -2057,7 +2160,7 @@ function physicalPathIdentity(path) {
|
|
|
2057
2160
|
while (true) {
|
|
2058
2161
|
try {
|
|
2059
2162
|
const real = realpathSync(cursor);
|
|
2060
|
-
return missing.length === 0 ? real :
|
|
2163
|
+
return missing.length === 0 ? real : join3(real, ...missing);
|
|
2061
2164
|
} catch (error) {
|
|
2062
2165
|
if (errnoCode(error) !== "ENOENT") {
|
|
2063
2166
|
return absolute;
|
|
@@ -2157,7 +2260,7 @@ function ensureRealDirectoryTree(root, targetDir) {
|
|
|
2157
2260
|
if (part === "..") {
|
|
2158
2261
|
throw new ActivationLedgerError(`activation ledger path contains '..': ${absoluteTarget}`);
|
|
2159
2262
|
}
|
|
2160
|
-
lexicalCursor =
|
|
2263
|
+
lexicalCursor = join3(lexicalCursor, part);
|
|
2161
2264
|
let st;
|
|
2162
2265
|
try {
|
|
2163
2266
|
st = lstatSync(lexicalCursor);
|
|
@@ -2572,7 +2675,7 @@ var init_sitian_contracts = __esm({
|
|
|
2572
2675
|
// src/sitian-appender.ts
|
|
2573
2676
|
import { randomUUID } from "node:crypto";
|
|
2574
2677
|
import { appendFileSync } from "node:fs";
|
|
2575
|
-
import { dirname as dirname4, join as
|
|
2678
|
+
import { dirname as dirname4, join as join4 } from "node:path";
|
|
2576
2679
|
function appendSitianRecordBlock(input, block) {
|
|
2577
2680
|
if (block === "") return;
|
|
2578
2681
|
try {
|
|
@@ -2594,8 +2697,8 @@ function resolveSitianVolumeCategory(kind) {
|
|
|
2594
2697
|
return kind;
|
|
2595
2698
|
}
|
|
2596
2699
|
function ticketProvenanceUnderBookPaths(ledgerHome, bookKey, ticketId) {
|
|
2597
|
-
const sessionDir =
|
|
2598
|
-
return { sessionDir, recordFile:
|
|
2700
|
+
const sessionDir = join4(activationBookDirectory(ledgerHome, bookKey), ticketId);
|
|
2701
|
+
return { sessionDir, recordFile: join4(sessionDir, SITIAN_RECORDS_LEAF) };
|
|
2599
2702
|
}
|
|
2600
2703
|
function resolveSitianRecordPathInLedger(input, ledgerHome) {
|
|
2601
2704
|
const category = resolveSitianVolumeCategory(input.kind);
|
|
@@ -2612,13 +2715,13 @@ function resolveSitianRecordPathInLedger(input, ledgerHome) {
|
|
|
2612
2715
|
recordFile = paths.recordFile;
|
|
2613
2716
|
} else if (category === "ticket-provenance" && input.runDirectory !== void 0) {
|
|
2614
2717
|
sessionDir = input.runDirectory;
|
|
2615
|
-
recordFile =
|
|
2718
|
+
recordFile = join4(sessionDir, SITIAN_RECORDS_LEAF);
|
|
2616
2719
|
} else {
|
|
2617
2720
|
if (input.sessionParent === void 0 || input.sessionParent.length === 0 || !physicallyContainedIn(ledgerHome, input.sessionParent)) {
|
|
2618
2721
|
throw new Error("Sitian record ownership requires a parent session inside the ledger home");
|
|
2619
2722
|
}
|
|
2620
|
-
sessionDir =
|
|
2621
|
-
recordFile =
|
|
2723
|
+
sessionDir = join4(dirname4(input.sessionParent), category);
|
|
2724
|
+
recordFile = join4(sessionDir, SITIAN_RECORDS_LEAF);
|
|
2622
2725
|
}
|
|
2623
2726
|
if (!physicallyContainedIn(ledgerHome, sessionDir)) {
|
|
2624
2727
|
throw new Error("Sitian record ownership requires a directory inside the ledger home");
|
|
@@ -2745,108 +2848,9 @@ var init_sitian_facade = __esm({
|
|
|
2745
2848
|
}
|
|
2746
2849
|
});
|
|
2747
2850
|
|
|
2748
|
-
// src/host-descriptions.ts
|
|
2749
|
-
function lookupHostDescription(host) {
|
|
2750
|
-
return Object.hasOwn(HOST_DESCRIPTIONS, host) ? HOST_DESCRIPTIONS[host] : void 0;
|
|
2751
|
-
}
|
|
2752
|
-
function lookupHeadlessHostDescription(host) {
|
|
2753
|
-
return Object.hasOwn(HEADLESS_HOST_DESCRIPTIONS, host) ? HEADLESS_HOST_DESCRIPTIONS[host] : void 0;
|
|
2754
|
-
}
|
|
2755
|
-
function lookupHostFamily(host) {
|
|
2756
|
-
if (lookupHostDescription(host) !== void 0) return "acp";
|
|
2757
|
-
if (lookupHeadlessHostDescription(host) !== void 0) return "headless";
|
|
2758
|
-
return void 0;
|
|
2759
|
-
}
|
|
2760
|
-
function packagedExternalHostNames() {
|
|
2761
|
-
return [...Object.keys(HOST_DESCRIPTIONS), ...Object.keys(HEADLESS_HOST_DESCRIPTIONS)];
|
|
2762
|
-
}
|
|
2763
|
-
function assertRegisteredHostName(host) {
|
|
2764
|
-
if (host === DEFAULT_ROLE_TURN_HOST || lookupHostFamily(host) !== void 0) {
|
|
2765
|
-
return host;
|
|
2766
|
-
}
|
|
2767
|
-
throw new Error(`unregistered host: ${host}`);
|
|
2768
|
-
}
|
|
2769
|
-
var DEFAULT_ROLE_TURN_HOST, HOST_DESCRIPTIONS, HEADLESS_HOST_DESCRIPTIONS;
|
|
2770
|
-
var init_host_descriptions = __esm({
|
|
2771
|
-
"src/host-descriptions.ts"() {
|
|
2772
|
-
"use strict";
|
|
2773
|
-
DEFAULT_ROLE_TURN_HOST = "pi";
|
|
2774
|
-
HOST_DESCRIPTIONS = Object.freeze({
|
|
2775
|
-
/** Operator home `~/.grok`, native session/load resume, `agent [--model X] stdio`. */
|
|
2776
|
-
"grok-build": Object.freeze({
|
|
2777
|
-
binaryFromHome: Object.freeze([".grok", "bin", "grok"]),
|
|
2778
|
-
argv: Object.freeze({
|
|
2779
|
-
prefix: Object.freeze(["agent"]),
|
|
2780
|
-
suffix: Object.freeze(["stdio"]),
|
|
2781
|
-
modelFlag: "--model"
|
|
2782
|
-
}),
|
|
2783
|
-
modelPassing: "argv",
|
|
2784
|
-
sessionBindingFile: "grok-acp-session.json"
|
|
2785
|
-
}),
|
|
2786
|
-
/**
|
|
2787
|
-
* Operator home `~/.hermes`, native session/load resume, `acp` subcommand.
|
|
2788
|
-
* Model arrives as an ACP `session/set_model` RPC with modelId `provider:model`
|
|
2789
|
-
* (seat table provider + model concatenated). Reasoning is the global
|
|
2790
|
-
* `--reasoning` flag before `acp`. Soul is the seat profile SOUL.md symlink
|
|
2791
|
-
* (`hermes -p ak-<role> …`); package `souls/<role>.md` is the sole source.
|
|
2792
|
-
*/
|
|
2793
|
-
"hermes": Object.freeze({
|
|
2794
|
-
binaryFromHome: Object.freeze([".local", "bin", "hermes"]),
|
|
2795
|
-
argv: Object.freeze({
|
|
2796
|
-
prefix: Object.freeze(["acp"]),
|
|
2797
|
-
suffix: Object.freeze([]),
|
|
2798
|
-
thinkingFlag: "--reasoning"
|
|
2799
|
-
}),
|
|
2800
|
-
modelPassing: "set_model",
|
|
2801
|
-
sessionBindingFile: "hermes-acp-session.json",
|
|
2802
|
-
seatProfileSoul: Object.freeze({
|
|
2803
|
-
flag: "-p",
|
|
2804
|
-
namePrefix: "ak-",
|
|
2805
|
-
profilesRootFromHome: Object.freeze([".hermes", "profiles"]),
|
|
2806
|
-
soulFileName: "SOUL.md"
|
|
2807
|
-
})
|
|
2808
|
-
})
|
|
2809
|
-
});
|
|
2810
|
-
HEADLESS_HOST_DESCRIPTIONS = Object.freeze({
|
|
2811
|
-
"claude": Object.freeze({
|
|
2812
|
-
protocol: "claude-print",
|
|
2813
|
-
binaryFromHome: Object.freeze([".local", "bin", "claude"]),
|
|
2814
|
-
sessionBindingFile: "claude-headless-session.json",
|
|
2815
|
-
fixedArgs: Object.freeze([
|
|
2816
|
-
// Live NDJSON events → sitian host-session records (#811); last line is the result receipt.
|
|
2817
|
-
"--output-format",
|
|
2818
|
-
"stream-json",
|
|
2819
|
-
// Intermediate assistant/tool/system events require verbose with stream-json.
|
|
2820
|
-
"--verbose",
|
|
2821
|
-
"--permission-mode",
|
|
2822
|
-
"bypassPermissions"
|
|
2823
|
-
]),
|
|
2824
|
-
promptFlag: "-p",
|
|
2825
|
-
modelFlag: "--model",
|
|
2826
|
-
effortFlag: "--effort",
|
|
2827
|
-
// File path keeps large role envelopes off ARG_MAX.
|
|
2828
|
-
systemPromptFlag: "--system-prompt-file",
|
|
2829
|
-
jsonSchemaFlag: "--json-schema",
|
|
2830
|
-
mcpConfigFlag: "--mcp-config",
|
|
2831
|
-
sessionIdFlag: "--session-id",
|
|
2832
|
-
resumeFlag: "--resume"
|
|
2833
|
-
}),
|
|
2834
|
-
/**
|
|
2835
|
-
* Codex headless (#646). Binary under operator home; auth stays in CODEX_HOME.
|
|
2836
|
-
* Argv/parse/schema-close are codex-exec helpers — not Claude flag mapping.
|
|
2837
|
-
*/
|
|
2838
|
-
"codex": Object.freeze({
|
|
2839
|
-
protocol: "codex-exec",
|
|
2840
|
-
binaryFromHome: Object.freeze([".local", "bin", "codex"]),
|
|
2841
|
-
sessionBindingFile: "codex-headless-session.json"
|
|
2842
|
-
})
|
|
2843
|
-
});
|
|
2844
|
-
}
|
|
2845
|
-
});
|
|
2846
|
-
|
|
2847
2851
|
// src/package-resources/engine-material.ts
|
|
2848
2852
|
import { existsSync as existsSync2, readdirSync } from "node:fs";
|
|
2849
|
-
import { join as
|
|
2853
|
+
import { join as join5 } from "node:path";
|
|
2850
2854
|
function pickEngineAxis(source) {
|
|
2851
2855
|
return {
|
|
2852
2856
|
...source.engine === void 0 ? {} : { engine: source.engine },
|
|
@@ -2867,11 +2871,11 @@ function isEngineNameSyntax(name) {
|
|
|
2867
2871
|
return true;
|
|
2868
2872
|
}
|
|
2869
2873
|
function resolveEngineMaterialDirectory(packageRoot) {
|
|
2870
|
-
return
|
|
2874
|
+
return join5(packageRoot, ENGINE_MATERIAL_RELATIVE_ROOT);
|
|
2871
2875
|
}
|
|
2872
2876
|
function resolveEngineMaterialPath(packageRoot, name) {
|
|
2873
2877
|
const legal = assertLegalEngineName(name);
|
|
2874
|
-
return
|
|
2878
|
+
return join5(resolveEngineMaterialDirectory(packageRoot), `${legal}.md`);
|
|
2875
2879
|
}
|
|
2876
2880
|
function assertLegalEngineName(name) {
|
|
2877
2881
|
if (!isEngineNameSyntax(name)) {
|
|
@@ -3050,7 +3054,7 @@ __export(config_exports, {
|
|
|
3050
3054
|
validatePublicCliConfigAxes: () => validatePublicCliConfigAxes
|
|
3051
3055
|
});
|
|
3052
3056
|
import { mkdir, readFile as readFile4, writeFile } from "node:fs/promises";
|
|
3053
|
-
import { dirname as dirname5, join as
|
|
3057
|
+
import { dirname as dirname5, join as join6 } from "node:path";
|
|
3054
3058
|
function isGateOfficerSeat(value) {
|
|
3055
3059
|
return packagedProvinceConfig(value);
|
|
3056
3060
|
}
|
|
@@ -3058,7 +3062,7 @@ function publicCliConfigPath(home) {
|
|
|
3058
3062
|
if (typeof home !== "string" || home.trim() === "") {
|
|
3059
3063
|
throw new Error("home must be explicitly provided");
|
|
3060
3064
|
}
|
|
3061
|
-
return
|
|
3065
|
+
return join6(home, ".ak-roles", "public-cli.json");
|
|
3062
3066
|
}
|
|
3063
3067
|
async function loadPublicCliConfig(home) {
|
|
3064
3068
|
const path = publicCliConfigPath(home);
|
|
@@ -3521,7 +3525,7 @@ function credentialProvidersFromAuthData(data) {
|
|
|
3521
3525
|
}
|
|
3522
3526
|
async function loadCredentialProviders(agentDir) {
|
|
3523
3527
|
try {
|
|
3524
|
-
const raw = await readFile4(
|
|
3528
|
+
const raw = await readFile4(join6(agentDir, "auth.json"), "utf8");
|
|
3525
3529
|
return credentialProvidersFromAuthData(JSON.parse(raw));
|
|
3526
3530
|
} catch (error) {
|
|
3527
3531
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
@@ -3599,10 +3603,10 @@ var init_cli_errors = __esm({
|
|
|
3599
3603
|
// src/atomic-write.ts
|
|
3600
3604
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
3601
3605
|
import { rename, rm, writeFile as writeFile2 } from "node:fs/promises";
|
|
3602
|
-
import { dirname as dirname6, join as
|
|
3606
|
+
import { dirname as dirname6, join as join7 } from "node:path";
|
|
3603
3607
|
async function writeFileAtomically(destination, contents) {
|
|
3604
3608
|
const parent = dirname6(destination);
|
|
3605
|
-
const temporary =
|
|
3609
|
+
const temporary = join7(parent, `.atomic-write-${randomUUID2()}.tmp`);
|
|
3606
3610
|
try {
|
|
3607
3611
|
await writeFile2(temporary, contents);
|
|
3608
3612
|
await rename(temporary, destination);
|
|
@@ -3619,7 +3623,7 @@ var init_atomic_write = __esm({
|
|
|
3619
3623
|
|
|
3620
3624
|
// src/role-run-placement.ts
|
|
3621
3625
|
import { readdir as readdir2 } from "node:fs/promises";
|
|
3622
|
-
import { join as
|
|
3626
|
+
import { join as join9 } from "node:path";
|
|
3623
3627
|
function isMissingPathError2(error) {
|
|
3624
3628
|
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
3625
3629
|
}
|
|
@@ -3636,13 +3640,13 @@ async function listBookRunDirectories(bookDir) {
|
|
|
3636
3640
|
}
|
|
3637
3641
|
for (const entry of entries) {
|
|
3638
3642
|
if (!entry.isDirectory()) continue;
|
|
3639
|
-
const runDir =
|
|
3643
|
+
const runDir = join9(runsDir, entry.name);
|
|
3640
3644
|
if (seen.has(runDir)) continue;
|
|
3641
3645
|
seen.add(runDir);
|
|
3642
3646
|
out.push(runDir);
|
|
3643
3647
|
}
|
|
3644
3648
|
};
|
|
3645
|
-
await collect(
|
|
3649
|
+
await collect(join9(bookDir, "runs"));
|
|
3646
3650
|
let subjects;
|
|
3647
3651
|
try {
|
|
3648
3652
|
subjects = await readdir2(bookDir, { withFileTypes: true });
|
|
@@ -3652,7 +3656,7 @@ async function listBookRunDirectories(bookDir) {
|
|
|
3652
3656
|
}
|
|
3653
3657
|
for (const subject of subjects) {
|
|
3654
3658
|
if (!subject.isDirectory() || subject.name === "runs") continue;
|
|
3655
|
-
await collect(
|
|
3659
|
+
await collect(join9(bookDir, subject.name, "runs"));
|
|
3656
3660
|
}
|
|
3657
3661
|
return out.sort();
|
|
3658
3662
|
}
|
|
@@ -3661,23 +3665,23 @@ function roleRunPlacement(ledgerHome, input) {
|
|
|
3661
3665
|
input.subject.ticketNumber,
|
|
3662
3666
|
"roleRunPlacement subject.ticketNumber"
|
|
3663
3667
|
)) : "unbound";
|
|
3664
|
-
const runDirectory =
|
|
3668
|
+
const runDirectory = join9(
|
|
3665
3669
|
activationBookDirectory(ledgerHome, input.bookKey),
|
|
3666
3670
|
subjectDirectory,
|
|
3667
3671
|
"runs",
|
|
3668
3672
|
`${input.runId}@${input.role}`
|
|
3669
3673
|
);
|
|
3670
|
-
const sessionDirectory =
|
|
3674
|
+
const sessionDirectory = join9(runDirectory, "session");
|
|
3671
3675
|
return {
|
|
3672
3676
|
runDirectory,
|
|
3673
3677
|
sessionDirectory,
|
|
3674
|
-
sessionFile:
|
|
3678
|
+
sessionFile: join9(sessionDirectory, "session.jsonl"),
|
|
3675
3679
|
artifactsDirectory: roleRunArtifactsDirectory(runDirectory),
|
|
3676
|
-
attachmentsDirectory:
|
|
3680
|
+
attachmentsDirectory: join9(runDirectory, "attachments")
|
|
3677
3681
|
};
|
|
3678
3682
|
}
|
|
3679
3683
|
function roleRunArtifactsDirectory(runDirectory) {
|
|
3680
|
-
return
|
|
3684
|
+
return join9(runDirectory, "artifacts");
|
|
3681
3685
|
}
|
|
3682
3686
|
function ensureRoleRunDirectory(ledgerHome, directory) {
|
|
3683
3687
|
return ensureRealDirectoryTree(ledgerHome, directory);
|
|
@@ -3704,7 +3708,7 @@ __export(durable_principal_exports, {
|
|
|
3704
3708
|
issuePiDurablePrincipalCoordinates: () => issuePiDurablePrincipalCoordinates,
|
|
3705
3709
|
piDurablePrincipalAuthority: () => piDurablePrincipalAuthority
|
|
3706
3710
|
});
|
|
3707
|
-
import { join as
|
|
3711
|
+
import { join as join10 } from "node:path";
|
|
3708
3712
|
function encode(coordinates) {
|
|
3709
3713
|
return coordinates;
|
|
3710
3714
|
}
|
|
@@ -3754,7 +3758,7 @@ var init_durable_principal = __esm({
|
|
|
3754
3758
|
}
|
|
3755
3759
|
return {
|
|
3756
3760
|
sessionDirectory: record4.sessionDirectory,
|
|
3757
|
-
sessionFile: typeof record4.sessionFile === "string" && record4.sessionFile.trim() !== "" ? record4.sessionFile :
|
|
3761
|
+
sessionFile: typeof record4.sessionFile === "string" && record4.sessionFile.trim() !== "" ? record4.sessionFile : join10(record4.sessionDirectory, "session.jsonl")
|
|
3758
3762
|
};
|
|
3759
3763
|
}
|
|
3760
3764
|
};
|
|
@@ -3763,9 +3767,9 @@ var init_durable_principal = __esm({
|
|
|
3763
3767
|
|
|
3764
3768
|
// src/typed-provider-http.ts
|
|
3765
3769
|
import { readFile as readFile6, unlink, writeFile as writeFile3 } from "node:fs/promises";
|
|
3766
|
-
import { join as
|
|
3770
|
+
import { join as join11 } from "node:path";
|
|
3767
3771
|
function typedProviderHttpPath(runDirectory) {
|
|
3768
|
-
return
|
|
3772
|
+
return join11(runDirectory, TYPED_HTTP_FILE);
|
|
3769
3773
|
}
|
|
3770
3774
|
async function clearTypedProviderHttpObservation(runDirectory) {
|
|
3771
3775
|
try {
|
|
@@ -3909,7 +3913,7 @@ __export(auditor_dossier_tool_exports, {
|
|
|
3909
3913
|
auditorRunDirectory: () => auditorRunDirectory,
|
|
3910
3914
|
createAuditorDossierTool: () => createAuditorDossierTool
|
|
3911
3915
|
});
|
|
3912
|
-
import { dirname as dirname8, join as
|
|
3916
|
+
import { dirname as dirname8, join as join12, resolve as resolve6 } from "node:path";
|
|
3913
3917
|
import { Type as Type11 } from "typebox";
|
|
3914
3918
|
function auditorRunDirectory(context) {
|
|
3915
3919
|
const sessionFile = context.sessionManager?.getSessionFile?.();
|
|
@@ -3932,9 +3936,9 @@ function createAuditorDossierTool(runDirectory) {
|
|
|
3932
3936
|
}
|
|
3933
3937
|
const details = {
|
|
3934
3938
|
runDirectory,
|
|
3935
|
-
admittedRequest:
|
|
3936
|
-
parentSessionCandidate:
|
|
3937
|
-
attachments:
|
|
3939
|
+
admittedRequest: join12(runDirectory, "admitted-request.json"),
|
|
3940
|
+
parentSessionCandidate: join12(runDirectory, "session", "session.jsonl"),
|
|
3941
|
+
attachments: join12(runDirectory, "attachments"),
|
|
3938
3942
|
artifacts: roleRunArtifactsDirectory(runDirectory)
|
|
3939
3943
|
};
|
|
3940
3944
|
return {
|
|
@@ -3964,7 +3968,7 @@ __export(run_terminal_artifacts_exports, {
|
|
|
3964
3968
|
runIdFromRunDirectory: () => runIdFromRunDirectory
|
|
3965
3969
|
});
|
|
3966
3970
|
import { readdir as readdir3, readFile as readFile8 } from "node:fs/promises";
|
|
3967
|
-
import { basename as basename4, dirname as dirname9, join as
|
|
3971
|
+
import { basename as basename4, dirname as dirname9, join as join13 } from "node:path";
|
|
3968
3972
|
function isMissingPathError3(error) {
|
|
3969
3973
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
3970
3974
|
}
|
|
@@ -4039,7 +4043,7 @@ async function listUniqueErrorFallbackPaths(directories) {
|
|
|
4039
4043
|
}
|
|
4040
4044
|
for (const name of names.sort((a, b) => a.localeCompare(b))) {
|
|
4041
4045
|
if (!UNIQUE_ERROR_FALLBACK_NAME.test(name)) continue;
|
|
4042
|
-
found.push(
|
|
4046
|
+
found.push(join13(dir, name));
|
|
4043
4047
|
}
|
|
4044
4048
|
}
|
|
4045
4049
|
return found;
|
|
@@ -4085,11 +4089,11 @@ async function readRunTerminalArtifact(runDirectory) {
|
|
|
4085
4089
|
unreadable.push(read);
|
|
4086
4090
|
};
|
|
4087
4091
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
4088
|
-
consider(await readTerminalArtifactAtPath(
|
|
4092
|
+
consider(await readTerminalArtifactAtPath(join13(artifactsDir, file), file));
|
|
4089
4093
|
}
|
|
4090
4094
|
for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
4091
4095
|
consider(
|
|
4092
|
-
await readTerminalArtifactAtPath(
|
|
4096
|
+
await readTerminalArtifactAtPath(join13(runDirectory, relative3), "error.json")
|
|
4093
4097
|
);
|
|
4094
4098
|
}
|
|
4095
4099
|
for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
|
|
@@ -4438,7 +4442,7 @@ __export(session_assistant_usage_exports, {
|
|
|
4438
4442
|
sessionFileFromPublicSummon: () => sessionFileFromPublicSummon,
|
|
4439
4443
|
usageFromPublicSummon: () => usageFromPublicSummon
|
|
4440
4444
|
});
|
|
4441
|
-
import { join as
|
|
4445
|
+
import { join as join14 } from "node:path";
|
|
4442
4446
|
async function readAssistantUsageFromSessionFile(sessionFile) {
|
|
4443
4447
|
const { readFile: readFile25 } = await import("node:fs/promises");
|
|
4444
4448
|
let text;
|
|
@@ -4508,7 +4512,7 @@ async function readAssistantUsageFromSessionFile(sessionFile) {
|
|
|
4508
4512
|
}
|
|
4509
4513
|
function sessionFileFromPublicSummon(summoned) {
|
|
4510
4514
|
if (typeof summoned.runDirectory === "string" && summoned.runDirectory.trim() !== "") {
|
|
4511
|
-
return
|
|
4515
|
+
return join14(summoned.runDirectory, "session", "session.jsonl");
|
|
4512
4516
|
}
|
|
4513
4517
|
const fromArtifacts = summoned.terminal?.artifacts?.map((a) => a.path).find((p) => typeof p === "string" && p.endsWith("session.jsonl"));
|
|
4514
4518
|
if (fromArtifacts !== void 0) return fromArtifacts;
|
|
@@ -4517,7 +4521,7 @@ function sessionFileFromPublicSummon(summoned) {
|
|
|
4517
4521
|
const facts = outcome.decisiveFacts;
|
|
4518
4522
|
const pointer = facts?.runPointer;
|
|
4519
4523
|
if (typeof pointer === "string" && pointer.trim() !== "") {
|
|
4520
|
-
return
|
|
4524
|
+
return join14(pointer, "session", "session.jsonl");
|
|
4521
4525
|
}
|
|
4522
4526
|
return void 0;
|
|
4523
4527
|
}
|
|
@@ -4536,7 +4540,7 @@ var init_session_assistant_usage = __esm({
|
|
|
4536
4540
|
import { spawn } from "node:child_process";
|
|
4537
4541
|
import { mkdtemp, rm as rm2, writeFile as writeFile4 } from "node:fs/promises";
|
|
4538
4542
|
import { tmpdir } from "node:os";
|
|
4539
|
-
import { join as
|
|
4543
|
+
import { join as join15 } from "node:path";
|
|
4540
4544
|
function normalizeEngineName(engine) {
|
|
4541
4545
|
if (engine === void 0) return void 0;
|
|
4542
4546
|
const trimmed = engine.trim();
|
|
@@ -4637,8 +4641,8 @@ async function runEngineDetourOnce(input) {
|
|
|
4637
4641
|
if (input.stagedPrompt === void 0) {
|
|
4638
4642
|
return spawnEngineDetourOnce(input);
|
|
4639
4643
|
}
|
|
4640
|
-
const stagingDir = await mkdtemp(
|
|
4641
|
-
const stagedPath =
|
|
4644
|
+
const stagingDir = await mkdtemp(join15(tmpdir(), "ak-engine-detour-"));
|
|
4645
|
+
const stagedPath = join15(stagingDir, "prompt.txt");
|
|
4642
4646
|
let result;
|
|
4643
4647
|
let runError;
|
|
4644
4648
|
try {
|
|
@@ -4772,12 +4776,12 @@ __export(role_turn_host_exports, {
|
|
|
4772
4776
|
import { execFile, spawn as spawn2 } from "node:child_process";
|
|
4773
4777
|
import { constants } from "node:fs";
|
|
4774
4778
|
import { access, appendFile, readFile as readFile9, realpath as realpath2 } from "node:fs/promises";
|
|
4775
|
-
import { delimiter, dirname as dirname10, isAbsolute as isAbsolute3, join as
|
|
4779
|
+
import { delimiter, dirname as dirname10, isAbsolute as isAbsolute3, join as join16, resolve as resolve7 } from "node:path";
|
|
4776
4780
|
import { platform } from "node:process";
|
|
4777
4781
|
import { promisify } from "node:util";
|
|
4778
4782
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
4779
4783
|
function resolveInternalRoleEntrypoint(packageRoot) {
|
|
4780
|
-
return
|
|
4784
|
+
return join16(packageRoot, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
|
|
4781
4785
|
}
|
|
4782
4786
|
function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
|
|
4783
4787
|
return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
|
|
@@ -5536,13 +5540,13 @@ var init_session_dialogue = __esm({
|
|
|
5536
5540
|
|
|
5537
5541
|
// src/ticket-provenance.ts
|
|
5538
5542
|
import { readFile as readFile12, unlink as unlink2 } from "node:fs/promises";
|
|
5539
|
-
import { basename as basename5, dirname as dirname11, join as
|
|
5543
|
+
import { basename as basename5, dirname as dirname11, join as join17, resolve as resolve9 } from "node:path";
|
|
5540
5544
|
function dialogueSessionSourceRoots(home) {
|
|
5541
5545
|
const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
|
|
5542
5546
|
return [
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5547
|
+
join17(machineHome, ".claude", "projects"),
|
|
5548
|
+
join17(machineHome, ".codex", "sessions"),
|
|
5549
|
+
join17(machineHome, ".pi", "agent", "sessions")
|
|
5546
5550
|
];
|
|
5547
5551
|
}
|
|
5548
5552
|
function isLedgerRoleSessionFile(absolute, home) {
|
|
@@ -5580,7 +5584,7 @@ function ticketProvenanceRecordInput(ticketNumber, cwd, home, runDirectory) {
|
|
|
5580
5584
|
};
|
|
5581
5585
|
}
|
|
5582
5586
|
async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, home) {
|
|
5583
|
-
const source =
|
|
5587
|
+
const source = join17(runDirectory, "records.jsonl");
|
|
5584
5588
|
let content;
|
|
5585
5589
|
try {
|
|
5586
5590
|
content = await readFile12(source, "utf8");
|
|
@@ -5765,7 +5769,7 @@ var init_ticket_provenance = __esm({
|
|
|
5765
5769
|
});
|
|
5766
5770
|
|
|
5767
5771
|
// src/notary-source-run.ts
|
|
5768
|
-
import { dirname as dirname12, isAbsolute as isAbsolute5, join as
|
|
5772
|
+
import { dirname as dirname12, isAbsolute as isAbsolute5, join as join18, resolve as resolve10, basename as basename6 } from "node:path";
|
|
5769
5773
|
import { lstat, realpath as realpath3 } from "node:fs/promises";
|
|
5770
5774
|
async function readRetainedIdentity(runDirectory) {
|
|
5771
5775
|
try {
|
|
@@ -5822,11 +5826,11 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
5822
5826
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
5823
5827
|
const bookKey = resolveBookKeyFromGit(options.projectRoot);
|
|
5824
5828
|
const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
|
|
5825
|
-
const bookRunsRoot =
|
|
5829
|
+
const bookRunsRoot = join18(bookDirectory, "runs");
|
|
5826
5830
|
let candidate;
|
|
5827
5831
|
const bare = parseRunDirectoryName(raw);
|
|
5828
5832
|
if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
|
|
5829
|
-
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ??
|
|
5833
|
+
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join18(bookRunsRoot, `${bare.runId}@${bare.role}`);
|
|
5830
5834
|
} else {
|
|
5831
5835
|
candidate = isAbsolute5(raw) ? raw : resolve10(options.projectRoot, raw);
|
|
5832
5836
|
const identity2 = parseRunDirectoryName(basename6(candidate));
|
|
@@ -6967,7 +6971,7 @@ import {
|
|
|
6967
6971
|
writeFile as writeFile5
|
|
6968
6972
|
} from "node:fs/promises";
|
|
6969
6973
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
6970
|
-
import { basename as basename7, dirname as dirname13, isAbsolute as isAbsolute6, join as
|
|
6974
|
+
import { basename as basename7, dirname as dirname13, isAbsolute as isAbsolute6, join as join19, resolve as resolve11, sep as sep3 } from "node:path";
|
|
6971
6975
|
function issueAdmissionPlacement(authority, request) {
|
|
6972
6976
|
const ledgerHome = resolveActivationLedgerHome(request.home);
|
|
6973
6977
|
const bookKey = resolveBookKeyFromGit(request.cwd);
|
|
@@ -7021,14 +7025,14 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
|
|
|
7021
7025
|
...effectiveModelLedgerFields(effectiveModel)
|
|
7022
7026
|
};
|
|
7023
7027
|
await writeFile5(
|
|
7024
|
-
|
|
7028
|
+
join19(source.runDirectory, "invocation.json"),
|
|
7025
7029
|
`${JSON.stringify(identity, null, 2)}
|
|
7026
7030
|
`,
|
|
7027
7031
|
"utf8"
|
|
7028
7032
|
);
|
|
7029
7033
|
}
|
|
7030
7034
|
async function recordEffectiveInvocationModel(runDirectory, model, engine, host, engineModel) {
|
|
7031
|
-
const ledgerPath =
|
|
7035
|
+
const ledgerPath = join19(runDirectory, "invocation.json");
|
|
7032
7036
|
const current = JSON.parse(await readFile13(ledgerPath, "utf8"));
|
|
7033
7037
|
const next = { ...current };
|
|
7034
7038
|
if (model !== void 0) {
|
|
@@ -7061,7 +7065,7 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host,
|
|
|
7061
7065
|
);
|
|
7062
7066
|
}
|
|
7063
7067
|
async function mergeInvocationIdentityPage(runDirectory, fields) {
|
|
7064
|
-
const ledgerPath =
|
|
7068
|
+
const ledgerPath = join19(runDirectory, "invocation.json");
|
|
7065
7069
|
const current = JSON.parse(await readFile13(ledgerPath, "utf8"));
|
|
7066
7070
|
await writeFile5(
|
|
7067
7071
|
ledgerPath,
|
|
@@ -7144,7 +7148,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
7144
7148
|
const childRunIds = parentPage.childDiaristRunIds;
|
|
7145
7149
|
for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
|
|
7146
7150
|
if (typeof childRunId !== "string") continue;
|
|
7147
|
-
const childDirectory =
|
|
7151
|
+
const childDirectory = join19(dirname13(oldRunDirectory), `${childRunId}@diarist`);
|
|
7148
7152
|
if (!existsSync4(childDirectory)) continue;
|
|
7149
7153
|
const childTarget = roleRunPlacement(ledgerHome, {
|
|
7150
7154
|
bookKey: admitted.bookKey,
|
|
@@ -7201,7 +7205,7 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
|
7201
7205
|
ticketNumber,
|
|
7202
7206
|
"bindTicketNumberOnRunDirectory"
|
|
7203
7207
|
);
|
|
7204
|
-
const admittedPath =
|
|
7208
|
+
const admittedPath = join19(runDirectory, "admitted-request.json");
|
|
7205
7209
|
const admitted = JSON.parse(await readFile13(admittedPath, "utf8"));
|
|
7206
7210
|
if (admitted.ticketNumber === ticketNumber) return;
|
|
7207
7211
|
await writeFile5(
|
|
@@ -7221,7 +7225,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
7221
7225
|
async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
|
|
7222
7226
|
const rolePackageRoot = packageRoot;
|
|
7223
7227
|
const raw = JSON.parse(
|
|
7224
|
-
await readFile13(
|
|
7228
|
+
await readFile13(join19(rolePackageRoot, "package.json"), "utf8")
|
|
7225
7229
|
);
|
|
7226
7230
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
7227
7231
|
throw new Error(
|
|
@@ -7509,13 +7513,13 @@ async function removePreparedAttachmentDirectory(stagingDirectory) {
|
|
|
7509
7513
|
}
|
|
7510
7514
|
async function withPreparedAttachments(attachmentPaths, use) {
|
|
7511
7515
|
if (attachmentPaths.length === 0) return await use([]);
|
|
7512
|
-
const stagingDirectory = await mkdtemp2(
|
|
7516
|
+
const stagingDirectory = await mkdtemp2(join19(tmpdir2(), "ak-role-attachments-"));
|
|
7513
7517
|
const prepared = [];
|
|
7514
7518
|
let result;
|
|
7515
7519
|
try {
|
|
7516
7520
|
for (let index = 0; index < attachmentPaths.length; index += 1) {
|
|
7517
7521
|
const { absolute, bytes } = await readRegularFileAttachment(attachmentPaths[index]);
|
|
7518
|
-
const snapshotPath =
|
|
7522
|
+
const snapshotPath = join19(stagingDirectory, String(index).padStart(6, "0"));
|
|
7519
7523
|
await writeFile5(snapshotPath, bytes);
|
|
7520
7524
|
prepared.push({ absolute, snapshotPath });
|
|
7521
7525
|
}
|
|
@@ -7536,7 +7540,7 @@ async function withPreparedAttachments(attachmentPaths, use) {
|
|
|
7536
7540
|
return result;
|
|
7537
7541
|
}
|
|
7538
7542
|
async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, index) {
|
|
7539
|
-
const frozenPath =
|
|
7543
|
+
const frozenPath = join19(
|
|
7540
7544
|
destinationDir,
|
|
7541
7545
|
`${String(index).padStart(2, "0")}-${basename7(provenancePath)}`
|
|
7542
7546
|
);
|
|
@@ -7579,14 +7583,14 @@ async function freezeAttachments(attachmentPaths, attachmentsDirectory) {
|
|
|
7579
7583
|
async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKey = `s-${Date.now().toString(36)}`) {
|
|
7580
7584
|
if (attachmentPaths.length === 0) return [];
|
|
7581
7585
|
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
7582
|
-
const attachmentsDirectory =
|
|
7586
|
+
const attachmentsDirectory = join19(runDirectory, "attachments", summonsKey);
|
|
7583
7587
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
7584
7588
|
return freezeAttachments(attachmentPaths, attachmentsDirectory);
|
|
7585
7589
|
}
|
|
7586
7590
|
async function freezePreparedAttachmentsIntoRun(prepared, runDirectory, summonsKey) {
|
|
7587
7591
|
if (prepared.length === 0) return [];
|
|
7588
7592
|
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
7589
|
-
const attachmentsDirectory = summonsKey === void 0 ?
|
|
7593
|
+
const attachmentsDirectory = summonsKey === void 0 ? join19(runDirectory, "attachments") : join19(runDirectory, "attachments", summonsKey);
|
|
7590
7594
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
7591
7595
|
const attachments = [];
|
|
7592
7596
|
for (let index = 0; index < prepared.length; index += 1) {
|
|
@@ -7663,7 +7667,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7663
7667
|
attachmentPaths,
|
|
7664
7668
|
...project,
|
|
7665
7669
|
placedFields: async (placed) => {
|
|
7666
|
-
const taskPath =
|
|
7670
|
+
const taskPath = join19(placed.runDirectory, "task.md");
|
|
7667
7671
|
await writeFile5(taskPath, instruction, "utf8");
|
|
7668
7672
|
return { phase, taskPath };
|
|
7669
7673
|
}
|
|
@@ -7709,7 +7713,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7709
7713
|
placedFields: async (placed) => {
|
|
7710
7714
|
let prerequisitesPath;
|
|
7711
7715
|
if (prerequisitesSource !== void 0) {
|
|
7712
|
-
prerequisitesPath =
|
|
7716
|
+
prerequisitesPath = join19(placed.runDirectory, "prerequisites.json");
|
|
7713
7717
|
await writeFile5(
|
|
7714
7718
|
prerequisitesPath,
|
|
7715
7719
|
`${JSON.stringify(prerequisites, null, 2)}
|
|
@@ -7717,7 +7721,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7717
7721
|
"utf8"
|
|
7718
7722
|
);
|
|
7719
7723
|
}
|
|
7720
|
-
const packetPath =
|
|
7724
|
+
const packetPath = join19(placed.runDirectory, "fix-packet.md");
|
|
7721
7725
|
await writeFile5(packetPath, instruction, "utf8");
|
|
7722
7726
|
return {
|
|
7723
7727
|
phase,
|
|
@@ -7775,7 +7779,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7775
7779
|
placedFields: async (placed) => {
|
|
7776
7780
|
let requestManifestPath;
|
|
7777
7781
|
if (manifestCanonicalJson !== void 0) {
|
|
7778
|
-
requestManifestPath =
|
|
7782
|
+
requestManifestPath = join19(placed.runDirectory, "request-manifest.json");
|
|
7779
7783
|
await writeFile5(requestManifestPath, manifestCanonicalJson, "utf8");
|
|
7780
7784
|
}
|
|
7781
7785
|
return {
|
|
@@ -7965,7 +7969,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7965
7969
|
resolutionScope: [...derived.resolutionScope],
|
|
7966
7970
|
authorizedChecks: []
|
|
7967
7971
|
});
|
|
7968
|
-
const mergerInputPath =
|
|
7972
|
+
const mergerInputPath = join19(placed.runDirectory, "merger-input.json");
|
|
7969
7973
|
await writeFile5(
|
|
7970
7974
|
mergerInputPath,
|
|
7971
7975
|
`${JSON.stringify(mergerInput, null, 2)}
|
|
@@ -8039,7 +8043,7 @@ function persistedAttachmentRefs(attachments) {
|
|
|
8039
8043
|
}));
|
|
8040
8044
|
}
|
|
8041
8045
|
async function persistPlacedAdmission(admitted, placed, model) {
|
|
8042
|
-
const admittedRequestPath =
|
|
8046
|
+
const admittedRequestPath = join19(placed.runDirectory, "admitted-request.json");
|
|
8043
8047
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
8044
8048
|
sessionDirectory: placed.sessionDirectory,
|
|
8045
8049
|
sessionFile: placed.sessionFile
|
|
@@ -8092,7 +8096,7 @@ async function admitStandardMaterialInvocation(role, options) {
|
|
|
8092
8096
|
attachments: persistedAttachmentRefs(placed.attachments),
|
|
8093
8097
|
...placed.ticketFields
|
|
8094
8098
|
};
|
|
8095
|
-
const admittedRequestPath = defer ?
|
|
8099
|
+
const admittedRequestPath = defer ? join19(placed.runDirectory, "admitted-request.json") : await persistPlacedAdmission(admitted, placed, options.model);
|
|
8096
8100
|
return {
|
|
8097
8101
|
role,
|
|
8098
8102
|
runId: placed.runId,
|
|
@@ -8170,7 +8174,7 @@ async function materializeCountersignInvocation(admitted, options) {
|
|
|
8170
8174
|
});
|
|
8171
8175
|
const placement = placed;
|
|
8172
8176
|
admitted.runDirectory = placement.runDirectory;
|
|
8173
|
-
admitted.admittedRequestPath =
|
|
8177
|
+
admitted.admittedRequestPath = join19(
|
|
8174
8178
|
placement.runDirectory,
|
|
8175
8179
|
"admitted-request.json"
|
|
8176
8180
|
);
|
|
@@ -8197,7 +8201,7 @@ async function materializeCountersignInvocation(admitted, options) {
|
|
|
8197
8201
|
async function loadAdmittedJudgeRequest(runDirectory) {
|
|
8198
8202
|
try {
|
|
8199
8203
|
const raw = JSON.parse(
|
|
8200
|
-
await readFile13(
|
|
8204
|
+
await readFile13(join19(runDirectory, "admitted-request.json"), "utf8")
|
|
8201
8205
|
);
|
|
8202
8206
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
8203
8207
|
const record4 = raw;
|
|
@@ -8286,7 +8290,7 @@ function parseDoctorIssueNumber(raw) {
|
|
|
8286
8290
|
}
|
|
8287
8291
|
async function resolveDoctorCaseRunsPath(options) {
|
|
8288
8292
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
8289
|
-
const defaultRuns =
|
|
8293
|
+
const defaultRuns = join19(
|
|
8290
8294
|
activationBookDirectory(ledgerHome, options.bookKey),
|
|
8291
8295
|
String(options.issueNumber),
|
|
8292
8296
|
"runs"
|
|
@@ -8607,15 +8611,15 @@ var init_invocation = __esm({
|
|
|
8607
8611
|
|
|
8608
8612
|
// src/public-cli/load-production-acp-host.ts
|
|
8609
8613
|
import { existsSync as existsSync5 } from "node:fs";
|
|
8610
|
-
import { join as
|
|
8614
|
+
import { join as join20 } from "node:path";
|
|
8611
8615
|
import { pathToFileURL } from "node:url";
|
|
8612
8616
|
async function loadProductionAcpHostFactory(packageRoot, host) {
|
|
8613
8617
|
const description = lookupHostDescription(host);
|
|
8614
8618
|
if (description === void 0) {
|
|
8615
8619
|
throw new Error(`unregistered host: ${host}`);
|
|
8616
8620
|
}
|
|
8617
|
-
const built =
|
|
8618
|
-
const source =
|
|
8621
|
+
const built = join20(packageRoot, "dist/acp-host/production-host.js");
|
|
8622
|
+
const source = join20(packageRoot, "src/acp-host/production-host.ts");
|
|
8619
8623
|
const target = existsSync5(built) ? built : source;
|
|
8620
8624
|
const href = pathToFileURL(target).href;
|
|
8621
8625
|
const mod = await import(href);
|
|
@@ -8631,15 +8635,15 @@ var init_load_production_acp_host = __esm({
|
|
|
8631
8635
|
|
|
8632
8636
|
// src/public-cli/load-production-headless-host.ts
|
|
8633
8637
|
import { existsSync as existsSync6 } from "node:fs";
|
|
8634
|
-
import { join as
|
|
8638
|
+
import { join as join21 } from "node:path";
|
|
8635
8639
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
8636
8640
|
async function loadProductionHeadlessHostFactory(packageRoot, host) {
|
|
8637
8641
|
const description = lookupHeadlessHostDescription(host);
|
|
8638
8642
|
if (description === void 0) {
|
|
8639
8643
|
throw new Error(`unregistered headless host: ${host}`);
|
|
8640
8644
|
}
|
|
8641
|
-
const built =
|
|
8642
|
-
const source =
|
|
8645
|
+
const built = join21(packageRoot, "dist/headless-host/production-host.js");
|
|
8646
|
+
const source = join21(packageRoot, "src/headless-host/production-host.ts");
|
|
8643
8647
|
const target = existsSync6(built) ? built : source;
|
|
8644
8648
|
const href = pathToFileURL2(target).href;
|
|
8645
8649
|
const mod = await import(href);
|
|
@@ -8693,8 +8697,8 @@ __export(role_turn_host_resolution_exports, {
|
|
|
8693
8697
|
resolveRoleTurnHost: () => resolveRoleTurnHost,
|
|
8694
8698
|
selectRoleTurnHost: () => selectRoleTurnHost
|
|
8695
8699
|
});
|
|
8696
|
-
function formatHostSelectionFailure(
|
|
8697
|
-
return `${
|
|
8700
|
+
function formatHostSelectionFailure(failure) {
|
|
8701
|
+
return `${failure.kind}: ${failure.host}; seat=${failure.seat}; model=${failure.model}; registered: ${failure.registeredHosts.join(", ")}`;
|
|
8698
8702
|
}
|
|
8699
8703
|
function composeRoleTurnHostAdapters(env, principalAuthority) {
|
|
8700
8704
|
const piHost = env.roleTurnHost ?? createPiRoleTurnHost({
|
|
@@ -8754,9 +8758,9 @@ var init_role_turn_host_resolution = __esm({
|
|
|
8754
8758
|
init_invocation();
|
|
8755
8759
|
init_load_production_external_host();
|
|
8756
8760
|
HostSelectionError = class extends Error {
|
|
8757
|
-
constructor(
|
|
8758
|
-
super(formatHostSelectionFailure(
|
|
8759
|
-
this.failure =
|
|
8761
|
+
constructor(failure) {
|
|
8762
|
+
super(formatHostSelectionFailure(failure));
|
|
8763
|
+
this.failure = failure;
|
|
8760
8764
|
this.name = "HostSelectionError";
|
|
8761
8765
|
}
|
|
8762
8766
|
failure;
|
|
@@ -8778,15 +8782,15 @@ __export(host_providers_exports, {
|
|
|
8778
8782
|
renderHostProvidersTable: () => renderHostProvidersTable
|
|
8779
8783
|
});
|
|
8780
8784
|
import { readFileSync } from "node:fs";
|
|
8781
|
-
import { join as
|
|
8785
|
+
import { join as join22 } from "node:path";
|
|
8782
8786
|
function hostProvidersPath(home) {
|
|
8783
8787
|
if (typeof home !== "string" || home.trim() === "") {
|
|
8784
8788
|
throw new Error("home must be explicitly provided");
|
|
8785
8789
|
}
|
|
8786
|
-
return
|
|
8790
|
+
return join22(home, ".ak-roles", "host-providers.json");
|
|
8787
8791
|
}
|
|
8788
8792
|
function hermesProviderModelsCachePath(home) {
|
|
8789
|
-
return
|
|
8793
|
+
return join22(home, ".hermes", "provider_models_cache.json");
|
|
8790
8794
|
}
|
|
8791
8795
|
function parseHostProvidersTable(value) {
|
|
8792
8796
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
@@ -8942,7 +8946,7 @@ var init_host_providers = __esm({
|
|
|
8942
8946
|
|
|
8943
8947
|
// src/analyst-gate-cycles-read.ts
|
|
8944
8948
|
import { readdir as readdir4 } from "node:fs/promises";
|
|
8945
|
-
import { join as
|
|
8949
|
+
import { join as join23 } from "node:path";
|
|
8946
8950
|
function isRecord6(value) {
|
|
8947
8951
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8948
8952
|
}
|
|
@@ -9193,7 +9197,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
|
|
|
9193
9197
|
throw error;
|
|
9194
9198
|
}
|
|
9195
9199
|
for (const name of names) {
|
|
9196
|
-
const path =
|
|
9200
|
+
const path = join23(directory, name);
|
|
9197
9201
|
const fromPointer = name.endsWith(".pointer.json");
|
|
9198
9202
|
const pointer = fromPointer ? await resolveOfficerSessionFromPointerFile(path) : void 0;
|
|
9199
9203
|
const sessionPath = pointer?.sessionFile ?? path;
|
|
@@ -9235,7 +9239,7 @@ var init_analyst_gate_cycles_read = __esm({
|
|
|
9235
9239
|
});
|
|
9236
9240
|
|
|
9237
9241
|
// src/submission-ledger.ts
|
|
9238
|
-
import { join as
|
|
9242
|
+
import { join as join24 } from "node:path";
|
|
9239
9243
|
function runIdentity(context) {
|
|
9240
9244
|
const directory = runDirectoryFromHostContext(context);
|
|
9241
9245
|
if (directory !== void 0) {
|
|
@@ -9257,7 +9261,7 @@ async function submissionRecordFile(cwd, runId, scope) {
|
|
|
9257
9261
|
if (sessionParent === void 0) {
|
|
9258
9262
|
const discoveredRun = await findRunDirectoryById(scope.home, runId);
|
|
9259
9263
|
if (discoveredRun === void 0) return void 0;
|
|
9260
|
-
sessionParent =
|
|
9264
|
+
sessionParent = join24(discoveredRun, "session", "session.jsonl");
|
|
9261
9265
|
}
|
|
9262
9266
|
return resolveSitianRecordPathInLedger({
|
|
9263
9267
|
level: "event",
|
|
@@ -9450,12 +9454,12 @@ async function restoreState(cwd, runId, scope) {
|
|
|
9450
9454
|
}
|
|
9451
9455
|
function sessionParentFromHostContext(context) {
|
|
9452
9456
|
const runDirectory = runDirectoryFromHostContext(context);
|
|
9453
|
-
if (runDirectory !== void 0) return
|
|
9457
|
+
if (runDirectory !== void 0) return join24(runDirectory, "session", "session.jsonl");
|
|
9454
9458
|
const sessionFile = context.sessionManager.getSessionFile?.();
|
|
9455
9459
|
if (typeof sessionFile === "string" && sessionFile.length > 0) return sessionFile;
|
|
9456
9460
|
const sessionDir = context.sessionManager.getSessionDir?.();
|
|
9457
9461
|
if (typeof sessionDir === "string" && sessionDir.length > 0) {
|
|
9458
|
-
return
|
|
9462
|
+
return join24(sessionDir, "session.jsonl");
|
|
9459
9463
|
}
|
|
9460
9464
|
return void 0;
|
|
9461
9465
|
}
|
|
@@ -9643,12 +9647,12 @@ var init_audit_escalation = __esm({
|
|
|
9643
9647
|
// src/session-opening-materials.ts
|
|
9644
9648
|
import { existsSync as existsSync7 } from "node:fs";
|
|
9645
9649
|
import { readFile as readFile14 } from "node:fs/promises";
|
|
9646
|
-
import { dirname as dirname14, join as
|
|
9650
|
+
import { dirname as dirname14, join as join25 } from "node:path";
|
|
9647
9651
|
import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
9648
9652
|
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
9649
9653
|
let dir = dirname14(fileURLToPath(moduleUrl));
|
|
9650
9654
|
for (let i = 0; i < 8; i += 1) {
|
|
9651
|
-
if (existsSync7(
|
|
9655
|
+
if (existsSync7(join25(dir, "package.json")) && existsSync7(join25(dir, "souls"))) {
|
|
9652
9656
|
return dir;
|
|
9653
9657
|
}
|
|
9654
9658
|
const parent = dirname14(dir);
|
|
@@ -9717,7 +9721,7 @@ __export(auditor_soul_exports, {
|
|
|
9717
9721
|
resolveAuditorSubject: () => resolveAuditorSubject
|
|
9718
9722
|
});
|
|
9719
9723
|
import { readFile as readFile15 } from "node:fs/promises";
|
|
9720
|
-
import { basename as basename8, join as
|
|
9724
|
+
import { basename as basename8, join as join26 } from "node:path";
|
|
9721
9725
|
function auditorSoulRelativePath(role) {
|
|
9722
9726
|
return `souls/${role}-auditor.md`;
|
|
9723
9727
|
}
|
|
@@ -9759,7 +9763,7 @@ function subjectFromSourceDirectory(sourceRunDirectory) {
|
|
|
9759
9763
|
async function readAuditorResumeBinding(runDirectory) {
|
|
9760
9764
|
let raw;
|
|
9761
9765
|
try {
|
|
9762
|
-
raw = JSON.parse(await readFile15(
|
|
9766
|
+
raw = JSON.parse(await readFile15(join26(runDirectory, "admitted-request.json"), "utf8"));
|
|
9763
9767
|
} catch (error) {
|
|
9764
9768
|
if (error.code === "ENOENT") return void 0;
|
|
9765
9769
|
throw error;
|
|
@@ -9872,7 +9876,7 @@ var init_serialize_thrown_value = __esm({
|
|
|
9872
9876
|
// src/engine-detour-usage.ts
|
|
9873
9877
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
9874
9878
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
9875
|
-
import { dirname as dirname15, join as
|
|
9879
|
+
import { dirname as dirname15, join as join27 } from "node:path";
|
|
9876
9880
|
function engineDetourStdoutByteLength(stdout) {
|
|
9877
9881
|
return Buffer.byteLength(stdout, "utf8");
|
|
9878
9882
|
}
|
|
@@ -10009,7 +10013,7 @@ function projectEngineDetourToolUsageForPublicTerminal(usage, options) {
|
|
|
10009
10013
|
function readInvocationRecord(runDirectory) {
|
|
10010
10014
|
try {
|
|
10011
10015
|
const raw = JSON.parse(
|
|
10012
|
-
readFileSync2(
|
|
10016
|
+
readFileSync2(join27(runDirectory, "invocation.json"), "utf8")
|
|
10013
10017
|
);
|
|
10014
10018
|
return isRecord7(raw) ? raw : void 0;
|
|
10015
10019
|
} catch (error) {
|
|
@@ -10037,7 +10041,7 @@ function runDirectoryFromSessionDirectory(sessionDirectory) {
|
|
|
10037
10041
|
return dirname15(sessionDirectory);
|
|
10038
10042
|
}
|
|
10039
10043
|
function sessionFileFromSessionDirectory(sessionDirectory) {
|
|
10040
|
-
return
|
|
10044
|
+
return join27(sessionDirectory, "session.jsonl");
|
|
10041
10045
|
}
|
|
10042
10046
|
function mintEngineDetourInvocationScope(input) {
|
|
10043
10047
|
const engine = input.effectiveEngine?.trim();
|
|
@@ -10282,14 +10286,14 @@ __export(settlement_exports, {
|
|
|
10282
10286
|
});
|
|
10283
10287
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
10284
10288
|
import { appendFile as appendFile2, readFile as readFile16, readdir as readdir5, rm as rm4, writeFile as writeFile6 } from "node:fs/promises";
|
|
10285
|
-
import { dirname as dirname16, join as
|
|
10289
|
+
import { dirname as dirname16, join as join28 } from "node:path";
|
|
10286
10290
|
function sealedLedgerHome(admitted) {
|
|
10287
10291
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
10288
10292
|
}
|
|
10289
10293
|
function ledgerReadScope(admitted, scope) {
|
|
10290
10294
|
return {
|
|
10291
10295
|
home: sealedLedgerHome(admitted),
|
|
10292
|
-
sessionParent:
|
|
10296
|
+
sessionParent: join28(admitted.runDirectory, "session", "session.jsonl"),
|
|
10293
10297
|
...scope?.courtAttemptId === void 0 || scope.courtAttemptId.length === 0 ? {} : { attemptId: scope.courtAttemptId }
|
|
10294
10298
|
};
|
|
10295
10299
|
}
|
|
@@ -10421,8 +10425,8 @@ function formatCliDiagnostic(message) {
|
|
|
10421
10425
|
return `ak-role: ${message}
|
|
10422
10426
|
`;
|
|
10423
10427
|
}
|
|
10424
|
-
function formatFailureStderrDiagnostic(
|
|
10425
|
-
const text =
|
|
10428
|
+
function formatFailureStderrDiagnostic(failure) {
|
|
10429
|
+
const text = failure.diagnostic.trim().length > 0 ? failure.diagnostic : "failure";
|
|
10426
10430
|
return formatCliDiagnostic(text);
|
|
10427
10431
|
}
|
|
10428
10432
|
function formatErrorCauseDetail(cause) {
|
|
@@ -10447,10 +10451,10 @@ function presentStructuralRejection(error, io) {
|
|
|
10447
10451
|
}
|
|
10448
10452
|
io.stderr(formatCliDiagnostic(message));
|
|
10449
10453
|
}
|
|
10450
|
-
function presentControlledFailure(
|
|
10451
|
-
io.stdout(`${JSON.stringify(
|
|
10454
|
+
function presentControlledFailure(failure, io) {
|
|
10455
|
+
io.stdout(`${JSON.stringify(failure, null, 2)}
|
|
10452
10456
|
`);
|
|
10453
|
-
io.stderr(formatFailureStderrDiagnostic(
|
|
10457
|
+
io.stderr(formatFailureStderrDiagnostic(failure));
|
|
10454
10458
|
}
|
|
10455
10459
|
async function inspectJudgeSession(sessionFile) {
|
|
10456
10460
|
try {
|
|
@@ -10553,14 +10557,14 @@ function classifyThrownFailure(error) {
|
|
|
10553
10557
|
}
|
|
10554
10558
|
};
|
|
10555
10559
|
}
|
|
10556
|
-
function withKnownDetails(
|
|
10557
|
-
if (knownDetails === void 0) return
|
|
10560
|
+
function withKnownDetails(failure, knownDetails) {
|
|
10561
|
+
if (knownDetails === void 0) return failure;
|
|
10558
10562
|
const { timedOut: _knownTimedOut, ...rest } = knownDetails;
|
|
10559
10563
|
return {
|
|
10560
|
-
...
|
|
10564
|
+
...failure,
|
|
10561
10565
|
details: {
|
|
10562
10566
|
...rest,
|
|
10563
|
-
...
|
|
10567
|
+
...failure.details ?? {}
|
|
10564
10568
|
}
|
|
10565
10569
|
};
|
|
10566
10570
|
}
|
|
@@ -10653,13 +10657,13 @@ function classifyPostAdmissionFailure(input) {
|
|
|
10653
10657
|
input.knownDetails
|
|
10654
10658
|
);
|
|
10655
10659
|
}
|
|
10656
|
-
function explicitInternalKnownFailureClassificationInput(
|
|
10657
|
-
if (
|
|
10660
|
+
function explicitInternalKnownFailureClassificationInput(failure) {
|
|
10661
|
+
if (failure === void 0) return {};
|
|
10658
10662
|
return {
|
|
10659
|
-
...
|
|
10660
|
-
...
|
|
10661
|
-
...
|
|
10662
|
-
...
|
|
10663
|
+
...failure.cause === void 0 ? {} : { knownCause: failure.cause },
|
|
10664
|
+
...failure.identity === void 0 ? {} : { knownIdentity: failure.identity },
|
|
10665
|
+
...failure.diagnostic === void 0 ? {} : { knownDiagnostic: failure.diagnostic },
|
|
10666
|
+
...failure.details === void 0 ? {} : { knownDetails: failure.details }
|
|
10663
10667
|
};
|
|
10664
10668
|
}
|
|
10665
10669
|
function isMissingPathError4(error) {
|
|
@@ -10790,7 +10794,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
10790
10794
|
}
|
|
10791
10795
|
const parentId = parentEntries.find((entry) => entry.type === "session")?.id;
|
|
10792
10796
|
if (parentId === void 0) return void 0;
|
|
10793
|
-
const childDirectories = [
|
|
10797
|
+
const childDirectories = [join28(dirname16(sessionFile), "auditor-roles")];
|
|
10794
10798
|
const valid = [];
|
|
10795
10799
|
let sawAnyDirectory = false;
|
|
10796
10800
|
for (const childDirectory of childDirectories) {
|
|
@@ -10805,7 +10809,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
10805
10809
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
10806
10810
|
let entries;
|
|
10807
10811
|
try {
|
|
10808
|
-
entries = await readBoundSessionEntries(
|
|
10812
|
+
entries = await readBoundSessionEntries(join28(childDirectory, file));
|
|
10809
10813
|
} catch (error) {
|
|
10810
10814
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
10811
10815
|
}
|
|
@@ -10850,19 +10854,19 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
10850
10854
|
const entry = entries[i];
|
|
10851
10855
|
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord10(entry.data)) continue;
|
|
10852
10856
|
const parent = isRecord10(entry.data.parent) ? entry.data.parent : void 0;
|
|
10853
|
-
const
|
|
10857
|
+
const failure = isRecord10(entry.data.failure) ? entry.data.failure : void 0;
|
|
10854
10858
|
if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId) continue;
|
|
10855
|
-
if (
|
|
10856
|
-
const identity = isRecord10(
|
|
10857
|
-
const typedCause =
|
|
10859
|
+
if (failure === void 0) continue;
|
|
10860
|
+
const identity = isRecord10(failure.identity) ? failure.identity : void 0;
|
|
10861
|
+
const typedCause = failure.cause === "provider" || failure.cause === "activation" || failure.cause === "session" || failure.cause === "output" || failure.cause === "timeout" ? failure.cause : void 0;
|
|
10858
10862
|
return {
|
|
10859
10863
|
...typedCause === void 0 ? {} : { cause: typedCause },
|
|
10860
10864
|
...identity === void 0 ? {} : { identity: {
|
|
10861
10865
|
...typeof identity.name === "string" ? { name: identity.name } : {},
|
|
10862
10866
|
...typeof identity.code === "string" || typeof identity.code === "number" ? { code: identity.code } : {}
|
|
10863
10867
|
} },
|
|
10864
|
-
...typeof
|
|
10865
|
-
...isRecord10(
|
|
10868
|
+
...typeof failure.diagnostic === "string" ? { diagnostic: failure.diagnostic } : {},
|
|
10869
|
+
...isRecord10(failure.details) ? { details: failure.details } : {}
|
|
10866
10870
|
};
|
|
10867
10871
|
}
|
|
10868
10872
|
}
|
|
@@ -10934,11 +10938,11 @@ async function resolveAuditedRunnerFailureResolution(input) {
|
|
|
10934
10938
|
const auditorCompliance = await readBoundAuditorComplianceFailure(input.sessionFile);
|
|
10935
10939
|
if (auditorCompliance !== void 0) return resolutionOf(auditorCompliance);
|
|
10936
10940
|
} catch (error) {
|
|
10937
|
-
const
|
|
10941
|
+
const failure = sessionReadFailure(error, "failed to recover bound auditor failure");
|
|
10938
10942
|
return resolutionOf({
|
|
10939
10943
|
cause: "session",
|
|
10940
|
-
identity: thrownIdentity(
|
|
10941
|
-
diagnostic:
|
|
10944
|
+
identity: thrownIdentity(failure),
|
|
10945
|
+
diagnostic: failure.message || failure.name
|
|
10942
10946
|
});
|
|
10943
10947
|
}
|
|
10944
10948
|
try {
|
|
@@ -10948,11 +10952,11 @@ async function resolveAuditedRunnerFailureResolution(input) {
|
|
|
10948
10952
|
if (terminatingFailure !== void 0) return resolutionOf(terminatingFailure);
|
|
10949
10953
|
} catch (error) {
|
|
10950
10954
|
if (!isMissingPathError4(error)) {
|
|
10951
|
-
const
|
|
10955
|
+
const failure = sessionReadFailure(error, "failed to recover typed terminating-tool failure");
|
|
10952
10956
|
return resolutionOf({
|
|
10953
10957
|
cause: "session",
|
|
10954
|
-
identity: thrownIdentity(
|
|
10955
|
-
diagnostic:
|
|
10958
|
+
identity: thrownIdentity(failure),
|
|
10959
|
+
diagnostic: failure.message || failure.name
|
|
10956
10960
|
});
|
|
10957
10961
|
}
|
|
10958
10962
|
}
|
|
@@ -10960,11 +10964,11 @@ async function resolveAuditedRunnerFailureResolution(input) {
|
|
|
10960
10964
|
const auditorStop = await readBoundAuditorProviderStopFallback(input.sessionFile);
|
|
10961
10965
|
if (auditorStop !== void 0) return resolutionOf(auditorStop);
|
|
10962
10966
|
} catch (error) {
|
|
10963
|
-
const
|
|
10967
|
+
const failure = sessionReadFailure(error, "failed to recover bound auditor provider stop");
|
|
10964
10968
|
return resolutionOf({
|
|
10965
10969
|
cause: "session",
|
|
10966
|
-
identity: thrownIdentity(
|
|
10967
|
-
diagnostic:
|
|
10970
|
+
identity: thrownIdentity(failure),
|
|
10971
|
+
diagnostic: failure.message || failure.name
|
|
10968
10972
|
});
|
|
10969
10973
|
}
|
|
10970
10974
|
const parentStop = await readSessionProviderStop(input.sessionFile);
|
|
@@ -10973,12 +10977,12 @@ async function resolveAuditedRunnerFailureResolution(input) {
|
|
|
10973
10977
|
try {
|
|
10974
10978
|
httpObservation = await readLatestTypedProviderHttpObservation(input.runDirectory);
|
|
10975
10979
|
} catch (error) {
|
|
10976
|
-
const
|
|
10980
|
+
const failure = error instanceof Error ? error : new Error(String(error));
|
|
10977
10981
|
return resolutionOf(
|
|
10978
10982
|
{
|
|
10979
10983
|
cause: "session",
|
|
10980
|
-
identity: thrownIdentity(
|
|
10981
|
-
diagnostic:
|
|
10984
|
+
identity: thrownIdentity(failure),
|
|
10985
|
+
diagnostic: failure.message || failure.name
|
|
10982
10986
|
},
|
|
10983
10987
|
{ settled: true }
|
|
10984
10988
|
);
|
|
@@ -11029,12 +11033,12 @@ async function resolveControlledFailureResumeObservation(input) {
|
|
|
11029
11033
|
const typedHttp429 = await readTypedHttp429Observation(input.runDirectory);
|
|
11030
11034
|
return typedHttp429 === void 0 ? {} : { typedHttp429 };
|
|
11031
11035
|
} catch (error) {
|
|
11032
|
-
const
|
|
11036
|
+
const failure = error instanceof Error ? error : new Error(String(error));
|
|
11033
11037
|
return {
|
|
11034
11038
|
observationReadFailure: {
|
|
11035
11039
|
cause: "session",
|
|
11036
|
-
identity: thrownIdentity(
|
|
11037
|
-
diagnostic:
|
|
11040
|
+
identity: thrownIdentity(failure),
|
|
11041
|
+
diagnostic: failure.message || failure.name
|
|
11038
11042
|
}
|
|
11039
11043
|
};
|
|
11040
11044
|
}
|
|
@@ -11114,11 +11118,11 @@ async function readEngineDetourInfrastructureFailure(sessionFile) {
|
|
|
11114
11118
|
ENGINE_DETOUR_INFRASTRUCTURE_FAILURE_SPEC
|
|
11115
11119
|
);
|
|
11116
11120
|
}
|
|
11117
|
-
function knownFailureFromControlled(
|
|
11121
|
+
function knownFailureFromControlled(failure) {
|
|
11118
11122
|
return {
|
|
11119
|
-
...
|
|
11120
|
-
diagnostic:
|
|
11121
|
-
...
|
|
11123
|
+
...failure.cause === void 0 ? {} : { cause: failure.cause },
|
|
11124
|
+
diagnostic: failure.diagnostic,
|
|
11125
|
+
...failure.identity === void 0 ? {} : { identity: failure.identity }
|
|
11122
11126
|
};
|
|
11123
11127
|
}
|
|
11124
11128
|
function seatKnownFailureResolver(role) {
|
|
@@ -11281,8 +11285,8 @@ function projectTerminalGateFact(rounds) {
|
|
|
11281
11285
|
};
|
|
11282
11286
|
}
|
|
11283
11287
|
async function extractGateFactFromSessionDirectory(sessionDirectory, options = {}) {
|
|
11284
|
-
const directories = [
|
|
11285
|
-
const parentSessionFile = options.parentSessionFile ??
|
|
11288
|
+
const directories = [join28(sessionDirectory, "auditor-roles")];
|
|
11289
|
+
const parentSessionFile = options.parentSessionFile ?? join28(sessionDirectory, "session.jsonl");
|
|
11286
11290
|
const rounds = await readAnalystGateCyclesFromAuditorRoles(directories, {
|
|
11287
11291
|
parentSessionFile
|
|
11288
11292
|
});
|
|
@@ -11394,10 +11398,10 @@ async function removeFaceIfPresent(path) {
|
|
|
11394
11398
|
async function clearOppositeTerminalArtifactFace(runDirectory) {
|
|
11395
11399
|
const artifactsDir = roleRunArtifactsDirectory(runDirectory);
|
|
11396
11400
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
11397
|
-
await removeFaceIfPresent(
|
|
11401
|
+
await removeFaceIfPresent(join28(artifactsDir, file));
|
|
11398
11402
|
}
|
|
11399
11403
|
for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
11400
|
-
await removeFaceIfPresent(
|
|
11404
|
+
await removeFaceIfPresent(join28(runDirectory, relative3));
|
|
11401
11405
|
}
|
|
11402
11406
|
for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
|
|
11403
11407
|
await removeFaceIfPresent(path);
|
|
@@ -11426,8 +11430,8 @@ async function publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinat
|
|
|
11426
11430
|
roleOutcome
|
|
11427
11431
|
);
|
|
11428
11432
|
const artifactsDir = await ensureTerminalArtifactFace(admitted.runDirectory);
|
|
11429
|
-
const reportPath =
|
|
11430
|
-
const evidencePath =
|
|
11433
|
+
const reportPath = join28(artifactsDir, "report.json");
|
|
11434
|
+
const evidencePath = join28(artifactsDir, "evidence.json");
|
|
11431
11435
|
await writeFile6(
|
|
11432
11436
|
reportPath,
|
|
11433
11437
|
`${JSON.stringify(bodies.report, null, 2)}
|
|
@@ -11836,7 +11840,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
|
|
|
11836
11840
|
const candidates = [
|
|
11837
11841
|
...preferredCandidates,
|
|
11838
11842
|
// One unique name per fallback dir — collisions on fixed names cannot exhaust this.
|
|
11839
|
-
...uniqueFallbackDirs.map((dir) =>
|
|
11843
|
+
...uniqueFallbackDirs.map((dir) => join28(dir, `${stem}.${randomUUID5()}.json`))
|
|
11840
11844
|
];
|
|
11841
11845
|
for (let i = 0; i < candidates.length; i += 1) {
|
|
11842
11846
|
const path = candidates[i];
|
|
@@ -11866,7 +11870,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
|
|
|
11866
11870
|
error.publicationAttempts = issues;
|
|
11867
11871
|
throw error;
|
|
11868
11872
|
}
|
|
11869
|
-
async function publishFailureArtifacts(admitted,
|
|
11873
|
+
async function publishFailureArtifacts(admitted, failure, authority, onErrorPublished) {
|
|
11870
11874
|
const { sessionDirectory, sessionFile } = coordinatesFromAdmitted(authority, admitted);
|
|
11871
11875
|
const { baseDir, attempt: baseAttempt } = await resolveFailureArtifactsBase(
|
|
11872
11876
|
admitted.runDirectory
|
|
@@ -11886,7 +11890,7 @@ async function publishFailureArtifacts(admitted, failure2, authority, onErrorPub
|
|
|
11886
11890
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile }, {
|
|
11887
11891
|
kind: "failure",
|
|
11888
11892
|
role: admitted.role,
|
|
11889
|
-
...
|
|
11893
|
+
...failure
|
|
11890
11894
|
});
|
|
11891
11895
|
} catch (error) {
|
|
11892
11896
|
priorIssues.push(publicationAttemptFromError(sessionFile, error));
|
|
@@ -11897,29 +11901,29 @@ async function publishFailureArtifacts(admitted, failure2, authority, onErrorPub
|
|
|
11897
11901
|
baseDir
|
|
11898
11902
|
);
|
|
11899
11903
|
const errorCandidates = underArtifacts ? [
|
|
11900
|
-
|
|
11901
|
-
|
|
11902
|
-
|
|
11904
|
+
join28(baseDir, "error.json"),
|
|
11905
|
+
join28(baseDir, "error.settlement.json"),
|
|
11906
|
+
join28(admitted.runDirectory, "error.settlement.json")
|
|
11903
11907
|
] : [
|
|
11904
|
-
|
|
11905
|
-
|
|
11908
|
+
join28(baseDir, "error.settlement.json"),
|
|
11909
|
+
join28(baseDir, "error.json")
|
|
11906
11910
|
];
|
|
11907
11911
|
const evidenceCandidates = underArtifacts ? [
|
|
11908
|
-
|
|
11909
|
-
|
|
11910
|
-
|
|
11912
|
+
join28(baseDir, "evidence.json"),
|
|
11913
|
+
join28(baseDir, "evidence.settlement.json"),
|
|
11914
|
+
join28(admitted.runDirectory, "evidence.settlement.json")
|
|
11911
11915
|
] : [
|
|
11912
|
-
|
|
11913
|
-
|
|
11916
|
+
join28(baseDir, "evidence.settlement.json"),
|
|
11917
|
+
join28(baseDir, "evidence.json")
|
|
11914
11918
|
];
|
|
11915
11919
|
const errorPayloadBase = {
|
|
11916
11920
|
kind: "error",
|
|
11917
11921
|
role: admitted.role,
|
|
11918
11922
|
runId: admitted.runId,
|
|
11919
|
-
...
|
|
11920
|
-
diagnostic:
|
|
11921
|
-
...
|
|
11922
|
-
...
|
|
11923
|
+
...failure.cause === void 0 ? {} : { cause: failure.cause },
|
|
11924
|
+
diagnostic: failure.diagnostic,
|
|
11925
|
+
...failure.identity === void 0 ? {} : { identity: failure.identity },
|
|
11926
|
+
...failure.details === void 0 ? {} : { details: failure.details }
|
|
11923
11927
|
};
|
|
11924
11928
|
const errorWrite = await writeFailureJsonRetainingCause(
|
|
11925
11929
|
errorCandidates,
|
|
@@ -11940,7 +11944,7 @@ async function publishFailureArtifacts(admitted, failure2, authority, onErrorPub
|
|
|
11940
11944
|
sha256: a.sha256,
|
|
11941
11945
|
byteLength: a.byteLength
|
|
11942
11946
|
})),
|
|
11943
|
-
...
|
|
11947
|
+
...failure.cause === void 0 ? {} : { failureCause: failure.cause }
|
|
11944
11948
|
};
|
|
11945
11949
|
const evidenceWrite = await writeFailureJsonRetainingCause(
|
|
11946
11950
|
evidenceCandidates,
|
|
@@ -11955,10 +11959,10 @@ async function publishFailureArtifacts(admitted, failure2, authority, onErrorPub
|
|
|
11955
11959
|
{ kind: "evidence", path: evidenceWrite.path }
|
|
11956
11960
|
];
|
|
11957
11961
|
}
|
|
11958
|
-
async function settleFailureTerminalResult(admitted,
|
|
11962
|
+
async function settleFailureTerminalResult(admitted, failure, authority, options = {}) {
|
|
11959
11963
|
const coordinates = coordinatesFromAdmitted(authority, admitted);
|
|
11960
11964
|
const { sessionDirectory, sessionFile } = coordinates;
|
|
11961
|
-
if (
|
|
11965
|
+
if (failure.cause === "output") {
|
|
11962
11966
|
const entries = await readBoundSessionEntries(sessionFile).catch(() => void 0);
|
|
11963
11967
|
if (entries !== void 0) {
|
|
11964
11968
|
let attemptStart = 0;
|
|
@@ -12000,27 +12004,27 @@ async function settleFailureTerminalResult(admitted, failure2, authority, option
|
|
|
12000
12004
|
}
|
|
12001
12005
|
}
|
|
12002
12006
|
const navigator = await extractNavigatorFactFromAdmittedSession(sessionFile);
|
|
12003
|
-
const artifacts = await publishFailureArtifacts(admitted,
|
|
12007
|
+
const artifacts = await publishFailureArtifacts(admitted, failure, authority, options.onErrorPublished);
|
|
12004
12008
|
const errorPath = artifacts.find((artifact) => artifact.kind === "error")?.path;
|
|
12005
12009
|
const decisiveFacts = {
|
|
12006
|
-
...
|
|
12007
|
-
diagnostic:
|
|
12010
|
+
...failure.cause === void 0 ? {} : { cause: failure.cause },
|
|
12011
|
+
diagnostic: failure.diagnostic
|
|
12008
12012
|
};
|
|
12009
|
-
if (
|
|
12010
|
-
decisiveFacts.errorName =
|
|
12013
|
+
if (failure.identity?.name !== void 0) {
|
|
12014
|
+
decisiveFacts.errorName = failure.identity.name;
|
|
12011
12015
|
}
|
|
12012
|
-
if (
|
|
12013
|
-
decisiveFacts.errorCode =
|
|
12016
|
+
if (failure.identity?.code !== void 0) {
|
|
12017
|
+
decisiveFacts.errorCode = failure.identity.code;
|
|
12014
12018
|
}
|
|
12015
|
-
if (
|
|
12016
|
-
decisiveFacts.secondaryEvidence =
|
|
12019
|
+
if (failure.details !== void 0) {
|
|
12020
|
+
decisiveFacts.secondaryEvidence = failure.details;
|
|
12017
12021
|
}
|
|
12018
12022
|
if (options.resume !== void 0) {
|
|
12019
12023
|
const roleOutcome2 = {
|
|
12020
12024
|
kind: "failure",
|
|
12021
12025
|
role: admitted.role,
|
|
12022
|
-
...
|
|
12023
|
-
diagnostic:
|
|
12026
|
+
...failure.cause === void 0 ? {} : { cause: failure.cause },
|
|
12027
|
+
diagnostic: failure.diagnostic,
|
|
12024
12028
|
decisiveFacts
|
|
12025
12029
|
};
|
|
12026
12030
|
const terminal = await withOptionalGateProjection(
|
|
@@ -12039,8 +12043,8 @@ async function settleFailureTerminalResult(admitted, failure2, authority, option
|
|
|
12039
12043
|
const roleOutcome = {
|
|
12040
12044
|
kind: "failure",
|
|
12041
12045
|
role: admitted.role,
|
|
12042
|
-
...
|
|
12043
|
-
diagnostic:
|
|
12046
|
+
...failure.cause === void 0 ? {} : { cause: failure.cause },
|
|
12047
|
+
diagnostic: failure.diagnostic,
|
|
12044
12048
|
decisiveFacts
|
|
12045
12049
|
};
|
|
12046
12050
|
return withOptionalGateProjection(
|
|
@@ -12054,8 +12058,8 @@ async function settleFailureTerminalResult(admitted, failure2, authority, option
|
|
|
12054
12058
|
detourGateContext(admitted, options)
|
|
12055
12059
|
);
|
|
12056
12060
|
}
|
|
12057
|
-
async function settleJudgeFailureTerminalResult(admitted,
|
|
12058
|
-
return settleFailureTerminalResult(admitted,
|
|
12061
|
+
async function settleJudgeFailureTerminalResult(admitted, failure, authority, options = {}) {
|
|
12062
|
+
return settleFailureTerminalResult(admitted, failure, authority, options);
|
|
12059
12063
|
}
|
|
12060
12064
|
function presentFailureTerminal(terminal, io) {
|
|
12061
12065
|
if (terminal.roleOutcome.kind !== "failure" && terminal.roleOutcome.kind !== "no_receipt") {
|
|
@@ -12165,9 +12169,9 @@ var init_settlement = __esm({
|
|
|
12165
12169
|
|
|
12166
12170
|
// src/archivist-record-pointer.ts
|
|
12167
12171
|
import { mkdirSync as mkdirSync2, writeFileSync } from "node:fs";
|
|
12168
|
-
import { dirname as dirname17, join as
|
|
12172
|
+
import { dirname as dirname17, join as join29 } from "node:path";
|
|
12169
12173
|
function bookDirectOfficerRunPointer(options) {
|
|
12170
|
-
const nest =
|
|
12174
|
+
const nest = join29(dirname17(options.parentSessionFile), "auditor-roles");
|
|
12171
12175
|
mkdirSync2(nest, { recursive: true });
|
|
12172
12176
|
const pointer = {
|
|
12173
12177
|
version: 1,
|
|
@@ -12177,7 +12181,7 @@ function bookDirectOfficerRunPointer(options) {
|
|
|
12177
12181
|
...options.runDirectory !== void 0 && options.runDirectory.trim() !== "" ? { runDirectory: options.runDirectory } : {}
|
|
12178
12182
|
};
|
|
12179
12183
|
writeFileSync(
|
|
12180
|
-
|
|
12184
|
+
join29(nest, `${options.officer}.pointer.json`),
|
|
12181
12185
|
`${JSON.stringify(pointer)}
|
|
12182
12186
|
`,
|
|
12183
12187
|
"utf8"
|
|
@@ -12406,11 +12410,11 @@ async function requireSubmissionGate(options) {
|
|
|
12406
12410
|
continue;
|
|
12407
12411
|
}
|
|
12408
12412
|
if (gatekeeper.status === "transport_failure") {
|
|
12409
|
-
const
|
|
12413
|
+
const failure = Object.assign(new Error(gatekeeper.reason), {
|
|
12410
12414
|
name: "GatekeeperTransportFailure",
|
|
12411
12415
|
...gatekeeper.submission === void 0 ? {} : { submission: gatekeeper.submission }
|
|
12412
12416
|
});
|
|
12413
|
-
options.hostActions.failInfrastructure(
|
|
12417
|
+
options.hostActions.failInfrastructure(failure, options.context, options.toolCallId);
|
|
12414
12418
|
}
|
|
12415
12419
|
if (gatekeeper.status === "escalate") {
|
|
12416
12420
|
return {
|
|
@@ -12436,9 +12440,9 @@ var init_submission_gate = __esm({
|
|
|
12436
12440
|
|
|
12437
12441
|
// src/session-identity.ts
|
|
12438
12442
|
import { mkdir as mkdir2, readFile as readFile17, rename as rename3, writeFile as writeFile7 } from "node:fs/promises";
|
|
12439
|
-
import { dirname as dirname18, join as
|
|
12443
|
+
import { dirname as dirname18, join as join30 } from "node:path";
|
|
12440
12444
|
function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
12441
|
-
const bindingPath = (principal) =>
|
|
12445
|
+
const bindingPath = (principal) => join30(authority.decode(principal).sessionDirectory, sessionBindingFile);
|
|
12442
12446
|
return {
|
|
12443
12447
|
resolveSessionFile(principal) {
|
|
12444
12448
|
return authority.decode(principal).sessionFile;
|
|
@@ -12516,7 +12520,7 @@ import {
|
|
|
12516
12520
|
statSync as statSync3
|
|
12517
12521
|
} from "node:fs";
|
|
12518
12522
|
import { homedir } from "node:os";
|
|
12519
|
-
import { dirname as dirname19, join as
|
|
12523
|
+
import { dirname as dirname19, join as join31 } from "node:path";
|
|
12520
12524
|
function declareHostSessionFailure(error) {
|
|
12521
12525
|
const message = error instanceof Error ? error.stack || error.message : String(error);
|
|
12522
12526
|
process.stderr.write(`[host-session] Dossier record failure: ${message}
|
|
@@ -12541,7 +12545,7 @@ function findCodexRollout(sessionsDir, sessionId) {
|
|
|
12541
12545
|
return;
|
|
12542
12546
|
}
|
|
12543
12547
|
for (const entry of entries) {
|
|
12544
|
-
const fullPath =
|
|
12548
|
+
const fullPath = join31(dir, entry.name);
|
|
12545
12549
|
if (entry.isDirectory()) {
|
|
12546
12550
|
scan(fullPath, depth + 1);
|
|
12547
12551
|
} else if (entry.isFile() && entry.name.endsWith(".jsonl") && entry.name.includes(sessionId)) {
|
|
@@ -12565,25 +12569,25 @@ function sanitizeClaudeCwd(cwd) {
|
|
|
12565
12569
|
function resolveNativeSessionPath(options) {
|
|
12566
12570
|
const home = options.home || homedir();
|
|
12567
12571
|
if (options.host === "claude") {
|
|
12568
|
-
const configDir = process.env.CLAUDE_CONFIG_DIR ||
|
|
12572
|
+
const configDir = process.env.CLAUDE_CONFIG_DIR || join31(home, ".claude");
|
|
12569
12573
|
const sanitizedCwd = sanitizeClaudeCwd(options.cwd);
|
|
12570
|
-
return
|
|
12574
|
+
return join31(configDir, "projects", sanitizedCwd, `${options.sessionId}.jsonl`);
|
|
12571
12575
|
}
|
|
12572
12576
|
if (options.host === "codex") {
|
|
12573
12577
|
return findCodexRollout(codexSessionsDirectory(home), options.sessionId);
|
|
12574
12578
|
}
|
|
12575
12579
|
if (options.host === "grok-build") {
|
|
12576
|
-
const grokHome = process.env.GROK_HOME ||
|
|
12577
|
-
return
|
|
12580
|
+
const grokHome = process.env.GROK_HOME || join31(home, ".grok");
|
|
12581
|
+
return join31(grokHome, "sessions", encodeURIComponent(options.cwd), options.sessionId);
|
|
12578
12582
|
}
|
|
12579
12583
|
return void 0;
|
|
12580
12584
|
}
|
|
12581
12585
|
function codexSessionsDirectory(home) {
|
|
12582
|
-
return
|
|
12586
|
+
return join31(process.env.CODEX_HOME || join31(home || homedir(), ".codex"), "sessions");
|
|
12583
12587
|
}
|
|
12584
12588
|
function recordRunStart(runDirectory) {
|
|
12585
12589
|
try {
|
|
12586
|
-
appendFileSync2(
|
|
12590
|
+
appendFileSync2(join31(runDirectory, ".run-starts"), "\n");
|
|
12587
12591
|
} catch (error) {
|
|
12588
12592
|
declareHostSessionFailure(error);
|
|
12589
12593
|
}
|
|
@@ -12607,12 +12611,12 @@ function resolveHostDossierLandingPath(options) {
|
|
|
12607
12611
|
} catch {
|
|
12608
12612
|
}
|
|
12609
12613
|
}
|
|
12610
|
-
const startsPath =
|
|
12614
|
+
const startsPath = join31(dirname19(options.sessionDirectory), ".run-starts");
|
|
12611
12615
|
let starts = 0;
|
|
12612
12616
|
if (existsSync9(startsPath)) starts = readFileSync3(startsPath, "utf8").length;
|
|
12613
12617
|
const ordinal = Math.max(maxOrdinal + 1, starts, options.continuation.kind === "resume" ? 2 : 1);
|
|
12614
12618
|
const baseName = `${options.host}-${sanitizedModel}-${ordinal}`;
|
|
12615
|
-
const landingPath = options.host === "grok-build" ?
|
|
12619
|
+
const landingPath = options.host === "grok-build" ? join31(options.sessionDirectory, baseName) : join31(options.sessionDirectory, `${baseName}.jsonl`);
|
|
12616
12620
|
return { landingPath, ordinal, sanitizedModel };
|
|
12617
12621
|
}
|
|
12618
12622
|
function recordNativeSessionPointer(options) {
|
|
@@ -12645,18 +12649,18 @@ function copyFileCloneOrFallback(src, dest) {
|
|
|
12645
12649
|
copyFileSync(src, dest);
|
|
12646
12650
|
}
|
|
12647
12651
|
function copyGrokDossier(srcDir, destDir) {
|
|
12648
|
-
const chatHistorySrc =
|
|
12652
|
+
const chatHistorySrc = join31(srcDir, "chat_history.jsonl");
|
|
12649
12653
|
if (!existsSync9(chatHistorySrc)) {
|
|
12650
12654
|
throw new Error(`Grok native chat_history.jsonl missing at ${chatHistorySrc}`);
|
|
12651
12655
|
}
|
|
12652
12656
|
mkdirSync3(destDir, { recursive: true });
|
|
12653
|
-
const chatHistoryDest =
|
|
12657
|
+
const chatHistoryDest = join31(destDir, "chat_history.jsonl");
|
|
12654
12658
|
copyFileCloneOrFallback(chatHistorySrc, chatHistoryDest);
|
|
12655
|
-
const usageSrc =
|
|
12659
|
+
const usageSrc = join31(srcDir, "usage.json");
|
|
12656
12660
|
if (!existsSync9(usageSrc)) {
|
|
12657
12661
|
throw new Error(`Grok native usage.json missing at ${usageSrc}`);
|
|
12658
12662
|
}
|
|
12659
|
-
copyFileCloneOrFallback(usageSrc,
|
|
12663
|
+
copyFileCloneOrFallback(usageSrc, join31(destDir, "usage.json"));
|
|
12660
12664
|
}
|
|
12661
12665
|
function copyAndRecordHostDossier(options) {
|
|
12662
12666
|
if (options.host === "pi" || options.host === "hermes") {
|
|
@@ -12731,7 +12735,7 @@ function copyAndRecordHostDossier(options) {
|
|
|
12731
12735
|
}
|
|
12732
12736
|
try {
|
|
12733
12737
|
mkdirSync3(options.sessionDirectory, { recursive: true });
|
|
12734
|
-
closeSync(openSync(
|
|
12738
|
+
closeSync(openSync(join31(options.sessionDirectory, `${options.host}-${sanitizedModel}-${ordinal}.failed`), "a"));
|
|
12735
12739
|
} catch {
|
|
12736
12740
|
}
|
|
12737
12741
|
sitianReportSafe({
|
|
@@ -12765,7 +12769,7 @@ var init_host_session_record = __esm({
|
|
|
12765
12769
|
import { constants as fsConstants2 } from "node:fs";
|
|
12766
12770
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
12767
12771
|
import { lstat as lstat4, mkdir as mkdir3, open } from "node:fs/promises";
|
|
12768
|
-
import { join as
|
|
12772
|
+
import { join as join32 } from "node:path";
|
|
12769
12773
|
async function persistReturnedRunState(admitted, options) {
|
|
12770
12774
|
if (options?.lawful === true) {
|
|
12771
12775
|
await markRunTerminal(admitted.runDirectory);
|
|
@@ -12834,7 +12838,7 @@ function jsonSafeReplacer() {
|
|
|
12834
12838
|
};
|
|
12835
12839
|
}
|
|
12836
12840
|
async function writeHardenedArtifactFile(artifactsDir, namePrefix, payload) {
|
|
12837
|
-
const filePath =
|
|
12841
|
+
const filePath = join32(artifactsDir, `${namePrefix}-${randomUUID6()}.json`);
|
|
12838
12842
|
const body = `${JSON.stringify(payload, jsonSafeReplacer(), 2)}
|
|
12839
12843
|
`;
|
|
12840
12844
|
const noFollowFlag = typeof fsConstants2.O_NOFOLLOW === "number" ? fsConstants2.O_NOFOLLOW : 0;
|
|
@@ -13089,7 +13093,7 @@ var init_auto_resume = __esm({
|
|
|
13089
13093
|
// src/public-cli/post-admission.ts
|
|
13090
13094
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
13091
13095
|
import { writeFile as writeFile8 } from "node:fs/promises";
|
|
13092
|
-
import { isAbsolute as isAbsolute7, join as
|
|
13096
|
+
import { isAbsolute as isAbsolute7, join as join33, resolve as resolve13 } from "node:path";
|
|
13093
13097
|
function describeCaughtError(error) {
|
|
13094
13098
|
if (error instanceof Error) {
|
|
13095
13099
|
const code = error.code;
|
|
@@ -13185,7 +13189,7 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
13185
13189
|
try {
|
|
13186
13190
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
13187
13191
|
await writeFile8(
|
|
13188
|
-
|
|
13192
|
+
join33(artifactsDir, `post-admission-diagnostic-${randomUUID7()}.json`),
|
|
13189
13193
|
`${JSON.stringify({ version: 1, ...payload }, null, 2)}
|
|
13190
13194
|
`,
|
|
13191
13195
|
{ encoding: "utf8", flag: "wx" }
|
|
@@ -13214,7 +13218,7 @@ async function presentControlledFailure2(admitted, failureInput, adapters, autho
|
|
|
13214
13218
|
const knownFailure = failureInput.knownFailure ?? resumeObservation.observationReadFailure;
|
|
13215
13219
|
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;
|
|
13216
13220
|
const fromKnownFailure = explicitInternalKnownFailureClassificationInput(knownFailure);
|
|
13217
|
-
const
|
|
13221
|
+
const failure = classifyPostAdmissionFailure({
|
|
13218
13222
|
timedOut: failureInput.timedOut,
|
|
13219
13223
|
code: failureInput.code,
|
|
13220
13224
|
stderr: failureInput.stderr,
|
|
@@ -13233,7 +13237,7 @@ async function presentControlledFailure2(admitted, failureInput, adapters, autho
|
|
|
13233
13237
|
let publishedErrorPath;
|
|
13234
13238
|
let terminal;
|
|
13235
13239
|
try {
|
|
13236
|
-
const settled = await settleFailureTerminalResult(admitted,
|
|
13240
|
+
const settled = await settleFailureTerminalResult(admitted, failure, authority, {
|
|
13237
13241
|
...resumable ? { resume: { command: renderResumeCommand(admitted.runId) } } : {},
|
|
13238
13242
|
...failureInput.invocationScopeId === void 0 || failureInput.invocationScopeId.length === 0 ? {} : { invocationScopeId: failureInput.invocationScopeId },
|
|
13239
13243
|
onErrorPublished: (path) => {
|
|
@@ -13326,7 +13330,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
13326
13330
|
const rows = await readRecordedSubmissionRows(
|
|
13327
13331
|
admitted.projectRoot,
|
|
13328
13332
|
admitted.runId,
|
|
13329
|
-
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent:
|
|
13333
|
+
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent: join33(admitted.runDirectory, "session", "session.jsonl") }
|
|
13330
13334
|
);
|
|
13331
13335
|
let ticketNumber;
|
|
13332
13336
|
for (const row of rows) {
|
|
@@ -13453,7 +13457,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
13453
13457
|
let stderrLogWriteFailure;
|
|
13454
13458
|
try {
|
|
13455
13459
|
await writeFile8(
|
|
13456
|
-
|
|
13460
|
+
join33(admitted.runDirectory, "stderr.log"),
|
|
13457
13461
|
result.stderr,
|
|
13458
13462
|
"utf8"
|
|
13459
13463
|
);
|
|
@@ -13732,7 +13736,7 @@ async function dispatchAfterWriterLease(input) {
|
|
|
13732
13736
|
}
|
|
13733
13737
|
function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
|
|
13734
13738
|
const absolute = isAbsolute7(attachmentPath) ? attachmentPath : resolve13(attachmentPath);
|
|
13735
|
-
return pathContainedIn(
|
|
13739
|
+
return pathContainedIn(join33(runDirectory, "attachments"), absolute);
|
|
13736
13740
|
}
|
|
13737
13741
|
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
13738
13742
|
if (summons === void 0) return void 0;
|
|
@@ -13914,10 +13918,10 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
13914
13918
|
await presentResumeFailurePointer(
|
|
13915
13919
|
input.io,
|
|
13916
13920
|
error,
|
|
13917
|
-
(
|
|
13921
|
+
(failure) => writeResumeDiagnosticFile(
|
|
13918
13922
|
loaded.admitted.runDirectory,
|
|
13919
13923
|
loaded.admitted.runId,
|
|
13920
|
-
|
|
13924
|
+
failure,
|
|
13921
13925
|
loaded.admitted.role
|
|
13922
13926
|
)
|
|
13923
13927
|
);
|
|
@@ -13940,7 +13944,7 @@ async function pointExistingRunFailure(home, runId, authority, io, thrown) {
|
|
|
13940
13944
|
await presentResumeFailurePointer(
|
|
13941
13945
|
io,
|
|
13942
13946
|
thrown,
|
|
13943
|
-
(
|
|
13947
|
+
(failure) => writeResumeDiagnosticFile(runDirectory, runId, failure)
|
|
13944
13948
|
);
|
|
13945
13949
|
return true;
|
|
13946
13950
|
}
|
|
@@ -13948,7 +13952,7 @@ async function pointExistingRunFailure(home, runId, authority, io, thrown) {
|
|
|
13948
13952
|
await presentResumeFailurePointer(
|
|
13949
13953
|
io,
|
|
13950
13954
|
thrown,
|
|
13951
|
-
(
|
|
13955
|
+
(failure) => writeResumeDiagnosticFile(runDirectory, runId, failure, record4.role)
|
|
13952
13956
|
);
|
|
13953
13957
|
return true;
|
|
13954
13958
|
}
|
|
@@ -13964,14 +13968,14 @@ function showResumeErrorPointer(io, exitCode, terminal) {
|
|
|
13964
13968
|
if (publishedError !== void 0) writeResumeFailurePointer(io, publishedError);
|
|
13965
13969
|
}
|
|
13966
13970
|
async function presentResumeFailurePointer(io, thrown, publish) {
|
|
13967
|
-
const
|
|
13971
|
+
const failure = classifyPostAdmissionFailure({
|
|
13968
13972
|
timedOut: false,
|
|
13969
13973
|
code: null,
|
|
13970
13974
|
stderr: "",
|
|
13971
13975
|
thrown
|
|
13972
13976
|
});
|
|
13973
13977
|
try {
|
|
13974
|
-
writeResumeFailurePointer(io, await publish(
|
|
13978
|
+
writeResumeFailurePointer(io, await publish(failure));
|
|
13975
13979
|
} catch (publishError) {
|
|
13976
13980
|
const cause = {
|
|
13977
13981
|
publishError: formatErrorCauseDetail(publishError)
|
|
@@ -13985,18 +13989,18 @@ async function presentResumeFailurePointer(io, thrown, publish) {
|
|
|
13985
13989
|
}, io);
|
|
13986
13990
|
}
|
|
13987
13991
|
}
|
|
13988
|
-
async function writeResumeDiagnosticFile(runDirectory, runId,
|
|
13992
|
+
async function writeResumeDiagnosticFile(runDirectory, runId, failure, role) {
|
|
13989
13993
|
const dir = await ensureRealArtifactsDirectory(runDirectory);
|
|
13990
|
-
const path =
|
|
13994
|
+
const path = join33(dir, `resume-diagnostic-${randomUUID7()}.json`);
|
|
13991
13995
|
await writeFile8(
|
|
13992
13996
|
path,
|
|
13993
13997
|
`${JSON.stringify({
|
|
13994
13998
|
runId,
|
|
13995
13999
|
...role === void 0 ? {} : { role },
|
|
13996
|
-
diagnostic:
|
|
13997
|
-
...
|
|
13998
|
-
...
|
|
13999
|
-
...
|
|
14000
|
+
diagnostic: failure.diagnostic,
|
|
14001
|
+
...failure.cause === void 0 ? {} : { cause: failure.cause },
|
|
14002
|
+
...failure.identity === void 0 ? {} : { identity: failure.identity },
|
|
14003
|
+
...failure.details === void 0 ? {} : { details: failure.details }
|
|
14000
14004
|
}, null, 2)}
|
|
14001
14005
|
`,
|
|
14002
14006
|
{ encoding: "utf8", flag: "wx" }
|
|
@@ -14156,16 +14160,16 @@ var init_seat_ticket_binding = __esm({
|
|
|
14156
14160
|
// src/public-cli/machine-method-skills.ts
|
|
14157
14161
|
import { accessSync, constants as constants2, statSync as statSync4 } from "node:fs";
|
|
14158
14162
|
import { lstat as lstat5, mkdir as mkdir4, symlink } from "node:fs/promises";
|
|
14159
|
-
import { join as
|
|
14163
|
+
import { join as join34 } from "node:path";
|
|
14160
14164
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
14161
14165
|
function skillRoot(home) {
|
|
14162
|
-
return
|
|
14166
|
+
return join34(home, ".agents/skills");
|
|
14163
14167
|
}
|
|
14164
14168
|
function installedMethodSkillPath(home, name) {
|
|
14165
14169
|
return installedSkillPath(skillRoot(home), name);
|
|
14166
14170
|
}
|
|
14167
14171
|
function installedSkillPath(root, name) {
|
|
14168
|
-
const path =
|
|
14172
|
+
const path = join34(root, name, "SKILL.md");
|
|
14169
14173
|
try {
|
|
14170
14174
|
if (!statSync4(path).isFile()) return void 0;
|
|
14171
14175
|
accessSync(path, constants2.R_OK);
|
|
@@ -14178,9 +14182,9 @@ function installedSkillPath(root, name) {
|
|
|
14178
14182
|
}
|
|
14179
14183
|
function linkedSkillRoot(home, host) {
|
|
14180
14184
|
if (host === "claude" || host === "claude-code") {
|
|
14181
|
-
return
|
|
14185
|
+
return join34(process.env.CLAUDE_CONFIG_DIR?.trim() || join34(home, ".claude"), "skills");
|
|
14182
14186
|
}
|
|
14183
|
-
if (host === "hermes") return
|
|
14187
|
+
if (host === "hermes") return join34(home, ".hermes/skills");
|
|
14184
14188
|
return void 0;
|
|
14185
14189
|
}
|
|
14186
14190
|
async function occupied(path) {
|
|
@@ -14237,7 +14241,7 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
14237
14241
|
const missingBySource = /* @__PURE__ */ new Map();
|
|
14238
14242
|
let unsourced = false;
|
|
14239
14243
|
for (const name of packagedMethodSkillNames()) {
|
|
14240
|
-
const path =
|
|
14244
|
+
const path = join34(canonical, name);
|
|
14241
14245
|
if (await occupied(path)) {
|
|
14242
14246
|
warnOccupied(path, stdout);
|
|
14243
14247
|
continue;
|
|
@@ -14259,17 +14263,17 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
14259
14263
|
if (unsourced) return 1;
|
|
14260
14264
|
for (const host of ["claude-code", "hermes"]) {
|
|
14261
14265
|
const root = linkedSkillRoot(home, host);
|
|
14262
|
-
const
|
|
14266
|
+
const description = host === "claude-code" ? HEADLESS_HOST_DESCRIPTIONS.claude : HOST_DESCRIPTIONS.hermes;
|
|
14263
14267
|
try {
|
|
14264
|
-
accessSync(
|
|
14268
|
+
accessSync(resolveHostBinary(description, home), constants2.X_OK);
|
|
14265
14269
|
} catch (error) {
|
|
14266
14270
|
if (["ENOENT", "ENOTDIR", "EACCES"].includes(error.code ?? "")) continue;
|
|
14267
14271
|
throw error;
|
|
14268
14272
|
}
|
|
14269
14273
|
for (const name of packagedMethodSkillNames()) {
|
|
14270
|
-
const target =
|
|
14274
|
+
const target = join34(canonical, name);
|
|
14271
14275
|
if (installedMethodSkillPath(home, name) === void 0) continue;
|
|
14272
|
-
const link =
|
|
14276
|
+
const link = join34(root, name);
|
|
14273
14277
|
if (await occupied(link)) {
|
|
14274
14278
|
warnOccupied(link, stdout);
|
|
14275
14279
|
continue;
|
|
@@ -15477,7 +15481,7 @@ var init_analyst_book_key = __esm({
|
|
|
15477
15481
|
|
|
15478
15482
|
// src/analyst-index.ts
|
|
15479
15483
|
import { open as open2, readFile as readFile18, unlink as unlink4 } from "node:fs/promises";
|
|
15480
|
-
import { dirname as dirname21, join as
|
|
15484
|
+
import { dirname as dirname21, join as join35 } from "node:path";
|
|
15481
15485
|
function sleep(ms) {
|
|
15482
15486
|
return new Promise((resolve22) => {
|
|
15483
15487
|
setTimeout(resolve22, ms);
|
|
@@ -15486,7 +15490,7 @@ function sleep(ms) {
|
|
|
15486
15490
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
15487
15491
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
15488
15492
|
ensureRealDirectoryTree(ledgerHome, dirname21(indexPath));
|
|
15489
|
-
const lockPath =
|
|
15493
|
+
const lockPath = join35(dirname21(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
15490
15494
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
15491
15495
|
const startedAt = Date.now();
|
|
15492
15496
|
while (true) {
|
|
@@ -15513,7 +15517,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
15513
15517
|
}
|
|
15514
15518
|
}
|
|
15515
15519
|
function analystLibraryIndexPath(ledgerHome) {
|
|
15516
|
-
return
|
|
15520
|
+
return join35(ledgerHome, "analyst", "library-index.json");
|
|
15517
15521
|
}
|
|
15518
15522
|
function rowFromIssueMetricsPage(page) {
|
|
15519
15523
|
return {
|
|
@@ -15809,7 +15813,7 @@ var init_analyst_cohort = __esm({
|
|
|
15809
15813
|
|
|
15810
15814
|
// src/analyst-ledger.ts
|
|
15811
15815
|
import { readdir as readdir6, readFile as readFile19 } from "node:fs/promises";
|
|
15812
|
-
import { basename as basename9, join as
|
|
15816
|
+
import { basename as basename9, join as join36 } from "node:path";
|
|
15813
15817
|
function isMissingPathError6(error) {
|
|
15814
15818
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
15815
15819
|
}
|
|
@@ -15838,7 +15842,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
|
|
|
15838
15842
|
}
|
|
15839
15843
|
}
|
|
15840
15844
|
async function classifyGhostCandidate(input) {
|
|
15841
|
-
const autopsy = await autopsyWriterLock(
|
|
15845
|
+
const autopsy = await autopsyWriterLock(join36(input.runDirectory, "writer.lock"));
|
|
15842
15846
|
const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
|
|
15843
15847
|
if (leaseCheck === void 0) return { kind: "live" };
|
|
15844
15848
|
return {
|
|
@@ -15867,7 +15871,7 @@ async function listLedgerBookNames(booksRoot) {
|
|
|
15867
15871
|
async function readInvocationScopeFields(runDirectory) {
|
|
15868
15872
|
let raw;
|
|
15869
15873
|
try {
|
|
15870
|
-
raw = await readFile19(
|
|
15874
|
+
raw = await readFile19(join36(runDirectory, "invocation.json"), "utf8");
|
|
15871
15875
|
} catch (error) {
|
|
15872
15876
|
if (isMissingPathError6(error)) return void 0;
|
|
15873
15877
|
throw error;
|
|
@@ -15900,7 +15904,7 @@ function decideIssueScope(input) {
|
|
|
15900
15904
|
}
|
|
15901
15905
|
async function resolveSessionFile(runDirectory) {
|
|
15902
15906
|
try {
|
|
15903
|
-
const raw = await readFile19(
|
|
15907
|
+
const raw = await readFile19(join36(runDirectory, "invocation.json"), "utf8");
|
|
15904
15908
|
const parsed = JSON.parse(raw);
|
|
15905
15909
|
if (isRecord12(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
15906
15910
|
return parsed.sessionFile;
|
|
@@ -15908,7 +15912,7 @@ async function resolveSessionFile(runDirectory) {
|
|
|
15908
15912
|
} catch (error) {
|
|
15909
15913
|
if (!isMissingPathError6(error)) throw error;
|
|
15910
15914
|
}
|
|
15911
|
-
return
|
|
15915
|
+
return join36(runDirectory, "session", "session.jsonl");
|
|
15912
15916
|
}
|
|
15913
15917
|
function attributeSessionRowsForRun(input) {
|
|
15914
15918
|
if (pathContainedIn(input.runDirectory, input.sessionFile)) {
|
|
@@ -16110,9 +16114,9 @@ async function classifyScopedRun(input) {
|
|
|
16110
16114
|
}
|
|
16111
16115
|
let gateCycles;
|
|
16112
16116
|
try {
|
|
16113
|
-
const parentSessionFile =
|
|
16117
|
+
const parentSessionFile = join36(input.runDirectory, "session", "session.jsonl");
|
|
16114
16118
|
gateCycles = await readAnalystGateCyclesFromAuditorRoles(
|
|
16115
|
-
|
|
16119
|
+
join36(input.runDirectory, "session", "auditor-roles"),
|
|
16116
16120
|
{ parentSessionFile }
|
|
16117
16121
|
);
|
|
16118
16122
|
} catch (error) {
|
|
@@ -16147,7 +16151,7 @@ async function classifyScopedRun(input) {
|
|
|
16147
16151
|
async function scanAnalystIssueRuns(input) {
|
|
16148
16152
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
16149
16153
|
const scopeTicketNumber = input.ticketNumber;
|
|
16150
|
-
const booksRoot =
|
|
16154
|
+
const booksRoot = join36(ledgerHome, "books");
|
|
16151
16155
|
let wholeBook = false;
|
|
16152
16156
|
let scopeRootIdentity;
|
|
16153
16157
|
let bookNames;
|
|
@@ -16180,7 +16184,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
16180
16184
|
const ghostLegs = [];
|
|
16181
16185
|
const scopeConflicts = [];
|
|
16182
16186
|
for (const book of bookNames) {
|
|
16183
|
-
const bookDir =
|
|
16187
|
+
const bookDir = join36(booksRoot, book);
|
|
16184
16188
|
let runDirectories;
|
|
16185
16189
|
try {
|
|
16186
16190
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
@@ -16917,7 +16921,7 @@ var init_analyst_metric_family = __esm({
|
|
|
16917
16921
|
|
|
16918
16922
|
// src/analyst-page.ts
|
|
16919
16923
|
import { createHash as createHash3 } from "node:crypto";
|
|
16920
|
-
import { dirname as dirname22, join as
|
|
16924
|
+
import { dirname as dirname22, join as join37 } from "node:path";
|
|
16921
16925
|
function analystIssuePageKey(address) {
|
|
16922
16926
|
const parts = ["book", address.bookKey];
|
|
16923
16927
|
if (address.issueNumber !== void 0) {
|
|
@@ -16928,7 +16932,7 @@ function analystIssuePageKey(address) {
|
|
|
16928
16932
|
return createHash3("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
16929
16933
|
}
|
|
16930
16934
|
function analystIssuePagePath(ledgerHome, address) {
|
|
16931
|
-
return
|
|
16935
|
+
return join37(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
16932
16936
|
}
|
|
16933
16937
|
function analystIssuePageAddressFromPage(page) {
|
|
16934
16938
|
return {
|
|
@@ -17567,7 +17571,7 @@ __export(cli_exports, {
|
|
|
17567
17571
|
runAkRole: () => runAkRole
|
|
17568
17572
|
});
|
|
17569
17573
|
import { realpath as realpath5 } from "node:fs/promises";
|
|
17570
|
-
import { join as
|
|
17574
|
+
import { join as join38 } from "node:path";
|
|
17571
17575
|
function publicSeatArgv(owner) {
|
|
17572
17576
|
return {
|
|
17573
17577
|
parse: (args) => parsePublicSeatArgv(owner, args),
|
|
@@ -17706,7 +17710,7 @@ function resolveHome(env) {
|
|
|
17706
17710
|
return env.home ?? packageMachineHome();
|
|
17707
17711
|
}
|
|
17708
17712
|
function resolveAgentDir(env, home) {
|
|
17709
|
-
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
17713
|
+
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join38(home, ".pi", "agent");
|
|
17710
17714
|
}
|
|
17711
17715
|
function parseThinking(value) {
|
|
17712
17716
|
return value;
|
|
@@ -18478,7 +18482,7 @@ __export(public_role_summons_exports, {
|
|
|
18478
18482
|
import { execFile as execFile3 } from "node:child_process";
|
|
18479
18483
|
import { existsSync as existsSync10 } from "node:fs";
|
|
18480
18484
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
18481
|
-
import { join as
|
|
18485
|
+
import { join as join39 } from "node:path";
|
|
18482
18486
|
import { promisify as promisify3 } from "node:util";
|
|
18483
18487
|
function createCapturingIo() {
|
|
18484
18488
|
const chunks = [];
|
|
@@ -18502,7 +18506,7 @@ function parentDir(path) {
|
|
|
18502
18506
|
function walkPackageRoot(start) {
|
|
18503
18507
|
let dir = start;
|
|
18504
18508
|
for (let i = 0; i < 12; i += 1) {
|
|
18505
|
-
if (existsSync10(
|
|
18509
|
+
if (existsSync10(join39(dir, "package.json")) && existsSync10(join39(dir, "souls"))) {
|
|
18506
18510
|
return dir;
|
|
18507
18511
|
}
|
|
18508
18512
|
const parent = parentDir(dir);
|
|
@@ -18552,8 +18556,8 @@ function projectSeatHost2(seat) {
|
|
|
18552
18556
|
function hostSelectionFailureFromUnknown(error) {
|
|
18553
18557
|
if (typeof error !== "object" || error === null) return void 0;
|
|
18554
18558
|
if (error.name !== "HostSelectionError") return void 0;
|
|
18555
|
-
const
|
|
18556
|
-
return
|
|
18559
|
+
const failure = error.failure;
|
|
18560
|
+
return failure;
|
|
18557
18561
|
}
|
|
18558
18562
|
async function createSummonEnv(options, afterHost) {
|
|
18559
18563
|
const [
|
|
@@ -18618,7 +18622,7 @@ async function createSummonEnv(options, afterHost) {
|
|
|
18618
18622
|
async function summonPublicRole(options) {
|
|
18619
18623
|
const packageRoot = resolveSummonsPackageRoot(options.packageRoot);
|
|
18620
18624
|
const home = await resolveSummonHome(options);
|
|
18621
|
-
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
18625
|
+
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join39(home, ".pi", "agent");
|
|
18622
18626
|
const {
|
|
18623
18627
|
loadCredentialProviders: loadCredentialProviders2,
|
|
18624
18628
|
loadPublicCliConfig: loadPublicCliConfig2,
|
|
@@ -18686,10 +18690,10 @@ async function summonPublicRole(options) {
|
|
|
18686
18690
|
}
|
|
18687
18691
|
};
|
|
18688
18692
|
} catch (error) {
|
|
18689
|
-
const
|
|
18690
|
-
if (
|
|
18693
|
+
const failure = hostSelectionFailureFromUnknown(error);
|
|
18694
|
+
if (failure !== void 0) {
|
|
18691
18695
|
const { formatHostSelectionFailure: formatHostSelectionFailure2 } = await Promise.resolve().then(() => (init_role_turn_host_resolution(), role_turn_host_resolution_exports));
|
|
18692
|
-
return { ok: false, exitCode: 1, stderr: formatHostSelectionFailure2(
|
|
18696
|
+
return { ok: false, exitCode: 1, stderr: formatHostSelectionFailure2(failure) };
|
|
18693
18697
|
}
|
|
18694
18698
|
const { CliUsageError: CliUsageError2 } = await Promise.resolve().then(() => (init_cli_errors(), cli_errors_exports));
|
|
18695
18699
|
if (error instanceof CliUsageError2) {
|
|
@@ -18785,8 +18789,8 @@ async function summonParallelReviewerLenses(options) {
|
|
|
18785
18789
|
stderr: describeFailure(error)
|
|
18786
18790
|
});
|
|
18787
18791
|
const dualFailure = (error) => {
|
|
18788
|
-
const
|
|
18789
|
-
return { completeness:
|
|
18792
|
+
const failure = failedResult(error);
|
|
18793
|
+
return { completeness: failure, correctness: failure };
|
|
18790
18794
|
};
|
|
18791
18795
|
let sourceProjectRoot;
|
|
18792
18796
|
let targetCommit;
|
|
@@ -19126,7 +19130,7 @@ var init_compliance_transport = __esm({
|
|
|
19126
19130
|
});
|
|
19127
19131
|
|
|
19128
19132
|
// src/role-run-relocation.ts
|
|
19129
|
-
import { join as
|
|
19133
|
+
import { join as join40, sep as sep5 } from "node:path";
|
|
19130
19134
|
function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
|
|
19131
19135
|
if (typeof value !== "string") return value;
|
|
19132
19136
|
if (value === oldRunDirectory) return newRunDirectory;
|
|
@@ -19254,7 +19258,7 @@ __export(run_lifecycle_exports, {
|
|
|
19254
19258
|
writeRoleRunState: () => writeRoleRunState
|
|
19255
19259
|
});
|
|
19256
19260
|
import { chmod, lstat as lstat6, open as open3, readdir as readdir7, readFile as readFile22, unlink as unlink5, writeFile as writeFile9 } from "node:fs/promises";
|
|
19257
|
-
import { basename as basename10, join as
|
|
19261
|
+
import { basename as basename10, join as join41 } from "node:path";
|
|
19258
19262
|
function buildAutoResumeContinuationPrompt(options) {
|
|
19259
19263
|
return appendEngineSessionMaterial(
|
|
19260
19264
|
[RESUME_TRANSPORT_ENVELOPE],
|
|
@@ -19280,7 +19284,7 @@ function renderResumeCommand(runId) {
|
|
|
19280
19284
|
async function writeRoleRunState(runDirectory, record4) {
|
|
19281
19285
|
const payload = { ...record4, runDirectory };
|
|
19282
19286
|
await writeFile9(
|
|
19283
|
-
|
|
19287
|
+
join41(runDirectory, RUN_STATE_FILE),
|
|
19284
19288
|
`${JSON.stringify(payload, null, 2)}
|
|
19285
19289
|
`,
|
|
19286
19290
|
"utf8"
|
|
@@ -19330,7 +19334,7 @@ function parseCurrentCourtState(raw) {
|
|
|
19330
19334
|
async function readRoleRunStateRaw(runDirectory) {
|
|
19331
19335
|
let raw;
|
|
19332
19336
|
try {
|
|
19333
|
-
raw = JSON.parse(await readFile22(
|
|
19337
|
+
raw = JSON.parse(await readFile22(join41(runDirectory, RUN_STATE_FILE), "utf8"));
|
|
19334
19338
|
} catch (error) {
|
|
19335
19339
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
19336
19340
|
throw error;
|
|
@@ -19424,7 +19428,7 @@ async function writeRoleRunStateDisk(runDirectory, disk) {
|
|
|
19424
19428
|
...disk.currentCourt === void 0 ? {} : { currentCourt: disk.currentCourt }
|
|
19425
19429
|
};
|
|
19426
19430
|
await writeFile9(
|
|
19427
|
-
|
|
19431
|
+
join41(runDirectory, RUN_STATE_FILE),
|
|
19428
19432
|
`${JSON.stringify(payload, null, 2)}
|
|
19429
19433
|
`,
|
|
19430
19434
|
"utf8"
|
|
@@ -19647,7 +19651,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
|
|
|
19647
19651
|
},
|
|
19648
19652
|
relocate(nextRunDirectory) {
|
|
19649
19653
|
currentRunDirectory = nextRunDirectory;
|
|
19650
|
-
currentLockPath =
|
|
19654
|
+
currentLockPath = join41(nextRunDirectory, WRITER_LOCK_FILE);
|
|
19651
19655
|
},
|
|
19652
19656
|
async release() {
|
|
19653
19657
|
if (released) return;
|
|
@@ -19686,10 +19690,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
19686
19690
|
};
|
|
19687
19691
|
const reportReadFailure = (error) => {
|
|
19688
19692
|
reportDiagnostic(
|
|
19689
|
-
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${
|
|
19693
|
+
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join41(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
|
|
19690
19694
|
);
|
|
19691
19695
|
};
|
|
19692
|
-
const lockPath =
|
|
19696
|
+
const lockPath = join41(runDirectory, WRITER_LOCK_FILE);
|
|
19693
19697
|
let lastAutopsy = { verdict: "absent" };
|
|
19694
19698
|
let lastReclaimFailure;
|
|
19695
19699
|
for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
|
|
@@ -19744,7 +19748,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
19744
19748
|
async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
19745
19749
|
if (runId.trim() === "") return void 0;
|
|
19746
19750
|
const ledgerHome = resolveActivationLedgerHome(home);
|
|
19747
|
-
const booksRoot =
|
|
19751
|
+
const booksRoot = join41(ledgerHome, "books");
|
|
19748
19752
|
let bookKeys;
|
|
19749
19753
|
try {
|
|
19750
19754
|
bookKeys = await readdir7(booksRoot);
|
|
@@ -19785,7 +19789,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
19785
19789
|
let raw;
|
|
19786
19790
|
try {
|
|
19787
19791
|
raw = JSON.parse(
|
|
19788
|
-
await readFile22(
|
|
19792
|
+
await readFile22(join41(runDirectory, "admitted-request.json"), "utf8")
|
|
19789
19793
|
);
|
|
19790
19794
|
} catch (error) {
|
|
19791
19795
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -19806,7 +19810,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
19806
19810
|
async function runHasFormedSessionPrincipal(runDirectory) {
|
|
19807
19811
|
const disk = await readRoleRunStateDisk(runDirectory);
|
|
19808
19812
|
if (disk === void 0) return false;
|
|
19809
|
-
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile :
|
|
19813
|
+
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : join41(disk.principalWire.sessionDirectory, "session.jsonl");
|
|
19810
19814
|
try {
|
|
19811
19815
|
const stat2 = await lstat6(sessionFile);
|
|
19812
19816
|
return stat2.isFile() && !stat2.isSymbolicLink();
|
|
@@ -19824,7 +19828,7 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
19824
19828
|
let runDirectories;
|
|
19825
19829
|
try {
|
|
19826
19830
|
runDirectories = await listBookRunDirectories(
|
|
19827
|
-
input.ticketNumber === void 0 ? bookDir :
|
|
19831
|
+
input.ticketNumber === void 0 ? bookDir : join41(bookDir, String(input.ticketNumber))
|
|
19828
19832
|
);
|
|
19829
19833
|
} catch (error) {
|
|
19830
19834
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -20022,7 +20026,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
20022
20026
|
let model;
|
|
20023
20027
|
try {
|
|
20024
20028
|
const invocationRaw = JSON.parse(
|
|
20025
|
-
await readFile22(
|
|
20029
|
+
await readFile22(join41(run.runDirectory, "invocation.json"), "utf8")
|
|
20026
20030
|
);
|
|
20027
20031
|
if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
|
|
20028
20032
|
const rec = invocationRaw;
|
|
@@ -20391,7 +20395,7 @@ var init_run_lifecycle = __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 statSync6,
|
|
20477
20481
|
writeFileSync as writeFileSync2
|
|
20478
20482
|
} from "node:fs";
|
|
20479
|
-
import { dirname as dirname23, resolve as resolve16, join as
|
|
20483
|
+
import { dirname as dirname23, resolve as resolve16, 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
|
writeFileSync2(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 = statSync6(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/headless-host/production-host.ts
|
|
20779
|
+
init_host_descriptions();
|
|
20775
20780
|
import { randomUUID as randomUUID11 } from "node:crypto";
|
|
20776
20781
|
|
|
20777
20782
|
// src/role-runtime-dependencies.ts
|
|
@@ -20985,10 +20990,10 @@ init_packaged_role_registry();
|
|
|
20985
20990
|
init_atomic_write();
|
|
20986
20991
|
import { existsSync as existsSync3, realpathSync as realpathSync2 } from "node:fs";
|
|
20987
20992
|
import { readFile as readFile5 } from "node:fs/promises";
|
|
20988
|
-
import { basename as basename3, dirname as dirname7, join as
|
|
20993
|
+
import { basename as basename3, dirname as dirname7, join as join8, resolve as resolve5 } from "node:path";
|
|
20989
20994
|
var NAVIGATOR_WORK_CONTEXT_BASENAME = "work-context.json";
|
|
20990
20995
|
function navigatorWorkContextFile(sessionDir) {
|
|
20991
|
-
return
|
|
20996
|
+
return join8(sessionDir, NAVIGATOR_WORK_CONTEXT_BASENAME);
|
|
20992
20997
|
}
|
|
20993
20998
|
function isNavigatorWorkContextFile(path) {
|
|
20994
20999
|
const resolved = resolve5(path);
|
|
@@ -21405,12 +21410,12 @@ function createNavigatorAttendance(options) {
|
|
|
21405
21410
|
return { ...options.context, signal };
|
|
21406
21411
|
};
|
|
21407
21412
|
const unavailable = (invocationId, reason) => {
|
|
21408
|
-
const
|
|
21413
|
+
const failure = reason instanceof NavigatorUnavailableError ? reason : navigatorUnavailableError("unknown", reason);
|
|
21409
21414
|
return {
|
|
21410
21415
|
disposition: "unavailable",
|
|
21411
|
-
unavailableReason:
|
|
21412
|
-
unavailableSource:
|
|
21413
|
-
unavailableCause:
|
|
21416
|
+
unavailableReason: failure.message,
|
|
21417
|
+
unavailableSource: failure.unavailableSource,
|
|
21418
|
+
unavailableCause: failure.unavailableCause
|
|
21414
21419
|
};
|
|
21415
21420
|
};
|
|
21416
21421
|
let prepareBoundSettlement;
|
|
@@ -21847,7 +21852,7 @@ init_sitian_facade();
|
|
|
21847
21852
|
init_submission_ledger();
|
|
21848
21853
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
21849
21854
|
import { readFileSync as readFileSync6, writeSync as writeSync2 } from "node:fs";
|
|
21850
|
-
import { join as
|
|
21855
|
+
import { join as join45 } from "node:path";
|
|
21851
21856
|
import { Value as Value4 } from "typebox/value";
|
|
21852
21857
|
|
|
21853
21858
|
// src/activation-trace.ts
|
|
@@ -23803,7 +23808,7 @@ function readDiaristTicketAssertion(submitted) {
|
|
|
23803
23808
|
function readRoleRunCoordinates(ctx, label) {
|
|
23804
23809
|
const runDirectory = runDirectoryFromHostContext(ctx);
|
|
23805
23810
|
if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
|
|
23806
|
-
const admittedPath =
|
|
23811
|
+
const admittedPath = join45(runDirectory, "admitted-request.json");
|
|
23807
23812
|
const admitted = JSON.parse(readFileSync6(admittedPath, "utf8"));
|
|
23808
23813
|
if (typeof admitted.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
|
|
23809
23814
|
throw new Error(`${label} admitted-request missing projectRoot (${admittedPath})`);
|
|
@@ -24732,7 +24737,7 @@ init_packaged_role_registry();
|
|
|
24732
24737
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
24733
24738
|
import { appendFile as appendFile3, mkdir as mkdir5, writeFile as writeFile10 } from "node:fs/promises";
|
|
24734
24739
|
import { createServer } from "node:net";
|
|
24735
|
-
import { dirname as dirname25, join as
|
|
24740
|
+
import { dirname as dirname25, join as join46 } from "node:path";
|
|
24736
24741
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
24737
24742
|
init_role_activation_flags();
|
|
24738
24743
|
init_submission_correctable_error();
|
|
@@ -24778,7 +24783,7 @@ async function prepareRoleEnvelope(options) {
|
|
|
24778
24783
|
const hostAbort = new AbortController();
|
|
24779
24784
|
const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID9();
|
|
24780
24785
|
await mkdir5(request.runDirectory, { recursive: true });
|
|
24781
|
-
let sessionFile = options.sessionFile ??
|
|
24786
|
+
let sessionFile = options.sessionFile ?? join46(request.runDirectory, "session", "session.jsonl");
|
|
24782
24787
|
await mkdir5(dirname25(sessionFile), { recursive: true });
|
|
24783
24788
|
if (request.continuation.kind !== "resume") {
|
|
24784
24789
|
try {
|
|
@@ -25297,17 +25302,129 @@ async function prepareRoleEnvelope(options) {
|
|
|
25297
25302
|
// src/headless-host/production-host.ts
|
|
25298
25303
|
init_session_identity();
|
|
25299
25304
|
|
|
25305
|
+
// src/headless-host/role-turn-host.ts
|
|
25306
|
+
import { spawn as spawn3, spawnSync as spawnSync3 } from "node:child_process";
|
|
25307
|
+
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
25308
|
+
import { existsSync as existsSync15 } from "node:fs";
|
|
25309
|
+
import { writeFile as writeFile11 } from "node:fs/promises";
|
|
25310
|
+
import { dirname as dirname26, isAbsolute as isAbsolute12, join as join47, resolve as resolve21 } from "node:path";
|
|
25311
|
+
|
|
25312
|
+
// src/external-host-turn-loop.ts
|
|
25313
|
+
var EXTERNAL_ROLE_TURN_ROUND_LIMIT = 8;
|
|
25314
|
+
function mergeRoleTurnAbortSignals(prepared, request) {
|
|
25315
|
+
if (request === void 0) return prepared;
|
|
25316
|
+
if (prepared === void 0) return request;
|
|
25317
|
+
return AbortSignal.any([prepared, request]);
|
|
25318
|
+
}
|
|
25319
|
+
function isHostAbortedError(error) {
|
|
25320
|
+
return typeof error === "object" && error !== null && error.code === "host-aborted";
|
|
25321
|
+
}
|
|
25322
|
+
function hostAbortedError(message = "host aborted") {
|
|
25323
|
+
return Object.assign(new Error(message), { code: "host-aborted" });
|
|
25324
|
+
}
|
|
25325
|
+
function externalHostFailure(cause, name, code, details, diagnostic) {
|
|
25326
|
+
return asFailure({
|
|
25327
|
+
cause,
|
|
25328
|
+
identity: { name, code },
|
|
25329
|
+
...diagnostic === void 0 ? {} : { diagnostic },
|
|
25330
|
+
...details === void 0 ? {} : { details }
|
|
25331
|
+
});
|
|
25332
|
+
}
|
|
25333
|
+
function withExternalHostCleanupFailure(outcome, cleanupError, name) {
|
|
25334
|
+
const message = cleanupError instanceof Error ? cleanupError.message : String(cleanupError);
|
|
25335
|
+
if (outcome.knownFailure === void 0) {
|
|
25336
|
+
return externalHostFailure("session", name, "dispose-failed", { cleanupError: message }, message);
|
|
25337
|
+
}
|
|
25338
|
+
return {
|
|
25339
|
+
...outcome,
|
|
25340
|
+
knownFailure: {
|
|
25341
|
+
...outcome.knownFailure,
|
|
25342
|
+
details: { ...outcome.knownFailure.details ?? {}, cleanupError: message }
|
|
25343
|
+
}
|
|
25344
|
+
};
|
|
25345
|
+
}
|
|
25346
|
+
function asFailure(knownFailure, stderr = "") {
|
|
25347
|
+
return { code: null, stderr, timedOut: false, knownFailure };
|
|
25348
|
+
}
|
|
25349
|
+
async function settleHostAborted(prepared, sessionId) {
|
|
25350
|
+
const closure = await prepared.closeRound();
|
|
25351
|
+
if ("failure" in closure) return asFailure(closure.failure);
|
|
25352
|
+
return asFailure({
|
|
25353
|
+
cause: "session",
|
|
25354
|
+
identity: { name: "HostAborted", code: "host-aborted" },
|
|
25355
|
+
...sessionId === void 0 ? {} : { details: { sessionId } }
|
|
25356
|
+
});
|
|
25357
|
+
}
|
|
25358
|
+
async function driveExternalRoleTurnRounds(prepared, request, driver) {
|
|
25359
|
+
let prompt = prepared.prompt;
|
|
25360
|
+
const abortSignal = mergeRoleTurnAbortSignals(prepared.abortSignal, request.signal);
|
|
25361
|
+
let stderr = "";
|
|
25362
|
+
for (let attempt = 0; attempt < EXTERNAL_ROLE_TURN_ROUND_LIMIT; attempt += 1) {
|
|
25363
|
+
if (abortSignal?.aborted) return settleHostAborted(prepared, driver.currentSessionId());
|
|
25364
|
+
let round;
|
|
25365
|
+
try {
|
|
25366
|
+
round = await driver.runRound({ prompt, abortSignal, attempt });
|
|
25367
|
+
} catch (error) {
|
|
25368
|
+
if (isHostAbortedError(error)) return settleHostAborted(prepared, driver.currentSessionId());
|
|
25369
|
+
throw error;
|
|
25370
|
+
}
|
|
25371
|
+
if (round.status === "terminal") {
|
|
25372
|
+
const result = round.result;
|
|
25373
|
+
const combined = `${stderr}${result.stderr}`;
|
|
25374
|
+
return combined === result.stderr ? result : { ...result, stderr: combined };
|
|
25375
|
+
}
|
|
25376
|
+
if (round.stderr !== void 0 && round.stderr.length > 0) stderr += round.stderr;
|
|
25377
|
+
const closure = await prepared.closeRound();
|
|
25378
|
+
if (closure.accepted) {
|
|
25379
|
+
await driver.afterAccepted?.();
|
|
25380
|
+
return { code: 0, stderr, timedOut: false };
|
|
25381
|
+
}
|
|
25382
|
+
if ("failure" in closure) return asFailure(closure.failure, stderr);
|
|
25383
|
+
prompt = closure.retry.message;
|
|
25384
|
+
driver.afterRetry?.();
|
|
25385
|
+
}
|
|
25386
|
+
return asFailure({
|
|
25387
|
+
cause: "output",
|
|
25388
|
+
identity: { name: driver.roundLimitName, code: "round-retry-limit" },
|
|
25389
|
+
...driver.currentSessionId() === void 0 ? {} : { details: { sessionId: driver.currentSessionId() } }
|
|
25390
|
+
});
|
|
25391
|
+
}
|
|
25392
|
+
function createSerializedRoleTurnHost(execute) {
|
|
25393
|
+
let serial = Promise.resolve();
|
|
25394
|
+
return {
|
|
25395
|
+
executeTurn(request) {
|
|
25396
|
+
const execution = serial.then(() => execute(request));
|
|
25397
|
+
serial = execution.then(() => void 0, () => void 0);
|
|
25398
|
+
return execution;
|
|
25399
|
+
}
|
|
25400
|
+
};
|
|
25401
|
+
}
|
|
25402
|
+
|
|
25403
|
+
// src/agent-start-materials.ts
|
|
25404
|
+
function renderAgentStartMaterials(body, materials) {
|
|
25405
|
+
if (materials.length === 0) return body;
|
|
25406
|
+
return [body, ...materials.map((material) => JSON.stringify(material))].join("\n\n");
|
|
25407
|
+
}
|
|
25408
|
+
|
|
25409
|
+
// src/prepared-role-turn.ts
|
|
25410
|
+
function renderSystemPromptOverride(authority) {
|
|
25411
|
+
return renderAgentStartMaterials(authority.body, authority.materials);
|
|
25412
|
+
}
|
|
25413
|
+
async function resolveBoundHostSessionId(request, identity) {
|
|
25414
|
+
const explicit = request.continuation.kind === "resume" ? request.continuation.hostSessionId : void 0;
|
|
25415
|
+
return explicit !== void 0 && explicit !== "" ? explicit : identity.load(request.principal);
|
|
25416
|
+
}
|
|
25417
|
+
|
|
25418
|
+
// src/headless-host/role-turn-host.ts
|
|
25419
|
+
init_host_session_record();
|
|
25420
|
+
|
|
25300
25421
|
// src/headless-host/description.ts
|
|
25301
|
-
import { join as join46 } from "node:path";
|
|
25302
25422
|
function isClaudePrintDescription(description) {
|
|
25303
25423
|
return description.protocol === "claude-print";
|
|
25304
25424
|
}
|
|
25305
25425
|
function isCodexExecDescription(description) {
|
|
25306
25426
|
return description.protocol === "codex-exec";
|
|
25307
25427
|
}
|
|
25308
|
-
function resolveHeadlessBinary(description, operatorHome) {
|
|
25309
|
-
return join46(operatorHome, ...description.binaryFromHome);
|
|
25310
|
-
}
|
|
25311
25428
|
function headlessTurnArgs(options) {
|
|
25312
25429
|
const { description } = options;
|
|
25313
25430
|
const args = [
|
|
@@ -25566,109 +25683,7 @@ function headlessMcpConfigDocument(mcpServers) {
|
|
|
25566
25683
|
}
|
|
25567
25684
|
|
|
25568
25685
|
// src/headless-host/role-turn-host.ts
|
|
25569
|
-
import { spawn as spawn3, spawnSync as spawnSync3 } from "node:child_process";
|
|
25570
|
-
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
25571
|
-
import { existsSync as existsSync15 } from "node:fs";
|
|
25572
|
-
import { writeFile as writeFile11 } from "node:fs/promises";
|
|
25573
|
-
import { dirname as dirname26, isAbsolute as isAbsolute12, join as join47, resolve as resolve21 } from "node:path";
|
|
25574
|
-
|
|
25575
|
-
// src/external-host-turn-loop.ts
|
|
25576
|
-
var EXTERNAL_ROLE_TURN_ROUND_LIMIT = 8;
|
|
25577
|
-
function mergeRoleTurnAbortSignals(prepared, request) {
|
|
25578
|
-
if (request === void 0) return prepared;
|
|
25579
|
-
if (prepared === void 0) return request;
|
|
25580
|
-
return AbortSignal.any([prepared, request]);
|
|
25581
|
-
}
|
|
25582
|
-
function isHostAbortedError(error) {
|
|
25583
|
-
return typeof error === "object" && error !== null && error.code === "host-aborted";
|
|
25584
|
-
}
|
|
25585
|
-
function hostAbortedError(message = "host aborted") {
|
|
25586
|
-
return Object.assign(new Error(message), { code: "host-aborted" });
|
|
25587
|
-
}
|
|
25588
|
-
function asFailure(knownFailure, stderr = "") {
|
|
25589
|
-
return { code: null, stderr, timedOut: false, knownFailure };
|
|
25590
|
-
}
|
|
25591
|
-
async function settleHostAborted(prepared, sessionId) {
|
|
25592
|
-
const closure = await prepared.closeRound();
|
|
25593
|
-
if ("failure" in closure) return asFailure(closure.failure);
|
|
25594
|
-
return asFailure({
|
|
25595
|
-
cause: "session",
|
|
25596
|
-
identity: { name: "HostAborted", code: "host-aborted" },
|
|
25597
|
-
...sessionId === void 0 ? {} : { details: { sessionId } }
|
|
25598
|
-
});
|
|
25599
|
-
}
|
|
25600
|
-
async function driveExternalRoleTurnRounds(prepared, request, driver) {
|
|
25601
|
-
let prompt = prepared.prompt;
|
|
25602
|
-
const abortSignal = mergeRoleTurnAbortSignals(prepared.abortSignal, request.signal);
|
|
25603
|
-
let stderr = "";
|
|
25604
|
-
for (let attempt = 0; attempt < EXTERNAL_ROLE_TURN_ROUND_LIMIT; attempt += 1) {
|
|
25605
|
-
if (abortSignal?.aborted) return settleHostAborted(prepared, driver.currentSessionId());
|
|
25606
|
-
let round;
|
|
25607
|
-
try {
|
|
25608
|
-
round = await driver.runRound({ prompt, abortSignal, attempt });
|
|
25609
|
-
} catch (error) {
|
|
25610
|
-
if (isHostAbortedError(error)) return settleHostAborted(prepared, driver.currentSessionId());
|
|
25611
|
-
throw error;
|
|
25612
|
-
}
|
|
25613
|
-
if (round.status === "terminal") {
|
|
25614
|
-
const result = round.result;
|
|
25615
|
-
const combined = `${stderr}${result.stderr}`;
|
|
25616
|
-
return combined === result.stderr ? result : { ...result, stderr: combined };
|
|
25617
|
-
}
|
|
25618
|
-
if (round.stderr !== void 0 && round.stderr.length > 0) stderr += round.stderr;
|
|
25619
|
-
const closure = await prepared.closeRound();
|
|
25620
|
-
if (closure.accepted) {
|
|
25621
|
-
await driver.afterAccepted?.();
|
|
25622
|
-
return { code: 0, stderr, timedOut: false };
|
|
25623
|
-
}
|
|
25624
|
-
if ("failure" in closure) return asFailure(closure.failure, stderr);
|
|
25625
|
-
prompt = closure.retry.message;
|
|
25626
|
-
driver.afterRetry?.();
|
|
25627
|
-
}
|
|
25628
|
-
return asFailure({
|
|
25629
|
-
cause: "output",
|
|
25630
|
-
identity: { name: driver.roundLimitName, code: "round-retry-limit" },
|
|
25631
|
-
...driver.currentSessionId() === void 0 ? {} : { details: { sessionId: driver.currentSessionId() } }
|
|
25632
|
-
});
|
|
25633
|
-
}
|
|
25634
|
-
function createSerializedRoleTurnHost(execute) {
|
|
25635
|
-
let serial = Promise.resolve();
|
|
25636
|
-
return {
|
|
25637
|
-
executeTurn(request) {
|
|
25638
|
-
const execution = serial.then(() => execute(request));
|
|
25639
|
-
serial = execution.then(() => void 0, () => void 0);
|
|
25640
|
-
return execution;
|
|
25641
|
-
}
|
|
25642
|
-
};
|
|
25643
|
-
}
|
|
25644
|
-
|
|
25645
|
-
// src/agent-start-materials.ts
|
|
25646
|
-
function renderAgentStartMaterials(body, materials) {
|
|
25647
|
-
if (materials.length === 0) return body;
|
|
25648
|
-
return [body, ...materials.map((material) => JSON.stringify(material))].join("\n\n");
|
|
25649
|
-
}
|
|
25650
|
-
|
|
25651
|
-
// src/prepared-role-turn.ts
|
|
25652
|
-
function renderSystemPromptOverride(authority) {
|
|
25653
|
-
return renderAgentStartMaterials(authority.body, authority.materials);
|
|
25654
|
-
}
|
|
25655
|
-
|
|
25656
|
-
// src/headless-host/role-turn-host.ts
|
|
25657
|
-
init_host_session_record();
|
|
25658
25686
|
init_navigator_output();
|
|
25659
|
-
function failure(cause, name, code, details, diagnostic) {
|
|
25660
|
-
return {
|
|
25661
|
-
code: null,
|
|
25662
|
-
stderr: "",
|
|
25663
|
-
timedOut: false,
|
|
25664
|
-
knownFailure: {
|
|
25665
|
-
cause,
|
|
25666
|
-
identity: { name, code },
|
|
25667
|
-
...diagnostic === void 0 ? {} : { diagnostic },
|
|
25668
|
-
...details === void 0 ? {} : { details }
|
|
25669
|
-
}
|
|
25670
|
-
};
|
|
25671
|
-
}
|
|
25672
25687
|
function isHeadlessResultCandidate(value) {
|
|
25673
25688
|
if (!isPlainObject2(value)) return false;
|
|
25674
25689
|
const record4 = value;
|
|
@@ -25678,25 +25693,11 @@ function parseHeadlessCliStdout(stdout) {
|
|
|
25678
25693
|
const trimmed = stdout.trim();
|
|
25679
25694
|
if (trimmed === "") return void 0;
|
|
25680
25695
|
try {
|
|
25681
|
-
const
|
|
25682
|
-
|
|
25696
|
+
const value = JSON.parse(trimmed);
|
|
25697
|
+
return isHeadlessResultCandidate(value) ? value : void 0;
|
|
25683
25698
|
} catch {
|
|
25699
|
+
return void 0;
|
|
25684
25700
|
}
|
|
25685
|
-
let last;
|
|
25686
|
-
for (const line2 of trimmed.split("\n")) {
|
|
25687
|
-
const text = line2.trim();
|
|
25688
|
-
if (text === "") continue;
|
|
25689
|
-
try {
|
|
25690
|
-
const value = JSON.parse(text);
|
|
25691
|
-
if (!isPlainObject2(value)) continue;
|
|
25692
|
-
const record4 = value;
|
|
25693
|
-
if (record4.type === "result" || record4.structured_output !== void 0) {
|
|
25694
|
-
last = record4;
|
|
25695
|
-
}
|
|
25696
|
-
} catch {
|
|
25697
|
-
}
|
|
25698
|
-
}
|
|
25699
|
-
return last;
|
|
25700
25701
|
}
|
|
25701
25702
|
function resultCandidateText(line2) {
|
|
25702
25703
|
const text = line2.trim();
|
|
@@ -25903,19 +25904,6 @@ function spawnHeadlessTurn(options) {
|
|
|
25903
25904
|
}
|
|
25904
25905
|
});
|
|
25905
25906
|
}
|
|
25906
|
-
function withCleanupFailure(outcome, cleanupError) {
|
|
25907
|
-
const message = cleanupError instanceof Error ? cleanupError.message : String(cleanupError);
|
|
25908
|
-
if (outcome.knownFailure === void 0) {
|
|
25909
|
-
return failure("session", "HeadlessDisposeFailure", "dispose-failed", { cleanupError: message }, message);
|
|
25910
|
-
}
|
|
25911
|
-
return {
|
|
25912
|
-
...outcome,
|
|
25913
|
-
knownFailure: {
|
|
25914
|
-
...outcome.knownFailure,
|
|
25915
|
-
details: { ...outcome.knownFailure.details ?? {}, cleanupError: message }
|
|
25916
|
-
}
|
|
25917
|
-
};
|
|
25918
|
-
}
|
|
25919
25907
|
function terminalFromSpawned(spawned, knownFailure) {
|
|
25920
25908
|
return {
|
|
25921
25909
|
status: "terminal",
|
|
@@ -25962,12 +25950,11 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
25962
25950
|
const prepared = await config.prepare(request);
|
|
25963
25951
|
const systemPrompt = renderSystemPromptOverride(prepared.systemPrompt);
|
|
25964
25952
|
const codex = isCodexExecDescription(config.description);
|
|
25965
|
-
let outcome =
|
|
25953
|
+
let outcome = externalHostFailure("session", "HeadlessNoOutcome", "no-outcome");
|
|
25966
25954
|
try {
|
|
25967
|
-
|
|
25968
|
-
let sessionId = explicitHostSessionId !== void 0 && explicitHostSessionId !== "" ? explicitHostSessionId : await config.sessionIdentity.load(request.principal);
|
|
25955
|
+
let sessionId = await resolveBoundHostSessionId(request, config.sessionIdentity);
|
|
25969
25956
|
if (request.continuation.kind === "resume" && (sessionId === void 0 || sessionId === "")) {
|
|
25970
|
-
outcome =
|
|
25957
|
+
outcome = externalHostFailure(
|
|
25971
25958
|
"session",
|
|
25972
25959
|
"HeadlessSessionFailure",
|
|
25973
25960
|
"session-id-missing",
|
|
@@ -26036,7 +26023,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
26036
26023
|
const message = error instanceof Error ? error.message : String(error);
|
|
26037
26024
|
return {
|
|
26038
26025
|
status: "terminal",
|
|
26039
|
-
result:
|
|
26026
|
+
result: externalHostFailure("session", "HeadlessArgvFailure", "argv-failed", { diagnostic: message }, message)
|
|
26040
26027
|
};
|
|
26041
26028
|
}
|
|
26042
26029
|
const codexObserver = codex ? createCodexExecTurnObserver() : void 0;
|
|
@@ -26107,7 +26094,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
26107
26094
|
if (observedHostFailure !== void 0) {
|
|
26108
26095
|
return {
|
|
26109
26096
|
status: "terminal",
|
|
26110
|
-
result:
|
|
26097
|
+
result: externalHostFailure("output", "HeadlessCliError", "codex-turn-failed", {
|
|
26111
26098
|
diagnostic: observedHostFailure,
|
|
26112
26099
|
sessionRecordDiagnostic: message,
|
|
26113
26100
|
sessionId
|
|
@@ -26116,7 +26103,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
26116
26103
|
}
|
|
26117
26104
|
return {
|
|
26118
26105
|
status: "terminal",
|
|
26119
|
-
result:
|
|
26106
|
+
result: externalHostFailure("activation", "HeadlessSpawnFailure", "spawn-failed", {
|
|
26120
26107
|
diagnostic: message,
|
|
26121
26108
|
binary: config.binary
|
|
26122
26109
|
}, message)
|
|
@@ -26272,7 +26259,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
26272
26259
|
try {
|
|
26273
26260
|
await prepared.dispose?.();
|
|
26274
26261
|
} catch (cleanupError) {
|
|
26275
|
-
outcome =
|
|
26262
|
+
outcome = withExternalHostCleanupFailure(outcome, cleanupError, "HeadlessDisposeFailure");
|
|
26276
26263
|
}
|
|
26277
26264
|
}
|
|
26278
26265
|
return outcome;
|
|
@@ -26291,7 +26278,7 @@ function createProductionHeadlessRoleTurnHost(options) {
|
|
|
26291
26278
|
description,
|
|
26292
26279
|
hostName,
|
|
26293
26280
|
sessionIdentity,
|
|
26294
|
-
binary:
|
|
26281
|
+
binary: resolveHostBinary(description, operatorHome),
|
|
26295
26282
|
env: {
|
|
26296
26283
|
...process.env,
|
|
26297
26284
|
AK_PACKAGE_ROOT: packageRoot
|