@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
package/dist/public-cli/main.js
CHANGED
|
@@ -8548,11 +8548,8 @@ var init_navigator_output = __esm({
|
|
|
8548
8548
|
navigatorOutputSchema = withTerminatingOutputDeclarations(
|
|
8549
8549
|
openToolObject(
|
|
8550
8550
|
typebox_exports.Object({
|
|
8551
|
-
|
|
8552
|
-
description: "
|
|
8553
|
-
}),
|
|
8554
|
-
candidates: typebox_exports.Unknown({
|
|
8555
|
-
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"
|
|
8551
|
+
prose: typebox_exports.Unknown({
|
|
8552
|
+
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"
|
|
8556
8553
|
})
|
|
8557
8554
|
})
|
|
8558
8555
|
)
|
|
@@ -17694,7 +17691,7 @@ async function listPullRequestNumbersByCommit(runner, input) {
|
|
|
17694
17691
|
function createGhApiRunner(options = {}) {
|
|
17695
17692
|
const spawnImpl = options.spawnImpl ?? spawn2;
|
|
17696
17693
|
return async (args, runOptions = {}) => {
|
|
17697
|
-
return await new Promise((
|
|
17694
|
+
return await new Promise((resolve11, reject) => {
|
|
17698
17695
|
const signal = runOptions.signal;
|
|
17699
17696
|
if (signal?.aborted) {
|
|
17700
17697
|
reject(signal.reason ?? new Error("aborted"));
|
|
@@ -17767,11 +17764,11 @@ function createGhApiRunner(options = {}) {
|
|
|
17767
17764
|
const value = line2.slice(idx + 1).trim();
|
|
17768
17765
|
headers[name] = value;
|
|
17769
17766
|
}
|
|
17770
|
-
|
|
17767
|
+
resolve11({ status, headers, bodyText });
|
|
17771
17768
|
return;
|
|
17772
17769
|
}
|
|
17773
17770
|
if (code === 0) {
|
|
17774
|
-
|
|
17771
|
+
resolve11({ status: 200, headers: {}, bodyText: stdout });
|
|
17775
17772
|
return;
|
|
17776
17773
|
}
|
|
17777
17774
|
const failure = new Error(
|
|
@@ -18165,6 +18162,15 @@ function buildResumeContinuationPrompt(options) {
|
|
|
18165
18162
|
})
|
|
18166
18163
|
);
|
|
18167
18164
|
}
|
|
18165
|
+
function buildAutoResumeContinuationPrompt(options) {
|
|
18166
|
+
return selectResumeContinuationPrompt(
|
|
18167
|
+
RESUME_TRANSPORT_ENVELOPE,
|
|
18168
|
+
engineSessionMaterialFromOptions({
|
|
18169
|
+
packageRoot: options.packageRoot,
|
|
18170
|
+
...pickEngineAxis(options)
|
|
18171
|
+
})
|
|
18172
|
+
);
|
|
18173
|
+
}
|
|
18168
18174
|
function isV1ResumableProvider(provider) {
|
|
18169
18175
|
return V1_RESUMABLE_PROVIDERS.includes(provider);
|
|
18170
18176
|
}
|
|
@@ -19397,7 +19403,7 @@ var init_run_lifecycle = __esm({
|
|
|
19397
19403
|
init_invocation();
|
|
19398
19404
|
V1_RESUMABLE_PROVIDERS = ["openai-codex", "xai"];
|
|
19399
19405
|
AUTO_RESUME_LIMIT = 2;
|
|
19400
|
-
RESUME_TRANSPORT_ENVELOPE = "
|
|
19406
|
+
RESUME_TRANSPORT_ENVELOPE = "\u7EE7\u7EED\u3002";
|
|
19401
19407
|
RUN_STATE_FILE = "run-state.json";
|
|
19402
19408
|
WRITER_LOCK_FILE = "writer.lock";
|
|
19403
19409
|
RunWriterLeaseHeldError = class extends Error {
|
|
@@ -20096,12 +20102,12 @@ var init_option_definitions = __esm({
|
|
|
20096
20102
|
canonical: "--lens",
|
|
20097
20103
|
aliases: [],
|
|
20098
20104
|
valueMetavar: "completeness|correctness",
|
|
20099
|
-
required:
|
|
20105
|
+
required: false,
|
|
20100
20106
|
repeatable: false,
|
|
20101
20107
|
form: "option",
|
|
20102
20108
|
description: {
|
|
20103
|
-
en: "
|
|
20104
|
-
zh: "\
|
|
20109
|
+
en: "Optional single-lens override: completeness or correctness; omitted runs both in parallel.",
|
|
20110
|
+
zh: "\u53EF\u9009\u5355 lens \u8986\u76D6\uFF1Acompleteness \u6216 correctness\uFF1B\u7701\u7565\u65F6\u5E76\u884C\u8FD0\u884C\u4E24\u8F74\u3002"
|
|
20105
20111
|
}
|
|
20106
20112
|
},
|
|
20107
20113
|
{
|
|
@@ -20459,9 +20465,9 @@ var init_option_definitions = __esm({
|
|
|
20459
20465
|
},
|
|
20460
20466
|
reviewer: {
|
|
20461
20467
|
command: "reviewer",
|
|
20462
|
-
summary: "Fixed-target
|
|
20468
|
+
summary: "Fixed-target parallel two-lens review, with an optional single-lens override.",
|
|
20463
20469
|
usage: [
|
|
20464
|
-
"ak-role reviewer --base <revision> --lens completeness|correctness --authority-ref <ref> [options] <instruction>"
|
|
20470
|
+
"ak-role reviewer --base <revision> [--lens completeness|correctness] --authority-ref <ref> [options] <instruction>"
|
|
20465
20471
|
],
|
|
20466
20472
|
examples: [
|
|
20467
20473
|
'ak-role reviewer --base main --lens completeness --authority-ref docs/adr/0001.md "Review the branch."',
|
|
@@ -20512,7 +20518,7 @@ var init_option_definitions = __esm({
|
|
|
20512
20518
|
},
|
|
20513
20519
|
navigator: {
|
|
20514
20520
|
command: "navigator",
|
|
20515
|
-
summary: "Direct Navigator (\u6E38\u5955\u4F7F) route advice
|
|
20521
|
+
summary: "Direct Navigator (\u6E38\u5955\u4F7F) free-form prose route advice.",
|
|
20516
20522
|
usage: ["ak-role navigator [options] [instruction]"],
|
|
20517
20523
|
examples: [
|
|
20518
20524
|
'ak-role navigator "\u521A\u5B8C\u6210 coder apply \u6536\u655B\uFF0C\u4E0B\u4E00\u6B65\uFF1F"'
|
|
@@ -22594,7 +22600,7 @@ function parseReviewerArgv(args) {
|
|
|
22594
22600
|
instruction: positional.join(" "),
|
|
22595
22601
|
attachmentPaths,
|
|
22596
22602
|
baseRevision,
|
|
22597
|
-
lens,
|
|
22603
|
+
...lens === void 0 ? {} : { lens },
|
|
22598
22604
|
authorityRefs,
|
|
22599
22605
|
...project === void 0 ? {} : { project }
|
|
22600
22606
|
};
|
|
@@ -22643,6 +22649,7 @@ async function admitReviewerInvocation(options) {
|
|
|
22643
22649
|
baseRevision,
|
|
22644
22650
|
lens,
|
|
22645
22651
|
authorityRefs: [...authorityRefs],
|
|
22652
|
+
...options.correlationId === void 0 ? {} : { correlationId: options.correlationId },
|
|
22646
22653
|
attachments: attachments.map((a) => ({
|
|
22647
22654
|
provenancePath: a.provenancePath,
|
|
22648
22655
|
frozenPath: a.frozenPath,
|
|
@@ -22670,7 +22677,8 @@ async function admitReviewerInvocation(options) {
|
|
|
22670
22677
|
admittedRequestPath,
|
|
22671
22678
|
baseRevision,
|
|
22672
22679
|
lens,
|
|
22673
|
-
authorityRefs
|
|
22680
|
+
authorityRefs,
|
|
22681
|
+
...options.correlationId === void 0 ? {} : { correlationId: options.correlationId }
|
|
22674
22682
|
};
|
|
22675
22683
|
}
|
|
22676
22684
|
function buildReviewerSkillArgProjection(admitted) {
|
|
@@ -22887,11 +22895,11 @@ function parseAnalystCohortIssueToken(raw, flag) {
|
|
|
22887
22895
|
`${flag} requires a comma-separated list of N or book:N`
|
|
22888
22896
|
);
|
|
22889
22897
|
}
|
|
22890
|
-
const
|
|
22891
|
-
if (
|
|
22892
|
-
const rhs = trimmed.slice(
|
|
22898
|
+
const sep6 = trimmed.lastIndexOf(":");
|
|
22899
|
+
if (sep6 > 0) {
|
|
22900
|
+
const rhs = trimmed.slice(sep6 + 1);
|
|
22893
22901
|
if (ANALYST_TICKET_NUMBER_PATTERN.test(rhs)) {
|
|
22894
|
-
const bookKey = trimmed.slice(0,
|
|
22902
|
+
const bookKey = trimmed.slice(0, sep6);
|
|
22895
22903
|
if (bookKey.trim() === "") {
|
|
22896
22904
|
throw new CliUsageError(
|
|
22897
22905
|
`${flag} book:N requires a non-empty book key, got ${raw}`
|
|
@@ -24108,8 +24116,8 @@ async function readRunTerminalArtifact(runDirectory) {
|
|
|
24108
24116
|
const read = await readTerminalArtifactAtPath(path, file);
|
|
24109
24117
|
if (read !== void 0) return read;
|
|
24110
24118
|
}
|
|
24111
|
-
for (const
|
|
24112
|
-
const path = join20(runDirectory,
|
|
24119
|
+
for (const relative4 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
24120
|
+
const path = join20(runDirectory, relative4);
|
|
24113
24121
|
const read = await readTerminalArtifactAtPath(path, "error.json");
|
|
24114
24122
|
if (read !== void 0) return read;
|
|
24115
24123
|
}
|
|
@@ -24880,44 +24888,6 @@ var init_receipt_delivery_policy = __esm({
|
|
|
24880
24888
|
}
|
|
24881
24889
|
});
|
|
24882
24890
|
|
|
24883
|
-
// src/public-command-renderer.ts
|
|
24884
|
-
function isPublicCallableRole2(role) {
|
|
24885
|
-
return PUBLIC_CALLABLE_ROLES3.has(role);
|
|
24886
|
-
}
|
|
24887
|
-
function renderPublicAkRoleCommand(target) {
|
|
24888
|
-
if (!isPublicCallableRole2(target.role)) return void 0;
|
|
24889
|
-
const role = target.role;
|
|
24890
|
-
const metadata = packagedRoleMetadata(role);
|
|
24891
|
-
if (metadata !== void 0 && "bareCommand" in metadata && metadata.bareCommand === false) {
|
|
24892
|
-
return void 0;
|
|
24893
|
-
}
|
|
24894
|
-
if (target.phase === null || target.phase === void 0) {
|
|
24895
|
-
return `ak-role ${role}`;
|
|
24896
|
-
}
|
|
24897
|
-
if (role === "coder" || role === "fixer") {
|
|
24898
|
-
return `ak-role ${role} ${target.phase}`;
|
|
24899
|
-
}
|
|
24900
|
-
return `ak-role ${role}`;
|
|
24901
|
-
}
|
|
24902
|
-
var PUBLIC_CALLABLE_ROLES3;
|
|
24903
|
-
var init_public_command_renderer = __esm({
|
|
24904
|
-
"src/public-command-renderer.ts"() {
|
|
24905
|
-
"use strict";
|
|
24906
|
-
init_packaged_role_registry();
|
|
24907
|
-
PUBLIC_CALLABLE_ROLES3 = new Set(
|
|
24908
|
-
PACKAGED_ROLE_REGISTRY.map((entry) => entry.role)
|
|
24909
|
-
);
|
|
24910
|
-
}
|
|
24911
|
-
});
|
|
24912
|
-
|
|
24913
|
-
// src/public-cli/command-renderer.ts
|
|
24914
|
-
var init_command_renderer = __esm({
|
|
24915
|
-
"src/public-cli/command-renderer.ts"() {
|
|
24916
|
-
"use strict";
|
|
24917
|
-
init_public_command_renderer();
|
|
24918
|
-
}
|
|
24919
|
-
});
|
|
24920
|
-
|
|
24921
24891
|
// src/public-cli/terminal.ts
|
|
24922
24892
|
function encodeTerminalField(value) {
|
|
24923
24893
|
return JSON.stringify(value);
|
|
@@ -24928,14 +24898,10 @@ function isLawfulTypedTerminalOutcome(outcome) {
|
|
|
24928
24898
|
function exitCodeForTerminalOutcome(outcome) {
|
|
24929
24899
|
return isLawfulTypedTerminalOutcome(outcome) ? 0 : 1;
|
|
24930
24900
|
}
|
|
24931
|
-
function
|
|
24932
|
-
const command = typeof input.modelCommand === "string" && input.modelCommand.trim() !== "" ? input.modelCommand : isPublicCallableRole2(input.next.role) ? renderPublicAkRoleCommand(input.next) : void 0;
|
|
24901
|
+
function adviceNavigatorFact(input) {
|
|
24933
24902
|
return {
|
|
24934
|
-
disposition: "
|
|
24935
|
-
|
|
24936
|
-
reason: input.reason,
|
|
24937
|
-
...command === void 0 ? {} : { command },
|
|
24938
|
-
...input.route === void 0 ? {} : { route: input.route },
|
|
24903
|
+
disposition: "advice",
|
|
24904
|
+
prose: input.prose,
|
|
24939
24905
|
...input.advisoryDiagnostic === void 0 ? {} : { advisoryDiagnostic: input.advisoryDiagnostic }
|
|
24940
24906
|
};
|
|
24941
24907
|
}
|
|
@@ -24963,14 +24929,8 @@ function formatTerminalResult(result2) {
|
|
|
24963
24929
|
if (result2.navigator.advisoryDiagnostic !== void 0) {
|
|
24964
24930
|
lines.push(`navigator-advisory ${encodeTerminalField(result2.navigator.advisoryDiagnostic)}`);
|
|
24965
24931
|
}
|
|
24966
|
-
if (result2.navigator.disposition === "
|
|
24967
|
-
lines.push(
|
|
24968
|
-
`next ${result2.navigator.next.role} ${result2.navigator.next.phase ?? "none"}`
|
|
24969
|
-
);
|
|
24970
|
-
lines.push(`reason ${encodeTerminalField(result2.navigator.reason)}`);
|
|
24971
|
-
if (result2.navigator.command !== void 0) {
|
|
24972
|
-
lines.push(`command ${encodeTerminalField(result2.navigator.command)}`);
|
|
24973
|
-
}
|
|
24932
|
+
if (result2.navigator.disposition === "advice") {
|
|
24933
|
+
lines.push(`prose ${encodeTerminalField(result2.navigator.prose)}`);
|
|
24974
24934
|
} else if (result2.navigator.disposition === "unavailable") {
|
|
24975
24935
|
lines.push(
|
|
24976
24936
|
`unavailable ${result2.navigator.source} ${encodeTerminalField(result2.navigator.reason)}`
|
|
@@ -24990,6 +24950,15 @@ function formatTerminalResult(result2) {
|
|
|
24990
24950
|
);
|
|
24991
24951
|
}
|
|
24992
24952
|
}
|
|
24953
|
+
if (result2.reviewerChildOutcomes !== void 0) {
|
|
24954
|
+
for (const axis of ["completeness", "correctness"]) {
|
|
24955
|
+
const child = result2.reviewerChildOutcomes[axis];
|
|
24956
|
+
lines.push(`reviewer-child ${axis} ${child.exitCode}`);
|
|
24957
|
+
if (child.stderr !== void 0 && child.stderr !== "") {
|
|
24958
|
+
lines.push(`reviewer-child-diagnostic ${axis} ${encodeTerminalField(child.stderr)}`);
|
|
24959
|
+
}
|
|
24960
|
+
}
|
|
24961
|
+
}
|
|
24993
24962
|
if (result2.resume !== void 0) {
|
|
24994
24963
|
lines.push(`resume ${encodeTerminalField(result2.resume.command)}`);
|
|
24995
24964
|
} else if (result2.runId !== void 0) {
|
|
@@ -25010,7 +24979,6 @@ function formatTerminalResult(result2) {
|
|
|
25010
24979
|
var init_terminal = __esm({
|
|
25011
24980
|
"src/public-cli/terminal.ts"() {
|
|
25012
24981
|
"use strict";
|
|
25013
|
-
init_command_renderer();
|
|
25014
24982
|
}
|
|
25015
24983
|
});
|
|
25016
24984
|
|
|
@@ -25990,10 +25958,6 @@ async function appendRunAttemptHistory(source, outcome) {
|
|
|
25990
25958
|
} catch {
|
|
25991
25959
|
}
|
|
25992
25960
|
}
|
|
25993
|
-
function navigatorPhaseValue(value) {
|
|
25994
|
-
if (value === "plan" || value === "apply") return value;
|
|
25995
|
-
return null;
|
|
25996
|
-
}
|
|
25997
25961
|
function navigatorAttendanceCorrelatedWithBoundMarker(details, attendanceIndex, terminalIndex, marker) {
|
|
25998
25962
|
if (attendanceIndex <= terminalIndex) return false;
|
|
25999
25963
|
if (details.invocationId !== marker.invocationId) return false;
|
|
@@ -26002,29 +25966,33 @@ function navigatorAttendanceCorrelatedWithBoundMarker(details, attendanceIndex,
|
|
|
26002
25966
|
function parseNavigatorAttendanceDetails(details) {
|
|
26003
25967
|
const disposition = details.disposition;
|
|
26004
25968
|
const advisoryDiagnostic = typeof details.routePlaybookReadFailure === "string" ? { advisoryDiagnostic: details.routePlaybookReadFailure } : {};
|
|
26005
|
-
if (disposition === "recommendation") {
|
|
26006
|
-
|
|
26007
|
-
if (
|
|
25969
|
+
if (disposition === "advice" || disposition === "recommendation") {
|
|
25970
|
+
let prose;
|
|
25971
|
+
if (typeof details.prose === "string" && details.prose.trim() !== "") {
|
|
25972
|
+
prose = details.prose;
|
|
25973
|
+
} else {
|
|
25974
|
+
const next = isRecord10(details.next) && typeof details.next.role === "string" ? details.next.role : void 0;
|
|
25975
|
+
const reason = typeof details.reason === "string" && details.reason.trim() !== "" ? details.reason : void 0;
|
|
25976
|
+
const command = typeof details.command === "string" && details.command.trim() !== "" ? details.command : void 0;
|
|
25977
|
+
if (reason !== void 0 && next !== void 0) {
|
|
25978
|
+
prose = `${reason}\uFF08\u4E0B\u4E00\u6B65\uFF1A${next}\uFF09`;
|
|
25979
|
+
} else if (reason !== void 0) {
|
|
25980
|
+
prose = reason;
|
|
25981
|
+
} else if (next !== void 0) {
|
|
25982
|
+
prose = `\u4E0B\u4E00\u6B65\uFF1A${next}`;
|
|
25983
|
+
} else if (command !== void 0) {
|
|
25984
|
+
prose = command;
|
|
25985
|
+
}
|
|
25986
|
+
}
|
|
25987
|
+
if (prose === void 0 || prose.trim() === "") {
|
|
26008
25988
|
return {
|
|
26009
|
-
disposition: "
|
|
26010
|
-
|
|
26011
|
-
reason: "navigator recommendation missing typed next role"
|
|
25989
|
+
disposition: "no-advice",
|
|
25990
|
+
...advisoryDiagnostic
|
|
26012
25991
|
};
|
|
26013
25992
|
}
|
|
26014
|
-
|
|
26015
|
-
|
|
26016
|
-
|
|
26017
|
-
phase: navigatorPhaseValue(target.phase)
|
|
26018
|
-
})) : void 0;
|
|
26019
|
-
return recommendationNavigatorFact({
|
|
26020
|
-
...advisoryDiagnostic,
|
|
26021
|
-
next: {
|
|
26022
|
-
role: next.role,
|
|
26023
|
-
phase: navigatorPhaseValue(next.phase)
|
|
26024
|
-
},
|
|
26025
|
-
reason,
|
|
26026
|
-
...route === void 0 ? {} : { route },
|
|
26027
|
-
...typeof details.command === "string" ? { modelCommand: details.command } : {}
|
|
25993
|
+
return adviceNavigatorFact({
|
|
25994
|
+
prose,
|
|
25995
|
+
...advisoryDiagnostic
|
|
26028
25996
|
});
|
|
26029
25997
|
}
|
|
26030
25998
|
if (disposition === "unavailable") {
|
|
@@ -27450,10 +27418,10 @@ function presentFailureTerminal(terminal, io) {
|
|
|
27450
27418
|
}
|
|
27451
27419
|
function defaultNavigatorGraceSleep() {
|
|
27452
27420
|
let timer;
|
|
27453
|
-
const sleep2 = ((ms) => new Promise((
|
|
27421
|
+
const sleep2 = ((ms) => new Promise((resolve11) => {
|
|
27454
27422
|
timer = setTimeout(() => {
|
|
27455
27423
|
timer = void 0;
|
|
27456
|
-
|
|
27424
|
+
resolve11();
|
|
27457
27425
|
}, ms);
|
|
27458
27426
|
}));
|
|
27459
27427
|
sleep2.cancel = () => {
|
|
@@ -27465,7 +27433,7 @@ function defaultNavigatorGraceSleep() {
|
|
|
27465
27433
|
return sleep2;
|
|
27466
27434
|
}
|
|
27467
27435
|
function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2 = defaultNavigatorGraceSleep()) {
|
|
27468
|
-
return new Promise((
|
|
27436
|
+
return new Promise((resolve11, reject) => {
|
|
27469
27437
|
let settled = false;
|
|
27470
27438
|
const finish = (action) => {
|
|
27471
27439
|
if (settled) return;
|
|
@@ -27474,11 +27442,11 @@ function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2
|
|
|
27474
27442
|
action();
|
|
27475
27443
|
};
|
|
27476
27444
|
void work.then(
|
|
27477
|
-
(value) => finish(() =>
|
|
27445
|
+
(value) => finish(() => resolve11({ status: "done", value })),
|
|
27478
27446
|
(error) => finish(() => reject(error))
|
|
27479
27447
|
);
|
|
27480
27448
|
void sleep2(graceMs).then(() => {
|
|
27481
|
-
finish(() =>
|
|
27449
|
+
finish(() => resolve11({ status: "timeout" }));
|
|
27482
27450
|
});
|
|
27483
27451
|
});
|
|
27484
27452
|
}
|
|
@@ -27547,7 +27515,7 @@ var init_settlement = __esm({
|
|
|
27547
27515
|
|
|
27548
27516
|
// src/public-cli/turn-request.ts
|
|
27549
27517
|
function projectRoleTurnRequest(admitted, roleDetails, options) {
|
|
27550
|
-
const cwd = admitted.projectRoot ?? admitted.repoRoot ?? admitted.cwd;
|
|
27518
|
+
const cwd = options.cwd ?? admitted.projectRoot ?? admitted.repoRoot ?? admitted.cwd;
|
|
27551
27519
|
if (cwd === void 0) throw new Error("admitted invocation missing working directory");
|
|
27552
27520
|
if (admitted.principal === void 0) throw new Error("admitted invocation missing principal");
|
|
27553
27521
|
return {
|
|
@@ -28838,6 +28806,8 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
28838
28806
|
}
|
|
28839
28807
|
adapters = prepared.adapters;
|
|
28840
28808
|
}
|
|
28809
|
+
let env = input.env;
|
|
28810
|
+
let preparedCleanup;
|
|
28841
28811
|
const buildRequestAfterLease = async () => {
|
|
28842
28812
|
let openCourtAttemptId;
|
|
28843
28813
|
let admittedForBuild = loaded.admitted;
|
|
@@ -28888,7 +28858,12 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
28888
28858
|
return turnRequest;
|
|
28889
28859
|
};
|
|
28890
28860
|
try {
|
|
28891
|
-
if (input.
|
|
28861
|
+
if (input.afterAdmittedPrepare !== void 0) {
|
|
28862
|
+
const prepared = await input.afterAdmittedPrepare(loaded.admitted);
|
|
28863
|
+
if (prepared.env !== void 0) env = prepared.env;
|
|
28864
|
+
preparedCleanup = prepared.cleanup;
|
|
28865
|
+
}
|
|
28866
|
+
if (env.stationChild === true) {
|
|
28892
28867
|
let firstTurn;
|
|
28893
28868
|
const stationAdapters = withOnceSuccessfulBeforeDispatch(adapters);
|
|
28894
28869
|
const invocationScopeId = mintEngineDetourInvocationScope({
|
|
@@ -28896,14 +28871,14 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
28896
28871
|
});
|
|
28897
28872
|
return await runWithAutoResumeLoop({
|
|
28898
28873
|
admitted: loaded.admitted,
|
|
28899
|
-
principalAuthority:
|
|
28874
|
+
principalAuthority: env.principalAuthority,
|
|
28900
28875
|
isPrincipalAvailable: resolveHostAwareSessionAvailability(
|
|
28901
|
-
|
|
28902
|
-
|
|
28876
|
+
env.host,
|
|
28877
|
+
env.principalAuthority
|
|
28903
28878
|
),
|
|
28904
28879
|
io: input.io,
|
|
28905
|
-
sessionAppender:
|
|
28906
|
-
autoResumeLimit:
|
|
28880
|
+
sessionAppender: env.sessionAppender,
|
|
28881
|
+
autoResumeLimit: env.autoResumeLimit,
|
|
28907
28882
|
buildInitialPayload: () => ({ resumeTurn: false }),
|
|
28908
28883
|
buildResumePayload: () => ({ resumeTurn: true }),
|
|
28909
28884
|
// Same as public manual resume: prior-court sealed acceptance is not a
|
|
@@ -28930,7 +28905,7 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
28930
28905
|
dispatch: async (turnRequest) => {
|
|
28931
28906
|
const result2 = await dispatchPostAdmissionTurn({
|
|
28932
28907
|
admitted: loaded.admitted,
|
|
28933
|
-
env
|
|
28908
|
+
env,
|
|
28934
28909
|
io: attemptIo,
|
|
28935
28910
|
request: turnRequest,
|
|
28936
28911
|
lease,
|
|
@@ -28940,7 +28915,7 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
28940
28915
|
});
|
|
28941
28916
|
return settleDeferredPersist(
|
|
28942
28917
|
loaded.admitted,
|
|
28943
|
-
|
|
28918
|
+
env.principalAuthority,
|
|
28944
28919
|
stationAdapters,
|
|
28945
28920
|
attemptIo,
|
|
28946
28921
|
result2
|
|
@@ -28951,7 +28926,7 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
28951
28926
|
}
|
|
28952
28927
|
return await runPostAdmissionManualResume({
|
|
28953
28928
|
admitted: loaded.admitted,
|
|
28954
|
-
env
|
|
28929
|
+
env,
|
|
28955
28930
|
io: input.io,
|
|
28956
28931
|
adapters,
|
|
28957
28932
|
...input.effectiveEngine === void 0 ? {} : { effectiveEngine: input.effectiveEngine },
|
|
@@ -28963,6 +28938,10 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
28963
28938
|
return { exitCode: 2 };
|
|
28964
28939
|
}
|
|
28965
28940
|
throw error;
|
|
28941
|
+
} finally {
|
|
28942
|
+
if (preparedCleanup !== void 0) {
|
|
28943
|
+
await preparedCleanup();
|
|
28944
|
+
}
|
|
28966
28945
|
}
|
|
28967
28946
|
}
|
|
28968
28947
|
async function runPostAdmissionOneShot(input) {
|
|
@@ -28975,7 +28954,7 @@ async function runPostAdmissionOneShot(input) {
|
|
|
28975
28954
|
...input.request,
|
|
28976
28955
|
continuation: {
|
|
28977
28956
|
kind: "resume",
|
|
28978
|
-
prompt:
|
|
28957
|
+
prompt: buildAutoResumeContinuationPrompt({
|
|
28979
28958
|
packageRoot: input.env.packageRoot,
|
|
28980
28959
|
...pickEngineAxis({
|
|
28981
28960
|
engine: input.effectiveEngine ?? input.env.engine,
|
|
@@ -29232,7 +29211,7 @@ async function runPublicCoder(argv, env, io, parseCoderArgv2) {
|
|
|
29232
29211
|
...admitted.correlationId === void 0 && env.correlationId === void 0 ? {} : { correlationId: admitted.correlationId ?? env.correlationId },
|
|
29233
29212
|
continuation: {
|
|
29234
29213
|
kind: "resume",
|
|
29235
|
-
prompt:
|
|
29214
|
+
prompt: buildAutoResumeContinuationPrompt({
|
|
29236
29215
|
packageRoot: env.packageRoot,
|
|
29237
29216
|
...pickEngineAxis(env)
|
|
29238
29217
|
})
|
|
@@ -30116,7 +30095,7 @@ async function runPublicJudge(argv, env, io, parseJudgeArgv2) {
|
|
|
30116
30095
|
...admitted.correlationId === void 0 && env.correlationId === void 0 ? {} : { correlationId: admitted.correlationId ?? env.correlationId },
|
|
30117
30096
|
continuation: {
|
|
30118
30097
|
kind: "resume",
|
|
30119
|
-
prompt:
|
|
30098
|
+
prompt: buildAutoResumeContinuationPrompt({
|
|
30120
30099
|
packageRoot: env.packageRoot,
|
|
30121
30100
|
...pickEngineAxis(env)
|
|
30122
30101
|
})
|
|
@@ -30423,110 +30402,441 @@ var init_diarist_run = __esm({
|
|
|
30423
30402
|
}
|
|
30424
30403
|
});
|
|
30425
30404
|
|
|
30426
|
-
// src/public-
|
|
30427
|
-
var
|
|
30428
|
-
__export(
|
|
30429
|
-
|
|
30430
|
-
|
|
30431
|
-
|
|
30432
|
-
summonPublicRole: () => summonPublicRole
|
|
30405
|
+
// src/public-cli/reviewer-run.ts
|
|
30406
|
+
var reviewer_run_exports = {};
|
|
30407
|
+
__export(reviewer_run_exports, {
|
|
30408
|
+
buildReviewerTurnRequest: () => buildReviewerTurnRequest,
|
|
30409
|
+
runPublicReviewer: () => runPublicReviewer,
|
|
30410
|
+
runPublicReviewerResume: () => runPublicReviewerResume
|
|
30433
30411
|
});
|
|
30434
|
-
import {
|
|
30435
|
-
|
|
30436
|
-
|
|
30437
|
-
|
|
30438
|
-
|
|
30439
|
-
|
|
30440
|
-
|
|
30412
|
+
import { resolve as resolve9 } from "node:path";
|
|
30413
|
+
function reviewerMethods(packageRoot2) {
|
|
30414
|
+
return [{ kind: "skill", path: resolvePackagedMethodSkillPath(packageRoot2, "ak-cross-m-review") }];
|
|
30415
|
+
}
|
|
30416
|
+
async function runReviewerTurnInFreshCopy(env, projectRoot, io, body) {
|
|
30417
|
+
if (env.executionCwd !== void 0) {
|
|
30418
|
+
return body(env);
|
|
30419
|
+
}
|
|
30420
|
+
const { withEphemeralReviewerWorktree: withEphemeralReviewerWorktree2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
|
|
30421
|
+
return await withEphemeralReviewerWorktree2({
|
|
30422
|
+
projectRoot,
|
|
30423
|
+
onCleanupDiagnostic: (diagnostic) => {
|
|
30424
|
+
io.stderr(`${diagnostic}
|
|
30425
|
+
`);
|
|
30426
|
+
},
|
|
30427
|
+
run: (executionCwd) => body({ ...env, executionCwd })
|
|
30428
|
+
});
|
|
30429
|
+
}
|
|
30430
|
+
function buildReviewerTurnRequest(admitted, options) {
|
|
30431
|
+
return projectRoleTurnRequest(
|
|
30432
|
+
admitted,
|
|
30433
|
+
{
|
|
30434
|
+
activation: {
|
|
30435
|
+
role: "reviewer",
|
|
30436
|
+
baseRevision: admitted.baseRevision,
|
|
30437
|
+
lens: admitted.lens,
|
|
30438
|
+
authorityRefs: admitted.authorityRefs,
|
|
30439
|
+
...admitted.ticketNumber === void 0 ? {} : { ticketNumber: admitted.ticketNumber }
|
|
30441
30440
|
},
|
|
30442
|
-
|
|
30443
|
-
chunks.push(text);
|
|
30444
|
-
}
|
|
30441
|
+
methods: reviewerMethods(options.packageRoot)
|
|
30445
30442
|
},
|
|
30446
|
-
|
|
30443
|
+
options
|
|
30444
|
+
);
|
|
30445
|
+
}
|
|
30446
|
+
function reviewerAdapters(packageRoot2, methodMaterial) {
|
|
30447
|
+
return {
|
|
30448
|
+
trySettle: (admitted, authority, scope) => methodMaterial === void 0 ? Promise.resolve(void 0) : trySettleReviewerTerminalResult(
|
|
30449
|
+
admitted,
|
|
30450
|
+
authority,
|
|
30451
|
+
{
|
|
30452
|
+
methodProvenance: methodMaterial.provenance,
|
|
30453
|
+
methodSkillPath: methodMaterial.skillPath,
|
|
30454
|
+
methodSkillConfiguredPath: resolvePackagedMethodSkillPath(
|
|
30455
|
+
packageRoot2,
|
|
30456
|
+
"ak-cross-m-review"
|
|
30457
|
+
)
|
|
30458
|
+
},
|
|
30459
|
+
scope
|
|
30460
|
+
),
|
|
30461
|
+
resolveRunnerKnownFailure: async ({ result: result2, sessionFile }) => {
|
|
30462
|
+
const infrastructureFailure = await readEngineDetourInfrastructureFailure(sessionFile);
|
|
30463
|
+
return infrastructureFailure === void 0 ? result2.knownFailure : {
|
|
30464
|
+
...infrastructureFailure.cause === void 0 ? {} : { cause: infrastructureFailure.cause },
|
|
30465
|
+
diagnostic: infrastructureFailure.diagnostic,
|
|
30466
|
+
...infrastructureFailure.identity === void 0 ? {} : { identity: infrastructureFailure.identity }
|
|
30467
|
+
};
|
|
30468
|
+
}
|
|
30447
30469
|
};
|
|
30448
30470
|
}
|
|
30449
|
-
function
|
|
30450
|
-
|
|
30451
|
-
const idx = Math.max(end.lastIndexOf("/"), end.lastIndexOf("\\"));
|
|
30452
|
-
if (idx <= 0) return end;
|
|
30453
|
-
return end.slice(0, idx);
|
|
30471
|
+
async function loadReviewerMethodMaterial(packageRoot2) {
|
|
30472
|
+
return await loadPackagedMethodSkillMaterial(packageRoot2, "ak-cross-m-review");
|
|
30454
30473
|
}
|
|
30455
|
-
function
|
|
30456
|
-
|
|
30457
|
-
|
|
30458
|
-
|
|
30459
|
-
|
|
30460
|
-
|
|
30461
|
-
|
|
30462
|
-
|
|
30463
|
-
|
|
30464
|
-
|
|
30465
|
-
return void 0;
|
|
30474
|
+
function reviewerResumePrompt(env, message) {
|
|
30475
|
+
const lines = [RESUME_TRANSPORT_ENVELOPE];
|
|
30476
|
+
if (message !== void 0) lines.push("", message);
|
|
30477
|
+
return appendEngineSessionMaterial(
|
|
30478
|
+
lines,
|
|
30479
|
+
engineSessionMaterialFromOptions({
|
|
30480
|
+
...pickEngineAxis(env),
|
|
30481
|
+
packageRoot: env.packageRoot
|
|
30482
|
+
})
|
|
30483
|
+
).join("\n");
|
|
30466
30484
|
}
|
|
30467
|
-
function
|
|
30468
|
-
|
|
30469
|
-
|
|
30485
|
+
async function runPublicReviewer(argv, env, io, parseReviewerArgv2) {
|
|
30486
|
+
let parsed;
|
|
30487
|
+
try {
|
|
30488
|
+
parsed = parseReviewerArgv2(argv);
|
|
30489
|
+
} catch (error) {
|
|
30490
|
+
if (error instanceof CliUsageError) {
|
|
30491
|
+
presentStructuralRejection(error, io);
|
|
30492
|
+
return { exitCode: 2 };
|
|
30493
|
+
}
|
|
30494
|
+
throw error;
|
|
30470
30495
|
}
|
|
30471
|
-
|
|
30472
|
-
|
|
30473
|
-
|
|
30496
|
+
if (parsed.lens === void 0) {
|
|
30497
|
+
const { summonParallelReviewerLenses: summonParallelReviewerLenses2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
|
|
30498
|
+
const children = await summonParallelReviewerLenses2({
|
|
30499
|
+
argv,
|
|
30500
|
+
// Replay argv under the same cwd the single-axis entry would see (10a).
|
|
30501
|
+
// Do not substitute the resolved project path — relative --project must
|
|
30502
|
+
// not be re-resolved against a shifted cwd.
|
|
30503
|
+
cwd: env.cwd,
|
|
30504
|
+
projectRoot: resolve9(parsed.project ?? env.cwd),
|
|
30505
|
+
// Typed base from the public parse — precheck only; child argv stays verbatim.
|
|
30506
|
+
baseRevision: parsed.baseRevision,
|
|
30507
|
+
home: env.home,
|
|
30508
|
+
agentDir: env.agentDir,
|
|
30509
|
+
...env.credentials === void 0 ? {} : { credentials: env.credentials },
|
|
30510
|
+
...env.model === void 0 ? {} : { model: env.model },
|
|
30511
|
+
...env.host === void 0 ? {} : { host: env.host },
|
|
30512
|
+
...env.engine === void 0 ? {} : { engine: env.engine },
|
|
30513
|
+
...env.engineModel === void 0 ? {} : { engineModel: env.engineModel },
|
|
30514
|
+
packageRoot: env.packageRoot,
|
|
30515
|
+
...env.signal === void 0 ? {} : { signal: env.signal },
|
|
30516
|
+
...env.correlationId === void 0 ? {} : { correlationId: env.correlationId },
|
|
30517
|
+
roleTurnHost: env.roleTurnHost,
|
|
30518
|
+
...env.hostAdapters === void 0 ? {} : { hostAdapters: env.hostAdapters },
|
|
30519
|
+
principalAuthority: env.principalAuthority,
|
|
30520
|
+
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs }
|
|
30521
|
+
});
|
|
30522
|
+
const childResults = [children.completeness, children.correctness];
|
|
30523
|
+
const terminals = childResults.map((child) => child.terminal).filter((terminal2) => terminal2 !== void 0);
|
|
30524
|
+
const failedChildren = childResults.filter((child) => child.terminal === void 0 || !isLawfulTypedTerminalOutcome(child.terminal.roleOutcome)).length;
|
|
30525
|
+
const overlayExit = childResults.some((child) => child.exitCode !== 0);
|
|
30526
|
+
const failed = failedChildren > 0 || overlayExit;
|
|
30527
|
+
const overlayDiagnostics = [...new Set(
|
|
30528
|
+
childResults.map((child) => child.stderr).filter((text) => typeof text === "string" && text !== "")
|
|
30529
|
+
)];
|
|
30530
|
+
const terminal = {
|
|
30531
|
+
batch: "reviewer",
|
|
30532
|
+
roleOutcome: failed ? {
|
|
30533
|
+
kind: "failure",
|
|
30534
|
+
role: "reviewer",
|
|
30535
|
+
diagnostic: failedChildren > 0 ? "Reviewer batch child failure" : overlayDiagnostics[0] ?? "Reviewer batch infrastructure failure",
|
|
30536
|
+
decisiveFacts: { failedChildren },
|
|
30537
|
+
payloads: terminals
|
|
30538
|
+
} : { kind: "accepted", role: "reviewer", payloads: terminals },
|
|
30539
|
+
reviewerChildren: {
|
|
30540
|
+
...children.completeness.terminal === void 0 ? {} : { completeness: children.completeness.terminal },
|
|
30541
|
+
...children.correctness.terminal === void 0 ? {} : { correctness: children.correctness.terminal }
|
|
30542
|
+
},
|
|
30543
|
+
reviewerChildOutcomes: {
|
|
30544
|
+
completeness: { exitCode: children.completeness.exitCode, ...children.completeness.stderr === void 0 ? {} : { stderr: children.completeness.stderr } },
|
|
30545
|
+
correctness: { exitCode: children.correctness.exitCode, ...children.correctness.stderr === void 0 ? {} : { stderr: children.correctness.stderr } }
|
|
30546
|
+
},
|
|
30547
|
+
// Batch has no parent run and no own attendance; no-advice is affirmative
|
|
30548
|
+
// only (navigator-attendance.ts). Children carry their own navigator facts.
|
|
30549
|
+
navigator: {
|
|
30550
|
+
disposition: "unavailable",
|
|
30551
|
+
source: "unknown",
|
|
30552
|
+
reason: "Reviewer batch has no parent-run Navigator attendance"
|
|
30553
|
+
},
|
|
30554
|
+
artifacts: terminals.flatMap((item) => item.artifacts)
|
|
30555
|
+
};
|
|
30556
|
+
io.stdout(formatTerminalResult(terminal));
|
|
30557
|
+
return { exitCode: failed ? 1 : 0, terminal };
|
|
30474
30558
|
}
|
|
30475
|
-
|
|
30476
|
-
if (fromCwd !== void 0) return fromCwd;
|
|
30559
|
+
let admitted;
|
|
30477
30560
|
try {
|
|
30478
|
-
|
|
30479
|
-
|
|
30480
|
-
|
|
30481
|
-
|
|
30482
|
-
|
|
30561
|
+
admitted = await admitReviewerInvocation({
|
|
30562
|
+
home: env.home,
|
|
30563
|
+
principalAuthority: env.principalAuthority,
|
|
30564
|
+
cwd: env.cwd,
|
|
30565
|
+
instruction: parsed.instruction,
|
|
30566
|
+
attachmentPaths: parsed.attachmentPaths,
|
|
30567
|
+
baseRevision: parsed.baseRevision,
|
|
30568
|
+
lens: parsed.lens,
|
|
30569
|
+
authorityRefs: parsed.authorityRefs,
|
|
30570
|
+
...parsed.project === void 0 ? {} : { project: parsed.project },
|
|
30571
|
+
...env.createRunId === void 0 ? {} : { createRunId: env.createRunId },
|
|
30572
|
+
...env.correlationId === void 0 ? {} : { correlationId: env.correlationId },
|
|
30573
|
+
...env.model === void 0 ? {} : { model: env.model }
|
|
30574
|
+
});
|
|
30575
|
+
} catch (error) {
|
|
30576
|
+
if (error instanceof CliUsageError) {
|
|
30577
|
+
presentStructuralRejection(error, io);
|
|
30578
|
+
return { exitCode: 2 };
|
|
30483
30579
|
}
|
|
30484
|
-
|
|
30580
|
+
throw error;
|
|
30485
30581
|
}
|
|
30486
|
-
|
|
30487
|
-
|
|
30488
|
-
|
|
30489
|
-
|
|
30490
|
-
|
|
30491
|
-
|
|
30492
|
-
|
|
30582
|
+
await markRunAdmitted(admitted, env.principalAuthority);
|
|
30583
|
+
let methodMaterial;
|
|
30584
|
+
try {
|
|
30585
|
+
methodMaterial = await loadReviewerMethodMaterial(env.packageRoot);
|
|
30586
|
+
} catch (error) {
|
|
30587
|
+
return await presentControlledFailure2(
|
|
30588
|
+
admitted,
|
|
30589
|
+
{
|
|
30590
|
+
timedOut: false,
|
|
30591
|
+
code: null,
|
|
30592
|
+
stderr: "",
|
|
30593
|
+
thrown: error
|
|
30594
|
+
},
|
|
30595
|
+
reviewerAdapters(env.packageRoot),
|
|
30596
|
+
env.principalAuthority,
|
|
30597
|
+
io
|
|
30598
|
+
);
|
|
30493
30599
|
}
|
|
30494
|
-
|
|
30495
|
-
|
|
30496
|
-
|
|
30497
|
-
|
|
30498
|
-
|
|
30499
|
-
|
|
30500
|
-
|
|
30501
|
-
|
|
30502
|
-
|
|
30503
|
-
|
|
30504
|
-
|
|
30505
|
-
|
|
30506
|
-
|
|
30507
|
-
|
|
30508
|
-
|
|
30509
|
-
|
|
30510
|
-
|
|
30511
|
-
|
|
30512
|
-
|
|
30513
|
-
|
|
30514
|
-
|
|
30515
|
-
|
|
30516
|
-
|
|
30517
|
-
|
|
30600
|
+
try {
|
|
30601
|
+
return await runReviewerTurnInFreshCopy(env, admitted.projectRoot, io, async (sandboxedEnv) => await runPostAdmissionResumable({
|
|
30602
|
+
admitted,
|
|
30603
|
+
env: sandboxedEnv,
|
|
30604
|
+
io,
|
|
30605
|
+
buildInitialRequest: () => buildReviewerTurnRequest(admitted, {
|
|
30606
|
+
packageRoot: sandboxedEnv.packageRoot,
|
|
30607
|
+
home: sandboxedEnv.home,
|
|
30608
|
+
agentDir: sandboxedEnv.agentDir,
|
|
30609
|
+
...sandboxedEnv.model === void 0 ? {} : { model: sandboxedEnv.model },
|
|
30610
|
+
...pickEngineAxis(sandboxedEnv),
|
|
30611
|
+
...sandboxedEnv.timeoutMs === void 0 ? {} : { timeoutMs: sandboxedEnv.timeoutMs },
|
|
30612
|
+
...admitted.correlationId === void 0 && sandboxedEnv.correlationId === void 0 ? {} : { correlationId: admitted.correlationId ?? sandboxedEnv.correlationId },
|
|
30613
|
+
// Ephemeral worktree cwd; durable projectRoot stays on admitted caller project.
|
|
30614
|
+
...sandboxedEnv.executionCwd === void 0 ? {} : { cwd: sandboxedEnv.executionCwd },
|
|
30615
|
+
continuation: {
|
|
30616
|
+
kind: "initial",
|
|
30617
|
+
prompt: buildReviewerTransportPrompt(
|
|
30618
|
+
admitted,
|
|
30619
|
+
engineSessionMaterialFromOptions({
|
|
30620
|
+
...pickEngineAxis(sandboxedEnv),
|
|
30621
|
+
packageRoot: sandboxedEnv.packageRoot
|
|
30622
|
+
})
|
|
30623
|
+
)
|
|
30624
|
+
}
|
|
30625
|
+
}),
|
|
30626
|
+
buildResumeRequest: () => buildReviewerTurnRequest(admitted, {
|
|
30627
|
+
packageRoot: sandboxedEnv.packageRoot,
|
|
30628
|
+
home: sandboxedEnv.home,
|
|
30629
|
+
agentDir: sandboxedEnv.agentDir,
|
|
30630
|
+
...sandboxedEnv.model === void 0 ? {} : { model: sandboxedEnv.model },
|
|
30631
|
+
...pickEngineAxis(sandboxedEnv),
|
|
30632
|
+
...sandboxedEnv.timeoutMs === void 0 ? {} : { timeoutMs: sandboxedEnv.timeoutMs },
|
|
30633
|
+
...admitted.correlationId === void 0 && sandboxedEnv.correlationId === void 0 ? {} : { correlationId: admitted.correlationId ?? sandboxedEnv.correlationId },
|
|
30634
|
+
// In-batch auto-resume keeps the same call's sandbox (dual-lens or single).
|
|
30635
|
+
...sandboxedEnv.executionCwd === void 0 ? {} : { cwd: sandboxedEnv.executionCwd },
|
|
30636
|
+
continuation: {
|
|
30637
|
+
kind: "resume",
|
|
30638
|
+
prompt: reviewerResumePrompt(sandboxedEnv)
|
|
30639
|
+
}
|
|
30640
|
+
}),
|
|
30641
|
+
adapters: reviewerAdapters(sandboxedEnv.packageRoot, methodMaterial),
|
|
30642
|
+
...sandboxedEnv.engine === void 0 ? {} : { effectiveEngine: sandboxedEnv.engine }
|
|
30643
|
+
}));
|
|
30644
|
+
} catch (error) {
|
|
30645
|
+
return await presentControlledFailure2(
|
|
30646
|
+
admitted,
|
|
30647
|
+
{
|
|
30648
|
+
timedOut: false,
|
|
30649
|
+
code: null,
|
|
30650
|
+
stderr: "",
|
|
30651
|
+
thrown: error
|
|
30652
|
+
},
|
|
30653
|
+
reviewerAdapters(env.packageRoot, methodMaterial),
|
|
30654
|
+
env.principalAuthority,
|
|
30655
|
+
io
|
|
30656
|
+
);
|
|
30657
|
+
}
|
|
30658
|
+
}
|
|
30659
|
+
async function runPublicReviewerResume(request, env, io) {
|
|
30660
|
+
const sandbox = {
|
|
30661
|
+
...env.executionCwd === void 0 ? {} : { executionCwd: env.executionCwd }
|
|
30662
|
+
};
|
|
30663
|
+
return await runPostAdmissionSeatResume({
|
|
30664
|
+
request,
|
|
30665
|
+
env,
|
|
30666
|
+
io,
|
|
30667
|
+
load: (effective) => loadResumableReviewerRun(env.home, effective.runId, env.principalAuthority),
|
|
30668
|
+
buildTurnRequest: (admitted, effective) => {
|
|
30669
|
+
const activeEnv = sandbox.executionCwd === void 0 ? env : { ...env, executionCwd: sandbox.executionCwd };
|
|
30670
|
+
const base = resumeTurnRequestProjectionOptions(admitted, effective, activeEnv);
|
|
30671
|
+
return buildReviewerTurnRequest(admitted, {
|
|
30672
|
+
...base,
|
|
30673
|
+
// Fresh copy at resume time; durable projectRoot unchanged.
|
|
30674
|
+
...sandbox.executionCwd === void 0 ? {} : { cwd: sandbox.executionCwd },
|
|
30675
|
+
continuation: {
|
|
30676
|
+
kind: "resume",
|
|
30677
|
+
prompt: reviewerResumePrompt(activeEnv, effective.message)
|
|
30678
|
+
}
|
|
30679
|
+
});
|
|
30680
|
+
},
|
|
30681
|
+
adapters: reviewerAdapters(env.packageRoot),
|
|
30682
|
+
afterAdmittedLoad: async (admitted) => {
|
|
30683
|
+
return resolveResumeMethodMaterialAdapters({
|
|
30684
|
+
admitted,
|
|
30685
|
+
authority: env.principalAuthority,
|
|
30686
|
+
io,
|
|
30687
|
+
loadMaterial: () => loadReviewerMethodMaterial(env.packageRoot),
|
|
30688
|
+
adaptersWith: (material) => reviewerAdapters(env.packageRoot, material),
|
|
30689
|
+
emptyAdapters: reviewerAdapters(env.packageRoot)
|
|
30690
|
+
});
|
|
30691
|
+
},
|
|
30692
|
+
afterAdmittedPrepare: async (admitted) => {
|
|
30693
|
+
if (sandbox.executionCwd !== void 0) {
|
|
30694
|
+
return { env: { ...env, executionCwd: sandbox.executionCwd } };
|
|
30695
|
+
}
|
|
30696
|
+
const { openEphemeralReviewerWorktree: openEphemeralReviewerWorktree2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
|
|
30697
|
+
const opened = await openEphemeralReviewerWorktree2({
|
|
30698
|
+
projectRoot: admitted.projectRoot,
|
|
30699
|
+
onCleanupDiagnostic: (diagnostic) => {
|
|
30700
|
+
io.stderr(`${diagnostic}
|
|
30701
|
+
`);
|
|
30702
|
+
}
|
|
30703
|
+
});
|
|
30704
|
+
sandbox.executionCwd = opened.executionCwd;
|
|
30705
|
+
return {
|
|
30706
|
+
env: { ...env, executionCwd: opened.executionCwd },
|
|
30707
|
+
cleanup: opened.close
|
|
30708
|
+
};
|
|
30709
|
+
},
|
|
30710
|
+
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
30711
|
+
});
|
|
30712
|
+
}
|
|
30713
|
+
var init_reviewer_run = __esm({
|
|
30714
|
+
"src/public-cli/reviewer-run.ts"() {
|
|
30715
|
+
"use strict";
|
|
30716
|
+
init_engine_material();
|
|
30717
|
+
init_method_skill();
|
|
30718
|
+
init_cli_errors();
|
|
30719
|
+
init_invocation();
|
|
30720
|
+
init_run_lifecycle();
|
|
30721
|
+
init_settlement();
|
|
30722
|
+
init_terminal();
|
|
30723
|
+
init_turn_request();
|
|
30724
|
+
init_post_admission();
|
|
30725
|
+
}
|
|
30726
|
+
});
|
|
30727
|
+
|
|
30728
|
+
// src/public-role-summons.ts
|
|
30729
|
+
var public_role_summons_exports = {};
|
|
30730
|
+
__export(public_role_summons_exports, {
|
|
30731
|
+
AK_ROLE_PACKAGE_ROOT_ENV: () => AK_ROLE_PACKAGE_ROOT_ENV,
|
|
30732
|
+
openEphemeralReviewerWorktree: () => openEphemeralReviewerWorktree,
|
|
30733
|
+
resolveSummonsPackageRoot: () => resolveSummonsPackageRoot,
|
|
30734
|
+
summonGateOfficer: () => summonGateOfficer,
|
|
30735
|
+
summonParallelReviewerLenses: () => summonParallelReviewerLenses,
|
|
30736
|
+
summonPublicRole: () => summonPublicRole,
|
|
30737
|
+
withEphemeralReviewerWorktree: () => withEphemeralReviewerWorktree
|
|
30738
|
+
});
|
|
30739
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
30740
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
30741
|
+
import { mkdir as mkdir5, mkdtemp as mkdtemp3, realpath as realpath6, rm as rm3 } from "node:fs/promises";
|
|
30742
|
+
import { tmpdir as tmpdir3 } from "node:os";
|
|
30743
|
+
import { join as join30, relative as relative3, sep as sep5 } from "node:path";
|
|
30744
|
+
import { promisify as promisify3 } from "node:util";
|
|
30745
|
+
function createCapturingIo() {
|
|
30746
|
+
const chunks = [];
|
|
30747
|
+
return {
|
|
30748
|
+
io: {
|
|
30749
|
+
stdout() {
|
|
30750
|
+
},
|
|
30751
|
+
stderr(text) {
|
|
30752
|
+
chunks.push(text);
|
|
30753
|
+
}
|
|
30754
|
+
},
|
|
30755
|
+
stderrText: () => chunks.join("")
|
|
30756
|
+
};
|
|
30757
|
+
}
|
|
30758
|
+
function parentDir(path) {
|
|
30759
|
+
const end = path.endsWith("/") || path.endsWith("\\") ? path.slice(0, -1) : path;
|
|
30760
|
+
const idx = Math.max(end.lastIndexOf("/"), end.lastIndexOf("\\"));
|
|
30761
|
+
if (idx <= 0) return end;
|
|
30762
|
+
return end.slice(0, idx);
|
|
30763
|
+
}
|
|
30764
|
+
function walkPackageRoot(start) {
|
|
30765
|
+
let dir = start;
|
|
30766
|
+
for (let i = 0; i < 12; i += 1) {
|
|
30767
|
+
if (existsSync10(join30(dir, "package.json")) && existsSync10(join30(dir, "souls"))) {
|
|
30768
|
+
return dir;
|
|
30769
|
+
}
|
|
30770
|
+
const parent = parentDir(dir);
|
|
30771
|
+
if (parent === dir) break;
|
|
30772
|
+
dir = parent;
|
|
30773
|
+
}
|
|
30774
|
+
return void 0;
|
|
30775
|
+
}
|
|
30776
|
+
function resolveSummonsPackageRoot(explicit) {
|
|
30777
|
+
if (typeof explicit === "string" && explicit.trim() !== "") {
|
|
30778
|
+
return explicit;
|
|
30779
|
+
}
|
|
30780
|
+
const fromEnv = process.env[AK_ROLE_PACKAGE_ROOT_ENV];
|
|
30781
|
+
if (typeof fromEnv === "string" && fromEnv.trim() !== "") {
|
|
30782
|
+
return fromEnv;
|
|
30783
|
+
}
|
|
30784
|
+
const fromCwd = walkPackageRoot(process.cwd());
|
|
30785
|
+
if (fromCwd !== void 0) return fromCwd;
|
|
30786
|
+
try {
|
|
30787
|
+
const metaUrl = import.meta.url;
|
|
30788
|
+
if (typeof metaUrl === "string" && metaUrl.startsWith("file:")) {
|
|
30789
|
+
const filePath = decodeURIComponent(metaUrl.slice("file://".length));
|
|
30790
|
+
const fromMeta = walkPackageRoot(parentDir(filePath));
|
|
30791
|
+
if (fromMeta !== void 0) return fromMeta;
|
|
30792
|
+
}
|
|
30793
|
+
} catch {
|
|
30794
|
+
}
|
|
30795
|
+
throw new Error(
|
|
30796
|
+
"public role summons cannot resolve package root (pass packageRoot or set AK_ROLE_PACKAGE_ROOT)"
|
|
30797
|
+
);
|
|
30798
|
+
}
|
|
30799
|
+
async function resolveSummonHome(options) {
|
|
30800
|
+
if (options.home !== void 0 && options.home.trim() !== "") {
|
|
30801
|
+
return options.home;
|
|
30802
|
+
}
|
|
30803
|
+
const { tryHomeFromAkRolesPath: tryHomeFromAkRolesPath2, packageMachineHome: packageMachineHome2 } = await Promise.resolve().then(() => (init_activation_ledger_topology(), activation_ledger_topology_exports));
|
|
30804
|
+
const fromCwd = tryHomeFromAkRolesPath2(options.cwd);
|
|
30805
|
+
if (fromCwd !== void 0 && fromCwd.length > 0) return fromCwd;
|
|
30806
|
+
return packageMachineHome2();
|
|
30807
|
+
}
|
|
30808
|
+
function projectSeatEngine(seat) {
|
|
30809
|
+
return pickEngineAxis(seat);
|
|
30810
|
+
}
|
|
30811
|
+
function projectSeatHost(seat) {
|
|
30812
|
+
return seat.host === void 0 ? {} : { host: seat.host };
|
|
30813
|
+
}
|
|
30814
|
+
function hostSelectionFailureFromUnknown(error) {
|
|
30815
|
+
if (typeof error !== "object" || error === null) return void 0;
|
|
30816
|
+
if (error.name !== "HostSelectionError") return void 0;
|
|
30817
|
+
const failure = error.failure;
|
|
30818
|
+
return failure;
|
|
30819
|
+
}
|
|
30820
|
+
async function createSummonEnv(options, afterHost) {
|
|
30821
|
+
const [
|
|
30822
|
+
{ piDurablePrincipalAuthority: piDurablePrincipalAuthority2 },
|
|
30823
|
+
{ appendPiSessionCustomEntry: appendPiSessionCustomEntry2 },
|
|
30824
|
+
{ resolveRoleTurnHost: resolveRoleTurnHost2 },
|
|
30825
|
+
{ missingResolvedSeatModelMessage: missingResolvedSeatModelMessage2, resolvedSeatWithModel: resolvedSeatWithModel2 }
|
|
30826
|
+
] = await Promise.all([
|
|
30518
30827
|
Promise.resolve().then(() => (init_durable_principal(), durable_principal_exports)),
|
|
30519
30828
|
Promise.resolve().then(() => (init_role_turn_host(), role_turn_host_exports)),
|
|
30520
30829
|
Promise.resolve().then(() => (init_role_turn_host_resolution(), role_turn_host_resolution_exports)),
|
|
30521
30830
|
Promise.resolve().then(() => (init_config2(), config_exports))
|
|
30522
30831
|
]);
|
|
30523
|
-
const principalAuthority = piDurablePrincipalAuthority2;
|
|
30832
|
+
const principalAuthority = options.principalAuthority ?? piDurablePrincipalAuthority2;
|
|
30524
30833
|
const roleTurnHost = resolveRoleTurnHost2(
|
|
30525
30834
|
{
|
|
30526
30835
|
packageRoot: options.packageRoot,
|
|
30527
30836
|
...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
|
|
30528
30837
|
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
30529
|
-
...options.extraPiArgs === void 0 || options.extraPiArgs.length === 0 ? {} : { extraPiArgs: options.extraPiArgs }
|
|
30838
|
+
...options.extraPiArgs === void 0 || options.extraPiArgs.length === 0 ? {} : { extraPiArgs: options.extraPiArgs },
|
|
30839
|
+
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
30530
30840
|
},
|
|
30531
30841
|
{ role: options.role, seat: options.seat, principalAuthority }
|
|
30532
30842
|
);
|
|
@@ -30539,13 +30849,16 @@ async function createSummonEnv(options, afterHost) {
|
|
|
30539
30849
|
};
|
|
30540
30850
|
}
|
|
30541
30851
|
const hostName = seatWithModel.host ?? "pi";
|
|
30542
|
-
|
|
30543
|
-
|
|
30544
|
-
|
|
30545
|
-
|
|
30546
|
-
|
|
30547
|
-
|
|
30548
|
-
|
|
30852
|
+
let hostFacingSelection = options.hostFacingModel;
|
|
30853
|
+
if (hostFacingSelection === void 0) {
|
|
30854
|
+
const { loadHostProvidersTable: loadHostProvidersTable2, projectHostFacingProvider: projectHostFacingProvider2 } = await Promise.resolve().then(() => (init_host_providers(), host_providers_exports));
|
|
30855
|
+
hostFacingSelection = projectHostFacingProvider2(
|
|
30856
|
+
seatWithModel.selection,
|
|
30857
|
+
hostName,
|
|
30858
|
+
loadHostProvidersTable2(options.home),
|
|
30859
|
+
options.home
|
|
30860
|
+
);
|
|
30861
|
+
}
|
|
30549
30862
|
return {
|
|
30550
30863
|
ok: true,
|
|
30551
30864
|
env: {
|
|
@@ -30559,7 +30872,8 @@ async function createSummonEnv(options, afterHost) {
|
|
|
30559
30872
|
credentials: options.credentials,
|
|
30560
30873
|
...hostFacingSelection === void 0 ? {} : { model: hostFacingSelection },
|
|
30561
30874
|
...projectSeatEngine(seatWithModel),
|
|
30562
|
-
...projectSeatHost(seatWithModel)
|
|
30875
|
+
...projectSeatHost(seatWithModel),
|
|
30876
|
+
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
30563
30877
|
}
|
|
30564
30878
|
};
|
|
30565
30879
|
}
|
|
@@ -30574,7 +30888,19 @@ async function summonPublicRole(options) {
|
|
|
30574
30888
|
} = await Promise.resolve().then(() => (init_config2(), config_exports));
|
|
30575
30889
|
const credentials = options.credentials ?? await loadCredentialProviders2(agentDir);
|
|
30576
30890
|
const config = await loadPublicCliConfig2(home);
|
|
30577
|
-
const
|
|
30891
|
+
const resolvedSeat = resolveEffectiveSeat2(config, options.role, credentials);
|
|
30892
|
+
const inheritedSelection = options.model === void 0 ? void 0 : {
|
|
30893
|
+
provider: options.model.provider,
|
|
30894
|
+
model: options.model.model,
|
|
30895
|
+
...options.model.thinking === void 0 ? {} : { thinking: options.model.thinking }
|
|
30896
|
+
};
|
|
30897
|
+
const seat = {
|
|
30898
|
+
...resolvedSeat,
|
|
30899
|
+
...inheritedSelection === void 0 ? {} : { selection: inheritedSelection, source: "invocation" },
|
|
30900
|
+
...options.host === void 0 ? {} : { host: options.host, hostSource: "invocation" },
|
|
30901
|
+
...options.engine === void 0 ? {} : { engine: options.engine, engineSource: "invocation" },
|
|
30902
|
+
...options.engineModel === void 0 ? {} : { engineModel: options.engineModel }
|
|
30903
|
+
};
|
|
30578
30904
|
const captured = options.io === void 0 ? createCapturingIo() : void 0;
|
|
30579
30905
|
const io = options.io ?? captured.io;
|
|
30580
30906
|
const summonEnvInput = {
|
|
@@ -30587,7 +30913,11 @@ async function summonPublicRole(options) {
|
|
|
30587
30913
|
seat,
|
|
30588
30914
|
...options.extraPiArgs === void 0 ? {} : { extraPiArgs: options.extraPiArgs },
|
|
30589
30915
|
...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
|
|
30590
|
-
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters }
|
|
30916
|
+
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
30917
|
+
...options.principalAuthority === void 0 ? {} : { principalAuthority: options.principalAuthority },
|
|
30918
|
+
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs },
|
|
30919
|
+
// Parent model is already host-facing; child must not project again.
|
|
30920
|
+
...options.model === void 0 ? {} : { hostFacingModel: options.model }
|
|
30591
30921
|
};
|
|
30592
30922
|
async function prepareSummonEnv(afterHost) {
|
|
30593
30923
|
try {
|
|
@@ -30599,7 +30929,9 @@ async function summonPublicRole(options) {
|
|
|
30599
30929
|
ok: true,
|
|
30600
30930
|
env: {
|
|
30601
30931
|
...built.env,
|
|
30602
|
-
|
|
30932
|
+
// Nested court stations keep station-child semantics; dual-lens
|
|
30933
|
+
// ordinary Reviewer axes opt out (#946 / ADR 0082).
|
|
30934
|
+
...options.stationChild === false ? {} : { stationChild: true },
|
|
30603
30935
|
// Forward composition-root adapters so nested court stations (e.g.
|
|
30604
30936
|
// countersign → diarist) select the same faux/production table (#924).
|
|
30605
30937
|
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
@@ -30609,7 +30941,8 @@ async function summonPublicRole(options) {
|
|
|
30609
30941
|
...options.gateReviewInstruction === void 0 ? {} : { gateReviewInstruction: options.gateReviewInstruction },
|
|
30610
30942
|
...options.boundTicketNumber === void 0 ? {} : { boundTicketNumber: options.boundTicketNumber },
|
|
30611
30943
|
...options.correlationId === void 0 || options.correlationId.trim() === "" ? {} : { correlationId: options.correlationId },
|
|
30612
|
-
...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
|
|
30944
|
+
...options.createRunId === void 0 ? {} : { createRunId: options.createRunId },
|
|
30945
|
+
...options.executionCwd === void 0 ? {} : { executionCwd: options.executionCwd }
|
|
30613
30946
|
}
|
|
30614
30947
|
};
|
|
30615
30948
|
} catch (error) {
|
|
@@ -30671,14 +31004,32 @@ async function summonPublicRole(options) {
|
|
|
30671
31004
|
case "navigator":
|
|
30672
31005
|
case "gatekeeper": {
|
|
30673
31006
|
const seat2 = options.role;
|
|
30674
|
-
const [{ runPublicInstructionSeat: runPublicInstructionSeat2 }, invocation] = await Promise.all([
|
|
31007
|
+
const [{ runPublicInstructionSeat: runPublicInstructionSeat2, runPublicInstructionSeatResume: runPublicInstructionSeatResume2 }, invocation] = await Promise.all([
|
|
30675
31008
|
Promise.resolve().then(() => (init_instruction_seat_run(), instruction_seat_run_exports)),
|
|
30676
31009
|
Promise.resolve().then(() => (init_invocation(), invocation_exports))
|
|
30677
31010
|
]);
|
|
30678
31011
|
const parse = seat2 === "auditor" ? invocation.parseAuditorArgv : seat2 === "navigator" ? invocation.parseNavigatorArgv : invocation.parseGatekeeperArgv;
|
|
30679
|
-
const
|
|
30680
|
-
if (
|
|
30681
|
-
|
|
31012
|
+
const resumeRunId = typeof options.resumeRunId === "string" && options.resumeRunId.trim() !== "" ? options.resumeRunId.trim() : void 0;
|
|
31013
|
+
if (resumeRunId !== void 0) {
|
|
31014
|
+
const instruction = options.argv[0] ?? "";
|
|
31015
|
+
const stepped = await runPrepared(parse, (env) => runPublicInstructionSeatResume2(
|
|
31016
|
+
{
|
|
31017
|
+
runId: resumeRunId,
|
|
31018
|
+
summons: {
|
|
31019
|
+
instruction,
|
|
31020
|
+
instructionEmpty: instruction.trim() === ""
|
|
31021
|
+
}
|
|
31022
|
+
},
|
|
31023
|
+
env,
|
|
31024
|
+
io
|
|
31025
|
+
));
|
|
31026
|
+
if ("fail" in stepped) return stepped.fail;
|
|
31027
|
+
result2 = stepped.ok;
|
|
31028
|
+
} else {
|
|
31029
|
+
const stepped = await runPrepared(parse, (env, once) => runPublicInstructionSeat2(options.argv, env, io, seat2, once));
|
|
31030
|
+
if ("fail" in stepped) return stepped.fail;
|
|
31031
|
+
result2 = stepped.ok;
|
|
31032
|
+
}
|
|
30682
31033
|
break;
|
|
30683
31034
|
}
|
|
30684
31035
|
case "judge": {
|
|
@@ -30721,6 +31072,16 @@ async function summonPublicRole(options) {
|
|
|
30721
31072
|
result2 = stepped.ok;
|
|
30722
31073
|
break;
|
|
30723
31074
|
}
|
|
31075
|
+
case "reviewer": {
|
|
31076
|
+
const [{ runPublicReviewer: runPublicReviewer2 }, { parseReviewerArgv: parseReviewerArgv2 }] = await Promise.all([
|
|
31077
|
+
Promise.resolve().then(() => (init_reviewer_run(), reviewer_run_exports)),
|
|
31078
|
+
Promise.resolve().then(() => (init_invocation(), invocation_exports))
|
|
31079
|
+
]);
|
|
31080
|
+
const stepped = await runPrepared(parseReviewerArgv2, (env, once) => runPublicReviewer2(options.argv, env, io, once));
|
|
31081
|
+
if ("fail" in stepped) return stepped.fail;
|
|
31082
|
+
result2 = stepped.ok;
|
|
31083
|
+
break;
|
|
31084
|
+
}
|
|
30724
31085
|
}
|
|
30725
31086
|
const stderr = captured?.stderrText();
|
|
30726
31087
|
const runDirectory = result2.admitted?.runDirectory;
|
|
@@ -30732,6 +31093,296 @@ async function summonPublicRole(options) {
|
|
|
30732
31093
|
...stderr === void 0 || stderr === "" ? {} : { stderr }
|
|
30733
31094
|
};
|
|
30734
31095
|
}
|
|
31096
|
+
function withReviewerLens(argv, lens) {
|
|
31097
|
+
const separator = argv.indexOf("--");
|
|
31098
|
+
if (separator === -1) return [...argv, "--lens", lens];
|
|
31099
|
+
return [...argv.slice(0, separator), "--lens", lens, ...argv.slice(separator)];
|
|
31100
|
+
}
|
|
31101
|
+
async function resolveReviewerWorktreeRoots(projectRoot) {
|
|
31102
|
+
const callerProjectRoot = await realpath6(projectRoot);
|
|
31103
|
+
const sourceProjectRoot = await realpath6((await execFileAsync3(
|
|
31104
|
+
"git",
|
|
31105
|
+
["rev-parse", "--show-toplevel"],
|
|
31106
|
+
{ cwd: callerProjectRoot }
|
|
31107
|
+
)).stdout.trim());
|
|
31108
|
+
const callerRelative = relative3(sourceProjectRoot, callerProjectRoot);
|
|
31109
|
+
const projectRelative = callerRelative === "" || callerRelative === "." || callerRelative.startsWith(`..${sep5}`) || callerRelative === ".." ? "" : callerRelative;
|
|
31110
|
+
return { callerProjectRoot, sourceProjectRoot, projectRelative };
|
|
31111
|
+
}
|
|
31112
|
+
function reviewerSandboxPath(worktreeAxis, projectRelative) {
|
|
31113
|
+
return projectRelative === "" ? worktreeAxis : join30(worktreeAxis, projectRelative);
|
|
31114
|
+
}
|
|
31115
|
+
async function openEphemeralReviewerWorktree(options) {
|
|
31116
|
+
const { sourceProjectRoot, projectRelative } = await resolveReviewerWorktreeRoots(
|
|
31117
|
+
options.projectRoot
|
|
31118
|
+
);
|
|
31119
|
+
const { stdout: headStdout } = await execFileAsync3(
|
|
31120
|
+
"git",
|
|
31121
|
+
["rev-parse", "--verify", "HEAD^{commit}"],
|
|
31122
|
+
{ cwd: sourceProjectRoot }
|
|
31123
|
+
);
|
|
31124
|
+
const targetCommit = headStdout.trim();
|
|
31125
|
+
const root = await mkdtemp3(join30(tmpdir3(), "ak-reviewer-sandbox-"));
|
|
31126
|
+
const worktreeRoot = join30(root, "work");
|
|
31127
|
+
let registered = false;
|
|
31128
|
+
const rollback = async (cause) => {
|
|
31129
|
+
const cleanupErrors = [];
|
|
31130
|
+
if (registered) {
|
|
31131
|
+
try {
|
|
31132
|
+
await execFileAsync3("git", ["worktree", "remove", "--force", worktreeRoot], {
|
|
31133
|
+
cwd: sourceProjectRoot
|
|
31134
|
+
});
|
|
31135
|
+
} catch (error) {
|
|
31136
|
+
cleanupErrors.push(error);
|
|
31137
|
+
}
|
|
31138
|
+
}
|
|
31139
|
+
try {
|
|
31140
|
+
await rm3(root, { recursive: true, force: true });
|
|
31141
|
+
} catch (error) {
|
|
31142
|
+
cleanupErrors.push(error);
|
|
31143
|
+
}
|
|
31144
|
+
if (cleanupErrors.length > 0) {
|
|
31145
|
+
options.onCleanupDiagnostic?.([
|
|
31146
|
+
"reviewer worktree cleanup failed",
|
|
31147
|
+
...cleanupErrors.map((error) => error instanceof Error ? error.message : String(error))
|
|
31148
|
+
].join("\n"));
|
|
31149
|
+
}
|
|
31150
|
+
throw cause;
|
|
31151
|
+
};
|
|
31152
|
+
try {
|
|
31153
|
+
await execFileAsync3("git", ["worktree", "add", "--detach", worktreeRoot, targetCommit], {
|
|
31154
|
+
cwd: sourceProjectRoot
|
|
31155
|
+
});
|
|
31156
|
+
registered = true;
|
|
31157
|
+
if (projectRelative !== "") {
|
|
31158
|
+
await mkdir5(reviewerSandboxPath(worktreeRoot, projectRelative), { recursive: true });
|
|
31159
|
+
}
|
|
31160
|
+
} catch (error) {
|
|
31161
|
+
await rollback(error);
|
|
31162
|
+
}
|
|
31163
|
+
let closed = false;
|
|
31164
|
+
return {
|
|
31165
|
+
executionCwd: reviewerSandboxPath(worktreeRoot, projectRelative),
|
|
31166
|
+
close: async () => {
|
|
31167
|
+
if (closed) return;
|
|
31168
|
+
closed = true;
|
|
31169
|
+
const cleanupErrors = [];
|
|
31170
|
+
try {
|
|
31171
|
+
await execFileAsync3("git", ["worktree", "remove", worktreeRoot], {
|
|
31172
|
+
cwd: sourceProjectRoot
|
|
31173
|
+
});
|
|
31174
|
+
} catch (error) {
|
|
31175
|
+
cleanupErrors.push(error);
|
|
31176
|
+
}
|
|
31177
|
+
try {
|
|
31178
|
+
await rm3(root, { recursive: true, force: true });
|
|
31179
|
+
} catch (error) {
|
|
31180
|
+
cleanupErrors.push(error);
|
|
31181
|
+
}
|
|
31182
|
+
if (cleanupErrors.length > 0) {
|
|
31183
|
+
options.onCleanupDiagnostic?.([
|
|
31184
|
+
"reviewer worktree cleanup failed",
|
|
31185
|
+
...cleanupErrors.map((error) => error instanceof Error ? error.message : String(error))
|
|
31186
|
+
].join("\n"));
|
|
31187
|
+
}
|
|
31188
|
+
}
|
|
31189
|
+
};
|
|
31190
|
+
}
|
|
31191
|
+
async function withEphemeralReviewerWorktree(options) {
|
|
31192
|
+
const sandbox = await openEphemeralReviewerWorktree({
|
|
31193
|
+
projectRoot: options.projectRoot,
|
|
31194
|
+
...options.onCleanupDiagnostic === void 0 ? {} : { onCleanupDiagnostic: options.onCleanupDiagnostic }
|
|
31195
|
+
});
|
|
31196
|
+
try {
|
|
31197
|
+
return await options.run(sandbox.executionCwd);
|
|
31198
|
+
} finally {
|
|
31199
|
+
await sandbox.close();
|
|
31200
|
+
}
|
|
31201
|
+
}
|
|
31202
|
+
async function summonParallelReviewerLenses(options) {
|
|
31203
|
+
const describeFailure = (error) => {
|
|
31204
|
+
if (error instanceof AggregateError) {
|
|
31205
|
+
return [error.message, ...error.errors.map(describeFailure)].join("\n");
|
|
31206
|
+
}
|
|
31207
|
+
return error instanceof Error ? error.message : String(error);
|
|
31208
|
+
};
|
|
31209
|
+
const failedResult = (error) => ({
|
|
31210
|
+
exitCode: 1,
|
|
31211
|
+
stderr: describeFailure(error)
|
|
31212
|
+
});
|
|
31213
|
+
const dualFailure = (error) => {
|
|
31214
|
+
const failure = failedResult(error);
|
|
31215
|
+
return { completeness: failure, correctness: failure };
|
|
31216
|
+
};
|
|
31217
|
+
let sourceProjectRoot;
|
|
31218
|
+
let projectRelative;
|
|
31219
|
+
let targetCommit;
|
|
31220
|
+
const statusArgs = [
|
|
31221
|
+
"status",
|
|
31222
|
+
"--porcelain=v1",
|
|
31223
|
+
"--untracked-files=all",
|
|
31224
|
+
"--",
|
|
31225
|
+
":/",
|
|
31226
|
+
":(top,exclude).claude/worktrees/**"
|
|
31227
|
+
];
|
|
31228
|
+
try {
|
|
31229
|
+
const roots = await resolveReviewerWorktreeRoots(options.projectRoot);
|
|
31230
|
+
sourceProjectRoot = roots.sourceProjectRoot;
|
|
31231
|
+
projectRelative = roots.projectRelative;
|
|
31232
|
+
const { stdout: statusStdout } = await execFileAsync3("git", statusArgs, {
|
|
31233
|
+
cwd: sourceProjectRoot
|
|
31234
|
+
});
|
|
31235
|
+
if (statusStdout !== "") {
|
|
31236
|
+
const diagnostic = [
|
|
31237
|
+
"Reviewer target status gate failed:",
|
|
31238
|
+
"git status --porcelain=v1 --untracked-files=all -- :/ ':(top,exclude).claude/worktrees/**'",
|
|
31239
|
+
statusStdout
|
|
31240
|
+
].join("\n");
|
|
31241
|
+
return dualFailure(new Error(diagnostic));
|
|
31242
|
+
}
|
|
31243
|
+
const { stdout: targetStdout } = await execFileAsync3(
|
|
31244
|
+
"git",
|
|
31245
|
+
["rev-parse", "--verify", "HEAD^{commit}"],
|
|
31246
|
+
{ cwd: sourceProjectRoot }
|
|
31247
|
+
);
|
|
31248
|
+
targetCommit = targetStdout.trim();
|
|
31249
|
+
await execFileAsync3(
|
|
31250
|
+
"git",
|
|
31251
|
+
["rev-parse", "--verify", `${options.baseRevision}^{commit}`],
|
|
31252
|
+
{ cwd: sourceProjectRoot }
|
|
31253
|
+
);
|
|
31254
|
+
} catch (error) {
|
|
31255
|
+
return dualFailure(error);
|
|
31256
|
+
}
|
|
31257
|
+
const root = await mkdtemp3(join30(tmpdir3(), "ak-reviewer-lenses-"));
|
|
31258
|
+
const completenessRoot = join30(root, "completeness");
|
|
31259
|
+
const correctnessRoot = join30(root, "correctness");
|
|
31260
|
+
const worktrees = [completenessRoot, correctnessRoot];
|
|
31261
|
+
const created = /* @__PURE__ */ new Set();
|
|
31262
|
+
let results;
|
|
31263
|
+
const creation = await Promise.allSettled(
|
|
31264
|
+
worktrees.map(async (path) => {
|
|
31265
|
+
await execFileAsync3("git", ["worktree", "add", "--detach", path, targetCommit], {
|
|
31266
|
+
cwd: sourceProjectRoot
|
|
31267
|
+
});
|
|
31268
|
+
created.add(path);
|
|
31269
|
+
if (projectRelative !== "") {
|
|
31270
|
+
await mkdir5(reviewerSandboxPath(path, projectRelative), { recursive: true });
|
|
31271
|
+
}
|
|
31272
|
+
})
|
|
31273
|
+
);
|
|
31274
|
+
const creationFailures = creation.flatMap((result2) => result2.status === "rejected" ? [result2.reason] : []);
|
|
31275
|
+
if (creationFailures.length > 0) {
|
|
31276
|
+
const failure = failedResult(new AggregateError(
|
|
31277
|
+
creationFailures,
|
|
31278
|
+
"parallel reviewer worktree creation failed"
|
|
31279
|
+
));
|
|
31280
|
+
results = { completeness: failure, correctness: failure };
|
|
31281
|
+
} else {
|
|
31282
|
+
const summon = (lens, worktreeAxis) => {
|
|
31283
|
+
const sandbox = reviewerSandboxPath(worktreeAxis, projectRelative);
|
|
31284
|
+
return summonPublicRole({
|
|
31285
|
+
role: "reviewer",
|
|
31286
|
+
argv: withReviewerLens(options.argv, lens),
|
|
31287
|
+
cwd: options.cwd,
|
|
31288
|
+
executionCwd: sandbox,
|
|
31289
|
+
// Ordinary single-axis public semantics — not a nested court station.
|
|
31290
|
+
stationChild: false,
|
|
31291
|
+
home: options.home,
|
|
31292
|
+
...options.agentDir === void 0 ? {} : { agentDir: options.agentDir },
|
|
31293
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
31294
|
+
...options.model === void 0 ? {} : { model: options.model },
|
|
31295
|
+
...options.host === void 0 ? {} : { host: options.host },
|
|
31296
|
+
...options.engine === void 0 ? {} : { engine: options.engine },
|
|
31297
|
+
...options.engineModel === void 0 ? {} : { engineModel: options.engineModel },
|
|
31298
|
+
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
31299
|
+
...options.correlationId === void 0 ? {} : { correlationId: options.correlationId },
|
|
31300
|
+
...options.packageRoot === void 0 ? {} : { packageRoot: options.packageRoot },
|
|
31301
|
+
...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
|
|
31302
|
+
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
31303
|
+
...options.principalAuthority === void 0 ? {} : { principalAuthority: options.principalAuthority },
|
|
31304
|
+
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
31305
|
+
});
|
|
31306
|
+
};
|
|
31307
|
+
const settled = await Promise.allSettled([
|
|
31308
|
+
summon("completeness", completenessRoot),
|
|
31309
|
+
summon("correctness", correctnessRoot)
|
|
31310
|
+
]);
|
|
31311
|
+
results = {
|
|
31312
|
+
completeness: settled[0].status === "fulfilled" ? settled[0].value : failedResult(settled[0].reason),
|
|
31313
|
+
correctness: settled[1].status === "fulfilled" ? settled[1].value : failedResult(settled[1].reason)
|
|
31314
|
+
};
|
|
31315
|
+
}
|
|
31316
|
+
let sealDiagnostic;
|
|
31317
|
+
try {
|
|
31318
|
+
const { stdout: headBeforeStdout } = await execFileAsync3(
|
|
31319
|
+
"git",
|
|
31320
|
+
["rev-parse", "--verify", "HEAD^{commit}"],
|
|
31321
|
+
{ cwd: sourceProjectRoot }
|
|
31322
|
+
);
|
|
31323
|
+
const { stdout: sealedStatusStdout } = await execFileAsync3("git", statusArgs, {
|
|
31324
|
+
cwd: sourceProjectRoot
|
|
31325
|
+
});
|
|
31326
|
+
const { stdout: headAfterStdout } = await execFileAsync3(
|
|
31327
|
+
"git",
|
|
31328
|
+
["rev-parse", "--verify", "HEAD^{commit}"],
|
|
31329
|
+
{ cwd: sourceProjectRoot }
|
|
31330
|
+
);
|
|
31331
|
+
const headBefore = headBeforeStdout.trim();
|
|
31332
|
+
const headAfter = headAfterStdout.trim();
|
|
31333
|
+
if (headBefore !== targetCommit || headAfter !== targetCommit || sealedStatusStdout !== "") {
|
|
31334
|
+
sealDiagnostic = [
|
|
31335
|
+
"Reviewer target final seal failed:",
|
|
31336
|
+
`HEAD before status => ${headBefore}`,
|
|
31337
|
+
`HEAD after status => ${headAfter}`,
|
|
31338
|
+
`expected PRE_HEAD ${targetCommit}`,
|
|
31339
|
+
"git status --porcelain=v1 --untracked-files=all -- :/ ':(top,exclude).claude/worktrees/**'",
|
|
31340
|
+
sealedStatusStdout
|
|
31341
|
+
].join("\n");
|
|
31342
|
+
}
|
|
31343
|
+
} catch (error) {
|
|
31344
|
+
sealDiagnostic = `Reviewer target final seal failed:
|
|
31345
|
+
${describeFailure(error)}`;
|
|
31346
|
+
}
|
|
31347
|
+
if (sealDiagnostic !== void 0) {
|
|
31348
|
+
const withSealFailure = (result2) => ({
|
|
31349
|
+
...result2,
|
|
31350
|
+
exitCode: 1,
|
|
31351
|
+
stderr: [result2.stderr, sealDiagnostic].filter(
|
|
31352
|
+
(text) => typeof text === "string" && text !== ""
|
|
31353
|
+
).join("\n")
|
|
31354
|
+
});
|
|
31355
|
+
results = {
|
|
31356
|
+
completeness: withSealFailure(results.completeness),
|
|
31357
|
+
correctness: withSealFailure(results.correctness)
|
|
31358
|
+
};
|
|
31359
|
+
}
|
|
31360
|
+
const cleanup = await Promise.allSettled(
|
|
31361
|
+
[...created].map((path) => execFileAsync3("git", ["worktree", "remove", path], { cwd: sourceProjectRoot }))
|
|
31362
|
+
);
|
|
31363
|
+
const cleanupFailures = cleanup.flatMap((result2) => result2.status === "rejected" ? [result2.reason] : []);
|
|
31364
|
+
if (cleanupFailures.length === 0) {
|
|
31365
|
+
const rootCleanup = await Promise.allSettled([rm3(root, { recursive: true, force: true })]);
|
|
31366
|
+
cleanupFailures.push(...rootCleanup.flatMap((result2) => result2.status === "rejected" ? [result2.reason] : []));
|
|
31367
|
+
}
|
|
31368
|
+
if (cleanupFailures.length > 0) {
|
|
31369
|
+
const diagnostic = [
|
|
31370
|
+
"parallel reviewer worktree cleanup failed",
|
|
31371
|
+
...cleanupFailures.map((failure) => failure instanceof Error ? failure.message : String(failure))
|
|
31372
|
+
].join("\n");
|
|
31373
|
+
const withCleanupDiagnostic = (result2) => ({
|
|
31374
|
+
...result2,
|
|
31375
|
+
stderr: [result2.stderr, diagnostic].filter(
|
|
31376
|
+
(text) => typeof text === "string" && text !== ""
|
|
31377
|
+
).join("\n")
|
|
31378
|
+
});
|
|
31379
|
+
results = {
|
|
31380
|
+
completeness: withCleanupDiagnostic(results.completeness),
|
|
31381
|
+
correctness: withCleanupDiagnostic(results.correctness)
|
|
31382
|
+
};
|
|
31383
|
+
}
|
|
31384
|
+
return results;
|
|
31385
|
+
}
|
|
30735
31386
|
async function summonGateOfficer(options) {
|
|
30736
31387
|
let home = options.home;
|
|
30737
31388
|
if (home === void 0) {
|
|
@@ -30781,12 +31432,13 @@ async function summonGateOfficer(options) {
|
|
|
30781
31432
|
...common
|
|
30782
31433
|
});
|
|
30783
31434
|
}
|
|
30784
|
-
var AK_ROLE_PACKAGE_ROOT_ENV;
|
|
31435
|
+
var AK_ROLE_PACKAGE_ROOT_ENV, execFileAsync3;
|
|
30785
31436
|
var init_public_role_summons = __esm({
|
|
30786
31437
|
"src/public-role-summons.ts"() {
|
|
30787
31438
|
"use strict";
|
|
30788
31439
|
init_engine_material();
|
|
30789
31440
|
AK_ROLE_PACKAGE_ROOT_ENV = "AK_ROLE_PACKAGE_ROOT";
|
|
31441
|
+
execFileAsync3 = promisify3(execFile3);
|
|
30790
31442
|
}
|
|
30791
31443
|
});
|
|
30792
31444
|
|
|
@@ -31663,7 +32315,7 @@ async function runPublicFixer(argv, env, io, parseFixerArgv2) {
|
|
|
31663
32315
|
...admitted.correlationId === void 0 && env.correlationId === void 0 ? {} : { correlationId: admitted.correlationId ?? env.correlationId },
|
|
31664
32316
|
continuation: {
|
|
31665
32317
|
kind: "resume",
|
|
31666
|
-
prompt:
|
|
32318
|
+
prompt: buildAutoResumeContinuationPrompt({
|
|
31667
32319
|
packageRoot: env.packageRoot,
|
|
31668
32320
|
...pickEngineAxis(env)
|
|
31669
32321
|
})
|
|
@@ -31842,7 +32494,7 @@ async function runPublicMerger(argv, env, io, parseMergerArgv2) {
|
|
|
31842
32494
|
...admitted.correlationId === void 0 && env.correlationId === void 0 ? {} : { correlationId: admitted.correlationId ?? env.correlationId },
|
|
31843
32495
|
continuation: {
|
|
31844
32496
|
kind: "resume",
|
|
31845
|
-
prompt:
|
|
32497
|
+
prompt: buildAutoResumeContinuationPrompt({
|
|
31846
32498
|
packageRoot: env.packageRoot,
|
|
31847
32499
|
...pickEngineAxis(env)
|
|
31848
32500
|
})
|
|
@@ -31889,189 +32541,6 @@ var init_merger_run = __esm({
|
|
|
31889
32541
|
}
|
|
31890
32542
|
});
|
|
31891
32543
|
|
|
31892
|
-
// src/public-cli/reviewer-run.ts
|
|
31893
|
-
function reviewerMethods(packageRoot2) {
|
|
31894
|
-
return [{ kind: "skill", path: resolvePackagedMethodSkillPath(packageRoot2, "ak-cross-m-review") }];
|
|
31895
|
-
}
|
|
31896
|
-
function buildReviewerTurnRequest(admitted, options) {
|
|
31897
|
-
return projectRoleTurnRequest(
|
|
31898
|
-
admitted,
|
|
31899
|
-
{
|
|
31900
|
-
activation: {
|
|
31901
|
-
role: "reviewer",
|
|
31902
|
-
baseRevision: admitted.baseRevision,
|
|
31903
|
-
lens: admitted.lens,
|
|
31904
|
-
authorityRefs: admitted.authorityRefs,
|
|
31905
|
-
...admitted.ticketNumber === void 0 ? {} : { ticketNumber: admitted.ticketNumber }
|
|
31906
|
-
},
|
|
31907
|
-
methods: reviewerMethods(options.packageRoot)
|
|
31908
|
-
},
|
|
31909
|
-
options
|
|
31910
|
-
);
|
|
31911
|
-
}
|
|
31912
|
-
function reviewerAdapters(packageRoot2, methodMaterial) {
|
|
31913
|
-
return {
|
|
31914
|
-
trySettle: (admitted, authority, scope) => methodMaterial === void 0 ? Promise.resolve(void 0) : trySettleReviewerTerminalResult(
|
|
31915
|
-
admitted,
|
|
31916
|
-
authority,
|
|
31917
|
-
{
|
|
31918
|
-
methodProvenance: methodMaterial.provenance,
|
|
31919
|
-
methodSkillPath: methodMaterial.skillPath,
|
|
31920
|
-
methodSkillConfiguredPath: resolvePackagedMethodSkillPath(
|
|
31921
|
-
packageRoot2,
|
|
31922
|
-
"ak-cross-m-review"
|
|
31923
|
-
)
|
|
31924
|
-
},
|
|
31925
|
-
scope
|
|
31926
|
-
),
|
|
31927
|
-
resolveRunnerKnownFailure: async ({ result: result2, sessionFile }) => {
|
|
31928
|
-
const infrastructureFailure = await readEngineDetourInfrastructureFailure(sessionFile);
|
|
31929
|
-
return infrastructureFailure === void 0 ? result2.knownFailure : {
|
|
31930
|
-
...infrastructureFailure.cause === void 0 ? {} : { cause: infrastructureFailure.cause },
|
|
31931
|
-
diagnostic: infrastructureFailure.diagnostic,
|
|
31932
|
-
...infrastructureFailure.identity === void 0 ? {} : { identity: infrastructureFailure.identity }
|
|
31933
|
-
};
|
|
31934
|
-
}
|
|
31935
|
-
};
|
|
31936
|
-
}
|
|
31937
|
-
async function loadReviewerMethodMaterial(packageRoot2) {
|
|
31938
|
-
return await loadPackagedMethodSkillMaterial(packageRoot2, "ak-cross-m-review");
|
|
31939
|
-
}
|
|
31940
|
-
function reviewerResumePrompt(env, message) {
|
|
31941
|
-
const lines = [RESUME_TRANSPORT_ENVELOPE];
|
|
31942
|
-
if (message !== void 0) lines.push("", message);
|
|
31943
|
-
return appendEngineSessionMaterial(
|
|
31944
|
-
lines,
|
|
31945
|
-
engineSessionMaterialFromOptions({
|
|
31946
|
-
...pickEngineAxis(env),
|
|
31947
|
-
packageRoot: env.packageRoot
|
|
31948
|
-
})
|
|
31949
|
-
).join("\n");
|
|
31950
|
-
}
|
|
31951
|
-
async function runPublicReviewer(argv, env, io, parseReviewerArgv2) {
|
|
31952
|
-
let admitted;
|
|
31953
|
-
try {
|
|
31954
|
-
const parsed = parseReviewerArgv2(argv);
|
|
31955
|
-
admitted = await admitReviewerInvocation({
|
|
31956
|
-
home: env.home,
|
|
31957
|
-
principalAuthority: env.principalAuthority,
|
|
31958
|
-
cwd: env.cwd,
|
|
31959
|
-
instruction: parsed.instruction,
|
|
31960
|
-
attachmentPaths: parsed.attachmentPaths,
|
|
31961
|
-
baseRevision: parsed.baseRevision,
|
|
31962
|
-
lens: parsed.lens,
|
|
31963
|
-
authorityRefs: parsed.authorityRefs,
|
|
31964
|
-
...parsed.project === void 0 ? {} : { project: parsed.project },
|
|
31965
|
-
...env.createRunId === void 0 ? {} : { createRunId: env.createRunId },
|
|
31966
|
-
...env.model === void 0 ? {} : { model: env.model }
|
|
31967
|
-
});
|
|
31968
|
-
} catch (error) {
|
|
31969
|
-
if (error instanceof CliUsageError) {
|
|
31970
|
-
presentStructuralRejection(error, io);
|
|
31971
|
-
return { exitCode: 2 };
|
|
31972
|
-
}
|
|
31973
|
-
throw error;
|
|
31974
|
-
}
|
|
31975
|
-
await markRunAdmitted(admitted, env.principalAuthority);
|
|
31976
|
-
let methodMaterial;
|
|
31977
|
-
try {
|
|
31978
|
-
methodMaterial = await loadReviewerMethodMaterial(env.packageRoot);
|
|
31979
|
-
} catch (error) {
|
|
31980
|
-
return await presentControlledFailure2(
|
|
31981
|
-
admitted,
|
|
31982
|
-
{
|
|
31983
|
-
timedOut: false,
|
|
31984
|
-
code: null,
|
|
31985
|
-
stderr: "",
|
|
31986
|
-
thrown: error
|
|
31987
|
-
},
|
|
31988
|
-
reviewerAdapters(env.packageRoot),
|
|
31989
|
-
env.principalAuthority,
|
|
31990
|
-
io
|
|
31991
|
-
);
|
|
31992
|
-
}
|
|
31993
|
-
return await runPostAdmissionResumable({
|
|
31994
|
-
admitted,
|
|
31995
|
-
env,
|
|
31996
|
-
io,
|
|
31997
|
-
buildInitialRequest: () => buildReviewerTurnRequest(admitted, {
|
|
31998
|
-
packageRoot: env.packageRoot,
|
|
31999
|
-
home: env.home,
|
|
32000
|
-
agentDir: env.agentDir,
|
|
32001
|
-
...env.model === void 0 ? {} : { model: env.model },
|
|
32002
|
-
...pickEngineAxis(env),
|
|
32003
|
-
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
|
|
32004
|
-
...admitted.correlationId === void 0 && env.correlationId === void 0 ? {} : { correlationId: admitted.correlationId ?? env.correlationId },
|
|
32005
|
-
continuation: {
|
|
32006
|
-
kind: "initial",
|
|
32007
|
-
prompt: buildReviewerTransportPrompt(
|
|
32008
|
-
admitted,
|
|
32009
|
-
engineSessionMaterialFromOptions({
|
|
32010
|
-
...pickEngineAxis(env),
|
|
32011
|
-
packageRoot: env.packageRoot
|
|
32012
|
-
})
|
|
32013
|
-
)
|
|
32014
|
-
}
|
|
32015
|
-
}),
|
|
32016
|
-
buildResumeRequest: () => buildReviewerTurnRequest(admitted, {
|
|
32017
|
-
packageRoot: env.packageRoot,
|
|
32018
|
-
home: env.home,
|
|
32019
|
-
agentDir: env.agentDir,
|
|
32020
|
-
...env.model === void 0 ? {} : { model: env.model },
|
|
32021
|
-
...pickEngineAxis(env),
|
|
32022
|
-
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
|
|
32023
|
-
...admitted.correlationId === void 0 && env.correlationId === void 0 ? {} : { correlationId: admitted.correlationId ?? env.correlationId },
|
|
32024
|
-
continuation: {
|
|
32025
|
-
kind: "resume",
|
|
32026
|
-
prompt: reviewerResumePrompt(env)
|
|
32027
|
-
}
|
|
32028
|
-
}),
|
|
32029
|
-
adapters: reviewerAdapters(env.packageRoot, methodMaterial),
|
|
32030
|
-
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
32031
|
-
});
|
|
32032
|
-
}
|
|
32033
|
-
async function runPublicReviewerResume(request, env, io) {
|
|
32034
|
-
return await runPostAdmissionSeatResume({
|
|
32035
|
-
request,
|
|
32036
|
-
env,
|
|
32037
|
-
io,
|
|
32038
|
-
load: (effective) => loadResumableReviewerRun(env.home, effective.runId, env.principalAuthority),
|
|
32039
|
-
buildTurnRequest: (admitted, effective) => {
|
|
32040
|
-
const base = resumeTurnRequestProjectionOptions(admitted, effective, env);
|
|
32041
|
-
return buildReviewerTurnRequest(admitted, {
|
|
32042
|
-
...base,
|
|
32043
|
-
continuation: {
|
|
32044
|
-
kind: "resume",
|
|
32045
|
-
prompt: reviewerResumePrompt(env, effective.message)
|
|
32046
|
-
}
|
|
32047
|
-
});
|
|
32048
|
-
},
|
|
32049
|
-
adapters: reviewerAdapters(env.packageRoot),
|
|
32050
|
-
afterAdmittedLoad: (admitted) => resolveResumeMethodMaterialAdapters({
|
|
32051
|
-
admitted,
|
|
32052
|
-
authority: env.principalAuthority,
|
|
32053
|
-
io,
|
|
32054
|
-
loadMaterial: () => loadReviewerMethodMaterial(env.packageRoot),
|
|
32055
|
-
adaptersWith: (material) => reviewerAdapters(env.packageRoot, material),
|
|
32056
|
-
emptyAdapters: reviewerAdapters(env.packageRoot)
|
|
32057
|
-
}),
|
|
32058
|
-
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
32059
|
-
});
|
|
32060
|
-
}
|
|
32061
|
-
var init_reviewer_run = __esm({
|
|
32062
|
-
"src/public-cli/reviewer-run.ts"() {
|
|
32063
|
-
"use strict";
|
|
32064
|
-
init_engine_material();
|
|
32065
|
-
init_method_skill();
|
|
32066
|
-
init_cli_errors();
|
|
32067
|
-
init_invocation();
|
|
32068
|
-
init_run_lifecycle();
|
|
32069
|
-
init_settlement();
|
|
32070
|
-
init_turn_request();
|
|
32071
|
-
init_post_admission();
|
|
32072
|
-
}
|
|
32073
|
-
});
|
|
32074
|
-
|
|
32075
32544
|
// src/analyst-book-key.ts
|
|
32076
32545
|
import { statSync as statSync2 } from "node:fs";
|
|
32077
32546
|
import { isAbsolute as isAbsolute9 } from "node:path";
|
|
@@ -32108,7 +32577,7 @@ var init_analyst_book_key = __esm({
|
|
|
32108
32577
|
|
|
32109
32578
|
// src/atomic-write.ts
|
|
32110
32579
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
32111
|
-
import { rename as rename3, rm as
|
|
32580
|
+
import { rename as rename3, rm as rm4, writeFile as writeFile10 } from "node:fs/promises";
|
|
32112
32581
|
import { dirname as dirname16, join as join31 } from "node:path";
|
|
32113
32582
|
async function writeFileAtomically(destination, contents) {
|
|
32114
32583
|
const parent = dirname16(destination);
|
|
@@ -32117,7 +32586,7 @@ async function writeFileAtomically(destination, contents) {
|
|
|
32117
32586
|
await writeFile10(temporary, contents);
|
|
32118
32587
|
await rename3(temporary, destination);
|
|
32119
32588
|
} catch (error) {
|
|
32120
|
-
await
|
|
32589
|
+
await rm4(temporary, { force: true }).catch(() => void 0);
|
|
32121
32590
|
throw error;
|
|
32122
32591
|
}
|
|
32123
32592
|
}
|
|
@@ -32131,8 +32600,8 @@ var init_atomic_write = __esm({
|
|
|
32131
32600
|
import { open as open3, readFile as readFile19, unlink as unlink3 } from "node:fs/promises";
|
|
32132
32601
|
import { dirname as dirname17, join as join32 } from "node:path";
|
|
32133
32602
|
function sleep(ms) {
|
|
32134
|
-
return new Promise((
|
|
32135
|
-
setTimeout(
|
|
32603
|
+
return new Promise((resolve11) => {
|
|
32604
|
+
setTimeout(resolve11, ms);
|
|
32136
32605
|
});
|
|
32137
32606
|
}
|
|
32138
32607
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
@@ -34025,7 +34494,7 @@ var init_analyst_entry = __esm({
|
|
|
34025
34494
|
|
|
34026
34495
|
// src/public-cli/analyst-run.ts
|
|
34027
34496
|
import { readFile as readFile22 } from "node:fs/promises";
|
|
34028
|
-
import { isAbsolute as isAbsolute10, resolve as
|
|
34497
|
+
import { isAbsolute as isAbsolute10, resolve as resolve10 } from "node:path";
|
|
34029
34498
|
function resolveAnalystIssueBookKeyFromCwd(cwd = process.cwd()) {
|
|
34030
34499
|
try {
|
|
34031
34500
|
return resolveBookKeyFromGit(cwd);
|
|
@@ -34074,7 +34543,7 @@ async function buildAnalystSweepModeInputFromAttachmentPaths(attachmentPaths) {
|
|
|
34074
34543
|
);
|
|
34075
34544
|
}
|
|
34076
34545
|
const sourcePath = attachmentPaths[0];
|
|
34077
|
-
const absolute = isAbsolute10(sourcePath) ? sourcePath :
|
|
34546
|
+
const absolute = isAbsolute10(sourcePath) ? sourcePath : resolve10(sourcePath);
|
|
34078
34547
|
let bytes;
|
|
34079
34548
|
try {
|
|
34080
34549
|
bytes = await readFile22(absolute);
|
|
@@ -34196,7 +34665,7 @@ __export(cli_exports, {
|
|
|
34196
34665
|
resolveInternalRoleEntrypoint: () => resolveInternalRoleEntrypoint,
|
|
34197
34666
|
runAkRole: () => runAkRole
|
|
34198
34667
|
});
|
|
34199
|
-
import { realpath as
|
|
34668
|
+
import { realpath as realpath7 } from "node:fs/promises";
|
|
34200
34669
|
import { join as join35 } from "node:path";
|
|
34201
34670
|
function takePublicGlobalFlag(argv, index, options) {
|
|
34202
34671
|
const tokens = argv.slice(index);
|
|
@@ -34850,7 +35319,7 @@ async function runAkRole(argv, env) {
|
|
|
34850
35319
|
try {
|
|
34851
35320
|
env = {
|
|
34852
35321
|
...env,
|
|
34853
|
-
packageRoot: await
|
|
35322
|
+
packageRoot: await realpath7(env.packageRoot),
|
|
34854
35323
|
principalAuthority: env.principalAuthority ?? piDurablePrincipalAuthority
|
|
34855
35324
|
};
|
|
34856
35325
|
let parsed = parseArgv(argv);
|