@akagilnc/pi-workflow-roles 0.1.4204 → 0.1.4228
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp-host/production-host.js +1203 -770
- package/dist/atomic-write.js +23 -0
- package/dist/diarist-contracts.js +22 -8
- package/dist/headless-host/production-host.js +1191 -758
- package/dist/ledger-session-read.js +52 -21
- package/dist/migrate-book-topology.js +238 -205
- package/dist/public-cli/case-dossier-delivery.js +0 -1
- package/dist/public-cli/main.js +303 -261
- package/dist/session-dialogue.js +221 -0
- package/dist/sitian-facade.js +1 -0
- package/dist/sitian-volume.js +67 -0
- package/dist/ticket-provenance-contracts.js +122 -39
- package/dist/ticket-provenance.js +289 -204
- package/package.json +1 -1
- package/src/book-topology-migration.ts +0 -7
- package/src/book-topology-record-class-migrators.ts +203 -99
- package/src/diarist-contracts.ts +42 -29
- package/src/diarist-role.ts +77 -31
- package/src/diarist.ts +31 -67
- package/src/ledger-session-read.ts +70 -27
- package/src/package-contracts/reviewer-output.ts +1 -1
- package/src/public-cli/case-dossier-delivery.ts +0 -1
- package/src/reviewer-role.ts +3 -3
- package/src/role-runtime.ts +56 -14
- package/src/session-dialogue.ts +225 -0
- package/src/sitian-appender.ts +1 -1
- package/src/sitian-facade.ts +7 -1
- package/src/sitian-volume.ts +91 -0
- package/src/ticket-provenance-contracts.ts +158 -101
- package/src/ticket-provenance.ts +387 -263
package/dist/public-cli/main.js
CHANGED
|
@@ -14848,6 +14848,15 @@ var init_auditor_output = __esm({
|
|
|
14848
14848
|
}
|
|
14849
14849
|
});
|
|
14850
14850
|
|
|
14851
|
+
// src/ticket-provenance-contracts.ts
|
|
14852
|
+
var TICKET_PROVENANCE_KIND;
|
|
14853
|
+
var init_ticket_provenance_contracts = __esm({
|
|
14854
|
+
"src/ticket-provenance-contracts.ts"() {
|
|
14855
|
+
"use strict";
|
|
14856
|
+
TICKET_PROVENANCE_KIND = "ticket-provenance";
|
|
14857
|
+
}
|
|
14858
|
+
});
|
|
14859
|
+
|
|
14851
14860
|
// src/diarist-contracts.ts
|
|
14852
14861
|
function projectCourtTicketNumbers(raw, options) {
|
|
14853
14862
|
if (!Array.isArray(raw)) return null;
|
|
@@ -14926,6 +14935,7 @@ var DIARIST_OUTPUT_TOOL_NAME;
|
|
|
14926
14935
|
var init_diarist_contracts = __esm({
|
|
14927
14936
|
"src/diarist-contracts.ts"() {
|
|
14928
14937
|
"use strict";
|
|
14938
|
+
init_ticket_provenance_contracts();
|
|
14929
14939
|
init_run_ticket_number();
|
|
14930
14940
|
DIARIST_OUTPUT_TOOL_NAME = "ak_diarist_output";
|
|
14931
14941
|
}
|
|
@@ -16524,6 +16534,42 @@ var init_sitian_reader = __esm({
|
|
|
16524
16534
|
}
|
|
16525
16535
|
});
|
|
16526
16536
|
|
|
16537
|
+
// src/atomic-write.ts
|
|
16538
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
16539
|
+
import { rename, rm, writeFile as writeFile2 } from "node:fs/promises";
|
|
16540
|
+
import { dirname as dirname6, join as join10 } from "node:path";
|
|
16541
|
+
async function writeFileAtomically(destination, contents) {
|
|
16542
|
+
const parent = dirname6(destination);
|
|
16543
|
+
const temporary = join10(parent, `.atomic-write-${randomUUID2()}.tmp`);
|
|
16544
|
+
try {
|
|
16545
|
+
await writeFile2(temporary, contents);
|
|
16546
|
+
await rename(temporary, destination);
|
|
16547
|
+
} catch (error) {
|
|
16548
|
+
await rm(temporary, { force: true }).catch(() => void 0);
|
|
16549
|
+
throw error;
|
|
16550
|
+
}
|
|
16551
|
+
}
|
|
16552
|
+
var init_atomic_write = __esm({
|
|
16553
|
+
"src/atomic-write.ts"() {
|
|
16554
|
+
"use strict";
|
|
16555
|
+
}
|
|
16556
|
+
});
|
|
16557
|
+
|
|
16558
|
+
// src/sitian-volume.ts
|
|
16559
|
+
function resolveSitianVolume(input) {
|
|
16560
|
+
const path = resolveSitianRecordPath(input);
|
|
16561
|
+
return { recordFile: path.recordFile, volumeDir: path.sessionDir };
|
|
16562
|
+
}
|
|
16563
|
+
var init_sitian_volume = __esm({
|
|
16564
|
+
"src/sitian-volume.ts"() {
|
|
16565
|
+
"use strict";
|
|
16566
|
+
init_activation_ledger_topology();
|
|
16567
|
+
init_atomic_write();
|
|
16568
|
+
init_sitian_appender();
|
|
16569
|
+
init_sitian_contracts();
|
|
16570
|
+
}
|
|
16571
|
+
});
|
|
16572
|
+
|
|
16527
16573
|
// src/sitian-facade.ts
|
|
16528
16574
|
function sitianReport(input) {
|
|
16529
16575
|
return appendSitianRecord(input);
|
|
@@ -16535,6 +16581,7 @@ var init_sitian_facade = __esm({
|
|
|
16535
16581
|
init_sitian_contracts();
|
|
16536
16582
|
init_sitian_appender();
|
|
16537
16583
|
init_sitian_reader();
|
|
16584
|
+
init_sitian_volume();
|
|
16538
16585
|
}
|
|
16539
16586
|
});
|
|
16540
16587
|
|
|
@@ -16553,12 +16600,12 @@ __export(role_turn_host_exports, {
|
|
|
16553
16600
|
import { execFile, spawn } from "node:child_process";
|
|
16554
16601
|
import { constants } from "node:fs";
|
|
16555
16602
|
import { access, appendFile, readFile as readFile4, realpath } from "node:fs/promises";
|
|
16556
|
-
import { basename as basename3, delimiter as delimiter2, dirname as
|
|
16603
|
+
import { basename as basename3, delimiter as delimiter2, dirname as dirname7, isAbsolute as isAbsolute3, join as join11, resolve as resolve3 } from "node:path";
|
|
16557
16604
|
import { platform } from "node:process";
|
|
16558
16605
|
import { promisify } from "node:util";
|
|
16559
|
-
import { randomUUID as
|
|
16606
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
16560
16607
|
function resolveInternalRoleEntrypoint(packageRoot2) {
|
|
16561
|
-
return
|
|
16608
|
+
return join11(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
|
|
16562
16609
|
}
|
|
16563
16610
|
function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
|
|
16564
16611
|
return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
|
|
@@ -16594,7 +16641,7 @@ function buildMethodArgs(methods) {
|
|
|
16594
16641
|
function applyPiNativeSkillInvocation(methods, prompt) {
|
|
16595
16642
|
const skills = methods.filter((method) => method.kind === "skill");
|
|
16596
16643
|
if (skills.length !== 1) return prompt;
|
|
16597
|
-
const name = basename3(
|
|
16644
|
+
const name = basename3(dirname7(skills[0].path));
|
|
16598
16645
|
if (name.length === 0) return prompt;
|
|
16599
16646
|
const token = `/skill:${name}`;
|
|
16600
16647
|
const trimmed = prompt.trimStart();
|
|
@@ -16842,7 +16889,7 @@ async function appendPiSessionCustomEntry(authority, principal, customType, data
|
|
|
16842
16889
|
type: "custom",
|
|
16843
16890
|
customType,
|
|
16844
16891
|
data,
|
|
16845
|
-
id:
|
|
16892
|
+
id: randomUUID3(),
|
|
16846
16893
|
parentId,
|
|
16847
16894
|
timestamp: timestamp2
|
|
16848
16895
|
})}
|
|
@@ -16942,8 +16989,8 @@ var init_compliance_transport = __esm({
|
|
|
16942
16989
|
|
|
16943
16990
|
// src/role-run-relocation.ts
|
|
16944
16991
|
import { existsSync as existsSync5 } from "node:fs";
|
|
16945
|
-
import { readdir as readdir2, readFile as readFile5, writeFile as
|
|
16946
|
-
import { join as
|
|
16992
|
+
import { readdir as readdir2, readFile as readFile5, writeFile as writeFile3 } from "node:fs/promises";
|
|
16993
|
+
import { join as join12, sep as sep2 } from "node:path";
|
|
16947
16994
|
function isEnoent2(error) {
|
|
16948
16995
|
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
16949
16996
|
}
|
|
@@ -17035,7 +17082,7 @@ async function rewriteJsonObjectFile(path, fields, rewrites) {
|
|
|
17035
17082
|
const page = JSON.parse(await readFile5(path, "utf8"));
|
|
17036
17083
|
if (!isPlainObject(page)) return;
|
|
17037
17084
|
rewriteRunDirectoryPathFieldsAgainstRewrites(page, fields, rewrites);
|
|
17038
|
-
await
|
|
17085
|
+
await writeFile3(path, `${JSON.stringify(page, null, 2)}
|
|
17039
17086
|
`, "utf8");
|
|
17040
17087
|
}
|
|
17041
17088
|
async function rewriteOfficerPointerFile(path, rewrites) {
|
|
@@ -17048,7 +17095,7 @@ async function rewriteOfficerPointerFile(path, rewrites) {
|
|
|
17048
17095
|
OFFICER_POINTER_FIELDS,
|
|
17049
17096
|
rewrites
|
|
17050
17097
|
);
|
|
17051
|
-
await
|
|
17098
|
+
await writeFile3(path, `${JSON.stringify(page)}
|
|
17052
17099
|
`, "utf8");
|
|
17053
17100
|
}
|
|
17054
17101
|
async function rewriteSitianRecordsJsonl(path, rewrites) {
|
|
@@ -17095,7 +17142,7 @@ async function rewriteSitianRecordsJsonl(path, rewrites) {
|
|
|
17095
17142
|
}
|
|
17096
17143
|
if (!changed) return;
|
|
17097
17144
|
const body = out.join("\n");
|
|
17098
|
-
await
|
|
17145
|
+
await writeFile3(
|
|
17099
17146
|
path,
|
|
17100
17147
|
endsWithNewline && !body.endsWith("\n") ? `${body}
|
|
17101
17148
|
` : body,
|
|
@@ -17155,7 +17202,7 @@ async function rewriteSessionTranscriptBindings(path, rewrites) {
|
|
|
17155
17202
|
}
|
|
17156
17203
|
if (!changed) return;
|
|
17157
17204
|
const body = out.join("\n");
|
|
17158
|
-
await
|
|
17205
|
+
await writeFile3(
|
|
17159
17206
|
path,
|
|
17160
17207
|
endsWithNewline && !body.endsWith("\n") ? `${body}
|
|
17161
17208
|
` : body,
|
|
@@ -17163,7 +17210,7 @@ async function rewriteSessionTranscriptBindings(path, rewrites) {
|
|
|
17163
17210
|
);
|
|
17164
17211
|
}
|
|
17165
17212
|
async function rewriteNestedMachinePathPages(pagesDirectory, rewrites) {
|
|
17166
|
-
const sessionRoot =
|
|
17213
|
+
const sessionRoot = join12(pagesDirectory, "session");
|
|
17167
17214
|
async function walk(directory) {
|
|
17168
17215
|
let entries;
|
|
17169
17216
|
try {
|
|
@@ -17173,7 +17220,7 @@ async function rewriteNestedMachinePathPages(pagesDirectory, rewrites) {
|
|
|
17173
17220
|
throw error;
|
|
17174
17221
|
}
|
|
17175
17222
|
for (const entry of entries) {
|
|
17176
|
-
const path =
|
|
17223
|
+
const path = join12(directory, entry.name);
|
|
17177
17224
|
if (entry.isDirectory()) {
|
|
17178
17225
|
await walk(path);
|
|
17179
17226
|
continue;
|
|
@@ -17195,7 +17242,7 @@ async function rewriteNestedMachinePathPages(pagesDirectory, rewrites) {
|
|
|
17195
17242
|
async function rewriteRoleRunDurablePages(input) {
|
|
17196
17243
|
const { pagesDirectory } = input;
|
|
17197
17244
|
const rewrites = collectRewrites(input);
|
|
17198
|
-
const admittedPath =
|
|
17245
|
+
const admittedPath = join12(pagesDirectory, "admitted-request.json");
|
|
17199
17246
|
if (existsSync5(admittedPath)) {
|
|
17200
17247
|
const page = JSON.parse(await readFile5(admittedPath, "utf8"));
|
|
17201
17248
|
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
@@ -17222,10 +17269,10 @@ async function rewriteRoleRunDurablePages(input) {
|
|
|
17222
17269
|
rewrites
|
|
17223
17270
|
);
|
|
17224
17271
|
}
|
|
17225
|
-
await
|
|
17272
|
+
await writeFile3(admittedPath, `${JSON.stringify(page, null, 2)}
|
|
17226
17273
|
`, "utf8");
|
|
17227
17274
|
}
|
|
17228
|
-
const invocationPath =
|
|
17275
|
+
const invocationPath = join12(pagesDirectory, "invocation.json");
|
|
17229
17276
|
if (existsSync5(invocationPath)) {
|
|
17230
17277
|
const page = JSON.parse(await readFile5(invocationPath, "utf8"));
|
|
17231
17278
|
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
@@ -17233,14 +17280,14 @@ async function rewriteRoleRunDurablePages(input) {
|
|
|
17233
17280
|
INVOCATION_PAGE_FIELDS,
|
|
17234
17281
|
rewrites
|
|
17235
17282
|
);
|
|
17236
|
-
await
|
|
17283
|
+
await writeFile3(
|
|
17237
17284
|
invocationPath,
|
|
17238
17285
|
`${JSON.stringify(page, null, 2)}
|
|
17239
17286
|
`,
|
|
17240
17287
|
"utf8"
|
|
17241
17288
|
);
|
|
17242
17289
|
}
|
|
17243
|
-
const statePath =
|
|
17290
|
+
const statePath = join12(pagesDirectory, "run-state.json");
|
|
17244
17291
|
if (existsSync5(statePath)) {
|
|
17245
17292
|
const page = JSON.parse(await readFile5(statePath, "utf8"));
|
|
17246
17293
|
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
@@ -17258,7 +17305,7 @@ async function rewriteRoleRunDurablePages(input) {
|
|
|
17258
17305
|
if (isPlainObject(page.currentCourt)) {
|
|
17259
17306
|
rewriteSummonsMaterials(page.currentCourt.summons, rewrites);
|
|
17260
17307
|
}
|
|
17261
|
-
await
|
|
17308
|
+
await writeFile3(statePath, `${JSON.stringify(page, null, 2)}
|
|
17262
17309
|
`, "utf8");
|
|
17263
17310
|
}
|
|
17264
17311
|
await rewriteNestedMachinePathPages(pagesDirectory, rewrites);
|
|
@@ -17403,7 +17450,7 @@ var init_terminating_tools = __esm({
|
|
|
17403
17450
|
|
|
17404
17451
|
// src/doctor-evidence.ts
|
|
17405
17452
|
import { readdir as readdir3, readFile as readFile6, realpath as realpath2, stat } from "node:fs/promises";
|
|
17406
|
-
import { dirname as
|
|
17453
|
+
import { dirname as dirname8, relative as relative2, resolve as resolve4, sep as sep3 } from "node:path";
|
|
17407
17454
|
function record2(value) {
|
|
17408
17455
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17409
17456
|
}
|
|
@@ -17442,7 +17489,7 @@ async function stableRunsIdentity(root) {
|
|
|
17442
17489
|
} catch (error) {
|
|
17443
17490
|
if (!isMissingPathError2(error)) throw error;
|
|
17444
17491
|
}
|
|
17445
|
-
const parent =
|
|
17492
|
+
const parent = dirname8(cursor);
|
|
17446
17493
|
if (parent === cursor) return root;
|
|
17447
17494
|
cursor = parent;
|
|
17448
17495
|
}
|
|
@@ -18104,10 +18151,10 @@ var init_uuidv7 = __esm({
|
|
|
18104
18151
|
});
|
|
18105
18152
|
|
|
18106
18153
|
// src/typed-provider-http.ts
|
|
18107
|
-
import { readFile as readFile9, unlink, writeFile as
|
|
18108
|
-
import { join as
|
|
18154
|
+
import { readFile as readFile9, unlink, writeFile as writeFile4 } from "node:fs/promises";
|
|
18155
|
+
import { join as join13 } from "node:path";
|
|
18109
18156
|
function typedProviderHttpPath(runDirectory) {
|
|
18110
|
-
return
|
|
18157
|
+
return join13(runDirectory, TYPED_HTTP_FILE);
|
|
18111
18158
|
}
|
|
18112
18159
|
async function clearTypedProviderHttpObservation(runDirectory) {
|
|
18113
18160
|
try {
|
|
@@ -18151,8 +18198,8 @@ var init_typed_provider_http = __esm({
|
|
|
18151
18198
|
});
|
|
18152
18199
|
|
|
18153
18200
|
// src/public-cli/run-lifecycle.ts
|
|
18154
|
-
import { chmod, lstat as lstat2, open, readdir as readdir4, readFile as readFile10, unlink as unlink2, writeFile as
|
|
18155
|
-
import { basename as basename4, join as
|
|
18201
|
+
import { chmod, lstat as lstat2, open, readdir as readdir4, readFile as readFile10, unlink as unlink2, writeFile as writeFile5 } from "node:fs/promises";
|
|
18202
|
+
import { basename as basename4, join as join14 } from "node:path";
|
|
18156
18203
|
function selectResumeContinuationPrompt(message, engineMaterial) {
|
|
18157
18204
|
const lines = message !== void 0 ? [message] : [];
|
|
18158
18205
|
return appendEngineSessionMaterial(lines, engineMaterial).join("\n");
|
|
@@ -18181,8 +18228,8 @@ function renderResumeCommand(runId) {
|
|
|
18181
18228
|
}
|
|
18182
18229
|
async function writeRoleRunState(runDirectory, record4) {
|
|
18183
18230
|
const payload = { ...record4, runDirectory };
|
|
18184
|
-
await
|
|
18185
|
-
|
|
18231
|
+
await writeFile5(
|
|
18232
|
+
join14(runDirectory, RUN_STATE_FILE),
|
|
18186
18233
|
`${JSON.stringify(payload, null, 2)}
|
|
18187
18234
|
`,
|
|
18188
18235
|
"utf8"
|
|
@@ -18232,7 +18279,7 @@ function parseCurrentCourtState(raw) {
|
|
|
18232
18279
|
async function readRoleRunStateDisk(runDirectory) {
|
|
18233
18280
|
let raw;
|
|
18234
18281
|
try {
|
|
18235
|
-
raw = JSON.parse(await readFile10(
|
|
18282
|
+
raw = JSON.parse(await readFile10(join14(runDirectory, RUN_STATE_FILE), "utf8"));
|
|
18236
18283
|
} catch (error) {
|
|
18237
18284
|
if (errorCodeOf2(error) === "ENOENT") return void 0;
|
|
18238
18285
|
throw error;
|
|
@@ -18299,8 +18346,8 @@ async function writeRoleRunStateDisk(runDirectory, disk) {
|
|
|
18299
18346
|
...disk.resumable === void 0 ? {} : { resumable: disk.resumable },
|
|
18300
18347
|
...disk.currentCourt === void 0 ? {} : { currentCourt: disk.currentCourt }
|
|
18301
18348
|
};
|
|
18302
|
-
await
|
|
18303
|
-
|
|
18349
|
+
await writeFile5(
|
|
18350
|
+
join14(runDirectory, RUN_STATE_FILE),
|
|
18304
18351
|
`${JSON.stringify(payload, null, 2)}
|
|
18305
18352
|
`,
|
|
18306
18353
|
"utf8"
|
|
@@ -18526,7 +18573,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
|
|
|
18526
18573
|
},
|
|
18527
18574
|
relocate(nextRunDirectory) {
|
|
18528
18575
|
currentRunDirectory = nextRunDirectory;
|
|
18529
|
-
currentLockPath =
|
|
18576
|
+
currentLockPath = join14(nextRunDirectory, WRITER_LOCK_FILE);
|
|
18530
18577
|
},
|
|
18531
18578
|
async release() {
|
|
18532
18579
|
if (released) return;
|
|
@@ -18565,10 +18612,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
18565
18612
|
};
|
|
18566
18613
|
const reportReadFailure = (error) => {
|
|
18567
18614
|
reportDiagnostic(
|
|
18568
|
-
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${
|
|
18615
|
+
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join14(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
|
|
18569
18616
|
);
|
|
18570
18617
|
};
|
|
18571
|
-
const lockPath =
|
|
18618
|
+
const lockPath = join14(runDirectory, WRITER_LOCK_FILE);
|
|
18572
18619
|
let lastAutopsy = { verdict: "absent" };
|
|
18573
18620
|
let lastReclaimFailure;
|
|
18574
18621
|
for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
|
|
@@ -18623,7 +18670,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
18623
18670
|
async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
18624
18671
|
if (runId.trim() === "") return void 0;
|
|
18625
18672
|
const ledgerHome = resolveActivationLedgerHome(home);
|
|
18626
|
-
const booksRoot =
|
|
18673
|
+
const booksRoot = join14(ledgerHome, "books");
|
|
18627
18674
|
let bookKeys;
|
|
18628
18675
|
try {
|
|
18629
18676
|
bookKeys = await readdir4(booksRoot);
|
|
@@ -18664,7 +18711,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
18664
18711
|
let raw;
|
|
18665
18712
|
try {
|
|
18666
18713
|
raw = JSON.parse(
|
|
18667
|
-
await readFile10(
|
|
18714
|
+
await readFile10(join14(runDirectory, "admitted-request.json"), "utf8")
|
|
18668
18715
|
);
|
|
18669
18716
|
} catch (error) {
|
|
18670
18717
|
if (errorCodeOf2(error) === "ENOENT") return void 0;
|
|
@@ -18685,7 +18732,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
18685
18732
|
async function runHasFormedSessionPrincipal(runDirectory) {
|
|
18686
18733
|
const disk = await readRoleRunStateDisk(runDirectory);
|
|
18687
18734
|
if (disk === void 0) return false;
|
|
18688
|
-
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile :
|
|
18735
|
+
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : join14(disk.principalWire.sessionDirectory, "session.jsonl");
|
|
18689
18736
|
try {
|
|
18690
18737
|
const stat2 = await lstat2(sessionFile);
|
|
18691
18738
|
return stat2.isFile() && !stat2.isSymbolicLink();
|
|
@@ -18947,7 +18994,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
18947
18994
|
let model;
|
|
18948
18995
|
try {
|
|
18949
18996
|
const invocationRaw = JSON.parse(
|
|
18950
|
-
await readFile10(
|
|
18997
|
+
await readFile10(join14(run.runDirectory, "invocation.json"), "utf8")
|
|
18951
18998
|
);
|
|
18952
18999
|
if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
|
|
18953
19000
|
const rec = invocationRaw;
|
|
@@ -19381,7 +19428,7 @@ __export(notary_source_run_exports, {
|
|
|
19381
19428
|
loadNotarySourceRunLocator: () => loadNotarySourceRunLocator,
|
|
19382
19429
|
resolveNotarySourceRunLocator: () => resolveNotarySourceRunLocator
|
|
19383
19430
|
});
|
|
19384
|
-
import { dirname as
|
|
19431
|
+
import { dirname as dirname9, isAbsolute as isAbsolute6, join as join15, resolve as resolve6, basename as basename5 } from "node:path";
|
|
19385
19432
|
import { lstat as lstat3, realpath as realpath3 } from "node:fs/promises";
|
|
19386
19433
|
function parseRunDirectoryName(name) {
|
|
19387
19434
|
const match = RUN_DIR_NAME.exec(name);
|
|
@@ -19427,20 +19474,20 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
19427
19474
|
}
|
|
19428
19475
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
19429
19476
|
const bookKey = resolveBookKeyFromGit(options.projectRoot);
|
|
19430
|
-
const bookRunsRoot =
|
|
19477
|
+
const bookRunsRoot = join15(activationBookDirectory(ledgerHome, bookKey), "runs");
|
|
19431
19478
|
let candidate;
|
|
19432
19479
|
const bare = parseRunDirectoryName(raw);
|
|
19433
19480
|
if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
|
|
19434
|
-
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ??
|
|
19481
|
+
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join15(bookRunsRoot, `${bare.runId}@${bare.role}`);
|
|
19435
19482
|
} else {
|
|
19436
19483
|
candidate = isAbsolute6(raw) ? raw : resolve6(options.projectRoot, raw);
|
|
19437
19484
|
}
|
|
19438
19485
|
const real = await requireRunDirectory(candidate, raw);
|
|
19439
19486
|
const identity = parseRunDirectoryName(basename5(real));
|
|
19440
19487
|
const bookIdentity = physicalPathIdentity(activationBookDirectory(ledgerHome, bookKey));
|
|
19441
|
-
const parentIdentity = physicalPathIdentity(
|
|
19442
|
-
const subjectBookIdentity = physicalPathIdentity(
|
|
19443
|
-
if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename5(
|
|
19488
|
+
const parentIdentity = physicalPathIdentity(dirname9(real));
|
|
19489
|
+
const subjectBookIdentity = physicalPathIdentity(dirname9(dirname9(dirname9(real))));
|
|
19490
|
+
if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename5(dirname9(real)) === "runs" && subjectBookIdentity === bookIdentity)) {
|
|
19444
19491
|
throw new NotarySourceRunError(
|
|
19445
19492
|
"notary --source-run must resolve to a retained run under the project machine-ledger book"
|
|
19446
19493
|
);
|
|
@@ -20643,10 +20690,10 @@ import {
|
|
|
20643
20690
|
lstat as lstat4,
|
|
20644
20691
|
readFile as readFile11,
|
|
20645
20692
|
realpath as realpath4,
|
|
20646
|
-
rename,
|
|
20647
|
-
writeFile as
|
|
20693
|
+
rename as rename2,
|
|
20694
|
+
writeFile as writeFile6
|
|
20648
20695
|
} from "node:fs/promises";
|
|
20649
|
-
import { basename as basename6, dirname as
|
|
20696
|
+
import { basename as basename6, dirname as dirname10, isAbsolute as isAbsolute7, join as join16, resolve as resolve7, sep as sep4 } from "node:path";
|
|
20650
20697
|
function issueAdmissionPlacement(authority, request) {
|
|
20651
20698
|
const ledgerHome = resolveActivationLedgerHome(request.home);
|
|
20652
20699
|
const bookKey = resolveBookKeyFromGit(request.cwd);
|
|
@@ -20671,7 +20718,7 @@ async function writeAdmittedRequestPersistence(admittedRequestPath, body, coordi
|
|
|
20671
20718
|
sessionDirectory: coordinates.sessionDirectory,
|
|
20672
20719
|
sessionFile: coordinates.sessionFile
|
|
20673
20720
|
};
|
|
20674
|
-
await
|
|
20721
|
+
await writeFile6(
|
|
20675
20722
|
admittedRequestPath,
|
|
20676
20723
|
`${JSON.stringify(projection, null, 2)}
|
|
20677
20724
|
`,
|
|
@@ -20699,15 +20746,15 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
|
|
|
20699
20746
|
...source.ticketNumber === void 0 ? {} : { ticketNumber: source.ticketNumber },
|
|
20700
20747
|
...effectiveModelLedgerFields(effectiveModel)
|
|
20701
20748
|
};
|
|
20702
|
-
await
|
|
20703
|
-
|
|
20749
|
+
await writeFile6(
|
|
20750
|
+
join16(source.runDirectory, "invocation.json"),
|
|
20704
20751
|
`${JSON.stringify(identity, null, 2)}
|
|
20705
20752
|
`,
|
|
20706
20753
|
"utf8"
|
|
20707
20754
|
);
|
|
20708
20755
|
}
|
|
20709
20756
|
async function recordEffectiveInvocationModel(runDirectory, model, engine, host, engineModel) {
|
|
20710
|
-
const ledgerPath =
|
|
20757
|
+
const ledgerPath = join16(runDirectory, "invocation.json");
|
|
20711
20758
|
const current = JSON.parse(await readFile11(ledgerPath, "utf8"));
|
|
20712
20759
|
const next = { ...current };
|
|
20713
20760
|
if (model !== void 0) {
|
|
@@ -20732,7 +20779,7 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host,
|
|
|
20732
20779
|
if (host !== void 0) {
|
|
20733
20780
|
next.host = host;
|
|
20734
20781
|
}
|
|
20735
|
-
await
|
|
20782
|
+
await writeFile6(
|
|
20736
20783
|
ledgerPath,
|
|
20737
20784
|
`${JSON.stringify(next, null, 2)}
|
|
20738
20785
|
`,
|
|
@@ -20740,9 +20787,9 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host,
|
|
|
20740
20787
|
);
|
|
20741
20788
|
}
|
|
20742
20789
|
async function mergeInvocationIdentityPage(runDirectory, fields) {
|
|
20743
|
-
const ledgerPath =
|
|
20790
|
+
const ledgerPath = join16(runDirectory, "invocation.json");
|
|
20744
20791
|
const current = JSON.parse(await readFile11(ledgerPath, "utf8"));
|
|
20745
|
-
await
|
|
20792
|
+
await writeFile6(
|
|
20746
20793
|
ledgerPath,
|
|
20747
20794
|
`${JSON.stringify({
|
|
20748
20795
|
...current,
|
|
@@ -20764,7 +20811,7 @@ async function persistAdmittedSourceRunPath(admitted, sourceRunPath) {
|
|
|
20764
20811
|
`persistAdmittedSourceRunPath refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`
|
|
20765
20812
|
);
|
|
20766
20813
|
}
|
|
20767
|
-
await
|
|
20814
|
+
await writeFile6(
|
|
20768
20815
|
admittedPath,
|
|
20769
20816
|
`${JSON.stringify({ ...current, sourceRunPath }, null, 2)}
|
|
20770
20817
|
`,
|
|
@@ -20807,7 +20854,7 @@ async function bindCourtTicketNumbersOnAdmitted(admitted, courtTicketNumbers) {
|
|
|
20807
20854
|
const frozen = Object.freeze([...projected]);
|
|
20808
20855
|
const admittedPath = admitted.admittedRequestPath;
|
|
20809
20856
|
const current = JSON.parse(await readFile11(admittedPath, "utf8"));
|
|
20810
|
-
await
|
|
20857
|
+
await writeFile6(
|
|
20811
20858
|
admittedPath,
|
|
20812
20859
|
`${JSON.stringify({ ...current, courtTicketNumbers: frozen }, null, 2)}
|
|
20813
20860
|
`,
|
|
@@ -20828,8 +20875,8 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
20828
20875
|
runId: admitted.runId,
|
|
20829
20876
|
role: admitted.role
|
|
20830
20877
|
});
|
|
20831
|
-
ensureRoleRunDirectory(ledgerHome,
|
|
20832
|
-
await
|
|
20878
|
+
ensureRoleRunDirectory(ledgerHome, dirname10(target.runDirectory));
|
|
20879
|
+
await rename2(oldRunDirectory, target.runDirectory);
|
|
20833
20880
|
heldLease?.relocate(target.runDirectory);
|
|
20834
20881
|
const admittedRecord = admitted;
|
|
20835
20882
|
rewriteRunDirectoryPathFields(
|
|
@@ -20866,8 +20913,8 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
|
20866
20913
|
ticketNumber,
|
|
20867
20914
|
"bindTicketNumberOnRunDirectory"
|
|
20868
20915
|
);
|
|
20869
|
-
const admittedPath =
|
|
20870
|
-
const invocationPath =
|
|
20916
|
+
const admittedPath = join16(runDirectory, "admitted-request.json");
|
|
20917
|
+
const invocationPath = join16(runDirectory, "invocation.json");
|
|
20871
20918
|
const admitted = JSON.parse(await readFile11(admittedPath, "utf8"));
|
|
20872
20919
|
const existing = admitted.ticketNumber;
|
|
20873
20920
|
if (typeof existing === "number") {
|
|
@@ -20886,7 +20933,7 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
|
20886
20933
|
);
|
|
20887
20934
|
}
|
|
20888
20935
|
}
|
|
20889
|
-
await
|
|
20936
|
+
await writeFile6(
|
|
20890
20937
|
admittedPath,
|
|
20891
20938
|
`${JSON.stringify({ ...admitted, ticketNumber }, null, 2)}
|
|
20892
20939
|
`,
|
|
@@ -20903,7 +20950,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
20903
20950
|
async function observeLaunchedRolePackageIdentity(packageRoot2, selectedRoleEntry) {
|
|
20904
20951
|
const rolePackageRoot = packageRoot2;
|
|
20905
20952
|
const raw = JSON.parse(
|
|
20906
|
-
await readFile11(
|
|
20953
|
+
await readFile11(join16(rolePackageRoot, "package.json"), "utf8")
|
|
20907
20954
|
);
|
|
20908
20955
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
20909
20956
|
throw new Error(
|
|
@@ -21161,8 +21208,8 @@ async function freezeRegularFileAttachment(sourcePath, destinationDir, index) {
|
|
|
21161
21208
|
}
|
|
21162
21209
|
const bytes = await readFile11(absolute);
|
|
21163
21210
|
const name = `${String(index).padStart(2, "0")}-${basename6(absolute)}`;
|
|
21164
|
-
const frozenPath =
|
|
21165
|
-
await
|
|
21211
|
+
const frozenPath = join16(destinationDir, name);
|
|
21212
|
+
await writeFile6(frozenPath, bytes);
|
|
21166
21213
|
return {
|
|
21167
21214
|
attachment: {
|
|
21168
21215
|
provenancePath: absolute,
|
|
@@ -21189,7 +21236,7 @@ async function freezeAttachments(attachmentPaths, attachmentsDirectory) {
|
|
|
21189
21236
|
async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKey = `s-${Date.now().toString(36)}`) {
|
|
21190
21237
|
if (attachmentPaths.length === 0) return [];
|
|
21191
21238
|
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
21192
|
-
const attachmentsDirectory =
|
|
21239
|
+
const attachmentsDirectory = join16(runDirectory, "attachments", summonsKey);
|
|
21193
21240
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
21194
21241
|
return freezeAttachments(attachmentPaths, attachmentsDirectory);
|
|
21195
21242
|
}
|
|
@@ -21247,7 +21294,7 @@ async function admitStandardMaterialInvocation(role, options) {
|
|
|
21247
21294
|
})),
|
|
21248
21295
|
...ticketFields
|
|
21249
21296
|
};
|
|
21250
|
-
const admittedRequestPath =
|
|
21297
|
+
const admittedRequestPath = join16(runDirectory, "admitted-request.json");
|
|
21251
21298
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
21252
21299
|
sessionDirectory,
|
|
21253
21300
|
sessionFile
|
|
@@ -21349,7 +21396,7 @@ async function admitCountersignInvocation(options) {
|
|
|
21349
21396
|
mediaKind: a.mediaKind
|
|
21350
21397
|
}))
|
|
21351
21398
|
};
|
|
21352
|
-
const admittedRequestPath =
|
|
21399
|
+
const admittedRequestPath = join16(runDirectory, "admitted-request.json");
|
|
21353
21400
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
21354
21401
|
sessionDirectory,
|
|
21355
21402
|
sessionFile
|
|
@@ -21375,7 +21422,7 @@ function buildCountersignTransportPrompt(admitted, engineMaterial) {
|
|
|
21375
21422
|
async function loadAdmittedJudgeRequest(runDirectory) {
|
|
21376
21423
|
try {
|
|
21377
21424
|
const raw = JSON.parse(
|
|
21378
|
-
await readFile11(
|
|
21425
|
+
await readFile11(join16(runDirectory, "admitted-request.json"), "utf8")
|
|
21379
21426
|
);
|
|
21380
21427
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
21381
21428
|
const record4 = raw;
|
|
@@ -21430,8 +21477,8 @@ async function admitCoderInvocation(options) {
|
|
|
21430
21477
|
home: options.home
|
|
21431
21478
|
});
|
|
21432
21479
|
const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
|
|
21433
|
-
const taskPath =
|
|
21434
|
-
await
|
|
21480
|
+
const taskPath = join16(runDirectory, "task.md");
|
|
21481
|
+
await writeFile6(taskPath, instruction, "utf8");
|
|
21435
21482
|
const admitted = {
|
|
21436
21483
|
role: "coder",
|
|
21437
21484
|
phase: options.phase,
|
|
@@ -21451,7 +21498,7 @@ async function admitCoderInvocation(options) {
|
|
|
21451
21498
|
mediaKind: a.mediaKind
|
|
21452
21499
|
}))
|
|
21453
21500
|
};
|
|
21454
|
-
const admittedRequestPath =
|
|
21501
|
+
const admittedRequestPath = join16(runDirectory, "admitted-request.json");
|
|
21455
21502
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
21456
21503
|
sessionDirectory,
|
|
21457
21504
|
sessionFile
|
|
@@ -21537,16 +21584,16 @@ async function admitFixerInvocation(options) {
|
|
|
21537
21584
|
const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
|
|
21538
21585
|
let prerequisitesPath;
|
|
21539
21586
|
if (prerequisitesSource !== void 0) {
|
|
21540
|
-
prerequisitesPath =
|
|
21541
|
-
await
|
|
21587
|
+
prerequisitesPath = join16(runDirectory, "prerequisites.json");
|
|
21588
|
+
await writeFile6(
|
|
21542
21589
|
prerequisitesPath,
|
|
21543
21590
|
`${JSON.stringify(prerequisites, null, 2)}
|
|
21544
21591
|
`,
|
|
21545
21592
|
"utf8"
|
|
21546
21593
|
);
|
|
21547
21594
|
}
|
|
21548
|
-
const packetPath =
|
|
21549
|
-
await
|
|
21595
|
+
const packetPath = join16(runDirectory, "fix-packet.md");
|
|
21596
|
+
await writeFile6(packetPath, instruction, "utf8");
|
|
21550
21597
|
const admitted = {
|
|
21551
21598
|
role: "fixer",
|
|
21552
21599
|
phase: options.phase,
|
|
@@ -21571,7 +21618,7 @@ async function admitFixerInvocation(options) {
|
|
|
21571
21618
|
mediaKind: a.mediaKind
|
|
21572
21619
|
}))
|
|
21573
21620
|
};
|
|
21574
|
-
const admittedRequestPath =
|
|
21621
|
+
const admittedRequestPath = join16(runDirectory, "admitted-request.json");
|
|
21575
21622
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
21576
21623
|
sessionDirectory,
|
|
21577
21624
|
sessionFile
|
|
@@ -21791,8 +21838,8 @@ async function admitCollectorInvocation(options) {
|
|
|
21791
21838
|
const prNumber = target.kind === "bound" ? target.prNumber : void 0;
|
|
21792
21839
|
let requestManifestPath;
|
|
21793
21840
|
if (manifestCanonicalJson !== void 0) {
|
|
21794
|
-
requestManifestPath =
|
|
21795
|
-
await
|
|
21841
|
+
requestManifestPath = join16(runDirectory, "request-manifest.json");
|
|
21842
|
+
await writeFile6(requestManifestPath, manifestCanonicalJson, "utf8");
|
|
21796
21843
|
}
|
|
21797
21844
|
const admitted = {
|
|
21798
21845
|
role: "collector",
|
|
@@ -21817,7 +21864,7 @@ async function admitCollectorInvocation(options) {
|
|
|
21817
21864
|
mediaKind: a.mediaKind
|
|
21818
21865
|
}))
|
|
21819
21866
|
};
|
|
21820
|
-
const admittedRequestPath =
|
|
21867
|
+
const admittedRequestPath = join16(runDirectory, "admitted-request.json");
|
|
21821
21868
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
21822
21869
|
sessionDirectory,
|
|
21823
21870
|
sessionFile
|
|
@@ -21915,7 +21962,7 @@ function parseDoctorArgv(args) {
|
|
|
21915
21962
|
}
|
|
21916
21963
|
async function resolveDoctorCaseRunsPath(options) {
|
|
21917
21964
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
21918
|
-
const defaultRuns =
|
|
21965
|
+
const defaultRuns = join16(
|
|
21919
21966
|
activationBookDirectory(ledgerHome, options.bookKey),
|
|
21920
21967
|
String(options.issueNumber),
|
|
21921
21968
|
"runs"
|
|
@@ -22046,7 +22093,7 @@ async function admitDoctorInvocation(options) {
|
|
|
22046
22093
|
mediaKind: a.mediaKind
|
|
22047
22094
|
}))
|
|
22048
22095
|
};
|
|
22049
|
-
const admittedRequestPath =
|
|
22096
|
+
const admittedRequestPath = join16(runDirectory, "admitted-request.json");
|
|
22050
22097
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
22051
22098
|
sessionDirectory,
|
|
22052
22099
|
sessionFile
|
|
@@ -22178,7 +22225,7 @@ async function admitNotaryInvocation(options) {
|
|
|
22178
22225
|
...ticketFields,
|
|
22179
22226
|
...options.correlationId === void 0 ? {} : { correlationId: options.correlationId }
|
|
22180
22227
|
};
|
|
22181
|
-
const admittedRequestPath =
|
|
22228
|
+
const admittedRequestPath = join16(runDirectory, "admitted-request.json");
|
|
22182
22229
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
22183
22230
|
sessionDirectory,
|
|
22184
22231
|
sessionFile
|
|
@@ -22281,7 +22328,7 @@ async function admitGleanerLeftInvocation(options) {
|
|
|
22281
22328
|
attachments: [],
|
|
22282
22329
|
...options.correlationId === void 0 ? {} : { correlationId: options.correlationId }
|
|
22283
22330
|
};
|
|
22284
|
-
const admittedRequestPath =
|
|
22331
|
+
const admittedRequestPath = join16(runDirectory, "admitted-request.json");
|
|
22285
22332
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
22286
22333
|
sessionDirectory,
|
|
22287
22334
|
sessionFile
|
|
@@ -22410,7 +22457,7 @@ async function admitReviewerInvocation(options) {
|
|
|
22410
22457
|
mediaKind: a.mediaKind
|
|
22411
22458
|
}))
|
|
22412
22459
|
};
|
|
22413
|
-
const admittedRequestPath =
|
|
22460
|
+
const admittedRequestPath = join16(runDirectory, "admitted-request.json");
|
|
22414
22461
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
22415
22462
|
sessionDirectory,
|
|
22416
22463
|
sessionFile
|
|
@@ -22555,8 +22602,8 @@ async function admitMergerInvocation(options) {
|
|
|
22555
22602
|
resolutionScope: [...derived.resolutionScope],
|
|
22556
22603
|
authorizedChecks: []
|
|
22557
22604
|
});
|
|
22558
|
-
const mergerInputPath =
|
|
22559
|
-
await
|
|
22605
|
+
const mergerInputPath = join16(runDirectory, "merger-input.json");
|
|
22606
|
+
await writeFile6(
|
|
22560
22607
|
mergerInputPath,
|
|
22561
22608
|
`${JSON.stringify(mergerInput, null, 2)}
|
|
22562
22609
|
`,
|
|
@@ -22586,7 +22633,7 @@ async function admitMergerInvocation(options) {
|
|
|
22586
22633
|
mediaKind: a.mediaKind
|
|
22587
22634
|
}))
|
|
22588
22635
|
};
|
|
22589
|
-
const admittedRequestPath =
|
|
22636
|
+
const admittedRequestPath = join16(runDirectory, "admitted-request.json");
|
|
22590
22637
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
22591
22638
|
sessionDirectory,
|
|
22592
22639
|
sessionFile
|
|
@@ -22870,15 +22917,15 @@ var init_invocation = __esm({
|
|
|
22870
22917
|
|
|
22871
22918
|
// src/public-cli/load-production-acp-host.ts
|
|
22872
22919
|
import { existsSync as existsSync7 } from "node:fs";
|
|
22873
|
-
import { join as
|
|
22920
|
+
import { join as join17 } from "node:path";
|
|
22874
22921
|
import { pathToFileURL } from "node:url";
|
|
22875
22922
|
async function loadProductionAcpHostFactory(packageRoot2, host) {
|
|
22876
22923
|
const description = lookupHostDescription(host);
|
|
22877
22924
|
if (description === void 0) {
|
|
22878
22925
|
throw new Error(`unregistered host: ${host}`);
|
|
22879
22926
|
}
|
|
22880
|
-
const built =
|
|
22881
|
-
const source =
|
|
22927
|
+
const built = join17(packageRoot2, "dist/acp-host/production-host.js");
|
|
22928
|
+
const source = join17(packageRoot2, "src/acp-host/production-host.ts");
|
|
22882
22929
|
const target = existsSync7(built) ? built : source;
|
|
22883
22930
|
const href = pathToFileURL(target).href;
|
|
22884
22931
|
const mod = await import(href);
|
|
@@ -22894,15 +22941,15 @@ var init_load_production_acp_host = __esm({
|
|
|
22894
22941
|
|
|
22895
22942
|
// src/public-cli/load-production-headless-host.ts
|
|
22896
22943
|
import { existsSync as existsSync8 } from "node:fs";
|
|
22897
|
-
import { join as
|
|
22944
|
+
import { join as join18 } from "node:path";
|
|
22898
22945
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
22899
22946
|
async function loadProductionHeadlessHostFactory(packageRoot2, host) {
|
|
22900
22947
|
const description = lookupHeadlessHostDescription(host);
|
|
22901
22948
|
if (description === void 0) {
|
|
22902
22949
|
throw new Error(`unregistered headless host: ${host}`);
|
|
22903
22950
|
}
|
|
22904
|
-
const built =
|
|
22905
|
-
const source =
|
|
22951
|
+
const built = join18(packageRoot2, "dist/headless-host/production-host.js");
|
|
22952
|
+
const source = join18(packageRoot2, "src/headless-host/production-host.ts");
|
|
22906
22953
|
const target = existsSync8(built) ? built : source;
|
|
22907
22954
|
const href = pathToFileURL2(target).href;
|
|
22908
22955
|
const mod = await import(href);
|
|
@@ -23030,7 +23077,7 @@ var init_role_turn_host_resolution = __esm({
|
|
|
23030
23077
|
// src/package-resources/method-skill.ts
|
|
23031
23078
|
import { createHash as createHash4 } from "node:crypto";
|
|
23032
23079
|
import { readFile as readFile12, realpath as realpath5 } from "node:fs/promises";
|
|
23033
|
-
import { join as
|
|
23080
|
+
import { join as join19 } from "node:path";
|
|
23034
23081
|
function gitBlobOid(bytes) {
|
|
23035
23082
|
const body = typeof bytes === "string" ? Buffer.from(bytes, "utf8") : Buffer.from(bytes);
|
|
23036
23083
|
const header = Buffer.from(`blob ${body.byteLength}\0`, "utf8");
|
|
@@ -23047,10 +23094,10 @@ function packagedMethodSkillRelativeDirectory(name) {
|
|
|
23047
23094
|
return `${METHOD_SKILL_RELATIVE_ROOT}/${name}`;
|
|
23048
23095
|
}
|
|
23049
23096
|
function resolvePackagedMethodSkillRoot(packageRoot2, name) {
|
|
23050
|
-
return
|
|
23097
|
+
return join19(packageRoot2, packagedMethodSkillRelativeDirectory(name));
|
|
23051
23098
|
}
|
|
23052
23099
|
function resolvePackagedMethodSkillPath(packageRoot2, name) {
|
|
23053
|
-
return
|
|
23100
|
+
return join19(resolvePackagedMethodSkillRoot(packageRoot2, name), "SKILL.md");
|
|
23054
23101
|
}
|
|
23055
23102
|
function isRecord4(value) {
|
|
23056
23103
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -23144,8 +23191,8 @@ function parseProvenance(raw, expectedName) {
|
|
|
23144
23191
|
}
|
|
23145
23192
|
async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
|
|
23146
23193
|
const rootDirectory = resolvePackagedMethodSkillRoot(packageRoot2, name);
|
|
23147
|
-
const skillPathConfigured =
|
|
23148
|
-
const provenancePath =
|
|
23194
|
+
const skillPathConfigured = join19(rootDirectory, "SKILL.md");
|
|
23195
|
+
const provenancePath = join19(rootDirectory, "provenance.json");
|
|
23149
23196
|
let provenanceRaw;
|
|
23150
23197
|
try {
|
|
23151
23198
|
provenanceRaw = await readFile12(provenancePath, "utf8");
|
|
@@ -23162,7 +23209,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
|
|
|
23162
23209
|
}
|
|
23163
23210
|
const provenance = parseProvenance(provenanceJson, name);
|
|
23164
23211
|
for (const [rel, expected] of Object.entries(provenance.files)) {
|
|
23165
|
-
const absolute =
|
|
23212
|
+
const absolute = join19(rootDirectory, rel);
|
|
23166
23213
|
let bytes;
|
|
23167
23214
|
try {
|
|
23168
23215
|
bytes = await readFile12(absolute);
|
|
@@ -23264,35 +23311,52 @@ import { readFile as readFile13 } from "node:fs/promises";
|
|
|
23264
23311
|
function isRecord5(value) {
|
|
23265
23312
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23266
23313
|
}
|
|
23267
|
-
async function
|
|
23314
|
+
async function readLedgerSessionJsonlLines(path) {
|
|
23268
23315
|
const text = await readFile13(path, "utf8");
|
|
23269
23316
|
const lines = text.split("\n");
|
|
23270
|
-
const
|
|
23317
|
+
const out = [];
|
|
23271
23318
|
for (let index = 0; index < lines.length; index += 1) {
|
|
23272
|
-
const
|
|
23273
|
-
if (!
|
|
23319
|
+
const raw = lines[index];
|
|
23320
|
+
if (!raw.trim()) continue;
|
|
23321
|
+
const lineNumber = index + 1;
|
|
23274
23322
|
let row;
|
|
23275
23323
|
try {
|
|
23276
|
-
row = JSON.parse(
|
|
23324
|
+
row = JSON.parse(raw);
|
|
23277
23325
|
} catch (error) {
|
|
23278
23326
|
if (!(error instanceof SyntaxError)) throw error;
|
|
23279
23327
|
const completedByTerminator = index < lines.length - 1;
|
|
23280
|
-
if (completedByTerminator)
|
|
23281
|
-
|
|
23282
|
-
|
|
23283
|
-
|
|
23284
|
-
|
|
23285
|
-
}
|
|
23286
|
-
|
|
23328
|
+
if (!completedByTerminator) break;
|
|
23329
|
+
out.push({
|
|
23330
|
+
line: lineNumber,
|
|
23331
|
+
raw,
|
|
23332
|
+
error: `malformed JSONL record in ${path} at line ${lineNumber}: ${error.message}`
|
|
23333
|
+
});
|
|
23334
|
+
continue;
|
|
23287
23335
|
}
|
|
23288
23336
|
if (!isRecord5(row)) {
|
|
23289
23337
|
const kind = row === null ? "null" : Array.isArray(row) ? "array" : typeof row;
|
|
23290
|
-
|
|
23291
|
-
|
|
23292
|
-
|
|
23293
|
-
|
|
23338
|
+
out.push({
|
|
23339
|
+
line: lineNumber,
|
|
23340
|
+
raw,
|
|
23341
|
+
error: `complete non-object JSONL record in ${path} at line ${lineNumber}: expected object, got ${kind}`
|
|
23342
|
+
});
|
|
23343
|
+
continue;
|
|
23294
23344
|
}
|
|
23295
|
-
|
|
23345
|
+
out.push({ line: lineNumber, raw, row });
|
|
23346
|
+
}
|
|
23347
|
+
return out;
|
|
23348
|
+
}
|
|
23349
|
+
async function readLedgerSessionJsonl(path) {
|
|
23350
|
+
const rows = [];
|
|
23351
|
+
for (const line2 of await readLedgerSessionJsonlLines(path)) {
|
|
23352
|
+
if (line2.row === void 0) {
|
|
23353
|
+
throw new LedgerSessionJsonlError(line2.error ?? `unreadable JSONL record in ${path} at line ${line2.line}`, {
|
|
23354
|
+
path,
|
|
23355
|
+
line: line2.line,
|
|
23356
|
+
prefixRows: rows
|
|
23357
|
+
});
|
|
23358
|
+
}
|
|
23359
|
+
rows.push(line2.row);
|
|
23296
23360
|
}
|
|
23297
23361
|
return rows;
|
|
23298
23362
|
}
|
|
@@ -23440,7 +23504,7 @@ var init_ledger_session_read = __esm({
|
|
|
23440
23504
|
|
|
23441
23505
|
// src/analyst-gate-cycles-read.ts
|
|
23442
23506
|
import { readdir as readdir5 } from "node:fs/promises";
|
|
23443
|
-
import { join as
|
|
23507
|
+
import { join as join20 } from "node:path";
|
|
23444
23508
|
function isRecord6(value) {
|
|
23445
23509
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23446
23510
|
}
|
|
@@ -23690,7 +23754,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
|
|
|
23690
23754
|
throw error;
|
|
23691
23755
|
}
|
|
23692
23756
|
for (const name of names) {
|
|
23693
|
-
const path =
|
|
23757
|
+
const path = join20(directory, name);
|
|
23694
23758
|
const fromPointer = name.endsWith(".pointer.json");
|
|
23695
23759
|
const sessionPath = fromPointer ? await resolveOfficerSessionFromPointerFile(path) : path;
|
|
23696
23760
|
if (sessionPath === void 0) continue;
|
|
@@ -23742,7 +23806,7 @@ var init_audit_escalation = __esm({
|
|
|
23742
23806
|
|
|
23743
23807
|
// src/run-terminal-artifacts.ts
|
|
23744
23808
|
import { readdir as readdir6, readFile as readFile14 } from "node:fs/promises";
|
|
23745
|
-
import { basename as basename7, dirname as
|
|
23809
|
+
import { basename as basename7, dirname as dirname11, join as join21 } from "node:path";
|
|
23746
23810
|
function isMissingPathError3(error) {
|
|
23747
23811
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
23748
23812
|
}
|
|
@@ -23817,7 +23881,7 @@ async function listUniqueErrorFallbackPaths(directories) {
|
|
|
23817
23881
|
}
|
|
23818
23882
|
for (const name of names.sort((a, b) => a.localeCompare(b))) {
|
|
23819
23883
|
if (!UNIQUE_ERROR_FALLBACK_NAME.test(name)) continue;
|
|
23820
|
-
found.push(
|
|
23884
|
+
found.push(join21(dir, name));
|
|
23821
23885
|
}
|
|
23822
23886
|
}
|
|
23823
23887
|
return found;
|
|
@@ -23835,12 +23899,12 @@ function presentUniqueFallbackBoundToRun(body, expectedRunId) {
|
|
|
23835
23899
|
async function readRunTerminalArtifact(runDirectory) {
|
|
23836
23900
|
const artifactsDir = roleRunArtifactsDirectory(runDirectory);
|
|
23837
23901
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
23838
|
-
const path =
|
|
23902
|
+
const path = join21(artifactsDir, file);
|
|
23839
23903
|
const read = await readTerminalArtifactAtPath(path, file);
|
|
23840
23904
|
if (read !== void 0) return read;
|
|
23841
23905
|
}
|
|
23842
23906
|
for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
23843
|
-
const path =
|
|
23907
|
+
const path = join21(runDirectory, relative3);
|
|
23844
23908
|
const read = await readTerminalArtifactAtPath(path, "error.json");
|
|
23845
23909
|
if (read !== void 0) return read;
|
|
23846
23910
|
}
|
|
@@ -23849,7 +23913,7 @@ async function readRunTerminalArtifact(runDirectory) {
|
|
|
23849
23913
|
if (read !== void 0) return read;
|
|
23850
23914
|
}
|
|
23851
23915
|
const expectedRunId = runIdFromRunDirectory(runDirectory);
|
|
23852
|
-
for (const path of await listUniqueErrorFallbackPaths([
|
|
23916
|
+
for (const path of await listUniqueErrorFallbackPaths([dirname11(runDirectory)])) {
|
|
23853
23917
|
const read = await readTerminalArtifactAtPath(path, "error.json");
|
|
23854
23918
|
if (read === void 0) continue;
|
|
23855
23919
|
if (read.status === "present") {
|
|
@@ -23878,14 +23942,14 @@ var init_run_terminal_artifacts = __esm({
|
|
|
23878
23942
|
});
|
|
23879
23943
|
|
|
23880
23944
|
// src/submission-ledger.ts
|
|
23881
|
-
import { join as
|
|
23945
|
+
import { join as join22 } from "node:path";
|
|
23882
23946
|
async function submissionRecordFile(cwd, runId, scope) {
|
|
23883
23947
|
const ledgerHome = resolveActivationLedgerHome(scope.home);
|
|
23884
23948
|
let sessionParent = scope.sessionParent;
|
|
23885
23949
|
if (sessionParent === void 0) {
|
|
23886
23950
|
const discoveredRun = await findRunDirectoryById(scope.home, runId);
|
|
23887
23951
|
if (discoveredRun === void 0) return void 0;
|
|
23888
|
-
sessionParent =
|
|
23952
|
+
sessionParent = join22(discoveredRun, "session", "session.jsonl");
|
|
23889
23953
|
}
|
|
23890
23954
|
return resolveSitianRecordPathInLedger({
|
|
23891
23955
|
level: "event",
|
|
@@ -24073,15 +24137,15 @@ var init_submission_ledger = __esm({
|
|
|
24073
24137
|
// src/session-opening-materials.ts
|
|
24074
24138
|
import { existsSync as existsSync9 } from "node:fs";
|
|
24075
24139
|
import { readFile as readFile15 } from "node:fs/promises";
|
|
24076
|
-
import { dirname as
|
|
24140
|
+
import { dirname as dirname12, join as join23 } from "node:path";
|
|
24077
24141
|
import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
24078
24142
|
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
24079
|
-
let dir =
|
|
24143
|
+
let dir = dirname12(fileURLToPath(moduleUrl));
|
|
24080
24144
|
for (let i = 0; i < 8; i += 1) {
|
|
24081
|
-
if (existsSync9(
|
|
24145
|
+
if (existsSync9(join23(dir, "package.json")) && existsSync9(join23(dir, "souls"))) {
|
|
24082
24146
|
return dir;
|
|
24083
24147
|
}
|
|
24084
|
-
const parent =
|
|
24148
|
+
const parent = dirname12(dir);
|
|
24085
24149
|
if (parent === dir) break;
|
|
24086
24150
|
dir = parent;
|
|
24087
24151
|
}
|
|
@@ -24331,12 +24395,12 @@ var init_reviewer_dispatch = __esm({
|
|
|
24331
24395
|
|
|
24332
24396
|
// src/public-cli/reviewer-dispatch-rejection.ts
|
|
24333
24397
|
import { readFile as readFile16, unlink as unlink3 } from "node:fs/promises";
|
|
24334
|
-
import { join as
|
|
24398
|
+
import { join as join24 } from "node:path";
|
|
24335
24399
|
function isReviewerPreflightViolation(value) {
|
|
24336
24400
|
return typeof value === "string" && REVIEWER_PREFLIGHT_VIOLATIONS.includes(value);
|
|
24337
24401
|
}
|
|
24338
24402
|
function reviewerDispatchRejectionPath(runDirectory) {
|
|
24339
|
-
return
|
|
24403
|
+
return join24(runDirectory, REVIEWER_DISPATCH_REJECTION_FILE);
|
|
24340
24404
|
}
|
|
24341
24405
|
async function clearReviewerDispatchRejection(runDirectory) {
|
|
24342
24406
|
try {
|
|
@@ -24707,16 +24771,16 @@ var init_terminal = __esm({
|
|
|
24707
24771
|
});
|
|
24708
24772
|
|
|
24709
24773
|
// src/public-cli/settlement.ts
|
|
24710
|
-
import { randomUUID as
|
|
24711
|
-
import { appendFile as appendFile2, readFile as readFile17, readdir as readdir7, writeFile as
|
|
24712
|
-
import { dirname as
|
|
24774
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
24775
|
+
import { appendFile as appendFile2, readFile as readFile17, readdir as readdir7, writeFile as writeFile7 } from "node:fs/promises";
|
|
24776
|
+
import { dirname as dirname13, join as join25 } from "node:path";
|
|
24713
24777
|
function sealedLedgerHome(admitted) {
|
|
24714
24778
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
24715
24779
|
}
|
|
24716
24780
|
function ledgerReadScope(admitted, scope) {
|
|
24717
24781
|
return {
|
|
24718
24782
|
home: sealedLedgerHome(admitted),
|
|
24719
|
-
sessionParent:
|
|
24783
|
+
sessionParent: join25(admitted.runDirectory, "session", "session.jsonl"),
|
|
24720
24784
|
...scope?.courtAttemptId === void 0 || scope.courtAttemptId.length === 0 ? {} : { attemptId: scope.courtAttemptId }
|
|
24721
24785
|
};
|
|
24722
24786
|
}
|
|
@@ -25144,7 +25208,7 @@ async function readSitianRetainedAuditorProviderStop(sessionFile) {
|
|
|
25144
25208
|
kind: "auditor",
|
|
25145
25209
|
sessionParent: sessionFile,
|
|
25146
25210
|
// Path is driven by sessionParent when under ledger home; cwd is a fallback only.
|
|
25147
|
-
cwd:
|
|
25211
|
+
cwd: dirname13(sessionFile)
|
|
25148
25212
|
});
|
|
25149
25213
|
const { records } = await readSitianRecords(recordFile);
|
|
25150
25214
|
for (let i = records.length - 1; i >= 0; i -= 1) {
|
|
@@ -25170,7 +25234,7 @@ async function readSessionProviderStop(sessionFile) {
|
|
|
25170
25234
|
}
|
|
25171
25235
|
}
|
|
25172
25236
|
async function readBoundEvidenceChildKnownFailure(sessionFile) {
|
|
25173
|
-
const childDirectory =
|
|
25237
|
+
const childDirectory = join25(dirname13(sessionFile), "evidence-children");
|
|
25174
25238
|
let names;
|
|
25175
25239
|
try {
|
|
25176
25240
|
names = await readdir7(childDirectory);
|
|
@@ -25181,7 +25245,7 @@ async function readBoundEvidenceChildKnownFailure(sessionFile) {
|
|
|
25181
25245
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
25182
25246
|
let entries;
|
|
25183
25247
|
try {
|
|
25184
|
-
entries = await readBoundSessionEntries(
|
|
25248
|
+
entries = await readBoundSessionEntries(join25(childDirectory, file));
|
|
25185
25249
|
} catch (error) {
|
|
25186
25250
|
throw sessionReadFailure(error, "failed to read discovered evidence-child session");
|
|
25187
25251
|
}
|
|
@@ -25236,7 +25300,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
25236
25300
|
latestParentUserIndex = i;
|
|
25237
25301
|
break;
|
|
25238
25302
|
}
|
|
25239
|
-
const childDirectories = [
|
|
25303
|
+
const childDirectories = [join25(dirname13(sessionFile), "auditor-roles")];
|
|
25240
25304
|
const valid = [];
|
|
25241
25305
|
let sawAnyDirectory = false;
|
|
25242
25306
|
for (const childDirectory of childDirectories) {
|
|
@@ -25251,7 +25315,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
25251
25315
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
25252
25316
|
let entries;
|
|
25253
25317
|
try {
|
|
25254
|
-
entries = await readBoundSessionEntries(
|
|
25318
|
+
entries = await readBoundSessionEntries(join25(childDirectory, file));
|
|
25255
25319
|
} catch (error) {
|
|
25256
25320
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
25257
25321
|
}
|
|
@@ -25650,7 +25714,7 @@ async function appendRunAttemptHistory(source, outcome) {
|
|
|
25650
25714
|
type: "custom",
|
|
25651
25715
|
customType: ATTEMPT_HISTORY_ENTRY_TYPE,
|
|
25652
25716
|
data: attemptData,
|
|
25653
|
-
id:
|
|
25717
|
+
id: randomUUID4(),
|
|
25654
25718
|
parentId,
|
|
25655
25719
|
timestamp: timestamp2
|
|
25656
25720
|
})}
|
|
@@ -25756,8 +25820,8 @@ function projectTerminalGateFact(rounds) {
|
|
|
25756
25820
|
};
|
|
25757
25821
|
}
|
|
25758
25822
|
async function extractGateFactFromSessionDirectory(sessionDirectory, options = {}) {
|
|
25759
|
-
const directories = [
|
|
25760
|
-
const parentSessionFile = options.parentSessionFile ??
|
|
25823
|
+
const directories = [join25(sessionDirectory, "auditor-roles")];
|
|
25824
|
+
const parentSessionFile = options.parentSessionFile ?? join25(sessionDirectory, "session.jsonl");
|
|
25761
25825
|
const rounds = await readAnalystGateCyclesFromAuditorRoles(directories, {
|
|
25762
25826
|
parentSessionFile
|
|
25763
25827
|
});
|
|
@@ -25855,9 +25919,9 @@ async function extractNavigatorFactFromAdmittedSession(sessionFile) {
|
|
|
25855
25919
|
async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
|
|
25856
25920
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
25857
25921
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
25858
|
-
const reportPath =
|
|
25859
|
-
const evidencePath =
|
|
25860
|
-
await
|
|
25922
|
+
const reportPath = join25(artifactsDir, "report.json");
|
|
25923
|
+
const evidencePath = join25(artifactsDir, "evidence.json");
|
|
25924
|
+
await writeFile7(
|
|
25861
25925
|
reportPath,
|
|
25862
25926
|
`${JSON.stringify(
|
|
25863
25927
|
{
|
|
@@ -25871,7 +25935,7 @@ async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
|
|
|
25871
25935
|
`,
|
|
25872
25936
|
"utf8"
|
|
25873
25937
|
);
|
|
25874
|
-
await
|
|
25938
|
+
await writeFile7(
|
|
25875
25939
|
evidencePath,
|
|
25876
25940
|
`${JSON.stringify(
|
|
25877
25941
|
{
|
|
@@ -25900,9 +25964,9 @@ async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
|
|
|
25900
25964
|
async function publishCoderArtifacts(admitted, roleOutcome, coordinates, options = {}) {
|
|
25901
25965
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
25902
25966
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
25903
|
-
const reportPath =
|
|
25904
|
-
const evidencePath =
|
|
25905
|
-
await
|
|
25967
|
+
const reportPath = join25(artifactsDir, "report.json");
|
|
25968
|
+
const evidencePath = join25(artifactsDir, "evidence.json");
|
|
25969
|
+
await writeFile7(
|
|
25906
25970
|
reportPath,
|
|
25907
25971
|
`${JSON.stringify(
|
|
25908
25972
|
{
|
|
@@ -25917,7 +25981,7 @@ async function publishCoderArtifacts(admitted, roleOutcome, coordinates, options
|
|
|
25917
25981
|
`,
|
|
25918
25982
|
"utf8"
|
|
25919
25983
|
);
|
|
25920
|
-
await
|
|
25984
|
+
await writeFile7(
|
|
25921
25985
|
evidencePath,
|
|
25922
25986
|
`${JSON.stringify(
|
|
25923
25987
|
{
|
|
@@ -26038,9 +26102,9 @@ function extractFixerMethodInvocations(entries, options) {
|
|
|
26038
26102
|
async function publishFixerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
26039
26103
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
26040
26104
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
26041
|
-
const reportPath =
|
|
26042
|
-
const evidencePath =
|
|
26043
|
-
await
|
|
26105
|
+
const reportPath = join25(artifactsDir, "report.json");
|
|
26106
|
+
const evidencePath = join25(artifactsDir, "evidence.json");
|
|
26107
|
+
await writeFile7(
|
|
26044
26108
|
reportPath,
|
|
26045
26109
|
`${JSON.stringify(
|
|
26046
26110
|
{
|
|
@@ -26055,7 +26119,7 @@ async function publishFixerArtifacts(admitted, roleOutcome, coordinates, options
|
|
|
26055
26119
|
`,
|
|
26056
26120
|
"utf8"
|
|
26057
26121
|
);
|
|
26058
|
-
await
|
|
26122
|
+
await writeFile7(
|
|
26059
26123
|
evidencePath,
|
|
26060
26124
|
`${JSON.stringify(
|
|
26061
26125
|
{
|
|
@@ -26126,9 +26190,9 @@ async function settleLawfulFixerTerminalResult(admitted, authority, options, sco
|
|
|
26126
26190
|
async function publishCollectorArtifacts(admitted, roleOutcome, coordinates) {
|
|
26127
26191
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
26128
26192
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
26129
|
-
const reportPath =
|
|
26130
|
-
const evidencePath =
|
|
26131
|
-
await
|
|
26193
|
+
const reportPath = join25(artifactsDir, "report.json");
|
|
26194
|
+
const evidencePath = join25(artifactsDir, "evidence.json");
|
|
26195
|
+
await writeFile7(
|
|
26132
26196
|
reportPath,
|
|
26133
26197
|
`${JSON.stringify(
|
|
26134
26198
|
{
|
|
@@ -26142,7 +26206,7 @@ async function publishCollectorArtifacts(admitted, roleOutcome, coordinates) {
|
|
|
26142
26206
|
`,
|
|
26143
26207
|
"utf8"
|
|
26144
26208
|
);
|
|
26145
|
-
await
|
|
26209
|
+
await writeFile7(
|
|
26146
26210
|
evidencePath,
|
|
26147
26211
|
`${JSON.stringify(
|
|
26148
26212
|
{
|
|
@@ -26244,9 +26308,9 @@ function extractDoctorCandidateAuditNoReceiptFact(entries) {
|
|
|
26244
26308
|
async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
|
|
26245
26309
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
26246
26310
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
26247
|
-
const reportPath =
|
|
26248
|
-
const evidencePath =
|
|
26249
|
-
await
|
|
26311
|
+
const reportPath = join25(artifactsDir, "report.json");
|
|
26312
|
+
const evidencePath = join25(artifactsDir, "evidence.json");
|
|
26313
|
+
await writeFile7(
|
|
26250
26314
|
reportPath,
|
|
26251
26315
|
`${JSON.stringify(
|
|
26252
26316
|
{
|
|
@@ -26262,7 +26326,7 @@ async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, option
|
|
|
26262
26326
|
`,
|
|
26263
26327
|
"utf8"
|
|
26264
26328
|
);
|
|
26265
|
-
await
|
|
26329
|
+
await writeFile7(
|
|
26266
26330
|
evidencePath,
|
|
26267
26331
|
`${JSON.stringify(
|
|
26268
26332
|
{
|
|
@@ -26500,9 +26564,9 @@ function extractReviewerMethodInvocations(entries, options) {
|
|
|
26500
26564
|
async function publishReviewerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
26501
26565
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
26502
26566
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
26503
|
-
const reportPath =
|
|
26504
|
-
const evidencePath =
|
|
26505
|
-
await
|
|
26567
|
+
const reportPath = join25(artifactsDir, "report.json");
|
|
26568
|
+
const evidencePath = join25(artifactsDir, "evidence.json");
|
|
26569
|
+
await writeFile7(
|
|
26506
26570
|
reportPath,
|
|
26507
26571
|
`${JSON.stringify(
|
|
26508
26572
|
{
|
|
@@ -26516,7 +26580,7 @@ async function publishReviewerArtifacts(admitted, roleOutcome, coordinates, opti
|
|
|
26516
26580
|
`,
|
|
26517
26581
|
"utf8"
|
|
26518
26582
|
);
|
|
26519
|
-
await
|
|
26583
|
+
await writeFile7(
|
|
26520
26584
|
evidencePath,
|
|
26521
26585
|
`${JSON.stringify(
|
|
26522
26586
|
{
|
|
@@ -26605,9 +26669,9 @@ function extractMergerMethodInvocations(entries, options) {
|
|
|
26605
26669
|
async function publishMergerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
26606
26670
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
26607
26671
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
26608
|
-
const reportPath =
|
|
26609
|
-
const evidencePath =
|
|
26610
|
-
await
|
|
26672
|
+
const reportPath = join25(artifactsDir, "report.json");
|
|
26673
|
+
const evidencePath = join25(artifactsDir, "evidence.json");
|
|
26674
|
+
await writeFile7(
|
|
26611
26675
|
reportPath,
|
|
26612
26676
|
`${JSON.stringify(
|
|
26613
26677
|
{
|
|
@@ -26621,7 +26685,7 @@ async function publishMergerArtifacts(admitted, roleOutcome, coordinates, option
|
|
|
26621
26685
|
`,
|
|
26622
26686
|
"utf8"
|
|
26623
26687
|
);
|
|
26624
|
-
await
|
|
26688
|
+
await writeFile7(
|
|
26625
26689
|
evidencePath,
|
|
26626
26690
|
`${JSON.stringify(
|
|
26627
26691
|
{
|
|
@@ -26725,7 +26789,7 @@ function publicationAttemptFromError(path, error) {
|
|
|
26725
26789
|
}
|
|
26726
26790
|
function uniqueFailureFallbackDirs(runDirectory, baseDir) {
|
|
26727
26791
|
const dirs = [];
|
|
26728
|
-
for (const dir of [baseDir, runDirectory,
|
|
26792
|
+
for (const dir of [baseDir, runDirectory, dirname13(runDirectory)]) {
|
|
26729
26793
|
if (!dirs.includes(dir)) dirs.push(dir);
|
|
26730
26794
|
}
|
|
26731
26795
|
return dirs;
|
|
@@ -26747,13 +26811,13 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
|
|
|
26747
26811
|
const candidates = [
|
|
26748
26812
|
...preferredCandidates,
|
|
26749
26813
|
// One unique name per fallback dir — collisions on fixed names cannot exhaust this.
|
|
26750
|
-
...uniqueFallbackDirs.map((dir) =>
|
|
26814
|
+
...uniqueFallbackDirs.map((dir) => join25(dir, `${stem}.${randomUUID4()}.json`))
|
|
26751
26815
|
];
|
|
26752
26816
|
for (let i = 0; i < candidates.length; i += 1) {
|
|
26753
26817
|
const path = candidates[i];
|
|
26754
26818
|
const payload = issues.length === 0 ? basePayload : { ...basePayload, publicationIssues: issues };
|
|
26755
26819
|
try {
|
|
26756
|
-
await
|
|
26820
|
+
await writeFile7(
|
|
26757
26821
|
path,
|
|
26758
26822
|
`${JSON.stringify(payload, null, 2)}
|
|
26759
26823
|
`,
|
|
@@ -26798,20 +26862,20 @@ async function publishFailureArtifacts(admitted, failure, authority) {
|
|
|
26798
26862
|
baseDir
|
|
26799
26863
|
);
|
|
26800
26864
|
const errorCandidates = underArtifacts ? [
|
|
26801
|
-
|
|
26802
|
-
|
|
26803
|
-
|
|
26865
|
+
join25(baseDir, "error.json"),
|
|
26866
|
+
join25(baseDir, "error.settlement.json"),
|
|
26867
|
+
join25(admitted.runDirectory, "error.settlement.json")
|
|
26804
26868
|
] : [
|
|
26805
|
-
|
|
26806
|
-
|
|
26869
|
+
join25(baseDir, "error.settlement.json"),
|
|
26870
|
+
join25(baseDir, "error.json")
|
|
26807
26871
|
];
|
|
26808
26872
|
const evidenceCandidates = underArtifacts ? [
|
|
26809
|
-
|
|
26810
|
-
|
|
26811
|
-
|
|
26873
|
+
join25(baseDir, "evidence.json"),
|
|
26874
|
+
join25(baseDir, "evidence.settlement.json"),
|
|
26875
|
+
join25(admitted.runDirectory, "evidence.settlement.json")
|
|
26812
26876
|
] : [
|
|
26813
|
-
|
|
26814
|
-
|
|
26877
|
+
join25(baseDir, "evidence.settlement.json"),
|
|
26878
|
+
join25(baseDir, "evidence.json")
|
|
26815
26879
|
];
|
|
26816
26880
|
const errorPayloadBase = {
|
|
26817
26881
|
kind: "error",
|
|
@@ -27062,10 +27126,10 @@ var init_turn_request = __esm({
|
|
|
27062
27126
|
});
|
|
27063
27127
|
|
|
27064
27128
|
// src/session-identity.ts
|
|
27065
|
-
import { mkdir as mkdir3, readFile as readFile18, rename as
|
|
27066
|
-
import { dirname as
|
|
27129
|
+
import { mkdir as mkdir3, readFile as readFile18, rename as rename3, writeFile as writeFile8 } from "node:fs/promises";
|
|
27130
|
+
import { dirname as dirname14, join as join26 } from "node:path";
|
|
27067
27131
|
function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
27068
|
-
const bindingPath = (principal) =>
|
|
27132
|
+
const bindingPath = (principal) => join26(authority.decode(principal).sessionDirectory, sessionBindingFile);
|
|
27069
27133
|
return {
|
|
27070
27134
|
resolveSessionFile(principal) {
|
|
27071
27135
|
return authority.decode(principal).sessionFile;
|
|
@@ -27084,11 +27148,11 @@ function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
|
27084
27148
|
},
|
|
27085
27149
|
async bind(principal, sessionId) {
|
|
27086
27150
|
const target = bindingPath(principal);
|
|
27087
|
-
await mkdir3(
|
|
27151
|
+
await mkdir3(dirname14(target), { recursive: true });
|
|
27088
27152
|
const temporary = `${target}.${process.pid}.tmp`;
|
|
27089
|
-
await
|
|
27153
|
+
await writeFile8(temporary, `${JSON.stringify({ sessionId })}
|
|
27090
27154
|
`, { encoding: "utf8", mode: 384 });
|
|
27091
|
-
await
|
|
27155
|
+
await rename3(temporary, target);
|
|
27092
27156
|
}
|
|
27093
27157
|
};
|
|
27094
27158
|
}
|
|
@@ -27110,49 +27174,49 @@ var init_session_identity = __esm({
|
|
|
27110
27174
|
}
|
|
27111
27175
|
});
|
|
27112
27176
|
|
|
27113
|
-
// src/
|
|
27114
|
-
var
|
|
27115
|
-
|
|
27116
|
-
"src/ticket-provenance-contracts.ts"() {
|
|
27177
|
+
// src/session-dialogue.ts
|
|
27178
|
+
var init_session_dialogue = __esm({
|
|
27179
|
+
"src/session-dialogue.ts"() {
|
|
27117
27180
|
"use strict";
|
|
27118
|
-
TICKET_PROVENANCE_KIND = "ticket-provenance";
|
|
27119
|
-
TICKET_PROVENANCE_HUMAN_VIEW = "\u8D77\u5C45\u5F55.md";
|
|
27120
27181
|
}
|
|
27121
27182
|
});
|
|
27122
27183
|
|
|
27123
27184
|
// src/ticket-provenance.ts
|
|
27124
|
-
import { join as join26 } from "node:path";
|
|
27125
27185
|
function ticketProvenanceSubject(ticketNumber) {
|
|
27126
27186
|
if (!isSafePositiveTicketNumber(ticketNumber)) {
|
|
27127
|
-
throw new Error(
|
|
27187
|
+
throw new Error(
|
|
27188
|
+
`ticket-provenance subject requires a positive ticket number, got ${String(ticketNumber)}`
|
|
27189
|
+
);
|
|
27128
27190
|
}
|
|
27129
27191
|
return String(ticketNumber);
|
|
27130
27192
|
}
|
|
27131
|
-
function
|
|
27132
|
-
|
|
27193
|
+
function ticketProvenanceRecordInput(ticketNumber, cwd, home) {
|
|
27194
|
+
return {
|
|
27133
27195
|
level: "event",
|
|
27134
27196
|
kind: TICKET_PROVENANCE_KIND,
|
|
27135
27197
|
subject: ticketProvenanceSubject(ticketNumber),
|
|
27136
27198
|
cwd,
|
|
27137
27199
|
...home === void 0 ? {} : { home }
|
|
27138
|
-
});
|
|
27139
|
-
return {
|
|
27140
|
-
recordFile: path.recordFile,
|
|
27141
|
-
volumeDir: path.sessionDir,
|
|
27142
|
-
humanViewFile: join26(path.sessionDir, TICKET_PROVENANCE_HUMAN_VIEW)
|
|
27143
27200
|
};
|
|
27144
27201
|
}
|
|
27202
|
+
function resolveTicketProvenanceVolume(ticketNumber, cwd, home) {
|
|
27203
|
+
return resolveSitianVolume(ticketProvenanceRecordInput(ticketNumber, cwd, home));
|
|
27204
|
+
}
|
|
27145
27205
|
var init_ticket_provenance = __esm({
|
|
27146
27206
|
"src/ticket-provenance.ts"() {
|
|
27147
27207
|
"use strict";
|
|
27148
|
-
|
|
27208
|
+
init_activation_ledger_git();
|
|
27209
|
+
init_activation_ledger_topology();
|
|
27210
|
+
init_ledger_session_read();
|
|
27149
27211
|
init_run_ticket_number();
|
|
27212
|
+
init_session_dialogue();
|
|
27213
|
+
init_sitian_facade();
|
|
27150
27214
|
init_ticket_provenance_contracts();
|
|
27151
27215
|
}
|
|
27152
27216
|
});
|
|
27153
27217
|
|
|
27154
27218
|
// src/public-cli/case-dossier-delivery.ts
|
|
27155
|
-
import { mkdtemp, readFile as readFile19, rm, writeFile as
|
|
27219
|
+
import { mkdtemp, readFile as readFile19, rm as rm2, writeFile as writeFile9 } from "node:fs/promises";
|
|
27156
27220
|
import { tmpdir } from "node:os";
|
|
27157
27221
|
import { join as join27 } from "node:path";
|
|
27158
27222
|
function describeDossierFile(path) {
|
|
@@ -27169,7 +27233,6 @@ async function projectCaseDossierPointerSection(input) {
|
|
|
27169
27233
|
CASE_DOSSIER_SECTION_HEADING,
|
|
27170
27234
|
"",
|
|
27171
27235
|
`\u7968\u53F7\uFF1A#${input.ticketNumber}`,
|
|
27172
|
-
`\u4EBA\u8BFB\u89C6\u56FE\uFF1A${describeDossierFile(volume.humanViewFile)}`,
|
|
27173
27236
|
`\u8BB0\u5F55\u5377\u5B97\uFF1A${describeDossierFile(volume.recordFile)}`
|
|
27174
27237
|
].join("\n");
|
|
27175
27238
|
}
|
|
@@ -27183,7 +27246,7 @@ async function deliverCaseDossierAsAttachment(input) {
|
|
|
27183
27246
|
const stagingDir = await mkdtemp(join27(tmpdir(), "ak-case-dossier-"));
|
|
27184
27247
|
try {
|
|
27185
27248
|
const stagingPath = join27(stagingDir, CASE_DOSSIER_ATTACH_FILE);
|
|
27186
|
-
await
|
|
27249
|
+
await writeFile9(stagingPath, `${section}
|
|
27187
27250
|
`, "utf8");
|
|
27188
27251
|
return await freezeAttachmentsIntoRun(
|
|
27189
27252
|
[stagingPath],
|
|
@@ -27191,7 +27254,7 @@ async function deliverCaseDossierAsAttachment(input) {
|
|
|
27191
27254
|
CASE_DOSSIER_ATTACH_KEY
|
|
27192
27255
|
);
|
|
27193
27256
|
} finally {
|
|
27194
|
-
await
|
|
27257
|
+
await rm2(stagingDir, { recursive: true, force: true });
|
|
27195
27258
|
}
|
|
27196
27259
|
}
|
|
27197
27260
|
var CASE_DOSSIER_SECTION_HEADING, CASE_DOSSIER_ATTACH_KEY, CASE_DOSSIER_ATTACH_FILE;
|
|
@@ -27208,7 +27271,7 @@ var init_case_dossier_delivery = __esm({
|
|
|
27208
27271
|
|
|
27209
27272
|
// src/host-transition-prior-native.ts
|
|
27210
27273
|
import { access as access3, readdir as readdir8 } from "node:fs/promises";
|
|
27211
|
-
import { dirname as
|
|
27274
|
+
import { dirname as dirname15, join as join28 } from "node:path";
|
|
27212
27275
|
function isEnoent3(error) {
|
|
27213
27276
|
return typeof error === "object" && error !== null && error.code === "ENOENT";
|
|
27214
27277
|
}
|
|
@@ -27222,7 +27285,7 @@ async function listPiNativeRecordPaths(sessionFile) {
|
|
|
27222
27285
|
}
|
|
27223
27286
|
}
|
|
27224
27287
|
async function listSitianRecordPaths(sessionParent) {
|
|
27225
|
-
const sessionRoot =
|
|
27288
|
+
const sessionRoot = dirname15(sessionParent);
|
|
27226
27289
|
let entries;
|
|
27227
27290
|
try {
|
|
27228
27291
|
entries = await readdir8(sessionRoot, { withFileTypes: true });
|
|
@@ -27301,7 +27364,7 @@ var init_public_run_credentials = __esm({
|
|
|
27301
27364
|
|
|
27302
27365
|
// src/public-cli/auto-resume.ts
|
|
27303
27366
|
import { constants as fsConstants2 } from "node:fs";
|
|
27304
|
-
import { randomUUID as
|
|
27367
|
+
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
27305
27368
|
import { lstat as lstat6, mkdir as mkdir4, open as open2 } from "node:fs/promises";
|
|
27306
27369
|
import { join as join29 } from "node:path";
|
|
27307
27370
|
async function persistReturnedRunState(admitted, authority, options) {
|
|
@@ -27418,7 +27481,7 @@ function jsonSafeReplacer() {
|
|
|
27418
27481
|
};
|
|
27419
27482
|
}
|
|
27420
27483
|
async function writeHardenedArtifactFile(artifactsDir, namePrefix, payload) {
|
|
27421
|
-
const filePath = join29(artifactsDir, `${namePrefix}-${
|
|
27484
|
+
const filePath = join29(artifactsDir, `${namePrefix}-${randomUUID5()}.json`);
|
|
27422
27485
|
const body = `${JSON.stringify(payload, jsonSafeReplacer(), 2)}
|
|
27423
27486
|
`;
|
|
27424
27487
|
const noFollowFlag = typeof fsConstants2.O_NOFOLLOW === "number" ? fsConstants2.O_NOFOLLOW : 0;
|
|
@@ -27689,8 +27752,8 @@ var init_auto_resume = __esm({
|
|
|
27689
27752
|
});
|
|
27690
27753
|
|
|
27691
27754
|
// src/public-cli/post-admission.ts
|
|
27692
|
-
import { randomUUID as
|
|
27693
|
-
import { readFile as readFile20, writeFile as
|
|
27755
|
+
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
27756
|
+
import { readFile as readFile20, writeFile as writeFile10 } from "node:fs/promises";
|
|
27694
27757
|
import { isAbsolute as isAbsolute8, join as join30, resolve as resolve8 } from "node:path";
|
|
27695
27758
|
function describeCaughtError(error) {
|
|
27696
27759
|
if (error instanceof Error) {
|
|
@@ -27735,8 +27798,8 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
27735
27798
|
} catch (appendError) {
|
|
27736
27799
|
try {
|
|
27737
27800
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
27738
|
-
await
|
|
27739
|
-
join30(artifactsDir, `post-admission-diagnostic-${
|
|
27801
|
+
await writeFile10(
|
|
27802
|
+
join30(artifactsDir, `post-admission-diagnostic-${randomUUID6()}.json`),
|
|
27740
27803
|
`${JSON.stringify({ version: 1, ...payload }, null, 2)}
|
|
27741
27804
|
`,
|
|
27742
27805
|
{ encoding: "utf8", flag: "wx" }
|
|
@@ -28038,7 +28101,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28038
28101
|
}
|
|
28039
28102
|
let stderrLogWriteFailure;
|
|
28040
28103
|
try {
|
|
28041
|
-
await
|
|
28104
|
+
await writeFile10(
|
|
28042
28105
|
join30(admitted.runDirectory, "stderr.log"),
|
|
28043
28106
|
result2.stderr,
|
|
28044
28107
|
"utf8"
|
|
@@ -28268,7 +28331,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
28268
28331
|
kind: "resume",
|
|
28269
28332
|
prompt
|
|
28270
28333
|
},
|
|
28271
|
-
...request.message === void 0 ? {} : { courtAttemptId:
|
|
28334
|
+
...request.message === void 0 ? {} : { courtAttemptId: randomUUID6() },
|
|
28272
28335
|
...env.stationChild === void 0 ? {} : { stationChild: env.stationChild }
|
|
28273
28336
|
};
|
|
28274
28337
|
}
|
|
@@ -28365,7 +28428,7 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
28365
28428
|
}
|
|
28366
28429
|
let turnRequest = await input.buildTurnRequest(admittedForBuild, request);
|
|
28367
28430
|
if (openCourtAttemptId !== void 0 || request.summons !== void 0 || request.message !== void 0) {
|
|
28368
|
-
const courtAttemptId = openCourtAttemptId ?? (turnRequest.courtAttemptId !== void 0 && turnRequest.courtAttemptId.length > 0 ? turnRequest.courtAttemptId :
|
|
28431
|
+
const courtAttemptId = openCourtAttemptId ?? (turnRequest.courtAttemptId !== void 0 && turnRequest.courtAttemptId.length > 0 ? turnRequest.courtAttemptId : randomUUID6());
|
|
28369
28432
|
turnRequest = { ...turnRequest, courtAttemptId };
|
|
28370
28433
|
if (openCourtAttemptId === void 0) {
|
|
28371
28434
|
const court = {
|
|
@@ -31261,30 +31324,9 @@ var init_analyst_book_key = __esm({
|
|
|
31261
31324
|
}
|
|
31262
31325
|
});
|
|
31263
31326
|
|
|
31264
|
-
// src/atomic-write.ts
|
|
31265
|
-
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
31266
|
-
import { rename as rename3, rm as rm2, writeFile as writeFile10 } from "node:fs/promises";
|
|
31267
|
-
import { dirname as dirname15, join as join32 } from "node:path";
|
|
31268
|
-
async function writeFileAtomically(destination, contents) {
|
|
31269
|
-
const parent = dirname15(destination);
|
|
31270
|
-
const temporary = join32(parent, `.atomic-write-${randomUUID6()}.tmp`);
|
|
31271
|
-
try {
|
|
31272
|
-
await writeFile10(temporary, contents);
|
|
31273
|
-
await rename3(temporary, destination);
|
|
31274
|
-
} catch (error) {
|
|
31275
|
-
await rm2(temporary, { force: true }).catch(() => void 0);
|
|
31276
|
-
throw error;
|
|
31277
|
-
}
|
|
31278
|
-
}
|
|
31279
|
-
var init_atomic_write = __esm({
|
|
31280
|
-
"src/atomic-write.ts"() {
|
|
31281
|
-
"use strict";
|
|
31282
|
-
}
|
|
31283
|
-
});
|
|
31284
|
-
|
|
31285
31327
|
// src/analyst-index.ts
|
|
31286
31328
|
import { open as open3, readFile as readFile21, unlink as unlink4 } from "node:fs/promises";
|
|
31287
|
-
import { dirname as dirname16, join as
|
|
31329
|
+
import { dirname as dirname16, join as join32 } from "node:path";
|
|
31288
31330
|
function sleep(ms) {
|
|
31289
31331
|
return new Promise((resolve10) => {
|
|
31290
31332
|
setTimeout(resolve10, ms);
|
|
@@ -31293,7 +31335,7 @@ function sleep(ms) {
|
|
|
31293
31335
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
31294
31336
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
31295
31337
|
ensureRealDirectoryTree(ledgerHome, dirname16(indexPath));
|
|
31296
|
-
const lockPath =
|
|
31338
|
+
const lockPath = join32(dirname16(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
31297
31339
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
31298
31340
|
const startedAt = Date.now();
|
|
31299
31341
|
while (true) {
|
|
@@ -31320,7 +31362,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
31320
31362
|
}
|
|
31321
31363
|
}
|
|
31322
31364
|
function analystLibraryIndexPath(ledgerHome) {
|
|
31323
|
-
return
|
|
31365
|
+
return join32(ledgerHome, "analyst", "library-index.json");
|
|
31324
31366
|
}
|
|
31325
31367
|
function rowFromIssueMetricsPage(page) {
|
|
31326
31368
|
return {
|
|
@@ -31616,7 +31658,7 @@ var init_analyst_cohort = __esm({
|
|
|
31616
31658
|
|
|
31617
31659
|
// src/analyst-ledger.ts
|
|
31618
31660
|
import { readdir as readdir9, readFile as readFile22 } from "node:fs/promises";
|
|
31619
|
-
import { basename as basename8, join as
|
|
31661
|
+
import { basename as basename8, join as join33 } from "node:path";
|
|
31620
31662
|
function isMissingPathError6(error) {
|
|
31621
31663
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
31622
31664
|
}
|
|
@@ -31629,7 +31671,7 @@ function isRecord10(value) {
|
|
|
31629
31671
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
31630
31672
|
try {
|
|
31631
31673
|
const raw = JSON.parse(
|
|
31632
|
-
await readFile22(
|
|
31674
|
+
await readFile22(join33(runDirectory, "run-state.json"), "utf8")
|
|
31633
31675
|
);
|
|
31634
31676
|
if (!isRecord10(raw) || typeof raw.state !== "string") return void 0;
|
|
31635
31677
|
return raw.state;
|
|
@@ -31661,7 +31703,7 @@ async function listLedgerBookNames(booksRoot) {
|
|
|
31661
31703
|
async function readInvocationScopeFields(runDirectory) {
|
|
31662
31704
|
let raw;
|
|
31663
31705
|
try {
|
|
31664
|
-
raw = await readFile22(
|
|
31706
|
+
raw = await readFile22(join33(runDirectory, "invocation.json"), "utf8");
|
|
31665
31707
|
} catch (error) {
|
|
31666
31708
|
if (isMissingPathError6(error)) return void 0;
|
|
31667
31709
|
throw error;
|
|
@@ -31694,7 +31736,7 @@ function decideIssueScope(input) {
|
|
|
31694
31736
|
}
|
|
31695
31737
|
async function resolveSessionFile(runDirectory) {
|
|
31696
31738
|
try {
|
|
31697
|
-
const raw = await readFile22(
|
|
31739
|
+
const raw = await readFile22(join33(runDirectory, "invocation.json"), "utf8");
|
|
31698
31740
|
const parsed = JSON.parse(raw);
|
|
31699
31741
|
if (isRecord10(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
31700
31742
|
return parsed.sessionFile;
|
|
@@ -31702,7 +31744,7 @@ async function resolveSessionFile(runDirectory) {
|
|
|
31702
31744
|
} catch (error) {
|
|
31703
31745
|
if (!isMissingPathError6(error)) throw error;
|
|
31704
31746
|
}
|
|
31705
|
-
return
|
|
31747
|
+
return join33(runDirectory, "session", "session.jsonl");
|
|
31706
31748
|
}
|
|
31707
31749
|
function attributeSessionRowsForRun(input) {
|
|
31708
31750
|
if (pathContainedIn(input.runDirectory, input.sessionFile)) {
|
|
@@ -31874,9 +31916,9 @@ async function classifyScopedRun(input) {
|
|
|
31874
31916
|
}
|
|
31875
31917
|
let gateCycles;
|
|
31876
31918
|
try {
|
|
31877
|
-
const parentSessionFile =
|
|
31919
|
+
const parentSessionFile = join33(input.runDirectory, "session", "session.jsonl");
|
|
31878
31920
|
gateCycles = await readAnalystGateCyclesFromAuditorRoles(
|
|
31879
|
-
|
|
31921
|
+
join33(input.runDirectory, "session", "auditor-roles"),
|
|
31880
31922
|
{ parentSessionFile }
|
|
31881
31923
|
);
|
|
31882
31924
|
} catch (error) {
|
|
@@ -31909,7 +31951,7 @@ async function classifyScopedRun(input) {
|
|
|
31909
31951
|
async function scanAnalystIssueRuns(input) {
|
|
31910
31952
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
31911
31953
|
const scopeTicketNumber = input.ticketNumber;
|
|
31912
|
-
const booksRoot =
|
|
31954
|
+
const booksRoot = join33(ledgerHome, "books");
|
|
31913
31955
|
let wholeBook = false;
|
|
31914
31956
|
let scopeRootIdentity;
|
|
31915
31957
|
let bookNames;
|
|
@@ -31941,7 +31983,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
31941
31983
|
const unreadable = [];
|
|
31942
31984
|
const scopeConflicts = [];
|
|
31943
31985
|
for (const book of bookNames) {
|
|
31944
|
-
const bookDir =
|
|
31986
|
+
const bookDir = join33(booksRoot, book);
|
|
31945
31987
|
let runDirectories;
|
|
31946
31988
|
try {
|
|
31947
31989
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
@@ -32808,7 +32850,7 @@ var init_analyst_metric_family = __esm({
|
|
|
32808
32850
|
|
|
32809
32851
|
// src/analyst-page.ts
|
|
32810
32852
|
import { createHash as createHash5 } from "node:crypto";
|
|
32811
|
-
import { dirname as dirname17, join as
|
|
32853
|
+
import { dirname as dirname17, join as join34 } from "node:path";
|
|
32812
32854
|
function analystIssuePageKey(address) {
|
|
32813
32855
|
const parts = ["book", address.bookKey];
|
|
32814
32856
|
if (address.issueNumber !== void 0) {
|
|
@@ -32819,7 +32861,7 @@ function analystIssuePageKey(address) {
|
|
|
32819
32861
|
return createHash5("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
32820
32862
|
}
|
|
32821
32863
|
function analystIssuePagePath(ledgerHome, address) {
|
|
32822
|
-
return
|
|
32864
|
+
return join34(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
32823
32865
|
}
|
|
32824
32866
|
function analystIssuePageAddressFromPage(page) {
|
|
32825
32867
|
return {
|
|
@@ -33352,7 +33394,7 @@ __export(cli_exports, {
|
|
|
33352
33394
|
runAkRole: () => runAkRole
|
|
33353
33395
|
});
|
|
33354
33396
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
33355
|
-
import { join as
|
|
33397
|
+
import { join as join35 } from "node:path";
|
|
33356
33398
|
function takePublicGlobalFlag(argv, index, options) {
|
|
33357
33399
|
const tokens = argv.slice(index);
|
|
33358
33400
|
const taken = options.takeDashed(tokens);
|
|
@@ -33449,7 +33491,7 @@ function resolveHome(env) {
|
|
|
33449
33491
|
return env.home ?? packageMachineHome();
|
|
33450
33492
|
}
|
|
33451
33493
|
function resolveAgentDir(env, home) {
|
|
33452
|
-
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
33494
|
+
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join35(home, ".pi", "agent");
|
|
33453
33495
|
}
|
|
33454
33496
|
function parseThinking(value) {
|
|
33455
33497
|
return value;
|
|
@@ -34464,7 +34506,7 @@ var init_cli = __esm({
|
|
|
34464
34506
|
|
|
34465
34507
|
// src/public-cli/main.ts
|
|
34466
34508
|
import { existsSync as existsSync11 } from "node:fs";
|
|
34467
|
-
import { dirname as dirname18, join as
|
|
34509
|
+
import { dirname as dirname18, join as join36 } from "node:path";
|
|
34468
34510
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
34469
34511
|
|
|
34470
34512
|
// src/public-cli/host-pi-runtime.ts
|
|
@@ -34553,8 +34595,8 @@ function linkPackage(packageRoot2, name, targetDir) {
|
|
|
34553
34595
|
// src/public-cli/main.ts
|
|
34554
34596
|
var here = dirname18(fileURLToPath2(import.meta.url));
|
|
34555
34597
|
function resolvePackageRoot(binDir) {
|
|
34556
|
-
const canonical =
|
|
34557
|
-
if (existsSync11(
|
|
34598
|
+
const canonical = join36(binDir, "..", "..");
|
|
34599
|
+
if (existsSync11(join36(canonical, "package.json"))) {
|
|
34558
34600
|
return canonical;
|
|
34559
34601
|
}
|
|
34560
34602
|
return binDir;
|