@akagilnc/pi-workflow-roles 0.1.4992 → 0.1.4996
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 +71 -64
- package/dist/analyst-ledger.js +13 -23
- package/dist/analyst-metric-families/acceptance-success-rework.js +1 -1
- package/dist/analyst-metric-families/round-timeline.js +2 -9
- package/dist/headless-host/production-host.js +71 -64
- package/dist/notary-source-run.js +14 -2
- package/dist/pi/role-turn-host.js +7 -10
- package/dist/public-cli/main.js +66 -62
- package/dist/public-cli/post-admission.js +1 -1
- package/dist/public-cli/run-lifecycle.js +31 -22
- package/dist/public-role-summons.js +3 -1
- package/package.json +1 -1
- package/src/analyst-ledger.ts +12 -23
- package/src/analyst-metric-families/acceptance-success-rework.ts +1 -1
- package/src/analyst-metric-families/round-timeline.ts +2 -8
- package/src/analyst-page.ts +1 -0
- package/src/collector-role.ts +4 -1
- package/src/notary-source-run.ts +13 -2
- package/src/pi/role-turn-host.ts +7 -9
- package/src/public-cli/post-admission.ts +1 -1
- package/src/public-cli/run-lifecycle.ts +41 -24
- package/src/public-role-summons.ts +2 -0
|
@@ -312,9 +312,7 @@ function parseCurrentCourtState(raw: unknown): CurrentCourtState | undefined {
|
|
|
312
312
|
};
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
-
async function
|
|
316
|
-
runDirectory: string,
|
|
317
|
-
): Promise<RoleRunStateDisk | undefined> {
|
|
315
|
+
async function readRoleRunStateRaw(runDirectory: string): Promise<unknown | undefined> {
|
|
318
316
|
let raw: unknown;
|
|
319
317
|
try {
|
|
320
318
|
raw = JSON.parse(await readFile(join(runDirectory, RUN_STATE_FILE), "utf8"));
|
|
@@ -328,16 +326,26 @@ async function readRoleRunStateDisk(
|
|
|
328
326
|
if (errorCodeOf(error) === "ENOENT") return undefined;
|
|
329
327
|
throw error;
|
|
330
328
|
}
|
|
329
|
+
return raw;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function parseRoleRunIdentity(raw: unknown, runDirectory: string): {
|
|
333
|
+
readonly runId: string;
|
|
334
|
+
readonly role: RoleRunRecord["role"];
|
|
335
|
+
readonly bookKey: string;
|
|
336
|
+
readonly runDirectory: string;
|
|
337
|
+
readonly state: RoleRunState;
|
|
338
|
+
} {
|
|
331
339
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
332
|
-
|
|
340
|
+
throw new TypeError("Invalid run-state.json");
|
|
333
341
|
}
|
|
334
342
|
const record = raw as Record<string, unknown>;
|
|
335
343
|
if (typeof record.runId !== "string" || record.runId.trim() === "") {
|
|
336
|
-
|
|
344
|
+
throw new TypeError("Invalid run-state.json");
|
|
337
345
|
}
|
|
338
346
|
const role = typeof record.role === "string" ? packagedRoleMetadata(record.role)?.role : undefined;
|
|
339
347
|
if (role === undefined) {
|
|
340
|
-
|
|
348
|
+
throw new TypeError("Invalid run-state.json");
|
|
341
349
|
}
|
|
342
350
|
if (
|
|
343
351
|
record.state !== "admitted" &&
|
|
@@ -345,12 +353,28 @@ async function readRoleRunStateDisk(
|
|
|
345
353
|
record.state !== "resumable" &&
|
|
346
354
|
record.state !== "terminal"
|
|
347
355
|
) {
|
|
348
|
-
|
|
356
|
+
throw new TypeError("Invalid run-state.json");
|
|
349
357
|
}
|
|
350
|
-
if (typeof record.bookKey !== "string")
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
358
|
+
if (typeof record.bookKey !== "string") throw new TypeError("Invalid run-state.json");
|
|
359
|
+
return {
|
|
360
|
+
runId: record.runId,
|
|
361
|
+
role,
|
|
362
|
+
state: record.state,
|
|
363
|
+
bookKey: record.bookKey,
|
|
364
|
+
runDirectory,
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
async function readRoleRunStateDisk(
|
|
369
|
+
runDirectory: string,
|
|
370
|
+
): Promise<RoleRunStateDisk | undefined> {
|
|
371
|
+
const raw = await readRoleRunStateRaw(runDirectory);
|
|
372
|
+
if (raw === undefined) return undefined;
|
|
373
|
+
const identity = parseRoleRunIdentity(raw, runDirectory);
|
|
374
|
+
const record = raw as Record<string, unknown>;
|
|
375
|
+
if (typeof record.projectRoot !== "string") throw new TypeError("Invalid run-state.json");
|
|
376
|
+
if (typeof record.sessionDirectory !== "string") throw new TypeError("Invalid run-state.json");
|
|
377
|
+
if (typeof record.admittedRequestPath !== "string") throw new TypeError("Invalid run-state.json");
|
|
354
378
|
const storedRunDirectory =
|
|
355
379
|
typeof record.runDirectory === "string" && record.runDirectory.trim() !== ""
|
|
356
380
|
? record.runDirectory
|
|
@@ -389,10 +413,10 @@ async function readRoleRunStateDisk(
|
|
|
389
413
|
: undefined;
|
|
390
414
|
const currentCourt = parseCurrentCourtState(record.currentCourt);
|
|
391
415
|
return {
|
|
392
|
-
runId:
|
|
393
|
-
role,
|
|
394
|
-
state:
|
|
395
|
-
bookKey:
|
|
416
|
+
runId: identity.runId,
|
|
417
|
+
role: identity.role,
|
|
418
|
+
state: identity.state,
|
|
419
|
+
bookKey: identity.bookKey,
|
|
396
420
|
projectRoot: record.projectRoot,
|
|
397
421
|
runDirectory: runDir,
|
|
398
422
|
admittedRequestPath: rewriteRunDirectoryPathValue(
|
|
@@ -491,15 +515,8 @@ export async function readRoleRunIdentity(
|
|
|
491
515
|
}
|
|
492
516
|
| undefined
|
|
493
517
|
> {
|
|
494
|
-
const
|
|
495
|
-
|
|
496
|
-
return {
|
|
497
|
-
runId: disk.runId,
|
|
498
|
-
role: disk.role,
|
|
499
|
-
bookKey: disk.bookKey,
|
|
500
|
-
runDirectory: disk.runDirectory,
|
|
501
|
-
state: disk.state,
|
|
502
|
-
};
|
|
518
|
+
const raw = await readRoleRunStateRaw(runDirectory);
|
|
519
|
+
return raw === undefined ? undefined : parseRoleRunIdentity(raw, runDirectory);
|
|
503
520
|
}
|
|
504
521
|
|
|
505
522
|
export async function markRunAdmitted(
|
|
@@ -352,10 +352,12 @@ export async function summonPublicRole(
|
|
|
352
352
|
loadCredentialProviders,
|
|
353
353
|
loadPublicCliConfig,
|
|
354
354
|
resolveEffectiveSeat,
|
|
355
|
+
validatePublicCliConfigAxes,
|
|
355
356
|
} = await import("./public-cli/config.ts");
|
|
356
357
|
const credentials =
|
|
357
358
|
options.credentials ?? (await loadCredentialProviders(agentDir));
|
|
358
359
|
const config = await loadPublicCliConfig(home);
|
|
360
|
+
validatePublicCliConfigAxes(config, packageRoot);
|
|
359
361
|
// Nested summons: officer seat only (flag>seat>default pi). #178 order below.
|
|
360
362
|
const resolvedSeat = resolveEffectiveSeat(config, options.role, credentials);
|
|
361
363
|
const inheritedSelection = options.model === undefined
|