@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
|
@@ -62,7 +62,7 @@ async function spawnEngineDetourOnce(input) {
|
|
|
62
62
|
}
|
|
63
63
|
const command = input.argv[0];
|
|
64
64
|
const args = input.argv.slice(1);
|
|
65
|
-
return await new Promise((
|
|
65
|
+
return await new Promise((resolve22, reject) => {
|
|
66
66
|
let settled = false;
|
|
67
67
|
const signal = input.signal;
|
|
68
68
|
const child = spawn(command, args, {
|
|
@@ -92,7 +92,7 @@ async function spawnEngineDetourOnce(input) {
|
|
|
92
92
|
if (signal !== void 0) {
|
|
93
93
|
signal.removeEventListener("abort", onAbort);
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
resolve22(result);
|
|
96
96
|
};
|
|
97
97
|
const onAbort = () => {
|
|
98
98
|
fail4(signal !== void 0 ? abortReasonError(signal) : new Error("aborted"));
|
|
@@ -4754,7 +4754,7 @@ function normalizeReviewComment(raw) {
|
|
|
4754
4754
|
function createGhApiRunner(options = {}) {
|
|
4755
4755
|
const spawnImpl = options.spawnImpl ?? spawn3;
|
|
4756
4756
|
return async (args, runOptions = {}) => {
|
|
4757
|
-
return await new Promise((
|
|
4757
|
+
return await new Promise((resolve22, reject) => {
|
|
4758
4758
|
const signal = runOptions.signal;
|
|
4759
4759
|
if (signal?.aborted) {
|
|
4760
4760
|
reject(signal.reason ?? new Error("aborted"));
|
|
@@ -4827,11 +4827,11 @@ function createGhApiRunner(options = {}) {
|
|
|
4827
4827
|
const value = line2.slice(idx + 1).trim();
|
|
4828
4828
|
headers[name] = value;
|
|
4829
4829
|
}
|
|
4830
|
-
|
|
4830
|
+
resolve22({ status, headers, bodyText });
|
|
4831
4831
|
return;
|
|
4832
4832
|
}
|
|
4833
4833
|
if (code === 0) {
|
|
4834
|
-
|
|
4834
|
+
resolve22({ status: 200, headers: {}, bodyText: stdout });
|
|
4835
4835
|
return;
|
|
4836
4836
|
}
|
|
4837
4837
|
const failure2 = new Error(
|
|
@@ -6331,6 +6331,48 @@ async function loadResumableJudgeRun(home, runId, authority) {
|
|
|
6331
6331
|
};
|
|
6332
6332
|
return seatLoadedResult(loaded, admitted);
|
|
6333
6333
|
}
|
|
6334
|
+
async function loadResumableReviewerRun(home, runId, authority) {
|
|
6335
|
+
const loaded = await loadResumableRunRecord(home, runId, authority);
|
|
6336
|
+
if (loaded.run.role !== "reviewer") {
|
|
6337
|
+
throw new CliUsageError(
|
|
6338
|
+
`role run ${runId} belongs to ${loaded.run.role}, not reviewer`
|
|
6339
|
+
);
|
|
6340
|
+
}
|
|
6341
|
+
const rawBase = loaded.admittedFields.baseRevision;
|
|
6342
|
+
if (rawBase === void 0 || rawBase.trim() === "") {
|
|
6343
|
+
throw new CliUsageError(
|
|
6344
|
+
`role run admitted reviewer base revision is missing: ${runId}`
|
|
6345
|
+
);
|
|
6346
|
+
}
|
|
6347
|
+
if (/\s/.test(rawBase) || rawBase.startsWith("-")) {
|
|
6348
|
+
throw new CliUsageError(
|
|
6349
|
+
`role run admitted reviewer base revision is damaged: ${runId}`
|
|
6350
|
+
);
|
|
6351
|
+
}
|
|
6352
|
+
const baseRevision = rawBase;
|
|
6353
|
+
const lens = loaded.admittedFields.lens;
|
|
6354
|
+
if (!isReviewerLens(lens)) {
|
|
6355
|
+
throw new CliUsageError(
|
|
6356
|
+
`role run admitted reviewer lens is missing: ${runId}`
|
|
6357
|
+
);
|
|
6358
|
+
}
|
|
6359
|
+
const authorityRefs = Object.freeze([
|
|
6360
|
+
...loaded.admittedFields.authorityRefs ?? []
|
|
6361
|
+
]);
|
|
6362
|
+
if (authorityRefs.length === 0) {
|
|
6363
|
+
throw new CliUsageError(
|
|
6364
|
+
`role run admitted reviewer authority refs are missing: ${runId}`
|
|
6365
|
+
);
|
|
6366
|
+
}
|
|
6367
|
+
const admitted = {
|
|
6368
|
+
role: "reviewer",
|
|
6369
|
+
...resumedBaseAdmitted(loaded),
|
|
6370
|
+
baseRevision,
|
|
6371
|
+
lens,
|
|
6372
|
+
authorityRefs
|
|
6373
|
+
};
|
|
6374
|
+
return seatLoadedResult(loaded, admitted);
|
|
6375
|
+
}
|
|
6334
6376
|
async function loadResumableCountersignRun(home, runId, authority) {
|
|
6335
6377
|
const loaded = await loadResumableRunRecord(home, runId, authority);
|
|
6336
6378
|
if (loaded.run.role !== "countersign") {
|
|
@@ -7088,12 +7130,12 @@ var init_option_definitions = __esm({
|
|
|
7088
7130
|
canonical: "--lens",
|
|
7089
7131
|
aliases: [],
|
|
7090
7132
|
valueMetavar: "completeness|correctness",
|
|
7091
|
-
required:
|
|
7133
|
+
required: false,
|
|
7092
7134
|
repeatable: false,
|
|
7093
7135
|
form: "option",
|
|
7094
7136
|
description: {
|
|
7095
|
-
en: "
|
|
7096
|
-
zh: "\
|
|
7137
|
+
en: "Optional single-lens override: completeness or correctness; omitted runs both in parallel.",
|
|
7138
|
+
zh: "\u53EF\u9009\u5355 lens \u8986\u76D6\uFF1Acompleteness \u6216 correctness\uFF1B\u7701\u7565\u65F6\u5E76\u884C\u8FD0\u884C\u4E24\u8F74\u3002"
|
|
7097
7139
|
}
|
|
7098
7140
|
},
|
|
7099
7141
|
{
|
|
@@ -7450,9 +7492,9 @@ var init_option_definitions = __esm({
|
|
|
7450
7492
|
},
|
|
7451
7493
|
reviewer: {
|
|
7452
7494
|
command: "reviewer",
|
|
7453
|
-
summary: "Fixed-target
|
|
7495
|
+
summary: "Fixed-target parallel two-lens review, with an optional single-lens override.",
|
|
7454
7496
|
usage: [
|
|
7455
|
-
"ak-role reviewer --base <revision> --lens completeness|correctness --authority-ref <ref> [options] <instruction>"
|
|
7497
|
+
"ak-role reviewer --base <revision> [--lens completeness|correctness] --authority-ref <ref> [options] <instruction>"
|
|
7456
7498
|
],
|
|
7457
7499
|
examples: [
|
|
7458
7500
|
'ak-role reviewer --base main --lens completeness --authority-ref docs/adr/0001.md "Review the branch."',
|
|
@@ -9585,7 +9627,7 @@ function parseReviewerArgv(args) {
|
|
|
9585
9627
|
instruction: positional.join(" "),
|
|
9586
9628
|
attachmentPaths,
|
|
9587
9629
|
baseRevision,
|
|
9588
|
-
lens,
|
|
9630
|
+
...lens === void 0 ? {} : { lens },
|
|
9589
9631
|
authorityRefs,
|
|
9590
9632
|
...project === void 0 ? {} : { project }
|
|
9591
9633
|
};
|
|
@@ -9634,6 +9676,7 @@ async function admitReviewerInvocation(options) {
|
|
|
9634
9676
|
baseRevision,
|
|
9635
9677
|
lens,
|
|
9636
9678
|
authorityRefs: [...authorityRefs],
|
|
9679
|
+
...options.correlationId === void 0 ? {} : { correlationId: options.correlationId },
|
|
9637
9680
|
attachments: attachments.map((a) => ({
|
|
9638
9681
|
provenancePath: a.provenancePath,
|
|
9639
9682
|
frozenPath: a.frozenPath,
|
|
@@ -9661,7 +9704,8 @@ async function admitReviewerInvocation(options) {
|
|
|
9661
9704
|
admittedRequestPath,
|
|
9662
9705
|
baseRevision,
|
|
9663
9706
|
lens,
|
|
9664
|
-
authorityRefs
|
|
9707
|
+
authorityRefs,
|
|
9708
|
+
...options.correlationId === void 0 ? {} : { correlationId: options.correlationId }
|
|
9665
9709
|
};
|
|
9666
9710
|
}
|
|
9667
9711
|
function buildReviewerSkillArgProjection(admitted) {
|
|
@@ -9878,11 +9922,11 @@ function parseAnalystCohortIssueToken(raw, flag) {
|
|
|
9878
9922
|
`${flag} requires a comma-separated list of N or book:N`
|
|
9879
9923
|
);
|
|
9880
9924
|
}
|
|
9881
|
-
const
|
|
9882
|
-
if (
|
|
9883
|
-
const rhs = trimmed.slice(
|
|
9925
|
+
const sep7 = trimmed.lastIndexOf(":");
|
|
9926
|
+
if (sep7 > 0) {
|
|
9927
|
+
const rhs = trimmed.slice(sep7 + 1);
|
|
9884
9928
|
if (ANALYST_TICKET_NUMBER_PATTERN.test(rhs)) {
|
|
9885
|
-
const bookKey = trimmed.slice(0,
|
|
9929
|
+
const bookKey = trimmed.slice(0, sep7);
|
|
9886
9930
|
if (bookKey.trim() === "") {
|
|
9887
9931
|
throw new CliUsageError(
|
|
9888
9932
|
`${flag} book:N requires a non-empty book key, got ${raw}`
|
|
@@ -12268,12 +12312,12 @@ function createSystemCollectorClock() {
|
|
|
12268
12312
|
return {
|
|
12269
12313
|
wallNow: () => /* @__PURE__ */ new Date(),
|
|
12270
12314
|
monoNow: () => Number(process.hrtime.bigint() - start) / 1e6,
|
|
12271
|
-
sleep: (ms, signal) => new Promise((
|
|
12315
|
+
sleep: (ms, signal) => new Promise((resolve22, reject) => {
|
|
12272
12316
|
if (signal?.aborted) {
|
|
12273
12317
|
reject(signal.reason ?? new Error("aborted"));
|
|
12274
12318
|
return;
|
|
12275
12319
|
}
|
|
12276
|
-
const timer = setTimeout(
|
|
12320
|
+
const timer = setTimeout(resolve22, ms);
|
|
12277
12321
|
const onAbort = () => {
|
|
12278
12322
|
clearTimeout(timer);
|
|
12279
12323
|
reject(signal?.reason ?? new Error("aborted"));
|
|
@@ -14263,6 +14307,15 @@ function formatTerminalResult(result) {
|
|
|
14263
14307
|
);
|
|
14264
14308
|
}
|
|
14265
14309
|
}
|
|
14310
|
+
if (result.reviewerChildOutcomes !== void 0) {
|
|
14311
|
+
for (const axis of ["completeness", "correctness"]) {
|
|
14312
|
+
const child = result.reviewerChildOutcomes[axis];
|
|
14313
|
+
lines.push(`reviewer-child ${axis} ${child.exitCode}`);
|
|
14314
|
+
if (child.stderr !== void 0 && child.stderr !== "") {
|
|
14315
|
+
lines.push(`reviewer-child-diagnostic ${axis} ${encodeTerminalField(child.stderr)}`);
|
|
14316
|
+
}
|
|
14317
|
+
}
|
|
14318
|
+
}
|
|
14266
14319
|
if (result.resume !== void 0) {
|
|
14267
14320
|
lines.push(`resume ${encodeTerminalField(result.resume.command)}`);
|
|
14268
14321
|
} else if (result.runId !== void 0) {
|
|
@@ -16723,10 +16776,10 @@ function presentFailureTerminal(terminal, io) {
|
|
|
16723
16776
|
}
|
|
16724
16777
|
function defaultNavigatorGraceSleep() {
|
|
16725
16778
|
let timer;
|
|
16726
|
-
const sleep = ((ms) => new Promise((
|
|
16779
|
+
const sleep = ((ms) => new Promise((resolve22) => {
|
|
16727
16780
|
timer = setTimeout(() => {
|
|
16728
16781
|
timer = void 0;
|
|
16729
|
-
|
|
16782
|
+
resolve22();
|
|
16730
16783
|
}, ms);
|
|
16731
16784
|
}));
|
|
16732
16785
|
sleep.cancel = () => {
|
|
@@ -16738,7 +16791,7 @@ function defaultNavigatorGraceSleep() {
|
|
|
16738
16791
|
return sleep;
|
|
16739
16792
|
}
|
|
16740
16793
|
function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep = defaultNavigatorGraceSleep()) {
|
|
16741
|
-
return new Promise((
|
|
16794
|
+
return new Promise((resolve22, reject) => {
|
|
16742
16795
|
let settled = false;
|
|
16743
16796
|
const finish = (action) => {
|
|
16744
16797
|
if (settled) return;
|
|
@@ -16747,11 +16800,11 @@ function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep
|
|
|
16747
16800
|
action();
|
|
16748
16801
|
};
|
|
16749
16802
|
void work.then(
|
|
16750
|
-
(value) => finish(() =>
|
|
16803
|
+
(value) => finish(() => resolve22({ status: "done", value })),
|
|
16751
16804
|
(error) => finish(() => reject(error))
|
|
16752
16805
|
);
|
|
16753
16806
|
void sleep(graceMs).then(() => {
|
|
16754
|
-
finish(() =>
|
|
16807
|
+
finish(() => resolve22({ status: "timeout" }));
|
|
16755
16808
|
});
|
|
16756
16809
|
});
|
|
16757
16810
|
}
|
|
@@ -18202,6 +18255,30 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
18202
18255
|
}
|
|
18203
18256
|
}
|
|
18204
18257
|
}
|
|
18258
|
+
async function resolveResumeMethodMaterialAdapters(input) {
|
|
18259
|
+
if (input.shouldLoad === false) {
|
|
18260
|
+
return { kind: "continue", adapters: input.emptyAdapters };
|
|
18261
|
+
}
|
|
18262
|
+
try {
|
|
18263
|
+
const material = await input.loadMaterial();
|
|
18264
|
+
return { kind: "continue", adapters: input.adaptersWith(material) };
|
|
18265
|
+
} catch (error) {
|
|
18266
|
+
const terminal = await presentControlledFailure2(
|
|
18267
|
+
input.admitted,
|
|
18268
|
+
{
|
|
18269
|
+
timedOut: false,
|
|
18270
|
+
code: null,
|
|
18271
|
+
stderr: "",
|
|
18272
|
+
thrown: error,
|
|
18273
|
+
...input.knownCause === void 0 ? {} : { knownCause: input.knownCause }
|
|
18274
|
+
},
|
|
18275
|
+
input.emptyAdapters,
|
|
18276
|
+
input.authority,
|
|
18277
|
+
input.io
|
|
18278
|
+
);
|
|
18279
|
+
return { kind: "terminal", ...terminal };
|
|
18280
|
+
}
|
|
18281
|
+
}
|
|
18205
18282
|
async function presentControlledFailure2(admitted, failureInput, adapters, authority, io, persistRunState = true) {
|
|
18206
18283
|
const hasThrown = Object.hasOwn(failureInput, "thrown");
|
|
18207
18284
|
const resumeObservation = await resolveControlledFailureResumeObservation({
|
|
@@ -18752,6 +18829,8 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
18752
18829
|
}
|
|
18753
18830
|
adapters = prepared.adapters;
|
|
18754
18831
|
}
|
|
18832
|
+
let env = input.env;
|
|
18833
|
+
let preparedCleanup;
|
|
18755
18834
|
const buildRequestAfterLease = async () => {
|
|
18756
18835
|
let openCourtAttemptId;
|
|
18757
18836
|
let admittedForBuild = loaded.admitted;
|
|
@@ -18802,7 +18881,12 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
18802
18881
|
return turnRequest;
|
|
18803
18882
|
};
|
|
18804
18883
|
try {
|
|
18805
|
-
if (input.
|
|
18884
|
+
if (input.afterAdmittedPrepare !== void 0) {
|
|
18885
|
+
const prepared = await input.afterAdmittedPrepare(loaded.admitted);
|
|
18886
|
+
if (prepared.env !== void 0) env = prepared.env;
|
|
18887
|
+
preparedCleanup = prepared.cleanup;
|
|
18888
|
+
}
|
|
18889
|
+
if (env.stationChild === true) {
|
|
18806
18890
|
let firstTurn;
|
|
18807
18891
|
const stationAdapters = withOnceSuccessfulBeforeDispatch(adapters);
|
|
18808
18892
|
const invocationScopeId = mintEngineDetourInvocationScope({
|
|
@@ -18810,14 +18894,14 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
18810
18894
|
});
|
|
18811
18895
|
return await runWithAutoResumeLoop({
|
|
18812
18896
|
admitted: loaded.admitted,
|
|
18813
|
-
principalAuthority:
|
|
18897
|
+
principalAuthority: env.principalAuthority,
|
|
18814
18898
|
isPrincipalAvailable: resolveHostAwareSessionAvailability(
|
|
18815
|
-
|
|
18816
|
-
|
|
18899
|
+
env.host,
|
|
18900
|
+
env.principalAuthority
|
|
18817
18901
|
),
|
|
18818
18902
|
io: input.io,
|
|
18819
|
-
sessionAppender:
|
|
18820
|
-
autoResumeLimit:
|
|
18903
|
+
sessionAppender: env.sessionAppender,
|
|
18904
|
+
autoResumeLimit: env.autoResumeLimit,
|
|
18821
18905
|
buildInitialPayload: () => ({ resumeTurn: false }),
|
|
18822
18906
|
buildResumePayload: () => ({ resumeTurn: true }),
|
|
18823
18907
|
// Same as public manual resume: prior-court sealed acceptance is not a
|
|
@@ -18844,7 +18928,7 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
18844
18928
|
dispatch: async (turnRequest) => {
|
|
18845
18929
|
const result = await dispatchPostAdmissionTurn({
|
|
18846
18930
|
admitted: loaded.admitted,
|
|
18847
|
-
env
|
|
18931
|
+
env,
|
|
18848
18932
|
io: attemptIo,
|
|
18849
18933
|
request: turnRequest,
|
|
18850
18934
|
lease,
|
|
@@ -18854,7 +18938,7 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
18854
18938
|
});
|
|
18855
18939
|
return settleDeferredPersist(
|
|
18856
18940
|
loaded.admitted,
|
|
18857
|
-
|
|
18941
|
+
env.principalAuthority,
|
|
18858
18942
|
stationAdapters,
|
|
18859
18943
|
attemptIo,
|
|
18860
18944
|
result
|
|
@@ -18865,7 +18949,7 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
18865
18949
|
}
|
|
18866
18950
|
return await runPostAdmissionManualResume({
|
|
18867
18951
|
admitted: loaded.admitted,
|
|
18868
|
-
env
|
|
18952
|
+
env,
|
|
18869
18953
|
io: input.io,
|
|
18870
18954
|
adapters,
|
|
18871
18955
|
...input.effectiveEngine === void 0 ? {} : { effectiveEngine: input.effectiveEngine },
|
|
@@ -18877,6 +18961,10 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
18877
18961
|
return { exitCode: 2 };
|
|
18878
18962
|
}
|
|
18879
18963
|
throw error;
|
|
18964
|
+
} finally {
|
|
18965
|
+
if (preparedCleanup !== void 0) {
|
|
18966
|
+
await preparedCleanup();
|
|
18967
|
+
}
|
|
18880
18968
|
}
|
|
18881
18969
|
}
|
|
18882
18970
|
async function runPostAdmissionOneShot(input) {
|
|
@@ -19038,7 +19126,7 @@ var init_post_admission = __esm({
|
|
|
19038
19126
|
|
|
19039
19127
|
// src/public-cli/turn-request.ts
|
|
19040
19128
|
function projectRoleTurnRequest(admitted, roleDetails, options) {
|
|
19041
|
-
const cwd = admitted.projectRoot ?? admitted.repoRoot ?? admitted.cwd;
|
|
19129
|
+
const cwd = options.cwd ?? admitted.projectRoot ?? admitted.repoRoot ?? admitted.cwd;
|
|
19042
19130
|
if (cwd === void 0) throw new Error("admitted invocation missing working directory");
|
|
19043
19131
|
if (admitted.principal === void 0) throw new Error("admitted invocation missing principal");
|
|
19044
19132
|
return {
|
|
@@ -20542,16 +20630,346 @@ var init_countersign_run = __esm({
|
|
|
20542
20630
|
}
|
|
20543
20631
|
});
|
|
20544
20632
|
|
|
20633
|
+
// src/public-cli/reviewer-run.ts
|
|
20634
|
+
var reviewer_run_exports = {};
|
|
20635
|
+
__export(reviewer_run_exports, {
|
|
20636
|
+
buildReviewerTurnRequest: () => buildReviewerTurnRequest,
|
|
20637
|
+
runPublicReviewer: () => runPublicReviewer,
|
|
20638
|
+
runPublicReviewerResume: () => runPublicReviewerResume
|
|
20639
|
+
});
|
|
20640
|
+
import { resolve as resolve14 } from "node:path";
|
|
20641
|
+
function reviewerMethods(packageRoot) {
|
|
20642
|
+
return [{ kind: "skill", path: resolvePackagedMethodSkillPath(packageRoot, "ak-cross-m-review") }];
|
|
20643
|
+
}
|
|
20644
|
+
async function runReviewerTurnInFreshCopy(env, projectRoot, io, body) {
|
|
20645
|
+
if (env.executionCwd !== void 0) {
|
|
20646
|
+
return body(env);
|
|
20647
|
+
}
|
|
20648
|
+
const { withEphemeralReviewerWorktree: withEphemeralReviewerWorktree2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
|
|
20649
|
+
return await withEphemeralReviewerWorktree2({
|
|
20650
|
+
projectRoot,
|
|
20651
|
+
onCleanupDiagnostic: (diagnostic) => {
|
|
20652
|
+
io.stderr(`${diagnostic}
|
|
20653
|
+
`);
|
|
20654
|
+
},
|
|
20655
|
+
run: (executionCwd) => body({ ...env, executionCwd })
|
|
20656
|
+
});
|
|
20657
|
+
}
|
|
20658
|
+
function buildReviewerTurnRequest(admitted, options) {
|
|
20659
|
+
return projectRoleTurnRequest(
|
|
20660
|
+
admitted,
|
|
20661
|
+
{
|
|
20662
|
+
activation: {
|
|
20663
|
+
role: "reviewer",
|
|
20664
|
+
baseRevision: admitted.baseRevision,
|
|
20665
|
+
lens: admitted.lens,
|
|
20666
|
+
authorityRefs: admitted.authorityRefs,
|
|
20667
|
+
...admitted.ticketNumber === void 0 ? {} : { ticketNumber: admitted.ticketNumber }
|
|
20668
|
+
},
|
|
20669
|
+
methods: reviewerMethods(options.packageRoot)
|
|
20670
|
+
},
|
|
20671
|
+
options
|
|
20672
|
+
);
|
|
20673
|
+
}
|
|
20674
|
+
function reviewerAdapters(packageRoot, methodMaterial) {
|
|
20675
|
+
return {
|
|
20676
|
+
trySettle: (admitted, authority, scope) => methodMaterial === void 0 ? Promise.resolve(void 0) : trySettleReviewerTerminalResult(
|
|
20677
|
+
admitted,
|
|
20678
|
+
authority,
|
|
20679
|
+
{
|
|
20680
|
+
methodProvenance: methodMaterial.provenance,
|
|
20681
|
+
methodSkillPath: methodMaterial.skillPath,
|
|
20682
|
+
methodSkillConfiguredPath: resolvePackagedMethodSkillPath(
|
|
20683
|
+
packageRoot,
|
|
20684
|
+
"ak-cross-m-review"
|
|
20685
|
+
)
|
|
20686
|
+
},
|
|
20687
|
+
scope
|
|
20688
|
+
),
|
|
20689
|
+
resolveRunnerKnownFailure: async ({ result, sessionFile }) => {
|
|
20690
|
+
const infrastructureFailure = await readEngineDetourInfrastructureFailure(sessionFile);
|
|
20691
|
+
return infrastructureFailure === void 0 ? result.knownFailure : {
|
|
20692
|
+
...infrastructureFailure.cause === void 0 ? {} : { cause: infrastructureFailure.cause },
|
|
20693
|
+
diagnostic: infrastructureFailure.diagnostic,
|
|
20694
|
+
...infrastructureFailure.identity === void 0 ? {} : { identity: infrastructureFailure.identity }
|
|
20695
|
+
};
|
|
20696
|
+
}
|
|
20697
|
+
};
|
|
20698
|
+
}
|
|
20699
|
+
async function loadReviewerMethodMaterial(packageRoot) {
|
|
20700
|
+
return await loadPackagedMethodSkillMaterial(packageRoot, "ak-cross-m-review");
|
|
20701
|
+
}
|
|
20702
|
+
function reviewerResumePrompt(env, message) {
|
|
20703
|
+
const lines = [RESUME_TRANSPORT_ENVELOPE];
|
|
20704
|
+
if (message !== void 0) lines.push("", message);
|
|
20705
|
+
return appendEngineSessionMaterial(
|
|
20706
|
+
lines,
|
|
20707
|
+
engineSessionMaterialFromOptions({
|
|
20708
|
+
...pickEngineAxis(env),
|
|
20709
|
+
packageRoot: env.packageRoot
|
|
20710
|
+
})
|
|
20711
|
+
).join("\n");
|
|
20712
|
+
}
|
|
20713
|
+
async function runPublicReviewer(argv, env, io, parseReviewerArgv2) {
|
|
20714
|
+
let parsed;
|
|
20715
|
+
try {
|
|
20716
|
+
parsed = parseReviewerArgv2(argv);
|
|
20717
|
+
} catch (error) {
|
|
20718
|
+
if (error instanceof CliUsageError) {
|
|
20719
|
+
presentStructuralRejection(error, io);
|
|
20720
|
+
return { exitCode: 2 };
|
|
20721
|
+
}
|
|
20722
|
+
throw error;
|
|
20723
|
+
}
|
|
20724
|
+
if (parsed.lens === void 0) {
|
|
20725
|
+
const { summonParallelReviewerLenses: summonParallelReviewerLenses2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
|
|
20726
|
+
const children = await summonParallelReviewerLenses2({
|
|
20727
|
+
argv,
|
|
20728
|
+
// Replay argv under the same cwd the single-axis entry would see (10a).
|
|
20729
|
+
// Do not substitute the resolved project path — relative --project must
|
|
20730
|
+
// not be re-resolved against a shifted cwd.
|
|
20731
|
+
cwd: env.cwd,
|
|
20732
|
+
projectRoot: resolve14(parsed.project ?? env.cwd),
|
|
20733
|
+
// Typed base from the public parse — precheck only; child argv stays verbatim.
|
|
20734
|
+
baseRevision: parsed.baseRevision,
|
|
20735
|
+
home: env.home,
|
|
20736
|
+
agentDir: env.agentDir,
|
|
20737
|
+
...env.credentials === void 0 ? {} : { credentials: env.credentials },
|
|
20738
|
+
...env.model === void 0 ? {} : { model: env.model },
|
|
20739
|
+
...env.host === void 0 ? {} : { host: env.host },
|
|
20740
|
+
...env.engine === void 0 ? {} : { engine: env.engine },
|
|
20741
|
+
...env.engineModel === void 0 ? {} : { engineModel: env.engineModel },
|
|
20742
|
+
packageRoot: env.packageRoot,
|
|
20743
|
+
...env.signal === void 0 ? {} : { signal: env.signal },
|
|
20744
|
+
...env.correlationId === void 0 ? {} : { correlationId: env.correlationId },
|
|
20745
|
+
roleTurnHost: env.roleTurnHost,
|
|
20746
|
+
...env.hostAdapters === void 0 ? {} : { hostAdapters: env.hostAdapters },
|
|
20747
|
+
principalAuthority: env.principalAuthority,
|
|
20748
|
+
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs }
|
|
20749
|
+
});
|
|
20750
|
+
const childResults = [children.completeness, children.correctness];
|
|
20751
|
+
const terminals = childResults.map((child) => child.terminal).filter((terminal2) => terminal2 !== void 0);
|
|
20752
|
+
const failedChildren = childResults.filter((child) => child.terminal === void 0 || !isLawfulTypedTerminalOutcome(child.terminal.roleOutcome)).length;
|
|
20753
|
+
const overlayExit = childResults.some((child) => child.exitCode !== 0);
|
|
20754
|
+
const failed = failedChildren > 0 || overlayExit;
|
|
20755
|
+
const overlayDiagnostics = [...new Set(
|
|
20756
|
+
childResults.map((child) => child.stderr).filter((text) => typeof text === "string" && text !== "")
|
|
20757
|
+
)];
|
|
20758
|
+
const terminal = {
|
|
20759
|
+
batch: "reviewer",
|
|
20760
|
+
roleOutcome: failed ? {
|
|
20761
|
+
kind: "failure",
|
|
20762
|
+
role: "reviewer",
|
|
20763
|
+
diagnostic: failedChildren > 0 ? "Reviewer batch child failure" : overlayDiagnostics[0] ?? "Reviewer batch infrastructure failure",
|
|
20764
|
+
decisiveFacts: { failedChildren },
|
|
20765
|
+
payloads: terminals
|
|
20766
|
+
} : { kind: "accepted", role: "reviewer", payloads: terminals },
|
|
20767
|
+
reviewerChildren: {
|
|
20768
|
+
...children.completeness.terminal === void 0 ? {} : { completeness: children.completeness.terminal },
|
|
20769
|
+
...children.correctness.terminal === void 0 ? {} : { correctness: children.correctness.terminal }
|
|
20770
|
+
},
|
|
20771
|
+
reviewerChildOutcomes: {
|
|
20772
|
+
completeness: { exitCode: children.completeness.exitCode, ...children.completeness.stderr === void 0 ? {} : { stderr: children.completeness.stderr } },
|
|
20773
|
+
correctness: { exitCode: children.correctness.exitCode, ...children.correctness.stderr === void 0 ? {} : { stderr: children.correctness.stderr } }
|
|
20774
|
+
},
|
|
20775
|
+
// Batch has no parent run and no own attendance; no-advice is affirmative
|
|
20776
|
+
// only (navigator-attendance.ts). Children carry their own navigator facts.
|
|
20777
|
+
navigator: {
|
|
20778
|
+
disposition: "unavailable",
|
|
20779
|
+
source: "unknown",
|
|
20780
|
+
reason: "Reviewer batch has no parent-run Navigator attendance"
|
|
20781
|
+
},
|
|
20782
|
+
artifacts: terminals.flatMap((item) => item.artifacts)
|
|
20783
|
+
};
|
|
20784
|
+
io.stdout(formatTerminalResult(terminal));
|
|
20785
|
+
return { exitCode: failed ? 1 : 0, terminal };
|
|
20786
|
+
}
|
|
20787
|
+
let admitted;
|
|
20788
|
+
try {
|
|
20789
|
+
admitted = await admitReviewerInvocation({
|
|
20790
|
+
home: env.home,
|
|
20791
|
+
principalAuthority: env.principalAuthority,
|
|
20792
|
+
cwd: env.cwd,
|
|
20793
|
+
instruction: parsed.instruction,
|
|
20794
|
+
attachmentPaths: parsed.attachmentPaths,
|
|
20795
|
+
baseRevision: parsed.baseRevision,
|
|
20796
|
+
lens: parsed.lens,
|
|
20797
|
+
authorityRefs: parsed.authorityRefs,
|
|
20798
|
+
...parsed.project === void 0 ? {} : { project: parsed.project },
|
|
20799
|
+
...env.createRunId === void 0 ? {} : { createRunId: env.createRunId },
|
|
20800
|
+
...env.correlationId === void 0 ? {} : { correlationId: env.correlationId },
|
|
20801
|
+
...env.model === void 0 ? {} : { model: env.model }
|
|
20802
|
+
});
|
|
20803
|
+
} catch (error) {
|
|
20804
|
+
if (error instanceof CliUsageError) {
|
|
20805
|
+
presentStructuralRejection(error, io);
|
|
20806
|
+
return { exitCode: 2 };
|
|
20807
|
+
}
|
|
20808
|
+
throw error;
|
|
20809
|
+
}
|
|
20810
|
+
await markRunAdmitted(admitted, env.principalAuthority);
|
|
20811
|
+
let methodMaterial;
|
|
20812
|
+
try {
|
|
20813
|
+
methodMaterial = await loadReviewerMethodMaterial(env.packageRoot);
|
|
20814
|
+
} catch (error) {
|
|
20815
|
+
return await presentControlledFailure2(
|
|
20816
|
+
admitted,
|
|
20817
|
+
{
|
|
20818
|
+
timedOut: false,
|
|
20819
|
+
code: null,
|
|
20820
|
+
stderr: "",
|
|
20821
|
+
thrown: error
|
|
20822
|
+
},
|
|
20823
|
+
reviewerAdapters(env.packageRoot),
|
|
20824
|
+
env.principalAuthority,
|
|
20825
|
+
io
|
|
20826
|
+
);
|
|
20827
|
+
}
|
|
20828
|
+
try {
|
|
20829
|
+
return await runReviewerTurnInFreshCopy(env, admitted.projectRoot, io, async (sandboxedEnv) => await runPostAdmissionResumable({
|
|
20830
|
+
admitted,
|
|
20831
|
+
env: sandboxedEnv,
|
|
20832
|
+
io,
|
|
20833
|
+
buildInitialRequest: () => buildReviewerTurnRequest(admitted, {
|
|
20834
|
+
packageRoot: sandboxedEnv.packageRoot,
|
|
20835
|
+
home: sandboxedEnv.home,
|
|
20836
|
+
agentDir: sandboxedEnv.agentDir,
|
|
20837
|
+
...sandboxedEnv.model === void 0 ? {} : { model: sandboxedEnv.model },
|
|
20838
|
+
...pickEngineAxis(sandboxedEnv),
|
|
20839
|
+
...sandboxedEnv.timeoutMs === void 0 ? {} : { timeoutMs: sandboxedEnv.timeoutMs },
|
|
20840
|
+
...admitted.correlationId === void 0 && sandboxedEnv.correlationId === void 0 ? {} : { correlationId: admitted.correlationId ?? sandboxedEnv.correlationId },
|
|
20841
|
+
// Ephemeral worktree cwd; durable projectRoot stays on admitted caller project.
|
|
20842
|
+
...sandboxedEnv.executionCwd === void 0 ? {} : { cwd: sandboxedEnv.executionCwd },
|
|
20843
|
+
continuation: {
|
|
20844
|
+
kind: "initial",
|
|
20845
|
+
prompt: buildReviewerTransportPrompt(
|
|
20846
|
+
admitted,
|
|
20847
|
+
engineSessionMaterialFromOptions({
|
|
20848
|
+
...pickEngineAxis(sandboxedEnv),
|
|
20849
|
+
packageRoot: sandboxedEnv.packageRoot
|
|
20850
|
+
})
|
|
20851
|
+
)
|
|
20852
|
+
}
|
|
20853
|
+
}),
|
|
20854
|
+
buildResumeRequest: () => buildReviewerTurnRequest(admitted, {
|
|
20855
|
+
packageRoot: sandboxedEnv.packageRoot,
|
|
20856
|
+
home: sandboxedEnv.home,
|
|
20857
|
+
agentDir: sandboxedEnv.agentDir,
|
|
20858
|
+
...sandboxedEnv.model === void 0 ? {} : { model: sandboxedEnv.model },
|
|
20859
|
+
...pickEngineAxis(sandboxedEnv),
|
|
20860
|
+
...sandboxedEnv.timeoutMs === void 0 ? {} : { timeoutMs: sandboxedEnv.timeoutMs },
|
|
20861
|
+
...admitted.correlationId === void 0 && sandboxedEnv.correlationId === void 0 ? {} : { correlationId: admitted.correlationId ?? sandboxedEnv.correlationId },
|
|
20862
|
+
// In-batch auto-resume keeps the same call's sandbox (dual-lens or single).
|
|
20863
|
+
...sandboxedEnv.executionCwd === void 0 ? {} : { cwd: sandboxedEnv.executionCwd },
|
|
20864
|
+
continuation: {
|
|
20865
|
+
kind: "resume",
|
|
20866
|
+
prompt: reviewerResumePrompt(sandboxedEnv)
|
|
20867
|
+
}
|
|
20868
|
+
}),
|
|
20869
|
+
adapters: reviewerAdapters(sandboxedEnv.packageRoot, methodMaterial),
|
|
20870
|
+
...sandboxedEnv.engine === void 0 ? {} : { effectiveEngine: sandboxedEnv.engine }
|
|
20871
|
+
}));
|
|
20872
|
+
} catch (error) {
|
|
20873
|
+
return await presentControlledFailure2(
|
|
20874
|
+
admitted,
|
|
20875
|
+
{
|
|
20876
|
+
timedOut: false,
|
|
20877
|
+
code: null,
|
|
20878
|
+
stderr: "",
|
|
20879
|
+
thrown: error
|
|
20880
|
+
},
|
|
20881
|
+
reviewerAdapters(env.packageRoot, methodMaterial),
|
|
20882
|
+
env.principalAuthority,
|
|
20883
|
+
io
|
|
20884
|
+
);
|
|
20885
|
+
}
|
|
20886
|
+
}
|
|
20887
|
+
async function runPublicReviewerResume(request, env, io) {
|
|
20888
|
+
const sandbox = {
|
|
20889
|
+
...env.executionCwd === void 0 ? {} : { executionCwd: env.executionCwd }
|
|
20890
|
+
};
|
|
20891
|
+
return await runPostAdmissionSeatResume({
|
|
20892
|
+
request,
|
|
20893
|
+
env,
|
|
20894
|
+
io,
|
|
20895
|
+
load: (effective) => loadResumableReviewerRun(env.home, effective.runId, env.principalAuthority),
|
|
20896
|
+
buildTurnRequest: (admitted, effective) => {
|
|
20897
|
+
const activeEnv = sandbox.executionCwd === void 0 ? env : { ...env, executionCwd: sandbox.executionCwd };
|
|
20898
|
+
const base = resumeTurnRequestProjectionOptions(admitted, effective, activeEnv);
|
|
20899
|
+
return buildReviewerTurnRequest(admitted, {
|
|
20900
|
+
...base,
|
|
20901
|
+
// Fresh copy at resume time; durable projectRoot unchanged.
|
|
20902
|
+
...sandbox.executionCwd === void 0 ? {} : { cwd: sandbox.executionCwd },
|
|
20903
|
+
continuation: {
|
|
20904
|
+
kind: "resume",
|
|
20905
|
+
prompt: reviewerResumePrompt(activeEnv, effective.message)
|
|
20906
|
+
}
|
|
20907
|
+
});
|
|
20908
|
+
},
|
|
20909
|
+
adapters: reviewerAdapters(env.packageRoot),
|
|
20910
|
+
afterAdmittedLoad: async (admitted) => {
|
|
20911
|
+
return resolveResumeMethodMaterialAdapters({
|
|
20912
|
+
admitted,
|
|
20913
|
+
authority: env.principalAuthority,
|
|
20914
|
+
io,
|
|
20915
|
+
loadMaterial: () => loadReviewerMethodMaterial(env.packageRoot),
|
|
20916
|
+
adaptersWith: (material) => reviewerAdapters(env.packageRoot, material),
|
|
20917
|
+
emptyAdapters: reviewerAdapters(env.packageRoot)
|
|
20918
|
+
});
|
|
20919
|
+
},
|
|
20920
|
+
afterAdmittedPrepare: async (admitted) => {
|
|
20921
|
+
if (sandbox.executionCwd !== void 0) {
|
|
20922
|
+
return { env: { ...env, executionCwd: sandbox.executionCwd } };
|
|
20923
|
+
}
|
|
20924
|
+
const { openEphemeralReviewerWorktree: openEphemeralReviewerWorktree2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
|
|
20925
|
+
const opened = await openEphemeralReviewerWorktree2({
|
|
20926
|
+
projectRoot: admitted.projectRoot,
|
|
20927
|
+
onCleanupDiagnostic: (diagnostic) => {
|
|
20928
|
+
io.stderr(`${diagnostic}
|
|
20929
|
+
`);
|
|
20930
|
+
}
|
|
20931
|
+
});
|
|
20932
|
+
sandbox.executionCwd = opened.executionCwd;
|
|
20933
|
+
return {
|
|
20934
|
+
env: { ...env, executionCwd: opened.executionCwd },
|
|
20935
|
+
cleanup: opened.close
|
|
20936
|
+
};
|
|
20937
|
+
},
|
|
20938
|
+
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
20939
|
+
});
|
|
20940
|
+
}
|
|
20941
|
+
var init_reviewer_run = __esm({
|
|
20942
|
+
"src/public-cli/reviewer-run.ts"() {
|
|
20943
|
+
"use strict";
|
|
20944
|
+
init_engine_material();
|
|
20945
|
+
init_method_skill();
|
|
20946
|
+
init_cli_errors();
|
|
20947
|
+
init_invocation();
|
|
20948
|
+
init_run_lifecycle();
|
|
20949
|
+
init_settlement();
|
|
20950
|
+
init_terminal();
|
|
20951
|
+
init_turn_request();
|
|
20952
|
+
init_post_admission();
|
|
20953
|
+
}
|
|
20954
|
+
});
|
|
20955
|
+
|
|
20545
20956
|
// src/public-role-summons.ts
|
|
20546
20957
|
var public_role_summons_exports = {};
|
|
20547
20958
|
__export(public_role_summons_exports, {
|
|
20548
20959
|
AK_ROLE_PACKAGE_ROOT_ENV: () => AK_ROLE_PACKAGE_ROOT_ENV,
|
|
20960
|
+
openEphemeralReviewerWorktree: () => openEphemeralReviewerWorktree,
|
|
20549
20961
|
resolveSummonsPackageRoot: () => resolveSummonsPackageRoot,
|
|
20550
20962
|
summonGateOfficer: () => summonGateOfficer,
|
|
20551
|
-
|
|
20963
|
+
summonParallelReviewerLenses: () => summonParallelReviewerLenses,
|
|
20964
|
+
summonPublicRole: () => summonPublicRole,
|
|
20965
|
+
withEphemeralReviewerWorktree: () => withEphemeralReviewerWorktree
|
|
20552
20966
|
});
|
|
20967
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
20553
20968
|
import { existsSync as existsSync11 } from "node:fs";
|
|
20554
|
-
import {
|
|
20969
|
+
import { mkdir as mkdir5, mkdtemp as mkdtemp4, realpath as realpath6, rm as rm4 } from "node:fs/promises";
|
|
20970
|
+
import { tmpdir as tmpdir4 } from "node:os";
|
|
20971
|
+
import { join as join35, relative as relative3, sep as sep5 } from "node:path";
|
|
20972
|
+
import { promisify as promisify3 } from "node:util";
|
|
20555
20973
|
function createCapturingIo() {
|
|
20556
20974
|
const chunks = [];
|
|
20557
20975
|
return {
|
|
@@ -20639,13 +21057,14 @@ async function createSummonEnv(options, afterHost) {
|
|
|
20639
21057
|
Promise.resolve().then(() => (init_role_turn_host_resolution(), role_turn_host_resolution_exports)),
|
|
20640
21058
|
Promise.resolve().then(() => (init_config(), config_exports))
|
|
20641
21059
|
]);
|
|
20642
|
-
const principalAuthority = piDurablePrincipalAuthority2;
|
|
21060
|
+
const principalAuthority = options.principalAuthority ?? piDurablePrincipalAuthority2;
|
|
20643
21061
|
const roleTurnHost = resolveRoleTurnHost2(
|
|
20644
21062
|
{
|
|
20645
21063
|
packageRoot: options.packageRoot,
|
|
20646
21064
|
...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
|
|
20647
21065
|
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
20648
|
-
...options.extraPiArgs === void 0 || options.extraPiArgs.length === 0 ? {} : { extraPiArgs: options.extraPiArgs }
|
|
21066
|
+
...options.extraPiArgs === void 0 || options.extraPiArgs.length === 0 ? {} : { extraPiArgs: options.extraPiArgs },
|
|
21067
|
+
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
20649
21068
|
},
|
|
20650
21069
|
{ role: options.role, seat: options.seat, principalAuthority }
|
|
20651
21070
|
);
|
|
@@ -20658,13 +21077,16 @@ async function createSummonEnv(options, afterHost) {
|
|
|
20658
21077
|
};
|
|
20659
21078
|
}
|
|
20660
21079
|
const hostName = seatWithModel.host ?? "pi";
|
|
20661
|
-
|
|
20662
|
-
|
|
20663
|
-
|
|
20664
|
-
|
|
20665
|
-
|
|
20666
|
-
|
|
20667
|
-
|
|
21080
|
+
let hostFacingSelection = options.hostFacingModel;
|
|
21081
|
+
if (hostFacingSelection === void 0) {
|
|
21082
|
+
const { loadHostProvidersTable: loadHostProvidersTable2, projectHostFacingProvider: projectHostFacingProvider2 } = await Promise.resolve().then(() => (init_host_providers(), host_providers_exports));
|
|
21083
|
+
hostFacingSelection = projectHostFacingProvider2(
|
|
21084
|
+
seatWithModel.selection,
|
|
21085
|
+
hostName,
|
|
21086
|
+
loadHostProvidersTable2(options.home),
|
|
21087
|
+
options.home
|
|
21088
|
+
);
|
|
21089
|
+
}
|
|
20668
21090
|
return {
|
|
20669
21091
|
ok: true,
|
|
20670
21092
|
env: {
|
|
@@ -20678,7 +21100,8 @@ async function createSummonEnv(options, afterHost) {
|
|
|
20678
21100
|
credentials: options.credentials,
|
|
20679
21101
|
...hostFacingSelection === void 0 ? {} : { model: hostFacingSelection },
|
|
20680
21102
|
...projectSeatEngine(seatWithModel),
|
|
20681
|
-
...projectSeatHost(seatWithModel)
|
|
21103
|
+
...projectSeatHost(seatWithModel),
|
|
21104
|
+
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
20682
21105
|
}
|
|
20683
21106
|
};
|
|
20684
21107
|
}
|
|
@@ -20693,7 +21116,19 @@ async function summonPublicRole(options) {
|
|
|
20693
21116
|
} = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
20694
21117
|
const credentials = options.credentials ?? await loadCredentialProviders2(agentDir);
|
|
20695
21118
|
const config = await loadPublicCliConfig2(home);
|
|
20696
|
-
const
|
|
21119
|
+
const resolvedSeat = resolveEffectiveSeat2(config, options.role, credentials);
|
|
21120
|
+
const inheritedSelection = options.model === void 0 ? void 0 : {
|
|
21121
|
+
provider: options.model.provider,
|
|
21122
|
+
model: options.model.model,
|
|
21123
|
+
...options.model.thinking === void 0 ? {} : { thinking: options.model.thinking }
|
|
21124
|
+
};
|
|
21125
|
+
const seat = {
|
|
21126
|
+
...resolvedSeat,
|
|
21127
|
+
...inheritedSelection === void 0 ? {} : { selection: inheritedSelection, source: "invocation" },
|
|
21128
|
+
...options.host === void 0 ? {} : { host: options.host, hostSource: "invocation" },
|
|
21129
|
+
...options.engine === void 0 ? {} : { engine: options.engine, engineSource: "invocation" },
|
|
21130
|
+
...options.engineModel === void 0 ? {} : { engineModel: options.engineModel }
|
|
21131
|
+
};
|
|
20697
21132
|
const captured = options.io === void 0 ? createCapturingIo() : void 0;
|
|
20698
21133
|
const io = options.io ?? captured.io;
|
|
20699
21134
|
const summonEnvInput = {
|
|
@@ -20706,7 +21141,11 @@ async function summonPublicRole(options) {
|
|
|
20706
21141
|
seat,
|
|
20707
21142
|
...options.extraPiArgs === void 0 ? {} : { extraPiArgs: options.extraPiArgs },
|
|
20708
21143
|
...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
|
|
20709
|
-
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters }
|
|
21144
|
+
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
21145
|
+
...options.principalAuthority === void 0 ? {} : { principalAuthority: options.principalAuthority },
|
|
21146
|
+
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs },
|
|
21147
|
+
// Parent model is already host-facing; child must not project again.
|
|
21148
|
+
...options.model === void 0 ? {} : { hostFacingModel: options.model }
|
|
20710
21149
|
};
|
|
20711
21150
|
async function prepareSummonEnv(afterHost) {
|
|
20712
21151
|
try {
|
|
@@ -20718,7 +21157,9 @@ async function summonPublicRole(options) {
|
|
|
20718
21157
|
ok: true,
|
|
20719
21158
|
env: {
|
|
20720
21159
|
...built.env,
|
|
20721
|
-
|
|
21160
|
+
// Nested court stations keep station-child semantics; dual-lens
|
|
21161
|
+
// ordinary Reviewer axes opt out (#946 / ADR 0082).
|
|
21162
|
+
...options.stationChild === false ? {} : { stationChild: true },
|
|
20722
21163
|
// Forward composition-root adapters so nested court stations (e.g.
|
|
20723
21164
|
// countersign → diarist) select the same faux/production table (#924).
|
|
20724
21165
|
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
@@ -20728,7 +21169,8 @@ async function summonPublicRole(options) {
|
|
|
20728
21169
|
...options.gateReviewInstruction === void 0 ? {} : { gateReviewInstruction: options.gateReviewInstruction },
|
|
20729
21170
|
...options.boundTicketNumber === void 0 ? {} : { boundTicketNumber: options.boundTicketNumber },
|
|
20730
21171
|
...options.correlationId === void 0 || options.correlationId.trim() === "" ? {} : { correlationId: options.correlationId },
|
|
20731
|
-
...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
|
|
21172
|
+
...options.createRunId === void 0 ? {} : { createRunId: options.createRunId },
|
|
21173
|
+
...options.executionCwd === void 0 ? {} : { executionCwd: options.executionCwd }
|
|
20732
21174
|
}
|
|
20733
21175
|
};
|
|
20734
21176
|
} catch (error) {
|
|
@@ -20840,6 +21282,16 @@ async function summonPublicRole(options) {
|
|
|
20840
21282
|
result = stepped.ok;
|
|
20841
21283
|
break;
|
|
20842
21284
|
}
|
|
21285
|
+
case "reviewer": {
|
|
21286
|
+
const [{ runPublicReviewer: runPublicReviewer2 }, { parseReviewerArgv: parseReviewerArgv2 }] = await Promise.all([
|
|
21287
|
+
Promise.resolve().then(() => (init_reviewer_run(), reviewer_run_exports)),
|
|
21288
|
+
Promise.resolve().then(() => (init_invocation(), invocation_exports))
|
|
21289
|
+
]);
|
|
21290
|
+
const stepped = await runPrepared(parseReviewerArgv2, (env, once) => runPublicReviewer2(options.argv, env, io, once));
|
|
21291
|
+
if ("fail" in stepped) return stepped.fail;
|
|
21292
|
+
result = stepped.ok;
|
|
21293
|
+
break;
|
|
21294
|
+
}
|
|
20843
21295
|
}
|
|
20844
21296
|
const stderr = captured?.stderrText();
|
|
20845
21297
|
const runDirectory = result.admitted?.runDirectory;
|
|
@@ -20851,6 +21303,296 @@ async function summonPublicRole(options) {
|
|
|
20851
21303
|
...stderr === void 0 || stderr === "" ? {} : { stderr }
|
|
20852
21304
|
};
|
|
20853
21305
|
}
|
|
21306
|
+
function withReviewerLens(argv, lens) {
|
|
21307
|
+
const separator = argv.indexOf("--");
|
|
21308
|
+
if (separator === -1) return [...argv, "--lens", lens];
|
|
21309
|
+
return [...argv.slice(0, separator), "--lens", lens, ...argv.slice(separator)];
|
|
21310
|
+
}
|
|
21311
|
+
async function resolveReviewerWorktreeRoots(projectRoot) {
|
|
21312
|
+
const callerProjectRoot = await realpath6(projectRoot);
|
|
21313
|
+
const sourceProjectRoot = await realpath6((await execFileAsync3(
|
|
21314
|
+
"git",
|
|
21315
|
+
["rev-parse", "--show-toplevel"],
|
|
21316
|
+
{ cwd: callerProjectRoot }
|
|
21317
|
+
)).stdout.trim());
|
|
21318
|
+
const callerRelative = relative3(sourceProjectRoot, callerProjectRoot);
|
|
21319
|
+
const projectRelative = callerRelative === "" || callerRelative === "." || callerRelative.startsWith(`..${sep5}`) || callerRelative === ".." ? "" : callerRelative;
|
|
21320
|
+
return { callerProjectRoot, sourceProjectRoot, projectRelative };
|
|
21321
|
+
}
|
|
21322
|
+
function reviewerSandboxPath(worktreeAxis, projectRelative) {
|
|
21323
|
+
return projectRelative === "" ? worktreeAxis : join35(worktreeAxis, projectRelative);
|
|
21324
|
+
}
|
|
21325
|
+
async function openEphemeralReviewerWorktree(options) {
|
|
21326
|
+
const { sourceProjectRoot, projectRelative } = await resolveReviewerWorktreeRoots(
|
|
21327
|
+
options.projectRoot
|
|
21328
|
+
);
|
|
21329
|
+
const { stdout: headStdout } = await execFileAsync3(
|
|
21330
|
+
"git",
|
|
21331
|
+
["rev-parse", "--verify", "HEAD^{commit}"],
|
|
21332
|
+
{ cwd: sourceProjectRoot }
|
|
21333
|
+
);
|
|
21334
|
+
const targetCommit = headStdout.trim();
|
|
21335
|
+
const root = await mkdtemp4(join35(tmpdir4(), "ak-reviewer-sandbox-"));
|
|
21336
|
+
const worktreeRoot = join35(root, "work");
|
|
21337
|
+
let registered = false;
|
|
21338
|
+
const rollback = async (cause) => {
|
|
21339
|
+
const cleanupErrors = [];
|
|
21340
|
+
if (registered) {
|
|
21341
|
+
try {
|
|
21342
|
+
await execFileAsync3("git", ["worktree", "remove", "--force", worktreeRoot], {
|
|
21343
|
+
cwd: sourceProjectRoot
|
|
21344
|
+
});
|
|
21345
|
+
} catch (error) {
|
|
21346
|
+
cleanupErrors.push(error);
|
|
21347
|
+
}
|
|
21348
|
+
}
|
|
21349
|
+
try {
|
|
21350
|
+
await rm4(root, { recursive: true, force: true });
|
|
21351
|
+
} catch (error) {
|
|
21352
|
+
cleanupErrors.push(error);
|
|
21353
|
+
}
|
|
21354
|
+
if (cleanupErrors.length > 0) {
|
|
21355
|
+
options.onCleanupDiagnostic?.([
|
|
21356
|
+
"reviewer worktree cleanup failed",
|
|
21357
|
+
...cleanupErrors.map((error) => error instanceof Error ? error.message : String(error))
|
|
21358
|
+
].join("\n"));
|
|
21359
|
+
}
|
|
21360
|
+
throw cause;
|
|
21361
|
+
};
|
|
21362
|
+
try {
|
|
21363
|
+
await execFileAsync3("git", ["worktree", "add", "--detach", worktreeRoot, targetCommit], {
|
|
21364
|
+
cwd: sourceProjectRoot
|
|
21365
|
+
});
|
|
21366
|
+
registered = true;
|
|
21367
|
+
if (projectRelative !== "") {
|
|
21368
|
+
await mkdir5(reviewerSandboxPath(worktreeRoot, projectRelative), { recursive: true });
|
|
21369
|
+
}
|
|
21370
|
+
} catch (error) {
|
|
21371
|
+
await rollback(error);
|
|
21372
|
+
}
|
|
21373
|
+
let closed = false;
|
|
21374
|
+
return {
|
|
21375
|
+
executionCwd: reviewerSandboxPath(worktreeRoot, projectRelative),
|
|
21376
|
+
close: async () => {
|
|
21377
|
+
if (closed) return;
|
|
21378
|
+
closed = true;
|
|
21379
|
+
const cleanupErrors = [];
|
|
21380
|
+
try {
|
|
21381
|
+
await execFileAsync3("git", ["worktree", "remove", worktreeRoot], {
|
|
21382
|
+
cwd: sourceProjectRoot
|
|
21383
|
+
});
|
|
21384
|
+
} catch (error) {
|
|
21385
|
+
cleanupErrors.push(error);
|
|
21386
|
+
}
|
|
21387
|
+
try {
|
|
21388
|
+
await rm4(root, { recursive: true, force: true });
|
|
21389
|
+
} catch (error) {
|
|
21390
|
+
cleanupErrors.push(error);
|
|
21391
|
+
}
|
|
21392
|
+
if (cleanupErrors.length > 0) {
|
|
21393
|
+
options.onCleanupDiagnostic?.([
|
|
21394
|
+
"reviewer worktree cleanup failed",
|
|
21395
|
+
...cleanupErrors.map((error) => error instanceof Error ? error.message : String(error))
|
|
21396
|
+
].join("\n"));
|
|
21397
|
+
}
|
|
21398
|
+
}
|
|
21399
|
+
};
|
|
21400
|
+
}
|
|
21401
|
+
async function withEphemeralReviewerWorktree(options) {
|
|
21402
|
+
const sandbox = await openEphemeralReviewerWorktree({
|
|
21403
|
+
projectRoot: options.projectRoot,
|
|
21404
|
+
...options.onCleanupDiagnostic === void 0 ? {} : { onCleanupDiagnostic: options.onCleanupDiagnostic }
|
|
21405
|
+
});
|
|
21406
|
+
try {
|
|
21407
|
+
return await options.run(sandbox.executionCwd);
|
|
21408
|
+
} finally {
|
|
21409
|
+
await sandbox.close();
|
|
21410
|
+
}
|
|
21411
|
+
}
|
|
21412
|
+
async function summonParallelReviewerLenses(options) {
|
|
21413
|
+
const describeFailure = (error) => {
|
|
21414
|
+
if (error instanceof AggregateError) {
|
|
21415
|
+
return [error.message, ...error.errors.map(describeFailure)].join("\n");
|
|
21416
|
+
}
|
|
21417
|
+
return error instanceof Error ? error.message : String(error);
|
|
21418
|
+
};
|
|
21419
|
+
const failedResult = (error) => ({
|
|
21420
|
+
exitCode: 1,
|
|
21421
|
+
stderr: describeFailure(error)
|
|
21422
|
+
});
|
|
21423
|
+
const dualFailure = (error) => {
|
|
21424
|
+
const failure2 = failedResult(error);
|
|
21425
|
+
return { completeness: failure2, correctness: failure2 };
|
|
21426
|
+
};
|
|
21427
|
+
let sourceProjectRoot;
|
|
21428
|
+
let projectRelative;
|
|
21429
|
+
let targetCommit;
|
|
21430
|
+
const statusArgs = [
|
|
21431
|
+
"status",
|
|
21432
|
+
"--porcelain=v1",
|
|
21433
|
+
"--untracked-files=all",
|
|
21434
|
+
"--",
|
|
21435
|
+
":/",
|
|
21436
|
+
":(top,exclude).claude/worktrees/**"
|
|
21437
|
+
];
|
|
21438
|
+
try {
|
|
21439
|
+
const roots = await resolveReviewerWorktreeRoots(options.projectRoot);
|
|
21440
|
+
sourceProjectRoot = roots.sourceProjectRoot;
|
|
21441
|
+
projectRelative = roots.projectRelative;
|
|
21442
|
+
const { stdout: statusStdout } = await execFileAsync3("git", statusArgs, {
|
|
21443
|
+
cwd: sourceProjectRoot
|
|
21444
|
+
});
|
|
21445
|
+
if (statusStdout !== "") {
|
|
21446
|
+
const diagnostic = [
|
|
21447
|
+
"Reviewer target status gate failed:",
|
|
21448
|
+
"git status --porcelain=v1 --untracked-files=all -- :/ ':(top,exclude).claude/worktrees/**'",
|
|
21449
|
+
statusStdout
|
|
21450
|
+
].join("\n");
|
|
21451
|
+
return dualFailure(new Error(diagnostic));
|
|
21452
|
+
}
|
|
21453
|
+
const { stdout: targetStdout } = await execFileAsync3(
|
|
21454
|
+
"git",
|
|
21455
|
+
["rev-parse", "--verify", "HEAD^{commit}"],
|
|
21456
|
+
{ cwd: sourceProjectRoot }
|
|
21457
|
+
);
|
|
21458
|
+
targetCommit = targetStdout.trim();
|
|
21459
|
+
await execFileAsync3(
|
|
21460
|
+
"git",
|
|
21461
|
+
["rev-parse", "--verify", `${options.baseRevision}^{commit}`],
|
|
21462
|
+
{ cwd: sourceProjectRoot }
|
|
21463
|
+
);
|
|
21464
|
+
} catch (error) {
|
|
21465
|
+
return dualFailure(error);
|
|
21466
|
+
}
|
|
21467
|
+
const root = await mkdtemp4(join35(tmpdir4(), "ak-reviewer-lenses-"));
|
|
21468
|
+
const completenessRoot = join35(root, "completeness");
|
|
21469
|
+
const correctnessRoot = join35(root, "correctness");
|
|
21470
|
+
const worktrees = [completenessRoot, correctnessRoot];
|
|
21471
|
+
const created = /* @__PURE__ */ new Set();
|
|
21472
|
+
let results;
|
|
21473
|
+
const creation = await Promise.allSettled(
|
|
21474
|
+
worktrees.map(async (path) => {
|
|
21475
|
+
await execFileAsync3("git", ["worktree", "add", "--detach", path, targetCommit], {
|
|
21476
|
+
cwd: sourceProjectRoot
|
|
21477
|
+
});
|
|
21478
|
+
created.add(path);
|
|
21479
|
+
if (projectRelative !== "") {
|
|
21480
|
+
await mkdir5(reviewerSandboxPath(path, projectRelative), { recursive: true });
|
|
21481
|
+
}
|
|
21482
|
+
})
|
|
21483
|
+
);
|
|
21484
|
+
const creationFailures = creation.flatMap((result) => result.status === "rejected" ? [result.reason] : []);
|
|
21485
|
+
if (creationFailures.length > 0) {
|
|
21486
|
+
const failure2 = failedResult(new AggregateError(
|
|
21487
|
+
creationFailures,
|
|
21488
|
+
"parallel reviewer worktree creation failed"
|
|
21489
|
+
));
|
|
21490
|
+
results = { completeness: failure2, correctness: failure2 };
|
|
21491
|
+
} else {
|
|
21492
|
+
const summon = (lens, worktreeAxis) => {
|
|
21493
|
+
const sandbox = reviewerSandboxPath(worktreeAxis, projectRelative);
|
|
21494
|
+
return summonPublicRole({
|
|
21495
|
+
role: "reviewer",
|
|
21496
|
+
argv: withReviewerLens(options.argv, lens),
|
|
21497
|
+
cwd: options.cwd,
|
|
21498
|
+
executionCwd: sandbox,
|
|
21499
|
+
// Ordinary single-axis public semantics — not a nested court station.
|
|
21500
|
+
stationChild: false,
|
|
21501
|
+
home: options.home,
|
|
21502
|
+
...options.agentDir === void 0 ? {} : { agentDir: options.agentDir },
|
|
21503
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
21504
|
+
...options.model === void 0 ? {} : { model: options.model },
|
|
21505
|
+
...options.host === void 0 ? {} : { host: options.host },
|
|
21506
|
+
...options.engine === void 0 ? {} : { engine: options.engine },
|
|
21507
|
+
...options.engineModel === void 0 ? {} : { engineModel: options.engineModel },
|
|
21508
|
+
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
21509
|
+
...options.correlationId === void 0 ? {} : { correlationId: options.correlationId },
|
|
21510
|
+
...options.packageRoot === void 0 ? {} : { packageRoot: options.packageRoot },
|
|
21511
|
+
...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
|
|
21512
|
+
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
21513
|
+
...options.principalAuthority === void 0 ? {} : { principalAuthority: options.principalAuthority },
|
|
21514
|
+
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
21515
|
+
});
|
|
21516
|
+
};
|
|
21517
|
+
const settled = await Promise.allSettled([
|
|
21518
|
+
summon("completeness", completenessRoot),
|
|
21519
|
+
summon("correctness", correctnessRoot)
|
|
21520
|
+
]);
|
|
21521
|
+
results = {
|
|
21522
|
+
completeness: settled[0].status === "fulfilled" ? settled[0].value : failedResult(settled[0].reason),
|
|
21523
|
+
correctness: settled[1].status === "fulfilled" ? settled[1].value : failedResult(settled[1].reason)
|
|
21524
|
+
};
|
|
21525
|
+
}
|
|
21526
|
+
let sealDiagnostic;
|
|
21527
|
+
try {
|
|
21528
|
+
const { stdout: headBeforeStdout } = await execFileAsync3(
|
|
21529
|
+
"git",
|
|
21530
|
+
["rev-parse", "--verify", "HEAD^{commit}"],
|
|
21531
|
+
{ cwd: sourceProjectRoot }
|
|
21532
|
+
);
|
|
21533
|
+
const { stdout: sealedStatusStdout } = await execFileAsync3("git", statusArgs, {
|
|
21534
|
+
cwd: sourceProjectRoot
|
|
21535
|
+
});
|
|
21536
|
+
const { stdout: headAfterStdout } = await execFileAsync3(
|
|
21537
|
+
"git",
|
|
21538
|
+
["rev-parse", "--verify", "HEAD^{commit}"],
|
|
21539
|
+
{ cwd: sourceProjectRoot }
|
|
21540
|
+
);
|
|
21541
|
+
const headBefore = headBeforeStdout.trim();
|
|
21542
|
+
const headAfter = headAfterStdout.trim();
|
|
21543
|
+
if (headBefore !== targetCommit || headAfter !== targetCommit || sealedStatusStdout !== "") {
|
|
21544
|
+
sealDiagnostic = [
|
|
21545
|
+
"Reviewer target final seal failed:",
|
|
21546
|
+
`HEAD before status => ${headBefore}`,
|
|
21547
|
+
`HEAD after status => ${headAfter}`,
|
|
21548
|
+
`expected PRE_HEAD ${targetCommit}`,
|
|
21549
|
+
"git status --porcelain=v1 --untracked-files=all -- :/ ':(top,exclude).claude/worktrees/**'",
|
|
21550
|
+
sealedStatusStdout
|
|
21551
|
+
].join("\n");
|
|
21552
|
+
}
|
|
21553
|
+
} catch (error) {
|
|
21554
|
+
sealDiagnostic = `Reviewer target final seal failed:
|
|
21555
|
+
${describeFailure(error)}`;
|
|
21556
|
+
}
|
|
21557
|
+
if (sealDiagnostic !== void 0) {
|
|
21558
|
+
const withSealFailure = (result) => ({
|
|
21559
|
+
...result,
|
|
21560
|
+
exitCode: 1,
|
|
21561
|
+
stderr: [result.stderr, sealDiagnostic].filter(
|
|
21562
|
+
(text) => typeof text === "string" && text !== ""
|
|
21563
|
+
).join("\n")
|
|
21564
|
+
});
|
|
21565
|
+
results = {
|
|
21566
|
+
completeness: withSealFailure(results.completeness),
|
|
21567
|
+
correctness: withSealFailure(results.correctness)
|
|
21568
|
+
};
|
|
21569
|
+
}
|
|
21570
|
+
const cleanup = await Promise.allSettled(
|
|
21571
|
+
[...created].map((path) => execFileAsync3("git", ["worktree", "remove", path], { cwd: sourceProjectRoot }))
|
|
21572
|
+
);
|
|
21573
|
+
const cleanupFailures = cleanup.flatMap((result) => result.status === "rejected" ? [result.reason] : []);
|
|
21574
|
+
if (cleanupFailures.length === 0) {
|
|
21575
|
+
const rootCleanup = await Promise.allSettled([rm4(root, { recursive: true, force: true })]);
|
|
21576
|
+
cleanupFailures.push(...rootCleanup.flatMap((result) => result.status === "rejected" ? [result.reason] : []));
|
|
21577
|
+
}
|
|
21578
|
+
if (cleanupFailures.length > 0) {
|
|
21579
|
+
const diagnostic = [
|
|
21580
|
+
"parallel reviewer worktree cleanup failed",
|
|
21581
|
+
...cleanupFailures.map((failure2) => failure2 instanceof Error ? failure2.message : String(failure2))
|
|
21582
|
+
].join("\n");
|
|
21583
|
+
const withCleanupDiagnostic = (result) => ({
|
|
21584
|
+
...result,
|
|
21585
|
+
stderr: [result.stderr, diagnostic].filter(
|
|
21586
|
+
(text) => typeof text === "string" && text !== ""
|
|
21587
|
+
).join("\n")
|
|
21588
|
+
});
|
|
21589
|
+
results = {
|
|
21590
|
+
completeness: withCleanupDiagnostic(results.completeness),
|
|
21591
|
+
correctness: withCleanupDiagnostic(results.correctness)
|
|
21592
|
+
};
|
|
21593
|
+
}
|
|
21594
|
+
return results;
|
|
21595
|
+
}
|
|
20854
21596
|
async function summonGateOfficer(options) {
|
|
20855
21597
|
let home = options.home;
|
|
20856
21598
|
if (home === void 0) {
|
|
@@ -20900,12 +21642,13 @@ async function summonGateOfficer(options) {
|
|
|
20900
21642
|
...common
|
|
20901
21643
|
});
|
|
20902
21644
|
}
|
|
20903
|
-
var AK_ROLE_PACKAGE_ROOT_ENV;
|
|
21645
|
+
var AK_ROLE_PACKAGE_ROOT_ENV, execFileAsync3;
|
|
20904
21646
|
var init_public_role_summons = __esm({
|
|
20905
21647
|
"src/public-role-summons.ts"() {
|
|
20906
21648
|
"use strict";
|
|
20907
21649
|
init_engine_material();
|
|
20908
21650
|
AK_ROLE_PACKAGE_ROOT_ENV = "AK_ROLE_PACKAGE_ROOT";
|
|
21651
|
+
execFileAsync3 = promisify3(execFile3);
|
|
20909
21652
|
}
|
|
20910
21653
|
});
|
|
20911
21654
|
|
|
@@ -20915,7 +21658,7 @@ import { randomUUID as randomUUID9 } from "node:crypto";
|
|
|
20915
21658
|
// src/role-envelope.ts
|
|
20916
21659
|
init_engine_detour();
|
|
20917
21660
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
20918
|
-
import { mkdir as
|
|
21661
|
+
import { mkdir as mkdir7, writeFile as writeFile12 } from "node:fs/promises";
|
|
20919
21662
|
import { createServer } from "node:net";
|
|
20920
21663
|
import { dirname as dirname22, join as join41 } from "node:path";
|
|
20921
21664
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
@@ -21003,7 +21746,7 @@ async function requireGatekeeperPass(options) {
|
|
|
21003
21746
|
}
|
|
21004
21747
|
|
|
21005
21748
|
// src/host-native-method.ts
|
|
21006
|
-
import { lstat as lstat7, mkdir as
|
|
21749
|
+
import { lstat as lstat7, mkdir as mkdir6, readlink, realpath as realpath7, symlink } from "node:fs/promises";
|
|
21007
21750
|
import { basename as basename9, dirname as dirname18, join as join36 } from "node:path";
|
|
21008
21751
|
var packagedMethodsDir = (root) => join36(root, "resources", "methods");
|
|
21009
21752
|
function hostMethodSkills(methods) {
|
|
@@ -21014,11 +21757,11 @@ function hostMethodSkills(methods) {
|
|
|
21014
21757
|
}));
|
|
21015
21758
|
}
|
|
21016
21759
|
async function installWorkspaceMethodSkills(cwd, packageRoot) {
|
|
21017
|
-
const target = await
|
|
21760
|
+
const target = await realpath7(packagedMethodsDir(packageRoot));
|
|
21018
21761
|
const link = join36(cwd, ".agents", "skills");
|
|
21019
21762
|
try {
|
|
21020
21763
|
const stat2 = await lstat7(link);
|
|
21021
|
-
if (!stat2.isSymbolicLink() || await
|
|
21764
|
+
if (!stat2.isSymbolicLink() || await realpath7(link) !== target) {
|
|
21022
21765
|
const detail = stat2.isSymbolicLink() ? `symlink to ${await readlink(link)}` : "non-symlink entry";
|
|
21023
21766
|
throw new Error(`workspace method catalog conflict at ${link}: ${detail}`);
|
|
21024
21767
|
}
|
|
@@ -21026,12 +21769,12 @@ async function installWorkspaceMethodSkills(cwd, packageRoot) {
|
|
|
21026
21769
|
} catch (error) {
|
|
21027
21770
|
if (error.code !== "ENOENT") throw error;
|
|
21028
21771
|
}
|
|
21029
|
-
await
|
|
21772
|
+
await mkdir6(dirname18(link), { recursive: true });
|
|
21030
21773
|
try {
|
|
21031
21774
|
await symlink(target, link);
|
|
21032
21775
|
} catch (error) {
|
|
21033
21776
|
if (error.code !== "EEXIST") throw error;
|
|
21034
|
-
if (await
|
|
21777
|
+
if (await realpath7(link).catch(() => "") !== target) {
|
|
21035
21778
|
throw new Error(`workspace method catalog conflict at ${link}`);
|
|
21036
21779
|
}
|
|
21037
21780
|
}
|
|
@@ -21096,7 +21839,7 @@ import {
|
|
|
21096
21839
|
openSync as openSync2,
|
|
21097
21840
|
writeSync
|
|
21098
21841
|
} from "node:fs";
|
|
21099
|
-
import { dirname as dirname19, isAbsolute as isAbsolute10, resolve as
|
|
21842
|
+
import { dirname as dirname19, isAbsolute as isAbsolute10, resolve as resolve16 } from "node:path";
|
|
21100
21843
|
|
|
21101
21844
|
// src/activation-ledger-session.ts
|
|
21102
21845
|
init_activation_ledger_topology();
|
|
@@ -21106,7 +21849,7 @@ import {
|
|
|
21106
21849
|
statSync as statSync4,
|
|
21107
21850
|
writeFileSync as writeFileSync3
|
|
21108
21851
|
} from "node:fs";
|
|
21109
|
-
import { isAbsolute as isAbsolute9, resolve as
|
|
21852
|
+
import { isAbsolute as isAbsolute9, resolve as resolve15 } from "node:path";
|
|
21110
21853
|
var ActivationSessionFileMissingError = class extends Error {
|
|
21111
21854
|
code = "AK_ACTIVATION_SESSION_FILE_MISSING";
|
|
21112
21855
|
path;
|
|
@@ -21151,7 +21894,7 @@ function durableSessionPointer(sessionManager) {
|
|
|
21151
21894
|
`Workflow role activation requires an absolute durable session file path; got relative path: ${file}`
|
|
21152
21895
|
);
|
|
21153
21896
|
}
|
|
21154
|
-
const resolvedFile =
|
|
21897
|
+
const resolvedFile = resolve15(file);
|
|
21155
21898
|
try {
|
|
21156
21899
|
lstatSync2(resolvedFile);
|
|
21157
21900
|
} catch (error) {
|
|
@@ -21243,8 +21986,8 @@ function appendActivationLedgerLine(ledgerPath, line2, options) {
|
|
|
21243
21986
|
`activation ledger home must be absolute: ${options.ledgerHome}`
|
|
21244
21987
|
);
|
|
21245
21988
|
}
|
|
21246
|
-
const resolvedLedger =
|
|
21247
|
-
const resolvedHome =
|
|
21989
|
+
const resolvedLedger = resolve16(ledgerPath);
|
|
21990
|
+
const resolvedHome = resolve16(options.ledgerHome);
|
|
21248
21991
|
const parent = dirname19(resolvedLedger);
|
|
21249
21992
|
ensureRealDirectoryTree(resolvedHome, parent);
|
|
21250
21993
|
assertLedgerFileInsideHome(resolvedLedger, resolvedHome);
|
|
@@ -21605,11 +22348,11 @@ init_collector_github();
|
|
|
21605
22348
|
|
|
21606
22349
|
// src/collector-handbook.ts
|
|
21607
22350
|
import { readFile as readFile19 } from "node:fs/promises";
|
|
21608
|
-
import { join as join38, sep as
|
|
22351
|
+
import { join as join38, sep as sep6 } from "node:path";
|
|
21609
22352
|
|
|
21610
22353
|
// src/atomic-write.ts
|
|
21611
22354
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
21612
|
-
import { rename as rename3, rm as
|
|
22355
|
+
import { rename as rename3, rm as rm5, writeFile as writeFile11 } from "node:fs/promises";
|
|
21613
22356
|
import { dirname as dirname20, join as join37 } from "node:path";
|
|
21614
22357
|
async function writeFileAtomically(destination, contents) {
|
|
21615
22358
|
const parent = dirname20(destination);
|
|
@@ -21618,7 +22361,7 @@ async function writeFileAtomically(destination, contents) {
|
|
|
21618
22361
|
await writeFile11(temporary, contents);
|
|
21619
22362
|
await rename3(temporary, destination);
|
|
21620
22363
|
} catch (error) {
|
|
21621
|
-
await
|
|
22364
|
+
await rm5(temporary, { force: true }).catch(() => void 0);
|
|
21622
22365
|
throw error;
|
|
21623
22366
|
}
|
|
21624
22367
|
}
|
|
@@ -21719,7 +22462,7 @@ function resolveCollectorHandbookRoot(sessionPath) {
|
|
|
21719
22462
|
if (typeof sessionPath !== "string" || sessionPath.trim().length === 0) {
|
|
21720
22463
|
throw new Error("\u901A\u8FDB\u53F8\u624B\u518C\u8981\u6C42\u975E\u7A7A session \u8DEF\u5F84\uFF0C\u4E14\u4F4D\u4E8E books/<bookKey>/");
|
|
21721
22464
|
}
|
|
21722
|
-
const segments = sessionPath.split(
|
|
22465
|
+
const segments = sessionPath.split(sep6);
|
|
21723
22466
|
let bookKey;
|
|
21724
22467
|
for (let i = 0; i + 3 < segments.length; i += 1) {
|
|
21725
22468
|
if (segments[i] === ".ak-roles" && segments[i + 1] === "books") {
|
|
@@ -22916,7 +23659,7 @@ import { createHash as createHash9 } from "node:crypto";
|
|
|
22916
23659
|
init_navigator_invocation_identity();
|
|
22917
23660
|
init_packaged_role_registry();
|
|
22918
23661
|
init_activation_ledger_topology();
|
|
22919
|
-
import { resolve as
|
|
23662
|
+
import { resolve as resolve17 } from "node:path";
|
|
22920
23663
|
import "@earendil-works/pi-coding-agent";
|
|
22921
23664
|
import { Type as Type22 } from "typebox";
|
|
22922
23665
|
|
|
@@ -23369,7 +24112,7 @@ function navigatorSubjectKey(subjectRoot, subject, provenance = "role_input") {
|
|
|
23369
24112
|
}
|
|
23370
24113
|
function navigatorSubjectKeyForInput(subjectRoot, reference, cwd = process.cwd()) {
|
|
23371
24114
|
if (issueRoot(subjectRoot) !== void 0 || !subjectRoot.includes("/.ak/work/")) return subjectRoot;
|
|
23372
|
-
const resolvedReference =
|
|
24115
|
+
const resolvedReference = resolve17(cwd, reference);
|
|
23373
24116
|
const marker = "/runs/";
|
|
23374
24117
|
if (resolvedReference.includes(marker)) {
|
|
23375
24118
|
return subjectRoot;
|
|
@@ -24010,7 +24753,7 @@ var reviewerAmendmentsSchema = Type24.Object({
|
|
|
24010
24753
|
}))
|
|
24011
24754
|
}, {
|
|
24012
24755
|
additionalProperties: true,
|
|
24013
|
-
description: "\
|
|
24756
|
+
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"
|
|
24014
24757
|
});
|
|
24015
24758
|
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";
|
|
24016
24759
|
var reviewerOutputVariants = Type24.Union([
|
|
@@ -24086,7 +24829,7 @@ init_submission_errors();
|
|
|
24086
24829
|
init_submission_errors();
|
|
24087
24830
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
24088
24831
|
import { existsSync as existsSync12, lstatSync as lstatSync3, readdirSync as readdirSync3, readFileSync as readFileSync5, rmdirSync, rmSync } from "node:fs";
|
|
24089
|
-
import { resolve as
|
|
24832
|
+
import { resolve as resolve18 } from "node:path";
|
|
24090
24833
|
var WORKER_SUBMISSION_GATE_RECORD_KIND = WORKER_SUBMISSION_GATE_KIND;
|
|
24091
24834
|
var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
|
|
24092
24835
|
var WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE = "commit-reminder-bounce";
|
|
@@ -24135,7 +24878,7 @@ function escapeGitConfigValueRegex(value) {
|
|
|
24135
24878
|
function unsetOwnedHooksPath(file) {
|
|
24136
24879
|
const owned = [];
|
|
24137
24880
|
for (const value of tryGetAll(file, "core.hooksPath")) {
|
|
24138
|
-
if (!ownedHook(
|
|
24881
|
+
if (!ownedHook(resolve18(value, HOOK_FILE))) continue;
|
|
24139
24882
|
try {
|
|
24140
24883
|
gitFile(file, [
|
|
24141
24884
|
"--unset-all",
|
|
@@ -24150,15 +24893,15 @@ function unsetOwnedHooksPath(file) {
|
|
|
24150
24893
|
return owned;
|
|
24151
24894
|
}
|
|
24152
24895
|
function rmOwnedDir(dir) {
|
|
24153
|
-
const hookPath =
|
|
24896
|
+
const hookPath = resolve18(dir, HOOK_FILE);
|
|
24154
24897
|
if (!ownedHook(hookPath)) return;
|
|
24155
24898
|
rmSync(hookPath, { force: true });
|
|
24156
24899
|
if (existsSync12(dir) && readdirSync3(dir).length === 0) rmdirSync(dir);
|
|
24157
24900
|
}
|
|
24158
24901
|
function linkedGitDirs(commonDir) {
|
|
24159
|
-
const root =
|
|
24902
|
+
const root = resolve18(commonDir, "worktrees");
|
|
24160
24903
|
if (!existsSync12(root)) return [];
|
|
24161
|
-
return readdirSync3(root).map((name) =>
|
|
24904
|
+
return readdirSync3(root).map((name) => resolve18(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
|
|
24162
24905
|
}
|
|
24163
24906
|
function uninstallPackageWorkerHooks(cwd) {
|
|
24164
24907
|
let inside;
|
|
@@ -24172,14 +24915,14 @@ function uninstallPackageWorkerHooks(cwd) {
|
|
|
24172
24915
|
const clear = (configFile) => {
|
|
24173
24916
|
for (const hooks of unsetOwnedHooksPath(configFile)) rmOwnedDir(hooks);
|
|
24174
24917
|
};
|
|
24175
|
-
clear(
|
|
24176
|
-
clear(
|
|
24177
|
-
rmOwnedDir(
|
|
24178
|
-
const legacy =
|
|
24918
|
+
clear(resolve18(commonDir, "config"));
|
|
24919
|
+
clear(resolve18(commonDir, "config.worktree"));
|
|
24920
|
+
rmOwnedDir(resolve18(commonDir, HOOKS_DIR));
|
|
24921
|
+
const legacy = resolve18(commonDir, "hooks", HOOK_FILE);
|
|
24179
24922
|
if (ownedHook(legacy)) rmSync(legacy, { force: true });
|
|
24180
24923
|
for (const gitDir of linkedGitDirs(commonDir)) {
|
|
24181
|
-
clear(
|
|
24182
|
-
rmOwnedDir(
|
|
24924
|
+
clear(resolve18(gitDir, "config.worktree"));
|
|
24925
|
+
rmOwnedDir(resolve18(gitDir, HOOKS_DIR));
|
|
24183
24926
|
}
|
|
24184
24927
|
}
|
|
24185
24928
|
function isRecord13(value) {
|
|
@@ -24224,11 +24967,11 @@ function reliableWindow(cwd, baseline, head) {
|
|
|
24224
24967
|
const raw = git2(cwd, ["log", "--format=%P%x1e%s", range]);
|
|
24225
24968
|
if (raw.length === 0) return [];
|
|
24226
24969
|
return raw.split("\n").flatMap((line2) => {
|
|
24227
|
-
const
|
|
24228
|
-
if (
|
|
24970
|
+
const sep7 = line2.indexOf("");
|
|
24971
|
+
if (sep7 < 0) return [];
|
|
24229
24972
|
return [{
|
|
24230
|
-
subject: line2.slice(
|
|
24231
|
-
merge: line2.slice(0,
|
|
24973
|
+
subject: line2.slice(sep7 + 1),
|
|
24974
|
+
merge: line2.slice(0, sep7).trim().includes(" ")
|
|
24232
24975
|
}];
|
|
24233
24976
|
});
|
|
24234
24977
|
}
|
|
@@ -24773,7 +25516,7 @@ var REVIEWER_TRANSPORT_FLAGS = Object.freeze([
|
|
|
24773
25516
|
Object.freeze({
|
|
24774
25517
|
name: "ak-review-lens",
|
|
24775
25518
|
definition: Object.freeze({
|
|
24776
|
-
description: "
|
|
25519
|
+
description: "Single review lens: completeness or correctness",
|
|
24777
25520
|
type: "string"
|
|
24778
25521
|
})
|
|
24779
25522
|
}),
|
|
@@ -26228,11 +26971,11 @@ init_role_activation_flags();
|
|
|
26228
26971
|
init_submission_correctable_error();
|
|
26229
26972
|
init_navigator_invocation_identity();
|
|
26230
26973
|
async function listen(server, path) {
|
|
26231
|
-
await new Promise((
|
|
26974
|
+
await new Promise((resolve22, reject) => {
|
|
26232
26975
|
server.once("error", reject);
|
|
26233
26976
|
server.listen(path, () => {
|
|
26234
26977
|
server.off("error", reject);
|
|
26235
|
-
|
|
26978
|
+
resolve22();
|
|
26236
26979
|
});
|
|
26237
26980
|
});
|
|
26238
26981
|
}
|
|
@@ -26266,9 +27009,9 @@ async function prepareRoleEnvelope(options) {
|
|
|
26266
27009
|
let infrastructureRoundFailure;
|
|
26267
27010
|
const hostAbort = new AbortController();
|
|
26268
27011
|
const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID8();
|
|
26269
|
-
await
|
|
27012
|
+
await mkdir7(request.runDirectory, { recursive: true });
|
|
26270
27013
|
let sessionFile = options.sessionFile ?? join41(request.runDirectory, "session", "session.jsonl");
|
|
26271
|
-
await
|
|
27014
|
+
await mkdir7(dirname22(sessionFile), { recursive: true });
|
|
26272
27015
|
if (request.continuation.kind !== "resume") {
|
|
26273
27016
|
try {
|
|
26274
27017
|
await writeFile12(
|
|
@@ -26610,8 +27353,8 @@ async function prepareRoleEnvelope(options) {
|
|
|
26610
27353
|
try {
|
|
26611
27354
|
const closeAll = server.closeAllConnections;
|
|
26612
27355
|
if (typeof closeAll === "function") closeAll.call(server);
|
|
26613
|
-
await new Promise((
|
|
26614
|
-
server.close((error) => error ? reject(error) :
|
|
27356
|
+
await new Promise((resolve22, reject) => {
|
|
27357
|
+
server.close((error) => error ? reject(error) : resolve22());
|
|
26615
27358
|
});
|
|
26616
27359
|
} catch (error) {
|
|
26617
27360
|
cleanupFailures.push(error);
|
|
@@ -26743,9 +27486,9 @@ import { readFile as readFile22 } from "node:fs/promises";
|
|
|
26743
27486
|
import { join as join42 } from "node:path";
|
|
26744
27487
|
|
|
26745
27488
|
// src/canonical-skill-binding.ts
|
|
26746
|
-
import { readFile as readFile20, realpath as
|
|
27489
|
+
import { readFile as readFile20, realpath as realpath8 } from "node:fs/promises";
|
|
26747
27490
|
import { homedir } from "node:os";
|
|
26748
|
-
import { dirname as dirname23, resolve as
|
|
27491
|
+
import { dirname as dirname23, resolve as resolve19 } from "node:path";
|
|
26749
27492
|
import { stripFrontmatter } from "@earendil-works/pi-coding-agent";
|
|
26750
27493
|
function captureCanonicalSkillExpansion(name, snapshot, configuredPath, evidence, originalRequest) {
|
|
26751
27494
|
const matchedPath = evidence?.location === configuredPath ? configuredPath : evidence?.location === snapshot.path ? snapshot.path : void 0;
|
|
@@ -26768,14 +27511,14 @@ var CanonicalSkillUnavailableError = class extends Error {
|
|
|
26768
27511
|
code = "canonical-skill-unavailable";
|
|
26769
27512
|
};
|
|
26770
27513
|
async function loadCanonicalSkillBinding(name) {
|
|
26771
|
-
const configuredPath =
|
|
27514
|
+
const configuredPath = resolve19(
|
|
26772
27515
|
homedir(),
|
|
26773
27516
|
`.agents/skills/${name}/SKILL.md`
|
|
26774
27517
|
);
|
|
26775
27518
|
let path;
|
|
26776
27519
|
let raw;
|
|
26777
27520
|
try {
|
|
26778
|
-
path = await
|
|
27521
|
+
path = await realpath8(configuredPath);
|
|
26779
27522
|
raw = await readFile20(path, "utf8");
|
|
26780
27523
|
} catch (error) {
|
|
26781
27524
|
throw new CanonicalSkillUnavailableError(name, configuredPath, error);
|
|
@@ -26816,7 +27559,7 @@ init_doctor_evidence();
|
|
|
26816
27559
|
init_doctor_evidence();
|
|
26817
27560
|
init_host_contracts();
|
|
26818
27561
|
import { readFile as readFile21 } from "node:fs/promises";
|
|
26819
|
-
import { resolve as
|
|
27562
|
+
import { resolve as resolve20 } from "node:path";
|
|
26820
27563
|
init_notary_source_run();
|
|
26821
27564
|
init_packaged_role_registry();
|
|
26822
27565
|
init_invocation();
|
|
@@ -26824,7 +27567,7 @@ function navigatorInputReference(getFlag, role) {
|
|
|
26824
27567
|
if (getFlag === void 0) return void 0;
|
|
26825
27568
|
const name = packagedRoleInputFlag(role);
|
|
26826
27569
|
const value = name === void 0 ? void 0 : getFlag(name);
|
|
26827
|
-
return typeof value === "string" && value !== "" ?
|
|
27570
|
+
return typeof value === "string" && value !== "" ? resolve20(value) : void 0;
|
|
26828
27571
|
}
|
|
26829
27572
|
async function loadNavigatorWorkContext(options) {
|
|
26830
27573
|
const reference = navigatorInputReference(options.getFlag, options.role);
|
|
@@ -26845,7 +27588,7 @@ async function loadNavigatorWorkContext(options) {
|
|
|
26845
27588
|
}
|
|
26846
27589
|
const publicRunDir = runDirectoryFromHostContext(options.context);
|
|
26847
27590
|
const currentSessionDir = options.context.sessionManager.getSessionDir();
|
|
26848
|
-
const isBoundPublicRun = publicRunDir !== void 0 &&
|
|
27591
|
+
const isBoundPublicRun = publicRunDir !== void 0 && resolve20(currentSessionDir) === resolve20(publicRunDir, "session");
|
|
26849
27592
|
if (options.role === "judge" && isBoundPublicRun) {
|
|
26850
27593
|
let admitted;
|
|
26851
27594
|
try {
|
|
@@ -26878,9 +27621,9 @@ async function loadNavigatorWorkContext(options) {
|
|
|
26878
27621
|
}
|
|
26879
27622
|
const workRoot = subjectRoot.includes("/.ak/work/") ? subjectRoot : void 0;
|
|
26880
27623
|
const authorityFiles = workRoot === void 0 ? [] : [
|
|
26881
|
-
|
|
26882
|
-
|
|
26883
|
-
|
|
27624
|
+
resolve20(workRoot, "authority.md"),
|
|
27625
|
+
resolve20(workRoot, "authority.txt"),
|
|
27626
|
+
resolve20(workRoot, "design-v2/owner-direction.md")
|
|
26884
27627
|
];
|
|
26885
27628
|
let authorityMaterial;
|
|
26886
27629
|
for (const path of authorityFiles) {
|
|
@@ -27064,7 +27807,7 @@ function hostAbortedError(message = "host aborted") {
|
|
|
27064
27807
|
function raceAgainstHostAbort(work, abortSignal, message = "host aborted") {
|
|
27065
27808
|
if (abortSignal?.aborted) return Promise.reject(hostAbortedError(message));
|
|
27066
27809
|
if (abortSignal === void 0) return work;
|
|
27067
|
-
return new Promise((
|
|
27810
|
+
return new Promise((resolve22, reject) => {
|
|
27068
27811
|
let settled = false;
|
|
27069
27812
|
const onAbort = () => {
|
|
27070
27813
|
if (settled) return;
|
|
@@ -27079,7 +27822,7 @@ function raceAgainstHostAbort(work, abortSignal, message = "host aborted") {
|
|
|
27079
27822
|
if (settled) return;
|
|
27080
27823
|
settled = true;
|
|
27081
27824
|
abortSignal.removeEventListener("abort", onAbort);
|
|
27082
|
-
|
|
27825
|
+
resolve22(value);
|
|
27083
27826
|
},
|
|
27084
27827
|
(error) => {
|
|
27085
27828
|
if (settled) return;
|
|
@@ -27267,8 +28010,8 @@ function connectAcpStdio(options) {
|
|
|
27267
28010
|
request(method, params) {
|
|
27268
28011
|
if (closed) return Promise.reject(terminalError ?? acpError("acp-connection-closed", "ACP connection is closed"));
|
|
27269
28012
|
const id = ++nextId;
|
|
27270
|
-
return new Promise((
|
|
27271
|
-
pending.set(id, { resolve:
|
|
28013
|
+
return new Promise((resolve22, reject) => {
|
|
28014
|
+
pending.set(id, { resolve: resolve22, reject });
|
|
27272
28015
|
child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", id, method, params })}
|
|
27273
28016
|
`, (error) => {
|
|
27274
28017
|
if (error === null || error === void 0) return;
|
|
@@ -27295,7 +28038,7 @@ function connectAcpStdio(options) {
|
|
|
27295
28038
|
settleClosed(acpError("acp-connection-closed", "ACP connection is closed"));
|
|
27296
28039
|
child.stdin.end();
|
|
27297
28040
|
child.kill("SIGTERM");
|
|
27298
|
-
await new Promise((
|
|
28041
|
+
await new Promise((resolve22) => child.once("close", () => resolve22()));
|
|
27299
28042
|
}
|
|
27300
28043
|
});
|
|
27301
28044
|
}
|
|
@@ -27461,8 +28204,8 @@ function createAcpRoleTurnHost(config) {
|
|
|
27461
28204
|
|
|
27462
28205
|
// src/acp-host/seat-profile-soul.ts
|
|
27463
28206
|
import { constants as constants3 } from "node:fs";
|
|
27464
|
-
import { access as access4, copyFile, lstat as lstat8, mkdir as
|
|
27465
|
-
import { dirname as dirname25, join as join44, relative as
|
|
28207
|
+
import { access as access4, copyFile, lstat as lstat8, mkdir as mkdir8, readlink as readlink2, symlink as symlink2, unlink as unlink3 } from "node:fs/promises";
|
|
28208
|
+
import { dirname as dirname25, join as join44, relative as relative4, resolve as resolve21 } from "node:path";
|
|
27466
28209
|
function seatProfileName(spec, role) {
|
|
27467
28210
|
return `${spec.namePrefix}${role}`;
|
|
27468
28211
|
}
|
|
@@ -27480,7 +28223,7 @@ async function pathExists2(path) {
|
|
|
27480
28223
|
async function ensureSeatProfileSoul(options) {
|
|
27481
28224
|
const { spec, operatorHome, packageRoot, role } = options;
|
|
27482
28225
|
const profileName = seatProfileName(spec, role);
|
|
27483
|
-
const soulTarget =
|
|
28226
|
+
const soulTarget = resolve21(packageRoleSoulPath(packageRoot, role));
|
|
27484
28227
|
if (!await pathExists2(soulTarget)) {
|
|
27485
28228
|
throw new Error(`packaged role soul missing: ${soulTarget}`);
|
|
27486
28229
|
}
|
|
@@ -27489,16 +28232,16 @@ async function ensureSeatProfileSoul(options) {
|
|
|
27489
28232
|
const hostRoot = dirname25(profilesRoot);
|
|
27490
28233
|
const soulPath = join44(profileDir, spec.soulFileName);
|
|
27491
28234
|
if (!await pathExists2(profileDir)) {
|
|
27492
|
-
await
|
|
28235
|
+
await mkdir8(profileDir, { recursive: true });
|
|
27493
28236
|
for (const name of ["auth.json", ".env", "config.yaml"]) {
|
|
27494
28237
|
const source = join44(hostRoot, name);
|
|
27495
28238
|
if (!await pathExists2(source)) continue;
|
|
27496
28239
|
await copyFile(source, join44(profileDir, name));
|
|
27497
28240
|
}
|
|
27498
28241
|
} else {
|
|
27499
|
-
await
|
|
28242
|
+
await mkdir8(profileDir, { recursive: true });
|
|
27500
28243
|
}
|
|
27501
|
-
const desiredLink =
|
|
28244
|
+
const desiredLink = relative4(profileDir, soulTarget);
|
|
27502
28245
|
let current;
|
|
27503
28246
|
try {
|
|
27504
28247
|
const st = await lstat8(soulPath);
|