@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
|
@@ -649,27 +649,61 @@ var init_gatekeeper_output = __esm({
|
|
|
649
649
|
var navigator_output_exports = {};
|
|
650
650
|
__export(navigator_output_exports, {
|
|
651
651
|
NAVIGATOR_OUTPUT_TOOL_NAME: () => NAVIGATOR_OUTPUT_TOOL_NAME,
|
|
652
|
+
byStatusToPlainObject: () => byStatusToPlainObject,
|
|
653
|
+
mergePreparedAdvice: () => mergePreparedAdvice,
|
|
654
|
+
navigatorAdviceBodySchema: () => navigatorAdviceBodySchema,
|
|
655
|
+
navigatorAdviceFields: () => navigatorAdviceFields,
|
|
652
656
|
navigatorOutputSchema: () => navigatorOutputSchema,
|
|
653
657
|
navigatorProseFromUnknown: () => navigatorProseFromUnknown,
|
|
658
|
+
pickPreparedProse: () => pickPreparedProse,
|
|
659
|
+
preparedAdviceFromUnknown: () => preparedAdviceFromUnknown,
|
|
654
660
|
projectLawfulNavigatorOutput: () => projectLawfulNavigatorOutput,
|
|
655
661
|
validateRecordedNavigatorOutput: () => validateRecordedNavigatorOutput
|
|
656
662
|
});
|
|
657
663
|
import { Type as Type6 } from "typebox";
|
|
664
|
+
function nonEmptyProse(value) {
|
|
665
|
+
if (typeof value === "string") {
|
|
666
|
+
return value.trim() === "" ? void 0 : value;
|
|
667
|
+
}
|
|
668
|
+
if (value === void 0 || value === null) return void 0;
|
|
669
|
+
if (typeof value === "object") {
|
|
670
|
+
const text2 = JSON.stringify(value);
|
|
671
|
+
if (text2 === void 0 || text2.trim() === "" || text2 === "{}" || text2 === "[]") return void 0;
|
|
672
|
+
return text2;
|
|
673
|
+
}
|
|
674
|
+
const text = String(value);
|
|
675
|
+
return text.trim() === "" ? void 0 : text;
|
|
676
|
+
}
|
|
677
|
+
function setStatusProse(target, key, prose) {
|
|
678
|
+
const prior = target.get(key);
|
|
679
|
+
target.set(key, prior === void 0 ? prose : `${prior}
|
|
680
|
+
|
|
681
|
+
${prose}`);
|
|
682
|
+
}
|
|
683
|
+
function byStatusFromUnknown(value) {
|
|
684
|
+
const out = /* @__PURE__ */ new Map();
|
|
685
|
+
if (!isRecord(value)) return out;
|
|
686
|
+
for (const [key, raw] of Object.entries(value)) {
|
|
687
|
+
const prose = nonEmptyProse(raw);
|
|
688
|
+
if (prose !== void 0) out.set(key, prose);
|
|
689
|
+
}
|
|
690
|
+
return out;
|
|
691
|
+
}
|
|
692
|
+
function byStatusToPlainObject(byStatus) {
|
|
693
|
+
return Object.fromEntries(byStatus);
|
|
694
|
+
}
|
|
658
695
|
function projectLawfulNavigatorOutput(value) {
|
|
659
696
|
if (value === void 0 || value === null) return void 0;
|
|
660
697
|
if (typeof value === "string") return { prose: value };
|
|
661
698
|
if (isRecord(value)) {
|
|
662
699
|
if (typeof value.prose === "string") return { prose: value.prose };
|
|
663
700
|
if (value.prose !== void 0 && value.prose !== null) {
|
|
664
|
-
|
|
701
|
+
const serialized = nonEmptyProse(value.prose);
|
|
702
|
+
if (serialized !== void 0) return { prose: serialized };
|
|
665
703
|
}
|
|
666
704
|
const keys = Object.keys(value);
|
|
667
705
|
if (keys.length === 0) return { prose: "" };
|
|
668
|
-
|
|
669
|
-
return { prose: JSON.stringify(value) };
|
|
670
|
-
} catch {
|
|
671
|
-
return { prose: String(value) };
|
|
672
|
-
}
|
|
706
|
+
return { prose: JSON.stringify(value) };
|
|
673
707
|
}
|
|
674
708
|
return { prose: String(value) };
|
|
675
709
|
}
|
|
@@ -686,7 +720,58 @@ function navigatorProseFromUnknown(value) {
|
|
|
686
720
|
const trimmed = projected.prose.trim();
|
|
687
721
|
return trimmed === "" ? void 0 : projected.prose;
|
|
688
722
|
}
|
|
689
|
-
|
|
723
|
+
function preparedAdviceFromUnknown(value) {
|
|
724
|
+
if (value === void 0 || value === null) return void 0;
|
|
725
|
+
if (typeof value === "string") {
|
|
726
|
+
const prose2 = nonEmptyProse(value);
|
|
727
|
+
return prose2 === void 0 ? void 0 : { byStatus: /* @__PURE__ */ new Map(), prose: prose2 };
|
|
728
|
+
}
|
|
729
|
+
if (!isRecord(value)) {
|
|
730
|
+
const prose2 = nonEmptyProse(value);
|
|
731
|
+
return prose2 === void 0 ? void 0 : { byStatus: /* @__PURE__ */ new Map(), prose: prose2 };
|
|
732
|
+
}
|
|
733
|
+
const byStatus = byStatusFromUnknown(value.byStatus);
|
|
734
|
+
const hasProseField = Object.prototype.hasOwnProperty.call(value, "prose");
|
|
735
|
+
const hasByStatusField = Object.prototype.hasOwnProperty.call(value, "byStatus");
|
|
736
|
+
const prose = nonEmptyProse(value.prose);
|
|
737
|
+
if (byStatus.size === 0 && prose === void 0) {
|
|
738
|
+
if (hasProseField || hasByStatusField) return void 0;
|
|
739
|
+
const keys = Object.keys(value);
|
|
740
|
+
if (keys.length === 0) return void 0;
|
|
741
|
+
const text = JSON.stringify(value);
|
|
742
|
+
return text.trim() === "" || text === "{}" ? void 0 : { byStatus: /* @__PURE__ */ new Map(), prose: text };
|
|
743
|
+
}
|
|
744
|
+
return {
|
|
745
|
+
byStatus,
|
|
746
|
+
...prose === void 0 ? {} : { prose }
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
function mergePreparedAdvice(prior, next) {
|
|
750
|
+
if (prior === void 0) return next;
|
|
751
|
+
if (next === void 0) return prior;
|
|
752
|
+
const byStatus = new Map(prior.byStatus);
|
|
753
|
+
for (const [key, prose2] of next.byStatus) {
|
|
754
|
+
setStatusProse(byStatus, key, prose2);
|
|
755
|
+
}
|
|
756
|
+
const proseParts = [prior.prose, next.prose].filter((part) => typeof part === "string" && part.trim() !== "");
|
|
757
|
+
const prose = proseParts.length === 0 ? void 0 : proseParts.join("\n\n");
|
|
758
|
+
if (byStatus.size === 0 && prose === void 0) return void 0;
|
|
759
|
+
return {
|
|
760
|
+
byStatus,
|
|
761
|
+
...prose === void 0 ? {} : { prose }
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
function pickPreparedProse(prepared, status) {
|
|
765
|
+
if (prepared === void 0) return void 0;
|
|
766
|
+
if (prepared.byStatus.size > 0) {
|
|
767
|
+
if (status === void 0) return void 0;
|
|
768
|
+
const hit = prepared.byStatus.get(status);
|
|
769
|
+
return typeof hit === "string" && hit.trim() !== "" ? hit : void 0;
|
|
770
|
+
}
|
|
771
|
+
const prose = prepared.prose;
|
|
772
|
+
return typeof prose === "string" && prose.trim() !== "" ? prose : void 0;
|
|
773
|
+
}
|
|
774
|
+
var NAVIGATOR_OUTPUT_TOOL_NAME, navigatorAdviceFields, navigatorAdviceBodySchema, navigatorOutputSchema;
|
|
690
775
|
var init_navigator_output = __esm({
|
|
691
776
|
"src/package-contracts/navigator-output.ts"() {
|
|
692
777
|
"use strict";
|
|
@@ -694,15 +779,16 @@ var init_navigator_output = __esm({
|
|
|
694
779
|
init_open_tool_schema();
|
|
695
780
|
init_terminating_infrastructure();
|
|
696
781
|
NAVIGATOR_OUTPUT_TOOL_NAME = "ak_navigator_output";
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
);
|
|
782
|
+
navigatorAdviceFields = {
|
|
783
|
+
prose: Type6.Unknown({
|
|
784
|
+
description: "\u5355\u6761\u6563\u6587\u5EFA\u8BAE\u3002\u65E0\u72B6\u6001\u5206\u53C9\u65F6\u4F7F\u7528\uFF1B\u539F\u6837\u5448\u73B0\u3002"
|
|
785
|
+
}),
|
|
786
|
+
byStatus: Type6.Unknown({
|
|
787
|
+
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"
|
|
788
|
+
})
|
|
789
|
+
};
|
|
790
|
+
navigatorAdviceBodySchema = openToolObject(Type6.Object(navigatorAdviceFields));
|
|
791
|
+
navigatorOutputSchema = withTerminatingOutputDeclarations(navigatorAdviceBodySchema);
|
|
706
792
|
}
|
|
707
793
|
});
|
|
708
794
|
|
|
@@ -10790,8 +10876,10 @@ function buildPiTurnExtraArgs(request, authority, extraPiArgs = []) {
|
|
|
10790
10876
|
// Envelope assembly = projectActivationFlags; pi only renders argv pairs.
|
|
10791
10877
|
...activationFlagsToPiArgv(projectActivationFlags(request)),
|
|
10792
10878
|
...piEngineModelArgs(request),
|
|
10879
|
+
// #1182: text single-shot keeps pi's native assistant error/aborted
|
|
10880
|
+
// exit (stderr + exit 1). json mode never takes that failure branch.
|
|
10793
10881
|
"--mode",
|
|
10794
|
-
"
|
|
10882
|
+
"text",
|
|
10795
10883
|
...buildSeatModelCliArgs2(request.model)
|
|
10796
10884
|
];
|
|
10797
10885
|
}
|
|
@@ -12310,6 +12398,7 @@ function projectRoleTurnRequest(admitted, roleDetails, options) {
|
|
|
12310
12398
|
...options.courtAttemptId === void 0 || options.courtAttemptId.length === 0 ? {} : { courtAttemptId: options.courtAttemptId },
|
|
12311
12399
|
...options.invocationScopeId === void 0 || options.invocationScopeId.length === 0 ? {} : { invocationScopeId: options.invocationScopeId },
|
|
12312
12400
|
...options.stationChild === void 0 ? {} : { stationChild: options.stationChild },
|
|
12401
|
+
...options.navigatorByStatusPrepare === void 0 ? {} : { navigatorByStatusPrepare: options.navigatorByStatusPrepare },
|
|
12313
12402
|
...options.deliveryRequestLimit === void 0 ? {} : { deliveryRequestLimit: options.deliveryRequestLimit }
|
|
12314
12403
|
};
|
|
12315
12404
|
}
|
|
@@ -13285,6 +13374,9 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
13285
13374
|
if (env.stationChild !== void 0) {
|
|
13286
13375
|
turnRequest = { ...turnRequest, stationChild: env.stationChild };
|
|
13287
13376
|
}
|
|
13377
|
+
if (env.navigatorByStatusPrepare === true) {
|
|
13378
|
+
turnRequest = { ...turnRequest, navigatorByStatusPrepare: true };
|
|
13379
|
+
}
|
|
13288
13380
|
if (typeof env.host === "string" && env.host.trim() !== "") {
|
|
13289
13381
|
turnRequest = { ...turnRequest, host: env.host.trim() };
|
|
13290
13382
|
}
|
|
@@ -13543,6 +13635,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
13543
13635
|
prompt
|
|
13544
13636
|
},
|
|
13545
13637
|
...env.stationChild === void 0 ? {} : { stationChild: env.stationChild },
|
|
13638
|
+
...env.navigatorByStatusPrepare === true ? { navigatorByStatusPrepare: true } : {},
|
|
13546
13639
|
// #1132: one configured ceiling, already resolved by the caller (#422).
|
|
13547
13640
|
deliveryRequestLimit: deliveryLimitFromConfig(env.autoResumeLimit)
|
|
13548
13641
|
};
|
|
@@ -13555,6 +13648,7 @@ function roleTurnOptions(env, admitted, continuation) {
|
|
|
13555
13648
|
...correlationId === void 0 || correlationId.trim() === "" ? {} : { correlationId },
|
|
13556
13649
|
continuation,
|
|
13557
13650
|
...env.stationChild === void 0 ? {} : { stationChild: env.stationChild },
|
|
13651
|
+
...env.navigatorByStatusPrepare === true ? { navigatorByStatusPrepare: true } : {},
|
|
13558
13652
|
// #1132: one configured ceiling, already resolved by the caller (#422).
|
|
13559
13653
|
deliveryRequestLimit: deliveryLimitFromConfig(env.autoResumeLimit)
|
|
13560
13654
|
};
|
|
@@ -18789,6 +18883,7 @@ async function summonPublicRole(options) {
|
|
|
18789
18883
|
// Nested court stations keep station-child semantics; dual-lens
|
|
18790
18884
|
// ordinary Reviewer axes opt out (#946 / ADR 0082).
|
|
18791
18885
|
...options.stationChild === false ? {} : { stationChild: true },
|
|
18886
|
+
...options.navigatorByStatusPrepare === true ? { navigatorByStatusPrepare: true } : {},
|
|
18792
18887
|
// Forward composition-root adapters so nested stations (e.g.
|
|
18793
18888
|
// secretariat → diarist) select the same faux/production table (#924).
|
|
18794
18889
|
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
@@ -20371,7 +20466,7 @@ init_navigator_invocation_identity();
|
|
|
20371
20466
|
init_packaged_role_registry();
|
|
20372
20467
|
init_activation_ledger_topology();
|
|
20373
20468
|
import { resolve as resolve14 } from "node:path";
|
|
20374
|
-
import
|
|
20469
|
+
import "typebox";
|
|
20375
20470
|
|
|
20376
20471
|
// src/navigator-public-session.ts
|
|
20377
20472
|
init_host_session_record();
|
|
@@ -20596,7 +20691,6 @@ async function navigatorHostRunResumable(home, runId) {
|
|
|
20596
20691
|
}
|
|
20597
20692
|
function createNativeNavigatorSessionFactory(deps) {
|
|
20598
20693
|
return async ({ context, tool }) => {
|
|
20599
|
-
let thinkingLevel;
|
|
20600
20694
|
const entries = [];
|
|
20601
20695
|
let providerFailure;
|
|
20602
20696
|
let noReceipt;
|
|
@@ -20624,6 +20718,9 @@ function createNativeNavigatorSessionFactory(deps) {
|
|
|
20624
20718
|
role: "navigator",
|
|
20625
20719
|
argv: [text],
|
|
20626
20720
|
cwd: context.cwd,
|
|
20721
|
+
// Attendance prepare always asks for structured byStatus (#1160).
|
|
20722
|
+
// Direct `ak-role navigator` never sets this flag.
|
|
20723
|
+
navigatorByStatusPrepare: true,
|
|
20627
20724
|
...summonHome === void 0 ? {} : { home: summonHome },
|
|
20628
20725
|
...context.signal === void 0 ? {} : { signal: context.signal }
|
|
20629
20726
|
};
|
|
@@ -20682,17 +20779,23 @@ function createNativeNavigatorSessionFactory(deps) {
|
|
|
20682
20779
|
if (outcome.kind !== "accepted") {
|
|
20683
20780
|
return;
|
|
20684
20781
|
}
|
|
20685
|
-
const {
|
|
20686
|
-
|
|
20782
|
+
const {
|
|
20783
|
+
byStatusToPlainObject: byStatusToPlainObject2,
|
|
20784
|
+
mergePreparedAdvice: mergePreparedAdvice2,
|
|
20785
|
+
preparedAdviceFromUnknown: preparedAdviceFromUnknown2
|
|
20786
|
+
} = await Promise.resolve().then(() => (init_navigator_output(), navigator_output_exports));
|
|
20787
|
+
let prepared = void 0;
|
|
20687
20788
|
for (const payload of outcome.payloads ?? []) {
|
|
20688
|
-
|
|
20689
|
-
if (prose !== void 0) proseParts.push(prose);
|
|
20789
|
+
prepared = mergePreparedAdvice2(prepared, preparedAdviceFromUnknown2(payload));
|
|
20690
20790
|
}
|
|
20691
|
-
if (
|
|
20791
|
+
if (prepared === void 0) return;
|
|
20692
20792
|
if (disposed) return;
|
|
20693
20793
|
await tool.execute(
|
|
20694
20794
|
"navigator-public-prepare",
|
|
20695
|
-
{
|
|
20795
|
+
{
|
|
20796
|
+
...prepared.prose === void 0 ? {} : { prose: prepared.prose },
|
|
20797
|
+
...prepared.byStatus.size === 0 ? {} : { byStatus: byStatusToPlainObject2(prepared.byStatus) }
|
|
20798
|
+
},
|
|
20696
20799
|
void 0,
|
|
20697
20800
|
void 0,
|
|
20698
20801
|
context
|
|
@@ -20721,16 +20824,13 @@ function createNativeNavigatorSessionFactory(deps) {
|
|
|
20721
20824
|
});
|
|
20722
20825
|
},
|
|
20723
20826
|
entries: () => entries,
|
|
20724
|
-
setModel: async (next
|
|
20725
|
-
let nextParsed;
|
|
20827
|
+
setModel: async (next) => {
|
|
20726
20828
|
try {
|
|
20727
|
-
|
|
20829
|
+
parseNavigatorModelSetting(next);
|
|
20728
20830
|
} catch (error) {
|
|
20729
20831
|
throw navigatorUnavailableError("model", error);
|
|
20730
20832
|
}
|
|
20731
|
-
thinkingLevel = nextThinking ?? nextParsed.thinkingLevel;
|
|
20732
20833
|
},
|
|
20733
|
-
getThinkingLevel: () => thinkingLevel,
|
|
20734
20834
|
dispose: async () => {
|
|
20735
20835
|
disposed = true;
|
|
20736
20836
|
}
|
|
@@ -20752,11 +20852,7 @@ function resolveNavigatorAuthorityMaterial(roleInput, fileAuthority) {
|
|
|
20752
20852
|
return void 0;
|
|
20753
20853
|
}
|
|
20754
20854
|
var NAVIGATOR_TARGETS = PACKAGED_ROLE_REGISTRY.map(({ role, phases }) => ({ role, phases }));
|
|
20755
|
-
var prepareSchema =
|
|
20756
|
-
prose: Type18.Optional(Type18.Unknown({
|
|
20757
|
-
description: "\u6E38\u5955\u4F7F\u6563\u6587\u5EFA\u8BAE\uFF0C\u539F\u6837\u5448\u73B0\u3002\u4E0D\u8981\u6C42 candidates/next \u7ED3\u6784\u3002"
|
|
20758
|
-
}))
|
|
20759
|
-
}, { additionalProperties: true });
|
|
20855
|
+
var prepareSchema = navigatorAdviceBodySchema;
|
|
20760
20856
|
var INVOCATION_ENTRY = NAVIGATOR_INVOCATION_ENTRY;
|
|
20761
20857
|
var SETTLEMENT_ENTRY = "ak-navigator-settlement";
|
|
20762
20858
|
function rejectedPrepareReason(entries, start) {
|
|
@@ -20781,8 +20877,8 @@ function rejectedPrepareReason(entries, start) {
|
|
|
20781
20877
|
}
|
|
20782
20878
|
return reason;
|
|
20783
20879
|
}
|
|
20784
|
-
function
|
|
20785
|
-
return
|
|
20880
|
+
function normalizePreparedAdvice(value) {
|
|
20881
|
+
return preparedAdviceFromUnknown(value);
|
|
20786
20882
|
}
|
|
20787
20883
|
function navigatorSubjectKey(subjectRoot, subject, provenance = "role_input") {
|
|
20788
20884
|
if (issueRoot(subjectRoot) !== void 0 || !subjectRoot.includes("/.ak/work/")) return subjectRoot;
|
|
@@ -20832,7 +20928,7 @@ function createNavigatorAttendance(options) {
|
|
|
20832
20928
|
let subject = options.subject;
|
|
20833
20929
|
let authority = options.authority;
|
|
20834
20930
|
let contextError = options.contextError;
|
|
20835
|
-
let
|
|
20931
|
+
let preparedAdvice;
|
|
20836
20932
|
const invocationPrincipal = options.invocationId ?? mintNavigatorInvocationId();
|
|
20837
20933
|
let activeInvocationId = invocationPrincipal;
|
|
20838
20934
|
let outputSink;
|
|
@@ -20857,7 +20953,6 @@ function createNavigatorAttendance(options) {
|
|
|
20857
20953
|
unavailableCause: failure.unavailableCause
|
|
20858
20954
|
};
|
|
20859
20955
|
};
|
|
20860
|
-
let prepareBoundSettlement;
|
|
20861
20956
|
const loadMaterialsAndSession = async (invocationId) => {
|
|
20862
20957
|
if (contextError !== void 0) throw navigatorUnavailableError("context", contextError);
|
|
20863
20958
|
if (typeof authority !== "string" || authority.trim() === "") {
|
|
@@ -20928,29 +21023,32 @@ function createNavigatorAttendance(options) {
|
|
|
20928
21023
|
if (session === void 0) throw new Error("Navigator session was not created");
|
|
20929
21024
|
return session;
|
|
20930
21025
|
};
|
|
20931
|
-
const prepare = async (
|
|
20932
|
-
const boundSettlement = prepareBoundSettlement;
|
|
20933
|
-
prepareBoundSettlement = void 0;
|
|
21026
|
+
const prepare = async () => {
|
|
20934
21027
|
const invocationId = invocationPrincipal;
|
|
20935
21028
|
activeInvocationId = invocationId;
|
|
20936
21029
|
let output;
|
|
20937
21030
|
let prepareBatchRejected = false;
|
|
20938
21031
|
outputSink = (value) => {
|
|
21032
|
+
const next = normalizePreparedAdvice(value);
|
|
20939
21033
|
if (output === void 0) {
|
|
20940
21034
|
output = value;
|
|
20941
21035
|
return;
|
|
20942
21036
|
}
|
|
20943
|
-
const
|
|
20944
|
-
|
|
20945
|
-
|
|
20946
|
-
|
|
21037
|
+
const merged = mergePreparedAdvice(normalizePreparedAdvice(output), next);
|
|
21038
|
+
output = {
|
|
21039
|
+
...merged?.prose === void 0 ? {} : { prose: merged.prose },
|
|
21040
|
+
...merged === void 0 || merged.byStatus.size === 0 ? {} : { byStatus: byStatusToPlainObject(merged.byStatus) }
|
|
21041
|
+
};
|
|
20947
21042
|
};
|
|
20948
|
-
const activeSession =
|
|
20949
|
-
if (boundSettlement === void 0) return void 0;
|
|
21043
|
+
const activeSession = await loadMaterialsAndSession(invocationId);
|
|
20950
21044
|
const request = JSON.stringify({
|
|
20951
|
-
|
|
21045
|
+
kind: "prepare",
|
|
21046
|
+
role: options.role,
|
|
21047
|
+
phase: options.phase,
|
|
20952
21048
|
invocationId,
|
|
20953
|
-
subjectKey
|
|
21049
|
+
subjectKey,
|
|
21050
|
+
subject,
|
|
21051
|
+
authority
|
|
20954
21052
|
});
|
|
20955
21053
|
try {
|
|
20956
21054
|
try {
|
|
@@ -20984,27 +21082,21 @@ function createNavigatorAttendance(options) {
|
|
|
20984
21082
|
}
|
|
20985
21083
|
};
|
|
20986
21084
|
await promptAllowingRejectedPrepare(request);
|
|
20987
|
-
|
|
20988
|
-
|
|
20989
|
-
|
|
20990
|
-
|
|
20991
|
-
|
|
20992
|
-
|
|
20993
|
-
|
|
20994
|
-
|
|
20995
|
-
|
|
20996
|
-
|
|
20997
|
-
return void 0;
|
|
20998
|
-
}
|
|
21085
|
+
while (output === void 0 && prepareBatchRejected && delivery.nextAction() === "request-delivery") {
|
|
21086
|
+
delivery.recordDeliveryRequest();
|
|
21087
|
+
await promptAllowingRejectedPrepare(JSON.stringify(delivery.deliveryState()));
|
|
21088
|
+
}
|
|
21089
|
+
if (output === void 0 && delivery.nextAction() === "request-delivery") {
|
|
21090
|
+
delivery.closeBudget();
|
|
21091
|
+
}
|
|
21092
|
+
if (output === void 0 && delivery.nextAction() === "no-receipt" && activeSession.providerFailure?.() === void 0) {
|
|
21093
|
+
preparedAdvice = void 0;
|
|
21094
|
+
return void 0;
|
|
20999
21095
|
}
|
|
21000
21096
|
} catch (error) {
|
|
21001
21097
|
throw error instanceof NavigatorUnavailableError ? error : navigatorUnavailableError("transport", error);
|
|
21002
21098
|
}
|
|
21003
21099
|
if (output === void 0) {
|
|
21004
|
-
if (boundSettlement === void 0) {
|
|
21005
|
-
preparedProse = void 0;
|
|
21006
|
-
return void 0;
|
|
21007
|
-
}
|
|
21008
21100
|
const nativeFailure = [...activeSession.entries()].reverse().find((entry) => {
|
|
21009
21101
|
if (!isRecord(entry) || entry.type !== "message" || !isRecord(entry.message)) return false;
|
|
21010
21102
|
return entry.message.role === "assistant" && typeof entry.message.errorMessage === "string" && entry.message.errorMessage.trim() !== "";
|
|
@@ -21016,12 +21108,8 @@ function createNavigatorAttendance(options) {
|
|
|
21016
21108
|
const cause = providerFailure?.cause ?? source;
|
|
21017
21109
|
throw navigatorUnavailableError(source, errorMessage, cause);
|
|
21018
21110
|
}
|
|
21019
|
-
|
|
21020
|
-
|
|
21021
|
-
return void 0;
|
|
21022
|
-
}
|
|
21023
|
-
preparedProse = normalizePrepareProse(output);
|
|
21024
|
-
return preparedProse;
|
|
21111
|
+
preparedAdvice = normalizePreparedAdvice(output);
|
|
21112
|
+
return preparedAdvice;
|
|
21025
21113
|
} finally {
|
|
21026
21114
|
const playbookFailure = activeSession.routePlaybookReadFailure?.();
|
|
21027
21115
|
observedRoutePlaybookFailure = typeof playbookFailure === "string" && playbookFailure.trim() !== "" ? playbookFailure : void 0;
|
|
@@ -21045,6 +21133,7 @@ function createNavigatorAttendance(options) {
|
|
|
21045
21133
|
prepare() {
|
|
21046
21134
|
if (disposed || preparation !== void 0) return;
|
|
21047
21135
|
preparationFailure = void 0;
|
|
21136
|
+
preparedAdvice = void 0;
|
|
21048
21137
|
preparationInFlight = true;
|
|
21049
21138
|
preparation = prepare().finally(() => {
|
|
21050
21139
|
preparationInFlight = false;
|
|
@@ -21082,24 +21171,8 @@ function createNavigatorAttendance(options) {
|
|
|
21082
21171
|
};
|
|
21083
21172
|
async function settleOnce(settlement) {
|
|
21084
21173
|
if (disposed) return;
|
|
21085
|
-
observedRoutePlaybookFailure = void 0;
|
|
21086
21174
|
const invocationId = activeInvocationId ?? invocationPrincipal;
|
|
21087
21175
|
let report;
|
|
21088
|
-
if (sessionReady !== void 0) {
|
|
21089
|
-
try {
|
|
21090
|
-
await sessionReady;
|
|
21091
|
-
} catch (error) {
|
|
21092
|
-
preparationFailure ??= error;
|
|
21093
|
-
}
|
|
21094
|
-
}
|
|
21095
|
-
if (preparation !== void 0) {
|
|
21096
|
-
try {
|
|
21097
|
-
await preparation;
|
|
21098
|
-
} catch (error) {
|
|
21099
|
-
preparationFailure ??= error;
|
|
21100
|
-
}
|
|
21101
|
-
preparation = void 0;
|
|
21102
|
-
}
|
|
21103
21176
|
const settlementFact = {
|
|
21104
21177
|
invocationId,
|
|
21105
21178
|
subjectKey,
|
|
@@ -21108,8 +21181,14 @@ function createNavigatorAttendance(options) {
|
|
|
21108
21181
|
kind: settlement.kind,
|
|
21109
21182
|
..."status" in settlement && settlement.status !== void 0 ? { status: settlement.status } : {}
|
|
21110
21183
|
};
|
|
21111
|
-
let drainedProse;
|
|
21112
21184
|
if (settlement.kind === "arrival") {
|
|
21185
|
+
if (sessionReady !== void 0) {
|
|
21186
|
+
try {
|
|
21187
|
+
await sessionReady;
|
|
21188
|
+
} catch (error) {
|
|
21189
|
+
preparationFailure ??= error;
|
|
21190
|
+
}
|
|
21191
|
+
}
|
|
21113
21192
|
session?.appendEntry(SETTLEMENT_ENTRY, settlementFact);
|
|
21114
21193
|
if (preparationFailure !== void 0) {
|
|
21115
21194
|
report = unavailable(invocationId, preparationFailure);
|
|
@@ -21120,35 +21199,32 @@ function createNavigatorAttendance(options) {
|
|
|
21120
21199
|
};
|
|
21121
21200
|
}
|
|
21122
21201
|
} else {
|
|
21123
|
-
if (
|
|
21124
|
-
let coldSession;
|
|
21125
|
-
if (session === void 0 && preparationFailure === void 0) {
|
|
21202
|
+
if (sessionReady !== void 0) {
|
|
21126
21203
|
try {
|
|
21127
|
-
|
|
21204
|
+
await sessionReady;
|
|
21128
21205
|
} catch (error) {
|
|
21129
|
-
preparationFailure
|
|
21206
|
+
preparationFailure ??= error;
|
|
21130
21207
|
}
|
|
21131
21208
|
}
|
|
21132
|
-
|
|
21133
|
-
if (preparationFailure === void 0) {
|
|
21134
|
-
prepareBoundSettlement = settlement;
|
|
21135
|
-
preparation = prepare(coldSession);
|
|
21136
|
-
void preparation.catch((error) => {
|
|
21137
|
-
preparationFailure = error;
|
|
21138
|
-
});
|
|
21209
|
+
if (preparation !== void 0) {
|
|
21139
21210
|
try {
|
|
21140
|
-
|
|
21211
|
+
await preparation;
|
|
21141
21212
|
} catch (error) {
|
|
21142
21213
|
preparationFailure ??= error;
|
|
21143
21214
|
}
|
|
21144
21215
|
preparation = void 0;
|
|
21145
21216
|
}
|
|
21217
|
+
session?.appendEntry(SETTLEMENT_ENTRY, settlementFact);
|
|
21146
21218
|
if (preparationFailure !== void 0) {
|
|
21147
21219
|
report = unavailable(invocationId, preparationFailure);
|
|
21148
|
-
} else if (typeof drainedProse === "string" && drainedProse.trim() !== "") {
|
|
21149
|
-
report = { disposition: "advice", prose: drainedProse };
|
|
21150
21220
|
} else {
|
|
21151
|
-
|
|
21221
|
+
const status = "status" in settlement ? settlement.status : void 0;
|
|
21222
|
+
const picked = pickPreparedProse(preparedAdvice, status);
|
|
21223
|
+
if (typeof picked === "string" && picked.trim() !== "") {
|
|
21224
|
+
report = { disposition: "advice", prose: picked };
|
|
21225
|
+
} else {
|
|
21226
|
+
report = { disposition: "no-advice" };
|
|
21227
|
+
}
|
|
21152
21228
|
}
|
|
21153
21229
|
}
|
|
21154
21230
|
if (observedRoutePlaybookFailure !== void 0) {
|
|
@@ -21177,8 +21253,9 @@ function createNavigatorAttendance(options) {
|
|
|
21177
21253
|
}
|
|
21178
21254
|
preparation = void 0;
|
|
21179
21255
|
sessionReady = void 0;
|
|
21180
|
-
|
|
21256
|
+
preparedAdvice = void 0;
|
|
21181
21257
|
preparationFailure = void 0;
|
|
21258
|
+
observedRoutePlaybookFailure = void 0;
|
|
21182
21259
|
}
|
|
21183
21260
|
}
|
|
21184
21261
|
|
|
@@ -21296,18 +21373,18 @@ import { join as join30 } from "node:path";
|
|
|
21296
21373
|
import { Value as Value3 } from "typebox/value";
|
|
21297
21374
|
|
|
21298
21375
|
// src/activation-trace.ts
|
|
21299
|
-
import { Type as
|
|
21300
|
-
var causeSchema =
|
|
21301
|
-
identity:
|
|
21302
|
-
name:
|
|
21303
|
-
message:
|
|
21304
|
-
evidenceId:
|
|
21376
|
+
import { Type as Type18 } from "typebox";
|
|
21377
|
+
var causeSchema = Type18.Object({
|
|
21378
|
+
identity: Type18.String({ minLength: 1 }),
|
|
21379
|
+
name: Type18.String({ minLength: 1 }),
|
|
21380
|
+
message: Type18.String(),
|
|
21381
|
+
evidenceId: Type18.Optional(Type18.String({ minLength: 1 }))
|
|
21305
21382
|
}, { additionalProperties: false });
|
|
21306
|
-
var activationTraceRecordSchema =
|
|
21307
|
-
role:
|
|
21308
|
-
stageId:
|
|
21309
|
-
status:
|
|
21310
|
-
timestamp:
|
|
21383
|
+
var activationTraceRecordSchema = Type18.Object({
|
|
21384
|
+
role: Type18.String({ minLength: 1 }),
|
|
21385
|
+
stageId: Type18.String({ pattern: "^[a-z][a-z0-9-]*$" }),
|
|
21386
|
+
status: Type18.Literal("failed"),
|
|
21387
|
+
timestamp: Type18.String({ format: "date-time" }),
|
|
21311
21388
|
cause: causeSchema
|
|
21312
21389
|
}, { additionalProperties: false });
|
|
21313
21390
|
var activationCauseEvidence = 0;
|
|
@@ -21472,10 +21549,10 @@ init_engine_material();
|
|
|
21472
21549
|
init_engine_detour();
|
|
21473
21550
|
init_engine_detour_usage();
|
|
21474
21551
|
init_run_terminal_artifacts();
|
|
21475
|
-
import { Type as
|
|
21476
|
-
var engineDetourArgsSchema =
|
|
21552
|
+
import { Type as Type19 } from "typebox";
|
|
21553
|
+
var engineDetourArgsSchema = Type19.Object(
|
|
21477
21554
|
{
|
|
21478
|
-
argv:
|
|
21555
|
+
argv: Type19.Array(Type19.String({ minLength: 1 }), {
|
|
21479
21556
|
minItems: 1,
|
|
21480
21557
|
description: "\u9996\u9879\u4E3A PATH \u4E2D\u7684\u53EF\u6267\u884C\u6587\u4EF6\uFF0C\u5176\u4F59\u9879\u4E3A\u53C2\u6570\u3002"
|
|
21481
21558
|
})
|
|
@@ -25017,6 +25094,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
25017
25094
|
const prepared = await config.prepare(request);
|
|
25018
25095
|
const systemPrompt = renderSystemPromptOverride(prepared.systemPrompt);
|
|
25019
25096
|
const codex = isCodexExecDescription(config.description);
|
|
25097
|
+
const navigatorProseExit = prepared.terminatingToolName === NAVIGATOR_OUTPUT_TOOL_NAME && request.navigatorByStatusPrepare !== true;
|
|
25020
25098
|
let outcome = externalHostFailure("session", "HeadlessNoOutcome", "no-outcome");
|
|
25021
25099
|
try {
|
|
25022
25100
|
let sessionId = await resolveBoundHostSessionId(request, config.sessionIdentity);
|
|
@@ -25045,7 +25123,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
25045
25123
|
await writeFile6(systemPromptPath, systemPrompt, "utf8");
|
|
25046
25124
|
let deliveredSchema;
|
|
25047
25125
|
if (codex) {
|
|
25048
|
-
if (
|
|
25126
|
+
if (!navigatorProseExit) {
|
|
25049
25127
|
outputSchemaPath = join31(inputsDirectory, "output-schema.json");
|
|
25050
25128
|
deliveredSchema = closeJsonSchemaForCodex(prepared.jsonSchema);
|
|
25051
25129
|
await writeFile6(outputSchemaPath, `${JSON.stringify(deliveredSchema, null, 2)}
|
|
@@ -25059,7 +25137,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
25059
25137
|
`,
|
|
25060
25138
|
"utf8"
|
|
25061
25139
|
);
|
|
25062
|
-
if (
|
|
25140
|
+
if (!navigatorProseExit) deliveredSchema = prepared.jsonSchema;
|
|
25063
25141
|
}
|
|
25064
25142
|
startedWithSchema = deliveredSchema;
|
|
25065
25143
|
} catch (setupError) {
|
|
@@ -25088,8 +25166,8 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
25088
25166
|
args = buildTurnArgs({
|
|
25089
25167
|
description: config.description,
|
|
25090
25168
|
systemPromptPath,
|
|
25091
|
-
//
|
|
25092
|
-
...
|
|
25169
|
+
// Direct navigator prose exit omits --json-schema; byStatus prepare mounts it.
|
|
25170
|
+
...navigatorProseExit ? {} : { jsonSchema: prepared.jsonSchema },
|
|
25093
25171
|
mcpServers: prepared.mcpServers,
|
|
25094
25172
|
...mcpConfigPath === void 0 ? {} : { mcpConfigPath },
|
|
25095
25173
|
...outputSchemaPath === void 0 ? {} : { outputSchemaPath },
|
|
@@ -25212,10 +25290,9 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
25212
25290
|
...observation.failureEvent === void 0 ? {} : { details: observation.failureEvent }
|
|
25213
25291
|
});
|
|
25214
25292
|
}
|
|
25215
|
-
const navigator = prepared.terminatingToolName === NAVIGATOR_OUTPUT_TOOL_NAME;
|
|
25216
25293
|
const deliverReply = async () => {
|
|
25217
25294
|
if (!observation.turnCompleted || observation.finalMessage === void 0) return void 0;
|
|
25218
|
-
if (
|
|
25295
|
+
if (navigatorProseExit) {
|
|
25219
25296
|
if (observation.finalMessage.trim() === "") return void 0;
|
|
25220
25297
|
await prepared.ingestStructuredOutput({ prose: observation.finalMessage });
|
|
25221
25298
|
return deliveredFromSpawned(spawned);
|
|
@@ -25253,7 +25330,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
25253
25330
|
}
|
|
25254
25331
|
if (envelope.structured_output !== void 0) {
|
|
25255
25332
|
await prepared.ingestStructuredOutput(envelope.structured_output);
|
|
25256
|
-
} else if (
|
|
25333
|
+
} else if (navigatorProseExit && typeof envelope.result === "string" && envelope.result.trim() !== "") {
|
|
25257
25334
|
await prepared.ingestStructuredOutput({ prose: envelope.result });
|
|
25258
25335
|
}
|
|
25259
25336
|
return deliveredFromSpawned(spawned);
|
|
@@ -8584,7 +8584,7 @@ var init_gatekeeper_output = __esm({
|
|
|
8584
8584
|
});
|
|
8585
8585
|
|
|
8586
8586
|
// src/package-contracts/navigator-output.ts
|
|
8587
|
-
var NAVIGATOR_OUTPUT_TOOL_NAME, navigatorOutputSchema;
|
|
8587
|
+
var NAVIGATOR_OUTPUT_TOOL_NAME, navigatorAdviceFields, navigatorAdviceBodySchema, navigatorOutputSchema;
|
|
8588
8588
|
var init_navigator_output = __esm({
|
|
8589
8589
|
"src/package-contracts/navigator-output.ts"() {
|
|
8590
8590
|
"use strict";
|
|
@@ -8593,15 +8593,16 @@ var init_navigator_output = __esm({
|
|
|
8593
8593
|
init_open_tool_schema();
|
|
8594
8594
|
init_terminating_infrastructure();
|
|
8595
8595
|
NAVIGATOR_OUTPUT_TOOL_NAME = "ak_navigator_output";
|
|
8596
|
-
|
|
8597
|
-
|
|
8598
|
-
|
|
8599
|
-
|
|
8600
|
-
|
|
8601
|
-
|
|
8602
|
-
|
|
8603
|
-
|
|
8604
|
-
);
|
|
8596
|
+
navigatorAdviceFields = {
|
|
8597
|
+
prose: typebox_exports.Unknown({
|
|
8598
|
+
description: "\u5355\u6761\u6563\u6587\u5EFA\u8BAE\u3002\u65E0\u72B6\u6001\u5206\u53C9\u65F6\u4F7F\u7528\uFF1B\u539F\u6837\u5448\u73B0\u3002"
|
|
8599
|
+
}),
|
|
8600
|
+
byStatus: typebox_exports.Unknown({
|
|
8601
|
+
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"
|
|
8602
|
+
})
|
|
8603
|
+
};
|
|
8604
|
+
navigatorAdviceBodySchema = openToolObject(typebox_exports.Object(navigatorAdviceFields));
|
|
8605
|
+
navigatorOutputSchema = withTerminatingOutputDeclarations(navigatorAdviceBodySchema);
|
|
8605
8606
|
}
|
|
8606
8607
|
});
|
|
8607
8608
|
|