@akagilnc/pi-workflow-roles 0.1.4528 → 0.1.4586
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 +3 -2
- package/README.zh-CN.md +4 -3
- package/dist/acp-host/production-host.js +854 -111
- package/dist/headless-host/production-host.js +850 -107
- package/dist/migrate-book-topology.js +5 -5
- package/dist/public-cli/invocation.js +10 -4
- package/dist/public-cli/main.js +733 -239
- package/dist/public-cli/option-definitions.js +5 -5
- package/dist/public-cli/post-admission.js +23 -8
- package/dist/public-cli/reviewer-run.js +339 -0
- package/dist/public-cli/terminal.js +9 -0
- package/dist/public-cli/turn-request.js +1 -1
- package/dist/public-role-summons.js +348 -16
- package/package.json +1 -1
- package/src/host-contracts.ts +0 -1
- package/src/public-cli/invocation.ts +19 -9
- package/src/public-cli/option-definitions.ts +5 -5
- package/src/public-cli/post-admission.ts +39 -9
- package/src/public-cli/reviewer-run.ts +238 -53
- package/src/public-cli/settlement.ts +0 -1
- package/src/public-cli/terminal.ts +27 -0
- package/src/public-cli/turn-request.ts +7 -1
- package/src/public-role-summons.ts +510 -17
- package/src/reviewer-role.ts +1 -2
- package/src/role-runtime.ts +2 -2
|
@@ -417,7 +417,7 @@ function normalizeReviewComment(raw) {
|
|
|
417
417
|
function createGhApiRunner(options = {}) {
|
|
418
418
|
const spawnImpl = options.spawnImpl ?? spawn;
|
|
419
419
|
return async (args, runOptions = {}) => {
|
|
420
|
-
return await new Promise((
|
|
420
|
+
return await new Promise((resolve22, reject) => {
|
|
421
421
|
const signal = runOptions.signal;
|
|
422
422
|
if (signal?.aborted) {
|
|
423
423
|
reject(signal.reason ?? new Error("aborted"));
|
|
@@ -490,11 +490,11 @@ function createGhApiRunner(options = {}) {
|
|
|
490
490
|
const value = line2.slice(idx + 1).trim();
|
|
491
491
|
headers[name] = value;
|
|
492
492
|
}
|
|
493
|
-
|
|
493
|
+
resolve22({ status, headers, bodyText });
|
|
494
494
|
return;
|
|
495
495
|
}
|
|
496
496
|
if (code === 0) {
|
|
497
|
-
|
|
497
|
+
resolve22({ status: 200, headers: {}, bodyText: stdout });
|
|
498
498
|
return;
|
|
499
499
|
}
|
|
500
500
|
const failure2 = new Error(
|
|
@@ -1964,7 +1964,7 @@ async function spawnEngineDetourOnce(input) {
|
|
|
1964
1964
|
}
|
|
1965
1965
|
const command = input.argv[0];
|
|
1966
1966
|
const args = input.argv.slice(1);
|
|
1967
|
-
return await new Promise((
|
|
1967
|
+
return await new Promise((resolve22, reject) => {
|
|
1968
1968
|
let settled = false;
|
|
1969
1969
|
const signal = input.signal;
|
|
1970
1970
|
const child = spawn2(command, args, {
|
|
@@ -1994,7 +1994,7 @@ async function spawnEngineDetourOnce(input) {
|
|
|
1994
1994
|
if (signal !== void 0) {
|
|
1995
1995
|
signal.removeEventListener("abort", onAbort);
|
|
1996
1996
|
}
|
|
1997
|
-
|
|
1997
|
+
resolve22(result);
|
|
1998
1998
|
};
|
|
1999
1999
|
const onAbort = () => {
|
|
2000
2000
|
fail4(signal !== void 0 ? abortReasonError(signal) : new Error("aborted"));
|
|
@@ -5823,6 +5823,48 @@ async function loadResumableJudgeRun(home, runId, authority) {
|
|
|
5823
5823
|
};
|
|
5824
5824
|
return seatLoadedResult(loaded, admitted);
|
|
5825
5825
|
}
|
|
5826
|
+
async function loadResumableReviewerRun(home, runId, authority) {
|
|
5827
|
+
const loaded = await loadResumableRunRecord(home, runId, authority);
|
|
5828
|
+
if (loaded.run.role !== "reviewer") {
|
|
5829
|
+
throw new CliUsageError(
|
|
5830
|
+
`role run ${runId} belongs to ${loaded.run.role}, not reviewer`
|
|
5831
|
+
);
|
|
5832
|
+
}
|
|
5833
|
+
const rawBase = loaded.admittedFields.baseRevision;
|
|
5834
|
+
if (rawBase === void 0 || rawBase.trim() === "") {
|
|
5835
|
+
throw new CliUsageError(
|
|
5836
|
+
`role run admitted reviewer base revision is missing: ${runId}`
|
|
5837
|
+
);
|
|
5838
|
+
}
|
|
5839
|
+
if (/\s/.test(rawBase) || rawBase.startsWith("-")) {
|
|
5840
|
+
throw new CliUsageError(
|
|
5841
|
+
`role run admitted reviewer base revision is damaged: ${runId}`
|
|
5842
|
+
);
|
|
5843
|
+
}
|
|
5844
|
+
const baseRevision = rawBase;
|
|
5845
|
+
const lens = loaded.admittedFields.lens;
|
|
5846
|
+
if (!isReviewerLens(lens)) {
|
|
5847
|
+
throw new CliUsageError(
|
|
5848
|
+
`role run admitted reviewer lens is missing: ${runId}`
|
|
5849
|
+
);
|
|
5850
|
+
}
|
|
5851
|
+
const authorityRefs = Object.freeze([
|
|
5852
|
+
...loaded.admittedFields.authorityRefs ?? []
|
|
5853
|
+
]);
|
|
5854
|
+
if (authorityRefs.length === 0) {
|
|
5855
|
+
throw new CliUsageError(
|
|
5856
|
+
`role run admitted reviewer authority refs are missing: ${runId}`
|
|
5857
|
+
);
|
|
5858
|
+
}
|
|
5859
|
+
const admitted = {
|
|
5860
|
+
role: "reviewer",
|
|
5861
|
+
...resumedBaseAdmitted(loaded),
|
|
5862
|
+
baseRevision,
|
|
5863
|
+
lens,
|
|
5864
|
+
authorityRefs
|
|
5865
|
+
};
|
|
5866
|
+
return seatLoadedResult(loaded, admitted);
|
|
5867
|
+
}
|
|
5826
5868
|
async function loadResumableCountersignRun(home, runId, authority) {
|
|
5827
5869
|
const loaded = await loadResumableRunRecord(home, runId, authority);
|
|
5828
5870
|
if (loaded.run.role !== "countersign") {
|
|
@@ -6580,12 +6622,12 @@ var init_option_definitions = __esm({
|
|
|
6580
6622
|
canonical: "--lens",
|
|
6581
6623
|
aliases: [],
|
|
6582
6624
|
valueMetavar: "completeness|correctness",
|
|
6583
|
-
required:
|
|
6625
|
+
required: false,
|
|
6584
6626
|
repeatable: false,
|
|
6585
6627
|
form: "option",
|
|
6586
6628
|
description: {
|
|
6587
|
-
en: "
|
|
6588
|
-
zh: "\
|
|
6629
|
+
en: "Optional single-lens override: completeness or correctness; omitted runs both in parallel.",
|
|
6630
|
+
zh: "\u53EF\u9009\u5355 lens \u8986\u76D6\uFF1Acompleteness \u6216 correctness\uFF1B\u7701\u7565\u65F6\u5E76\u884C\u8FD0\u884C\u4E24\u8F74\u3002"
|
|
6589
6631
|
}
|
|
6590
6632
|
},
|
|
6591
6633
|
{
|
|
@@ -6942,9 +6984,9 @@ var init_option_definitions = __esm({
|
|
|
6942
6984
|
},
|
|
6943
6985
|
reviewer: {
|
|
6944
6986
|
command: "reviewer",
|
|
6945
|
-
summary: "Fixed-target
|
|
6987
|
+
summary: "Fixed-target parallel two-lens review, with an optional single-lens override.",
|
|
6946
6988
|
usage: [
|
|
6947
|
-
"ak-role reviewer --base <revision> --lens completeness|correctness --authority-ref <ref> [options] <instruction>"
|
|
6989
|
+
"ak-role reviewer --base <revision> [--lens completeness|correctness] --authority-ref <ref> [options] <instruction>"
|
|
6948
6990
|
],
|
|
6949
6991
|
examples: [
|
|
6950
6992
|
'ak-role reviewer --base main --lens completeness --authority-ref docs/adr/0001.md "Review the branch."',
|
|
@@ -9077,7 +9119,7 @@ function parseReviewerArgv(args) {
|
|
|
9077
9119
|
instruction: positional.join(" "),
|
|
9078
9120
|
attachmentPaths,
|
|
9079
9121
|
baseRevision,
|
|
9080
|
-
lens,
|
|
9122
|
+
...lens === void 0 ? {} : { lens },
|
|
9081
9123
|
authorityRefs,
|
|
9082
9124
|
...project === void 0 ? {} : { project }
|
|
9083
9125
|
};
|
|
@@ -9126,6 +9168,7 @@ async function admitReviewerInvocation(options) {
|
|
|
9126
9168
|
baseRevision,
|
|
9127
9169
|
lens,
|
|
9128
9170
|
authorityRefs: [...authorityRefs],
|
|
9171
|
+
...options.correlationId === void 0 ? {} : { correlationId: options.correlationId },
|
|
9129
9172
|
attachments: attachments.map((a) => ({
|
|
9130
9173
|
provenancePath: a.provenancePath,
|
|
9131
9174
|
frozenPath: a.frozenPath,
|
|
@@ -9153,7 +9196,8 @@ async function admitReviewerInvocation(options) {
|
|
|
9153
9196
|
admittedRequestPath,
|
|
9154
9197
|
baseRevision,
|
|
9155
9198
|
lens,
|
|
9156
|
-
authorityRefs
|
|
9199
|
+
authorityRefs,
|
|
9200
|
+
...options.correlationId === void 0 ? {} : { correlationId: options.correlationId }
|
|
9157
9201
|
};
|
|
9158
9202
|
}
|
|
9159
9203
|
function buildReviewerSkillArgProjection(admitted) {
|
|
@@ -9370,11 +9414,11 @@ function parseAnalystCohortIssueToken(raw, flag) {
|
|
|
9370
9414
|
`${flag} requires a comma-separated list of N or book:N`
|
|
9371
9415
|
);
|
|
9372
9416
|
}
|
|
9373
|
-
const
|
|
9374
|
-
if (
|
|
9375
|
-
const rhs = trimmed.slice(
|
|
9417
|
+
const sep7 = trimmed.lastIndexOf(":");
|
|
9418
|
+
if (sep7 > 0) {
|
|
9419
|
+
const rhs = trimmed.slice(sep7 + 1);
|
|
9376
9420
|
if (ANALYST_TICKET_NUMBER_PATTERN.test(rhs)) {
|
|
9377
|
-
const bookKey = trimmed.slice(0,
|
|
9421
|
+
const bookKey = trimmed.slice(0, sep7);
|
|
9378
9422
|
if (bookKey.trim() === "") {
|
|
9379
9423
|
throw new CliUsageError(
|
|
9380
9424
|
`${flag} book:N requires a non-empty book key, got ${raw}`
|
|
@@ -11668,12 +11712,12 @@ function createSystemCollectorClock() {
|
|
|
11668
11712
|
return {
|
|
11669
11713
|
wallNow: () => /* @__PURE__ */ new Date(),
|
|
11670
11714
|
monoNow: () => Number(process.hrtime.bigint() - start) / 1e6,
|
|
11671
|
-
sleep: (ms, signal) => new Promise((
|
|
11715
|
+
sleep: (ms, signal) => new Promise((resolve22, reject) => {
|
|
11672
11716
|
if (signal?.aborted) {
|
|
11673
11717
|
reject(signal.reason ?? new Error("aborted"));
|
|
11674
11718
|
return;
|
|
11675
11719
|
}
|
|
11676
|
-
const timer = setTimeout(
|
|
11720
|
+
const timer = setTimeout(resolve22, ms);
|
|
11677
11721
|
const onAbort = () => {
|
|
11678
11722
|
clearTimeout(timer);
|
|
11679
11723
|
reject(signal?.reason ?? new Error("aborted"));
|
|
@@ -13730,6 +13774,15 @@ function formatTerminalResult(result) {
|
|
|
13730
13774
|
);
|
|
13731
13775
|
}
|
|
13732
13776
|
}
|
|
13777
|
+
if (result.reviewerChildOutcomes !== void 0) {
|
|
13778
|
+
for (const axis of ["completeness", "correctness"]) {
|
|
13779
|
+
const child = result.reviewerChildOutcomes[axis];
|
|
13780
|
+
lines.push(`reviewer-child ${axis} ${child.exitCode}`);
|
|
13781
|
+
if (child.stderr !== void 0 && child.stderr !== "") {
|
|
13782
|
+
lines.push(`reviewer-child-diagnostic ${axis} ${encodeTerminalField(child.stderr)}`);
|
|
13783
|
+
}
|
|
13784
|
+
}
|
|
13785
|
+
}
|
|
13733
13786
|
if (result.resume !== void 0) {
|
|
13734
13787
|
lines.push(`resume ${encodeTerminalField(result.resume.command)}`);
|
|
13735
13788
|
} else if (result.runId !== void 0) {
|
|
@@ -16190,10 +16243,10 @@ function presentFailureTerminal(terminal, io) {
|
|
|
16190
16243
|
}
|
|
16191
16244
|
function defaultNavigatorGraceSleep() {
|
|
16192
16245
|
let timer;
|
|
16193
|
-
const sleep = ((ms) => new Promise((
|
|
16246
|
+
const sleep = ((ms) => new Promise((resolve22) => {
|
|
16194
16247
|
timer = setTimeout(() => {
|
|
16195
16248
|
timer = void 0;
|
|
16196
|
-
|
|
16249
|
+
resolve22();
|
|
16197
16250
|
}, ms);
|
|
16198
16251
|
}));
|
|
16199
16252
|
sleep.cancel = () => {
|
|
@@ -16205,7 +16258,7 @@ function defaultNavigatorGraceSleep() {
|
|
|
16205
16258
|
return sleep;
|
|
16206
16259
|
}
|
|
16207
16260
|
function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep = defaultNavigatorGraceSleep()) {
|
|
16208
|
-
return new Promise((
|
|
16261
|
+
return new Promise((resolve22, reject) => {
|
|
16209
16262
|
let settled = false;
|
|
16210
16263
|
const finish = (action) => {
|
|
16211
16264
|
if (settled) return;
|
|
@@ -16214,11 +16267,11 @@ function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep
|
|
|
16214
16267
|
action();
|
|
16215
16268
|
};
|
|
16216
16269
|
void work.then(
|
|
16217
|
-
(value) => finish(() =>
|
|
16270
|
+
(value) => finish(() => resolve22({ status: "done", value })),
|
|
16218
16271
|
(error) => finish(() => reject(error))
|
|
16219
16272
|
);
|
|
16220
16273
|
void sleep(graceMs).then(() => {
|
|
16221
|
-
finish(() =>
|
|
16274
|
+
finish(() => resolve22({ status: "timeout" }));
|
|
16222
16275
|
});
|
|
16223
16276
|
});
|
|
16224
16277
|
}
|
|
@@ -17669,6 +17722,30 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
17669
17722
|
}
|
|
17670
17723
|
}
|
|
17671
17724
|
}
|
|
17725
|
+
async function resolveResumeMethodMaterialAdapters(input) {
|
|
17726
|
+
if (input.shouldLoad === false) {
|
|
17727
|
+
return { kind: "continue", adapters: input.emptyAdapters };
|
|
17728
|
+
}
|
|
17729
|
+
try {
|
|
17730
|
+
const material = await input.loadMaterial();
|
|
17731
|
+
return { kind: "continue", adapters: input.adaptersWith(material) };
|
|
17732
|
+
} catch (error) {
|
|
17733
|
+
const terminal = await presentControlledFailure2(
|
|
17734
|
+
input.admitted,
|
|
17735
|
+
{
|
|
17736
|
+
timedOut: false,
|
|
17737
|
+
code: null,
|
|
17738
|
+
stderr: "",
|
|
17739
|
+
thrown: error,
|
|
17740
|
+
...input.knownCause === void 0 ? {} : { knownCause: input.knownCause }
|
|
17741
|
+
},
|
|
17742
|
+
input.emptyAdapters,
|
|
17743
|
+
input.authority,
|
|
17744
|
+
input.io
|
|
17745
|
+
);
|
|
17746
|
+
return { kind: "terminal", ...terminal };
|
|
17747
|
+
}
|
|
17748
|
+
}
|
|
17672
17749
|
async function presentControlledFailure2(admitted, failureInput, adapters, authority, io, persistRunState = true) {
|
|
17673
17750
|
const hasThrown = Object.hasOwn(failureInput, "thrown");
|
|
17674
17751
|
const resumeObservation = await resolveControlledFailureResumeObservation({
|
|
@@ -18219,6 +18296,8 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
18219
18296
|
}
|
|
18220
18297
|
adapters = prepared.adapters;
|
|
18221
18298
|
}
|
|
18299
|
+
let env = input.env;
|
|
18300
|
+
let preparedCleanup;
|
|
18222
18301
|
const buildRequestAfterLease = async () => {
|
|
18223
18302
|
let openCourtAttemptId;
|
|
18224
18303
|
let admittedForBuild = loaded.admitted;
|
|
@@ -18269,7 +18348,12 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
18269
18348
|
return turnRequest;
|
|
18270
18349
|
};
|
|
18271
18350
|
try {
|
|
18272
|
-
if (input.
|
|
18351
|
+
if (input.afterAdmittedPrepare !== void 0) {
|
|
18352
|
+
const prepared = await input.afterAdmittedPrepare(loaded.admitted);
|
|
18353
|
+
if (prepared.env !== void 0) env = prepared.env;
|
|
18354
|
+
preparedCleanup = prepared.cleanup;
|
|
18355
|
+
}
|
|
18356
|
+
if (env.stationChild === true) {
|
|
18273
18357
|
let firstTurn;
|
|
18274
18358
|
const stationAdapters = withOnceSuccessfulBeforeDispatch(adapters);
|
|
18275
18359
|
const invocationScopeId = mintEngineDetourInvocationScope({
|
|
@@ -18277,14 +18361,14 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
18277
18361
|
});
|
|
18278
18362
|
return await runWithAutoResumeLoop({
|
|
18279
18363
|
admitted: loaded.admitted,
|
|
18280
|
-
principalAuthority:
|
|
18364
|
+
principalAuthority: env.principalAuthority,
|
|
18281
18365
|
isPrincipalAvailable: resolveHostAwareSessionAvailability(
|
|
18282
|
-
|
|
18283
|
-
|
|
18366
|
+
env.host,
|
|
18367
|
+
env.principalAuthority
|
|
18284
18368
|
),
|
|
18285
18369
|
io: input.io,
|
|
18286
|
-
sessionAppender:
|
|
18287
|
-
autoResumeLimit:
|
|
18370
|
+
sessionAppender: env.sessionAppender,
|
|
18371
|
+
autoResumeLimit: env.autoResumeLimit,
|
|
18288
18372
|
buildInitialPayload: () => ({ resumeTurn: false }),
|
|
18289
18373
|
buildResumePayload: () => ({ resumeTurn: true }),
|
|
18290
18374
|
// Same as public manual resume: prior-court sealed acceptance is not a
|
|
@@ -18311,7 +18395,7 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
18311
18395
|
dispatch: async (turnRequest) => {
|
|
18312
18396
|
const result = await dispatchPostAdmissionTurn({
|
|
18313
18397
|
admitted: loaded.admitted,
|
|
18314
|
-
env
|
|
18398
|
+
env,
|
|
18315
18399
|
io: attemptIo,
|
|
18316
18400
|
request: turnRequest,
|
|
18317
18401
|
lease,
|
|
@@ -18321,7 +18405,7 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
18321
18405
|
});
|
|
18322
18406
|
return settleDeferredPersist(
|
|
18323
18407
|
loaded.admitted,
|
|
18324
|
-
|
|
18408
|
+
env.principalAuthority,
|
|
18325
18409
|
stationAdapters,
|
|
18326
18410
|
attemptIo,
|
|
18327
18411
|
result
|
|
@@ -18332,7 +18416,7 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
18332
18416
|
}
|
|
18333
18417
|
return await runPostAdmissionManualResume({
|
|
18334
18418
|
admitted: loaded.admitted,
|
|
18335
|
-
env
|
|
18419
|
+
env,
|
|
18336
18420
|
io: input.io,
|
|
18337
18421
|
adapters,
|
|
18338
18422
|
...input.effectiveEngine === void 0 ? {} : { effectiveEngine: input.effectiveEngine },
|
|
@@ -18344,6 +18428,10 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
18344
18428
|
return { exitCode: 2 };
|
|
18345
18429
|
}
|
|
18346
18430
|
throw error;
|
|
18431
|
+
} finally {
|
|
18432
|
+
if (preparedCleanup !== void 0) {
|
|
18433
|
+
await preparedCleanup();
|
|
18434
|
+
}
|
|
18347
18435
|
}
|
|
18348
18436
|
}
|
|
18349
18437
|
async function runPostAdmissionOneShot(input) {
|
|
@@ -18505,7 +18593,7 @@ var init_post_admission = __esm({
|
|
|
18505
18593
|
|
|
18506
18594
|
// src/public-cli/turn-request.ts
|
|
18507
18595
|
function projectRoleTurnRequest(admitted, roleDetails, options) {
|
|
18508
|
-
const cwd = admitted.projectRoot ?? admitted.repoRoot ?? admitted.cwd;
|
|
18596
|
+
const cwd = options.cwd ?? admitted.projectRoot ?? admitted.repoRoot ?? admitted.cwd;
|
|
18509
18597
|
if (cwd === void 0) throw new Error("admitted invocation missing working directory");
|
|
18510
18598
|
if (admitted.principal === void 0) throw new Error("admitted invocation missing principal");
|
|
18511
18599
|
return {
|
|
@@ -20009,16 +20097,346 @@ var init_countersign_run = __esm({
|
|
|
20009
20097
|
}
|
|
20010
20098
|
});
|
|
20011
20099
|
|
|
20100
|
+
// src/public-cli/reviewer-run.ts
|
|
20101
|
+
var reviewer_run_exports = {};
|
|
20102
|
+
__export(reviewer_run_exports, {
|
|
20103
|
+
buildReviewerTurnRequest: () => buildReviewerTurnRequest,
|
|
20104
|
+
runPublicReviewer: () => runPublicReviewer,
|
|
20105
|
+
runPublicReviewerResume: () => runPublicReviewerResume
|
|
20106
|
+
});
|
|
20107
|
+
import { resolve as resolve14 } from "node:path";
|
|
20108
|
+
function reviewerMethods(packageRoot) {
|
|
20109
|
+
return [{ kind: "skill", path: resolvePackagedMethodSkillPath(packageRoot, "ak-cross-m-review") }];
|
|
20110
|
+
}
|
|
20111
|
+
async function runReviewerTurnInFreshCopy(env, projectRoot, io, body) {
|
|
20112
|
+
if (env.executionCwd !== void 0) {
|
|
20113
|
+
return body(env);
|
|
20114
|
+
}
|
|
20115
|
+
const { withEphemeralReviewerWorktree: withEphemeralReviewerWorktree2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
|
|
20116
|
+
return await withEphemeralReviewerWorktree2({
|
|
20117
|
+
projectRoot,
|
|
20118
|
+
onCleanupDiagnostic: (diagnostic) => {
|
|
20119
|
+
io.stderr(`${diagnostic}
|
|
20120
|
+
`);
|
|
20121
|
+
},
|
|
20122
|
+
run: (executionCwd) => body({ ...env, executionCwd })
|
|
20123
|
+
});
|
|
20124
|
+
}
|
|
20125
|
+
function buildReviewerTurnRequest(admitted, options) {
|
|
20126
|
+
return projectRoleTurnRequest(
|
|
20127
|
+
admitted,
|
|
20128
|
+
{
|
|
20129
|
+
activation: {
|
|
20130
|
+
role: "reviewer",
|
|
20131
|
+
baseRevision: admitted.baseRevision,
|
|
20132
|
+
lens: admitted.lens,
|
|
20133
|
+
authorityRefs: admitted.authorityRefs,
|
|
20134
|
+
...admitted.ticketNumber === void 0 ? {} : { ticketNumber: admitted.ticketNumber }
|
|
20135
|
+
},
|
|
20136
|
+
methods: reviewerMethods(options.packageRoot)
|
|
20137
|
+
},
|
|
20138
|
+
options
|
|
20139
|
+
);
|
|
20140
|
+
}
|
|
20141
|
+
function reviewerAdapters(packageRoot, methodMaterial) {
|
|
20142
|
+
return {
|
|
20143
|
+
trySettle: (admitted, authority, scope) => methodMaterial === void 0 ? Promise.resolve(void 0) : trySettleReviewerTerminalResult(
|
|
20144
|
+
admitted,
|
|
20145
|
+
authority,
|
|
20146
|
+
{
|
|
20147
|
+
methodProvenance: methodMaterial.provenance,
|
|
20148
|
+
methodSkillPath: methodMaterial.skillPath,
|
|
20149
|
+
methodSkillConfiguredPath: resolvePackagedMethodSkillPath(
|
|
20150
|
+
packageRoot,
|
|
20151
|
+
"ak-cross-m-review"
|
|
20152
|
+
)
|
|
20153
|
+
},
|
|
20154
|
+
scope
|
|
20155
|
+
),
|
|
20156
|
+
resolveRunnerKnownFailure: async ({ result, sessionFile }) => {
|
|
20157
|
+
const infrastructureFailure = await readEngineDetourInfrastructureFailure(sessionFile);
|
|
20158
|
+
return infrastructureFailure === void 0 ? result.knownFailure : {
|
|
20159
|
+
...infrastructureFailure.cause === void 0 ? {} : { cause: infrastructureFailure.cause },
|
|
20160
|
+
diagnostic: infrastructureFailure.diagnostic,
|
|
20161
|
+
...infrastructureFailure.identity === void 0 ? {} : { identity: infrastructureFailure.identity }
|
|
20162
|
+
};
|
|
20163
|
+
}
|
|
20164
|
+
};
|
|
20165
|
+
}
|
|
20166
|
+
async function loadReviewerMethodMaterial(packageRoot) {
|
|
20167
|
+
return await loadPackagedMethodSkillMaterial(packageRoot, "ak-cross-m-review");
|
|
20168
|
+
}
|
|
20169
|
+
function reviewerResumePrompt(env, message) {
|
|
20170
|
+
const lines = [RESUME_TRANSPORT_ENVELOPE];
|
|
20171
|
+
if (message !== void 0) lines.push("", message);
|
|
20172
|
+
return appendEngineSessionMaterial(
|
|
20173
|
+
lines,
|
|
20174
|
+
engineSessionMaterialFromOptions({
|
|
20175
|
+
...pickEngineAxis(env),
|
|
20176
|
+
packageRoot: env.packageRoot
|
|
20177
|
+
})
|
|
20178
|
+
).join("\n");
|
|
20179
|
+
}
|
|
20180
|
+
async function runPublicReviewer(argv, env, io, parseReviewerArgv2) {
|
|
20181
|
+
let parsed;
|
|
20182
|
+
try {
|
|
20183
|
+
parsed = parseReviewerArgv2(argv);
|
|
20184
|
+
} catch (error) {
|
|
20185
|
+
if (error instanceof CliUsageError) {
|
|
20186
|
+
presentStructuralRejection(error, io);
|
|
20187
|
+
return { exitCode: 2 };
|
|
20188
|
+
}
|
|
20189
|
+
throw error;
|
|
20190
|
+
}
|
|
20191
|
+
if (parsed.lens === void 0) {
|
|
20192
|
+
const { summonParallelReviewerLenses: summonParallelReviewerLenses2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
|
|
20193
|
+
const children = await summonParallelReviewerLenses2({
|
|
20194
|
+
argv,
|
|
20195
|
+
// Replay argv under the same cwd the single-axis entry would see (10a).
|
|
20196
|
+
// Do not substitute the resolved project path — relative --project must
|
|
20197
|
+
// not be re-resolved against a shifted cwd.
|
|
20198
|
+
cwd: env.cwd,
|
|
20199
|
+
projectRoot: resolve14(parsed.project ?? env.cwd),
|
|
20200
|
+
// Typed base from the public parse — precheck only; child argv stays verbatim.
|
|
20201
|
+
baseRevision: parsed.baseRevision,
|
|
20202
|
+
home: env.home,
|
|
20203
|
+
agentDir: env.agentDir,
|
|
20204
|
+
...env.credentials === void 0 ? {} : { credentials: env.credentials },
|
|
20205
|
+
...env.model === void 0 ? {} : { model: env.model },
|
|
20206
|
+
...env.host === void 0 ? {} : { host: env.host },
|
|
20207
|
+
...env.engine === void 0 ? {} : { engine: env.engine },
|
|
20208
|
+
...env.engineModel === void 0 ? {} : { engineModel: env.engineModel },
|
|
20209
|
+
packageRoot: env.packageRoot,
|
|
20210
|
+
...env.signal === void 0 ? {} : { signal: env.signal },
|
|
20211
|
+
...env.correlationId === void 0 ? {} : { correlationId: env.correlationId },
|
|
20212
|
+
roleTurnHost: env.roleTurnHost,
|
|
20213
|
+
...env.hostAdapters === void 0 ? {} : { hostAdapters: env.hostAdapters },
|
|
20214
|
+
principalAuthority: env.principalAuthority,
|
|
20215
|
+
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs }
|
|
20216
|
+
});
|
|
20217
|
+
const childResults = [children.completeness, children.correctness];
|
|
20218
|
+
const terminals = childResults.map((child) => child.terminal).filter((terminal2) => terminal2 !== void 0);
|
|
20219
|
+
const failedChildren = childResults.filter((child) => child.terminal === void 0 || !isLawfulTypedTerminalOutcome(child.terminal.roleOutcome)).length;
|
|
20220
|
+
const overlayExit = childResults.some((child) => child.exitCode !== 0);
|
|
20221
|
+
const failed = failedChildren > 0 || overlayExit;
|
|
20222
|
+
const overlayDiagnostics = [...new Set(
|
|
20223
|
+
childResults.map((child) => child.stderr).filter((text) => typeof text === "string" && text !== "")
|
|
20224
|
+
)];
|
|
20225
|
+
const terminal = {
|
|
20226
|
+
batch: "reviewer",
|
|
20227
|
+
roleOutcome: failed ? {
|
|
20228
|
+
kind: "failure",
|
|
20229
|
+
role: "reviewer",
|
|
20230
|
+
diagnostic: failedChildren > 0 ? "Reviewer batch child failure" : overlayDiagnostics[0] ?? "Reviewer batch infrastructure failure",
|
|
20231
|
+
decisiveFacts: { failedChildren },
|
|
20232
|
+
payloads: terminals
|
|
20233
|
+
} : { kind: "accepted", role: "reviewer", payloads: terminals },
|
|
20234
|
+
reviewerChildren: {
|
|
20235
|
+
...children.completeness.terminal === void 0 ? {} : { completeness: children.completeness.terminal },
|
|
20236
|
+
...children.correctness.terminal === void 0 ? {} : { correctness: children.correctness.terminal }
|
|
20237
|
+
},
|
|
20238
|
+
reviewerChildOutcomes: {
|
|
20239
|
+
completeness: { exitCode: children.completeness.exitCode, ...children.completeness.stderr === void 0 ? {} : { stderr: children.completeness.stderr } },
|
|
20240
|
+
correctness: { exitCode: children.correctness.exitCode, ...children.correctness.stderr === void 0 ? {} : { stderr: children.correctness.stderr } }
|
|
20241
|
+
},
|
|
20242
|
+
// Batch has no parent run and no own attendance; no-advice is affirmative
|
|
20243
|
+
// only (navigator-attendance.ts). Children carry their own navigator facts.
|
|
20244
|
+
navigator: {
|
|
20245
|
+
disposition: "unavailable",
|
|
20246
|
+
source: "unknown",
|
|
20247
|
+
reason: "Reviewer batch has no parent-run Navigator attendance"
|
|
20248
|
+
},
|
|
20249
|
+
artifacts: terminals.flatMap((item) => item.artifacts)
|
|
20250
|
+
};
|
|
20251
|
+
io.stdout(formatTerminalResult(terminal));
|
|
20252
|
+
return { exitCode: failed ? 1 : 0, terminal };
|
|
20253
|
+
}
|
|
20254
|
+
let admitted;
|
|
20255
|
+
try {
|
|
20256
|
+
admitted = await admitReviewerInvocation({
|
|
20257
|
+
home: env.home,
|
|
20258
|
+
principalAuthority: env.principalAuthority,
|
|
20259
|
+
cwd: env.cwd,
|
|
20260
|
+
instruction: parsed.instruction,
|
|
20261
|
+
attachmentPaths: parsed.attachmentPaths,
|
|
20262
|
+
baseRevision: parsed.baseRevision,
|
|
20263
|
+
lens: parsed.lens,
|
|
20264
|
+
authorityRefs: parsed.authorityRefs,
|
|
20265
|
+
...parsed.project === void 0 ? {} : { project: parsed.project },
|
|
20266
|
+
...env.createRunId === void 0 ? {} : { createRunId: env.createRunId },
|
|
20267
|
+
...env.correlationId === void 0 ? {} : { correlationId: env.correlationId },
|
|
20268
|
+
...env.model === void 0 ? {} : { model: env.model }
|
|
20269
|
+
});
|
|
20270
|
+
} catch (error) {
|
|
20271
|
+
if (error instanceof CliUsageError) {
|
|
20272
|
+
presentStructuralRejection(error, io);
|
|
20273
|
+
return { exitCode: 2 };
|
|
20274
|
+
}
|
|
20275
|
+
throw error;
|
|
20276
|
+
}
|
|
20277
|
+
await markRunAdmitted(admitted, env.principalAuthority);
|
|
20278
|
+
let methodMaterial;
|
|
20279
|
+
try {
|
|
20280
|
+
methodMaterial = await loadReviewerMethodMaterial(env.packageRoot);
|
|
20281
|
+
} catch (error) {
|
|
20282
|
+
return await presentControlledFailure2(
|
|
20283
|
+
admitted,
|
|
20284
|
+
{
|
|
20285
|
+
timedOut: false,
|
|
20286
|
+
code: null,
|
|
20287
|
+
stderr: "",
|
|
20288
|
+
thrown: error
|
|
20289
|
+
},
|
|
20290
|
+
reviewerAdapters(env.packageRoot),
|
|
20291
|
+
env.principalAuthority,
|
|
20292
|
+
io
|
|
20293
|
+
);
|
|
20294
|
+
}
|
|
20295
|
+
try {
|
|
20296
|
+
return await runReviewerTurnInFreshCopy(env, admitted.projectRoot, io, async (sandboxedEnv) => await runPostAdmissionResumable({
|
|
20297
|
+
admitted,
|
|
20298
|
+
env: sandboxedEnv,
|
|
20299
|
+
io,
|
|
20300
|
+
buildInitialRequest: () => buildReviewerTurnRequest(admitted, {
|
|
20301
|
+
packageRoot: sandboxedEnv.packageRoot,
|
|
20302
|
+
home: sandboxedEnv.home,
|
|
20303
|
+
agentDir: sandboxedEnv.agentDir,
|
|
20304
|
+
...sandboxedEnv.model === void 0 ? {} : { model: sandboxedEnv.model },
|
|
20305
|
+
...pickEngineAxis(sandboxedEnv),
|
|
20306
|
+
...sandboxedEnv.timeoutMs === void 0 ? {} : { timeoutMs: sandboxedEnv.timeoutMs },
|
|
20307
|
+
...admitted.correlationId === void 0 && sandboxedEnv.correlationId === void 0 ? {} : { correlationId: admitted.correlationId ?? sandboxedEnv.correlationId },
|
|
20308
|
+
// Ephemeral worktree cwd; durable projectRoot stays on admitted caller project.
|
|
20309
|
+
...sandboxedEnv.executionCwd === void 0 ? {} : { cwd: sandboxedEnv.executionCwd },
|
|
20310
|
+
continuation: {
|
|
20311
|
+
kind: "initial",
|
|
20312
|
+
prompt: buildReviewerTransportPrompt(
|
|
20313
|
+
admitted,
|
|
20314
|
+
engineSessionMaterialFromOptions({
|
|
20315
|
+
...pickEngineAxis(sandboxedEnv),
|
|
20316
|
+
packageRoot: sandboxedEnv.packageRoot
|
|
20317
|
+
})
|
|
20318
|
+
)
|
|
20319
|
+
}
|
|
20320
|
+
}),
|
|
20321
|
+
buildResumeRequest: () => buildReviewerTurnRequest(admitted, {
|
|
20322
|
+
packageRoot: sandboxedEnv.packageRoot,
|
|
20323
|
+
home: sandboxedEnv.home,
|
|
20324
|
+
agentDir: sandboxedEnv.agentDir,
|
|
20325
|
+
...sandboxedEnv.model === void 0 ? {} : { model: sandboxedEnv.model },
|
|
20326
|
+
...pickEngineAxis(sandboxedEnv),
|
|
20327
|
+
...sandboxedEnv.timeoutMs === void 0 ? {} : { timeoutMs: sandboxedEnv.timeoutMs },
|
|
20328
|
+
...admitted.correlationId === void 0 && sandboxedEnv.correlationId === void 0 ? {} : { correlationId: admitted.correlationId ?? sandboxedEnv.correlationId },
|
|
20329
|
+
// In-batch auto-resume keeps the same call's sandbox (dual-lens or single).
|
|
20330
|
+
...sandboxedEnv.executionCwd === void 0 ? {} : { cwd: sandboxedEnv.executionCwd },
|
|
20331
|
+
continuation: {
|
|
20332
|
+
kind: "resume",
|
|
20333
|
+
prompt: reviewerResumePrompt(sandboxedEnv)
|
|
20334
|
+
}
|
|
20335
|
+
}),
|
|
20336
|
+
adapters: reviewerAdapters(sandboxedEnv.packageRoot, methodMaterial),
|
|
20337
|
+
...sandboxedEnv.engine === void 0 ? {} : { effectiveEngine: sandboxedEnv.engine }
|
|
20338
|
+
}));
|
|
20339
|
+
} catch (error) {
|
|
20340
|
+
return await presentControlledFailure2(
|
|
20341
|
+
admitted,
|
|
20342
|
+
{
|
|
20343
|
+
timedOut: false,
|
|
20344
|
+
code: null,
|
|
20345
|
+
stderr: "",
|
|
20346
|
+
thrown: error
|
|
20347
|
+
},
|
|
20348
|
+
reviewerAdapters(env.packageRoot, methodMaterial),
|
|
20349
|
+
env.principalAuthority,
|
|
20350
|
+
io
|
|
20351
|
+
);
|
|
20352
|
+
}
|
|
20353
|
+
}
|
|
20354
|
+
async function runPublicReviewerResume(request, env, io) {
|
|
20355
|
+
const sandbox = {
|
|
20356
|
+
...env.executionCwd === void 0 ? {} : { executionCwd: env.executionCwd }
|
|
20357
|
+
};
|
|
20358
|
+
return await runPostAdmissionSeatResume({
|
|
20359
|
+
request,
|
|
20360
|
+
env,
|
|
20361
|
+
io,
|
|
20362
|
+
load: (effective) => loadResumableReviewerRun(env.home, effective.runId, env.principalAuthority),
|
|
20363
|
+
buildTurnRequest: (admitted, effective) => {
|
|
20364
|
+
const activeEnv = sandbox.executionCwd === void 0 ? env : { ...env, executionCwd: sandbox.executionCwd };
|
|
20365
|
+
const base = resumeTurnRequestProjectionOptions(admitted, effective, activeEnv);
|
|
20366
|
+
return buildReviewerTurnRequest(admitted, {
|
|
20367
|
+
...base,
|
|
20368
|
+
// Fresh copy at resume time; durable projectRoot unchanged.
|
|
20369
|
+
...sandbox.executionCwd === void 0 ? {} : { cwd: sandbox.executionCwd },
|
|
20370
|
+
continuation: {
|
|
20371
|
+
kind: "resume",
|
|
20372
|
+
prompt: reviewerResumePrompt(activeEnv, effective.message)
|
|
20373
|
+
}
|
|
20374
|
+
});
|
|
20375
|
+
},
|
|
20376
|
+
adapters: reviewerAdapters(env.packageRoot),
|
|
20377
|
+
afterAdmittedLoad: async (admitted) => {
|
|
20378
|
+
return resolveResumeMethodMaterialAdapters({
|
|
20379
|
+
admitted,
|
|
20380
|
+
authority: env.principalAuthority,
|
|
20381
|
+
io,
|
|
20382
|
+
loadMaterial: () => loadReviewerMethodMaterial(env.packageRoot),
|
|
20383
|
+
adaptersWith: (material) => reviewerAdapters(env.packageRoot, material),
|
|
20384
|
+
emptyAdapters: reviewerAdapters(env.packageRoot)
|
|
20385
|
+
});
|
|
20386
|
+
},
|
|
20387
|
+
afterAdmittedPrepare: async (admitted) => {
|
|
20388
|
+
if (sandbox.executionCwd !== void 0) {
|
|
20389
|
+
return { env: { ...env, executionCwd: sandbox.executionCwd } };
|
|
20390
|
+
}
|
|
20391
|
+
const { openEphemeralReviewerWorktree: openEphemeralReviewerWorktree2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
|
|
20392
|
+
const opened = await openEphemeralReviewerWorktree2({
|
|
20393
|
+
projectRoot: admitted.projectRoot,
|
|
20394
|
+
onCleanupDiagnostic: (diagnostic) => {
|
|
20395
|
+
io.stderr(`${diagnostic}
|
|
20396
|
+
`);
|
|
20397
|
+
}
|
|
20398
|
+
});
|
|
20399
|
+
sandbox.executionCwd = opened.executionCwd;
|
|
20400
|
+
return {
|
|
20401
|
+
env: { ...env, executionCwd: opened.executionCwd },
|
|
20402
|
+
cleanup: opened.close
|
|
20403
|
+
};
|
|
20404
|
+
},
|
|
20405
|
+
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
20406
|
+
});
|
|
20407
|
+
}
|
|
20408
|
+
var init_reviewer_run = __esm({
|
|
20409
|
+
"src/public-cli/reviewer-run.ts"() {
|
|
20410
|
+
"use strict";
|
|
20411
|
+
init_engine_material();
|
|
20412
|
+
init_method_skill();
|
|
20413
|
+
init_cli_errors();
|
|
20414
|
+
init_invocation();
|
|
20415
|
+
init_run_lifecycle();
|
|
20416
|
+
init_settlement();
|
|
20417
|
+
init_terminal();
|
|
20418
|
+
init_turn_request();
|
|
20419
|
+
init_post_admission();
|
|
20420
|
+
}
|
|
20421
|
+
});
|
|
20422
|
+
|
|
20012
20423
|
// src/public-role-summons.ts
|
|
20013
20424
|
var public_role_summons_exports = {};
|
|
20014
20425
|
__export(public_role_summons_exports, {
|
|
20015
20426
|
AK_ROLE_PACKAGE_ROOT_ENV: () => AK_ROLE_PACKAGE_ROOT_ENV,
|
|
20427
|
+
openEphemeralReviewerWorktree: () => openEphemeralReviewerWorktree,
|
|
20016
20428
|
resolveSummonsPackageRoot: () => resolveSummonsPackageRoot,
|
|
20017
20429
|
summonGateOfficer: () => summonGateOfficer,
|
|
20018
|
-
|
|
20430
|
+
summonParallelReviewerLenses: () => summonParallelReviewerLenses,
|
|
20431
|
+
summonPublicRole: () => summonPublicRole,
|
|
20432
|
+
withEphemeralReviewerWorktree: () => withEphemeralReviewerWorktree
|
|
20019
20433
|
});
|
|
20434
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
20020
20435
|
import { existsSync as existsSync10 } from "node:fs";
|
|
20021
|
-
import {
|
|
20436
|
+
import { mkdir as mkdir5, mkdtemp as mkdtemp4, realpath as realpath7, rm as rm4 } from "node:fs/promises";
|
|
20437
|
+
import { tmpdir as tmpdir4 } from "node:os";
|
|
20438
|
+
import { join as join33, relative as relative3, sep as sep5 } from "node:path";
|
|
20439
|
+
import { promisify as promisify3 } from "node:util";
|
|
20022
20440
|
function createCapturingIo() {
|
|
20023
20441
|
const chunks = [];
|
|
20024
20442
|
return {
|
|
@@ -20106,13 +20524,14 @@ async function createSummonEnv(options, afterHost) {
|
|
|
20106
20524
|
Promise.resolve().then(() => (init_role_turn_host_resolution(), role_turn_host_resolution_exports)),
|
|
20107
20525
|
Promise.resolve().then(() => (init_config(), config_exports))
|
|
20108
20526
|
]);
|
|
20109
|
-
const principalAuthority = piDurablePrincipalAuthority2;
|
|
20527
|
+
const principalAuthority = options.principalAuthority ?? piDurablePrincipalAuthority2;
|
|
20110
20528
|
const roleTurnHost = resolveRoleTurnHost2(
|
|
20111
20529
|
{
|
|
20112
20530
|
packageRoot: options.packageRoot,
|
|
20113
20531
|
...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
|
|
20114
20532
|
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
20115
|
-
...options.extraPiArgs === void 0 || options.extraPiArgs.length === 0 ? {} : { extraPiArgs: options.extraPiArgs }
|
|
20533
|
+
...options.extraPiArgs === void 0 || options.extraPiArgs.length === 0 ? {} : { extraPiArgs: options.extraPiArgs },
|
|
20534
|
+
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
20116
20535
|
},
|
|
20117
20536
|
{ role: options.role, seat: options.seat, principalAuthority }
|
|
20118
20537
|
);
|
|
@@ -20125,13 +20544,16 @@ async function createSummonEnv(options, afterHost) {
|
|
|
20125
20544
|
};
|
|
20126
20545
|
}
|
|
20127
20546
|
const hostName = seatWithModel.host ?? "pi";
|
|
20128
|
-
|
|
20129
|
-
|
|
20130
|
-
|
|
20131
|
-
|
|
20132
|
-
|
|
20133
|
-
|
|
20134
|
-
|
|
20547
|
+
let hostFacingSelection = options.hostFacingModel;
|
|
20548
|
+
if (hostFacingSelection === void 0) {
|
|
20549
|
+
const { loadHostProvidersTable: loadHostProvidersTable2, projectHostFacingProvider: projectHostFacingProvider2 } = await Promise.resolve().then(() => (init_host_providers(), host_providers_exports));
|
|
20550
|
+
hostFacingSelection = projectHostFacingProvider2(
|
|
20551
|
+
seatWithModel.selection,
|
|
20552
|
+
hostName,
|
|
20553
|
+
loadHostProvidersTable2(options.home),
|
|
20554
|
+
options.home
|
|
20555
|
+
);
|
|
20556
|
+
}
|
|
20135
20557
|
return {
|
|
20136
20558
|
ok: true,
|
|
20137
20559
|
env: {
|
|
@@ -20145,7 +20567,8 @@ async function createSummonEnv(options, afterHost) {
|
|
|
20145
20567
|
credentials: options.credentials,
|
|
20146
20568
|
...hostFacingSelection === void 0 ? {} : { model: hostFacingSelection },
|
|
20147
20569
|
...projectSeatEngine(seatWithModel),
|
|
20148
|
-
...projectSeatHost(seatWithModel)
|
|
20570
|
+
...projectSeatHost(seatWithModel),
|
|
20571
|
+
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
20149
20572
|
}
|
|
20150
20573
|
};
|
|
20151
20574
|
}
|
|
@@ -20160,7 +20583,19 @@ async function summonPublicRole(options) {
|
|
|
20160
20583
|
} = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
20161
20584
|
const credentials = options.credentials ?? await loadCredentialProviders2(agentDir);
|
|
20162
20585
|
const config = await loadPublicCliConfig2(home);
|
|
20163
|
-
const
|
|
20586
|
+
const resolvedSeat = resolveEffectiveSeat2(config, options.role, credentials);
|
|
20587
|
+
const inheritedSelection = options.model === void 0 ? void 0 : {
|
|
20588
|
+
provider: options.model.provider,
|
|
20589
|
+
model: options.model.model,
|
|
20590
|
+
...options.model.thinking === void 0 ? {} : { thinking: options.model.thinking }
|
|
20591
|
+
};
|
|
20592
|
+
const seat = {
|
|
20593
|
+
...resolvedSeat,
|
|
20594
|
+
...inheritedSelection === void 0 ? {} : { selection: inheritedSelection, source: "invocation" },
|
|
20595
|
+
...options.host === void 0 ? {} : { host: options.host, hostSource: "invocation" },
|
|
20596
|
+
...options.engine === void 0 ? {} : { engine: options.engine, engineSource: "invocation" },
|
|
20597
|
+
...options.engineModel === void 0 ? {} : { engineModel: options.engineModel }
|
|
20598
|
+
};
|
|
20164
20599
|
const captured = options.io === void 0 ? createCapturingIo() : void 0;
|
|
20165
20600
|
const io = options.io ?? captured.io;
|
|
20166
20601
|
const summonEnvInput = {
|
|
@@ -20173,7 +20608,11 @@ async function summonPublicRole(options) {
|
|
|
20173
20608
|
seat,
|
|
20174
20609
|
...options.extraPiArgs === void 0 ? {} : { extraPiArgs: options.extraPiArgs },
|
|
20175
20610
|
...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
|
|
20176
|
-
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters }
|
|
20611
|
+
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
20612
|
+
...options.principalAuthority === void 0 ? {} : { principalAuthority: options.principalAuthority },
|
|
20613
|
+
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs },
|
|
20614
|
+
// Parent model is already host-facing; child must not project again.
|
|
20615
|
+
...options.model === void 0 ? {} : { hostFacingModel: options.model }
|
|
20177
20616
|
};
|
|
20178
20617
|
async function prepareSummonEnv(afterHost) {
|
|
20179
20618
|
try {
|
|
@@ -20185,7 +20624,9 @@ async function summonPublicRole(options) {
|
|
|
20185
20624
|
ok: true,
|
|
20186
20625
|
env: {
|
|
20187
20626
|
...built.env,
|
|
20188
|
-
|
|
20627
|
+
// Nested court stations keep station-child semantics; dual-lens
|
|
20628
|
+
// ordinary Reviewer axes opt out (#946 / ADR 0082).
|
|
20629
|
+
...options.stationChild === false ? {} : { stationChild: true },
|
|
20189
20630
|
// Forward composition-root adapters so nested court stations (e.g.
|
|
20190
20631
|
// countersign → diarist) select the same faux/production table (#924).
|
|
20191
20632
|
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
@@ -20195,7 +20636,8 @@ async function summonPublicRole(options) {
|
|
|
20195
20636
|
...options.gateReviewInstruction === void 0 ? {} : { gateReviewInstruction: options.gateReviewInstruction },
|
|
20196
20637
|
...options.boundTicketNumber === void 0 ? {} : { boundTicketNumber: options.boundTicketNumber },
|
|
20197
20638
|
...options.correlationId === void 0 || options.correlationId.trim() === "" ? {} : { correlationId: options.correlationId },
|
|
20198
|
-
...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
|
|
20639
|
+
...options.createRunId === void 0 ? {} : { createRunId: options.createRunId },
|
|
20640
|
+
...options.executionCwd === void 0 ? {} : { executionCwd: options.executionCwd }
|
|
20199
20641
|
}
|
|
20200
20642
|
};
|
|
20201
20643
|
} catch (error) {
|
|
@@ -20307,6 +20749,16 @@ async function summonPublicRole(options) {
|
|
|
20307
20749
|
result = stepped.ok;
|
|
20308
20750
|
break;
|
|
20309
20751
|
}
|
|
20752
|
+
case "reviewer": {
|
|
20753
|
+
const [{ runPublicReviewer: runPublicReviewer2 }, { parseReviewerArgv: parseReviewerArgv2 }] = await Promise.all([
|
|
20754
|
+
Promise.resolve().then(() => (init_reviewer_run(), reviewer_run_exports)),
|
|
20755
|
+
Promise.resolve().then(() => (init_invocation(), invocation_exports))
|
|
20756
|
+
]);
|
|
20757
|
+
const stepped = await runPrepared(parseReviewerArgv2, (env, once) => runPublicReviewer2(options.argv, env, io, once));
|
|
20758
|
+
if ("fail" in stepped) return stepped.fail;
|
|
20759
|
+
result = stepped.ok;
|
|
20760
|
+
break;
|
|
20761
|
+
}
|
|
20310
20762
|
}
|
|
20311
20763
|
const stderr = captured?.stderrText();
|
|
20312
20764
|
const runDirectory = result.admitted?.runDirectory;
|
|
@@ -20318,6 +20770,296 @@ async function summonPublicRole(options) {
|
|
|
20318
20770
|
...stderr === void 0 || stderr === "" ? {} : { stderr }
|
|
20319
20771
|
};
|
|
20320
20772
|
}
|
|
20773
|
+
function withReviewerLens(argv, lens) {
|
|
20774
|
+
const separator = argv.indexOf("--");
|
|
20775
|
+
if (separator === -1) return [...argv, "--lens", lens];
|
|
20776
|
+
return [...argv.slice(0, separator), "--lens", lens, ...argv.slice(separator)];
|
|
20777
|
+
}
|
|
20778
|
+
async function resolveReviewerWorktreeRoots(projectRoot) {
|
|
20779
|
+
const callerProjectRoot = await realpath7(projectRoot);
|
|
20780
|
+
const sourceProjectRoot = await realpath7((await execFileAsync3(
|
|
20781
|
+
"git",
|
|
20782
|
+
["rev-parse", "--show-toplevel"],
|
|
20783
|
+
{ cwd: callerProjectRoot }
|
|
20784
|
+
)).stdout.trim());
|
|
20785
|
+
const callerRelative = relative3(sourceProjectRoot, callerProjectRoot);
|
|
20786
|
+
const projectRelative = callerRelative === "" || callerRelative === "." || callerRelative.startsWith(`..${sep5}`) || callerRelative === ".." ? "" : callerRelative;
|
|
20787
|
+
return { callerProjectRoot, sourceProjectRoot, projectRelative };
|
|
20788
|
+
}
|
|
20789
|
+
function reviewerSandboxPath(worktreeAxis, projectRelative) {
|
|
20790
|
+
return projectRelative === "" ? worktreeAxis : join33(worktreeAxis, projectRelative);
|
|
20791
|
+
}
|
|
20792
|
+
async function openEphemeralReviewerWorktree(options) {
|
|
20793
|
+
const { sourceProjectRoot, projectRelative } = await resolveReviewerWorktreeRoots(
|
|
20794
|
+
options.projectRoot
|
|
20795
|
+
);
|
|
20796
|
+
const { stdout: headStdout } = await execFileAsync3(
|
|
20797
|
+
"git",
|
|
20798
|
+
["rev-parse", "--verify", "HEAD^{commit}"],
|
|
20799
|
+
{ cwd: sourceProjectRoot }
|
|
20800
|
+
);
|
|
20801
|
+
const targetCommit = headStdout.trim();
|
|
20802
|
+
const root = await mkdtemp4(join33(tmpdir4(), "ak-reviewer-sandbox-"));
|
|
20803
|
+
const worktreeRoot = join33(root, "work");
|
|
20804
|
+
let registered = false;
|
|
20805
|
+
const rollback = async (cause) => {
|
|
20806
|
+
const cleanupErrors = [];
|
|
20807
|
+
if (registered) {
|
|
20808
|
+
try {
|
|
20809
|
+
await execFileAsync3("git", ["worktree", "remove", "--force", worktreeRoot], {
|
|
20810
|
+
cwd: sourceProjectRoot
|
|
20811
|
+
});
|
|
20812
|
+
} catch (error) {
|
|
20813
|
+
cleanupErrors.push(error);
|
|
20814
|
+
}
|
|
20815
|
+
}
|
|
20816
|
+
try {
|
|
20817
|
+
await rm4(root, { recursive: true, force: true });
|
|
20818
|
+
} catch (error) {
|
|
20819
|
+
cleanupErrors.push(error);
|
|
20820
|
+
}
|
|
20821
|
+
if (cleanupErrors.length > 0) {
|
|
20822
|
+
options.onCleanupDiagnostic?.([
|
|
20823
|
+
"reviewer worktree cleanup failed",
|
|
20824
|
+
...cleanupErrors.map((error) => error instanceof Error ? error.message : String(error))
|
|
20825
|
+
].join("\n"));
|
|
20826
|
+
}
|
|
20827
|
+
throw cause;
|
|
20828
|
+
};
|
|
20829
|
+
try {
|
|
20830
|
+
await execFileAsync3("git", ["worktree", "add", "--detach", worktreeRoot, targetCommit], {
|
|
20831
|
+
cwd: sourceProjectRoot
|
|
20832
|
+
});
|
|
20833
|
+
registered = true;
|
|
20834
|
+
if (projectRelative !== "") {
|
|
20835
|
+
await mkdir5(reviewerSandboxPath(worktreeRoot, projectRelative), { recursive: true });
|
|
20836
|
+
}
|
|
20837
|
+
} catch (error) {
|
|
20838
|
+
await rollback(error);
|
|
20839
|
+
}
|
|
20840
|
+
let closed = false;
|
|
20841
|
+
return {
|
|
20842
|
+
executionCwd: reviewerSandboxPath(worktreeRoot, projectRelative),
|
|
20843
|
+
close: async () => {
|
|
20844
|
+
if (closed) return;
|
|
20845
|
+
closed = true;
|
|
20846
|
+
const cleanupErrors = [];
|
|
20847
|
+
try {
|
|
20848
|
+
await execFileAsync3("git", ["worktree", "remove", worktreeRoot], {
|
|
20849
|
+
cwd: sourceProjectRoot
|
|
20850
|
+
});
|
|
20851
|
+
} catch (error) {
|
|
20852
|
+
cleanupErrors.push(error);
|
|
20853
|
+
}
|
|
20854
|
+
try {
|
|
20855
|
+
await rm4(root, { recursive: true, force: true });
|
|
20856
|
+
} catch (error) {
|
|
20857
|
+
cleanupErrors.push(error);
|
|
20858
|
+
}
|
|
20859
|
+
if (cleanupErrors.length > 0) {
|
|
20860
|
+
options.onCleanupDiagnostic?.([
|
|
20861
|
+
"reviewer worktree cleanup failed",
|
|
20862
|
+
...cleanupErrors.map((error) => error instanceof Error ? error.message : String(error))
|
|
20863
|
+
].join("\n"));
|
|
20864
|
+
}
|
|
20865
|
+
}
|
|
20866
|
+
};
|
|
20867
|
+
}
|
|
20868
|
+
async function withEphemeralReviewerWorktree(options) {
|
|
20869
|
+
const sandbox = await openEphemeralReviewerWorktree({
|
|
20870
|
+
projectRoot: options.projectRoot,
|
|
20871
|
+
...options.onCleanupDiagnostic === void 0 ? {} : { onCleanupDiagnostic: options.onCleanupDiagnostic }
|
|
20872
|
+
});
|
|
20873
|
+
try {
|
|
20874
|
+
return await options.run(sandbox.executionCwd);
|
|
20875
|
+
} finally {
|
|
20876
|
+
await sandbox.close();
|
|
20877
|
+
}
|
|
20878
|
+
}
|
|
20879
|
+
async function summonParallelReviewerLenses(options) {
|
|
20880
|
+
const describeFailure = (error) => {
|
|
20881
|
+
if (error instanceof AggregateError) {
|
|
20882
|
+
return [error.message, ...error.errors.map(describeFailure)].join("\n");
|
|
20883
|
+
}
|
|
20884
|
+
return error instanceof Error ? error.message : String(error);
|
|
20885
|
+
};
|
|
20886
|
+
const failedResult = (error) => ({
|
|
20887
|
+
exitCode: 1,
|
|
20888
|
+
stderr: describeFailure(error)
|
|
20889
|
+
});
|
|
20890
|
+
const dualFailure = (error) => {
|
|
20891
|
+
const failure2 = failedResult(error);
|
|
20892
|
+
return { completeness: failure2, correctness: failure2 };
|
|
20893
|
+
};
|
|
20894
|
+
let sourceProjectRoot;
|
|
20895
|
+
let projectRelative;
|
|
20896
|
+
let targetCommit;
|
|
20897
|
+
const statusArgs = [
|
|
20898
|
+
"status",
|
|
20899
|
+
"--porcelain=v1",
|
|
20900
|
+
"--untracked-files=all",
|
|
20901
|
+
"--",
|
|
20902
|
+
":/",
|
|
20903
|
+
":(top,exclude).claude/worktrees/**"
|
|
20904
|
+
];
|
|
20905
|
+
try {
|
|
20906
|
+
const roots = await resolveReviewerWorktreeRoots(options.projectRoot);
|
|
20907
|
+
sourceProjectRoot = roots.sourceProjectRoot;
|
|
20908
|
+
projectRelative = roots.projectRelative;
|
|
20909
|
+
const { stdout: statusStdout } = await execFileAsync3("git", statusArgs, {
|
|
20910
|
+
cwd: sourceProjectRoot
|
|
20911
|
+
});
|
|
20912
|
+
if (statusStdout !== "") {
|
|
20913
|
+
const diagnostic = [
|
|
20914
|
+
"Reviewer target status gate failed:",
|
|
20915
|
+
"git status --porcelain=v1 --untracked-files=all -- :/ ':(top,exclude).claude/worktrees/**'",
|
|
20916
|
+
statusStdout
|
|
20917
|
+
].join("\n");
|
|
20918
|
+
return dualFailure(new Error(diagnostic));
|
|
20919
|
+
}
|
|
20920
|
+
const { stdout: targetStdout } = await execFileAsync3(
|
|
20921
|
+
"git",
|
|
20922
|
+
["rev-parse", "--verify", "HEAD^{commit}"],
|
|
20923
|
+
{ cwd: sourceProjectRoot }
|
|
20924
|
+
);
|
|
20925
|
+
targetCommit = targetStdout.trim();
|
|
20926
|
+
await execFileAsync3(
|
|
20927
|
+
"git",
|
|
20928
|
+
["rev-parse", "--verify", `${options.baseRevision}^{commit}`],
|
|
20929
|
+
{ cwd: sourceProjectRoot }
|
|
20930
|
+
);
|
|
20931
|
+
} catch (error) {
|
|
20932
|
+
return dualFailure(error);
|
|
20933
|
+
}
|
|
20934
|
+
const root = await mkdtemp4(join33(tmpdir4(), "ak-reviewer-lenses-"));
|
|
20935
|
+
const completenessRoot = join33(root, "completeness");
|
|
20936
|
+
const correctnessRoot = join33(root, "correctness");
|
|
20937
|
+
const worktrees = [completenessRoot, correctnessRoot];
|
|
20938
|
+
const created = /* @__PURE__ */ new Set();
|
|
20939
|
+
let results;
|
|
20940
|
+
const creation = await Promise.allSettled(
|
|
20941
|
+
worktrees.map(async (path) => {
|
|
20942
|
+
await execFileAsync3("git", ["worktree", "add", "--detach", path, targetCommit], {
|
|
20943
|
+
cwd: sourceProjectRoot
|
|
20944
|
+
});
|
|
20945
|
+
created.add(path);
|
|
20946
|
+
if (projectRelative !== "") {
|
|
20947
|
+
await mkdir5(reviewerSandboxPath(path, projectRelative), { recursive: true });
|
|
20948
|
+
}
|
|
20949
|
+
})
|
|
20950
|
+
);
|
|
20951
|
+
const creationFailures = creation.flatMap((result) => result.status === "rejected" ? [result.reason] : []);
|
|
20952
|
+
if (creationFailures.length > 0) {
|
|
20953
|
+
const failure2 = failedResult(new AggregateError(
|
|
20954
|
+
creationFailures,
|
|
20955
|
+
"parallel reviewer worktree creation failed"
|
|
20956
|
+
));
|
|
20957
|
+
results = { completeness: failure2, correctness: failure2 };
|
|
20958
|
+
} else {
|
|
20959
|
+
const summon = (lens, worktreeAxis) => {
|
|
20960
|
+
const sandbox = reviewerSandboxPath(worktreeAxis, projectRelative);
|
|
20961
|
+
return summonPublicRole({
|
|
20962
|
+
role: "reviewer",
|
|
20963
|
+
argv: withReviewerLens(options.argv, lens),
|
|
20964
|
+
cwd: options.cwd,
|
|
20965
|
+
executionCwd: sandbox,
|
|
20966
|
+
// Ordinary single-axis public semantics — not a nested court station.
|
|
20967
|
+
stationChild: false,
|
|
20968
|
+
home: options.home,
|
|
20969
|
+
...options.agentDir === void 0 ? {} : { agentDir: options.agentDir },
|
|
20970
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
20971
|
+
...options.model === void 0 ? {} : { model: options.model },
|
|
20972
|
+
...options.host === void 0 ? {} : { host: options.host },
|
|
20973
|
+
...options.engine === void 0 ? {} : { engine: options.engine },
|
|
20974
|
+
...options.engineModel === void 0 ? {} : { engineModel: options.engineModel },
|
|
20975
|
+
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
20976
|
+
...options.correlationId === void 0 ? {} : { correlationId: options.correlationId },
|
|
20977
|
+
...options.packageRoot === void 0 ? {} : { packageRoot: options.packageRoot },
|
|
20978
|
+
...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
|
|
20979
|
+
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
20980
|
+
...options.principalAuthority === void 0 ? {} : { principalAuthority: options.principalAuthority },
|
|
20981
|
+
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
20982
|
+
});
|
|
20983
|
+
};
|
|
20984
|
+
const settled = await Promise.allSettled([
|
|
20985
|
+
summon("completeness", completenessRoot),
|
|
20986
|
+
summon("correctness", correctnessRoot)
|
|
20987
|
+
]);
|
|
20988
|
+
results = {
|
|
20989
|
+
completeness: settled[0].status === "fulfilled" ? settled[0].value : failedResult(settled[0].reason),
|
|
20990
|
+
correctness: settled[1].status === "fulfilled" ? settled[1].value : failedResult(settled[1].reason)
|
|
20991
|
+
};
|
|
20992
|
+
}
|
|
20993
|
+
let sealDiagnostic;
|
|
20994
|
+
try {
|
|
20995
|
+
const { stdout: headBeforeStdout } = await execFileAsync3(
|
|
20996
|
+
"git",
|
|
20997
|
+
["rev-parse", "--verify", "HEAD^{commit}"],
|
|
20998
|
+
{ cwd: sourceProjectRoot }
|
|
20999
|
+
);
|
|
21000
|
+
const { stdout: sealedStatusStdout } = await execFileAsync3("git", statusArgs, {
|
|
21001
|
+
cwd: sourceProjectRoot
|
|
21002
|
+
});
|
|
21003
|
+
const { stdout: headAfterStdout } = await execFileAsync3(
|
|
21004
|
+
"git",
|
|
21005
|
+
["rev-parse", "--verify", "HEAD^{commit}"],
|
|
21006
|
+
{ cwd: sourceProjectRoot }
|
|
21007
|
+
);
|
|
21008
|
+
const headBefore = headBeforeStdout.trim();
|
|
21009
|
+
const headAfter = headAfterStdout.trim();
|
|
21010
|
+
if (headBefore !== targetCommit || headAfter !== targetCommit || sealedStatusStdout !== "") {
|
|
21011
|
+
sealDiagnostic = [
|
|
21012
|
+
"Reviewer target final seal failed:",
|
|
21013
|
+
`HEAD before status => ${headBefore}`,
|
|
21014
|
+
`HEAD after status => ${headAfter}`,
|
|
21015
|
+
`expected PRE_HEAD ${targetCommit}`,
|
|
21016
|
+
"git status --porcelain=v1 --untracked-files=all -- :/ ':(top,exclude).claude/worktrees/**'",
|
|
21017
|
+
sealedStatusStdout
|
|
21018
|
+
].join("\n");
|
|
21019
|
+
}
|
|
21020
|
+
} catch (error) {
|
|
21021
|
+
sealDiagnostic = `Reviewer target final seal failed:
|
|
21022
|
+
${describeFailure(error)}`;
|
|
21023
|
+
}
|
|
21024
|
+
if (sealDiagnostic !== void 0) {
|
|
21025
|
+
const withSealFailure = (result) => ({
|
|
21026
|
+
...result,
|
|
21027
|
+
exitCode: 1,
|
|
21028
|
+
stderr: [result.stderr, sealDiagnostic].filter(
|
|
21029
|
+
(text) => typeof text === "string" && text !== ""
|
|
21030
|
+
).join("\n")
|
|
21031
|
+
});
|
|
21032
|
+
results = {
|
|
21033
|
+
completeness: withSealFailure(results.completeness),
|
|
21034
|
+
correctness: withSealFailure(results.correctness)
|
|
21035
|
+
};
|
|
21036
|
+
}
|
|
21037
|
+
const cleanup = await Promise.allSettled(
|
|
21038
|
+
[...created].map((path) => execFileAsync3("git", ["worktree", "remove", path], { cwd: sourceProjectRoot }))
|
|
21039
|
+
);
|
|
21040
|
+
const cleanupFailures = cleanup.flatMap((result) => result.status === "rejected" ? [result.reason] : []);
|
|
21041
|
+
if (cleanupFailures.length === 0) {
|
|
21042
|
+
const rootCleanup = await Promise.allSettled([rm4(root, { recursive: true, force: true })]);
|
|
21043
|
+
cleanupFailures.push(...rootCleanup.flatMap((result) => result.status === "rejected" ? [result.reason] : []));
|
|
21044
|
+
}
|
|
21045
|
+
if (cleanupFailures.length > 0) {
|
|
21046
|
+
const diagnostic = [
|
|
21047
|
+
"parallel reviewer worktree cleanup failed",
|
|
21048
|
+
...cleanupFailures.map((failure2) => failure2 instanceof Error ? failure2.message : String(failure2))
|
|
21049
|
+
].join("\n");
|
|
21050
|
+
const withCleanupDiagnostic = (result) => ({
|
|
21051
|
+
...result,
|
|
21052
|
+
stderr: [result.stderr, diagnostic].filter(
|
|
21053
|
+
(text) => typeof text === "string" && text !== ""
|
|
21054
|
+
).join("\n")
|
|
21055
|
+
});
|
|
21056
|
+
results = {
|
|
21057
|
+
completeness: withCleanupDiagnostic(results.completeness),
|
|
21058
|
+
correctness: withCleanupDiagnostic(results.correctness)
|
|
21059
|
+
};
|
|
21060
|
+
}
|
|
21061
|
+
return results;
|
|
21062
|
+
}
|
|
20321
21063
|
async function summonGateOfficer(options) {
|
|
20322
21064
|
let home = options.home;
|
|
20323
21065
|
if (home === void 0) {
|
|
@@ -20367,12 +21109,13 @@ async function summonGateOfficer(options) {
|
|
|
20367
21109
|
...common
|
|
20368
21110
|
});
|
|
20369
21111
|
}
|
|
20370
|
-
var AK_ROLE_PACKAGE_ROOT_ENV;
|
|
21112
|
+
var AK_ROLE_PACKAGE_ROOT_ENV, execFileAsync3;
|
|
20371
21113
|
var init_public_role_summons = __esm({
|
|
20372
21114
|
"src/public-role-summons.ts"() {
|
|
20373
21115
|
"use strict";
|
|
20374
21116
|
init_engine_material();
|
|
20375
21117
|
AK_ROLE_PACKAGE_ROOT_ENV = "AK_ROLE_PACKAGE_ROOT";
|
|
21118
|
+
execFileAsync3 = promisify3(execFile3);
|
|
20376
21119
|
}
|
|
20377
21120
|
});
|
|
20378
21121
|
|
|
@@ -20594,7 +21337,7 @@ import {
|
|
|
20594
21337
|
statSync as statSync3,
|
|
20595
21338
|
writeFileSync as writeFileSync2
|
|
20596
21339
|
} from "node:fs";
|
|
20597
|
-
import { dirname as dirname18, resolve as
|
|
21340
|
+
import { dirname as dirname18, resolve as resolve15, join as join35 } from "node:path";
|
|
20598
21341
|
import { StringDecoder } from "node:string_decoder";
|
|
20599
21342
|
import { SessionManager } from "@earendil-works/pi-coding-agent";
|
|
20600
21343
|
function readCurrentSession(sessionDir) {
|
|
@@ -20702,8 +21445,8 @@ function parseSessionHeaderLine(line2) {
|
|
|
20702
21445
|
};
|
|
20703
21446
|
}
|
|
20704
21447
|
function mostRecentNavigatorSessionFile(sessionDir, cwd) {
|
|
20705
|
-
const absoluteSessionDir =
|
|
20706
|
-
const absoluteCwd =
|
|
21448
|
+
const absoluteSessionDir = resolve15(sessionDir);
|
|
21449
|
+
const absoluteCwd = resolve15(cwd);
|
|
20707
21450
|
let names;
|
|
20708
21451
|
try {
|
|
20709
21452
|
names = readdirSync2(absoluteSessionDir);
|
|
@@ -20738,7 +21481,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
|
|
|
20738
21481
|
}
|
|
20739
21482
|
if (header === void 0) continue;
|
|
20740
21483
|
if (typeof header.cwd !== "string" || header.cwd.length === 0) continue;
|
|
20741
|
-
if (
|
|
21484
|
+
if (resolve15(header.cwd) !== absoluteCwd) continue;
|
|
20742
21485
|
matched.push({ path: filePath, mtimeMs: st.mtimeMs });
|
|
20743
21486
|
}
|
|
20744
21487
|
if (matched.length === 0) return void 0;
|
|
@@ -20768,8 +21511,8 @@ function resolveNavigatorNestContinuation(sessionDir, cwd) {
|
|
|
20768
21511
|
}
|
|
20769
21512
|
}
|
|
20770
21513
|
function assertRecentFinalFileUnderSessionDir(sessionDir, recentFile) {
|
|
20771
|
-
const absoluteSessionDir =
|
|
20772
|
-
const absoluteFile =
|
|
21514
|
+
const absoluteSessionDir = resolve15(sessionDir);
|
|
21515
|
+
const absoluteFile = resolve15(recentFile);
|
|
20773
21516
|
if (absoluteFile !== absoluteSessionDir && !pathContainedIn(absoluteSessionDir, absoluteFile)) {
|
|
20774
21517
|
throw new ActivationLedgerError(
|
|
20775
21518
|
`archivist record session must be under the authorized nest (${sessionDir}): ${recentFile}`
|
|
@@ -20824,7 +21567,7 @@ function createRecordSessionOpen(options) {
|
|
|
20824
21567
|
throw new Error("Durable record ownership requires a parent session inside the ledger home");
|
|
20825
21568
|
} else {
|
|
20826
21569
|
ledgerHome = resolveActivationLedgerHomeForPath(parentFile);
|
|
20827
|
-
const parentResolved =
|
|
21570
|
+
const parentResolved = resolve15(parentFile);
|
|
20828
21571
|
if (!physicallyContainedIn(ledgerHome, parentResolved)) {
|
|
20829
21572
|
throw new Error("Durable record ownership requires a parent session inside the ledger home");
|
|
20830
21573
|
}
|
|
@@ -20991,7 +21734,7 @@ import { createHash as createHash9 } from "node:crypto";
|
|
|
20991
21734
|
init_navigator_invocation_identity();
|
|
20992
21735
|
init_packaged_role_registry();
|
|
20993
21736
|
init_activation_ledger_topology();
|
|
20994
|
-
import { resolve as
|
|
21737
|
+
import { resolve as resolve16 } from "node:path";
|
|
20995
21738
|
import "@earendil-works/pi-coding-agent";
|
|
20996
21739
|
import { Type as Type13 } from "typebox";
|
|
20997
21740
|
|
|
@@ -21444,7 +22187,7 @@ function navigatorSubjectKey(subjectRoot, subject, provenance = "role_input") {
|
|
|
21444
22187
|
}
|
|
21445
22188
|
function navigatorSubjectKeyForInput(subjectRoot, reference, cwd = process.cwd()) {
|
|
21446
22189
|
if (issueRoot(subjectRoot) !== void 0 || !subjectRoot.includes("/.ak/work/")) return subjectRoot;
|
|
21447
|
-
const resolvedReference =
|
|
22190
|
+
const resolvedReference = resolve16(cwd, reference);
|
|
21448
22191
|
const marker = "/runs/";
|
|
21449
22192
|
if (resolvedReference.includes(marker)) {
|
|
21450
22193
|
return subjectRoot;
|
|
@@ -21956,7 +22699,7 @@ ${helpContext}
|
|
|
21956
22699
|
init_doctor_evidence();
|
|
21957
22700
|
init_host_contracts();
|
|
21958
22701
|
import { readFile as readFile20 } from "node:fs/promises";
|
|
21959
|
-
import { resolve as
|
|
22702
|
+
import { resolve as resolve17 } from "node:path";
|
|
21960
22703
|
init_notary_source_run();
|
|
21961
22704
|
init_packaged_role_registry();
|
|
21962
22705
|
init_invocation();
|
|
@@ -21964,7 +22707,7 @@ function navigatorInputReference(getFlag, role) {
|
|
|
21964
22707
|
if (getFlag === void 0) return void 0;
|
|
21965
22708
|
const name = packagedRoleInputFlag(role);
|
|
21966
22709
|
const value = name === void 0 ? void 0 : getFlag(name);
|
|
21967
|
-
return typeof value === "string" && value !== "" ?
|
|
22710
|
+
return typeof value === "string" && value !== "" ? resolve17(value) : void 0;
|
|
21968
22711
|
}
|
|
21969
22712
|
async function loadNavigatorWorkContext(options) {
|
|
21970
22713
|
const reference = navigatorInputReference(options.getFlag, options.role);
|
|
@@ -21985,7 +22728,7 @@ async function loadNavigatorWorkContext(options) {
|
|
|
21985
22728
|
}
|
|
21986
22729
|
const publicRunDir = runDirectoryFromHostContext(options.context);
|
|
21987
22730
|
const currentSessionDir = options.context.sessionManager.getSessionDir();
|
|
21988
|
-
const isBoundPublicRun = publicRunDir !== void 0 &&
|
|
22731
|
+
const isBoundPublicRun = publicRunDir !== void 0 && resolve17(currentSessionDir) === resolve17(publicRunDir, "session");
|
|
21989
22732
|
if (options.role === "judge" && isBoundPublicRun) {
|
|
21990
22733
|
let admitted;
|
|
21991
22734
|
try {
|
|
@@ -22018,9 +22761,9 @@ async function loadNavigatorWorkContext(options) {
|
|
|
22018
22761
|
}
|
|
22019
22762
|
const workRoot = subjectRoot.includes("/.ak/work/") ? subjectRoot : void 0;
|
|
22020
22763
|
const authorityFiles = workRoot === void 0 ? [] : [
|
|
22021
|
-
|
|
22022
|
-
|
|
22023
|
-
|
|
22764
|
+
resolve17(workRoot, "authority.md"),
|
|
22765
|
+
resolve17(workRoot, "authority.txt"),
|
|
22766
|
+
resolve17(workRoot, "design-v2/owner-direction.md")
|
|
22024
22767
|
];
|
|
22025
22768
|
let authorityMaterial;
|
|
22026
22769
|
for (const path of authorityFiles) {
|
|
@@ -22134,7 +22877,7 @@ import {
|
|
|
22134
22877
|
openSync as openSync2,
|
|
22135
22878
|
writeSync
|
|
22136
22879
|
} from "node:fs";
|
|
22137
|
-
import { dirname as dirname21, isAbsolute as isAbsolute10, resolve as
|
|
22880
|
+
import { dirname as dirname21, isAbsolute as isAbsolute10, resolve as resolve19 } from "node:path";
|
|
22138
22881
|
|
|
22139
22882
|
// src/activation-ledger-session.ts
|
|
22140
22883
|
init_activation_ledger_topology();
|
|
@@ -22144,7 +22887,7 @@ import {
|
|
|
22144
22887
|
statSync as statSync4,
|
|
22145
22888
|
writeFileSync as writeFileSync3
|
|
22146
22889
|
} from "node:fs";
|
|
22147
|
-
import { isAbsolute as isAbsolute9, resolve as
|
|
22890
|
+
import { isAbsolute as isAbsolute9, resolve as resolve18 } from "node:path";
|
|
22148
22891
|
var ActivationSessionFileMissingError = class extends Error {
|
|
22149
22892
|
code = "AK_ACTIVATION_SESSION_FILE_MISSING";
|
|
22150
22893
|
path;
|
|
@@ -22189,7 +22932,7 @@ function durableSessionPointer(sessionManager) {
|
|
|
22189
22932
|
`Workflow role activation requires an absolute durable session file path; got relative path: ${file}`
|
|
22190
22933
|
);
|
|
22191
22934
|
}
|
|
22192
|
-
const resolvedFile =
|
|
22935
|
+
const resolvedFile = resolve18(file);
|
|
22193
22936
|
try {
|
|
22194
22937
|
lstatSync2(resolvedFile);
|
|
22195
22938
|
} catch (error) {
|
|
@@ -22281,8 +23024,8 @@ function appendActivationLedgerLine(ledgerPath, line2, options) {
|
|
|
22281
23024
|
`activation ledger home must be absolute: ${options.ledgerHome}`
|
|
22282
23025
|
);
|
|
22283
23026
|
}
|
|
22284
|
-
const resolvedLedger =
|
|
22285
|
-
const resolvedHome =
|
|
23027
|
+
const resolvedLedger = resolve19(ledgerPath);
|
|
23028
|
+
const resolvedHome = resolve19(options.ledgerHome);
|
|
22286
23029
|
const parent = dirname21(resolvedLedger);
|
|
22287
23030
|
ensureRealDirectoryTree(resolvedHome, parent);
|
|
22288
23031
|
assertLedgerFileInsideHome(resolvedLedger, resolvedHome);
|
|
@@ -22643,11 +23386,11 @@ init_collector_github();
|
|
|
22643
23386
|
|
|
22644
23387
|
// src/collector-handbook.ts
|
|
22645
23388
|
import { readFile as readFile21 } from "node:fs/promises";
|
|
22646
|
-
import { join as join38, sep as
|
|
23389
|
+
import { join as join38, sep as sep6 } from "node:path";
|
|
22647
23390
|
|
|
22648
23391
|
// src/atomic-write.ts
|
|
22649
23392
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
22650
|
-
import { rename as rename3, rm as
|
|
23393
|
+
import { rename as rename3, rm as rm5, writeFile as writeFile11 } from "node:fs/promises";
|
|
22651
23394
|
import { dirname as dirname22, join as join37 } from "node:path";
|
|
22652
23395
|
async function writeFileAtomically(destination, contents) {
|
|
22653
23396
|
const parent = dirname22(destination);
|
|
@@ -22656,7 +23399,7 @@ async function writeFileAtomically(destination, contents) {
|
|
|
22656
23399
|
await writeFile11(temporary, contents);
|
|
22657
23400
|
await rename3(temporary, destination);
|
|
22658
23401
|
} catch (error) {
|
|
22659
|
-
await
|
|
23402
|
+
await rm5(temporary, { force: true }).catch(() => void 0);
|
|
22660
23403
|
throw error;
|
|
22661
23404
|
}
|
|
22662
23405
|
}
|
|
@@ -22757,7 +23500,7 @@ function resolveCollectorHandbookRoot(sessionPath) {
|
|
|
22757
23500
|
if (typeof sessionPath !== "string" || sessionPath.trim().length === 0) {
|
|
22758
23501
|
throw new Error("\u901A\u8FDB\u53F8\u624B\u518C\u8981\u6C42\u975E\u7A7A session \u8DEF\u5F84\uFF0C\u4E14\u4F4D\u4E8E books/<bookKey>/");
|
|
22759
23502
|
}
|
|
22760
|
-
const segments = sessionPath.split(
|
|
23503
|
+
const segments = sessionPath.split(sep6);
|
|
22761
23504
|
let bookKey;
|
|
22762
23505
|
for (let i = 0; i + 3 < segments.length; i += 1) {
|
|
22763
23506
|
if (segments[i] === ".ak-roles" && segments[i + 1] === "books") {
|
|
@@ -24080,7 +24823,7 @@ var reviewerAmendmentsSchema = Type24.Object({
|
|
|
24080
24823
|
}))
|
|
24081
24824
|
}, {
|
|
24082
24825
|
additionalProperties: true,
|
|
24083
|
-
description: "\
|
|
24826
|
+
description: "\u5DF2\u8FD0\u884C lens \u7684 amendments \u627F\u8F7D candidates\u3001\u9010\u6761\u5904\u7F6E\u4E0E verdict \u7684\u5B8C\u6574\u62A5\u544A\uFF08\u975E\u4EC5 verdict \u884C\uFF09\uFF1B\u663E\u5F0F\u5355\u8F74\u65F6\u53E6\u4E00\u8F74\u53EF\u7701\u7565\u3002hard-stop\uFF0Fusage error \u4E3A refused \u65F6\uFF0C\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u5BF9\u5E94 lens \u5B57\u6BB5\u3002\u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\u3002"
|
|
24084
24827
|
});
|
|
24085
24828
|
var REVIEWER_STATUS_DESCRIPTION = "completed | refused \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\u3002\u4E24\u79CD\u6B63\u5E38 lens verdict\uFF08completeness / correctness\uFF09\u5747 completed\uFF1Bhard-stop \u4E0E usage error \u4E3A refused\uFF08\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u8FDB\u6240\u9009 lens amendments\uFF09\u3002";
|
|
24086
24829
|
var reviewerOutputVariants = Type24.Union([
|
|
@@ -24156,7 +24899,7 @@ init_submission_errors();
|
|
|
24156
24899
|
init_submission_errors();
|
|
24157
24900
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
24158
24901
|
import { existsSync as existsSync12, lstatSync as lstatSync3, readdirSync as readdirSync3, readFileSync as readFileSync5, rmdirSync, rmSync } from "node:fs";
|
|
24159
|
-
import { resolve as
|
|
24902
|
+
import { resolve as resolve20 } from "node:path";
|
|
24160
24903
|
var WORKER_SUBMISSION_GATE_RECORD_KIND = WORKER_SUBMISSION_GATE_KIND;
|
|
24161
24904
|
var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
|
|
24162
24905
|
var WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE = "commit-reminder-bounce";
|
|
@@ -24205,7 +24948,7 @@ function escapeGitConfigValueRegex(value) {
|
|
|
24205
24948
|
function unsetOwnedHooksPath(file) {
|
|
24206
24949
|
const owned = [];
|
|
24207
24950
|
for (const value of tryGetAll(file, "core.hooksPath")) {
|
|
24208
|
-
if (!ownedHook(
|
|
24951
|
+
if (!ownedHook(resolve20(value, HOOK_FILE))) continue;
|
|
24209
24952
|
try {
|
|
24210
24953
|
gitFile(file, [
|
|
24211
24954
|
"--unset-all",
|
|
@@ -24220,15 +24963,15 @@ function unsetOwnedHooksPath(file) {
|
|
|
24220
24963
|
return owned;
|
|
24221
24964
|
}
|
|
24222
24965
|
function rmOwnedDir(dir) {
|
|
24223
|
-
const hookPath =
|
|
24966
|
+
const hookPath = resolve20(dir, HOOK_FILE);
|
|
24224
24967
|
if (!ownedHook(hookPath)) return;
|
|
24225
24968
|
rmSync(hookPath, { force: true });
|
|
24226
24969
|
if (existsSync12(dir) && readdirSync3(dir).length === 0) rmdirSync(dir);
|
|
24227
24970
|
}
|
|
24228
24971
|
function linkedGitDirs(commonDir) {
|
|
24229
|
-
const root =
|
|
24972
|
+
const root = resolve20(commonDir, "worktrees");
|
|
24230
24973
|
if (!existsSync12(root)) return [];
|
|
24231
|
-
return readdirSync3(root).map((name) =>
|
|
24974
|
+
return readdirSync3(root).map((name) => resolve20(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
|
|
24232
24975
|
}
|
|
24233
24976
|
function uninstallPackageWorkerHooks(cwd) {
|
|
24234
24977
|
let inside;
|
|
@@ -24242,14 +24985,14 @@ function uninstallPackageWorkerHooks(cwd) {
|
|
|
24242
24985
|
const clear = (configFile) => {
|
|
24243
24986
|
for (const hooks of unsetOwnedHooksPath(configFile)) rmOwnedDir(hooks);
|
|
24244
24987
|
};
|
|
24245
|
-
clear(
|
|
24246
|
-
clear(
|
|
24247
|
-
rmOwnedDir(
|
|
24248
|
-
const legacy =
|
|
24988
|
+
clear(resolve20(commonDir, "config"));
|
|
24989
|
+
clear(resolve20(commonDir, "config.worktree"));
|
|
24990
|
+
rmOwnedDir(resolve20(commonDir, HOOKS_DIR));
|
|
24991
|
+
const legacy = resolve20(commonDir, "hooks", HOOK_FILE);
|
|
24249
24992
|
if (ownedHook(legacy)) rmSync(legacy, { force: true });
|
|
24250
24993
|
for (const gitDir of linkedGitDirs(commonDir)) {
|
|
24251
|
-
clear(
|
|
24252
|
-
rmOwnedDir(
|
|
24994
|
+
clear(resolve20(gitDir, "config.worktree"));
|
|
24995
|
+
rmOwnedDir(resolve20(gitDir, HOOKS_DIR));
|
|
24253
24996
|
}
|
|
24254
24997
|
}
|
|
24255
24998
|
function isRecord13(value) {
|
|
@@ -24294,11 +25037,11 @@ function reliableWindow(cwd, baseline, head) {
|
|
|
24294
25037
|
const raw = git2(cwd, ["log", "--format=%P%x1e%s", range]);
|
|
24295
25038
|
if (raw.length === 0) return [];
|
|
24296
25039
|
return raw.split("\n").flatMap((line2) => {
|
|
24297
|
-
const
|
|
24298
|
-
if (
|
|
25040
|
+
const sep7 = line2.indexOf("");
|
|
25041
|
+
if (sep7 < 0) return [];
|
|
24299
25042
|
return [{
|
|
24300
|
-
subject: line2.slice(
|
|
24301
|
-
merge: line2.slice(0,
|
|
25043
|
+
subject: line2.slice(sep7 + 1),
|
|
25044
|
+
merge: line2.slice(0, sep7).trim().includes(" ")
|
|
24302
25045
|
}];
|
|
24303
25046
|
});
|
|
24304
25047
|
}
|
|
@@ -24843,7 +25586,7 @@ var REVIEWER_TRANSPORT_FLAGS = Object.freeze([
|
|
|
24843
25586
|
Object.freeze({
|
|
24844
25587
|
name: "ak-review-lens",
|
|
24845
25588
|
definition: Object.freeze({
|
|
24846
|
-
description: "
|
|
25589
|
+
description: "Single review lens: completeness or correctness",
|
|
24847
25590
|
type: "string"
|
|
24848
25591
|
})
|
|
24849
25592
|
}),
|
|
@@ -26367,7 +27110,7 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
26367
27110
|
// src/role-envelope.ts
|
|
26368
27111
|
init_engine_detour();
|
|
26369
27112
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
26370
|
-
import { mkdir as
|
|
27113
|
+
import { mkdir as mkdir7, writeFile as writeFile12 } from "node:fs/promises";
|
|
26371
27114
|
import { createServer } from "node:net";
|
|
26372
27115
|
import { dirname as dirname24, join as join42 } from "node:path";
|
|
26373
27116
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
@@ -26455,7 +27198,7 @@ async function requireGatekeeperPass(options) {
|
|
|
26455
27198
|
}
|
|
26456
27199
|
|
|
26457
27200
|
// src/host-native-method.ts
|
|
26458
|
-
import { lstat as lstat7, mkdir as
|
|
27201
|
+
import { lstat as lstat7, mkdir as mkdir6, readlink, realpath as realpath8, symlink } from "node:fs/promises";
|
|
26459
27202
|
import { basename as basename9, dirname as dirname23, join as join41 } from "node:path";
|
|
26460
27203
|
var HOST_METHOD_PLUGIN_NAME = "ak-methods";
|
|
26461
27204
|
var packagedMethodsDir = (root) => join41(root, "resources", "methods");
|
|
@@ -26488,11 +27231,11 @@ function applyCodexSkillInvocation(methods, prompt) {
|
|
|
26488
27231
|
);
|
|
26489
27232
|
}
|
|
26490
27233
|
async function installWorkspaceMethodSkills(cwd, packageRoot) {
|
|
26491
|
-
const target = await
|
|
27234
|
+
const target = await realpath8(packagedMethodsDir(packageRoot));
|
|
26492
27235
|
const link = join41(cwd, ".agents", "skills");
|
|
26493
27236
|
try {
|
|
26494
27237
|
const stat2 = await lstat7(link);
|
|
26495
|
-
if (!stat2.isSymbolicLink() || await
|
|
27238
|
+
if (!stat2.isSymbolicLink() || await realpath8(link) !== target) {
|
|
26496
27239
|
const detail = stat2.isSymbolicLink() ? `symlink to ${await readlink(link)}` : "non-symlink entry";
|
|
26497
27240
|
throw new Error(`workspace method catalog conflict at ${link}: ${detail}`);
|
|
26498
27241
|
}
|
|
@@ -26500,12 +27243,12 @@ async function installWorkspaceMethodSkills(cwd, packageRoot) {
|
|
|
26500
27243
|
} catch (error) {
|
|
26501
27244
|
if (error.code !== "ENOENT") throw error;
|
|
26502
27245
|
}
|
|
26503
|
-
await
|
|
27246
|
+
await mkdir6(dirname23(link), { recursive: true });
|
|
26504
27247
|
try {
|
|
26505
27248
|
await symlink(target, link);
|
|
26506
27249
|
} catch (error) {
|
|
26507
27250
|
if (error.code !== "EEXIST") throw error;
|
|
26508
|
-
if (await
|
|
27251
|
+
if (await realpath8(link).catch(() => "") !== target) {
|
|
26509
27252
|
throw new Error(`workspace method catalog conflict at ${link}`);
|
|
26510
27253
|
}
|
|
26511
27254
|
}
|
|
@@ -26517,11 +27260,11 @@ init_role_activation_flags();
|
|
|
26517
27260
|
init_submission_correctable_error();
|
|
26518
27261
|
init_navigator_invocation_identity();
|
|
26519
27262
|
async function listen(server, path) {
|
|
26520
|
-
await new Promise((
|
|
27263
|
+
await new Promise((resolve22, reject) => {
|
|
26521
27264
|
server.once("error", reject);
|
|
26522
27265
|
server.listen(path, () => {
|
|
26523
27266
|
server.off("error", reject);
|
|
26524
|
-
|
|
27267
|
+
resolve22();
|
|
26525
27268
|
});
|
|
26526
27269
|
});
|
|
26527
27270
|
}
|
|
@@ -26555,9 +27298,9 @@ async function prepareRoleEnvelope(options) {
|
|
|
26555
27298
|
let infrastructureRoundFailure;
|
|
26556
27299
|
const hostAbort = new AbortController();
|
|
26557
27300
|
const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID8();
|
|
26558
|
-
await
|
|
27301
|
+
await mkdir7(request.runDirectory, { recursive: true });
|
|
26559
27302
|
let sessionFile = options.sessionFile ?? join42(request.runDirectory, "session", "session.jsonl");
|
|
26560
|
-
await
|
|
27303
|
+
await mkdir7(dirname24(sessionFile), { recursive: true });
|
|
26561
27304
|
if (request.continuation.kind !== "resume") {
|
|
26562
27305
|
try {
|
|
26563
27306
|
await writeFile12(
|
|
@@ -26899,8 +27642,8 @@ async function prepareRoleEnvelope(options) {
|
|
|
26899
27642
|
try {
|
|
26900
27643
|
const closeAll = server.closeAllConnections;
|
|
26901
27644
|
if (typeof closeAll === "function") closeAll.call(server);
|
|
26902
|
-
await new Promise((
|
|
26903
|
-
server.close((error) => error ? reject(error) :
|
|
27645
|
+
await new Promise((resolve22, reject) => {
|
|
27646
|
+
server.close((error) => error ? reject(error) : resolve22());
|
|
26904
27647
|
});
|
|
26905
27648
|
} catch (error) {
|
|
26906
27649
|
cleanupFailures.push(error);
|
|
@@ -27295,7 +28038,7 @@ import { spawn as spawn4, spawnSync } from "node:child_process";
|
|
|
27295
28038
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
27296
28039
|
import { existsSync as existsSync13 } from "node:fs";
|
|
27297
28040
|
import { writeFile as writeFile13 } from "node:fs/promises";
|
|
27298
|
-
import { dirname as dirname25, isAbsolute as isAbsolute11, join as join44, resolve as
|
|
28041
|
+
import { dirname as dirname25, isAbsolute as isAbsolute11, join as join44, resolve as resolve21 } from "node:path";
|
|
27299
28042
|
|
|
27300
28043
|
// src/external-host-turn-loop.ts
|
|
27301
28044
|
init_host_contracts();
|
|
@@ -27543,10 +28286,10 @@ function resolveGitCommonDir(cwd) {
|
|
|
27543
28286
|
if (raw === "") {
|
|
27544
28287
|
throw new Error("git rev-parse --git-common-dir returned empty stdout");
|
|
27545
28288
|
}
|
|
27546
|
-
return isAbsolute11(raw) ? raw :
|
|
28289
|
+
return isAbsolute11(raw) ? raw : resolve21(cwd, raw);
|
|
27547
28290
|
}
|
|
27548
28291
|
function spawnHeadlessTurn(options) {
|
|
27549
|
-
return new Promise((
|
|
28292
|
+
return new Promise((resolve22, reject) => {
|
|
27550
28293
|
if (options.signal?.aborted) {
|
|
27551
28294
|
reject(hostAbortedError("headless host aborted"));
|
|
27552
28295
|
return;
|
|
@@ -27621,7 +28364,7 @@ function spawnHeadlessTurn(options) {
|
|
|
27621
28364
|
reject(stdinDeliveryError);
|
|
27622
28365
|
return;
|
|
27623
28366
|
}
|
|
27624
|
-
|
|
28367
|
+
resolve22({ code, stdout: resultStdout, stderr, timedOut });
|
|
27625
28368
|
};
|
|
27626
28369
|
const onAbort = () => {
|
|
27627
28370
|
child.kill("SIGTERM");
|