@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
package/dist/public-cli/main.js
CHANGED
|
@@ -17149,19 +17149,7 @@ var init_machine_method_skills = __esm({
|
|
|
17149
17149
|
}
|
|
17150
17150
|
});
|
|
17151
17151
|
|
|
17152
|
-
// src/sha256.ts
|
|
17153
|
-
import { createHash } from "node:crypto";
|
|
17154
|
-
function sha256Hex(bytes) {
|
|
17155
|
-
return createHash("sha256").update(bytes).digest("hex");
|
|
17156
|
-
}
|
|
17157
|
-
var init_sha256 = __esm({
|
|
17158
|
-
"src/sha256.ts"() {
|
|
17159
|
-
"use strict";
|
|
17160
|
-
}
|
|
17161
|
-
});
|
|
17162
|
-
|
|
17163
17152
|
// src/collector-config.ts
|
|
17164
|
-
import { readFile as readFile4 } from "node:fs/promises";
|
|
17165
17153
|
function fail3(message, cause) {
|
|
17166
17154
|
throw new Error(message, cause === void 0 ? void 0 : { cause });
|
|
17167
17155
|
}
|
|
@@ -17189,47 +17177,10 @@ function parseCollectorPrNumber(raw) {
|
|
|
17189
17177
|
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");
|
|
17190
17178
|
return value;
|
|
17191
17179
|
}
|
|
17192
|
-
function canonicalManifest(requests) {
|
|
17193
|
-
return `${JSON.stringify({ requests: requests.map((request) => ({ id: request.id, body: request.requestBody })) })}
|
|
17194
|
-
`;
|
|
17195
|
-
}
|
|
17196
|
-
function emptyCollectorManifest() {
|
|
17197
|
-
const canonicalJson2 = canonicalManifest([]);
|
|
17198
|
-
return { requests: [], canonicalJson: canonicalJson2, digest: sha256Hex(canonicalJson2) };
|
|
17199
|
-
}
|
|
17200
|
-
async function loadCollectorManifest(path) {
|
|
17201
|
-
let bytes;
|
|
17202
|
-
try {
|
|
17203
|
-
bytes = await readFile4(path);
|
|
17204
|
-
} catch (error) {
|
|
17205
|
-
fail3(`Collector request manifest is unreadable at ${path}`, error);
|
|
17206
|
-
}
|
|
17207
|
-
let parsed;
|
|
17208
|
-
try {
|
|
17209
|
-
parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
|
|
17210
|
-
} catch (error) {
|
|
17211
|
-
fail3("Collector request manifest must be UTF-8 JSON", error);
|
|
17212
|
-
}
|
|
17213
|
-
if (!isRecord(parsed)) fail3("Collector request manifest must be an object");
|
|
17214
|
-
const rawRequests = parsed.requests ?? [];
|
|
17215
|
-
if (!Array.isArray(rawRequests)) fail3("Collector request manifest requests must be an array");
|
|
17216
|
-
const requests = [];
|
|
17217
|
-
const ids = /* @__PURE__ */ new Set();
|
|
17218
|
-
for (const [index, item] of rawRequests.entries()) {
|
|
17219
|
-
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`);
|
|
17220
|
-
if (ids.has(item.id)) fail3(`Collector request manifest has duplicate request id "${item.id}"`);
|
|
17221
|
-
ids.add(item.id);
|
|
17222
|
-
requests.push({ id: item.id, requestBody: item.body });
|
|
17223
|
-
}
|
|
17224
|
-
const canonicalJson2 = canonicalManifest(requests);
|
|
17225
|
-
return { requests, canonicalJson: canonicalJson2, digest: sha256Hex(canonicalJson2), sourcePath: path };
|
|
17226
|
-
}
|
|
17227
17180
|
var COLLECTOR_OWNER_PATTERN, COLLECTOR_REPO_PATTERN;
|
|
17228
17181
|
var init_collector_config = __esm({
|
|
17229
17182
|
"src/collector-config.ts"() {
|
|
17230
17183
|
"use strict";
|
|
17231
|
-
init_sha256();
|
|
17232
|
-
init_unknown_value();
|
|
17233
17184
|
init_run_ticket_number();
|
|
17234
17185
|
COLLECTOR_OWNER_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/;
|
|
17235
17186
|
COLLECTOR_REPO_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,98}[A-Za-z0-9])?$/;
|
|
@@ -18050,13 +18001,13 @@ var init_receipt_delivery_policy = __esm({
|
|
|
18050
18001
|
});
|
|
18051
18002
|
|
|
18052
18003
|
// src/ledger-session-read.ts
|
|
18053
|
-
import { readFile as
|
|
18004
|
+
import { readFile as readFile4 } from "node:fs/promises";
|
|
18054
18005
|
async function readStrictPiSessionJsonl(path) {
|
|
18055
|
-
const text = await
|
|
18006
|
+
const text = await readFile4(path, "utf8");
|
|
18056
18007
|
return text.trim().split("\n").filter(Boolean).map((line2) => JSON.parse(line2));
|
|
18057
18008
|
}
|
|
18058
18009
|
async function readLedgerSessionJsonlLines(path) {
|
|
18059
|
-
const text = await
|
|
18010
|
+
const text = await readFile4(path, "utf8");
|
|
18060
18011
|
const lines = text.split("\n");
|
|
18061
18012
|
const out = [];
|
|
18062
18013
|
for (let index = 0; index < lines.length; index += 1) {
|
|
@@ -19164,6 +19115,17 @@ var init_dossier_resolution = __esm({
|
|
|
19164
19115
|
}
|
|
19165
19116
|
});
|
|
19166
19117
|
|
|
19118
|
+
// src/sha256.ts
|
|
19119
|
+
import { createHash } from "node:crypto";
|
|
19120
|
+
function sha256Hex(bytes) {
|
|
19121
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
19122
|
+
}
|
|
19123
|
+
var init_sha256 = __esm({
|
|
19124
|
+
"src/sha256.ts"() {
|
|
19125
|
+
"use strict";
|
|
19126
|
+
}
|
|
19127
|
+
});
|
|
19128
|
+
|
|
19167
19129
|
// src/package-contracts/terminating-tools.ts
|
|
19168
19130
|
function isTerminatingToolName(name) {
|
|
19169
19131
|
return TERMINATING_TOOL_NAMES.includes(name);
|
|
@@ -19225,7 +19187,7 @@ var init_terminating_tools = __esm({
|
|
|
19225
19187
|
});
|
|
19226
19188
|
|
|
19227
19189
|
// src/doctor-evidence.ts
|
|
19228
|
-
import { readdir as readdir2, readFile as
|
|
19190
|
+
import { readdir as readdir2, readFile as readFile5, realpath, stat } from "node:fs/promises";
|
|
19229
19191
|
import { dirname as dirname8, relative as relative2, resolve as resolve5, sep as sep2 } from "node:path";
|
|
19230
19192
|
async function discoverCaseFiles(root) {
|
|
19231
19193
|
const found = [];
|
|
@@ -19338,7 +19300,7 @@ async function loadDoctorCase(runsPath, projectRoot) {
|
|
|
19338
19300
|
const turns = { count: 0, sources: [] }, calls = { count: 0, sources: [] }, tokens = { count: 0, sources: [] };
|
|
19339
19301
|
for (const path of await discoverCaseFiles(root)) {
|
|
19340
19302
|
const id = relative2(root, path).split(sep2).join("/");
|
|
19341
|
-
const bytes = await
|
|
19303
|
+
const bytes = await readFile5(path);
|
|
19342
19304
|
const content = bytes.toString("utf8");
|
|
19343
19305
|
const kind = id.split("/").length === 2 && id.endsWith("/log.jsonl") ? "log" : "session";
|
|
19344
19306
|
evidence.push({ id, kind, byteLength: bytes.byteLength, contentLength: content.length, sha256: sha256Hex(bytes), content });
|
|
@@ -19416,7 +19378,7 @@ var init_git_object_id = __esm({
|
|
|
19416
19378
|
|
|
19417
19379
|
// src/merger-git-state.ts
|
|
19418
19380
|
import { execFile } from "node:child_process";
|
|
19419
|
-
import { access, readFile as
|
|
19381
|
+
import { access, readFile as readFile6 } from "node:fs/promises";
|
|
19420
19382
|
import { constants as fsConstants } from "node:fs";
|
|
19421
19383
|
import { isAbsolute as isAbsolute3, resolve as resolve6 } from "node:path";
|
|
19422
19384
|
import { promisify } from "node:util";
|
|
@@ -19486,7 +19448,7 @@ function createProductionMergerGitState(repositoryRoot = process.cwd()) {
|
|
|
19486
19448
|
const mergeHeadPath = isAbsolute3(mergeHeadReported) ? mergeHeadReported : resolve6(repositoryRoot, mergeHeadReported);
|
|
19487
19449
|
let sourceObjectId = "";
|
|
19488
19450
|
if (await pathExists(mergeHeadPath)) {
|
|
19489
|
-
const raw = exactUtf8(await
|
|
19451
|
+
const raw = exactUtf8(await readFile6(mergeHeadPath), "Git MERGE_HEAD");
|
|
19490
19452
|
const mergeHeads = raw.trim().split(/\r?\n/).map((row) => row.trim()).filter(Boolean);
|
|
19491
19453
|
if (mergeHeads.length === 0) throw new Error("Git MERGE_HEAD is empty");
|
|
19492
19454
|
if (mergeHeads.length !== 1) throw new Error("Assigned repository does not have one ordinary in-progress merge");
|
|
@@ -19521,7 +19483,7 @@ var init_session_dialogue = __esm({
|
|
|
19521
19483
|
});
|
|
19522
19484
|
|
|
19523
19485
|
// src/ticket-provenance.ts
|
|
19524
|
-
import { readFile as
|
|
19486
|
+
import { readFile as readFile7 } from "node:fs/promises";
|
|
19525
19487
|
import { join as join13, resolve as resolve7 } from "node:path";
|
|
19526
19488
|
function ticketProvenanceSubject(ticketNumber) {
|
|
19527
19489
|
if (!isSafePositiveTicketNumber(ticketNumber)) {
|
|
@@ -19545,7 +19507,7 @@ async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, ho
|
|
|
19545
19507
|
const ticketInput = ticketProvenanceRecordInput(ticketNumber, cwd, home);
|
|
19546
19508
|
let history;
|
|
19547
19509
|
try {
|
|
19548
|
-
history = await
|
|
19510
|
+
history = await readFile7(join13(runDirectory, RUN_HISTORY_FILE), "utf8");
|
|
19549
19511
|
} catch (error) {
|
|
19550
19512
|
if (errnoCode(error) === "ENOENT") return;
|
|
19551
19513
|
throw error;
|
|
@@ -20128,8 +20090,8 @@ var init_option_definitions = __esm({
|
|
|
20128
20090
|
repeatable: true,
|
|
20129
20091
|
form: "option",
|
|
20130
20092
|
description: {
|
|
20131
|
-
en: "
|
|
20132
|
-
zh: "\
|
|
20093
|
+
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.",
|
|
20094
|
+
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"
|
|
20133
20095
|
}
|
|
20134
20096
|
};
|
|
20135
20097
|
SHARED_PHASE_SEMANTICS = {
|
|
@@ -20304,8 +20266,8 @@ var init_option_definitions = __esm({
|
|
|
20304
20266
|
repeatable: false,
|
|
20305
20267
|
form: "option",
|
|
20306
20268
|
description: {
|
|
20307
|
-
en: "
|
|
20308
|
-
zh: "\
|
|
20269
|
+
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.",
|
|
20270
|
+
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"
|
|
20309
20271
|
}
|
|
20310
20272
|
}
|
|
20311
20273
|
];
|
|
@@ -20764,16 +20726,22 @@ var init_option_definitions = __esm({
|
|
|
20764
20726
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
20765
20727
|
import { existsSync as existsSync4 } from "node:fs";
|
|
20766
20728
|
import {
|
|
20767
|
-
|
|
20768
|
-
mkdtemp,
|
|
20769
|
-
readFile as readFile9,
|
|
20729
|
+
readFile as readFile8,
|
|
20770
20730
|
realpath as realpath3,
|
|
20771
20731
|
rename,
|
|
20772
|
-
rm,
|
|
20773
20732
|
writeFile as writeFile2
|
|
20774
20733
|
} from "node:fs/promises";
|
|
20775
|
-
import {
|
|
20776
|
-
|
|
20734
|
+
import { dirname as dirname10, isAbsolute as isAbsolute5, join as join15, resolve as resolve9 } from "node:path";
|
|
20735
|
+
function normalizeAdmittedAttachment(raw) {
|
|
20736
|
+
if (typeof raw !== "object" || raw === null) return void 0;
|
|
20737
|
+
const record = raw;
|
|
20738
|
+
const path = record.path;
|
|
20739
|
+
if (typeof path === "string") return { path };
|
|
20740
|
+
return void 0;
|
|
20741
|
+
}
|
|
20742
|
+
function admitCallerAttachments(attachmentPaths) {
|
|
20743
|
+
return attachmentPaths.map((path) => ({ path }));
|
|
20744
|
+
}
|
|
20777
20745
|
function issueAdmissionPlacement(authority, request) {
|
|
20778
20746
|
const ledgerHome = resolveActivationLedgerHome(request.home);
|
|
20779
20747
|
const bookKey = resolveBookKeyFromGit(request.cwd);
|
|
@@ -20952,19 +20920,11 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
20952
20920
|
"taskPath",
|
|
20953
20921
|
"packetPath",
|
|
20954
20922
|
"prerequisitesPath",
|
|
20955
|
-
"requestManifestPath",
|
|
20956
20923
|
"mergerInputPath"
|
|
20957
20924
|
],
|
|
20958
20925
|
oldRunDirectory,
|
|
20959
20926
|
target.runDirectory
|
|
20960
20927
|
);
|
|
20961
|
-
for (const attachment of admitted.attachments) {
|
|
20962
|
-
attachment.frozenPath = rewriteRunDirectoryPathValue(
|
|
20963
|
-
attachment.frozenPath,
|
|
20964
|
-
oldRunDirectory,
|
|
20965
|
-
target.runDirectory
|
|
20966
|
-
);
|
|
20967
|
-
}
|
|
20968
20928
|
admitted.principal = principal;
|
|
20969
20929
|
renderCurrentSync(target.runDirectory);
|
|
20970
20930
|
return { oldRunDirectory, newRunDirectory: target.runDirectory };
|
|
@@ -21001,7 +20961,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
21001
20961
|
async function observeLaunchedRolePackageIdentity(packageRoot2, selectedRoleEntry) {
|
|
21002
20962
|
const rolePackageRoot = packageRoot2;
|
|
21003
20963
|
const raw = JSON.parse(
|
|
21004
|
-
await
|
|
20964
|
+
await readFile8(join15(rolePackageRoot, "package.json"), "utf8")
|
|
21005
20965
|
);
|
|
21006
20966
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
21007
20967
|
throw new Error(
|
|
@@ -21057,7 +21017,7 @@ function assignPublicSeatOption(owner, taken, fields) {
|
|
|
21057
21017
|
const value = taken.value;
|
|
21058
21018
|
switch (taken.def.id) {
|
|
21059
21019
|
case "attach":
|
|
21060
|
-
fields.attachmentPaths.push(
|
|
21020
|
+
fields.attachmentPaths.push(requireProvidedOptionValue(taken.def.canonical, value));
|
|
21061
21021
|
return;
|
|
21062
21022
|
case "project":
|
|
21063
21023
|
fields.project = requireOptionPath(taken.def.canonical, value);
|
|
@@ -21101,7 +21061,7 @@ function assignPublicSeatOption(owner, taken, fields) {
|
|
|
21101
21061
|
fields.repo = parseRepoOption(value);
|
|
21102
21062
|
return;
|
|
21103
21063
|
case "request-manifest":
|
|
21104
|
-
fields.requestManifestPath =
|
|
21064
|
+
fields.requestManifestPath = requireProvidedOptionValue(taken.def.canonical, value);
|
|
21105
21065
|
return;
|
|
21106
21066
|
case "issue": {
|
|
21107
21067
|
if (value === void 0 || value.trim() === "") {
|
|
@@ -21216,6 +21176,12 @@ function requireOptionPath(flag, value) {
|
|
|
21216
21176
|
}
|
|
21217
21177
|
return value;
|
|
21218
21178
|
}
|
|
21179
|
+
function requireProvidedOptionValue(flag, value) {
|
|
21180
|
+
if (value === void 0) {
|
|
21181
|
+
throw new CliUsageError(`${flag} requires a path`);
|
|
21182
|
+
}
|
|
21183
|
+
return value;
|
|
21184
|
+
}
|
|
21219
21185
|
function skillArgTokenFault(value) {
|
|
21220
21186
|
if (value === void 0 || value.trim() === "") return "empty";
|
|
21221
21187
|
if (/\s/.test(value)) return "whitespace";
|
|
@@ -21268,124 +21234,6 @@ function requireAuthorityRef(value) {
|
|
|
21268
21234
|
optionLike: "--authority-ref requires a durable reference, not inline Spec prose"
|
|
21269
21235
|
});
|
|
21270
21236
|
}
|
|
21271
|
-
async function readRegularFileAttachment(sourcePath) {
|
|
21272
|
-
const absolute = isAbsolute5(sourcePath) ? sourcePath : resolve9(sourcePath);
|
|
21273
|
-
let st;
|
|
21274
|
-
try {
|
|
21275
|
-
st = await lstat3(absolute);
|
|
21276
|
-
} catch (error) {
|
|
21277
|
-
throw new CliUsageError(
|
|
21278
|
-
`attachment is not a readable regular file: ${sourcePath}`,
|
|
21279
|
-
{ cause: error }
|
|
21280
|
-
);
|
|
21281
|
-
}
|
|
21282
|
-
if (!st.isFile() || st.isSymbolicLink()) {
|
|
21283
|
-
throw new CliUsageError(
|
|
21284
|
-
`attachment must be a regular file (not a directory or symlink): ${sourcePath}`
|
|
21285
|
-
);
|
|
21286
|
-
}
|
|
21287
|
-
try {
|
|
21288
|
-
return { absolute, bytes: await readFile9(absolute) };
|
|
21289
|
-
} catch (error) {
|
|
21290
|
-
throw new CliUsageError(
|
|
21291
|
-
`attachment is not a readable regular file: ${sourcePath}`,
|
|
21292
|
-
{ cause: error }
|
|
21293
|
-
);
|
|
21294
|
-
}
|
|
21295
|
-
}
|
|
21296
|
-
async function removePreparedAttachmentDirectory(stagingDirectory) {
|
|
21297
|
-
await rm(stagingDirectory, { recursive: true, force: true });
|
|
21298
|
-
}
|
|
21299
|
-
async function withPreparedAttachments(attachmentPaths, use) {
|
|
21300
|
-
if (attachmentPaths.length === 0) return await use([]);
|
|
21301
|
-
const stagingDirectory = await mkdtemp(join15(tmpdir(), "ak-role-attachments-"));
|
|
21302
|
-
const prepared = [];
|
|
21303
|
-
let result;
|
|
21304
|
-
try {
|
|
21305
|
-
for (let index = 0; index < attachmentPaths.length; index += 1) {
|
|
21306
|
-
const { absolute, bytes } = await readRegularFileAttachment(attachmentPaths[index]);
|
|
21307
|
-
const snapshotPath = join15(stagingDirectory, String(index).padStart(6, "0"));
|
|
21308
|
-
await writeFile2(snapshotPath, bytes);
|
|
21309
|
-
prepared.push({ absolute, snapshotPath });
|
|
21310
|
-
}
|
|
21311
|
-
result = await use(prepared);
|
|
21312
|
-
} catch (primary) {
|
|
21313
|
-
try {
|
|
21314
|
-
await removePreparedAttachmentDirectory(stagingDirectory);
|
|
21315
|
-
} catch (cleanup) {
|
|
21316
|
-
throw new AggregateError(
|
|
21317
|
-
[primary, cleanup],
|
|
21318
|
-
"attachment snapshot operation failed and cleanup also failed",
|
|
21319
|
-
{ cause: primary }
|
|
21320
|
-
);
|
|
21321
|
-
}
|
|
21322
|
-
throw primary;
|
|
21323
|
-
}
|
|
21324
|
-
await removePreparedAttachmentDirectory(stagingDirectory);
|
|
21325
|
-
return result;
|
|
21326
|
-
}
|
|
21327
|
-
async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, index) {
|
|
21328
|
-
const frozenPath = join15(
|
|
21329
|
-
destinationDir,
|
|
21330
|
-
`${String(index).padStart(2, "0")}-${basename8(provenancePath)}`
|
|
21331
|
-
);
|
|
21332
|
-
await writeFile2(frozenPath, bytes);
|
|
21333
|
-
return {
|
|
21334
|
-
provenancePath,
|
|
21335
|
-
frozenPath,
|
|
21336
|
-
byteLength: bytes.byteLength,
|
|
21337
|
-
sha256: sha256Hex(bytes),
|
|
21338
|
-
mediaKind: "regular-file"
|
|
21339
|
-
};
|
|
21340
|
-
}
|
|
21341
|
-
async function freezePreparedAttachment(prepared, destinationDir, index) {
|
|
21342
|
-
return freezeAttachmentBytes(
|
|
21343
|
-
prepared.absolute,
|
|
21344
|
-
await readFile9(prepared.snapshotPath),
|
|
21345
|
-
destinationDir,
|
|
21346
|
-
index
|
|
21347
|
-
);
|
|
21348
|
-
}
|
|
21349
|
-
async function freezeRegularFileAttachment(sourcePath, destinationDir, index) {
|
|
21350
|
-
const { absolute, bytes } = await readRegularFileAttachment(sourcePath);
|
|
21351
|
-
return {
|
|
21352
|
-
attachment: await freezeAttachmentBytes(absolute, bytes, destinationDir, index),
|
|
21353
|
-
body: bytes
|
|
21354
|
-
};
|
|
21355
|
-
}
|
|
21356
|
-
async function freezeAttachments(ledgerHome, attachmentPaths, attachmentsDirectory) {
|
|
21357
|
-
const attachments = [];
|
|
21358
|
-
if (attachmentPaths.length > 0) {
|
|
21359
|
-
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
21360
|
-
}
|
|
21361
|
-
for (let i = 0; i < attachmentPaths.length; i += 1) {
|
|
21362
|
-
const frozen = await freezeRegularFileAttachment(
|
|
21363
|
-
attachmentPaths[i],
|
|
21364
|
-
attachmentsDirectory,
|
|
21365
|
-
i
|
|
21366
|
-
);
|
|
21367
|
-
attachments.push(frozen.attachment);
|
|
21368
|
-
}
|
|
21369
|
-
return attachments;
|
|
21370
|
-
}
|
|
21371
|
-
async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKey = `s-${Date.now().toString(36)}`) {
|
|
21372
|
-
if (attachmentPaths.length === 0) return [];
|
|
21373
|
-
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
21374
|
-
const attachmentsDirectory = join15(runDirectory, "attachments", summonsKey);
|
|
21375
|
-
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
21376
|
-
return freezeAttachments(ledgerHome, attachmentPaths, attachmentsDirectory);
|
|
21377
|
-
}
|
|
21378
|
-
async function freezePreparedAttachmentsIntoRun(prepared, runDirectory, summonsKey) {
|
|
21379
|
-
if (prepared.length === 0) return [];
|
|
21380
|
-
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
21381
|
-
const attachmentsDirectory = summonsKey === void 0 ? join15(runDirectory, "attachments") : join15(runDirectory, "attachments", summonsKey);
|
|
21382
|
-
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
21383
|
-
const attachments = [];
|
|
21384
|
-
for (let index = 0; index < prepared.length; index += 1) {
|
|
21385
|
-
attachments.push(await freezePreparedAttachment(prepared[index], attachmentsDirectory, index));
|
|
21386
|
-
}
|
|
21387
|
-
return attachments;
|
|
21388
|
-
}
|
|
21389
21237
|
function ticketAdmissionFields(ticketNumber) {
|
|
21390
21238
|
if (ticketNumber === void 0) return {};
|
|
21391
21239
|
return {
|
|
@@ -21474,7 +21322,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
21474
21322
|
if (parsed.prerequisitesPath !== void 0) {
|
|
21475
21323
|
const absolutePrereq = isAbsolute5(parsed.prerequisitesPath) ? parsed.prerequisitesPath : resolve9(parsed.prerequisitesPath);
|
|
21476
21324
|
try {
|
|
21477
|
-
prerequisitesSource = await
|
|
21325
|
+
prerequisitesSource = await readFile8(absolutePrereq, "utf8");
|
|
21478
21326
|
} catch (error) {
|
|
21479
21327
|
throw new CliUsageError(
|
|
21480
21328
|
`fixer prerequisites path is unreadable: ${parsed.prerequisitesPath}`,
|
|
@@ -21531,37 +21379,17 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
21531
21379
|
} else {
|
|
21532
21380
|
repository = resolveGitHubRemoteRepository(projectRoot);
|
|
21533
21381
|
}
|
|
21534
|
-
let manifest = emptyCollectorManifest();
|
|
21535
|
-
let manifestCanonicalJson;
|
|
21536
|
-
if (parsed.requestManifestPath !== void 0) {
|
|
21537
|
-
try {
|
|
21538
|
-
manifest = await loadCollectorManifest(parsed.requestManifestPath);
|
|
21539
|
-
manifestCanonicalJson = manifest.canonicalJson;
|
|
21540
|
-
} catch (error) {
|
|
21541
|
-
throw new CliUsageError(
|
|
21542
|
-
errorText(error),
|
|
21543
|
-
{ cause: error }
|
|
21544
|
-
);
|
|
21545
|
-
}
|
|
21546
|
-
}
|
|
21547
|
-
const manifestDigest = manifest.digest;
|
|
21548
21382
|
const admittedCollector = await admitStandardMaterialInvocation("collector", {
|
|
21549
21383
|
...shared,
|
|
21550
21384
|
instruction,
|
|
21551
21385
|
attachmentPaths,
|
|
21552
21386
|
...project,
|
|
21553
|
-
placedFields: async (
|
|
21554
|
-
let requestManifestPath;
|
|
21555
|
-
if (manifestCanonicalJson !== void 0) {
|
|
21556
|
-
requestManifestPath = join15(placed.runDirectory, "request-manifest.json");
|
|
21557
|
-
await writeFile2(requestManifestPath, manifestCanonicalJson, "utf8");
|
|
21558
|
-
}
|
|
21387
|
+
placedFields: async () => {
|
|
21559
21388
|
return {
|
|
21560
21389
|
...explicitPrNumber === void 0 ? {} : { prNumber: explicitPrNumber },
|
|
21561
21390
|
repository: repository.canonical,
|
|
21562
21391
|
repositoryDisplay: repository.display,
|
|
21563
|
-
...requestManifestPath === void 0 ? {} : { requestManifestPath }
|
|
21564
|
-
manifestDigest
|
|
21392
|
+
...parsed.requestManifestPath === void 0 ? {} : { requestManifestPath: parsed.requestManifestPath }
|
|
21565
21393
|
};
|
|
21566
21394
|
}
|
|
21567
21395
|
});
|
|
@@ -21574,12 +21402,10 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
21574
21402
|
);
|
|
21575
21403
|
}
|
|
21576
21404
|
const issueNumber = parsed.issueNumber;
|
|
21577
|
-
|
|
21578
|
-
const admittedDoctor = await admitStandardMaterialInvocation("doctor", {
|
|
21405
|
+
return admitStandardMaterialInvocation("doctor", {
|
|
21579
21406
|
...shared,
|
|
21580
21407
|
instruction,
|
|
21581
|
-
attachmentPaths
|
|
21582
|
-
freezeAttachments: false,
|
|
21408
|
+
attachmentPaths,
|
|
21583
21409
|
...project,
|
|
21584
21410
|
placedFields: async (placed) => {
|
|
21585
21411
|
let caseRunsPath;
|
|
@@ -21620,16 +21446,13 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
21620
21446
|
{ cause: error }
|
|
21621
21447
|
);
|
|
21622
21448
|
}
|
|
21623
|
-
frozenAttachments = await freezeAttachments(placed.ledgerHome, attachmentPaths, placed.attachmentsDirectory);
|
|
21624
21449
|
return {
|
|
21625
21450
|
issueNumber,
|
|
21626
21451
|
caseRunsPath,
|
|
21627
|
-
caseIdentity
|
|
21628
|
-
attachments: persistedAttachmentRefs(frozenAttachments)
|
|
21452
|
+
caseIdentity
|
|
21629
21453
|
};
|
|
21630
21454
|
}
|
|
21631
21455
|
});
|
|
21632
|
-
return { ...admittedDoctor, attachments: frozenAttachments };
|
|
21633
21456
|
}
|
|
21634
21457
|
case "source-locator": {
|
|
21635
21458
|
const projectRoot = resolve9(parsed.project ?? shared.cwd);
|
|
@@ -21656,7 +21479,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
21656
21479
|
instruction: "",
|
|
21657
21480
|
attachmentPaths: [],
|
|
21658
21481
|
...project,
|
|
21659
|
-
|
|
21482
|
+
recordAttachments: false,
|
|
21660
21483
|
admittedFields: {
|
|
21661
21484
|
sourceRunPath: sourceRun.runDirectory,
|
|
21662
21485
|
sourceRun
|
|
@@ -21673,7 +21496,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
21673
21496
|
instruction,
|
|
21674
21497
|
attachmentPaths: [],
|
|
21675
21498
|
...project,
|
|
21676
|
-
|
|
21499
|
+
recordAttachments: false,
|
|
21677
21500
|
admittedFields: { baseRevision }
|
|
21678
21501
|
});
|
|
21679
21502
|
}
|
|
@@ -21785,7 +21608,7 @@ async function placeRoleAdmission(options) {
|
|
|
21785
21608
|
home: options.home,
|
|
21786
21609
|
...options.materialize === void 0 ? {} : { materialize: options.materialize }
|
|
21787
21610
|
});
|
|
21788
|
-
const attachments = options.
|
|
21611
|
+
const attachments = options.recordAttachments === false ? [] : admitCallerAttachments(options.attachmentPaths);
|
|
21789
21612
|
return {
|
|
21790
21613
|
runId,
|
|
21791
21614
|
bookKey,
|
|
@@ -21801,13 +21624,7 @@ async function placeRoleAdmission(options) {
|
|
|
21801
21624
|
};
|
|
21802
21625
|
}
|
|
21803
21626
|
function persistedAttachmentRefs(attachments) {
|
|
21804
|
-
return attachments.map((attachment) => ({
|
|
21805
|
-
provenancePath: attachment.provenancePath,
|
|
21806
|
-
frozenPath: attachment.frozenPath,
|
|
21807
|
-
byteLength: attachment.byteLength,
|
|
21808
|
-
sha256: attachment.sha256,
|
|
21809
|
-
mediaKind: attachment.mediaKind
|
|
21810
|
-
}));
|
|
21627
|
+
return attachments.map((attachment) => ({ path: attachment.path }));
|
|
21811
21628
|
}
|
|
21812
21629
|
async function persistPlacedAdmission(admitted, placed, model) {
|
|
21813
21630
|
writeAdmittedRequestPersistence(placed.runDirectory, admitted, {
|
|
@@ -21826,14 +21643,14 @@ async function persistPlacedAdmission(admitted, placed, model) {
|
|
|
21826
21643
|
}
|
|
21827
21644
|
async function admitStandardMaterialInvocation(role, options) {
|
|
21828
21645
|
const defer = options.deferPersistence === true;
|
|
21829
|
-
const
|
|
21646
|
+
const skipAttachments = defer || options.recordAttachments === false;
|
|
21830
21647
|
const placed = await placeRoleAdmission({
|
|
21831
21648
|
role,
|
|
21832
21649
|
home: options.home,
|
|
21833
21650
|
principalAuthority: options.principalAuthority,
|
|
21834
21651
|
cwd: options.cwd,
|
|
21835
21652
|
attachmentPaths: options.attachmentPaths,
|
|
21836
|
-
...
|
|
21653
|
+
...skipAttachments ? { recordAttachments: false } : {},
|
|
21837
21654
|
...defer ? { materialize: false } : {},
|
|
21838
21655
|
...options.project === void 0 ? {} : { project: options.project },
|
|
21839
21656
|
...options.createRunId === void 0 ? {} : { createRunId: options.createRunId },
|
|
@@ -21841,7 +21658,7 @@ async function admitStandardMaterialInvocation(role, options) {
|
|
|
21841
21658
|
});
|
|
21842
21659
|
const correlationFields = options.correlationId === void 0 ? {} : { correlationId: options.correlationId };
|
|
21843
21660
|
const instruction = options.instruction;
|
|
21844
|
-
const instructionEmpty = instruction.
|
|
21661
|
+
const instructionEmpty = instruction.length === 0;
|
|
21845
21662
|
const placedExtra = options.placedFields === void 0 ? void 0 : await options.placedFields(placed);
|
|
21846
21663
|
const admittedFields = {
|
|
21847
21664
|
...options.admittedFields ?? {},
|
|
@@ -21896,7 +21713,7 @@ function buildInstructionTransportPrompt(admitted) {
|
|
|
21896
21713
|
throw new Error("baseline transport prompt is missing the bound revision");
|
|
21897
21714
|
}
|
|
21898
21715
|
const lines2 = [admitted.baseRevision];
|
|
21899
|
-
if (
|
|
21716
|
+
if (admitted.instruction.length > 0) {
|
|
21900
21717
|
lines2.push("", admitted.instruction);
|
|
21901
21718
|
}
|
|
21902
21719
|
return lines2.join("\n");
|
|
@@ -21910,17 +21727,21 @@ function buildInstructionTransportPrompt(admitted) {
|
|
|
21910
21727
|
lens: admitted.lens,
|
|
21911
21728
|
authorityRefs: admitted.authorityRefs
|
|
21912
21729
|
})];
|
|
21913
|
-
if (
|
|
21730
|
+
if (admitted.instruction.length > 0) {
|
|
21914
21731
|
lines2.push("", admitted.instruction);
|
|
21915
21732
|
}
|
|
21916
21733
|
return lines2.join("\n");
|
|
21917
21734
|
}
|
|
21918
|
-
const lines = [admitted.
|
|
21919
|
-
|
|
21735
|
+
const lines = [admitted.instruction];
|
|
21736
|
+
const flaggedPaths = [
|
|
21737
|
+
...admitted.attachments.map((attachment) => `--attach ${attachment.path}`),
|
|
21738
|
+
...admitted.requestManifestPath === void 0 ? [] : [`--request-manifest ${admitted.requestManifestPath}`]
|
|
21739
|
+
];
|
|
21740
|
+
if (flaggedPaths.length > 0) {
|
|
21920
21741
|
lines.push("");
|
|
21921
|
-
lines.push("\u5DF2\u53D7\u7406\u9644\u4EF6\
|
|
21922
|
-
for (const
|
|
21923
|
-
lines.push(`- ${
|
|
21742
|
+
lines.push("\u5DF2\u53D7\u7406\u9644\u4EF6\uFF1A");
|
|
21743
|
+
for (const entry of flaggedPaths) {
|
|
21744
|
+
lines.push(`- ${entry}`);
|
|
21924
21745
|
}
|
|
21925
21746
|
}
|
|
21926
21747
|
return lines.join("\n");
|
|
@@ -21931,8 +21752,7 @@ async function materializeCountersignInvocation(admitted, options) {
|
|
|
21931
21752
|
home: options.home,
|
|
21932
21753
|
principalAuthority: options.principalAuthority,
|
|
21933
21754
|
cwd: admitted.projectRoot,
|
|
21934
|
-
attachmentPaths:
|
|
21935
|
-
freezeAttachments: false,
|
|
21755
|
+
attachmentPaths: options.attachmentPaths,
|
|
21936
21756
|
runId: admitted.runId,
|
|
21937
21757
|
...options.ticketNumber === void 0 ? {} : { assertedTicketNumber: options.ticketNumber }
|
|
21938
21758
|
});
|
|
@@ -21943,11 +21763,7 @@ async function materializeCountersignInvocation(admitted, options) {
|
|
|
21943
21763
|
if (ticketFields.ticketNumber !== void 0) {
|
|
21944
21764
|
admitted.ticketNumber = ticketFields.ticketNumber;
|
|
21945
21765
|
}
|
|
21946
|
-
|
|
21947
|
-
options.preparedAttachments,
|
|
21948
|
-
admitted.runDirectory
|
|
21949
|
-
);
|
|
21950
|
-
admitted.attachments = attachments;
|
|
21766
|
+
admitted.attachments = placement.attachments;
|
|
21951
21767
|
writeAdmittedRequestPersistence(admitted.runDirectory, admitted, {
|
|
21952
21768
|
sessionDirectory: placement.sessionDirectory,
|
|
21953
21769
|
sessionFile: placement.sessionFile
|
|
@@ -22187,7 +22003,7 @@ function parseAnalystArgv(args) {
|
|
|
22187
22003
|
if (taken.def.id === "attach") {
|
|
22188
22004
|
pushValue(
|
|
22189
22005
|
"attach",
|
|
22190
|
-
|
|
22006
|
+
requireProvidedOptionValue(taken.def.canonical, taken.value)
|
|
22191
22007
|
);
|
|
22192
22008
|
return;
|
|
22193
22009
|
}
|
|
@@ -23477,10 +23293,10 @@ function presentFailureTerminal(terminal, io) {
|
|
|
23477
23293
|
}
|
|
23478
23294
|
function defaultNavigatorGraceSleep() {
|
|
23479
23295
|
let timer;
|
|
23480
|
-
const sleep2 = ((ms) => new Promise((
|
|
23296
|
+
const sleep2 = ((ms) => new Promise((resolve13) => {
|
|
23481
23297
|
timer = setTimeout(() => {
|
|
23482
23298
|
timer = void 0;
|
|
23483
|
-
|
|
23299
|
+
resolve13();
|
|
23484
23300
|
}, ms);
|
|
23485
23301
|
}));
|
|
23486
23302
|
sleep2.cancel = () => {
|
|
@@ -23492,7 +23308,7 @@ function defaultNavigatorGraceSleep() {
|
|
|
23492
23308
|
return sleep2;
|
|
23493
23309
|
}
|
|
23494
23310
|
function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2 = defaultNavigatorGraceSleep()) {
|
|
23495
|
-
return new Promise((
|
|
23311
|
+
return new Promise((resolve13, reject) => {
|
|
23496
23312
|
let settled = false;
|
|
23497
23313
|
const finish = (action) => {
|
|
23498
23314
|
if (settled) return;
|
|
@@ -23501,11 +23317,11 @@ function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2
|
|
|
23501
23317
|
action();
|
|
23502
23318
|
};
|
|
23503
23319
|
void work.then(
|
|
23504
|
-
(value) => finish(() =>
|
|
23320
|
+
(value) => finish(() => resolve13({ status: "done", value })),
|
|
23505
23321
|
(error) => finish(() => reject(error))
|
|
23506
23322
|
);
|
|
23507
23323
|
void sleep2(graceMs).then(() => {
|
|
23508
|
-
finish(() =>
|
|
23324
|
+
finish(() => resolve13({ status: "timeout" }));
|
|
23509
23325
|
});
|
|
23510
23326
|
});
|
|
23511
23327
|
}
|
|
@@ -24196,7 +24012,7 @@ var init_role_seat_runtime = __esm({
|
|
|
24196
24012
|
});
|
|
24197
24013
|
|
|
24198
24014
|
// src/archivist-record-pointer.ts
|
|
24199
|
-
import { basename as
|
|
24015
|
+
import { basename as basename8, join as join20 } from "node:path";
|
|
24200
24016
|
function bookDirectOfficerRunPointer(options) {
|
|
24201
24017
|
const submissionToolCallId = options.submissionToolCallId?.trim() ?? "";
|
|
24202
24018
|
const pointer = {
|
|
@@ -24222,7 +24038,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
|
24222
24038
|
let runDirectory = typeof raw.runDirectory === "string" && raw.runDirectory.trim() !== "" ? raw.runDirectory : void 0;
|
|
24223
24039
|
let sessionFile = raw.sessionFile;
|
|
24224
24040
|
const recordedRunDirectory = runDirectory ?? runDirectoryOfSessionFile(sessionFile);
|
|
24225
|
-
const leaf = parseRunLeaf(
|
|
24041
|
+
const leaf = parseRunLeaf(basename8(recordedRunDirectory));
|
|
24226
24042
|
const parentIdentity = await readRoleRunIdentity(parentRunDirectory);
|
|
24227
24043
|
if (leaf !== void 0 && parentIdentity !== void 0) {
|
|
24228
24044
|
const currentRunDirectory = await findRunDirectoryById(
|
|
@@ -24538,7 +24354,7 @@ var init_submission_gate = __esm({
|
|
|
24538
24354
|
|
|
24539
24355
|
// src/session-opening-materials.ts
|
|
24540
24356
|
import { existsSync as existsSync7 } from "node:fs";
|
|
24541
|
-
import { readFile as
|
|
24357
|
+
import { readFile as readFile9 } from "node:fs/promises";
|
|
24542
24358
|
import { dirname as dirname13, join as join21 } from "node:path";
|
|
24543
24359
|
import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
24544
24360
|
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
@@ -24554,7 +24370,7 @@ function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
|
24554
24370
|
return fileURLToPath(new URL("..", moduleUrl));
|
|
24555
24371
|
}
|
|
24556
24372
|
async function readPackageMaterial(relativePath) {
|
|
24557
|
-
return
|
|
24373
|
+
return readFile9(fileURLToPath(new URL(relativePath, packageRootUrl)), "utf8");
|
|
24558
24374
|
}
|
|
24559
24375
|
async function joinPackageMaterials(relativePaths) {
|
|
24560
24376
|
const chunks = [];
|
|
@@ -24596,7 +24412,7 @@ __export(auditor_soul_exports, {
|
|
|
24596
24412
|
readAuditorResumeBinding: () => readAuditorResumeBinding,
|
|
24597
24413
|
resolveAuditorSubject: () => resolveAuditorSubject
|
|
24598
24414
|
});
|
|
24599
|
-
import { basename as
|
|
24415
|
+
import { basename as basename9 } from "node:path";
|
|
24600
24416
|
function auditorSoulRelativePath(role) {
|
|
24601
24417
|
return `souls/${role}-auditor.md`;
|
|
24602
24418
|
}
|
|
@@ -24632,7 +24448,7 @@ function loadAuditorReferenceMaterialsFromSubjectInput(raw) {
|
|
|
24632
24448
|
return loadAuditorReferenceMaterials(resolveAuditorSubject(raw));
|
|
24633
24449
|
}
|
|
24634
24450
|
function subjectFromSourceDirectory(sourceRunDirectory) {
|
|
24635
|
-
const role = parseRunLeaf(
|
|
24451
|
+
const role = parseRunLeaf(basename9(sourceRunDirectory))?.role;
|
|
24636
24452
|
return isAuditorSoulRole(role) ? role : void 0;
|
|
24637
24453
|
}
|
|
24638
24454
|
async function readAuditorResumeBinding(runDirectory) {
|
|
@@ -25492,7 +25308,7 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
25492
25308
|
summons: {
|
|
25493
25309
|
sourceRunPath: gateParentRunPath,
|
|
25494
25310
|
instruction: resumeInstruction,
|
|
25495
|
-
instructionEmpty: resumeInstruction.
|
|
25311
|
+
instructionEmpty: resumeInstruction.length === 0
|
|
25496
25312
|
}
|
|
25497
25313
|
});
|
|
25498
25314
|
if (resumed != null) return resumed;
|
|
@@ -25506,12 +25322,12 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
25506
25322
|
throw error;
|
|
25507
25323
|
}
|
|
25508
25324
|
try {
|
|
25509
|
-
|
|
25325
|
+
{
|
|
25510
25326
|
const materializeAdmission = async (ticketNumber) => {
|
|
25511
25327
|
await materializeCountersignInvocation(admitted, {
|
|
25512
25328
|
home: env.home,
|
|
25513
25329
|
principalAuthority: env.principalAuthority,
|
|
25514
|
-
|
|
25330
|
+
attachmentPaths: parsed.attachmentPaths ?? [],
|
|
25515
25331
|
...env.model === void 0 ? {} : { model: env.model },
|
|
25516
25332
|
...ticketNumber === void 0 ? {} : { ticketNumber }
|
|
25517
25333
|
});
|
|
@@ -25546,7 +25362,7 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
25546
25362
|
});
|
|
25547
25363
|
await relocateAdmittedRunToTicket(admitted, env.principalAuthority);
|
|
25548
25364
|
return result;
|
|
25549
|
-
}
|
|
25365
|
+
}
|
|
25550
25366
|
} catch (error) {
|
|
25551
25367
|
const rejected = usageExit(error, io);
|
|
25552
25368
|
if (rejected !== void 0) return rejected;
|
|
@@ -25611,7 +25427,7 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
|
|
|
25611
25427
|
const summons = {
|
|
25612
25428
|
...sameParentInstruction(env, {
|
|
25613
25429
|
instruction: parsed.instruction ?? "",
|
|
25614
|
-
instructionEmpty: (parsed.instruction ?? "").
|
|
25430
|
+
instructionEmpty: (parsed.instruction ?? "").length === 0
|
|
25615
25431
|
}),
|
|
25616
25432
|
attachmentPaths: parsed.attachmentPaths ?? []
|
|
25617
25433
|
};
|
|
@@ -25636,7 +25452,7 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
|
|
|
25636
25452
|
sourceRunPath: parentRunPath,
|
|
25637
25453
|
...sameParentInstruction(env, {
|
|
25638
25454
|
instruction: parsed.instruction ?? "",
|
|
25639
|
-
instructionEmpty: (parsed.instruction ?? "").
|
|
25455
|
+
instructionEmpty: (parsed.instruction ?? "").length === 0
|
|
25640
25456
|
}),
|
|
25641
25457
|
attachmentPaths: parsed.attachmentPaths ?? []
|
|
25642
25458
|
};
|
|
@@ -25720,7 +25536,7 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
|
|
|
25720
25536
|
instruction: parsed.instruction ?? "",
|
|
25721
25537
|
projectRoot: admitted.projectRoot,
|
|
25722
25538
|
failureLabel: "secretariat unbound summons",
|
|
25723
|
-
attachmentPaths: admitted.attachments.map((attachment) => attachment.
|
|
25539
|
+
attachmentPaths: admitted.attachments.map((attachment) => attachment.path),
|
|
25724
25540
|
correlationId: admitted.runId
|
|
25725
25541
|
}, env, io);
|
|
25726
25542
|
} catch (error) {
|
|
@@ -26533,7 +26349,7 @@ async function summonPublicRole(options) {
|
|
|
26533
26349
|
runId: resumeRunId,
|
|
26534
26350
|
summons: {
|
|
26535
26351
|
instruction,
|
|
26536
|
-
instructionEmpty: instruction.
|
|
26352
|
+
instructionEmpty: instruction.length === 0
|
|
26537
26353
|
}
|
|
26538
26354
|
},
|
|
26539
26355
|
env,
|
|
@@ -26996,13 +26812,6 @@ function rewriteSourceRunLocator(value, rewrites) {
|
|
|
26996
26812
|
function rewriteAdmittedRoleRunPage(page, rewrites) {
|
|
26997
26813
|
rewriteRunDirectoryPathFieldsAgainstRewrites(page, ADMITTED_PAGE_FIELDS, rewrites);
|
|
26998
26814
|
rewriteSourceRunLocator(page.sourceRun, rewrites);
|
|
26999
|
-
if (Array.isArray(page.attachments)) {
|
|
27000
|
-
for (const attachment of page.attachments) {
|
|
27001
|
-
if (isRecord(attachment)) {
|
|
27002
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(attachment, ["frozenPath"], rewrites);
|
|
27003
|
-
}
|
|
27004
|
-
}
|
|
27005
|
-
}
|
|
27006
26815
|
if (isRecord(page.principal)) {
|
|
27007
26816
|
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
27008
26817
|
page.principal,
|
|
@@ -27030,7 +26839,7 @@ var init_role_run_relocation = __esm({
|
|
|
27030
26839
|
"taskPath",
|
|
27031
26840
|
"packetPath",
|
|
27032
26841
|
"prerequisitesPath",
|
|
27033
|
-
|
|
26842
|
+
// #1165: requestManifestPath is a caller path — never rewrite.
|
|
27034
26843
|
"mergerInputPath",
|
|
27035
26844
|
"sourceRunPath"
|
|
27036
26845
|
];
|
|
@@ -27065,8 +26874,8 @@ __export(run_lifecycle_exports, {
|
|
|
27065
26874
|
recordCurrentCourt: () => recordCurrentCourt,
|
|
27066
26875
|
writeRoleRunState: () => writeRoleRunState
|
|
27067
26876
|
});
|
|
27068
|
-
import { chmod, lstat as
|
|
27069
|
-
import { basename as
|
|
26877
|
+
import { chmod, lstat as lstat3, open, readdir as readdir3, readFile as readFile10, unlink } from "node:fs/promises";
|
|
26878
|
+
import { basename as basename10, join as join25 } from "node:path";
|
|
27070
26879
|
function buildAutoResumeContinuationPrompt() {
|
|
27071
26880
|
return RESUME_TRANSPORT_ENVELOPE;
|
|
27072
26881
|
}
|
|
@@ -27079,7 +26888,7 @@ function parseSameTicketSummonsMaterials(raw) {
|
|
|
27079
26888
|
const record = raw;
|
|
27080
26889
|
const instruction = typeof record.instruction === "string" ? record.instruction : void 0;
|
|
27081
26890
|
const instructionEmpty = typeof record.instructionEmpty === "boolean" ? record.instructionEmpty : void 0;
|
|
27082
|
-
const attachmentPaths = Array.isArray(record.attachmentPaths) ? record.attachmentPaths.filter((p) => typeof p === "string"
|
|
26891
|
+
const attachmentPaths = Array.isArray(record.attachmentPaths) ? record.attachmentPaths.filter((p) => typeof p === "string") : void 0;
|
|
27083
26892
|
const sourceRunPath = typeof record.sourceRunPath === "string" && record.sourceRunPath.trim() !== "" ? record.sourceRunPath : void 0;
|
|
27084
26893
|
let sourceRun;
|
|
27085
26894
|
if (isRecord(record.sourceRun)) {
|
|
@@ -27304,7 +27113,7 @@ function isProcessAlive(pid) {
|
|
|
27304
27113
|
async function autopsyWriterLock(lockPath) {
|
|
27305
27114
|
let content;
|
|
27306
27115
|
try {
|
|
27307
|
-
content = await
|
|
27116
|
+
content = await readFile10(lockPath, "utf8");
|
|
27308
27117
|
} catch (error) {
|
|
27309
27118
|
if (errorCodeOf(error) === "ENOENT") return { verdict: "absent" };
|
|
27310
27119
|
return { verdict: "unknown", reason: "unreadable", readFailure: error };
|
|
@@ -27497,7 +27306,7 @@ async function runHasFormedSessionPrincipal(runDirectory) {
|
|
|
27497
27306
|
if (disk === void 0) return false;
|
|
27498
27307
|
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : sessionFileIn(disk.principalWire.sessionDirectory);
|
|
27499
27308
|
try {
|
|
27500
|
-
const stat2 = await
|
|
27309
|
+
const stat2 = await lstat3(sessionFile);
|
|
27501
27310
|
return stat2.isFile() && !stat2.isSymbolicLink();
|
|
27502
27311
|
} catch (error) {
|
|
27503
27312
|
if (errorCodeOf(error) === "ENOENT") return false;
|
|
@@ -27521,7 +27330,7 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
27521
27330
|
}
|
|
27522
27331
|
let best;
|
|
27523
27332
|
for (const runDirectory of runDirectories) {
|
|
27524
|
-
const parsed = parseRunLeaf(
|
|
27333
|
+
const parsed = parseRunLeaf(basename10(runDirectory));
|
|
27525
27334
|
if (parsed === void 0 || parsed.role !== input.role) continue;
|
|
27526
27335
|
const runId = parsed.runId;
|
|
27527
27336
|
const parentPath = await readRunParentPath(runDirectory);
|
|
@@ -27578,7 +27387,6 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
27578
27387
|
let repository;
|
|
27579
27388
|
let repositoryDisplay;
|
|
27580
27389
|
let requestManifestPath;
|
|
27581
|
-
let manifestDigest;
|
|
27582
27390
|
let waitWindowMs;
|
|
27583
27391
|
let issueNumber;
|
|
27584
27392
|
let caseRunsPath;
|
|
@@ -27601,7 +27409,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
27601
27409
|
instructionEmpty = record.instructionEmpty;
|
|
27602
27410
|
}
|
|
27603
27411
|
if (Array.isArray(record.attachments)) {
|
|
27604
|
-
attachments = record.attachments;
|
|
27412
|
+
attachments = record.attachments.map((item) => normalizeAdmittedAttachment(item)).filter((item) => item !== void 0);
|
|
27605
27413
|
}
|
|
27606
27414
|
if (record.phase === "plan" || record.phase === "apply") {
|
|
27607
27415
|
phase = record.phase;
|
|
@@ -27633,12 +27441,9 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
27633
27441
|
if (typeof record.repositoryDisplay === "string" && record.repositoryDisplay.trim() !== "") {
|
|
27634
27442
|
repositoryDisplay = record.repositoryDisplay;
|
|
27635
27443
|
}
|
|
27636
|
-
if (typeof record.requestManifestPath === "string"
|
|
27444
|
+
if (typeof record.requestManifestPath === "string") {
|
|
27637
27445
|
requestManifestPath = record.requestManifestPath;
|
|
27638
27446
|
}
|
|
27639
|
-
if (typeof record.manifestDigest === "string" && record.manifestDigest.trim() !== "") {
|
|
27640
|
-
manifestDigest = record.manifestDigest;
|
|
27641
|
-
}
|
|
27642
27447
|
if (typeof record.waitWindowMs === "number" && Number.isSafeInteger(record.waitWindowMs) && record.waitWindowMs >= 1) {
|
|
27643
27448
|
waitWindowMs = record.waitWindowMs;
|
|
27644
27449
|
}
|
|
@@ -27732,7 +27537,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
27732
27537
|
);
|
|
27733
27538
|
}
|
|
27734
27539
|
}
|
|
27735
|
-
const sourceRunLeaf = parseRunLeaf(
|
|
27540
|
+
const sourceRunLeaf = parseRunLeaf(basename10(sourceRunPath ?? ""));
|
|
27736
27541
|
const referencedRunId = sourceRun?.runId ?? sourceRunLeaf?.runId;
|
|
27737
27542
|
const referencedRole = sourceRun?.role ?? sourceRunLeaf?.role;
|
|
27738
27543
|
if (referencedRunId !== void 0 && referencedRunId !== "") {
|
|
@@ -27772,7 +27577,6 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
27772
27577
|
...repository === void 0 ? {} : { repository },
|
|
27773
27578
|
...repositoryDisplay === void 0 ? {} : { repositoryDisplay },
|
|
27774
27579
|
...requestManifestPath === void 0 ? {} : { requestManifestPath },
|
|
27775
|
-
...manifestDigest === void 0 ? {} : { manifestDigest },
|
|
27776
27580
|
...waitWindowMs === void 0 ? {} : { waitWindowMs },
|
|
27777
27581
|
...issueNumber === void 0 ? {} : { issueNumber },
|
|
27778
27582
|
...caseRunsPath === void 0 ? {} : { caseRunsPath },
|
|
@@ -27962,8 +27766,8 @@ function admitResumedRole(loaded) {
|
|
|
27962
27766
|
return admitted;
|
|
27963
27767
|
}
|
|
27964
27768
|
case "collect-target": {
|
|
27965
|
-
const { prNumber, repository, repositoryDisplay
|
|
27966
|
-
if (repository === void 0 || repositoryDisplay === void 0
|
|
27769
|
+
const { prNumber, repository, repositoryDisplay } = fields;
|
|
27770
|
+
if (repository === void 0 || repositoryDisplay === void 0) {
|
|
27967
27771
|
throw new CliUsageError(
|
|
27968
27772
|
`role run admitted collector repository identity is missing: ${runId}`
|
|
27969
27773
|
);
|
|
@@ -27986,8 +27790,7 @@ function admitResumedRole(loaded) {
|
|
|
27986
27790
|
...prNumber === void 0 ? {} : { prNumber },
|
|
27987
27791
|
repository: parsedRepository,
|
|
27988
27792
|
...fields.requestManifestPath === void 0 ? {} : { requestManifestPath: fields.requestManifestPath },
|
|
27989
|
-
...fields.waitWindowMs === void 0 ? {} : { waitWindowMs: fields.waitWindowMs }
|
|
27990
|
-
manifestDigest
|
|
27793
|
+
...fields.waitWindowMs === void 0 ? {} : { waitWindowMs: fields.waitWindowMs }
|
|
27991
27794
|
};
|
|
27992
27795
|
return admitted;
|
|
27993
27796
|
}
|
|
@@ -28071,7 +27874,6 @@ var init_run_lifecycle = __esm({
|
|
|
28071
27874
|
|
|
28072
27875
|
// src/public-cli/post-admission.ts
|
|
28073
27876
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
28074
|
-
import { isAbsolute as isAbsolute8, join as join26, resolve as resolve12 } from "node:path";
|
|
28075
27877
|
function describeCaughtError(error) {
|
|
28076
27878
|
if (error instanceof Error) {
|
|
28077
27879
|
const code = error.code;
|
|
@@ -28093,7 +27895,7 @@ function projectRelocatedTurnIdentity(request, result, admitted, relocation) {
|
|
|
28093
27895
|
mutableRequest.principal = admitted.principal;
|
|
28094
27896
|
const activation = mutableRequest.activation;
|
|
28095
27897
|
if (isRecord(activation)) {
|
|
28096
|
-
for (const field of ["taskPath", "packetPath", "prerequisitesPath", "inputPath"
|
|
27898
|
+
for (const field of ["taskPath", "packetPath", "prerequisitesPath", "inputPath"]) {
|
|
28097
27899
|
const record = activation;
|
|
28098
27900
|
if (field in record) record[field] = rewrite(record[field]);
|
|
28099
27901
|
}
|
|
@@ -28826,7 +28628,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
28826
28628
|
prompt = request.message;
|
|
28827
28629
|
}
|
|
28828
28630
|
} else if (summonsPrepared !== void 0) {
|
|
28829
|
-
prompt = officerDialogue ? summonsPrepared.
|
|
28631
|
+
prompt = officerDialogue ? summonsPrepared.instruction : buildInstructionTransportPrompt(summonsPrepared);
|
|
28830
28632
|
} else if (request.summons !== void 0) {
|
|
28831
28633
|
prompt = "";
|
|
28832
28634
|
} else {
|
|
@@ -28907,24 +28709,14 @@ async function runSettledAutoResumeLoop(input) {
|
|
|
28907
28709
|
})
|
|
28908
28710
|
});
|
|
28909
28711
|
}
|
|
28910
|
-
function
|
|
28911
|
-
const absolute = isAbsolute8(attachmentPath) ? attachmentPath : resolve12(attachmentPath);
|
|
28912
|
-
return pathContainedIn(join26(runDirectory, "attachments"), absolute);
|
|
28913
|
-
}
|
|
28914
|
-
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
28712
|
+
async function prepareSummonsResumeMaterials(_runDirectory, summons) {
|
|
28915
28713
|
if (summons === void 0) return void 0;
|
|
28916
28714
|
if (summons.instruction === void 0 && (summons.attachmentPaths?.length ?? 0) === 0) {
|
|
28917
28715
|
return void 0;
|
|
28918
28716
|
}
|
|
28919
28717
|
const instruction = summons.instruction ?? "";
|
|
28920
|
-
const instructionEmpty = summons.instructionEmpty ?? instruction.
|
|
28921
|
-
|
|
28922
|
-
if (summons.attachmentPaths !== void 0 && summons.attachmentPaths.length > 0) {
|
|
28923
|
-
const alreadyFrozen = summons.attachmentPaths.every(
|
|
28924
|
-
(path) => isAlreadyFrozenSummonsAttachment(runDirectory, path)
|
|
28925
|
-
);
|
|
28926
|
-
attachments = alreadyFrozen ? summons.attachmentPaths.map((frozenPath) => ({ frozenPath })) : await freezeAttachmentsIntoRun(summons.attachmentPaths, runDirectory);
|
|
28927
|
-
}
|
|
28718
|
+
const instructionEmpty = summons.instructionEmpty ?? instruction.length === 0;
|
|
28719
|
+
const attachments = (summons.attachmentPaths ?? []).map((path) => ({ path }));
|
|
28928
28720
|
return { instruction, instructionEmpty, attachments };
|
|
28929
28721
|
}
|
|
28930
28722
|
async function runPostAdmissionSeatResume(input) {
|
|
@@ -28973,23 +28765,6 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
28973
28765
|
openCourtAttemptId = openCourt.courtAttemptId;
|
|
28974
28766
|
}
|
|
28975
28767
|
}
|
|
28976
|
-
if (request.summons !== void 0) {
|
|
28977
|
-
const prepared = await prepareSummonsResumeMaterials(
|
|
28978
|
-
admittedForBuild.runDirectory,
|
|
28979
|
-
request.summons
|
|
28980
|
-
);
|
|
28981
|
-
if (prepared !== void 0 && (request.summons.attachmentPaths?.length ?? 0) > 0) {
|
|
28982
|
-
request = {
|
|
28983
|
-
...request,
|
|
28984
|
-
summons: {
|
|
28985
|
-
...request.summons,
|
|
28986
|
-
attachmentPaths: prepared.attachments.map(
|
|
28987
|
-
(attachment) => attachment.frozenPath
|
|
28988
|
-
)
|
|
28989
|
-
}
|
|
28990
|
-
};
|
|
28991
|
-
}
|
|
28992
|
-
}
|
|
28993
28768
|
let turnRequest = await input.buildTurnRequest(admittedForBuild, request);
|
|
28994
28769
|
if (turnRequest.continuation.kind === "resume" && turnRequest.continuation.hostSessionId === void 0) {
|
|
28995
28770
|
const hostSessionId = await readStoredHostSessionId(
|
|
@@ -29239,7 +29014,6 @@ var init_post_admission = __esm({
|
|
|
29239
29014
|
init_invocation();
|
|
29240
29015
|
init_submission_ledger();
|
|
29241
29016
|
init_run_ticket_number();
|
|
29242
|
-
init_activation_ledger_topology();
|
|
29243
29017
|
init_session_identity();
|
|
29244
29018
|
init_sitian_facade();
|
|
29245
29019
|
init_receipt_delivery_policy();
|
|
@@ -29259,7 +29033,7 @@ var init_post_admission = __esm({
|
|
|
29259
29033
|
|
|
29260
29034
|
// src/analyst-book-key.ts
|
|
29261
29035
|
import { statSync as statSync6 } from "node:fs";
|
|
29262
|
-
import { isAbsolute as
|
|
29036
|
+
import { isAbsolute as isAbsolute8 } from "node:path";
|
|
29263
29037
|
function resolveAnalystBookKey(projectRoot) {
|
|
29264
29038
|
const identity = physicalPathIdentity(projectRoot);
|
|
29265
29039
|
let stats;
|
|
@@ -29281,7 +29055,7 @@ function resolveAnalystBookKey(projectRoot) {
|
|
|
29281
29055
|
}
|
|
29282
29056
|
}
|
|
29283
29057
|
function isSyntheticAnalystBookKey(bookKey) {
|
|
29284
|
-
return bookKey.startsWith("root:") &&
|
|
29058
|
+
return bookKey.startsWith("root:") && isAbsolute8(bookKey.slice("root:".length));
|
|
29285
29059
|
}
|
|
29286
29060
|
var init_analyst_book_key = __esm({
|
|
29287
29061
|
"src/analyst-book-key.ts"() {
|
|
@@ -29293,16 +29067,16 @@ var init_analyst_book_key = __esm({
|
|
|
29293
29067
|
|
|
29294
29068
|
// src/atomic-write.ts
|
|
29295
29069
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
29296
|
-
import { rename as rename2, rm
|
|
29297
|
-
import { dirname as dirname16, join as
|
|
29070
|
+
import { rename as rename2, rm, writeFile as writeFile4 } from "node:fs/promises";
|
|
29071
|
+
import { dirname as dirname16, join as join26 } from "node:path";
|
|
29298
29072
|
async function writeFileAtomically(destination, contents, options) {
|
|
29299
29073
|
const parent = dirname16(destination);
|
|
29300
|
-
const temporary =
|
|
29074
|
+
const temporary = join26(parent, `.atomic-write-${randomUUID6()}.tmp`);
|
|
29301
29075
|
try {
|
|
29302
29076
|
await writeFile4(temporary, contents, options);
|
|
29303
29077
|
await rename2(temporary, destination);
|
|
29304
29078
|
} catch (error) {
|
|
29305
|
-
await
|
|
29079
|
+
await rm(temporary, { force: true }).catch(() => void 0);
|
|
29306
29080
|
throw error;
|
|
29307
29081
|
}
|
|
29308
29082
|
}
|
|
@@ -29313,13 +29087,13 @@ var init_atomic_write = __esm({
|
|
|
29313
29087
|
});
|
|
29314
29088
|
|
|
29315
29089
|
// src/analyst-index.ts
|
|
29316
|
-
import { open as open2, readFile as
|
|
29317
|
-
import { dirname as dirname17, join as
|
|
29090
|
+
import { open as open2, readFile as readFile11, unlink as unlink2 } from "node:fs/promises";
|
|
29091
|
+
import { dirname as dirname17, join as join27 } from "node:path";
|
|
29318
29092
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
29319
29093
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
29320
29094
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
29321
29095
|
ensureRealDirectoryTree(ledgerHome, dirname17(indexPath));
|
|
29322
|
-
const lockPath =
|
|
29096
|
+
const lockPath = join27(dirname17(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
29323
29097
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
29324
29098
|
const startedAt = Date.now();
|
|
29325
29099
|
while (true) {
|
|
@@ -29346,7 +29120,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
29346
29120
|
}
|
|
29347
29121
|
}
|
|
29348
29122
|
function analystLibraryIndexPath(ledgerHome) {
|
|
29349
|
-
return
|
|
29123
|
+
return join27(ledgerHome, "analyst", "library-index.json");
|
|
29350
29124
|
}
|
|
29351
29125
|
function rowFromIssueMetricsPage(page) {
|
|
29352
29126
|
return {
|
|
@@ -29437,7 +29211,7 @@ async function readAnalystLibraryIndexPage(ledgerHome) {
|
|
|
29437
29211
|
const path = analystLibraryIndexPath(ledgerHome);
|
|
29438
29212
|
let raw;
|
|
29439
29213
|
try {
|
|
29440
|
-
raw = await
|
|
29214
|
+
raw = await readFile11(path, "utf8");
|
|
29441
29215
|
} catch (error) {
|
|
29442
29216
|
if (isMissingPathError(error)) return void 0;
|
|
29443
29217
|
throw error;
|
|
@@ -29892,7 +29666,7 @@ var init_analyst_gate_cycles_read = __esm({
|
|
|
29892
29666
|
|
|
29893
29667
|
// src/analyst-ledger.ts
|
|
29894
29668
|
import { readdir as readdir4 } from "node:fs/promises";
|
|
29895
|
-
import { basename as
|
|
29669
|
+
import { basename as basename11, join as join28 } from "node:path";
|
|
29896
29670
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
29897
29671
|
return (await readRoleRunIdentity(runDirectory))?.state;
|
|
29898
29672
|
}
|
|
@@ -29912,7 +29686,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
|
|
|
29912
29686
|
}
|
|
29913
29687
|
}
|
|
29914
29688
|
async function classifyGhostCandidate(input) {
|
|
29915
|
-
const autopsy = await autopsyWriterLock(
|
|
29689
|
+
const autopsy = await autopsyWriterLock(join28(input.runDirectory, "writer.lock"));
|
|
29916
29690
|
const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
|
|
29917
29691
|
if (leaseCheck === void 0) return { kind: "live" };
|
|
29918
29692
|
return {
|
|
@@ -30202,7 +29976,7 @@ async function classifyScopedRun(input) {
|
|
|
30202
29976
|
async function scanAnalystIssueRuns(input) {
|
|
30203
29977
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
30204
29978
|
const scopeTicketNumber = input.ticketNumber;
|
|
30205
|
-
const booksRoot =
|
|
29979
|
+
const booksRoot = join28(ledgerHome, "books");
|
|
30206
29980
|
let wholeBook = false;
|
|
30207
29981
|
let scopeRootIdentity;
|
|
30208
29982
|
let bookNames;
|
|
@@ -30235,7 +30009,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
30235
30009
|
const ghostLegs = [];
|
|
30236
30010
|
const scopeConflicts = [];
|
|
30237
30011
|
for (const book of bookNames) {
|
|
30238
|
-
const bookDir =
|
|
30012
|
+
const bookDir = join28(booksRoot, book);
|
|
30239
30013
|
let runDirectories;
|
|
30240
30014
|
try {
|
|
30241
30015
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
@@ -30244,7 +30018,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
30244
30018
|
throw error;
|
|
30245
30019
|
}
|
|
30246
30020
|
for (const runDirectory of runDirectories) {
|
|
30247
|
-
const runName =
|
|
30021
|
+
const runName = basename11(runDirectory);
|
|
30248
30022
|
const parsed = parseRunLeaf(runName);
|
|
30249
30023
|
if (parsed === void 0) continue;
|
|
30250
30024
|
let scopeFields;
|
|
@@ -30981,7 +30755,7 @@ var init_analyst_metric_family = __esm({
|
|
|
30981
30755
|
});
|
|
30982
30756
|
|
|
30983
30757
|
// src/analyst-page.ts
|
|
30984
|
-
import { dirname as dirname18, join as
|
|
30758
|
+
import { dirname as dirname18, join as join29 } from "node:path";
|
|
30985
30759
|
function analystIssuePageKey(address) {
|
|
30986
30760
|
const parts = ["book", address.bookKey];
|
|
30987
30761
|
if (address.issueNumber !== void 0) {
|
|
@@ -30992,7 +30766,7 @@ function analystIssuePageKey(address) {
|
|
|
30992
30766
|
return sha256Hex(parts.join("\0")).slice(0, 32);
|
|
30993
30767
|
}
|
|
30994
30768
|
function analystIssuePagePath(ledgerHome, address) {
|
|
30995
|
-
return
|
|
30769
|
+
return join29(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
30996
30770
|
}
|
|
30997
30771
|
function analystIssuePageAddressFromPage(page) {
|
|
30998
30772
|
return {
|
|
@@ -31228,7 +31002,7 @@ var init_analyst_model_groups = __esm({
|
|
|
31228
31002
|
});
|
|
31229
31003
|
|
|
31230
31004
|
// src/analyst-entry.ts
|
|
31231
|
-
import { readFile as
|
|
31005
|
+
import { readFile as readFile13 } from "node:fs/promises";
|
|
31232
31006
|
function cachedPageMatchesRequestedScope(page, input) {
|
|
31233
31007
|
if (page.bookKey !== input.bookKey) return false;
|
|
31234
31008
|
const requestedTicket = input.ticketNumber ?? input.issueNumber;
|
|
@@ -31255,7 +31029,7 @@ async function readOrComputeAnalystIssuePage(input, options) {
|
|
|
31255
31029
|
...issueNumber === void 0 && input.bookKey === void 0 ? { scopeRootIdentity: projectRoot } : {}
|
|
31256
31030
|
});
|
|
31257
31031
|
try {
|
|
31258
|
-
const raw = await
|
|
31032
|
+
const raw = await readFile13(pagePath, "utf8");
|
|
31259
31033
|
const page = JSON.parse(raw);
|
|
31260
31034
|
if (cachedPageMatchesRequestedScope(page, { bookKey, ...input })) {
|
|
31261
31035
|
const ghostScan = await scanAnalystIssueRuns({
|
|
@@ -31356,7 +31130,7 @@ async function runAnalystModelGroupsMode(input, home) {
|
|
|
31356
31130
|
scopeRootIdentity: projectRoot
|
|
31357
31131
|
});
|
|
31358
31132
|
try {
|
|
31359
|
-
const raw = await
|
|
31133
|
+
const raw = await readFile13(pagePath, "utf8");
|
|
31360
31134
|
JSON.parse(raw);
|
|
31361
31135
|
} catch (error) {
|
|
31362
31136
|
if (!isMissingPathError(error)) {
|
|
@@ -31454,8 +31228,8 @@ var init_analyst_entry = __esm({
|
|
|
31454
31228
|
});
|
|
31455
31229
|
|
|
31456
31230
|
// src/public-cli/analyst-run.ts
|
|
31457
|
-
import { readFile as
|
|
31458
|
-
import { isAbsolute as
|
|
31231
|
+
import { readFile as readFile14 } from "node:fs/promises";
|
|
31232
|
+
import { isAbsolute as isAbsolute9, resolve as resolve12 } from "node:path";
|
|
31459
31233
|
function resolveAnalystIssueBookKeyFromCwd(cwd = process.cwd()) {
|
|
31460
31234
|
try {
|
|
31461
31235
|
return resolveBookKeyFromGit(cwd);
|
|
@@ -31504,10 +31278,10 @@ async function buildAnalystSweepModeInputFromAttachmentPaths(attachmentPaths) {
|
|
|
31504
31278
|
);
|
|
31505
31279
|
}
|
|
31506
31280
|
const sourcePath = attachmentPaths[0];
|
|
31507
|
-
const absolute =
|
|
31281
|
+
const absolute = isAbsolute9(sourcePath) ? sourcePath : resolve12(sourcePath);
|
|
31508
31282
|
let bytes;
|
|
31509
31283
|
try {
|
|
31510
|
-
bytes = await
|
|
31284
|
+
bytes = await readFile14(absolute);
|
|
31511
31285
|
} catch (error) {
|
|
31512
31286
|
throw new CliUsageError(
|
|
31513
31287
|
`analyst sweep attachment is not a readable regular file: ${sourcePath}`,
|
|
@@ -32528,7 +32302,7 @@ var init_cli = __esm({
|
|
|
32528
32302
|
|
|
32529
32303
|
// src/public-cli/main.ts
|
|
32530
32304
|
import { existsSync as existsSync9 } from "node:fs";
|
|
32531
|
-
import { dirname as dirname19, join as
|
|
32305
|
+
import { dirname as dirname19, join as join30 } from "node:path";
|
|
32532
32306
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
32533
32307
|
|
|
32534
32308
|
// src/public-cli/host-pi-runtime.ts
|
|
@@ -32617,8 +32391,8 @@ function linkPackage(packageRoot2, name, targetDir) {
|
|
|
32617
32391
|
// src/public-cli/main.ts
|
|
32618
32392
|
var here = dirname19(fileURLToPath2(import.meta.url));
|
|
32619
32393
|
function resolvePackageRoot(binDir) {
|
|
32620
|
-
const canonical =
|
|
32621
|
-
if (existsSync9(
|
|
32394
|
+
const canonical = join30(binDir, "..", "..");
|
|
32395
|
+
if (existsSync9(join30(canonical, "package.json"))) {
|
|
32622
32396
|
return canonical;
|
|
32623
32397
|
}
|
|
32624
32398
|
return binDir;
|