@akagilnc/pi-workflow-roles 0.1.4759 → 0.1.4772
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 +227 -428
- package/dist/headless-host/production-host.js +233 -434
- package/dist/migrate-book-topology.js +1255 -1087
- package/dist/notary-source-run.js +12 -2
- package/dist/public-cli/invocation.js +11 -8
- package/dist/public-cli/main.js +198 -399
- package/dist/public-cli/post-admission.js +27 -1
- package/dist/public-cli/run-lifecycle.js +25 -4
- package/dist/role-run-relocation.js +19 -18
- package/package.json +1 -1
- package/src/book-topology-migration-placement.ts +9 -1
- package/src/book-topology-runs-migrator.ts +156 -4
- package/src/notary-source-run.ts +18 -2
- package/src/public-cli/invocation.ts +13 -9
- package/src/public-cli/post-admission.ts +36 -0
- package/src/public-cli/run-lifecycle.ts +42 -4
- package/src/role-run-relocation.ts +27 -30
|
@@ -1761,10 +1761,10 @@ __export(session_assistant_usage_exports, {
|
|
|
1761
1761
|
});
|
|
1762
1762
|
import { join as join9 } from "node:path";
|
|
1763
1763
|
async function readAssistantUsageFromSessionFile(sessionFile) {
|
|
1764
|
-
const { readFile:
|
|
1764
|
+
const { readFile: readFile24 } = await import("node:fs/promises");
|
|
1765
1765
|
let text;
|
|
1766
1766
|
try {
|
|
1767
|
-
text = await
|
|
1767
|
+
text = await readFile24(sessionFile, "utf8");
|
|
1768
1768
|
} catch (error) {
|
|
1769
1769
|
if (error?.code === "ENOENT") return void 0;
|
|
1770
1770
|
throw error;
|
|
@@ -4114,12 +4114,7 @@ var init_compliance_transport = __esm({
|
|
|
4114
4114
|
});
|
|
4115
4115
|
|
|
4116
4116
|
// src/role-run-relocation.ts
|
|
4117
|
-
import { existsSync as existsSync5 } from "node:fs";
|
|
4118
|
-
import { readdir as readdir3, readFile as readFile5, writeFile as writeFile2 } from "node:fs/promises";
|
|
4119
4117
|
import { join as join14, sep as sep2 } from "node:path";
|
|
4120
|
-
function isEnoent2(error) {
|
|
4121
|
-
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
4122
|
-
}
|
|
4123
4118
|
function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
|
|
4124
4119
|
if (typeof value !== "string") return value;
|
|
4125
4120
|
if (value === oldRunDirectory) return newRunDirectory;
|
|
@@ -4161,23 +4156,6 @@ function rewriteRunDirectoryPathFieldsAgainstRewrites(record4, fields, rewrites)
|
|
|
4161
4156
|
}
|
|
4162
4157
|
}
|
|
4163
4158
|
}
|
|
4164
|
-
function collectRewrites(input) {
|
|
4165
|
-
const own = {
|
|
4166
|
-
oldRunDirectory: input.oldRunDirectory,
|
|
4167
|
-
newRunDirectory: input.newRunDirectory
|
|
4168
|
-
};
|
|
4169
|
-
if (input.crossRunRewrites === void 0 || input.crossRunRewrites.length === 0) {
|
|
4170
|
-
return [own];
|
|
4171
|
-
}
|
|
4172
|
-
const seen = /* @__PURE__ */ new Set([own.oldRunDirectory]);
|
|
4173
|
-
const out = [own];
|
|
4174
|
-
for (const rewrite of input.crossRunRewrites) {
|
|
4175
|
-
if (seen.has(rewrite.oldRunDirectory)) continue;
|
|
4176
|
-
seen.add(rewrite.oldRunDirectory);
|
|
4177
|
-
out.push(rewrite);
|
|
4178
|
-
}
|
|
4179
|
-
return out;
|
|
4180
|
-
}
|
|
4181
4159
|
function isPlainObject(value) {
|
|
4182
4160
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
4183
4161
|
}
|
|
@@ -4189,254 +4167,25 @@ function rewriteSourceRunLocator(value, rewrites) {
|
|
|
4189
4167
|
rewrites
|
|
4190
4168
|
);
|
|
4191
4169
|
}
|
|
4192
|
-
function
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
rewriteSourceRunLocator(value.sourceRun, rewrites);
|
|
4200
|
-
if (Array.isArray(value.attachmentPaths)) {
|
|
4201
|
-
value.attachmentPaths = value.attachmentPaths.map(
|
|
4202
|
-
(path) => rewriteRunDirectoryPathValueAgainstRewrites(path, rewrites)
|
|
4203
|
-
);
|
|
4204
|
-
}
|
|
4205
|
-
}
|
|
4206
|
-
async function rewriteJsonObjectFile(path, fields, rewrites) {
|
|
4207
|
-
if (!existsSync5(path)) return;
|
|
4208
|
-
const page = JSON.parse(await readFile5(path, "utf8"));
|
|
4209
|
-
if (!isPlainObject(page)) return;
|
|
4210
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(page, fields, rewrites);
|
|
4211
|
-
await writeFile2(path, `${JSON.stringify(page, null, 2)}
|
|
4212
|
-
`, "utf8");
|
|
4213
|
-
}
|
|
4214
|
-
async function rewriteOfficerPointerFile(path, rewrites) {
|
|
4215
|
-
if (!existsSync5(path)) return;
|
|
4216
|
-
const page = JSON.parse(await readFile5(path, "utf8"));
|
|
4217
|
-
if (!isPlainObject(page)) return;
|
|
4218
|
-
if (page.kind !== "direct-officer-run-pointer") return;
|
|
4219
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
4220
|
-
page,
|
|
4221
|
-
OFFICER_POINTER_FIELDS,
|
|
4222
|
-
rewrites
|
|
4223
|
-
);
|
|
4224
|
-
await writeFile2(path, `${JSON.stringify(page)}
|
|
4225
|
-
`, "utf8");
|
|
4226
|
-
}
|
|
4227
|
-
async function rewriteSitianRecordsJsonl(path, rewrites) {
|
|
4228
|
-
if (!existsSync5(path)) return;
|
|
4229
|
-
const raw = await readFile5(path, "utf8");
|
|
4230
|
-
if (raw.length === 0) return;
|
|
4231
|
-
const endsWithNewline = raw.endsWith("\n");
|
|
4232
|
-
const lines = raw.split("\n");
|
|
4233
|
-
let changed = false;
|
|
4234
|
-
const out = [];
|
|
4235
|
-
for (let i = 0; i < lines.length; i += 1) {
|
|
4236
|
-
const line2 = lines[i];
|
|
4237
|
-
if (line2 === "" && i === lines.length - 1 && endsWithNewline) {
|
|
4238
|
-
out.push("");
|
|
4239
|
-
continue;
|
|
4240
|
-
}
|
|
4241
|
-
if (line2.trim() === "") {
|
|
4242
|
-
out.push(line2);
|
|
4243
|
-
continue;
|
|
4244
|
-
}
|
|
4245
|
-
let parsed;
|
|
4246
|
-
try {
|
|
4247
|
-
parsed = JSON.parse(line2);
|
|
4248
|
-
} catch {
|
|
4249
|
-
out.push(line2);
|
|
4250
|
-
continue;
|
|
4251
|
-
}
|
|
4252
|
-
if (!isPlainObject(parsed)) {
|
|
4253
|
-
out.push(line2);
|
|
4254
|
-
continue;
|
|
4255
|
-
}
|
|
4256
|
-
if (!("sessionParent" in parsed)) {
|
|
4257
|
-
out.push(line2);
|
|
4258
|
-
continue;
|
|
4259
|
-
}
|
|
4260
|
-
const before = parsed.sessionParent;
|
|
4261
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
4262
|
-
parsed,
|
|
4263
|
-
SITIAN_RECORD_FIELDS,
|
|
4264
|
-
rewrites
|
|
4265
|
-
);
|
|
4266
|
-
if (parsed.sessionParent !== before) changed = true;
|
|
4267
|
-
out.push(JSON.stringify(parsed));
|
|
4268
|
-
}
|
|
4269
|
-
if (!changed) return;
|
|
4270
|
-
const body = out.join("\n");
|
|
4271
|
-
await writeFile2(
|
|
4272
|
-
path,
|
|
4273
|
-
endsWithNewline && !body.endsWith("\n") ? `${body}
|
|
4274
|
-
` : body,
|
|
4275
|
-
"utf8"
|
|
4276
|
-
);
|
|
4277
|
-
}
|
|
4278
|
-
async function rewriteSessionTranscriptBindings(path, rewrites) {
|
|
4279
|
-
if (!existsSync5(path)) return;
|
|
4280
|
-
const raw = await readFile5(path, "utf8");
|
|
4281
|
-
if (raw.length === 0) return;
|
|
4282
|
-
const endsWithNewline = raw.endsWith("\n");
|
|
4283
|
-
const lines = raw.split("\n");
|
|
4284
|
-
let changed = false;
|
|
4285
|
-
const out = [];
|
|
4286
|
-
for (let i = 0; i < lines.length; i += 1) {
|
|
4287
|
-
const line2 = lines[i];
|
|
4288
|
-
if (line2 === "" && i === lines.length - 1 && endsWithNewline) {
|
|
4289
|
-
out.push("");
|
|
4290
|
-
continue;
|
|
4291
|
-
}
|
|
4292
|
-
if (line2.trim() === "") {
|
|
4293
|
-
out.push(line2);
|
|
4294
|
-
continue;
|
|
4295
|
-
}
|
|
4296
|
-
let parsed;
|
|
4297
|
-
try {
|
|
4298
|
-
parsed = JSON.parse(line2);
|
|
4299
|
-
} catch {
|
|
4300
|
-
out.push(line2);
|
|
4301
|
-
continue;
|
|
4302
|
-
}
|
|
4303
|
-
if (!isPlainObject(parsed)) {
|
|
4304
|
-
out.push(line2);
|
|
4305
|
-
continue;
|
|
4306
|
-
}
|
|
4307
|
-
let lineChanged = false;
|
|
4308
|
-
if (parsed.type === "session" && "parentSession" in parsed) {
|
|
4309
|
-
const before = parsed.parentSession;
|
|
4310
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
4311
|
-
parsed,
|
|
4312
|
-
SESSION_HEADER_FIELDS,
|
|
4313
|
-
rewrites
|
|
4314
|
-
);
|
|
4315
|
-
if (parsed.parentSession !== before) lineChanged = true;
|
|
4316
|
-
} else if (parsed.type === "custom" && parsed.customType === AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE && isPlainObject(parsed.data) && isPlainObject(parsed.data.parent)) {
|
|
4317
|
-
const parent = parsed.data.parent;
|
|
4318
|
-
const before = parent.sessionFile;
|
|
4319
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
4320
|
-
parent,
|
|
4321
|
-
BINDING_PARENT_FIELDS,
|
|
4322
|
-
rewrites
|
|
4323
|
-
);
|
|
4324
|
-
if (parent.sessionFile !== before) lineChanged = true;
|
|
4325
|
-
}
|
|
4326
|
-
if (lineChanged) changed = true;
|
|
4327
|
-
out.push(lineChanged ? JSON.stringify(parsed) : line2);
|
|
4328
|
-
}
|
|
4329
|
-
if (!changed) return;
|
|
4330
|
-
const body = out.join("\n");
|
|
4331
|
-
await writeFile2(
|
|
4332
|
-
path,
|
|
4333
|
-
endsWithNewline && !body.endsWith("\n") ? `${body}
|
|
4334
|
-
` : body,
|
|
4335
|
-
"utf8"
|
|
4336
|
-
);
|
|
4337
|
-
}
|
|
4338
|
-
async function rewriteNestedMachinePathPages(pagesDirectory, rewrites) {
|
|
4339
|
-
const sessionRoot = join14(pagesDirectory, "session");
|
|
4340
|
-
async function walk(directory) {
|
|
4341
|
-
let entries;
|
|
4342
|
-
try {
|
|
4343
|
-
entries = await readdir3(directory, { withFileTypes: true });
|
|
4344
|
-
} catch (error) {
|
|
4345
|
-
if (isEnoent2(error)) return;
|
|
4346
|
-
throw error;
|
|
4347
|
-
}
|
|
4348
|
-
for (const entry of entries) {
|
|
4349
|
-
const path = join14(directory, entry.name);
|
|
4350
|
-
if (entry.isDirectory()) {
|
|
4351
|
-
await walk(path);
|
|
4352
|
-
continue;
|
|
4353
|
-
}
|
|
4354
|
-
if (!entry.isFile()) continue;
|
|
4355
|
-
if (entry.name === "current-session.json") {
|
|
4356
|
-
await rewriteJsonObjectFile(path, CURRENT_SESSION_FIELDS, rewrites);
|
|
4357
|
-
} else if (entry.name.endsWith(".pointer.json")) {
|
|
4358
|
-
await rewriteOfficerPointerFile(path, rewrites);
|
|
4359
|
-
} else if (entry.name === "records.jsonl") {
|
|
4360
|
-
await rewriteSitianRecordsJsonl(path, rewrites);
|
|
4361
|
-
} else if (entry.name.endsWith(".jsonl")) {
|
|
4362
|
-
await rewriteSessionTranscriptBindings(path, rewrites);
|
|
4170
|
+
function rewriteAdmittedRoleRunPage(page, rewrites) {
|
|
4171
|
+
rewriteRunDirectoryPathFieldsAgainstRewrites(page, ADMITTED_PAGE_FIELDS, rewrites);
|
|
4172
|
+
rewriteSourceRunLocator(page.sourceRun, rewrites);
|
|
4173
|
+
if (Array.isArray(page.attachments)) {
|
|
4174
|
+
for (const attachment of page.attachments) {
|
|
4175
|
+
if (isPlainObject(attachment)) {
|
|
4176
|
+
rewriteRunDirectoryPathFieldsAgainstRewrites(attachment, ["frozenPath"], rewrites);
|
|
4363
4177
|
}
|
|
4364
4178
|
}
|
|
4365
4179
|
}
|
|
4366
|
-
|
|
4367
|
-
}
|
|
4368
|
-
async function rewriteRoleRunDurablePages(input) {
|
|
4369
|
-
const { pagesDirectory } = input;
|
|
4370
|
-
const rewrites = collectRewrites(input);
|
|
4371
|
-
const admittedPath = join14(pagesDirectory, "admitted-request.json");
|
|
4372
|
-
if (existsSync5(admittedPath)) {
|
|
4373
|
-
const page = JSON.parse(await readFile5(admittedPath, "utf8"));
|
|
4180
|
+
if (isPlainObject(page.principal)) {
|
|
4374
4181
|
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
4375
|
-
page,
|
|
4376
|
-
|
|
4182
|
+
page.principal,
|
|
4183
|
+
["sessionDirectory", "sessionFile"],
|
|
4377
4184
|
rewrites
|
|
4378
4185
|
);
|
|
4379
|
-
rewriteSourceRunLocator(page.sourceRun, rewrites);
|
|
4380
|
-
if (Array.isArray(page.attachments)) {
|
|
4381
|
-
for (const attachment of page.attachments) {
|
|
4382
|
-
if (isPlainObject(attachment)) {
|
|
4383
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
4384
|
-
attachment,
|
|
4385
|
-
["frozenPath"],
|
|
4386
|
-
rewrites
|
|
4387
|
-
);
|
|
4388
|
-
}
|
|
4389
|
-
}
|
|
4390
|
-
}
|
|
4391
|
-
if (isPlainObject(page.principal)) {
|
|
4392
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
4393
|
-
page.principal,
|
|
4394
|
-
["sessionDirectory", "sessionFile"],
|
|
4395
|
-
rewrites
|
|
4396
|
-
);
|
|
4397
|
-
}
|
|
4398
|
-
await writeFile2(admittedPath, `${JSON.stringify(page, null, 2)}
|
|
4399
|
-
`, "utf8");
|
|
4400
4186
|
}
|
|
4401
|
-
const invocationPath = join14(pagesDirectory, "invocation.json");
|
|
4402
|
-
if (existsSync5(invocationPath)) {
|
|
4403
|
-
const page = JSON.parse(await readFile5(invocationPath, "utf8"));
|
|
4404
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
4405
|
-
page,
|
|
4406
|
-
INVOCATION_PAGE_FIELDS,
|
|
4407
|
-
rewrites
|
|
4408
|
-
);
|
|
4409
|
-
await writeFile2(
|
|
4410
|
-
invocationPath,
|
|
4411
|
-
`${JSON.stringify(page, null, 2)}
|
|
4412
|
-
`,
|
|
4413
|
-
"utf8"
|
|
4414
|
-
);
|
|
4415
|
-
}
|
|
4416
|
-
const statePath = join14(pagesDirectory, "run-state.json");
|
|
4417
|
-
if (existsSync5(statePath)) {
|
|
4418
|
-
const page = JSON.parse(await readFile5(statePath, "utf8"));
|
|
4419
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
4420
|
-
page,
|
|
4421
|
-
RUN_STATE_PAGE_FIELDS,
|
|
4422
|
-
rewrites
|
|
4423
|
-
);
|
|
4424
|
-
if (isPlainObject(page.principal)) {
|
|
4425
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
4426
|
-
page.principal,
|
|
4427
|
-
["sessionDirectory", "sessionFile"],
|
|
4428
|
-
rewrites
|
|
4429
|
-
);
|
|
4430
|
-
}
|
|
4431
|
-
if (isPlainObject(page.currentCourt)) {
|
|
4432
|
-
rewriteSummonsMaterials(page.currentCourt.summons, rewrites);
|
|
4433
|
-
}
|
|
4434
|
-
await writeFile2(statePath, `${JSON.stringify(page, null, 2)}
|
|
4435
|
-
`, "utf8");
|
|
4436
|
-
}
|
|
4437
|
-
await rewriteNestedMachinePathPages(pagesDirectory, rewrites);
|
|
4438
4187
|
}
|
|
4439
|
-
var ADMITTED_PAGE_FIELDS,
|
|
4188
|
+
var ADMITTED_PAGE_FIELDS, SOURCE_RUN_LOCATOR_FIELDS;
|
|
4440
4189
|
var init_role_run_relocation = __esm({
|
|
4441
4190
|
"src/role-run-relocation.ts"() {
|
|
4442
4191
|
"use strict";
|
|
@@ -4453,24 +4202,7 @@ var init_role_run_relocation = __esm({
|
|
|
4453
4202
|
"mergerInputPath",
|
|
4454
4203
|
"sourceRunPath"
|
|
4455
4204
|
];
|
|
4456
|
-
INVOCATION_PAGE_FIELDS = [
|
|
4457
|
-
"runDirectory",
|
|
4458
|
-
"sessionDirectory",
|
|
4459
|
-
"sessionFile"
|
|
4460
|
-
];
|
|
4461
|
-
RUN_STATE_PAGE_FIELDS = [
|
|
4462
|
-
"runDirectory",
|
|
4463
|
-
"admittedRequestPath",
|
|
4464
|
-
"sessionDirectory",
|
|
4465
|
-
"sessionFile"
|
|
4466
|
-
];
|
|
4467
4205
|
SOURCE_RUN_LOCATOR_FIELDS = ["runDirectory"];
|
|
4468
|
-
SUMMONS_PATH_FIELDS = ["sourceRunPath"];
|
|
4469
|
-
CURRENT_SESSION_FIELDS = ["sessionFile"];
|
|
4470
|
-
OFFICER_POINTER_FIELDS = ["sessionFile", "runDirectory"];
|
|
4471
|
-
SITIAN_RECORD_FIELDS = ["sessionParent"];
|
|
4472
|
-
SESSION_HEADER_FIELDS = ["parentSession"];
|
|
4473
|
-
BINDING_PARENT_FIELDS = ["sessionFile"];
|
|
4474
4206
|
}
|
|
4475
4207
|
});
|
|
4476
4208
|
|
|
@@ -4603,7 +4335,7 @@ var init_terminating_tools = __esm({
|
|
|
4603
4335
|
});
|
|
4604
4336
|
|
|
4605
4337
|
// src/doctor-evidence.ts
|
|
4606
|
-
import { readdir as
|
|
4338
|
+
import { readdir as readdir3, readFile as readFile5, realpath as realpath2, stat } from "node:fs/promises";
|
|
4607
4339
|
import { dirname as dirname8, relative as relative2, resolve as resolve6, sep as sep3 } from "node:path";
|
|
4608
4340
|
function record2(value) {
|
|
4609
4341
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -4611,7 +4343,7 @@ function record2(value) {
|
|
|
4611
4343
|
async function discoverCaseFiles(root) {
|
|
4612
4344
|
const found = [];
|
|
4613
4345
|
async function walk(dir, depth) {
|
|
4614
|
-
for (const item of await
|
|
4346
|
+
for (const item of await readdir3(dir, { withFileTypes: true })) {
|
|
4615
4347
|
const path = resolve6(dir, item.name);
|
|
4616
4348
|
if (item.isDirectory()) {
|
|
4617
4349
|
await walk(path, depth + 1);
|
|
@@ -4719,7 +4451,7 @@ async function loadDoctorCase(runsPath) {
|
|
|
4719
4451
|
const turns = { count: 0, sources: [] }, calls = { count: 0, sources: [] }, tokens = { count: 0, sources: [] };
|
|
4720
4452
|
for (const path of await discoverCaseFiles(root)) {
|
|
4721
4453
|
const id = relative2(root, path).split(sep3).join("/");
|
|
4722
|
-
const bytes = await
|
|
4454
|
+
const bytes = await readFile5(path);
|
|
4723
4455
|
const content = bytes.toString("utf8");
|
|
4724
4456
|
const kind = id.endsWith(".jsonl") ? "session" : "stderr";
|
|
4725
4457
|
evidence.push({ id, kind, byteLength: bytes.byteLength, contentLength: content.length, sha256: sha256Hex(bytes), content });
|
|
@@ -4732,7 +4464,7 @@ async function loadDoctorCase(runsPath) {
|
|
|
4732
4464
|
accumulate(calls, result.calls, id);
|
|
4733
4465
|
accumulate(tokens, result.tokens, id);
|
|
4734
4466
|
}
|
|
4735
|
-
const runDirs = (await
|
|
4467
|
+
const runDirs = (await readdir3(root, { withFileTypes: true })).filter((item) => item.isDirectory()).map((item) => item.name).sort();
|
|
4736
4468
|
const legs = evidence.filter((entry) => entry.kind === "session").map((entry) => entry.id);
|
|
4737
4469
|
const retryDirs = runDirs.filter((name) => /(?:^|[-_])retry(?:[-_]|$)/i.test(name));
|
|
4738
4470
|
const rawBytes = evidence.filter((entry) => entry.kind === "session").reduce((sum, entry) => sum + entry.byteLength, 0);
|
|
@@ -4749,7 +4481,7 @@ var init_doctor_evidence = __esm({
|
|
|
4749
4481
|
|
|
4750
4482
|
// src/collector-config.ts
|
|
4751
4483
|
import { createHash as createHash4 } from "node:crypto";
|
|
4752
|
-
import { readFile as
|
|
4484
|
+
import { readFile as readFile6 } from "node:fs/promises";
|
|
4753
4485
|
function fail3(message, cause) {
|
|
4754
4486
|
throw new Error(message, cause === void 0 ? void 0 : { cause });
|
|
4755
4487
|
}
|
|
@@ -4792,7 +4524,7 @@ function emptyCollectorManifest() {
|
|
|
4792
4524
|
async function loadCollectorManifest(path) {
|
|
4793
4525
|
let bytes;
|
|
4794
4526
|
try {
|
|
4795
|
-
bytes = await
|
|
4527
|
+
bytes = await readFile6(path);
|
|
4796
4528
|
} catch (error) {
|
|
4797
4529
|
fail3(`Collector request manifest is unreadable at ${path}`, error);
|
|
4798
4530
|
}
|
|
@@ -5632,7 +5364,7 @@ var init_git_object_id = __esm({
|
|
|
5632
5364
|
|
|
5633
5365
|
// src/merger-git-state.ts
|
|
5634
5366
|
import { execFile as execFile2 } from "node:child_process";
|
|
5635
|
-
import { access as access2, readFile as
|
|
5367
|
+
import { access as access2, readFile as readFile7 } from "node:fs/promises";
|
|
5636
5368
|
import { constants as fsConstants } from "node:fs";
|
|
5637
5369
|
import { isAbsolute as isAbsolute4, resolve as resolve7 } from "node:path";
|
|
5638
5370
|
import { promisify as promisify2 } from "node:util";
|
|
@@ -5702,7 +5434,7 @@ function createProductionMergerGitState(repositoryRoot = process.cwd()) {
|
|
|
5702
5434
|
const mergeHeadPath = isAbsolute4(mergeHeadReported) ? mergeHeadReported : resolve7(repositoryRoot, mergeHeadReported);
|
|
5703
5435
|
let sourceObjectId = "";
|
|
5704
5436
|
if (await pathExists(mergeHeadPath)) {
|
|
5705
|
-
const raw = exactUtf8(await
|
|
5437
|
+
const raw = exactUtf8(await readFile7(mergeHeadPath), "Git MERGE_HEAD");
|
|
5706
5438
|
const mergeHeads = raw.trim().split(/\r?\n/).map((row) => row.trim()).filter(Boolean);
|
|
5707
5439
|
if (mergeHeads.length === 0) throw new Error("Git MERGE_HEAD is empty");
|
|
5708
5440
|
if (mergeHeads.length !== 1) throw new Error("Assigned repository does not have one ordinary in-progress merge");
|
|
@@ -5754,7 +5486,7 @@ var init_uuidv7 = __esm({
|
|
|
5754
5486
|
});
|
|
5755
5487
|
|
|
5756
5488
|
// src/typed-provider-http.ts
|
|
5757
|
-
import { readFile as
|
|
5489
|
+
import { readFile as readFile8, unlink, writeFile as writeFile2 } from "node:fs/promises";
|
|
5758
5490
|
import { join as join15 } from "node:path";
|
|
5759
5491
|
function typedProviderHttpPath(runDirectory) {
|
|
5760
5492
|
return join15(runDirectory, TYPED_HTTP_FILE);
|
|
@@ -5778,7 +5510,7 @@ async function recordTypedProviderHttpStatus(runDirectory, observation) {
|
|
|
5778
5510
|
httpStatus: observation.httpStatus,
|
|
5779
5511
|
provider: observation.provider
|
|
5780
5512
|
};
|
|
5781
|
-
await
|
|
5513
|
+
await writeFile2(
|
|
5782
5514
|
typedProviderHttpPath(runDirectory),
|
|
5783
5515
|
`${JSON.stringify(body)}
|
|
5784
5516
|
`,
|
|
@@ -5788,7 +5520,7 @@ async function recordTypedProviderHttpStatus(runDirectory, observation) {
|
|
|
5788
5520
|
async function readLatestTypedProviderHttpObservation(runDirectory) {
|
|
5789
5521
|
let text;
|
|
5790
5522
|
try {
|
|
5791
|
-
text = await
|
|
5523
|
+
text = await readFile8(typedProviderHttpPath(runDirectory), "utf8");
|
|
5792
5524
|
} catch (error) {
|
|
5793
5525
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
5794
5526
|
return void 0;
|
|
@@ -5867,7 +5599,7 @@ __export(run_lifecycle_exports, {
|
|
|
5867
5599
|
selectResumeContinuationPrompt: () => selectResumeContinuationPrompt,
|
|
5868
5600
|
writeRoleRunState: () => writeRoleRunState
|
|
5869
5601
|
});
|
|
5870
|
-
import { chmod, lstat as lstat2, open, readdir as
|
|
5602
|
+
import { chmod, lstat as lstat2, open, readdir as readdir4, readFile as readFile9, unlink as unlink2, writeFile as writeFile3 } from "node:fs/promises";
|
|
5871
5603
|
import { basename as basename5, join as join16 } from "node:path";
|
|
5872
5604
|
function selectResumeContinuationPrompt(message, engineMaterial) {
|
|
5873
5605
|
const lines = message !== void 0 ? [message] : [];
|
|
@@ -5906,7 +5638,7 @@ function renderResumeCommand(runId) {
|
|
|
5906
5638
|
}
|
|
5907
5639
|
async function writeRoleRunState(runDirectory, record4) {
|
|
5908
5640
|
const payload = { ...record4, runDirectory };
|
|
5909
|
-
await
|
|
5641
|
+
await writeFile3(
|
|
5910
5642
|
join16(runDirectory, RUN_STATE_FILE),
|
|
5911
5643
|
`${JSON.stringify(payload, null, 2)}
|
|
5912
5644
|
`,
|
|
@@ -5957,7 +5689,7 @@ function parseCurrentCourtState(raw) {
|
|
|
5957
5689
|
async function readRoleRunStateDisk(runDirectory) {
|
|
5958
5690
|
let raw;
|
|
5959
5691
|
try {
|
|
5960
|
-
raw = JSON.parse(await
|
|
5692
|
+
raw = JSON.parse(await readFile9(join16(runDirectory, RUN_STATE_FILE), "utf8"));
|
|
5961
5693
|
} catch (error) {
|
|
5962
5694
|
if (errorCodeOf2(error) === "ENOENT") return void 0;
|
|
5963
5695
|
throw error;
|
|
@@ -5979,10 +5711,15 @@ async function readRoleRunStateDisk(runDirectory) {
|
|
|
5979
5711
|
if (typeof record4.projectRoot !== "string") return void 0;
|
|
5980
5712
|
if (typeof record4.sessionDirectory !== "string") return void 0;
|
|
5981
5713
|
if (typeof record4.admittedRequestPath !== "string") return void 0;
|
|
5982
|
-
const
|
|
5714
|
+
const storedRunDirectory = typeof record4.runDirectory === "string" && record4.runDirectory.trim() !== "" ? record4.runDirectory : runDirectory;
|
|
5715
|
+
const runDir = runDirectory;
|
|
5983
5716
|
const principalWire = {
|
|
5984
|
-
sessionDirectory:
|
|
5985
|
-
|
|
5717
|
+
sessionDirectory: rewriteRunDirectoryPathValue(
|
|
5718
|
+
record4.sessionDirectory,
|
|
5719
|
+
storedRunDirectory,
|
|
5720
|
+
runDirectory
|
|
5721
|
+
),
|
|
5722
|
+
...typeof record4.sessionFile === "string" ? { sessionFile: rewriteRunDirectoryPathValue(record4.sessionFile, storedRunDirectory, runDirectory) } : {}
|
|
5986
5723
|
};
|
|
5987
5724
|
let resumable;
|
|
5988
5725
|
if (record4.resumable !== void 0 && record4.resumable !== null) {
|
|
@@ -6002,7 +5739,11 @@ async function readRoleRunStateDisk(runDirectory) {
|
|
|
6002
5739
|
bookKey: record4.bookKey,
|
|
6003
5740
|
projectRoot: record4.projectRoot,
|
|
6004
5741
|
runDirectory: runDir,
|
|
6005
|
-
admittedRequestPath:
|
|
5742
|
+
admittedRequestPath: rewriteRunDirectoryPathValue(
|
|
5743
|
+
record4.admittedRequestPath,
|
|
5744
|
+
storedRunDirectory,
|
|
5745
|
+
runDirectory
|
|
5746
|
+
),
|
|
6006
5747
|
principalWire,
|
|
6007
5748
|
...phase === void 0 ? {} : { phase },
|
|
6008
5749
|
...resumable === void 0 ? {} : { resumable },
|
|
@@ -6024,7 +5765,7 @@ async function writeRoleRunStateDisk(runDirectory, disk) {
|
|
|
6024
5765
|
...disk.resumable === void 0 ? {} : { resumable: disk.resumable },
|
|
6025
5766
|
...disk.currentCourt === void 0 ? {} : { currentCourt: disk.currentCourt }
|
|
6026
5767
|
};
|
|
6027
|
-
await
|
|
5768
|
+
await writeFile3(
|
|
6028
5769
|
join16(runDirectory, RUN_STATE_FILE),
|
|
6029
5770
|
`${JSON.stringify(payload, null, 2)}
|
|
6030
5771
|
`,
|
|
@@ -6197,7 +5938,7 @@ function isProcessAlive(pid) {
|
|
|
6197
5938
|
async function autopsyWriterLock(lockPath) {
|
|
6198
5939
|
let content;
|
|
6199
5940
|
try {
|
|
6200
|
-
content = await
|
|
5941
|
+
content = await readFile9(lockPath, "utf8");
|
|
6201
5942
|
} catch (error) {
|
|
6202
5943
|
if (errorCodeOf2(error) === "ENOENT") return { verdict: "absent" };
|
|
6203
5944
|
return { verdict: "unknown", reason: "unreadable", readFailure: error };
|
|
@@ -6356,7 +6097,7 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
|
6356
6097
|
const booksRoot = join16(ledgerHome, "books");
|
|
6357
6098
|
let bookKeys;
|
|
6358
6099
|
try {
|
|
6359
|
-
bookKeys = await
|
|
6100
|
+
bookKeys = await readdir4(booksRoot);
|
|
6360
6101
|
} catch (error) {
|
|
6361
6102
|
if (errorCodeOf2(error) === "ENOENT") return void 0;
|
|
6362
6103
|
throw error;
|
|
@@ -6394,7 +6135,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
6394
6135
|
let raw;
|
|
6395
6136
|
try {
|
|
6396
6137
|
raw = JSON.parse(
|
|
6397
|
-
await
|
|
6138
|
+
await readFile9(join16(runDirectory, "admitted-request.json"), "utf8")
|
|
6398
6139
|
);
|
|
6399
6140
|
} catch (error) {
|
|
6400
6141
|
if (errorCodeOf2(error) === "ENOENT") return void 0;
|
|
@@ -6563,10 +6304,15 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
6563
6304
|
let sourceRun;
|
|
6564
6305
|
try {
|
|
6565
6306
|
const raw = JSON.parse(
|
|
6566
|
-
await
|
|
6307
|
+
await readFile9(run.admittedRequestPath, "utf8")
|
|
6567
6308
|
);
|
|
6568
6309
|
if (raw !== null && typeof raw === "object" && !Array.isArray(raw)) {
|
|
6569
6310
|
const record4 = raw;
|
|
6311
|
+
const storedRunDirectory = typeof record4.runDirectory === "string" && record4.runDirectory.trim() !== "" ? record4.runDirectory : run.runDirectory;
|
|
6312
|
+
rewriteAdmittedRoleRunPage(record4, [{
|
|
6313
|
+
oldRunDirectory: storedRunDirectory,
|
|
6314
|
+
newRunDirectory: run.runDirectory
|
|
6315
|
+
}]);
|
|
6570
6316
|
if (typeof record4.instruction === "string") {
|
|
6571
6317
|
instruction = record4.instruction;
|
|
6572
6318
|
}
|
|
@@ -6681,7 +6427,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
6681
6427
|
let model;
|
|
6682
6428
|
try {
|
|
6683
6429
|
const invocationRaw = JSON.parse(
|
|
6684
|
-
await
|
|
6430
|
+
await readFile9(join16(run.runDirectory, "invocation.json"), "utf8")
|
|
6685
6431
|
);
|
|
6686
6432
|
if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
|
|
6687
6433
|
const rec = invocationRaw;
|
|
@@ -6720,6 +6466,23 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
6720
6466
|
} else if (mergedSet.tickets !== void 0) {
|
|
6721
6467
|
courtTicketNumbers = mergedSet.tickets;
|
|
6722
6468
|
}
|
|
6469
|
+
const sourceRunLeaf = basename5(sourceRunPath ?? "").split("@");
|
|
6470
|
+
const referencedRunId = sourceRun?.runId ?? sourceRunLeaf[0];
|
|
6471
|
+
const referencedRole = sourceRun?.role ?? sourceRunLeaf[1];
|
|
6472
|
+
if (referencedRunId !== void 0 && referencedRunId !== "") {
|
|
6473
|
+
const currentSourceRunDirectory = await findRunDirectoryById(
|
|
6474
|
+
home,
|
|
6475
|
+
referencedRunId,
|
|
6476
|
+
run.bookKey,
|
|
6477
|
+
referencedRole
|
|
6478
|
+
);
|
|
6479
|
+
if (currentSourceRunDirectory !== void 0) {
|
|
6480
|
+
sourceRunPath = currentSourceRunDirectory;
|
|
6481
|
+
if (sourceRun !== void 0) {
|
|
6482
|
+
sourceRun = { ...sourceRun, runDirectory: currentSourceRunDirectory };
|
|
6483
|
+
}
|
|
6484
|
+
}
|
|
6485
|
+
}
|
|
6723
6486
|
return {
|
|
6724
6487
|
run,
|
|
6725
6488
|
principal,
|
|
@@ -7124,6 +6887,7 @@ var init_run_lifecycle = __esm({
|
|
|
7124
6887
|
init_typed_provider_http();
|
|
7125
6888
|
init_collector_config();
|
|
7126
6889
|
init_diarist_contracts();
|
|
6890
|
+
init_role_run_relocation();
|
|
7127
6891
|
init_engine_material();
|
|
7128
6892
|
init_invocation();
|
|
7129
6893
|
V1_RESUMABLE_PROVIDERS = ["openai-codex", "xai"];
|
|
@@ -7196,17 +6960,29 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
7196
6960
|
}
|
|
7197
6961
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
7198
6962
|
const bookKey = resolveBookKeyFromGit(options.projectRoot);
|
|
7199
|
-
const
|
|
6963
|
+
const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
|
|
6964
|
+
const bookRunsRoot = join17(bookDirectory, "runs");
|
|
7200
6965
|
let candidate;
|
|
7201
6966
|
const bare = parseRunDirectoryName(raw);
|
|
7202
6967
|
if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
|
|
7203
6968
|
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join17(bookRunsRoot, `${bare.runId}@${bare.role}`);
|
|
7204
6969
|
} else {
|
|
7205
6970
|
candidate = isAbsolute6(raw) ? raw : resolve8(options.projectRoot, raw);
|
|
6971
|
+
const identity2 = parseRunDirectoryName(basename6(candidate));
|
|
6972
|
+
const subjectDirectory = dirname9(dirname9(candidate));
|
|
6973
|
+
const isLegacyUnboundLocator = identity2 !== void 0 && basename6(dirname9(candidate)) === "runs" && basename6(subjectDirectory) === "unbound" && resolve8(dirname9(subjectDirectory)) === resolve8(bookDirectory);
|
|
6974
|
+
if (isLegacyUnboundLocator) {
|
|
6975
|
+
candidate = await findRunDirectoryById(
|
|
6976
|
+
options.home,
|
|
6977
|
+
identity2.runId,
|
|
6978
|
+
bookKey,
|
|
6979
|
+
identity2.role
|
|
6980
|
+
) ?? candidate;
|
|
6981
|
+
}
|
|
7206
6982
|
}
|
|
7207
6983
|
const real = await requireRunDirectory(candidate, raw);
|
|
7208
6984
|
const identity = parseRunDirectoryName(basename6(real));
|
|
7209
|
-
const bookIdentity = physicalPathIdentity(
|
|
6985
|
+
const bookIdentity = physicalPathIdentity(bookDirectory);
|
|
7210
6986
|
const parentIdentity = physicalPathIdentity(dirname9(real));
|
|
7211
6987
|
const subjectBookIdentity = physicalPathIdentity(dirname9(dirname9(dirname9(real))));
|
|
7212
6988
|
if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename6(dirname9(real)) === "runs" && subjectBookIdentity === bookIdentity)) {
|
|
@@ -8388,15 +8164,15 @@ __export(invocation_exports, {
|
|
|
8388
8164
|
withPreparedAttachments: () => withPreparedAttachments
|
|
8389
8165
|
});
|
|
8390
8166
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
8391
|
-
import { existsSync as
|
|
8167
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
8392
8168
|
import {
|
|
8393
8169
|
lstat as lstat4,
|
|
8394
8170
|
mkdtemp as mkdtemp2,
|
|
8395
|
-
readFile as
|
|
8171
|
+
readFile as readFile10,
|
|
8396
8172
|
realpath as realpath4,
|
|
8397
8173
|
rename,
|
|
8398
8174
|
rm as rm2,
|
|
8399
|
-
writeFile as
|
|
8175
|
+
writeFile as writeFile4
|
|
8400
8176
|
} from "node:fs/promises";
|
|
8401
8177
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
8402
8178
|
import { basename as basename7, dirname as dirname10, isAbsolute as isAbsolute7, join as join18, resolve as resolve9, sep as sep4 } from "node:path";
|
|
@@ -8424,7 +8200,7 @@ async function writeAdmittedRequestPersistence(admittedRequestPath, body, coordi
|
|
|
8424
8200
|
sessionDirectory: coordinates.sessionDirectory,
|
|
8425
8201
|
sessionFile: coordinates.sessionFile
|
|
8426
8202
|
};
|
|
8427
|
-
await
|
|
8203
|
+
await writeFile4(
|
|
8428
8204
|
admittedRequestPath,
|
|
8429
8205
|
`${JSON.stringify(projection, null, 2)}
|
|
8430
8206
|
`,
|
|
@@ -8452,7 +8228,7 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
|
|
|
8452
8228
|
...source.ticketNumber === void 0 ? {} : { ticketNumber: source.ticketNumber },
|
|
8453
8229
|
...effectiveModelLedgerFields(effectiveModel)
|
|
8454
8230
|
};
|
|
8455
|
-
await
|
|
8231
|
+
await writeFile4(
|
|
8456
8232
|
join18(source.runDirectory, "invocation.json"),
|
|
8457
8233
|
`${JSON.stringify(identity, null, 2)}
|
|
8458
8234
|
`,
|
|
@@ -8461,7 +8237,7 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
|
|
|
8461
8237
|
}
|
|
8462
8238
|
async function recordEffectiveInvocationModel(runDirectory, model, engine, host, engineModel) {
|
|
8463
8239
|
const ledgerPath = join18(runDirectory, "invocation.json");
|
|
8464
|
-
const current = JSON.parse(await
|
|
8240
|
+
const current = JSON.parse(await readFile10(ledgerPath, "utf8"));
|
|
8465
8241
|
const next = { ...current };
|
|
8466
8242
|
if (model !== void 0) {
|
|
8467
8243
|
next.provider = model.provider;
|
|
@@ -8485,7 +8261,7 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host,
|
|
|
8485
8261
|
if (host !== void 0) {
|
|
8486
8262
|
next.host = host;
|
|
8487
8263
|
}
|
|
8488
|
-
await
|
|
8264
|
+
await writeFile4(
|
|
8489
8265
|
ledgerPath,
|
|
8490
8266
|
`${JSON.stringify(next, null, 2)}
|
|
8491
8267
|
`,
|
|
@@ -8494,8 +8270,8 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host,
|
|
|
8494
8270
|
}
|
|
8495
8271
|
async function mergeInvocationIdentityPage(runDirectory, fields) {
|
|
8496
8272
|
const ledgerPath = join18(runDirectory, "invocation.json");
|
|
8497
|
-
const current = JSON.parse(await
|
|
8498
|
-
await
|
|
8273
|
+
const current = JSON.parse(await readFile10(ledgerPath, "utf8"));
|
|
8274
|
+
await writeFile4(
|
|
8499
8275
|
ledgerPath,
|
|
8500
8276
|
`${JSON.stringify({
|
|
8501
8277
|
...current,
|
|
@@ -8510,14 +8286,14 @@ async function persistAdmittedSourceRunPath(admitted, sourceRunPath) {
|
|
|
8510
8286
|
throw new Error("persistAdmittedSourceRunPath requires a non-empty sourceRunPath");
|
|
8511
8287
|
}
|
|
8512
8288
|
const admittedPath = admitted.admittedRequestPath;
|
|
8513
|
-
const current = JSON.parse(await
|
|
8289
|
+
const current = JSON.parse(await readFile10(admittedPath, "utf8"));
|
|
8514
8290
|
if (typeof current.sourceRunPath === "string") {
|
|
8515
8291
|
if (current.sourceRunPath === sourceRunPath) return;
|
|
8516
8292
|
throw new Error(
|
|
8517
8293
|
`persistAdmittedSourceRunPath refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`
|
|
8518
8294
|
);
|
|
8519
8295
|
}
|
|
8520
|
-
await
|
|
8296
|
+
await writeFile4(
|
|
8521
8297
|
admittedPath,
|
|
8522
8298
|
`${JSON.stringify({ ...current, sourceRunPath }, null, 2)}
|
|
8523
8299
|
`,
|
|
@@ -8536,7 +8312,7 @@ async function bindAdmittedTicketNumber(admitted, ticketNumber) {
|
|
|
8536
8312
|
}
|
|
8537
8313
|
async function recordAdmittedCorrelation(admitted, correlationId) {
|
|
8538
8314
|
const current = JSON.parse(
|
|
8539
|
-
await
|
|
8315
|
+
await readFile10(admitted.admittedRequestPath, "utf8")
|
|
8540
8316
|
);
|
|
8541
8317
|
const prior = [
|
|
8542
8318
|
...Array.isArray(current.correlationIds) ? current.correlationIds.filter(
|
|
@@ -8545,7 +8321,7 @@ async function recordAdmittedCorrelation(admitted, correlationId) {
|
|
|
8545
8321
|
...typeof current.correlationId === "string" && current.correlationId.trim() !== "" ? [current.correlationId] : []
|
|
8546
8322
|
];
|
|
8547
8323
|
const correlationIds = [.../* @__PURE__ */ new Set([...prior, correlationId])];
|
|
8548
|
-
await
|
|
8324
|
+
await writeFile4(
|
|
8549
8325
|
admitted.admittedRequestPath,
|
|
8550
8326
|
`${JSON.stringify({ ...current, correlationId, correlationIds }, null, 2)}
|
|
8551
8327
|
`,
|
|
@@ -8584,8 +8360,8 @@ async function bindCourtTicketNumbersOnAdmitted(admitted, courtTicketNumbers) {
|
|
|
8584
8360
|
}
|
|
8585
8361
|
const frozen = Object.freeze([...projected]);
|
|
8586
8362
|
const admittedPath = admitted.admittedRequestPath;
|
|
8587
|
-
const current = JSON.parse(await
|
|
8588
|
-
await
|
|
8363
|
+
const current = JSON.parse(await readFile10(admittedPath, "utf8"));
|
|
8364
|
+
await writeFile4(
|
|
8589
8365
|
admittedPath,
|
|
8590
8366
|
`${JSON.stringify({ ...current, courtTicketNumbers: frozen }, null, 2)}
|
|
8591
8367
|
`,
|
|
@@ -8597,7 +8373,7 @@ async function bindCourtTicketNumbersOnAdmitted(admitted, courtTicketNumbers) {
|
|
|
8597
8373
|
admitted.courtTicketNumbers = frozen;
|
|
8598
8374
|
}
|
|
8599
8375
|
async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
8600
|
-
if (admitted.ticketNumber === void 0 || !admitted.runDirectory.includes(`${sep4}unbound${sep4}runs${sep4}`)) return;
|
|
8376
|
+
if (admitted.ticketNumber === void 0 || !admitted.runDirectory.includes(`${sep4}unbound${sep4}runs${sep4}`)) return void 0;
|
|
8601
8377
|
const oldRunDirectory = admitted.runDirectory;
|
|
8602
8378
|
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(oldRunDirectory));
|
|
8603
8379
|
const target = roleRunPlacement(ledgerHome, {
|
|
@@ -8607,6 +8383,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
8607
8383
|
role: admitted.role
|
|
8608
8384
|
});
|
|
8609
8385
|
ensureRoleRunDirectory(ledgerHome, dirname10(target.runDirectory));
|
|
8386
|
+
const principal = authority.seal(target);
|
|
8610
8387
|
await rename(oldRunDirectory, target.runDirectory);
|
|
8611
8388
|
heldLease?.relocate(target.runDirectory);
|
|
8612
8389
|
const admittedRecord = admitted;
|
|
@@ -8631,13 +8408,8 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
8631
8408
|
target.runDirectory
|
|
8632
8409
|
);
|
|
8633
8410
|
}
|
|
8634
|
-
const principal = authority.seal(target);
|
|
8635
8411
|
admitted.principal = principal;
|
|
8636
|
-
|
|
8637
|
-
pagesDirectory: target.runDirectory,
|
|
8638
|
-
oldRunDirectory,
|
|
8639
|
-
newRunDirectory: target.runDirectory
|
|
8640
|
-
});
|
|
8412
|
+
return { oldRunDirectory, newRunDirectory: target.runDirectory };
|
|
8641
8413
|
}
|
|
8642
8414
|
async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
8643
8415
|
requireSafePositiveTicketNumber(
|
|
@@ -8646,7 +8418,7 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
|
8646
8418
|
);
|
|
8647
8419
|
const admittedPath = join18(runDirectory, "admitted-request.json");
|
|
8648
8420
|
const invocationPath = join18(runDirectory, "invocation.json");
|
|
8649
|
-
const admitted = JSON.parse(await
|
|
8421
|
+
const admitted = JSON.parse(await readFile10(admittedPath, "utf8"));
|
|
8650
8422
|
const existing = admitted.ticketNumber;
|
|
8651
8423
|
if (typeof existing === "number") {
|
|
8652
8424
|
if (existing === ticketNumber) return;
|
|
@@ -8654,9 +8426,9 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
|
8654
8426
|
`bindTicketNumberOnRunDirectory refuses to replace existing ticket #${existing} with #${ticketNumber}`
|
|
8655
8427
|
);
|
|
8656
8428
|
}
|
|
8657
|
-
if (
|
|
8429
|
+
if (existsSync5(invocationPath)) {
|
|
8658
8430
|
const invocation = JSON.parse(
|
|
8659
|
-
await
|
|
8431
|
+
await readFile10(invocationPath, "utf8")
|
|
8660
8432
|
);
|
|
8661
8433
|
if (typeof invocation.ticketNumber === "number" && invocation.ticketNumber !== ticketNumber) {
|
|
8662
8434
|
throw new Error(
|
|
@@ -8664,7 +8436,7 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
|
8664
8436
|
);
|
|
8665
8437
|
}
|
|
8666
8438
|
}
|
|
8667
|
-
await
|
|
8439
|
+
await writeFile4(
|
|
8668
8440
|
admittedPath,
|
|
8669
8441
|
`${JSON.stringify({ ...admitted, ticketNumber }, null, 2)}
|
|
8670
8442
|
`,
|
|
@@ -8681,7 +8453,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
8681
8453
|
async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
|
|
8682
8454
|
const rolePackageRoot = packageRoot;
|
|
8683
8455
|
const raw = JSON.parse(
|
|
8684
|
-
await
|
|
8456
|
+
await readFile10(join18(rolePackageRoot, "package.json"), "utf8")
|
|
8685
8457
|
);
|
|
8686
8458
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
8687
8459
|
throw new Error(
|
|
@@ -8966,7 +8738,7 @@ async function readRegularFileAttachment(sourcePath) {
|
|
|
8966
8738
|
);
|
|
8967
8739
|
}
|
|
8968
8740
|
try {
|
|
8969
|
-
return { absolute, bytes: await
|
|
8741
|
+
return { absolute, bytes: await readFile10(absolute) };
|
|
8970
8742
|
} catch (error) {
|
|
8971
8743
|
throw new CliUsageError(
|
|
8972
8744
|
`attachment is not a readable regular file: ${sourcePath}`,
|
|
@@ -8986,7 +8758,7 @@ async function withPreparedAttachments(attachmentPaths, use) {
|
|
|
8986
8758
|
for (let index = 0; index < attachmentPaths.length; index += 1) {
|
|
8987
8759
|
const { absolute, bytes } = await readRegularFileAttachment(attachmentPaths[index]);
|
|
8988
8760
|
const snapshotPath = join18(stagingDirectory, String(index).padStart(6, "0"));
|
|
8989
|
-
await
|
|
8761
|
+
await writeFile4(snapshotPath, bytes);
|
|
8990
8762
|
prepared.push({ absolute, snapshotPath });
|
|
8991
8763
|
}
|
|
8992
8764
|
result = await use(prepared);
|
|
@@ -9010,7 +8782,7 @@ async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, inde
|
|
|
9010
8782
|
destinationDir,
|
|
9011
8783
|
`${String(index).padStart(2, "0")}-${basename7(provenancePath)}`
|
|
9012
8784
|
);
|
|
9013
|
-
await
|
|
8785
|
+
await writeFile4(frozenPath, bytes);
|
|
9014
8786
|
return {
|
|
9015
8787
|
provenancePath,
|
|
9016
8788
|
frozenPath,
|
|
@@ -9022,7 +8794,7 @@ async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, inde
|
|
|
9022
8794
|
async function freezePreparedAttachment(prepared, destinationDir, index) {
|
|
9023
8795
|
return freezeAttachmentBytes(
|
|
9024
8796
|
prepared.absolute,
|
|
9025
|
-
await
|
|
8797
|
+
await readFile10(prepared.snapshotPath),
|
|
9026
8798
|
destinationDir,
|
|
9027
8799
|
index
|
|
9028
8800
|
);
|
|
@@ -9278,7 +9050,7 @@ function buildCountersignTransportPrompt(admitted, engineMaterial) {
|
|
|
9278
9050
|
async function loadAdmittedJudgeRequest(runDirectory) {
|
|
9279
9051
|
try {
|
|
9280
9052
|
const raw = JSON.parse(
|
|
9281
|
-
await
|
|
9053
|
+
await readFile10(join18(runDirectory, "admitted-request.json"), "utf8")
|
|
9282
9054
|
);
|
|
9283
9055
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
9284
9056
|
const record4 = raw;
|
|
@@ -9334,7 +9106,7 @@ async function admitCoderInvocation(options) {
|
|
|
9334
9106
|
});
|
|
9335
9107
|
const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
|
|
9336
9108
|
const taskPath = join18(runDirectory, "task.md");
|
|
9337
|
-
await
|
|
9109
|
+
await writeFile4(taskPath, instruction, "utf8");
|
|
9338
9110
|
const admitted = {
|
|
9339
9111
|
role: "coder",
|
|
9340
9112
|
phase: options.phase,
|
|
@@ -9404,7 +9176,7 @@ async function admitFixerInvocation(options) {
|
|
|
9404
9176
|
if (options.prerequisitesPath !== void 0) {
|
|
9405
9177
|
const absolutePrereq = isAbsolute7(options.prerequisitesPath) ? options.prerequisitesPath : resolve9(options.prerequisitesPath);
|
|
9406
9178
|
try {
|
|
9407
|
-
prerequisitesSource = await
|
|
9179
|
+
prerequisitesSource = await readFile10(absolutePrereq, "utf8");
|
|
9408
9180
|
} catch (error) {
|
|
9409
9181
|
throw new CliUsageError(
|
|
9410
9182
|
`fixer prerequisites path is unreadable: ${options.prerequisitesPath}`,
|
|
@@ -9441,7 +9213,7 @@ async function admitFixerInvocation(options) {
|
|
|
9441
9213
|
let prerequisitesPath;
|
|
9442
9214
|
if (prerequisitesSource !== void 0) {
|
|
9443
9215
|
prerequisitesPath = join18(runDirectory, "prerequisites.json");
|
|
9444
|
-
await
|
|
9216
|
+
await writeFile4(
|
|
9445
9217
|
prerequisitesPath,
|
|
9446
9218
|
`${JSON.stringify(prerequisites, null, 2)}
|
|
9447
9219
|
`,
|
|
@@ -9449,7 +9221,7 @@ async function admitFixerInvocation(options) {
|
|
|
9449
9221
|
);
|
|
9450
9222
|
}
|
|
9451
9223
|
const packetPath = join18(runDirectory, "fix-packet.md");
|
|
9452
|
-
await
|
|
9224
|
+
await writeFile4(packetPath, instruction, "utf8");
|
|
9453
9225
|
const admitted = {
|
|
9454
9226
|
role: "fixer",
|
|
9455
9227
|
phase: options.phase,
|
|
@@ -9695,7 +9467,7 @@ async function admitCollectorInvocation(options) {
|
|
|
9695
9467
|
let requestManifestPath;
|
|
9696
9468
|
if (manifestCanonicalJson !== void 0) {
|
|
9697
9469
|
requestManifestPath = join18(runDirectory, "request-manifest.json");
|
|
9698
|
-
await
|
|
9470
|
+
await writeFile4(requestManifestPath, manifestCanonicalJson, "utf8");
|
|
9699
9471
|
}
|
|
9700
9472
|
const admitted = {
|
|
9701
9473
|
role: "collector",
|
|
@@ -10476,7 +10248,7 @@ async function admitMergerInvocation(options) {
|
|
|
10476
10248
|
authorizedChecks: []
|
|
10477
10249
|
});
|
|
10478
10250
|
const mergerInputPath = join18(runDirectory, "merger-input.json");
|
|
10479
|
-
await
|
|
10251
|
+
await writeFile4(
|
|
10480
10252
|
mergerInputPath,
|
|
10481
10253
|
`${JSON.stringify(mergerInput, null, 2)}
|
|
10482
10254
|
`,
|
|
@@ -10789,7 +10561,7 @@ var init_invocation = __esm({
|
|
|
10789
10561
|
});
|
|
10790
10562
|
|
|
10791
10563
|
// src/public-cli/load-production-acp-host.ts
|
|
10792
|
-
import { existsSync as
|
|
10564
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
10793
10565
|
import { join as join19 } from "node:path";
|
|
10794
10566
|
import { pathToFileURL } from "node:url";
|
|
10795
10567
|
async function loadProductionAcpHostFactory(packageRoot, host) {
|
|
@@ -10799,7 +10571,7 @@ async function loadProductionAcpHostFactory(packageRoot, host) {
|
|
|
10799
10571
|
}
|
|
10800
10572
|
const built = join19(packageRoot, "dist/acp-host/production-host.js");
|
|
10801
10573
|
const source = join19(packageRoot, "src/acp-host/production-host.ts");
|
|
10802
|
-
const target =
|
|
10574
|
+
const target = existsSync6(built) ? built : source;
|
|
10803
10575
|
const href = pathToFileURL(target).href;
|
|
10804
10576
|
const mod = await import(href);
|
|
10805
10577
|
const create = mod.createProductionAcpRoleTurnHost;
|
|
@@ -10813,7 +10585,7 @@ var init_load_production_acp_host = __esm({
|
|
|
10813
10585
|
});
|
|
10814
10586
|
|
|
10815
10587
|
// src/public-cli/load-production-headless-host.ts
|
|
10816
|
-
import { existsSync as
|
|
10588
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
10817
10589
|
import { join as join20 } from "node:path";
|
|
10818
10590
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
10819
10591
|
async function loadProductionHeadlessHostFactory(packageRoot, host) {
|
|
@@ -10823,7 +10595,7 @@ async function loadProductionHeadlessHostFactory(packageRoot, host) {
|
|
|
10823
10595
|
}
|
|
10824
10596
|
const built = join20(packageRoot, "dist/headless-host/production-host.js");
|
|
10825
10597
|
const source = join20(packageRoot, "src/headless-host/production-host.ts");
|
|
10826
|
-
const target =
|
|
10598
|
+
const target = existsSync7(built) ? built : source;
|
|
10827
10599
|
const href = pathToFileURL2(target).href;
|
|
10828
10600
|
const mod = await import(href);
|
|
10829
10601
|
const create = mod.createProductionHeadlessRoleTurnHost;
|
|
@@ -11071,7 +10843,7 @@ __export(config_exports, {
|
|
|
11071
10843
|
setPersistentSeatHost: () => setPersistentSeatHost,
|
|
11072
10844
|
validatePublicCliConfigAxes: () => validatePublicCliConfigAxes
|
|
11073
10845
|
});
|
|
11074
|
-
import { mkdir, readFile as
|
|
10846
|
+
import { mkdir, readFile as readFile11, writeFile as writeFile5 } from "node:fs/promises";
|
|
11075
10847
|
import { dirname as dirname11, join as join21 } from "node:path";
|
|
11076
10848
|
function isGateOfficerSeat(value) {
|
|
11077
10849
|
return GATE_OFFICER_SEATS.includes(value);
|
|
@@ -11085,7 +10857,7 @@ function publicCliConfigPath(home) {
|
|
|
11085
10857
|
async function loadPublicCliConfig(home) {
|
|
11086
10858
|
const path = publicCliConfigPath(home);
|
|
11087
10859
|
try {
|
|
11088
|
-
const raw = await
|
|
10860
|
+
const raw = await readFile11(path, "utf8");
|
|
11089
10861
|
return parsePublicCliConfig(JSON.parse(raw));
|
|
11090
10862
|
} catch (error) {
|
|
11091
10863
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
@@ -11098,7 +10870,7 @@ async function savePublicCliConfig(config, home) {
|
|
|
11098
10870
|
const path = publicCliConfigPath(home);
|
|
11099
10871
|
await mkdir(dirname11(path), { recursive: true });
|
|
11100
10872
|
const normalized = parsePublicCliConfig(config);
|
|
11101
|
-
await
|
|
10873
|
+
await writeFile5(
|
|
11102
10874
|
path,
|
|
11103
10875
|
`${JSON.stringify(serializePublicCliConfig(normalized), null, 2)}
|
|
11104
10876
|
`,
|
|
@@ -11543,7 +11315,7 @@ function credentialProvidersFromAuthData(data) {
|
|
|
11543
11315
|
}
|
|
11544
11316
|
async function loadCredentialProviders(agentDir) {
|
|
11545
11317
|
try {
|
|
11546
|
-
const raw = await
|
|
11318
|
+
const raw = await readFile11(join21(agentDir, "auth.json"), "utf8");
|
|
11547
11319
|
return credentialProvidersFromAuthData(JSON.parse(raw));
|
|
11548
11320
|
} catch (error) {
|
|
11549
11321
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
@@ -11745,12 +11517,12 @@ var init_host_providers = __esm({
|
|
|
11745
11517
|
});
|
|
11746
11518
|
|
|
11747
11519
|
// src/ledger-session-read.ts
|
|
11748
|
-
import { readFile as
|
|
11520
|
+
import { readFile as readFile12 } from "node:fs/promises";
|
|
11749
11521
|
function isRecord6(value) {
|
|
11750
11522
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11751
11523
|
}
|
|
11752
11524
|
async function readLedgerSessionJsonlLines(path) {
|
|
11753
|
-
const text = await
|
|
11525
|
+
const text = await readFile12(path, "utf8");
|
|
11754
11526
|
const lines = text.split("\n");
|
|
11755
11527
|
const out = [];
|
|
11756
11528
|
for (let index = 0; index < lines.length; index += 1) {
|
|
@@ -11848,7 +11620,7 @@ var init_ledger_session_read = __esm({
|
|
|
11848
11620
|
});
|
|
11849
11621
|
|
|
11850
11622
|
// src/analyst-gate-cycles-read.ts
|
|
11851
|
-
import { readdir as
|
|
11623
|
+
import { readdir as readdir5 } from "node:fs/promises";
|
|
11852
11624
|
import { join as join23 } from "node:path";
|
|
11853
11625
|
function isRecord7(value) {
|
|
11854
11626
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -12064,10 +11836,10 @@ function pairGateRounds(volumes) {
|
|
|
12064
11836
|
return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
|
|
12065
11837
|
}
|
|
12066
11838
|
async function resolveOfficerSessionFromPointerFile(pointerPath) {
|
|
12067
|
-
const { readFile:
|
|
11839
|
+
const { readFile: readFile24 } = await import("node:fs/promises");
|
|
12068
11840
|
let raw;
|
|
12069
11841
|
try {
|
|
12070
|
-
raw = JSON.parse(await
|
|
11842
|
+
raw = JSON.parse(await readFile24(pointerPath, "utf8"));
|
|
12071
11843
|
} catch (error) {
|
|
12072
11844
|
throw new Error(
|
|
12073
11845
|
`direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -12090,7 +11862,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
|
|
|
12090
11862
|
for (const directory of directories) {
|
|
12091
11863
|
let names;
|
|
12092
11864
|
try {
|
|
12093
|
-
const entries = await
|
|
11865
|
+
const entries = await readdir5(directory, { withFileTypes: true });
|
|
12094
11866
|
names = entries.filter(
|
|
12095
11867
|
(e) => e.isFile() && (e.name.endsWith(".jsonl") || e.name.endsWith(".pointer.json"))
|
|
12096
11868
|
).map((e) => e.name).sort();
|
|
@@ -12668,14 +12440,14 @@ var init_submission_ledger = __esm({
|
|
|
12668
12440
|
});
|
|
12669
12441
|
|
|
12670
12442
|
// src/session-opening-materials.ts
|
|
12671
|
-
import { existsSync as
|
|
12672
|
-
import { readFile as
|
|
12443
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
12444
|
+
import { readFile as readFile13 } from "node:fs/promises";
|
|
12673
12445
|
import { dirname as dirname12, join as join25 } from "node:path";
|
|
12674
12446
|
import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
12675
12447
|
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
12676
12448
|
let dir = dirname12(fileURLToPath(moduleUrl));
|
|
12677
12449
|
for (let i = 0; i < 8; i += 1) {
|
|
12678
|
-
if (
|
|
12450
|
+
if (existsSync8(join25(dir, "package.json")) && existsSync8(join25(dir, "souls"))) {
|
|
12679
12451
|
return dir;
|
|
12680
12452
|
}
|
|
12681
12453
|
const parent = dirname12(dir);
|
|
@@ -12685,7 +12457,7 @@ function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
|
12685
12457
|
return fileURLToPath(new URL("..", moduleUrl));
|
|
12686
12458
|
}
|
|
12687
12459
|
async function readPackageMaterial(relativePath) {
|
|
12688
|
-
return
|
|
12460
|
+
return readFile13(fileURLToPath(new URL(relativePath, packageRootUrl)), "utf8");
|
|
12689
12461
|
}
|
|
12690
12462
|
async function joinPackageMaterials(relativePaths) {
|
|
12691
12463
|
const chunks = [];
|
|
@@ -12803,7 +12575,7 @@ var init_auditor_soul = __esm({
|
|
|
12803
12575
|
});
|
|
12804
12576
|
|
|
12805
12577
|
// src/dossier-resolution.ts
|
|
12806
|
-
import { existsSync as
|
|
12578
|
+
import { existsSync as existsSync9, statSync as statSync3 } from "node:fs";
|
|
12807
12579
|
import { resolve as resolve10 } from "node:path";
|
|
12808
12580
|
function isHostContext(value) {
|
|
12809
12581
|
return "sessionManager" in value;
|
|
@@ -12823,7 +12595,7 @@ function resolveAuditDossier(source) {
|
|
|
12823
12595
|
}
|
|
12824
12596
|
const runDirectory = resolve10(raw);
|
|
12825
12597
|
try {
|
|
12826
|
-
if (!
|
|
12598
|
+
if (!existsSync9(runDirectory) || !statSync3(runDirectory).isDirectory()) {
|
|
12827
12599
|
return { status: "incomplete", observation: { kind: "missing-dossier" } };
|
|
12828
12600
|
}
|
|
12829
12601
|
} catch {
|
|
@@ -14324,7 +14096,7 @@ var init_engine_detour_usage = __esm({
|
|
|
14324
14096
|
|
|
14325
14097
|
// src/package-resources/method-skill.ts
|
|
14326
14098
|
import { createHash as createHash7 } from "node:crypto";
|
|
14327
|
-
import { readFile as
|
|
14099
|
+
import { readFile as readFile14, realpath as realpath5 } from "node:fs/promises";
|
|
14328
14100
|
import { join as join27 } from "node:path";
|
|
14329
14101
|
function gitBlobOid(bytes) {
|
|
14330
14102
|
const body = typeof bytes === "string" ? Buffer.from(bytes, "utf8") : Buffer.from(bytes);
|
|
@@ -14443,7 +14215,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot, name) {
|
|
|
14443
14215
|
const provenancePath = join27(rootDirectory, "provenance.json");
|
|
14444
14216
|
let provenanceRaw;
|
|
14445
14217
|
try {
|
|
14446
|
-
provenanceRaw = await
|
|
14218
|
+
provenanceRaw = await readFile14(provenancePath, "utf8");
|
|
14447
14219
|
} catch (error) {
|
|
14448
14220
|
throw new PackagedMethodSkillUnavailableError(name, provenancePath, error);
|
|
14449
14221
|
}
|
|
@@ -14460,7 +14232,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot, name) {
|
|
|
14460
14232
|
const absolute = join27(rootDirectory, rel);
|
|
14461
14233
|
let bytes;
|
|
14462
14234
|
try {
|
|
14463
|
-
bytes = await
|
|
14235
|
+
bytes = await readFile14(absolute);
|
|
14464
14236
|
} catch (error) {
|
|
14465
14237
|
throw new PackagedMethodSkillUnavailableError(name, absolute, error);
|
|
14466
14238
|
}
|
|
@@ -14476,7 +14248,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot, name) {
|
|
|
14476
14248
|
let raw;
|
|
14477
14249
|
try {
|
|
14478
14250
|
skillPath = await realpath5(skillPathConfigured);
|
|
14479
|
-
raw = await
|
|
14251
|
+
raw = await readFile14(skillPath, "utf8");
|
|
14480
14252
|
} catch (error) {
|
|
14481
14253
|
throw new PackagedMethodSkillUnavailableError(name, skillPathConfigured, error);
|
|
14482
14254
|
}
|
|
@@ -14937,7 +14709,7 @@ __export(settlement_exports, {
|
|
|
14937
14709
|
withSubmissions: () => withSubmissions
|
|
14938
14710
|
});
|
|
14939
14711
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
14940
|
-
import { appendFile as appendFile2, readFile as
|
|
14712
|
+
import { appendFile as appendFile2, readFile as readFile15, readdir as readdir6, rm as rm3, writeFile as writeFile6 } from "node:fs/promises";
|
|
14941
14713
|
import { dirname as dirname14, join as join28 } from "node:path";
|
|
14942
14714
|
function sealedLedgerHome(admitted) {
|
|
14943
14715
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
@@ -15088,7 +14860,7 @@ function presentControlledFailure(failure2, io) {
|
|
|
15088
14860
|
}
|
|
15089
14861
|
async function inspectJudgeSession(sessionFile) {
|
|
15090
14862
|
try {
|
|
15091
|
-
await
|
|
14863
|
+
await readFile15(sessionFile, "utf8");
|
|
15092
14864
|
return { state: "present" };
|
|
15093
14865
|
} catch (error) {
|
|
15094
14866
|
if (isMissingPathError4(error)) return { state: "missing" };
|
|
@@ -15323,7 +15095,7 @@ function sessionReadFailure(error, fallbackMessage) {
|
|
|
15323
15095
|
return failed;
|
|
15324
15096
|
}
|
|
15325
15097
|
async function readBoundSessionEntries(sessionFile) {
|
|
15326
|
-
const text = await
|
|
15098
|
+
const text = await readFile15(sessionFile, "utf8");
|
|
15327
15099
|
const entries = [];
|
|
15328
15100
|
for (const line2 of text.trim().split("\n").filter(Boolean)) {
|
|
15329
15101
|
try {
|
|
@@ -15425,7 +15197,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
15425
15197
|
for (const childDirectory of childDirectories) {
|
|
15426
15198
|
let names;
|
|
15427
15199
|
try {
|
|
15428
|
-
names = await
|
|
15200
|
+
names = await readdir6(childDirectory);
|
|
15429
15201
|
sawAnyDirectory = true;
|
|
15430
15202
|
} catch (error) {
|
|
15431
15203
|
if (isMissingPathError4(error)) continue;
|
|
@@ -16100,13 +15872,13 @@ async function publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinat
|
|
|
16100
15872
|
const artifactsDir = await ensureTerminalArtifactFace(admitted.runDirectory);
|
|
16101
15873
|
const reportPath = join28(artifactsDir, "report.json");
|
|
16102
15874
|
const evidencePath = join28(artifactsDir, "evidence.json");
|
|
16103
|
-
await
|
|
15875
|
+
await writeFile6(
|
|
16104
15876
|
reportPath,
|
|
16105
15877
|
`${JSON.stringify(bodies.report, null, 2)}
|
|
16106
15878
|
`,
|
|
16107
15879
|
"utf8"
|
|
16108
15880
|
);
|
|
16109
|
-
await
|
|
15881
|
+
await writeFile6(
|
|
16110
15882
|
evidencePath,
|
|
16111
15883
|
`${JSON.stringify(bodies.evidence, null, 2)}
|
|
16112
15884
|
`,
|
|
@@ -17020,7 +16792,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
|
|
|
17020
16792
|
const path = candidates[i];
|
|
17021
16793
|
const payload = issues.length === 0 ? basePayload : { ...basePayload, publicationIssues: issues };
|
|
17022
16794
|
try {
|
|
17023
|
-
await
|
|
16795
|
+
await writeFile6(
|
|
17024
16796
|
path,
|
|
17025
16797
|
`${JSON.stringify(payload, null, 2)}
|
|
17026
16798
|
`,
|
|
@@ -17385,7 +17157,7 @@ var init_seat_ticket_binding = __esm({
|
|
|
17385
17157
|
});
|
|
17386
17158
|
|
|
17387
17159
|
// src/session-identity.ts
|
|
17388
|
-
import { mkdir as mkdir2, readFile as
|
|
17160
|
+
import { mkdir as mkdir2, readFile as readFile16, rename as rename2, writeFile as writeFile7 } from "node:fs/promises";
|
|
17389
17161
|
import { dirname as dirname15, join as join29 } from "node:path";
|
|
17390
17162
|
function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
17391
17163
|
const bindingPath = (principal) => join29(authority.decode(principal).sessionDirectory, sessionBindingFile);
|
|
@@ -17395,7 +17167,7 @@ function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
|
17395
17167
|
},
|
|
17396
17168
|
async load(principal) {
|
|
17397
17169
|
try {
|
|
17398
|
-
const value = JSON.parse(await
|
|
17170
|
+
const value = JSON.parse(await readFile16(bindingPath(principal), "utf8"));
|
|
17399
17171
|
if (typeof value !== "object" || value === null || typeof value.sessionId !== "string") {
|
|
17400
17172
|
throw new Error("durable session binding is invalid");
|
|
17401
17173
|
}
|
|
@@ -17409,7 +17181,7 @@ function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
|
17409
17181
|
const target = bindingPath(principal);
|
|
17410
17182
|
await mkdir2(dirname15(target), { recursive: true });
|
|
17411
17183
|
const temporary = `${target}.${process.pid}.tmp`;
|
|
17412
|
-
await
|
|
17184
|
+
await writeFile7(temporary, `${JSON.stringify({ sessionId })}
|
|
17413
17185
|
`, { encoding: "utf8", mode: 384 });
|
|
17414
17186
|
await rename2(temporary, target);
|
|
17415
17187
|
}
|
|
@@ -17556,7 +17328,7 @@ var init_session_dialogue = __esm({
|
|
|
17556
17328
|
|
|
17557
17329
|
// src/ticket-provenance.ts
|
|
17558
17330
|
import { createHash as createHash8 } from "node:crypto";
|
|
17559
|
-
import { readFile as
|
|
17331
|
+
import { readFile as readFile17 } from "node:fs/promises";
|
|
17560
17332
|
import { basename as basename8, dirname as dirname16, join as join30, resolve as resolve12 } from "node:path";
|
|
17561
17333
|
function dialogueSessionSourceRoots(home) {
|
|
17562
17334
|
const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
|
|
@@ -17652,7 +17424,7 @@ async function readTicketProvenance(ticketNumber, cwd, home) {
|
|
|
17652
17424
|
const { recordFile } = resolveTicketProvenanceVolume(ticketNumber, cwd, home);
|
|
17653
17425
|
let text;
|
|
17654
17426
|
try {
|
|
17655
|
-
text = await
|
|
17427
|
+
text = await readFile17(recordFile, "utf8");
|
|
17656
17428
|
} catch (error) {
|
|
17657
17429
|
if (error.code === "ENOENT") {
|
|
17658
17430
|
return {
|
|
@@ -18132,7 +17904,7 @@ __export(case_dossier_delivery_exports, {
|
|
|
18132
17904
|
loadCaseDossierReadingMaterial: () => loadCaseDossierReadingMaterial,
|
|
18133
17905
|
projectCaseDossierPointerSection: () => projectCaseDossierPointerSection
|
|
18134
17906
|
});
|
|
18135
|
-
import { mkdtemp as mkdtemp3, readFile as
|
|
17907
|
+
import { mkdtemp as mkdtemp3, readFile as readFile18, rm as rm4, writeFile as writeFile8 } from "node:fs/promises";
|
|
18136
17908
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
18137
17909
|
import { join as join31 } from "node:path";
|
|
18138
17910
|
async function projectCaseDossierPointerSection(input) {
|
|
@@ -18164,7 +17936,7 @@ async function deliverCaseDossierAsAttachment(input) {
|
|
|
18164
17936
|
const stagingDir = await mkdtemp3(join31(tmpdir3(), "ak-case-dossier-"));
|
|
18165
17937
|
try {
|
|
18166
17938
|
const stagingPath = join31(stagingDir, CASE_DOSSIER_ATTACH_FILE);
|
|
18167
|
-
await
|
|
17939
|
+
await writeFile8(stagingPath, `${section}
|
|
18168
17940
|
`, "utf8");
|
|
18169
17941
|
return await freezeAttachmentsIntoRun(
|
|
18170
17942
|
[stagingPath],
|
|
@@ -18184,7 +17956,7 @@ async function loadCaseDossierReadingMaterial(runDirectory) {
|
|
|
18184
17956
|
);
|
|
18185
17957
|
let section;
|
|
18186
17958
|
try {
|
|
18187
|
-
section = await
|
|
17959
|
+
section = await readFile18(frozenPath, "utf8");
|
|
18188
17960
|
} catch (error) {
|
|
18189
17961
|
if (error.code === "ENOENT") return void 0;
|
|
18190
17962
|
throw error;
|
|
@@ -18207,9 +17979,9 @@ var init_case_dossier_delivery = __esm({
|
|
|
18207
17979
|
});
|
|
18208
17980
|
|
|
18209
17981
|
// src/host-transition-prior-native.ts
|
|
18210
|
-
import { access as access3, readdir as
|
|
17982
|
+
import { access as access3, readdir as readdir7 } from "node:fs/promises";
|
|
18211
17983
|
import { dirname as dirname17, join as join32 } from "node:path";
|
|
18212
|
-
function
|
|
17984
|
+
function isEnoent2(error) {
|
|
18213
17985
|
return typeof error === "object" && error !== null && error.code === "ENOENT";
|
|
18214
17986
|
}
|
|
18215
17987
|
async function listPiNativeRecordPaths(sessionFile) {
|
|
@@ -18217,7 +17989,7 @@ async function listPiNativeRecordPaths(sessionFile) {
|
|
|
18217
17989
|
await access3(sessionFile);
|
|
18218
17990
|
return [sessionFile];
|
|
18219
17991
|
} catch (error) {
|
|
18220
|
-
if (
|
|
17992
|
+
if (isEnoent2(error)) return [];
|
|
18221
17993
|
throw error;
|
|
18222
17994
|
}
|
|
18223
17995
|
}
|
|
@@ -18225,9 +17997,9 @@ async function listSitianRecordPaths(sessionParent) {
|
|
|
18225
17997
|
const sessionRoot = dirname17(sessionParent);
|
|
18226
17998
|
let entries;
|
|
18227
17999
|
try {
|
|
18228
|
-
entries = await
|
|
18000
|
+
entries = await readdir7(sessionRoot, { withFileTypes: true });
|
|
18229
18001
|
} catch (error) {
|
|
18230
|
-
if (
|
|
18002
|
+
if (isEnoent2(error)) return [];
|
|
18231
18003
|
throw error;
|
|
18232
18004
|
}
|
|
18233
18005
|
const recordPaths = [];
|
|
@@ -18238,7 +18010,7 @@ async function listSitianRecordPaths(sessionParent) {
|
|
|
18238
18010
|
await access3(recordFile);
|
|
18239
18011
|
recordPaths.push(recordFile);
|
|
18240
18012
|
} catch (error) {
|
|
18241
|
-
if (!
|
|
18013
|
+
if (!isEnoent2(error)) throw error;
|
|
18242
18014
|
}
|
|
18243
18015
|
}
|
|
18244
18016
|
recordPaths.sort();
|
|
@@ -18699,7 +18471,7 @@ var init_auto_resume = __esm({
|
|
|
18699
18471
|
|
|
18700
18472
|
// src/public-cli/post-admission.ts
|
|
18701
18473
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
18702
|
-
import { writeFile as
|
|
18474
|
+
import { writeFile as writeFile9 } from "node:fs/promises";
|
|
18703
18475
|
import { isAbsolute as isAbsolute8, join as join34, resolve as resolve13 } from "node:path";
|
|
18704
18476
|
function describeCaughtError(error) {
|
|
18705
18477
|
if (error instanceof Error) {
|
|
@@ -18711,6 +18483,28 @@ function describeCaughtError(error) {
|
|
|
18711
18483
|
function isStationChildOfficerDialogue(role, env) {
|
|
18712
18484
|
return env.stationChild === true && isOfficerReviewSeat(role);
|
|
18713
18485
|
}
|
|
18486
|
+
function projectRelocatedTurnIdentity(request, result, admitted, relocation) {
|
|
18487
|
+
const rewrite = (value) => rewriteRunDirectoryPathValue(
|
|
18488
|
+
value,
|
|
18489
|
+
relocation.oldRunDirectory,
|
|
18490
|
+
relocation.newRunDirectory
|
|
18491
|
+
);
|
|
18492
|
+
const mutableRequest = request;
|
|
18493
|
+
mutableRequest.runDirectory = admitted.runDirectory;
|
|
18494
|
+
mutableRequest.principal = admitted.principal;
|
|
18495
|
+
const activation = mutableRequest.activation;
|
|
18496
|
+
if (activation !== null && typeof activation === "object" && !Array.isArray(activation)) {
|
|
18497
|
+
for (const field of ["taskPath", "packetPath", "prerequisitesPath", "inputPath", "requestManifestPath"]) {
|
|
18498
|
+
const record4 = activation;
|
|
18499
|
+
if (field in record4) record4[field] = rewrite(record4[field]);
|
|
18500
|
+
}
|
|
18501
|
+
}
|
|
18502
|
+
if (result.terminal !== void 0) {
|
|
18503
|
+
for (const artifact of result.terminal.artifacts) {
|
|
18504
|
+
artifact.path = rewrite(artifact.path);
|
|
18505
|
+
}
|
|
18506
|
+
}
|
|
18507
|
+
}
|
|
18714
18508
|
function withProcessCancelSkipAutoResume(result, signal) {
|
|
18715
18509
|
if (processCancelSignalName(signal) === void 0) {
|
|
18716
18510
|
return result;
|
|
@@ -18767,7 +18561,7 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
18767
18561
|
} catch (appendError) {
|
|
18768
18562
|
try {
|
|
18769
18563
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
18770
|
-
await
|
|
18564
|
+
await writeFile9(
|
|
18771
18565
|
join34(artifactsDir, `post-admission-diagnostic-${randomUUID6()}.json`),
|
|
18772
18566
|
`${JSON.stringify({ version: 1, ...payload }, null, 2)}
|
|
18773
18567
|
`,
|
|
@@ -18943,6 +18737,10 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18943
18737
|
const ticketNumber = asserted === void 0 ? void 0 : asserted.ticketNumber;
|
|
18944
18738
|
if (ticketNumber !== void 0) await bindAdmittedTicketNumber(admitted, ticketNumber);
|
|
18945
18739
|
}
|
|
18740
|
+
const relocation = await relocateAdmittedRunToTicket(admitted, env.principalAuthority, lease);
|
|
18741
|
+
if (relocation !== void 0) {
|
|
18742
|
+
projectRelocatedTurnIdentity(request, result, admitted, relocation);
|
|
18743
|
+
}
|
|
18946
18744
|
if (adapters.afterDispatch !== void 0) await adapters.afterDispatch(admitted, lease);
|
|
18947
18745
|
return result;
|
|
18948
18746
|
} catch (error) {
|
|
@@ -19083,7 +18881,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
19083
18881
|
}
|
|
19084
18882
|
let stderrLogWriteFailure;
|
|
19085
18883
|
try {
|
|
19086
|
-
await
|
|
18884
|
+
await writeFile9(
|
|
19087
18885
|
join34(admitted.runDirectory, "stderr.log"),
|
|
19088
18886
|
result.stderr,
|
|
19089
18887
|
"utf8"
|
|
@@ -19649,6 +19447,7 @@ var init_post_admission = __esm({
|
|
|
19649
19447
|
init_activation_ledger_topology();
|
|
19650
19448
|
init_engine_material();
|
|
19651
19449
|
init_session_identity();
|
|
19450
|
+
init_role_run_relocation();
|
|
19652
19451
|
init_host_contracts();
|
|
19653
19452
|
init_case_dossier_delivery();
|
|
19654
19453
|
init_engine_detour_usage();
|
|
@@ -21542,7 +21341,7 @@ __export(public_role_summons_exports, {
|
|
|
21542
21341
|
withEphemeralReviewerWorktree: () => withEphemeralReviewerWorktree
|
|
21543
21342
|
});
|
|
21544
21343
|
import { execFile as execFile3 } from "node:child_process";
|
|
21545
|
-
import { existsSync as
|
|
21344
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
21546
21345
|
import { mkdir as mkdir4, mkdtemp as mkdtemp4, realpath as realpath6, rm as rm5 } from "node:fs/promises";
|
|
21547
21346
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
21548
21347
|
import { join as join35, relative as relative3, sep as sep5 } from "node:path";
|
|
@@ -21569,7 +21368,7 @@ function parentDir(path) {
|
|
|
21569
21368
|
function walkPackageRoot(start) {
|
|
21570
21369
|
let dir = start;
|
|
21571
21370
|
for (let i = 0; i < 12; i += 1) {
|
|
21572
|
-
if (
|
|
21371
|
+
if (existsSync10(join35(dir, "package.json")) && existsSync10(join35(dir, "souls"))) {
|
|
21573
21372
|
return dir;
|
|
21574
21373
|
}
|
|
21575
21374
|
const parent = parentDir(dir);
|
|
@@ -22272,7 +22071,7 @@ import { randomUUID as randomUUID10 } from "node:crypto";
|
|
|
22272
22071
|
// src/role-envelope.ts
|
|
22273
22072
|
init_engine_detour();
|
|
22274
22073
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
22275
|
-
import { appendFile as appendFile3, mkdir as mkdir6, writeFile as
|
|
22074
|
+
import { appendFile as appendFile3, mkdir as mkdir6, writeFile as writeFile11 } from "node:fs/promises";
|
|
22276
22075
|
import { createServer } from "node:net";
|
|
22277
22076
|
import { dirname as dirname21, join as join41 } from "node:path";
|
|
22278
22077
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
@@ -22370,7 +22169,7 @@ async function requireGatekeeperPass(options) {
|
|
|
22370
22169
|
}
|
|
22371
22170
|
|
|
22372
22171
|
// src/host-native-method.ts
|
|
22373
|
-
import { access as access4, lstat as lstat7, mkdir as mkdir5, readdir as
|
|
22172
|
+
import { access as access4, lstat as lstat7, mkdir as mkdir5, readdir as readdir8, readFile as readFile19, readlink, realpath as realpath7, symlink } from "node:fs/promises";
|
|
22374
22173
|
import { basename as basename9, dirname as dirname18, join as join36 } from "node:path";
|
|
22375
22174
|
var packagedMethodsDir = (root) => join36(root, "resources", "methods");
|
|
22376
22175
|
function hostMethodSkills(methods) {
|
|
@@ -22380,16 +22179,16 @@ function hostMethodSkills(methods) {
|
|
|
22380
22179
|
return name ? [Object.freeze({ name })] : [];
|
|
22381
22180
|
}));
|
|
22382
22181
|
}
|
|
22383
|
-
var
|
|
22182
|
+
var isEnoent3 = (error) => error.code === "ENOENT";
|
|
22384
22183
|
async function packagedMethodSkillNames(packagedMethodsRealpath) {
|
|
22385
|
-
const entries = await
|
|
22184
|
+
const entries = await readdir8(packagedMethodsRealpath, { withFileTypes: true });
|
|
22386
22185
|
const names = [];
|
|
22387
22186
|
for (const entry of entries) {
|
|
22388
22187
|
if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
|
|
22389
22188
|
try {
|
|
22390
22189
|
await access4(join36(packagedMethodsRealpath, entry.name, "SKILL.md"));
|
|
22391
22190
|
} catch (error) {
|
|
22392
|
-
if (
|
|
22191
|
+
if (isEnoent3(error)) continue;
|
|
22393
22192
|
throw error;
|
|
22394
22193
|
}
|
|
22395
22194
|
names.push(entry.name);
|
|
@@ -22400,12 +22199,12 @@ async function packagedSkillFileBytes(skillDir) {
|
|
|
22400
22199
|
try {
|
|
22401
22200
|
await access4(join36(skillDir, "SKILL.md"));
|
|
22402
22201
|
} catch (error) {
|
|
22403
|
-
if (
|
|
22202
|
+
if (isEnoent3(error)) return void 0;
|
|
22404
22203
|
throw error;
|
|
22405
22204
|
}
|
|
22406
22205
|
const files = /* @__PURE__ */ new Map();
|
|
22407
22206
|
async function walk(dir, prefix) {
|
|
22408
|
-
const entries = await
|
|
22207
|
+
const entries = await readdir8(dir, { withFileTypes: true });
|
|
22409
22208
|
for (const entry of entries) {
|
|
22410
22209
|
const rel = prefix === "" ? entry.name : `${prefix}/${entry.name}`;
|
|
22411
22210
|
const full = join36(dir, entry.name);
|
|
@@ -22414,7 +22213,7 @@ async function packagedSkillFileBytes(skillDir) {
|
|
|
22414
22213
|
continue;
|
|
22415
22214
|
}
|
|
22416
22215
|
if (entry.isFile()) {
|
|
22417
|
-
files.set(rel, await
|
|
22216
|
+
files.set(rel, await readFile19(full));
|
|
22418
22217
|
}
|
|
22419
22218
|
}
|
|
22420
22219
|
}
|
|
@@ -22425,9 +22224,9 @@ async function catalogPublishesPackagedSkill(catalogSkillDir, required) {
|
|
|
22425
22224
|
for (const [rel, bytes] of required) {
|
|
22426
22225
|
let other;
|
|
22427
22226
|
try {
|
|
22428
|
-
other = await
|
|
22227
|
+
other = await readFile19(join36(catalogSkillDir, rel));
|
|
22429
22228
|
} catch (error) {
|
|
22430
|
-
if (
|
|
22229
|
+
if (isEnoent3(error)) return false;
|
|
22431
22230
|
throw error;
|
|
22432
22231
|
}
|
|
22433
22232
|
if (!bytes.equals(other)) return false;
|
|
@@ -22441,7 +22240,7 @@ async function isCompatibleMethodCatalog(link, packagedMethodsRealpath) {
|
|
|
22441
22240
|
try {
|
|
22442
22241
|
resolved = await realpath7(link);
|
|
22443
22242
|
} catch (error) {
|
|
22444
|
-
if (
|
|
22243
|
+
if (isEnoent3(error)) return false;
|
|
22445
22244
|
throw error;
|
|
22446
22245
|
}
|
|
22447
22246
|
if (resolved === packagedMethodsRealpath) return true;
|
|
@@ -22462,7 +22261,7 @@ async function installWorkspaceMethodSkills(cwd, packageRoot) {
|
|
|
22462
22261
|
await lstat7(link);
|
|
22463
22262
|
present = true;
|
|
22464
22263
|
} catch (error) {
|
|
22465
|
-
if (!
|
|
22264
|
+
if (!isEnoent3(error)) throw error;
|
|
22466
22265
|
present = false;
|
|
22467
22266
|
}
|
|
22468
22267
|
if (present) {
|
|
@@ -22924,18 +22723,18 @@ init_collector_evidence();
|
|
|
22924
22723
|
init_collector_github();
|
|
22925
22724
|
|
|
22926
22725
|
// src/collector-handbook.ts
|
|
22927
|
-
import { readFile as
|
|
22726
|
+
import { readFile as readFile20 } from "node:fs/promises";
|
|
22928
22727
|
import { join as join38, sep as sep6 } from "node:path";
|
|
22929
22728
|
|
|
22930
22729
|
// src/atomic-write.ts
|
|
22931
22730
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
22932
|
-
import { rename as rename3, rm as rm6, writeFile as
|
|
22731
|
+
import { rename as rename3, rm as rm6, writeFile as writeFile10 } from "node:fs/promises";
|
|
22933
22732
|
import { dirname as dirname19, join as join37 } from "node:path";
|
|
22934
22733
|
async function writeFileAtomically(destination, contents) {
|
|
22935
22734
|
const parent = dirname19(destination);
|
|
22936
22735
|
const temporary = join37(parent, `.atomic-write-${randomUUID7()}.tmp`);
|
|
22937
22736
|
try {
|
|
22938
|
-
await
|
|
22737
|
+
await writeFile10(temporary, contents);
|
|
22939
22738
|
await rename3(temporary, destination);
|
|
22940
22739
|
} catch (error) {
|
|
22941
22740
|
await rm6(temporary, { force: true }).catch(() => void 0);
|
|
@@ -23087,7 +22886,7 @@ function createCollectorHandbookStore(input) {
|
|
|
23087
22886
|
ensureRealDirectoryTree(input.ledgerHome, parentDir2);
|
|
23088
22887
|
assertLedgerFileInsideHome(path, input.ledgerHome);
|
|
23089
22888
|
try {
|
|
23090
|
-
const body = await
|
|
22889
|
+
const body = await readFile20(path, "utf8");
|
|
23091
22890
|
assertHandbookBudget(body, "\u6B63\u6587");
|
|
23092
22891
|
return body;
|
|
23093
22892
|
} catch (error) {
|
|
@@ -25399,7 +25198,7 @@ init_sitian_facade();
|
|
|
25399
25198
|
init_submission_errors();
|
|
25400
25199
|
init_submission_errors();
|
|
25401
25200
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
25402
|
-
import { existsSync as
|
|
25201
|
+
import { existsSync as existsSync11, lstatSync as lstatSync3, readdirSync as readdirSync3, readFileSync as readFileSync5, rmdirSync, rmSync } from "node:fs";
|
|
25403
25202
|
import { resolve as resolve17 } from "node:path";
|
|
25404
25203
|
var WORKER_SUBMISSION_GATE_RECORD_KIND = WORKER_SUBMISSION_GATE_KIND;
|
|
25405
25204
|
var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
|
|
@@ -25430,7 +25229,7 @@ function statusOf(error) {
|
|
|
25430
25229
|
return typeof error === "object" && error !== null && "status" in error ? error.status : void 0;
|
|
25431
25230
|
}
|
|
25432
25231
|
function tryGetAll(file, key) {
|
|
25433
|
-
if (!
|
|
25232
|
+
if (!existsSync11(file)) return [];
|
|
25434
25233
|
try {
|
|
25435
25234
|
const out = gitFile(file, ["--get-all", key]);
|
|
25436
25235
|
return out.length === 0 ? [] : out.split("\n");
|
|
@@ -25440,7 +25239,7 @@ function tryGetAll(file, key) {
|
|
|
25440
25239
|
}
|
|
25441
25240
|
}
|
|
25442
25241
|
function ownedHook(path) {
|
|
25443
|
-
if (!
|
|
25242
|
+
if (!existsSync11(path)) return false;
|
|
25444
25243
|
return readFileSync5(path, "utf8").includes(HOOK_MARKER);
|
|
25445
25244
|
}
|
|
25446
25245
|
function escapeGitConfigValueRegex(value) {
|
|
@@ -25467,11 +25266,11 @@ function rmOwnedDir(dir) {
|
|
|
25467
25266
|
const hookPath = resolve17(dir, HOOK_FILE);
|
|
25468
25267
|
if (!ownedHook(hookPath)) return;
|
|
25469
25268
|
rmSync(hookPath, { force: true });
|
|
25470
|
-
if (
|
|
25269
|
+
if (existsSync11(dir) && readdirSync3(dir).length === 0) rmdirSync(dir);
|
|
25471
25270
|
}
|
|
25472
25271
|
function linkedGitDirs(commonDir) {
|
|
25473
25272
|
const root = resolve17(commonDir, "worktrees");
|
|
25474
|
-
if (!
|
|
25273
|
+
if (!existsSync11(root)) return [];
|
|
25475
25274
|
return readdirSync3(root).map((name) => resolve17(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
|
|
25476
25275
|
}
|
|
25477
25276
|
function uninstallPackageWorkerHooks(cwd) {
|
|
@@ -27703,7 +27502,7 @@ async function prepareRoleEnvelope(options) {
|
|
|
27703
27502
|
await mkdir6(dirname21(sessionFile), { recursive: true });
|
|
27704
27503
|
if (request.continuation.kind !== "resume") {
|
|
27705
27504
|
try {
|
|
27706
|
-
await
|
|
27505
|
+
await writeFile11(
|
|
27707
27506
|
sessionFile,
|
|
27708
27507
|
`${JSON.stringify({
|
|
27709
27508
|
type: "session",
|
|
@@ -28243,11 +28042,11 @@ async function prepareRoleEnvelope(options) {
|
|
|
28243
28042
|
}
|
|
28244
28043
|
|
|
28245
28044
|
// src/role-runtime-dependencies.ts
|
|
28246
|
-
import { readFile as
|
|
28045
|
+
import { readFile as readFile23 } from "node:fs/promises";
|
|
28247
28046
|
import { join as join42 } from "node:path";
|
|
28248
28047
|
|
|
28249
28048
|
// src/canonical-skill-binding.ts
|
|
28250
|
-
import { readFile as
|
|
28049
|
+
import { readFile as readFile21, realpath as realpath8 } from "node:fs/promises";
|
|
28251
28050
|
import { homedir } from "node:os";
|
|
28252
28051
|
import { dirname as dirname22, resolve as resolve18 } from "node:path";
|
|
28253
28052
|
import { stripFrontmatter } from "@earendil-works/pi-coding-agent";
|
|
@@ -28280,7 +28079,7 @@ async function loadCanonicalSkillBinding(name) {
|
|
|
28280
28079
|
let raw;
|
|
28281
28080
|
try {
|
|
28282
28081
|
path = await realpath8(configuredPath);
|
|
28283
|
-
raw = await
|
|
28082
|
+
raw = await readFile21(path, "utf8");
|
|
28284
28083
|
} catch (error) {
|
|
28285
28084
|
throw new CanonicalSkillUnavailableError(name, configuredPath, error);
|
|
28286
28085
|
}
|
|
@@ -28319,7 +28118,7 @@ init_doctor_evidence();
|
|
|
28319
28118
|
// src/navigator-work-context.ts
|
|
28320
28119
|
init_doctor_evidence();
|
|
28321
28120
|
init_host_contracts();
|
|
28322
|
-
import { readFile as
|
|
28121
|
+
import { readFile as readFile22 } from "node:fs/promises";
|
|
28323
28122
|
import { resolve as resolve19 } from "node:path";
|
|
28324
28123
|
init_notary_source_run();
|
|
28325
28124
|
init_packaged_role_registry();
|
|
@@ -28332,7 +28131,7 @@ function navigatorInputReference(getFlag, role) {
|
|
|
28332
28131
|
}
|
|
28333
28132
|
async function loadNavigatorWorkContext(options) {
|
|
28334
28133
|
const reference = navigatorInputReference(options.getFlag, options.role);
|
|
28335
|
-
const input = reference === void 0 || options.role === "doctor" || options.role === "notary" ? void 0 : await
|
|
28134
|
+
const input = reference === void 0 || options.role === "doctor" || options.role === "notary" ? void 0 : await readFile22(reference, "utf8");
|
|
28336
28135
|
const subjectRoot = subjectPath(reference ?? options.context.sessionManager.getSessionDir(), options.context.cwd);
|
|
28337
28136
|
let subjectKey = reference === void 0 ? subjectRoot : navigatorSubjectKeyForInput(subjectRoot, reference, options.context.cwd);
|
|
28338
28137
|
let subject = input ?? `work subject: ${subjectKey}`;
|
|
@@ -28389,7 +28188,7 @@ async function loadNavigatorWorkContext(options) {
|
|
|
28389
28188
|
let authorityMaterial;
|
|
28390
28189
|
for (const path of authorityFiles) {
|
|
28391
28190
|
try {
|
|
28392
|
-
const content = await
|
|
28191
|
+
const content = await readFile22(path, "utf8");
|
|
28393
28192
|
if (content.trim() !== "") {
|
|
28394
28193
|
authorityMaterial = content;
|
|
28395
28194
|
break;
|
|
@@ -28458,12 +28257,12 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
28458
28257
|
loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
|
|
28459
28258
|
loadJudgeSoul: () => loadMainRoleSessionMaterials("judge"),
|
|
28460
28259
|
loadFixerSoul: () => loadMainRoleSessionMaterials("fixer"),
|
|
28461
|
-
loadFixPacket: (path) =>
|
|
28260
|
+
loadFixPacket: (path) => readFile23(path, "utf8"),
|
|
28462
28261
|
loadCoderSoul: () => loadMainRoleSessionMaterials("coder"),
|
|
28463
|
-
loadCoderTask: (path) =>
|
|
28262
|
+
loadCoderTask: (path) => readFile23(path, "utf8"),
|
|
28464
28263
|
loadReviewerSoul: () => loadMainRoleSessionMaterials("reviewer"),
|
|
28465
28264
|
loadCollectorSoul: () => loadMainRoleSessionMaterials("collector"),
|
|
28466
|
-
loadCollectorHandbookSeed: () =>
|
|
28265
|
+
loadCollectorHandbookSeed: () => readFile23(collectorHandbookSeedPath, "utf8"),
|
|
28467
28266
|
createCollectorTransport: () => createGhCollectorGitHubTransport(),
|
|
28468
28267
|
loadDoctorSoul: () => loadMainRoleSessionMaterials("doctor"),
|
|
28469
28268
|
loadDoctorCase,
|
|
@@ -28478,7 +28277,7 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
28478
28277
|
loadSecretariatSoul: () => loadMainRoleSessionMaterials("secretariat"),
|
|
28479
28278
|
loadNotarySourceRun: loadNotarySourceRunLocator,
|
|
28480
28279
|
loadMergerSoul: () => loadMainRoleSessionMaterials("merger"),
|
|
28481
|
-
loadMergerInput: async (path) => JSON.parse(await
|
|
28280
|
+
loadMergerInput: async (path) => JSON.parse(await readFile23(path, "utf8")),
|
|
28482
28281
|
async loadCanonicalSkillBinding(name) {
|
|
28483
28282
|
if (name === "tdd") {
|
|
28484
28283
|
return loadPackagedCanonicalSkillBinding(packageRoot, "tdd");
|
|
@@ -28504,7 +28303,7 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
28504
28303
|
authority: options.authority,
|
|
28505
28304
|
invocationId: options.invocationId,
|
|
28506
28305
|
loadSoul: () => loadMainRoleSessionMaterials("navigator"),
|
|
28507
|
-
loadRoutePlaybook: () =>
|
|
28306
|
+
loadRoutePlaybook: () => readFile23(navigatorRoutePlaybookPath, "utf8"),
|
|
28508
28307
|
loadRoleHelp: async (role) => formatNavigatorRoleHelp(role),
|
|
28509
28308
|
createSession: navigatorSessionFactory,
|
|
28510
28309
|
...options.contextError === void 0 ? {} : { contextError: options.contextError },
|