@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
|
@@ -4279,14 +4279,6 @@ function resolveSitianRecordPathInLedger(input, ledgerHome) {
|
|
|
4279
4279
|
}
|
|
4280
4280
|
return { sessionDir, recordFile, ledgerHome };
|
|
4281
4281
|
}
|
|
4282
|
-
function projectTicketRecordsPathShape() {
|
|
4283
|
-
const { recordFile } = ticketProvenanceUnderBookPaths(
|
|
4284
|
-
join4("~", ".ak-roles"),
|
|
4285
|
-
"<\u7C3F>",
|
|
4286
|
-
"<\u7968\u53F7>"
|
|
4287
|
-
);
|
|
4288
|
-
return recordFile.replace(/\\/g, "/");
|
|
4289
|
-
}
|
|
4290
4282
|
function resolveSitianRecordPath(input) {
|
|
4291
4283
|
const ledgerHome = input.home !== void 0 && input.home.length > 0 ? resolveActivationLedgerHome(input.home) : resolveActivationLedgerHomeForPath(input.runDirectory ?? input.sessionParent);
|
|
4292
4284
|
return resolveSitianRecordPathInLedger(input, ledgerHome);
|
|
@@ -5111,10 +5103,10 @@ __export(session_assistant_usage_exports, {
|
|
|
5111
5103
|
});
|
|
5112
5104
|
import { join as join9 } from "node:path";
|
|
5113
5105
|
async function readAssistantUsageFromSessionFile(sessionFile) {
|
|
5114
|
-
const { readFile:
|
|
5106
|
+
const { readFile: readFile26 } = await import("node:fs/promises");
|
|
5115
5107
|
let text;
|
|
5116
5108
|
try {
|
|
5117
|
-
text = await
|
|
5109
|
+
text = await readFile26(sessionFile, "utf8");
|
|
5118
5110
|
} catch (error) {
|
|
5119
5111
|
if (error?.code === "ENOENT") return void 0;
|
|
5120
5112
|
throw error;
|
|
@@ -6675,12 +6667,6 @@ function ticketProvenanceRecordInput(ticketNumber, cwd, home, runDirectory) {
|
|
|
6675
6667
|
...home === void 0 ? {} : { home }
|
|
6676
6668
|
};
|
|
6677
6669
|
}
|
|
6678
|
-
function resolveTicketProvenanceVolume(ticketNumber, cwd, home) {
|
|
6679
|
-
const path = resolveSitianRecordPath(
|
|
6680
|
-
ticketProvenanceRecordInput(ticketNumber, cwd, home)
|
|
6681
|
-
);
|
|
6682
|
-
return { recordFile: path.recordFile, volumeDir: path.sessionDir };
|
|
6683
|
-
}
|
|
6684
6670
|
async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, home) {
|
|
6685
6671
|
const source = join13(runDirectory, "records.jsonl");
|
|
6686
6672
|
let content;
|
|
@@ -10985,10 +10971,10 @@ function pairGateRounds(volumes) {
|
|
|
10985
10971
|
return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
|
|
10986
10972
|
}
|
|
10987
10973
|
async function resolveOfficerSessionFromPointerFile(pointerPath) {
|
|
10988
|
-
const { readFile:
|
|
10974
|
+
const { readFile: readFile26 } = await import("node:fs/promises");
|
|
10989
10975
|
let raw;
|
|
10990
10976
|
try {
|
|
10991
|
-
raw = JSON.parse(await
|
|
10977
|
+
raw = JSON.parse(await readFile26(pointerPath, "utf8"));
|
|
10992
10978
|
} catch (error) {
|
|
10993
10979
|
throw new Error(
|
|
10994
10980
|
`direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -14240,87 +14226,6 @@ var init_session_identity = __esm({
|
|
|
14240
14226
|
}
|
|
14241
14227
|
});
|
|
14242
14228
|
|
|
14243
|
-
// src/public-cli/case-dossier-delivery.ts
|
|
14244
|
-
var case_dossier_delivery_exports = {};
|
|
14245
|
-
__export(case_dossier_delivery_exports, {
|
|
14246
|
-
deliverCaseDossierAsAttachment: () => deliverCaseDossierAsAttachment,
|
|
14247
|
-
loadCaseDossierReadingMaterial: () => loadCaseDossierReadingMaterial,
|
|
14248
|
-
projectCaseDossierPointerSection: () => projectCaseDossierPointerSection
|
|
14249
|
-
});
|
|
14250
|
-
import { mkdtemp as mkdtemp3, readFile as readFile17, rm as rm4, writeFile as writeFile7 } from "node:fs/promises";
|
|
14251
|
-
import { tmpdir as tmpdir3 } from "node:os";
|
|
14252
|
-
import { join as join27 } from "node:path";
|
|
14253
|
-
async function projectCaseDossierPointerSection(input) {
|
|
14254
|
-
if (input.ticketNumber === void 0) {
|
|
14255
|
-
return [
|
|
14256
|
-
UNBOUND_DOSSIER_PATH_HEADING,
|
|
14257
|
-
"",
|
|
14258
|
-
`\u8BB0\u5F55\u5377\u5B97\uFF1A${projectTicketRecordsPathShape()}`
|
|
14259
|
-
].join("\n");
|
|
14260
|
-
}
|
|
14261
|
-
const volume = resolveTicketProvenanceVolume(
|
|
14262
|
-
input.ticketNumber,
|
|
14263
|
-
input.projectRoot,
|
|
14264
|
-
input.home
|
|
14265
|
-
);
|
|
14266
|
-
return [
|
|
14267
|
-
CASE_DOSSIER_SECTION_HEADING,
|
|
14268
|
-
"",
|
|
14269
|
-
`\u7968\u53F7\uFF1A#${input.ticketNumber}`,
|
|
14270
|
-
`\u8BB0\u5F55\u5377\u5B97\uFF1A${volume.recordFile}`
|
|
14271
|
-
].join("\n");
|
|
14272
|
-
}
|
|
14273
|
-
async function deliverCaseDossierAsAttachment(input) {
|
|
14274
|
-
const section = await projectCaseDossierPointerSection({
|
|
14275
|
-
ticketNumber: input.ticketNumber,
|
|
14276
|
-
projectRoot: input.projectRoot,
|
|
14277
|
-
home: input.home
|
|
14278
|
-
});
|
|
14279
|
-
const stagingDir = await mkdtemp3(join27(tmpdir3(), "ak-case-dossier-"));
|
|
14280
|
-
try {
|
|
14281
|
-
const stagingPath = join27(stagingDir, CASE_DOSSIER_ATTACH_FILE);
|
|
14282
|
-
await writeFile7(stagingPath, `${section}
|
|
14283
|
-
`, "utf8");
|
|
14284
|
-
return await freezeAttachmentsIntoRun(
|
|
14285
|
-
[stagingPath],
|
|
14286
|
-
input.runDirectory,
|
|
14287
|
-
CASE_DOSSIER_ATTACH_KEY
|
|
14288
|
-
);
|
|
14289
|
-
} finally {
|
|
14290
|
-
await rm4(stagingDir, { recursive: true, force: true });
|
|
14291
|
-
}
|
|
14292
|
-
}
|
|
14293
|
-
async function loadCaseDossierReadingMaterial(runDirectory) {
|
|
14294
|
-
const frozenPath = join27(
|
|
14295
|
-
runDirectory,
|
|
14296
|
-
"attachments",
|
|
14297
|
-
CASE_DOSSIER_ATTACH_KEY,
|
|
14298
|
-
`00-${CASE_DOSSIER_ATTACH_FILE}`
|
|
14299
|
-
);
|
|
14300
|
-
let section;
|
|
14301
|
-
try {
|
|
14302
|
-
section = await readFile17(frozenPath, "utf8");
|
|
14303
|
-
} catch (error) {
|
|
14304
|
-
if (error.code === "ENOENT") return void 0;
|
|
14305
|
-
throw error;
|
|
14306
|
-
}
|
|
14307
|
-
if (section.trim() === "") return void 0;
|
|
14308
|
-
return { kind: "case-dossier-pointer", frozenPath, section };
|
|
14309
|
-
}
|
|
14310
|
-
var CASE_DOSSIER_SECTION_HEADING, UNBOUND_DOSSIER_PATH_HEADING, CASE_DOSSIER_ATTACH_KEY, CASE_DOSSIER_ATTACH_FILE;
|
|
14311
|
-
var init_case_dossier_delivery = __esm({
|
|
14312
|
-
"src/public-cli/case-dossier-delivery.ts"() {
|
|
14313
|
-
"use strict";
|
|
14314
|
-
init_sitian_facade();
|
|
14315
|
-
init_ticket_provenance();
|
|
14316
|
-
init_invocation();
|
|
14317
|
-
CASE_DOSSIER_SECTION_HEADING = "## \u672C\u7968\u8D77\u5C45\u5F55\uFF08\u7CFB\u7EDF\u968F\u6848\u63D0\u4F9B\uFF09";
|
|
14318
|
-
UNBOUND_DOSSIER_PATH_HEADING = "## \u8D77\u5C45\u5F55\u8DEF\u5F84\uFF08\u7CFB\u7EDF\u968F\u6848\u63D0\u4F9B\uFF09";
|
|
14319
|
-
CASE_DOSSIER_ATTACH_KEY = "case-dossier";
|
|
14320
|
-
CASE_DOSSIER_ATTACH_FILE = "case-dossier-pointer.md";
|
|
14321
|
-
}
|
|
14322
|
-
});
|
|
14323
|
-
|
|
14324
14229
|
// src/public-cli/process-cancel.ts
|
|
14325
14230
|
function processCancelSignalName(signal) {
|
|
14326
14231
|
if (signal === void 0 || signal.aborted !== true) return void 0;
|
|
@@ -14354,7 +14259,7 @@ import {
|
|
|
14354
14259
|
statSync as statSync3
|
|
14355
14260
|
} from "node:fs";
|
|
14356
14261
|
import { homedir } from "node:os";
|
|
14357
|
-
import { dirname as dirname17, join as
|
|
14262
|
+
import { dirname as dirname17, join as join27 } from "node:path";
|
|
14358
14263
|
function declareHostSessionFailure(error) {
|
|
14359
14264
|
const message = error instanceof Error ? error.stack || error.message : String(error);
|
|
14360
14265
|
process.stderr.write(`[host-session] Dossier record failure: ${message}
|
|
@@ -14379,7 +14284,7 @@ function findCodexRollout(sessionsDir, sessionId) {
|
|
|
14379
14284
|
return;
|
|
14380
14285
|
}
|
|
14381
14286
|
for (const entry of entries) {
|
|
14382
|
-
const fullPath =
|
|
14287
|
+
const fullPath = join27(dir, entry.name);
|
|
14383
14288
|
if (entry.isDirectory()) {
|
|
14384
14289
|
scan(fullPath, depth + 1);
|
|
14385
14290
|
} else if (entry.isFile() && entry.name.endsWith(".jsonl") && entry.name.includes(sessionId)) {
|
|
@@ -14403,25 +14308,25 @@ function sanitizeClaudeCwd(cwd) {
|
|
|
14403
14308
|
function resolveNativeSessionPath(options) {
|
|
14404
14309
|
const home = options.home || homedir();
|
|
14405
14310
|
if (options.host === "claude") {
|
|
14406
|
-
const configDir = process.env.CLAUDE_CONFIG_DIR ||
|
|
14311
|
+
const configDir = process.env.CLAUDE_CONFIG_DIR || join27(home, ".claude");
|
|
14407
14312
|
const sanitizedCwd = sanitizeClaudeCwd(options.cwd);
|
|
14408
|
-
return
|
|
14313
|
+
return join27(configDir, "projects", sanitizedCwd, `${options.sessionId}.jsonl`);
|
|
14409
14314
|
}
|
|
14410
14315
|
if (options.host === "codex") {
|
|
14411
14316
|
return findCodexRollout(codexSessionsDirectory(home), options.sessionId);
|
|
14412
14317
|
}
|
|
14413
14318
|
if (options.host === "grok-build") {
|
|
14414
|
-
const grokHome = process.env.GROK_HOME ||
|
|
14415
|
-
return
|
|
14319
|
+
const grokHome = process.env.GROK_HOME || join27(home, ".grok");
|
|
14320
|
+
return join27(grokHome, "sessions", encodeURIComponent(options.cwd), options.sessionId);
|
|
14416
14321
|
}
|
|
14417
14322
|
return void 0;
|
|
14418
14323
|
}
|
|
14419
14324
|
function codexSessionsDirectory(home) {
|
|
14420
|
-
return
|
|
14325
|
+
return join27(process.env.CODEX_HOME || join27(home || homedir(), ".codex"), "sessions");
|
|
14421
14326
|
}
|
|
14422
14327
|
function recordRunStart(runDirectory) {
|
|
14423
14328
|
try {
|
|
14424
|
-
appendFileSync2(
|
|
14329
|
+
appendFileSync2(join27(runDirectory, ".run-starts"), "\n");
|
|
14425
14330
|
} catch (error) {
|
|
14426
14331
|
declareHostSessionFailure(error);
|
|
14427
14332
|
}
|
|
@@ -14445,12 +14350,12 @@ function resolveHostDossierLandingPath(options) {
|
|
|
14445
14350
|
} catch {
|
|
14446
14351
|
}
|
|
14447
14352
|
}
|
|
14448
|
-
const startsPath =
|
|
14353
|
+
const startsPath = join27(dirname17(options.sessionDirectory), ".run-starts");
|
|
14449
14354
|
let starts = 0;
|
|
14450
14355
|
if (existsSync8(startsPath)) starts = readFileSync3(startsPath, "utf8").length;
|
|
14451
14356
|
const ordinal = Math.max(maxOrdinal + 1, starts, options.continuation.kind === "resume" ? 2 : 1);
|
|
14452
14357
|
const baseName = `${options.host}-${sanitizedModel}-${ordinal}`;
|
|
14453
|
-
const landingPath = options.host === "grok-build" ?
|
|
14358
|
+
const landingPath = options.host === "grok-build" ? join27(options.sessionDirectory, baseName) : join27(options.sessionDirectory, `${baseName}.jsonl`);
|
|
14454
14359
|
return { landingPath, ordinal, sanitizedModel };
|
|
14455
14360
|
}
|
|
14456
14361
|
function recordNativeSessionPointer(options) {
|
|
@@ -14483,18 +14388,18 @@ function copyFileCloneOrFallback(src, dest) {
|
|
|
14483
14388
|
copyFileSync(src, dest);
|
|
14484
14389
|
}
|
|
14485
14390
|
function copyGrokDossier(srcDir, destDir) {
|
|
14486
|
-
const chatHistorySrc =
|
|
14391
|
+
const chatHistorySrc = join27(srcDir, "chat_history.jsonl");
|
|
14487
14392
|
if (!existsSync8(chatHistorySrc)) {
|
|
14488
14393
|
throw new Error(`Grok native chat_history.jsonl missing at ${chatHistorySrc}`);
|
|
14489
14394
|
}
|
|
14490
14395
|
mkdirSync3(destDir, { recursive: true });
|
|
14491
|
-
const chatHistoryDest =
|
|
14396
|
+
const chatHistoryDest = join27(destDir, "chat_history.jsonl");
|
|
14492
14397
|
copyFileCloneOrFallback(chatHistorySrc, chatHistoryDest);
|
|
14493
|
-
const usageSrc =
|
|
14398
|
+
const usageSrc = join27(srcDir, "usage.json");
|
|
14494
14399
|
if (!existsSync8(usageSrc)) {
|
|
14495
14400
|
throw new Error(`Grok native usage.json missing at ${usageSrc}`);
|
|
14496
14401
|
}
|
|
14497
|
-
copyFileCloneOrFallback(usageSrc,
|
|
14402
|
+
copyFileCloneOrFallback(usageSrc, join27(destDir, "usage.json"));
|
|
14498
14403
|
}
|
|
14499
14404
|
function copyAndRecordHostDossier(options) {
|
|
14500
14405
|
if (options.host === "pi" || options.host === "hermes") {
|
|
@@ -14569,7 +14474,7 @@ function copyAndRecordHostDossier(options) {
|
|
|
14569
14474
|
}
|
|
14570
14475
|
try {
|
|
14571
14476
|
mkdirSync3(options.sessionDirectory, { recursive: true });
|
|
14572
|
-
closeSync(openSync(
|
|
14477
|
+
closeSync(openSync(join27(options.sessionDirectory, `${options.host}-${sanitizedModel}-${ordinal}.failed`), "a"));
|
|
14573
14478
|
} catch {
|
|
14574
14479
|
}
|
|
14575
14480
|
sitianReportSafe({
|
|
@@ -14603,7 +14508,7 @@ var init_host_session_record = __esm({
|
|
|
14603
14508
|
import { constants as fsConstants2 } from "node:fs";
|
|
14604
14509
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
14605
14510
|
import { lstat as lstat5, mkdir as mkdir3, open } from "node:fs/promises";
|
|
14606
|
-
import { join as
|
|
14511
|
+
import { join as join28 } from "node:path";
|
|
14607
14512
|
async function persistReturnedRunState(admitted, authority, options) {
|
|
14608
14513
|
if (options?.lawful === true) {
|
|
14609
14514
|
await markRunTerminal(admitted.runDirectory);
|
|
@@ -14674,7 +14579,7 @@ function jsonSafeReplacer() {
|
|
|
14674
14579
|
};
|
|
14675
14580
|
}
|
|
14676
14581
|
async function writeHardenedArtifactFile(artifactsDir, namePrefix, payload) {
|
|
14677
|
-
const filePath =
|
|
14582
|
+
const filePath = join28(artifactsDir, `${namePrefix}-${randomUUID5()}.json`);
|
|
14678
14583
|
const body = `${JSON.stringify(payload, jsonSafeReplacer(), 2)}
|
|
14679
14584
|
`;
|
|
14680
14585
|
const noFollowFlag = typeof fsConstants2.O_NOFOLLOW === "number" ? fsConstants2.O_NOFOLLOW : 0;
|
|
@@ -14962,8 +14867,8 @@ var init_auto_resume = __esm({
|
|
|
14962
14867
|
|
|
14963
14868
|
// src/public-cli/post-admission.ts
|
|
14964
14869
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
14965
|
-
import { writeFile as
|
|
14966
|
-
import { isAbsolute as isAbsolute7, join as
|
|
14870
|
+
import { writeFile as writeFile7 } from "node:fs/promises";
|
|
14871
|
+
import { isAbsolute as isAbsolute7, join as join29, resolve as resolve12 } from "node:path";
|
|
14967
14872
|
function describeCaughtError(error) {
|
|
14968
14873
|
if (error instanceof Error) {
|
|
14969
14874
|
const code = error.code;
|
|
@@ -15058,8 +14963,8 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
15058
14963
|
} catch (appendError) {
|
|
15059
14964
|
try {
|
|
15060
14965
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
15061
|
-
await
|
|
15062
|
-
|
|
14966
|
+
await writeFile7(
|
|
14967
|
+
join29(artifactsDir, `post-admission-diagnostic-${randomUUID6()}.json`),
|
|
15063
14968
|
`${JSON.stringify({ version: 1, ...payload }, null, 2)}
|
|
15064
14969
|
`,
|
|
15065
14970
|
{ encoding: "utf8", flag: "wx" }
|
|
@@ -15205,7 +15110,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
15205
15110
|
const rows = await readRecordedSubmissionRows(
|
|
15206
15111
|
admitted.projectRoot,
|
|
15207
15112
|
admitted.runId,
|
|
15208
|
-
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent:
|
|
15113
|
+
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent: join29(admitted.runDirectory, "session", "session.jsonl") }
|
|
15209
15114
|
);
|
|
15210
15115
|
let ticketNumber;
|
|
15211
15116
|
for (const row of rows) {
|
|
@@ -15299,12 +15204,6 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
15299
15204
|
if (typeof env.host === "string" && env.host.trim() !== "") {
|
|
15300
15205
|
turnRequest = { ...turnRequest, host: env.host.trim() };
|
|
15301
15206
|
}
|
|
15302
|
-
await deliverCaseDossierAsAttachment({
|
|
15303
|
-
ticketNumber: admitted.ticketNumber,
|
|
15304
|
-
projectRoot: admitted.projectRoot,
|
|
15305
|
-
home: env.home,
|
|
15306
|
-
runDirectory: admitted.runDirectory
|
|
15307
|
-
});
|
|
15308
15207
|
await markRunRunning(
|
|
15309
15208
|
admitted.runDirectory,
|
|
15310
15209
|
env.model,
|
|
@@ -15340,8 +15239,8 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
15340
15239
|
}
|
|
15341
15240
|
let stderrLogWriteFailure;
|
|
15342
15241
|
try {
|
|
15343
|
-
await
|
|
15344
|
-
|
|
15242
|
+
await writeFile7(
|
|
15243
|
+
join29(admitted.runDirectory, "stderr.log"),
|
|
15345
15244
|
result.stderr,
|
|
15346
15245
|
"utf8"
|
|
15347
15246
|
);
|
|
@@ -15620,7 +15519,7 @@ async function dispatchAfterWriterLease(input) {
|
|
|
15620
15519
|
}
|
|
15621
15520
|
function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
|
|
15622
15521
|
const absolute = isAbsolute7(attachmentPath) ? attachmentPath : resolve12(attachmentPath);
|
|
15623
|
-
return pathContainedIn(
|
|
15522
|
+
return pathContainedIn(join29(runDirectory, "attachments"), absolute);
|
|
15624
15523
|
}
|
|
15625
15524
|
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
15626
15525
|
if (summons === void 0) return void 0;
|
|
@@ -15879,8 +15778,8 @@ async function presentResumeFailurePointer(io, thrown, publish) {
|
|
|
15879
15778
|
}
|
|
15880
15779
|
async function writeResumeDiagnosticFile(runDirectory, runId, failure2, role) {
|
|
15881
15780
|
const dir = await ensureRealArtifactsDirectory(runDirectory);
|
|
15882
|
-
const path =
|
|
15883
|
-
await
|
|
15781
|
+
const path = join29(dir, `resume-diagnostic-${randomUUID6()}.json`);
|
|
15782
|
+
await writeFile7(
|
|
15884
15783
|
path,
|
|
15885
15784
|
`${JSON.stringify({
|
|
15886
15785
|
runId,
|
|
@@ -16012,7 +15911,6 @@ var init_post_admission = __esm({
|
|
|
16012
15911
|
init_session_identity();
|
|
16013
15912
|
init_role_run_relocation();
|
|
16014
15913
|
init_packaged_role_registry();
|
|
16015
|
-
init_case_dossier_delivery();
|
|
16016
15914
|
init_engine_detour_usage();
|
|
16017
15915
|
init_run_lifecycle();
|
|
16018
15916
|
init_process_cancel();
|
|
@@ -16053,16 +15951,16 @@ var init_seat_ticket_binding = __esm({
|
|
|
16053
15951
|
// src/public-cli/machine-method-skills.ts
|
|
16054
15952
|
import { accessSync, constants as constants2, statSync as statSync4 } from "node:fs";
|
|
16055
15953
|
import { lstat as lstat6, mkdir as mkdir4, symlink } from "node:fs/promises";
|
|
16056
|
-
import { join as
|
|
15954
|
+
import { join as join30 } from "node:path";
|
|
16057
15955
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
16058
15956
|
function skillRoot(home) {
|
|
16059
|
-
return
|
|
15957
|
+
return join30(home, ".agents/skills");
|
|
16060
15958
|
}
|
|
16061
15959
|
function installedMethodSkillPath(home, name) {
|
|
16062
15960
|
return installedSkillPath(skillRoot(home), name);
|
|
16063
15961
|
}
|
|
16064
15962
|
function installedSkillPath(root, name) {
|
|
16065
|
-
const path =
|
|
15963
|
+
const path = join30(root, name, "SKILL.md");
|
|
16066
15964
|
try {
|
|
16067
15965
|
if (!statSync4(path).isFile()) return void 0;
|
|
16068
15966
|
accessSync(path, constants2.R_OK);
|
|
@@ -16075,9 +15973,9 @@ function installedSkillPath(root, name) {
|
|
|
16075
15973
|
}
|
|
16076
15974
|
function linkedSkillRoot(home, host) {
|
|
16077
15975
|
if (host === "claude" || host === "claude-code") {
|
|
16078
|
-
return
|
|
15976
|
+
return join30(process.env.CLAUDE_CONFIG_DIR?.trim() || join30(home, ".claude"), "skills");
|
|
16079
15977
|
}
|
|
16080
|
-
if (host === "hermes") return
|
|
15978
|
+
if (host === "hermes") return join30(home, ".hermes/skills");
|
|
16081
15979
|
return void 0;
|
|
16082
15980
|
}
|
|
16083
15981
|
async function occupied(path) {
|
|
@@ -16134,7 +16032,7 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
16134
16032
|
const missingBySource = /* @__PURE__ */ new Map();
|
|
16135
16033
|
let unsourced = false;
|
|
16136
16034
|
for (const name of packagedMethodSkillNames()) {
|
|
16137
|
-
const path =
|
|
16035
|
+
const path = join30(canonical, name);
|
|
16138
16036
|
if (await occupied(path)) {
|
|
16139
16037
|
warnOccupied(path, stdout);
|
|
16140
16038
|
continue;
|
|
@@ -16158,15 +16056,15 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
16158
16056
|
const root = linkedSkillRoot(home, host);
|
|
16159
16057
|
const binaryFromHome = host === "claude-code" ? HEADLESS_HOST_DESCRIPTIONS.claude.binaryFromHome : HOST_DESCRIPTIONS.hermes.binaryFromHome;
|
|
16160
16058
|
try {
|
|
16161
|
-
accessSync(
|
|
16059
|
+
accessSync(join30(home, ...binaryFromHome), constants2.X_OK);
|
|
16162
16060
|
} catch (error) {
|
|
16163
16061
|
if (["ENOENT", "ENOTDIR", "EACCES"].includes(error.code ?? "")) continue;
|
|
16164
16062
|
throw error;
|
|
16165
16063
|
}
|
|
16166
16064
|
for (const name of packagedMethodSkillNames()) {
|
|
16167
|
-
const target =
|
|
16065
|
+
const target = join30(canonical, name);
|
|
16168
16066
|
if (installedMethodSkillPath(home, name) === void 0) continue;
|
|
16169
|
-
const link =
|
|
16067
|
+
const link = join30(root, name);
|
|
16170
16068
|
if (await occupied(link)) {
|
|
16171
16069
|
warnOccupied(link, stdout);
|
|
16172
16070
|
continue;
|
|
@@ -17546,16 +17444,16 @@ var init_analyst_book_key = __esm({
|
|
|
17546
17444
|
|
|
17547
17445
|
// src/atomic-write.ts
|
|
17548
17446
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
17549
|
-
import { rename as rename3, rm as
|
|
17550
|
-
import { dirname as dirname19, join as
|
|
17447
|
+
import { rename as rename3, rm as rm4, writeFile as writeFile8 } from "node:fs/promises";
|
|
17448
|
+
import { dirname as dirname19, join as join31 } from "node:path";
|
|
17551
17449
|
async function writeFileAtomically(destination, contents) {
|
|
17552
17450
|
const parent = dirname19(destination);
|
|
17553
|
-
const temporary =
|
|
17451
|
+
const temporary = join31(parent, `.atomic-write-${randomUUID7()}.tmp`);
|
|
17554
17452
|
try {
|
|
17555
|
-
await
|
|
17453
|
+
await writeFile8(temporary, contents);
|
|
17556
17454
|
await rename3(temporary, destination);
|
|
17557
17455
|
} catch (error) {
|
|
17558
|
-
await
|
|
17456
|
+
await rm4(temporary, { force: true }).catch(() => void 0);
|
|
17559
17457
|
throw error;
|
|
17560
17458
|
}
|
|
17561
17459
|
}
|
|
@@ -17566,8 +17464,8 @@ var init_atomic_write = __esm({
|
|
|
17566
17464
|
});
|
|
17567
17465
|
|
|
17568
17466
|
// src/analyst-index.ts
|
|
17569
|
-
import { open as open2, readFile as
|
|
17570
|
-
import { dirname as dirname20, join as
|
|
17467
|
+
import { open as open2, readFile as readFile17, unlink as unlink4 } from "node:fs/promises";
|
|
17468
|
+
import { dirname as dirname20, join as join32 } from "node:path";
|
|
17571
17469
|
function sleep(ms) {
|
|
17572
17470
|
return new Promise((resolve22) => {
|
|
17573
17471
|
setTimeout(resolve22, ms);
|
|
@@ -17576,7 +17474,7 @@ function sleep(ms) {
|
|
|
17576
17474
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
17577
17475
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
17578
17476
|
ensureRealDirectoryTree(ledgerHome, dirname20(indexPath));
|
|
17579
|
-
const lockPath =
|
|
17477
|
+
const lockPath = join32(dirname20(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
17580
17478
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
17581
17479
|
const startedAt = Date.now();
|
|
17582
17480
|
while (true) {
|
|
@@ -17603,7 +17501,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
17603
17501
|
}
|
|
17604
17502
|
}
|
|
17605
17503
|
function analystLibraryIndexPath(ledgerHome) {
|
|
17606
|
-
return
|
|
17504
|
+
return join32(ledgerHome, "analyst", "library-index.json");
|
|
17607
17505
|
}
|
|
17608
17506
|
function rowFromIssueMetricsPage(page) {
|
|
17609
17507
|
return {
|
|
@@ -17694,7 +17592,7 @@ async function readAnalystLibraryIndexPage(ledgerHome) {
|
|
|
17694
17592
|
const path = analystLibraryIndexPath(ledgerHome);
|
|
17695
17593
|
let raw;
|
|
17696
17594
|
try {
|
|
17697
|
-
raw = await
|
|
17595
|
+
raw = await readFile17(path, "utf8");
|
|
17698
17596
|
} catch (error) {
|
|
17699
17597
|
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR")) {
|
|
17700
17598
|
return void 0;
|
|
@@ -17898,8 +17796,8 @@ var init_analyst_cohort = __esm({
|
|
|
17898
17796
|
});
|
|
17899
17797
|
|
|
17900
17798
|
// src/analyst-ledger.ts
|
|
17901
|
-
import { readdir as readdir6, readFile as
|
|
17902
|
-
import { basename as basename8, join as
|
|
17799
|
+
import { readdir as readdir6, readFile as readFile18 } from "node:fs/promises";
|
|
17800
|
+
import { basename as basename8, join as join33 } from "node:path";
|
|
17903
17801
|
function isMissingPathError6(error) {
|
|
17904
17802
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
17905
17803
|
}
|
|
@@ -17928,7 +17826,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
|
|
|
17928
17826
|
}
|
|
17929
17827
|
}
|
|
17930
17828
|
async function classifyGhostCandidate(input) {
|
|
17931
|
-
const autopsy = await autopsyWriterLock(
|
|
17829
|
+
const autopsy = await autopsyWriterLock(join33(input.runDirectory, "writer.lock"));
|
|
17932
17830
|
const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
|
|
17933
17831
|
if (leaseCheck === void 0) return { kind: "live" };
|
|
17934
17832
|
return {
|
|
@@ -17957,7 +17855,7 @@ async function listLedgerBookNames(booksRoot) {
|
|
|
17957
17855
|
async function readInvocationScopeFields(runDirectory) {
|
|
17958
17856
|
let raw;
|
|
17959
17857
|
try {
|
|
17960
|
-
raw = await
|
|
17858
|
+
raw = await readFile18(join33(runDirectory, "invocation.json"), "utf8");
|
|
17961
17859
|
} catch (error) {
|
|
17962
17860
|
if (isMissingPathError6(error)) return void 0;
|
|
17963
17861
|
throw error;
|
|
@@ -17990,7 +17888,7 @@ function decideIssueScope(input) {
|
|
|
17990
17888
|
}
|
|
17991
17889
|
async function resolveSessionFile(runDirectory) {
|
|
17992
17890
|
try {
|
|
17993
|
-
const raw = await
|
|
17891
|
+
const raw = await readFile18(join33(runDirectory, "invocation.json"), "utf8");
|
|
17994
17892
|
const parsed = JSON.parse(raw);
|
|
17995
17893
|
if (isRecord13(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
17996
17894
|
return parsed.sessionFile;
|
|
@@ -17998,7 +17896,7 @@ async function resolveSessionFile(runDirectory) {
|
|
|
17998
17896
|
} catch (error) {
|
|
17999
17897
|
if (!isMissingPathError6(error)) throw error;
|
|
18000
17898
|
}
|
|
18001
|
-
return
|
|
17899
|
+
return join33(runDirectory, "session", "session.jsonl");
|
|
18002
17900
|
}
|
|
18003
17901
|
function attributeSessionRowsForRun(input) {
|
|
18004
17902
|
if (pathContainedIn(input.runDirectory, input.sessionFile)) {
|
|
@@ -18190,9 +18088,9 @@ async function classifyScopedRun(input) {
|
|
|
18190
18088
|
}
|
|
18191
18089
|
let gateCycles;
|
|
18192
18090
|
try {
|
|
18193
|
-
const parentSessionFile =
|
|
18091
|
+
const parentSessionFile = join33(input.runDirectory, "session", "session.jsonl");
|
|
18194
18092
|
gateCycles = await readAnalystGateCyclesFromAuditorRoles(
|
|
18195
|
-
|
|
18093
|
+
join33(input.runDirectory, "session", "auditor-roles"),
|
|
18196
18094
|
{ parentSessionFile }
|
|
18197
18095
|
);
|
|
18198
18096
|
} catch (error) {
|
|
@@ -18227,7 +18125,7 @@ async function classifyScopedRun(input) {
|
|
|
18227
18125
|
async function scanAnalystIssueRuns(input) {
|
|
18228
18126
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
18229
18127
|
const scopeTicketNumber = input.ticketNumber;
|
|
18230
|
-
const booksRoot =
|
|
18128
|
+
const booksRoot = join33(ledgerHome, "books");
|
|
18231
18129
|
let wholeBook = false;
|
|
18232
18130
|
let scopeRootIdentity;
|
|
18233
18131
|
let bookNames;
|
|
@@ -18260,7 +18158,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
18260
18158
|
const ghostLegs = [];
|
|
18261
18159
|
const scopeConflicts = [];
|
|
18262
18160
|
for (const book of bookNames) {
|
|
18263
|
-
const bookDir =
|
|
18161
|
+
const bookDir = join33(booksRoot, book);
|
|
18264
18162
|
let runDirectories;
|
|
18265
18163
|
try {
|
|
18266
18164
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
@@ -19132,7 +19030,7 @@ var init_analyst_metric_family = __esm({
|
|
|
19132
19030
|
|
|
19133
19031
|
// src/analyst-page.ts
|
|
19134
19032
|
import { createHash as createHash5 } from "node:crypto";
|
|
19135
|
-
import { dirname as dirname21, join as
|
|
19033
|
+
import { dirname as dirname21, join as join34 } from "node:path";
|
|
19136
19034
|
function analystIssuePageKey(address) {
|
|
19137
19035
|
const parts = ["book", address.bookKey];
|
|
19138
19036
|
if (address.issueNumber !== void 0) {
|
|
@@ -19143,7 +19041,7 @@ function analystIssuePageKey(address) {
|
|
|
19143
19041
|
return createHash5("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
19144
19042
|
}
|
|
19145
19043
|
function analystIssuePagePath(ledgerHome, address) {
|
|
19146
|
-
return
|
|
19044
|
+
return join34(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
19147
19045
|
}
|
|
19148
19046
|
function analystIssuePageAddressFromPage(page) {
|
|
19149
19047
|
return {
|
|
@@ -19279,7 +19177,7 @@ var init_analyst_page = __esm({
|
|
|
19279
19177
|
});
|
|
19280
19178
|
|
|
19281
19179
|
// src/analyst-entry.ts
|
|
19282
|
-
import { readFile as
|
|
19180
|
+
import { readFile as readFile19 } from "node:fs/promises";
|
|
19283
19181
|
import { Type as Type11 } from "typebox";
|
|
19284
19182
|
function isMissingPathError7(error) {
|
|
19285
19183
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
@@ -19310,7 +19208,7 @@ async function readOrComputeAnalystIssuePage(input, options) {
|
|
|
19310
19208
|
...issueNumber === void 0 && input.bookKey === void 0 ? { scopeRootIdentity: projectRoot } : {}
|
|
19311
19209
|
});
|
|
19312
19210
|
try {
|
|
19313
|
-
const raw = await
|
|
19211
|
+
const raw = await readFile19(pagePath, "utf8");
|
|
19314
19212
|
const page = JSON.parse(raw);
|
|
19315
19213
|
if (cachedPageMatchesRequestedScope(page, { bookKey, ...input })) {
|
|
19316
19214
|
const ghostScan = await scanAnalystIssueRuns({
|
|
@@ -19411,7 +19309,7 @@ async function runAnalystModelGroupsMode(input, home) {
|
|
|
19411
19309
|
scopeRootIdentity: projectRoot
|
|
19412
19310
|
});
|
|
19413
19311
|
try {
|
|
19414
|
-
const raw = await
|
|
19312
|
+
const raw = await readFile19(pagePath, "utf8");
|
|
19415
19313
|
JSON.parse(raw);
|
|
19416
19314
|
} catch (error) {
|
|
19417
19315
|
if (!isMissingPathError7(error)) {
|
|
@@ -19509,7 +19407,7 @@ var init_analyst_entry = __esm({
|
|
|
19509
19407
|
});
|
|
19510
19408
|
|
|
19511
19409
|
// src/public-cli/analyst-run.ts
|
|
19512
|
-
import { readFile as
|
|
19410
|
+
import { readFile as readFile20 } from "node:fs/promises";
|
|
19513
19411
|
import { isAbsolute as isAbsolute9, resolve as resolve14 } from "node:path";
|
|
19514
19412
|
import { Value as Value2 } from "typebox/value";
|
|
19515
19413
|
function resolveAnalystIssueBookKeyFromCwd(cwd = process.cwd()) {
|
|
@@ -19563,7 +19461,7 @@ async function buildAnalystSweepModeInputFromAttachmentPaths(attachmentPaths) {
|
|
|
19563
19461
|
const absolute = isAbsolute9(sourcePath) ? sourcePath : resolve14(sourcePath);
|
|
19564
19462
|
let bytes;
|
|
19565
19463
|
try {
|
|
19566
|
-
bytes = await
|
|
19464
|
+
bytes = await readFile20(absolute);
|
|
19567
19465
|
} catch (error) {
|
|
19568
19466
|
throw new CliUsageError(
|
|
19569
19467
|
`analyst sweep attachment is not a readable regular file: ${sourcePath}`,
|
|
@@ -19683,7 +19581,7 @@ __export(cli_exports, {
|
|
|
19683
19581
|
runAkRole: () => runAkRole
|
|
19684
19582
|
});
|
|
19685
19583
|
import { realpath as realpath5 } from "node:fs/promises";
|
|
19686
|
-
import { join as
|
|
19584
|
+
import { join as join35 } from "node:path";
|
|
19687
19585
|
function publicSeatArgv(owner) {
|
|
19688
19586
|
return {
|
|
19689
19587
|
parse: (args) => parsePublicSeatArgv(owner, args),
|
|
@@ -19822,7 +19720,7 @@ function resolveHome(env) {
|
|
|
19822
19720
|
return env.home ?? packageMachineHome();
|
|
19823
19721
|
}
|
|
19824
19722
|
function resolveAgentDir(env, home) {
|
|
19825
|
-
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
19723
|
+
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join35(home, ".pi", "agent");
|
|
19826
19724
|
}
|
|
19827
19725
|
function parseThinking(value) {
|
|
19828
19726
|
return value;
|
|
@@ -20594,7 +20492,7 @@ __export(public_role_summons_exports, {
|
|
|
20594
20492
|
import { execFile as execFile3 } from "node:child_process";
|
|
20595
20493
|
import { existsSync as existsSync9 } from "node:fs";
|
|
20596
20494
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
20597
|
-
import { join as
|
|
20495
|
+
import { join as join36 } from "node:path";
|
|
20598
20496
|
import { promisify as promisify3 } from "node:util";
|
|
20599
20497
|
function createCapturingIo() {
|
|
20600
20498
|
const chunks = [];
|
|
@@ -20618,7 +20516,7 @@ function parentDir(path) {
|
|
|
20618
20516
|
function walkPackageRoot(start) {
|
|
20619
20517
|
let dir = start;
|
|
20620
20518
|
for (let i = 0; i < 12; i += 1) {
|
|
20621
|
-
if (existsSync9(
|
|
20519
|
+
if (existsSync9(join36(dir, "package.json")) && existsSync9(join36(dir, "souls"))) {
|
|
20622
20520
|
return dir;
|
|
20623
20521
|
}
|
|
20624
20522
|
const parent = parentDir(dir);
|
|
@@ -20734,7 +20632,7 @@ async function createSummonEnv(options, afterHost) {
|
|
|
20734
20632
|
async function summonPublicRole(options) {
|
|
20735
20633
|
const packageRoot = resolveSummonsPackageRoot(options.packageRoot);
|
|
20736
20634
|
const home = await resolveSummonHome(options);
|
|
20737
|
-
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
20635
|
+
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join36(home, ".pi", "agent");
|
|
20738
20636
|
const {
|
|
20739
20637
|
loadCredentialProviders: loadCredentialProviders2,
|
|
20740
20638
|
loadPublicCliConfig: loadPublicCliConfig2,
|
|
@@ -21242,7 +21140,7 @@ var init_compliance_transport = __esm({
|
|
|
21242
21140
|
});
|
|
21243
21141
|
|
|
21244
21142
|
// src/role-run-relocation.ts
|
|
21245
|
-
import { join as
|
|
21143
|
+
import { join as join37, sep as sep5 } from "node:path";
|
|
21246
21144
|
function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
|
|
21247
21145
|
if (typeof value !== "string") return value;
|
|
21248
21146
|
if (value === oldRunDirectory) return newRunDirectory;
|
|
@@ -21370,8 +21268,8 @@ __export(run_lifecycle_exports, {
|
|
|
21370
21268
|
renderResumeCommand: () => renderResumeCommand,
|
|
21371
21269
|
writeRoleRunState: () => writeRoleRunState
|
|
21372
21270
|
});
|
|
21373
|
-
import { chmod, lstat as lstat7, open as open3, readdir as readdir7, readFile as
|
|
21374
|
-
import { basename as basename9, join as
|
|
21271
|
+
import { chmod, lstat as lstat7, open as open3, readdir as readdir7, readFile as readFile21, unlink as unlink5, writeFile as writeFile9 } from "node:fs/promises";
|
|
21272
|
+
import { basename as basename9, join as join38 } from "node:path";
|
|
21375
21273
|
function buildAutoResumeContinuationPrompt(options) {
|
|
21376
21274
|
return appendEngineSessionMaterial(
|
|
21377
21275
|
[RESUME_TRANSPORT_ENVELOPE],
|
|
@@ -21396,8 +21294,8 @@ function renderResumeCommand(runId) {
|
|
|
21396
21294
|
}
|
|
21397
21295
|
async function writeRoleRunState(runDirectory, record4) {
|
|
21398
21296
|
const payload = { ...record4, runDirectory };
|
|
21399
|
-
await
|
|
21400
|
-
|
|
21297
|
+
await writeFile9(
|
|
21298
|
+
join38(runDirectory, RUN_STATE_FILE),
|
|
21401
21299
|
`${JSON.stringify(payload, null, 2)}
|
|
21402
21300
|
`,
|
|
21403
21301
|
"utf8"
|
|
@@ -21447,7 +21345,7 @@ function parseCurrentCourtState(raw) {
|
|
|
21447
21345
|
async function readRoleRunStateRaw(runDirectory) {
|
|
21448
21346
|
let raw;
|
|
21449
21347
|
try {
|
|
21450
|
-
raw = JSON.parse(await
|
|
21348
|
+
raw = JSON.parse(await readFile21(join38(runDirectory, RUN_STATE_FILE), "utf8"));
|
|
21451
21349
|
} catch (error) {
|
|
21452
21350
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
21453
21351
|
throw error;
|
|
@@ -21540,8 +21438,8 @@ async function writeRoleRunStateDisk(runDirectory, disk) {
|
|
|
21540
21438
|
...disk.resumable === void 0 ? {} : { resumable: disk.resumable },
|
|
21541
21439
|
...disk.currentCourt === void 0 ? {} : { currentCourt: disk.currentCourt }
|
|
21542
21440
|
};
|
|
21543
|
-
await
|
|
21544
|
-
|
|
21441
|
+
await writeFile9(
|
|
21442
|
+
join38(runDirectory, RUN_STATE_FILE),
|
|
21545
21443
|
`${JSON.stringify(payload, null, 2)}
|
|
21546
21444
|
`,
|
|
21547
21445
|
"utf8"
|
|
@@ -21708,7 +21606,7 @@ function isProcessAlive(pid) {
|
|
|
21708
21606
|
async function autopsyWriterLock(lockPath) {
|
|
21709
21607
|
let content;
|
|
21710
21608
|
try {
|
|
21711
|
-
content = await
|
|
21609
|
+
content = await readFile21(lockPath, "utf8");
|
|
21712
21610
|
} catch (error) {
|
|
21713
21611
|
if (errorCodeOf(error) === "ENOENT") return { verdict: "absent" };
|
|
21714
21612
|
return { verdict: "unknown", reason: "unreadable", readFailure: error };
|
|
@@ -21767,7 +21665,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
|
|
|
21767
21665
|
},
|
|
21768
21666
|
relocate(nextRunDirectory) {
|
|
21769
21667
|
currentRunDirectory = nextRunDirectory;
|
|
21770
|
-
currentLockPath =
|
|
21668
|
+
currentLockPath = join38(nextRunDirectory, WRITER_LOCK_FILE);
|
|
21771
21669
|
},
|
|
21772
21670
|
async release() {
|
|
21773
21671
|
if (released) return;
|
|
@@ -21806,10 +21704,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
21806
21704
|
};
|
|
21807
21705
|
const reportReadFailure = (error) => {
|
|
21808
21706
|
reportDiagnostic(
|
|
21809
|
-
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${
|
|
21707
|
+
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join38(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
|
|
21810
21708
|
);
|
|
21811
21709
|
};
|
|
21812
|
-
const lockPath =
|
|
21710
|
+
const lockPath = join38(runDirectory, WRITER_LOCK_FILE);
|
|
21813
21711
|
let lastAutopsy = { verdict: "absent" };
|
|
21814
21712
|
let lastReclaimFailure;
|
|
21815
21713
|
for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
|
|
@@ -21864,7 +21762,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
21864
21762
|
async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
21865
21763
|
if (runId.trim() === "") return void 0;
|
|
21866
21764
|
const ledgerHome = resolveActivationLedgerHome(home);
|
|
21867
|
-
const booksRoot =
|
|
21765
|
+
const booksRoot = join38(ledgerHome, "books");
|
|
21868
21766
|
let bookKeys;
|
|
21869
21767
|
try {
|
|
21870
21768
|
bookKeys = await readdir7(booksRoot);
|
|
@@ -21905,7 +21803,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
21905
21803
|
let raw;
|
|
21906
21804
|
try {
|
|
21907
21805
|
raw = JSON.parse(
|
|
21908
|
-
await
|
|
21806
|
+
await readFile21(join38(runDirectory, "admitted-request.json"), "utf8")
|
|
21909
21807
|
);
|
|
21910
21808
|
} catch (error) {
|
|
21911
21809
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -21926,7 +21824,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
21926
21824
|
async function runHasFormedSessionPrincipal(runDirectory) {
|
|
21927
21825
|
const disk = await readRoleRunStateDisk(runDirectory);
|
|
21928
21826
|
if (disk === void 0) return false;
|
|
21929
|
-
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile :
|
|
21827
|
+
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : join38(disk.principalWire.sessionDirectory, "session.jsonl");
|
|
21930
21828
|
try {
|
|
21931
21829
|
const stat2 = await lstat7(sessionFile);
|
|
21932
21830
|
return stat2.isFile() && !stat2.isSymbolicLink();
|
|
@@ -21944,7 +21842,7 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
21944
21842
|
let runDirectories;
|
|
21945
21843
|
try {
|
|
21946
21844
|
runDirectories = await listBookRunDirectories(
|
|
21947
|
-
input.ticketNumber === void 0 ? bookDir :
|
|
21845
|
+
input.ticketNumber === void 0 ? bookDir : join38(bookDir, String(input.ticketNumber))
|
|
21948
21846
|
);
|
|
21949
21847
|
} catch (error) {
|
|
21950
21848
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -22071,7 +21969,7 @@ async function loadResumableRunRecord(home, runId, authority, allowUnformedAdmit
|
|
|
22071
21969
|
let sourceRun;
|
|
22072
21970
|
try {
|
|
22073
21971
|
const raw = JSON.parse(
|
|
22074
|
-
await
|
|
21972
|
+
await readFile21(run.admittedRequestPath, "utf8")
|
|
22075
21973
|
);
|
|
22076
21974
|
if (raw !== null && typeof raw === "object" && !Array.isArray(raw)) {
|
|
22077
21975
|
const record4 = raw;
|
|
@@ -22194,7 +22092,7 @@ async function loadResumableRunRecord(home, runId, authority, allowUnformedAdmit
|
|
|
22194
22092
|
let model;
|
|
22195
22093
|
try {
|
|
22196
22094
|
const invocationRaw = JSON.parse(
|
|
22197
|
-
await
|
|
22095
|
+
await readFile21(join38(run.runDirectory, "invocation.json"), "utf8")
|
|
22198
22096
|
);
|
|
22199
22097
|
if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
|
|
22200
22098
|
const rec = invocationRaw;
|
|
@@ -22578,7 +22476,7 @@ var init_run_lifecycle = __esm({
|
|
|
22578
22476
|
});
|
|
22579
22477
|
|
|
22580
22478
|
// src/submission-ledger.ts
|
|
22581
|
-
import { join as
|
|
22479
|
+
import { join as join39 } from "node:path";
|
|
22582
22480
|
function runIdentity(context) {
|
|
22583
22481
|
const directory = runDirectoryFromHostContext(context);
|
|
22584
22482
|
if (directory !== void 0) {
|
|
@@ -22600,7 +22498,7 @@ async function submissionRecordFile(cwd, runId, scope) {
|
|
|
22600
22498
|
if (sessionParent === void 0) {
|
|
22601
22499
|
const discoveredRun = await findRunDirectoryById(scope.home, runId);
|
|
22602
22500
|
if (discoveredRun === void 0) return void 0;
|
|
22603
|
-
sessionParent =
|
|
22501
|
+
sessionParent = join39(discoveredRun, "session", "session.jsonl");
|
|
22604
22502
|
}
|
|
22605
22503
|
return resolveSitianRecordPathInLedger({
|
|
22606
22504
|
level: "event",
|
|
@@ -22793,12 +22691,12 @@ async function restoreState(cwd, runId, scope) {
|
|
|
22793
22691
|
}
|
|
22794
22692
|
function sessionParentFromHostContext(context) {
|
|
22795
22693
|
const runDirectory = runDirectoryFromHostContext(context);
|
|
22796
|
-
if (runDirectory !== void 0) return
|
|
22694
|
+
if (runDirectory !== void 0) return join39(runDirectory, "session", "session.jsonl");
|
|
22797
22695
|
const sessionFile = context.sessionManager.getSessionFile?.();
|
|
22798
22696
|
if (typeof sessionFile === "string" && sessionFile.length > 0) return sessionFile;
|
|
22799
22697
|
const sessionDir = context.sessionManager.getSessionDir?.();
|
|
22800
22698
|
if (typeof sessionDir === "string" && sessionDir.length > 0) {
|
|
22801
|
-
return
|
|
22699
|
+
return join39(sessionDir, "session.jsonl");
|
|
22802
22700
|
}
|
|
22803
22701
|
return void 0;
|
|
22804
22702
|
}
|
|
@@ -22978,7 +22876,7 @@ var init_submission_ledger = __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 join42 } 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: join42(
|
|
22995
22893
|
activationBookDirectory(ledgerHome, resolveBookKeyFromGit(input.cwd)),
|
|
22996
22894
|
NAVIGATOR_RECORD_KIND,
|
|
22997
22895
|
digest
|
|
@@ -23063,10 +22961,10 @@ import {
|
|
|
23063
22961
|
statSync as statSync7,
|
|
23064
22962
|
writeFileSync as writeFileSync3
|
|
23065
22963
|
} from "node:fs";
|
|
23066
|
-
import { dirname as dirname23, resolve as resolve17, join as
|
|
22964
|
+
import { dirname as dirname23, resolve as resolve17, join as join43 } from "node:path";
|
|
23067
22965
|
import { StringDecoder } from "node:string_decoder";
|
|
23068
22966
|
function readCurrentSession(sessionDir) {
|
|
23069
|
-
const ledger =
|
|
22967
|
+
const ledger = join43(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 = join43(sessionDir, CURRENT_SESSION_LEDGER);
|
|
23085
22983
|
try {
|
|
23086
22984
|
writeFileSync3(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 join43(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 = join43(absoluteSessionDir, name);
|
|
23188
23086
|
let st;
|
|
23189
23087
|
try {
|
|
23190
23088
|
st = statSync7(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 = join43(dirname23(parentResolved), options.kind);
|
|
23300
23198
|
parentSession = parentFile;
|
|
23301
23199
|
mayResumeSameNest = options.kind === WORKER_SUBMISSION_GATE_KIND;
|
|
23302
23200
|
}
|
|
@@ -23365,9 +23263,9 @@ import { randomUUID as randomUUID10 } from "node:crypto";
|
|
|
23365
23263
|
init_engine_detour();
|
|
23366
23264
|
init_packaged_role_registry();
|
|
23367
23265
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
23368
|
-
import { appendFile as appendFile3, mkdir as mkdir5, writeFile as
|
|
23266
|
+
import { appendFile as appendFile3, mkdir as mkdir5, writeFile as writeFile10 } from "node:fs/promises";
|
|
23369
23267
|
import { createServer } from "node:net";
|
|
23370
|
-
import { dirname as dirname25, join as
|
|
23268
|
+
import { dirname as dirname25, join as join46 } from "node:path";
|
|
23371
23269
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
23372
23270
|
|
|
23373
23271
|
// src/role-runtime.ts
|
|
@@ -23377,7 +23275,7 @@ init_submission_ledger();
|
|
|
23377
23275
|
init_collector_ledger();
|
|
23378
23276
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
23379
23277
|
import { readFileSync as readFileSync6, writeSync as writeSync2 } from "node:fs";
|
|
23380
|
-
import { join as
|
|
23278
|
+
import { join as join45 } from "node:path";
|
|
23381
23279
|
import { Value as Value4 } from "typebox/value";
|
|
23382
23280
|
|
|
23383
23281
|
// src/activation-trace.ts
|
|
@@ -23700,8 +23598,8 @@ init_collector_github();
|
|
|
23700
23598
|
// src/collector-handbook.ts
|
|
23701
23599
|
init_atomic_write();
|
|
23702
23600
|
init_activation_ledger_topology();
|
|
23703
|
-
import { readFile as
|
|
23704
|
-
import { join as
|
|
23601
|
+
import { readFile as readFile22 } from "node:fs/promises";
|
|
23602
|
+
import { join as join40, sep as sep6 } from "node:path";
|
|
23705
23603
|
|
|
23706
23604
|
// src/collector-tool-schemas.ts
|
|
23707
23605
|
init_open_tool_schema();
|
|
@@ -23816,7 +23714,7 @@ function resolveCollectorHandbookRoot(sessionPath) {
|
|
|
23816
23714
|
throw new Error(`\u901A\u8FDB\u53F8\u624B\u518C\u62D2\u7EDD\u4E0D\u5B89\u5168 bookKey ${JSON.stringify(bookKey)}`);
|
|
23817
23715
|
}
|
|
23818
23716
|
const ledgerHome = resolveActivationLedgerHomeForPath(sessionPath);
|
|
23819
|
-
const root =
|
|
23717
|
+
const root = join40(activationBookDirectory(ledgerHome, bookKey), "collector-handbook");
|
|
23820
23718
|
return { ledgerHome, bookKey, root };
|
|
23821
23719
|
}
|
|
23822
23720
|
function collectorHandbookRepoFileName(repositoryCanonical) {
|
|
@@ -23828,9 +23726,9 @@ function collectorHandbookRepoFileName(repositoryCanonical) {
|
|
|
23828
23726
|
return `${repositoryCanonical.replaceAll("/", "__")}.md`;
|
|
23829
23727
|
}
|
|
23830
23728
|
function createCollectorHandbookStore(input) {
|
|
23831
|
-
const generalPath =
|
|
23832
|
-
const repoDir =
|
|
23833
|
-
const repoPath =
|
|
23729
|
+
const generalPath = join40(input.handbookRoot, "general.md");
|
|
23730
|
+
const repoDir = join40(input.handbookRoot, "repos");
|
|
23731
|
+
const repoPath = join40(repoDir, collectorHandbookRepoFileName(input.repositoryCanonical));
|
|
23834
23732
|
const assertHandbookBudget = (body, label) => {
|
|
23835
23733
|
const byteLength = Buffer.byteLength(body, "utf8");
|
|
23836
23734
|
if (byteLength > COLLECTOR_HANDBOOK_MAX_BYTES) {
|
|
@@ -23844,7 +23742,7 @@ function createCollectorHandbookStore(input) {
|
|
|
23844
23742
|
ensureRealDirectoryTree(input.ledgerHome, parentDir2);
|
|
23845
23743
|
assertLedgerFileInsideHome(path, input.ledgerHome);
|
|
23846
23744
|
try {
|
|
23847
|
-
const body = await
|
|
23745
|
+
const body = await readFile22(path, "utf8");
|
|
23848
23746
|
assertHandbookBudget(body, "\u6B63\u6587");
|
|
23849
23747
|
return body;
|
|
23850
23748
|
} catch (error) {
|
|
@@ -25047,11 +24945,11 @@ init_packaged_role_registry();
|
|
|
25047
24945
|
// src/navigator-work-base.ts
|
|
25048
24946
|
init_atomic_write();
|
|
25049
24947
|
import { existsSync as existsSync10, realpathSync as realpathSync3 } from "node:fs";
|
|
25050
|
-
import { readFile as
|
|
25051
|
-
import { basename as basename10, dirname as dirname22, join as
|
|
24948
|
+
import { readFile as readFile23 } from "node:fs/promises";
|
|
24949
|
+
import { basename as basename10, dirname as dirname22, join as join41, resolve as resolve16 } from "node:path";
|
|
25052
24950
|
var NAVIGATOR_WORK_CONTEXT_BASENAME = "work-context.json";
|
|
25053
24951
|
function navigatorWorkContextFile(sessionDir) {
|
|
25054
|
-
return
|
|
24952
|
+
return join41(sessionDir, NAVIGATOR_WORK_CONTEXT_BASENAME);
|
|
25055
24953
|
}
|
|
25056
24954
|
function isNavigatorWorkContextFile(path) {
|
|
25057
24955
|
const resolved = resolve16(path);
|
|
@@ -25076,7 +24974,7 @@ async function persistNavigatorWorkBase(sessionDir, body) {
|
|
|
25076
24974
|
const next = `${JSON.stringify({ subject: body.subject, authority: body.authority })}
|
|
25077
24975
|
`;
|
|
25078
24976
|
try {
|
|
25079
|
-
const current = await
|
|
24977
|
+
const current = await readFile23(path, "utf8");
|
|
25080
24978
|
if (current === next) return path;
|
|
25081
24979
|
} catch (error) {
|
|
25082
24980
|
if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) {
|
|
@@ -25091,7 +24989,7 @@ async function readNavigatorWorkBase(path) {
|
|
|
25091
24989
|
if (canonical === void 0) return void 0;
|
|
25092
24990
|
let text;
|
|
25093
24991
|
try {
|
|
25094
|
-
text = await
|
|
24992
|
+
text = await readFile23(canonical, "utf8");
|
|
25095
24993
|
} catch (error) {
|
|
25096
24994
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
25097
24995
|
return void 0;
|
|
@@ -26887,7 +26785,7 @@ function readDiaristTicketAssertion(submitted) {
|
|
|
26887
26785
|
function readRoleRunCoordinates(ctx, label) {
|
|
26888
26786
|
const runDirectory = runDirectoryFromHostContext(ctx);
|
|
26889
26787
|
if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
|
|
26890
|
-
const admittedPath =
|
|
26788
|
+
const admittedPath = join45(runDirectory, "admitted-request.json");
|
|
26891
26789
|
const admitted = JSON.parse(readFileSync6(admittedPath, "utf8"));
|
|
26892
26790
|
if (typeof admitted.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
|
|
26893
26791
|
throw new Error(`${label} admitted-request missing projectRoot (${admittedPath})`);
|
|
@@ -27240,14 +27138,6 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27240
27138
|
}
|
|
27241
27139
|
};
|
|
27242
27140
|
});
|
|
27243
|
-
roleHost.on("before_agent_start", async (_event, ctx) => {
|
|
27244
|
-
const runDir = runDirectoryFromHostContext(ctx);
|
|
27245
|
-
if (runDir === void 0) return;
|
|
27246
|
-
const { loadCaseDossierReadingMaterial: loadCaseDossierReadingMaterial2 } = await Promise.resolve().then(() => (init_case_dossier_delivery(), case_dossier_delivery_exports));
|
|
27247
|
-
const caseDossier = await loadCaseDossierReadingMaterial2(runDir);
|
|
27248
|
-
if (caseDossier === void 0) return;
|
|
27249
|
-
return { readingMaterial: caseDossier };
|
|
27250
|
-
});
|
|
27251
27141
|
roleHost.on("tool_result", async (event) => {
|
|
27252
27142
|
const role = selectedRole;
|
|
27253
27143
|
if (role === void 0) return;
|
|
@@ -27855,11 +27745,11 @@ async function prepareRoleEnvelope(options) {
|
|
|
27855
27745
|
const hostAbort = new AbortController();
|
|
27856
27746
|
const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID9();
|
|
27857
27747
|
await mkdir5(request.runDirectory, { recursive: true });
|
|
27858
|
-
let sessionFile = options.sessionFile ??
|
|
27748
|
+
let sessionFile = options.sessionFile ?? join46(request.runDirectory, "session", "session.jsonl");
|
|
27859
27749
|
await mkdir5(dirname25(sessionFile), { recursive: true });
|
|
27860
27750
|
if (request.continuation.kind !== "resume") {
|
|
27861
27751
|
try {
|
|
27862
|
-
await
|
|
27752
|
+
await writeFile10(
|
|
27863
27753
|
sessionFile,
|
|
27864
27754
|
`${JSON.stringify({
|
|
27865
27755
|
type: "session",
|
|
@@ -28374,13 +28264,13 @@ async function prepareRoleEnvelope(options) {
|
|
|
28374
28264
|
// src/role-runtime-dependencies.ts
|
|
28375
28265
|
init_collector_github();
|
|
28376
28266
|
init_doctor_evidence();
|
|
28377
|
-
import { readFile as
|
|
28378
|
-
import { join as
|
|
28267
|
+
import { readFile as readFile25 } from "node:fs/promises";
|
|
28268
|
+
import { join as join47 } from "node:path";
|
|
28379
28269
|
|
|
28380
28270
|
// src/navigator-work-context.ts
|
|
28381
28271
|
init_doctor_evidence();
|
|
28382
28272
|
init_host_contracts();
|
|
28383
|
-
import { readFile as
|
|
28273
|
+
import { readFile as readFile24 } from "node:fs/promises";
|
|
28384
28274
|
import { resolve as resolve20 } from "node:path";
|
|
28385
28275
|
init_notary_source_run();
|
|
28386
28276
|
init_packaged_role_registry();
|
|
@@ -28394,7 +28284,7 @@ function navigatorInputReference(getFlag, role) {
|
|
|
28394
28284
|
async function loadNavigatorWorkContext(options) {
|
|
28395
28285
|
const reference = navigatorInputReference(options.getFlag, options.role);
|
|
28396
28286
|
const subjectMode = packagedNavigatorSubject(options.role);
|
|
28397
|
-
const input = reference === void 0 || subjectMode === "case" || subjectMode === "source-run" ? void 0 : await
|
|
28287
|
+
const input = reference === void 0 || subjectMode === "case" || subjectMode === "source-run" ? void 0 : await readFile24(reference, "utf8");
|
|
28398
28288
|
const subjectRoot = subjectPath(reference ?? options.context.sessionManager.getSessionDir(), options.context.cwd);
|
|
28399
28289
|
let subjectKey = reference === void 0 ? subjectRoot : navigatorSubjectKeyForInput(subjectRoot, reference, options.context.cwd);
|
|
28400
28290
|
let subject = input ?? `work subject: ${subjectKey}`;
|
|
@@ -28451,7 +28341,7 @@ async function loadNavigatorWorkContext(options) {
|
|
|
28451
28341
|
let authorityMaterial;
|
|
28452
28342
|
for (const path of authorityFiles) {
|
|
28453
28343
|
try {
|
|
28454
|
-
const content = await
|
|
28344
|
+
const content = await readFile24(path, "utf8");
|
|
28455
28345
|
if (content.trim() !== "") {
|
|
28456
28346
|
authorityMaterial = content;
|
|
28457
28347
|
break;
|
|
@@ -28488,19 +28378,19 @@ function loadRegisteredRoleSoul(role) {
|
|
|
28488
28378
|
return usesSubjectSoul(role) ? loadAuditorSoulFromSubjectInput() : loadMainRoleSessionMaterials(role);
|
|
28489
28379
|
}
|
|
28490
28380
|
function createRoleRuntimeDependencies(packageRoot) {
|
|
28491
|
-
const collectorHandbookSeedPath =
|
|
28381
|
+
const collectorHandbookSeedPath = join47(packageRoot, "resources/collector-bot-handbook.md");
|
|
28492
28382
|
const navigatorSessionFactory = createNativeNavigatorSessionFactory();
|
|
28493
28383
|
return {
|
|
28494
28384
|
packageRoot,
|
|
28495
28385
|
loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
|
|
28496
28386
|
loadRoleSoul: loadRegisteredRoleSoul,
|
|
28497
|
-
loadFixPacket: (path) =>
|
|
28498
|
-
loadCoderTask: (path) =>
|
|
28499
|
-
loadCollectorHandbookSeed: () =>
|
|
28387
|
+
loadFixPacket: (path) => readFile25(path, "utf8"),
|
|
28388
|
+
loadCoderTask: (path) => readFile25(path, "utf8"),
|
|
28389
|
+
loadCollectorHandbookSeed: () => readFile25(collectorHandbookSeedPath, "utf8"),
|
|
28500
28390
|
createCollectorTransport: () => createGhCollectorGitHubTransport(),
|
|
28501
28391
|
loadDoctorCase,
|
|
28502
28392
|
loadNotarySourceRun: loadNotarySourceRunLocator,
|
|
28503
|
-
loadMergerInput: async (path) => JSON.parse(await
|
|
28393
|
+
loadMergerInput: async (path) => JSON.parse(await readFile25(path, "utf8")),
|
|
28504
28394
|
loadNavigatorWorkContext: (options) => loadNavigatorWorkContext({
|
|
28505
28395
|
context: options.context,
|
|
28506
28396
|
role: options.role,
|
|
@@ -28525,9 +28415,9 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
28525
28415
|
init_session_identity();
|
|
28526
28416
|
|
|
28527
28417
|
// src/acp-host/description.ts
|
|
28528
|
-
import { join as
|
|
28418
|
+
import { join as join48 } from "node:path";
|
|
28529
28419
|
function resolveAcpBinary(description, operatorHome) {
|
|
28530
|
-
return
|
|
28420
|
+
return join48(operatorHome, ...description.binaryFromHome);
|
|
28531
28421
|
}
|
|
28532
28422
|
function acpStdioArgs(description, model, seat) {
|
|
28533
28423
|
const { prefix, suffix, modelFlag, thinkingFlag } = description.argv;
|
|
@@ -28546,7 +28436,7 @@ function acpModelId(modelPassing, model) {
|
|
|
28546
28436
|
}
|
|
28547
28437
|
|
|
28548
28438
|
// src/acp-host/role-turn-host.ts
|
|
28549
|
-
import { join as
|
|
28439
|
+
import { join as join49 } from "node:path";
|
|
28550
28440
|
import { spawn as spawn4 } from "node:child_process";
|
|
28551
28441
|
import { createInterface } from "node:readline";
|
|
28552
28442
|
|
|
@@ -28993,7 +28883,7 @@ function createAcpRoleTurnHost(config) {
|
|
|
28993
28883
|
host: config.hostName,
|
|
28994
28884
|
sessionId,
|
|
28995
28885
|
cwd: request.cwd,
|
|
28996
|
-
sessionDirectory:
|
|
28886
|
+
sessionDirectory: join49(request.runDirectory, "session"),
|
|
28997
28887
|
sessionParent,
|
|
28998
28888
|
continuation: request.continuation,
|
|
28999
28889
|
...request.model !== void 0 ? { model: request.model } : {},
|
|
@@ -29013,12 +28903,12 @@ function createAcpRoleTurnHost(config) {
|
|
|
29013
28903
|
// src/acp-host/seat-profile-soul.ts
|
|
29014
28904
|
import { constants as constants3 } from "node:fs";
|
|
29015
28905
|
import { access as access3, copyFile, lstat as lstat8, mkdir as mkdir6, readlink, symlink as symlink2, unlink as unlink6 } from "node:fs/promises";
|
|
29016
|
-
import { dirname as dirname26, join as
|
|
28906
|
+
import { dirname as dirname26, join as join50, relative as relative3, resolve as resolve21 } from "node:path";
|
|
29017
28907
|
function seatProfileName(spec, role) {
|
|
29018
28908
|
return `${spec.namePrefix}${role}`;
|
|
29019
28909
|
}
|
|
29020
28910
|
function packageRoleSoulPath(packageRoot, role) {
|
|
29021
|
-
return
|
|
28911
|
+
return join50(packageRoot, "souls", `${role}.md`);
|
|
29022
28912
|
}
|
|
29023
28913
|
async function pathExists2(path) {
|
|
29024
28914
|
try {
|
|
@@ -29035,16 +28925,16 @@ async function ensureSeatProfileSoul(options) {
|
|
|
29035
28925
|
if (!await pathExists2(soulTarget)) {
|
|
29036
28926
|
throw new Error(`packaged role soul missing: ${soulTarget}`);
|
|
29037
28927
|
}
|
|
29038
|
-
const profilesRoot =
|
|
29039
|
-
const profileDir =
|
|
28928
|
+
const profilesRoot = join50(operatorHome, ...spec.profilesRootFromHome);
|
|
28929
|
+
const profileDir = join50(profilesRoot, profileName);
|
|
29040
28930
|
const hostRoot = dirname26(profilesRoot);
|
|
29041
|
-
const soulPath =
|
|
28931
|
+
const soulPath = join50(profileDir, spec.soulFileName);
|
|
29042
28932
|
if (!await pathExists2(profileDir)) {
|
|
29043
28933
|
await mkdir6(profileDir, { recursive: true });
|
|
29044
28934
|
for (const name of ["auth.json", ".env", "config.yaml"]) {
|
|
29045
|
-
const source =
|
|
28935
|
+
const source = join50(hostRoot, name);
|
|
29046
28936
|
if (!await pathExists2(source)) continue;
|
|
29047
|
-
await copyFile(source,
|
|
28937
|
+
await copyFile(source, join50(profileDir, name));
|
|
29048
28938
|
}
|
|
29049
28939
|
} else {
|
|
29050
28940
|
await mkdir6(profileDir, { recursive: true });
|