@akagilnc/pi-workflow-roles 0.1.4528 → 0.1.4620
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 +5 -4
- package/README.zh-CN.md +6 -5
- package/dist/acp-host/production-host.js +1834 -637
- package/dist/archivist-record-topology.js +27 -35
- package/dist/headless-host/description.js +7 -4
- package/dist/headless-host/production-host.js +1652 -519
- package/dist/migrate-book-topology.js +8 -11
- package/dist/navigator-attendance.js +146 -241
- package/dist/navigator-public-session.js +81 -15
- package/dist/package-contracts/navigator-output.js +30 -12
- package/dist/public-cli/invocation.js +10 -4
- package/dist/public-cli/judge-run.js +2 -2
- package/dist/public-cli/main.js +879 -410
- package/dist/public-cli/option-definitions.js +6 -6
- package/dist/public-cli/post-admission.js +25 -10
- package/dist/public-cli/reviewer-run.js +339 -0
- package/dist/public-cli/run-lifecycle.js +29 -7
- package/dist/public-cli/settlement.js +46 -32
- package/dist/public-cli/terminal.js +17 -27
- package/dist/public-cli/turn-request.js +1 -1
- package/dist/public-role-summons.js +370 -20
- package/dist/submission-ledger.js +56 -23
- package/package.json +1 -1
- package/resources/836-deleted-machine-instruction-inventory.md +2 -0
- package/resources/navigator-route-playbook.md +9 -0
- package/scripts/build-package.mjs +6 -1
- package/src/acp-host/role-turn-host.ts +129 -13
- package/src/headless-host/description.ts +17 -7
- package/src/headless-host/role-turn-host.ts +42 -11
- package/src/host-contracts.ts +0 -1
- package/src/navigator-attendance.ts +290 -425
- package/src/navigator-public-session.ts +126 -25
- package/src/navigator-role.ts +2 -2
- package/src/package-contracts/navigator-output.ts +41 -25
- package/src/public-cli/coder-run.ts +2 -2
- package/src/public-cli/fixer-run.ts +2 -2
- package/src/public-cli/invocation.ts +19 -9
- package/src/public-cli/judge-run.ts +2 -2
- package/src/public-cli/merger-run.ts +2 -2
- package/src/public-cli/option-definitions.ts +6 -6
- package/src/public-cli/post-admission.ts +41 -10
- package/src/public-cli/reviewer-run.ts +238 -53
- package/src/public-cli/run-lifecycle.ts +37 -7
- package/src/public-cli/settlement.ts +42 -34
- package/src/public-cli/terminal.ts +39 -37
- package/src/public-cli/turn-request.ts +7 -1
- package/src/public-role-summons.ts +544 -22
- package/src/reviewer-role.ts +1 -2
- package/src/role-envelope.ts +89 -4
- package/src/role-runtime.ts +76 -16
- package/src/submission-ledger.ts +63 -21
- package/dist/public-cli/command-renderer.js +0 -5
- package/dist/public-command-renderer.js +0 -29
- package/src/public-cli/command-renderer.ts +0 -9
- package/src/public-command-renderer.ts +0 -55
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { basename } from "node:path";
|
|
1
2
|
import { sitianReport } from "./sitian-facade.js";
|
|
2
3
|
import {
|
|
3
4
|
NavigatorUnavailableError,
|
|
@@ -7,6 +8,7 @@ import {
|
|
|
7
8
|
parseNavigatorModelSetting
|
|
8
9
|
} from "./navigator-session-contracts.js";
|
|
9
10
|
import { runDirectoryFromHostContext } from "./host-contracts.js";
|
|
11
|
+
import { CliUsageError } from "./public-cli/cli-errors.js";
|
|
10
12
|
async function resolveNavigatorLedgerHome(context) {
|
|
11
13
|
const { tryHomeFromAkRolesPath } = await import("./activation-ledger-topology.js");
|
|
12
14
|
const runDirectory = runDirectoryFromHostContext(context);
|
|
@@ -21,7 +23,42 @@ async function resolveNavigatorLedgerHome(context) {
|
|
|
21
23
|
}
|
|
22
24
|
return void 0;
|
|
23
25
|
}
|
|
24
|
-
|
|
26
|
+
const NAVIGATOR_HOST_RUN_POINTER_ENTRY = "ak-navigator-host-run";
|
|
27
|
+
function exactRecord(value) {
|
|
28
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
29
|
+
}
|
|
30
|
+
function runIdFromNavigatorDirectory(runDirectory) {
|
|
31
|
+
const entry = basename(runDirectory);
|
|
32
|
+
const suffix = "@navigator";
|
|
33
|
+
if (!entry.endsWith(suffix)) return void 0;
|
|
34
|
+
const runId = entry.slice(0, entry.length - suffix.length);
|
|
35
|
+
return runId.length > 0 ? runId : void 0;
|
|
36
|
+
}
|
|
37
|
+
function readNavigatorHostRunPointer(entries) {
|
|
38
|
+
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
39
|
+
const entry = entries[index];
|
|
40
|
+
if (!exactRecord(entry)) continue;
|
|
41
|
+
if (entry.type === "custom" && entry.customType === NAVIGATOR_HOST_RUN_POINTER_ENTRY) {
|
|
42
|
+
const data = entry.data;
|
|
43
|
+
if (exactRecord(data) && typeof data.runId === "string" && data.runId.trim() !== "") {
|
|
44
|
+
return data.runId.trim();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return void 0;
|
|
49
|
+
}
|
|
50
|
+
async function navigatorHostRunResumable(home, runId) {
|
|
51
|
+
const { piDurablePrincipalAuthority } = await import("./pi/durable-principal.js");
|
|
52
|
+
const { loadResumableInstructionSeatRun } = await import("./public-cli/run-lifecycle.js");
|
|
53
|
+
try {
|
|
54
|
+
const loaded = await loadResumableInstructionSeatRun(home, runId, piDurablePrincipalAuthority);
|
|
55
|
+
return loaded.admitted.role === "navigator";
|
|
56
|
+
} catch (error) {
|
|
57
|
+
if (error instanceof CliUsageError) return false;
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function createNativeNavigatorSessionFactory(deps) {
|
|
25
62
|
return async ({ context, subject, tool }) => {
|
|
26
63
|
let thinkingLevel;
|
|
27
64
|
const { createRecordSession, NAVIGATOR_RECORD_KIND } = await import("./archivist-record-entry.js");
|
|
@@ -37,6 +74,11 @@ function createNativeNavigatorSessionFactory() {
|
|
|
37
74
|
let noReceipt;
|
|
38
75
|
let disposed = false;
|
|
39
76
|
let inFlightPrompt;
|
|
77
|
+
let hostRunId = readNavigatorHostRunPointer(sessionManager.getEntries());
|
|
78
|
+
const summon = deps?.summonPublicRole ?? (async (options) => {
|
|
79
|
+
const { summonPublicRole } = await import("./public-role-summons.js");
|
|
80
|
+
return summonPublicRole(options);
|
|
81
|
+
});
|
|
40
82
|
return {
|
|
41
83
|
prompt: async (text) => {
|
|
42
84
|
if (disposed) {
|
|
@@ -46,14 +88,24 @@ function createNativeNavigatorSessionFactory() {
|
|
|
46
88
|
noReceipt = void 0;
|
|
47
89
|
const run = (async () => {
|
|
48
90
|
try {
|
|
49
|
-
const { summonPublicRole } = await import("./public-role-summons.js");
|
|
50
91
|
const summonHome = await resolveNavigatorLedgerHome(context);
|
|
51
|
-
const
|
|
92
|
+
const resumeRunId = hostRunId;
|
|
93
|
+
const baseSummon = {
|
|
52
94
|
role: "navigator",
|
|
53
95
|
argv: [text],
|
|
54
96
|
cwd: context.cwd,
|
|
55
97
|
...summonHome === void 0 ? {} : { home: summonHome }
|
|
56
|
-
}
|
|
98
|
+
};
|
|
99
|
+
const resumable = deps?.hostRunResumable ?? navigatorHostRunResumable;
|
|
100
|
+
let summoned;
|
|
101
|
+
if (resumeRunId === void 0 || summonHome === void 0) {
|
|
102
|
+
summoned = await summon(baseSummon);
|
|
103
|
+
} else if (await resumable(summonHome, resumeRunId)) {
|
|
104
|
+
summoned = await summon({ ...baseSummon, resumeRunId });
|
|
105
|
+
} else {
|
|
106
|
+
hostRunId = void 0;
|
|
107
|
+
summoned = await summon(baseSummon);
|
|
108
|
+
}
|
|
57
109
|
const outcome = summoned.terminal?.roleOutcome;
|
|
58
110
|
if (outcome === void 0) {
|
|
59
111
|
const detail = summoned.stderr?.trim() || `exit ${summoned.exitCode}`;
|
|
@@ -76,21 +128,31 @@ function createNativeNavigatorSessionFactory() {
|
|
|
76
128
|
noReceipt = outcome;
|
|
77
129
|
return;
|
|
78
130
|
}
|
|
131
|
+
const runDirectory = summoned.runDirectory ?? (typeof summoned.admitted?.runDirectory === "string" ? summoned.admitted.runDirectory : void 0);
|
|
132
|
+
if (typeof runDirectory === "string" && runDirectory.trim() !== "") {
|
|
133
|
+
const nextRunId = runIdFromNavigatorDirectory(runDirectory);
|
|
134
|
+
if (nextRunId !== void 0) {
|
|
135
|
+
hostRunId = nextRunId;
|
|
136
|
+
sessionManager.appendCustomEntry(NAVIGATOR_HOST_RUN_POINTER_ENTRY, { runId: nextRunId });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
79
139
|
if (outcome.kind !== "accepted") {
|
|
80
140
|
return;
|
|
81
141
|
}
|
|
142
|
+
const { navigatorProseFromUnknown } = await import("./package-contracts/navigator-output.js");
|
|
143
|
+
const proseParts = [];
|
|
82
144
|
for (const payload of outcome.payloads ?? []) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (!Array.isArray(candidates)) continue;
|
|
86
|
-
await tool.execute(
|
|
87
|
-
"navigator-public-prepare",
|
|
88
|
-
{ candidates },
|
|
89
|
-
void 0,
|
|
90
|
-
void 0,
|
|
91
|
-
context
|
|
92
|
-
);
|
|
145
|
+
const prose = navigatorProseFromUnknown(payload);
|
|
146
|
+
if (prose !== void 0) proseParts.push(prose);
|
|
93
147
|
}
|
|
148
|
+
if (proseParts.length === 0) return;
|
|
149
|
+
await tool.execute(
|
|
150
|
+
"navigator-public-prepare",
|
|
151
|
+
{ prose: proseParts.join("\n\n") },
|
|
152
|
+
void 0,
|
|
153
|
+
void 0,
|
|
154
|
+
context
|
|
155
|
+
);
|
|
94
156
|
} catch (error) {
|
|
95
157
|
if (error instanceof NavigatorUnavailableError) throw error;
|
|
96
158
|
const fact = navigatorProviderFailureFromError(error);
|
|
@@ -142,5 +204,9 @@ function createNativeNavigatorSessionFactory() {
|
|
|
142
204
|
};
|
|
143
205
|
}
|
|
144
206
|
export {
|
|
145
|
-
|
|
207
|
+
NAVIGATOR_HOST_RUN_POINTER_ENTRY,
|
|
208
|
+
createNativeNavigatorSessionFactory,
|
|
209
|
+
navigatorHostRunResumable,
|
|
210
|
+
readNavigatorHostRunPointer,
|
|
211
|
+
runIdFromNavigatorDirectory
|
|
146
212
|
};
|
|
@@ -6,31 +6,49 @@ const NAVIGATOR_ACCEPTED_TEXT = "\u6E38\u5955\u4F7F\u5EFA\u8BAE\u5DF2\u53D7\u740
|
|
|
6
6
|
const navigatorOutputSchema = withTerminatingOutputDeclarations(
|
|
7
7
|
openToolObject(
|
|
8
8
|
Type.Object({
|
|
9
|
-
|
|
10
|
-
description: "
|
|
11
|
-
}),
|
|
12
|
-
candidates: Type.Unknown({
|
|
13
|
-
description: "\u6392\u597D\u5E8F\u7684\u8DEF\u7EBF\u5EFA\u8BAE\u6570\u7EC4\uFF0C\u5143\u7D20\u542B next/phase/reason \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
|
|
9
|
+
prose: Type.Unknown({
|
|
10
|
+
description: "\u6E38\u5955\u4F7F\u6563\u6587\u5EFA\u8BAE\uFF0C\u539F\u6837\u5448\u73B0\u3002\u4E0D\u8981\u6C42 candidates/next \u7B49\u7ED3\u6784\u5316\u5B57\u6BB5\u3002\u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
|
|
14
11
|
})
|
|
15
12
|
})
|
|
16
13
|
)
|
|
17
14
|
);
|
|
18
|
-
function isRecord(value) {
|
|
19
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20
|
-
}
|
|
21
15
|
function projectLawfulNavigatorOutput(value) {
|
|
22
|
-
|
|
16
|
+
if (value === void 0 || value === null) return void 0;
|
|
17
|
+
if (typeof value === "string") return { prose: value };
|
|
18
|
+
if (typeof value === "object" && !Array.isArray(value)) {
|
|
19
|
+
const record = value;
|
|
20
|
+
if (typeof record.prose === "string") return { prose: record.prose };
|
|
21
|
+
if (record.prose !== void 0 && record.prose !== null) {
|
|
22
|
+
return { prose: typeof record.prose === "string" ? record.prose : String(record.prose) };
|
|
23
|
+
}
|
|
24
|
+
const keys = Object.keys(record);
|
|
25
|
+
if (keys.length === 0) return { prose: "" };
|
|
26
|
+
try {
|
|
27
|
+
return { prose: JSON.stringify(record) };
|
|
28
|
+
} catch {
|
|
29
|
+
return { prose: String(record) };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return { prose: String(value) };
|
|
23
33
|
}
|
|
24
34
|
function validateRecordedNavigatorOutput(value) {
|
|
25
|
-
|
|
26
|
-
|
|
35
|
+
const projected = projectLawfulNavigatorOutput(value);
|
|
36
|
+
if (projected === void 0) {
|
|
37
|
+
throw new Error("Navigator output is empty");
|
|
27
38
|
}
|
|
28
|
-
return
|
|
39
|
+
return projected;
|
|
40
|
+
}
|
|
41
|
+
function navigatorProseFromUnknown(value) {
|
|
42
|
+
const projected = projectLawfulNavigatorOutput(value);
|
|
43
|
+
if (projected === void 0) return void 0;
|
|
44
|
+
const trimmed = projected.prose.trim();
|
|
45
|
+
return trimmed === "" ? void 0 : projected.prose;
|
|
29
46
|
}
|
|
30
47
|
export {
|
|
31
48
|
NAVIGATOR_ACCEPTED_TEXT,
|
|
32
49
|
NAVIGATOR_OUTPUT_TOOL_NAME,
|
|
33
50
|
navigatorOutputSchema,
|
|
51
|
+
navigatorProseFromUnknown,
|
|
34
52
|
projectLawfulNavigatorOutput,
|
|
35
53
|
validateRecordedNavigatorOutput
|
|
36
54
|
};
|
|
@@ -436,7 +436,7 @@ export function requireReviewerBaseRevision(value) {
|
|
|
436
436
|
export function isReviewerLens(value) {
|
|
437
437
|
return value === "completeness" || value === "correctness";
|
|
438
438
|
}
|
|
439
|
-
/**
|
|
439
|
+
/** Admitted single-axis lens enum; public `--lens all` and bare omission are not admitted values. */
|
|
440
440
|
export function requireReviewerLens(value) {
|
|
441
441
|
const trimmed = (value ?? "").trim();
|
|
442
442
|
if (!isReviewerLens(trimmed)) {
|
|
@@ -1952,7 +1952,7 @@ export function parseReviewerArgv(args) {
|
|
|
1952
1952
|
continue;
|
|
1953
1953
|
}
|
|
1954
1954
|
if (taken.def.id === "lens") {
|
|
1955
|
-
//
|
|
1955
|
+
// Public override is single-axis only; omission stays undefined for the parallel branch.
|
|
1956
1956
|
lens = requireReviewerLens(taken.value);
|
|
1957
1957
|
continue;
|
|
1958
1958
|
}
|
|
@@ -1968,13 +1968,13 @@ export function parseReviewerArgv(args) {
|
|
|
1968
1968
|
}
|
|
1969
1969
|
positional.push(token);
|
|
1970
1970
|
}
|
|
1971
|
-
//
|
|
1971
|
+
// Base and authority are required; omitted lens selects the parallel two-axis mode.
|
|
1972
1972
|
options.assertRequired();
|
|
1973
1973
|
return {
|
|
1974
1974
|
instruction: positional.join(" "),
|
|
1975
1975
|
attachmentPaths,
|
|
1976
1976
|
baseRevision: baseRevision,
|
|
1977
|
-
lens: lens,
|
|
1977
|
+
...(lens === undefined ? {} : { lens }),
|
|
1978
1978
|
authorityRefs,
|
|
1979
1979
|
...(project === undefined ? {} : { project }),
|
|
1980
1980
|
};
|
|
@@ -2019,6 +2019,9 @@ export async function admitReviewerInvocation(options) {
|
|
|
2019
2019
|
baseRevision,
|
|
2020
2020
|
lens,
|
|
2021
2021
|
authorityRefs: [...authorityRefs],
|
|
2022
|
+
...(options.correlationId === undefined
|
|
2023
|
+
? {}
|
|
2024
|
+
: { correlationId: options.correlationId }),
|
|
2022
2025
|
attachments: attachments.map((a) => ({
|
|
2023
2026
|
provenancePath: a.provenancePath,
|
|
2024
2027
|
frozenPath: a.frozenPath,
|
|
@@ -2047,6 +2050,9 @@ export async function admitReviewerInvocation(options) {
|
|
|
2047
2050
|
baseRevision,
|
|
2048
2051
|
lens,
|
|
2049
2052
|
authorityRefs,
|
|
2053
|
+
...(options.correlationId === undefined
|
|
2054
|
+
? {}
|
|
2055
|
+
: { correlationId: options.correlationId }),
|
|
2050
2056
|
};
|
|
2051
2057
|
}
|
|
2052
2058
|
/** Frozen Skill arg projection shared by initial and resume (never reverse-parsed). */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { engineSessionMaterialFromOptions, pickEngineAxis } from "../package-resources/engine-material.js";
|
|
2
2
|
import { CliUsageError } from "./cli-errors.js";
|
|
3
3
|
import { admitJudgeInvocation, buildJudgeTransportPrompt, } from "./invocation.js";
|
|
4
|
-
import { loadResumableJudgeRun, markRunAdmitted,
|
|
4
|
+
import { loadResumableJudgeRun, markRunAdmitted, buildAutoResumeContinuationPrompt, } from "./run-lifecycle.js";
|
|
5
5
|
import { presentStructuralRejection, readEngineDetourInfrastructureFailure, trySettleJudgeTerminalResult, } from "./settlement.js";
|
|
6
6
|
import { projectRoleTurnRequest, } from "./turn-request.js";
|
|
7
7
|
import { runPostAdmissionResumable, runPostAdmissionSeatResume, resumeTurnRequestProjectionOptions, } from "./post-admission.js";
|
|
@@ -86,7 +86,7 @@ export async function runPublicJudge(argv, env, io, parseJudgeArgv) {
|
|
|
86
86
|
: { correlationId: admitted.correlationId ?? env.correlationId }),
|
|
87
87
|
continuation: {
|
|
88
88
|
kind: "resume",
|
|
89
|
-
prompt:
|
|
89
|
+
prompt: buildAutoResumeContinuationPrompt({
|
|
90
90
|
packageRoot: env.packageRoot,
|
|
91
91
|
...pickEngineAxis(env),
|
|
92
92
|
}),
|