@akagilnc/pi-workflow-roles 0.1.5805 → 0.1.5835
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/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/acp-host/production-host.js +397 -311
- package/dist/acp-host/role-turn-host.js +484 -0
- package/dist/activation-ledger-session.js +105 -0
- package/dist/activation-ledger.js +8 -0
- package/dist/activation-trace.js +33 -0
- package/dist/audit-escalation.js +7 -0
- package/dist/audited-run-identity.js +21 -0
- package/dist/auditor-role.js +7 -0
- package/dist/book-topology-migration-placement.js +404 -0
- package/dist/book-topology-migration.js +125 -0
- package/dist/book-topology-migrators-t11.js +677 -0
- package/dist/book-topology-mixed-volume-migrators.js +322 -0
- package/dist/book-topology-partition-migrators.js +23 -0
- package/dist/book-topology-record-class-migrators.js +671 -0
- package/dist/book-topology-runs-migrator.js +272 -0
- package/dist/collector-role.js +109 -0
- package/dist/compliance-transport.js +5 -3
- package/dist/countersign-role.js +17 -0
- package/dist/diarist-role.js +8 -0
- package/dist/diarist.js +15 -0
- package/dist/doctor-role.js +80 -0
- package/dist/factory-board.js +1478 -0
- package/dist/fixer-bash-seatbelt.js +13 -0
- package/dist/gatekeeper-role.js +1 -2
- package/dist/gh-api-runner.js +81 -0
- package/dist/gleaner-left-role.js +8 -0
- package/dist/headless-host/production-host.js +397 -311
- package/dist/headless-host/role-turn-host.js +691 -0
- package/dist/human-format.js +67 -0
- package/dist/inspector-role.js +12 -0
- package/dist/judge-recording-anti-forge.js +39 -0
- package/dist/judge-role.js +21 -3
- package/dist/merger-role.js +57 -0
- package/dist/migrate-book-topology.js +7 -6
- package/dist/navigator-role.js +6 -0
- package/dist/navigator-work-context.js +72 -0
- package/dist/notary-role.js +113 -0
- package/dist/oauth-keepalive.js +149 -0
- package/dist/package-contracts/terminating-infrastructure.js +0 -35
- package/dist/packaged-role-registry.js +1 -0
- package/dist/pi/adapter.js +272 -0
- package/dist/public-cli/cli.js +9 -3
- package/dist/public-cli/instruction-seat-run.js +163 -44
- package/dist/public-cli/main.js +248 -127
- package/dist/public-cli/option-definitions.js +2 -2
- package/dist/report-ticket-tool.js +24 -13
- package/dist/reviewer-role.js +33 -0
- package/dist/role-envelope.js +707 -0
- package/dist/role-runtime-dependencies.js +57 -0
- package/dist/role-runtime.js +1476 -0
- package/dist/secretariat-contracts.js +4 -2
- package/dist/secretariat-role.js +4 -0
- package/dist/stderr-jsonl.js +26 -0
- package/dist/submission-correctable-error.js +2 -6
- package/dist/submission-errors.js +0 -30
- package/dist/submission-gate.js +61 -54
- package/dist/submission-ledger.js +105 -98
- package/dist/ticket-snapshot.js +486 -0
- package/dist/ticket-trajectory.js +843 -0
- package/dist/worker-role.js +184 -0
- package/dist/worker-submission-gates.js +333 -0
- package/package.json +1 -1
- package/resources/secretariat-ticket-identity.md +1 -1
- package/souls/countersign.md +1 -1
- package/souls/design-law.md +47 -0
- package/souls/secretariat.md +14 -25
- package/souls/ticket-law.md +3 -3
- package/src/compliance-transport.ts +7 -3
- package/src/gatekeeper-role.ts +1 -15
- package/src/host-contracts.ts +2 -12
- package/src/judge-role.ts +30 -7
- package/src/package-contracts/terminating-infrastructure.ts +8 -81
- package/src/packaged-role-registry.ts +1 -0
- package/src/pi/adapter.ts +0 -1
- package/src/public-cli/cli.ts +21 -14
- package/src/public-cli/instruction-seat-run.ts +227 -44
- package/src/public-cli/option-definitions.ts +2 -2
- package/src/report-ticket-tool.ts +27 -13
- package/src/role-envelope.ts +32 -34
- package/src/role-runtime.ts +62 -55
- package/src/secretariat-contracts.ts +10 -17
- package/src/secretariat-role.ts +2 -4
- package/src/submission-correctable-error.ts +1 -6
- package/src/submission-errors.ts +0 -34
- package/src/submission-gate.ts +71 -56
- package/src/submission-ledger.ts +109 -104
|
@@ -1535,43 +1535,10 @@ function withTerminatingOutputDeclarations(schema) {
|
|
|
1535
1535
|
object.required = preserved;
|
|
1536
1536
|
return object;
|
|
1537
1537
|
}
|
|
1538
|
-
function isInfrastructureFailureDeclaration(parameters) {
|
|
1539
|
-
if (!isRecord(parameters)) return false;
|
|
1540
|
-
if (!Object.hasOwn(parameters, INFRASTRUCTURE_FAILURE_DECLARATION_KEY)) return false;
|
|
1541
|
-
const declaration = parameters[INFRASTRUCTURE_FAILURE_DECLARATION_KEY];
|
|
1542
|
-
if (!isRecord(declaration)) return false;
|
|
1543
|
-
const diagnostic = declaration[INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY];
|
|
1544
|
-
return typeof diagnostic === "string" && diagnostic.trim().length > 0;
|
|
1545
|
-
}
|
|
1546
|
-
function infrastructureFailureDiagnostic(parameters) {
|
|
1547
|
-
if (!isInfrastructureFailureDeclaration(parameters)) return void 0;
|
|
1548
|
-
const declaration = parameters[INFRASTRUCTURE_FAILURE_DECLARATION_KEY];
|
|
1549
|
-
const diagnostic = declaration[INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY];
|
|
1550
|
-
return typeof diagnostic === "string" ? diagnostic.trim() : void 0;
|
|
1551
|
-
}
|
|
1552
|
-
function infrastructureFailureError(diagnostic) {
|
|
1553
|
-
const error = new Error(diagnostic);
|
|
1554
|
-
error.name = "InfrastructureFailure";
|
|
1555
|
-
return error;
|
|
1556
|
-
}
|
|
1557
|
-
function failOnInfrastructureFailureDeclaration(parameters, hostActions, ctx, toolCallId, bounceInfrastructureDeclaration) {
|
|
1558
|
-
const diagnostic = infrastructureFailureDiagnostic(parameters);
|
|
1559
|
-
if (diagnostic === void 0) return;
|
|
1560
|
-
if (bounceInfrastructureDeclaration !== void 0) {
|
|
1561
|
-
const bounce = bounceInfrastructureDeclaration(parameters, toolCallId, ctx);
|
|
1562
|
-
if (bounce !== void 0) throw bounce;
|
|
1563
|
-
}
|
|
1564
|
-
hostActions.failInfrastructure(
|
|
1565
|
-
infrastructureFailureError(diagnostic),
|
|
1566
|
-
ctx,
|
|
1567
|
-
toolCallId
|
|
1568
|
-
);
|
|
1569
|
-
}
|
|
1570
1538
|
var INFRASTRUCTURE_FAILURE_DECLARATION_KEY, INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY, infrastructureFailureNested, infrastructureFailureDeclarationSchema;
|
|
1571
1539
|
var init_terminating_infrastructure = __esm({
|
|
1572
1540
|
"src/package-contracts/terminating-infrastructure.ts"() {
|
|
1573
1541
|
"use strict";
|
|
1574
|
-
init_unknown_value();
|
|
1575
1542
|
INFRASTRUCTURE_FAILURE_DECLARATION_KEY = "infrastructureFailure";
|
|
1576
1543
|
INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY = "diagnostic";
|
|
1577
1544
|
infrastructureFailureNested = Type2.Object(
|
|
@@ -2348,10 +2315,12 @@ var init_secretariat_contracts = __esm({
|
|
|
2348
2315
|
ticketNumber: Type13.Optional(
|
|
2349
2316
|
Type13.Unknown({ description: "\u672C\u7968\u53F7\uFF1B\u7F72\u65F6\u6307\u5411\u6700\u7EC8\u6B63\u6587\u6240\u5728\u7968" })
|
|
2350
2317
|
),
|
|
2351
|
-
note: Type13.Unknown({
|
|
2318
|
+
note: Type13.Unknown({
|
|
2319
|
+
description: "\u9644\u6CE8\uFF1B\u7F72\uFF08converged\uFF09\u65F6\u9010\u9898\u5217\u7B54\u6848\u3001\u4F9D\u636E\u4E0E\u843D\u5728\u54EA\u4E00\u53E5\uFF1B\u5C01\u8FD8\uFF08escalate\uFF09\u65F6\u9996\u5199\u300C\u5C01\u8FD8\u300D\u3002\u539F\u6837\u7559\u5B58\u3002"
|
|
2320
|
+
}),
|
|
2352
2321
|
evidence: Type13.Optional(Type13.Unknown({ description: "\u7559\u5B58\u8BC1\u636E" })),
|
|
2353
2322
|
decisionGate: Type13.Unknown({
|
|
2354
|
-
description: "\
|
|
2323
|
+
description: "\u672C\u8F6E\u9898\u76EE\uFF1A\u6BCF\u9898 question\u3001options\uFF08\u7A3F\u91CC\u505A\u6CD5\uFF0F\u53E6\u4E00\u505A\u6CD5\uFF09\u3001\u4E24\u8FB9\u4EE3\u4EF7\u3001\u5EFA\u8BAE\u3002\u539F\u6837\u7559\u5B58\u3002"
|
|
2355
2324
|
})
|
|
2356
2325
|
},
|
|
2357
2326
|
{ additionalProperties: true }
|
|
@@ -2882,6 +2851,7 @@ var init_packaged_role_registry = __esm({
|
|
|
2882
2851
|
sessionMaterials: [
|
|
2883
2852
|
"CLAUDE.md",
|
|
2884
2853
|
"souls/secretariat.md",
|
|
2854
|
+
"souls/design-law.md",
|
|
2885
2855
|
"souls/ticket-law.md",
|
|
2886
2856
|
"resources/secretariat-ticket-identity.md",
|
|
2887
2857
|
"souls/countersign.md",
|
|
@@ -3106,20 +3076,6 @@ var init_readable_gate_item = __esm({
|
|
|
3106
3076
|
});
|
|
3107
3077
|
|
|
3108
3078
|
// src/submission-errors.ts
|
|
3109
|
-
function serializeReceipt(receipt) {
|
|
3110
|
-
return readableGateItem(receipt);
|
|
3111
|
-
}
|
|
3112
|
-
function gatekeeperNonPassMessage(result) {
|
|
3113
|
-
if (result.status === "continue") {
|
|
3114
|
-
return serializeReceipt(result.receipt);
|
|
3115
|
-
}
|
|
3116
|
-
if (result.status === "transport_failure") {
|
|
3117
|
-
const head = `\u95E8\u4E0B\u7701 ${result.status}\uFF08${result.stage}\uFF09\uFF1A${result.reason}`;
|
|
3118
|
-
return result.submission === void 0 ? head : `${head}
|
|
3119
|
-
${serializeReceipt(result.submission)}`;
|
|
3120
|
-
}
|
|
3121
|
-
return `\u95E8\u4E0B\u7701 ${result.status}\uFF08${result.stage}\uFF09\uFF1A${result.reason}`;
|
|
3122
|
-
}
|
|
3123
3079
|
function isOneShotWorkerReminderCode(code) {
|
|
3124
3080
|
return code === "worker_commit_reminder" || code === "worker_prefix_reminder";
|
|
3125
3081
|
}
|
|
@@ -3132,20 +3088,12 @@ function receivedDiscriminator(receipt, field) {
|
|
|
3132
3088
|
if (!Object.hasOwn(receipt, field)) return void 0;
|
|
3133
3089
|
return receipt[field];
|
|
3134
3090
|
}
|
|
3135
|
-
var
|
|
3091
|
+
var WorkerCommitReminderError, WorkerPrefixReminderError, WorkerUnfinishedReasonReminderError, ParentQueueReaskError;
|
|
3136
3092
|
var init_submission_errors = __esm({
|
|
3137
3093
|
"src/submission-errors.ts"() {
|
|
3138
3094
|
"use strict";
|
|
3139
3095
|
init_readable_gate_item();
|
|
3140
3096
|
init_unknown_value();
|
|
3141
|
-
GatekeeperDecisionError = class extends Error {
|
|
3142
|
-
result;
|
|
3143
|
-
constructor(result, message) {
|
|
3144
|
-
super(message ?? gatekeeperNonPassMessage(result));
|
|
3145
|
-
this.name = "GatekeeperDecisionError";
|
|
3146
|
-
this.result = result;
|
|
3147
|
-
}
|
|
3148
|
-
};
|
|
3149
3097
|
WorkerCommitReminderError = class extends Error {
|
|
3150
3098
|
code = "worker_commit_reminder";
|
|
3151
3099
|
constructor() {
|
|
@@ -3703,7 +3651,6 @@ var init_gatekeeper_role = __esm({
|
|
|
3703
3651
|
init_run_terminal_artifacts();
|
|
3704
3652
|
init_unknown_value();
|
|
3705
3653
|
init_serialize_thrown_value();
|
|
3706
|
-
init_submission_errors();
|
|
3707
3654
|
GATE_OFFICER_BY_SUBJECT = {
|
|
3708
3655
|
worker_completion: "inspector",
|
|
3709
3656
|
judge_compliance: "auditor",
|
|
@@ -4483,13 +4430,10 @@ function isCorrectableSubmissionError(error) {
|
|
|
4483
4430
|
return error instanceof CorrectableSubmissionError;
|
|
4484
4431
|
}
|
|
4485
4432
|
function isCorrectableExecuteError(error) {
|
|
4486
|
-
return isCorrectableSubmissionError(error) || error instanceof
|
|
4433
|
+
return isCorrectableSubmissionError(error) || error instanceof ParentQueueReaskError || error instanceof WorkerCommitReminderError || error instanceof WorkerPrefixReminderError || error instanceof WorkerUnfinishedReasonReminderError;
|
|
4487
4434
|
}
|
|
4488
4435
|
function projectCorrectableExecuteRejection(error) {
|
|
4489
4436
|
const diagnostic = errorText(error);
|
|
4490
|
-
if (error instanceof GatekeeperDecisionError) {
|
|
4491
|
-
return { diagnostic, details: { ...error.result } };
|
|
4492
|
-
}
|
|
4493
4437
|
if (error instanceof WorkerCommitReminderError || error instanceof WorkerPrefixReminderError || error instanceof WorkerUnfinishedReasonReminderError) {
|
|
4494
4438
|
return { diagnostic, details: { code: error.code } };
|
|
4495
4439
|
}
|
|
@@ -6669,10 +6613,10 @@ var init_option_definitions = __esm({
|
|
|
6669
6613
|
},
|
|
6670
6614
|
secretariat: {
|
|
6671
6615
|
command: "secretariat",
|
|
6672
|
-
summary: "Secretariat (\u4E2D\u4E66\u7701):
|
|
6616
|
+
summary: "Secretariat (\u4E2D\u4E66\u7701): review the drafted ticket's design by asking the caller questions; converges once the revised ticket lands every answer, then the gate summons countersign.",
|
|
6673
6617
|
usage: ["ak-role secretariat [options] [instruction]"],
|
|
6674
6618
|
examples: [
|
|
6675
|
-
'ak-role secretariat "\
|
|
6619
|
+
'ak-role secretariat "\u5BA1 #924 \u7968\u9762\u7684\u8BBE\u8BA1\u3002"'
|
|
6676
6620
|
]
|
|
6677
6621
|
},
|
|
6678
6622
|
notary: {
|
|
@@ -8243,11 +8187,7 @@ function admittedForLiveTicketReport(runDirectory, authority) {
|
|
|
8243
8187
|
...ticketNumber === void 0 ? {} : { ticketNumber }
|
|
8244
8188
|
};
|
|
8245
8189
|
}
|
|
8246
|
-
async function reportTicketFromHostContext(context,
|
|
8247
|
-
const ticketNumber = readDeclaredTicketNumber(rawTicketNumber);
|
|
8248
|
-
if (ticketNumber === void 0) {
|
|
8249
|
-
throw new Error("ak_report_ticket requires an identifiable ticketNumber");
|
|
8250
|
-
}
|
|
8190
|
+
async function reportTicketFromHostContext(context, ticketNumber, authority = piDurablePrincipalAuthority) {
|
|
8251
8191
|
const runDirectory = runDirectoryFromHostContext(context);
|
|
8252
8192
|
if (runDirectory === void 0) {
|
|
8253
8193
|
throw new Error("ak_report_ticket requires a per-turn run directory");
|
|
@@ -8283,7 +8223,7 @@ async function reportTicketFromHostContext(context, rawTicketNumber, authority =
|
|
|
8283
8223
|
relocated: relocation !== void 0
|
|
8284
8224
|
};
|
|
8285
8225
|
}
|
|
8286
|
-
function registerReportTicketTool(roleHost) {
|
|
8226
|
+
function registerReportTicketTool(roleHost, hostActions) {
|
|
8287
8227
|
if (roleHost.getAllTools().some((tool) => tool.name === REPORT_TICKET_TOOL_NAME)) return;
|
|
8288
8228
|
roleHost.registerTool({
|
|
8289
8229
|
name: REPORT_TICKET_TOOL_NAME,
|
|
@@ -8291,13 +8231,21 @@ function registerReportTicketTool(roleHost) {
|
|
|
8291
8231
|
description: REPORT_TICKET_TOOL_DESCRIPTION,
|
|
8292
8232
|
promptSnippet: "\u5DF2\u77E5\u7968\u53F7\u65F6\u7ACB\u5373\u7533\u62A5\uFF0C\u5305\u5F53\u573A\u5F52\u4F4D",
|
|
8293
8233
|
parameters: reportTicketArgsSchema,
|
|
8294
|
-
async execute(
|
|
8234
|
+
async execute(toolCallId, parameters, _signal, _onUpdate, ctx) {
|
|
8295
8235
|
const raw = isRecord(parameters) ? parameters.ticketNumber : void 0;
|
|
8296
|
-
const
|
|
8297
|
-
|
|
8298
|
-
|
|
8299
|
-
|
|
8300
|
-
|
|
8236
|
+
const ticketNumber = readDeclaredTicketNumber(raw);
|
|
8237
|
+
if (ticketNumber === void 0) {
|
|
8238
|
+
throw new Error("ak_report_ticket requires an identifiable ticketNumber");
|
|
8239
|
+
}
|
|
8240
|
+
try {
|
|
8241
|
+
const details = await reportTicketFromHostContext(ctx, ticketNumber);
|
|
8242
|
+
return {
|
|
8243
|
+
content: [],
|
|
8244
|
+
details
|
|
8245
|
+
};
|
|
8246
|
+
} catch (error) {
|
|
8247
|
+
hostActions.failInfrastructure(error, ctx, toolCallId);
|
|
8248
|
+
}
|
|
8301
8249
|
}
|
|
8302
8250
|
});
|
|
8303
8251
|
}
|
|
@@ -8490,6 +8438,14 @@ async function readAttemptScopedSubmissionRows(cwd, runId, attemptId, homeOrScop
|
|
|
8490
8438
|
const { owned } = await readOwnedSubmissionRecords(cwd, runId, scope);
|
|
8491
8439
|
return mapOwnedToSubmissionRows(owned.filter((record) => recordAttemptId(record) === attemptId));
|
|
8492
8440
|
}
|
|
8441
|
+
async function readSubmissionAttemptId(cwd, runId, toolCallId, homeOrScope) {
|
|
8442
|
+
const { owned } = await readOwnedSubmissionRecords(cwd, runId, resolveReadScope(homeOrScope));
|
|
8443
|
+
const record = owned.find((candidate) => {
|
|
8444
|
+
const payload = candidate.payload;
|
|
8445
|
+
return payload?.toolCallId === toolCallId;
|
|
8446
|
+
});
|
|
8447
|
+
return record === void 0 ? void 0 : recordAttemptId(record);
|
|
8448
|
+
}
|
|
8493
8449
|
async function readRecordedSubmissions(cwd, runId, homeOrScope) {
|
|
8494
8450
|
return (await readRecordedSubmissionRows(cwd, runId, homeOrScope)).map((row) => row.accepted);
|
|
8495
8451
|
}
|
|
@@ -8613,89 +8569,82 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
|
|
|
8613
8569
|
host.registerTool({
|
|
8614
8570
|
...tool,
|
|
8615
8571
|
async execute(toolCallId, params, signal, update, context) {
|
|
8616
|
-
|
|
8617
|
-
if (typedTicket !== void 0) {
|
|
8618
|
-
await reportTicketFromHostContext(context, typedTicket);
|
|
8619
|
-
}
|
|
8620
|
-
const runId = runIdentity(context);
|
|
8621
|
-
const attemptId = attemptIdentity(context, runId);
|
|
8622
|
-
const state = await stateFor(context, runId);
|
|
8623
|
-
const append = (event) => appendFor(context, runId, attemptId, event);
|
|
8624
|
-
append({
|
|
8625
|
-
type: "candidate",
|
|
8626
|
-
attemptId,
|
|
8627
|
-
toolCallId,
|
|
8628
|
-
toolName: tool.name,
|
|
8629
|
-
sequence: ++state.sequence,
|
|
8630
|
-
role,
|
|
8631
|
-
params
|
|
8632
|
-
});
|
|
8572
|
+
let toolThrew = false;
|
|
8633
8573
|
let result;
|
|
8574
|
+
let closed;
|
|
8634
8575
|
try {
|
|
8635
|
-
const
|
|
8636
|
-
if (
|
|
8637
|
-
|
|
8638
|
-
params,
|
|
8639
|
-
{
|
|
8640
|
-
failInfrastructure(error, ctx) {
|
|
8641
|
-
failInfrastructure2(error, ctx);
|
|
8642
|
-
}
|
|
8643
|
-
},
|
|
8644
|
-
context,
|
|
8645
|
-
toolCallId,
|
|
8646
|
-
tool.bounceInfrastructureDeclaration
|
|
8647
|
-
);
|
|
8576
|
+
const typedTicket = isRecord(params) ? readDeclaredTicketNumber(params.ticketNumber) : void 0;
|
|
8577
|
+
if (typedTicket !== void 0) {
|
|
8578
|
+
await reportTicketFromHostContext(context, typedTicket);
|
|
8648
8579
|
}
|
|
8649
|
-
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
|
|
8655
|
-
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
|
|
8659
|
-
|
|
8660
|
-
|
|
8661
|
-
|
|
8662
|
-
|
|
8663
|
-
|
|
8664
|
-
|
|
8665
|
-
|
|
8666
|
-
|
|
8667
|
-
|
|
8668
|
-
|
|
8669
|
-
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
|
|
8580
|
+
const runId = runIdentity(context);
|
|
8581
|
+
const attemptId = attemptIdentity(context, runId);
|
|
8582
|
+
const state = await stateFor(context, runId);
|
|
8583
|
+
const append = (event) => appendFor(context, runId, attemptId, event);
|
|
8584
|
+
append({
|
|
8585
|
+
type: "candidate",
|
|
8586
|
+
attemptId,
|
|
8587
|
+
toolCallId,
|
|
8588
|
+
toolName: tool.name,
|
|
8589
|
+
sequence: ++state.sequence,
|
|
8590
|
+
role,
|
|
8591
|
+
params
|
|
8592
|
+
});
|
|
8593
|
+
try {
|
|
8594
|
+
result = await tool.execute(toolCallId, params, signal, update, context);
|
|
8595
|
+
} catch (error) {
|
|
8596
|
+
if (isCorrectableExecuteError(error)) {
|
|
8597
|
+
append({
|
|
8598
|
+
type: "outcome",
|
|
8599
|
+
attemptId,
|
|
8600
|
+
toolCallId,
|
|
8601
|
+
outcome: "correctable-rejection",
|
|
8602
|
+
code: "typed-bounce",
|
|
8603
|
+
diagnostic: errorText(error),
|
|
8604
|
+
role,
|
|
8605
|
+
accepted: params
|
|
8606
|
+
});
|
|
8607
|
+
} else {
|
|
8608
|
+
append({
|
|
8609
|
+
type: "outcome",
|
|
8610
|
+
attemptId,
|
|
8611
|
+
toolCallId,
|
|
8612
|
+
outcome: "infrastructure",
|
|
8613
|
+
diagnostic: errorText(error),
|
|
8614
|
+
role,
|
|
8615
|
+
accepted: params
|
|
8616
|
+
});
|
|
8617
|
+
}
|
|
8618
|
+
toolThrew = true;
|
|
8673
8619
|
throw error;
|
|
8674
8620
|
}
|
|
8621
|
+
if (result.terminate === false) return result;
|
|
8622
|
+
closed = {
|
|
8623
|
+
role,
|
|
8624
|
+
kind: "accepted",
|
|
8625
|
+
accepted: params
|
|
8626
|
+
};
|
|
8627
|
+
const sealHead = captureWorktreeHead(context.cwd);
|
|
8628
|
+
append({
|
|
8629
|
+
type: "sealed",
|
|
8630
|
+
attemptId,
|
|
8631
|
+
toolCallId,
|
|
8632
|
+
role,
|
|
8633
|
+
accepted: params
|
|
8634
|
+
});
|
|
8635
|
+
const rawLens = typeof host.getFlag === "function" ? host.getFlag("ak-review-lens") : void 0;
|
|
8636
|
+
landTicketProgressForSealedSubmission({
|
|
8637
|
+
context,
|
|
8638
|
+
role,
|
|
8639
|
+
accepted: params,
|
|
8640
|
+
sealHead,
|
|
8641
|
+
...rawLens === "completeness" || rawLens === "correctness" ? { lens: rawLens } : {}
|
|
8642
|
+
});
|
|
8643
|
+
} catch (error) {
|
|
8644
|
+
if (toolThrew) throw error;
|
|
8645
|
+
return failInfrastructure2(error, context, toolCallId);
|
|
8675
8646
|
}
|
|
8676
|
-
|
|
8677
|
-
const closed = {
|
|
8678
|
-
role,
|
|
8679
|
-
kind: "accepted",
|
|
8680
|
-
accepted: params
|
|
8681
|
-
};
|
|
8682
|
-
const sealHead = captureWorktreeHead(context.cwd);
|
|
8683
|
-
append({
|
|
8684
|
-
type: "sealed",
|
|
8685
|
-
attemptId,
|
|
8686
|
-
toolCallId,
|
|
8687
|
-
role,
|
|
8688
|
-
accepted: params
|
|
8689
|
-
});
|
|
8690
|
-
const rawLens = typeof host.getFlag === "function" ? host.getFlag("ak-review-lens") : void 0;
|
|
8691
|
-
landTicketProgressForSealedSubmission({
|
|
8692
|
-
context,
|
|
8693
|
-
role,
|
|
8694
|
-
accepted: params,
|
|
8695
|
-
sealHead,
|
|
8696
|
-
...rawLens === "completeness" || rawLens === "correctness" ? { lens: rawLens } : {}
|
|
8697
|
-
});
|
|
8698
|
-
await projectClosure(closed, context);
|
|
8647
|
+
await projectClosure(closed, context, toolCallId);
|
|
8699
8648
|
return result;
|
|
8700
8649
|
}
|
|
8701
8650
|
});
|
|
@@ -8712,9 +8661,7 @@ var init_submission_ledger = __esm({
|
|
|
8712
8661
|
init_sitian_facade();
|
|
8713
8662
|
init_run_lifecycle();
|
|
8714
8663
|
init_submission_correctable_error();
|
|
8715
|
-
init_terminating_infrastructure();
|
|
8716
8664
|
init_report_ticket_tool();
|
|
8717
|
-
init_review_submission();
|
|
8718
8665
|
init_run_ticket_number();
|
|
8719
8666
|
init_ticket_progress();
|
|
8720
8667
|
init_unknown_value();
|
|
@@ -12064,11 +12011,21 @@ async function runJudgeGates(input) {
|
|
|
12064
12011
|
if (await input.gateAlreadyConverged(subject)) continue;
|
|
12065
12012
|
const pass = await input.runGate(subject);
|
|
12066
12013
|
const received = pass?.status;
|
|
12067
|
-
if (pass === void 0 || (typeof received !== "string" || !REVIEW_QUEUE_STATUSES.has(received) && received !== "needs_reask")) {
|
|
12068
|
-
|
|
12014
|
+
if (pass === void 0 || (typeof received !== "string" || !REVIEW_QUEUE_STATUSES.has(received) && received !== "needs_reask" && received !== "transport_failure" && received !== "no_receipt")) {
|
|
12015
|
+
return {
|
|
12016
|
+
status: "needs_reask",
|
|
12017
|
+
passes: [{
|
|
12018
|
+
subject,
|
|
12019
|
+
status: "needs_reask",
|
|
12020
|
+
receipt: pass?.receipt ?? { reason: "judge gate returned no conclusion" },
|
|
12021
|
+
...pass?.runId === void 0 ? {} : { runId: pass.runId },
|
|
12022
|
+
...pass?.runDirectory === void 0 ? {} : { runDirectory: pass.runDirectory },
|
|
12023
|
+
...pass?.terminal === void 0 ? {} : { terminal: pass.terminal }
|
|
12024
|
+
}]
|
|
12025
|
+
};
|
|
12069
12026
|
}
|
|
12070
12027
|
const status = received;
|
|
12071
|
-
if (status === "needs_reask") {
|
|
12028
|
+
if (status === "needs_reask" || status === "transport_failure" || status === "no_receipt") {
|
|
12072
12029
|
return {
|
|
12073
12030
|
status,
|
|
12074
12031
|
passes: [{
|
|
@@ -12077,7 +12034,8 @@ async function runJudgeGates(input) {
|
|
|
12077
12034
|
receipt: pass.receipt,
|
|
12078
12035
|
...pass.runId === void 0 ? {} : { runId: pass.runId },
|
|
12079
12036
|
...pass.runDirectory === void 0 ? {} : { runDirectory: pass.runDirectory },
|
|
12080
|
-
...pass.terminal === void 0 ? {} : { terminal: pass.terminal }
|
|
12037
|
+
...pass.terminal === void 0 ? {} : { terminal: pass.terminal },
|
|
12038
|
+
...pass.reason === void 0 ? {} : { reason: pass.reason }
|
|
12081
12039
|
}]
|
|
12082
12040
|
};
|
|
12083
12041
|
}
|
|
@@ -12086,7 +12044,8 @@ async function runJudgeGates(input) {
|
|
|
12086
12044
|
status,
|
|
12087
12045
|
receipt: pass.receipt,
|
|
12088
12046
|
...pass.runId === void 0 ? {} : { runId: pass.runId },
|
|
12089
|
-
...pass.runDirectory === void 0 ? {} : { runDirectory: pass.runDirectory }
|
|
12047
|
+
...pass.runDirectory === void 0 ? {} : { runDirectory: pass.runDirectory },
|
|
12048
|
+
...pass.terminal === void 0 ? {} : { terminal: pass.terminal }
|
|
12090
12049
|
});
|
|
12091
12050
|
if (status === "continue" || status === "escalate") return { status, passes };
|
|
12092
12051
|
}
|
|
@@ -12199,6 +12158,17 @@ function createDefaultGateOfficerSummon(options) {
|
|
|
12199
12158
|
});
|
|
12200
12159
|
};
|
|
12201
12160
|
}
|
|
12161
|
+
function presentGateOutcome(fields) {
|
|
12162
|
+
return {
|
|
12163
|
+
status: fields.status,
|
|
12164
|
+
officer: fields.officer,
|
|
12165
|
+
receipt: fields.receipt,
|
|
12166
|
+
...typeof fields.runId === "string" && fields.runId.trim() !== "" ? { runId: fields.runId } : {},
|
|
12167
|
+
...typeof fields.runDirectory === "string" && fields.runDirectory.trim() !== "" ? { runDirectory: fields.runDirectory } : {},
|
|
12168
|
+
...fields.terminal === void 0 ? {} : { terminal: fields.terminal },
|
|
12169
|
+
...fields.reason === void 0 ? {} : { reason: fields.reason }
|
|
12170
|
+
};
|
|
12171
|
+
}
|
|
12202
12172
|
async function requireSubmissionGate(options) {
|
|
12203
12173
|
let reask;
|
|
12204
12174
|
let reasksSpent = 0;
|
|
@@ -12216,7 +12186,7 @@ async function requireSubmissionGate(options) {
|
|
|
12216
12186
|
...reask === void 0 ? {} : { reask }
|
|
12217
12187
|
});
|
|
12218
12188
|
const gatekeeper = projected.result;
|
|
12219
|
-
if (projected.summoned !== void 0 && options.toolCallId.trim() !== "" && (gatekeeper.status === "converged" || gatekeeper.status === "continue" || gatekeeper.status === "escalate" || gatekeeper.status === "needs_reask" || gatekeeper.status === "transport_failure")) {
|
|
12189
|
+
if (projected.summoned !== void 0 && options.toolCallId.trim() !== "" && (gatekeeper.status === "converged" || gatekeeper.status === "continue" || gatekeeper.status === "escalate" || gatekeeper.status === "needs_reask" || gatekeeper.status === "transport_failure" || gatekeeper.status === "no_receipt")) {
|
|
12220
12190
|
const officerRunDirectory = await directoryForSummonedOfficer(
|
|
12221
12191
|
projected.officer,
|
|
12222
12192
|
projected.summoned
|
|
@@ -12226,61 +12196,69 @@ async function requireSubmissionGate(options) {
|
|
|
12226
12196
|
}
|
|
12227
12197
|
}
|
|
12228
12198
|
if (gatekeeper.status === "converged") {
|
|
12229
|
-
return {
|
|
12199
|
+
return presentGateOutcome({
|
|
12230
12200
|
status: "converged",
|
|
12231
12201
|
officer: projected.officer,
|
|
12232
12202
|
receipt: gatekeeper.receipt,
|
|
12233
|
-
|
|
12234
|
-
|
|
12235
|
-
|
|
12236
|
-
|
|
12237
|
-
...projected.summoned?.terminal === void 0 ? {} : { terminal: projected.summoned.terminal }
|
|
12238
|
-
};
|
|
12203
|
+
runId: gatekeeper.runId,
|
|
12204
|
+
runDirectory: projected.summoned?.runDirectory,
|
|
12205
|
+
terminal: projected.summoned?.terminal
|
|
12206
|
+
});
|
|
12239
12207
|
}
|
|
12240
12208
|
if (gatekeeper.status === "continue") {
|
|
12241
|
-
return {
|
|
12209
|
+
return presentGateOutcome({
|
|
12242
12210
|
status: "continue",
|
|
12243
12211
|
officer: projected.officer,
|
|
12244
12212
|
receipt: gatekeeper.receipt,
|
|
12245
|
-
|
|
12246
|
-
};
|
|
12213
|
+
runId: gatekeeper.runId
|
|
12214
|
+
});
|
|
12247
12215
|
}
|
|
12248
12216
|
if (gatekeeper.status === "needs_reask") {
|
|
12249
12217
|
const nestedIncomplete = projected.summoned?.terminal?.roleOutcome.kind === "accepted" && projected.summoned.terminal.roleOutcome.decisiveFacts?.directionUnsettled === true;
|
|
12250
12218
|
if (nestedIncomplete || reasksSpent >= reaskLimit) {
|
|
12251
|
-
return {
|
|
12219
|
+
return presentGateOutcome({
|
|
12252
12220
|
status: "needs_reask",
|
|
12253
12221
|
officer: projected.officer,
|
|
12254
12222
|
receipt: gatekeeper.receipt,
|
|
12255
|
-
|
|
12256
|
-
|
|
12257
|
-
|
|
12258
|
-
};
|
|
12223
|
+
runId: gatekeeper.runId,
|
|
12224
|
+
runDirectory: projected.summoned?.runDirectory,
|
|
12225
|
+
terminal: projected.summoned?.terminal
|
|
12226
|
+
});
|
|
12259
12227
|
}
|
|
12260
12228
|
reasksSpent += 1;
|
|
12261
12229
|
reask = officerConclusionReask(gatekeeper.receivedStatus);
|
|
12262
12230
|
continue;
|
|
12263
12231
|
}
|
|
12264
12232
|
if (gatekeeper.status === "transport_failure") {
|
|
12265
|
-
|
|
12266
|
-
|
|
12267
|
-
|
|
12233
|
+
return presentGateOutcome({
|
|
12234
|
+
status: "transport_failure",
|
|
12235
|
+
officer: projected.officer,
|
|
12236
|
+
receipt: gatekeeper.submission ?? { reason: gatekeeper.reason },
|
|
12237
|
+
reason: gatekeeper.reason,
|
|
12238
|
+
runId: projected.summoned?.terminal?.runId,
|
|
12239
|
+
runDirectory: projected.summoned?.runDirectory,
|
|
12240
|
+
terminal: projected.summoned?.terminal
|
|
12268
12241
|
});
|
|
12269
|
-
options.hostActions.failInfrastructure(failure, options.context, options.toolCallId);
|
|
12270
12242
|
}
|
|
12271
12243
|
if (gatekeeper.status === "escalate") {
|
|
12272
|
-
return {
|
|
12244
|
+
return presentGateOutcome({
|
|
12273
12245
|
status: "escalate",
|
|
12274
12246
|
officer: projected.officer,
|
|
12275
12247
|
receipt: gatekeeper.receipt,
|
|
12276
|
-
|
|
12277
|
-
|
|
12278
|
-
|
|
12279
|
-
|
|
12280
|
-
};
|
|
12248
|
+
runId: gatekeeper.runId,
|
|
12249
|
+
runDirectory: projected.summoned?.runDirectory,
|
|
12250
|
+
terminal: projected.summoned?.terminal
|
|
12251
|
+
});
|
|
12281
12252
|
}
|
|
12282
|
-
|
|
12283
|
-
|
|
12253
|
+
return presentGateOutcome({
|
|
12254
|
+
status: "no_receipt",
|
|
12255
|
+
officer: projected.officer,
|
|
12256
|
+
receipt: gatekeeper.facts ?? { reason: gatekeeper.reason },
|
|
12257
|
+
reason: gatekeeper.reason,
|
|
12258
|
+
runId: projected.summoned?.terminal?.runId,
|
|
12259
|
+
runDirectory: projected.summoned?.runDirectory,
|
|
12260
|
+
terminal: projected.summoned?.terminal
|
|
12261
|
+
});
|
|
12284
12262
|
}
|
|
12285
12263
|
}
|
|
12286
12264
|
var init_submission_gate = __esm({
|
|
@@ -14306,6 +14284,7 @@ __export(instruction_seat_run_exports, {
|
|
|
14306
14284
|
NOTARY_FIXED_DISPATCH: () => NOTARY_FIXED_DISPATCH,
|
|
14307
14285
|
buildInstructionSeatTurnRequest: () => buildInstructionSeatTurnRequest,
|
|
14308
14286
|
continueParentAfterChild: () => continueParentAfterChild,
|
|
14287
|
+
presentAuditedOriginalOfUnsettledOfficer: () => presentAuditedOriginalOfUnsettledOfficer,
|
|
14309
14288
|
resolveReviewSeatDialogueBody: () => resolveReviewSeatDialogueBody,
|
|
14310
14289
|
runPublicInstructionSeat: () => runPublicInstructionSeat,
|
|
14311
14290
|
runPublicInstructionSeatResume: () => runPublicInstructionSeatResume
|
|
@@ -14369,6 +14348,60 @@ async function presentUnsettledOfficer(officer, io, runDirectory) {
|
|
|
14369
14348
|
await presentTerminal(terminal, { ...io, omitFailureStderrDiagnostic: true }, runDirectory);
|
|
14370
14349
|
return terminal;
|
|
14371
14350
|
}
|
|
14351
|
+
async function presentAuditedOriginalVolume(turn, io) {
|
|
14352
|
+
const admitted = turn.admitted;
|
|
14353
|
+
if (turn.terminal === void 0 || admitted === void 0) return;
|
|
14354
|
+
await presentTerminal(
|
|
14355
|
+
turn.terminal,
|
|
14356
|
+
{ ...io, omitFailureStderrDiagnostic: true },
|
|
14357
|
+
admitted.runDirectory
|
|
14358
|
+
);
|
|
14359
|
+
}
|
|
14360
|
+
async function incompleteAuditWithoutOfficerVolume(turn, admitted, io, diagnostic) {
|
|
14361
|
+
await presentAuditedOriginalVolume(turn, io);
|
|
14362
|
+
io.stderr(diagnostic);
|
|
14363
|
+
return { exitCode: 1, admitted };
|
|
14364
|
+
}
|
|
14365
|
+
async function presentAuditedOriginalOfOfficer(officer, presentedRunId, env, io) {
|
|
14366
|
+
if (!GATE_CHILD_ROLES.has(officer.role)) return;
|
|
14367
|
+
const audited = officer.correlationId;
|
|
14368
|
+
if (audited === void 0 || audited === presentedRunId) return;
|
|
14369
|
+
const auditedSource = admittedSourceRunPath(officer);
|
|
14370
|
+
const parent = await loadResumablePublicRole(
|
|
14371
|
+
env.home,
|
|
14372
|
+
audited,
|
|
14373
|
+
env.principalAuthority,
|
|
14374
|
+
auditedSource === void 0 ? void 0 : { runDirectory: auditedSource }
|
|
14375
|
+
);
|
|
14376
|
+
if (!AUDITED_ROLES.has(parent.admitted.role)) return;
|
|
14377
|
+
const sealId = readAdmittedAuditedSubmissionToolCallId(officer.runDirectory);
|
|
14378
|
+
const courtAttemptId = sealId === void 0 ? (await readCurrentCourt(parent.admitted.runDirectory))?.courtAttemptId : await readSubmissionAttemptId(
|
|
14379
|
+
parent.admitted.projectRoot,
|
|
14380
|
+
parent.admitted.runId,
|
|
14381
|
+
sealId,
|
|
14382
|
+
ledgerReadScope(parent.admitted)
|
|
14383
|
+
);
|
|
14384
|
+
if (sealId !== void 0 && courtAttemptId === void 0) return;
|
|
14385
|
+
const terminal = await trySettlePublicSeat(
|
|
14386
|
+
parent.admitted,
|
|
14387
|
+
env.principalAuthority,
|
|
14388
|
+
{
|
|
14389
|
+
...courtAttemptId === void 0 ? {} : { courtAttemptId },
|
|
14390
|
+
previewOnly: true,
|
|
14391
|
+
...packageFaultScope(parent.admitted, env, io)
|
|
14392
|
+
}
|
|
14393
|
+
);
|
|
14394
|
+
if (terminal?.roleOutcome.kind !== "accepted") return;
|
|
14395
|
+
await presentTerminal(terminal, { ...io, omitFailureStderrDiagnostic: true }, parent.admitted.runDirectory);
|
|
14396
|
+
}
|
|
14397
|
+
function leavesAuditedVerdictUnsettled(result) {
|
|
14398
|
+
const outcome = result.terminal?.roleOutcome;
|
|
14399
|
+
return result.exitCode !== 0 || outcome?.kind === "no_receipt" || outcome?.decisiveFacts?.directionUnsettled === true;
|
|
14400
|
+
}
|
|
14401
|
+
async function presentAuditedOriginalOfUnsettledOfficer(result, env, io) {
|
|
14402
|
+
if (result.admitted === void 0 || !leavesAuditedVerdictUnsettled(result)) return;
|
|
14403
|
+
await presentAuditedOriginalOfOfficer(result.admitted, void 0, env, io);
|
|
14404
|
+
}
|
|
14372
14405
|
async function reaskUnreadablePostSubmissionStatus(admitted, terminal, env, io, message = unreadablePostSubmissionStatus(admitted, terminal)) {
|
|
14373
14406
|
if (message === void 0) return void 0;
|
|
14374
14407
|
const next = withUnreadableReask(env);
|
|
@@ -15235,7 +15268,7 @@ async function queueConclusionFromChild(child, env, io) {
|
|
|
15235
15268
|
if (terminal !== void 0 && typeof status === "string" && REVIEW_QUEUE_STATUSES.has(status)) {
|
|
15236
15269
|
return { admitted: child, terminal, status };
|
|
15237
15270
|
}
|
|
15238
|
-
return { stop: { exitCode: 0, ...terminal === void 0 ? {} : { terminal } } };
|
|
15271
|
+
return { stop: { exitCode: 0, admitted: child, ...terminal === void 0 ? {} : { terminal } } };
|
|
15239
15272
|
}
|
|
15240
15273
|
let current = child;
|
|
15241
15274
|
let budgetEnv = envForCourtContinue(env);
|
|
@@ -15257,7 +15290,7 @@ async function queueConclusionFromChild(child, env, io) {
|
|
|
15257
15290
|
officerConclusionReask(status)
|
|
15258
15291
|
);
|
|
15259
15292
|
if (reasked === void 0 || isUnreadableReaskExhausted(reasked)) {
|
|
15260
|
-
return { stop: { exitCode: 0, ...terminal === void 0 ? {} : { terminal } } };
|
|
15293
|
+
return { stop: { exitCode: 0, admitted: current, ...terminal === void 0 ? {} : { terminal } } };
|
|
15261
15294
|
}
|
|
15262
15295
|
budgetEnv = withUnreadableReask(budgetEnv);
|
|
15263
15296
|
if (reasked.exitCode !== 0 || reasked.admitted === void 0 || reasked.terminal === void 0 || reasked.terminal.roleOutcome.kind === "no_receipt" || reasked.terminal.roleOutcome.decisiveFacts?.directionUnsettled === true) {
|
|
@@ -15293,6 +15326,9 @@ async function continueParentAfterChild(parentRunId, child, env, io) {
|
|
|
15293
15326
|
const resolved = await queueConclusionFromChild(child, env, io);
|
|
15294
15327
|
if (resolved !== void 0 && "stop" in resolved) {
|
|
15295
15328
|
const stopped = resolved.stop;
|
|
15329
|
+
if (stopped.admitted !== void 0 && (leavesAuditedVerdictUnsettled(stopped) || heldUnreadableTerminal(stopped.terminal))) {
|
|
15330
|
+
await presentAuditedOriginalOfOfficer(stopped.admitted, void 0, env, io);
|
|
15331
|
+
}
|
|
15296
15332
|
if (stopped.exitCode === 0 && heldUnreadableTerminal(stopped.terminal) && stopped.terminal !== void 0 && stopped.admitted !== void 0) {
|
|
15297
15333
|
const terminal = await presentUnsettledOfficer(
|
|
15298
15334
|
stopped.terminal,
|
|
@@ -15460,20 +15496,27 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
15460
15496
|
}, envForCourtContinue(env), io);
|
|
15461
15497
|
}
|
|
15462
15498
|
if (decision.status === "received") {
|
|
15463
|
-
if (lastSummon?.terminal
|
|
15464
|
-
|
|
15499
|
+
if (lastSummon?.terminal !== void 0) {
|
|
15500
|
+
await presentAuditedOriginalVolume(turn, io);
|
|
15501
|
+
const officerAdmitted = lastSummon.admitted;
|
|
15502
|
+
const officerDir = officerAdmitted?.runDirectory ?? lastSummon.runDirectory ?? admitted.runDirectory;
|
|
15503
|
+
const terminal = await presentUnsettledOfficer(lastSummon.terminal, io, officerDir);
|
|
15504
|
+
return {
|
|
15505
|
+
exitCode: 0,
|
|
15506
|
+
...officerAdmitted === void 0 ? { admitted } : { admitted: officerAdmitted },
|
|
15507
|
+
terminal
|
|
15508
|
+
};
|
|
15465
15509
|
}
|
|
15466
|
-
|
|
15467
|
-
|
|
15468
|
-
|
|
15469
|
-
|
|
15470
|
-
|
|
15471
|
-
|
|
15472
|
-
terminal
|
|
15473
|
-
};
|
|
15510
|
+
return incompleteAuditWithoutOfficerVolume(
|
|
15511
|
+
turn,
|
|
15512
|
+
admitted,
|
|
15513
|
+
io,
|
|
15514
|
+
"doctor audit kept an unreadable reply with no terminal"
|
|
15515
|
+
);
|
|
15474
15516
|
}
|
|
15475
15517
|
if (decision.status !== "converged") {
|
|
15476
15518
|
if (lastSummon?.terminal !== void 0) {
|
|
15519
|
+
await presentAuditedOriginalVolume(turn, io);
|
|
15477
15520
|
await presentTerminal(lastSummon.terminal, { ...io, omitFailureStderrDiagnostic: true }, lastSummon.admitted?.runDirectory ?? admitted.runDirectory);
|
|
15478
15521
|
return {
|
|
15479
15522
|
exitCode: lastSummon.exitCode,
|
|
@@ -15481,7 +15524,8 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
15481
15524
|
terminal: lastSummon.terminal
|
|
15482
15525
|
};
|
|
15483
15526
|
}
|
|
15484
|
-
|
|
15527
|
+
const diagnostic = decision.status === "transport_failure" && "diagnostic" in decision && typeof decision.diagnostic === "string" ? decision.diagnostic : `doctor audit did not converge: ${decision.status}`;
|
|
15528
|
+
return incompleteAuditWithoutOfficerVolume(turn, admitted, io, diagnostic);
|
|
15485
15529
|
}
|
|
15486
15530
|
}
|
|
15487
15531
|
} else {
|
|
@@ -15500,14 +15544,7 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
15500
15544
|
submission: accepted,
|
|
15501
15545
|
summonOfficer,
|
|
15502
15546
|
...env.autoResumeLimit === void 0 ? {} : { autoResumeLimit: env.autoResumeLimit },
|
|
15503
|
-
...env.signal === void 0 ? {} : { signal: env.signal }
|
|
15504
|
-
hostActions: {
|
|
15505
|
-
failInfrastructure(error) {
|
|
15506
|
-
throw error;
|
|
15507
|
-
},
|
|
15508
|
-
bindSubmissionNonPass() {
|
|
15509
|
-
}
|
|
15510
|
-
}
|
|
15547
|
+
...env.signal === void 0 ? {} : { signal: env.signal }
|
|
15511
15548
|
});
|
|
15512
15549
|
if (admitted.role === "judge") {
|
|
15513
15550
|
const judgeGateOrder = JUDGE_GATES.map(gateOfficerForSubject);
|
|
@@ -15522,45 +15559,83 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
15522
15559
|
chain = { status: "converged", passes: [] };
|
|
15523
15560
|
} else {
|
|
15524
15561
|
const pass = await runGate(subject);
|
|
15525
|
-
if (pass === void 0)
|
|
15526
|
-
|
|
15527
|
-
|
|
15528
|
-
|
|
15529
|
-
|
|
15562
|
+
if (pass === void 0) {
|
|
15563
|
+
chain = {
|
|
15564
|
+
status: "needs_reask",
|
|
15565
|
+
passes: [{
|
|
15566
|
+
subject,
|
|
15567
|
+
status: "needs_reask",
|
|
15568
|
+
receipt: { reason: "audit gate returned no conclusion" }
|
|
15569
|
+
}]
|
|
15570
|
+
};
|
|
15571
|
+
} else {
|
|
15572
|
+
chain = {
|
|
15530
15573
|
status: pass.status,
|
|
15531
|
-
|
|
15532
|
-
|
|
15533
|
-
|
|
15534
|
-
|
|
15535
|
-
|
|
15536
|
-
|
|
15574
|
+
passes: [{
|
|
15575
|
+
subject,
|
|
15576
|
+
status: pass.status,
|
|
15577
|
+
receipt: pass.receipt,
|
|
15578
|
+
...pass.runId === void 0 ? {} : { runId: pass.runId },
|
|
15579
|
+
...pass.runDirectory === void 0 ? {} : { runDirectory: pass.runDirectory },
|
|
15580
|
+
...pass.terminal === void 0 ? {} : { terminal: pass.terminal },
|
|
15581
|
+
...pass.reason === void 0 ? {} : { reason: pass.reason }
|
|
15582
|
+
}]
|
|
15583
|
+
};
|
|
15584
|
+
}
|
|
15537
15585
|
}
|
|
15538
15586
|
}
|
|
15539
|
-
if (chain.status === "needs_reask") {
|
|
15587
|
+
if (chain.status === "needs_reask" || chain.status === "transport_failure" || chain.status === "no_receipt") {
|
|
15540
15588
|
const pass = chain.passes.at(-1);
|
|
15541
15589
|
const officerTerminal = pass?.terminal;
|
|
15542
|
-
if (officerTerminal === void 0) throw new Error("unreadable audit has no terminal result");
|
|
15543
15590
|
const officerRunDirectory = pass?.runDirectory;
|
|
15544
15591
|
const officerRunId = pass?.runId ?? (officerRunDirectory === void 0 ? void 0 : runIdFromRunDirectory(officerRunDirectory));
|
|
15545
|
-
if (
|
|
15546
|
-
|
|
15547
|
-
|
|
15548
|
-
|
|
15549
|
-
|
|
15550
|
-
|
|
15551
|
-
|
|
15552
|
-
|
|
15553
|
-
|
|
15592
|
+
if (officerTerminal !== void 0 && officerRunId !== void 0) {
|
|
15593
|
+
await presentAuditedOriginalVolume(turn, io);
|
|
15594
|
+
const officer = await loadResumablePublicRole(
|
|
15595
|
+
env.home,
|
|
15596
|
+
officerRunId,
|
|
15597
|
+
env.principalAuthority,
|
|
15598
|
+
officerRunDirectory === void 0 ? void 0 : { runDirectory: officerRunDirectory }
|
|
15599
|
+
);
|
|
15600
|
+
await presentAuditedOriginalOfOfficer(officer.admitted, admitted.runId, env, io);
|
|
15601
|
+
if (chain.status === "needs_reask" || chain.status === "no_receipt") {
|
|
15602
|
+
const terminal = await presentUnsettledOfficer(
|
|
15603
|
+
officerTerminal,
|
|
15604
|
+
io,
|
|
15605
|
+
officer.admitted.runDirectory
|
|
15606
|
+
);
|
|
15607
|
+
return { exitCode: 0, admitted: officer.admitted, terminal };
|
|
15608
|
+
}
|
|
15609
|
+
await presentTerminal(
|
|
15610
|
+
officerTerminal,
|
|
15611
|
+
{ ...io, omitFailureStderrDiagnostic: true },
|
|
15612
|
+
officer.admitted.runDirectory
|
|
15613
|
+
);
|
|
15614
|
+
return {
|
|
15615
|
+
exitCode: officerTerminal.roleOutcome.kind === "failure" ? 1 : 0,
|
|
15616
|
+
admitted: officer.admitted,
|
|
15617
|
+
terminal: officerTerminal
|
|
15618
|
+
};
|
|
15619
|
+
}
|
|
15620
|
+
return incompleteAuditWithoutOfficerVolume(
|
|
15621
|
+
turn,
|
|
15622
|
+
admitted,
|
|
15554
15623
|
io,
|
|
15555
|
-
officer.
|
|
15624
|
+
pass?.reason ?? (chain.status === "transport_failure" ? "audit officer transport failure with no presentable volume" : chain.status === "no_receipt" ? "audit officer no_receipt with no presentable volume" : "unreadable audit has no terminal result")
|
|
15556
15625
|
);
|
|
15557
|
-
return { exitCode: 0, admitted: officer.admitted, terminal };
|
|
15558
15626
|
}
|
|
15559
15627
|
if (chain.status === "escalate") {
|
|
15560
15628
|
const escalation = chain.passes.at(-1);
|
|
15561
15629
|
const escalatedRunDirectory = escalation?.runDirectory;
|
|
15562
15630
|
const escalatedRunId = escalation?.runId ?? (escalatedRunDirectory === void 0 ? void 0 : runIdFromRunDirectory(escalatedRunDirectory));
|
|
15563
|
-
if (escalatedRunId === void 0)
|
|
15631
|
+
if (escalatedRunId === void 0) {
|
|
15632
|
+
return incompleteAuditWithoutOfficerVolume(
|
|
15633
|
+
turn,
|
|
15634
|
+
admitted,
|
|
15635
|
+
io,
|
|
15636
|
+
"escalated audit has no resumable run identity"
|
|
15637
|
+
);
|
|
15638
|
+
}
|
|
15564
15639
|
const officer = await loadResumablePublicRole(
|
|
15565
15640
|
env.home,
|
|
15566
15641
|
escalatedRunId,
|
|
@@ -15575,7 +15650,14 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
15575
15650
|
{ ...await readCurrentCourt(officer.admitted.runDirectory), ...packageFaultScope(officer.admitted, env, io) }
|
|
15576
15651
|
);
|
|
15577
15652
|
}
|
|
15578
|
-
if (terminal === void 0)
|
|
15653
|
+
if (terminal === void 0) {
|
|
15654
|
+
return incompleteAuditWithoutOfficerVolume(
|
|
15655
|
+
turn,
|
|
15656
|
+
officer.admitted,
|
|
15657
|
+
io,
|
|
15658
|
+
"escalated audit has no terminal result"
|
|
15659
|
+
);
|
|
15660
|
+
}
|
|
15579
15661
|
await presentTerminal(terminal, { ...io, omitFailureStderrDiagnostic: true }, officer.admitted.runDirectory);
|
|
15580
15662
|
return { exitCode: 0, admitted: officer.admitted, terminal };
|
|
15581
15663
|
}
|
|
@@ -18877,19 +18959,19 @@ async function runAkRole(argv, env) {
|
|
|
18877
18959
|
parts.credentials,
|
|
18878
18960
|
invocationFromParsed(parsed)
|
|
18879
18961
|
);
|
|
18880
|
-
const
|
|
18881
|
-
|
|
18882
|
-
|
|
18883
|
-
|
|
18884
|
-
|
|
18885
|
-
|
|
18886
|
-
|
|
18887
|
-
|
|
18888
|
-
|
|
18889
|
-
|
|
18890
|
-
|
|
18891
|
-
io
|
|
18892
|
-
|
|
18962
|
+
const resumeEnv = createRoleEnvironment(env, {
|
|
18963
|
+
role: seatRole,
|
|
18964
|
+
home,
|
|
18965
|
+
agentDir: parts.agentDir,
|
|
18966
|
+
cwd: parts.cwd,
|
|
18967
|
+
credentials: parts.credentials,
|
|
18968
|
+
seat,
|
|
18969
|
+
config: parts.config
|
|
18970
|
+
});
|
|
18971
|
+
const result = await runPublicInstructionSeatResume(resumeRequest, resumeEnv, io);
|
|
18972
|
+
if (result.admitted?.runId === resumeRequest.runId) {
|
|
18973
|
+
await presentAuditedOriginalOfUnsettledOfficer(result, resumeEnv, io);
|
|
18974
|
+
}
|
|
18893
18975
|
let current = result;
|
|
18894
18976
|
while (current.exitCode === 0 && current.admitted?.correlationId !== void 0 && current.terminal?.roleOutcome.kind === "accepted" && current.terminal.roleOutcome.decisiveFacts?.directionUnsettled !== true && !latestPayloadEscalated(current.terminal.roleOutcome)) {
|
|
18895
18977
|
const parentRunId = current.admitted.correlationId;
|
|
@@ -19513,9 +19595,11 @@ async function projectAuditorTerminal(summoned) {
|
|
|
19513
19595
|
const outcome = summoned.terminal?.roleOutcome;
|
|
19514
19596
|
if (outcome === void 0) {
|
|
19515
19597
|
const detail = summoned.stderr?.trim();
|
|
19516
|
-
|
|
19517
|
-
|
|
19518
|
-
|
|
19598
|
+
return {
|
|
19599
|
+
status: "transport_failure",
|
|
19600
|
+
diagnostic: detail && detail.length > 0 ? `Auditor public summon produced no terminal (exit ${summoned.exitCode}: ${detail})` : `Auditor public summon produced no terminal (exit ${summoned.exitCode})`,
|
|
19601
|
+
...summoned.terminal === void 0 ? {} : { terminal: summoned.terminal }
|
|
19602
|
+
};
|
|
19519
19603
|
}
|
|
19520
19604
|
const usage = await usageFromSummonedSession(summoned);
|
|
19521
19605
|
if (outcome.kind === "no_receipt") {
|
|
@@ -21561,7 +21645,6 @@ init_diarist_contracts();
|
|
|
21561
21645
|
var DIARIST_TOOL_SPEC = roleSubmissionDeclaration("diarist");
|
|
21562
21646
|
|
|
21563
21647
|
// src/secretariat-role.ts
|
|
21564
|
-
init_secretariat_contracts();
|
|
21565
21648
|
init_role_submission_declarations();
|
|
21566
21649
|
init_secretariat_contracts();
|
|
21567
21650
|
init_secretariat_contracts();
|
|
@@ -23162,7 +23245,7 @@ function publicNavigatorSettlement(role, phase, event) {
|
|
|
23162
23245
|
}
|
|
23163
23246
|
return { kind: "accepted", role, phase, ...status === void 0 ? {} : { status } };
|
|
23164
23247
|
}
|
|
23165
|
-
async function projectClosedSubmissionLifecycle(closed, context, phase, recordAccepted, settle) {
|
|
23248
|
+
async function projectClosedSubmissionLifecycle(closed, context, phase, recordAccepted, settle, failRecord) {
|
|
23166
23249
|
recordAccepted();
|
|
23167
23250
|
const closure = {
|
|
23168
23251
|
toolName: navigatorOutputTool(closed.role),
|
|
@@ -23173,10 +23256,14 @@ async function projectClosedSubmissionLifecycle(closed, context, phase, recordAc
|
|
|
23173
23256
|
try {
|
|
23174
23257
|
navigator = await settle(publicNavigatorSettlement(closed.role, phase, closure));
|
|
23175
23258
|
} finally {
|
|
23176
|
-
|
|
23177
|
-
|
|
23178
|
-
|
|
23179
|
-
|
|
23259
|
+
try {
|
|
23260
|
+
context.sessionManager.appendCustomEntry?.("ak-role-submission-closure", {
|
|
23261
|
+
...closure,
|
|
23262
|
+
...navigator === void 0 ? {} : { navigator }
|
|
23263
|
+
});
|
|
23264
|
+
} catch (error) {
|
|
23265
|
+
failRecord(error);
|
|
23266
|
+
}
|
|
23180
23267
|
}
|
|
23181
23268
|
}
|
|
23182
23269
|
function createFiledOfficerRuntime(roleHost, spec, dependencies) {
|
|
@@ -23364,30 +23451,28 @@ function readDiaristRunCoordinates(ctx) {
|
|
|
23364
23451
|
};
|
|
23365
23452
|
}
|
|
23366
23453
|
var DIARIST_BOUNDS_REASK = "\u8FB9\u754C\u65E0\u6CD5\u4F7F\u7528\u3002\u591A\u7968\u8BF7\u9010\u7968\u91CD\u4EA4 ticketSessions\uFF0C\u5355\u7968\u91CD\u4EA4 sessions\uFF1B\u6BCF\u5377 path + ranges\uFF0C\u6BCF\u7AEF\u4EE5\u539F\u751F id \u6216\u672C\u8F6E\u884C\u53F7\u4E8C\u9009\u4E00\u6307\u540D\u3002";
|
|
23367
|
-
function createDiaristRoleRuntime(roleHost, dependencies) {
|
|
23454
|
+
function createDiaristRoleRuntime(roleHost, dependencies, hostActions) {
|
|
23368
23455
|
return createFiledOfficerRuntime(
|
|
23369
23456
|
roleHost,
|
|
23370
23457
|
{
|
|
23371
23458
|
role: "diarist",
|
|
23372
23459
|
tool: DIARIST_TOOL_SPEC,
|
|
23373
23460
|
soulTag: "diarist",
|
|
23374
|
-
beforeAccept: async ({ parameters, ctx }) => {
|
|
23461
|
+
beforeAccept: async ({ toolCallId, parameters, ctx }) => {
|
|
23375
23462
|
const submitted = isRecord(parameters) ? parameters : void 0;
|
|
23376
23463
|
const status = submitted?.status;
|
|
23377
23464
|
if (status !== "completed") return parameters;
|
|
23378
23465
|
const assertion = readDiaristTicketAssertion(submitted);
|
|
23379
23466
|
const ticketNumber = assertion.kind === "ticket" ? assertion.ticketNumber : void 0;
|
|
23380
|
-
if (ticketNumber !== void 0) {
|
|
23381
|
-
await reportTicketFromHostContext(ctx, ticketNumber);
|
|
23382
|
-
}
|
|
23383
|
-
const coords = readDiaristRunCoordinates(ctx);
|
|
23384
|
-
const multiTicket = submitted?.ticketSessions != null;
|
|
23385
|
-
const singleSessions = submitted && !multiTicket ? projectDiaristSessions(parameters) : void 0;
|
|
23386
|
-
const ticketSessions = submitted && multiTicket ? projectDiaristTicketSessions(submitted) : singleSessions === void 0 ? void 0 : [{ ticketNumber: ticketNumber ?? null, sessions: singleSessions }];
|
|
23387
|
-
if (ticketSessions === void 0) {
|
|
23388
|
-
throw new ParentQueueReaskError(DIARIST_BOUNDS_REASK);
|
|
23389
|
-
}
|
|
23390
23467
|
try {
|
|
23468
|
+
if (ticketNumber !== void 0) await reportTicketFromHostContext(ctx, ticketNumber);
|
|
23469
|
+
const coords = readDiaristRunCoordinates(ctx);
|
|
23470
|
+
const multiTicket = submitted?.ticketSessions != null;
|
|
23471
|
+
const singleSessions = submitted && !multiTicket ? projectDiaristSessions(parameters) : void 0;
|
|
23472
|
+
const ticketSessions = submitted && multiTicket ? projectDiaristTicketSessions(submitted) : singleSessions === void 0 ? void 0 : [{ ticketNumber: ticketNumber ?? null, sessions: singleSessions }];
|
|
23473
|
+
if (ticketSessions === void 0) {
|
|
23474
|
+
throw new ParentQueueReaskError(DIARIST_BOUNDS_REASK);
|
|
23475
|
+
}
|
|
23391
23476
|
await commitDiaristProjection({
|
|
23392
23477
|
cwd: coords.projectRoot,
|
|
23393
23478
|
home: coords.home,
|
|
@@ -23402,7 +23487,7 @@ function createDiaristRoleRuntime(roleHost, dependencies) {
|
|
|
23402
23487
|
${error.message}`
|
|
23403
23488
|
);
|
|
23404
23489
|
}
|
|
23405
|
-
|
|
23490
|
+
hostActions.failInfrastructure(error, ctx, toolCallId);
|
|
23406
23491
|
}
|
|
23407
23492
|
return parameters;
|
|
23408
23493
|
}
|
|
@@ -23489,8 +23574,8 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
|
|
|
23489
23574
|
}
|
|
23490
23575
|
return entries;
|
|
23491
23576
|
}, [])),
|
|
23492
|
-
failInfrastructure,
|
|
23493
|
-
async (closed, context) => projectClosedSubmission(closed, context)
|
|
23577
|
+
(error, ctx, toolCallId) => hostActions.failInfrastructure(error, ctx, toolCallId),
|
|
23578
|
+
async (closed, context, toolCallId) => projectClosedSubmission(closed, context, toolCallId)
|
|
23494
23579
|
);
|
|
23495
23580
|
roleHost.registerFlag(ROLE_FLAG.name, ROLE_FLAG.definition);
|
|
23496
23581
|
for (const flag of REVIEWER_TRANSPORT_FLAGS) {
|
|
@@ -23528,7 +23613,6 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
|
|
|
23528
23613
|
let navigatorSessionParent;
|
|
23529
23614
|
let navigatorCwd;
|
|
23530
23615
|
const pendingInfrastructureFailures = /* @__PURE__ */ new Map();
|
|
23531
|
-
const pendingSubmissionNonPassByToolCallId = /* @__PURE__ */ new Map();
|
|
23532
23616
|
let engineDetourRegistered = false;
|
|
23533
23617
|
let receiptDelivery = createReceiptDeliveryPolicy(deliveryLimit);
|
|
23534
23618
|
let noReceiptRecorded = false;
|
|
@@ -23601,13 +23685,14 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
|
|
|
23601
23685
|
await pending;
|
|
23602
23686
|
return pendingNavigatorPresentation?.event;
|
|
23603
23687
|
};
|
|
23604
|
-
projectClosedSubmission = async (closed, context) => {
|
|
23688
|
+
projectClosedSubmission = async (closed, context, toolCallId) => {
|
|
23605
23689
|
await projectClosedSubmissionLifecycle(
|
|
23606
23690
|
closed,
|
|
23607
23691
|
context,
|
|
23608
23692
|
navigatorPhase(roleHost, closed.role),
|
|
23609
23693
|
() => receiptDelivery.recordAccepted(),
|
|
23610
|
-
settleNavigatorProjection
|
|
23694
|
+
settleNavigatorProjection,
|
|
23695
|
+
(error) => hostActions.failInfrastructure(error, context, toolCallId)
|
|
23611
23696
|
);
|
|
23612
23697
|
};
|
|
23613
23698
|
roleHost.on("input", (event, ctx) => {
|
|
@@ -23709,14 +23794,18 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
|
|
|
23709
23794
|
}
|
|
23710
23795
|
}
|
|
23711
23796
|
const settlement = isRoleInfrastructureFailure || outputClassification?.kind === "infrastructure" ? publicNavigatorSettlement(role, navigatorPhase(roleHost, role), classified) : void 0;
|
|
23712
|
-
|
|
23713
|
-
|
|
23714
|
-
|
|
23797
|
+
let projectionFailure;
|
|
23798
|
+
try {
|
|
23799
|
+
await settleNavigatorProjection(settlement);
|
|
23800
|
+
} catch (error) {
|
|
23801
|
+
if (infrastructureDetails === void 0) throw error;
|
|
23802
|
+
projectionFailure = errorText(error);
|
|
23715
23803
|
}
|
|
23716
|
-
|
|
23717
|
-
|
|
23718
|
-
|
|
23719
|
-
|
|
23804
|
+
if (infrastructureDetails !== void 0) {
|
|
23805
|
+
return {
|
|
23806
|
+
isError: true,
|
|
23807
|
+
details: projectionFailure === void 0 ? infrastructureDetails : { ...infrastructureDetails, projectionFailure }
|
|
23808
|
+
};
|
|
23720
23809
|
}
|
|
23721
23810
|
});
|
|
23722
23811
|
roleHost.on("agent_end", async (event, ctx) => {
|
|
@@ -23732,15 +23821,17 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
|
|
|
23732
23821
|
const prose = lastAssistantProse(event.messages);
|
|
23733
23822
|
if (prose !== void 0 && prose.trim() !== "") {
|
|
23734
23823
|
const accepted = { prose };
|
|
23824
|
+
const toolCallId = `navigator-prose-exit:${randomUUID7()}`;
|
|
23735
23825
|
await sealAcceptedSubmission({
|
|
23736
23826
|
context: ctx,
|
|
23737
23827
|
role: "navigator",
|
|
23738
23828
|
accepted,
|
|
23739
|
-
toolCallId
|
|
23829
|
+
toolCallId
|
|
23740
23830
|
});
|
|
23741
23831
|
await projectClosedSubmission(
|
|
23742
23832
|
{ role: "navigator", kind: "accepted", accepted },
|
|
23743
|
-
ctx
|
|
23833
|
+
ctx,
|
|
23834
|
+
toolCallId
|
|
23744
23835
|
);
|
|
23745
23836
|
return;
|
|
23746
23837
|
}
|
|
@@ -23842,7 +23933,6 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
|
|
|
23842
23933
|
pendingNavigatorSettlement = void 0;
|
|
23843
23934
|
disposeNavigatorAttendanceNonBlocking(attendanceToDispose);
|
|
23844
23935
|
pendingInfrastructureFailures.clear();
|
|
23845
|
-
pendingSubmissionNonPassByToolCallId.clear();
|
|
23846
23936
|
}
|
|
23847
23937
|
});
|
|
23848
23938
|
const hostActions = {
|
|
@@ -23851,9 +23941,6 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
|
|
|
23851
23941
|
pendingInfrastructureFailures.set(toolCallId, buildPendingInfrastructureFailure(error));
|
|
23852
23942
|
}
|
|
23853
23943
|
failInfrastructure(error, ctx);
|
|
23854
|
-
},
|
|
23855
|
-
bindSubmissionNonPass(toolCallId, result) {
|
|
23856
|
-
pendingSubmissionNonPassByToolCallId.set(toolCallId, result);
|
|
23857
23944
|
}
|
|
23858
23945
|
};
|
|
23859
23946
|
const requireRoleSoul = (role) => dependencies.loadRoleSoul(role);
|
|
@@ -23933,7 +24020,8 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
|
|
|
23933
24020
|
roleHost,
|
|
23934
24021
|
{
|
|
23935
24022
|
loadSoul: () => requireRoleSoul("diarist")
|
|
23936
|
-
}
|
|
24023
|
+
},
|
|
24024
|
+
hostActions
|
|
23937
24025
|
);
|
|
23938
24026
|
const secretariat = createSecretariatRoleRuntime(roleHost, {
|
|
23939
24027
|
loadSoul: () => requireRoleSoul("secretariat")
|
|
@@ -24031,7 +24119,6 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
|
|
|
24031
24119
|
navigatorDeliveryClosed = false;
|
|
24032
24120
|
pendingNavigatorSettlement = void 0;
|
|
24033
24121
|
pendingInfrastructureFailures.clear();
|
|
24034
|
-
pendingSubmissionNonPassByToolCallId.clear();
|
|
24035
24122
|
navigatorWorkContext = void 0;
|
|
24036
24123
|
envelopeHost.startKeepalive(ctx);
|
|
24037
24124
|
const rawRole = roleHost.getFlag(ROLE_FLAG.name);
|
|
@@ -24147,7 +24234,7 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
|
|
|
24147
24234
|
}
|
|
24148
24235
|
}
|
|
24149
24236
|
await executeActivationStage(entry.role, activationStage(entry.role, activateByRole), { clock, writeTrace });
|
|
24150
|
-
registerReportTicketTool(roleHost);
|
|
24237
|
+
registerReportTicketTool(roleHost, hostActions);
|
|
24151
24238
|
roleHost.setActiveTools([
|
|
24152
24239
|
.../* @__PURE__ */ new Set([...roleHost.getActiveTools(), REPORT_TICKET_TOOL_NAME])
|
|
24153
24240
|
]);
|
|
@@ -24397,19 +24484,6 @@ async function prepareRoleEnvelope(options) {
|
|
|
24397
24484
|
)(envelope);
|
|
24398
24485
|
const token = randomUUID9();
|
|
24399
24486
|
const server = createServer((socket) => serveSocket(socket));
|
|
24400
|
-
function rememberProjectedRejection(details, toolCallId, content) {
|
|
24401
|
-
if (typeof details !== "object" || details === null) return;
|
|
24402
|
-
const record = details;
|
|
24403
|
-
if (record.cause === "infrastructure") return;
|
|
24404
|
-
if (record.kind === "role_infrastructure_failure") return;
|
|
24405
|
-
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;
|
|
24406
|
-
if (code === void 0) return;
|
|
24407
|
-
rejection = {
|
|
24408
|
-
code,
|
|
24409
|
-
toolCallIds: [toolCallId],
|
|
24410
|
-
message: textDiagnostic(content) ?? code
|
|
24411
|
-
};
|
|
24412
|
-
}
|
|
24413
24487
|
function textDiagnostic(content) {
|
|
24414
24488
|
const text = content.filter((part) => part.type === "text").map((part) => part.text).join("\n\n");
|
|
24415
24489
|
return text.trim().length > 0 ? text : void 0;
|
|
@@ -24480,7 +24554,6 @@ async function prepareRoleEnvelope(options) {
|
|
|
24480
24554
|
sessionEntries.push(toolResultEntry);
|
|
24481
24555
|
if (projected.isError) {
|
|
24482
24556
|
rememberInfrastructureFailure(projected.details, projected.content);
|
|
24483
|
-
rememberProjectedRejection(projected.details, toolCallId, projected.content);
|
|
24484
24557
|
}
|
|
24485
24558
|
await emit("tool_execution_end", { toolCallId, toolName, isError: projected.isError });
|
|
24486
24559
|
return projected;
|
|
@@ -24539,18 +24612,31 @@ async function prepareRoleEnvelope(options) {
|
|
|
24539
24612
|
} catch (error) {
|
|
24540
24613
|
let content;
|
|
24541
24614
|
let details;
|
|
24542
|
-
|
|
24543
|
-
|
|
24544
|
-
content = [{ type: "text", text:
|
|
24545
|
-
details =
|
|
24615
|
+
const correctable = isCorrectableExecuteError(error) ? projectCorrectableExecuteRejection(error) : void 0;
|
|
24616
|
+
if (correctable !== void 0) {
|
|
24617
|
+
content = [{ type: "text", text: correctable.diagnostic }];
|
|
24618
|
+
details = correctable.details;
|
|
24546
24619
|
} else {
|
|
24547
|
-
|
|
24620
|
+
const diagnostic = errorText(error);
|
|
24621
|
+
content = [{ type: "text", text: diagnostic }];
|
|
24622
|
+
details = {
|
|
24623
|
+
code: typeof error?.code === "string" ? error.code : "ak-tool-execution-failed",
|
|
24624
|
+
error: serializeThrownValue(error)
|
|
24625
|
+
};
|
|
24548
24626
|
}
|
|
24549
24627
|
const projected = await projectToolResult(toolCallId, name, {
|
|
24550
24628
|
content,
|
|
24551
24629
|
details,
|
|
24552
24630
|
isError: true
|
|
24553
24631
|
});
|
|
24632
|
+
if (correctable !== void 0) {
|
|
24633
|
+
const code = typeof correctable.details.code === "string" && correctable.details.code.length > 0 ? correctable.details.code : "correctable-submission-error";
|
|
24634
|
+
rejection = {
|
|
24635
|
+
code,
|
|
24636
|
+
toolCallIds: [toolCallId],
|
|
24637
|
+
message: textDiagnostic(projected.content) ?? correctable.diagnostic
|
|
24638
|
+
};
|
|
24639
|
+
}
|
|
24554
24640
|
return { content: projected.content, isError: projected.isError };
|
|
24555
24641
|
}
|
|
24556
24642
|
}
|