@akagilnc/pi-workflow-roles 0.1.5663 → 0.1.5673
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 +183 -106
- package/dist/headless-host/production-host.js +204 -127
- package/dist/migrate-book-topology.js +11 -10
- package/dist/navigator-attendance.js +61 -78
- package/dist/navigator-public-session.js +17 -12
- package/dist/package-contracts/navigator-output.js +101 -15
- package/dist/pi/role-turn-host.js +3 -1
- package/dist/public-cli/main.js +21 -11
- package/dist/public-cli/post-admission.js +9 -0
- package/dist/public-cli/turn-request.js +3 -0
- package/dist/public-role-summons.js +1 -0
- package/package.json +1 -1
- package/resources/navigator-route-playbook.md +3 -3
- package/src/headless-host/description.ts +2 -1
- package/src/headless-host/role-turn-host.ts +18 -15
- package/src/host-contracts.ts +6 -0
- package/src/navigator-attendance.ts +149 -171
- package/src/navigator-public-session.ts +23 -16
- package/src/navigator-session-contracts.ts +0 -1
- package/src/package-contracts/navigator-output.ts +146 -20
- package/src/pi/role-turn-host.ts +3 -1
- package/src/public-cli/post-admission.ts +11 -0
- package/src/public-cli/turn-request.ts +5 -0
- package/src/public-role-summons.ts +8 -0
- package/src/role-runtime.ts +3 -2
|
@@ -1466,27 +1466,61 @@ var init_gatekeeper_output = __esm({
|
|
|
1466
1466
|
var navigator_output_exports = {};
|
|
1467
1467
|
__export(navigator_output_exports, {
|
|
1468
1468
|
NAVIGATOR_OUTPUT_TOOL_NAME: () => NAVIGATOR_OUTPUT_TOOL_NAME,
|
|
1469
|
+
byStatusToPlainObject: () => byStatusToPlainObject,
|
|
1470
|
+
mergePreparedAdvice: () => mergePreparedAdvice,
|
|
1471
|
+
navigatorAdviceBodySchema: () => navigatorAdviceBodySchema,
|
|
1472
|
+
navigatorAdviceFields: () => navigatorAdviceFields,
|
|
1469
1473
|
navigatorOutputSchema: () => navigatorOutputSchema,
|
|
1470
1474
|
navigatorProseFromUnknown: () => navigatorProseFromUnknown,
|
|
1475
|
+
pickPreparedProse: () => pickPreparedProse,
|
|
1476
|
+
preparedAdviceFromUnknown: () => preparedAdviceFromUnknown,
|
|
1471
1477
|
projectLawfulNavigatorOutput: () => projectLawfulNavigatorOutput,
|
|
1472
1478
|
validateRecordedNavigatorOutput: () => validateRecordedNavigatorOutput
|
|
1473
1479
|
});
|
|
1474
1480
|
import { Type as Type4 } from "typebox";
|
|
1481
|
+
function nonEmptyProse(value) {
|
|
1482
|
+
if (typeof value === "string") {
|
|
1483
|
+
return value.trim() === "" ? void 0 : value;
|
|
1484
|
+
}
|
|
1485
|
+
if (value === void 0 || value === null) return void 0;
|
|
1486
|
+
if (typeof value === "object") {
|
|
1487
|
+
const text2 = JSON.stringify(value);
|
|
1488
|
+
if (text2 === void 0 || text2.trim() === "" || text2 === "{}" || text2 === "[]") return void 0;
|
|
1489
|
+
return text2;
|
|
1490
|
+
}
|
|
1491
|
+
const text = String(value);
|
|
1492
|
+
return text.trim() === "" ? void 0 : text;
|
|
1493
|
+
}
|
|
1494
|
+
function setStatusProse(target, key, prose) {
|
|
1495
|
+
const prior = target.get(key);
|
|
1496
|
+
target.set(key, prior === void 0 ? prose : `${prior}
|
|
1497
|
+
|
|
1498
|
+
${prose}`);
|
|
1499
|
+
}
|
|
1500
|
+
function byStatusFromUnknown(value) {
|
|
1501
|
+
const out = /* @__PURE__ */ new Map();
|
|
1502
|
+
if (!isRecord(value)) return out;
|
|
1503
|
+
for (const [key, raw] of Object.entries(value)) {
|
|
1504
|
+
const prose = nonEmptyProse(raw);
|
|
1505
|
+
if (prose !== void 0) out.set(key, prose);
|
|
1506
|
+
}
|
|
1507
|
+
return out;
|
|
1508
|
+
}
|
|
1509
|
+
function byStatusToPlainObject(byStatus) {
|
|
1510
|
+
return Object.fromEntries(byStatus);
|
|
1511
|
+
}
|
|
1475
1512
|
function projectLawfulNavigatorOutput(value) {
|
|
1476
1513
|
if (value === void 0 || value === null) return void 0;
|
|
1477
1514
|
if (typeof value === "string") return { prose: value };
|
|
1478
1515
|
if (isRecord(value)) {
|
|
1479
1516
|
if (typeof value.prose === "string") return { prose: value.prose };
|
|
1480
1517
|
if (value.prose !== void 0 && value.prose !== null) {
|
|
1481
|
-
|
|
1518
|
+
const serialized = nonEmptyProse(value.prose);
|
|
1519
|
+
if (serialized !== void 0) return { prose: serialized };
|
|
1482
1520
|
}
|
|
1483
1521
|
const keys = Object.keys(value);
|
|
1484
1522
|
if (keys.length === 0) return { prose: "" };
|
|
1485
|
-
|
|
1486
|
-
return { prose: JSON.stringify(value) };
|
|
1487
|
-
} catch {
|
|
1488
|
-
return { prose: String(value) };
|
|
1489
|
-
}
|
|
1523
|
+
return { prose: JSON.stringify(value) };
|
|
1490
1524
|
}
|
|
1491
1525
|
return { prose: String(value) };
|
|
1492
1526
|
}
|
|
@@ -1503,7 +1537,58 @@ function navigatorProseFromUnknown(value) {
|
|
|
1503
1537
|
const trimmed = projected.prose.trim();
|
|
1504
1538
|
return trimmed === "" ? void 0 : projected.prose;
|
|
1505
1539
|
}
|
|
1506
|
-
|
|
1540
|
+
function preparedAdviceFromUnknown(value) {
|
|
1541
|
+
if (value === void 0 || value === null) return void 0;
|
|
1542
|
+
if (typeof value === "string") {
|
|
1543
|
+
const prose2 = nonEmptyProse(value);
|
|
1544
|
+
return prose2 === void 0 ? void 0 : { byStatus: /* @__PURE__ */ new Map(), prose: prose2 };
|
|
1545
|
+
}
|
|
1546
|
+
if (!isRecord(value)) {
|
|
1547
|
+
const prose2 = nonEmptyProse(value);
|
|
1548
|
+
return prose2 === void 0 ? void 0 : { byStatus: /* @__PURE__ */ new Map(), prose: prose2 };
|
|
1549
|
+
}
|
|
1550
|
+
const byStatus = byStatusFromUnknown(value.byStatus);
|
|
1551
|
+
const hasProseField = Object.prototype.hasOwnProperty.call(value, "prose");
|
|
1552
|
+
const hasByStatusField = Object.prototype.hasOwnProperty.call(value, "byStatus");
|
|
1553
|
+
const prose = nonEmptyProse(value.prose);
|
|
1554
|
+
if (byStatus.size === 0 && prose === void 0) {
|
|
1555
|
+
if (hasProseField || hasByStatusField) return void 0;
|
|
1556
|
+
const keys = Object.keys(value);
|
|
1557
|
+
if (keys.length === 0) return void 0;
|
|
1558
|
+
const text = JSON.stringify(value);
|
|
1559
|
+
return text.trim() === "" || text === "{}" ? void 0 : { byStatus: /* @__PURE__ */ new Map(), prose: text };
|
|
1560
|
+
}
|
|
1561
|
+
return {
|
|
1562
|
+
byStatus,
|
|
1563
|
+
...prose === void 0 ? {} : { prose }
|
|
1564
|
+
};
|
|
1565
|
+
}
|
|
1566
|
+
function mergePreparedAdvice(prior, next) {
|
|
1567
|
+
if (prior === void 0) return next;
|
|
1568
|
+
if (next === void 0) return prior;
|
|
1569
|
+
const byStatus = new Map(prior.byStatus);
|
|
1570
|
+
for (const [key, prose2] of next.byStatus) {
|
|
1571
|
+
setStatusProse(byStatus, key, prose2);
|
|
1572
|
+
}
|
|
1573
|
+
const proseParts = [prior.prose, next.prose].filter((part) => typeof part === "string" && part.trim() !== "");
|
|
1574
|
+
const prose = proseParts.length === 0 ? void 0 : proseParts.join("\n\n");
|
|
1575
|
+
if (byStatus.size === 0 && prose === void 0) return void 0;
|
|
1576
|
+
return {
|
|
1577
|
+
byStatus,
|
|
1578
|
+
...prose === void 0 ? {} : { prose }
|
|
1579
|
+
};
|
|
1580
|
+
}
|
|
1581
|
+
function pickPreparedProse(prepared, status) {
|
|
1582
|
+
if (prepared === void 0) return void 0;
|
|
1583
|
+
if (prepared.byStatus.size > 0) {
|
|
1584
|
+
if (status === void 0) return void 0;
|
|
1585
|
+
const hit = prepared.byStatus.get(status);
|
|
1586
|
+
return typeof hit === "string" && hit.trim() !== "" ? hit : void 0;
|
|
1587
|
+
}
|
|
1588
|
+
const prose = prepared.prose;
|
|
1589
|
+
return typeof prose === "string" && prose.trim() !== "" ? prose : void 0;
|
|
1590
|
+
}
|
|
1591
|
+
var NAVIGATOR_OUTPUT_TOOL_NAME, navigatorAdviceFields, navigatorAdviceBodySchema, navigatorOutputSchema;
|
|
1507
1592
|
var init_navigator_output = __esm({
|
|
1508
1593
|
"src/package-contracts/navigator-output.ts"() {
|
|
1509
1594
|
"use strict";
|
|
@@ -1511,15 +1596,16 @@ var init_navigator_output = __esm({
|
|
|
1511
1596
|
init_open_tool_schema();
|
|
1512
1597
|
init_terminating_infrastructure();
|
|
1513
1598
|
NAVIGATOR_OUTPUT_TOOL_NAME = "ak_navigator_output";
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
);
|
|
1599
|
+
navigatorAdviceFields = {
|
|
1600
|
+
prose: Type4.Unknown({
|
|
1601
|
+
description: "\u5355\u6761\u6563\u6587\u5EFA\u8BAE\u3002\u65E0\u72B6\u6001\u5206\u53C9\u65F6\u4F7F\u7528\uFF1B\u539F\u6837\u5448\u73B0\u3002"
|
|
1602
|
+
}),
|
|
1603
|
+
byStatus: Type4.Unknown({
|
|
1604
|
+
description: "\u6309\u4E3B\u8859\u95E8\u7ED3\u5C40 status \u9884\u5199\u7684\u6563\u6587\u5EFA\u8BAE\u3002\u952E\u4E3A status \u5B57\u9762\u91CF\uFF0C\u503C\u4E3A\u5EFA\u8BAE\u6B63\u6587\u3002\u7ED3\u7B97\u65F6\u4EE3\u7801\u53EA\u6309\u5B9E\u9645 status \u53D6\u5BF9\u5E94\u539F\u6587\uFF0C\u4E0D\u89E3\u6790\u5EFA\u8BAE\u8BED\u4E49\u3002"
|
|
1605
|
+
})
|
|
1606
|
+
};
|
|
1607
|
+
navigatorAdviceBodySchema = openToolObject(Type4.Object(navigatorAdviceFields));
|
|
1608
|
+
navigatorOutputSchema = withTerminatingOutputDeclarations(navigatorAdviceBodySchema);
|
|
1523
1609
|
}
|
|
1524
1610
|
});
|
|
1525
1611
|
|
|
@@ -9972,8 +10058,10 @@ function buildPiTurnExtraArgs(request, authority, extraPiArgs = []) {
|
|
|
9972
10058
|
// Envelope assembly = projectActivationFlags; pi only renders argv pairs.
|
|
9973
10059
|
...activationFlagsToPiArgv(projectActivationFlags(request)),
|
|
9974
10060
|
...piEngineModelArgs(request),
|
|
10061
|
+
// #1182: text single-shot keeps pi's native assistant error/aborted
|
|
10062
|
+
// exit (stderr + exit 1). json mode never takes that failure branch.
|
|
9975
10063
|
"--mode",
|
|
9976
|
-
"
|
|
10064
|
+
"text",
|
|
9977
10065
|
...buildSeatModelCliArgs(request.model)
|
|
9978
10066
|
];
|
|
9979
10067
|
}
|
|
@@ -12116,6 +12204,7 @@ function projectRoleTurnRequest(admitted, roleDetails, options) {
|
|
|
12116
12204
|
...options.courtAttemptId === void 0 || options.courtAttemptId.length === 0 ? {} : { courtAttemptId: options.courtAttemptId },
|
|
12117
12205
|
...options.invocationScopeId === void 0 || options.invocationScopeId.length === 0 ? {} : { invocationScopeId: options.invocationScopeId },
|
|
12118
12206
|
...options.stationChild === void 0 ? {} : { stationChild: options.stationChild },
|
|
12207
|
+
...options.navigatorByStatusPrepare === void 0 ? {} : { navigatorByStatusPrepare: options.navigatorByStatusPrepare },
|
|
12119
12208
|
...options.deliveryRequestLimit === void 0 ? {} : { deliveryRequestLimit: options.deliveryRequestLimit }
|
|
12120
12209
|
};
|
|
12121
12210
|
}
|
|
@@ -13091,6 +13180,9 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
13091
13180
|
if (env.stationChild !== void 0) {
|
|
13092
13181
|
turnRequest = { ...turnRequest, stationChild: env.stationChild };
|
|
13093
13182
|
}
|
|
13183
|
+
if (env.navigatorByStatusPrepare === true) {
|
|
13184
|
+
turnRequest = { ...turnRequest, navigatorByStatusPrepare: true };
|
|
13185
|
+
}
|
|
13094
13186
|
if (typeof env.host === "string" && env.host.trim() !== "") {
|
|
13095
13187
|
turnRequest = { ...turnRequest, host: env.host.trim() };
|
|
13096
13188
|
}
|
|
@@ -13349,6 +13441,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
13349
13441
|
prompt
|
|
13350
13442
|
},
|
|
13351
13443
|
...env.stationChild === void 0 ? {} : { stationChild: env.stationChild },
|
|
13444
|
+
...env.navigatorByStatusPrepare === true ? { navigatorByStatusPrepare: true } : {},
|
|
13352
13445
|
// #1132: one configured ceiling, already resolved by the caller (#422).
|
|
13353
13446
|
deliveryRequestLimit: deliveryLimitFromConfig(env.autoResumeLimit)
|
|
13354
13447
|
};
|
|
@@ -13361,6 +13454,7 @@ function roleTurnOptions(env, admitted, continuation) {
|
|
|
13361
13454
|
...correlationId === void 0 || correlationId.trim() === "" ? {} : { correlationId },
|
|
13362
13455
|
continuation,
|
|
13363
13456
|
...env.stationChild === void 0 ? {} : { stationChild: env.stationChild },
|
|
13457
|
+
...env.navigatorByStatusPrepare === true ? { navigatorByStatusPrepare: true } : {},
|
|
13364
13458
|
// #1132: one configured ceiling, already resolved by the caller (#422).
|
|
13365
13459
|
deliveryRequestLimit: deliveryLimitFromConfig(env.autoResumeLimit)
|
|
13366
13460
|
};
|
|
@@ -18595,6 +18689,7 @@ async function summonPublicRole(options) {
|
|
|
18595
18689
|
// Nested court stations keep station-child semantics; dual-lens
|
|
18596
18690
|
// ordinary Reviewer axes opt out (#946 / ADR 0082).
|
|
18597
18691
|
...options.stationChild === false ? {} : { stationChild: true },
|
|
18692
|
+
...options.navigatorByStatusPrepare === true ? { navigatorByStatusPrepare: true } : {},
|
|
18598
18693
|
// Forward composition-root adapters so nested stations (e.g.
|
|
18599
18694
|
// secretariat → diarist) select the same faux/production table (#924).
|
|
18600
18695
|
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
@@ -21097,7 +21192,7 @@ init_navigator_invocation_identity();
|
|
|
21097
21192
|
init_packaged_role_registry();
|
|
21098
21193
|
init_activation_ledger_topology();
|
|
21099
21194
|
import { resolve as resolve15 } from "node:path";
|
|
21100
|
-
import
|
|
21195
|
+
import "typebox";
|
|
21101
21196
|
|
|
21102
21197
|
// src/navigator-public-session.ts
|
|
21103
21198
|
init_host_session_record();
|
|
@@ -21322,7 +21417,6 @@ async function navigatorHostRunResumable(home, runId) {
|
|
|
21322
21417
|
}
|
|
21323
21418
|
function createNativeNavigatorSessionFactory(deps) {
|
|
21324
21419
|
return async ({ context, tool }) => {
|
|
21325
|
-
let thinkingLevel;
|
|
21326
21420
|
const entries = [];
|
|
21327
21421
|
let providerFailure;
|
|
21328
21422
|
let noReceipt;
|
|
@@ -21350,6 +21444,9 @@ function createNativeNavigatorSessionFactory(deps) {
|
|
|
21350
21444
|
role: "navigator",
|
|
21351
21445
|
argv: [text],
|
|
21352
21446
|
cwd: context.cwd,
|
|
21447
|
+
// Attendance prepare always asks for structured byStatus (#1160).
|
|
21448
|
+
// Direct `ak-role navigator` never sets this flag.
|
|
21449
|
+
navigatorByStatusPrepare: true,
|
|
21353
21450
|
...summonHome === void 0 ? {} : { home: summonHome },
|
|
21354
21451
|
...context.signal === void 0 ? {} : { signal: context.signal }
|
|
21355
21452
|
};
|
|
@@ -21408,17 +21505,23 @@ function createNativeNavigatorSessionFactory(deps) {
|
|
|
21408
21505
|
if (outcome.kind !== "accepted") {
|
|
21409
21506
|
return;
|
|
21410
21507
|
}
|
|
21411
|
-
const {
|
|
21412
|
-
|
|
21508
|
+
const {
|
|
21509
|
+
byStatusToPlainObject: byStatusToPlainObject2,
|
|
21510
|
+
mergePreparedAdvice: mergePreparedAdvice2,
|
|
21511
|
+
preparedAdviceFromUnknown: preparedAdviceFromUnknown2
|
|
21512
|
+
} = await Promise.resolve().then(() => (init_navigator_output(), navigator_output_exports));
|
|
21513
|
+
let prepared = void 0;
|
|
21413
21514
|
for (const payload of outcome.payloads ?? []) {
|
|
21414
|
-
|
|
21415
|
-
if (prose !== void 0) proseParts.push(prose);
|
|
21515
|
+
prepared = mergePreparedAdvice2(prepared, preparedAdviceFromUnknown2(payload));
|
|
21416
21516
|
}
|
|
21417
|
-
if (
|
|
21517
|
+
if (prepared === void 0) return;
|
|
21418
21518
|
if (disposed) return;
|
|
21419
21519
|
await tool.execute(
|
|
21420
21520
|
"navigator-public-prepare",
|
|
21421
|
-
{
|
|
21521
|
+
{
|
|
21522
|
+
...prepared.prose === void 0 ? {} : { prose: prepared.prose },
|
|
21523
|
+
...prepared.byStatus.size === 0 ? {} : { byStatus: byStatusToPlainObject2(prepared.byStatus) }
|
|
21524
|
+
},
|
|
21422
21525
|
void 0,
|
|
21423
21526
|
void 0,
|
|
21424
21527
|
context
|
|
@@ -21447,16 +21550,13 @@ function createNativeNavigatorSessionFactory(deps) {
|
|
|
21447
21550
|
});
|
|
21448
21551
|
},
|
|
21449
21552
|
entries: () => entries,
|
|
21450
|
-
setModel: async (next
|
|
21451
|
-
let nextParsed;
|
|
21553
|
+
setModel: async (next) => {
|
|
21452
21554
|
try {
|
|
21453
|
-
|
|
21555
|
+
parseNavigatorModelSetting(next);
|
|
21454
21556
|
} catch (error) {
|
|
21455
21557
|
throw navigatorUnavailableError("model", error);
|
|
21456
21558
|
}
|
|
21457
|
-
thinkingLevel = nextThinking ?? nextParsed.thinkingLevel;
|
|
21458
21559
|
},
|
|
21459
|
-
getThinkingLevel: () => thinkingLevel,
|
|
21460
21560
|
dispose: async () => {
|
|
21461
21561
|
disposed = true;
|
|
21462
21562
|
}
|
|
@@ -21478,11 +21578,7 @@ function resolveNavigatorAuthorityMaterial(roleInput, fileAuthority) {
|
|
|
21478
21578
|
return void 0;
|
|
21479
21579
|
}
|
|
21480
21580
|
var NAVIGATOR_TARGETS = PACKAGED_ROLE_REGISTRY.map(({ role, phases }) => ({ role, phases }));
|
|
21481
|
-
var prepareSchema =
|
|
21482
|
-
prose: Type20.Optional(Type20.Unknown({
|
|
21483
|
-
description: "\u6E38\u5955\u4F7F\u6563\u6587\u5EFA\u8BAE\uFF0C\u539F\u6837\u5448\u73B0\u3002\u4E0D\u8981\u6C42 candidates/next \u7ED3\u6784\u3002"
|
|
21484
|
-
}))
|
|
21485
|
-
}, { additionalProperties: true });
|
|
21581
|
+
var prepareSchema = navigatorAdviceBodySchema;
|
|
21486
21582
|
var INVOCATION_ENTRY = NAVIGATOR_INVOCATION_ENTRY;
|
|
21487
21583
|
var SETTLEMENT_ENTRY = "ak-navigator-settlement";
|
|
21488
21584
|
function rejectedPrepareReason(entries, start) {
|
|
@@ -21507,8 +21603,8 @@ function rejectedPrepareReason(entries, start) {
|
|
|
21507
21603
|
}
|
|
21508
21604
|
return reason;
|
|
21509
21605
|
}
|
|
21510
|
-
function
|
|
21511
|
-
return
|
|
21606
|
+
function normalizePreparedAdvice(value) {
|
|
21607
|
+
return preparedAdviceFromUnknown(value);
|
|
21512
21608
|
}
|
|
21513
21609
|
function navigatorSubjectKey(subjectRoot, subject, provenance = "role_input") {
|
|
21514
21610
|
if (issueRoot(subjectRoot) !== void 0 || !subjectRoot.includes("/.ak/work/")) return subjectRoot;
|
|
@@ -21558,7 +21654,7 @@ function createNavigatorAttendance(options) {
|
|
|
21558
21654
|
let subject = options.subject;
|
|
21559
21655
|
let authority = options.authority;
|
|
21560
21656
|
let contextError = options.contextError;
|
|
21561
|
-
let
|
|
21657
|
+
let preparedAdvice;
|
|
21562
21658
|
const invocationPrincipal = options.invocationId ?? mintNavigatorInvocationId();
|
|
21563
21659
|
let activeInvocationId = invocationPrincipal;
|
|
21564
21660
|
let outputSink;
|
|
@@ -21583,7 +21679,6 @@ function createNavigatorAttendance(options) {
|
|
|
21583
21679
|
unavailableCause: failure.unavailableCause
|
|
21584
21680
|
};
|
|
21585
21681
|
};
|
|
21586
|
-
let prepareBoundSettlement;
|
|
21587
21682
|
const loadMaterialsAndSession = async (invocationId) => {
|
|
21588
21683
|
if (contextError !== void 0) throw navigatorUnavailableError("context", contextError);
|
|
21589
21684
|
if (typeof authority !== "string" || authority.trim() === "") {
|
|
@@ -21654,29 +21749,32 @@ function createNavigatorAttendance(options) {
|
|
|
21654
21749
|
if (session === void 0) throw new Error("Navigator session was not created");
|
|
21655
21750
|
return session;
|
|
21656
21751
|
};
|
|
21657
|
-
const prepare = async (
|
|
21658
|
-
const boundSettlement = prepareBoundSettlement;
|
|
21659
|
-
prepareBoundSettlement = void 0;
|
|
21752
|
+
const prepare = async () => {
|
|
21660
21753
|
const invocationId = invocationPrincipal;
|
|
21661
21754
|
activeInvocationId = invocationId;
|
|
21662
21755
|
let output;
|
|
21663
21756
|
let prepareBatchRejected = false;
|
|
21664
21757
|
outputSink = (value) => {
|
|
21758
|
+
const next = normalizePreparedAdvice(value);
|
|
21665
21759
|
if (output === void 0) {
|
|
21666
21760
|
output = value;
|
|
21667
21761
|
return;
|
|
21668
21762
|
}
|
|
21669
|
-
const
|
|
21670
|
-
|
|
21671
|
-
|
|
21672
|
-
|
|
21763
|
+
const merged = mergePreparedAdvice(normalizePreparedAdvice(output), next);
|
|
21764
|
+
output = {
|
|
21765
|
+
...merged?.prose === void 0 ? {} : { prose: merged.prose },
|
|
21766
|
+
...merged === void 0 || merged.byStatus.size === 0 ? {} : { byStatus: byStatusToPlainObject(merged.byStatus) }
|
|
21767
|
+
};
|
|
21673
21768
|
};
|
|
21674
|
-
const activeSession =
|
|
21675
|
-
if (boundSettlement === void 0) return void 0;
|
|
21769
|
+
const activeSession = await loadMaterialsAndSession(invocationId);
|
|
21676
21770
|
const request = JSON.stringify({
|
|
21677
|
-
|
|
21771
|
+
kind: "prepare",
|
|
21772
|
+
role: options.role,
|
|
21773
|
+
phase: options.phase,
|
|
21678
21774
|
invocationId,
|
|
21679
|
-
subjectKey
|
|
21775
|
+
subjectKey,
|
|
21776
|
+
subject,
|
|
21777
|
+
authority
|
|
21680
21778
|
});
|
|
21681
21779
|
try {
|
|
21682
21780
|
try {
|
|
@@ -21710,27 +21808,21 @@ function createNavigatorAttendance(options) {
|
|
|
21710
21808
|
}
|
|
21711
21809
|
};
|
|
21712
21810
|
await promptAllowingRejectedPrepare(request);
|
|
21713
|
-
|
|
21714
|
-
|
|
21715
|
-
|
|
21716
|
-
|
|
21717
|
-
|
|
21718
|
-
|
|
21719
|
-
|
|
21720
|
-
|
|
21721
|
-
|
|
21722
|
-
|
|
21723
|
-
return void 0;
|
|
21724
|
-
}
|
|
21811
|
+
while (output === void 0 && prepareBatchRejected && delivery.nextAction() === "request-delivery") {
|
|
21812
|
+
delivery.recordDeliveryRequest();
|
|
21813
|
+
await promptAllowingRejectedPrepare(JSON.stringify(delivery.deliveryState()));
|
|
21814
|
+
}
|
|
21815
|
+
if (output === void 0 && delivery.nextAction() === "request-delivery") {
|
|
21816
|
+
delivery.closeBudget();
|
|
21817
|
+
}
|
|
21818
|
+
if (output === void 0 && delivery.nextAction() === "no-receipt" && activeSession.providerFailure?.() === void 0) {
|
|
21819
|
+
preparedAdvice = void 0;
|
|
21820
|
+
return void 0;
|
|
21725
21821
|
}
|
|
21726
21822
|
} catch (error) {
|
|
21727
21823
|
throw error instanceof NavigatorUnavailableError ? error : navigatorUnavailableError("transport", error);
|
|
21728
21824
|
}
|
|
21729
21825
|
if (output === void 0) {
|
|
21730
|
-
if (boundSettlement === void 0) {
|
|
21731
|
-
preparedProse = void 0;
|
|
21732
|
-
return void 0;
|
|
21733
|
-
}
|
|
21734
21826
|
const nativeFailure = [...activeSession.entries()].reverse().find((entry) => {
|
|
21735
21827
|
if (!isRecord(entry) || entry.type !== "message" || !isRecord(entry.message)) return false;
|
|
21736
21828
|
return entry.message.role === "assistant" && typeof entry.message.errorMessage === "string" && entry.message.errorMessage.trim() !== "";
|
|
@@ -21742,12 +21834,8 @@ function createNavigatorAttendance(options) {
|
|
|
21742
21834
|
const cause = providerFailure?.cause ?? source;
|
|
21743
21835
|
throw navigatorUnavailableError(source, errorMessage, cause);
|
|
21744
21836
|
}
|
|
21745
|
-
|
|
21746
|
-
|
|
21747
|
-
return void 0;
|
|
21748
|
-
}
|
|
21749
|
-
preparedProse = normalizePrepareProse(output);
|
|
21750
|
-
return preparedProse;
|
|
21837
|
+
preparedAdvice = normalizePreparedAdvice(output);
|
|
21838
|
+
return preparedAdvice;
|
|
21751
21839
|
} finally {
|
|
21752
21840
|
const playbookFailure = activeSession.routePlaybookReadFailure?.();
|
|
21753
21841
|
observedRoutePlaybookFailure = typeof playbookFailure === "string" && playbookFailure.trim() !== "" ? playbookFailure : void 0;
|
|
@@ -21771,6 +21859,7 @@ function createNavigatorAttendance(options) {
|
|
|
21771
21859
|
prepare() {
|
|
21772
21860
|
if (disposed || preparation !== void 0) return;
|
|
21773
21861
|
preparationFailure = void 0;
|
|
21862
|
+
preparedAdvice = void 0;
|
|
21774
21863
|
preparationInFlight = true;
|
|
21775
21864
|
preparation = prepare().finally(() => {
|
|
21776
21865
|
preparationInFlight = false;
|
|
@@ -21808,24 +21897,8 @@ function createNavigatorAttendance(options) {
|
|
|
21808
21897
|
};
|
|
21809
21898
|
async function settleOnce(settlement) {
|
|
21810
21899
|
if (disposed) return;
|
|
21811
|
-
observedRoutePlaybookFailure = void 0;
|
|
21812
21900
|
const invocationId = activeInvocationId ?? invocationPrincipal;
|
|
21813
21901
|
let report;
|
|
21814
|
-
if (sessionReady !== void 0) {
|
|
21815
|
-
try {
|
|
21816
|
-
await sessionReady;
|
|
21817
|
-
} catch (error) {
|
|
21818
|
-
preparationFailure ??= error;
|
|
21819
|
-
}
|
|
21820
|
-
}
|
|
21821
|
-
if (preparation !== void 0) {
|
|
21822
|
-
try {
|
|
21823
|
-
await preparation;
|
|
21824
|
-
} catch (error) {
|
|
21825
|
-
preparationFailure ??= error;
|
|
21826
|
-
}
|
|
21827
|
-
preparation = void 0;
|
|
21828
|
-
}
|
|
21829
21902
|
const settlementFact = {
|
|
21830
21903
|
invocationId,
|
|
21831
21904
|
subjectKey,
|
|
@@ -21834,8 +21907,14 @@ function createNavigatorAttendance(options) {
|
|
|
21834
21907
|
kind: settlement.kind,
|
|
21835
21908
|
..."status" in settlement && settlement.status !== void 0 ? { status: settlement.status } : {}
|
|
21836
21909
|
};
|
|
21837
|
-
let drainedProse;
|
|
21838
21910
|
if (settlement.kind === "arrival") {
|
|
21911
|
+
if (sessionReady !== void 0) {
|
|
21912
|
+
try {
|
|
21913
|
+
await sessionReady;
|
|
21914
|
+
} catch (error) {
|
|
21915
|
+
preparationFailure ??= error;
|
|
21916
|
+
}
|
|
21917
|
+
}
|
|
21839
21918
|
session?.appendEntry(SETTLEMENT_ENTRY, settlementFact);
|
|
21840
21919
|
if (preparationFailure !== void 0) {
|
|
21841
21920
|
report = unavailable(invocationId, preparationFailure);
|
|
@@ -21846,35 +21925,32 @@ function createNavigatorAttendance(options) {
|
|
|
21846
21925
|
};
|
|
21847
21926
|
}
|
|
21848
21927
|
} else {
|
|
21849
|
-
if (
|
|
21850
|
-
let coldSession;
|
|
21851
|
-
if (session === void 0 && preparationFailure === void 0) {
|
|
21928
|
+
if (sessionReady !== void 0) {
|
|
21852
21929
|
try {
|
|
21853
|
-
|
|
21930
|
+
await sessionReady;
|
|
21854
21931
|
} catch (error) {
|
|
21855
|
-
preparationFailure
|
|
21932
|
+
preparationFailure ??= error;
|
|
21856
21933
|
}
|
|
21857
21934
|
}
|
|
21858
|
-
|
|
21859
|
-
if (preparationFailure === void 0) {
|
|
21860
|
-
prepareBoundSettlement = settlement;
|
|
21861
|
-
preparation = prepare(coldSession);
|
|
21862
|
-
void preparation.catch((error) => {
|
|
21863
|
-
preparationFailure = error;
|
|
21864
|
-
});
|
|
21935
|
+
if (preparation !== void 0) {
|
|
21865
21936
|
try {
|
|
21866
|
-
|
|
21937
|
+
await preparation;
|
|
21867
21938
|
} catch (error) {
|
|
21868
21939
|
preparationFailure ??= error;
|
|
21869
21940
|
}
|
|
21870
21941
|
preparation = void 0;
|
|
21871
21942
|
}
|
|
21943
|
+
session?.appendEntry(SETTLEMENT_ENTRY, settlementFact);
|
|
21872
21944
|
if (preparationFailure !== void 0) {
|
|
21873
21945
|
report = unavailable(invocationId, preparationFailure);
|
|
21874
|
-
} else if (typeof drainedProse === "string" && drainedProse.trim() !== "") {
|
|
21875
|
-
report = { disposition: "advice", prose: drainedProse };
|
|
21876
21946
|
} else {
|
|
21877
|
-
|
|
21947
|
+
const status = "status" in settlement ? settlement.status : void 0;
|
|
21948
|
+
const picked = pickPreparedProse(preparedAdvice, status);
|
|
21949
|
+
if (typeof picked === "string" && picked.trim() !== "") {
|
|
21950
|
+
report = { disposition: "advice", prose: picked };
|
|
21951
|
+
} else {
|
|
21952
|
+
report = { disposition: "no-advice" };
|
|
21953
|
+
}
|
|
21878
21954
|
}
|
|
21879
21955
|
}
|
|
21880
21956
|
if (observedRoutePlaybookFailure !== void 0) {
|
|
@@ -21903,8 +21979,9 @@ function createNavigatorAttendance(options) {
|
|
|
21903
21979
|
}
|
|
21904
21980
|
preparation = void 0;
|
|
21905
21981
|
sessionReady = void 0;
|
|
21906
|
-
|
|
21982
|
+
preparedAdvice = void 0;
|
|
21907
21983
|
preparationFailure = void 0;
|
|
21984
|
+
observedRoutePlaybookFailure = void 0;
|
|
21908
21985
|
}
|
|
21909
21986
|
}
|
|
21910
21987
|
|