@akagilnc/pi-workflow-roles 0.1.5583 → 0.1.5593
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/README.md +2 -0
- package/README.zh-CN.md +2 -0
- package/dist/acp-host/production-host.js +231 -466
- package/dist/collector-config.js +0 -44
- package/dist/headless-host/production-host.js +199 -434
- package/dist/migrate-book-topology.js +16 -30
- package/dist/public-cli/instruction-seat-run.js +8 -8
- package/dist/public-cli/invocation.js +77 -187
- package/dist/public-cli/main.js +137 -363
- package/dist/public-cli/option-definitions.js +5 -5
- package/dist/public-cli/post-admission.js +11 -40
- package/dist/public-cli/run-lifecycle.js +9 -14
- package/dist/public-role-summons.js +1 -1
- package/dist/role-run-relocation.js +12 -20
- package/package.json +1 -1
- package/src/collector-config.ts +0 -42
- package/src/collector-role.ts +10 -20
- package/src/public-cli/instruction-seat-run.ts +7 -8
- package/src/public-cli/invocation.ts +92 -283
- package/src/public-cli/option-definitions.ts +5 -5
- package/src/public-cli/post-admission.ts +12 -56
- package/src/public-cli/run-lifecycle.ts +9 -16
- package/src/public-role-summons.ts +1 -1
- package/src/role-run-placement.ts +0 -1
- package/src/role-run-relocation.ts +12 -22
|
@@ -4436,7 +4436,6 @@ var init_durable_principal = __esm({
|
|
|
4436
4436
|
});
|
|
4437
4437
|
|
|
4438
4438
|
// src/collector-config.ts
|
|
4439
|
-
import { readFile as readFile6 } from "node:fs/promises";
|
|
4440
4439
|
function fail3(message, cause) {
|
|
4441
4440
|
throw new Error(message, cause === void 0 ? void 0 : { cause });
|
|
4442
4441
|
}
|
|
@@ -4464,47 +4463,10 @@ function parseCollectorPrNumber(raw) {
|
|
|
4464
4463
|
if (value === void 0) fail3(typeof raw === "string" && !isTicketNumberString(raw) ? "Collector pull request number must be a positive safe integer string" : "Collector pull request number must be a positive safe integer");
|
|
4465
4464
|
return value;
|
|
4466
4465
|
}
|
|
4467
|
-
function canonicalManifest(requests) {
|
|
4468
|
-
return `${JSON.stringify({ requests: requests.map((request) => ({ id: request.id, body: request.requestBody })) })}
|
|
4469
|
-
`;
|
|
4470
|
-
}
|
|
4471
|
-
function emptyCollectorManifest() {
|
|
4472
|
-
const canonicalJson2 = canonicalManifest([]);
|
|
4473
|
-
return { requests: [], canonicalJson: canonicalJson2, digest: sha256Hex(canonicalJson2) };
|
|
4474
|
-
}
|
|
4475
|
-
async function loadCollectorManifest(path) {
|
|
4476
|
-
let bytes;
|
|
4477
|
-
try {
|
|
4478
|
-
bytes = await readFile6(path);
|
|
4479
|
-
} catch (error) {
|
|
4480
|
-
fail3(`Collector request manifest is unreadable at ${path}`, error);
|
|
4481
|
-
}
|
|
4482
|
-
let parsed;
|
|
4483
|
-
try {
|
|
4484
|
-
parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
|
|
4485
|
-
} catch (error) {
|
|
4486
|
-
fail3("Collector request manifest must be UTF-8 JSON", error);
|
|
4487
|
-
}
|
|
4488
|
-
if (!isRecord(parsed)) fail3("Collector request manifest must be an object");
|
|
4489
|
-
const rawRequests = parsed.requests ?? [];
|
|
4490
|
-
if (!Array.isArray(rawRequests)) fail3("Collector request manifest requests must be an array");
|
|
4491
|
-
const requests = [];
|
|
4492
|
-
const ids = /* @__PURE__ */ new Set();
|
|
4493
|
-
for (const [index, item] of rawRequests.entries()) {
|
|
4494
|
-
if (!isRecord(item) || typeof item.id !== "string" || item.id.length === 0 || typeof item.body !== "string" || item.body.trim() === "") fail3(`Collector request manifest requests[${index}] is invalid`);
|
|
4495
|
-
if (ids.has(item.id)) fail3(`Collector request manifest has duplicate request id "${item.id}"`);
|
|
4496
|
-
ids.add(item.id);
|
|
4497
|
-
requests.push({ id: item.id, requestBody: item.body });
|
|
4498
|
-
}
|
|
4499
|
-
const canonicalJson2 = canonicalManifest(requests);
|
|
4500
|
-
return { requests, canonicalJson: canonicalJson2, digest: sha256Hex(canonicalJson2), sourcePath: path };
|
|
4501
|
-
}
|
|
4502
4466
|
var COLLECTOR_OWNER_PATTERN, COLLECTOR_REPO_PATTERN;
|
|
4503
4467
|
var init_collector_config = __esm({
|
|
4504
4468
|
"src/collector-config.ts"() {
|
|
4505
4469
|
"use strict";
|
|
4506
|
-
init_sha256();
|
|
4507
|
-
init_unknown_value();
|
|
4508
4470
|
init_run_ticket_number();
|
|
4509
4471
|
COLLECTOR_OWNER_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/;
|
|
4510
4472
|
COLLECTOR_REPO_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,98}[A-Za-z0-9])?$/;
|
|
@@ -5310,13 +5272,13 @@ var init_receipt_delivery_policy = __esm({
|
|
|
5310
5272
|
});
|
|
5311
5273
|
|
|
5312
5274
|
// src/ledger-session-read.ts
|
|
5313
|
-
import { readFile as
|
|
5275
|
+
import { readFile as readFile6 } from "node:fs/promises";
|
|
5314
5276
|
async function readStrictPiSessionJsonl(path) {
|
|
5315
|
-
const text = await
|
|
5277
|
+
const text = await readFile6(path, "utf8");
|
|
5316
5278
|
return text.trim().split("\n").filter(Boolean).map((line2) => JSON.parse(line2));
|
|
5317
5279
|
}
|
|
5318
5280
|
async function readLedgerSessionJsonlLines(path) {
|
|
5319
|
-
const text = await
|
|
5281
|
+
const text = await readFile6(path, "utf8");
|
|
5320
5282
|
const lines = text.split("\n");
|
|
5321
5283
|
const out = [];
|
|
5322
5284
|
for (let index = 0; index < lines.length; index += 1) {
|
|
@@ -5636,7 +5598,7 @@ async function runEngineDetourOnce(input) {
|
|
|
5636
5598
|
}
|
|
5637
5599
|
const command = input.argv[0];
|
|
5638
5600
|
const args = input.argv.slice(1);
|
|
5639
|
-
return await new Promise((
|
|
5601
|
+
return await new Promise((resolve21, reject) => {
|
|
5640
5602
|
let settled = false;
|
|
5641
5603
|
const signal = input.signal;
|
|
5642
5604
|
const child = spawn(command, args, {
|
|
@@ -5666,7 +5628,7 @@ async function runEngineDetourOnce(input) {
|
|
|
5666
5628
|
if (signal !== void 0) {
|
|
5667
5629
|
signal.removeEventListener("abort", onAbort);
|
|
5668
5630
|
}
|
|
5669
|
-
|
|
5631
|
+
resolve21(result);
|
|
5670
5632
|
};
|
|
5671
5633
|
const onAbort = () => {
|
|
5672
5634
|
fail4(signal !== void 0 ? abortReasonError(signal) : new Error("aborted"));
|
|
@@ -6445,7 +6407,7 @@ var init_git_object_id = __esm({
|
|
|
6445
6407
|
|
|
6446
6408
|
// src/merger-git-state.ts
|
|
6447
6409
|
import { execFile } from "node:child_process";
|
|
6448
|
-
import { access, readFile as
|
|
6410
|
+
import { access, readFile as readFile7 } from "node:fs/promises";
|
|
6449
6411
|
import { constants as fsConstants } from "node:fs";
|
|
6450
6412
|
import { isAbsolute as isAbsolute3, resolve as resolve8 } from "node:path";
|
|
6451
6413
|
import { promisify } from "node:util";
|
|
@@ -6515,7 +6477,7 @@ function createProductionMergerGitState(repositoryRoot = process.cwd()) {
|
|
|
6515
6477
|
const mergeHeadPath = isAbsolute3(mergeHeadReported) ? mergeHeadReported : resolve8(repositoryRoot, mergeHeadReported);
|
|
6516
6478
|
let sourceObjectId = "";
|
|
6517
6479
|
if (await pathExists(mergeHeadPath)) {
|
|
6518
|
-
const raw = exactUtf8(await
|
|
6480
|
+
const raw = exactUtf8(await readFile7(mergeHeadPath), "Git MERGE_HEAD");
|
|
6519
6481
|
const mergeHeads = raw.trim().split(/\r?\n/).map((row) => row.trim()).filter(Boolean);
|
|
6520
6482
|
if (mergeHeads.length === 0) throw new Error("Git MERGE_HEAD is empty");
|
|
6521
6483
|
if (mergeHeads.length !== 1) throw new Error("Assigned repository does not have one ordinary in-progress merge");
|
|
@@ -6661,7 +6623,7 @@ var init_session_dialogue = __esm({
|
|
|
6661
6623
|
});
|
|
6662
6624
|
|
|
6663
6625
|
// src/ticket-provenance.ts
|
|
6664
|
-
import { readFile as
|
|
6626
|
+
import { readFile as readFile8 } from "node:fs/promises";
|
|
6665
6627
|
import { join as join13, resolve as resolve9 } from "node:path";
|
|
6666
6628
|
function dialogueSessionSourceRoots(home) {
|
|
6667
6629
|
const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
|
|
@@ -6709,7 +6671,7 @@ async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, ho
|
|
|
6709
6671
|
const ticketInput = ticketProvenanceRecordInput(ticketNumber, cwd, home);
|
|
6710
6672
|
let history;
|
|
6711
6673
|
try {
|
|
6712
|
-
history = await
|
|
6674
|
+
history = await readFile8(join13(runDirectory, RUN_HISTORY_FILE), "utf8");
|
|
6713
6675
|
} catch (error) {
|
|
6714
6676
|
if (errnoCode(error) === "ENOENT") return;
|
|
6715
6677
|
throw error;
|
|
@@ -7453,8 +7415,8 @@ var init_option_definitions = __esm({
|
|
|
7453
7415
|
repeatable: true,
|
|
7454
7416
|
form: "option",
|
|
7455
7417
|
description: {
|
|
7456
|
-
en: "
|
|
7457
|
-
zh: "\
|
|
7418
|
+
en: "Caller file path passed as-is to the role (repeatable). Package does not read, copy, or validate; use an absolute path when cwd differs from --project.",
|
|
7419
|
+
zh: "\u8C03\u7528\u65B9\u6587\u4EF6\u8DEF\u5F84\u539F\u6837\u9012\u7ED9\u8859\u95E8\uFF08\u53EF\u91CD\u590D\uFF09\u3002\u5305\u4E0D\u8BFB\u3001\u4E0D\u590D\u5236\u3001\u4E0D\u6821\u9A8C\uFF1B\u8C03\u7528\u65B9\u5F53\u524D\u76EE\u5F55\u4E0E --project \u4E0D\u540C\u65F6\u8BF7\u7ED9\u7EDD\u5BF9\u8DEF\u5F84\u3002"
|
|
7458
7420
|
}
|
|
7459
7421
|
};
|
|
7460
7422
|
SHARED_PHASE_SEMANTICS = {
|
|
@@ -7629,8 +7591,8 @@ var init_option_definitions = __esm({
|
|
|
7629
7591
|
repeatable: false,
|
|
7630
7592
|
form: "option",
|
|
7631
7593
|
description: {
|
|
7632
|
-
en: "
|
|
7633
|
-
zh: "\
|
|
7594
|
+
en: "Caller path to a request manifest JSON file, passed as-is. Package does not read, copy, or validate; use an absolute path when cwd differs from --project.",
|
|
7595
|
+
zh: "\u8C03\u7528\u65B9 request manifest JSON \u8DEF\u5F84\uFF0C\u539F\u6837\u4F20\u9012\u3002\u5305\u4E0D\u8BFB\u3001\u4E0D\u590D\u5236\u3001\u4E0D\u6821\u9A8C\uFF1B\u8C03\u7528\u65B9\u5F53\u524D\u76EE\u5F55\u4E0E --project \u4E0D\u540C\u65F6\u8BF7\u7ED9\u7EDD\u5BF9\u8DEF\u5F84\u3002"
|
|
7634
7596
|
}
|
|
7635
7597
|
}
|
|
7636
7598
|
];
|
|
@@ -8089,16 +8051,22 @@ var init_option_definitions = __esm({
|
|
|
8089
8051
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
8090
8052
|
import { existsSync as existsSync5 } from "node:fs";
|
|
8091
8053
|
import {
|
|
8092
|
-
|
|
8093
|
-
mkdtemp,
|
|
8094
|
-
readFile as readFile10,
|
|
8054
|
+
readFile as readFile9,
|
|
8095
8055
|
realpath as realpath3,
|
|
8096
8056
|
rename as rename2,
|
|
8097
|
-
rm as rm2,
|
|
8098
8057
|
writeFile as writeFile3
|
|
8099
8058
|
} from "node:fs/promises";
|
|
8100
|
-
import {
|
|
8101
|
-
|
|
8059
|
+
import { dirname as dirname11, isAbsolute as isAbsolute5, join as join15, resolve as resolve11 } from "node:path";
|
|
8060
|
+
function normalizeAdmittedAttachment(raw) {
|
|
8061
|
+
if (typeof raw !== "object" || raw === null) return void 0;
|
|
8062
|
+
const record = raw;
|
|
8063
|
+
const path = record.path;
|
|
8064
|
+
if (typeof path === "string") return { path };
|
|
8065
|
+
return void 0;
|
|
8066
|
+
}
|
|
8067
|
+
function admitCallerAttachments(attachmentPaths) {
|
|
8068
|
+
return attachmentPaths.map((path) => ({ path }));
|
|
8069
|
+
}
|
|
8102
8070
|
function issueAdmissionPlacement(authority, request) {
|
|
8103
8071
|
const ledgerHome = resolveActivationLedgerHome(request.home);
|
|
8104
8072
|
const bookKey = resolveBookKeyFromGit(request.cwd);
|
|
@@ -8277,19 +8245,11 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
8277
8245
|
"taskPath",
|
|
8278
8246
|
"packetPath",
|
|
8279
8247
|
"prerequisitesPath",
|
|
8280
|
-
"requestManifestPath",
|
|
8281
8248
|
"mergerInputPath"
|
|
8282
8249
|
],
|
|
8283
8250
|
oldRunDirectory,
|
|
8284
8251
|
target.runDirectory
|
|
8285
8252
|
);
|
|
8286
|
-
for (const attachment of admitted.attachments) {
|
|
8287
|
-
attachment.frozenPath = rewriteRunDirectoryPathValue(
|
|
8288
|
-
attachment.frozenPath,
|
|
8289
|
-
oldRunDirectory,
|
|
8290
|
-
target.runDirectory
|
|
8291
|
-
);
|
|
8292
|
-
}
|
|
8293
8253
|
admitted.principal = principal;
|
|
8294
8254
|
renderCurrentSync(target.runDirectory);
|
|
8295
8255
|
return { oldRunDirectory, newRunDirectory: target.runDirectory };
|
|
@@ -8326,7 +8286,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
8326
8286
|
async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
|
|
8327
8287
|
const rolePackageRoot = packageRoot;
|
|
8328
8288
|
const raw = JSON.parse(
|
|
8329
|
-
await
|
|
8289
|
+
await readFile9(join15(rolePackageRoot, "package.json"), "utf8")
|
|
8330
8290
|
);
|
|
8331
8291
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
8332
8292
|
throw new Error(
|
|
@@ -8382,7 +8342,7 @@ function assignPublicSeatOption(owner, taken, fields) {
|
|
|
8382
8342
|
const value = taken.value;
|
|
8383
8343
|
switch (taken.def.id) {
|
|
8384
8344
|
case "attach":
|
|
8385
|
-
fields.attachmentPaths.push(
|
|
8345
|
+
fields.attachmentPaths.push(requireProvidedOptionValue(taken.def.canonical, value));
|
|
8386
8346
|
return;
|
|
8387
8347
|
case "project":
|
|
8388
8348
|
fields.project = requireOptionPath(taken.def.canonical, value);
|
|
@@ -8426,7 +8386,7 @@ function assignPublicSeatOption(owner, taken, fields) {
|
|
|
8426
8386
|
fields.repo = parseRepoOption(value);
|
|
8427
8387
|
return;
|
|
8428
8388
|
case "request-manifest":
|
|
8429
|
-
fields.requestManifestPath =
|
|
8389
|
+
fields.requestManifestPath = requireProvidedOptionValue(taken.def.canonical, value);
|
|
8430
8390
|
return;
|
|
8431
8391
|
case "issue": {
|
|
8432
8392
|
if (value === void 0 || value.trim() === "") {
|
|
@@ -8541,6 +8501,12 @@ function requireOptionPath(flag, value) {
|
|
|
8541
8501
|
}
|
|
8542
8502
|
return value;
|
|
8543
8503
|
}
|
|
8504
|
+
function requireProvidedOptionValue(flag, value) {
|
|
8505
|
+
if (value === void 0) {
|
|
8506
|
+
throw new CliUsageError(`${flag} requires a path`);
|
|
8507
|
+
}
|
|
8508
|
+
return value;
|
|
8509
|
+
}
|
|
8544
8510
|
function skillArgTokenFault(value) {
|
|
8545
8511
|
if (value === void 0 || value.trim() === "") return "empty";
|
|
8546
8512
|
if (/\s/.test(value)) return "whitespace";
|
|
@@ -8593,124 +8559,6 @@ function requireAuthorityRef(value) {
|
|
|
8593
8559
|
optionLike: "--authority-ref requires a durable reference, not inline Spec prose"
|
|
8594
8560
|
});
|
|
8595
8561
|
}
|
|
8596
|
-
async function readRegularFileAttachment(sourcePath) {
|
|
8597
|
-
const absolute = isAbsolute5(sourcePath) ? sourcePath : resolve11(sourcePath);
|
|
8598
|
-
let st;
|
|
8599
|
-
try {
|
|
8600
|
-
st = await lstat2(absolute);
|
|
8601
|
-
} catch (error) {
|
|
8602
|
-
throw new CliUsageError(
|
|
8603
|
-
`attachment is not a readable regular file: ${sourcePath}`,
|
|
8604
|
-
{ cause: error }
|
|
8605
|
-
);
|
|
8606
|
-
}
|
|
8607
|
-
if (!st.isFile() || st.isSymbolicLink()) {
|
|
8608
|
-
throw new CliUsageError(
|
|
8609
|
-
`attachment must be a regular file (not a directory or symlink): ${sourcePath}`
|
|
8610
|
-
);
|
|
8611
|
-
}
|
|
8612
|
-
try {
|
|
8613
|
-
return { absolute, bytes: await readFile10(absolute) };
|
|
8614
|
-
} catch (error) {
|
|
8615
|
-
throw new CliUsageError(
|
|
8616
|
-
`attachment is not a readable regular file: ${sourcePath}`,
|
|
8617
|
-
{ cause: error }
|
|
8618
|
-
);
|
|
8619
|
-
}
|
|
8620
|
-
}
|
|
8621
|
-
async function removePreparedAttachmentDirectory(stagingDirectory) {
|
|
8622
|
-
await rm2(stagingDirectory, { recursive: true, force: true });
|
|
8623
|
-
}
|
|
8624
|
-
async function withPreparedAttachments(attachmentPaths, use) {
|
|
8625
|
-
if (attachmentPaths.length === 0) return await use([]);
|
|
8626
|
-
const stagingDirectory = await mkdtemp(join15(tmpdir(), "ak-role-attachments-"));
|
|
8627
|
-
const prepared = [];
|
|
8628
|
-
let result;
|
|
8629
|
-
try {
|
|
8630
|
-
for (let index = 0; index < attachmentPaths.length; index += 1) {
|
|
8631
|
-
const { absolute, bytes } = await readRegularFileAttachment(attachmentPaths[index]);
|
|
8632
|
-
const snapshotPath = join15(stagingDirectory, String(index).padStart(6, "0"));
|
|
8633
|
-
await writeFile3(snapshotPath, bytes);
|
|
8634
|
-
prepared.push({ absolute, snapshotPath });
|
|
8635
|
-
}
|
|
8636
|
-
result = await use(prepared);
|
|
8637
|
-
} catch (primary) {
|
|
8638
|
-
try {
|
|
8639
|
-
await removePreparedAttachmentDirectory(stagingDirectory);
|
|
8640
|
-
} catch (cleanup) {
|
|
8641
|
-
throw new AggregateError(
|
|
8642
|
-
[primary, cleanup],
|
|
8643
|
-
"attachment snapshot operation failed and cleanup also failed",
|
|
8644
|
-
{ cause: primary }
|
|
8645
|
-
);
|
|
8646
|
-
}
|
|
8647
|
-
throw primary;
|
|
8648
|
-
}
|
|
8649
|
-
await removePreparedAttachmentDirectory(stagingDirectory);
|
|
8650
|
-
return result;
|
|
8651
|
-
}
|
|
8652
|
-
async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, index) {
|
|
8653
|
-
const frozenPath = join15(
|
|
8654
|
-
destinationDir,
|
|
8655
|
-
`${String(index).padStart(2, "0")}-${basename9(provenancePath)}`
|
|
8656
|
-
);
|
|
8657
|
-
await writeFile3(frozenPath, bytes);
|
|
8658
|
-
return {
|
|
8659
|
-
provenancePath,
|
|
8660
|
-
frozenPath,
|
|
8661
|
-
byteLength: bytes.byteLength,
|
|
8662
|
-
sha256: sha256Hex(bytes),
|
|
8663
|
-
mediaKind: "regular-file"
|
|
8664
|
-
};
|
|
8665
|
-
}
|
|
8666
|
-
async function freezePreparedAttachment(prepared, destinationDir, index) {
|
|
8667
|
-
return freezeAttachmentBytes(
|
|
8668
|
-
prepared.absolute,
|
|
8669
|
-
await readFile10(prepared.snapshotPath),
|
|
8670
|
-
destinationDir,
|
|
8671
|
-
index
|
|
8672
|
-
);
|
|
8673
|
-
}
|
|
8674
|
-
async function freezeRegularFileAttachment(sourcePath, destinationDir, index) {
|
|
8675
|
-
const { absolute, bytes } = await readRegularFileAttachment(sourcePath);
|
|
8676
|
-
return {
|
|
8677
|
-
attachment: await freezeAttachmentBytes(absolute, bytes, destinationDir, index),
|
|
8678
|
-
body: bytes
|
|
8679
|
-
};
|
|
8680
|
-
}
|
|
8681
|
-
async function freezeAttachments(ledgerHome, attachmentPaths, attachmentsDirectory) {
|
|
8682
|
-
const attachments = [];
|
|
8683
|
-
if (attachmentPaths.length > 0) {
|
|
8684
|
-
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
8685
|
-
}
|
|
8686
|
-
for (let i = 0; i < attachmentPaths.length; i += 1) {
|
|
8687
|
-
const frozen = await freezeRegularFileAttachment(
|
|
8688
|
-
attachmentPaths[i],
|
|
8689
|
-
attachmentsDirectory,
|
|
8690
|
-
i
|
|
8691
|
-
);
|
|
8692
|
-
attachments.push(frozen.attachment);
|
|
8693
|
-
}
|
|
8694
|
-
return attachments;
|
|
8695
|
-
}
|
|
8696
|
-
async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKey = `s-${Date.now().toString(36)}`) {
|
|
8697
|
-
if (attachmentPaths.length === 0) return [];
|
|
8698
|
-
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
8699
|
-
const attachmentsDirectory = join15(runDirectory, "attachments", summonsKey);
|
|
8700
|
-
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
8701
|
-
return freezeAttachments(ledgerHome, attachmentPaths, attachmentsDirectory);
|
|
8702
|
-
}
|
|
8703
|
-
async function freezePreparedAttachmentsIntoRun(prepared, runDirectory, summonsKey) {
|
|
8704
|
-
if (prepared.length === 0) return [];
|
|
8705
|
-
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
8706
|
-
const attachmentsDirectory = summonsKey === void 0 ? join15(runDirectory, "attachments") : join15(runDirectory, "attachments", summonsKey);
|
|
8707
|
-
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
8708
|
-
const attachments = [];
|
|
8709
|
-
for (let index = 0; index < prepared.length; index += 1) {
|
|
8710
|
-
attachments.push(await freezePreparedAttachment(prepared[index], attachmentsDirectory, index));
|
|
8711
|
-
}
|
|
8712
|
-
return attachments;
|
|
8713
|
-
}
|
|
8714
8562
|
function ticketAdmissionFields(ticketNumber) {
|
|
8715
8563
|
if (ticketNumber === void 0) return {};
|
|
8716
8564
|
return {
|
|
@@ -8799,7 +8647,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
8799
8647
|
if (parsed.prerequisitesPath !== void 0) {
|
|
8800
8648
|
const absolutePrereq = isAbsolute5(parsed.prerequisitesPath) ? parsed.prerequisitesPath : resolve11(parsed.prerequisitesPath);
|
|
8801
8649
|
try {
|
|
8802
|
-
prerequisitesSource = await
|
|
8650
|
+
prerequisitesSource = await readFile9(absolutePrereq, "utf8");
|
|
8803
8651
|
} catch (error) {
|
|
8804
8652
|
throw new CliUsageError(
|
|
8805
8653
|
`fixer prerequisites path is unreadable: ${parsed.prerequisitesPath}`,
|
|
@@ -8856,37 +8704,17 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
8856
8704
|
} else {
|
|
8857
8705
|
repository = resolveGitHubRemoteRepository(projectRoot);
|
|
8858
8706
|
}
|
|
8859
|
-
let manifest = emptyCollectorManifest();
|
|
8860
|
-
let manifestCanonicalJson;
|
|
8861
|
-
if (parsed.requestManifestPath !== void 0) {
|
|
8862
|
-
try {
|
|
8863
|
-
manifest = await loadCollectorManifest(parsed.requestManifestPath);
|
|
8864
|
-
manifestCanonicalJson = manifest.canonicalJson;
|
|
8865
|
-
} catch (error) {
|
|
8866
|
-
throw new CliUsageError(
|
|
8867
|
-
errorText(error),
|
|
8868
|
-
{ cause: error }
|
|
8869
|
-
);
|
|
8870
|
-
}
|
|
8871
|
-
}
|
|
8872
|
-
const manifestDigest = manifest.digest;
|
|
8873
8707
|
const admittedCollector = await admitStandardMaterialInvocation("collector", {
|
|
8874
8708
|
...shared,
|
|
8875
8709
|
instruction,
|
|
8876
8710
|
attachmentPaths,
|
|
8877
8711
|
...project,
|
|
8878
|
-
placedFields: async (
|
|
8879
|
-
let requestManifestPath;
|
|
8880
|
-
if (manifestCanonicalJson !== void 0) {
|
|
8881
|
-
requestManifestPath = join15(placed.runDirectory, "request-manifest.json");
|
|
8882
|
-
await writeFile3(requestManifestPath, manifestCanonicalJson, "utf8");
|
|
8883
|
-
}
|
|
8712
|
+
placedFields: async () => {
|
|
8884
8713
|
return {
|
|
8885
8714
|
...explicitPrNumber === void 0 ? {} : { prNumber: explicitPrNumber },
|
|
8886
8715
|
repository: repository.canonical,
|
|
8887
8716
|
repositoryDisplay: repository.display,
|
|
8888
|
-
...requestManifestPath === void 0 ? {} : { requestManifestPath }
|
|
8889
|
-
manifestDigest
|
|
8717
|
+
...parsed.requestManifestPath === void 0 ? {} : { requestManifestPath: parsed.requestManifestPath }
|
|
8890
8718
|
};
|
|
8891
8719
|
}
|
|
8892
8720
|
});
|
|
@@ -8899,12 +8727,10 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
8899
8727
|
);
|
|
8900
8728
|
}
|
|
8901
8729
|
const issueNumber = parsed.issueNumber;
|
|
8902
|
-
|
|
8903
|
-
const admittedDoctor = await admitStandardMaterialInvocation("doctor", {
|
|
8730
|
+
return admitStandardMaterialInvocation("doctor", {
|
|
8904
8731
|
...shared,
|
|
8905
8732
|
instruction,
|
|
8906
|
-
attachmentPaths
|
|
8907
|
-
freezeAttachments: false,
|
|
8733
|
+
attachmentPaths,
|
|
8908
8734
|
...project,
|
|
8909
8735
|
placedFields: async (placed) => {
|
|
8910
8736
|
let caseRunsPath;
|
|
@@ -8945,16 +8771,13 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
8945
8771
|
{ cause: error }
|
|
8946
8772
|
);
|
|
8947
8773
|
}
|
|
8948
|
-
frozenAttachments = await freezeAttachments(placed.ledgerHome, attachmentPaths, placed.attachmentsDirectory);
|
|
8949
8774
|
return {
|
|
8950
8775
|
issueNumber,
|
|
8951
8776
|
caseRunsPath,
|
|
8952
|
-
caseIdentity
|
|
8953
|
-
attachments: persistedAttachmentRefs(frozenAttachments)
|
|
8777
|
+
caseIdentity
|
|
8954
8778
|
};
|
|
8955
8779
|
}
|
|
8956
8780
|
});
|
|
8957
|
-
return { ...admittedDoctor, attachments: frozenAttachments };
|
|
8958
8781
|
}
|
|
8959
8782
|
case "source-locator": {
|
|
8960
8783
|
const projectRoot = resolve11(parsed.project ?? shared.cwd);
|
|
@@ -8981,7 +8804,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
8981
8804
|
instruction: "",
|
|
8982
8805
|
attachmentPaths: [],
|
|
8983
8806
|
...project,
|
|
8984
|
-
|
|
8807
|
+
recordAttachments: false,
|
|
8985
8808
|
admittedFields: {
|
|
8986
8809
|
sourceRunPath: sourceRun.runDirectory,
|
|
8987
8810
|
sourceRun
|
|
@@ -8998,7 +8821,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
8998
8821
|
instruction,
|
|
8999
8822
|
attachmentPaths: [],
|
|
9000
8823
|
...project,
|
|
9001
|
-
|
|
8824
|
+
recordAttachments: false,
|
|
9002
8825
|
admittedFields: { baseRevision }
|
|
9003
8826
|
});
|
|
9004
8827
|
}
|
|
@@ -9110,7 +8933,7 @@ async function placeRoleAdmission(options) {
|
|
|
9110
8933
|
home: options.home,
|
|
9111
8934
|
...options.materialize === void 0 ? {} : { materialize: options.materialize }
|
|
9112
8935
|
});
|
|
9113
|
-
const attachments = options.
|
|
8936
|
+
const attachments = options.recordAttachments === false ? [] : admitCallerAttachments(options.attachmentPaths);
|
|
9114
8937
|
return {
|
|
9115
8938
|
runId,
|
|
9116
8939
|
bookKey,
|
|
@@ -9126,13 +8949,7 @@ async function placeRoleAdmission(options) {
|
|
|
9126
8949
|
};
|
|
9127
8950
|
}
|
|
9128
8951
|
function persistedAttachmentRefs(attachments) {
|
|
9129
|
-
return attachments.map((attachment) => ({
|
|
9130
|
-
provenancePath: attachment.provenancePath,
|
|
9131
|
-
frozenPath: attachment.frozenPath,
|
|
9132
|
-
byteLength: attachment.byteLength,
|
|
9133
|
-
sha256: attachment.sha256,
|
|
9134
|
-
mediaKind: attachment.mediaKind
|
|
9135
|
-
}));
|
|
8952
|
+
return attachments.map((attachment) => ({ path: attachment.path }));
|
|
9136
8953
|
}
|
|
9137
8954
|
async function persistPlacedAdmission(admitted, placed, model) {
|
|
9138
8955
|
writeAdmittedRequestPersistence(placed.runDirectory, admitted, {
|
|
@@ -9151,14 +8968,14 @@ async function persistPlacedAdmission(admitted, placed, model) {
|
|
|
9151
8968
|
}
|
|
9152
8969
|
async function admitStandardMaterialInvocation(role, options) {
|
|
9153
8970
|
const defer = options.deferPersistence === true;
|
|
9154
|
-
const
|
|
8971
|
+
const skipAttachments = defer || options.recordAttachments === false;
|
|
9155
8972
|
const placed = await placeRoleAdmission({
|
|
9156
8973
|
role,
|
|
9157
8974
|
home: options.home,
|
|
9158
8975
|
principalAuthority: options.principalAuthority,
|
|
9159
8976
|
cwd: options.cwd,
|
|
9160
8977
|
attachmentPaths: options.attachmentPaths,
|
|
9161
|
-
...
|
|
8978
|
+
...skipAttachments ? { recordAttachments: false } : {},
|
|
9162
8979
|
...defer ? { materialize: false } : {},
|
|
9163
8980
|
...options.project === void 0 ? {} : { project: options.project },
|
|
9164
8981
|
...options.createRunId === void 0 ? {} : { createRunId: options.createRunId },
|
|
@@ -9166,7 +8983,7 @@ async function admitStandardMaterialInvocation(role, options) {
|
|
|
9166
8983
|
});
|
|
9167
8984
|
const correlationFields = options.correlationId === void 0 ? {} : { correlationId: options.correlationId };
|
|
9168
8985
|
const instruction = options.instruction;
|
|
9169
|
-
const instructionEmpty = instruction.
|
|
8986
|
+
const instructionEmpty = instruction.length === 0;
|
|
9170
8987
|
const placedExtra = options.placedFields === void 0 ? void 0 : await options.placedFields(placed);
|
|
9171
8988
|
const admittedFields = {
|
|
9172
8989
|
...options.admittedFields ?? {},
|
|
@@ -9221,7 +9038,7 @@ function buildInstructionTransportPrompt(admitted) {
|
|
|
9221
9038
|
throw new Error("baseline transport prompt is missing the bound revision");
|
|
9222
9039
|
}
|
|
9223
9040
|
const lines2 = [admitted.baseRevision];
|
|
9224
|
-
if (
|
|
9041
|
+
if (admitted.instruction.length > 0) {
|
|
9225
9042
|
lines2.push("", admitted.instruction);
|
|
9226
9043
|
}
|
|
9227
9044
|
return lines2.join("\n");
|
|
@@ -9235,17 +9052,21 @@ function buildInstructionTransportPrompt(admitted) {
|
|
|
9235
9052
|
lens: admitted.lens,
|
|
9236
9053
|
authorityRefs: admitted.authorityRefs
|
|
9237
9054
|
})];
|
|
9238
|
-
if (
|
|
9055
|
+
if (admitted.instruction.length > 0) {
|
|
9239
9056
|
lines2.push("", admitted.instruction);
|
|
9240
9057
|
}
|
|
9241
9058
|
return lines2.join("\n");
|
|
9242
9059
|
}
|
|
9243
|
-
const lines = [admitted.
|
|
9244
|
-
|
|
9060
|
+
const lines = [admitted.instruction];
|
|
9061
|
+
const flaggedPaths = [
|
|
9062
|
+
...admitted.attachments.map((attachment) => `--attach ${attachment.path}`),
|
|
9063
|
+
...admitted.requestManifestPath === void 0 ? [] : [`--request-manifest ${admitted.requestManifestPath}`]
|
|
9064
|
+
];
|
|
9065
|
+
if (flaggedPaths.length > 0) {
|
|
9245
9066
|
lines.push("");
|
|
9246
|
-
lines.push("\u5DF2\u53D7\u7406\u9644\u4EF6\
|
|
9247
|
-
for (const
|
|
9248
|
-
lines.push(`- ${
|
|
9067
|
+
lines.push("\u5DF2\u53D7\u7406\u9644\u4EF6\uFF1A");
|
|
9068
|
+
for (const entry of flaggedPaths) {
|
|
9069
|
+
lines.push(`- ${entry}`);
|
|
9249
9070
|
}
|
|
9250
9071
|
}
|
|
9251
9072
|
return lines.join("\n");
|
|
@@ -9256,8 +9077,7 @@ async function materializeCountersignInvocation(admitted, options) {
|
|
|
9256
9077
|
home: options.home,
|
|
9257
9078
|
principalAuthority: options.principalAuthority,
|
|
9258
9079
|
cwd: admitted.projectRoot,
|
|
9259
|
-
attachmentPaths:
|
|
9260
|
-
freezeAttachments: false,
|
|
9080
|
+
attachmentPaths: options.attachmentPaths,
|
|
9261
9081
|
runId: admitted.runId,
|
|
9262
9082
|
...options.ticketNumber === void 0 ? {} : { assertedTicketNumber: options.ticketNumber }
|
|
9263
9083
|
});
|
|
@@ -9268,11 +9088,7 @@ async function materializeCountersignInvocation(admitted, options) {
|
|
|
9268
9088
|
if (ticketFields.ticketNumber !== void 0) {
|
|
9269
9089
|
admitted.ticketNumber = ticketFields.ticketNumber;
|
|
9270
9090
|
}
|
|
9271
|
-
|
|
9272
|
-
options.preparedAttachments,
|
|
9273
|
-
admitted.runDirectory
|
|
9274
|
-
);
|
|
9275
|
-
admitted.attachments = attachments;
|
|
9091
|
+
admitted.attachments = placement.attachments;
|
|
9276
9092
|
writeAdmittedRequestPersistence(admitted.runDirectory, admitted, {
|
|
9277
9093
|
sessionDirectory: placement.sessionDirectory,
|
|
9278
9094
|
sessionFile: placement.sessionFile
|
|
@@ -9291,10 +9107,11 @@ async function loadAdmittedJudgeRequest(runDirectory) {
|
|
|
9291
9107
|
if (typeof record.instruction !== "string") return void 0;
|
|
9292
9108
|
if (typeof record.instructionEmpty !== "boolean") return void 0;
|
|
9293
9109
|
if (!Array.isArray(record.attachments)) return void 0;
|
|
9110
|
+
const attachments = record.attachments.map((item) => normalizeAdmittedAttachment(item)).filter((item) => item !== void 0);
|
|
9294
9111
|
return {
|
|
9295
9112
|
instruction: record.instruction,
|
|
9296
9113
|
instructionEmpty: record.instructionEmpty,
|
|
9297
|
-
attachments
|
|
9114
|
+
attachments
|
|
9298
9115
|
};
|
|
9299
9116
|
} catch {
|
|
9300
9117
|
return void 0;
|
|
@@ -9529,7 +9346,7 @@ function parseAnalystArgv(args) {
|
|
|
9529
9346
|
if (taken.def.id === "attach") {
|
|
9530
9347
|
pushValue(
|
|
9531
9348
|
"attach",
|
|
9532
|
-
|
|
9349
|
+
requireProvidedOptionValue(taken.def.canonical, taken.value)
|
|
9533
9350
|
);
|
|
9534
9351
|
return;
|
|
9535
9352
|
}
|
|
@@ -10706,10 +10523,10 @@ function presentFailureTerminal(terminal, io) {
|
|
|
10706
10523
|
}
|
|
10707
10524
|
function defaultNavigatorGraceSleep() {
|
|
10708
10525
|
let timer;
|
|
10709
|
-
const sleep2 = ((ms) => new Promise((
|
|
10526
|
+
const sleep2 = ((ms) => new Promise((resolve21) => {
|
|
10710
10527
|
timer = setTimeout(() => {
|
|
10711
10528
|
timer = void 0;
|
|
10712
|
-
|
|
10529
|
+
resolve21();
|
|
10713
10530
|
}, ms);
|
|
10714
10531
|
}));
|
|
10715
10532
|
sleep2.cancel = () => {
|
|
@@ -10721,7 +10538,7 @@ function defaultNavigatorGraceSleep() {
|
|
|
10721
10538
|
return sleep2;
|
|
10722
10539
|
}
|
|
10723
10540
|
function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2 = defaultNavigatorGraceSleep()) {
|
|
10724
|
-
return new Promise((
|
|
10541
|
+
return new Promise((resolve21, reject) => {
|
|
10725
10542
|
let settled = false;
|
|
10726
10543
|
const finish = (action) => {
|
|
10727
10544
|
if (settled) return;
|
|
@@ -10730,11 +10547,11 @@ function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2
|
|
|
10730
10547
|
action();
|
|
10731
10548
|
};
|
|
10732
10549
|
void work.then(
|
|
10733
|
-
(value) => finish(() =>
|
|
10550
|
+
(value) => finish(() => resolve21({ status: "done", value })),
|
|
10734
10551
|
(error) => finish(() => reject(error))
|
|
10735
10552
|
);
|
|
10736
10553
|
void sleep2(graceMs).then(() => {
|
|
10737
|
-
finish(() =>
|
|
10554
|
+
finish(() => resolve21({ status: "timeout" }));
|
|
10738
10555
|
});
|
|
10739
10556
|
});
|
|
10740
10557
|
}
|
|
@@ -11584,7 +11401,7 @@ var init_role_seat_runtime = __esm({
|
|
|
11584
11401
|
});
|
|
11585
11402
|
|
|
11586
11403
|
// src/archivist-record-pointer.ts
|
|
11587
|
-
import { basename as
|
|
11404
|
+
import { basename as basename9, join as join21 } from "node:path";
|
|
11588
11405
|
function bookDirectOfficerRunPointer(options) {
|
|
11589
11406
|
const submissionToolCallId = options.submissionToolCallId?.trim() ?? "";
|
|
11590
11407
|
const pointer = {
|
|
@@ -11610,7 +11427,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
|
11610
11427
|
let runDirectory = typeof raw.runDirectory === "string" && raw.runDirectory.trim() !== "" ? raw.runDirectory : void 0;
|
|
11611
11428
|
let sessionFile = raw.sessionFile;
|
|
11612
11429
|
const recordedRunDirectory = runDirectory ?? runDirectoryOfSessionFile(sessionFile);
|
|
11613
|
-
const leaf = parseRunLeaf(
|
|
11430
|
+
const leaf = parseRunLeaf(basename9(recordedRunDirectory));
|
|
11614
11431
|
const parentIdentity = await readRoleRunIdentity(parentRunDirectory);
|
|
11615
11432
|
if (leaf !== void 0 && parentIdentity !== void 0) {
|
|
11616
11433
|
const currentRunDirectory = await findRunDirectoryById(
|
|
@@ -11971,7 +11788,7 @@ var init_submission_gate = __esm({
|
|
|
11971
11788
|
|
|
11972
11789
|
// src/session-opening-materials.ts
|
|
11973
11790
|
import { existsSync as existsSync8 } from "node:fs";
|
|
11974
|
-
import { readFile as
|
|
11791
|
+
import { readFile as readFile10 } from "node:fs/promises";
|
|
11975
11792
|
import { dirname as dirname14, join as join22 } from "node:path";
|
|
11976
11793
|
import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
11977
11794
|
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
@@ -11987,7 +11804,7 @@ function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
|
11987
11804
|
return fileURLToPath(new URL("..", moduleUrl));
|
|
11988
11805
|
}
|
|
11989
11806
|
async function readPackageMaterial(relativePath) {
|
|
11990
|
-
return
|
|
11807
|
+
return readFile10(fileURLToPath(new URL(relativePath, packageRootUrl)), "utf8");
|
|
11991
11808
|
}
|
|
11992
11809
|
async function joinPackageMaterials(relativePaths) {
|
|
11993
11810
|
const chunks = [];
|
|
@@ -12045,7 +11862,7 @@ __export(auditor_soul_exports, {
|
|
|
12045
11862
|
readAuditorResumeBinding: () => readAuditorResumeBinding,
|
|
12046
11863
|
resolveAuditorSubject: () => resolveAuditorSubject
|
|
12047
11864
|
});
|
|
12048
|
-
import { basename as
|
|
11865
|
+
import { basename as basename10 } from "node:path";
|
|
12049
11866
|
function auditorSoulRelativePath(role) {
|
|
12050
11867
|
return `souls/${role}-auditor.md`;
|
|
12051
11868
|
}
|
|
@@ -12081,7 +11898,7 @@ function loadAuditorReferenceMaterialsFromSubjectInput(raw) {
|
|
|
12081
11898
|
return loadAuditorReferenceMaterials(resolveAuditorSubject(raw));
|
|
12082
11899
|
}
|
|
12083
11900
|
function subjectFromSourceDirectory(sourceRunDirectory) {
|
|
12084
|
-
const role = parseRunLeaf(
|
|
11901
|
+
const role = parseRunLeaf(basename10(sourceRunDirectory))?.role;
|
|
12085
11902
|
return isAuditorSoulRole(role) ? role : void 0;
|
|
12086
11903
|
}
|
|
12087
11904
|
async function readAuditorResumeBinding(runDirectory) {
|
|
@@ -12121,7 +11938,7 @@ var init_auditor_soul = __esm({
|
|
|
12121
11938
|
|
|
12122
11939
|
// src/public-cli/machine-method-skills.ts
|
|
12123
11940
|
import { accessSync, constants as constants2, statSync as statSync5 } from "node:fs";
|
|
12124
|
-
import { lstat as
|
|
11941
|
+
import { lstat as lstat2, mkdir as mkdir2, symlink } from "node:fs/promises";
|
|
12125
11942
|
import { join as join24 } from "node:path";
|
|
12126
11943
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
12127
11944
|
function skillRoot(home) {
|
|
@@ -12151,7 +11968,7 @@ function linkedSkillRoot(home, host) {
|
|
|
12151
11968
|
}
|
|
12152
11969
|
async function occupied(path) {
|
|
12153
11970
|
try {
|
|
12154
|
-
await
|
|
11971
|
+
await lstat2(path);
|
|
12155
11972
|
return true;
|
|
12156
11973
|
} catch (error) {
|
|
12157
11974
|
if (error.code !== "ENOENT") throw error;
|
|
@@ -12648,7 +12465,6 @@ var init_auto_resume = __esm({
|
|
|
12648
12465
|
|
|
12649
12466
|
// src/public-cli/post-admission.ts
|
|
12650
12467
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
12651
|
-
import { isAbsolute as isAbsolute7, join as join25, resolve as resolve13 } from "node:path";
|
|
12652
12468
|
function describeCaughtError(error) {
|
|
12653
12469
|
if (error instanceof Error) {
|
|
12654
12470
|
const code = error.code;
|
|
@@ -12670,7 +12486,7 @@ function projectRelocatedTurnIdentity(request, result, admitted, relocation) {
|
|
|
12670
12486
|
mutableRequest.principal = admitted.principal;
|
|
12671
12487
|
const activation = mutableRequest.activation;
|
|
12672
12488
|
if (isRecord(activation)) {
|
|
12673
|
-
for (const field of ["taskPath", "packetPath", "prerequisitesPath", "inputPath"
|
|
12489
|
+
for (const field of ["taskPath", "packetPath", "prerequisitesPath", "inputPath"]) {
|
|
12674
12490
|
const record = activation;
|
|
12675
12491
|
if (field in record) record[field] = rewrite(record[field]);
|
|
12676
12492
|
}
|
|
@@ -13403,7 +13219,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
13403
13219
|
prompt = request.message;
|
|
13404
13220
|
}
|
|
13405
13221
|
} else if (summonsPrepared !== void 0) {
|
|
13406
|
-
prompt = officerDialogue ? summonsPrepared.
|
|
13222
|
+
prompt = officerDialogue ? summonsPrepared.instruction : buildInstructionTransportPrompt(summonsPrepared);
|
|
13407
13223
|
} else if (request.summons !== void 0) {
|
|
13408
13224
|
prompt = "";
|
|
13409
13225
|
} else {
|
|
@@ -13484,24 +13300,14 @@ async function runSettledAutoResumeLoop(input) {
|
|
|
13484
13300
|
})
|
|
13485
13301
|
});
|
|
13486
13302
|
}
|
|
13487
|
-
function
|
|
13488
|
-
const absolute = isAbsolute7(attachmentPath) ? attachmentPath : resolve13(attachmentPath);
|
|
13489
|
-
return pathContainedIn(join25(runDirectory, "attachments"), absolute);
|
|
13490
|
-
}
|
|
13491
|
-
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
13303
|
+
async function prepareSummonsResumeMaterials(_runDirectory, summons) {
|
|
13492
13304
|
if (summons === void 0) return void 0;
|
|
13493
13305
|
if (summons.instruction === void 0 && (summons.attachmentPaths?.length ?? 0) === 0) {
|
|
13494
13306
|
return void 0;
|
|
13495
13307
|
}
|
|
13496
13308
|
const instruction = summons.instruction ?? "";
|
|
13497
|
-
const instructionEmpty = summons.instructionEmpty ?? instruction.
|
|
13498
|
-
|
|
13499
|
-
if (summons.attachmentPaths !== void 0 && summons.attachmentPaths.length > 0) {
|
|
13500
|
-
const alreadyFrozen = summons.attachmentPaths.every(
|
|
13501
|
-
(path) => isAlreadyFrozenSummonsAttachment(runDirectory, path)
|
|
13502
|
-
);
|
|
13503
|
-
attachments = alreadyFrozen ? summons.attachmentPaths.map((frozenPath) => ({ frozenPath })) : await freezeAttachmentsIntoRun(summons.attachmentPaths, runDirectory);
|
|
13504
|
-
}
|
|
13309
|
+
const instructionEmpty = summons.instructionEmpty ?? instruction.length === 0;
|
|
13310
|
+
const attachments = (summons.attachmentPaths ?? []).map((path) => ({ path }));
|
|
13505
13311
|
return { instruction, instructionEmpty, attachments };
|
|
13506
13312
|
}
|
|
13507
13313
|
async function runPostAdmissionSeatResume(input) {
|
|
@@ -13550,23 +13356,6 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
13550
13356
|
openCourtAttemptId = openCourt.courtAttemptId;
|
|
13551
13357
|
}
|
|
13552
13358
|
}
|
|
13553
|
-
if (request.summons !== void 0) {
|
|
13554
|
-
const prepared = await prepareSummonsResumeMaterials(
|
|
13555
|
-
admittedForBuild.runDirectory,
|
|
13556
|
-
request.summons
|
|
13557
|
-
);
|
|
13558
|
-
if (prepared !== void 0 && (request.summons.attachmentPaths?.length ?? 0) > 0) {
|
|
13559
|
-
request = {
|
|
13560
|
-
...request,
|
|
13561
|
-
summons: {
|
|
13562
|
-
...request.summons,
|
|
13563
|
-
attachmentPaths: prepared.attachments.map(
|
|
13564
|
-
(attachment) => attachment.frozenPath
|
|
13565
|
-
)
|
|
13566
|
-
}
|
|
13567
|
-
};
|
|
13568
|
-
}
|
|
13569
|
-
}
|
|
13570
13359
|
let turnRequest = await input.buildTurnRequest(admittedForBuild, request);
|
|
13571
13360
|
if (turnRequest.continuation.kind === "resume" && turnRequest.continuation.hostSessionId === void 0) {
|
|
13572
13361
|
const hostSessionId = await readStoredHostSessionId(
|
|
@@ -13816,7 +13605,6 @@ var init_post_admission = __esm({
|
|
|
13816
13605
|
init_invocation();
|
|
13817
13606
|
init_submission_ledger();
|
|
13818
13607
|
init_run_ticket_number();
|
|
13819
|
-
init_activation_ledger_topology();
|
|
13820
13608
|
init_session_identity();
|
|
13821
13609
|
init_sitian_facade();
|
|
13822
13610
|
init_receipt_delivery_policy();
|
|
@@ -13956,7 +13744,7 @@ __export(instruction_seat_run_exports, {
|
|
|
13956
13744
|
runPublicInstructionSeat: () => runPublicInstructionSeat,
|
|
13957
13745
|
runPublicInstructionSeatResume: () => runPublicInstructionSeatResume
|
|
13958
13746
|
});
|
|
13959
|
-
import { dirname as dirname15, resolve as
|
|
13747
|
+
import { dirname as dirname15, resolve as resolve13 } from "node:path";
|
|
13960
13748
|
function unreadablePostSubmissionStatus(admitted, terminal) {
|
|
13961
13749
|
if (terminal?.roleOutcome.kind !== "accepted") return void 0;
|
|
13962
13750
|
const route = POST_SUBMISSION_ROUTING[admitted.role];
|
|
@@ -14184,7 +13972,7 @@ async function runOmittedLensBatch(argv, parsed, env, io) {
|
|
|
14184
13972
|
const children = await summonParallelReviewerLenses2({
|
|
14185
13973
|
argv,
|
|
14186
13974
|
cwd: env.cwd,
|
|
14187
|
-
projectRoot:
|
|
13975
|
+
projectRoot: resolve13(parsed.project ?? env.cwd),
|
|
14188
13976
|
baseRevision: parsed.baseRevision ?? "",
|
|
14189
13977
|
home: env.home,
|
|
14190
13978
|
agentDir: env.agentDir,
|
|
@@ -14266,14 +14054,14 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
14266
14054
|
const resumed = await resumeSameParentInstructionSeat({
|
|
14267
14055
|
env,
|
|
14268
14056
|
io,
|
|
14269
|
-
projectRoot:
|
|
14057
|
+
projectRoot: resolve13(parsed.project ?? env.cwd),
|
|
14270
14058
|
role: "countersign",
|
|
14271
14059
|
parentRunPath: gateParentRunPath,
|
|
14272
14060
|
...isSafePositiveTicketNumber(env.boundTicketNumber) ? { ticketNumber: env.boundTicketNumber } : {},
|
|
14273
14061
|
summons: {
|
|
14274
14062
|
sourceRunPath: gateParentRunPath,
|
|
14275
14063
|
instruction: resumeInstruction,
|
|
14276
|
-
instructionEmpty: resumeInstruction.
|
|
14064
|
+
instructionEmpty: resumeInstruction.length === 0
|
|
14277
14065
|
}
|
|
14278
14066
|
});
|
|
14279
14067
|
if (resumed != null) return resumed;
|
|
@@ -14287,12 +14075,12 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
14287
14075
|
throw error;
|
|
14288
14076
|
}
|
|
14289
14077
|
try {
|
|
14290
|
-
|
|
14078
|
+
{
|
|
14291
14079
|
const materializeAdmission = async (ticketNumber) => {
|
|
14292
14080
|
await materializeCountersignInvocation(admitted, {
|
|
14293
14081
|
home: env.home,
|
|
14294
14082
|
principalAuthority: env.principalAuthority,
|
|
14295
|
-
|
|
14083
|
+
attachmentPaths: parsed.attachmentPaths ?? [],
|
|
14296
14084
|
...env.model === void 0 ? {} : { model: env.model },
|
|
14297
14085
|
...ticketNumber === void 0 ? {} : { ticketNumber }
|
|
14298
14086
|
});
|
|
@@ -14327,7 +14115,7 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
14327
14115
|
});
|
|
14328
14116
|
await relocateAdmittedRunToTicket(admitted, env.principalAuthority);
|
|
14329
14117
|
return result;
|
|
14330
|
-
}
|
|
14118
|
+
}
|
|
14331
14119
|
} catch (error) {
|
|
14332
14120
|
const rejected = usageExit(error, io);
|
|
14333
14121
|
if (rejected !== void 0) return rejected;
|
|
@@ -14392,7 +14180,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14392
14180
|
const summons = {
|
|
14393
14181
|
...sameParentInstruction(env, {
|
|
14394
14182
|
instruction: parsed.instruction ?? "",
|
|
14395
|
-
instructionEmpty: (parsed.instruction ?? "").
|
|
14183
|
+
instructionEmpty: (parsed.instruction ?? "").length === 0
|
|
14396
14184
|
}),
|
|
14397
14185
|
attachmentPaths: parsed.attachmentPaths ?? []
|
|
14398
14186
|
};
|
|
@@ -14417,7 +14205,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14417
14205
|
sourceRunPath: parentRunPath,
|
|
14418
14206
|
...sameParentInstruction(env, {
|
|
14419
14207
|
instruction: parsed.instruction ?? "",
|
|
14420
|
-
instructionEmpty: (parsed.instruction ?? "").
|
|
14208
|
+
instructionEmpty: (parsed.instruction ?? "").length === 0
|
|
14421
14209
|
}),
|
|
14422
14210
|
attachmentPaths: parsed.attachmentPaths ?? []
|
|
14423
14211
|
};
|
|
@@ -14501,7 +14289,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14501
14289
|
instruction: parsed.instruction ?? "",
|
|
14502
14290
|
projectRoot: admitted.projectRoot,
|
|
14503
14291
|
failureLabel: "secretariat unbound summons",
|
|
14504
|
-
attachmentPaths: admitted.attachments.map((attachment) => attachment.
|
|
14292
|
+
attachmentPaths: admitted.attachments.map((attachment) => attachment.path),
|
|
14505
14293
|
correlationId: admitted.runId
|
|
14506
14294
|
}, env, io);
|
|
14507
14295
|
} catch (error) {
|
|
@@ -15060,7 +14848,7 @@ var init_instruction_seat_run = __esm({
|
|
|
15060
14848
|
|
|
15061
14849
|
// src/analyst-book-key.ts
|
|
15062
14850
|
import { statSync as statSync6 } from "node:fs";
|
|
15063
|
-
import { isAbsolute as
|
|
14851
|
+
import { isAbsolute as isAbsolute7 } from "node:path";
|
|
15064
14852
|
function resolveAnalystBookKey(projectRoot) {
|
|
15065
14853
|
const identity = physicalPathIdentity(projectRoot);
|
|
15066
14854
|
let stats;
|
|
@@ -15082,7 +14870,7 @@ function resolveAnalystBookKey(projectRoot) {
|
|
|
15082
14870
|
}
|
|
15083
14871
|
}
|
|
15084
14872
|
function isSyntheticAnalystBookKey(bookKey) {
|
|
15085
|
-
return bookKey.startsWith("root:") &&
|
|
14873
|
+
return bookKey.startsWith("root:") && isAbsolute7(bookKey.slice("root:".length));
|
|
15086
14874
|
}
|
|
15087
14875
|
var init_analyst_book_key = __esm({
|
|
15088
14876
|
"src/analyst-book-key.ts"() {
|
|
@@ -15093,13 +14881,13 @@ var init_analyst_book_key = __esm({
|
|
|
15093
14881
|
});
|
|
15094
14882
|
|
|
15095
14883
|
// src/analyst-index.ts
|
|
15096
|
-
import { open, readFile as
|
|
15097
|
-
import { dirname as dirname16, join as
|
|
14884
|
+
import { open, readFile as readFile11, unlink } from "node:fs/promises";
|
|
14885
|
+
import { dirname as dirname16, join as join25 } from "node:path";
|
|
15098
14886
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
15099
14887
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
15100
14888
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
15101
14889
|
ensureRealDirectoryTree(ledgerHome, dirname16(indexPath));
|
|
15102
|
-
const lockPath =
|
|
14890
|
+
const lockPath = join25(dirname16(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
15103
14891
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
15104
14892
|
const startedAt = Date.now();
|
|
15105
14893
|
while (true) {
|
|
@@ -15126,7 +14914,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
15126
14914
|
}
|
|
15127
14915
|
}
|
|
15128
14916
|
function analystLibraryIndexPath(ledgerHome) {
|
|
15129
|
-
return
|
|
14917
|
+
return join25(ledgerHome, "analyst", "library-index.json");
|
|
15130
14918
|
}
|
|
15131
14919
|
function rowFromIssueMetricsPage(page) {
|
|
15132
14920
|
return {
|
|
@@ -15217,7 +15005,7 @@ async function readAnalystLibraryIndexPage(ledgerHome) {
|
|
|
15217
15005
|
const path = analystLibraryIndexPath(ledgerHome);
|
|
15218
15006
|
let raw;
|
|
15219
15007
|
try {
|
|
15220
|
-
raw = await
|
|
15008
|
+
raw = await readFile11(path, "utf8");
|
|
15221
15009
|
} catch (error) {
|
|
15222
15010
|
if (isMissingPathError(error)) return void 0;
|
|
15223
15011
|
throw error;
|
|
@@ -15672,7 +15460,7 @@ var init_analyst_gate_cycles_read = __esm({
|
|
|
15672
15460
|
|
|
15673
15461
|
// src/analyst-ledger.ts
|
|
15674
15462
|
import { readdir as readdir3 } from "node:fs/promises";
|
|
15675
|
-
import { basename as
|
|
15463
|
+
import { basename as basename11, join as join26 } from "node:path";
|
|
15676
15464
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
15677
15465
|
return (await readRoleRunIdentity(runDirectory))?.state;
|
|
15678
15466
|
}
|
|
@@ -15692,7 +15480,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
|
|
|
15692
15480
|
}
|
|
15693
15481
|
}
|
|
15694
15482
|
async function classifyGhostCandidate(input) {
|
|
15695
|
-
const autopsy = await autopsyWriterLock(
|
|
15483
|
+
const autopsy = await autopsyWriterLock(join26(input.runDirectory, "writer.lock"));
|
|
15696
15484
|
const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
|
|
15697
15485
|
if (leaseCheck === void 0) return { kind: "live" };
|
|
15698
15486
|
return {
|
|
@@ -15982,7 +15770,7 @@ async function classifyScopedRun(input) {
|
|
|
15982
15770
|
async function scanAnalystIssueRuns(input) {
|
|
15983
15771
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
15984
15772
|
const scopeTicketNumber = input.ticketNumber;
|
|
15985
|
-
const booksRoot =
|
|
15773
|
+
const booksRoot = join26(ledgerHome, "books");
|
|
15986
15774
|
let wholeBook = false;
|
|
15987
15775
|
let scopeRootIdentity;
|
|
15988
15776
|
let bookNames;
|
|
@@ -16015,7 +15803,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
16015
15803
|
const ghostLegs = [];
|
|
16016
15804
|
const scopeConflicts = [];
|
|
16017
15805
|
for (const book of bookNames) {
|
|
16018
|
-
const bookDir =
|
|
15806
|
+
const bookDir = join26(booksRoot, book);
|
|
16019
15807
|
let runDirectories;
|
|
16020
15808
|
try {
|
|
16021
15809
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
@@ -16024,7 +15812,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
16024
15812
|
throw error;
|
|
16025
15813
|
}
|
|
16026
15814
|
for (const runDirectory of runDirectories) {
|
|
16027
|
-
const runName =
|
|
15815
|
+
const runName = basename11(runDirectory);
|
|
16028
15816
|
const parsed = parseRunLeaf(runName);
|
|
16029
15817
|
if (parsed === void 0) continue;
|
|
16030
15818
|
let scopeFields;
|
|
@@ -16761,7 +16549,7 @@ var init_analyst_metric_family = __esm({
|
|
|
16761
16549
|
});
|
|
16762
16550
|
|
|
16763
16551
|
// src/analyst-page.ts
|
|
16764
|
-
import { dirname as dirname17, join as
|
|
16552
|
+
import { dirname as dirname17, join as join27 } from "node:path";
|
|
16765
16553
|
function analystIssuePageKey(address) {
|
|
16766
16554
|
const parts = ["book", address.bookKey];
|
|
16767
16555
|
if (address.issueNumber !== void 0) {
|
|
@@ -16772,7 +16560,7 @@ function analystIssuePageKey(address) {
|
|
|
16772
16560
|
return sha256Hex(parts.join("\0")).slice(0, 32);
|
|
16773
16561
|
}
|
|
16774
16562
|
function analystIssuePagePath(ledgerHome, address) {
|
|
16775
|
-
return
|
|
16563
|
+
return join27(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
16776
16564
|
}
|
|
16777
16565
|
function analystIssuePageAddressFromPage(page) {
|
|
16778
16566
|
return {
|
|
@@ -17008,7 +16796,7 @@ var init_analyst_model_groups = __esm({
|
|
|
17008
16796
|
});
|
|
17009
16797
|
|
|
17010
16798
|
// src/analyst-entry.ts
|
|
17011
|
-
import { readFile as
|
|
16799
|
+
import { readFile as readFile13 } from "node:fs/promises";
|
|
17012
16800
|
import { Type as Type18 } from "typebox";
|
|
17013
16801
|
function cachedPageMatchesRequestedScope(page, input) {
|
|
17014
16802
|
if (page.bookKey !== input.bookKey) return false;
|
|
@@ -17036,7 +16824,7 @@ async function readOrComputeAnalystIssuePage(input, options) {
|
|
|
17036
16824
|
...issueNumber === void 0 && input.bookKey === void 0 ? { scopeRootIdentity: projectRoot } : {}
|
|
17037
16825
|
});
|
|
17038
16826
|
try {
|
|
17039
|
-
const raw = await
|
|
16827
|
+
const raw = await readFile13(pagePath, "utf8");
|
|
17040
16828
|
const page = JSON.parse(raw);
|
|
17041
16829
|
if (cachedPageMatchesRequestedScope(page, { bookKey, ...input })) {
|
|
17042
16830
|
const ghostScan = await scanAnalystIssueRuns({
|
|
@@ -17137,7 +16925,7 @@ async function runAnalystModelGroupsMode(input, home) {
|
|
|
17137
16925
|
scopeRootIdentity: projectRoot
|
|
17138
16926
|
});
|
|
17139
16927
|
try {
|
|
17140
|
-
const raw = await
|
|
16928
|
+
const raw = await readFile13(pagePath, "utf8");
|
|
17141
16929
|
JSON.parse(raw);
|
|
17142
16930
|
} catch (error) {
|
|
17143
16931
|
if (!isMissingPathError(error)) {
|
|
@@ -17234,8 +17022,8 @@ var init_analyst_entry = __esm({
|
|
|
17234
17022
|
});
|
|
17235
17023
|
|
|
17236
17024
|
// src/public-cli/analyst-run.ts
|
|
17237
|
-
import { readFile as
|
|
17238
|
-
import { isAbsolute as
|
|
17025
|
+
import { readFile as readFile14 } from "node:fs/promises";
|
|
17026
|
+
import { isAbsolute as isAbsolute8, resolve as resolve14 } from "node:path";
|
|
17239
17027
|
import { Value as Value3 } from "typebox/value";
|
|
17240
17028
|
function resolveAnalystIssueBookKeyFromCwd(cwd = process.cwd()) {
|
|
17241
17029
|
try {
|
|
@@ -17285,10 +17073,10 @@ async function buildAnalystSweepModeInputFromAttachmentPaths(attachmentPaths) {
|
|
|
17285
17073
|
);
|
|
17286
17074
|
}
|
|
17287
17075
|
const sourcePath = attachmentPaths[0];
|
|
17288
|
-
const absolute =
|
|
17076
|
+
const absolute = isAbsolute8(sourcePath) ? sourcePath : resolve14(sourcePath);
|
|
17289
17077
|
let bytes;
|
|
17290
17078
|
try {
|
|
17291
|
-
bytes = await
|
|
17079
|
+
bytes = await readFile14(absolute);
|
|
17292
17080
|
} catch (error) {
|
|
17293
17081
|
throw new CliUsageError(
|
|
17294
17082
|
`analyst sweep attachment is not a readable regular file: ${sourcePath}`,
|
|
@@ -18318,7 +18106,7 @@ __export(public_role_summons_exports, {
|
|
|
18318
18106
|
import { execFile as execFile3 } from "node:child_process";
|
|
18319
18107
|
import { existsSync as existsSync9 } from "node:fs";
|
|
18320
18108
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
18321
|
-
import { join as
|
|
18109
|
+
import { join as join28 } from "node:path";
|
|
18322
18110
|
import { promisify as promisify3 } from "node:util";
|
|
18323
18111
|
function createCapturingIo() {
|
|
18324
18112
|
const chunks = [];
|
|
@@ -18342,7 +18130,7 @@ function parentDir(path) {
|
|
|
18342
18130
|
function walkPackageRoot(start) {
|
|
18343
18131
|
let dir = start;
|
|
18344
18132
|
for (let i = 0; i < 12; i += 1) {
|
|
18345
|
-
if (existsSync9(
|
|
18133
|
+
if (existsSync9(join28(dir, "package.json")) && existsSync9(join28(dir, "souls"))) {
|
|
18346
18134
|
return dir;
|
|
18347
18135
|
}
|
|
18348
18136
|
const parent = parentDir(dir);
|
|
@@ -18562,7 +18350,7 @@ async function summonPublicRole(options) {
|
|
|
18562
18350
|
runId: resumeRunId,
|
|
18563
18351
|
summons: {
|
|
18564
18352
|
instruction,
|
|
18565
|
-
instructionEmpty: instruction.
|
|
18353
|
+
instructionEmpty: instruction.length === 0
|
|
18566
18354
|
}
|
|
18567
18355
|
},
|
|
18568
18356
|
env,
|
|
@@ -18951,7 +18739,7 @@ var init_compliance_transport = __esm({
|
|
|
18951
18739
|
});
|
|
18952
18740
|
|
|
18953
18741
|
// src/role-run-relocation.ts
|
|
18954
|
-
import { dirname as dirname18, join as
|
|
18742
|
+
import { dirname as dirname18, join as join29, sep as sep4 } from "node:path";
|
|
18955
18743
|
function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
|
|
18956
18744
|
if (typeof value !== "string") return value;
|
|
18957
18745
|
if (value === oldRunDirectory) return newRunDirectory;
|
|
@@ -19031,13 +18819,6 @@ function rewriteSourceRunLocator(value, rewrites) {
|
|
|
19031
18819
|
function rewriteAdmittedRoleRunPage(page, rewrites) {
|
|
19032
18820
|
rewriteRunDirectoryPathFieldsAgainstRewrites(page, ADMITTED_PAGE_FIELDS, rewrites);
|
|
19033
18821
|
rewriteSourceRunLocator(page.sourceRun, rewrites);
|
|
19034
|
-
if (Array.isArray(page.attachments)) {
|
|
19035
|
-
for (const attachment of page.attachments) {
|
|
19036
|
-
if (isRecord(attachment)) {
|
|
19037
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(attachment, ["frozenPath"], rewrites);
|
|
19038
|
-
}
|
|
19039
|
-
}
|
|
19040
|
-
}
|
|
19041
18822
|
if (isRecord(page.principal)) {
|
|
19042
18823
|
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
19043
18824
|
page.principal,
|
|
@@ -19065,7 +18846,7 @@ var init_role_run_relocation = __esm({
|
|
|
19065
18846
|
"taskPath",
|
|
19066
18847
|
"packetPath",
|
|
19067
18848
|
"prerequisitesPath",
|
|
19068
|
-
|
|
18849
|
+
// #1165: requestManifestPath is a caller path — never rewrite.
|
|
19069
18850
|
"mergerInputPath",
|
|
19070
18851
|
"sourceRunPath"
|
|
19071
18852
|
];
|
|
@@ -19100,8 +18881,8 @@ __export(run_lifecycle_exports, {
|
|
|
19100
18881
|
recordCurrentCourt: () => recordCurrentCourt,
|
|
19101
18882
|
writeRoleRunState: () => writeRoleRunState
|
|
19102
18883
|
});
|
|
19103
|
-
import { chmod, lstat as
|
|
19104
|
-
import { basename as
|
|
18884
|
+
import { chmod, lstat as lstat3, open as open2, readdir as readdir4, readFile as readFile15, unlink as unlink2 } from "node:fs/promises";
|
|
18885
|
+
import { basename as basename12, join as join30 } from "node:path";
|
|
19105
18886
|
function buildAutoResumeContinuationPrompt() {
|
|
19106
18887
|
return RESUME_TRANSPORT_ENVELOPE;
|
|
19107
18888
|
}
|
|
@@ -19114,7 +18895,7 @@ function parseSameTicketSummonsMaterials(raw) {
|
|
|
19114
18895
|
const record = raw;
|
|
19115
18896
|
const instruction = typeof record.instruction === "string" ? record.instruction : void 0;
|
|
19116
18897
|
const instructionEmpty = typeof record.instructionEmpty === "boolean" ? record.instructionEmpty : void 0;
|
|
19117
|
-
const attachmentPaths = Array.isArray(record.attachmentPaths) ? record.attachmentPaths.filter((p) => typeof p === "string"
|
|
18898
|
+
const attachmentPaths = Array.isArray(record.attachmentPaths) ? record.attachmentPaths.filter((p) => typeof p === "string") : void 0;
|
|
19118
18899
|
const sourceRunPath = typeof record.sourceRunPath === "string" && record.sourceRunPath.trim() !== "" ? record.sourceRunPath : void 0;
|
|
19119
18900
|
let sourceRun;
|
|
19120
18901
|
if (isRecord(record.sourceRun)) {
|
|
@@ -19339,7 +19120,7 @@ function isProcessAlive(pid) {
|
|
|
19339
19120
|
async function autopsyWriterLock(lockPath) {
|
|
19340
19121
|
let content;
|
|
19341
19122
|
try {
|
|
19342
|
-
content = await
|
|
19123
|
+
content = await readFile15(lockPath, "utf8");
|
|
19343
19124
|
} catch (error) {
|
|
19344
19125
|
if (errorCodeOf(error) === "ENOENT") return { verdict: "absent" };
|
|
19345
19126
|
return { verdict: "unknown", reason: "unreadable", readFailure: error };
|
|
@@ -19398,7 +19179,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
|
|
|
19398
19179
|
},
|
|
19399
19180
|
relocate(nextRunDirectory) {
|
|
19400
19181
|
currentRunDirectory = nextRunDirectory;
|
|
19401
|
-
currentLockPath =
|
|
19182
|
+
currentLockPath = join30(nextRunDirectory, WRITER_LOCK_FILE);
|
|
19402
19183
|
},
|
|
19403
19184
|
async release() {
|
|
19404
19185
|
if (released) return;
|
|
@@ -19437,10 +19218,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
19437
19218
|
};
|
|
19438
19219
|
const reportReadFailure = (error) => {
|
|
19439
19220
|
reportDiagnostic(
|
|
19440
|
-
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${
|
|
19221
|
+
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join30(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
|
|
19441
19222
|
);
|
|
19442
19223
|
};
|
|
19443
|
-
const lockPath =
|
|
19224
|
+
const lockPath = join30(runDirectory, WRITER_LOCK_FILE);
|
|
19444
19225
|
let lastAutopsy = { verdict: "absent" };
|
|
19445
19226
|
let lastReclaimFailure;
|
|
19446
19227
|
for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
|
|
@@ -19497,7 +19278,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
19497
19278
|
async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
19498
19279
|
if (runId.trim() === "") return void 0;
|
|
19499
19280
|
const ledgerHome = resolveActivationLedgerHome(home);
|
|
19500
|
-
const booksRoot =
|
|
19281
|
+
const booksRoot = join30(ledgerHome, "books");
|
|
19501
19282
|
let bookKeys;
|
|
19502
19283
|
try {
|
|
19503
19284
|
bookKeys = await readdir4(booksRoot);
|
|
@@ -19532,7 +19313,7 @@ async function runHasFormedSessionPrincipal(runDirectory) {
|
|
|
19532
19313
|
if (disk === void 0) return false;
|
|
19533
19314
|
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : sessionFileIn(disk.principalWire.sessionDirectory);
|
|
19534
19315
|
try {
|
|
19535
|
-
const stat2 = await
|
|
19316
|
+
const stat2 = await lstat3(sessionFile);
|
|
19536
19317
|
return stat2.isFile() && !stat2.isSymbolicLink();
|
|
19537
19318
|
} catch (error) {
|
|
19538
19319
|
if (errorCodeOf(error) === "ENOENT") return false;
|
|
@@ -19548,7 +19329,7 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
19548
19329
|
let runDirectories;
|
|
19549
19330
|
try {
|
|
19550
19331
|
runDirectories = await listBookRunDirectories(
|
|
19551
|
-
input.ticketNumber === void 0 ? bookDir :
|
|
19332
|
+
input.ticketNumber === void 0 ? bookDir : join30(bookDir, String(input.ticketNumber))
|
|
19552
19333
|
);
|
|
19553
19334
|
} catch (error) {
|
|
19554
19335
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -19556,7 +19337,7 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
19556
19337
|
}
|
|
19557
19338
|
let best;
|
|
19558
19339
|
for (const runDirectory of runDirectories) {
|
|
19559
|
-
const parsed = parseRunLeaf(
|
|
19340
|
+
const parsed = parseRunLeaf(basename12(runDirectory));
|
|
19560
19341
|
if (parsed === void 0 || parsed.role !== input.role) continue;
|
|
19561
19342
|
const runId = parsed.runId;
|
|
19562
19343
|
const parentPath = await readRunParentPath(runDirectory);
|
|
@@ -19613,7 +19394,6 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19613
19394
|
let repository;
|
|
19614
19395
|
let repositoryDisplay;
|
|
19615
19396
|
let requestManifestPath;
|
|
19616
|
-
let manifestDigest;
|
|
19617
19397
|
let waitWindowMs;
|
|
19618
19398
|
let issueNumber;
|
|
19619
19399
|
let caseRunsPath;
|
|
@@ -19636,7 +19416,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19636
19416
|
instructionEmpty = record.instructionEmpty;
|
|
19637
19417
|
}
|
|
19638
19418
|
if (Array.isArray(record.attachments)) {
|
|
19639
|
-
attachments = record.attachments;
|
|
19419
|
+
attachments = record.attachments.map((item) => normalizeAdmittedAttachment(item)).filter((item) => item !== void 0);
|
|
19640
19420
|
}
|
|
19641
19421
|
if (record.phase === "plan" || record.phase === "apply") {
|
|
19642
19422
|
phase = record.phase;
|
|
@@ -19668,12 +19448,9 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19668
19448
|
if (typeof record.repositoryDisplay === "string" && record.repositoryDisplay.trim() !== "") {
|
|
19669
19449
|
repositoryDisplay = record.repositoryDisplay;
|
|
19670
19450
|
}
|
|
19671
|
-
if (typeof record.requestManifestPath === "string"
|
|
19451
|
+
if (typeof record.requestManifestPath === "string") {
|
|
19672
19452
|
requestManifestPath = record.requestManifestPath;
|
|
19673
19453
|
}
|
|
19674
|
-
if (typeof record.manifestDigest === "string" && record.manifestDigest.trim() !== "") {
|
|
19675
|
-
manifestDigest = record.manifestDigest;
|
|
19676
|
-
}
|
|
19677
19454
|
if (typeof record.waitWindowMs === "number" && Number.isSafeInteger(record.waitWindowMs) && record.waitWindowMs >= 1) {
|
|
19678
19455
|
waitWindowMs = record.waitWindowMs;
|
|
19679
19456
|
}
|
|
@@ -19767,7 +19544,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19767
19544
|
);
|
|
19768
19545
|
}
|
|
19769
19546
|
}
|
|
19770
|
-
const sourceRunLeaf = parseRunLeaf(
|
|
19547
|
+
const sourceRunLeaf = parseRunLeaf(basename12(sourceRunPath ?? ""));
|
|
19771
19548
|
const referencedRunId = sourceRun?.runId ?? sourceRunLeaf?.runId;
|
|
19772
19549
|
const referencedRole = sourceRun?.role ?? sourceRunLeaf?.role;
|
|
19773
19550
|
if (referencedRunId !== void 0 && referencedRunId !== "") {
|
|
@@ -19807,7 +19584,6 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19807
19584
|
...repository === void 0 ? {} : { repository },
|
|
19808
19585
|
...repositoryDisplay === void 0 ? {} : { repositoryDisplay },
|
|
19809
19586
|
...requestManifestPath === void 0 ? {} : { requestManifestPath },
|
|
19810
|
-
...manifestDigest === void 0 ? {} : { manifestDigest },
|
|
19811
19587
|
...waitWindowMs === void 0 ? {} : { waitWindowMs },
|
|
19812
19588
|
...issueNumber === void 0 ? {} : { issueNumber },
|
|
19813
19589
|
...caseRunsPath === void 0 ? {} : { caseRunsPath },
|
|
@@ -19997,8 +19773,8 @@ function admitResumedRole(loaded) {
|
|
|
19997
19773
|
return admitted;
|
|
19998
19774
|
}
|
|
19999
19775
|
case "collect-target": {
|
|
20000
|
-
const { prNumber, repository, repositoryDisplay
|
|
20001
|
-
if (repository === void 0 || repositoryDisplay === void 0
|
|
19776
|
+
const { prNumber, repository, repositoryDisplay } = fields;
|
|
19777
|
+
if (repository === void 0 || repositoryDisplay === void 0) {
|
|
20002
19778
|
throw new CliUsageError(
|
|
20003
19779
|
`role run admitted collector repository identity is missing: ${runId}`
|
|
20004
19780
|
);
|
|
@@ -20021,8 +19797,7 @@ function admitResumedRole(loaded) {
|
|
|
20021
19797
|
...prNumber === void 0 ? {} : { prNumber },
|
|
20022
19798
|
repository: parsedRepository,
|
|
20023
19799
|
...fields.requestManifestPath === void 0 ? {} : { requestManifestPath: fields.requestManifestPath },
|
|
20024
|
-
...fields.waitWindowMs === void 0 ? {} : { waitWindowMs: fields.waitWindowMs }
|
|
20025
|
-
manifestDigest
|
|
19800
|
+
...fields.waitWindowMs === void 0 ? {} : { waitWindowMs: fields.waitWindowMs }
|
|
20026
19801
|
};
|
|
20027
19802
|
return admitted;
|
|
20028
19803
|
}
|
|
@@ -20105,7 +19880,7 @@ var init_run_lifecycle = __esm({
|
|
|
20105
19880
|
});
|
|
20106
19881
|
|
|
20107
19882
|
// src/archivist-record-topology.ts
|
|
20108
|
-
import { join as
|
|
19883
|
+
import { join as join31 } from "node:path";
|
|
20109
19884
|
function resolveNavigatorWorkSubjectPlacement(input) {
|
|
20110
19885
|
let ledgerHome;
|
|
20111
19886
|
if (input.parentSessionFile !== void 0 && input.parentSessionFile.length > 0) {
|
|
@@ -20118,7 +19893,7 @@ function resolveNavigatorWorkSubjectPlacement(input) {
|
|
|
20118
19893
|
const digest = sha256Hex(input.subject).slice(0, 32);
|
|
20119
19894
|
return {
|
|
20120
19895
|
ledgerHome,
|
|
20121
|
-
sessionDir:
|
|
19896
|
+
sessionDir: join31(
|
|
20122
19897
|
activationBookDirectory(ledgerHome, resolveBookKeyFromGit(input.cwd)),
|
|
20123
19898
|
NAVIGATOR_RECORD_KIND,
|
|
20124
19899
|
digest
|
|
@@ -20191,7 +19966,7 @@ import {
|
|
|
20191
19966
|
statSync as statSync7,
|
|
20192
19967
|
writeFileSync as writeFileSync2
|
|
20193
19968
|
} from "node:fs";
|
|
20194
|
-
import { dirname as dirname19, resolve as
|
|
19969
|
+
import { dirname as dirname19, resolve as resolve15, join as join32 } from "node:path";
|
|
20195
19970
|
import { StringDecoder } from "node:string_decoder";
|
|
20196
19971
|
function readCurrentSession(sessionDir) {
|
|
20197
19972
|
const ledger = currentSessionLedgerPath(sessionDir);
|
|
@@ -20225,7 +20000,7 @@ function isCurrentSessionClaimRace(error) {
|
|
|
20225
20000
|
return errnoCode(error.cause) === "EEXIST";
|
|
20226
20001
|
}
|
|
20227
20002
|
function currentSessionLedgerPath(sessionDir) {
|
|
20228
|
-
return
|
|
20003
|
+
return join32(sessionDir, CURRENT_SESSION_LEDGER);
|
|
20229
20004
|
}
|
|
20230
20005
|
function readBoundedSessionHeader(filePath) {
|
|
20231
20006
|
const fd = openSync(filePath, "r");
|
|
@@ -20298,8 +20073,8 @@ function parseSessionHeaderLine(line2) {
|
|
|
20298
20073
|
};
|
|
20299
20074
|
}
|
|
20300
20075
|
function mostRecentNavigatorSessionFile(sessionDir, cwd) {
|
|
20301
|
-
const absoluteSessionDir =
|
|
20302
|
-
const absoluteCwd =
|
|
20076
|
+
const absoluteSessionDir = resolve15(sessionDir);
|
|
20077
|
+
const absoluteCwd = resolve15(cwd);
|
|
20303
20078
|
let names;
|
|
20304
20079
|
try {
|
|
20305
20080
|
names = readdirSync3(absoluteSessionDir);
|
|
@@ -20312,7 +20087,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
|
|
|
20312
20087
|
const matched = [];
|
|
20313
20088
|
for (const name of names) {
|
|
20314
20089
|
if (!name.endsWith(".jsonl")) continue;
|
|
20315
|
-
const filePath =
|
|
20090
|
+
const filePath = join32(absoluteSessionDir, name);
|
|
20316
20091
|
let st;
|
|
20317
20092
|
try {
|
|
20318
20093
|
st = statSync7(filePath);
|
|
@@ -20334,7 +20109,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
|
|
|
20334
20109
|
}
|
|
20335
20110
|
if (header === void 0) continue;
|
|
20336
20111
|
if (typeof header.cwd !== "string" || header.cwd.length === 0) continue;
|
|
20337
|
-
if (
|
|
20112
|
+
if (resolve15(header.cwd) !== absoluteCwd) continue;
|
|
20338
20113
|
matched.push({ path: filePath, mtimeMs: st.mtimeMs });
|
|
20339
20114
|
}
|
|
20340
20115
|
if (matched.length === 0) return void 0;
|
|
@@ -20364,8 +20139,8 @@ function resolveNavigatorNestContinuation(sessionDir, cwd) {
|
|
|
20364
20139
|
}
|
|
20365
20140
|
}
|
|
20366
20141
|
function assertRecentFinalFileUnderSessionDir(sessionDir, recentFile) {
|
|
20367
|
-
const absoluteSessionDir =
|
|
20368
|
-
const absoluteFile =
|
|
20142
|
+
const absoluteSessionDir = resolve15(sessionDir);
|
|
20143
|
+
const absoluteFile = resolve15(recentFile);
|
|
20369
20144
|
if (absoluteFile !== absoluteSessionDir && !pathContainedIn(absoluteSessionDir, absoluteFile)) {
|
|
20370
20145
|
throw new ActivationLedgerError(
|
|
20371
20146
|
`archivist record session must be under the authorized nest (${sessionDir}): ${recentFile}`
|
|
@@ -20420,7 +20195,7 @@ function createRecordSessionOpen(options, host = piRecordSessionHost) {
|
|
|
20420
20195
|
throw new Error("Durable record ownership requires a parent session inside the ledger home");
|
|
20421
20196
|
} else {
|
|
20422
20197
|
ledgerHome = resolveActivationLedgerHomeForPath(parentFile);
|
|
20423
|
-
const parentResolved =
|
|
20198
|
+
const parentResolved = resolve15(parentFile);
|
|
20424
20199
|
if (!physicallyContainedIn(ledgerHome, parentResolved)) {
|
|
20425
20200
|
throw new Error("Durable record ownership requires a parent session inside the ledger home");
|
|
20426
20201
|
}
|
|
@@ -20492,21 +20267,21 @@ init_host_descriptions();
|
|
|
20492
20267
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
20493
20268
|
|
|
20494
20269
|
// src/role-runtime-dependencies.ts
|
|
20495
|
-
import { readFile as
|
|
20270
|
+
import { readFile as readFile17 } from "node:fs/promises";
|
|
20496
20271
|
init_doctor_evidence();
|
|
20497
20272
|
|
|
20498
20273
|
// src/navigator-attendance.ts
|
|
20499
20274
|
init_navigator_invocation_identity();
|
|
20500
20275
|
init_packaged_role_registry();
|
|
20501
20276
|
init_activation_ledger_topology();
|
|
20502
|
-
import { resolve as
|
|
20277
|
+
import { resolve as resolve16 } from "node:path";
|
|
20503
20278
|
import "@earendil-works/pi-coding-agent";
|
|
20504
20279
|
import { Type as Type19 } from "typebox";
|
|
20505
20280
|
|
|
20506
20281
|
// src/navigator-public-session.ts
|
|
20507
20282
|
init_host_session_record();
|
|
20508
20283
|
import { existsSync as existsSync12 } from "node:fs";
|
|
20509
|
-
import { basename as
|
|
20284
|
+
import { basename as basename13 } from "node:path";
|
|
20510
20285
|
|
|
20511
20286
|
// src/navigator-session-contracts.ts
|
|
20512
20287
|
init_unknown_value();
|
|
@@ -20816,7 +20591,7 @@ async function resolveNavigatorLedgerHome(context) {
|
|
|
20816
20591
|
}
|
|
20817
20592
|
var NAVIGATOR_HOST_RUN_POINTER_ENTRY = "ak-navigator-host-run";
|
|
20818
20593
|
function runIdFromNavigatorDirectory(runDirectory) {
|
|
20819
|
-
const parsed = parseRunLeaf(
|
|
20594
|
+
const parsed = parseRunLeaf(basename13(runDirectory));
|
|
20820
20595
|
if (parsed === void 0 || parsed.role !== "navigator") return void 0;
|
|
20821
20596
|
return parsed.runId;
|
|
20822
20597
|
}
|
|
@@ -21053,7 +20828,7 @@ function navigatorSubjectKey(subjectRoot, subject, provenance = "role_input") {
|
|
|
21053
20828
|
}
|
|
21054
20829
|
function navigatorSubjectKeyForInput(subjectRoot, reference, cwd = process.cwd()) {
|
|
21055
20830
|
if (issueRoot(subjectRoot) !== void 0 || !subjectRoot.includes("/.ak/work/")) return subjectRoot;
|
|
21056
|
-
const resolvedReference =
|
|
20831
|
+
const resolvedReference = resolve16(cwd, reference);
|
|
21057
20832
|
const marker = "/runs/";
|
|
21058
20833
|
if (resolvedReference.includes(marker)) {
|
|
21059
20834
|
return subjectRoot;
|
|
@@ -21450,8 +21225,8 @@ init_role_run_placement();
|
|
|
21450
21225
|
init_doctor_evidence();
|
|
21451
21226
|
init_unknown_value();
|
|
21452
21227
|
init_host_contracts();
|
|
21453
|
-
import { readFile as
|
|
21454
|
-
import { resolve as
|
|
21228
|
+
import { readFile as readFile16 } from "node:fs/promises";
|
|
21229
|
+
import { resolve as resolve17 } from "node:path";
|
|
21455
21230
|
init_notary_source_run();
|
|
21456
21231
|
init_packaged_role_registry();
|
|
21457
21232
|
init_invocation();
|
|
@@ -21459,12 +21234,12 @@ function navigatorInputReference(getFlag, role) {
|
|
|
21459
21234
|
if (getFlag === void 0) return void 0;
|
|
21460
21235
|
const name = packagedRoleInputFlag(role);
|
|
21461
21236
|
const value = name === void 0 ? void 0 : getFlag(name);
|
|
21462
|
-
return typeof value === "string" && value !== "" ?
|
|
21237
|
+
return typeof value === "string" && value !== "" ? resolve17(value) : void 0;
|
|
21463
21238
|
}
|
|
21464
21239
|
async function loadNavigatorWorkContext(options) {
|
|
21465
21240
|
const reference = navigatorInputReference(options.getFlag, options.role);
|
|
21466
21241
|
const subjectMode = packagedNavigatorSubject(options.role);
|
|
21467
|
-
const input = reference === void 0 || subjectMode === "case" || subjectMode === "source-run" ? void 0 : await
|
|
21242
|
+
const input = reference === void 0 || subjectMode === "case" || subjectMode === "source-run" ? void 0 : await readFile16(reference, "utf8");
|
|
21468
21243
|
const subjectRoot = subjectPath(reference ?? options.context.sessionManager.getSessionDir(), options.context.cwd);
|
|
21469
21244
|
let subjectKey = reference === void 0 ? subjectRoot : navigatorSubjectKeyForInput(subjectRoot, reference, options.context.cwd);
|
|
21470
21245
|
let subject = input ?? `work subject: ${subjectKey}`;
|
|
@@ -21481,7 +21256,7 @@ async function loadNavigatorWorkContext(options) {
|
|
|
21481
21256
|
}
|
|
21482
21257
|
const publicRunDir = runDirectoryFromHostContext(options.context);
|
|
21483
21258
|
const currentSessionDir = options.context.sessionManager.getSessionDir();
|
|
21484
|
-
const isBoundPublicRun = publicRunDir !== void 0 &&
|
|
21259
|
+
const isBoundPublicRun = publicRunDir !== void 0 && resolve17(currentSessionDir) === resolve17(sessionDirectoryOf(publicRunDir));
|
|
21485
21260
|
if (subjectMode === "public-instruction" && isBoundPublicRun) {
|
|
21486
21261
|
let admitted;
|
|
21487
21262
|
try {
|
|
@@ -21514,14 +21289,14 @@ async function loadNavigatorWorkContext(options) {
|
|
|
21514
21289
|
}
|
|
21515
21290
|
const workRoot = subjectRoot.includes("/.ak/work/") ? subjectRoot : void 0;
|
|
21516
21291
|
const authorityFiles = workRoot === void 0 ? [] : [
|
|
21517
|
-
|
|
21518
|
-
|
|
21519
|
-
|
|
21292
|
+
resolve17(workRoot, "authority.md"),
|
|
21293
|
+
resolve17(workRoot, "authority.txt"),
|
|
21294
|
+
resolve17(workRoot, "design-v2/owner-direction.md")
|
|
21520
21295
|
];
|
|
21521
21296
|
let authorityMaterial;
|
|
21522
21297
|
for (const path of authorityFiles) {
|
|
21523
21298
|
try {
|
|
21524
|
-
const content = await
|
|
21299
|
+
const content = await readFile16(path, "utf8");
|
|
21525
21300
|
if (content.trim() !== "") {
|
|
21526
21301
|
authorityMaterial = content;
|
|
21527
21302
|
break;
|
|
@@ -21554,7 +21329,7 @@ init_submission_ledger();
|
|
|
21554
21329
|
init_filed_submission();
|
|
21555
21330
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
21556
21331
|
import { writeSync as writeSync2 } from "node:fs";
|
|
21557
|
-
import { join as
|
|
21332
|
+
import { join as join34 } from "node:path";
|
|
21558
21333
|
import { Value as Value4 } from "typebox/value";
|
|
21559
21334
|
|
|
21560
21335
|
// src/activation-trace.ts
|
|
@@ -21606,7 +21381,7 @@ import {
|
|
|
21606
21381
|
statSync as statSync8,
|
|
21607
21382
|
writeFileSync as writeFileSync3
|
|
21608
21383
|
} from "node:fs";
|
|
21609
|
-
import { isAbsolute as
|
|
21384
|
+
import { isAbsolute as isAbsolute10, resolve as resolve18 } from "node:path";
|
|
21610
21385
|
var ActivationSessionFileMissingError = class extends Error {
|
|
21611
21386
|
code = "AK_ACTIVATION_SESSION_FILE_MISSING";
|
|
21612
21387
|
path;
|
|
@@ -21646,12 +21421,12 @@ function durableSessionPointer(sessionManager) {
|
|
|
21646
21421
|
"Workflow role activation requires a durable Pi session file principal (getSessionFile); directory-only or --no-session invocations are rejected"
|
|
21647
21422
|
);
|
|
21648
21423
|
}
|
|
21649
|
-
if (!
|
|
21424
|
+
if (!isAbsolute10(file)) {
|
|
21650
21425
|
throw new Error(
|
|
21651
21426
|
`Workflow role activation requires an absolute durable session file path; got relative path: ${file}`
|
|
21652
21427
|
);
|
|
21653
21428
|
}
|
|
21654
|
-
const resolvedFile =
|
|
21429
|
+
const resolvedFile = resolve18(file);
|
|
21655
21430
|
try {
|
|
21656
21431
|
lstatSync2(resolvedFile);
|
|
21657
21432
|
} catch (error) {
|
|
@@ -21895,7 +21670,7 @@ var COLLECTOR_TRANSPORT_FLAGS = Object.freeze([
|
|
|
21895
21670
|
Object.freeze({
|
|
21896
21671
|
name: "ak-collector-request-manifest",
|
|
21897
21672
|
definition: Object.freeze({
|
|
21898
|
-
description: "
|
|
21673
|
+
description: "Caller path to a request manifest JSON file (passed as-is; package does not read or validate).",
|
|
21899
21674
|
type: "string"
|
|
21900
21675
|
})
|
|
21901
21676
|
})
|
|
@@ -21906,19 +21681,9 @@ function buildMethodContext(activation) {
|
|
|
21906
21681
|
`host: github.com`,
|
|
21907
21682
|
`repository: ${activation.repository.canonical}`,
|
|
21908
21683
|
`prNumber: ${activation.prNumber === void 0 ? "\u672A\u7ED1\u5B9A" : String(activation.prNumber)}`,
|
|
21909
|
-
|
|
21910
|
-
`manifestDigest: ${activation.manifest.digest}`,
|
|
21684
|
+
...activation.requestManifestPath === void 0 ? [] : [`requestManifestPath: ${activation.requestManifestPath}`],
|
|
21911
21685
|
"</collector_method>"
|
|
21912
21686
|
];
|
|
21913
|
-
if (activation.manifest.requests.length > 0) {
|
|
21914
|
-
const payload = JSON.stringify({
|
|
21915
|
-
requests: activation.manifest.requests.map((request) => ({
|
|
21916
|
-
id: request.id,
|
|
21917
|
-
body: request.requestBody
|
|
21918
|
-
}))
|
|
21919
|
-
}).replaceAll("<", "\\u003c");
|
|
21920
|
-
lines.push("", "<collector_request_manifest>", payload, "</collector_request_manifest>");
|
|
21921
|
-
}
|
|
21922
21687
|
return lines.join("\n");
|
|
21923
21688
|
}
|
|
21924
21689
|
function createCollectorRoleRuntime(pi, dependencies) {
|
|
@@ -21940,12 +21705,12 @@ function createCollectorRoleRuntime(pi, dependencies) {
|
|
|
21940
21705
|
} else if (typeof prFlag === "number") {
|
|
21941
21706
|
prNumber = parseCollectorPrNumber(prFlag);
|
|
21942
21707
|
}
|
|
21943
|
-
const
|
|
21708
|
+
const requestManifestPath = typeof requestManifestFlag === "string" ? requestManifestFlag : void 0;
|
|
21944
21709
|
return {
|
|
21945
21710
|
soul,
|
|
21946
21711
|
repository,
|
|
21947
21712
|
prNumber,
|
|
21948
|
-
|
|
21713
|
+
...requestManifestPath === void 0 ? {} : { requestManifestPath }
|
|
21949
21714
|
};
|
|
21950
21715
|
},
|
|
21951
21716
|
assembleMaterials(activation, baseSystemPrompt) {
|
|
@@ -22281,7 +22046,7 @@ init_submission_errors();
|
|
|
22281
22046
|
init_worker_submission_contracts();
|
|
22282
22047
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
22283
22048
|
import { existsSync as existsSync13, lstatSync as lstatSync3, readdirSync as readdirSync4, readFileSync as readFileSync5, rmdirSync, rmSync as rmSync3 } from "node:fs";
|
|
22284
|
-
import { resolve as
|
|
22049
|
+
import { resolve as resolve19 } from "node:path";
|
|
22285
22050
|
var WORKER_SUBMISSION_GATE_RECORD_KIND = WORKER_SUBMISSION_GATE_KIND;
|
|
22286
22051
|
var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
|
|
22287
22052
|
var WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE = "commit-reminder-bounce";
|
|
@@ -22329,7 +22094,7 @@ function escapeGitConfigValueRegex(value) {
|
|
|
22329
22094
|
function unsetOwnedHooksPath(file) {
|
|
22330
22095
|
const owned = [];
|
|
22331
22096
|
for (const value of tryGetAll(file, "core.hooksPath")) {
|
|
22332
|
-
if (!ownedHook(
|
|
22097
|
+
if (!ownedHook(resolve19(value, HOOK_FILE))) continue;
|
|
22333
22098
|
try {
|
|
22334
22099
|
gitFile(file, [
|
|
22335
22100
|
"--unset-all",
|
|
@@ -22344,15 +22109,15 @@ function unsetOwnedHooksPath(file) {
|
|
|
22344
22109
|
return owned;
|
|
22345
22110
|
}
|
|
22346
22111
|
function rmOwnedDir(dir) {
|
|
22347
|
-
const hookPath =
|
|
22112
|
+
const hookPath = resolve19(dir, HOOK_FILE);
|
|
22348
22113
|
if (!ownedHook(hookPath)) return;
|
|
22349
22114
|
rmSync3(hookPath, { force: true });
|
|
22350
22115
|
if (existsSync13(dir) && readdirSync4(dir).length === 0) rmdirSync(dir);
|
|
22351
22116
|
}
|
|
22352
22117
|
function linkedGitDirs(commonDir) {
|
|
22353
|
-
const root =
|
|
22118
|
+
const root = resolve19(commonDir, "worktrees");
|
|
22354
22119
|
if (!existsSync13(root)) return [];
|
|
22355
|
-
return readdirSync4(root).map((name) =>
|
|
22120
|
+
return readdirSync4(root).map((name) => resolve19(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
|
|
22356
22121
|
}
|
|
22357
22122
|
function uninstallPackageWorkerHooks(cwd) {
|
|
22358
22123
|
let inside;
|
|
@@ -22366,14 +22131,14 @@ function uninstallPackageWorkerHooks(cwd) {
|
|
|
22366
22131
|
const clear = (configFile) => {
|
|
22367
22132
|
for (const hooks of unsetOwnedHooksPath(configFile)) rmOwnedDir(hooks);
|
|
22368
22133
|
};
|
|
22369
|
-
clear(
|
|
22370
|
-
clear(
|
|
22371
|
-
rmOwnedDir(
|
|
22372
|
-
const legacy =
|
|
22134
|
+
clear(resolve19(commonDir, "config"));
|
|
22135
|
+
clear(resolve19(commonDir, "config.worktree"));
|
|
22136
|
+
rmOwnedDir(resolve19(commonDir, HOOKS_DIR));
|
|
22137
|
+
const legacy = resolve19(commonDir, "hooks", HOOK_FILE);
|
|
22373
22138
|
if (ownedHook(legacy)) rmSync3(legacy, { force: true });
|
|
22374
22139
|
for (const gitDir of linkedGitDirs(commonDir)) {
|
|
22375
|
-
clear(
|
|
22376
|
-
rmOwnedDir(
|
|
22140
|
+
clear(resolve19(gitDir, "config.worktree"));
|
|
22141
|
+
rmOwnedDir(resolve19(gitDir, HOOKS_DIR));
|
|
22377
22142
|
}
|
|
22378
22143
|
}
|
|
22379
22144
|
function containsWrittenReason(value) {
|
|
@@ -23245,7 +23010,7 @@ function readRoleRunCoordinates(ctx, label) {
|
|
|
23245
23010
|
if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
|
|
23246
23011
|
const admitted = readPageSync(runDirectory, "admitted");
|
|
23247
23012
|
if (typeof admitted?.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
|
|
23248
|
-
throw new Error(`${label} state.jsonl admitted-request row missing projectRoot (${
|
|
23013
|
+
throw new Error(`${label} state.jsonl admitted-request row missing projectRoot (${join34(runDirectory, RUN_STATE_FILE)})`);
|
|
23249
23014
|
}
|
|
23250
23015
|
return {
|
|
23251
23016
|
runDirectory,
|
|
@@ -24095,11 +23860,11 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
24095
23860
|
packageRoot,
|
|
24096
23861
|
loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
|
|
24097
23862
|
loadRoleSoul: loadRegisteredRoleSoul,
|
|
24098
|
-
loadFixPacket: (path) =>
|
|
24099
|
-
loadCoderTask: (path) =>
|
|
23863
|
+
loadFixPacket: (path) => readFile17(path, "utf8"),
|
|
23864
|
+
loadCoderTask: (path) => readFile17(path, "utf8"),
|
|
24100
23865
|
loadDoctorCase,
|
|
24101
23866
|
loadNotarySourceRun: loadNotarySourceRunLocator,
|
|
24102
|
-
loadMergerInput: async (path) => JSON.parse(await
|
|
23867
|
+
loadMergerInput: async (path) => JSON.parse(await readFile17(path, "utf8")),
|
|
24103
23868
|
loadNavigatorWorkContext: (options) => loadNavigatorWorkContext({
|
|
24104
23869
|
context: options.context,
|
|
24105
23870
|
role: options.role,
|
|
@@ -24139,11 +23904,11 @@ init_settlement();
|
|
|
24139
23904
|
init_run_lifecycle();
|
|
24140
23905
|
init_unknown_value();
|
|
24141
23906
|
async function listen(server, path) {
|
|
24142
|
-
await new Promise((
|
|
23907
|
+
await new Promise((resolve21, reject) => {
|
|
24143
23908
|
server.once("error", reject);
|
|
24144
23909
|
server.listen(path, () => {
|
|
24145
23910
|
server.off("error", reject);
|
|
24146
|
-
|
|
23911
|
+
resolve21();
|
|
24147
23912
|
});
|
|
24148
23913
|
});
|
|
24149
23914
|
}
|
|
@@ -24568,8 +24333,8 @@ async function prepareRoleEnvelope(options) {
|
|
|
24568
24333
|
try {
|
|
24569
24334
|
const closeAll = server.closeAllConnections;
|
|
24570
24335
|
if (typeof closeAll === "function") closeAll.call(server);
|
|
24571
|
-
await new Promise((
|
|
24572
|
-
server.close((error) => error ? reject(error) :
|
|
24336
|
+
await new Promise((resolve21, reject) => {
|
|
24337
|
+
server.close((error) => error ? reject(error) : resolve21());
|
|
24573
24338
|
});
|
|
24574
24339
|
} catch (error) {
|
|
24575
24340
|
await retainPackageFault({
|
|
@@ -24709,9 +24474,9 @@ init_role_run_placement();
|
|
|
24709
24474
|
import { spawn as spawn3, spawnSync as spawnSync3 } from "node:child_process";
|
|
24710
24475
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
24711
24476
|
import { existsSync as existsSync14 } from "node:fs";
|
|
24712
|
-
import { mkdtemp
|
|
24713
|
-
import { tmpdir
|
|
24714
|
-
import { dirname as dirname22, isAbsolute as
|
|
24477
|
+
import { mkdtemp, rm as rm2, writeFile as writeFile6 } from "node:fs/promises";
|
|
24478
|
+
import { tmpdir } from "node:os";
|
|
24479
|
+
import { dirname as dirname22, isAbsolute as isAbsolute11, join as join35, resolve as resolve20 } from "node:path";
|
|
24715
24480
|
|
|
24716
24481
|
// src/external-host-turn-loop.ts
|
|
24717
24482
|
init_settlement();
|
|
@@ -25250,7 +25015,7 @@ function formatCodexFailurePayload(payload) {
|
|
|
25250
25015
|
function cwdIsGitWorkTree(cwd) {
|
|
25251
25016
|
let dir = cwd;
|
|
25252
25017
|
for (; ; ) {
|
|
25253
|
-
if (existsSync14(
|
|
25018
|
+
if (existsSync14(join35(dir, ".git"))) return true;
|
|
25254
25019
|
const parent = dirname22(dir);
|
|
25255
25020
|
if (parent === dir) return false;
|
|
25256
25021
|
dir = parent;
|
|
@@ -25279,10 +25044,10 @@ function resolveGitCommonDir(cwd) {
|
|
|
25279
25044
|
if (raw === "") {
|
|
25280
25045
|
throw new Error("git rev-parse --git-common-dir returned empty stdout");
|
|
25281
25046
|
}
|
|
25282
|
-
return
|
|
25047
|
+
return isAbsolute11(raw) ? raw : resolve20(cwd, raw);
|
|
25283
25048
|
}
|
|
25284
25049
|
function spawnHeadlessTurn(options) {
|
|
25285
|
-
return new Promise((
|
|
25050
|
+
return new Promise((resolve21, reject) => {
|
|
25286
25051
|
if (options.signal?.aborted) {
|
|
25287
25052
|
reject(hostAbortedError("headless host aborted"));
|
|
25288
25053
|
return;
|
|
@@ -25348,7 +25113,7 @@ function spawnHeadlessTurn(options) {
|
|
|
25348
25113
|
if (timer !== void 0) clearTimeout(timer);
|
|
25349
25114
|
options.signal?.removeEventListener("abort", onAbort);
|
|
25350
25115
|
if (stdinDeliveryError !== void 0) packageErrors.push(stdinDeliveryError);
|
|
25351
|
-
|
|
25116
|
+
resolve21({
|
|
25352
25117
|
packageErrors,
|
|
25353
25118
|
code,
|
|
25354
25119
|
stdout: resultStdout,
|
|
@@ -25468,8 +25233,8 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
25468
25233
|
}
|
|
25469
25234
|
const env = { ...process.env, ...config.env ?? {} };
|
|
25470
25235
|
const sessionParent = config.sessionIdentity.resolveSessionFile(request.principal);
|
|
25471
|
-
const inputsDirectory = await
|
|
25472
|
-
const systemPromptPath =
|
|
25236
|
+
const inputsDirectory = await mkdtemp(join35(tmpdir(), "ak-role-headless-"));
|
|
25237
|
+
const systemPromptPath = join35(inputsDirectory, "system-prompt.txt");
|
|
25473
25238
|
let mcpConfigPath;
|
|
25474
25239
|
let outputSchemaPath;
|
|
25475
25240
|
let startedWithSchema;
|
|
@@ -25478,13 +25243,13 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
25478
25243
|
let deliveredSchema;
|
|
25479
25244
|
if (codex) {
|
|
25480
25245
|
if (prepared.terminatingToolName !== NAVIGATOR_OUTPUT_TOOL_NAME) {
|
|
25481
|
-
outputSchemaPath =
|
|
25246
|
+
outputSchemaPath = join35(inputsDirectory, "output-schema.json");
|
|
25482
25247
|
deliveredSchema = closeJsonSchemaForCodex(prepared.jsonSchema);
|
|
25483
25248
|
await writeFile6(outputSchemaPath, `${JSON.stringify(deliveredSchema, null, 2)}
|
|
25484
25249
|
`, "utf8");
|
|
25485
25250
|
}
|
|
25486
25251
|
} else {
|
|
25487
|
-
mcpConfigPath =
|
|
25252
|
+
mcpConfigPath = join35(inputsDirectory, "mcp-config.json");
|
|
25488
25253
|
await writeFile6(
|
|
25489
25254
|
mcpConfigPath,
|
|
25490
25255
|
`${JSON.stringify(headlessMcpConfigDocument(prepared.mcpServers), null, 2)}
|
|
@@ -25496,7 +25261,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
25496
25261
|
startedWithSchema = deliveredSchema;
|
|
25497
25262
|
} catch (setupError) {
|
|
25498
25263
|
try {
|
|
25499
|
-
await
|
|
25264
|
+
await rm2(inputsDirectory, { recursive: true, force: true });
|
|
25500
25265
|
} catch (cleanupError) {
|
|
25501
25266
|
await retainPackageFault({
|
|
25502
25267
|
runDirectory: request.runDirectory,
|
|
@@ -25707,7 +25472,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
25707
25472
|
});
|
|
25708
25473
|
} finally {
|
|
25709
25474
|
try {
|
|
25710
|
-
await
|
|
25475
|
+
await rm2(inputsDirectory, { recursive: true, force: true });
|
|
25711
25476
|
} catch (error) {
|
|
25712
25477
|
await retainPackageFault({
|
|
25713
25478
|
runDirectory: request.runDirectory,
|