@akagilnc/pi-workflow-roles 0.1.5663 → 0.1.5671
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 +180 -105
- package/dist/headless-host/production-host.js +201 -126
- 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/public-cli/main.js +18 -10
- 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/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
|
|
|
@@ -12116,6 +12202,7 @@ function projectRoleTurnRequest(admitted, roleDetails, options) {
|
|
|
12116
12202
|
...options.courtAttemptId === void 0 || options.courtAttemptId.length === 0 ? {} : { courtAttemptId: options.courtAttemptId },
|
|
12117
12203
|
...options.invocationScopeId === void 0 || options.invocationScopeId.length === 0 ? {} : { invocationScopeId: options.invocationScopeId },
|
|
12118
12204
|
...options.stationChild === void 0 ? {} : { stationChild: options.stationChild },
|
|
12205
|
+
...options.navigatorByStatusPrepare === void 0 ? {} : { navigatorByStatusPrepare: options.navigatorByStatusPrepare },
|
|
12119
12206
|
...options.deliveryRequestLimit === void 0 ? {} : { deliveryRequestLimit: options.deliveryRequestLimit }
|
|
12120
12207
|
};
|
|
12121
12208
|
}
|
|
@@ -13091,6 +13178,9 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
13091
13178
|
if (env.stationChild !== void 0) {
|
|
13092
13179
|
turnRequest = { ...turnRequest, stationChild: env.stationChild };
|
|
13093
13180
|
}
|
|
13181
|
+
if (env.navigatorByStatusPrepare === true) {
|
|
13182
|
+
turnRequest = { ...turnRequest, navigatorByStatusPrepare: true };
|
|
13183
|
+
}
|
|
13094
13184
|
if (typeof env.host === "string" && env.host.trim() !== "") {
|
|
13095
13185
|
turnRequest = { ...turnRequest, host: env.host.trim() };
|
|
13096
13186
|
}
|
|
@@ -13349,6 +13439,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
13349
13439
|
prompt
|
|
13350
13440
|
},
|
|
13351
13441
|
...env.stationChild === void 0 ? {} : { stationChild: env.stationChild },
|
|
13442
|
+
...env.navigatorByStatusPrepare === true ? { navigatorByStatusPrepare: true } : {},
|
|
13352
13443
|
// #1132: one configured ceiling, already resolved by the caller (#422).
|
|
13353
13444
|
deliveryRequestLimit: deliveryLimitFromConfig(env.autoResumeLimit)
|
|
13354
13445
|
};
|
|
@@ -13361,6 +13452,7 @@ function roleTurnOptions(env, admitted, continuation) {
|
|
|
13361
13452
|
...correlationId === void 0 || correlationId.trim() === "" ? {} : { correlationId },
|
|
13362
13453
|
continuation,
|
|
13363
13454
|
...env.stationChild === void 0 ? {} : { stationChild: env.stationChild },
|
|
13455
|
+
...env.navigatorByStatusPrepare === true ? { navigatorByStatusPrepare: true } : {},
|
|
13364
13456
|
// #1132: one configured ceiling, already resolved by the caller (#422).
|
|
13365
13457
|
deliveryRequestLimit: deliveryLimitFromConfig(env.autoResumeLimit)
|
|
13366
13458
|
};
|
|
@@ -18595,6 +18687,7 @@ async function summonPublicRole(options) {
|
|
|
18595
18687
|
// Nested court stations keep station-child semantics; dual-lens
|
|
18596
18688
|
// ordinary Reviewer axes opt out (#946 / ADR 0082).
|
|
18597
18689
|
...options.stationChild === false ? {} : { stationChild: true },
|
|
18690
|
+
...options.navigatorByStatusPrepare === true ? { navigatorByStatusPrepare: true } : {},
|
|
18598
18691
|
// Forward composition-root adapters so nested stations (e.g.
|
|
18599
18692
|
// secretariat → diarist) select the same faux/production table (#924).
|
|
18600
18693
|
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
@@ -21097,7 +21190,7 @@ init_navigator_invocation_identity();
|
|
|
21097
21190
|
init_packaged_role_registry();
|
|
21098
21191
|
init_activation_ledger_topology();
|
|
21099
21192
|
import { resolve as resolve15 } from "node:path";
|
|
21100
|
-
import
|
|
21193
|
+
import "typebox";
|
|
21101
21194
|
|
|
21102
21195
|
// src/navigator-public-session.ts
|
|
21103
21196
|
init_host_session_record();
|
|
@@ -21322,7 +21415,6 @@ async function navigatorHostRunResumable(home, runId) {
|
|
|
21322
21415
|
}
|
|
21323
21416
|
function createNativeNavigatorSessionFactory(deps) {
|
|
21324
21417
|
return async ({ context, tool }) => {
|
|
21325
|
-
let thinkingLevel;
|
|
21326
21418
|
const entries = [];
|
|
21327
21419
|
let providerFailure;
|
|
21328
21420
|
let noReceipt;
|
|
@@ -21350,6 +21442,9 @@ function createNativeNavigatorSessionFactory(deps) {
|
|
|
21350
21442
|
role: "navigator",
|
|
21351
21443
|
argv: [text],
|
|
21352
21444
|
cwd: context.cwd,
|
|
21445
|
+
// Attendance prepare always asks for structured byStatus (#1160).
|
|
21446
|
+
// Direct `ak-role navigator` never sets this flag.
|
|
21447
|
+
navigatorByStatusPrepare: true,
|
|
21353
21448
|
...summonHome === void 0 ? {} : { home: summonHome },
|
|
21354
21449
|
...context.signal === void 0 ? {} : { signal: context.signal }
|
|
21355
21450
|
};
|
|
@@ -21408,17 +21503,23 @@ function createNativeNavigatorSessionFactory(deps) {
|
|
|
21408
21503
|
if (outcome.kind !== "accepted") {
|
|
21409
21504
|
return;
|
|
21410
21505
|
}
|
|
21411
|
-
const {
|
|
21412
|
-
|
|
21506
|
+
const {
|
|
21507
|
+
byStatusToPlainObject: byStatusToPlainObject2,
|
|
21508
|
+
mergePreparedAdvice: mergePreparedAdvice2,
|
|
21509
|
+
preparedAdviceFromUnknown: preparedAdviceFromUnknown2
|
|
21510
|
+
} = await Promise.resolve().then(() => (init_navigator_output(), navigator_output_exports));
|
|
21511
|
+
let prepared = void 0;
|
|
21413
21512
|
for (const payload of outcome.payloads ?? []) {
|
|
21414
|
-
|
|
21415
|
-
if (prose !== void 0) proseParts.push(prose);
|
|
21513
|
+
prepared = mergePreparedAdvice2(prepared, preparedAdviceFromUnknown2(payload));
|
|
21416
21514
|
}
|
|
21417
|
-
if (
|
|
21515
|
+
if (prepared === void 0) return;
|
|
21418
21516
|
if (disposed) return;
|
|
21419
21517
|
await tool.execute(
|
|
21420
21518
|
"navigator-public-prepare",
|
|
21421
|
-
{
|
|
21519
|
+
{
|
|
21520
|
+
...prepared.prose === void 0 ? {} : { prose: prepared.prose },
|
|
21521
|
+
...prepared.byStatus.size === 0 ? {} : { byStatus: byStatusToPlainObject2(prepared.byStatus) }
|
|
21522
|
+
},
|
|
21422
21523
|
void 0,
|
|
21423
21524
|
void 0,
|
|
21424
21525
|
context
|
|
@@ -21447,16 +21548,13 @@ function createNativeNavigatorSessionFactory(deps) {
|
|
|
21447
21548
|
});
|
|
21448
21549
|
},
|
|
21449
21550
|
entries: () => entries,
|
|
21450
|
-
setModel: async (next
|
|
21451
|
-
let nextParsed;
|
|
21551
|
+
setModel: async (next) => {
|
|
21452
21552
|
try {
|
|
21453
|
-
|
|
21553
|
+
parseNavigatorModelSetting(next);
|
|
21454
21554
|
} catch (error) {
|
|
21455
21555
|
throw navigatorUnavailableError("model", error);
|
|
21456
21556
|
}
|
|
21457
|
-
thinkingLevel = nextThinking ?? nextParsed.thinkingLevel;
|
|
21458
21557
|
},
|
|
21459
|
-
getThinkingLevel: () => thinkingLevel,
|
|
21460
21558
|
dispose: async () => {
|
|
21461
21559
|
disposed = true;
|
|
21462
21560
|
}
|
|
@@ -21478,11 +21576,7 @@ function resolveNavigatorAuthorityMaterial(roleInput, fileAuthority) {
|
|
|
21478
21576
|
return void 0;
|
|
21479
21577
|
}
|
|
21480
21578
|
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 });
|
|
21579
|
+
var prepareSchema = navigatorAdviceBodySchema;
|
|
21486
21580
|
var INVOCATION_ENTRY = NAVIGATOR_INVOCATION_ENTRY;
|
|
21487
21581
|
var SETTLEMENT_ENTRY = "ak-navigator-settlement";
|
|
21488
21582
|
function rejectedPrepareReason(entries, start) {
|
|
@@ -21507,8 +21601,8 @@ function rejectedPrepareReason(entries, start) {
|
|
|
21507
21601
|
}
|
|
21508
21602
|
return reason;
|
|
21509
21603
|
}
|
|
21510
|
-
function
|
|
21511
|
-
return
|
|
21604
|
+
function normalizePreparedAdvice(value) {
|
|
21605
|
+
return preparedAdviceFromUnknown(value);
|
|
21512
21606
|
}
|
|
21513
21607
|
function navigatorSubjectKey(subjectRoot, subject, provenance = "role_input") {
|
|
21514
21608
|
if (issueRoot(subjectRoot) !== void 0 || !subjectRoot.includes("/.ak/work/")) return subjectRoot;
|
|
@@ -21558,7 +21652,7 @@ function createNavigatorAttendance(options) {
|
|
|
21558
21652
|
let subject = options.subject;
|
|
21559
21653
|
let authority = options.authority;
|
|
21560
21654
|
let contextError = options.contextError;
|
|
21561
|
-
let
|
|
21655
|
+
let preparedAdvice;
|
|
21562
21656
|
const invocationPrincipal = options.invocationId ?? mintNavigatorInvocationId();
|
|
21563
21657
|
let activeInvocationId = invocationPrincipal;
|
|
21564
21658
|
let outputSink;
|
|
@@ -21583,7 +21677,6 @@ function createNavigatorAttendance(options) {
|
|
|
21583
21677
|
unavailableCause: failure.unavailableCause
|
|
21584
21678
|
};
|
|
21585
21679
|
};
|
|
21586
|
-
let prepareBoundSettlement;
|
|
21587
21680
|
const loadMaterialsAndSession = async (invocationId) => {
|
|
21588
21681
|
if (contextError !== void 0) throw navigatorUnavailableError("context", contextError);
|
|
21589
21682
|
if (typeof authority !== "string" || authority.trim() === "") {
|
|
@@ -21654,29 +21747,32 @@ function createNavigatorAttendance(options) {
|
|
|
21654
21747
|
if (session === void 0) throw new Error("Navigator session was not created");
|
|
21655
21748
|
return session;
|
|
21656
21749
|
};
|
|
21657
|
-
const prepare = async (
|
|
21658
|
-
const boundSettlement = prepareBoundSettlement;
|
|
21659
|
-
prepareBoundSettlement = void 0;
|
|
21750
|
+
const prepare = async () => {
|
|
21660
21751
|
const invocationId = invocationPrincipal;
|
|
21661
21752
|
activeInvocationId = invocationId;
|
|
21662
21753
|
let output;
|
|
21663
21754
|
let prepareBatchRejected = false;
|
|
21664
21755
|
outputSink = (value) => {
|
|
21756
|
+
const next = normalizePreparedAdvice(value);
|
|
21665
21757
|
if (output === void 0) {
|
|
21666
21758
|
output = value;
|
|
21667
21759
|
return;
|
|
21668
21760
|
}
|
|
21669
|
-
const
|
|
21670
|
-
|
|
21671
|
-
|
|
21672
|
-
|
|
21761
|
+
const merged = mergePreparedAdvice(normalizePreparedAdvice(output), next);
|
|
21762
|
+
output = {
|
|
21763
|
+
...merged?.prose === void 0 ? {} : { prose: merged.prose },
|
|
21764
|
+
...merged === void 0 || merged.byStatus.size === 0 ? {} : { byStatus: byStatusToPlainObject(merged.byStatus) }
|
|
21765
|
+
};
|
|
21673
21766
|
};
|
|
21674
|
-
const activeSession =
|
|
21675
|
-
if (boundSettlement === void 0) return void 0;
|
|
21767
|
+
const activeSession = await loadMaterialsAndSession(invocationId);
|
|
21676
21768
|
const request = JSON.stringify({
|
|
21677
|
-
|
|
21769
|
+
kind: "prepare",
|
|
21770
|
+
role: options.role,
|
|
21771
|
+
phase: options.phase,
|
|
21678
21772
|
invocationId,
|
|
21679
|
-
subjectKey
|
|
21773
|
+
subjectKey,
|
|
21774
|
+
subject,
|
|
21775
|
+
authority
|
|
21680
21776
|
});
|
|
21681
21777
|
try {
|
|
21682
21778
|
try {
|
|
@@ -21710,27 +21806,21 @@ function createNavigatorAttendance(options) {
|
|
|
21710
21806
|
}
|
|
21711
21807
|
};
|
|
21712
21808
|
await promptAllowingRejectedPrepare(request);
|
|
21713
|
-
|
|
21714
|
-
|
|
21715
|
-
|
|
21716
|
-
|
|
21717
|
-
|
|
21718
|
-
|
|
21719
|
-
|
|
21720
|
-
|
|
21721
|
-
|
|
21722
|
-
|
|
21723
|
-
return void 0;
|
|
21724
|
-
}
|
|
21809
|
+
while (output === void 0 && prepareBatchRejected && delivery.nextAction() === "request-delivery") {
|
|
21810
|
+
delivery.recordDeliveryRequest();
|
|
21811
|
+
await promptAllowingRejectedPrepare(JSON.stringify(delivery.deliveryState()));
|
|
21812
|
+
}
|
|
21813
|
+
if (output === void 0 && delivery.nextAction() === "request-delivery") {
|
|
21814
|
+
delivery.closeBudget();
|
|
21815
|
+
}
|
|
21816
|
+
if (output === void 0 && delivery.nextAction() === "no-receipt" && activeSession.providerFailure?.() === void 0) {
|
|
21817
|
+
preparedAdvice = void 0;
|
|
21818
|
+
return void 0;
|
|
21725
21819
|
}
|
|
21726
21820
|
} catch (error) {
|
|
21727
21821
|
throw error instanceof NavigatorUnavailableError ? error : navigatorUnavailableError("transport", error);
|
|
21728
21822
|
}
|
|
21729
21823
|
if (output === void 0) {
|
|
21730
|
-
if (boundSettlement === void 0) {
|
|
21731
|
-
preparedProse = void 0;
|
|
21732
|
-
return void 0;
|
|
21733
|
-
}
|
|
21734
21824
|
const nativeFailure = [...activeSession.entries()].reverse().find((entry) => {
|
|
21735
21825
|
if (!isRecord(entry) || entry.type !== "message" || !isRecord(entry.message)) return false;
|
|
21736
21826
|
return entry.message.role === "assistant" && typeof entry.message.errorMessage === "string" && entry.message.errorMessage.trim() !== "";
|
|
@@ -21742,12 +21832,8 @@ function createNavigatorAttendance(options) {
|
|
|
21742
21832
|
const cause = providerFailure?.cause ?? source;
|
|
21743
21833
|
throw navigatorUnavailableError(source, errorMessage, cause);
|
|
21744
21834
|
}
|
|
21745
|
-
|
|
21746
|
-
|
|
21747
|
-
return void 0;
|
|
21748
|
-
}
|
|
21749
|
-
preparedProse = normalizePrepareProse(output);
|
|
21750
|
-
return preparedProse;
|
|
21835
|
+
preparedAdvice = normalizePreparedAdvice(output);
|
|
21836
|
+
return preparedAdvice;
|
|
21751
21837
|
} finally {
|
|
21752
21838
|
const playbookFailure = activeSession.routePlaybookReadFailure?.();
|
|
21753
21839
|
observedRoutePlaybookFailure = typeof playbookFailure === "string" && playbookFailure.trim() !== "" ? playbookFailure : void 0;
|
|
@@ -21771,6 +21857,7 @@ function createNavigatorAttendance(options) {
|
|
|
21771
21857
|
prepare() {
|
|
21772
21858
|
if (disposed || preparation !== void 0) return;
|
|
21773
21859
|
preparationFailure = void 0;
|
|
21860
|
+
preparedAdvice = void 0;
|
|
21774
21861
|
preparationInFlight = true;
|
|
21775
21862
|
preparation = prepare().finally(() => {
|
|
21776
21863
|
preparationInFlight = false;
|
|
@@ -21808,24 +21895,8 @@ function createNavigatorAttendance(options) {
|
|
|
21808
21895
|
};
|
|
21809
21896
|
async function settleOnce(settlement) {
|
|
21810
21897
|
if (disposed) return;
|
|
21811
|
-
observedRoutePlaybookFailure = void 0;
|
|
21812
21898
|
const invocationId = activeInvocationId ?? invocationPrincipal;
|
|
21813
21899
|
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
21900
|
const settlementFact = {
|
|
21830
21901
|
invocationId,
|
|
21831
21902
|
subjectKey,
|
|
@@ -21834,8 +21905,14 @@ function createNavigatorAttendance(options) {
|
|
|
21834
21905
|
kind: settlement.kind,
|
|
21835
21906
|
..."status" in settlement && settlement.status !== void 0 ? { status: settlement.status } : {}
|
|
21836
21907
|
};
|
|
21837
|
-
let drainedProse;
|
|
21838
21908
|
if (settlement.kind === "arrival") {
|
|
21909
|
+
if (sessionReady !== void 0) {
|
|
21910
|
+
try {
|
|
21911
|
+
await sessionReady;
|
|
21912
|
+
} catch (error) {
|
|
21913
|
+
preparationFailure ??= error;
|
|
21914
|
+
}
|
|
21915
|
+
}
|
|
21839
21916
|
session?.appendEntry(SETTLEMENT_ENTRY, settlementFact);
|
|
21840
21917
|
if (preparationFailure !== void 0) {
|
|
21841
21918
|
report = unavailable(invocationId, preparationFailure);
|
|
@@ -21846,35 +21923,32 @@ function createNavigatorAttendance(options) {
|
|
|
21846
21923
|
};
|
|
21847
21924
|
}
|
|
21848
21925
|
} else {
|
|
21849
|
-
if (
|
|
21850
|
-
let coldSession;
|
|
21851
|
-
if (session === void 0 && preparationFailure === void 0) {
|
|
21926
|
+
if (sessionReady !== void 0) {
|
|
21852
21927
|
try {
|
|
21853
|
-
|
|
21928
|
+
await sessionReady;
|
|
21854
21929
|
} catch (error) {
|
|
21855
|
-
preparationFailure
|
|
21930
|
+
preparationFailure ??= error;
|
|
21856
21931
|
}
|
|
21857
21932
|
}
|
|
21858
|
-
|
|
21859
|
-
if (preparationFailure === void 0) {
|
|
21860
|
-
prepareBoundSettlement = settlement;
|
|
21861
|
-
preparation = prepare(coldSession);
|
|
21862
|
-
void preparation.catch((error) => {
|
|
21863
|
-
preparationFailure = error;
|
|
21864
|
-
});
|
|
21933
|
+
if (preparation !== void 0) {
|
|
21865
21934
|
try {
|
|
21866
|
-
|
|
21935
|
+
await preparation;
|
|
21867
21936
|
} catch (error) {
|
|
21868
21937
|
preparationFailure ??= error;
|
|
21869
21938
|
}
|
|
21870
21939
|
preparation = void 0;
|
|
21871
21940
|
}
|
|
21941
|
+
session?.appendEntry(SETTLEMENT_ENTRY, settlementFact);
|
|
21872
21942
|
if (preparationFailure !== void 0) {
|
|
21873
21943
|
report = unavailable(invocationId, preparationFailure);
|
|
21874
|
-
} else if (typeof drainedProse === "string" && drainedProse.trim() !== "") {
|
|
21875
|
-
report = { disposition: "advice", prose: drainedProse };
|
|
21876
21944
|
} else {
|
|
21877
|
-
|
|
21945
|
+
const status = "status" in settlement ? settlement.status : void 0;
|
|
21946
|
+
const picked = pickPreparedProse(preparedAdvice, status);
|
|
21947
|
+
if (typeof picked === "string" && picked.trim() !== "") {
|
|
21948
|
+
report = { disposition: "advice", prose: picked };
|
|
21949
|
+
} else {
|
|
21950
|
+
report = { disposition: "no-advice" };
|
|
21951
|
+
}
|
|
21878
21952
|
}
|
|
21879
21953
|
}
|
|
21880
21954
|
if (observedRoutePlaybookFailure !== void 0) {
|
|
@@ -21903,8 +21977,9 @@ function createNavigatorAttendance(options) {
|
|
|
21903
21977
|
}
|
|
21904
21978
|
preparation = void 0;
|
|
21905
21979
|
sessionReady = void 0;
|
|
21906
|
-
|
|
21980
|
+
preparedAdvice = void 0;
|
|
21907
21981
|
preparationFailure = void 0;
|
|
21982
|
+
observedRoutePlaybookFailure = void 0;
|
|
21908
21983
|
}
|
|
21909
21984
|
}
|
|
21910
21985
|
|