@akagilnc/pi-workflow-roles 0.1.5368 → 0.1.5375
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 +719 -776
- package/dist/activation-ledger-git.js +2 -2
- package/dist/activation-ledger-topology.js +1 -7
- package/dist/analyst-entry.js +4 -8
- package/dist/analyst-gate-cycles-read.js +3 -11
- package/dist/analyst-index.js +3 -9
- package/dist/analyst-ledger.js +1 -11
- package/dist/analyst-metric-families/acceptance-success-rework.js +1 -3
- package/dist/analyst-metric-families/round-timeline.js +1 -3
- package/dist/analyst-page.js +2 -2
- package/dist/archivist-record-topology.js +2 -2
- package/dist/audit-escalation.js +2 -1
- package/dist/auditor-soul.js +2 -1
- package/dist/collector-config.js +6 -8
- package/dist/compliance-transport.js +2 -1
- package/dist/countersign-contracts.js +2 -1
- package/dist/diarist-contracts.js +3 -2
- package/dist/doctor-contracts.js +1 -3
- package/dist/doctor-evidence.js +7 -8
- package/dist/dossier-resolution.js +1 -3
- package/dist/engine-detour-usage.js +1 -3
- package/dist/gatekeeper-role.js +2 -9
- package/dist/gleaner-left-contracts.js +2 -1
- package/dist/headless-host/description.js +14 -17
- package/dist/headless-host/production-host.js +721 -780
- package/dist/host-session-record.js +3 -2
- package/dist/inspector-contracts.js +2 -1
- package/dist/ledger-session-read.js +1 -3
- package/dist/merger-contracts.js +9 -9
- package/dist/migrate-book-topology.js +348 -314
- package/dist/navigator-attendance.js +9 -11
- package/dist/navigator-invocation-identity.js +3 -2
- package/dist/navigator-public-session.js +3 -5
- package/dist/navigator-session-contracts.js +8 -10
- package/dist/navigator-work-base.js +5 -8
- package/dist/notary-contracts.js +3 -5
- package/dist/package-contracts/auditor-output.js +1 -3
- package/dist/package-contracts/fixer-packet.js +3 -6
- package/dist/package-contracts/gatekeeper-output.js +1 -3
- package/dist/package-contracts/navigator-output.js +8 -8
- package/dist/package-contracts/terminating-infrastructure.js +5 -9
- package/dist/package-contracts/terminating-tools.js +4 -3
- package/dist/public-cli/analyst-run.js +3 -2
- package/dist/public-cli/auto-resume.js +3 -8
- package/dist/public-cli/cli.js +9 -8
- package/dist/public-cli/config.js +8 -11
- package/dist/public-cli/countersign-run.js +1 -3
- package/dist/public-cli/host-providers.js +7 -14
- package/dist/public-cli/instruction-seat-run.js +4 -3
- package/dist/public-cli/invocation.js +9 -8
- package/dist/public-cli/main.js +1531 -1567
- package/dist/public-cli/post-admission.js +4 -3
- package/dist/public-cli/run-lifecycle.js +14 -26
- package/dist/public-cli/settlement.js +10 -26
- package/dist/public-role-summons.js +3 -2
- package/dist/receipt-delivery-policy.js +1 -3
- package/dist/role-run-placement.js +3 -5
- package/dist/role-run-relocation.js +12 -19
- package/dist/run-terminal-artifacts.js +1 -11
- package/dist/run-ticket-number.js +2 -4
- package/dist/session-assistant-usage.js +2 -1
- package/dist/session-dialogue.js +1 -14
- package/dist/sitian-reader.js +2 -4
- package/dist/submission-correctable-error.js +2 -1
- package/dist/submission-errors.js +2 -1
- package/dist/submission-gate.js +2 -1
- package/dist/submission-ledger.js +4 -5
- package/dist/ticket-provenance-contracts.js +1 -3
- package/dist/ticket-provenance.js +2 -1
- package/dist/typed-provider-http.js +4 -7
- package/dist/unknown-value.js +28 -0
- package/dist/user-dialogue-stdin.js +2 -1
- package/package.json +1 -1
- package/src/acp-host/role-turn-host.ts +4 -2
- package/src/activation-ledger-git.ts +3 -2
- package/src/activation-ledger-topology.ts +4 -12
- package/src/analyst-entry.ts +3 -11
- package/src/analyst-gate-cycles-read.ts +3 -15
- package/src/analyst-index.ts +3 -13
- package/src/analyst-ledger.ts +2 -16
- package/src/analyst-metric-families/acceptance-success-rework.ts +2 -4
- package/src/analyst-metric-families/round-timeline.ts +2 -4
- package/src/analyst-page.ts +2 -2
- package/src/archivist-record-topology.ts +2 -2
- package/src/audit-escalation.ts +2 -1
- package/src/auditor-soul.ts +3 -1
- package/src/book-topology-migration-placement.ts +5 -16
- package/src/book-topology-migrators-t11.ts +16 -15
- package/src/book-topology-mixed-volume-migrators.ts +3 -6
- package/src/book-topology-record-class-migrators.ts +7 -10
- package/src/book-topology-runs-migrator.ts +4 -3
- package/src/collector-config.ts +7 -9
- package/src/compliance-transport.ts +2 -1
- package/src/countersign-contracts.ts +2 -1
- package/src/diarist-contracts.ts +3 -2
- package/src/doctor-contracts.ts +3 -1
- package/src/doctor-evidence.ts +8 -7
- package/src/doctor-role.ts +4 -2
- package/src/dossier-resolution.ts +2 -4
- package/src/engine-detour-tool.ts +0 -2
- package/src/engine-detour-usage.ts +2 -4
- package/src/external-host-turn-loop.ts +3 -1
- package/src/factory-board.ts +1 -8
- package/src/gatekeeper-role.ts +2 -10
- package/src/gleaner-left-contracts.ts +3 -1
- package/src/headless-host/description.ts +15 -18
- package/src/headless-host/role-turn-host.ts +10 -9
- package/src/host-session-record.ts +4 -2
- package/src/inspector-contracts.ts +2 -1
- package/src/ledger-session-read.ts +2 -5
- package/src/merger-contracts.ts +10 -9
- package/src/navigator-attendance.ts +10 -12
- package/src/navigator-invocation-identity.ts +3 -2
- package/src/navigator-public-session.ts +4 -6
- package/src/navigator-session-contracts.ts +8 -11
- package/src/navigator-work-base.ts +5 -8
- package/src/navigator-work-context.ts +2 -1
- package/src/notary-contracts.ts +4 -6
- package/src/oauth-keepalive.ts +5 -18
- package/src/package-contracts/auditor-output.ts +2 -4
- package/src/package-contracts/fixer-packet.ts +4 -6
- package/src/package-contracts/gatekeeper-output.ts +2 -4
- package/src/package-contracts/judge-output.ts +0 -1
- package/src/package-contracts/navigator-output.ts +8 -8
- package/src/package-contracts/terminating-infrastructure.ts +6 -20
- package/src/package-contracts/terminating-tools.ts +8 -12
- package/src/pi/adapter.ts +0 -1
- package/src/pi/role-turn-host.ts +0 -1
- package/src/public-cli/analyst-run.ts +4 -2
- package/src/public-cli/auto-resume.ts +4 -11
- package/src/public-cli/cli.ts +10 -10
- package/src/public-cli/config.ts +8 -27
- package/src/public-cli/countersign-run.ts +2 -4
- package/src/public-cli/host-providers.ts +10 -27
- package/src/public-cli/instruction-seat-run.ts +5 -3
- package/src/public-cli/invocation.ts +11 -10
- package/src/public-cli/post-admission.ts +5 -3
- package/src/public-cli/run-lifecycle.ts +20 -41
- package/src/public-cli/settlement.ts +11 -33
- package/src/public-role-summons.ts +4 -3
- package/src/receipt-delivery-policy.ts +1 -4
- package/src/reviewer-role.ts +0 -1
- package/src/role-envelope.ts +5 -3
- package/src/role-run-placement.ts +4 -10
- package/src/role-run-relocation.ts +13 -23
- package/src/role-runtime.ts +9 -15
- package/src/run-terminal-artifacts.ts +2 -16
- package/src/run-ticket-number.ts +4 -10
- package/src/session-assistant-usage.ts +3 -1
- package/src/session-dialogue.ts +1 -4
- package/src/session-identity.ts +0 -1
- package/src/sitian-reader.ts +2 -4
- package/src/submission-correctable-error.ts +3 -1
- package/src/submission-errors.ts +2 -1
- package/src/submission-gate.ts +3 -1
- package/src/submission-ledger.ts +5 -6
- package/src/ticket-provenance-contracts.ts +1 -4
- package/src/ticket-provenance.ts +3 -1
- package/src/ticket-snapshot.ts +2 -4
- package/src/ticket-trajectory.ts +1 -8
- package/src/typed-provider-http.ts +5 -15
- package/src/unknown-value.ts +34 -0
- package/src/user-dialogue-stdin.ts +3 -1
- package/src/worker-role.ts +2 -5
- package/src/worker-submission-gates.ts +5 -7
|
@@ -278,6 +278,30 @@ var init_open_tool_schema = __esm({
|
|
|
278
278
|
}
|
|
279
279
|
});
|
|
280
280
|
|
|
281
|
+
// src/unknown-value.ts
|
|
282
|
+
import { Guard } from "typebox/guard";
|
|
283
|
+
function isRecord(value) {
|
|
284
|
+
return Guard.IsObjectNotArray(value);
|
|
285
|
+
}
|
|
286
|
+
function errnoCode(error) {
|
|
287
|
+
return error !== null && typeof error === "object" && "code" in error && typeof error.code === "string" ? error.code : void 0;
|
|
288
|
+
}
|
|
289
|
+
function errorText(error) {
|
|
290
|
+
return error instanceof Error ? error.message : String(error);
|
|
291
|
+
}
|
|
292
|
+
function isEnoent(error) {
|
|
293
|
+
return error instanceof Error && errnoCode(error) === "ENOENT";
|
|
294
|
+
}
|
|
295
|
+
function isMissingPathError(error) {
|
|
296
|
+
const code = errnoCode(error);
|
|
297
|
+
return error instanceof Error && (code === "ENOENT" || code === "ENOTDIR");
|
|
298
|
+
}
|
|
299
|
+
var init_unknown_value = __esm({
|
|
300
|
+
"src/unknown-value.ts"() {
|
|
301
|
+
"use strict";
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
|
|
281
305
|
// src/package-contracts/terminating-infrastructure.ts
|
|
282
306
|
import { Type as Type2 } from "typebox";
|
|
283
307
|
function withTerminatingOutputDeclarations(schema) {
|
|
@@ -298,15 +322,10 @@ function withTerminatingOutputDeclarations(schema) {
|
|
|
298
322
|
return object;
|
|
299
323
|
}
|
|
300
324
|
function isInfrastructureFailureDeclaration(parameters) {
|
|
301
|
-
if (
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
if (!Object.hasOwn(record4, INFRASTRUCTURE_FAILURE_DECLARATION_KEY)) return false;
|
|
306
|
-
const declaration = record4[INFRASTRUCTURE_FAILURE_DECLARATION_KEY];
|
|
307
|
-
if (declaration === null || typeof declaration !== "object" || Array.isArray(declaration)) {
|
|
308
|
-
return false;
|
|
309
|
-
}
|
|
325
|
+
if (!isRecord(parameters)) return false;
|
|
326
|
+
if (!Object.hasOwn(parameters, INFRASTRUCTURE_FAILURE_DECLARATION_KEY)) return false;
|
|
327
|
+
const declaration = parameters[INFRASTRUCTURE_FAILURE_DECLARATION_KEY];
|
|
328
|
+
if (!isRecord(declaration)) return false;
|
|
310
329
|
const diagnostic = declaration[INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY];
|
|
311
330
|
return typeof diagnostic === "string" && diagnostic.trim().length > 0;
|
|
312
331
|
}
|
|
@@ -338,6 +357,7 @@ var INFRASTRUCTURE_FAILURE_DECLARATION_KEY, INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KE
|
|
|
338
357
|
var init_terminating_infrastructure = __esm({
|
|
339
358
|
"src/package-contracts/terminating-infrastructure.ts"() {
|
|
340
359
|
"use strict";
|
|
360
|
+
init_unknown_value();
|
|
341
361
|
INFRASTRUCTURE_FAILURE_DECLARATION_KEY = "infrastructureFailure";
|
|
342
362
|
INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY = "diagnostic";
|
|
343
363
|
infrastructureFailureNested = Type2.Object(
|
|
@@ -369,6 +389,7 @@ var init_gatekeeper_output = __esm({
|
|
|
369
389
|
"use strict";
|
|
370
390
|
init_open_tool_schema();
|
|
371
391
|
init_terminating_infrastructure();
|
|
392
|
+
init_unknown_value();
|
|
372
393
|
GATEKEEPER_OUTPUT_TOOL_NAME = "ak_gatekeeper_output";
|
|
373
394
|
gatekeeperDecisionSchema = openToolObject(
|
|
374
395
|
Type3.Object({
|
|
@@ -402,18 +423,17 @@ import { Type as Type4 } from "typebox";
|
|
|
402
423
|
function projectLawfulNavigatorOutput(value) {
|
|
403
424
|
if (value === void 0 || value === null) return void 0;
|
|
404
425
|
if (typeof value === "string") return { prose: value };
|
|
405
|
-
if (
|
|
406
|
-
|
|
407
|
-
if (
|
|
408
|
-
|
|
409
|
-
return { prose: typeof record4.prose === "string" ? record4.prose : String(record4.prose) };
|
|
426
|
+
if (isRecord(value)) {
|
|
427
|
+
if (typeof value.prose === "string") return { prose: value.prose };
|
|
428
|
+
if (value.prose !== void 0 && value.prose !== null) {
|
|
429
|
+
return { prose: typeof value.prose === "string" ? value.prose : String(value.prose) };
|
|
410
430
|
}
|
|
411
|
-
const keys = Object.keys(
|
|
431
|
+
const keys = Object.keys(value);
|
|
412
432
|
if (keys.length === 0) return { prose: "" };
|
|
413
433
|
try {
|
|
414
|
-
return { prose: JSON.stringify(
|
|
434
|
+
return { prose: JSON.stringify(value) };
|
|
415
435
|
} catch {
|
|
416
|
-
return { prose: String(
|
|
436
|
+
return { prose: String(value) };
|
|
417
437
|
}
|
|
418
438
|
}
|
|
419
439
|
return { prose: String(value) };
|
|
@@ -435,6 +455,7 @@ var NAVIGATOR_OUTPUT_TOOL_NAME, navigatorOutputSchema;
|
|
|
435
455
|
var init_navigator_output = __esm({
|
|
436
456
|
"src/package-contracts/navigator-output.ts"() {
|
|
437
457
|
"use strict";
|
|
458
|
+
init_unknown_value();
|
|
438
459
|
init_open_tool_schema();
|
|
439
460
|
init_terminating_infrastructure();
|
|
440
461
|
NAVIGATOR_OUTPUT_TOOL_NAME = "ak_navigator_output";
|
|
@@ -562,13 +583,9 @@ function fail(cause) {
|
|
|
562
583
|
function parseFailure(value) {
|
|
563
584
|
if (!Array.isArray(value)) fail(new Error("Fixer prerequisites must be a JSON array"));
|
|
564
585
|
for (const entry of value) {
|
|
565
|
-
if (
|
|
586
|
+
if (!isRecord(entry)) {
|
|
566
587
|
fail(new Error("Fixer prerequisite entry must be an object with id and requirement fields"));
|
|
567
588
|
}
|
|
568
|
-
const keys = Object.keys(entry);
|
|
569
|
-
if (keys.length !== 2 || !keys.includes("id") || !keys.includes("requirement")) {
|
|
570
|
-
fail(new Error("Fixer prerequisite entry fields must be exactly id and requirement"));
|
|
571
|
-
}
|
|
572
589
|
if (typeof entry.id !== "string" || !new RegExp(FIXER_PREREQUISITE_ID_PATTERN).test(entry.id)) {
|
|
573
590
|
fail(new Error(`Fixer prerequisite id violates pattern ${FIXER_PREREQUISITE_ID_PATTERN}`));
|
|
574
591
|
}
|
|
@@ -604,11 +621,12 @@ var FIXER_PREREQUISITE_ID_PATTERN, fixerPrerequisiteSchema, fixerPrerequisitesSc
|
|
|
604
621
|
var init_fixer_packet = __esm({
|
|
605
622
|
"src/package-contracts/fixer-packet.ts"() {
|
|
606
623
|
"use strict";
|
|
624
|
+
init_unknown_value();
|
|
607
625
|
FIXER_PREREQUISITE_ID_PATTERN = "^[A-Za-z0-9][A-Za-z0-9._-]*$";
|
|
608
626
|
fixerPrerequisiteSchema = Type7.Object({
|
|
609
627
|
id: Type7.String({ pattern: FIXER_PREREQUISITE_ID_PATTERN }),
|
|
610
628
|
requirement: Type7.String({ pattern: "\\S" })
|
|
611
|
-
}
|
|
629
|
+
});
|
|
612
630
|
fixerPrerequisitesSchema = Type7.Array(fixerPrerequisiteSchema);
|
|
613
631
|
FixerPacketValidationError = class extends Error {
|
|
614
632
|
code = "AK_INVALID_FIX_PACKET";
|
|
@@ -664,6 +682,7 @@ var init_doctor_contracts = __esm({
|
|
|
664
682
|
init_canonical_json();
|
|
665
683
|
init_open_tool_schema();
|
|
666
684
|
init_terminating_infrastructure();
|
|
685
|
+
init_unknown_value();
|
|
667
686
|
DOCTOR_EVIDENCE_TOOL_NAME = "ak_doctor_evidence";
|
|
668
687
|
DOCTOR_OUTPUT_TOOL_NAME = "ak_doctor_output";
|
|
669
688
|
DOCTOR_AUDIT_TOOL_NAME = "ak_doctor_audit_decision";
|
|
@@ -774,35 +793,36 @@ function deepFreeze(value) {
|
|
|
774
793
|
return value;
|
|
775
794
|
}
|
|
776
795
|
function readMaterial(value, label) {
|
|
777
|
-
if (!
|
|
796
|
+
if (!isRecord(value) || typeof value.bytesBase64 !== "string") fail2(`Merger ${label} material is malformed`);
|
|
778
797
|
exactUtf8(Buffer.from(value.bytesBase64, "base64"), `Merger ${label} material`);
|
|
779
798
|
return { bytesBase64: value.bytesBase64, sha256: typeof value.sha256 === "string" ? value.sha256 : "" };
|
|
780
799
|
}
|
|
781
800
|
function validateMergerInput(value) {
|
|
782
|
-
if (!
|
|
783
|
-
if (!
|
|
801
|
+
if (!isRecord(value) || blank(value.attemptId)) fail2("Merger input requires a non-empty attemptId for accounting");
|
|
802
|
+
if (!isRecord(value.materials)) fail2("Merger materials are missing");
|
|
784
803
|
const materials = { task: readMaterial(value.materials.task, "task"), authority: readMaterial(value.materials.authority, "authority"), targetIntent: readMaterial(value.materials.targetIntent, "targetIntent"), sourceIntent: readMaterial(value.materials.sourceIntent, "sourceIntent") };
|
|
785
|
-
const authorizedChecks = Array.isArray(value.authorizedChecks) ? value.authorizedChecks.filter((check) =>
|
|
804
|
+
const authorizedChecks = Array.isArray(value.authorizedChecks) ? value.authorizedChecks.filter((check) => isRecord(check)).map((c) => ({ name: asString(c.name), argv: asStringArray(c.argv).filter((a) => a.trim().length > 0) })).filter((c) => c.name.trim().length > 0 && c.argv.length > 0) : [];
|
|
786
805
|
return deepFreeze(structuredClone({ attemptId: value.attemptId.trim(), targetObjectId: asString(value.targetObjectId), sourceObjectId: asString(value.sourceObjectId), materials, expectedConflictPaths: asStringArray(value.expectedConflictPaths), resolutionScope: asStringArray(value.resolutionScope), authorizedChecks }));
|
|
787
806
|
}
|
|
788
|
-
var materialSchema, checkSchema, mergerInputSchema, MERGER_STATUS_DESCRIPTION, mergerOutputObject, mergerOutputSchema, MERGER_OUTPUT_TOOL_NAME,
|
|
807
|
+
var materialSchema, checkSchema, mergerInputSchema, MERGER_STATUS_DESCRIPTION, mergerOutputObject, mergerOutputSchema, MERGER_OUTPUT_TOOL_NAME, blank, MergerInputContractError, asString, asStringArray;
|
|
789
808
|
var init_merger_contracts = __esm({
|
|
790
809
|
"src/merger-contracts.ts"() {
|
|
791
810
|
"use strict";
|
|
792
811
|
init_exact_utf8();
|
|
793
812
|
init_open_tool_schema();
|
|
794
813
|
init_terminating_infrastructure();
|
|
795
|
-
|
|
796
|
-
|
|
814
|
+
init_unknown_value();
|
|
815
|
+
materialSchema = Type9.Object({ bytesBase64: Type9.String(), sha256: Type9.String() });
|
|
816
|
+
checkSchema = Type9.Object({ name: Type9.String({ minLength: 1 }), argv: Type9.Array(Type9.String({ minLength: 1 }), { minItems: 1 }) });
|
|
797
817
|
mergerInputSchema = Type9.Object({
|
|
798
818
|
attemptId: Type9.String({ minLength: 1, description: "\u5BF9\u8D26 attempt \u8EAB\u4EFD\uFF08transport\uFF09" }),
|
|
799
819
|
targetObjectId: Type9.String({ description: "\u6750\u6599\uFF1Atarget parent OID\uFF1B\u53EF\u7A7A" }),
|
|
800
820
|
sourceObjectId: Type9.String({ description: "\u6750\u6599\uFF1Asource parent OID\uFF1B\u53EF\u7A7A" }),
|
|
801
|
-
materials: Type9.Object({ task: materialSchema, authority: materialSchema, targetIntent: materialSchema, sourceIntent: materialSchema }
|
|
821
|
+
materials: Type9.Object({ task: materialSchema, authority: materialSchema, targetIntent: materialSchema, sourceIntent: materialSchema }),
|
|
802
822
|
expectedConflictPaths: Type9.Array(Type9.String(), { description: "\u6750\u6599\uFF1A\u5F53\u524D\u672A\u5408\u5E76\u8DEF\u5F84\uFF1B\u53EF\u7A7A" }),
|
|
803
823
|
resolutionScope: Type9.Array(Type9.String(), { description: "\u6750\u6599\uFF1A\u89E3\u6790\u8303\u56F4\u63D0\u793A\uFF1B\u53EF\u7A7A" }),
|
|
804
824
|
authorizedChecks: Type9.Array(checkSchema)
|
|
805
|
-
}
|
|
825
|
+
});
|
|
806
826
|
MERGER_STATUS_DESCRIPTION = "completed | escalate";
|
|
807
827
|
mergerOutputObject = Type9.Object({
|
|
808
828
|
status: Type9.Unknown({ description: MERGER_STATUS_DESCRIPTION }),
|
|
@@ -815,7 +835,6 @@ var init_merger_contracts = __esm({
|
|
|
815
835
|
});
|
|
816
836
|
mergerOutputSchema = withTerminatingOutputDeclarations(openToolObject(mergerOutputObject));
|
|
817
837
|
MERGER_OUTPUT_TOOL_NAME = "ak_merger_output";
|
|
818
|
-
record = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
819
838
|
blank = (v) => typeof v !== "string" || v.trim().length === 0;
|
|
820
839
|
MergerInputContractError = class extends Error {
|
|
821
840
|
constructor(message = "Merger input violates its exact contract") {
|
|
@@ -834,6 +853,7 @@ var init_notary_contracts = __esm({
|
|
|
834
853
|
"src/notary-contracts.ts"() {
|
|
835
854
|
"use strict";
|
|
836
855
|
init_review_submission();
|
|
856
|
+
init_unknown_value();
|
|
837
857
|
NOTARY_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
|
|
838
858
|
NOTARY_SOURCE_RUN_FLAG = {
|
|
839
859
|
name: "ak-notary-source-run",
|
|
@@ -859,6 +879,7 @@ var init_countersign_contracts = __esm({
|
|
|
859
879
|
"src/countersign-contracts.ts"() {
|
|
860
880
|
"use strict";
|
|
861
881
|
init_review_submission();
|
|
882
|
+
init_unknown_value();
|
|
862
883
|
COUNTERSIGN_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
|
|
863
884
|
}
|
|
864
885
|
});
|
|
@@ -868,6 +889,7 @@ var GLEANER_LEFT_OUTPUT_TOOL_NAME, GLEANER_LEFT_BASE_FLAG;
|
|
|
868
889
|
var init_gleaner_left_contracts = __esm({
|
|
869
890
|
"src/gleaner-left-contracts.ts"() {
|
|
870
891
|
"use strict";
|
|
892
|
+
init_unknown_value();
|
|
871
893
|
GLEANER_LEFT_OUTPUT_TOOL_NAME = "ak_gleaner_left_output";
|
|
872
894
|
GLEANER_LEFT_BASE_FLAG = {
|
|
873
895
|
name: "ak-gleaner-left-base",
|
|
@@ -885,6 +907,7 @@ var init_inspector_contracts = __esm({
|
|
|
885
907
|
"src/inspector-contracts.ts"() {
|
|
886
908
|
"use strict";
|
|
887
909
|
init_review_submission();
|
|
910
|
+
init_unknown_value();
|
|
888
911
|
INSPECTOR_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
|
|
889
912
|
INSPECTOR_SOURCE_RUN_FLAG = {
|
|
890
913
|
name: "ak-inspector-source-run",
|
|
@@ -902,15 +925,13 @@ var init_auditor_output = __esm({
|
|
|
902
925
|
"src/package-contracts/auditor-output.ts"() {
|
|
903
926
|
"use strict";
|
|
904
927
|
init_review_submission();
|
|
928
|
+
init_unknown_value();
|
|
905
929
|
AUDITOR_OUTPUT_TOOL_NAME = REVIEW_SUBMISSION_OUTPUT_TOOL_NAME;
|
|
906
930
|
auditorOutputSchema = reviewSubmissionSchema;
|
|
907
931
|
}
|
|
908
932
|
});
|
|
909
933
|
|
|
910
934
|
// src/ticket-provenance-contracts.ts
|
|
911
|
-
function isRecord(value) {
|
|
912
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
913
|
-
}
|
|
914
935
|
function positiveInteger(value) {
|
|
915
936
|
if (typeof value === "number" && Number.isSafeInteger(value) && value >= 1) return value;
|
|
916
937
|
if (typeof value === "string" && /^[1-9][0-9]*$/.test(value)) {
|
|
@@ -951,6 +972,7 @@ var TICKET_PROVENANCE_KIND;
|
|
|
951
972
|
var init_ticket_provenance_contracts = __esm({
|
|
952
973
|
"src/ticket-provenance-contracts.ts"() {
|
|
953
974
|
"use strict";
|
|
975
|
+
init_unknown_value();
|
|
954
976
|
TICKET_PROVENANCE_KIND = "ticket-provenance";
|
|
955
977
|
}
|
|
956
978
|
});
|
|
@@ -968,9 +990,6 @@ __export(run_ticket_number_exports, {
|
|
|
968
990
|
});
|
|
969
991
|
import { readFile } from "node:fs/promises";
|
|
970
992
|
import { join as join2 } from "node:path";
|
|
971
|
-
function isEnoent(error) {
|
|
972
|
-
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
973
|
-
}
|
|
974
993
|
function isSafePositiveTicketNumber(value) {
|
|
975
994
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 1;
|
|
976
995
|
}
|
|
@@ -991,13 +1010,13 @@ function requireSafePositiveTicketNumber(ticketNumber, context = "ticketNumber")
|
|
|
991
1010
|
}
|
|
992
1011
|
return ticketNumber;
|
|
993
1012
|
}
|
|
994
|
-
function ticketFromRecord(
|
|
995
|
-
return isSafePositiveTicketNumber(
|
|
1013
|
+
function ticketFromRecord(record) {
|
|
1014
|
+
return isSafePositiveTicketNumber(record.ticketNumber) ? record.ticketNumber : void 0;
|
|
996
1015
|
}
|
|
997
1016
|
async function readJsonObject(path) {
|
|
998
1017
|
try {
|
|
999
1018
|
const raw = JSON.parse(await readFile(path, "utf8"));
|
|
1000
|
-
if (
|
|
1019
|
+
if (!isRecord(raw)) {
|
|
1001
1020
|
return void 0;
|
|
1002
1021
|
}
|
|
1003
1022
|
return raw;
|
|
@@ -1007,20 +1026,20 @@ async function readJsonObject(path) {
|
|
|
1007
1026
|
}
|
|
1008
1027
|
}
|
|
1009
1028
|
async function readBoardPageTicketNumber(runDirectory, page) {
|
|
1010
|
-
const
|
|
1011
|
-
if (
|
|
1012
|
-
return ticketFromRecord(
|
|
1029
|
+
const record = await readJsonObject(join2(runDirectory, page));
|
|
1030
|
+
if (record === void 0) return void 0;
|
|
1031
|
+
return ticketFromRecord(record);
|
|
1013
1032
|
}
|
|
1014
1033
|
async function readBoardTicketNumber(runDirectory) {
|
|
1015
1034
|
return await readBoardPageTicketNumber(runDirectory, "admitted-request.json") ?? await readBoardPageTicketNumber(runDirectory, "invocation.json");
|
|
1016
1035
|
}
|
|
1017
1036
|
async function readMigrationDerivedTicketNumber(runDirectory) {
|
|
1018
|
-
const
|
|
1037
|
+
const record = await readJsonObject(
|
|
1019
1038
|
join2(runDirectory, MIGRATION_TICKET_DERIVATION_PAGE)
|
|
1020
1039
|
);
|
|
1021
|
-
if (
|
|
1022
|
-
if (
|
|
1023
|
-
return ticketFromRecord(
|
|
1040
|
+
if (record === void 0) return void 0;
|
|
1041
|
+
if (record.derivation !== "worktree-path-basename") return void 0;
|
|
1042
|
+
return ticketFromRecord(record);
|
|
1024
1043
|
}
|
|
1025
1044
|
async function readRunTicketNumber(runDirectory) {
|
|
1026
1045
|
return await readBoardTicketNumber(runDirectory) ?? await readMigrationDerivedTicketNumber(runDirectory);
|
|
@@ -1029,6 +1048,7 @@ var MIGRATION_TICKET_DERIVATION_PAGE;
|
|
|
1029
1048
|
var init_run_ticket_number = __esm({
|
|
1030
1049
|
"src/run-ticket-number.ts"() {
|
|
1031
1050
|
"use strict";
|
|
1051
|
+
init_unknown_value();
|
|
1032
1052
|
MIGRATION_TICKET_DERIVATION_PAGE = "migration-ticket-derivation.json";
|
|
1033
1053
|
}
|
|
1034
1054
|
});
|
|
@@ -1044,7 +1064,7 @@ function projectDiaristTicketSessions(value) {
|
|
|
1044
1064
|
if (!Array.isArray(raw)) return void 0;
|
|
1045
1065
|
const perTicket = /* @__PURE__ */ new Map();
|
|
1046
1066
|
for (const entry of raw) {
|
|
1047
|
-
if (
|
|
1067
|
+
if (!isRecord(entry)) return void 0;
|
|
1048
1068
|
const { ticketNumber, sessions: rawSessions } = entry;
|
|
1049
1069
|
if (!isSafePositiveTicketNumber(ticketNumber)) return void 0;
|
|
1050
1070
|
const sessions = projectTicketProvenanceSessions(rawSessions);
|
|
@@ -1059,6 +1079,7 @@ var init_diarist_contracts = __esm({
|
|
|
1059
1079
|
"use strict";
|
|
1060
1080
|
init_ticket_provenance_contracts();
|
|
1061
1081
|
init_run_ticket_number();
|
|
1082
|
+
init_unknown_value();
|
|
1062
1083
|
DIARIST_OUTPUT_TOOL_NAME = "ak_diarist_output";
|
|
1063
1084
|
}
|
|
1064
1085
|
});
|
|
@@ -1131,40 +1152,40 @@ function packagedRoleMetadata(role) {
|
|
|
1131
1152
|
}
|
|
1132
1153
|
function packagedMethodSkillNames() {
|
|
1133
1154
|
const names = [];
|
|
1134
|
-
for (const
|
|
1135
|
-
if ("methodSkills" in
|
|
1136
|
-
for (const name of
|
|
1155
|
+
for (const record of PACKAGED_ROLE_REGISTRY) {
|
|
1156
|
+
if ("methodSkills" in record && record.methodSkills !== void 0) {
|
|
1157
|
+
for (const name of record.methodSkills) if (!names.includes(name)) names.push(name);
|
|
1137
1158
|
}
|
|
1138
|
-
if ("applyMethod" in
|
|
1139
|
-
names.push(
|
|
1159
|
+
if ("applyMethod" in record && record.applyMethod !== void 0 && !names.includes(record.applyMethod)) {
|
|
1160
|
+
names.push(record.applyMethod);
|
|
1140
1161
|
}
|
|
1141
1162
|
}
|
|
1142
1163
|
return names;
|
|
1143
1164
|
}
|
|
1144
1165
|
function isOfficerReviewSeat(role) {
|
|
1145
|
-
const
|
|
1146
|
-
return
|
|
1166
|
+
const record = packagedRoleMetadata(role);
|
|
1167
|
+
return record !== void 0 && "reviewOfficer" in record && record.reviewOfficer === true;
|
|
1147
1168
|
}
|
|
1148
1169
|
function packagedProvinceConfig(role) {
|
|
1149
|
-
const
|
|
1150
|
-
return
|
|
1170
|
+
const record = packagedRoleMetadata(role);
|
|
1171
|
+
return record !== void 0 && "provinceConfig" in record && record.provinceConfig === true;
|
|
1151
1172
|
}
|
|
1152
1173
|
function packagedModelParent(role) {
|
|
1153
|
-
const
|
|
1154
|
-
if (
|
|
1155
|
-
return
|
|
1174
|
+
const record = packagedRoleMetadata(role);
|
|
1175
|
+
if (record === void 0 || !("modelInheritsFrom" in record)) return void 0;
|
|
1176
|
+
return record.modelInheritsFrom;
|
|
1156
1177
|
}
|
|
1157
1178
|
function packagedRoleAcceptedOutputTool(role) {
|
|
1158
|
-
const
|
|
1159
|
-
if (
|
|
1179
|
+
const record = packagedRoleMetadata(role);
|
|
1180
|
+
if (record === void 0 || !("settlement" in record) || record.settlement !== "accepted") {
|
|
1160
1181
|
return void 0;
|
|
1161
1182
|
}
|
|
1162
|
-
return
|
|
1183
|
+
return record.outputTool;
|
|
1163
1184
|
}
|
|
1164
1185
|
function packagedRoleActivationFlags(role) {
|
|
1165
|
-
const
|
|
1166
|
-
if (
|
|
1167
|
-
return
|
|
1186
|
+
const record = packagedRoleMetadata(role);
|
|
1187
|
+
if (record === void 0 || !("activationFlags" in record)) return [];
|
|
1188
|
+
return record.activationFlags;
|
|
1168
1189
|
}
|
|
1169
1190
|
function packagedRoleInputFlag(role) {
|
|
1170
1191
|
return packagedRoleActivationFlags(role).find((spec) => spec.binds === "input")?.flag;
|
|
@@ -1176,8 +1197,8 @@ function packagedRoleOutputTool(role) {
|
|
|
1176
1197
|
return packagedRoleMetadata(role)?.outputTool;
|
|
1177
1198
|
}
|
|
1178
1199
|
function packagedBindsBoardTicket(role) {
|
|
1179
|
-
const
|
|
1180
|
-
return
|
|
1200
|
+
const record = packagedRoleMetadata(role);
|
|
1201
|
+
return record?.sameParent === "board-ticket";
|
|
1181
1202
|
}
|
|
1182
1203
|
function packagedRebindSourceOnResume(role) {
|
|
1183
1204
|
return packagedRoleMetadata(role)?.admission === "source-locator";
|
|
@@ -1186,31 +1207,31 @@ function packagedAdmitsCountersign(role) {
|
|
|
1186
1207
|
return packagedRoleMetadata(role)?.admission === "court-materials";
|
|
1187
1208
|
}
|
|
1188
1209
|
function packagedBareToken(role) {
|
|
1189
|
-
const
|
|
1190
|
-
if (
|
|
1191
|
-
return
|
|
1210
|
+
const record = packagedRoleMetadata(role);
|
|
1211
|
+
if (record === void 0 || !("bareToken" in record)) return void 0;
|
|
1212
|
+
return record.bareToken;
|
|
1192
1213
|
}
|
|
1193
1214
|
function packagedArgvResult(role) {
|
|
1194
|
-
const
|
|
1195
|
-
if (
|
|
1215
|
+
const record = packagedRoleMetadata(role);
|
|
1216
|
+
if (record !== void 0 && "argvResult" in record) return record.argvResult;
|
|
1196
1217
|
return "material";
|
|
1197
1218
|
}
|
|
1198
1219
|
function packagedStoresSourceRunRaw(role) {
|
|
1199
|
-
const
|
|
1200
|
-
return
|
|
1220
|
+
const record = packagedRoleMetadata(role);
|
|
1221
|
+
return record !== void 0 && "sourceRunStored" in record && record.sourceRunStored === "raw";
|
|
1201
1222
|
}
|
|
1202
1223
|
function packagedBaseIsRevision(role) {
|
|
1203
|
-
const
|
|
1204
|
-
return
|
|
1224
|
+
const record = packagedRoleMetadata(role);
|
|
1225
|
+
return record !== void 0 && "baseValue" in record && record.baseValue === "revision";
|
|
1205
1226
|
}
|
|
1206
1227
|
function packagedEmitsAuthorityRefs(role) {
|
|
1207
|
-
const
|
|
1208
|
-
return
|
|
1228
|
+
const record = packagedRoleMetadata(role);
|
|
1229
|
+
return record !== void 0 && "emitAuthorityRefs" in record && record.emitAuthorityRefs === true;
|
|
1209
1230
|
}
|
|
1210
1231
|
function packagedSubjectChoices(role) {
|
|
1211
|
-
const
|
|
1212
|
-
if (
|
|
1213
|
-
return
|
|
1232
|
+
const record = packagedRoleMetadata(role);
|
|
1233
|
+
if (record === void 0 || !("subjectChoices" in record)) return void 0;
|
|
1234
|
+
return record.subjectChoices;
|
|
1214
1235
|
}
|
|
1215
1236
|
function packagedAdmittedSubject(role, value) {
|
|
1216
1237
|
const choices = packagedSubjectChoices(role);
|
|
@@ -1220,47 +1241,47 @@ function packagedAdmittedSubject(role, value) {
|
|
|
1220
1241
|
return void 0;
|
|
1221
1242
|
}
|
|
1222
1243
|
function packagedAuditToolName(role) {
|
|
1223
|
-
const
|
|
1224
|
-
if (
|
|
1225
|
-
return
|
|
1244
|
+
const record = packagedRoleMetadata(role);
|
|
1245
|
+
if (record === void 0 || !("auditTool" in record)) return void 0;
|
|
1246
|
+
return record.auditTool;
|
|
1226
1247
|
}
|
|
1227
1248
|
function packagedSkipsGateOnInfrastructureStage(stage) {
|
|
1228
1249
|
return typeof stage === "string" && PUBLIC_ROLE_RECORDS.some(
|
|
1229
|
-
(
|
|
1250
|
+
(record) => "skipGateOnInfrastructureStage" in record && record.skipGateOnInfrastructureStage === true && record.role === stage
|
|
1230
1251
|
);
|
|
1231
1252
|
}
|
|
1232
1253
|
function packagedDurableOfficerEntry(officer) {
|
|
1233
1254
|
return typeof officer === "string" && PUBLIC_ROLE_RECORDS.some(
|
|
1234
|
-
(
|
|
1255
|
+
(record) => "durableOfficerEntry" in record && record.durableOfficerEntry === true && record.role === officer
|
|
1235
1256
|
);
|
|
1236
1257
|
}
|
|
1237
1258
|
function packagedPublicInstructionSubject(role) {
|
|
1238
1259
|
return typeof role === "string" && PUBLIC_ROLE_RECORDS.some(
|
|
1239
|
-
(
|
|
1260
|
+
(record) => "navigatorSubject" in record && record.navigatorSubject === "public-instruction" && record.role === role
|
|
1240
1261
|
);
|
|
1241
1262
|
}
|
|
1242
1263
|
function packagedResumeSourcePath(role) {
|
|
1243
|
-
const
|
|
1244
|
-
return
|
|
1264
|
+
const record = packagedRoleMetadata(role);
|
|
1265
|
+
return record !== void 0 && "resumeSourcePath" in record && record.resumeSourcePath === true;
|
|
1245
1266
|
}
|
|
1246
1267
|
function packagedProjectsTargetBindRejection(role) {
|
|
1247
|
-
const
|
|
1248
|
-
return
|
|
1268
|
+
const record = packagedRoleMetadata(role);
|
|
1269
|
+
return record !== void 0 && "projectTargetBindRejection" in record && record.projectTargetBindRejection === true;
|
|
1249
1270
|
}
|
|
1250
1271
|
function packagedNavigatorSubject(role) {
|
|
1251
|
-
const
|
|
1252
|
-
if (
|
|
1272
|
+
const record = packagedRoleMetadata(role);
|
|
1273
|
+
if (record !== void 0 && "navigatorSubject" in record) return record.navigatorSubject;
|
|
1253
1274
|
return "file";
|
|
1254
1275
|
}
|
|
1255
1276
|
function packagedBoardPlacement(role) {
|
|
1256
|
-
const
|
|
1257
|
-
if (
|
|
1258
|
-
return
|
|
1277
|
+
const record = packagedRoleMetadata(role);
|
|
1278
|
+
if (record === void 0 || !("boardPlacement" in record)) return void 0;
|
|
1279
|
+
return record.boardPlacement;
|
|
1259
1280
|
}
|
|
1260
1281
|
function packagedAnalystTerminal(role) {
|
|
1261
|
-
const
|
|
1262
|
-
if (
|
|
1263
|
-
return
|
|
1282
|
+
const record = packagedRoleMetadata(role);
|
|
1283
|
+
if (record === void 0 || !("analystTerminal" in record)) return void 0;
|
|
1284
|
+
return record.analystTerminal;
|
|
1264
1285
|
}
|
|
1265
1286
|
function packagedRoleSessionMaterials(role) {
|
|
1266
1287
|
return PUBLIC_ROLE_RECORDS.find((entry) => entry.role === role)?.sessionMaterials;
|
|
@@ -1269,13 +1290,13 @@ function isNavigatorSeat(role) {
|
|
|
1269
1290
|
return packagedRoleOutputTool(role) === NAVIGATOR_OUTPUT_TOOL_NAME;
|
|
1270
1291
|
}
|
|
1271
1292
|
function packagedGateStageLabel(role) {
|
|
1272
|
-
const
|
|
1273
|
-
if (
|
|
1274
|
-
return
|
|
1293
|
+
const record = packagedRoleMetadata(role);
|
|
1294
|
+
if (record === void 0 || !("gateStageLabel" in record)) return void 0;
|
|
1295
|
+
return record.gateStageLabel;
|
|
1275
1296
|
}
|
|
1276
1297
|
function packagedGateSummon(role) {
|
|
1277
|
-
const
|
|
1278
|
-
if (
|
|
1298
|
+
const record = packagedRoleMetadata(role);
|
|
1299
|
+
if (record !== void 0 && "gateSummon" in record) return record.gateSummon;
|
|
1279
1300
|
return "pointer";
|
|
1280
1301
|
}
|
|
1281
1302
|
var LEGACY_REVIEW_OUTPUT_ROLES, NOTARY_SESSION_MATERIALS, INSPECTOR_SESSION_MATERIALS, AUDITOR_PUBLIC_SESSION_MATERIALS, PUBLIC_ROLE_RECORDS, PACKAGED_ROLE_REGISTRY;
|
|
@@ -1848,8 +1869,7 @@ function isConfirmedNonRepositoryStderr(stderr) {
|
|
|
1848
1869
|
return CONFIRMED_NON_REPOSITORY_STDERR.test(stderr);
|
|
1849
1870
|
}
|
|
1850
1871
|
function isGitSpawnInfrastructureError(error) {
|
|
1851
|
-
|
|
1852
|
-
const code = error.code;
|
|
1872
|
+
const code = errnoCode(error);
|
|
1853
1873
|
return code === "ENOENT" || code === "EACCES" || code === "EPERM";
|
|
1854
1874
|
}
|
|
1855
1875
|
function gitChildExitedNonzero(error) {
|
|
@@ -1892,6 +1912,7 @@ var GIT_DISCOVERY_ENV_KEYS, CONFIRMED_NON_REPOSITORY_STDERR, ActivationGitReposi
|
|
|
1892
1912
|
var init_activation_ledger_git = __esm({
|
|
1893
1913
|
"src/activation-ledger-git.ts"() {
|
|
1894
1914
|
"use strict";
|
|
1915
|
+
init_unknown_value();
|
|
1895
1916
|
GIT_DISCOVERY_ENV_KEYS = [
|
|
1896
1917
|
"GIT_DIR",
|
|
1897
1918
|
"GIT_COMMON_DIR",
|
|
@@ -2008,13 +2029,6 @@ function physicalPathIdentity(path) {
|
|
|
2008
2029
|
function physicallyContainedIn(root, candidate) {
|
|
2009
2030
|
return pathContainedIn(physicalPathIdentity(root), physicalPathIdentity(candidate));
|
|
2010
2031
|
}
|
|
2011
|
-
function errnoCode(error) {
|
|
2012
|
-
return error !== null && typeof error === "object" && "code" in error && typeof error.code === "string" ? error.code : void 0;
|
|
2013
|
-
}
|
|
2014
|
-
function errorText(error) {
|
|
2015
|
-
if (!(error instanceof Error)) return String(error);
|
|
2016
|
-
return error.message;
|
|
2017
|
-
}
|
|
2018
2032
|
function assertPhysicalLedgerRoot(absoluteRoot) {
|
|
2019
2033
|
let st;
|
|
2020
2034
|
try {
|
|
@@ -2179,6 +2193,7 @@ var ActivationLedgerError;
|
|
|
2179
2193
|
var init_activation_ledger_topology = __esm({
|
|
2180
2194
|
"src/activation-ledger-topology.ts"() {
|
|
2181
2195
|
"use strict";
|
|
2196
|
+
init_unknown_value();
|
|
2182
2197
|
ActivationLedgerError = class extends Error {
|
|
2183
2198
|
code = "AK_ACTIVATION_LEDGER";
|
|
2184
2199
|
constructor(message, options) {
|
|
@@ -2280,7 +2295,7 @@ function appendSitianRecord(input) {
|
|
|
2280
2295
|
const identity = input.identity ?? randomUUID();
|
|
2281
2296
|
const timestamp2 = input.timestamp ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
2282
2297
|
const host = input.host ?? "pi";
|
|
2283
|
-
const
|
|
2298
|
+
const record = {
|
|
2284
2299
|
level: input.level,
|
|
2285
2300
|
kind: input.kind,
|
|
2286
2301
|
identity,
|
|
@@ -2293,14 +2308,14 @@ function appendSitianRecord(input) {
|
|
|
2293
2308
|
...input.raw === void 0 ? {} : { raw: input.raw },
|
|
2294
2309
|
...input.usage === void 0 ? {} : { usage: input.usage }
|
|
2295
2310
|
};
|
|
2296
|
-
const row = `${JSON.stringify(
|
|
2311
|
+
const row = `${JSON.stringify(record)}
|
|
2297
2312
|
`;
|
|
2298
2313
|
appendFileSync(recordFile, row, "utf8");
|
|
2299
2314
|
return {
|
|
2300
|
-
identity:
|
|
2315
|
+
identity: record.identity,
|
|
2301
2316
|
recordFile,
|
|
2302
|
-
kind:
|
|
2303
|
-
level:
|
|
2317
|
+
kind: record.kind,
|
|
2318
|
+
level: record.level
|
|
2304
2319
|
};
|
|
2305
2320
|
} catch (error) {
|
|
2306
2321
|
if (error instanceof SitianInfrastructureError) throw error;
|
|
@@ -2331,9 +2346,6 @@ var init_sitian_appender = __esm({
|
|
|
2331
2346
|
// src/sitian-reader.ts
|
|
2332
2347
|
import { existsSync } from "node:fs";
|
|
2333
2348
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
2334
|
-
function isRecord2(value) {
|
|
2335
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2336
|
-
}
|
|
2337
2349
|
async function readSitianRecords(recordFile) {
|
|
2338
2350
|
if (!existsSync(recordFile)) {
|
|
2339
2351
|
return { records: [], diagnostics: [] };
|
|
@@ -2347,7 +2359,7 @@ async function readSitianRecords(recordFile) {
|
|
|
2347
2359
|
if (!line2.trim()) continue;
|
|
2348
2360
|
try {
|
|
2349
2361
|
const parsed = JSON.parse(line2);
|
|
2350
|
-
if (
|
|
2362
|
+
if (isRecord(parsed)) {
|
|
2351
2363
|
records.push(parsed);
|
|
2352
2364
|
} else {
|
|
2353
2365
|
const typeDesc = parsed === null ? "null" : Array.isArray(parsed) ? "array" : typeof parsed;
|
|
@@ -2363,7 +2375,7 @@ async function readSitianRecords(recordFile) {
|
|
|
2363
2375
|
kind: "malformed",
|
|
2364
2376
|
line: index + 1,
|
|
2365
2377
|
raw: line2,
|
|
2366
|
-
error:
|
|
2378
|
+
error: errorText(error)
|
|
2367
2379
|
});
|
|
2368
2380
|
}
|
|
2369
2381
|
}
|
|
@@ -2372,6 +2384,7 @@ async function readSitianRecords(recordFile) {
|
|
|
2372
2384
|
var init_sitian_reader = __esm({
|
|
2373
2385
|
"src/sitian-reader.ts"() {
|
|
2374
2386
|
"use strict";
|
|
2387
|
+
init_unknown_value();
|
|
2375
2388
|
}
|
|
2376
2389
|
});
|
|
2377
2390
|
|
|
@@ -2392,9 +2405,6 @@ var init_sitian_facade = __esm({
|
|
|
2392
2405
|
// src/role-run-placement.ts
|
|
2393
2406
|
import { readdir } from "node:fs/promises";
|
|
2394
2407
|
import { join as join5 } from "node:path";
|
|
2395
|
-
function isMissingPathError(error) {
|
|
2396
|
-
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
2397
|
-
}
|
|
2398
2408
|
async function listBookRunDirectories(bookDir) {
|
|
2399
2409
|
const out = [];
|
|
2400
2410
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -2403,7 +2413,7 @@ async function listBookRunDirectories(bookDir) {
|
|
|
2403
2413
|
try {
|
|
2404
2414
|
entries = await readdir(runsDir, { withFileTypes: true });
|
|
2405
2415
|
} catch (error) {
|
|
2406
|
-
if (
|
|
2416
|
+
if (isEnoent(error)) return;
|
|
2407
2417
|
throw error;
|
|
2408
2418
|
}
|
|
2409
2419
|
for (const entry of entries) {
|
|
@@ -2419,7 +2429,7 @@ async function listBookRunDirectories(bookDir) {
|
|
|
2419
2429
|
try {
|
|
2420
2430
|
subjects = await readdir(bookDir, { withFileTypes: true });
|
|
2421
2431
|
} catch (error) {
|
|
2422
|
-
if (
|
|
2432
|
+
if (isEnoent(error)) return out.sort();
|
|
2423
2433
|
throw error;
|
|
2424
2434
|
}
|
|
2425
2435
|
for (const subject of subjects) {
|
|
@@ -2470,6 +2480,7 @@ var init_role_run_placement = __esm({
|
|
|
2470
2480
|
"use strict";
|
|
2471
2481
|
init_activation_ledger_topology();
|
|
2472
2482
|
init_run_ticket_number();
|
|
2483
|
+
init_unknown_value();
|
|
2473
2484
|
}
|
|
2474
2485
|
});
|
|
2475
2486
|
|
|
@@ -2485,20 +2496,11 @@ __export(run_terminal_artifacts_exports, {
|
|
|
2485
2496
|
});
|
|
2486
2497
|
import { readdir as readdir2, readFile as readFile3 } from "node:fs/promises";
|
|
2487
2498
|
import { basename as basename3, dirname as dirname4, join as join6 } from "node:path";
|
|
2488
|
-
function isMissingPathError2(error) {
|
|
2489
|
-
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
2490
|
-
}
|
|
2491
|
-
function errorText2(error) {
|
|
2492
|
-
return error instanceof Error ? error.message : String(error);
|
|
2493
|
-
}
|
|
2494
|
-
function isRecord3(value) {
|
|
2495
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2496
|
-
}
|
|
2497
2499
|
function readUsableTerminalArtifactBody(body) {
|
|
2498
2500
|
if (body === null) {
|
|
2499
2501
|
return { ok: false, reason: "terminal artifact JSON value is null" };
|
|
2500
2502
|
}
|
|
2501
|
-
if (!
|
|
2503
|
+
if (!isRecord(body)) {
|
|
2502
2504
|
return {
|
|
2503
2505
|
ok: false,
|
|
2504
2506
|
reason: `terminal artifact JSON value is not a typed object (${Array.isArray(body) ? "array" : typeof body})`
|
|
@@ -2517,12 +2519,12 @@ async function readTerminalArtifactAtPath(path, file) {
|
|
|
2517
2519
|
try {
|
|
2518
2520
|
raw = await readFile3(path, "utf8");
|
|
2519
2521
|
} catch (error) {
|
|
2520
|
-
if (
|
|
2522
|
+
if (isMissingPathError(error)) return void 0;
|
|
2521
2523
|
return {
|
|
2522
2524
|
status: "unreadable",
|
|
2523
2525
|
file,
|
|
2524
2526
|
path,
|
|
2525
|
-
reason:
|
|
2527
|
+
reason: errorText(error)
|
|
2526
2528
|
};
|
|
2527
2529
|
}
|
|
2528
2530
|
let parsed;
|
|
@@ -2554,7 +2556,7 @@ async function listUniqueErrorFallbackPaths(directories) {
|
|
|
2554
2556
|
try {
|
|
2555
2557
|
names = await readdir2(dir);
|
|
2556
2558
|
} catch (error) {
|
|
2557
|
-
if (
|
|
2559
|
+
if (isMissingPathError(error)) continue;
|
|
2558
2560
|
throw error;
|
|
2559
2561
|
}
|
|
2560
2562
|
for (const name of names.sort((a, b) => a.localeCompare(b))) {
|
|
@@ -2634,6 +2636,7 @@ var init_run_terminal_artifacts = __esm({
|
|
|
2634
2636
|
"src/run-terminal-artifacts.ts"() {
|
|
2635
2637
|
"use strict";
|
|
2636
2638
|
init_role_run_placement();
|
|
2639
|
+
init_unknown_value();
|
|
2637
2640
|
RUN_TERMINAL_ARTIFACT_FILES = [
|
|
2638
2641
|
"report.json",
|
|
2639
2642
|
"error.json",
|
|
@@ -2679,9 +2682,7 @@ async function clearTypedProviderHttpObservation(runDirectory) {
|
|
|
2679
2682
|
try {
|
|
2680
2683
|
await unlink(typedProviderHttpPath(runDirectory));
|
|
2681
2684
|
} catch (error) {
|
|
2682
|
-
if (error
|
|
2683
|
-
return;
|
|
2684
|
-
}
|
|
2685
|
+
if (isEnoent(error)) return;
|
|
2685
2686
|
throw error;
|
|
2686
2687
|
}
|
|
2687
2688
|
}
|
|
@@ -2706,34 +2707,43 @@ async function readLatestTypedProviderHttpObservation(runDirectory) {
|
|
|
2706
2707
|
try {
|
|
2707
2708
|
text = await readFile4(typedProviderHttpPath(runDirectory), "utf8");
|
|
2708
2709
|
} catch (error) {
|
|
2709
|
-
if (error
|
|
2710
|
-
return void 0;
|
|
2711
|
-
}
|
|
2710
|
+
if (isEnoent(error)) return void 0;
|
|
2712
2711
|
throw error;
|
|
2713
2712
|
}
|
|
2714
2713
|
const raw = JSON.parse(text);
|
|
2715
|
-
if (
|
|
2714
|
+
if (!isRecord(raw)) {
|
|
2716
2715
|
throw new Error("typed provider HTTP observation must be a JSON object");
|
|
2717
2716
|
}
|
|
2718
|
-
const
|
|
2719
|
-
if (typeof
|
|
2717
|
+
const record = raw;
|
|
2718
|
+
if (typeof record.httpStatus !== "number") {
|
|
2720
2719
|
throw new Error("typed provider HTTP observation missing numeric httpStatus");
|
|
2721
2720
|
}
|
|
2722
|
-
if (typeof
|
|
2721
|
+
if (typeof record.provider !== "string" || record.provider.trim() === "") {
|
|
2723
2722
|
throw new Error("typed provider HTTP observation missing non-empty provider");
|
|
2724
2723
|
}
|
|
2725
|
-
return { httpStatus:
|
|
2724
|
+
return { httpStatus: record.httpStatus, provider: record.provider };
|
|
2726
2725
|
}
|
|
2727
2726
|
var TYPED_HTTP_FILE;
|
|
2728
2727
|
var init_typed_provider_http = __esm({
|
|
2729
2728
|
"src/typed-provider-http.ts"() {
|
|
2730
2729
|
"use strict";
|
|
2730
|
+
init_unknown_value();
|
|
2731
2731
|
TYPED_HTTP_FILE = "typed-provider-http.json";
|
|
2732
2732
|
}
|
|
2733
2733
|
});
|
|
2734
2734
|
|
|
2735
|
-
// src/
|
|
2735
|
+
// src/sha256.ts
|
|
2736
2736
|
import { createHash } from "node:crypto";
|
|
2737
|
+
function sha256Hex(bytes) {
|
|
2738
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
2739
|
+
}
|
|
2740
|
+
var init_sha256 = __esm({
|
|
2741
|
+
"src/sha256.ts"() {
|
|
2742
|
+
"use strict";
|
|
2743
|
+
}
|
|
2744
|
+
});
|
|
2745
|
+
|
|
2746
|
+
// src/collector-config.ts
|
|
2737
2747
|
import { readFile as readFile5 } from "node:fs/promises";
|
|
2738
2748
|
function fail3(message, cause) {
|
|
2739
2749
|
throw new Error(message, cause === void 0 ? void 0 : { cause });
|
|
@@ -2763,16 +2773,13 @@ function parseCollectorPrNumber(raw) {
|
|
|
2763
2773
|
if (!Number.isSafeInteger(value) || value < 1) fail3("Collector pull request number must be a positive safe integer");
|
|
2764
2774
|
return value;
|
|
2765
2775
|
}
|
|
2766
|
-
function record2(value) {
|
|
2767
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2768
|
-
}
|
|
2769
2776
|
function canonicalManifest(requests) {
|
|
2770
2777
|
return `${JSON.stringify({ requests: requests.map((request) => ({ id: request.id, body: request.requestBody })) })}
|
|
2771
2778
|
`;
|
|
2772
2779
|
}
|
|
2773
2780
|
function emptyCollectorManifest() {
|
|
2774
2781
|
const canonicalJson2 = canonicalManifest([]);
|
|
2775
|
-
return { requests: [], canonicalJson: canonicalJson2, digest:
|
|
2782
|
+
return { requests: [], canonicalJson: canonicalJson2, digest: sha256Hex(canonicalJson2) };
|
|
2776
2783
|
}
|
|
2777
2784
|
async function loadCollectorManifest(path) {
|
|
2778
2785
|
let bytes;
|
|
@@ -2787,24 +2794,26 @@ async function loadCollectorManifest(path) {
|
|
|
2787
2794
|
} catch (error) {
|
|
2788
2795
|
fail3("Collector request manifest must be UTF-8 JSON", error);
|
|
2789
2796
|
}
|
|
2790
|
-
if (!
|
|
2797
|
+
if (!isRecord(parsed)) fail3("Collector request manifest must be an object");
|
|
2791
2798
|
const rawRequests = parsed.requests ?? [];
|
|
2792
2799
|
if (!Array.isArray(rawRequests)) fail3("Collector request manifest requests must be an array");
|
|
2793
2800
|
const requests = [];
|
|
2794
2801
|
const ids = /* @__PURE__ */ new Set();
|
|
2795
2802
|
for (const [index, item] of rawRequests.entries()) {
|
|
2796
|
-
if (!
|
|
2803
|
+
if (!isRecord(item) || typeof item.id !== "string" || item.id.length === 0 || typeof item.body !== "string" || item.body.trim() === "") fail3(`Collector request manifest requests[${index}] is invalid`);
|
|
2797
2804
|
if (ids.has(item.id)) fail3(`Collector request manifest has duplicate request id "${item.id}"`);
|
|
2798
2805
|
ids.add(item.id);
|
|
2799
2806
|
requests.push({ id: item.id, requestBody: item.body });
|
|
2800
2807
|
}
|
|
2801
2808
|
const canonicalJson2 = canonicalManifest(requests);
|
|
2802
|
-
return { requests, canonicalJson: canonicalJson2, digest:
|
|
2809
|
+
return { requests, canonicalJson: canonicalJson2, digest: sha256Hex(canonicalJson2), sourcePath: path };
|
|
2803
2810
|
}
|
|
2804
2811
|
var COLLECTOR_OWNER_PATTERN, COLLECTOR_REPO_PATTERN;
|
|
2805
2812
|
var init_collector_config = __esm({
|
|
2806
2813
|
"src/collector-config.ts"() {
|
|
2807
2814
|
"use strict";
|
|
2815
|
+
init_sha256();
|
|
2816
|
+
init_unknown_value();
|
|
2808
2817
|
COLLECTOR_OWNER_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/;
|
|
2809
2818
|
COLLECTOR_REPO_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,98}[A-Za-z0-9])?$/;
|
|
2810
2819
|
}
|
|
@@ -2899,7 +2908,7 @@ function unreadableDiscriminatorNotice(field, received) {
|
|
|
2899
2908
|
return `\u8BFB\u4E0D\u51FA ${field}\uFF1A${readableGateItem(received)}`;
|
|
2900
2909
|
}
|
|
2901
2910
|
function receivedDiscriminator(receipt, field) {
|
|
2902
|
-
if (
|
|
2911
|
+
if (!isRecord(receipt)) return void 0;
|
|
2903
2912
|
if (!Object.hasOwn(receipt, field)) return void 0;
|
|
2904
2913
|
return receipt[field];
|
|
2905
2914
|
}
|
|
@@ -2908,6 +2917,7 @@ var init_submission_errors = __esm({
|
|
|
2908
2917
|
"src/submission-errors.ts"() {
|
|
2909
2918
|
"use strict";
|
|
2910
2919
|
init_readable_gate_item();
|
|
2920
|
+
init_unknown_value();
|
|
2911
2921
|
GatekeeperDecisionError = class extends Error {
|
|
2912
2922
|
result;
|
|
2913
2923
|
constructor(result, message) {
|
|
@@ -2961,17 +2971,13 @@ function failureReason(error) {
|
|
|
2961
2971
|
function retainedReceipt(decision) {
|
|
2962
2972
|
return decision;
|
|
2963
2973
|
}
|
|
2964
|
-
function readRecord(value) {
|
|
2965
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
2966
|
-
return value;
|
|
2967
|
-
}
|
|
2968
2974
|
function reviewQueueStatus(status) {
|
|
2969
2975
|
return REVIEW_QUEUE_STATUSES.has(status) ? status : void 0;
|
|
2970
2976
|
}
|
|
2971
2977
|
function projectOfficerDecision(officer, decision, fallbackStatus) {
|
|
2972
2978
|
const receipt = retainedReceipt(decision);
|
|
2973
|
-
const
|
|
2974
|
-
const status = (
|
|
2979
|
+
const record = isRecord(decision) ? decision : void 0;
|
|
2980
|
+
const status = (record !== void 0 && typeof record.status === "string" ? record.status : void 0) ?? fallbackStatus;
|
|
2975
2981
|
const queueStatus = typeof status === "string" ? reviewQueueStatus(status) : void 0;
|
|
2976
2982
|
if (queueStatus === "converged") {
|
|
2977
2983
|
return { status: "converged", officer, receipt };
|
|
@@ -3125,6 +3131,7 @@ var init_gatekeeper_role = __esm({
|
|
|
3125
3131
|
init_review_submission();
|
|
3126
3132
|
init_gatekeeper_output();
|
|
3127
3133
|
init_run_terminal_artifacts();
|
|
3134
|
+
init_unknown_value();
|
|
3128
3135
|
init_submission_errors();
|
|
3129
3136
|
GATE_OFFICER_BY_SUBJECT = {
|
|
3130
3137
|
worker_completion: "inspector",
|
|
@@ -3273,7 +3280,7 @@ async function readAssistantUsageFromSessionFile(sessionFile) {
|
|
|
3273
3280
|
rows = text.trim().split("\n").filter(Boolean).map((line2) => JSON.parse(line2));
|
|
3274
3281
|
} catch (error) {
|
|
3275
3282
|
throw new Error(
|
|
3276
|
-
`session usage parse failed (${sessionFile}): ${
|
|
3283
|
+
`session usage parse failed (${sessionFile}): ${errorText(error)}`,
|
|
3277
3284
|
{ cause: error }
|
|
3278
3285
|
);
|
|
3279
3286
|
}
|
|
@@ -3349,6 +3356,7 @@ async function usageFromPublicSummon(summoned) {
|
|
|
3349
3356
|
var init_session_assistant_usage = __esm({
|
|
3350
3357
|
"src/session-assistant-usage.ts"() {
|
|
3351
3358
|
"use strict";
|
|
3359
|
+
init_unknown_value();
|
|
3352
3360
|
}
|
|
3353
3361
|
});
|
|
3354
3362
|
|
|
@@ -3399,16 +3407,16 @@ var init_durable_principal = __esm({
|
|
|
3399
3407
|
});
|
|
3400
3408
|
},
|
|
3401
3409
|
decode(value) {
|
|
3402
|
-
const
|
|
3403
|
-
if (
|
|
3410
|
+
const record = value;
|
|
3411
|
+
if (record === null || typeof record !== "object") {
|
|
3404
3412
|
throw new Error("durable principal payload is missing");
|
|
3405
3413
|
}
|
|
3406
|
-
if (typeof
|
|
3414
|
+
if (typeof record.sessionDirectory !== "string" || record.sessionDirectory.trim() === "") {
|
|
3407
3415
|
throw new Error("durable principal session directory is missing");
|
|
3408
3416
|
}
|
|
3409
3417
|
return {
|
|
3410
|
-
sessionDirectory:
|
|
3411
|
-
sessionFile: typeof
|
|
3418
|
+
sessionDirectory: record.sessionDirectory,
|
|
3419
|
+
sessionFile: typeof record.sessionFile === "string" && record.sessionFile.trim() !== "" ? record.sessionFile : join10(record.sessionDirectory, "session.jsonl")
|
|
3412
3420
|
};
|
|
3413
3421
|
}
|
|
3414
3422
|
};
|
|
@@ -3453,6 +3461,7 @@ var USER_DIALOGUE_STDIN_KIND;
|
|
|
3453
3461
|
var init_user_dialogue_stdin = __esm({
|
|
3454
3462
|
"src/user-dialogue-stdin.ts"() {
|
|
3455
3463
|
"use strict";
|
|
3464
|
+
init_unknown_value();
|
|
3456
3465
|
USER_DIALOGUE_STDIN_KIND = "ak-user-dialogue";
|
|
3457
3466
|
}
|
|
3458
3467
|
});
|
|
@@ -3995,9 +4004,7 @@ async function loadPublicCliConfig(home) {
|
|
|
3995
4004
|
const raw = await readFile7(path, "utf8");
|
|
3996
4005
|
return parsePublicCliConfig(JSON.parse(raw));
|
|
3997
4006
|
} catch (error) {
|
|
3998
|
-
if (error
|
|
3999
|
-
return { seats: {} };
|
|
4000
|
-
}
|
|
4007
|
+
if (isEnoent(error)) return { seats: {} };
|
|
4001
4008
|
throw error;
|
|
4002
4009
|
}
|
|
4003
4010
|
}
|
|
@@ -4218,35 +4225,35 @@ function serializePublicCliConfig(config) {
|
|
|
4218
4225
|
};
|
|
4219
4226
|
}
|
|
4220
4227
|
function parsePublicCliConfig(value) {
|
|
4221
|
-
if (
|
|
4228
|
+
if (!isRecord(value)) {
|
|
4222
4229
|
throw new Error("public CLI config must be an object");
|
|
4223
4230
|
}
|
|
4224
|
-
const
|
|
4231
|
+
const record = value;
|
|
4225
4232
|
let autoResumeLimit;
|
|
4226
|
-
if (
|
|
4227
|
-
autoResumeLimit = parseAutoResumeLimit(
|
|
4233
|
+
if (record.autoResumeLimit !== void 0) {
|
|
4234
|
+
autoResumeLimit = parseAutoResumeLimit(record.autoResumeLimit);
|
|
4228
4235
|
}
|
|
4229
4236
|
const unknownSeats = {};
|
|
4230
|
-
if (
|
|
4231
|
-
if (
|
|
4237
|
+
if (record.unknownSeats !== void 0) {
|
|
4238
|
+
if (!isRecord(record.unknownSeats)) {
|
|
4232
4239
|
throw new Error("public CLI config.unknownSeats must be an object");
|
|
4233
4240
|
}
|
|
4234
|
-
Object.assign(unknownSeats,
|
|
4241
|
+
Object.assign(unknownSeats, record.unknownSeats);
|
|
4235
4242
|
}
|
|
4236
4243
|
const withOpaque = (seats2) => ({
|
|
4237
4244
|
seats: seats2,
|
|
4238
4245
|
...autoResumeLimit === void 0 ? {} : { autoResumeLimit },
|
|
4239
4246
|
...Object.keys(unknownSeats).length === 0 ? {} : { unknownSeats }
|
|
4240
4247
|
});
|
|
4241
|
-
if (
|
|
4248
|
+
if (record.seats === void 0) {
|
|
4242
4249
|
return withOpaque({});
|
|
4243
4250
|
}
|
|
4244
|
-
if (
|
|
4251
|
+
if (!isRecord(record.seats)) {
|
|
4245
4252
|
throw new Error("public CLI config.seats must be an object");
|
|
4246
4253
|
}
|
|
4247
4254
|
const seats = {};
|
|
4248
4255
|
for (const [key, raw] of Object.entries(
|
|
4249
|
-
|
|
4256
|
+
record.seats
|
|
4250
4257
|
)) {
|
|
4251
4258
|
if (!isPublicConfigurableSeat(key)) {
|
|
4252
4259
|
unknownSeats[key] = raw;
|
|
@@ -4257,7 +4264,7 @@ function parsePublicCliConfig(value) {
|
|
|
4257
4264
|
return withOpaque(seats);
|
|
4258
4265
|
}
|
|
4259
4266
|
function parseSeatModelConfig(value, seat) {
|
|
4260
|
-
if (
|
|
4267
|
+
if (!isRecord(value)) {
|
|
4261
4268
|
throw new Error(`config seat ${seat} must be an object`);
|
|
4262
4269
|
}
|
|
4263
4270
|
const raw = value;
|
|
@@ -4439,13 +4446,13 @@ function listRolesForDisplay(config, credentials, invocation) {
|
|
|
4439
4446
|
return effectiveSeatConfigurations(config, credentials, invocation);
|
|
4440
4447
|
}
|
|
4441
4448
|
function credentialProvidersFromAuthData(data) {
|
|
4442
|
-
if (
|
|
4449
|
+
if (!isRecord(data)) {
|
|
4443
4450
|
return { "openai-codex": false, xai: false };
|
|
4444
4451
|
}
|
|
4445
|
-
const
|
|
4452
|
+
const record = data;
|
|
4446
4453
|
return {
|
|
4447
|
-
"openai-codex": Object.prototype.hasOwnProperty.call(
|
|
4448
|
-
xai: Object.prototype.hasOwnProperty.call(
|
|
4454
|
+
"openai-codex": Object.prototype.hasOwnProperty.call(record, "openai-codex"),
|
|
4455
|
+
xai: Object.prototype.hasOwnProperty.call(record, "xai")
|
|
4449
4456
|
};
|
|
4450
4457
|
}
|
|
4451
4458
|
function resolvePublicAgentDir(explicit, home) {
|
|
@@ -4456,9 +4463,7 @@ async function loadCredentialProviders(agentDir) {
|
|
|
4456
4463
|
const raw = await readFile7(join13(agentDir, "auth.json"), "utf8");
|
|
4457
4464
|
return credentialProvidersFromAuthData(JSON.parse(raw));
|
|
4458
4465
|
} catch (error) {
|
|
4459
|
-
if (error
|
|
4460
|
-
return { "openai-codex": false, xai: false };
|
|
4461
|
-
}
|
|
4466
|
+
if (isEnoent(error)) return { "openai-codex": false, xai: false };
|
|
4462
4467
|
throw error;
|
|
4463
4468
|
}
|
|
4464
4469
|
}
|
|
@@ -4471,8 +4476,9 @@ var init_config = __esm({
|
|
|
4471
4476
|
init_institutional_resolution();
|
|
4472
4477
|
init_packaged_role_registry();
|
|
4473
4478
|
init_registry();
|
|
4479
|
+
init_unknown_value();
|
|
4474
4480
|
GATE_OFFICER_SEATS = PUBLIC_ROLE_RECORDS.flatMap(
|
|
4475
|
-
(
|
|
4481
|
+
(record) => "provinceConfig" in record && record.provinceConfig === true ? [record.role] : []
|
|
4476
4482
|
);
|
|
4477
4483
|
}
|
|
4478
4484
|
});
|
|
@@ -4490,7 +4496,7 @@ function hermesProviderModelsCachePath(home) {
|
|
|
4490
4496
|
return join14(home, ".hermes", "provider_models_cache.json");
|
|
4491
4497
|
}
|
|
4492
4498
|
function parseHostProvidersTable(value) {
|
|
4493
|
-
if (
|
|
4499
|
+
if (!isRecord(value)) {
|
|
4494
4500
|
throw new Error("host-providers.json must be an object");
|
|
4495
4501
|
}
|
|
4496
4502
|
const out = {};
|
|
@@ -4498,13 +4504,11 @@ function parseHostProvidersTable(value) {
|
|
|
4498
4504
|
if (host.trim() === "") {
|
|
4499
4505
|
throw new Error("host-providers.json host key must be non-empty");
|
|
4500
4506
|
}
|
|
4501
|
-
if (
|
|
4507
|
+
if (!isRecord(byProvider)) {
|
|
4502
4508
|
throw new Error(`host-providers.json[${host}] must be an object`);
|
|
4503
4509
|
}
|
|
4504
4510
|
const providers = {};
|
|
4505
|
-
for (const [seatProvider, hostProvider] of Object.entries(
|
|
4506
|
-
byProvider
|
|
4507
|
-
)) {
|
|
4511
|
+
for (const [seatProvider, hostProvider] of Object.entries(byProvider)) {
|
|
4508
4512
|
if (seatProvider.trim() === "") {
|
|
4509
4513
|
throw new Error(
|
|
4510
4514
|
`host-providers.json[${host}] seat-provider key must be non-empty`
|
|
@@ -4529,9 +4533,7 @@ function loadHostProvidersTable(home) {
|
|
|
4529
4533
|
const raw = readFileSync(path, "utf8");
|
|
4530
4534
|
return parseHostProvidersTable(JSON.parse(raw));
|
|
4531
4535
|
} catch (error) {
|
|
4532
|
-
if (error
|
|
4533
|
-
return {};
|
|
4534
|
-
}
|
|
4536
|
+
if (isEnoent(error)) return {};
|
|
4535
4537
|
throw error;
|
|
4536
4538
|
}
|
|
4537
4539
|
}
|
|
@@ -4546,20 +4548,18 @@ function listHermesProvidersForModel(home, seatModel) {
|
|
|
4546
4548
|
try {
|
|
4547
4549
|
text = readFileSync(path, "utf8");
|
|
4548
4550
|
} catch (error) {
|
|
4549
|
-
if (error
|
|
4550
|
-
return [];
|
|
4551
|
-
}
|
|
4551
|
+
if (isEnoent(error)) return [];
|
|
4552
4552
|
throw error;
|
|
4553
4553
|
}
|
|
4554
4554
|
const raw = JSON.parse(text);
|
|
4555
|
-
if (
|
|
4555
|
+
if (!isRecord(raw)) {
|
|
4556
4556
|
throw new Error(
|
|
4557
4557
|
`hermes provider_models_cache.json must be an object: ${path}`
|
|
4558
4558
|
);
|
|
4559
4559
|
}
|
|
4560
4560
|
const found = [];
|
|
4561
4561
|
for (const [provider, entry] of Object.entries(raw)) {
|
|
4562
|
-
if (
|
|
4562
|
+
if (!isRecord(entry)) {
|
|
4563
4563
|
continue;
|
|
4564
4564
|
}
|
|
4565
4565
|
const models = entry.models;
|
|
@@ -4624,6 +4624,7 @@ var HostProviderResolutionError;
|
|
|
4624
4624
|
var init_host_providers = __esm({
|
|
4625
4625
|
"src/public-cli/host-providers.ts"() {
|
|
4626
4626
|
"use strict";
|
|
4627
|
+
init_unknown_value();
|
|
4627
4628
|
HostProviderResolutionError = class extends Error {
|
|
4628
4629
|
host;
|
|
4629
4630
|
seatProvider;
|
|
@@ -4641,17 +4642,6 @@ var init_host_providers = __esm({
|
|
|
4641
4642
|
}
|
|
4642
4643
|
});
|
|
4643
4644
|
|
|
4644
|
-
// src/sha256.ts
|
|
4645
|
-
import { createHash as createHash2 } from "node:crypto";
|
|
4646
|
-
function sha256Hex(bytes) {
|
|
4647
|
-
return createHash2("sha256").update(bytes).digest("hex");
|
|
4648
|
-
}
|
|
4649
|
-
var init_sha256 = __esm({
|
|
4650
|
-
"src/sha256.ts"() {
|
|
4651
|
-
"use strict";
|
|
4652
|
-
}
|
|
4653
|
-
});
|
|
4654
|
-
|
|
4655
4645
|
// src/submission-correctable-error.ts
|
|
4656
4646
|
function isCorrectableSubmissionError(error) {
|
|
4657
4647
|
return error instanceof CorrectableSubmissionError;
|
|
@@ -4660,7 +4650,7 @@ function isCorrectableExecuteError(error) {
|
|
|
4660
4650
|
return isCorrectableSubmissionError(error) || error instanceof GatekeeperDecisionError || error instanceof ParentQueueReaskError || error instanceof WorkerCommitReminderError || error instanceof WorkerPrefixReminderError || error instanceof WorkerUnfinishedReasonReminderError;
|
|
4661
4651
|
}
|
|
4662
4652
|
function projectCorrectableExecuteRejection(error) {
|
|
4663
|
-
const diagnostic =
|
|
4653
|
+
const diagnostic = errorText(error);
|
|
4664
4654
|
if (error instanceof GatekeeperDecisionError) {
|
|
4665
4655
|
return { diagnostic, details: { ...error.result } };
|
|
4666
4656
|
}
|
|
@@ -4682,6 +4672,7 @@ var init_submission_correctable_error = __esm({
|
|
|
4682
4672
|
"src/submission-correctable-error.ts"() {
|
|
4683
4673
|
"use strict";
|
|
4684
4674
|
init_submission_errors();
|
|
4675
|
+
init_unknown_value();
|
|
4685
4676
|
correctableSubmissionErrorBrand = /* @__PURE__ */ Symbol("ak-roles.correctable-submission-error");
|
|
4686
4677
|
CorrectableSubmissionError = class extends Error {
|
|
4687
4678
|
[correctableSubmissionErrorBrand] = true;
|
|
@@ -4694,20 +4685,20 @@ function isTerminatingToolName(name) {
|
|
|
4694
4685
|
return TERMINATING_TOOL_NAMES.includes(name);
|
|
4695
4686
|
}
|
|
4696
4687
|
function validateAcceptedDetails(_toolName, details) {
|
|
4697
|
-
if (
|
|
4688
|
+
if (isRecord(details)) {
|
|
4698
4689
|
return details;
|
|
4699
4690
|
}
|
|
4700
4691
|
return {};
|
|
4701
4692
|
}
|
|
4702
4693
|
function acceptedFacts(toolName, details) {
|
|
4703
|
-
const
|
|
4694
|
+
const record = details;
|
|
4704
4695
|
const entry = PACKAGED_ROLE_REGISTRY.find((candidate) => candidate.outputTool === toolName);
|
|
4705
4696
|
const legacyRole = LEGACY_REVIEW_OUTPUT_ROLES.get(toolName);
|
|
4706
4697
|
const statusKey = legacyRole === "judge" || legacyRole === "countersign" ? `${legacyRole}Status` : entry !== void 0 && "receiptStatusKey" in entry ? entry.receiptStatusKey : "status";
|
|
4707
|
-
const status = typeof
|
|
4698
|
+
const status = typeof record[statusKey] === "string" ? record[statusKey] : void 0;
|
|
4708
4699
|
const commitKey = entry !== void 0 && "receiptCommitKey" in entry ? entry.receiptCommitKey : void 0;
|
|
4709
4700
|
const commitWhen = entry !== void 0 && "receiptCommitWhen" in entry ? entry.receiptCommitWhen : void 0;
|
|
4710
|
-
const commit = commitKey !== void 0 && status === commitWhen && typeof
|
|
4701
|
+
const commit = commitKey !== void 0 && status === commitWhen && typeof record[commitKey] === "string" ? record[commitKey] : void 0;
|
|
4711
4702
|
return {
|
|
4712
4703
|
...status === void 0 ? {} : { status },
|
|
4713
4704
|
...commit === void 0 ? {} : { commit }
|
|
@@ -4734,6 +4725,7 @@ var init_terminating_tools = __esm({
|
|
|
4734
4725
|
init_diarist_contracts();
|
|
4735
4726
|
init_secretariat_contracts();
|
|
4736
4727
|
init_worker_output();
|
|
4728
|
+
init_unknown_value();
|
|
4737
4729
|
TERMINATING_TOOL_NAMES = [.../* @__PURE__ */ new Set([
|
|
4738
4730
|
...PACKAGED_ROLE_REGISTRY.map((entry) => entry.outputTool),
|
|
4739
4731
|
...LEGACY_REVIEW_OUTPUT_ROLES.keys()
|
|
@@ -4751,9 +4743,6 @@ var init_terminating_tools = __esm({
|
|
|
4751
4743
|
// src/doctor-evidence.ts
|
|
4752
4744
|
import { readdir as readdir3, readFile as readFile8, realpath as realpath2, stat } from "node:fs/promises";
|
|
4753
4745
|
import { dirname as dirname8, relative as relative2, resolve as resolve5, sep as sep2 } from "node:path";
|
|
4754
|
-
function record3(value) {
|
|
4755
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4756
|
-
}
|
|
4757
4746
|
async function discoverCaseFiles(root) {
|
|
4758
4747
|
const found = [];
|
|
4759
4748
|
async function walk(dir, depth) {
|
|
@@ -4777,9 +4766,6 @@ function accumulate(metric, value, source) {
|
|
|
4777
4766
|
function timestamp(row) {
|
|
4778
4767
|
return typeof row.timestamp === "string" && Number.isFinite(Date.parse(row.timestamp)) ? row.timestamp : void 0;
|
|
4779
4768
|
}
|
|
4780
|
-
function isMissingPathError3(error) {
|
|
4781
|
-
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
4782
|
-
}
|
|
4783
4769
|
async function stableRunsIdentity(root) {
|
|
4784
4770
|
let cursor = root;
|
|
4785
4771
|
while (true) {
|
|
@@ -4787,7 +4773,7 @@ async function stableRunsIdentity(root) {
|
|
|
4787
4773
|
const git3 = await stat(resolve5(cursor, ".git"));
|
|
4788
4774
|
if (git3.isDirectory() || git3.isFile()) return relative2(cursor, root).split(sep2).join("/");
|
|
4789
4775
|
} catch (error) {
|
|
4790
|
-
if (!
|
|
4776
|
+
if (!isMissingPathError(error)) throw error;
|
|
4791
4777
|
}
|
|
4792
4778
|
const parent = dirname8(cursor);
|
|
4793
4779
|
if (parent === cursor) return root;
|
|
@@ -4800,7 +4786,7 @@ function deriveSession(content, id) {
|
|
|
4800
4786
|
for (const line2 of content.split("\n")) if (line2.trim()) {
|
|
4801
4787
|
try {
|
|
4802
4788
|
const row = JSON.parse(line2);
|
|
4803
|
-
if (!
|
|
4789
|
+
if (!isRecord(row)) {
|
|
4804
4790
|
degradationReasons.push(`non-object session row in ${id}`);
|
|
4805
4791
|
break;
|
|
4806
4792
|
}
|
|
@@ -4819,17 +4805,17 @@ function deriveSession(content, id) {
|
|
|
4819
4805
|
let accepted, observedCommit, turns = 0, calls = 0, tokens = 0;
|
|
4820
4806
|
const statuses = [], commits = [];
|
|
4821
4807
|
for (const row of rows) {
|
|
4822
|
-
if (row.type === "custom" && row.customType === "ak-role-submission-closure" &&
|
|
4823
|
-
const message =
|
|
4808
|
+
if (row.type === "custom" && row.customType === "ak-role-submission-closure" && isRecord(row.data) && row.data.isError === false && typeof row.data.toolName === "string" && isTerminatingToolName(row.data.toolName)) accepted = row;
|
|
4809
|
+
const message = isRecord(row.message) ? row.message : void 0;
|
|
4824
4810
|
if (message?.role === "assistant") {
|
|
4825
|
-
for (const part of Array.isArray(message.content) ? message.content : []) if (
|
|
4811
|
+
for (const part of Array.isArray(message.content) ? message.content : []) if (isRecord(part) && part.type === "toolCall") calls++;
|
|
4826
4812
|
if (typeof message.responseId === "string") {
|
|
4827
4813
|
turns++;
|
|
4828
|
-
const usage =
|
|
4814
|
+
const usage = isRecord(message.usage) ? message.usage : void 0;
|
|
4829
4815
|
if (usage && typeof usage.output === "number") tokens += usage.output;
|
|
4830
4816
|
}
|
|
4831
4817
|
}
|
|
4832
|
-
if (message?.role === "toolResult" && message.isError !== true && typeof message.toolName === "string" && isTerminatingToolName(message.toolName) &&
|
|
4818
|
+
if (message?.role === "toolResult" && message.isError !== true && typeof message.toolName === "string" && isTerminatingToolName(message.toolName) && isRecord(message.details)) {
|
|
4833
4819
|
let details;
|
|
4834
4820
|
try {
|
|
4835
4821
|
details = validateAcceptedDetails(message.toolName, message.details);
|
|
@@ -4890,6 +4876,7 @@ var init_doctor_evidence = __esm({
|
|
|
4890
4876
|
"use strict";
|
|
4891
4877
|
init_sha256();
|
|
4892
4878
|
init_terminating_tools();
|
|
4879
|
+
init_unknown_value();
|
|
4893
4880
|
}
|
|
4894
4881
|
});
|
|
4895
4882
|
|
|
@@ -5039,9 +5026,6 @@ var init_merger_git_state = __esm({
|
|
|
5039
5026
|
|
|
5040
5027
|
// src/ledger-session-read.ts
|
|
5041
5028
|
import { readFile as readFile10 } from "node:fs/promises";
|
|
5042
|
-
function isRecord4(value) {
|
|
5043
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5044
|
-
}
|
|
5045
5029
|
async function readLedgerSessionJsonlLines(path) {
|
|
5046
5030
|
const text = await readFile10(path, "utf8");
|
|
5047
5031
|
const lines = text.split("\n");
|
|
@@ -5064,7 +5048,7 @@ async function readLedgerSessionJsonlLines(path) {
|
|
|
5064
5048
|
});
|
|
5065
5049
|
continue;
|
|
5066
5050
|
}
|
|
5067
|
-
if (!
|
|
5051
|
+
if (!isRecord(row)) {
|
|
5068
5052
|
const kind = row === null ? "null" : Array.isArray(row) ? "array" : typeof row;
|
|
5069
5053
|
out.push({
|
|
5070
5054
|
line: lineNumber,
|
|
@@ -5117,7 +5101,7 @@ function extractSessionModelSequence(rows) {
|
|
|
5117
5101
|
if (row.type === "model_change" && typeof row.modelId === "string") {
|
|
5118
5102
|
push(row.modelId);
|
|
5119
5103
|
}
|
|
5120
|
-
const message =
|
|
5104
|
+
const message = isRecord(row.message) ? row.message : void 0;
|
|
5121
5105
|
if (message?.role === "assistant" && typeof message.model === "string") {
|
|
5122
5106
|
push(message.model);
|
|
5123
5107
|
}
|
|
@@ -5133,11 +5117,11 @@ function extractSessionToolIntervals(rows) {
|
|
|
5133
5117
|
const openById = /* @__PURE__ */ new Map();
|
|
5134
5118
|
for (const row of rows) {
|
|
5135
5119
|
const rowTimestamp = typeof row.timestamp === "string" ? row.timestamp : void 0;
|
|
5136
|
-
const message =
|
|
5120
|
+
const message = isRecord(row.message) ? row.message : void 0;
|
|
5137
5121
|
if (message?.role === "assistant" && Array.isArray(message.content)) {
|
|
5138
5122
|
const callTimestamp = typeof message.timestamp === "string" && message.timestamp ? message.timestamp : rowTimestamp;
|
|
5139
5123
|
for (const part of message.content) {
|
|
5140
|
-
if (!
|
|
5124
|
+
if (!isRecord(part) || part.type !== "toolCall") continue;
|
|
5141
5125
|
if (typeof part.id !== "string" || part.id.length === 0) {
|
|
5142
5126
|
throw new Error("toolCall frame missing string id");
|
|
5143
5127
|
}
|
|
@@ -5150,7 +5134,7 @@ function extractSessionToolIntervals(rows) {
|
|
|
5150
5134
|
if (openById.has(part.id)) {
|
|
5151
5135
|
throw new Error(`duplicate toolCall id ${part.id}`);
|
|
5152
5136
|
}
|
|
5153
|
-
const args =
|
|
5137
|
+
const args = isRecord(part.arguments) ? part.arguments : void 0;
|
|
5154
5138
|
const command = part.name === "bash" && args !== void 0 && typeof args.command === "string" ? bashCommandFirstLine(args.command) : void 0;
|
|
5155
5139
|
const interval = {
|
|
5156
5140
|
toolCallId: part.id,
|
|
@@ -5218,6 +5202,7 @@ var LedgerSessionJsonlError;
|
|
|
5218
5202
|
var init_ledger_session_read = __esm({
|
|
5219
5203
|
"src/ledger-session-read.ts"() {
|
|
5220
5204
|
"use strict";
|
|
5205
|
+
init_unknown_value();
|
|
5221
5206
|
LedgerSessionJsonlError = class extends Error {
|
|
5222
5207
|
path;
|
|
5223
5208
|
line;
|
|
@@ -5234,9 +5219,6 @@ var init_ledger_session_read = __esm({
|
|
|
5234
5219
|
});
|
|
5235
5220
|
|
|
5236
5221
|
// src/session-dialogue.ts
|
|
5237
|
-
function isRecord5(value) {
|
|
5238
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5239
|
-
}
|
|
5240
5222
|
function nativeEventId(row) {
|
|
5241
5223
|
for (const key of ["uuid", "id"]) {
|
|
5242
5224
|
const value = row[key];
|
|
@@ -5244,7 +5226,7 @@ function nativeEventId(row) {
|
|
|
5244
5226
|
}
|
|
5245
5227
|
for (const nestKey of ["message", "payload"]) {
|
|
5246
5228
|
const nested = row[nestKey];
|
|
5247
|
-
if (!
|
|
5229
|
+
if (!isRecord(nested)) continue;
|
|
5248
5230
|
for (const key of ["uuid", "id"]) {
|
|
5249
5231
|
const value = nested[key];
|
|
5250
5232
|
if (typeof value === "string" && value !== "") return value;
|
|
@@ -5257,19 +5239,19 @@ function textParts(content) {
|
|
|
5257
5239
|
if (!Array.isArray(content)) return [];
|
|
5258
5240
|
const out = [];
|
|
5259
5241
|
for (const part of content) {
|
|
5260
|
-
if (!
|
|
5242
|
+
if (!isRecord(part) || !SPEAKER_TEXT_PART_TYPES.has(String(part.type))) continue;
|
|
5261
5243
|
const text = part.text;
|
|
5262
5244
|
if (typeof text === "string" && text !== "") out.push(text);
|
|
5263
5245
|
}
|
|
5264
5246
|
return out;
|
|
5265
5247
|
}
|
|
5266
5248
|
function responseItemMessage(row) {
|
|
5267
|
-
if (row.type !== "response_item" || !
|
|
5249
|
+
if (row.type !== "response_item" || !isRecord(row.payload)) return void 0;
|
|
5268
5250
|
if (row.payload.type !== "message") return void 0;
|
|
5269
5251
|
return row.payload;
|
|
5270
5252
|
}
|
|
5271
5253
|
function messageBody(row) {
|
|
5272
|
-
if (
|
|
5254
|
+
if (isRecord(row.message)) return row.message;
|
|
5273
5255
|
return responseItemMessage(row);
|
|
5274
5256
|
}
|
|
5275
5257
|
function speakerOf(message) {
|
|
@@ -5279,7 +5261,7 @@ function speakerOf(message) {
|
|
|
5279
5261
|
}
|
|
5280
5262
|
function codexContentItemKinds(message) {
|
|
5281
5263
|
const pass = message.internal_chat_message_metadata_passthrough;
|
|
5282
|
-
if (!
|
|
5264
|
+
if (!isRecord(pass) || !Array.isArray(pass.content_item_kinds)) return void 0;
|
|
5283
5265
|
const kinds = [];
|
|
5284
5266
|
for (const kind of pass.content_item_kinds) {
|
|
5285
5267
|
if (typeof kind === "string" && kind !== "") kinds.push(kind);
|
|
@@ -5308,7 +5290,7 @@ function isFixedNonOwnerEnqueueShape(content) {
|
|
|
5308
5290
|
return hasFixedOpenTagPrefix(content, TASK_NOTIFICATION_OPEN_TAG);
|
|
5309
5291
|
}
|
|
5310
5292
|
function materializationOriginKind(row) {
|
|
5311
|
-
if (!
|
|
5293
|
+
if (!isRecord(row.origin)) return void 0;
|
|
5312
5294
|
const kind = row.origin.kind;
|
|
5313
5295
|
return typeof kind === "string" && kind !== "" ? kind : void 0;
|
|
5314
5296
|
}
|
|
@@ -5349,6 +5331,7 @@ var SPEAKER_TEXT_PART_TYPES, TASK_NOTIFICATION_OPEN_TAG;
|
|
|
5349
5331
|
var init_session_dialogue = __esm({
|
|
5350
5332
|
"src/session-dialogue.ts"() {
|
|
5351
5333
|
"use strict";
|
|
5334
|
+
init_unknown_value();
|
|
5352
5335
|
SPEAKER_TEXT_PART_TYPES = /* @__PURE__ */ new Set(["text", "input_text", "output_text"]);
|
|
5353
5336
|
TASK_NOTIFICATION_OPEN_TAG = "<task-notification";
|
|
5354
5337
|
}
|
|
@@ -5491,7 +5474,7 @@ async function projectSessionRanges(input) {
|
|
|
5491
5474
|
if (error instanceof TicketProvenanceInputError) throw error;
|
|
5492
5475
|
const code = errnoCode(error);
|
|
5493
5476
|
if (code === "ENOENT" || code === "ENOTDIR" || code === "EISDIR") {
|
|
5494
|
-
const detail =
|
|
5477
|
+
const detail = errorText(error);
|
|
5495
5478
|
throw new TicketProvenanceInputError(
|
|
5496
5479
|
`session unreadable: ${input.session.path} (${detail})`,
|
|
5497
5480
|
{ cause: error }
|
|
@@ -5571,6 +5554,7 @@ var init_ticket_provenance = __esm({
|
|
|
5571
5554
|
init_session_dialogue();
|
|
5572
5555
|
init_sitian_facade();
|
|
5573
5556
|
init_ticket_provenance_contracts();
|
|
5557
|
+
init_unknown_value();
|
|
5574
5558
|
TicketProvenanceInputError = class extends Error {
|
|
5575
5559
|
code = "ticket-provenance-input";
|
|
5576
5560
|
constructor(message, options) {
|
|
@@ -7454,8 +7438,8 @@ function admissionCallerOptions(env) {
|
|
|
7454
7438
|
};
|
|
7455
7439
|
}
|
|
7456
7440
|
async function admitPublicRole(role, parsed, env, override) {
|
|
7457
|
-
const
|
|
7458
|
-
if (
|
|
7441
|
+
const record = packagedRoleMetadata(role);
|
|
7442
|
+
if (record === void 0) {
|
|
7459
7443
|
throw new CliUsageError(`unknown role: ${role}`);
|
|
7460
7444
|
}
|
|
7461
7445
|
const shared = {
|
|
@@ -7465,7 +7449,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7465
7449
|
const instruction = parsed.instruction ?? "";
|
|
7466
7450
|
const attachmentPaths = parsed.attachmentPaths ?? [];
|
|
7467
7451
|
const project = parsed.project === void 0 ? {} : { project: parsed.project };
|
|
7468
|
-
switch (
|
|
7452
|
+
switch (record.admission) {
|
|
7469
7453
|
case "instruction":
|
|
7470
7454
|
return admitStandardMaterialInvocation(
|
|
7471
7455
|
role,
|
|
@@ -7489,7 +7473,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7489
7473
|
throw new CliUsageError("coder requires a nonblank task instruction");
|
|
7490
7474
|
}
|
|
7491
7475
|
const phase = parsed.phase ?? "apply";
|
|
7492
|
-
if (!
|
|
7476
|
+
if (!record.phases.some((item) => item === phase)) {
|
|
7493
7477
|
throw new CliUsageError("coder phase must be plan or apply");
|
|
7494
7478
|
}
|
|
7495
7479
|
return admitStandardMaterialInvocation("coder", {
|
|
@@ -7509,7 +7493,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7509
7493
|
throw new CliUsageError("fixer requires a nonblank repair instruction");
|
|
7510
7494
|
}
|
|
7511
7495
|
const phase = parsed.phase ?? "apply";
|
|
7512
|
-
if (!
|
|
7496
|
+
if (!record.phases.some((item) => item === phase)) {
|
|
7513
7497
|
throw new CliUsageError("fixer phase must be plan or apply");
|
|
7514
7498
|
}
|
|
7515
7499
|
let prerequisites = Object.freeze([]);
|
|
@@ -7568,7 +7552,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7568
7552
|
try {
|
|
7569
7553
|
repository = parseCollectorRepository(parsed.repo);
|
|
7570
7554
|
} catch (error) {
|
|
7571
|
-
const detail =
|
|
7555
|
+
const detail = errorText(error);
|
|
7572
7556
|
throw new CliUsageError(detail, { cause: error });
|
|
7573
7557
|
}
|
|
7574
7558
|
} else {
|
|
@@ -7582,7 +7566,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7582
7566
|
manifestCanonicalJson = manifest.canonicalJson;
|
|
7583
7567
|
} catch (error) {
|
|
7584
7568
|
throw new CliUsageError(
|
|
7585
|
-
|
|
7569
|
+
errorText(error),
|
|
7586
7570
|
{ cause: error }
|
|
7587
7571
|
);
|
|
7588
7572
|
}
|
|
@@ -7636,7 +7620,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7636
7620
|
});
|
|
7637
7621
|
} catch (error) {
|
|
7638
7622
|
if (error instanceof CliUsageError) throw error;
|
|
7639
|
-
const detail =
|
|
7623
|
+
const detail = errorText(error);
|
|
7640
7624
|
throw new CliUsageError(detail, { cause: error });
|
|
7641
7625
|
}
|
|
7642
7626
|
if (parsed.runs === void 0) {
|
|
@@ -7654,7 +7638,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7654
7638
|
caseRunsPath = await realpath4(caseRunsPath);
|
|
7655
7639
|
} catch (error) {
|
|
7656
7640
|
if (error instanceof CliUsageError) throw error;
|
|
7657
|
-
const detail =
|
|
7641
|
+
const detail = errorText(error);
|
|
7658
7642
|
throw new CliUsageError(
|
|
7659
7643
|
`doctor case could not be constructed from retained evidence: ${detail}`,
|
|
7660
7644
|
{ cause: error }
|
|
@@ -7922,8 +7906,8 @@ async function admitStandardMaterialInvocation(role, options) {
|
|
|
7922
7906
|
}
|
|
7923
7907
|
function admittedTransportPromptKind(admitted) {
|
|
7924
7908
|
if (admitted.role === void 0) return "instruction";
|
|
7925
|
-
const
|
|
7926
|
-
if (
|
|
7909
|
+
const record = packagedRoleMetadata(admitted.role);
|
|
7910
|
+
if (record !== void 0 && "transportPrompt" in record) return record.transportPrompt;
|
|
7927
7911
|
return "instruction";
|
|
7928
7912
|
}
|
|
7929
7913
|
function buildInstructionTransportPrompt(admitted, engineMaterial) {
|
|
@@ -8010,16 +7994,16 @@ async function loadAdmittedJudgeRequest(runDirectory) {
|
|
|
8010
7994
|
const raw = JSON.parse(
|
|
8011
7995
|
await readFile12(join17(runDirectory, "admitted-request.json"), "utf8")
|
|
8012
7996
|
);
|
|
8013
|
-
if (
|
|
8014
|
-
const
|
|
8015
|
-
if (!packagedPublicInstructionSubject(
|
|
8016
|
-
if (typeof
|
|
8017
|
-
if (typeof
|
|
8018
|
-
if (!Array.isArray(
|
|
7997
|
+
if (!isRecord(raw)) return void 0;
|
|
7998
|
+
const record = raw;
|
|
7999
|
+
if (!packagedPublicInstructionSubject(record.role)) return void 0;
|
|
8000
|
+
if (typeof record.instruction !== "string") return void 0;
|
|
8001
|
+
if (typeof record.instructionEmpty !== "boolean") return void 0;
|
|
8002
|
+
if (!Array.isArray(record.attachments)) return void 0;
|
|
8019
8003
|
return {
|
|
8020
|
-
instruction:
|
|
8021
|
-
instructionEmpty:
|
|
8022
|
-
attachments:
|
|
8004
|
+
instruction: record.instruction,
|
|
8005
|
+
instructionEmpty: record.instructionEmpty,
|
|
8006
|
+
attachments: record.attachments
|
|
8023
8007
|
};
|
|
8024
8008
|
} catch {
|
|
8025
8009
|
return void 0;
|
|
@@ -8037,7 +8021,7 @@ function parsePositivePrOption(raw) {
|
|
|
8037
8021
|
try {
|
|
8038
8022
|
return parseCollectorPrNumber(raw);
|
|
8039
8023
|
} catch (error) {
|
|
8040
|
-
throw new CliUsageError(
|
|
8024
|
+
throw new CliUsageError(errorText(error), { cause: error });
|
|
8041
8025
|
}
|
|
8042
8026
|
}
|
|
8043
8027
|
function parseRepoOption(raw) {
|
|
@@ -8077,7 +8061,7 @@ function resolveGitHubRemoteRepository(projectRoot) {
|
|
|
8077
8061
|
try {
|
|
8078
8062
|
return parseCollectorRepository(ownerRepo);
|
|
8079
8063
|
} catch (error) {
|
|
8080
|
-
const detail =
|
|
8064
|
+
const detail = errorText(error);
|
|
8081
8065
|
throw new CliUsageError(detail, { cause: error });
|
|
8082
8066
|
}
|
|
8083
8067
|
}
|
|
@@ -8124,7 +8108,7 @@ async function resolveDoctorCaseRunsPath(options) {
|
|
|
8124
8108
|
try {
|
|
8125
8109
|
real = await realpath4(resolved);
|
|
8126
8110
|
} catch (error) {
|
|
8127
|
-
const detail =
|
|
8111
|
+
const detail = errorText(error);
|
|
8128
8112
|
throw new CliUsageError(
|
|
8129
8113
|
`doctor --runs is not a readable retained runs root: ${detail}`,
|
|
8130
8114
|
{ cause: error }
|
|
@@ -8410,6 +8394,7 @@ var init_invocation = __esm({
|
|
|
8410
8394
|
init_engine_material();
|
|
8411
8395
|
init_cli_errors();
|
|
8412
8396
|
init_option_definitions();
|
|
8397
|
+
init_unknown_value();
|
|
8413
8398
|
DOCTOR_ISSUE_NUMBER_PATTERN = /^[1-9]\d*$/;
|
|
8414
8399
|
DOCTOR_CASE_RUNS_PATH_PATTERN = /\/\.ak-roles\/books\/[^/]+\/(?:issues\/)?([1-9]\d*)\/runs$/;
|
|
8415
8400
|
ANALYST_TICKET_NUMBER_PATTERN = /^[1-9]\d*$/;
|
|
@@ -8620,18 +8605,12 @@ var init_role_seat_runtime = __esm({
|
|
|
8620
8605
|
// src/analyst-gate-cycles-read.ts
|
|
8621
8606
|
import { readdir as readdir4 } from "node:fs/promises";
|
|
8622
8607
|
import { join as join20 } from "node:path";
|
|
8623
|
-
function isRecord6(value) {
|
|
8624
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8625
|
-
}
|
|
8626
8608
|
function isParentAttemptBindingRow(row) {
|
|
8627
8609
|
return row.type === "custom" && row.customType === AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE;
|
|
8628
8610
|
}
|
|
8629
8611
|
function intervalRowsForGateCall(rows, callRowIndex) {
|
|
8630
8612
|
return intervalRowsAroundAnchor(rows, callRowIndex, isParentAttemptBindingRow).rows;
|
|
8631
8613
|
}
|
|
8632
|
-
function isMissingDirectoryError(error) {
|
|
8633
|
-
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
8634
|
-
}
|
|
8635
8614
|
function normalizeOfficerArg(raw) {
|
|
8636
8615
|
if (typeof raw !== "string") return void 0;
|
|
8637
8616
|
return OFFICER_ARG_ALIASES[raw.trim()];
|
|
@@ -8650,7 +8629,7 @@ function isGateTerminatingToolName(toolName) {
|
|
|
8650
8629
|
function acceptedGateReceiptIds(rows) {
|
|
8651
8630
|
const accepted = /* @__PURE__ */ new Set();
|
|
8652
8631
|
for (const row of rows) {
|
|
8653
|
-
const message =
|
|
8632
|
+
const message = isRecord(row.message) ? row.message : void 0;
|
|
8654
8633
|
if (message?.role !== "toolResult") continue;
|
|
8655
8634
|
if (typeof message.toolCallId !== "string" || message.toolCallId.length === 0) continue;
|
|
8656
8635
|
if (message.isError === false) accepted.add(message.toolCallId);
|
|
@@ -8685,7 +8664,7 @@ function nearestAttemptBindingBefore(rows, beforeIndex) {
|
|
|
8685
8664
|
for (let i = beforeIndex - 1; i >= 0; i -= 1) {
|
|
8686
8665
|
const row = rows[i];
|
|
8687
8666
|
if (!isParentAttemptBindingRow(row)) continue;
|
|
8688
|
-
if (!
|
|
8667
|
+
if (!isRecord(row.data) || !isRecord(row.data.parent)) continue;
|
|
8689
8668
|
const id = row.data.parent.attemptEntryId;
|
|
8690
8669
|
const sessionFile = row.data.parent.sessionFile;
|
|
8691
8670
|
return {
|
|
@@ -8700,10 +8679,10 @@ function extractAllAcceptedGateToolCalls(rows) {
|
|
|
8700
8679
|
const out = [];
|
|
8701
8680
|
for (let rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
|
|
8702
8681
|
const row = rows[rowIndex];
|
|
8703
|
-
const message =
|
|
8682
|
+
const message = isRecord(row.message) ? row.message : void 0;
|
|
8704
8683
|
if (message?.role !== "assistant" || !Array.isArray(message.content)) continue;
|
|
8705
8684
|
for (const part of message.content) {
|
|
8706
|
-
if (!
|
|
8685
|
+
if (!isRecord(part) || part.type !== "toolCall") continue;
|
|
8707
8686
|
if (typeof part.id !== "string" || part.id.length === 0) continue;
|
|
8708
8687
|
if (typeof part.name !== "string" || part.name.length === 0) continue;
|
|
8709
8688
|
if (!isGateTerminatingToolName(part.name)) continue;
|
|
@@ -8711,7 +8690,7 @@ function extractAllAcceptedGateToolCalls(rows) {
|
|
|
8711
8690
|
const binding = nearestAttemptBindingBefore(rows, rowIndex);
|
|
8712
8691
|
out.push({
|
|
8713
8692
|
toolName: part.name,
|
|
8714
|
-
args:
|
|
8693
|
+
args: isRecord(part.arguments) ? part.arguments : void 0,
|
|
8715
8694
|
accepted: true,
|
|
8716
8695
|
rowIndex,
|
|
8717
8696
|
...binding
|
|
@@ -8840,11 +8819,11 @@ async function resolveOfficerSessionFromPointerFile(pointerPath) {
|
|
|
8840
8819
|
raw = JSON.parse(await readFile25(pointerPath, "utf8"));
|
|
8841
8820
|
} catch (error) {
|
|
8842
8821
|
throw new Error(
|
|
8843
|
-
`direct officer run pointer unreadable in ${pointerPath}: ${
|
|
8822
|
+
`direct officer run pointer unreadable in ${pointerPath}: ${errorText(error)}`,
|
|
8844
8823
|
{ cause: error }
|
|
8845
8824
|
);
|
|
8846
8825
|
}
|
|
8847
|
-
if (!
|
|
8826
|
+
if (!isRecord(raw) || raw.kind !== "direct-officer-run-pointer" || raw.version !== 1) {
|
|
8848
8827
|
throw new Error(`direct officer run pointer has unknown shape in ${pointerPath}`);
|
|
8849
8828
|
}
|
|
8850
8829
|
const sessionFile = raw.sessionFile;
|
|
@@ -8866,7 +8845,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
|
|
|
8866
8845
|
(e) => e.isFile() && (e.name.endsWith(".jsonl") || e.name.endsWith(".pointer.json"))
|
|
8867
8846
|
).map((e) => e.name).sort();
|
|
8868
8847
|
} catch (error) {
|
|
8869
|
-
if (
|
|
8848
|
+
if (isEnoent(error)) continue;
|
|
8870
8849
|
throw error;
|
|
8871
8850
|
}
|
|
8872
8851
|
for (const name of names) {
|
|
@@ -8895,6 +8874,7 @@ var init_analyst_gate_cycles_read = __esm({
|
|
|
8895
8874
|
"use strict";
|
|
8896
8875
|
init_compliance_transport();
|
|
8897
8876
|
init_ledger_session_read();
|
|
8877
|
+
init_unknown_value();
|
|
8898
8878
|
DISPATCH_TOOLS = /* @__PURE__ */ new Set(["ak_menxia_output", "ak_gatekeeper_output"]);
|
|
8899
8879
|
OFFICER_TOOL_TO_FACE = {
|
|
8900
8880
|
ak_jishizhong_output: "inspector",
|
|
@@ -8915,6 +8895,7 @@ var init_analyst_gate_cycles_read = __esm({
|
|
|
8915
8895
|
var init_audit_escalation = __esm({
|
|
8916
8896
|
"src/audit-escalation.ts"() {
|
|
8917
8897
|
"use strict";
|
|
8898
|
+
init_unknown_value();
|
|
8918
8899
|
}
|
|
8919
8900
|
});
|
|
8920
8901
|
|
|
@@ -8967,7 +8948,7 @@ var init_session_opening_materials = __esm({
|
|
|
8967
8948
|
packageRootUrl = pathToFileURL3(resolvePackageRootDir() + "/").href;
|
|
8968
8949
|
MAIN_ROLE_SESSION_MATERIALS = {
|
|
8969
8950
|
...Object.fromEntries(
|
|
8970
|
-
PUBLIC_ROLE_RECORDS.map((
|
|
8951
|
+
PUBLIC_ROLE_RECORDS.map((record) => [record.role, record.sessionMaterials])
|
|
8971
8952
|
)
|
|
8972
8953
|
};
|
|
8973
8954
|
GATEKEEPER_SESSION_MATERIALS = {
|
|
@@ -9042,17 +9023,18 @@ async function readAuditorResumeBinding(runDirectory) {
|
|
|
9042
9023
|
if (error.code === "ENOENT") return void 0;
|
|
9043
9024
|
throw error;
|
|
9044
9025
|
}
|
|
9045
|
-
if (
|
|
9046
|
-
const
|
|
9047
|
-
if (typeof
|
|
9048
|
-
const subject = isAuditorSoulRole(
|
|
9026
|
+
if (!isRecord(raw)) return void 0;
|
|
9027
|
+
const record = raw;
|
|
9028
|
+
if (typeof record.sourceRunPath !== "string" || record.sourceRunPath.trim() === "") return void 0;
|
|
9029
|
+
const subject = isAuditorSoulRole(record.auditorSubject) ? record.auditorSubject : subjectFromSourceDirectory(record.sourceRunPath);
|
|
9049
9030
|
if (subject === void 0) return void 0;
|
|
9050
|
-
return { subject, sourceRunDirectory:
|
|
9031
|
+
return { subject, sourceRunDirectory: record.sourceRunPath };
|
|
9051
9032
|
}
|
|
9052
9033
|
var AUDITOR_SOUL_ROLES, AK_ROLE_AUDITOR_SUBJECT_ENV, AK_ROLE_AUDITOR_SOURCE_RUN_ENV, AUDITOR_SESSION_MATERIALS;
|
|
9053
9034
|
var init_auditor_soul = __esm({
|
|
9054
9035
|
"src/auditor-soul.ts"() {
|
|
9055
9036
|
"use strict";
|
|
9037
|
+
init_unknown_value();
|
|
9056
9038
|
init_session_opening_materials();
|
|
9057
9039
|
AUDITOR_SOUL_ROLES = [
|
|
9058
9040
|
"judge",
|
|
@@ -9203,11 +9185,8 @@ function reportEngineDetourCall(input) {
|
|
|
9203
9185
|
recordPointer: pointer
|
|
9204
9186
|
};
|
|
9205
9187
|
}
|
|
9206
|
-
function isRecord7(value) {
|
|
9207
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9208
|
-
}
|
|
9209
9188
|
function callFactFromSitianPayload(payload, pointer) {
|
|
9210
|
-
if (!
|
|
9189
|
+
if (!isRecord(payload)) return void 0;
|
|
9211
9190
|
if (payload.tool !== ENGINE_DETOUR_TOOL_NAME) return void 0;
|
|
9212
9191
|
if (typeof payload.toolCallId !== "string" || payload.toolCallId.length === 0) {
|
|
9213
9192
|
return void 0;
|
|
@@ -9223,13 +9202,13 @@ function callFactFromSitianPayload(payload, pointer) {
|
|
|
9223
9202
|
recordPointer: pointer
|
|
9224
9203
|
};
|
|
9225
9204
|
}
|
|
9226
|
-
function invocationScopeIdOfRecord(
|
|
9227
|
-
if (
|
|
9228
|
-
const fromSubject =
|
|
9205
|
+
function invocationScopeIdOfRecord(record) {
|
|
9206
|
+
if (isRecord(record.subject)) {
|
|
9207
|
+
const fromSubject = record.subject.invocationScopeId;
|
|
9229
9208
|
if (typeof fromSubject === "string" && fromSubject.length > 0) return fromSubject;
|
|
9230
9209
|
}
|
|
9231
|
-
if (
|
|
9232
|
-
const fromPayload =
|
|
9210
|
+
if (isRecord(record.payload)) {
|
|
9211
|
+
const fromPayload = record.payload.invocationScopeId;
|
|
9233
9212
|
if (typeof fromPayload === "string" && fromPayload.length > 0) return fromPayload;
|
|
9234
9213
|
}
|
|
9235
9214
|
return void 0;
|
|
@@ -9245,21 +9224,21 @@ async function readEngineDetourToolUsage(input) {
|
|
|
9245
9224
|
});
|
|
9246
9225
|
const { records } = await readSitianRecords(recordFile);
|
|
9247
9226
|
const callsByToolCallId = /* @__PURE__ */ new Map();
|
|
9248
|
-
for (const
|
|
9249
|
-
if (
|
|
9250
|
-
const boundScope = invocationScopeIdOfRecord(
|
|
9227
|
+
for (const record of records) {
|
|
9228
|
+
if (record.kind !== ENGINE_DETOUR_CALL_KIND) continue;
|
|
9229
|
+
const boundScope = invocationScopeIdOfRecord(record);
|
|
9251
9230
|
if (input.invocationScopeId !== void 0 && input.invocationScopeId.length > 0) {
|
|
9252
9231
|
if (boundScope !== input.invocationScopeId) continue;
|
|
9253
9232
|
} else if (boundScope !== void 0) {
|
|
9254
9233
|
continue;
|
|
9255
9234
|
}
|
|
9256
9235
|
const pointer = {
|
|
9257
|
-
identity:
|
|
9236
|
+
identity: record.identity,
|
|
9258
9237
|
recordFile,
|
|
9259
|
-
kind:
|
|
9260
|
-
level:
|
|
9238
|
+
kind: record.kind,
|
|
9239
|
+
level: record.level
|
|
9261
9240
|
};
|
|
9262
|
-
const fact = callFactFromSitianPayload(
|
|
9241
|
+
const fact = callFactFromSitianPayload(record.payload, pointer);
|
|
9263
9242
|
if (fact === void 0) continue;
|
|
9264
9243
|
callsByToolCallId.set(fact.toolCallId, fact);
|
|
9265
9244
|
}
|
|
@@ -9289,7 +9268,7 @@ function readInvocationRecord(runDirectory) {
|
|
|
9289
9268
|
const raw = JSON.parse(
|
|
9290
9269
|
readFileSync2(join23(runDirectory, "invocation.json"), "utf8")
|
|
9291
9270
|
);
|
|
9292
|
-
return
|
|
9271
|
+
return isRecord(raw) ? raw : void 0;
|
|
9293
9272
|
} catch (error) {
|
|
9294
9273
|
if (error?.code === "ENOENT") return void 0;
|
|
9295
9274
|
throw error;
|
|
@@ -9302,7 +9281,7 @@ async function readInvocationEngineMounted(runDirectory) {
|
|
|
9302
9281
|
}
|
|
9303
9282
|
function withEngineDetourToolUsageFact(outcome, usage) {
|
|
9304
9283
|
if (usage === void 0) return outcome;
|
|
9305
|
-
const prior =
|
|
9284
|
+
const prior = isRecord(outcome.decisiveFacts) ? outcome.decisiveFacts : {};
|
|
9306
9285
|
return {
|
|
9307
9286
|
...outcome,
|
|
9308
9287
|
decisiveFacts: {
|
|
@@ -9337,6 +9316,7 @@ var init_engine_detour_usage = __esm({
|
|
|
9337
9316
|
"use strict";
|
|
9338
9317
|
init_engine_detour();
|
|
9339
9318
|
init_sitian_facade();
|
|
9319
|
+
init_unknown_value();
|
|
9340
9320
|
ENGINE_DETOUR_CALL_KIND = "engine-detour-call";
|
|
9341
9321
|
ENGINE_DETOUR_TOOL_USAGE_FACT_KEY = "engineDetourToolUsage";
|
|
9342
9322
|
ENGINE_DETOUR_CALL_RECORD_FILE_RELATIVE = `session/${ENGINE_DETOUR_CALL_KIND}/records.jsonl`;
|
|
@@ -9372,13 +9352,10 @@ function resolveAuditDossier(source) {
|
|
|
9372
9352
|
}
|
|
9373
9353
|
return { status: "ok", runDirectory };
|
|
9374
9354
|
}
|
|
9375
|
-
function isRecord8(value) {
|
|
9376
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9377
|
-
}
|
|
9378
9355
|
function readDoctorAuditSubjects(context) {
|
|
9379
9356
|
const entries = context.sessionManager.getEntries?.() ?? [];
|
|
9380
9357
|
for (const entry of entries) {
|
|
9381
|
-
if (
|
|
9358
|
+
if (isRecord(entry) && entry.type === "custom" && entry.customType === DOCTOR_CANDIDATE_ENTRY_TYPE) {
|
|
9382
9359
|
return { status: "ok" };
|
|
9383
9360
|
}
|
|
9384
9361
|
}
|
|
@@ -9394,6 +9371,7 @@ var init_dossier_resolution = __esm({
|
|
|
9394
9371
|
"src/dossier-resolution.ts"() {
|
|
9395
9372
|
"use strict";
|
|
9396
9373
|
init_host_contracts();
|
|
9374
|
+
init_unknown_value();
|
|
9397
9375
|
AUDIT_RUN_DIR_ENV = "AK_ROLE_RUN_DIR";
|
|
9398
9376
|
DOCTOR_CANDIDATE_ENTRY_TYPE = "ak_doctor_audit_candidate";
|
|
9399
9377
|
AuditMaterialsUnavailableError = class extends Error {
|
|
@@ -9467,21 +9445,21 @@ function buildNavigatorInfrastructureFailureFact() {
|
|
|
9467
9445
|
}
|
|
9468
9446
|
function extractInfrastructureFailureEvidence(error) {
|
|
9469
9447
|
if (typeof error !== "object" || error === null) return {};
|
|
9470
|
-
const
|
|
9448
|
+
const record = error;
|
|
9471
9449
|
const evidence = {};
|
|
9472
9450
|
for (const key of NAVIGATOR_INFRASTRUCTURE_FAILURE_EVIDENCE_KEYS) {
|
|
9473
|
-
if (!Object.hasOwn(
|
|
9474
|
-
evidence[key] =
|
|
9451
|
+
if (!Object.hasOwn(record, key)) continue;
|
|
9452
|
+
evidence[key] = record[key] === void 0 ? null : record[key];
|
|
9475
9453
|
}
|
|
9476
9454
|
return evidence;
|
|
9477
9455
|
}
|
|
9478
9456
|
function hasNavigatorInfrastructureFailureBase(value) {
|
|
9479
|
-
if (
|
|
9480
|
-
const
|
|
9457
|
+
if (!isRecord(value)) return false;
|
|
9458
|
+
const record = value;
|
|
9481
9459
|
for (const key of NAVIGATOR_INFRASTRUCTURE_FAILURE_KEYS) {
|
|
9482
|
-
if (!Object.hasOwn(
|
|
9460
|
+
if (!Object.hasOwn(record, key)) return false;
|
|
9483
9461
|
}
|
|
9484
|
-
return
|
|
9462
|
+
return record.kind === NAVIGATOR_INFRASTRUCTURE_FAILURE_KIND && record.source === "shared-role-lifecycle" && record.reasonCode === "host_failure";
|
|
9485
9463
|
}
|
|
9486
9464
|
function mintNavigatorInvocationId() {
|
|
9487
9465
|
return uuidv7();
|
|
@@ -9491,21 +9469,21 @@ function invocationPhaseFromUnknown(value) {
|
|
|
9491
9469
|
return void 0;
|
|
9492
9470
|
}
|
|
9493
9471
|
function parseInvocationMarkerIdentity(data) {
|
|
9494
|
-
if (
|
|
9495
|
-
const
|
|
9496
|
-
const invocationId =
|
|
9472
|
+
if (!isRecord(data)) return void 0;
|
|
9473
|
+
const record = data;
|
|
9474
|
+
const invocationId = record.invocationId;
|
|
9497
9475
|
if (typeof invocationId !== "string") return void 0;
|
|
9498
9476
|
const trimmedId = invocationId.trim();
|
|
9499
9477
|
if (!isUuidV7(trimmedId)) return void 0;
|
|
9500
|
-
if (typeof
|
|
9501
|
-
const phase = invocationPhaseFromUnknown(
|
|
9478
|
+
if (typeof record.role !== "string" || record.role.trim() === "") return void 0;
|
|
9479
|
+
const phase = invocationPhaseFromUnknown(record.phase);
|
|
9502
9480
|
if (phase === void 0) return void 0;
|
|
9503
|
-
if (typeof
|
|
9481
|
+
if (typeof record.subjectKey !== "string" || record.subjectKey.trim() === "") return void 0;
|
|
9504
9482
|
return {
|
|
9505
9483
|
invocationId: trimmedId,
|
|
9506
|
-
role:
|
|
9484
|
+
role: record.role,
|
|
9507
9485
|
phase,
|
|
9508
|
-
subjectKey:
|
|
9486
|
+
subjectKey: record.subjectKey
|
|
9509
9487
|
};
|
|
9510
9488
|
}
|
|
9511
9489
|
function markerMatchesExpectedIdentity(marker, expected) {
|
|
@@ -9599,6 +9577,7 @@ var init_navigator_invocation_identity = __esm({
|
|
|
9599
9577
|
"use strict";
|
|
9600
9578
|
init_packaged_role_registry();
|
|
9601
9579
|
init_uuidv7();
|
|
9580
|
+
init_unknown_value();
|
|
9602
9581
|
init_work_subject_identity();
|
|
9603
9582
|
NAVIGATOR_INVOCATION_ENTRY = "ak-navigator-invocation";
|
|
9604
9583
|
NAVIGATOR_ROUTE_PLAYBOOK_FAILURE_ENTRY = "ak-navigator-route-playbook-failure";
|
|
@@ -9622,11 +9601,8 @@ var init_navigator_invocation_identity = __esm({
|
|
|
9622
9601
|
});
|
|
9623
9602
|
|
|
9624
9603
|
// src/receipt-delivery-policy.ts
|
|
9625
|
-
function isRecord9(value) {
|
|
9626
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9627
|
-
}
|
|
9628
9604
|
function parseNoReceiptLifecycleFacts(input) {
|
|
9629
|
-
if (!
|
|
9605
|
+
if (!isRecord(input) || typeof input.terminalToolCalled !== "boolean" || input.deliveryTurns !== RECEIPT_DELIVERY_TURN_LIMIT || input.sessionCompletion !== "settled-without-accepted-receipt" || input.acceptedReceipt !== false || typeof input.runPointer !== "string" || input.runPointer.trim() === "" || typeof input.attemptPointer !== "string" || input.attemptPointer.trim() === "" || !Array.isArray(input.rejectedReceipts) || !input.rejectedReceipts.every((item) => isRecord(item) && typeof item.reason === "string")) {
|
|
9630
9606
|
throw new TypeError("malformed no-receipt lifecycle facts");
|
|
9631
9607
|
}
|
|
9632
9608
|
return {
|
|
@@ -9713,6 +9689,7 @@ var RECEIPT_DELIVERY_TURN_LIMIT, NO_RECEIPT_LIFECYCLE_ENTRY_TYPE;
|
|
|
9713
9689
|
var init_receipt_delivery_policy = __esm({
|
|
9714
9690
|
"src/receipt-delivery-policy.ts"() {
|
|
9715
9691
|
"use strict";
|
|
9692
|
+
init_unknown_value();
|
|
9716
9693
|
RECEIPT_DELIVERY_TURN_LIMIT = 2;
|
|
9717
9694
|
NO_RECEIPT_LIFECYCLE_ENTRY_TYPE = "ak-no-receipt-lifecycle";
|
|
9718
9695
|
}
|
|
@@ -9946,7 +9923,7 @@ async function inspectJudgeSession(sessionFile) {
|
|
|
9946
9923
|
await readFile15(sessionFile, "utf8");
|
|
9947
9924
|
return { state: "present" };
|
|
9948
9925
|
} catch (error) {
|
|
9949
|
-
if (
|
|
9926
|
+
if (isEnoent(error)) return { state: "missing" };
|
|
9950
9927
|
return {
|
|
9951
9928
|
state: "unreadable",
|
|
9952
9929
|
diagnostic: error instanceof Error ? error.message || error.name : String(error)
|
|
@@ -10151,12 +10128,6 @@ function explicitInternalKnownFailureClassificationInput(failure) {
|
|
|
10151
10128
|
...failure.details === void 0 ? {} : { knownDetails: failure.details }
|
|
10152
10129
|
};
|
|
10153
10130
|
}
|
|
10154
|
-
function isMissingPathError4(error) {
|
|
10155
|
-
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
10156
|
-
}
|
|
10157
|
-
function isAbsentFacePathError(error) {
|
|
10158
|
-
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
10159
|
-
}
|
|
10160
10131
|
function sessionReadFailure(error, fallbackMessage) {
|
|
10161
10132
|
if (error instanceof SyntaxError) {
|
|
10162
10133
|
const failed2 = new SyntaxError(
|
|
@@ -10249,7 +10220,7 @@ async function readSitianRetainedAuditorProviderStop(sessionFile) {
|
|
|
10249
10220
|
const { records } = await readSitianRecords(recordFile);
|
|
10250
10221
|
for (let i = records.length - 1; i >= 0; i -= 1) {
|
|
10251
10222
|
const payload = records[i]?.payload;
|
|
10252
|
-
if (!
|
|
10223
|
+
if (!isRecord(payload) || !isRecord(payload.response)) continue;
|
|
10253
10224
|
if (typeof payload.type === "string") continue;
|
|
10254
10225
|
const stop = sessionProviderStopFromAssistant(payload.response);
|
|
10255
10226
|
if (stop !== void 0) return stop;
|
|
@@ -10274,7 +10245,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
10274
10245
|
try {
|
|
10275
10246
|
parentEntries = await readBoundSessionEntries(sessionFile);
|
|
10276
10247
|
} catch (error) {
|
|
10277
|
-
if (
|
|
10248
|
+
if (isEnoent(error)) return void 0;
|
|
10278
10249
|
throw sessionReadFailure(error, "failed to read parent session for auditor binding");
|
|
10279
10250
|
}
|
|
10280
10251
|
const parentId = parentEntries.find((entry) => entry.type === "session")?.id;
|
|
@@ -10288,7 +10259,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
10288
10259
|
names = await readdir5(childDirectory);
|
|
10289
10260
|
sawAnyDirectory = true;
|
|
10290
10261
|
} catch (error) {
|
|
10291
|
-
if (
|
|
10262
|
+
if (isEnoent(error)) continue;
|
|
10292
10263
|
throw sessionReadFailure(error, "failed to read bound auditor session directory");
|
|
10293
10264
|
}
|
|
10294
10265
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
@@ -10299,7 +10270,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
10299
10270
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
10300
10271
|
}
|
|
10301
10272
|
const header = entries.find((entry) => entry.type === "session");
|
|
10302
|
-
if (!
|
|
10273
|
+
if (!isRecord(header)) continue;
|
|
10303
10274
|
const bindingIndexes = [];
|
|
10304
10275
|
for (let i = 0; i < entries.length; i += 1) {
|
|
10305
10276
|
const entry = entries[i];
|
|
@@ -10313,7 +10284,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
10313
10284
|
end: idx + 1 < bindingIndexes.length ? bindingIndexes[idx + 1] : entries.length
|
|
10314
10285
|
})) : [{ entry: void 0, start: 0, end: entries.length }];
|
|
10315
10286
|
for (const { entry: bindingEntry, start, end } of bindingPasses) {
|
|
10316
|
-
const bindingParent = bindingEntry !== void 0 &&
|
|
10287
|
+
const bindingParent = bindingEntry !== void 0 && isRecord(bindingEntry.data) && isRecord(bindingEntry.data.parent) ? bindingEntry.data.parent : void 0;
|
|
10317
10288
|
const attemptEntryId = typeof bindingParent?.attemptEntryId === "string" ? bindingParent.attemptEntryId : void 0;
|
|
10318
10289
|
const boundSessionFile = typeof bindingParent?.sessionFile === "string" ? bindingParent.sessionFile : typeof header.parentSession === "string" ? header.parentSession : void 0;
|
|
10319
10290
|
if (boundSessionFile !== sessionFile) continue;
|
|
@@ -10337,12 +10308,12 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
10337
10308
|
if (stop === void 0) continue;
|
|
10338
10309
|
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
10339
10310
|
const entry = entries[i];
|
|
10340
|
-
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !
|
|
10341
|
-
const parent =
|
|
10342
|
-
const failure =
|
|
10311
|
+
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord(entry.data)) continue;
|
|
10312
|
+
const parent = isRecord(entry.data.parent) ? entry.data.parent : void 0;
|
|
10313
|
+
const failure = isRecord(entry.data.failure) ? entry.data.failure : void 0;
|
|
10343
10314
|
if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId) continue;
|
|
10344
10315
|
if (failure === void 0) continue;
|
|
10345
|
-
const identity =
|
|
10316
|
+
const identity = isRecord(failure.identity) ? failure.identity : void 0;
|
|
10346
10317
|
const typedCause = failure.cause === "provider" || failure.cause === "activation" || failure.cause === "session" || failure.cause === "output" || failure.cause === "timeout" ? failure.cause : void 0;
|
|
10347
10318
|
return {
|
|
10348
10319
|
...typedCause === void 0 ? {} : { cause: typedCause },
|
|
@@ -10351,7 +10322,7 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
10351
10322
|
...typeof identity.code === "string" || typeof identity.code === "number" ? { code: identity.code } : {}
|
|
10352
10323
|
} },
|
|
10353
10324
|
...typeof failure.diagnostic === "string" ? { diagnostic: failure.diagnostic } : {},
|
|
10354
|
-
...
|
|
10325
|
+
...isRecord(failure.details) ? { details: failure.details } : {}
|
|
10355
10326
|
};
|
|
10356
10327
|
}
|
|
10357
10328
|
}
|
|
@@ -10398,9 +10369,9 @@ function typedFailedTerminatingToolKnownFailure(entries) {
|
|
|
10398
10369
|
if (classification.kind !== "infrastructure") continue;
|
|
10399
10370
|
if (typeof message.toolCallId !== "string" || typeof message.toolName !== "string") continue;
|
|
10400
10371
|
if (boundRoleToolCallForResult(attemptEntries, i, message, message.toolName) === void 0) continue;
|
|
10401
|
-
const textPart = Array.isArray(message.content) ? message.content.find((part) =>
|
|
10402
|
-
const diagnostic =
|
|
10403
|
-
const details =
|
|
10372
|
+
const textPart = Array.isArray(message.content) ? message.content.find((part) => isRecord(part) && part.type === "text" && typeof part.text === "string") : void 0;
|
|
10373
|
+
const diagnostic = isRecord(textPart) ? textPart.text : void 0;
|
|
10374
|
+
const details = isRecord(message.details) ? message.details : classification.fact;
|
|
10404
10375
|
return {
|
|
10405
10376
|
cause: "activation",
|
|
10406
10377
|
identity: { name: message.toolName, code: message.toolCallId },
|
|
@@ -10436,7 +10407,7 @@ async function resolveAuditedRunnerFailureResolution(input) {
|
|
|
10436
10407
|
);
|
|
10437
10408
|
if (terminatingFailure !== void 0) return resolutionOf(terminatingFailure);
|
|
10438
10409
|
} catch (error) {
|
|
10439
|
-
if (!
|
|
10410
|
+
if (!isEnoent(error)) {
|
|
10440
10411
|
const failure = sessionReadFailure(error, "failed to recover typed terminating-tool failure");
|
|
10441
10412
|
return resolutionOf({
|
|
10442
10413
|
cause: "session",
|
|
@@ -10537,15 +10508,12 @@ function controlledFailureInputFromResolution(resolution) {
|
|
|
10537
10508
|
} : {}
|
|
10538
10509
|
};
|
|
10539
10510
|
}
|
|
10540
|
-
function isRecord10(value) {
|
|
10541
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10542
|
-
}
|
|
10543
10511
|
function toolResultText(message) {
|
|
10544
10512
|
const content = message.content;
|
|
10545
10513
|
if (typeof content === "string") return content.trim();
|
|
10546
10514
|
if (!Array.isArray(content)) return "";
|
|
10547
10515
|
return content.map((part) => {
|
|
10548
|
-
if (
|
|
10516
|
+
if (isRecord(part) && typeof part.text === "string") {
|
|
10549
10517
|
return part.text;
|
|
10550
10518
|
}
|
|
10551
10519
|
return "";
|
|
@@ -10611,9 +10579,9 @@ function knownFailureFromControlled(failure) {
|
|
|
10611
10579
|
};
|
|
10612
10580
|
}
|
|
10613
10581
|
function seatKnownFailureResolver(role) {
|
|
10614
|
-
const
|
|
10615
|
-
if (
|
|
10616
|
-
const policy = RUNNER_FAILURE_POLICY[
|
|
10582
|
+
const record = packagedRoleMetadata(role);
|
|
10583
|
+
if (record === void 0 || !("runnerFailure" in record)) return void 0;
|
|
10584
|
+
const policy = RUNNER_FAILURE_POLICY[record.runnerFailure];
|
|
10617
10585
|
return async ({ result, sessionFile }) => {
|
|
10618
10586
|
const infrastructureFailure = await policy.read(sessionFile);
|
|
10619
10587
|
if (policy.rank === "record-first") {
|
|
@@ -10632,7 +10600,7 @@ function boundRoleToolCallForResult(entries, resultIndex, message, outputToolNam
|
|
|
10632
10600
|
const candidateMessage = entries[index]?.message;
|
|
10633
10601
|
if (candidateMessage?.role === "assistant" && Array.isArray(candidateMessage.content)) {
|
|
10634
10602
|
for (const part of candidateMessage.content) {
|
|
10635
|
-
if (!
|
|
10603
|
+
if (!isRecord(part) || part.type !== "toolCall" || part.id !== callId) {
|
|
10636
10604
|
continue;
|
|
10637
10605
|
}
|
|
10638
10606
|
if (part.name !== outputToolName) return void 0;
|
|
@@ -10698,7 +10666,7 @@ function parseNavigatorAttendanceDetails(details) {
|
|
|
10698
10666
|
if (typeof details.prose === "string" && details.prose.trim() !== "") {
|
|
10699
10667
|
prose = details.prose;
|
|
10700
10668
|
} else {
|
|
10701
|
-
const next =
|
|
10669
|
+
const next = isRecord(details.next) && typeof details.next.role === "string" ? details.next.role : void 0;
|
|
10702
10670
|
const reason = typeof details.reason === "string" && details.reason.trim() !== "" ? details.reason : void 0;
|
|
10703
10671
|
const command = typeof details.command === "string" && details.command.trim() !== "" ? details.command : void 0;
|
|
10704
10672
|
if (reason !== void 0 && next !== void 0) {
|
|
@@ -10807,7 +10775,7 @@ function detourGateContext(admitted, scope) {
|
|
|
10807
10775
|
}
|
|
10808
10776
|
async function withOptionalGateProjection(base, sessionDirectory, gateContext = {}) {
|
|
10809
10777
|
const secondaryEvidence = base.roleOutcome.kind === "failure" ? base.roleOutcome.decisiveFacts.secondaryEvidence : void 0;
|
|
10810
|
-
const skipGate =
|
|
10778
|
+
const skipGate = isRecord(secondaryEvidence) && secondaryEvidence.kind === "role_infrastructure_failure" && packagedSkipsGateOnInfrastructureStage(secondaryEvidence.stage);
|
|
10811
10779
|
let next = base;
|
|
10812
10780
|
if (!skipGate) {
|
|
10813
10781
|
const gate = await extractGateFactFromSessionDirectory(sessionDirectory, gateContext);
|
|
@@ -10820,7 +10788,7 @@ function routePlaybookFailureMessage(entries) {
|
|
|
10820
10788
|
const entry = entries[i];
|
|
10821
10789
|
if (entry?.type !== "custom" || entry.customType !== NAVIGATOR_ROUTE_PLAYBOOK_FAILURE_ENTRY) continue;
|
|
10822
10790
|
const data = entry.data;
|
|
10823
|
-
if (!
|
|
10791
|
+
if (!isRecord(data) || typeof data.message !== "string" || data.message.trim() === "") return void 0;
|
|
10824
10792
|
return data.message;
|
|
10825
10793
|
}
|
|
10826
10794
|
return void 0;
|
|
@@ -10843,8 +10811,8 @@ function extractNavigatorAttendanceFact(entries) {
|
|
|
10843
10811
|
for (let i = terminal.index; i < entries.length; i += 1) {
|
|
10844
10812
|
const entry = entries[i];
|
|
10845
10813
|
if (entry?.type !== "custom" || entry.customType !== "ak-role-submission-closure") continue;
|
|
10846
|
-
const details =
|
|
10847
|
-
if (!
|
|
10814
|
+
const details = isRecord(entry.data) ? entry.data.navigator : void 0;
|
|
10815
|
+
if (!isRecord(details)) break;
|
|
10848
10816
|
return parseNavigatorAttendanceDetails(details);
|
|
10849
10817
|
}
|
|
10850
10818
|
return {
|
|
@@ -10858,7 +10826,7 @@ async function extractNavigatorFactFromAdmittedSession(sessionFile) {
|
|
|
10858
10826
|
const entries = await readBoundSessionEntries(sessionFile);
|
|
10859
10827
|
return extractNavigatorFact(entries);
|
|
10860
10828
|
} catch (error) {
|
|
10861
|
-
if (
|
|
10829
|
+
if (isEnoent(error)) {
|
|
10862
10830
|
return {
|
|
10863
10831
|
disposition: "unavailable",
|
|
10864
10832
|
source: "unknown",
|
|
@@ -10876,7 +10844,7 @@ async function removeFaceIfPresent(path) {
|
|
|
10876
10844
|
try {
|
|
10877
10845
|
await rm2(path, { recursive: true, force: true });
|
|
10878
10846
|
} catch (error) {
|
|
10879
|
-
if (
|
|
10847
|
+
if (isMissingPathError(error)) return;
|
|
10880
10848
|
throw error;
|
|
10881
10849
|
}
|
|
10882
10850
|
}
|
|
@@ -10941,7 +10909,7 @@ async function readLawfulSettlementEntries(sessionFile) {
|
|
|
10941
10909
|
try {
|
|
10942
10910
|
return await readBoundSessionEntries(sessionFile);
|
|
10943
10911
|
} catch (error) {
|
|
10944
|
-
if (
|
|
10912
|
+
if (isEnoent(error)) return void 0;
|
|
10945
10913
|
throw error instanceof Error && error.knownCause === "session" ? error : sessionReadFailure(error, "session unreadable");
|
|
10946
10914
|
}
|
|
10947
10915
|
}
|
|
@@ -10976,7 +10944,7 @@ async function settleSealedAcceptedOrToolResidual(admitted, authority, scope, ro
|
|
|
10976
10944
|
const residual = boundErroredToolCandidate(entries, index, message, residualToolName);
|
|
10977
10945
|
if (residual === void 0) continue;
|
|
10978
10946
|
const candidate = residual.candidate;
|
|
10979
|
-
const details =
|
|
10947
|
+
const details = isRecord(candidate) ? candidate : { candidate };
|
|
10980
10948
|
const failed = await settleFailureTerminalResult(
|
|
10981
10949
|
admitted,
|
|
10982
10950
|
{
|
|
@@ -11008,26 +10976,26 @@ async function settleSealedAcceptedOrToolResidual(admitted, authority, scope, ro
|
|
|
11008
10976
|
);
|
|
11009
10977
|
}
|
|
11010
10978
|
async function settleSeat(admitted, authority, scope) {
|
|
11011
|
-
const
|
|
11012
|
-
if (
|
|
10979
|
+
const record = packagedRoleMetadata(admitted.role);
|
|
10980
|
+
if (record === void 0) {
|
|
11013
10981
|
throw new Error(`no settlement for ${admitted.role}`);
|
|
11014
10982
|
}
|
|
11015
|
-
if (
|
|
10983
|
+
if (record.settlement === "accepted") {
|
|
11016
10984
|
return trySettleAcceptedSeatTerminalResult(admitted, authority, scope);
|
|
11017
10985
|
}
|
|
11018
10986
|
const publish = (roleOutcome, coordinates, entries) => publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries);
|
|
11019
|
-
if (
|
|
10987
|
+
if (record.settlement === "residual") {
|
|
11020
10988
|
return settleSealedAcceptedOrToolResidual(
|
|
11021
10989
|
admitted,
|
|
11022
10990
|
authority,
|
|
11023
10991
|
scope,
|
|
11024
10992
|
admitted.role,
|
|
11025
|
-
|
|
11026
|
-
|
|
10993
|
+
record.residualTool,
|
|
10994
|
+
record.residualScan,
|
|
11027
10995
|
publish
|
|
11028
10996
|
);
|
|
11029
10997
|
}
|
|
11030
|
-
const accept = "sealedAcceptedOnly" in
|
|
10998
|
+
const accept = "sealedAcceptedOnly" in record && record.sealedAcceptedOnly === true ? (roleOutcome) => roleOutcome.role === admitted.role && roleOutcome.kind === "accepted" : void 0;
|
|
11031
10999
|
return settleSealedLedgerTerminal(admitted, authority, scope, publish, accept);
|
|
11032
11000
|
}
|
|
11033
11001
|
async function trySettleSeatTerminalResult(admitted, authority, scope) {
|
|
@@ -11051,7 +11019,7 @@ function extractDoctorCandidateFacts(entries) {
|
|
|
11051
11019
|
continue;
|
|
11052
11020
|
}
|
|
11053
11021
|
const data = entry.data;
|
|
11054
|
-
if (!
|
|
11022
|
+
if (!isRecord(data)) return {};
|
|
11055
11023
|
return {
|
|
11056
11024
|
...data.cost === void 0 ? {} : { cost: data.cost },
|
|
11057
11025
|
...data.auditNoReceipt === void 0 ? {} : { auditNoReceipt: data.auditNoReceipt }
|
|
@@ -11060,9 +11028,9 @@ function extractDoctorCandidateFacts(entries) {
|
|
|
11060
11028
|
return {};
|
|
11061
11029
|
}
|
|
11062
11030
|
function seatArtifactFace(role) {
|
|
11063
|
-
const
|
|
11064
|
-
if (
|
|
11065
|
-
return
|
|
11031
|
+
const record = packagedRoleMetadata(role);
|
|
11032
|
+
if (record !== void 0 && "artifactFace" in record && record.artifactFace !== void 0) {
|
|
11033
|
+
return record.artifactFace;
|
|
11066
11034
|
}
|
|
11067
11035
|
return EMPTY_ARTIFACT_FACE;
|
|
11068
11036
|
}
|
|
@@ -11136,7 +11104,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
11136
11104
|
let residual;
|
|
11137
11105
|
for (let index = entries.length - 1; index >= scanStart; index -= 1) {
|
|
11138
11106
|
const entry = entries[index];
|
|
11139
|
-
if (entry?.type === "custom" && entry.customType === "ak-role-submission-closure" &&
|
|
11107
|
+
if (entry?.type === "custom" && entry.customType === "ak-role-submission-closure" && isRecord(entry.data) && entry.data.toolName === spec.toolName && classifyPackagedRoleTerminalResult(entry.data).kind === "accepted") {
|
|
11140
11108
|
thisAttemptHasSeatSuccess = true;
|
|
11141
11109
|
}
|
|
11142
11110
|
const message = entries[index]?.message;
|
|
@@ -11176,7 +11144,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
11176
11144
|
);
|
|
11177
11145
|
}
|
|
11178
11146
|
if (residual !== void 0) {
|
|
11179
|
-
const details =
|
|
11147
|
+
const details = isRecord(residual.candidate) ? residual.candidate : { candidate: residual.candidate };
|
|
11180
11148
|
const failed = await settleFailureTerminalResult(
|
|
11181
11149
|
admitted,
|
|
11182
11150
|
{
|
|
@@ -11200,8 +11168,8 @@ async function trySettleAcceptedSeatTerminalResult(admitted, authority, scope) {
|
|
|
11200
11168
|
role: admitted.role,
|
|
11201
11169
|
toolName
|
|
11202
11170
|
}, scope);
|
|
11203
|
-
const
|
|
11204
|
-
if (settled === void 0 ||
|
|
11171
|
+
const record = packagedRoleMetadata(admitted.role);
|
|
11172
|
+
if (settled === void 0 || record === void 0 || !("projectCountersignTerminal" in record) || record.projectCountersignTerminal !== true) {
|
|
11205
11173
|
return settled;
|
|
11206
11174
|
}
|
|
11207
11175
|
return applySecretariatCountersignTerminal(admitted, authority, settled);
|
|
@@ -11214,7 +11182,7 @@ function countersignTerminalFromEntries(entries) {
|
|
|
11214
11182
|
const entry = entries[index];
|
|
11215
11183
|
if (entry?.type !== "custom") continue;
|
|
11216
11184
|
if (entry.customType !== SECRETARIAT_GATE_OFFICER_ENTRY_TYPE) continue;
|
|
11217
|
-
const data =
|
|
11185
|
+
const data = isRecord(entry.data) ? entry.data : void 0;
|
|
11218
11186
|
if (data === void 0 || !packagedDurableOfficerEntry(data.officer)) continue;
|
|
11219
11187
|
if (data.receipt === void 0) continue;
|
|
11220
11188
|
const runId = typeof data.runId === "string" && data.runId.trim() !== "" ? data.runId : void 0;
|
|
@@ -11226,7 +11194,7 @@ function countersignTerminalFromEntries(entries) {
|
|
|
11226
11194
|
return void 0;
|
|
11227
11195
|
}
|
|
11228
11196
|
function withCountersignTerminalFact(roleOutcome, officer) {
|
|
11229
|
-
const prior = roleOutcome.decisiveFacts !== void 0 &&
|
|
11197
|
+
const prior = roleOutcome.decisiveFacts !== void 0 && isRecord(roleOutcome.decisiveFacts) ? roleOutcome.decisiveFacts : {};
|
|
11230
11198
|
return {
|
|
11231
11199
|
...roleOutcome,
|
|
11232
11200
|
decisiveFacts: {
|
|
@@ -11239,7 +11207,7 @@ function acceptedSecretariatDefinesOfficerProjection(roleOutcome) {
|
|
|
11239
11207
|
const payloads = roleOutcome.payloads ?? [];
|
|
11240
11208
|
for (let index = payloads.length - 1; index >= 0; index -= 1) {
|
|
11241
11209
|
const payload = payloads[index];
|
|
11242
|
-
if (!
|
|
11210
|
+
if (!isRecord(payload)) continue;
|
|
11243
11211
|
const status = payload.secretariatStatus;
|
|
11244
11212
|
if (typeof status !== "string") continue;
|
|
11245
11213
|
return status === "converged";
|
|
@@ -11630,6 +11598,7 @@ var init_settlement = __esm({
|
|
|
11630
11598
|
init_run_terminal_artifacts();
|
|
11631
11599
|
init_invocation();
|
|
11632
11600
|
init_terminal();
|
|
11601
|
+
init_unknown_value();
|
|
11633
11602
|
privateFailureErrorPaths = /* @__PURE__ */ new WeakMap();
|
|
11634
11603
|
NAVIGATOR_POST_ROLE_GRACE_MS = 1e4;
|
|
11635
11604
|
ENGINE_DETOUR_INFRASTRUCTURE_FAILURE_SPEC = {
|
|
@@ -11798,7 +11767,7 @@ function latestQueueStatus(terminal) {
|
|
|
11798
11767
|
if (outcome.kind === "audit_escalation") return "escalate";
|
|
11799
11768
|
if (outcome.kind !== "accepted") return void 0;
|
|
11800
11769
|
const latest = outcome.payloads?.[outcome.payloads.length - 1];
|
|
11801
|
-
if (
|
|
11770
|
+
if (isRecord(latest)) {
|
|
11802
11771
|
const status = latest.status;
|
|
11803
11772
|
if (typeof status === "string" && status.trim() !== "") return status;
|
|
11804
11773
|
}
|
|
@@ -11920,6 +11889,7 @@ var init_submission_gate = __esm({
|
|
|
11920
11889
|
init_archivist_record_pointer();
|
|
11921
11890
|
init_gatekeeper_role();
|
|
11922
11891
|
init_session_assistant_usage();
|
|
11892
|
+
init_unknown_value();
|
|
11923
11893
|
}
|
|
11924
11894
|
});
|
|
11925
11895
|
|
|
@@ -12101,12 +12071,12 @@ function projectRoleTurnRequest(admitted, roleDetails, options) {
|
|
|
12101
12071
|
};
|
|
12102
12072
|
}
|
|
12103
12073
|
function packagedSettleSkill(admitted) {
|
|
12104
|
-
const
|
|
12105
|
-
if (
|
|
12106
|
-
if ("applyMethod" in
|
|
12107
|
-
return "phase" in admitted && admitted.phase === "apply" ?
|
|
12074
|
+
const record = packagedRoleMetadata(admitted.role);
|
|
12075
|
+
if (record === void 0) return void 0;
|
|
12076
|
+
if ("applyMethod" in record && record.applyMethod !== void 0) {
|
|
12077
|
+
return "phase" in admitted && admitted.phase === "apply" ? record.applyMethod : void 0;
|
|
12108
12078
|
}
|
|
12109
|
-
if ("settleMethod" in
|
|
12079
|
+
if ("settleMethod" in record && record.settleMethod !== void 0) return record.settleMethod;
|
|
12110
12080
|
return void 0;
|
|
12111
12081
|
}
|
|
12112
12082
|
function readAdmittedPath2(admitted, path) {
|
|
@@ -12139,10 +12109,10 @@ function activationForAdmitted(admitted) {
|
|
|
12139
12109
|
return activation;
|
|
12140
12110
|
}
|
|
12141
12111
|
function requiredMethodSkills(admitted) {
|
|
12142
|
-
const
|
|
12112
|
+
const record = packagedRoleMetadata(admitted.role);
|
|
12143
12113
|
const names = [];
|
|
12144
|
-
if (
|
|
12145
|
-
names.push(...
|
|
12114
|
+
if (record !== void 0 && "methodSkills" in record && record.methodSkills !== void 0) {
|
|
12115
|
+
names.push(...record.methodSkills);
|
|
12146
12116
|
}
|
|
12147
12117
|
const apply = packagedSettleSkill(admitted);
|
|
12148
12118
|
if (apply !== void 0 && !names.includes(apply)) names.push(apply);
|
|
@@ -12423,7 +12393,7 @@ function copyAndRecordHostDossier(options) {
|
|
|
12423
12393
|
payload: {
|
|
12424
12394
|
type: "native-session-warning",
|
|
12425
12395
|
sessionId: options.sessionId,
|
|
12426
|
-
error:
|
|
12396
|
+
error: errorText(error)
|
|
12427
12397
|
}
|
|
12428
12398
|
});
|
|
12429
12399
|
return;
|
|
@@ -12487,7 +12457,7 @@ function copyAndRecordHostDossier(options) {
|
|
|
12487
12457
|
landingPath,
|
|
12488
12458
|
ordinal,
|
|
12489
12459
|
sessionId: options.sessionId,
|
|
12490
|
-
error:
|
|
12460
|
+
error: errorText(lastError)
|
|
12491
12461
|
}
|
|
12492
12462
|
});
|
|
12493
12463
|
}
|
|
@@ -12497,6 +12467,7 @@ var init_host_session_record = __esm({
|
|
|
12497
12467
|
"src/host-session-record.ts"() {
|
|
12498
12468
|
"use strict";
|
|
12499
12469
|
init_sitian_facade();
|
|
12470
|
+
init_unknown_value();
|
|
12500
12471
|
HOST_SESSION_RECORD_KIND = "host-session";
|
|
12501
12472
|
}
|
|
12502
12473
|
});
|
|
@@ -12550,7 +12521,7 @@ async function ensureRealArtifactsDirectory(runDirectory) {
|
|
|
12550
12521
|
throw new Error("run artifact retention: artifacts path is not a real directory");
|
|
12551
12522
|
}
|
|
12552
12523
|
} catch (error) {
|
|
12553
|
-
if (!
|
|
12524
|
+
if (!isEnoent(error)) throw error;
|
|
12554
12525
|
await mkdir4(artifactsDir, { recursive: true });
|
|
12555
12526
|
const created = await lstat5(artifactsDir);
|
|
12556
12527
|
if (created.isSymbolicLink() || !created.isDirectory()) {
|
|
@@ -12559,9 +12530,6 @@ async function ensureRealArtifactsDirectory(runDirectory) {
|
|
|
12559
12530
|
}
|
|
12560
12531
|
return artifactsDir;
|
|
12561
12532
|
}
|
|
12562
|
-
function isMissingPathError5(error) {
|
|
12563
|
-
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
12564
|
-
}
|
|
12565
12533
|
function jsonSafeReplacer() {
|
|
12566
12534
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
12567
12535
|
return (_key, value) => {
|
|
@@ -12810,6 +12778,7 @@ var init_auto_resume = __esm({
|
|
|
12810
12778
|
init_terminal();
|
|
12811
12779
|
init_settlement();
|
|
12812
12780
|
init_serialize_thrown_value();
|
|
12781
|
+
init_unknown_value();
|
|
12813
12782
|
dummyIo = { stdout: () => {
|
|
12814
12783
|
}, stderr: () => {
|
|
12815
12784
|
} };
|
|
@@ -12817,7 +12786,7 @@ var init_auto_resume = __esm({
|
|
|
12817
12786
|
name = "TurnDispatchedFailure";
|
|
12818
12787
|
constructor(cause) {
|
|
12819
12788
|
super(
|
|
12820
|
-
`settlement failed after the host turn genuinely started: ${
|
|
12789
|
+
`settlement failed after the host turn genuinely started: ${errorText(cause)}`,
|
|
12821
12790
|
{ cause }
|
|
12822
12791
|
);
|
|
12823
12792
|
}
|
|
@@ -12850,10 +12819,10 @@ function projectRelocatedTurnIdentity(request, result, admitted, relocation) {
|
|
|
12850
12819
|
mutableRequest.runDirectory = admitted.runDirectory;
|
|
12851
12820
|
mutableRequest.principal = admitted.principal;
|
|
12852
12821
|
const activation = mutableRequest.activation;
|
|
12853
|
-
if (
|
|
12822
|
+
if (isRecord(activation)) {
|
|
12854
12823
|
for (const field of ["taskPath", "packetPath", "prerequisitesPath", "inputPath", "requestManifestPath"]) {
|
|
12855
|
-
const
|
|
12856
|
-
if (field in
|
|
12824
|
+
const record = activation;
|
|
12825
|
+
if (field in record) record[field] = rewrite(record[field]);
|
|
12857
12826
|
}
|
|
12858
12827
|
}
|
|
12859
12828
|
if (result.terminal !== void 0) {
|
|
@@ -13072,7 +13041,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
13072
13041
|
continue;
|
|
13073
13042
|
}
|
|
13074
13043
|
const payload = row.accepted;
|
|
13075
|
-
if (
|
|
13044
|
+
if (!isRecord(payload)) continue;
|
|
13076
13045
|
ticketNumber = readDeclaredTicketNumber(
|
|
13077
13046
|
payload.ticketNumber
|
|
13078
13047
|
);
|
|
@@ -13672,9 +13641,9 @@ async function pointExistingRunFailure(home, runId, authority, io, thrown) {
|
|
|
13672
13641
|
}
|
|
13673
13642
|
if (foundRunDirectory === void 0) return false;
|
|
13674
13643
|
const runDirectory = foundRunDirectory;
|
|
13675
|
-
let
|
|
13644
|
+
let record;
|
|
13676
13645
|
try {
|
|
13677
|
-
|
|
13646
|
+
record = await readRoleRunState(runDirectory, authority);
|
|
13678
13647
|
} catch {
|
|
13679
13648
|
await presentResumeFailurePointer(
|
|
13680
13649
|
io,
|
|
@@ -13683,11 +13652,11 @@ async function pointExistingRunFailure(home, runId, authority, io, thrown) {
|
|
|
13683
13652
|
);
|
|
13684
13653
|
return true;
|
|
13685
13654
|
}
|
|
13686
|
-
if (
|
|
13655
|
+
if (record === void 0) return false;
|
|
13687
13656
|
await presentResumeFailurePointer(
|
|
13688
13657
|
io,
|
|
13689
13658
|
thrown,
|
|
13690
|
-
(failure) => writeResumeDiagnosticFile(runDirectory, runId, failure,
|
|
13659
|
+
(failure) => writeResumeDiagnosticFile(runDirectory, runId, failure, record.role)
|
|
13691
13660
|
);
|
|
13692
13661
|
return true;
|
|
13693
13662
|
}
|
|
@@ -13719,7 +13688,7 @@ async function presentResumeFailurePointer(io, thrown, publish) {
|
|
|
13719
13688
|
cause.thrownCause = formatErrorCauseDetail(thrown.cause);
|
|
13720
13689
|
}
|
|
13721
13690
|
presentStructuralRejection({
|
|
13722
|
-
message:
|
|
13691
|
+
message: errorText(thrown),
|
|
13723
13692
|
cause
|
|
13724
13693
|
}, io);
|
|
13725
13694
|
}
|
|
@@ -13854,6 +13823,7 @@ var init_post_admission = __esm({
|
|
|
13854
13823
|
init_settlement();
|
|
13855
13824
|
init_terminal();
|
|
13856
13825
|
init_auto_resume();
|
|
13826
|
+
init_unknown_value();
|
|
13857
13827
|
POST_ADMISSION_CLEANUP_DIAGNOSTIC_ENTRY_TYPE = "ak_post_admission_cleanup_diagnostic";
|
|
13858
13828
|
}
|
|
13859
13829
|
});
|
|
@@ -13881,11 +13851,8 @@ var init_seat_ticket_binding = __esm({
|
|
|
13881
13851
|
});
|
|
13882
13852
|
|
|
13883
13853
|
// src/public-cli/countersign-run.ts
|
|
13884
|
-
function isRecord11(value) {
|
|
13885
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13886
|
-
}
|
|
13887
13854
|
function isEscalatePayload(payload) {
|
|
13888
|
-
if (!
|
|
13855
|
+
if (!isRecord(payload)) return false;
|
|
13889
13856
|
return payload.status === "escalate";
|
|
13890
13857
|
}
|
|
13891
13858
|
function courtDiaristPayloadRows(roleOutcome, submissions) {
|
|
@@ -13979,6 +13946,7 @@ var init_countersign_run = __esm({
|
|
|
13979
13946
|
"src/public-cli/countersign-run.ts"() {
|
|
13980
13947
|
"use strict";
|
|
13981
13948
|
init_readable_gate_item();
|
|
13949
|
+
init_unknown_value();
|
|
13982
13950
|
}
|
|
13983
13951
|
});
|
|
13984
13952
|
|
|
@@ -13996,7 +13964,7 @@ function unreadablePostSubmissionStatus(admitted, terminal) {
|
|
|
13996
13964
|
const route = POST_SUBMISSION_ROUTING[admitted.role];
|
|
13997
13965
|
if (route === void 0) return void 0;
|
|
13998
13966
|
const payload = terminal.roleOutcome.payloads?.at(-1);
|
|
13999
|
-
const status =
|
|
13967
|
+
const status = isRecord(payload) ? payload.status : void 0;
|
|
14000
13968
|
return typeof status === "string" && route.statuses.has(status) ? void 0 : route.reask;
|
|
14001
13969
|
}
|
|
14002
13970
|
async function reaskUnreadablePostSubmissionStatus(admitted, terminal, env, io) {
|
|
@@ -14009,11 +13977,11 @@ async function reaskUnreadablePostSubmissionStatus(admitted, terminal, env, io)
|
|
|
14009
13977
|
);
|
|
14010
13978
|
}
|
|
14011
13979
|
function roleRecord(role) {
|
|
14012
|
-
const
|
|
14013
|
-
if (
|
|
13980
|
+
const record = packagedRoleMetadata(role);
|
|
13981
|
+
if (record === void 0) {
|
|
14014
13982
|
throw new CliUsageError(`unknown role: ${role}`);
|
|
14015
13983
|
}
|
|
14016
|
-
return
|
|
13984
|
+
return record;
|
|
14017
13985
|
}
|
|
14018
13986
|
function buildInstructionSeatTurnRequest(admitted, options) {
|
|
14019
13987
|
return projectRoleTurnRequest(
|
|
@@ -14023,9 +13991,9 @@ function buildInstructionSeatTurnRequest(admitted, options) {
|
|
|
14023
13991
|
);
|
|
14024
13992
|
}
|
|
14025
13993
|
function initialPrompt(admitted, env) {
|
|
14026
|
-
const
|
|
13994
|
+
const record = roleRecord(admitted.role);
|
|
14027
13995
|
const reask = env.reviewReask ?? env.gateReviewInstruction;
|
|
14028
|
-
if (reask !== void 0 && "reaskPrompt" in
|
|
13996
|
+
if (reask !== void 0 && "reaskPrompt" in record && record.reaskPrompt === true) {
|
|
14029
13997
|
return reask;
|
|
14030
13998
|
}
|
|
14031
13999
|
return buildInstructionTransportPrompt(
|
|
@@ -14052,8 +14020,8 @@ async function bindAndRelocateDiarist(admitted, authority, lease) {
|
|
|
14052
14020
|
return await relocateAdmittedRunToTicket(admitted, authority, lease);
|
|
14053
14021
|
}
|
|
14054
14022
|
function seatAdapters(admitted, env) {
|
|
14055
|
-
const
|
|
14056
|
-
const present = "presentSettled" in
|
|
14023
|
+
const record = roleRecord(admitted.role);
|
|
14024
|
+
const present = "presentSettled" in record ? record.presentSettled : "default";
|
|
14057
14025
|
return {
|
|
14058
14026
|
trySettle: (seat, authority, scope) => trySettlePublicSeat(seat, authority, scope),
|
|
14059
14027
|
...present === "always" ? { shouldPresentSettled: () => true } : {},
|
|
@@ -14106,7 +14074,7 @@ async function withAuditorSoulEnv(options) {
|
|
|
14106
14074
|
}
|
|
14107
14075
|
}
|
|
14108
14076
|
async function dispatchAdmitted(admitted, env, io) {
|
|
14109
|
-
const
|
|
14077
|
+
const record = roleRecord(admitted.role);
|
|
14110
14078
|
await warnMissingMethodSkills(env.home, env.host, admitted.role, requiredMethodSkills(admitted), io.stdout);
|
|
14111
14079
|
const adapters = seatAdapters(admitted, env);
|
|
14112
14080
|
const held = [];
|
|
@@ -14115,7 +14083,7 @@ async function dispatchAdmitted(admitted, env, io) {
|
|
|
14115
14083
|
if (activeEnv.correlationId !== void 0 && activeEnv.correlationId.trim() !== "") {
|
|
14116
14084
|
await recordAdmittedCorrelation(admitted, activeEnv.correlationId);
|
|
14117
14085
|
}
|
|
14118
|
-
const auto = "inCallAutoResume" in
|
|
14086
|
+
const auto = "inCallAutoResume" in record && record.inCallAutoResume === true;
|
|
14119
14087
|
if (auto) {
|
|
14120
14088
|
return await runPostAdmissionResumable({
|
|
14121
14089
|
admitted,
|
|
@@ -14329,7 +14297,7 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
14329
14297
|
}
|
|
14330
14298
|
}
|
|
14331
14299
|
async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
14332
|
-
const
|
|
14300
|
+
const record = roleRecord(role);
|
|
14333
14301
|
let parsed;
|
|
14334
14302
|
try {
|
|
14335
14303
|
parsed = parseArgv2(argv);
|
|
@@ -14348,7 +14316,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14348
14316
|
for (const value of held) io.stdout(value);
|
|
14349
14317
|
return result;
|
|
14350
14318
|
}
|
|
14351
|
-
if ("parallelLenses" in
|
|
14319
|
+
if ("parallelLenses" in record && record.parallelLenses === true) {
|
|
14352
14320
|
if (parsed.baseRevision === void 0) {
|
|
14353
14321
|
presentStructuralRejection(new CliUsageError("reviewer requires --base"), io);
|
|
14354
14322
|
return { exitCode: 2 };
|
|
@@ -14362,7 +14330,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14362
14330
|
let auditorSource;
|
|
14363
14331
|
let auditorTicket;
|
|
14364
14332
|
let resolvedNotarySource;
|
|
14365
|
-
if (
|
|
14333
|
+
if (record.sameParent === "subject-source") {
|
|
14366
14334
|
if (parsed.subject === void 0) {
|
|
14367
14335
|
presentStructuralRejection(new CliUsageError("auditor --subject requires judge|doctor"), io);
|
|
14368
14336
|
return { exitCode: 2 };
|
|
@@ -14378,7 +14346,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14378
14346
|
auditorSource = resolved.runDirectory;
|
|
14379
14347
|
auditorTicket = await readBoardTicketNumber(resolved.runDirectory);
|
|
14380
14348
|
} catch (error) {
|
|
14381
|
-
presentStructuralRejection(new CliUsageError(
|
|
14349
|
+
presentStructuralRejection(new CliUsageError(errorText(error)), io);
|
|
14382
14350
|
return { exitCode: 2 };
|
|
14383
14351
|
}
|
|
14384
14352
|
if (auditorSource === void 0) return { exitCode: 2 };
|
|
@@ -14404,7 +14372,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14404
14372
|
});
|
|
14405
14373
|
if (resumed != null) return resumed;
|
|
14406
14374
|
}
|
|
14407
|
-
if (
|
|
14375
|
+
if (record.sameParent === "gate-pointer") {
|
|
14408
14376
|
const parentRunPath = parentRunPathFromGatePointerInstruction(parsed.instruction ?? "");
|
|
14409
14377
|
if (parentRunPath !== void 0) {
|
|
14410
14378
|
const summons = {
|
|
@@ -14426,7 +14394,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14426
14394
|
if (resumed != null) return resumed;
|
|
14427
14395
|
}
|
|
14428
14396
|
}
|
|
14429
|
-
if (
|
|
14397
|
+
if (record.sameParent === "source-locator") {
|
|
14430
14398
|
let source;
|
|
14431
14399
|
try {
|
|
14432
14400
|
source = await resolveNotarySourceRunLocator({
|
|
@@ -14475,7 +14443,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14475
14443
|
if (rejected !== void 0) return rejected;
|
|
14476
14444
|
throw error;
|
|
14477
14445
|
}
|
|
14478
|
-
if (
|
|
14446
|
+
if (record.sameParent === "gate-pointer") {
|
|
14479
14447
|
const parentRunPath = parentRunPathFromGatePointerInstruction(parsed.instruction ?? "");
|
|
14480
14448
|
if (parentRunPath !== void 0) {
|
|
14481
14449
|
await persistAdmittedSourceRunPath(admitted, parentRunPath);
|
|
@@ -14483,7 +14451,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14483
14451
|
admitted = { ...admitted, ...sourcePatch };
|
|
14484
14452
|
}
|
|
14485
14453
|
}
|
|
14486
|
-
if (
|
|
14454
|
+
if (record.sameParent === "subject-source" && auditorSource !== void 0) {
|
|
14487
14455
|
await persistAdmittedSourceRunPath(admitted, auditorSource, auditorSubject);
|
|
14488
14456
|
}
|
|
14489
14457
|
const runAdmitted = async () => {
|
|
@@ -14523,7 +14491,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14523
14491
|
}
|
|
14524
14492
|
return dispatchAdmitted(admitted, env, io);
|
|
14525
14493
|
};
|
|
14526
|
-
if (
|
|
14494
|
+
if (record.sameParent === "subject-source") {
|
|
14527
14495
|
return withAuditorSoulEnv({
|
|
14528
14496
|
...auditorSubject === void 0 ? {} : { subject: auditorSubject },
|
|
14529
14497
|
...auditorSource === void 0 ? {} : { sourceRunDirectory: auditorSource },
|
|
@@ -14663,8 +14631,8 @@ async function auditSubmittedRole(turn, env, io, passedOfficer, passedReceipt, p
|
|
|
14663
14631
|
if (admitted === void 0 || !AUDITED_ROLES.has(admitted.role) || turn.terminal?.roleOutcome.kind !== "accepted") return turn;
|
|
14664
14632
|
const accepted = turn.terminal.roleOutcome.payloads?.at(-1);
|
|
14665
14633
|
if (accepted === void 0) throw new Error("accepted submission has no payload");
|
|
14666
|
-
const
|
|
14667
|
-
const status = admitted.role === "secretariat" ?
|
|
14634
|
+
const record = isRecord(accepted) ? accepted : void 0;
|
|
14635
|
+
const status = admitted.role === "secretariat" ? record?.secretariatStatus : record?.status;
|
|
14668
14636
|
if (admitted.role === "secretariat" && status !== "converged" && status !== "escalate") {
|
|
14669
14637
|
return runPublicInstructionSeatResume(
|
|
14670
14638
|
{ runId: admitted.runId, message: SECRETARIAT_STATUS_REASK },
|
|
@@ -14885,6 +14853,7 @@ var init_instruction_seat_run = __esm({
|
|
|
14885
14853
|
init_terminal();
|
|
14886
14854
|
init_turn_request();
|
|
14887
14855
|
init_countersign_run();
|
|
14856
|
+
init_unknown_value();
|
|
14888
14857
|
AUDITED_ROLES = /* @__PURE__ */ new Set(["judge", "fixer", "coder", "secretariat", "countersign", "doctor"]);
|
|
14889
14858
|
SECRETARIAT_STATUS_REASK = "secretariatStatus \u4E0D\u662F converged\u3001escalate \u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0CsecretariatStatus \u5199\u660E\u5176\u4E00\u3002";
|
|
14890
14859
|
COUNTERSIGN_STATUS_REASK = "status \u4E0D\u662F converged\u3001continue\u3001escalate \u4E09\u6001\u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
|
|
@@ -14985,11 +14954,7 @@ var init_atomic_write = __esm({
|
|
|
14985
14954
|
// src/analyst-index.ts
|
|
14986
14955
|
import { open as open2, readFile as readFile17, unlink as unlink4 } from "node:fs/promises";
|
|
14987
14956
|
import { dirname as dirname20, join as join32 } from "node:path";
|
|
14988
|
-
|
|
14989
|
-
return new Promise((resolve22) => {
|
|
14990
|
-
setTimeout(resolve22, ms);
|
|
14991
|
-
});
|
|
14992
|
-
}
|
|
14957
|
+
import { setTimeout as sleep } from "node:timers/promises";
|
|
14993
14958
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
14994
14959
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
14995
14960
|
ensureRealDirectoryTree(ledgerHome, dirname20(indexPath));
|
|
@@ -15113,9 +15078,7 @@ async function readAnalystLibraryIndexPage(ledgerHome) {
|
|
|
15113
15078
|
try {
|
|
15114
15079
|
raw = await readFile17(path, "utf8");
|
|
15115
15080
|
} catch (error) {
|
|
15116
|
-
if (
|
|
15117
|
-
return void 0;
|
|
15118
|
-
}
|
|
15081
|
+
if (isMissingPathError(error)) return void 0;
|
|
15119
15082
|
throw error;
|
|
15120
15083
|
}
|
|
15121
15084
|
const parsed = JSON.parse(raw);
|
|
@@ -15150,6 +15113,7 @@ var init_analyst_index = __esm({
|
|
|
15150
15113
|
init_atomic_write();
|
|
15151
15114
|
init_activation_ledger_topology();
|
|
15152
15115
|
init_analyst_book_key();
|
|
15116
|
+
init_unknown_value();
|
|
15153
15117
|
LIBRARY_INDEX_LOCK_NAME = ".library-index.lock";
|
|
15154
15118
|
LIBRARY_INDEX_LOCK_TIMEOUT_MS = 3e4;
|
|
15155
15119
|
LIBRARY_INDEX_LOCK_RETRY_MS = 15;
|
|
@@ -15317,15 +15281,6 @@ var init_analyst_cohort = __esm({
|
|
|
15317
15281
|
// src/analyst-ledger.ts
|
|
15318
15282
|
import { readdir as readdir6, readFile as readFile18 } from "node:fs/promises";
|
|
15319
15283
|
import { basename as basename8, join as join33 } from "node:path";
|
|
15320
|
-
function isMissingPathError6(error) {
|
|
15321
|
-
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
15322
|
-
}
|
|
15323
|
-
function errorText3(error) {
|
|
15324
|
-
return error instanceof Error ? error.message : String(error);
|
|
15325
|
-
}
|
|
15326
|
-
function isRecord12(value) {
|
|
15327
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15328
|
-
}
|
|
15329
15284
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
15330
15285
|
return (await readRoleRunIdentity(runDirectory))?.state;
|
|
15331
15286
|
}
|
|
@@ -15367,7 +15322,7 @@ async function listLedgerBookNames(booksRoot) {
|
|
|
15367
15322
|
const entries = await readdir6(booksRoot, { withFileTypes: true });
|
|
15368
15323
|
return entries.filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
15369
15324
|
} catch (error) {
|
|
15370
|
-
if (
|
|
15325
|
+
if (isMissingPathError(error)) return [];
|
|
15371
15326
|
throw error;
|
|
15372
15327
|
}
|
|
15373
15328
|
}
|
|
@@ -15376,11 +15331,11 @@ async function readInvocationScopeFields(runDirectory) {
|
|
|
15376
15331
|
try {
|
|
15377
15332
|
raw = await readFile18(join33(runDirectory, "invocation.json"), "utf8");
|
|
15378
15333
|
} catch (error) {
|
|
15379
|
-
if (
|
|
15334
|
+
if (isMissingPathError(error)) return void 0;
|
|
15380
15335
|
throw error;
|
|
15381
15336
|
}
|
|
15382
15337
|
const parsed = JSON.parse(raw);
|
|
15383
|
-
if (!
|
|
15338
|
+
if (!isRecord(parsed)) return void 0;
|
|
15384
15339
|
if (typeof parsed.projectRoot !== "string" || parsed.projectRoot.trim() === "") {
|
|
15385
15340
|
return void 0;
|
|
15386
15341
|
}
|
|
@@ -15409,11 +15364,11 @@ async function resolveSessionFile(runDirectory) {
|
|
|
15409
15364
|
try {
|
|
15410
15365
|
const raw = await readFile18(join33(runDirectory, "invocation.json"), "utf8");
|
|
15411
15366
|
const parsed = JSON.parse(raw);
|
|
15412
|
-
if (
|
|
15367
|
+
if (isRecord(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
15413
15368
|
return parsed.sessionFile;
|
|
15414
15369
|
}
|
|
15415
15370
|
} catch (error) {
|
|
15416
|
-
if (!
|
|
15371
|
+
if (!isMissingPathError(error)) throw error;
|
|
15417
15372
|
}
|
|
15418
15373
|
return join33(runDirectory, "session", "session.jsonl");
|
|
15419
15374
|
}
|
|
@@ -15530,18 +15485,18 @@ async function classifyScopedRun(input) {
|
|
|
15530
15485
|
admitAttributed(attributed.rows);
|
|
15531
15486
|
} else if (attributed.kind === "attributed") {
|
|
15532
15487
|
missingSources.push("session-timeline");
|
|
15533
|
-
reasons.push(
|
|
15488
|
+
reasons.push(errorText(error));
|
|
15534
15489
|
const admitted = admitFrameSpanFromRows(attributed.rows);
|
|
15535
15490
|
models = admitted.models;
|
|
15536
15491
|
partialFirstFrameAt = admitted.partialFirstFrameAt;
|
|
15537
15492
|
partialLastFrameAt = admitted.partialLastFrameAt;
|
|
15538
15493
|
} else {
|
|
15539
15494
|
missingSources.push("session-timeline");
|
|
15540
|
-
reasons.push(
|
|
15495
|
+
reasons.push(errorText(error));
|
|
15541
15496
|
}
|
|
15542
15497
|
} else {
|
|
15543
15498
|
missingSources.push("session-timeline");
|
|
15544
|
-
reasons.push(
|
|
15499
|
+
reasons.push(errorText(error));
|
|
15545
15500
|
}
|
|
15546
15501
|
}
|
|
15547
15502
|
if (rows !== void 0 && !missingSources.includes("session-timeline")) {
|
|
@@ -15549,7 +15504,7 @@ async function classifyScopedRun(input) {
|
|
|
15549
15504
|
toolIntervals = extractSessionToolIntervals(rows);
|
|
15550
15505
|
} catch (error) {
|
|
15551
15506
|
missingSources.push("tool-association");
|
|
15552
|
-
reasons.push(
|
|
15507
|
+
reasons.push(errorText(error));
|
|
15553
15508
|
}
|
|
15554
15509
|
}
|
|
15555
15510
|
let lifecycle;
|
|
@@ -15557,7 +15512,7 @@ async function classifyScopedRun(input) {
|
|
|
15557
15512
|
lifecycle = await readExistingRunLifecycleState(input.runDirectory);
|
|
15558
15513
|
} catch (error) {
|
|
15559
15514
|
missingSources.push("run-state");
|
|
15560
|
-
reasons.push(
|
|
15515
|
+
reasons.push(errorText(error));
|
|
15561
15516
|
}
|
|
15562
15517
|
let ghostLeg;
|
|
15563
15518
|
if (lifecycle === "admitted" || lifecycle === "running") {
|
|
@@ -15592,7 +15547,7 @@ async function classifyScopedRun(input) {
|
|
|
15592
15547
|
}
|
|
15593
15548
|
} catch (error) {
|
|
15594
15549
|
missingSources.push("terminal-artifact");
|
|
15595
|
-
reasons.push(
|
|
15550
|
+
reasons.push(errorText(error));
|
|
15596
15551
|
}
|
|
15597
15552
|
if (missingSources.length > 0) {
|
|
15598
15553
|
const firstFrameAt = frameSpan !== void 0 ? { status: "present", at: frameSpan.startedAt } : partialFirstFrameAt;
|
|
@@ -15629,7 +15584,7 @@ async function classifyScopedRun(input) {
|
|
|
15629
15584
|
runId: input.runId,
|
|
15630
15585
|
book: input.book,
|
|
15631
15586
|
missingSources: ["auditor-roles"],
|
|
15632
|
-
reason:
|
|
15587
|
+
reason: errorText(error),
|
|
15633
15588
|
firstFrameAt: { status: "present", at: frameSpan.startedAt },
|
|
15634
15589
|
lastFrameAt: { status: "present", at: frameSpan.endedAt }
|
|
15635
15590
|
},
|
|
@@ -15692,7 +15647,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
15692
15647
|
try {
|
|
15693
15648
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
15694
15649
|
} catch (error) {
|
|
15695
|
-
if (
|
|
15650
|
+
if (isMissingPathError(error)) continue;
|
|
15696
15651
|
throw error;
|
|
15697
15652
|
}
|
|
15698
15653
|
for (const runDirectory of runDirectories) {
|
|
@@ -15752,32 +15707,30 @@ var init_analyst_ledger = __esm({
|
|
|
15752
15707
|
init_ledger_session_read();
|
|
15753
15708
|
init_run_terminal_artifacts();
|
|
15754
15709
|
init_analyst_gate_cycles_read();
|
|
15710
|
+
init_unknown_value();
|
|
15755
15711
|
LIVE_RUN_STATES = /* @__PURE__ */ new Set(["admitted", "running", "resumable"]);
|
|
15756
15712
|
}
|
|
15757
15713
|
});
|
|
15758
15714
|
|
|
15759
15715
|
// src/analyst-metric-families/acceptance-success-rework.ts
|
|
15760
|
-
function isRecord13(value) {
|
|
15761
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15762
|
-
}
|
|
15763
15716
|
function findCollectorGroups(body) {
|
|
15764
15717
|
if (Array.isArray(body.groups)) return body.groups;
|
|
15765
15718
|
const receipt = body.receipt;
|
|
15766
|
-
if (
|
|
15719
|
+
if (isRecord(receipt) && Array.isArray(receipt.groups)) return receipt.groups;
|
|
15767
15720
|
const outcome = body.outcome;
|
|
15768
|
-
if (
|
|
15721
|
+
if (isRecord(outcome)) {
|
|
15769
15722
|
const facts = outcome.decisiveFacts;
|
|
15770
|
-
if (
|
|
15723
|
+
if (isRecord(facts) && Array.isArray(facts.groups)) return facts.groups;
|
|
15771
15724
|
}
|
|
15772
15725
|
return void 0;
|
|
15773
15726
|
}
|
|
15774
15727
|
function extractStatus(body) {
|
|
15775
15728
|
const outcome = body.outcome;
|
|
15776
|
-
if (
|
|
15729
|
+
if (isRecord(outcome) && typeof outcome.status === "string" && outcome.status.trim() !== "") {
|
|
15777
15730
|
return outcome.status;
|
|
15778
15731
|
}
|
|
15779
15732
|
const receipt = body.receipt;
|
|
15780
|
-
if (
|
|
15733
|
+
if (isRecord(receipt) && typeof receipt.status === "string" && receipt.status.trim() !== "") {
|
|
15781
15734
|
return receipt.status;
|
|
15782
15735
|
}
|
|
15783
15736
|
if (typeof body.status === "string" && body.status.trim() !== "") {
|
|
@@ -15956,6 +15909,7 @@ var init_acceptance_success_rework = __esm({
|
|
|
15956
15909
|
init_analyst_ledger();
|
|
15957
15910
|
init_analyst_median();
|
|
15958
15911
|
init_packaged_role_registry();
|
|
15912
|
+
init_unknown_value();
|
|
15959
15913
|
WORKER_ROLES = /* @__PURE__ */ new Set(["coder", "fixer"]);
|
|
15960
15914
|
ACCEPTED_STATUS = {
|
|
15961
15915
|
coder: /* @__PURE__ */ new Set(["completed", "refused", "partially_completed", "unfinished", "planned"]),
|
|
@@ -16274,12 +16228,9 @@ var init_leg_wall_clock = __esm({
|
|
|
16274
16228
|
});
|
|
16275
16229
|
|
|
16276
16230
|
// src/analyst-metric-families/round-timeline.ts
|
|
16277
|
-
function isRecord14(value) {
|
|
16278
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16279
|
-
}
|
|
16280
16231
|
function readClassCount(body) {
|
|
16281
|
-
if (!
|
|
16282
|
-
if (!
|
|
16232
|
+
if (!isRecord(body.outcome)) return void 0;
|
|
16233
|
+
if (!isRecord(body.outcome.decisiveFacts)) return void 0;
|
|
16283
16234
|
const classCount = body.outcome.decisiveFacts.classCount;
|
|
16284
16235
|
if (typeof classCount !== "number" || !Number.isFinite(classCount)) {
|
|
16285
16236
|
return void 0;
|
|
@@ -16366,6 +16317,7 @@ var init_round_timeline = __esm({
|
|
|
16366
16317
|
"src/analyst-metric-families/round-timeline.ts"() {
|
|
16367
16318
|
"use strict";
|
|
16368
16319
|
init_acceptance_success_rework();
|
|
16320
|
+
init_unknown_value();
|
|
16369
16321
|
roundTimelineFamily = {
|
|
16370
16322
|
id: "round-timeline",
|
|
16371
16323
|
contribute(input) {
|
|
@@ -16423,7 +16375,6 @@ var init_analyst_metric_family = __esm({
|
|
|
16423
16375
|
});
|
|
16424
16376
|
|
|
16425
16377
|
// src/analyst-page.ts
|
|
16426
|
-
import { createHash as createHash3 } from "node:crypto";
|
|
16427
16378
|
import { dirname as dirname21, join as join34 } from "node:path";
|
|
16428
16379
|
function analystIssuePageKey(address) {
|
|
16429
16380
|
const parts = ["book", address.bookKey];
|
|
@@ -16432,7 +16383,7 @@ function analystIssuePageKey(address) {
|
|
|
16432
16383
|
} else if (address.scopeRootIdentity !== void 0) {
|
|
16433
16384
|
parts.push("root", physicalPathIdentity(address.scopeRootIdentity));
|
|
16434
16385
|
}
|
|
16435
|
-
return
|
|
16386
|
+
return sha256Hex(parts.join("\0")).slice(0, 32);
|
|
16436
16387
|
}
|
|
16437
16388
|
function analystIssuePagePath(ledgerHome, address) {
|
|
16438
16389
|
return join34(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
@@ -16555,6 +16506,7 @@ async function writeAnalystIssueMetricsPage(ledgerHome, page) {
|
|
|
16555
16506
|
var init_analyst_page = __esm({
|
|
16556
16507
|
"src/analyst-page.ts"() {
|
|
16557
16508
|
"use strict";
|
|
16509
|
+
init_sha256();
|
|
16558
16510
|
init_atomic_write();
|
|
16559
16511
|
init_activation_ledger_topology();
|
|
16560
16512
|
init_analyst_ledger();
|
|
@@ -16672,9 +16624,6 @@ var init_analyst_model_groups = __esm({
|
|
|
16672
16624
|
// src/analyst-entry.ts
|
|
16673
16625
|
import { readFile as readFile19 } from "node:fs/promises";
|
|
16674
16626
|
import { Type as Type11 } from "typebox";
|
|
16675
|
-
function isMissingPathError7(error) {
|
|
16676
|
-
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
16677
|
-
}
|
|
16678
16627
|
function cachedPageMatchesRequestedScope(page, input) {
|
|
16679
16628
|
if (page.bookKey !== input.bookKey) return false;
|
|
16680
16629
|
const requestedTicket = input.ticketNumber ?? input.issueNumber;
|
|
@@ -16713,7 +16662,7 @@ async function readOrComputeAnalystIssuePage(input, options) {
|
|
|
16713
16662
|
return { mode: "issue", page, pagePath, ghostLegs: ghostScan.ghostLegs };
|
|
16714
16663
|
}
|
|
16715
16664
|
} catch (error) {
|
|
16716
|
-
if (!
|
|
16665
|
+
if (!isMissingPathError(error)) {
|
|
16717
16666
|
throw new AnalystIssueComputeError({
|
|
16718
16667
|
bookKey,
|
|
16719
16668
|
projectRoot,
|
|
@@ -16805,7 +16754,7 @@ async function runAnalystModelGroupsMode(input, home) {
|
|
|
16805
16754
|
const raw = await readFile19(pagePath, "utf8");
|
|
16806
16755
|
JSON.parse(raw);
|
|
16807
16756
|
} catch (error) {
|
|
16808
|
-
if (!
|
|
16757
|
+
if (!isMissingPathError(error)) {
|
|
16809
16758
|
throw new AnalystIssueComputeError({ bookKey, projectRoot, cause: error });
|
|
16810
16759
|
}
|
|
16811
16760
|
try {
|
|
@@ -16858,6 +16807,7 @@ var init_analyst_entry = __esm({
|
|
|
16858
16807
|
init_analyst_index();
|
|
16859
16808
|
init_analyst_model_groups();
|
|
16860
16809
|
init_analyst_page();
|
|
16810
|
+
init_unknown_value();
|
|
16861
16811
|
AnalystIssueComputeError = class extends Error {
|
|
16862
16812
|
code = "analyst-issue-compute-failed";
|
|
16863
16813
|
bookKey;
|
|
@@ -16889,12 +16839,10 @@ var init_analyst_entry = __esm({
|
|
|
16889
16839
|
changedLines: Type11.Optional(
|
|
16890
16840
|
Type11.Number({ minimum: 0, maximum: Number.MAX_VALUE })
|
|
16891
16841
|
)
|
|
16892
|
-
}
|
|
16893
|
-
{ additionalProperties: false }
|
|
16842
|
+
}
|
|
16894
16843
|
)
|
|
16895
16844
|
)
|
|
16896
|
-
}
|
|
16897
|
-
{ additionalProperties: false }
|
|
16845
|
+
}
|
|
16898
16846
|
);
|
|
16899
16847
|
}
|
|
16900
16848
|
});
|
|
@@ -16965,7 +16913,7 @@ async function buildAnalystSweepModeInputFromAttachmentPaths(attachmentPaths) {
|
|
|
16965
16913
|
try {
|
|
16966
16914
|
text = exactUtf8(bytes, "analyst sweep attachment");
|
|
16967
16915
|
} catch (error) {
|
|
16968
|
-
const detail =
|
|
16916
|
+
const detail = errorText(error);
|
|
16969
16917
|
throw new CliUsageError(detail, { cause: error });
|
|
16970
16918
|
}
|
|
16971
16919
|
let parsed;
|
|
@@ -17055,6 +17003,7 @@ var init_analyst_run = __esm({
|
|
|
17055
17003
|
init_analyst_entry();
|
|
17056
17004
|
init_cli_errors();
|
|
17057
17005
|
init_settlement();
|
|
17006
|
+
init_unknown_value();
|
|
17058
17007
|
}
|
|
17059
17008
|
});
|
|
17060
17009
|
|
|
@@ -17313,7 +17262,7 @@ function requireLegalEngineModel(model) {
|
|
|
17313
17262
|
return assertLegalEngineModel(model);
|
|
17314
17263
|
} catch (error) {
|
|
17315
17264
|
throw new CliUsageError(
|
|
17316
|
-
|
|
17265
|
+
errorText(error),
|
|
17317
17266
|
{ cause: error }
|
|
17318
17267
|
);
|
|
17319
17268
|
}
|
|
@@ -17323,7 +17272,7 @@ function requireLegalEngineName(name) {
|
|
|
17323
17272
|
return assertLegalEngineName(name);
|
|
17324
17273
|
} catch (error) {
|
|
17325
17274
|
throw new CliUsageError(
|
|
17326
|
-
|
|
17275
|
+
errorText(error),
|
|
17327
17276
|
{ cause: error }
|
|
17328
17277
|
);
|
|
17329
17278
|
}
|
|
@@ -17339,7 +17288,7 @@ function loadAndValidateConfig(home, packageRoot) {
|
|
|
17339
17288
|
validatePublicCliConfigAxes(config, packageRoot);
|
|
17340
17289
|
} catch (error) {
|
|
17341
17290
|
throw new CliUsageError(
|
|
17342
|
-
|
|
17291
|
+
errorText(error),
|
|
17343
17292
|
{ cause: error }
|
|
17344
17293
|
);
|
|
17345
17294
|
}
|
|
@@ -17601,7 +17550,7 @@ async function runConfigCommand(args, home, packageRoot, io) {
|
|
|
17601
17550
|
try {
|
|
17602
17551
|
config = setPersistentSeatHost(config, seat, unset ? void 0 : args[2]);
|
|
17603
17552
|
} catch (error) {
|
|
17604
|
-
throw new CliUsageError(
|
|
17553
|
+
throw new CliUsageError(errorText(error), { cause: error });
|
|
17605
17554
|
}
|
|
17606
17555
|
await savePublicCliConfig(config, home);
|
|
17607
17556
|
io.stdout(renderConfig(config, home));
|
|
@@ -17624,7 +17573,7 @@ async function runConfigCommand(args, home, packageRoot, io) {
|
|
|
17624
17573
|
config = setPersistentSeatEngine(config, seat, name, engineModel);
|
|
17625
17574
|
} catch (error) {
|
|
17626
17575
|
throw new CliUsageError(
|
|
17627
|
-
|
|
17576
|
+
errorText(error),
|
|
17628
17577
|
{ cause: error }
|
|
17629
17578
|
);
|
|
17630
17579
|
}
|
|
@@ -17645,7 +17594,7 @@ async function runConfigCommand(args, home, packageRoot, io) {
|
|
|
17645
17594
|
config = setPersistentSeatEngine(config, seat, void 0);
|
|
17646
17595
|
} catch (error) {
|
|
17647
17596
|
throw new CliUsageError(
|
|
17648
|
-
|
|
17597
|
+
errorText(error),
|
|
17649
17598
|
{ cause: error }
|
|
17650
17599
|
);
|
|
17651
17600
|
}
|
|
@@ -17668,7 +17617,7 @@ async function runConfigCommand(args, home, packageRoot, io) {
|
|
|
17668
17617
|
config = setPersistentSeatEngineModel(config, seat, model);
|
|
17669
17618
|
} catch (error) {
|
|
17670
17619
|
throw new CliUsageError(
|
|
17671
|
-
|
|
17620
|
+
errorText(error),
|
|
17672
17621
|
{ cause: error }
|
|
17673
17622
|
);
|
|
17674
17623
|
}
|
|
@@ -17689,7 +17638,7 @@ async function runConfigCommand(args, home, packageRoot, io) {
|
|
|
17689
17638
|
config = setPersistentSeatEngineModel(config, seat, void 0);
|
|
17690
17639
|
} catch (error) {
|
|
17691
17640
|
throw new CliUsageError(
|
|
17692
|
-
|
|
17641
|
+
errorText(error),
|
|
17693
17642
|
{ cause: error }
|
|
17694
17643
|
);
|
|
17695
17644
|
}
|
|
@@ -17957,6 +17906,7 @@ var init_cli = __esm({
|
|
|
17957
17906
|
init_run_lifecycle();
|
|
17958
17907
|
init_registry();
|
|
17959
17908
|
init_settlement();
|
|
17909
|
+
init_unknown_value();
|
|
17960
17910
|
init_role_turn_host();
|
|
17961
17911
|
init_cli_errors();
|
|
17962
17912
|
PUBLIC_ROLE_ARGV = Object.fromEntries(
|
|
@@ -18215,9 +18165,9 @@ async function summonPublicRole(options) {
|
|
|
18215
18165
|
Promise.resolve().then(() => (init_cli(), cli_exports))
|
|
18216
18166
|
]);
|
|
18217
18167
|
const { packagedRoleMetadata: packagedRoleMetadata2 } = await Promise.resolve().then(() => (init_packaged_role_registry(), packaged_role_registry_exports));
|
|
18218
|
-
const
|
|
18168
|
+
const record = packagedRoleMetadata2(options.role);
|
|
18219
18169
|
const parse = ((args) => PUBLIC_ROLE_ARGV2[options.role].parse(args));
|
|
18220
|
-
const resumeRunId =
|
|
18170
|
+
const resumeRunId = record?.summonResume === true && typeof options.resumeRunId === "string" && options.resumeRunId.trim() !== "" ? options.resumeRunId.trim() : void 0;
|
|
18221
18171
|
let result;
|
|
18222
18172
|
if (resumeRunId !== void 0) {
|
|
18223
18173
|
const instruction = options.argv[0] ?? "";
|
|
@@ -18270,7 +18220,7 @@ async function summonParallelReviewerLenses(options) {
|
|
|
18270
18220
|
if (error instanceof AggregateError) {
|
|
18271
18221
|
return [error.message, ...error.errors.map(describeFailure)].join("\n");
|
|
18272
18222
|
}
|
|
18273
|
-
return
|
|
18223
|
+
return errorText(error);
|
|
18274
18224
|
};
|
|
18275
18225
|
const failedResult = (error) => ({
|
|
18276
18226
|
exitCode: 1,
|
|
@@ -18451,7 +18401,7 @@ async function summonGateOfficer(options) {
|
|
|
18451
18401
|
const correlationId = parentRunId;
|
|
18452
18402
|
const { isSafePositiveTicketNumber: isSafePositiveTicketNumber3, readBoardTicketNumber: readBoardTicketNumber2 } = await Promise.resolve().then(() => (init_run_ticket_number(), run_ticket_number_exports));
|
|
18453
18403
|
const parentTicket = await readBoardTicketNumber2(options.sourceRunDirectory);
|
|
18454
|
-
const submittedTicket =
|
|
18404
|
+
const submittedTicket = isRecord(options.submission) ? options.submission.ticketNumber : void 0;
|
|
18455
18405
|
const courtTicket = isSafePositiveTicketNumber3(submittedTicket) ? submittedTicket : parentTicket;
|
|
18456
18406
|
const instruction = options.reask ?? gateReviewInstruction ?? "";
|
|
18457
18407
|
return summonPublicRole({
|
|
@@ -18473,6 +18423,7 @@ var AK_ROLE_PACKAGE_ROOT_ENV, execFileAsync3;
|
|
|
18473
18423
|
var init_public_role_summons = __esm({
|
|
18474
18424
|
"src/public-role-summons.ts"() {
|
|
18475
18425
|
"use strict";
|
|
18426
|
+
init_unknown_value();
|
|
18476
18427
|
AK_ROLE_PACKAGE_ROOT_ENV = "AK_ROLE_PACKAGE_ROOT";
|
|
18477
18428
|
execFileAsync3 = promisify3(execFile3);
|
|
18478
18429
|
}
|
|
@@ -18483,7 +18434,7 @@ function readListField(value) {
|
|
|
18483
18434
|
return Array.isArray(value) ? value : value === void 0 ? [] : [value];
|
|
18484
18435
|
}
|
|
18485
18436
|
function tryReadComplianceCandidate(arguments_, usage) {
|
|
18486
|
-
if (
|
|
18437
|
+
if (!isRecord(arguments_)) {
|
|
18487
18438
|
return void 0;
|
|
18488
18439
|
}
|
|
18489
18440
|
const args = arguments_;
|
|
@@ -18604,6 +18555,7 @@ var init_compliance_transport = __esm({
|
|
|
18604
18555
|
init_submission_errors();
|
|
18605
18556
|
init_terminal();
|
|
18606
18557
|
init_readable_gate_item();
|
|
18558
|
+
init_unknown_value();
|
|
18607
18559
|
AUDITOR_DOSSIER_PROMPT = "\u5377\u5B97\u6307\u9488\uFF1A";
|
|
18608
18560
|
AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE = "ak_auditor_parent_attempt_binding";
|
|
18609
18561
|
AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE = "ak_auditor_compliance_failure";
|
|
@@ -18644,26 +18596,23 @@ function rewriteRunDirectoryPathValueAgainstRewrites(value, rewrites) {
|
|
|
18644
18596
|
best.newRunDirectory
|
|
18645
18597
|
);
|
|
18646
18598
|
}
|
|
18647
|
-
function rewriteRunDirectoryPathFields(
|
|
18648
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
18599
|
+
function rewriteRunDirectoryPathFields(record, fields, oldRunDirectory, newRunDirectory) {
|
|
18600
|
+
rewriteRunDirectoryPathFieldsAgainstRewrites(record, fields, [
|
|
18649
18601
|
{ oldRunDirectory, newRunDirectory }
|
|
18650
18602
|
]);
|
|
18651
18603
|
}
|
|
18652
|
-
function rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
18604
|
+
function rewriteRunDirectoryPathFieldsAgainstRewrites(record, fields, rewrites) {
|
|
18653
18605
|
for (const field of fields) {
|
|
18654
|
-
if (field in
|
|
18655
|
-
|
|
18656
|
-
|
|
18606
|
+
if (field in record) {
|
|
18607
|
+
record[field] = rewriteRunDirectoryPathValueAgainstRewrites(
|
|
18608
|
+
record[field],
|
|
18657
18609
|
rewrites
|
|
18658
18610
|
);
|
|
18659
18611
|
}
|
|
18660
18612
|
}
|
|
18661
18613
|
}
|
|
18662
|
-
function isPlainObject(value) {
|
|
18663
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
18664
|
-
}
|
|
18665
18614
|
function rewriteSourceRunLocator(value, rewrites) {
|
|
18666
|
-
if (!
|
|
18615
|
+
if (!isRecord(value)) return;
|
|
18667
18616
|
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
18668
18617
|
value,
|
|
18669
18618
|
SOURCE_RUN_LOCATOR_FIELDS,
|
|
@@ -18675,12 +18624,12 @@ function rewriteAdmittedRoleRunPage(page, rewrites) {
|
|
|
18675
18624
|
rewriteSourceRunLocator(page.sourceRun, rewrites);
|
|
18676
18625
|
if (Array.isArray(page.attachments)) {
|
|
18677
18626
|
for (const attachment of page.attachments) {
|
|
18678
|
-
if (
|
|
18627
|
+
if (isRecord(attachment)) {
|
|
18679
18628
|
rewriteRunDirectoryPathFieldsAgainstRewrites(attachment, ["frozenPath"], rewrites);
|
|
18680
18629
|
}
|
|
18681
18630
|
}
|
|
18682
18631
|
}
|
|
18683
|
-
if (
|
|
18632
|
+
if (isRecord(page.principal)) {
|
|
18684
18633
|
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
18685
18634
|
page.principal,
|
|
18686
18635
|
["sessionDirectory", "sessionFile"],
|
|
@@ -18693,6 +18642,7 @@ var init_role_run_relocation = __esm({
|
|
|
18693
18642
|
"src/role-run-relocation.ts"() {
|
|
18694
18643
|
"use strict";
|
|
18695
18644
|
init_compliance_transport();
|
|
18645
|
+
init_unknown_value();
|
|
18696
18646
|
ADMITTED_PAGE_FIELDS = [
|
|
18697
18647
|
"runDirectory",
|
|
18698
18648
|
"admittedRequestPath",
|
|
@@ -18768,8 +18718,8 @@ async function readTypedHttp429Observation(runDirectory) {
|
|
|
18768
18718
|
function renderResumeCommand(runId) {
|
|
18769
18719
|
return `ak-role resume ${runId}`;
|
|
18770
18720
|
}
|
|
18771
|
-
async function writeRoleRunState(runDirectory,
|
|
18772
|
-
const payload = { ...
|
|
18721
|
+
async function writeRoleRunState(runDirectory, record) {
|
|
18722
|
+
const payload = { ...record, runDirectory };
|
|
18773
18723
|
await writeFile8(
|
|
18774
18724
|
join37(runDirectory, RUN_STATE_FILE),
|
|
18775
18725
|
`${JSON.stringify(payload, null, 2)}
|
|
@@ -18778,15 +18728,15 @@ async function writeRoleRunState(runDirectory, record4) {
|
|
|
18778
18728
|
);
|
|
18779
18729
|
}
|
|
18780
18730
|
function parseSameTicketSummonsMaterials(raw) {
|
|
18781
|
-
if (
|
|
18782
|
-
const
|
|
18783
|
-
const instruction = typeof
|
|
18784
|
-
const instructionEmpty = typeof
|
|
18785
|
-
const attachmentPaths = Array.isArray(
|
|
18786
|
-
const sourceRunPath = typeof
|
|
18731
|
+
if (!isRecord(raw)) return void 0;
|
|
18732
|
+
const record = raw;
|
|
18733
|
+
const instruction = typeof record.instruction === "string" ? record.instruction : void 0;
|
|
18734
|
+
const instructionEmpty = typeof record.instructionEmpty === "boolean" ? record.instructionEmpty : void 0;
|
|
18735
|
+
const attachmentPaths = Array.isArray(record.attachmentPaths) ? record.attachmentPaths.filter((p) => typeof p === "string" && p.length > 0) : void 0;
|
|
18736
|
+
const sourceRunPath = typeof record.sourceRunPath === "string" && record.sourceRunPath.trim() !== "" ? record.sourceRunPath : void 0;
|
|
18787
18737
|
let sourceRun;
|
|
18788
|
-
if (
|
|
18789
|
-
const sr =
|
|
18738
|
+
if (isRecord(record.sourceRun)) {
|
|
18739
|
+
const sr = record.sourceRun;
|
|
18790
18740
|
if (typeof sr.runId === "string" && sr.runId.trim() !== "" && typeof sr.role === "string" && sr.role.trim() !== "" && typeof sr.runDirectory === "string" && sr.runDirectory.trim() !== "") {
|
|
18791
18741
|
sourceRun = {
|
|
18792
18742
|
runId: sr.runId,
|
|
@@ -18807,14 +18757,14 @@ function parseSameTicketSummonsMaterials(raw) {
|
|
|
18807
18757
|
};
|
|
18808
18758
|
}
|
|
18809
18759
|
function parseCurrentCourtState(raw) {
|
|
18810
|
-
if (
|
|
18811
|
-
const
|
|
18812
|
-
if (typeof
|
|
18760
|
+
if (!isRecord(raw)) return void 0;
|
|
18761
|
+
const record = raw;
|
|
18762
|
+
if (typeof record.courtAttemptId !== "string" || record.courtAttemptId.length === 0) {
|
|
18813
18763
|
return void 0;
|
|
18814
18764
|
}
|
|
18815
|
-
const summons = parseSameTicketSummonsMaterials(
|
|
18765
|
+
const summons = parseSameTicketSummonsMaterials(record.summons);
|
|
18816
18766
|
return {
|
|
18817
|
-
courtAttemptId:
|
|
18767
|
+
courtAttemptId: record.courtAttemptId,
|
|
18818
18768
|
...summons === void 0 ? {} : { summons }
|
|
18819
18769
|
};
|
|
18820
18770
|
}
|
|
@@ -18829,26 +18779,26 @@ async function readRoleRunStateRaw(runDirectory) {
|
|
|
18829
18779
|
return raw;
|
|
18830
18780
|
}
|
|
18831
18781
|
function parseRoleRunIdentity(raw, runDirectory) {
|
|
18832
|
-
if (
|
|
18782
|
+
if (!isRecord(raw)) {
|
|
18833
18783
|
throw new TypeError("Invalid run-state.json");
|
|
18834
18784
|
}
|
|
18835
|
-
const
|
|
18836
|
-
if (typeof
|
|
18785
|
+
const record = raw;
|
|
18786
|
+
if (typeof record.runId !== "string" || record.runId.trim() === "") {
|
|
18837
18787
|
throw new TypeError("Invalid run-state.json");
|
|
18838
18788
|
}
|
|
18839
|
-
const role = typeof
|
|
18789
|
+
const role = typeof record.role === "string" ? packagedRoleMetadata(record.role)?.role : void 0;
|
|
18840
18790
|
if (role === void 0) {
|
|
18841
18791
|
throw new TypeError("Invalid run-state.json");
|
|
18842
18792
|
}
|
|
18843
|
-
if (
|
|
18793
|
+
if (record.state !== "admitted" && record.state !== "running" && record.state !== "resumable" && record.state !== "terminal") {
|
|
18844
18794
|
throw new TypeError("Invalid run-state.json");
|
|
18845
18795
|
}
|
|
18846
|
-
if (typeof
|
|
18796
|
+
if (typeof record.bookKey !== "string") throw new TypeError("Invalid run-state.json");
|
|
18847
18797
|
return {
|
|
18848
|
-
runId:
|
|
18798
|
+
runId: record.runId,
|
|
18849
18799
|
role,
|
|
18850
|
-
state:
|
|
18851
|
-
bookKey:
|
|
18800
|
+
state: record.state,
|
|
18801
|
+
bookKey: record.bookKey,
|
|
18852
18802
|
runDirectory
|
|
18853
18803
|
};
|
|
18854
18804
|
}
|
|
@@ -18856,40 +18806,40 @@ async function readRoleRunStateDisk(runDirectory) {
|
|
|
18856
18806
|
const raw = await readRoleRunStateRaw(runDirectory);
|
|
18857
18807
|
if (raw === void 0) return void 0;
|
|
18858
18808
|
const identity = parseRoleRunIdentity(raw, runDirectory);
|
|
18859
|
-
const
|
|
18860
|
-
if (typeof
|
|
18861
|
-
if (typeof
|
|
18862
|
-
if (typeof
|
|
18863
|
-
const storedRunDirectory = typeof
|
|
18809
|
+
const record = raw;
|
|
18810
|
+
if (typeof record.projectRoot !== "string") throw new TypeError("Invalid run-state.json");
|
|
18811
|
+
if (typeof record.sessionDirectory !== "string") throw new TypeError("Invalid run-state.json");
|
|
18812
|
+
if (typeof record.admittedRequestPath !== "string") throw new TypeError("Invalid run-state.json");
|
|
18813
|
+
const storedRunDirectory = typeof record.runDirectory === "string" && record.runDirectory.trim() !== "" ? record.runDirectory : runDirectory;
|
|
18864
18814
|
const runDir = runDirectory;
|
|
18865
18815
|
const principalWire = {
|
|
18866
18816
|
sessionDirectory: rewriteRunDirectoryPathValue(
|
|
18867
|
-
|
|
18817
|
+
record.sessionDirectory,
|
|
18868
18818
|
storedRunDirectory,
|
|
18869
18819
|
runDirectory
|
|
18870
18820
|
),
|
|
18871
|
-
...typeof
|
|
18821
|
+
...typeof record.sessionFile === "string" ? { sessionFile: rewriteRunDirectoryPathValue(record.sessionFile, storedRunDirectory, runDirectory) } : {}
|
|
18872
18822
|
};
|
|
18873
18823
|
let resumable;
|
|
18874
|
-
if (
|
|
18875
|
-
if (
|
|
18876
|
-
const r =
|
|
18824
|
+
if (record.resumable !== void 0 && record.resumable !== null) {
|
|
18825
|
+
if (isRecord(record.resumable)) {
|
|
18826
|
+
const r = record.resumable;
|
|
18877
18827
|
if (r.httpStatus === 429 && typeof r.provider === "string" && isV1ResumableProvider(r.provider)) {
|
|
18878
18828
|
resumable = { httpStatus: 429, provider: r.provider };
|
|
18879
18829
|
}
|
|
18880
18830
|
}
|
|
18881
18831
|
}
|
|
18882
|
-
const phase =
|
|
18883
|
-
const currentCourt = parseCurrentCourtState(
|
|
18832
|
+
const phase = record.phase === "plan" || record.phase === "apply" ? record.phase : void 0;
|
|
18833
|
+
const currentCourt = parseCurrentCourtState(record.currentCourt);
|
|
18884
18834
|
return {
|
|
18885
18835
|
runId: identity.runId,
|
|
18886
18836
|
role: identity.role,
|
|
18887
18837
|
state: identity.state,
|
|
18888
18838
|
bookKey: identity.bookKey,
|
|
18889
|
-
projectRoot:
|
|
18839
|
+
projectRoot: record.projectRoot,
|
|
18890
18840
|
runDirectory: runDir,
|
|
18891
18841
|
admittedRequestPath: rewriteRunDirectoryPathValue(
|
|
18892
|
-
|
|
18842
|
+
record.admittedRequestPath,
|
|
18893
18843
|
storedRunDirectory,
|
|
18894
18844
|
runDirectory
|
|
18895
18845
|
),
|
|
@@ -18955,8 +18905,8 @@ async function readRoleRunIdentity(runDirectory) {
|
|
|
18955
18905
|
}
|
|
18956
18906
|
async function markRunAdmitted(admitted, authority) {
|
|
18957
18907
|
const { sessionDirectory, sessionFile } = authority.decode(admitted.principal);
|
|
18958
|
-
const
|
|
18959
|
-
const workerPhase =
|
|
18908
|
+
const record = packagedRoleMetadata(admitted.role);
|
|
18909
|
+
const workerPhase = record !== void 0 && "worker" in record && record.worker === true && "phase" in admitted ? admitted.phase : void 0;
|
|
18960
18910
|
await writeRoleRunState(admitted.runDirectory, {
|
|
18961
18911
|
runId: admitted.runId,
|
|
18962
18912
|
role: admitted.role,
|
|
@@ -19282,15 +19232,15 @@ async function readRunParentPath(runDirectory) {
|
|
|
19282
19232
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
19283
19233
|
throw error;
|
|
19284
19234
|
}
|
|
19285
|
-
if (
|
|
19235
|
+
if (!isRecord(raw)) {
|
|
19286
19236
|
return void 0;
|
|
19287
19237
|
}
|
|
19288
|
-
const
|
|
19289
|
-
if (typeof
|
|
19290
|
-
return
|
|
19238
|
+
const record = raw;
|
|
19239
|
+
if (typeof record.sourceRunPath === "string" && record.sourceRunPath.trim() !== "") {
|
|
19240
|
+
return record.sourceRunPath;
|
|
19291
19241
|
}
|
|
19292
|
-
if (typeof
|
|
19293
|
-
return parentRunPathFromGatePointerInstruction(
|
|
19242
|
+
if (typeof record.instruction === "string") {
|
|
19243
|
+
return parentRunPathFromGatePointerInstruction(record.instruction);
|
|
19294
19244
|
}
|
|
19295
19245
|
return void 0;
|
|
19296
19246
|
}
|
|
@@ -19335,9 +19285,9 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
19335
19285
|
}
|
|
19336
19286
|
return best;
|
|
19337
19287
|
}
|
|
19338
|
-
function parsePersistedTicketIdentity(
|
|
19339
|
-
const correlationId = typeof
|
|
19340
|
-
const ticketNumber = isSafePositiveTicketNumber(
|
|
19288
|
+
function parsePersistedTicketIdentity(record) {
|
|
19289
|
+
const correlationId = typeof record.correlationId === "string" && record.correlationId.trim() !== "" ? record.correlationId : void 0;
|
|
19290
|
+
const ticketNumber = isSafePositiveTicketNumber(record.ticketNumber) ? record.ticketNumber : void 0;
|
|
19341
19291
|
return {
|
|
19342
19292
|
...correlationId === void 0 ? {} : { correlationId },
|
|
19343
19293
|
...ticketNumber === void 0 ? {} : { ticketNumber }
|
|
@@ -19393,78 +19343,78 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19393
19343
|
const raw = JSON.parse(
|
|
19394
19344
|
await readFile21(run.admittedRequestPath, "utf8")
|
|
19395
19345
|
);
|
|
19396
|
-
if (
|
|
19397
|
-
const
|
|
19398
|
-
const storedRunDirectory = typeof
|
|
19399
|
-
rewriteAdmittedRoleRunPage(
|
|
19346
|
+
if (isRecord(raw)) {
|
|
19347
|
+
const record = raw;
|
|
19348
|
+
const storedRunDirectory = typeof record.runDirectory === "string" && record.runDirectory.trim() !== "" ? record.runDirectory : run.runDirectory;
|
|
19349
|
+
rewriteAdmittedRoleRunPage(record, [{
|
|
19400
19350
|
oldRunDirectory: storedRunDirectory,
|
|
19401
19351
|
newRunDirectory: run.runDirectory
|
|
19402
19352
|
}]);
|
|
19403
|
-
if (typeof
|
|
19404
|
-
instruction =
|
|
19353
|
+
if (typeof record.instruction === "string") {
|
|
19354
|
+
instruction = record.instruction;
|
|
19405
19355
|
}
|
|
19406
|
-
if (typeof
|
|
19407
|
-
instructionEmpty =
|
|
19356
|
+
if (typeof record.instructionEmpty === "boolean") {
|
|
19357
|
+
instructionEmpty = record.instructionEmpty;
|
|
19408
19358
|
}
|
|
19409
|
-
if (Array.isArray(
|
|
19410
|
-
attachments =
|
|
19359
|
+
if (Array.isArray(record.attachments)) {
|
|
19360
|
+
attachments = record.attachments;
|
|
19411
19361
|
}
|
|
19412
|
-
if (
|
|
19413
|
-
phase =
|
|
19362
|
+
if (record.phase === "plan" || record.phase === "apply") {
|
|
19363
|
+
phase = record.phase;
|
|
19414
19364
|
}
|
|
19415
|
-
if (typeof
|
|
19416
|
-
taskPath =
|
|
19365
|
+
if (typeof record.taskPath === "string" && record.taskPath.trim() !== "") {
|
|
19366
|
+
taskPath = record.taskPath;
|
|
19417
19367
|
}
|
|
19418
|
-
if (typeof
|
|
19419
|
-
packetPath =
|
|
19368
|
+
if (typeof record.packetPath === "string" && record.packetPath.trim() !== "") {
|
|
19369
|
+
packetPath = record.packetPath;
|
|
19420
19370
|
}
|
|
19421
|
-
if (typeof
|
|
19422
|
-
prerequisitesPath =
|
|
19371
|
+
if (typeof record.prerequisitesPath === "string" && record.prerequisitesPath.trim() !== "") {
|
|
19372
|
+
prerequisitesPath = record.prerequisitesPath;
|
|
19423
19373
|
}
|
|
19424
|
-
if (Array.isArray(
|
|
19425
|
-
prerequisites =
|
|
19374
|
+
if (Array.isArray(record.prerequisites)) {
|
|
19375
|
+
prerequisites = record.prerequisites;
|
|
19426
19376
|
}
|
|
19427
|
-
if (typeof
|
|
19428
|
-
baseRevision =
|
|
19377
|
+
if (typeof record.baseRevision === "string" && record.baseRevision.trim() !== "") {
|
|
19378
|
+
baseRevision = record.baseRevision;
|
|
19429
19379
|
}
|
|
19430
|
-
if (isReviewerLens(
|
|
19431
|
-
lens =
|
|
19380
|
+
if (isReviewerLens(record.lens)) {
|
|
19381
|
+
lens = record.lens;
|
|
19432
19382
|
}
|
|
19433
|
-
if (typeof
|
|
19434
|
-
prNumber =
|
|
19383
|
+
if (typeof record.prNumber === "number" && Number.isSafeInteger(record.prNumber) && record.prNumber >= 1) {
|
|
19384
|
+
prNumber = record.prNumber;
|
|
19435
19385
|
}
|
|
19436
|
-
if (typeof
|
|
19437
|
-
repository =
|
|
19386
|
+
if (typeof record.repository === "string" && record.repository.trim() !== "") {
|
|
19387
|
+
repository = record.repository;
|
|
19438
19388
|
}
|
|
19439
|
-
if (typeof
|
|
19440
|
-
repositoryDisplay =
|
|
19389
|
+
if (typeof record.repositoryDisplay === "string" && record.repositoryDisplay.trim() !== "") {
|
|
19390
|
+
repositoryDisplay = record.repositoryDisplay;
|
|
19441
19391
|
}
|
|
19442
|
-
if (typeof
|
|
19443
|
-
requestManifestPath =
|
|
19392
|
+
if (typeof record.requestManifestPath === "string" && record.requestManifestPath.trim() !== "") {
|
|
19393
|
+
requestManifestPath = record.requestManifestPath;
|
|
19444
19394
|
}
|
|
19445
|
-
if (typeof
|
|
19446
|
-
manifestDigest =
|
|
19395
|
+
if (typeof record.manifestDigest === "string" && record.manifestDigest.trim() !== "") {
|
|
19396
|
+
manifestDigest = record.manifestDigest;
|
|
19447
19397
|
}
|
|
19448
|
-
if (typeof
|
|
19449
|
-
waitWindowMs =
|
|
19398
|
+
if (typeof record.waitWindowMs === "number" && Number.isSafeInteger(record.waitWindowMs) && record.waitWindowMs >= 1) {
|
|
19399
|
+
waitWindowMs = record.waitWindowMs;
|
|
19450
19400
|
}
|
|
19451
|
-
if (typeof
|
|
19452
|
-
issueNumber =
|
|
19401
|
+
if (typeof record.issueNumber === "number" && Number.isSafeInteger(record.issueNumber) && record.issueNumber >= 1) {
|
|
19402
|
+
issueNumber = record.issueNumber;
|
|
19453
19403
|
}
|
|
19454
|
-
if (typeof
|
|
19455
|
-
caseRunsPath =
|
|
19404
|
+
if (typeof record.caseRunsPath === "string" && record.caseRunsPath.trim() !== "") {
|
|
19405
|
+
caseRunsPath = record.caseRunsPath;
|
|
19456
19406
|
}
|
|
19457
|
-
if (
|
|
19458
|
-
const ci =
|
|
19407
|
+
if (isRecord(record.caseIdentity)) {
|
|
19408
|
+
const ci = record.caseIdentity;
|
|
19459
19409
|
if (typeof ci.issueNumber === "number" && Number.isSafeInteger(ci.issueNumber) && ci.issueNumber >= 1 && typeof ci.runsPath === "string" && ci.runsPath.trim() !== "") {
|
|
19460
19410
|
caseIdentity = { issueNumber: ci.issueNumber, runsPath: ci.runsPath };
|
|
19461
19411
|
}
|
|
19462
19412
|
}
|
|
19463
|
-
if (typeof
|
|
19464
|
-
sourceRunPath =
|
|
19413
|
+
if (typeof record.sourceRunPath === "string" && record.sourceRunPath.trim() !== "") {
|
|
19414
|
+
sourceRunPath = record.sourceRunPath;
|
|
19465
19415
|
}
|
|
19466
|
-
if (
|
|
19467
|
-
const sr =
|
|
19416
|
+
if (isRecord(record.sourceRun)) {
|
|
19417
|
+
const sr = record.sourceRun;
|
|
19468
19418
|
if (typeof sr.runId === "string" && sr.runId.trim() !== "" && typeof sr.role === "string" && sr.role.trim() !== "" && typeof sr.runDirectory === "string" && sr.runDirectory.trim() !== "") {
|
|
19469
19419
|
sourceRun = {
|
|
19470
19420
|
runId: sr.runId,
|
|
@@ -19473,9 +19423,9 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19473
19423
|
};
|
|
19474
19424
|
}
|
|
19475
19425
|
}
|
|
19476
|
-
if (Array.isArray(
|
|
19426
|
+
if (Array.isArray(record.authorityRefs)) {
|
|
19477
19427
|
authorityRefs = Object.freeze(
|
|
19478
|
-
|
|
19428
|
+
record.authorityRefs.map((ref) => {
|
|
19479
19429
|
if (typeof ref !== "string") {
|
|
19480
19430
|
throw new CliUsageError(
|
|
19481
19431
|
"role run admitted authority refs must be durable reference strings"
|
|
@@ -19485,11 +19435,11 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19485
19435
|
})
|
|
19486
19436
|
);
|
|
19487
19437
|
}
|
|
19488
|
-
if (typeof
|
|
19489
|
-
mergerInputPath =
|
|
19438
|
+
if (typeof record.mergerInputPath === "string" && record.mergerInputPath.trim() !== "") {
|
|
19439
|
+
mergerInputPath = record.mergerInputPath;
|
|
19490
19440
|
}
|
|
19491
|
-
if (
|
|
19492
|
-
const d =
|
|
19441
|
+
if (isRecord(record.derived)) {
|
|
19442
|
+
const d = record.derived;
|
|
19493
19443
|
if (typeof d.targetObjectId === "string" && typeof d.sourceObjectId === "string" && Array.isArray(d.expectedConflictPaths) && Array.isArray(d.resolutionScope) && d.expectedConflictPaths.every((p) => typeof p === "string") && d.resolutionScope.every((p) => typeof p === "string")) {
|
|
19494
19444
|
derived = {
|
|
19495
19445
|
targetObjectId: d.targetObjectId,
|
|
@@ -19499,7 +19449,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19499
19449
|
};
|
|
19500
19450
|
}
|
|
19501
19451
|
}
|
|
19502
|
-
const fromAdmitted = parsePersistedTicketIdentity(
|
|
19452
|
+
const fromAdmitted = parsePersistedTicketIdentity(record);
|
|
19503
19453
|
correlationId = fromAdmitted.correlationId;
|
|
19504
19454
|
ticketNumber = fromAdmitted.ticketNumber;
|
|
19505
19455
|
}
|
|
@@ -19515,7 +19465,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19515
19465
|
const invocationRaw = JSON.parse(
|
|
19516
19466
|
await readFile21(join37(run.runDirectory, "invocation.json"), "utf8")
|
|
19517
19467
|
);
|
|
19518
|
-
if (
|
|
19468
|
+
if (isRecord(invocationRaw)) {
|
|
19519
19469
|
const rec = invocationRaw;
|
|
19520
19470
|
if (typeof rec.provider === "string" && typeof rec.model === "string") {
|
|
19521
19471
|
model = {
|
|
@@ -19534,7 +19484,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19534
19484
|
if (error instanceof CliUsageError) {
|
|
19535
19485
|
throw error;
|
|
19536
19486
|
}
|
|
19537
|
-
if (!(error
|
|
19487
|
+
if (!isEnoent(error)) {
|
|
19538
19488
|
throw new CliUsageError(
|
|
19539
19489
|
`role run invocation identity is unreadable: ${runId}`,
|
|
19540
19490
|
{ cause: error }
|
|
@@ -19628,13 +19578,13 @@ async function loadResumablePublicRole(home, runId, authority) {
|
|
|
19628
19578
|
function admitResumedRole(loaded) {
|
|
19629
19579
|
const role = loaded.run.role;
|
|
19630
19580
|
const runId = loaded.run.runId;
|
|
19631
|
-
const
|
|
19632
|
-
if (
|
|
19581
|
+
const record = packagedRoleMetadata(role);
|
|
19582
|
+
if (record === void 0) {
|
|
19633
19583
|
throw new CliUsageError(`unknown role: ${role}`);
|
|
19634
19584
|
}
|
|
19635
19585
|
const fields = loaded.admittedFields;
|
|
19636
19586
|
const base = resumedBaseAdmitted(loaded);
|
|
19637
|
-
switch (
|
|
19587
|
+
switch (record.admission) {
|
|
19638
19588
|
case "instruction": {
|
|
19639
19589
|
if (packagedResumeSourcePath(role)) {
|
|
19640
19590
|
const admitted = {
|
|
@@ -19657,7 +19607,7 @@ function admitResumedRole(loaded) {
|
|
|
19657
19607
|
return admitted;
|
|
19658
19608
|
}
|
|
19659
19609
|
case "worker-task": {
|
|
19660
|
-
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase,
|
|
19610
|
+
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role, runId);
|
|
19661
19611
|
const taskPath = fields.taskPath;
|
|
19662
19612
|
if (taskPath === void 0) {
|
|
19663
19613
|
throw new CliUsageError(
|
|
@@ -19679,7 +19629,7 @@ function admitResumedRole(loaded) {
|
|
|
19679
19629
|
return admitted;
|
|
19680
19630
|
}
|
|
19681
19631
|
case "worker-packet": {
|
|
19682
|
-
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase,
|
|
19632
|
+
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role, runId);
|
|
19683
19633
|
const packetPath = fields.packetPath;
|
|
19684
19634
|
if (packetPath === void 0) {
|
|
19685
19635
|
throw new CliUsageError(
|
|
@@ -19784,7 +19734,7 @@ function admitResumedRole(loaded) {
|
|
|
19784
19734
|
try {
|
|
19785
19735
|
parsedRepository = parseCollectorRepository(repositoryDisplay);
|
|
19786
19736
|
} catch (error) {
|
|
19787
|
-
const detail =
|
|
19737
|
+
const detail = errorText(error);
|
|
19788
19738
|
throw new CliUsageError(detail, { cause: error });
|
|
19789
19739
|
}
|
|
19790
19740
|
if (parsedRepository.canonical !== repository) {
|
|
@@ -19859,6 +19809,7 @@ var init_run_lifecycle = __esm({
|
|
|
19859
19809
|
init_engine_material();
|
|
19860
19810
|
init_packaged_role_registry();
|
|
19861
19811
|
init_invocation();
|
|
19812
|
+
init_unknown_value();
|
|
19862
19813
|
V1_RESUMABLE_PROVIDERS = ["openai-codex", "xai"];
|
|
19863
19814
|
AUTO_RESUME_LIMIT = 2;
|
|
19864
19815
|
RESUME_TRANSPORT_ENVELOPE = "\u7EE7\u7EED\u3002";
|
|
@@ -19918,7 +19869,7 @@ async function readOwnedSubmissionRecords(cwd, runId, scope = {}) {
|
|
|
19918
19869
|
return {
|
|
19919
19870
|
file,
|
|
19920
19871
|
owned: records.filter(
|
|
19921
|
-
(
|
|
19872
|
+
(record) => typeof record.subject === "object" && record.subject !== null && record.subject.runId === runId
|
|
19922
19873
|
)
|
|
19923
19874
|
};
|
|
19924
19875
|
}
|
|
@@ -19931,24 +19882,24 @@ function recordsForAttempt(owned, attemptId) {
|
|
|
19931
19882
|
void attemptId;
|
|
19932
19883
|
return owned;
|
|
19933
19884
|
}
|
|
19934
|
-
function recordAttemptId(
|
|
19935
|
-
if (typeof
|
|
19936
|
-
const fromSubject =
|
|
19885
|
+
function recordAttemptId(record) {
|
|
19886
|
+
if (typeof record.subject === "object" && record.subject !== null) {
|
|
19887
|
+
const fromSubject = record.subject.attemptId;
|
|
19937
19888
|
if (typeof fromSubject === "string" && fromSubject.length > 0) return fromSubject;
|
|
19938
19889
|
}
|
|
19939
|
-
if (typeof
|
|
19940
|
-
const fromPayload =
|
|
19890
|
+
if (typeof record.payload === "object" && record.payload !== null) {
|
|
19891
|
+
const fromPayload = record.payload.attemptId;
|
|
19941
19892
|
if (typeof fromPayload === "string" && fromPayload.length > 0) return fromPayload;
|
|
19942
19893
|
}
|
|
19943
19894
|
return void 0;
|
|
19944
19895
|
}
|
|
19945
19896
|
async function hasFreshAttemptSubmission(cwd, runId, attemptId, homeOrScope) {
|
|
19946
19897
|
const { owned } = await readOwnedSubmissionRecords(cwd, runId, resolveReadScope(homeOrScope));
|
|
19947
|
-
return owned.some((
|
|
19948
|
-
if (recordAttemptId(
|
|
19949
|
-
if (
|
|
19950
|
-
if (
|
|
19951
|
-
const payload =
|
|
19898
|
+
return owned.some((record) => {
|
|
19899
|
+
if (recordAttemptId(record) !== attemptId) return false;
|
|
19900
|
+
if (record.kind === "sealed") return true;
|
|
19901
|
+
if (record.kind === "outcome") {
|
|
19902
|
+
const payload = record.payload;
|
|
19952
19903
|
return payload?.type === "outcome" && payload.outcome === "audit-escalation";
|
|
19953
19904
|
}
|
|
19954
19905
|
return false;
|
|
@@ -19994,12 +19945,12 @@ function mapOwnedToSubmissionRows(owned) {
|
|
|
19994
19945
|
const out = [];
|
|
19995
19946
|
const indexByCall = /* @__PURE__ */ new Map();
|
|
19996
19947
|
const roleByCall = /* @__PURE__ */ new Map();
|
|
19997
|
-
for (const
|
|
19998
|
-
const payload =
|
|
19948
|
+
for (const record of scoped) {
|
|
19949
|
+
const payload = record.payload;
|
|
19999
19950
|
if (typeof payload?.toolCallId !== "string" || payload.toolCallId.length === 0) continue;
|
|
20000
19951
|
const role = recordedRole(payload);
|
|
20001
19952
|
if (role !== void 0) {
|
|
20002
|
-
roleByCall.set(submissionCallKey(recordAttemptId(
|
|
19953
|
+
roleByCall.set(submissionCallKey(recordAttemptId(record), payload.toolCallId), role);
|
|
20003
19954
|
}
|
|
20004
19955
|
}
|
|
20005
19956
|
const take = (row, callKey) => {
|
|
@@ -20024,26 +19975,26 @@ function mapOwnedToSubmissionRows(owned) {
|
|
|
20024
19975
|
}
|
|
20025
19976
|
out.push(row);
|
|
20026
19977
|
};
|
|
20027
|
-
for (const
|
|
20028
|
-
const attemptId = recordAttemptId(
|
|
20029
|
-
if (
|
|
20030
|
-
const payload2 =
|
|
19978
|
+
for (const record of scoped) {
|
|
19979
|
+
const attemptId = recordAttemptId(record);
|
|
19980
|
+
if (record.kind === "candidate") {
|
|
19981
|
+
const payload2 = record.payload;
|
|
20031
19982
|
if (payload2?.type !== "candidate" || payload2.params === void 0) continue;
|
|
20032
19983
|
const callKey2 = typeof payload2.toolCallId === "string" ? submissionCallKey(attemptId, payload2.toolCallId) : void 0;
|
|
20033
19984
|
const fallback2 = callKey2 !== void 0 ? roleByCall.get(callKey2) : void 0;
|
|
20034
19985
|
take(rowFromPayload("candidate", payload2, payload2.params, fallback2), callKey2);
|
|
20035
19986
|
continue;
|
|
20036
19987
|
}
|
|
20037
|
-
if (
|
|
20038
|
-
const payload2 =
|
|
19988
|
+
if (record.kind === "sealed") {
|
|
19989
|
+
const payload2 = record.payload;
|
|
20039
19990
|
if (payload2?.type !== "sealed" || payload2.accepted === void 0) continue;
|
|
20040
19991
|
const callKey2 = typeof payload2.toolCallId === "string" ? submissionCallKey(attemptId, payload2.toolCallId) : void 0;
|
|
20041
19992
|
const fallback2 = callKey2 !== void 0 ? roleByCall.get(callKey2) : void 0;
|
|
20042
19993
|
take(rowFromPayload("accepted", payload2, payload2.accepted, fallback2), callKey2);
|
|
20043
19994
|
continue;
|
|
20044
19995
|
}
|
|
20045
|
-
if (
|
|
20046
|
-
const payload =
|
|
19996
|
+
if (record.kind !== "outcome") continue;
|
|
19997
|
+
const payload = record.payload;
|
|
20047
19998
|
if (payload?.type !== "outcome" || payload.accepted === void 0) continue;
|
|
20048
19999
|
const outcome = payload.outcome;
|
|
20049
20000
|
const kind = outcome === "audit-escalation" ? "audit-escalation" : outcome === "correctable-rejection" ? "correctable-rejection" : outcome === "infrastructure" ? "infrastructure" : void 0;
|
|
@@ -20067,7 +20018,7 @@ async function readAttemptScopedSubmissionRows(cwd, runId, attemptId, home) {
|
|
|
20067
20018
|
runId,
|
|
20068
20019
|
home === void 0 ? {} : { home }
|
|
20069
20020
|
);
|
|
20070
|
-
return mapOwnedToSubmissionRows(owned.filter((
|
|
20021
|
+
return mapOwnedToSubmissionRows(owned.filter((record) => recordAttemptId(record) === attemptId));
|
|
20071
20022
|
}
|
|
20072
20023
|
async function readRecordedSubmissions(cwd, runId, homeOrScope) {
|
|
20073
20024
|
return (await readRecordedSubmissionRows(cwd, runId, homeOrScope)).map((row) => row.accepted);
|
|
@@ -20084,8 +20035,8 @@ async function restoreState(cwd, runId, scope) {
|
|
|
20084
20035
|
}
|
|
20085
20036
|
const { owned } = located;
|
|
20086
20037
|
return {
|
|
20087
|
-
sequence: owned.reduce((maximum,
|
|
20088
|
-
const payload =
|
|
20038
|
+
sequence: owned.reduce((maximum, record) => {
|
|
20039
|
+
const payload = record.payload;
|
|
20089
20040
|
return payload?.type === "candidate" && typeof payload.sequence === "number" ? Math.max(maximum, payload.sequence) : maximum;
|
|
20090
20041
|
}, 0)
|
|
20091
20042
|
};
|
|
@@ -20200,7 +20151,7 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
|
|
|
20200
20151
|
});
|
|
20201
20152
|
let result;
|
|
20202
20153
|
try {
|
|
20203
|
-
const reviewEscalate = tool.name === REVIEW_SUBMISSION_OUTPUT_TOOL_NAME && infrastructureFailureDiagnostic(params) !== void 0 &&
|
|
20154
|
+
const reviewEscalate = tool.name === REVIEW_SUBMISSION_OUTPUT_TOOL_NAME && infrastructureFailureDiagnostic(params) !== void 0 && isRecord(params) && params.status === "escalate";
|
|
20204
20155
|
if (!reviewEscalate) {
|
|
20205
20156
|
failOnInfrastructureFailureDeclaration(
|
|
20206
20157
|
params,
|
|
@@ -20223,7 +20174,7 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
|
|
|
20223
20174
|
toolCallId,
|
|
20224
20175
|
outcome: "correctable-rejection",
|
|
20225
20176
|
code: "typed-bounce",
|
|
20226
|
-
diagnostic:
|
|
20177
|
+
diagnostic: errorText(error),
|
|
20227
20178
|
role,
|
|
20228
20179
|
accepted: params
|
|
20229
20180
|
});
|
|
@@ -20234,7 +20185,7 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
|
|
|
20234
20185
|
attemptId,
|
|
20235
20186
|
toolCallId,
|
|
20236
20187
|
outcome: "infrastructure",
|
|
20237
|
-
diagnostic:
|
|
20188
|
+
diagnostic: errorText(error),
|
|
20238
20189
|
role,
|
|
20239
20190
|
accepted: params
|
|
20240
20191
|
});
|
|
@@ -20272,11 +20223,11 @@ var init_submission_ledger = __esm({
|
|
|
20272
20223
|
init_submission_correctable_error();
|
|
20273
20224
|
init_terminating_infrastructure();
|
|
20274
20225
|
init_review_submission();
|
|
20226
|
+
init_unknown_value();
|
|
20275
20227
|
}
|
|
20276
20228
|
});
|
|
20277
20229
|
|
|
20278
20230
|
// src/archivist-record-topology.ts
|
|
20279
|
-
import { createHash as createHash4 } from "node:crypto";
|
|
20280
20231
|
import { join as join40 } from "node:path";
|
|
20281
20232
|
function resolveNavigatorWorkSubjectPlacement(input) {
|
|
20282
20233
|
let ledgerHome;
|
|
@@ -20287,7 +20238,7 @@ function resolveNavigatorWorkSubjectPlacement(input) {
|
|
|
20287
20238
|
}
|
|
20288
20239
|
}
|
|
20289
20240
|
ledgerHome ??= resolveActivationLedgerHome(input.home);
|
|
20290
|
-
const digest =
|
|
20241
|
+
const digest = sha256Hex(input.subject).slice(0, 32);
|
|
20291
20242
|
return {
|
|
20292
20243
|
ledgerHome,
|
|
20293
20244
|
sessionDir: join40(
|
|
@@ -20301,6 +20252,7 @@ var NAVIGATOR_RECORD_KIND;
|
|
|
20301
20252
|
var init_archivist_record_topology = __esm({
|
|
20302
20253
|
"src/archivist-record-topology.ts"() {
|
|
20303
20254
|
"use strict";
|
|
20255
|
+
init_sha256();
|
|
20304
20256
|
init_activation_ledger_git();
|
|
20305
20257
|
init_activation_ledger_topology();
|
|
20306
20258
|
NAVIGATOR_RECORD_KIND = "navigator";
|
|
@@ -20828,8 +20780,8 @@ init_session_opening_materials();
|
|
|
20828
20780
|
// src/stderr-jsonl.ts
|
|
20829
20781
|
import { writeSync } from "node:fs";
|
|
20830
20782
|
var STDERR_JSONL_WRITE_RETRY_LIMIT = 100;
|
|
20831
|
-
function writeStderrJsonlRecord(
|
|
20832
|
-
const bytes = Buffer.from(`${JSON.stringify(
|
|
20783
|
+
function writeStderrJsonlRecord(record, write = writeSync) {
|
|
20784
|
+
const bytes = Buffer.from(`${JSON.stringify(record)}
|
|
20833
20785
|
`);
|
|
20834
20786
|
let offset = 0;
|
|
20835
20787
|
let retries = 0;
|
|
@@ -21136,6 +21088,7 @@ init_compliance_transport();
|
|
|
21136
21088
|
init_dossier_resolution();
|
|
21137
21089
|
init_doctor_contracts();
|
|
21138
21090
|
init_sitian_facade();
|
|
21091
|
+
init_unknown_value();
|
|
21139
21092
|
var DOCTOR_CASE_FLAG = { name: "ak-doctor-case", definition: { description: "Retained .ak-roles/books/<book>/<n>/runs directory", type: "string" } };
|
|
21140
21093
|
function appendCandidate(ctx, data) {
|
|
21141
21094
|
try {
|
|
@@ -21148,14 +21101,14 @@ function appendCandidate(ctx, data) {
|
|
|
21148
21101
|
source: "doctor-role"
|
|
21149
21102
|
});
|
|
21150
21103
|
} catch (error) {
|
|
21151
|
-
throw new ComplianceResponseRetentionError(`\u592A\u533B\u7F72\u5019\u9009\u7559\u5B58\u5931\u8D25: ${
|
|
21104
|
+
throw new ComplianceResponseRetentionError(`\u592A\u533B\u7F72\u5019\u9009\u7559\u5B58\u5931\u8D25: ${errorText(error)}`, { cause: error });
|
|
21152
21105
|
}
|
|
21153
21106
|
const append = ctx.sessionManager.appendCustomEntry;
|
|
21154
21107
|
if (typeof append === "function") {
|
|
21155
21108
|
try {
|
|
21156
21109
|
append.call(ctx.sessionManager, DOCTOR_CANDIDATE_ENTRY_TYPE, data);
|
|
21157
21110
|
} catch (error) {
|
|
21158
|
-
throw new ComplianceResponseRetentionError(`\u592A\u533B\u7F72\u5019\u9009\u7559\u5B58\u5931\u8D25: ${
|
|
21111
|
+
throw new ComplianceResponseRetentionError(`\u592A\u533B\u7F72\u5019\u9009\u7559\u5B58\u5931\u8D25: ${errorText(error)}`, { cause: error });
|
|
21159
21112
|
}
|
|
21160
21113
|
}
|
|
21161
21114
|
}
|
|
@@ -21486,7 +21439,6 @@ var AUDITOR_TOOL_SPEC = {
|
|
|
21486
21439
|
};
|
|
21487
21440
|
|
|
21488
21441
|
// src/navigator-attendance.ts
|
|
21489
|
-
import { createHash as createHash5 } from "node:crypto";
|
|
21490
21442
|
init_navigator_invocation_identity();
|
|
21491
21443
|
init_packaged_role_registry();
|
|
21492
21444
|
init_activation_ledger_topology();
|
|
@@ -21500,6 +21452,7 @@ import { existsSync as existsSync13 } from "node:fs";
|
|
|
21500
21452
|
import { basename as basename11 } from "node:path";
|
|
21501
21453
|
|
|
21502
21454
|
// src/navigator-session-contracts.ts
|
|
21455
|
+
init_unknown_value();
|
|
21503
21456
|
import { Type as Type18 } from "typebox";
|
|
21504
21457
|
import { Value as Value3 } from "typebox/value";
|
|
21505
21458
|
var NAVIGATOR_PREPARE_TOOL_NAME = "ak_navigator_prepare";
|
|
@@ -21529,12 +21482,9 @@ var NavigatorUnavailableError = class extends Error {
|
|
|
21529
21482
|
}
|
|
21530
21483
|
};
|
|
21531
21484
|
function navigatorUnavailableError(source, error, cause = source) {
|
|
21532
|
-
const message =
|
|
21485
|
+
const message = errorText(error);
|
|
21533
21486
|
return error instanceof NavigatorUnavailableError ? error : new NavigatorUnavailableError(source, message, cause, error);
|
|
21534
21487
|
}
|
|
21535
|
-
function exactRecord(value) {
|
|
21536
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21537
|
-
}
|
|
21538
21488
|
function navigatorProviderFailureFromStatus(status) {
|
|
21539
21489
|
if (status === 401 || status === 403) return { source: "auth", cause: "auth" };
|
|
21540
21490
|
if (status === 429) return { source: "quota", cause: "quota" };
|
|
@@ -21556,7 +21506,7 @@ function navigatorProviderFailureFromError(error) {
|
|
|
21556
21506
|
if (cursor instanceof NavigatorUnavailableError) {
|
|
21557
21507
|
return { source: cursor.unavailableSource, cause: cursor.unavailableCause };
|
|
21558
21508
|
}
|
|
21559
|
-
if (!
|
|
21509
|
+
if (!isRecord(cursor)) {
|
|
21560
21510
|
cursor = cursor instanceof Error ? cursor.cause : void 0;
|
|
21561
21511
|
continue;
|
|
21562
21512
|
}
|
|
@@ -21574,13 +21524,13 @@ function navigatorProviderFailureFromError(error) {
|
|
|
21574
21524
|
function navigatorProviderFailureFromDiagnostics(diagnostics) {
|
|
21575
21525
|
if (!Array.isArray(diagnostics)) return void 0;
|
|
21576
21526
|
for (const diagnostic of diagnostics) {
|
|
21577
|
-
if (!
|
|
21527
|
+
if (!isRecord(diagnostic)) continue;
|
|
21578
21528
|
if (diagnostic.type === "provider_transport_failure") return { source: "transport", cause: "transport" };
|
|
21579
|
-
if (
|
|
21529
|
+
if (isRecord(diagnostic.error)) {
|
|
21580
21530
|
const fromCode = navigatorProviderFailureFromCode(diagnostic.error.code);
|
|
21581
21531
|
if (fromCode !== void 0) return fromCode;
|
|
21582
21532
|
}
|
|
21583
|
-
if (
|
|
21533
|
+
if (isRecord(diagnostic.details)) {
|
|
21584
21534
|
const status = typeof diagnostic.details.status === "number" ? diagnostic.details.status : typeof diagnostic.details.statusCode === "number" ? diagnostic.details.statusCode : void 0;
|
|
21585
21535
|
const fromStatus = navigatorProviderFailureFromStatus(status);
|
|
21586
21536
|
if (fromStatus !== void 0) return fromStatus;
|
|
@@ -21690,6 +21640,7 @@ init_packaged_role_registry();
|
|
|
21690
21640
|
|
|
21691
21641
|
// src/navigator-work-base.ts
|
|
21692
21642
|
init_atomic_write();
|
|
21643
|
+
init_unknown_value();
|
|
21693
21644
|
import { existsSync as existsSync10, realpathSync as realpathSync3 } from "node:fs";
|
|
21694
21645
|
import { readFile as readFile22 } from "node:fs/promises";
|
|
21695
21646
|
import { basename as basename10, dirname as dirname22, join as join39, resolve as resolve16 } from "node:path";
|
|
@@ -21723,9 +21674,7 @@ async function persistNavigatorWorkBase(sessionDir, body) {
|
|
|
21723
21674
|
const current = await readFile22(path, "utf8");
|
|
21724
21675
|
if (current === next) return path;
|
|
21725
21676
|
} catch (error) {
|
|
21726
|
-
if (!(error
|
|
21727
|
-
throw error;
|
|
21728
|
-
}
|
|
21677
|
+
if (!isEnoent(error)) throw error;
|
|
21729
21678
|
}
|
|
21730
21679
|
await writeFileAtomically(path, next);
|
|
21731
21680
|
return path;
|
|
@@ -21737,9 +21686,7 @@ async function readNavigatorWorkBase(path) {
|
|
|
21737
21686
|
try {
|
|
21738
21687
|
text = await readFile22(canonical, "utf8");
|
|
21739
21688
|
} catch (error) {
|
|
21740
|
-
if (error
|
|
21741
|
-
return void 0;
|
|
21742
|
-
}
|
|
21689
|
+
if (isEnoent(error)) return void 0;
|
|
21743
21690
|
throw error;
|
|
21744
21691
|
}
|
|
21745
21692
|
let parsed;
|
|
@@ -21748,36 +21695,36 @@ async function readNavigatorWorkBase(path) {
|
|
|
21748
21695
|
} catch {
|
|
21749
21696
|
return void 0;
|
|
21750
21697
|
}
|
|
21751
|
-
if (
|
|
21752
|
-
const
|
|
21753
|
-
if (typeof
|
|
21754
|
-
if (
|
|
21755
|
-
return { subject:
|
|
21698
|
+
if (!isRecord(parsed)) return void 0;
|
|
21699
|
+
const record = parsed;
|
|
21700
|
+
if (typeof record.subject !== "string" || typeof record.authority !== "string") return void 0;
|
|
21701
|
+
if (record.authority.trim() === "") return void 0;
|
|
21702
|
+
return { subject: record.subject, authority: record.authority };
|
|
21756
21703
|
}
|
|
21757
21704
|
function jsonObjectFromPrompt(prompt) {
|
|
21758
21705
|
const head = prompt.trimStart().split("\n\n", 1)[0] ?? "";
|
|
21759
21706
|
if (!head.startsWith("{")) return void 0;
|
|
21760
21707
|
try {
|
|
21761
21708
|
const parsed = JSON.parse(head);
|
|
21762
|
-
if (
|
|
21709
|
+
if (!isRecord(parsed)) return void 0;
|
|
21763
21710
|
return parsed;
|
|
21764
21711
|
} catch {
|
|
21765
21712
|
return void 0;
|
|
21766
21713
|
}
|
|
21767
21714
|
}
|
|
21768
21715
|
function workContextPathFromPrompt(prompt) {
|
|
21769
|
-
const
|
|
21770
|
-
const path =
|
|
21716
|
+
const record = jsonObjectFromPrompt(prompt);
|
|
21717
|
+
const path = record?.workContextPath;
|
|
21771
21718
|
if (typeof path !== "string" || path.trim() === "") return void 0;
|
|
21772
21719
|
return isNavigatorWorkContextFile(path) ? path : void 0;
|
|
21773
21720
|
}
|
|
21774
21721
|
function attachWorkContextPointer(text, workContextPath) {
|
|
21775
|
-
const
|
|
21776
|
-
if (
|
|
21777
|
-
if (typeof
|
|
21722
|
+
const record = jsonObjectFromPrompt(text);
|
|
21723
|
+
if (record === void 0) return text;
|
|
21724
|
+
if (typeof record.workContextPath === "string" && record.workContextPath.trim() !== "") return text;
|
|
21778
21725
|
const head = text.trimStart().split("\n\n", 1)[0] ?? "";
|
|
21779
21726
|
const rest = text.trimStart().slice(head.length);
|
|
21780
|
-
return `${JSON.stringify({ ...
|
|
21727
|
+
return `${JSON.stringify({ ...record, workContextPath })}${rest}`;
|
|
21781
21728
|
}
|
|
21782
21729
|
async function loadNavigatorWorkBaseSuffix(prompt) {
|
|
21783
21730
|
const path = workContextPathFromPrompt(prompt);
|
|
@@ -21794,6 +21741,7 @@ ${body.authority}
|
|
|
21794
21741
|
}
|
|
21795
21742
|
|
|
21796
21743
|
// src/navigator-public-session.ts
|
|
21744
|
+
init_unknown_value();
|
|
21797
21745
|
async function resolveNavigatorLedgerHome(context) {
|
|
21798
21746
|
const { tryHomeFromAkRolesPath: tryHomeFromAkRolesPath2 } = await Promise.resolve().then(() => (init_activation_ledger_topology(), activation_ledger_topology_exports));
|
|
21799
21747
|
const runDirectory = runDirectoryFromHostContext(context);
|
|
@@ -21809,9 +21757,6 @@ async function resolveNavigatorLedgerHome(context) {
|
|
|
21809
21757
|
return void 0;
|
|
21810
21758
|
}
|
|
21811
21759
|
var NAVIGATOR_HOST_RUN_POINTER_ENTRY = "ak-navigator-host-run";
|
|
21812
|
-
function exactRecord2(value) {
|
|
21813
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21814
|
-
}
|
|
21815
21760
|
function runIdFromNavigatorDirectory(runDirectory) {
|
|
21816
21761
|
const entry = basename11(runDirectory);
|
|
21817
21762
|
const suffix = "@navigator";
|
|
@@ -21822,10 +21767,10 @@ function runIdFromNavigatorDirectory(runDirectory) {
|
|
|
21822
21767
|
function readNavigatorHostRunPointer(entries) {
|
|
21823
21768
|
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
21824
21769
|
const entry = entries[index];
|
|
21825
|
-
if (!
|
|
21770
|
+
if (!isRecord(entry)) continue;
|
|
21826
21771
|
if (entry.type === "custom" && entry.customType === NAVIGATOR_HOST_RUN_POINTER_ENTRY) {
|
|
21827
21772
|
const data = entry.data;
|
|
21828
|
-
if (
|
|
21773
|
+
if (isRecord(data) && typeof data.runId === "string" && data.runId.trim() !== "") {
|
|
21829
21774
|
return data.runId.trim();
|
|
21830
21775
|
}
|
|
21831
21776
|
}
|
|
@@ -22005,6 +21950,8 @@ init_sitian_facade();
|
|
|
22005
21950
|
init_work_subject_identity();
|
|
22006
21951
|
init_receipt_delivery_policy();
|
|
22007
21952
|
init_navigator_output();
|
|
21953
|
+
init_sha256();
|
|
21954
|
+
init_unknown_value();
|
|
22008
21955
|
var NAVIGATOR_EVENT_TYPE = "ak-navigator-attendance";
|
|
22009
21956
|
function resolveNavigatorAuthorityMaterial(roleInput, fileAuthority) {
|
|
22010
21957
|
if (roleInput !== void 0 && roleInput.trim() !== "") return roleInput;
|
|
@@ -22019,27 +21966,24 @@ var prepareSchema = Type19.Object({
|
|
|
22019
21966
|
}, { additionalProperties: true });
|
|
22020
21967
|
var INVOCATION_ENTRY = NAVIGATOR_INVOCATION_ENTRY;
|
|
22021
21968
|
var SETTLEMENT_ENTRY = "ak-navigator-settlement";
|
|
22022
|
-
function exactRecord3(value) {
|
|
22023
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22024
|
-
}
|
|
22025
21969
|
function rejectedPrepareReason(entries, start) {
|
|
22026
21970
|
const recent = entries.slice(start);
|
|
22027
21971
|
const prepareCalls = /* @__PURE__ */ new Set();
|
|
22028
21972
|
for (const entry of recent) {
|
|
22029
|
-
if (!
|
|
21973
|
+
if (!isRecord(entry) || entry.type !== "message" || !isRecord(entry.message) || entry.message.role !== "assistant" || !Array.isArray(entry.message.content)) continue;
|
|
22030
21974
|
for (const part of entry.message.content) {
|
|
22031
|
-
if (
|
|
21975
|
+
if (isRecord(part) && part.type === "toolCall" && part.name === NAVIGATOR_PREPARE_TOOL_NAME && typeof part.id === "string") prepareCalls.add(part.id);
|
|
22032
21976
|
}
|
|
22033
21977
|
}
|
|
22034
21978
|
let reason;
|
|
22035
21979
|
for (const entry of recent) {
|
|
22036
|
-
if (!
|
|
21980
|
+
if (!isRecord(entry) || entry.type !== "message" || !isRecord(entry.message) || entry.message.role !== "toolResult" || entry.message.isError !== true) continue;
|
|
22037
21981
|
const callId = entry.message.toolCallId;
|
|
22038
21982
|
if (entry.message.toolName !== NAVIGATOR_PREPARE_TOOL_NAME || typeof callId !== "string" || !prepareCalls.has(callId)) {
|
|
22039
21983
|
return void 0;
|
|
22040
21984
|
}
|
|
22041
21985
|
const content = entry.message.content;
|
|
22042
|
-
const text = Array.isArray(content) ? content.flatMap((part) =>
|
|
21986
|
+
const text = Array.isArray(content) ? content.flatMap((part) => isRecord(part) && typeof part.text === "string" ? [part.text] : []).join("") : typeof content === "string" ? content : "";
|
|
22043
21987
|
if (text.trim() !== "") reason = text.trim();
|
|
22044
21988
|
}
|
|
22045
21989
|
return reason;
|
|
@@ -22052,7 +21996,7 @@ function navigatorSubjectKey(subjectRoot, subject, provenance = "role_input") {
|
|
|
22052
21996
|
if (provenance === "placeholder") return subjectRoot;
|
|
22053
21997
|
const normalized = subject.trim().replace(/\s+/g, " ");
|
|
22054
21998
|
if (normalized === "") return subjectRoot;
|
|
22055
|
-
return `${subjectRoot}#${
|
|
21999
|
+
return `${subjectRoot}#${sha256Hex(normalized).slice(0, 32)}`;
|
|
22056
22000
|
}
|
|
22057
22001
|
function navigatorSubjectKeyForInput(subjectRoot, reference, cwd = process.cwd()) {
|
|
22058
22002
|
if (issueRoot(subjectRoot) !== void 0 || !subjectRoot.includes("/.ak/work/")) return subjectRoot;
|
|
@@ -22274,10 +22218,10 @@ function createNavigatorAttendance(options) {
|
|
|
22274
22218
|
return void 0;
|
|
22275
22219
|
}
|
|
22276
22220
|
const nativeFailure = [...activeSession.entries()].reverse().find((entry) => {
|
|
22277
|
-
if (!
|
|
22221
|
+
if (!isRecord(entry) || entry.type !== "message" || !isRecord(entry.message)) return false;
|
|
22278
22222
|
return entry.message.role === "assistant" && typeof entry.message.errorMessage === "string" && entry.message.errorMessage.trim() !== "";
|
|
22279
22223
|
});
|
|
22280
|
-
const nativeMessage =
|
|
22224
|
+
const nativeMessage = isRecord(nativeFailure) && isRecord(nativeFailure.message) ? nativeFailure.message : void 0;
|
|
22281
22225
|
const errorMessage = nativeMessage !== void 0 && typeof nativeMessage.errorMessage === "string" ? nativeMessage.errorMessage : "Navigator did not submit direction advice";
|
|
22282
22226
|
const providerFailure = activeSession.providerFailure?.();
|
|
22283
22227
|
const source = providerFailure?.source ?? "unknown";
|
|
@@ -22524,6 +22468,7 @@ init_archivist_record_entry();
|
|
|
22524
22468
|
init_sitian_facade();
|
|
22525
22469
|
init_submission_errors();
|
|
22526
22470
|
init_worker_submission_contracts();
|
|
22471
|
+
init_unknown_value();
|
|
22527
22472
|
init_submission_errors();
|
|
22528
22473
|
init_worker_submission_contracts();
|
|
22529
22474
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
@@ -22623,13 +22568,10 @@ function uninstallPackageWorkerHooks(cwd) {
|
|
|
22623
22568
|
rmOwnedDir(resolve19(gitDir, HOOKS_DIR));
|
|
22624
22569
|
}
|
|
22625
22570
|
}
|
|
22626
|
-
function isRecord15(value) {
|
|
22627
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22628
|
-
}
|
|
22629
22571
|
function containsWrittenReason(value) {
|
|
22630
22572
|
if (typeof value === "string") return value.trim().length > 0;
|
|
22631
22573
|
if (Array.isArray(value)) return value.some(containsWrittenReason);
|
|
22632
|
-
if (
|
|
22574
|
+
if (isRecord(value)) {
|
|
22633
22575
|
return Object.entries(value).some(
|
|
22634
22576
|
([key, item]) => containsWrittenReason(key) || containsWrittenReason(item)
|
|
22635
22577
|
);
|
|
@@ -22637,7 +22579,7 @@ function containsWrittenReason(value) {
|
|
|
22637
22579
|
return false;
|
|
22638
22580
|
}
|
|
22639
22581
|
function unfinishedReasonPresent(details) {
|
|
22640
|
-
if (
|
|
22582
|
+
if (!isRecord(details)) return false;
|
|
22641
22583
|
return containsWrittenReason(details.reason);
|
|
22642
22584
|
}
|
|
22643
22585
|
function readGateState(session) {
|
|
@@ -22648,7 +22590,7 @@ function readGateState(session) {
|
|
|
22648
22590
|
if (entry.type !== "custom") continue;
|
|
22649
22591
|
if (entry.customType === WORKER_COMMIT_BASELINE_ENTRY_TYPE) {
|
|
22650
22592
|
const data = entry.data;
|
|
22651
|
-
if (
|
|
22593
|
+
if (isRecord(data) && (data.head === null || typeof data.head === "string")) {
|
|
22652
22594
|
baseline = data.head;
|
|
22653
22595
|
}
|
|
22654
22596
|
} else if (entry.customType === WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE) {
|
|
@@ -22688,7 +22630,7 @@ function createWorkerSubmissionGate(options = {}) {
|
|
|
22688
22630
|
let reminded = false;
|
|
22689
22631
|
let prefixReminded = false;
|
|
22690
22632
|
let unfinishedReasonBounces = 0;
|
|
22691
|
-
let
|
|
22633
|
+
let record;
|
|
22692
22634
|
let sessionParent;
|
|
22693
22635
|
const explicitHome = typeof options.home === "string" && options.home.length > 0 ? options.home : void 0;
|
|
22694
22636
|
const head = (cwd) => {
|
|
@@ -22715,12 +22657,12 @@ function createWorkerSubmissionGate(options = {}) {
|
|
|
22715
22657
|
uninstallPackageWorkerHooks(cwd);
|
|
22716
22658
|
root = cwd;
|
|
22717
22659
|
sessionParent = parent.getSessionFile();
|
|
22718
|
-
|
|
22660
|
+
record = createRecordSession({
|
|
22719
22661
|
cwd,
|
|
22720
22662
|
kind: WORKER_SUBMISSION_GATE_RECORD_KIND,
|
|
22721
22663
|
parent
|
|
22722
22664
|
});
|
|
22723
|
-
const prior = readGateState(
|
|
22665
|
+
const prior = readGateState(record);
|
|
22724
22666
|
if (prior.baseline !== void 0) {
|
|
22725
22667
|
baseline = prior.baseline;
|
|
22726
22668
|
reminded = prior.reminded;
|
|
@@ -22730,7 +22672,7 @@ function createWorkerSubmissionGate(options = {}) {
|
|
|
22730
22672
|
baseline = head(cwd);
|
|
22731
22673
|
reminded = false;
|
|
22732
22674
|
prefixReminded = false;
|
|
22733
|
-
|
|
22675
|
+
record.appendCustomEntry(WORKER_COMMIT_BASELINE_ENTRY_TYPE, {
|
|
22734
22676
|
version: 1,
|
|
22735
22677
|
head: baseline
|
|
22736
22678
|
});
|
|
@@ -22752,7 +22694,7 @@ function createWorkerSubmissionGate(options = {}) {
|
|
|
22752
22694
|
const headMoved = now !== null && (baseline === null || now !== baseline);
|
|
22753
22695
|
if (!headMoved && !reminded) {
|
|
22754
22696
|
reminded = true;
|
|
22755
|
-
|
|
22697
|
+
record?.appendCustomEntry(WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE, { version: 1 });
|
|
22756
22698
|
gateSitian(root, {
|
|
22757
22699
|
type: WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE,
|
|
22758
22700
|
version: 1
|
|
@@ -22766,7 +22708,7 @@ function createWorkerSubmissionGate(options = {}) {
|
|
|
22766
22708
|
return;
|
|
22767
22709
|
}
|
|
22768
22710
|
prefixReminded = true;
|
|
22769
|
-
|
|
22711
|
+
record?.appendCustomEntry(WORKER_PREFIX_REMINDER_BOUNCE_ENTRY_TYPE, { version: 1 });
|
|
22770
22712
|
gateSitian(root, {
|
|
22771
22713
|
type: WORKER_PREFIX_REMINDER_BOUNCE_ENTRY_TYPE,
|
|
22772
22714
|
version: 1
|
|
@@ -22791,6 +22733,7 @@ function fixerBashSeatbeltDenyReason(matched) {
|
|
|
22791
22733
|
}
|
|
22792
22734
|
|
|
22793
22735
|
// src/worker-role.ts
|
|
22736
|
+
init_unknown_value();
|
|
22794
22737
|
var CODER_STATUS_DESCRIPTION = `planned | completed | refused | partially_completed | unfinished\u3002unfinished\uFF1A\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u81F4\u672C\u5C40\u672A\u5B8C\u6210\u3002${PARTIALLY_COMPLETED_DEFINITION}`;
|
|
22795
22738
|
var coderOutputObject = Type21.Object({
|
|
22796
22739
|
status: Type21.Unknown({ description: CODER_STATUS_DESCRIPTION }),
|
|
@@ -22830,11 +22773,8 @@ var FIXER_PHASES = ["plan", "apply"];
|
|
|
22830
22773
|
function isWorkerPhase(value) {
|
|
22831
22774
|
return typeof value === "string" && FIXER_PHASES.includes(value);
|
|
22832
22775
|
}
|
|
22833
|
-
function isRecord16(value) {
|
|
22834
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22835
|
-
}
|
|
22836
22776
|
function workerStatusOf(output) {
|
|
22837
|
-
return
|
|
22777
|
+
return isRecord(output) && typeof output.status === "string" ? output.status : void 0;
|
|
22838
22778
|
}
|
|
22839
22779
|
function deepFreeze2(value) {
|
|
22840
22780
|
if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
|
|
@@ -23122,6 +23062,7 @@ init_navigator_invocation_identity();
|
|
|
23122
23062
|
init_gatekeeper_role();
|
|
23123
23063
|
init_submission_errors();
|
|
23124
23064
|
init_review_submission();
|
|
23065
|
+
init_unknown_value();
|
|
23125
23066
|
init_doctor_contracts();
|
|
23126
23067
|
init_doctor_evidence();
|
|
23127
23068
|
init_judge_role();
|
|
@@ -23194,7 +23135,7 @@ function decodeReviewerAdmittedInputs(getFlag) {
|
|
|
23194
23135
|
parsed = JSON.parse(rawAuthorityRefs);
|
|
23195
23136
|
} catch (error) {
|
|
23196
23137
|
throw new Error(
|
|
23197
|
-
`Reviewer authority refs transport error: JSON decode failed: ${
|
|
23138
|
+
`Reviewer authority refs transport error: JSON decode failed: ${errorText(error)}`
|
|
23198
23139
|
);
|
|
23199
23140
|
}
|
|
23200
23141
|
if (!Array.isArray(parsed) || parsed.some((ref) => typeof ref !== "string")) {
|
|
@@ -23232,23 +23173,23 @@ function assembleReviewerParentSystemPrompt(input) {
|
|
|
23232
23173
|
].join("\n");
|
|
23233
23174
|
}
|
|
23234
23175
|
function activationStage(role, activate) {
|
|
23235
|
-
const
|
|
23236
|
-
if (
|
|
23176
|
+
const record = packagedRoleMetadata(role);
|
|
23177
|
+
if (record === void 0) {
|
|
23237
23178
|
throw new Error(`Unsupported workflow role: ${String(role)}`);
|
|
23238
23179
|
}
|
|
23239
23180
|
return {
|
|
23240
|
-
id:
|
|
23181
|
+
id: record.activationStage,
|
|
23241
23182
|
run: () => activate[role]()
|
|
23242
23183
|
};
|
|
23243
23184
|
}
|
|
23244
|
-
function validateActivationTraceRecord(
|
|
23245
|
-
if (!Value4.Check(activationTraceRecordSchema,
|
|
23185
|
+
function validateActivationTraceRecord(record) {
|
|
23186
|
+
if (!Value4.Check(activationTraceRecordSchema, record)) {
|
|
23246
23187
|
throw new TypeError("Activation trace record does not match its closed contract");
|
|
23247
23188
|
}
|
|
23248
|
-
return
|
|
23189
|
+
return record;
|
|
23249
23190
|
}
|
|
23250
|
-
async function emitActivationTrace(writeTrace,
|
|
23251
|
-
await writeTrace(validateActivationTraceRecord(
|
|
23191
|
+
async function emitActivationTrace(writeTrace, record) {
|
|
23192
|
+
await writeTrace(validateActivationTraceRecord(record));
|
|
23252
23193
|
}
|
|
23253
23194
|
async function executeActivationStage(role, stage, infrastructure) {
|
|
23254
23195
|
try {
|
|
@@ -23268,8 +23209,8 @@ async function executeActivationStage(role, stage, infrastructure) {
|
|
|
23268
23209
|
throw activationError;
|
|
23269
23210
|
}
|
|
23270
23211
|
}
|
|
23271
|
-
function writeActivationTraceRecord(
|
|
23272
|
-
writeStderrJsonlRecord(
|
|
23212
|
+
function writeActivationTraceRecord(record, write = writeSync2) {
|
|
23213
|
+
writeStderrJsonlRecord(record, write);
|
|
23273
23214
|
}
|
|
23274
23215
|
var ActivationBarrierError = class extends Error {
|
|
23275
23216
|
code = "AK_ACTIVATION_NOT_ADMITTED";
|
|
@@ -23327,7 +23268,7 @@ function publicNavigatorSettlement(role, phase, event) {
|
|
|
23327
23268
|
if (classification.kind === "infrastructure") {
|
|
23328
23269
|
return { kind: "role_infrastructure_failure", role, phase };
|
|
23329
23270
|
}
|
|
23330
|
-
const details =
|
|
23271
|
+
const details = isRecord(event.details) ? event.details : {};
|
|
23331
23272
|
const status = typeof details.status === "string" ? details.status : receiptStatusFromRegistry(details);
|
|
23332
23273
|
if (status !== void 0 && status === "escalate") {
|
|
23333
23274
|
return { kind: "human_decision", role, phase, status };
|
|
@@ -23465,7 +23406,7 @@ function createNavigatorRoleRuntime(roleHost, dependencies) {
|
|
|
23465
23406
|
dependencies.recordRoutePlaybookReadFailure?.(void 0);
|
|
23466
23407
|
if (content.trim() !== "") parts.push(content);
|
|
23467
23408
|
} catch (error) {
|
|
23468
|
-
const message =
|
|
23409
|
+
const message = errorText(error);
|
|
23469
23410
|
if (message.trim() !== "") {
|
|
23470
23411
|
dependencies.recordRoutePlaybookReadFailure?.(message);
|
|
23471
23412
|
parts.push(message);
|
|
@@ -23558,7 +23499,7 @@ function createDiaristRoleRuntime(roleHost, dependencies) {
|
|
|
23558
23499
|
tool: DIARIST_TOOL_SPEC,
|
|
23559
23500
|
soulTag: "diarist",
|
|
23560
23501
|
beforeAccept: async ({ parameters, ctx }) => {
|
|
23561
|
-
const submitted =
|
|
23502
|
+
const submitted = isRecord(parameters) ? parameters : void 0;
|
|
23562
23503
|
const status = submitted?.status;
|
|
23563
23504
|
if (status !== "completed") return parameters;
|
|
23564
23505
|
const assertion = readDiaristTicketAssertion(submitted);
|
|
@@ -23724,7 +23665,7 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
23724
23665
|
const disposeNavigatorAttendanceNonBlocking = (attendance) => {
|
|
23725
23666
|
if (attendance === void 0) return;
|
|
23726
23667
|
const recordDisposeFailure = (error) => {
|
|
23727
|
-
const diagnostic =
|
|
23668
|
+
const diagnostic = errorText(error);
|
|
23728
23669
|
try {
|
|
23729
23670
|
sitianReport({
|
|
23730
23671
|
level: "event",
|
|
@@ -23738,7 +23679,7 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
23738
23679
|
try {
|
|
23739
23680
|
envelopeHost.appendEntry?.("ak-navigator-dispose-failure", {
|
|
23740
23681
|
diagnostic,
|
|
23741
|
-
recordFailure:
|
|
23682
|
+
recordFailure: errorText(recordError)
|
|
23742
23683
|
});
|
|
23743
23684
|
} catch {
|
|
23744
23685
|
}
|
|
@@ -24225,9 +24166,7 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
24225
24166
|
try {
|
|
24226
24167
|
await recordTypedProviderHttpStatus(runDir, { httpStatus: status, provider });
|
|
24227
24168
|
} catch (error) {
|
|
24228
|
-
if (status >= 200 && status < 300 && error
|
|
24229
|
-
return;
|
|
24230
|
-
}
|
|
24169
|
+
if (status >= 200 && status < 300 && isEnoent(error)) return;
|
|
24231
24170
|
failInfrastructure(error, ctx);
|
|
24232
24171
|
}
|
|
24233
24172
|
};
|
|
@@ -24411,6 +24350,7 @@ init_role_activation_flags();
|
|
|
24411
24350
|
init_submission_correctable_error();
|
|
24412
24351
|
init_navigator_invocation_identity();
|
|
24413
24352
|
init_serialize_thrown_value();
|
|
24353
|
+
init_unknown_value();
|
|
24414
24354
|
async function listen(server, path) {
|
|
24415
24355
|
await new Promise((resolve22, reject) => {
|
|
24416
24356
|
server.once("error", reject);
|
|
@@ -24485,7 +24425,7 @@ async function prepareRoleEnvelope(options) {
|
|
|
24485
24425
|
try {
|
|
24486
24426
|
await appendFile3(sessionFile, line2, "utf8");
|
|
24487
24427
|
} catch (error) {
|
|
24488
|
-
const diagnostic =
|
|
24428
|
+
const diagnostic = errorText(error);
|
|
24489
24429
|
armDurableWriteFailure?.(customType, diagnostic);
|
|
24490
24430
|
}
|
|
24491
24431
|
});
|
|
@@ -24591,10 +24531,10 @@ async function prepareRoleEnvelope(options) {
|
|
|
24591
24531
|
const server = createServer((socket) => serveSocket(socket));
|
|
24592
24532
|
function rememberProjectedRejection(details, toolCallId, content) {
|
|
24593
24533
|
if (typeof details !== "object" || details === null) return;
|
|
24594
|
-
const
|
|
24595
|
-
if (
|
|
24596
|
-
if (
|
|
24597
|
-
const code = typeof
|
|
24534
|
+
const record = details;
|
|
24535
|
+
if (record.cause === "infrastructure") return;
|
|
24536
|
+
if (record.kind === "role_infrastructure_failure") return;
|
|
24537
|
+
const code = typeof record.code === "string" && record.code.length > 0 ? record.code : record.status === "continue" || record.status === "escalate" || record.status === "no_receipt" ? record.status : void 0;
|
|
24598
24538
|
if (code === void 0) return;
|
|
24599
24539
|
rejection = {
|
|
24600
24540
|
code,
|
|
@@ -24608,18 +24548,18 @@ async function prepareRoleEnvelope(options) {
|
|
|
24608
24548
|
}
|
|
24609
24549
|
function rememberInfrastructureFailure(details, content) {
|
|
24610
24550
|
if (infrastructureRoundFailure !== void 0) return;
|
|
24611
|
-
const
|
|
24612
|
-
const isInfra =
|
|
24551
|
+
const record = isRecord(details) ? details : void 0;
|
|
24552
|
+
const isInfra = record !== void 0 && (record.cause === "infrastructure" || record.kind === "role_infrastructure_failure");
|
|
24613
24553
|
if (!isInfra) return;
|
|
24614
|
-
const diagnostic = textDiagnostic(content) ?? (typeof
|
|
24554
|
+
const diagnostic = textDiagnostic(content) ?? (typeof record.code === "string" && record.code.length > 0 ? record.code : void 0) ?? "role infrastructure failure";
|
|
24615
24555
|
infrastructureRoundFailure = {
|
|
24616
24556
|
cause: "output",
|
|
24617
24557
|
identity: {
|
|
24618
24558
|
name: "InfrastructureFailure",
|
|
24619
|
-
code: typeof
|
|
24559
|
+
code: typeof record.code === "string" && record.code.length > 0 ? record.code : "role-infrastructure-failure"
|
|
24620
24560
|
},
|
|
24621
24561
|
diagnostic,
|
|
24622
|
-
details:
|
|
24562
|
+
details: record
|
|
24623
24563
|
};
|
|
24624
24564
|
hostAbort.abort();
|
|
24625
24565
|
}
|
|
@@ -24635,7 +24575,7 @@ async function prepareRoleEnvelope(options) {
|
|
|
24635
24575
|
);
|
|
24636
24576
|
};
|
|
24637
24577
|
function declareRoundInfrastructureFailure(error) {
|
|
24638
|
-
const diagnostic =
|
|
24578
|
+
const diagnostic = errorText(error);
|
|
24639
24579
|
const content = [{ type: "text", text: diagnostic }];
|
|
24640
24580
|
const errorCode = typeof error?.code === "string" ? error.code : "ak-tool-execution-failed";
|
|
24641
24581
|
const details = {
|
|
@@ -24902,8 +24842,8 @@ async function prepareRoleEnvelope(options) {
|
|
|
24902
24842
|
let prompt = request.continuation.prompt;
|
|
24903
24843
|
for (const value of inputResults) {
|
|
24904
24844
|
if (typeof value !== "object" || value === null) continue;
|
|
24905
|
-
const
|
|
24906
|
-
if (
|
|
24845
|
+
const record = value;
|
|
24846
|
+
if (record.action === "transform" && typeof record.text === "string") prompt = record.text;
|
|
24907
24847
|
}
|
|
24908
24848
|
if (typeof prompt === "string" && prompt.trim() !== "") {
|
|
24909
24849
|
sessionEntries.push({
|
|
@@ -24973,6 +24913,7 @@ init_doctor_evidence();
|
|
|
24973
24913
|
|
|
24974
24914
|
// src/navigator-work-context.ts
|
|
24975
24915
|
init_doctor_evidence();
|
|
24916
|
+
init_unknown_value();
|
|
24976
24917
|
init_host_contracts();
|
|
24977
24918
|
import { readFile as readFile23 } from "node:fs/promises";
|
|
24978
24919
|
import { resolve as resolve20 } from "node:path";
|
|
@@ -25051,7 +24992,7 @@ async function loadNavigatorWorkContext(options) {
|
|
|
25051
24992
|
break;
|
|
25052
24993
|
}
|
|
25053
24994
|
} catch (error) {
|
|
25054
|
-
if (!(error
|
|
24995
|
+
if (!isEnoent(error)) throw error;
|
|
25055
24996
|
}
|
|
25056
24997
|
}
|
|
25057
24998
|
const authority = resolveNavigatorAuthorityMaterial(input, authorityMaterial);
|
|
@@ -25072,8 +25013,8 @@ init_auditor_soul();
|
|
|
25072
25013
|
init_packaged_role_registry();
|
|
25073
25014
|
init_session_opening_materials();
|
|
25074
25015
|
function usesSubjectSoul(role) {
|
|
25075
|
-
const
|
|
25076
|
-
return
|
|
25016
|
+
const record = packagedRoleMetadata(role);
|
|
25017
|
+
return record !== void 0 && "soulSource" in record && record.soulSource === "subject";
|
|
25077
25018
|
}
|
|
25078
25019
|
function loadPackagedRoleReferenceMaterials(role) {
|
|
25079
25020
|
return usesSubjectSoul(role) ? loadAuditorReferenceMaterialsFromSubjectInput() : loadMainRoleReferenceMaterials(role);
|
|
@@ -25138,6 +25079,7 @@ import { spawn as spawn3 } from "node:child_process";
|
|
|
25138
25079
|
import { createInterface } from "node:readline";
|
|
25139
25080
|
|
|
25140
25081
|
// src/external-host-turn-loop.ts
|
|
25082
|
+
init_unknown_value();
|
|
25141
25083
|
var EXTERNAL_ROLE_TURN_ROUND_LIMIT = 8;
|
|
25142
25084
|
function mergeRoleTurnAbortSignals(prepared, request) {
|
|
25143
25085
|
if (request === void 0) return prepared;
|
|
@@ -25188,7 +25130,7 @@ function externalHostFailure(cause, name, code, details, diagnostic) {
|
|
|
25188
25130
|
});
|
|
25189
25131
|
}
|
|
25190
25132
|
function withExternalHostCleanupFailure(outcome, cleanupError, name) {
|
|
25191
|
-
const message =
|
|
25133
|
+
const message = errorText(cleanupError);
|
|
25192
25134
|
if (outcome.knownFailure === void 0) {
|
|
25193
25135
|
return externalHostFailure("session", name, "dispose-failed", { cleanupError: message }, message);
|
|
25194
25136
|
}
|
|
@@ -25277,16 +25219,17 @@ async function resolveBoundHostSessionId(request, identity) {
|
|
|
25277
25219
|
}
|
|
25278
25220
|
|
|
25279
25221
|
// src/acp-host/role-turn-host.ts
|
|
25222
|
+
init_unknown_value();
|
|
25280
25223
|
function acpAgentTextChunk(params) {
|
|
25281
25224
|
let kind;
|
|
25282
25225
|
let content;
|
|
25283
25226
|
let textFallback;
|
|
25284
25227
|
const nested = params.update;
|
|
25285
|
-
if (
|
|
25286
|
-
const
|
|
25287
|
-
kind =
|
|
25288
|
-
content =
|
|
25289
|
-
textFallback =
|
|
25228
|
+
if (isRecord(nested)) {
|
|
25229
|
+
const record = nested;
|
|
25230
|
+
kind = record.sessionUpdate;
|
|
25231
|
+
content = record.content;
|
|
25232
|
+
textFallback = record.text;
|
|
25290
25233
|
} else {
|
|
25291
25234
|
kind = params.sessionUpdate ?? nested;
|
|
25292
25235
|
content = params.content;
|
|
@@ -25294,17 +25237,17 @@ function acpAgentTextChunk(params) {
|
|
|
25294
25237
|
}
|
|
25295
25238
|
if (kind !== "agent_message_chunk" && kind !== "agent_message") return void 0;
|
|
25296
25239
|
if (typeof content === "string" && content.length > 0) return content;
|
|
25297
|
-
if (
|
|
25298
|
-
const
|
|
25299
|
-
if (typeof
|
|
25240
|
+
if (isRecord(content)) {
|
|
25241
|
+
const record = content;
|
|
25242
|
+
if (typeof record.text === "string" && record.text.length > 0) return record.text;
|
|
25300
25243
|
}
|
|
25301
25244
|
if (Array.isArray(content)) {
|
|
25302
25245
|
const parts = [];
|
|
25303
25246
|
for (const part of content) {
|
|
25304
25247
|
if (typeof part === "string" && part.length > 0) parts.push(part);
|
|
25305
25248
|
else if (typeof part === "object" && part !== null) {
|
|
25306
|
-
const
|
|
25307
|
-
if (typeof
|
|
25249
|
+
const record = part;
|
|
25250
|
+
if (typeof record.text === "string" && record.text.length > 0) parts.push(record.text);
|
|
25308
25251
|
}
|
|
25309
25252
|
}
|
|
25310
25253
|
if (parts.length > 0) return parts.join("");
|