@akagilnc/pi-workflow-roles 0.1.4021 → 0.1.4035
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 +208 -107
- package/dist/headless-host/production-host.js +208 -107
- package/dist/navigator-attendance.js +2 -0
- package/dist/navigator-public-session.js +18 -34
- package/dist/navigator-session-contracts.js +19 -0
- package/dist/pi/known-failure.js +3 -4
- package/dist/public-cli/auto-resume.js +20 -7
- package/dist/public-cli/diarist-run.js +9 -23
- package/dist/public-cli/instruction-seat-run.js +3 -1
- package/dist/public-cli/judge-run.js +3 -1
- package/dist/public-cli/main.js +203 -112
- package/dist/public-cli/settlement.js +64 -61
- package/dist/public-cli/terminal.js +1 -11
- package/dist/submission-ledger.js +109 -11
- package/package.json +1 -1
- package/src/host-contracts.ts +8 -4
- package/src/navigator-attendance.ts +2 -0
- package/src/navigator-public-session.ts +19 -55
- package/src/navigator-session-contracts.ts +39 -0
- package/src/pi/known-failure.ts +3 -4
- package/src/public-cli/auto-resume.ts +57 -20
- package/src/public-cli/cli.ts +2 -2
- package/src/public-cli/collector-run.ts +3 -1
- package/src/public-cli/countersign-run.ts +34 -27
- package/src/public-cli/diarist-run.ts +10 -27
- package/src/public-cli/instruction-seat-run.ts +3 -1
- package/src/public-cli/judge-run.ts +3 -1
- package/src/public-cli/reviewer-run.ts +3 -1
- package/src/public-cli/settlement.ts +83 -84
- package/src/public-cli/terminal.ts +7 -16
- package/src/submission-ledger.ts +147 -13
|
@@ -10604,28 +10604,95 @@ function recordedRole(payload) {
|
|
|
10604
10604
|
if (isTerminalRoleName(payload.projection?.role)) return payload.projection.role;
|
|
10605
10605
|
return void 0;
|
|
10606
10606
|
}
|
|
10607
|
+
function rowRank(kind) {
|
|
10608
|
+
switch (kind) {
|
|
10609
|
+
case "accepted":
|
|
10610
|
+
return 4;
|
|
10611
|
+
case "audit-escalation":
|
|
10612
|
+
return 3;
|
|
10613
|
+
case "correctable-rejection":
|
|
10614
|
+
case "infrastructure":
|
|
10615
|
+
return 2;
|
|
10616
|
+
case "candidate":
|
|
10617
|
+
return 1;
|
|
10618
|
+
}
|
|
10619
|
+
}
|
|
10620
|
+
function submissionCallKey(attemptId, toolCallId) {
|
|
10621
|
+
return `${attemptId ?? ""}\0${toolCallId}`;
|
|
10622
|
+
}
|
|
10623
|
+
function rowFromPayload(kind, payload, accepted, roleFallback) {
|
|
10624
|
+
const role = recordedRole(payload) ?? roleFallback;
|
|
10625
|
+
return {
|
|
10626
|
+
...role === void 0 ? {} : { role },
|
|
10627
|
+
kind,
|
|
10628
|
+
accepted,
|
|
10629
|
+
...typeof payload.toolCallId === "string" && payload.toolCallId.length > 0 ? { toolCallId: payload.toolCallId } : {}
|
|
10630
|
+
};
|
|
10631
|
+
}
|
|
10607
10632
|
async function readRecordedSubmissionRows(cwd, runId, homeOrScope) {
|
|
10608
10633
|
const scope = resolveReadScope(homeOrScope);
|
|
10609
10634
|
const { owned } = await readOwnedSubmissionRecords(cwd, runId, scope.home);
|
|
10610
10635
|
const scoped = recordsForAttempt(owned, scope.attemptId);
|
|
10611
10636
|
const out = [];
|
|
10637
|
+
const indexByCall = /* @__PURE__ */ new Map();
|
|
10638
|
+
const roleByCall = /* @__PURE__ */ new Map();
|
|
10639
|
+
for (const record4 of scoped) {
|
|
10640
|
+
const payload = record4.payload;
|
|
10641
|
+
if (typeof payload?.toolCallId !== "string" || payload.toolCallId.length === 0) continue;
|
|
10642
|
+
const role = recordedRole(payload);
|
|
10643
|
+
if (role !== void 0) {
|
|
10644
|
+
roleByCall.set(submissionCallKey(recordAttemptId(record4), payload.toolCallId), role);
|
|
10645
|
+
}
|
|
10646
|
+
}
|
|
10647
|
+
const take = (row, callKey) => {
|
|
10648
|
+
const toolCallId = row.toolCallId;
|
|
10649
|
+
if (toolCallId !== void 0 && callKey !== void 0) {
|
|
10650
|
+
const existingIndex = indexByCall.get(callKey);
|
|
10651
|
+
if (existingIndex !== void 0) {
|
|
10652
|
+
const existing = out[existingIndex];
|
|
10653
|
+
if (rowRank(row.kind) >= rowRank(existing.kind)) {
|
|
10654
|
+
out[existingIndex] = {
|
|
10655
|
+
...row,
|
|
10656
|
+
toolCallId,
|
|
10657
|
+
// Keep a previously recovered role when the upgraded row still omits it.
|
|
10658
|
+
...row.role === void 0 && existing.role !== void 0 ? { role: existing.role } : {}
|
|
10659
|
+
};
|
|
10660
|
+
} else if (existing.role === void 0 && row.role !== void 0) {
|
|
10661
|
+
out[existingIndex] = { ...existing, role: row.role };
|
|
10662
|
+
}
|
|
10663
|
+
return;
|
|
10664
|
+
}
|
|
10665
|
+
indexByCall.set(callKey, out.length);
|
|
10666
|
+
}
|
|
10667
|
+
out.push(row);
|
|
10668
|
+
};
|
|
10612
10669
|
for (const record4 of scoped) {
|
|
10670
|
+
const attemptId = recordAttemptId(record4);
|
|
10671
|
+
if (record4.kind === "candidate") {
|
|
10672
|
+
const payload2 = record4.payload;
|
|
10673
|
+
if (payload2?.type !== "candidate" || payload2.params === void 0) continue;
|
|
10674
|
+
const callKey2 = typeof payload2.toolCallId === "string" ? submissionCallKey(attemptId, payload2.toolCallId) : void 0;
|
|
10675
|
+
const fallback2 = callKey2 !== void 0 ? roleByCall.get(callKey2) : void 0;
|
|
10676
|
+
take(rowFromPayload("candidate", payload2, payload2.params, fallback2), callKey2);
|
|
10677
|
+
continue;
|
|
10678
|
+
}
|
|
10613
10679
|
if (record4.kind === "sealed") {
|
|
10614
10680
|
const payload2 = record4.payload;
|
|
10615
10681
|
if (payload2?.type !== "sealed" || payload2.accepted === void 0) continue;
|
|
10616
|
-
const
|
|
10617
|
-
|
|
10618
|
-
|
|
10682
|
+
const callKey2 = typeof payload2.toolCallId === "string" ? submissionCallKey(attemptId, payload2.toolCallId) : void 0;
|
|
10683
|
+
const fallback2 = callKey2 !== void 0 ? roleByCall.get(callKey2) : void 0;
|
|
10684
|
+
take(rowFromPayload("accepted", payload2, payload2.accepted, fallback2), callKey2);
|
|
10619
10685
|
continue;
|
|
10620
10686
|
}
|
|
10621
10687
|
if (record4.kind !== "outcome") continue;
|
|
10622
10688
|
const payload = record4.payload;
|
|
10623
|
-
if (payload?.type !== "outcome" || payload.
|
|
10624
|
-
|
|
10625
|
-
|
|
10626
|
-
|
|
10627
|
-
|
|
10628
|
-
|
|
10689
|
+
if (payload?.type !== "outcome" || payload.accepted === void 0) continue;
|
|
10690
|
+
const outcome = payload.outcome;
|
|
10691
|
+
const kind = outcome === "audit-escalation" ? "audit-escalation" : outcome === "correctable-rejection" ? "correctable-rejection" : outcome === "infrastructure" ? "infrastructure" : void 0;
|
|
10692
|
+
if (kind === void 0) continue;
|
|
10693
|
+
const callKey = typeof payload.toolCallId === "string" ? submissionCallKey(attemptId, payload.toolCallId) : void 0;
|
|
10694
|
+
const fallback = callKey !== void 0 ? roleByCall.get(callKey) : void 0;
|
|
10695
|
+
take(rowFromPayload(kind, payload, payload.accepted, fallback), callKey);
|
|
10629
10696
|
}
|
|
10630
10697
|
return out;
|
|
10631
10698
|
}
|
|
@@ -10704,6 +10771,7 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
|
|
|
10704
10771
|
toolCallId,
|
|
10705
10772
|
toolName: tool.name,
|
|
10706
10773
|
sequence: ++state.sequence,
|
|
10774
|
+
role,
|
|
10707
10775
|
params
|
|
10708
10776
|
});
|
|
10709
10777
|
let result;
|
|
@@ -10729,6 +10797,7 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
|
|
|
10729
10797
|
outcome: "correctable-rejection",
|
|
10730
10798
|
code: "typed-bounce",
|
|
10731
10799
|
diagnostic: error instanceof Error ? error.message : String(error),
|
|
10800
|
+
role,
|
|
10732
10801
|
accepted: params
|
|
10733
10802
|
});
|
|
10734
10803
|
throw error;
|
|
@@ -10739,6 +10808,7 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
|
|
|
10739
10808
|
toolCallId,
|
|
10740
10809
|
outcome: "infrastructure",
|
|
10741
10810
|
diagnostic: error instanceof Error ? error.message : String(error),
|
|
10811
|
+
role,
|
|
10742
10812
|
accepted: params
|
|
10743
10813
|
});
|
|
10744
10814
|
throw error;
|
|
@@ -10966,7 +11036,7 @@ function knownFailureFromProviderStop(input) {
|
|
|
10966
11036
|
const diagnostic = nonEmptyString(input.errorMessage);
|
|
10967
11037
|
const details = sessionStopDetails(input);
|
|
10968
11038
|
return {
|
|
10969
|
-
|
|
11039
|
+
...hasUpstreamErrorTestimony(input) ? { cause: "provider" } : {},
|
|
10970
11040
|
...diagnostic === void 0 ? {} : { diagnostic },
|
|
10971
11041
|
...Object.keys(details).length === 0 ? {} : { details }
|
|
10972
11042
|
};
|
|
@@ -12746,15 +12816,6 @@ function isLawfulTypedTerminalOutcome(outcome) {
|
|
|
12746
12816
|
function exitCodeForTerminalOutcome(outcome) {
|
|
12747
12817
|
return isLawfulTypedTerminalOutcome(outcome) ? 0 : 1;
|
|
12748
12818
|
}
|
|
12749
|
-
function lastRolePayloadRecord(payloads) {
|
|
12750
|
-
for (let index = payloads.length - 1; index >= 0; index -= 1) {
|
|
12751
|
-
const payload = payloads[index];
|
|
12752
|
-
if (typeof payload === "object" && payload !== null && !Array.isArray(payload)) {
|
|
12753
|
-
return payload;
|
|
12754
|
-
}
|
|
12755
|
-
}
|
|
12756
|
-
return void 0;
|
|
12757
|
-
}
|
|
12758
12819
|
function recommendationNavigatorFact(input) {
|
|
12759
12820
|
const command = typeof input.modelCommand === "string" && input.modelCommand.trim() !== "" ? input.modelCommand : isPublicCallableRole2(input.next.role) ? renderPublicAkRoleCommand(input.next) : void 0;
|
|
12760
12821
|
return {
|
|
@@ -12769,7 +12830,7 @@ function recommendationNavigatorFact(input) {
|
|
|
12769
12830
|
function formatTerminalResult(result) {
|
|
12770
12831
|
const lines = [];
|
|
12771
12832
|
lines.push("role outcome status");
|
|
12772
|
-
const outcomeStatus = result.roleOutcome.kind === "failure" ? result.roleOutcome.cause : result.roleOutcome.kind === "accepted" ? "accepted" : result.roleOutcome.status;
|
|
12833
|
+
const outcomeStatus = result.roleOutcome.kind === "failure" ? result.roleOutcome.cause ?? "" : result.roleOutcome.kind === "accepted" ? "accepted" : result.roleOutcome.status;
|
|
12773
12834
|
lines.push(
|
|
12774
12835
|
`${result.roleOutcome.role} ${result.roleOutcome.kind} ${encodeTerminalField(outcomeStatus)}`
|
|
12775
12836
|
);
|
|
@@ -12855,9 +12916,12 @@ function ledgerReadScope(admitted, scope) {
|
|
|
12855
12916
|
}
|
|
12856
12917
|
function roleOutcomeFromRows(role, rows) {
|
|
12857
12918
|
const mine = rows.filter((row) => row.role === role);
|
|
12858
|
-
|
|
12919
|
+
const terminal = mine.filter(
|
|
12920
|
+
(row) => row.kind === "accepted" || row.kind === "audit-escalation"
|
|
12921
|
+
);
|
|
12922
|
+
if (terminal.length === 0) return void 0;
|
|
12859
12923
|
const payloads = mine.map((row) => row.accepted);
|
|
12860
|
-
if (
|
|
12924
|
+
if (terminal.some((row) => row.kind === "audit-escalation")) {
|
|
12861
12925
|
return { kind: "audit_escalation", role, status: "audit_escalation", payloads };
|
|
12862
12926
|
}
|
|
12863
12927
|
return { kind: "accepted", role, payloads };
|
|
@@ -12889,7 +12953,7 @@ async function recordedSubmissionPayloads(admitted, scope) {
|
|
|
12889
12953
|
function withSubmissions(terminal, submissions) {
|
|
12890
12954
|
if (submissions.length === 0) return terminal;
|
|
12891
12955
|
const roleOutcome = terminal.roleOutcome;
|
|
12892
|
-
const withPayloads = roleOutcome.kind === "accepted" || roleOutcome.kind === "audit_escalation"
|
|
12956
|
+
const withPayloads = roleOutcome.kind === "accepted" || roleOutcome.kind === "audit_escalation" || roleOutcome.kind === "failure" ? { ...roleOutcome, payloads: submissions } : roleOutcome;
|
|
12893
12957
|
return { ...terminal, roleOutcome: withPayloads, submissions };
|
|
12894
12958
|
}
|
|
12895
12959
|
async function attachRecordedSubmissions(admitted, terminal, scope) {
|
|
@@ -12985,7 +13049,7 @@ function thrownIdentity(error) {
|
|
|
12985
13049
|
function isTypedActivationError(error) {
|
|
12986
13050
|
if (!(error instanceof Error)) return false;
|
|
12987
13051
|
const cause = error.knownCause;
|
|
12988
|
-
return cause === "provider" || cause === "activation" || cause === "session" || cause === "output" || cause === "timeout"
|
|
13052
|
+
return cause === "provider" || cause === "activation" || cause === "session" || cause === "output" || cause === "timeout";
|
|
12989
13053
|
}
|
|
12990
13054
|
function flattenThrownFailureLeaves(error) {
|
|
12991
13055
|
if (!(error instanceof AggregateError)) {
|
|
@@ -13005,7 +13069,7 @@ function projectThrownFailureLeaf(error) {
|
|
|
13005
13069
|
}
|
|
13006
13070
|
return {
|
|
13007
13071
|
cause: error.knownCause,
|
|
13008
|
-
diagnostic: error.message || error.name || "
|
|
13072
|
+
diagnostic: error.message || error.name || "exception",
|
|
13009
13073
|
identity,
|
|
13010
13074
|
...error.details === void 0 ? {} : { details: error.details }
|
|
13011
13075
|
};
|
|
@@ -13013,13 +13077,11 @@ function projectThrownFailureLeaf(error) {
|
|
|
13013
13077
|
if (error instanceof Error) {
|
|
13014
13078
|
const identity = thrownIdentity(error);
|
|
13015
13079
|
return {
|
|
13016
|
-
|
|
13017
|
-
diagnostic: error.message || error.name || "unrecognized exception",
|
|
13080
|
+
diagnostic: error.message || error.name || "exception",
|
|
13018
13081
|
identity
|
|
13019
13082
|
};
|
|
13020
13083
|
}
|
|
13021
13084
|
return {
|
|
13022
|
-
cause: "unrecognized",
|
|
13023
13085
|
diagnostic: String(error)
|
|
13024
13086
|
};
|
|
13025
13087
|
}
|
|
@@ -13041,7 +13103,7 @@ function classifyThrownFailure(error) {
|
|
|
13041
13103
|
...leaves.slice(1).map((leaf) => {
|
|
13042
13104
|
const secondary = projectThrownFailureLeaf(leaf);
|
|
13043
13105
|
return {
|
|
13044
|
-
cause: secondary.cause,
|
|
13106
|
+
...secondary.cause === void 0 ? {} : { cause: secondary.cause },
|
|
13045
13107
|
diagnostic: secondary.diagnostic,
|
|
13046
13108
|
...secondary.identity === void 0 ? {} : { identity: secondary.identity },
|
|
13047
13109
|
...secondary.details === void 0 ? {} : { details: secondary.details }
|
|
@@ -13049,7 +13111,7 @@ function classifyThrownFailure(error) {
|
|
|
13049
13111
|
})
|
|
13050
13112
|
];
|
|
13051
13113
|
return {
|
|
13052
|
-
cause: primary.cause,
|
|
13114
|
+
...primary.cause === void 0 ? {} : { cause: primary.cause },
|
|
13053
13115
|
diagnostic: primary.diagnostic,
|
|
13054
13116
|
...primary.identity === void 0 ? {} : { identity: primary.identity },
|
|
13055
13117
|
details: {
|
|
@@ -13090,6 +13152,24 @@ function classifyPostAdmissionFailure(input) {
|
|
|
13090
13152
|
...input.knownIdentity === void 0 ? {} : { identity: input.knownIdentity }
|
|
13091
13153
|
};
|
|
13092
13154
|
}
|
|
13155
|
+
if (input.knownDiagnostic !== void 0 && input.knownDiagnostic.trim() !== "" || input.knownIdentity !== void 0) {
|
|
13156
|
+
const diagnostic = input.knownDiagnostic !== void 0 && input.knownDiagnostic.trim() !== "" ? input.knownDiagnostic : conciseChildDiagnostic(input.stderr, "role run failed");
|
|
13157
|
+
const { timedOut: _knownTimedOut, ...knownDetails } = input.knownDetails ?? {};
|
|
13158
|
+
const remoteCode = knownDetails.code;
|
|
13159
|
+
return withKnownDetails(
|
|
13160
|
+
{
|
|
13161
|
+
diagnostic,
|
|
13162
|
+
details: {
|
|
13163
|
+
...knownDetails,
|
|
13164
|
+
...remoteCode === void 0 ? {} : { code: remoteCode },
|
|
13165
|
+
exitCode: input.code,
|
|
13166
|
+
...input.timedOut ? { timedOut: true } : {}
|
|
13167
|
+
},
|
|
13168
|
+
...input.knownIdentity === void 0 ? {} : { identity: input.knownIdentity }
|
|
13169
|
+
},
|
|
13170
|
+
void 0
|
|
13171
|
+
);
|
|
13172
|
+
}
|
|
13093
13173
|
if (input.timedOut) {
|
|
13094
13174
|
return withKnownDetails(
|
|
13095
13175
|
{
|
|
@@ -13143,7 +13223,7 @@ function classifyPostAdmissionFailure(input) {
|
|
|
13143
13223
|
function explicitInternalKnownFailureClassificationInput(failure2) {
|
|
13144
13224
|
if (failure2 === void 0) return {};
|
|
13145
13225
|
return {
|
|
13146
|
-
knownCause: failure2.cause,
|
|
13226
|
+
...failure2.cause === void 0 ? {} : { knownCause: failure2.cause },
|
|
13147
13227
|
...failure2.identity === void 0 ? {} : { knownIdentity: failure2.identity },
|
|
13148
13228
|
...failure2.diagnostic === void 0 ? {} : { knownDiagnostic: failure2.diagnostic },
|
|
13149
13229
|
...failure2.details === void 0 ? {} : { knownDetails: failure2.details }
|
|
@@ -13395,10 +13475,12 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
13395
13475
|
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord10(entry.data)) continue;
|
|
13396
13476
|
const parent = isRecord10(entry.data.parent) ? entry.data.parent : void 0;
|
|
13397
13477
|
const failure2 = isRecord10(entry.data.failure) ? entry.data.failure : void 0;
|
|
13398
|
-
if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId
|
|
13478
|
+
if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId) continue;
|
|
13479
|
+
if (failure2 === void 0) continue;
|
|
13399
13480
|
const identity = isRecord10(failure2.identity) ? failure2.identity : void 0;
|
|
13481
|
+
const typedCause = failure2.cause === "provider" || failure2.cause === "activation" || failure2.cause === "session" || failure2.cause === "output" || failure2.cause === "timeout" ? failure2.cause : void 0;
|
|
13400
13482
|
return {
|
|
13401
|
-
|
|
13483
|
+
...typedCause === void 0 ? {} : { cause: typedCause },
|
|
13402
13484
|
...identity === void 0 ? {} : { identity: {
|
|
13403
13485
|
...typeof identity.name === "string" ? { name: identity.name } : {},
|
|
13404
13486
|
...typeof identity.code === "string" || typeof identity.code === "number" ? { code: identity.code } : {}
|
|
@@ -14050,8 +14132,6 @@ async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, option
|
|
|
14050
14132
|
role: "doctor",
|
|
14051
14133
|
runId: admitted.runId,
|
|
14052
14134
|
outcome: roleOutcome,
|
|
14053
|
-
...options.doctorOutput === void 0 ? {} : { receipt: options.doctorOutput },
|
|
14054
|
-
// Independent machine fields beside the receipt — not merged into it.
|
|
14055
14135
|
...options.cost === void 0 ? {} : { cost: options.cost },
|
|
14056
14136
|
...options.auditNoReceipt === void 0 ? {} : { auditNoReceipt: options.auditNoReceipt }
|
|
14057
14137
|
},
|
|
@@ -14109,7 +14189,6 @@ async function settleLawfulDoctorTerminalResult(admitted, authority, scope) {
|
|
|
14109
14189
|
sessionDirectory
|
|
14110
14190
|
);
|
|
14111
14191
|
}
|
|
14112
|
-
const output = lastRolePayloadRecord(sealed.payloads ?? []) ?? {};
|
|
14113
14192
|
const roleOutcome = sealed;
|
|
14114
14193
|
const navigator = extractNavigatorFact(entries);
|
|
14115
14194
|
const cost = extractDoctorCandidateCostFact(entries);
|
|
@@ -14119,7 +14198,6 @@ async function settleLawfulDoctorTerminalResult(admitted, authority, scope) {
|
|
|
14119
14198
|
roleOutcome,
|
|
14120
14199
|
coordinates,
|
|
14121
14200
|
{
|
|
14122
|
-
doctorOutput: output,
|
|
14123
14201
|
...cost === void 0 ? {} : { cost },
|
|
14124
14202
|
...auditNoReceipt === void 0 ? {} : { auditNoReceipt }
|
|
14125
14203
|
}
|
|
@@ -14369,7 +14447,7 @@ async function publishFailureArtifacts(admitted, failure2, authority) {
|
|
|
14369
14447
|
kind: "error",
|
|
14370
14448
|
role: admitted.role,
|
|
14371
14449
|
runId: admitted.runId,
|
|
14372
|
-
cause: failure2.cause,
|
|
14450
|
+
...failure2.cause === void 0 ? {} : { cause: failure2.cause },
|
|
14373
14451
|
diagnostic: failure2.diagnostic,
|
|
14374
14452
|
...failure2.identity === void 0 ? {} : { identity: failure2.identity },
|
|
14375
14453
|
...failure2.details === void 0 ? {} : { details: failure2.details }
|
|
@@ -14392,7 +14470,7 @@ async function publishFailureArtifacts(admitted, failure2, authority) {
|
|
|
14392
14470
|
sha256: a.sha256,
|
|
14393
14471
|
byteLength: a.byteLength
|
|
14394
14472
|
})),
|
|
14395
|
-
failureCause: failure2.cause
|
|
14473
|
+
...failure2.cause === void 0 ? {} : { failureCause: failure2.cause }
|
|
14396
14474
|
};
|
|
14397
14475
|
const evidenceWrite = await writeFailureJsonRetainingCause(
|
|
14398
14476
|
evidenceCandidates,
|
|
@@ -14456,7 +14534,7 @@ async function settleFailureTerminalResult(admitted, failure2, authority, option
|
|
|
14456
14534
|
const navigator = await extractNavigatorFactFromAdmittedSession(sessionFile);
|
|
14457
14535
|
const artifacts = await publishFailureArtifacts(admitted, failure2, authority);
|
|
14458
14536
|
const decisiveFacts = {
|
|
14459
|
-
cause: failure2.cause,
|
|
14537
|
+
...failure2.cause === void 0 ? {} : { cause: failure2.cause },
|
|
14460
14538
|
diagnostic: failure2.diagnostic
|
|
14461
14539
|
};
|
|
14462
14540
|
if (failure2.identity?.name !== void 0) {
|
|
@@ -14472,7 +14550,7 @@ async function settleFailureTerminalResult(admitted, failure2, authority, option
|
|
|
14472
14550
|
const roleOutcome2 = {
|
|
14473
14551
|
kind: "failure",
|
|
14474
14552
|
role: admitted.role,
|
|
14475
|
-
cause: failure2.cause,
|
|
14553
|
+
...failure2.cause === void 0 ? {} : { cause: failure2.cause },
|
|
14476
14554
|
diagnostic: failure2.diagnostic,
|
|
14477
14555
|
decisiveFacts
|
|
14478
14556
|
};
|
|
@@ -14489,7 +14567,7 @@ async function settleFailureTerminalResult(admitted, failure2, authority, option
|
|
|
14489
14567
|
const roleOutcome = {
|
|
14490
14568
|
kind: "failure",
|
|
14491
14569
|
role: admitted.role,
|
|
14492
|
-
cause: failure2.cause,
|
|
14570
|
+
...failure2.cause === void 0 ? {} : { cause: failure2.cause },
|
|
14493
14571
|
diagnostic: failure2.diagnostic,
|
|
14494
14572
|
decisiveFacts
|
|
14495
14573
|
};
|
|
@@ -14510,7 +14588,7 @@ function presentFailureTerminal(terminal, io) {
|
|
|
14510
14588
|
io.stdout(formatTerminalResult(terminal));
|
|
14511
14589
|
if (terminal.roleOutcome.kind === "failure") {
|
|
14512
14590
|
io.stderr(formatFailureStderrDiagnostic({
|
|
14513
|
-
cause: terminal.roleOutcome.cause,
|
|
14591
|
+
...terminal.roleOutcome.cause === void 0 ? {} : { cause: terminal.roleOutcome.cause },
|
|
14514
14592
|
diagnostic: terminal.roleOutcome.diagnostic
|
|
14515
14593
|
}));
|
|
14516
14594
|
return;
|
|
@@ -14780,12 +14858,29 @@ function unwrapTurnDispatchedFailure(error) {
|
|
|
14780
14858
|
}
|
|
14781
14859
|
return current;
|
|
14782
14860
|
}
|
|
14861
|
+
async function attachDispatchExceptionTerminal(admitted, terminal, io) {
|
|
14862
|
+
try {
|
|
14863
|
+
return await attachRecordedSubmissions(
|
|
14864
|
+
{
|
|
14865
|
+
projectRoot: admitted.projectRoot,
|
|
14866
|
+
runId: admitted.runId,
|
|
14867
|
+
runDirectory: admitted.runDirectory
|
|
14868
|
+
},
|
|
14869
|
+
terminal
|
|
14870
|
+
);
|
|
14871
|
+
} catch (error) {
|
|
14872
|
+
io.stderr(
|
|
14873
|
+
`dispatch exception ledger attach failed (best-effort continue): ${describeErrorIdentity(error)}
|
|
14874
|
+
`
|
|
14875
|
+
);
|
|
14876
|
+
return terminal;
|
|
14877
|
+
}
|
|
14878
|
+
}
|
|
14783
14879
|
function dispatchExceptionFailureTerminal(input) {
|
|
14784
14880
|
const causeError = unwrapTurnDispatchedFailure(input.causeError);
|
|
14785
14881
|
const history = input.everyAttemptThrew ? "dispatch threw an exception on every attempt" : "the final dispatch threw an exception";
|
|
14786
14882
|
const diagnostic = `${history} (${input.endReason}; resumes used ${input.autoResumeAttempts}); last cause: ${describeErrorIdentity(causeError)}`;
|
|
14787
14883
|
const decisiveFacts = {
|
|
14788
|
-
cause: "unrecognized",
|
|
14789
14884
|
diagnostic,
|
|
14790
14885
|
resumesUsed: input.autoResumeAttempts,
|
|
14791
14886
|
dispatchErrorFiles: [...input.errorFiles]
|
|
@@ -14806,7 +14901,6 @@ function dispatchExceptionFailureTerminal(input) {
|
|
|
14806
14901
|
roleOutcome: {
|
|
14807
14902
|
kind: "failure",
|
|
14808
14903
|
role: input.role,
|
|
14809
|
-
cause: "unrecognized",
|
|
14810
14904
|
diagnostic,
|
|
14811
14905
|
decisiveFacts
|
|
14812
14906
|
},
|
|
@@ -14906,15 +15000,19 @@ async function runWithAutoResumeLoop(options) {
|
|
|
14906
15000
|
}
|
|
14907
15001
|
} else {
|
|
14908
15002
|
if (autoResumeAttempts >= limit) {
|
|
14909
|
-
const terminal =
|
|
14910
|
-
|
|
14911
|
-
|
|
14912
|
-
|
|
14913
|
-
|
|
14914
|
-
|
|
14915
|
-
|
|
14916
|
-
|
|
14917
|
-
|
|
15003
|
+
const terminal = await attachDispatchExceptionTerminal(
|
|
15004
|
+
options.admitted,
|
|
15005
|
+
dispatchExceptionFailureTerminal({
|
|
15006
|
+
role: options.admitted.role,
|
|
15007
|
+
runId: options.admitted.runId,
|
|
15008
|
+
causeError: lastThrownError,
|
|
15009
|
+
errorFiles: retainedErrorFiles,
|
|
15010
|
+
autoResumeAttempts,
|
|
15011
|
+
endReason: "auto-resume budget exhausted",
|
|
15012
|
+
everyAttemptThrew
|
|
15013
|
+
}),
|
|
15014
|
+
options.io
|
|
15015
|
+
);
|
|
14918
15016
|
await finalizeExceptionRunBestEffort(options.admitted.runDirectory, options.io);
|
|
14919
15017
|
presentTerminal(terminal, options.io);
|
|
14920
15018
|
return {
|
|
@@ -14923,15 +15021,19 @@ async function runWithAutoResumeLoop(options) {
|
|
|
14923
15021
|
};
|
|
14924
15022
|
}
|
|
14925
15023
|
if (!await isPrincipalAvailable(options.admitted.principal)) {
|
|
14926
|
-
const terminal =
|
|
14927
|
-
|
|
14928
|
-
|
|
14929
|
-
|
|
14930
|
-
|
|
14931
|
-
|
|
14932
|
-
|
|
14933
|
-
|
|
14934
|
-
|
|
15024
|
+
const terminal = await attachDispatchExceptionTerminal(
|
|
15025
|
+
options.admitted,
|
|
15026
|
+
dispatchExceptionFailureTerminal({
|
|
15027
|
+
role: options.admitted.role,
|
|
15028
|
+
runId: options.admitted.runId,
|
|
15029
|
+
causeError: lastThrownError,
|
|
15030
|
+
errorFiles: retainedErrorFiles,
|
|
15031
|
+
autoResumeAttempts,
|
|
15032
|
+
endReason: "session principal unavailable before further resume",
|
|
15033
|
+
everyAttemptThrew
|
|
15034
|
+
}),
|
|
15035
|
+
options.io
|
|
15036
|
+
);
|
|
14935
15037
|
await finalizeExceptionRunBestEffort(options.admitted.runDirectory, options.io);
|
|
14936
15038
|
presentTerminal(terminal, options.io);
|
|
14937
15039
|
return {
|
|
@@ -16229,7 +16331,7 @@ function instructionSeatAdapters(options) {
|
|
|
16229
16331
|
}) => {
|
|
16230
16332
|
const infrastructureFailure = await readEngineDetourInfrastructureFailure(sessionFile);
|
|
16231
16333
|
return infrastructureFailure === void 0 ? result.knownFailure : {
|
|
16232
|
-
cause: infrastructureFailure.cause,
|
|
16334
|
+
...infrastructureFailure.cause === void 0 ? {} : { cause: infrastructureFailure.cause },
|
|
16233
16335
|
diagnostic: infrastructureFailure.diagnostic,
|
|
16234
16336
|
...infrastructureFailure.identity === void 0 ? {} : { identity: infrastructureFailure.identity }
|
|
16235
16337
|
};
|
|
@@ -16474,7 +16576,7 @@ function judgeAdapters() {
|
|
|
16474
16576
|
resolveRunnerKnownFailure: async ({ result, sessionFile }) => {
|
|
16475
16577
|
const infrastructureFailure = await readEngineDetourInfrastructureFailure(sessionFile);
|
|
16476
16578
|
return result.knownFailure ?? (infrastructureFailure === void 0 ? void 0 : {
|
|
16477
|
-
cause: infrastructureFailure.cause,
|
|
16579
|
+
...infrastructureFailure.cause === void 0 ? {} : { cause: infrastructureFailure.cause },
|
|
16478
16580
|
diagnostic: infrastructureFailure.diagnostic,
|
|
16479
16581
|
...infrastructureFailure.identity === void 0 ? {} : { identity: infrastructureFailure.identity }
|
|
16480
16582
|
});
|
|
@@ -16786,15 +16888,11 @@ async function runPublicDiarist(argv, env, io, parseDiaristArgv2) {
|
|
|
16786
16888
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
16787
16889
|
}).then(async (result) => {
|
|
16788
16890
|
if (admitted.ticketNumber === void 0 && result.admitted !== void 0) {
|
|
16789
|
-
const
|
|
16790
|
-
|
|
16791
|
-
|
|
16792
|
-
|
|
16793
|
-
|
|
16794
|
-
admitted.ticketNumber = raw;
|
|
16795
|
-
if (result.admitted.ticketNumber === void 0) {
|
|
16796
|
-
result.admitted.ticketNumber = raw;
|
|
16797
|
-
}
|
|
16891
|
+
const fromPages = await readRunTicketNumber(admitted.runDirectory);
|
|
16892
|
+
if (fromPages !== void 0) {
|
|
16893
|
+
await bindAdmittedTicketNumber(admitted, fromPages);
|
|
16894
|
+
if (result.admitted.ticketNumber === void 0) {
|
|
16895
|
+
result.admitted.ticketNumber = fromPages;
|
|
16798
16896
|
}
|
|
16799
16897
|
}
|
|
16800
16898
|
}
|
|
@@ -16836,8 +16934,8 @@ var init_diarist_run = __esm({
|
|
|
16836
16934
|
init_run_lifecycle();
|
|
16837
16935
|
init_seat_ticket_binding();
|
|
16838
16936
|
init_settlement();
|
|
16839
|
-
init_terminal();
|
|
16840
16937
|
init_turn_request();
|
|
16938
|
+
init_run_ticket_number();
|
|
16841
16939
|
}
|
|
16842
16940
|
});
|
|
16843
16941
|
|
|
@@ -17951,6 +18049,24 @@ function navigatorProviderFailureFromDiagnostics(diagnostics) {
|
|
|
17951
18049
|
}
|
|
17952
18050
|
return void 0;
|
|
17953
18051
|
}
|
|
18052
|
+
function navigatorProviderFailureFromPublicTerminal(outcome) {
|
|
18053
|
+
const facts = outcome.decisiveFacts;
|
|
18054
|
+
const secondary = typeof facts.secondaryEvidence === "object" && facts.secondaryEvidence !== null ? facts.secondaryEvidence : void 0;
|
|
18055
|
+
const httpStatus = typeof secondary?.httpStatus === "number" ? secondary.httpStatus : typeof facts.httpStatus === "number" ? facts.httpStatus : typeof facts.errorCode === "number" ? facts.errorCode : void 0;
|
|
18056
|
+
const fromStatus = navigatorProviderFailureFromStatus(httpStatus);
|
|
18057
|
+
if (fromStatus !== void 0) return fromStatus;
|
|
18058
|
+
const diagnostics = secondary?.diagnostics ?? facts.diagnostics;
|
|
18059
|
+
const fromDiagnostics = navigatorProviderFailureFromDiagnostics(diagnostics);
|
|
18060
|
+
if (fromDiagnostics !== void 0) return fromDiagnostics;
|
|
18061
|
+
const fromCode = navigatorProviderFailureFromError({
|
|
18062
|
+
code: secondary?.code ?? facts.errorCode
|
|
18063
|
+
});
|
|
18064
|
+
if (fromCode !== void 0) return fromCode;
|
|
18065
|
+
if (outcome.cause === "provider") return { source: "transport", cause: "unknown" };
|
|
18066
|
+
const typed = navigatorUnavailableKey(outcome.cause);
|
|
18067
|
+
if (typed !== void 0) return { source: typed, cause: typed };
|
|
18068
|
+
return { source: "unknown", cause: "unknown" };
|
|
18069
|
+
}
|
|
17954
18070
|
var navigatorProviderFailureSchema = Type12.Object({
|
|
17955
18071
|
source: Type12.Union([
|
|
17956
18072
|
Type12.Literal("context"),
|
|
@@ -18032,23 +18148,6 @@ async function resolveNavigatorSeatSelection(context) {
|
|
|
18032
18148
|
}
|
|
18033
18149
|
|
|
18034
18150
|
// src/navigator-public-session.ts
|
|
18035
|
-
init_terminal();
|
|
18036
|
-
function providerFailureFromPublicTerminal(outcome) {
|
|
18037
|
-
const facts = outcome.decisiveFacts;
|
|
18038
|
-
const secondary = typeof facts.secondaryEvidence === "object" && facts.secondaryEvidence !== null ? facts.secondaryEvidence : void 0;
|
|
18039
|
-
const httpStatus = typeof secondary?.httpStatus === "number" ? secondary.httpStatus : typeof facts.httpStatus === "number" ? facts.httpStatus : typeof facts.errorCode === "number" ? facts.errorCode : void 0;
|
|
18040
|
-
const fromStatus = navigatorProviderFailureFromStatus(httpStatus);
|
|
18041
|
-
if (fromStatus !== void 0) return fromStatus;
|
|
18042
|
-
const diagnostics = secondary?.diagnostics ?? facts.diagnostics;
|
|
18043
|
-
const fromDiagnostics = navigatorProviderFailureFromDiagnostics(diagnostics);
|
|
18044
|
-
if (fromDiagnostics !== void 0) return fromDiagnostics;
|
|
18045
|
-
const fromCode = navigatorProviderFailureFromError({
|
|
18046
|
-
code: secondary?.code ?? facts.errorCode
|
|
18047
|
-
});
|
|
18048
|
-
if (fromCode !== void 0) return fromCode;
|
|
18049
|
-
if (outcome.cause === "provider") return { source: "transport", cause: "transport" };
|
|
18050
|
-
return { source: "session", cause: "session" };
|
|
18051
|
-
}
|
|
18052
18151
|
function createNativeNavigatorSessionFactory() {
|
|
18053
18152
|
return async ({ context, subject, tool }) => {
|
|
18054
18153
|
const resolved = await resolveNavigatorSeatSelection(context);
|
|
@@ -18104,14 +18203,15 @@ function createNativeNavigatorSessionFactory() {
|
|
|
18104
18203
|
const outcome = summoned.terminal?.roleOutcome;
|
|
18105
18204
|
if (outcome === void 0) {
|
|
18106
18205
|
const detail = summoned.stderr?.trim() || `exit ${summoned.exitCode}`;
|
|
18107
|
-
providerFailure = { source: "transport", cause: "
|
|
18206
|
+
providerFailure = { source: "transport", cause: "unknown" };
|
|
18108
18207
|
throw navigatorUnavailableError(
|
|
18109
|
-
|
|
18110
|
-
new Error(`Navigator public summon produced no terminal (${detail})`)
|
|
18208
|
+
providerFailure.source,
|
|
18209
|
+
new Error(`Navigator public summon produced no terminal (${detail})`),
|
|
18210
|
+
providerFailure.cause
|
|
18111
18211
|
);
|
|
18112
18212
|
}
|
|
18113
18213
|
if (outcome.kind === "failure") {
|
|
18114
|
-
providerFailure =
|
|
18214
|
+
providerFailure = navigatorProviderFailureFromPublicTerminal(outcome);
|
|
18115
18215
|
throw navigatorUnavailableError(
|
|
18116
18216
|
providerFailure.source,
|
|
18117
18217
|
new Error(outcome.diagnostic),
|
|
@@ -18125,21 +18225,22 @@ function createNativeNavigatorSessionFactory() {
|
|
|
18125
18225
|
if (outcome.kind !== "accepted") {
|
|
18126
18226
|
return;
|
|
18127
18227
|
}
|
|
18128
|
-
const
|
|
18129
|
-
|
|
18130
|
-
|
|
18228
|
+
for (const payload of outcome.payloads ?? []) {
|
|
18229
|
+
if (typeof payload !== "object" || payload === null || Array.isArray(payload)) continue;
|
|
18230
|
+
const candidates = payload.candidates;
|
|
18231
|
+
if (!Array.isArray(candidates)) continue;
|
|
18232
|
+
await tool.execute(
|
|
18233
|
+
"navigator-public-prepare",
|
|
18234
|
+
{ candidates },
|
|
18235
|
+
void 0,
|
|
18236
|
+
void 0,
|
|
18237
|
+
context
|
|
18238
|
+
);
|
|
18131
18239
|
}
|
|
18132
|
-
await tool.execute(
|
|
18133
|
-
"navigator-public-prepare",
|
|
18134
|
-
{ candidates },
|
|
18135
|
-
void 0,
|
|
18136
|
-
void 0,
|
|
18137
|
-
context
|
|
18138
|
-
);
|
|
18139
18240
|
} catch (error) {
|
|
18140
18241
|
if (error instanceof NavigatorUnavailableError) throw error;
|
|
18141
18242
|
const fact = navigatorProviderFailureFromError(error);
|
|
18142
|
-
providerFailure = fact ?? { source: "transport", cause: "
|
|
18243
|
+
providerFailure = fact ?? { source: "transport", cause: "unknown" };
|
|
18143
18244
|
throw navigatorUnavailableError(providerFailure.source, error, providerFailure.cause);
|
|
18144
18245
|
}
|
|
18145
18246
|
})();
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
navigatorProviderFailure,
|
|
23
23
|
navigatorProviderFailureFromDiagnostics,
|
|
24
24
|
navigatorProviderFailureFromError,
|
|
25
|
+
navigatorProviderFailureFromPublicTerminal,
|
|
25
26
|
navigatorProviderFailureFromStatus,
|
|
26
27
|
navigatorUnavailableError,
|
|
27
28
|
parseNavigatorModelSetting,
|
|
@@ -698,6 +699,7 @@ export {
|
|
|
698
699
|
navigatorProviderFailure,
|
|
699
700
|
navigatorProviderFailureFromDiagnostics,
|
|
700
701
|
navigatorProviderFailureFromError,
|
|
702
|
+
navigatorProviderFailureFromPublicTerminal,
|
|
701
703
|
navigatorProviderFailureFromStatus,
|
|
702
704
|
navigatorSubjectKey,
|
|
703
705
|
navigatorSubjectKeyForInput,
|