@akagilnc/pi-workflow-roles 0.1.5235 → 0.1.5241
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/CLAUDE.md +3 -0
- package/dist/acp-host/production-host.js +141 -251
- package/dist/headless-host/production-host.js +128 -238
- package/dist/public-cli/main.js +50 -129
- package/dist/public-cli/post-admission.js +4 -17
- package/dist/sitian-appender.js +0 -9
- package/package.json +1 -1
- package/src/notary-role.ts +0 -1
- package/src/public-cli/countersign-run.ts +4 -3
- package/src/public-cli/post-admission.ts +4 -18
- package/src/role-envelope.ts +2 -2
- package/src/role-runtime.ts +0 -14
- package/src/sitian-appender.ts +0 -14
- package/dist/public-cli/case-dossier-delivery.js +0 -109
- package/src/public-cli/case-dossier-delivery.ts +0 -147
|
@@ -4517,14 +4517,6 @@ function resolveSitianRecordPathInLedger(input, ledgerHome) {
|
|
|
4517
4517
|
}
|
|
4518
4518
|
return { sessionDir, recordFile, ledgerHome };
|
|
4519
4519
|
}
|
|
4520
|
-
function projectTicketRecordsPathShape() {
|
|
4521
|
-
const { recordFile } = ticketProvenanceUnderBookPaths(
|
|
4522
|
-
join3("~", ".ak-roles"),
|
|
4523
|
-
"<\u7C3F>",
|
|
4524
|
-
"<\u7968\u53F7>"
|
|
4525
|
-
);
|
|
4526
|
-
return recordFile.replace(/\\/g, "/");
|
|
4527
|
-
}
|
|
4528
4520
|
function resolveSitianRecordPath(input) {
|
|
4529
4521
|
const ledgerHome = input.home !== void 0 && input.home.length > 0 ? resolveActivationLedgerHome(input.home) : resolveActivationLedgerHomeForPath(input.runDirectory ?? input.sessionParent);
|
|
4530
4522
|
return resolveSitianRecordPathInLedger(input, ledgerHome);
|
|
@@ -6274,10 +6266,10 @@ __export(session_assistant_usage_exports, {
|
|
|
6274
6266
|
});
|
|
6275
6267
|
import { join as join13 } from "node:path";
|
|
6276
6268
|
async function readAssistantUsageFromSessionFile(sessionFile) {
|
|
6277
|
-
const { readFile:
|
|
6269
|
+
const { readFile: readFile26 } = await import("node:fs/promises");
|
|
6278
6270
|
let text;
|
|
6279
6271
|
try {
|
|
6280
|
-
text = await
|
|
6272
|
+
text = await readFile26(sessionFile, "utf8");
|
|
6281
6273
|
} catch (error) {
|
|
6282
6274
|
if (error?.code === "ENOENT") return void 0;
|
|
6283
6275
|
throw error;
|
|
@@ -7555,12 +7547,6 @@ function ticketProvenanceRecordInput(ticketNumber, cwd, home, runDirectory) {
|
|
|
7555
7547
|
...home === void 0 ? {} : { home }
|
|
7556
7548
|
};
|
|
7557
7549
|
}
|
|
7558
|
-
function resolveTicketProvenanceVolume(ticketNumber, cwd, home) {
|
|
7559
|
-
const path = resolveSitianRecordPath(
|
|
7560
|
-
ticketProvenanceRecordInput(ticketNumber, cwd, home)
|
|
7561
|
-
);
|
|
7562
|
-
return { recordFile: path.recordFile, volumeDir: path.sessionDir };
|
|
7563
|
-
}
|
|
7564
7550
|
async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, home) {
|
|
7565
7551
|
const source = join16(runDirectory, "records.jsonl");
|
|
7566
7552
|
let content;
|
|
@@ -11217,10 +11203,10 @@ function pairGateRounds(volumes) {
|
|
|
11217
11203
|
return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
|
|
11218
11204
|
}
|
|
11219
11205
|
async function resolveOfficerSessionFromPointerFile(pointerPath) {
|
|
11220
|
-
const { readFile:
|
|
11206
|
+
const { readFile: readFile26 } = await import("node:fs/promises");
|
|
11221
11207
|
let raw;
|
|
11222
11208
|
try {
|
|
11223
|
-
raw = JSON.parse(await
|
|
11209
|
+
raw = JSON.parse(await readFile26(pointerPath, "utf8"));
|
|
11224
11210
|
} catch (error) {
|
|
11225
11211
|
throw new Error(
|
|
11226
11212
|
`direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -14660,87 +14646,6 @@ var init_session_identity = __esm({
|
|
|
14660
14646
|
}
|
|
14661
14647
|
});
|
|
14662
14648
|
|
|
14663
|
-
// src/public-cli/case-dossier-delivery.ts
|
|
14664
|
-
var case_dossier_delivery_exports = {};
|
|
14665
|
-
__export(case_dossier_delivery_exports, {
|
|
14666
|
-
deliverCaseDossierAsAttachment: () => deliverCaseDossierAsAttachment,
|
|
14667
|
-
loadCaseDossierReadingMaterial: () => loadCaseDossierReadingMaterial,
|
|
14668
|
-
projectCaseDossierPointerSection: () => projectCaseDossierPointerSection
|
|
14669
|
-
});
|
|
14670
|
-
import { mkdtemp as mkdtemp3, readFile as readFile18, rm as rm5, writeFile as writeFile8 } from "node:fs/promises";
|
|
14671
|
-
import { tmpdir as tmpdir3 } from "node:os";
|
|
14672
|
-
import { join as join30 } from "node:path";
|
|
14673
|
-
async function projectCaseDossierPointerSection(input) {
|
|
14674
|
-
if (input.ticketNumber === void 0) {
|
|
14675
|
-
return [
|
|
14676
|
-
UNBOUND_DOSSIER_PATH_HEADING,
|
|
14677
|
-
"",
|
|
14678
|
-
`\u8BB0\u5F55\u5377\u5B97\uFF1A${projectTicketRecordsPathShape()}`
|
|
14679
|
-
].join("\n");
|
|
14680
|
-
}
|
|
14681
|
-
const volume = resolveTicketProvenanceVolume(
|
|
14682
|
-
input.ticketNumber,
|
|
14683
|
-
input.projectRoot,
|
|
14684
|
-
input.home
|
|
14685
|
-
);
|
|
14686
|
-
return [
|
|
14687
|
-
CASE_DOSSIER_SECTION_HEADING,
|
|
14688
|
-
"",
|
|
14689
|
-
`\u7968\u53F7\uFF1A#${input.ticketNumber}`,
|
|
14690
|
-
`\u8BB0\u5F55\u5377\u5B97\uFF1A${volume.recordFile}`
|
|
14691
|
-
].join("\n");
|
|
14692
|
-
}
|
|
14693
|
-
async function deliverCaseDossierAsAttachment(input) {
|
|
14694
|
-
const section = await projectCaseDossierPointerSection({
|
|
14695
|
-
ticketNumber: input.ticketNumber,
|
|
14696
|
-
projectRoot: input.projectRoot,
|
|
14697
|
-
home: input.home
|
|
14698
|
-
});
|
|
14699
|
-
const stagingDir = await mkdtemp3(join30(tmpdir3(), "ak-case-dossier-"));
|
|
14700
|
-
try {
|
|
14701
|
-
const stagingPath = join30(stagingDir, CASE_DOSSIER_ATTACH_FILE);
|
|
14702
|
-
await writeFile8(stagingPath, `${section}
|
|
14703
|
-
`, "utf8");
|
|
14704
|
-
return await freezeAttachmentsIntoRun(
|
|
14705
|
-
[stagingPath],
|
|
14706
|
-
input.runDirectory,
|
|
14707
|
-
CASE_DOSSIER_ATTACH_KEY
|
|
14708
|
-
);
|
|
14709
|
-
} finally {
|
|
14710
|
-
await rm5(stagingDir, { recursive: true, force: true });
|
|
14711
|
-
}
|
|
14712
|
-
}
|
|
14713
|
-
async function loadCaseDossierReadingMaterial(runDirectory) {
|
|
14714
|
-
const frozenPath = join30(
|
|
14715
|
-
runDirectory,
|
|
14716
|
-
"attachments",
|
|
14717
|
-
CASE_DOSSIER_ATTACH_KEY,
|
|
14718
|
-
`00-${CASE_DOSSIER_ATTACH_FILE}`
|
|
14719
|
-
);
|
|
14720
|
-
let section;
|
|
14721
|
-
try {
|
|
14722
|
-
section = await readFile18(frozenPath, "utf8");
|
|
14723
|
-
} catch (error) {
|
|
14724
|
-
if (error.code === "ENOENT") return void 0;
|
|
14725
|
-
throw error;
|
|
14726
|
-
}
|
|
14727
|
-
if (section.trim() === "") return void 0;
|
|
14728
|
-
return { kind: "case-dossier-pointer", frozenPath, section };
|
|
14729
|
-
}
|
|
14730
|
-
var CASE_DOSSIER_SECTION_HEADING, UNBOUND_DOSSIER_PATH_HEADING, CASE_DOSSIER_ATTACH_KEY, CASE_DOSSIER_ATTACH_FILE;
|
|
14731
|
-
var init_case_dossier_delivery = __esm({
|
|
14732
|
-
"src/public-cli/case-dossier-delivery.ts"() {
|
|
14733
|
-
"use strict";
|
|
14734
|
-
init_sitian_facade();
|
|
14735
|
-
init_ticket_provenance();
|
|
14736
|
-
init_invocation();
|
|
14737
|
-
CASE_DOSSIER_SECTION_HEADING = "## \u672C\u7968\u8D77\u5C45\u5F55\uFF08\u7CFB\u7EDF\u968F\u6848\u63D0\u4F9B\uFF09";
|
|
14738
|
-
UNBOUND_DOSSIER_PATH_HEADING = "## \u8D77\u5C45\u5F55\u8DEF\u5F84\uFF08\u7CFB\u7EDF\u968F\u6848\u63D0\u4F9B\uFF09";
|
|
14739
|
-
CASE_DOSSIER_ATTACH_KEY = "case-dossier";
|
|
14740
|
-
CASE_DOSSIER_ATTACH_FILE = "case-dossier-pointer.md";
|
|
14741
|
-
}
|
|
14742
|
-
});
|
|
14743
|
-
|
|
14744
14649
|
// src/public-cli/process-cancel.ts
|
|
14745
14650
|
function processCancelSignalName(signal) {
|
|
14746
14651
|
if (signal === void 0 || signal.aborted !== true) return void 0;
|
|
@@ -14774,7 +14679,7 @@ import {
|
|
|
14774
14679
|
statSync as statSync3
|
|
14775
14680
|
} from "node:fs";
|
|
14776
14681
|
import { homedir } from "node:os";
|
|
14777
|
-
import { dirname as dirname19, join as
|
|
14682
|
+
import { dirname as dirname19, join as join30 } from "node:path";
|
|
14778
14683
|
function declareHostSessionFailure(error) {
|
|
14779
14684
|
const message = error instanceof Error ? error.stack || error.message : String(error);
|
|
14780
14685
|
process.stderr.write(`[host-session] Dossier record failure: ${message}
|
|
@@ -14799,7 +14704,7 @@ function findCodexRollout(sessionsDir, sessionId) {
|
|
|
14799
14704
|
return;
|
|
14800
14705
|
}
|
|
14801
14706
|
for (const entry of entries) {
|
|
14802
|
-
const fullPath =
|
|
14707
|
+
const fullPath = join30(dir, entry.name);
|
|
14803
14708
|
if (entry.isDirectory()) {
|
|
14804
14709
|
scan(fullPath, depth + 1);
|
|
14805
14710
|
} else if (entry.isFile() && entry.name.endsWith(".jsonl") && entry.name.includes(sessionId)) {
|
|
@@ -14823,25 +14728,25 @@ function sanitizeClaudeCwd(cwd) {
|
|
|
14823
14728
|
function resolveNativeSessionPath(options) {
|
|
14824
14729
|
const home = options.home || homedir();
|
|
14825
14730
|
if (options.host === "claude") {
|
|
14826
|
-
const configDir = process.env.CLAUDE_CONFIG_DIR ||
|
|
14731
|
+
const configDir = process.env.CLAUDE_CONFIG_DIR || join30(home, ".claude");
|
|
14827
14732
|
const sanitizedCwd = sanitizeClaudeCwd(options.cwd);
|
|
14828
|
-
return
|
|
14733
|
+
return join30(configDir, "projects", sanitizedCwd, `${options.sessionId}.jsonl`);
|
|
14829
14734
|
}
|
|
14830
14735
|
if (options.host === "codex") {
|
|
14831
14736
|
return findCodexRollout(codexSessionsDirectory(home), options.sessionId);
|
|
14832
14737
|
}
|
|
14833
14738
|
if (options.host === "grok-build") {
|
|
14834
|
-
const grokHome = process.env.GROK_HOME ||
|
|
14835
|
-
return
|
|
14739
|
+
const grokHome = process.env.GROK_HOME || join30(home, ".grok");
|
|
14740
|
+
return join30(grokHome, "sessions", encodeURIComponent(options.cwd), options.sessionId);
|
|
14836
14741
|
}
|
|
14837
14742
|
return void 0;
|
|
14838
14743
|
}
|
|
14839
14744
|
function codexSessionsDirectory(home) {
|
|
14840
|
-
return
|
|
14745
|
+
return join30(process.env.CODEX_HOME || join30(home || homedir(), ".codex"), "sessions");
|
|
14841
14746
|
}
|
|
14842
14747
|
function recordRunStart(runDirectory) {
|
|
14843
14748
|
try {
|
|
14844
|
-
appendFileSync2(
|
|
14749
|
+
appendFileSync2(join30(runDirectory, ".run-starts"), "\n");
|
|
14845
14750
|
} catch (error) {
|
|
14846
14751
|
declareHostSessionFailure(error);
|
|
14847
14752
|
}
|
|
@@ -14865,12 +14770,12 @@ function resolveHostDossierLandingPath(options) {
|
|
|
14865
14770
|
} catch {
|
|
14866
14771
|
}
|
|
14867
14772
|
}
|
|
14868
|
-
const startsPath =
|
|
14773
|
+
const startsPath = join30(dirname19(options.sessionDirectory), ".run-starts");
|
|
14869
14774
|
let starts = 0;
|
|
14870
14775
|
if (existsSync9(startsPath)) starts = readFileSync3(startsPath, "utf8").length;
|
|
14871
14776
|
const ordinal = Math.max(maxOrdinal + 1, starts, options.continuation.kind === "resume" ? 2 : 1);
|
|
14872
14777
|
const baseName = `${options.host}-${sanitizedModel}-${ordinal}`;
|
|
14873
|
-
const landingPath = options.host === "grok-build" ?
|
|
14778
|
+
const landingPath = options.host === "grok-build" ? join30(options.sessionDirectory, baseName) : join30(options.sessionDirectory, `${baseName}.jsonl`);
|
|
14874
14779
|
return { landingPath, ordinal, sanitizedModel };
|
|
14875
14780
|
}
|
|
14876
14781
|
function recordNativeSessionPointer(options) {
|
|
@@ -14903,18 +14808,18 @@ function copyFileCloneOrFallback(src, dest) {
|
|
|
14903
14808
|
copyFileSync(src, dest);
|
|
14904
14809
|
}
|
|
14905
14810
|
function copyGrokDossier(srcDir, destDir) {
|
|
14906
|
-
const chatHistorySrc =
|
|
14811
|
+
const chatHistorySrc = join30(srcDir, "chat_history.jsonl");
|
|
14907
14812
|
if (!existsSync9(chatHistorySrc)) {
|
|
14908
14813
|
throw new Error(`Grok native chat_history.jsonl missing at ${chatHistorySrc}`);
|
|
14909
14814
|
}
|
|
14910
14815
|
mkdirSync3(destDir, { recursive: true });
|
|
14911
|
-
const chatHistoryDest =
|
|
14816
|
+
const chatHistoryDest = join30(destDir, "chat_history.jsonl");
|
|
14912
14817
|
copyFileCloneOrFallback(chatHistorySrc, chatHistoryDest);
|
|
14913
|
-
const usageSrc =
|
|
14818
|
+
const usageSrc = join30(srcDir, "usage.json");
|
|
14914
14819
|
if (!existsSync9(usageSrc)) {
|
|
14915
14820
|
throw new Error(`Grok native usage.json missing at ${usageSrc}`);
|
|
14916
14821
|
}
|
|
14917
|
-
copyFileCloneOrFallback(usageSrc,
|
|
14822
|
+
copyFileCloneOrFallback(usageSrc, join30(destDir, "usage.json"));
|
|
14918
14823
|
}
|
|
14919
14824
|
function copyAndRecordHostDossier(options) {
|
|
14920
14825
|
if (options.host === "pi" || options.host === "hermes") {
|
|
@@ -14989,7 +14894,7 @@ function copyAndRecordHostDossier(options) {
|
|
|
14989
14894
|
}
|
|
14990
14895
|
try {
|
|
14991
14896
|
mkdirSync3(options.sessionDirectory, { recursive: true });
|
|
14992
|
-
closeSync(openSync(
|
|
14897
|
+
closeSync(openSync(join30(options.sessionDirectory, `${options.host}-${sanitizedModel}-${ordinal}.failed`), "a"));
|
|
14993
14898
|
} catch {
|
|
14994
14899
|
}
|
|
14995
14900
|
sitianReportSafe({
|
|
@@ -15023,7 +14928,7 @@ var init_host_session_record = __esm({
|
|
|
15023
14928
|
import { constants as fsConstants2 } from "node:fs";
|
|
15024
14929
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
15025
14930
|
import { lstat as lstat5, mkdir as mkdir3, open } from "node:fs/promises";
|
|
15026
|
-
import { join as
|
|
14931
|
+
import { join as join31 } from "node:path";
|
|
15027
14932
|
async function persistReturnedRunState(admitted, authority, options) {
|
|
15028
14933
|
if (options?.lawful === true) {
|
|
15029
14934
|
await markRunTerminal(admitted.runDirectory);
|
|
@@ -15094,7 +14999,7 @@ function jsonSafeReplacer() {
|
|
|
15094
14999
|
};
|
|
15095
15000
|
}
|
|
15096
15001
|
async function writeHardenedArtifactFile(artifactsDir, namePrefix, payload) {
|
|
15097
|
-
const filePath =
|
|
15002
|
+
const filePath = join31(artifactsDir, `${namePrefix}-${randomUUID6()}.json`);
|
|
15098
15003
|
const body = `${JSON.stringify(payload, jsonSafeReplacer(), 2)}
|
|
15099
15004
|
`;
|
|
15100
15005
|
const noFollowFlag = typeof fsConstants2.O_NOFOLLOW === "number" ? fsConstants2.O_NOFOLLOW : 0;
|
|
@@ -15382,8 +15287,8 @@ var init_auto_resume = __esm({
|
|
|
15382
15287
|
|
|
15383
15288
|
// src/public-cli/post-admission.ts
|
|
15384
15289
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
15385
|
-
import { writeFile as
|
|
15386
|
-
import { isAbsolute as isAbsolute7, join as
|
|
15290
|
+
import { writeFile as writeFile8 } from "node:fs/promises";
|
|
15291
|
+
import { isAbsolute as isAbsolute7, join as join32, resolve as resolve13 } from "node:path";
|
|
15387
15292
|
function describeCaughtError(error) {
|
|
15388
15293
|
if (error instanceof Error) {
|
|
15389
15294
|
const code = error.code;
|
|
@@ -15478,8 +15383,8 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
15478
15383
|
} catch (appendError) {
|
|
15479
15384
|
try {
|
|
15480
15385
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
15481
|
-
await
|
|
15482
|
-
|
|
15386
|
+
await writeFile8(
|
|
15387
|
+
join32(artifactsDir, `post-admission-diagnostic-${randomUUID7()}.json`),
|
|
15483
15388
|
`${JSON.stringify({ version: 1, ...payload }, null, 2)}
|
|
15484
15389
|
`,
|
|
15485
15390
|
{ encoding: "utf8", flag: "wx" }
|
|
@@ -15625,7 +15530,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
15625
15530
|
const rows = await readRecordedSubmissionRows(
|
|
15626
15531
|
admitted.projectRoot,
|
|
15627
15532
|
admitted.runId,
|
|
15628
|
-
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent:
|
|
15533
|
+
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent: join32(admitted.runDirectory, "session", "session.jsonl") }
|
|
15629
15534
|
);
|
|
15630
15535
|
let ticketNumber;
|
|
15631
15536
|
for (const row of rows) {
|
|
@@ -15719,12 +15624,6 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
15719
15624
|
if (typeof env.host === "string" && env.host.trim() !== "") {
|
|
15720
15625
|
turnRequest = { ...turnRequest, host: env.host.trim() };
|
|
15721
15626
|
}
|
|
15722
|
-
await deliverCaseDossierAsAttachment({
|
|
15723
|
-
ticketNumber: admitted.ticketNumber,
|
|
15724
|
-
projectRoot: admitted.projectRoot,
|
|
15725
|
-
home: env.home,
|
|
15726
|
-
runDirectory: admitted.runDirectory
|
|
15727
|
-
});
|
|
15728
15627
|
await markRunRunning(
|
|
15729
15628
|
admitted.runDirectory,
|
|
15730
15629
|
env.model,
|
|
@@ -15760,8 +15659,8 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
15760
15659
|
}
|
|
15761
15660
|
let stderrLogWriteFailure;
|
|
15762
15661
|
try {
|
|
15763
|
-
await
|
|
15764
|
-
|
|
15662
|
+
await writeFile8(
|
|
15663
|
+
join32(admitted.runDirectory, "stderr.log"),
|
|
15765
15664
|
result.stderr,
|
|
15766
15665
|
"utf8"
|
|
15767
15666
|
);
|
|
@@ -16040,7 +15939,7 @@ async function dispatchAfterWriterLease(input) {
|
|
|
16040
15939
|
}
|
|
16041
15940
|
function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
|
|
16042
15941
|
const absolute = isAbsolute7(attachmentPath) ? attachmentPath : resolve13(attachmentPath);
|
|
16043
|
-
return pathContainedIn(
|
|
15942
|
+
return pathContainedIn(join32(runDirectory, "attachments"), absolute);
|
|
16044
15943
|
}
|
|
16045
15944
|
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
16046
15945
|
if (summons === void 0) return void 0;
|
|
@@ -16299,8 +16198,8 @@ async function presentResumeFailurePointer(io, thrown, publish) {
|
|
|
16299
16198
|
}
|
|
16300
16199
|
async function writeResumeDiagnosticFile(runDirectory, runId, failure2, role) {
|
|
16301
16200
|
const dir = await ensureRealArtifactsDirectory(runDirectory);
|
|
16302
|
-
const path =
|
|
16303
|
-
await
|
|
16201
|
+
const path = join32(dir, `resume-diagnostic-${randomUUID7()}.json`);
|
|
16202
|
+
await writeFile8(
|
|
16304
16203
|
path,
|
|
16305
16204
|
`${JSON.stringify({
|
|
16306
16205
|
runId,
|
|
@@ -16432,7 +16331,6 @@ var init_post_admission = __esm({
|
|
|
16432
16331
|
init_session_identity();
|
|
16433
16332
|
init_role_run_relocation();
|
|
16434
16333
|
init_packaged_role_registry();
|
|
16435
|
-
init_case_dossier_delivery();
|
|
16436
16334
|
init_engine_detour_usage();
|
|
16437
16335
|
init_run_lifecycle();
|
|
16438
16336
|
init_process_cancel();
|
|
@@ -16473,16 +16371,16 @@ var init_seat_ticket_binding = __esm({
|
|
|
16473
16371
|
// src/public-cli/machine-method-skills.ts
|
|
16474
16372
|
import { accessSync, constants as constants2, statSync as statSync4 } from "node:fs";
|
|
16475
16373
|
import { lstat as lstat6, mkdir as mkdir4, symlink } from "node:fs/promises";
|
|
16476
|
-
import { join as
|
|
16374
|
+
import { join as join33 } from "node:path";
|
|
16477
16375
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
16478
16376
|
function skillRoot(home) {
|
|
16479
|
-
return
|
|
16377
|
+
return join33(home, ".agents/skills");
|
|
16480
16378
|
}
|
|
16481
16379
|
function installedMethodSkillPath(home, name) {
|
|
16482
16380
|
return installedSkillPath(skillRoot(home), name);
|
|
16483
16381
|
}
|
|
16484
16382
|
function installedSkillPath(root, name) {
|
|
16485
|
-
const path =
|
|
16383
|
+
const path = join33(root, name, "SKILL.md");
|
|
16486
16384
|
try {
|
|
16487
16385
|
if (!statSync4(path).isFile()) return void 0;
|
|
16488
16386
|
accessSync(path, constants2.R_OK);
|
|
@@ -16495,9 +16393,9 @@ function installedSkillPath(root, name) {
|
|
|
16495
16393
|
}
|
|
16496
16394
|
function linkedSkillRoot(home, host) {
|
|
16497
16395
|
if (host === "claude" || host === "claude-code") {
|
|
16498
|
-
return
|
|
16396
|
+
return join33(process.env.CLAUDE_CONFIG_DIR?.trim() || join33(home, ".claude"), "skills");
|
|
16499
16397
|
}
|
|
16500
|
-
if (host === "hermes") return
|
|
16398
|
+
if (host === "hermes") return join33(home, ".hermes/skills");
|
|
16501
16399
|
return void 0;
|
|
16502
16400
|
}
|
|
16503
16401
|
async function occupied(path) {
|
|
@@ -16554,7 +16452,7 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
16554
16452
|
const missingBySource = /* @__PURE__ */ new Map();
|
|
16555
16453
|
let unsourced = false;
|
|
16556
16454
|
for (const name of packagedMethodSkillNames()) {
|
|
16557
|
-
const path =
|
|
16455
|
+
const path = join33(canonical, name);
|
|
16558
16456
|
if (await occupied(path)) {
|
|
16559
16457
|
warnOccupied(path, stdout);
|
|
16560
16458
|
continue;
|
|
@@ -16578,15 +16476,15 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
16578
16476
|
const root = linkedSkillRoot(home, host);
|
|
16579
16477
|
const binaryFromHome = host === "claude-code" ? HEADLESS_HOST_DESCRIPTIONS.claude.binaryFromHome : HOST_DESCRIPTIONS.hermes.binaryFromHome;
|
|
16580
16478
|
try {
|
|
16581
|
-
accessSync(
|
|
16479
|
+
accessSync(join33(home, ...binaryFromHome), constants2.X_OK);
|
|
16582
16480
|
} catch (error) {
|
|
16583
16481
|
if (["ENOENT", "ENOTDIR", "EACCES"].includes(error.code ?? "")) continue;
|
|
16584
16482
|
throw error;
|
|
16585
16483
|
}
|
|
16586
16484
|
for (const name of packagedMethodSkillNames()) {
|
|
16587
|
-
const target =
|
|
16485
|
+
const target = join33(canonical, name);
|
|
16588
16486
|
if (installedMethodSkillPath(home, name) === void 0) continue;
|
|
16589
|
-
const link =
|
|
16487
|
+
const link = join33(root, name);
|
|
16590
16488
|
if (await occupied(link)) {
|
|
16591
16489
|
warnOccupied(link, stdout);
|
|
16592
16490
|
continue;
|
|
@@ -17965,8 +17863,8 @@ var init_analyst_book_key = __esm({
|
|
|
17965
17863
|
});
|
|
17966
17864
|
|
|
17967
17865
|
// src/analyst-index.ts
|
|
17968
|
-
import { open as open2, readFile as
|
|
17969
|
-
import { dirname as dirname21, join as
|
|
17866
|
+
import { open as open2, readFile as readFile18, unlink as unlink4 } from "node:fs/promises";
|
|
17867
|
+
import { dirname as dirname21, join as join34 } from "node:path";
|
|
17970
17868
|
function sleep(ms) {
|
|
17971
17869
|
return new Promise((resolve22) => {
|
|
17972
17870
|
setTimeout(resolve22, ms);
|
|
@@ -17975,7 +17873,7 @@ function sleep(ms) {
|
|
|
17975
17873
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
17976
17874
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
17977
17875
|
ensureRealDirectoryTree(ledgerHome, dirname21(indexPath));
|
|
17978
|
-
const lockPath =
|
|
17876
|
+
const lockPath = join34(dirname21(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
17979
17877
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
17980
17878
|
const startedAt = Date.now();
|
|
17981
17879
|
while (true) {
|
|
@@ -18002,7 +17900,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
18002
17900
|
}
|
|
18003
17901
|
}
|
|
18004
17902
|
function analystLibraryIndexPath(ledgerHome) {
|
|
18005
|
-
return
|
|
17903
|
+
return join34(ledgerHome, "analyst", "library-index.json");
|
|
18006
17904
|
}
|
|
18007
17905
|
function rowFromIssueMetricsPage(page) {
|
|
18008
17906
|
return {
|
|
@@ -18093,7 +17991,7 @@ async function readAnalystLibraryIndexPage(ledgerHome) {
|
|
|
18093
17991
|
const path = analystLibraryIndexPath(ledgerHome);
|
|
18094
17992
|
let raw;
|
|
18095
17993
|
try {
|
|
18096
|
-
raw = await
|
|
17994
|
+
raw = await readFile18(path, "utf8");
|
|
18097
17995
|
} catch (error) {
|
|
18098
17996
|
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR")) {
|
|
18099
17997
|
return void 0;
|
|
@@ -18297,8 +18195,8 @@ var init_analyst_cohort = __esm({
|
|
|
18297
18195
|
});
|
|
18298
18196
|
|
|
18299
18197
|
// src/analyst-ledger.ts
|
|
18300
|
-
import { readdir as readdir6, readFile as
|
|
18301
|
-
import { basename as basename9, join as
|
|
18198
|
+
import { readdir as readdir6, readFile as readFile19 } from "node:fs/promises";
|
|
18199
|
+
import { basename as basename9, join as join35 } from "node:path";
|
|
18302
18200
|
function isMissingPathError6(error) {
|
|
18303
18201
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
18304
18202
|
}
|
|
@@ -18327,7 +18225,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
|
|
|
18327
18225
|
}
|
|
18328
18226
|
}
|
|
18329
18227
|
async function classifyGhostCandidate(input) {
|
|
18330
|
-
const autopsy = await autopsyWriterLock(
|
|
18228
|
+
const autopsy = await autopsyWriterLock(join35(input.runDirectory, "writer.lock"));
|
|
18331
18229
|
const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
|
|
18332
18230
|
if (leaseCheck === void 0) return { kind: "live" };
|
|
18333
18231
|
return {
|
|
@@ -18356,7 +18254,7 @@ async function listLedgerBookNames(booksRoot) {
|
|
|
18356
18254
|
async function readInvocationScopeFields(runDirectory) {
|
|
18357
18255
|
let raw;
|
|
18358
18256
|
try {
|
|
18359
|
-
raw = await
|
|
18257
|
+
raw = await readFile19(join35(runDirectory, "invocation.json"), "utf8");
|
|
18360
18258
|
} catch (error) {
|
|
18361
18259
|
if (isMissingPathError6(error)) return void 0;
|
|
18362
18260
|
throw error;
|
|
@@ -18389,7 +18287,7 @@ function decideIssueScope(input) {
|
|
|
18389
18287
|
}
|
|
18390
18288
|
async function resolveSessionFile(runDirectory) {
|
|
18391
18289
|
try {
|
|
18392
|
-
const raw = await
|
|
18290
|
+
const raw = await readFile19(join35(runDirectory, "invocation.json"), "utf8");
|
|
18393
18291
|
const parsed = JSON.parse(raw);
|
|
18394
18292
|
if (isRecord13(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
18395
18293
|
return parsed.sessionFile;
|
|
@@ -18397,7 +18295,7 @@ async function resolveSessionFile(runDirectory) {
|
|
|
18397
18295
|
} catch (error) {
|
|
18398
18296
|
if (!isMissingPathError6(error)) throw error;
|
|
18399
18297
|
}
|
|
18400
|
-
return
|
|
18298
|
+
return join35(runDirectory, "session", "session.jsonl");
|
|
18401
18299
|
}
|
|
18402
18300
|
function attributeSessionRowsForRun(input) {
|
|
18403
18301
|
if (pathContainedIn(input.runDirectory, input.sessionFile)) {
|
|
@@ -18589,9 +18487,9 @@ async function classifyScopedRun(input) {
|
|
|
18589
18487
|
}
|
|
18590
18488
|
let gateCycles;
|
|
18591
18489
|
try {
|
|
18592
|
-
const parentSessionFile =
|
|
18490
|
+
const parentSessionFile = join35(input.runDirectory, "session", "session.jsonl");
|
|
18593
18491
|
gateCycles = await readAnalystGateCyclesFromAuditorRoles(
|
|
18594
|
-
|
|
18492
|
+
join35(input.runDirectory, "session", "auditor-roles"),
|
|
18595
18493
|
{ parentSessionFile }
|
|
18596
18494
|
);
|
|
18597
18495
|
} catch (error) {
|
|
@@ -18626,7 +18524,7 @@ async function classifyScopedRun(input) {
|
|
|
18626
18524
|
async function scanAnalystIssueRuns(input) {
|
|
18627
18525
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
18628
18526
|
const scopeTicketNumber = input.ticketNumber;
|
|
18629
|
-
const booksRoot =
|
|
18527
|
+
const booksRoot = join35(ledgerHome, "books");
|
|
18630
18528
|
let wholeBook = false;
|
|
18631
18529
|
let scopeRootIdentity;
|
|
18632
18530
|
let bookNames;
|
|
@@ -18659,7 +18557,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
18659
18557
|
const ghostLegs = [];
|
|
18660
18558
|
const scopeConflicts = [];
|
|
18661
18559
|
for (const book of bookNames) {
|
|
18662
|
-
const bookDir =
|
|
18560
|
+
const bookDir = join35(booksRoot, book);
|
|
18663
18561
|
let runDirectories;
|
|
18664
18562
|
try {
|
|
18665
18563
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
@@ -19531,7 +19429,7 @@ var init_analyst_metric_family = __esm({
|
|
|
19531
19429
|
|
|
19532
19430
|
// src/analyst-page.ts
|
|
19533
19431
|
import { createHash as createHash5 } from "node:crypto";
|
|
19534
|
-
import { dirname as dirname22, join as
|
|
19432
|
+
import { dirname as dirname22, join as join36 } from "node:path";
|
|
19535
19433
|
function analystIssuePageKey(address) {
|
|
19536
19434
|
const parts = ["book", address.bookKey];
|
|
19537
19435
|
if (address.issueNumber !== void 0) {
|
|
@@ -19542,7 +19440,7 @@ function analystIssuePageKey(address) {
|
|
|
19542
19440
|
return createHash5("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
19543
19441
|
}
|
|
19544
19442
|
function analystIssuePagePath(ledgerHome, address) {
|
|
19545
|
-
return
|
|
19443
|
+
return join36(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
19546
19444
|
}
|
|
19547
19445
|
function analystIssuePageAddressFromPage(page) {
|
|
19548
19446
|
return {
|
|
@@ -19678,7 +19576,7 @@ var init_analyst_page = __esm({
|
|
|
19678
19576
|
});
|
|
19679
19577
|
|
|
19680
19578
|
// src/analyst-entry.ts
|
|
19681
|
-
import { readFile as
|
|
19579
|
+
import { readFile as readFile20 } from "node:fs/promises";
|
|
19682
19580
|
import { Type as Type12 } from "typebox";
|
|
19683
19581
|
function isMissingPathError7(error) {
|
|
19684
19582
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
@@ -19709,7 +19607,7 @@ async function readOrComputeAnalystIssuePage(input, options) {
|
|
|
19709
19607
|
...issueNumber === void 0 && input.bookKey === void 0 ? { scopeRootIdentity: projectRoot } : {}
|
|
19710
19608
|
});
|
|
19711
19609
|
try {
|
|
19712
|
-
const raw = await
|
|
19610
|
+
const raw = await readFile20(pagePath, "utf8");
|
|
19713
19611
|
const page = JSON.parse(raw);
|
|
19714
19612
|
if (cachedPageMatchesRequestedScope(page, { bookKey, ...input })) {
|
|
19715
19613
|
const ghostScan = await scanAnalystIssueRuns({
|
|
@@ -19810,7 +19708,7 @@ async function runAnalystModelGroupsMode(input, home) {
|
|
|
19810
19708
|
scopeRootIdentity: projectRoot
|
|
19811
19709
|
});
|
|
19812
19710
|
try {
|
|
19813
|
-
const raw = await
|
|
19711
|
+
const raw = await readFile20(pagePath, "utf8");
|
|
19814
19712
|
JSON.parse(raw);
|
|
19815
19713
|
} catch (error) {
|
|
19816
19714
|
if (!isMissingPathError7(error)) {
|
|
@@ -19908,7 +19806,7 @@ var init_analyst_entry = __esm({
|
|
|
19908
19806
|
});
|
|
19909
19807
|
|
|
19910
19808
|
// src/public-cli/analyst-run.ts
|
|
19911
|
-
import { readFile as
|
|
19809
|
+
import { readFile as readFile21 } from "node:fs/promises";
|
|
19912
19810
|
import { isAbsolute as isAbsolute9, resolve as resolve15 } from "node:path";
|
|
19913
19811
|
import { Value as Value3 } from "typebox/value";
|
|
19914
19812
|
function resolveAnalystIssueBookKeyFromCwd(cwd = process.cwd()) {
|
|
@@ -19962,7 +19860,7 @@ async function buildAnalystSweepModeInputFromAttachmentPaths(attachmentPaths) {
|
|
|
19962
19860
|
const absolute = isAbsolute9(sourcePath) ? sourcePath : resolve15(sourcePath);
|
|
19963
19861
|
let bytes;
|
|
19964
19862
|
try {
|
|
19965
|
-
bytes = await
|
|
19863
|
+
bytes = await readFile21(absolute);
|
|
19966
19864
|
} catch (error) {
|
|
19967
19865
|
throw new CliUsageError(
|
|
19968
19866
|
`analyst sweep attachment is not a readable regular file: ${sourcePath}`,
|
|
@@ -20082,7 +19980,7 @@ __export(cli_exports, {
|
|
|
20082
19980
|
runAkRole: () => runAkRole
|
|
20083
19981
|
});
|
|
20084
19982
|
import { realpath as realpath5 } from "node:fs/promises";
|
|
20085
|
-
import { join as
|
|
19983
|
+
import { join as join37 } from "node:path";
|
|
20086
19984
|
function publicSeatArgv(owner) {
|
|
20087
19985
|
return {
|
|
20088
19986
|
parse: (args) => parsePublicSeatArgv(owner, args),
|
|
@@ -20221,7 +20119,7 @@ function resolveHome(env) {
|
|
|
20221
20119
|
return env.home ?? packageMachineHome();
|
|
20222
20120
|
}
|
|
20223
20121
|
function resolveAgentDir(env, home) {
|
|
20224
|
-
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
20122
|
+
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join37(home, ".pi", "agent");
|
|
20225
20123
|
}
|
|
20226
20124
|
function parseThinking(value) {
|
|
20227
20125
|
return value;
|
|
@@ -20993,7 +20891,7 @@ __export(public_role_summons_exports, {
|
|
|
20993
20891
|
import { execFile as execFile3 } from "node:child_process";
|
|
20994
20892
|
import { existsSync as existsSync10 } from "node:fs";
|
|
20995
20893
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
20996
|
-
import { join as
|
|
20894
|
+
import { join as join38 } from "node:path";
|
|
20997
20895
|
import { promisify as promisify3 } from "node:util";
|
|
20998
20896
|
function createCapturingIo() {
|
|
20999
20897
|
const chunks = [];
|
|
@@ -21017,7 +20915,7 @@ function parentDir(path) {
|
|
|
21017
20915
|
function walkPackageRoot(start) {
|
|
21018
20916
|
let dir = start;
|
|
21019
20917
|
for (let i = 0; i < 12; i += 1) {
|
|
21020
|
-
if (existsSync10(
|
|
20918
|
+
if (existsSync10(join38(dir, "package.json")) && existsSync10(join38(dir, "souls"))) {
|
|
21021
20919
|
return dir;
|
|
21022
20920
|
}
|
|
21023
20921
|
const parent = parentDir(dir);
|
|
@@ -21133,7 +21031,7 @@ async function createSummonEnv(options, afterHost) {
|
|
|
21133
21031
|
async function summonPublicRole(options) {
|
|
21134
21032
|
const packageRoot = resolveSummonsPackageRoot(options.packageRoot);
|
|
21135
21033
|
const home = await resolveSummonHome(options);
|
|
21136
|
-
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
21034
|
+
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join38(home, ".pi", "agent");
|
|
21137
21035
|
const {
|
|
21138
21036
|
loadCredentialProviders: loadCredentialProviders2,
|
|
21139
21037
|
loadPublicCliConfig: loadPublicCliConfig2,
|
|
@@ -21641,7 +21539,7 @@ var init_compliance_transport = __esm({
|
|
|
21641
21539
|
});
|
|
21642
21540
|
|
|
21643
21541
|
// src/role-run-relocation.ts
|
|
21644
|
-
import { join as
|
|
21542
|
+
import { join as join39, sep as sep5 } from "node:path";
|
|
21645
21543
|
function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
|
|
21646
21544
|
if (typeof value !== "string") return value;
|
|
21647
21545
|
if (value === oldRunDirectory) return newRunDirectory;
|
|
@@ -21769,8 +21667,8 @@ __export(run_lifecycle_exports, {
|
|
|
21769
21667
|
renderResumeCommand: () => renderResumeCommand,
|
|
21770
21668
|
writeRoleRunState: () => writeRoleRunState
|
|
21771
21669
|
});
|
|
21772
|
-
import { chmod, lstat as lstat7, open as open3, readdir as readdir7, readFile as
|
|
21773
|
-
import { basename as basename10, join as
|
|
21670
|
+
import { chmod, lstat as lstat7, open as open3, readdir as readdir7, readFile as readFile22, unlink as unlink5, writeFile as writeFile9 } from "node:fs/promises";
|
|
21671
|
+
import { basename as basename10, join as join40 } from "node:path";
|
|
21774
21672
|
function buildAutoResumeContinuationPrompt(options) {
|
|
21775
21673
|
return appendEngineSessionMaterial(
|
|
21776
21674
|
[RESUME_TRANSPORT_ENVELOPE],
|
|
@@ -21795,8 +21693,8 @@ function renderResumeCommand(runId) {
|
|
|
21795
21693
|
}
|
|
21796
21694
|
async function writeRoleRunState(runDirectory, record4) {
|
|
21797
21695
|
const payload = { ...record4, runDirectory };
|
|
21798
|
-
await
|
|
21799
|
-
|
|
21696
|
+
await writeFile9(
|
|
21697
|
+
join40(runDirectory, RUN_STATE_FILE),
|
|
21800
21698
|
`${JSON.stringify(payload, null, 2)}
|
|
21801
21699
|
`,
|
|
21802
21700
|
"utf8"
|
|
@@ -21846,7 +21744,7 @@ function parseCurrentCourtState(raw) {
|
|
|
21846
21744
|
async function readRoleRunStateRaw(runDirectory) {
|
|
21847
21745
|
let raw;
|
|
21848
21746
|
try {
|
|
21849
|
-
raw = JSON.parse(await
|
|
21747
|
+
raw = JSON.parse(await readFile22(join40(runDirectory, RUN_STATE_FILE), "utf8"));
|
|
21850
21748
|
} catch (error) {
|
|
21851
21749
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
21852
21750
|
throw error;
|
|
@@ -21939,8 +21837,8 @@ async function writeRoleRunStateDisk(runDirectory, disk) {
|
|
|
21939
21837
|
...disk.resumable === void 0 ? {} : { resumable: disk.resumable },
|
|
21940
21838
|
...disk.currentCourt === void 0 ? {} : { currentCourt: disk.currentCourt }
|
|
21941
21839
|
};
|
|
21942
|
-
await
|
|
21943
|
-
|
|
21840
|
+
await writeFile9(
|
|
21841
|
+
join40(runDirectory, RUN_STATE_FILE),
|
|
21944
21842
|
`${JSON.stringify(payload, null, 2)}
|
|
21945
21843
|
`,
|
|
21946
21844
|
"utf8"
|
|
@@ -22107,7 +22005,7 @@ function isProcessAlive(pid) {
|
|
|
22107
22005
|
async function autopsyWriterLock(lockPath) {
|
|
22108
22006
|
let content;
|
|
22109
22007
|
try {
|
|
22110
|
-
content = await
|
|
22008
|
+
content = await readFile22(lockPath, "utf8");
|
|
22111
22009
|
} catch (error) {
|
|
22112
22010
|
if (errorCodeOf(error) === "ENOENT") return { verdict: "absent" };
|
|
22113
22011
|
return { verdict: "unknown", reason: "unreadable", readFailure: error };
|
|
@@ -22166,7 +22064,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
|
|
|
22166
22064
|
},
|
|
22167
22065
|
relocate(nextRunDirectory) {
|
|
22168
22066
|
currentRunDirectory = nextRunDirectory;
|
|
22169
|
-
currentLockPath =
|
|
22067
|
+
currentLockPath = join40(nextRunDirectory, WRITER_LOCK_FILE);
|
|
22170
22068
|
},
|
|
22171
22069
|
async release() {
|
|
22172
22070
|
if (released) return;
|
|
@@ -22205,10 +22103,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
22205
22103
|
};
|
|
22206
22104
|
const reportReadFailure = (error) => {
|
|
22207
22105
|
reportDiagnostic(
|
|
22208
|
-
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${
|
|
22106
|
+
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join40(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
|
|
22209
22107
|
);
|
|
22210
22108
|
};
|
|
22211
|
-
const lockPath =
|
|
22109
|
+
const lockPath = join40(runDirectory, WRITER_LOCK_FILE);
|
|
22212
22110
|
let lastAutopsy = { verdict: "absent" };
|
|
22213
22111
|
let lastReclaimFailure;
|
|
22214
22112
|
for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
|
|
@@ -22263,7 +22161,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
22263
22161
|
async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
22264
22162
|
if (runId.trim() === "") return void 0;
|
|
22265
22163
|
const ledgerHome = resolveActivationLedgerHome(home);
|
|
22266
|
-
const booksRoot =
|
|
22164
|
+
const booksRoot = join40(ledgerHome, "books");
|
|
22267
22165
|
let bookKeys;
|
|
22268
22166
|
try {
|
|
22269
22167
|
bookKeys = await readdir7(booksRoot);
|
|
@@ -22304,7 +22202,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
22304
22202
|
let raw;
|
|
22305
22203
|
try {
|
|
22306
22204
|
raw = JSON.parse(
|
|
22307
|
-
await
|
|
22205
|
+
await readFile22(join40(runDirectory, "admitted-request.json"), "utf8")
|
|
22308
22206
|
);
|
|
22309
22207
|
} catch (error) {
|
|
22310
22208
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -22325,7 +22223,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
22325
22223
|
async function runHasFormedSessionPrincipal(runDirectory) {
|
|
22326
22224
|
const disk = await readRoleRunStateDisk(runDirectory);
|
|
22327
22225
|
if (disk === void 0) return false;
|
|
22328
|
-
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile :
|
|
22226
|
+
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : join40(disk.principalWire.sessionDirectory, "session.jsonl");
|
|
22329
22227
|
try {
|
|
22330
22228
|
const stat2 = await lstat7(sessionFile);
|
|
22331
22229
|
return stat2.isFile() && !stat2.isSymbolicLink();
|
|
@@ -22343,7 +22241,7 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
22343
22241
|
let runDirectories;
|
|
22344
22242
|
try {
|
|
22345
22243
|
runDirectories = await listBookRunDirectories(
|
|
22346
|
-
input.ticketNumber === void 0 ? bookDir :
|
|
22244
|
+
input.ticketNumber === void 0 ? bookDir : join40(bookDir, String(input.ticketNumber))
|
|
22347
22245
|
);
|
|
22348
22246
|
} catch (error) {
|
|
22349
22247
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -22470,7 +22368,7 @@ async function loadResumableRunRecord(home, runId, authority, allowUnformedAdmit
|
|
|
22470
22368
|
let sourceRun;
|
|
22471
22369
|
try {
|
|
22472
22370
|
const raw = JSON.parse(
|
|
22473
|
-
await
|
|
22371
|
+
await readFile22(run.admittedRequestPath, "utf8")
|
|
22474
22372
|
);
|
|
22475
22373
|
if (raw !== null && typeof raw === "object" && !Array.isArray(raw)) {
|
|
22476
22374
|
const record4 = raw;
|
|
@@ -22593,7 +22491,7 @@ async function loadResumableRunRecord(home, runId, authority, allowUnformedAdmit
|
|
|
22593
22491
|
let model;
|
|
22594
22492
|
try {
|
|
22595
22493
|
const invocationRaw = JSON.parse(
|
|
22596
|
-
await
|
|
22494
|
+
await readFile22(join40(run.runDirectory, "invocation.json"), "utf8")
|
|
22597
22495
|
);
|
|
22598
22496
|
if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
|
|
22599
22497
|
const rec = invocationRaw;
|
|
@@ -22978,7 +22876,7 @@ var init_run_lifecycle = __esm({
|
|
|
22978
22876
|
|
|
22979
22877
|
// src/archivist-record-topology.ts
|
|
22980
22878
|
import { createHash as createHash6 } from "node:crypto";
|
|
22981
|
-
import { join as
|
|
22879
|
+
import { join as join41 } from "node:path";
|
|
22982
22880
|
function resolveNavigatorWorkSubjectPlacement(input) {
|
|
22983
22881
|
let ledgerHome;
|
|
22984
22882
|
if (input.parentSessionFile !== void 0 && input.parentSessionFile.length > 0) {
|
|
@@ -22991,7 +22889,7 @@ function resolveNavigatorWorkSubjectPlacement(input) {
|
|
|
22991
22889
|
const digest = createHash6("sha256").update(input.subject).digest("hex").slice(0, 32);
|
|
22992
22890
|
return {
|
|
22993
22891
|
ledgerHome,
|
|
22994
|
-
sessionDir:
|
|
22892
|
+
sessionDir: join41(
|
|
22995
22893
|
activationBookDirectory(ledgerHome, resolveBookKeyFromGit(input.cwd)),
|
|
22996
22894
|
NAVIGATOR_RECORD_KIND,
|
|
22997
22895
|
digest
|
|
@@ -23063,10 +22961,10 @@ import {
|
|
|
23063
22961
|
statSync as statSync6,
|
|
23064
22962
|
writeFileSync as writeFileSync2
|
|
23065
22963
|
} from "node:fs";
|
|
23066
|
-
import { dirname as dirname23, resolve as resolve16, join as
|
|
22964
|
+
import { dirname as dirname23, resolve as resolve16, join as join42 } from "node:path";
|
|
23067
22965
|
import { StringDecoder } from "node:string_decoder";
|
|
23068
22966
|
function readCurrentSession(sessionDir) {
|
|
23069
|
-
const ledger =
|
|
22967
|
+
const ledger = join42(sessionDir, CURRENT_SESSION_LEDGER);
|
|
23070
22968
|
try {
|
|
23071
22969
|
const value = JSON.parse(readFileSync4(ledger, "utf8"));
|
|
23072
22970
|
if (typeof value !== "object" || value === null || typeof value.sessionFile !== "string" || value.sessionFile.length === 0) {
|
|
@@ -23081,7 +22979,7 @@ function readCurrentSession(sessionDir) {
|
|
|
23081
22979
|
}
|
|
23082
22980
|
}
|
|
23083
22981
|
function writeCurrentSession(sessionDir, sessionFile) {
|
|
23084
|
-
const ledger =
|
|
22982
|
+
const ledger = join42(sessionDir, CURRENT_SESSION_LEDGER);
|
|
23085
22983
|
try {
|
|
23086
22984
|
writeFileSync2(ledger, `${JSON.stringify({ sessionFile })}
|
|
23087
22985
|
`, { flag: "wx" });
|
|
@@ -23097,7 +22995,7 @@ function isCurrentSessionClaimRace(error) {
|
|
|
23097
22995
|
return errnoCode(error.cause) === "EEXIST";
|
|
23098
22996
|
}
|
|
23099
22997
|
function currentSessionLedgerPath(sessionDir) {
|
|
23100
|
-
return
|
|
22998
|
+
return join42(sessionDir, CURRENT_SESSION_LEDGER);
|
|
23101
22999
|
}
|
|
23102
23000
|
function readBoundedSessionHeader(filePath) {
|
|
23103
23001
|
const fd = openSync2(filePath, "r");
|
|
@@ -23184,7 +23082,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
|
|
|
23184
23082
|
const matched = [];
|
|
23185
23083
|
for (const name of names) {
|
|
23186
23084
|
if (!name.endsWith(".jsonl")) continue;
|
|
23187
|
-
const filePath =
|
|
23085
|
+
const filePath = join42(absoluteSessionDir, name);
|
|
23188
23086
|
let st;
|
|
23189
23087
|
try {
|
|
23190
23088
|
st = statSync6(filePath);
|
|
@@ -23296,7 +23194,7 @@ function createRecordSessionOpen(options, host = piRecordSessionHost) {
|
|
|
23296
23194
|
if (!physicallyContainedIn(ledgerHome, parentResolved)) {
|
|
23297
23195
|
throw new Error("Durable record ownership requires a parent session inside the ledger home");
|
|
23298
23196
|
}
|
|
23299
|
-
sessionDir =
|
|
23197
|
+
sessionDir = join42(dirname23(parentResolved), options.kind);
|
|
23300
23198
|
parentSession = parentFile;
|
|
23301
23199
|
mayResumeSameNest = options.kind === WORKER_SUBMISSION_GATE_KIND;
|
|
23302
23200
|
}
|
|
@@ -23364,8 +23262,8 @@ import { randomUUID as randomUUID11 } from "node:crypto";
|
|
|
23364
23262
|
// src/role-runtime-dependencies.ts
|
|
23365
23263
|
init_collector_github();
|
|
23366
23264
|
init_doctor_evidence();
|
|
23367
|
-
import { readFile as
|
|
23368
|
-
import { join as
|
|
23265
|
+
import { readFile as readFile25 } from "node:fs/promises";
|
|
23266
|
+
import { join as join46 } from "node:path";
|
|
23369
23267
|
|
|
23370
23268
|
// src/navigator-attendance.ts
|
|
23371
23269
|
import { createHash as createHash7 } from "node:crypto";
|
|
@@ -24330,7 +24228,7 @@ function createNavigatorAttendance(options) {
|
|
|
24330
24228
|
// src/navigator-work-context.ts
|
|
24331
24229
|
init_doctor_evidence();
|
|
24332
24230
|
init_host_contracts();
|
|
24333
|
-
import { readFile as
|
|
24231
|
+
import { readFile as readFile23 } from "node:fs/promises";
|
|
24334
24232
|
import { resolve as resolve18 } from "node:path";
|
|
24335
24233
|
init_notary_source_run();
|
|
24336
24234
|
init_packaged_role_registry();
|
|
@@ -24344,7 +24242,7 @@ function navigatorInputReference(getFlag, role) {
|
|
|
24344
24242
|
async function loadNavigatorWorkContext(options) {
|
|
24345
24243
|
const reference = navigatorInputReference(options.getFlag, options.role);
|
|
24346
24244
|
const subjectMode = packagedNavigatorSubject(options.role);
|
|
24347
|
-
const input = reference === void 0 || subjectMode === "case" || subjectMode === "source-run" ? void 0 : await
|
|
24245
|
+
const input = reference === void 0 || subjectMode === "case" || subjectMode === "source-run" ? void 0 : await readFile23(reference, "utf8");
|
|
24348
24246
|
const subjectRoot = subjectPath(reference ?? options.context.sessionManager.getSessionDir(), options.context.cwd);
|
|
24349
24247
|
let subjectKey = reference === void 0 ? subjectRoot : navigatorSubjectKeyForInput(subjectRoot, reference, options.context.cwd);
|
|
24350
24248
|
let subject = input ?? `work subject: ${subjectKey}`;
|
|
@@ -24401,7 +24299,7 @@ async function loadNavigatorWorkContext(options) {
|
|
|
24401
24299
|
let authorityMaterial;
|
|
24402
24300
|
for (const path of authorityFiles) {
|
|
24403
24301
|
try {
|
|
24404
|
-
const content = await
|
|
24302
|
+
const content = await readFile23(path, "utf8");
|
|
24405
24303
|
if (content.trim() !== "") {
|
|
24406
24304
|
authorityMaterial = content;
|
|
24407
24305
|
break;
|
|
@@ -24432,7 +24330,7 @@ init_submission_ledger();
|
|
|
24432
24330
|
init_collector_ledger();
|
|
24433
24331
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
24434
24332
|
import { readFileSync as readFileSync6, writeSync as writeSync2 } from "node:fs";
|
|
24435
|
-
import { join as
|
|
24333
|
+
import { join as join45 } from "node:path";
|
|
24436
24334
|
import { Value as Value4 } from "typebox/value";
|
|
24437
24335
|
|
|
24438
24336
|
// src/activation-trace.ts
|
|
@@ -24755,8 +24653,8 @@ init_collector_github();
|
|
|
24755
24653
|
// src/collector-handbook.ts
|
|
24756
24654
|
init_atomic_write();
|
|
24757
24655
|
init_activation_ledger_topology();
|
|
24758
|
-
import { readFile as
|
|
24759
|
-
import { join as
|
|
24656
|
+
import { readFile as readFile24 } from "node:fs/promises";
|
|
24657
|
+
import { join as join44, sep as sep6 } from "node:path";
|
|
24760
24658
|
|
|
24761
24659
|
// src/collector-tool-schemas.ts
|
|
24762
24660
|
init_open_tool_schema();
|
|
@@ -24871,7 +24769,7 @@ function resolveCollectorHandbookRoot(sessionPath) {
|
|
|
24871
24769
|
throw new Error(`\u901A\u8FDB\u53F8\u624B\u518C\u62D2\u7EDD\u4E0D\u5B89\u5168 bookKey ${JSON.stringify(bookKey)}`);
|
|
24872
24770
|
}
|
|
24873
24771
|
const ledgerHome = resolveActivationLedgerHomeForPath(sessionPath);
|
|
24874
|
-
const root =
|
|
24772
|
+
const root = join44(activationBookDirectory(ledgerHome, bookKey), "collector-handbook");
|
|
24875
24773
|
return { ledgerHome, bookKey, root };
|
|
24876
24774
|
}
|
|
24877
24775
|
function collectorHandbookRepoFileName(repositoryCanonical) {
|
|
@@ -24883,9 +24781,9 @@ function collectorHandbookRepoFileName(repositoryCanonical) {
|
|
|
24883
24781
|
return `${repositoryCanonical.replaceAll("/", "__")}.md`;
|
|
24884
24782
|
}
|
|
24885
24783
|
function createCollectorHandbookStore(input) {
|
|
24886
|
-
const generalPath =
|
|
24887
|
-
const repoDir =
|
|
24888
|
-
const repoPath =
|
|
24784
|
+
const generalPath = join44(input.handbookRoot, "general.md");
|
|
24785
|
+
const repoDir = join44(input.handbookRoot, "repos");
|
|
24786
|
+
const repoPath = join44(repoDir, collectorHandbookRepoFileName(input.repositoryCanonical));
|
|
24889
24787
|
const assertHandbookBudget = (body, label) => {
|
|
24890
24788
|
const byteLength = Buffer.byteLength(body, "utf8");
|
|
24891
24789
|
if (byteLength > COLLECTOR_HANDBOOK_MAX_BYTES) {
|
|
@@ -24899,7 +24797,7 @@ function createCollectorHandbookStore(input) {
|
|
|
24899
24797
|
ensureRealDirectoryTree(input.ledgerHome, parentDir2);
|
|
24900
24798
|
assertLedgerFileInsideHome(path, input.ledgerHome);
|
|
24901
24799
|
try {
|
|
24902
|
-
const body = await
|
|
24800
|
+
const body = await readFile24(path, "utf8");
|
|
24903
24801
|
assertHandbookBudget(body, "\u6B63\u6587");
|
|
24904
24802
|
return body;
|
|
24905
24803
|
} catch (error) {
|
|
@@ -26982,7 +26880,7 @@ function readDiaristTicketAssertion(submitted) {
|
|
|
26982
26880
|
function readRoleRunCoordinates(ctx, label) {
|
|
26983
26881
|
const runDirectory = runDirectoryFromHostContext(ctx);
|
|
26984
26882
|
if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
|
|
26985
|
-
const admittedPath =
|
|
26883
|
+
const admittedPath = join45(runDirectory, "admitted-request.json");
|
|
26986
26884
|
const admitted = JSON.parse(readFileSync6(admittedPath, "utf8"));
|
|
26987
26885
|
if (typeof admitted.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
|
|
26988
26886
|
throw new Error(`${label} admitted-request missing projectRoot (${admittedPath})`);
|
|
@@ -27335,14 +27233,6 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27335
27233
|
}
|
|
27336
27234
|
};
|
|
27337
27235
|
});
|
|
27338
|
-
roleHost.on("before_agent_start", async (_event, ctx) => {
|
|
27339
|
-
const runDir = runDirectoryFromHostContext(ctx);
|
|
27340
|
-
if (runDir === void 0) return;
|
|
27341
|
-
const { loadCaseDossierReadingMaterial: loadCaseDossierReadingMaterial2 } = await Promise.resolve().then(() => (init_case_dossier_delivery(), case_dossier_delivery_exports));
|
|
27342
|
-
const caseDossier = await loadCaseDossierReadingMaterial2(runDir);
|
|
27343
|
-
if (caseDossier === void 0) return;
|
|
27344
|
-
return { readingMaterial: caseDossier };
|
|
27345
|
-
});
|
|
27346
27236
|
roleHost.on("tool_result", async (event) => {
|
|
27347
27237
|
const role = selectedRole;
|
|
27348
27238
|
if (role === void 0) return;
|
|
@@ -27920,19 +27810,19 @@ function loadRegisteredRoleSoul(role) {
|
|
|
27920
27810
|
return usesSubjectSoul(role) ? loadAuditorSoulFromSubjectInput() : loadMainRoleSessionMaterials(role);
|
|
27921
27811
|
}
|
|
27922
27812
|
function createRoleRuntimeDependencies(packageRoot) {
|
|
27923
|
-
const collectorHandbookSeedPath =
|
|
27813
|
+
const collectorHandbookSeedPath = join46(packageRoot, "resources/collector-bot-handbook.md");
|
|
27924
27814
|
const navigatorSessionFactory = createNativeNavigatorSessionFactory();
|
|
27925
27815
|
return {
|
|
27926
27816
|
packageRoot,
|
|
27927
27817
|
loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
|
|
27928
27818
|
loadRoleSoul: loadRegisteredRoleSoul,
|
|
27929
|
-
loadFixPacket: (path) =>
|
|
27930
|
-
loadCoderTask: (path) =>
|
|
27931
|
-
loadCollectorHandbookSeed: () =>
|
|
27819
|
+
loadFixPacket: (path) => readFile25(path, "utf8"),
|
|
27820
|
+
loadCoderTask: (path) => readFile25(path, "utf8"),
|
|
27821
|
+
loadCollectorHandbookSeed: () => readFile25(collectorHandbookSeedPath, "utf8"),
|
|
27932
27822
|
createCollectorTransport: () => createGhCollectorGitHubTransport(),
|
|
27933
27823
|
loadDoctorCase,
|
|
27934
27824
|
loadNotarySourceRun: loadNotarySourceRunLocator,
|
|
27935
|
-
loadMergerInput: async (path) => JSON.parse(await
|
|
27825
|
+
loadMergerInput: async (path) => JSON.parse(await readFile25(path, "utf8")),
|
|
27936
27826
|
loadNavigatorWorkContext: (options) => loadNavigatorWorkContext({
|
|
27937
27827
|
context: options.context,
|
|
27938
27828
|
role: options.role,
|
|
@@ -27957,9 +27847,9 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
27957
27847
|
init_engine_detour();
|
|
27958
27848
|
init_packaged_role_registry();
|
|
27959
27849
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
27960
|
-
import { appendFile as appendFile3, mkdir as mkdir5, writeFile as
|
|
27850
|
+
import { appendFile as appendFile3, mkdir as mkdir5, writeFile as writeFile10 } from "node:fs/promises";
|
|
27961
27851
|
import { createServer } from "node:net";
|
|
27962
|
-
import { dirname as dirname25, join as
|
|
27852
|
+
import { dirname as dirname25, join as join47 } from "node:path";
|
|
27963
27853
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
27964
27854
|
init_role_activation_flags();
|
|
27965
27855
|
init_submission_correctable_error();
|
|
@@ -28005,11 +27895,11 @@ async function prepareRoleEnvelope(options) {
|
|
|
28005
27895
|
const hostAbort = new AbortController();
|
|
28006
27896
|
const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID9();
|
|
28007
27897
|
await mkdir5(request.runDirectory, { recursive: true });
|
|
28008
|
-
let sessionFile = options.sessionFile ??
|
|
27898
|
+
let sessionFile = options.sessionFile ?? join47(request.runDirectory, "session", "session.jsonl");
|
|
28009
27899
|
await mkdir5(dirname25(sessionFile), { recursive: true });
|
|
28010
27900
|
if (request.continuation.kind !== "resume") {
|
|
28011
27901
|
try {
|
|
28012
|
-
await
|
|
27902
|
+
await writeFile10(
|
|
28013
27903
|
sessionFile,
|
|
28014
27904
|
`${JSON.stringify({
|
|
28015
27905
|
type: "session",
|
|
@@ -28525,7 +28415,7 @@ async function prepareRoleEnvelope(options) {
|
|
|
28525
28415
|
init_session_identity();
|
|
28526
28416
|
|
|
28527
28417
|
// src/headless-host/description.ts
|
|
28528
|
-
import { join as
|
|
28418
|
+
import { join as join48 } from "node:path";
|
|
28529
28419
|
function isClaudePrintDescription(description) {
|
|
28530
28420
|
return description.protocol === "claude-print";
|
|
28531
28421
|
}
|
|
@@ -28533,7 +28423,7 @@ function isCodexExecDescription(description) {
|
|
|
28533
28423
|
return description.protocol === "codex-exec";
|
|
28534
28424
|
}
|
|
28535
28425
|
function resolveHeadlessBinary(description, operatorHome) {
|
|
28536
|
-
return
|
|
28426
|
+
return join48(operatorHome, ...description.binaryFromHome);
|
|
28537
28427
|
}
|
|
28538
28428
|
function headlessTurnArgs(options) {
|
|
28539
28429
|
const { description } = options;
|
|
@@ -28796,8 +28686,8 @@ function headlessMcpConfigDocument(mcpServers) {
|
|
|
28796
28686
|
import { spawn as spawn4, spawnSync as spawnSync3 } from "node:child_process";
|
|
28797
28687
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
28798
28688
|
import { existsSync as existsSync15 } from "node:fs";
|
|
28799
|
-
import { writeFile as
|
|
28800
|
-
import { dirname as dirname26, isAbsolute as isAbsolute12, join as
|
|
28689
|
+
import { writeFile as writeFile11 } from "node:fs/promises";
|
|
28690
|
+
import { dirname as dirname26, isAbsolute as isAbsolute12, join as join49, resolve as resolve21 } from "node:path";
|
|
28801
28691
|
|
|
28802
28692
|
// src/external-host-turn-loop.ts
|
|
28803
28693
|
var EXTERNAL_ROLE_TURN_ROUND_LIMIT = 8;
|
|
@@ -28983,7 +28873,7 @@ function formatCodexFailurePayload(payload) {
|
|
|
28983
28873
|
function cwdIsGitWorkTree(cwd) {
|
|
28984
28874
|
let dir = cwd;
|
|
28985
28875
|
for (; ; ) {
|
|
28986
|
-
if (existsSync15(
|
|
28876
|
+
if (existsSync15(join49(dir, ".git"))) return true;
|
|
28987
28877
|
const parent = dirname26(dir);
|
|
28988
28878
|
if (parent === dir) return false;
|
|
28989
28879
|
dir = parent;
|
|
@@ -29199,14 +29089,14 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
29199
29089
|
await config.sessionIdentity.bind(request.principal, sessionId);
|
|
29200
29090
|
}
|
|
29201
29091
|
const env = { ...process.env, ...config.env ?? {} };
|
|
29202
|
-
const systemPromptPath =
|
|
29203
|
-
await
|
|
29092
|
+
const systemPromptPath = join49(request.runDirectory, "headless-system-prompt.txt");
|
|
29093
|
+
await writeFile11(systemPromptPath, systemPrompt, "utf8");
|
|
29204
29094
|
let mcpConfigPath;
|
|
29205
29095
|
let outputSchemaPath;
|
|
29206
29096
|
if (codex) {
|
|
29207
29097
|
if (prepared.terminatingToolName !== NAVIGATOR_OUTPUT_TOOL_NAME) {
|
|
29208
|
-
outputSchemaPath =
|
|
29209
|
-
await
|
|
29098
|
+
outputSchemaPath = join49(request.runDirectory, "headless-output-schema.json");
|
|
29099
|
+
await writeFile11(
|
|
29210
29100
|
outputSchemaPath,
|
|
29211
29101
|
`${JSON.stringify(closeJsonSchemaForCodex(prepared.jsonSchema), null, 2)}
|
|
29212
29102
|
`,
|
|
@@ -29214,8 +29104,8 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
29214
29104
|
);
|
|
29215
29105
|
}
|
|
29216
29106
|
} else {
|
|
29217
|
-
mcpConfigPath =
|
|
29218
|
-
await
|
|
29107
|
+
mcpConfigPath = join49(request.runDirectory, "headless-mcp-config.json");
|
|
29108
|
+
await writeFile11(
|
|
29219
29109
|
mcpConfigPath,
|
|
29220
29110
|
`${JSON.stringify(headlessMcpConfigDocument(prepared.mcpServers), null, 2)}
|
|
29221
29111
|
`,
|
|
@@ -29478,7 +29368,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
29478
29368
|
host: config.hostName,
|
|
29479
29369
|
sessionId: exitedSessionId,
|
|
29480
29370
|
cwd: request.cwd,
|
|
29481
|
-
sessionDirectory:
|
|
29371
|
+
sessionDirectory: join49(request.runDirectory, "session"),
|
|
29482
29372
|
sessionParent,
|
|
29483
29373
|
continuation: request.continuation,
|
|
29484
29374
|
...request.model !== void 0 ? { model: request.model } : {},
|