@akagilnc/pi-workflow-roles 0.1.4620 → 0.1.4631
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.zh-CN.md +1 -1
- package/dist/acp-host/production-host.js +231 -218
- package/dist/activation-ledger-topology.js +0 -4
- package/dist/headless-host/production-host.js +215 -202
- package/dist/pi/role-turn-host.js +0 -3
- package/dist/public-cli/auto-resume.js +26 -0
- package/dist/public-cli/main.js +1054 -780
- package/dist/public-cli/post-admission.js +101 -7
- package/dist/public-cli/process-cancel.js +57 -0
- package/package.json +1 -1
- package/scripts/build-package.mjs +0 -1
- package/src/activation-ledger-topology.ts +1 -6
- package/src/activation-ledger.ts +5 -236
- package/src/analyst-entry.ts +19 -2
- package/src/analyst-ledger.ts +111 -6
- package/src/archivist-record-entry.ts +1 -1
- package/src/pi/role-turn-host.ts +0 -3
- package/src/public-cli/auto-resume.ts +34 -0
- package/src/public-cli/cli.ts +30 -0
- package/src/public-cli/main.ts +25 -3
- package/src/public-cli/post-admission.ts +173 -6
- package/src/public-cli/process-cancel.ts +75 -0
- package/src/role-runtime.ts +4 -51
- package/dist/activation-reconciliation.js +0 -61
- package/src/activation-reconciliation.ts +0 -163
|
@@ -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((resolve21, 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
|
+
resolve21({ status, headers, bodyText });
|
|
494
494
|
return;
|
|
495
495
|
}
|
|
496
496
|
if (code === 0) {
|
|
497
|
-
|
|
497
|
+
resolve21({ status: 200, headers: {}, bodyText: stdout });
|
|
498
498
|
return;
|
|
499
499
|
}
|
|
500
500
|
const failure2 = new Error(
|
|
@@ -691,7 +691,6 @@ var activation_ledger_topology_exports = {};
|
|
|
691
691
|
__export(activation_ledger_topology_exports, {
|
|
692
692
|
ActivationLedgerError: () => ActivationLedgerError,
|
|
693
693
|
activationBookDirectory: () => activationBookDirectory,
|
|
694
|
-
activationWaitingLedgerPath: () => activationWaitingLedgerPath,
|
|
695
694
|
assertLedgerFileInsideHome: () => assertLedgerFileInsideHome,
|
|
696
695
|
ensureRealDirectoryTree: () => ensureRealDirectoryTree,
|
|
697
696
|
errnoCode: () => errnoCode,
|
|
@@ -754,9 +753,6 @@ function resolveActivationLedgerHomeForPath(path) {
|
|
|
754
753
|
function activationBookDirectory(ledgerHome, bookKey) {
|
|
755
754
|
return join(ledgerHome, "books", bookKey);
|
|
756
755
|
}
|
|
757
|
-
function activationWaitingLedgerPath(ledgerHome, bookKey) {
|
|
758
|
-
return join(activationBookDirectory(ledgerHome, bookKey), "waiting.jsonl");
|
|
759
|
-
}
|
|
760
756
|
function pathContainedIn(root, candidate) {
|
|
761
757
|
const rel = relative(root, candidate);
|
|
762
758
|
return rel !== "" && rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel);
|
|
@@ -1964,7 +1960,7 @@ async function spawnEngineDetourOnce(input) {
|
|
|
1964
1960
|
}
|
|
1965
1961
|
const command = input.argv[0];
|
|
1966
1962
|
const args = input.argv.slice(1);
|
|
1967
|
-
return await new Promise((
|
|
1963
|
+
return await new Promise((resolve21, reject) => {
|
|
1968
1964
|
let settled = false;
|
|
1969
1965
|
const signal = input.signal;
|
|
1970
1966
|
const child = spawn2(command, args, {
|
|
@@ -1994,7 +1990,7 @@ async function spawnEngineDetourOnce(input) {
|
|
|
1994
1990
|
if (signal !== void 0) {
|
|
1995
1991
|
signal.removeEventListener("abort", onAbort);
|
|
1996
1992
|
}
|
|
1997
|
-
|
|
1993
|
+
resolve21(result);
|
|
1998
1994
|
};
|
|
1999
1995
|
const onAbort = () => {
|
|
2000
1996
|
fail4(signal !== void 0 ? abortReasonError(signal) : new Error("aborted"));
|
|
@@ -3746,9 +3742,6 @@ ${paths.join("\n")}`
|
|
|
3746
3742
|
if (typeof process.env.AK_ROLE_AUDITOR_SUBJECT === "string" && process.env.AK_ROLE_AUDITOR_SUBJECT.trim() !== "") {
|
|
3747
3743
|
env.AK_ROLE_AUDITOR_SUBJECT = process.env.AK_ROLE_AUDITOR_SUBJECT;
|
|
3748
3744
|
}
|
|
3749
|
-
if (request.correlationId !== void 0 && request.correlationId.trim() !== "") {
|
|
3750
|
-
env.AK_CORRELATION_ID = request.correlationId;
|
|
3751
|
-
}
|
|
3752
3745
|
if (config.recordLaunchedRolePackageIdentity !== void 0 && config.observeLaunchedRolePackageIdentity !== void 0) {
|
|
3753
3746
|
await config.recordLaunchedRolePackageIdentity(
|
|
3754
3747
|
request.runDirectory,
|
|
@@ -12018,12 +12011,12 @@ function createSystemCollectorClock() {
|
|
|
12018
12011
|
return {
|
|
12019
12012
|
wallNow: () => /* @__PURE__ */ new Date(),
|
|
12020
12013
|
monoNow: () => Number(process.hrtime.bigint() - start) / 1e6,
|
|
12021
|
-
sleep: (ms, signal) => new Promise((
|
|
12014
|
+
sleep: (ms, signal) => new Promise((resolve21, reject) => {
|
|
12022
12015
|
if (signal?.aborted) {
|
|
12023
12016
|
reject(signal.reason ?? new Error("aborted"));
|
|
12024
12017
|
return;
|
|
12025
12018
|
}
|
|
12026
|
-
const timer = setTimeout(
|
|
12019
|
+
const timer = setTimeout(resolve21, ms);
|
|
12027
12020
|
const onAbort = () => {
|
|
12028
12021
|
clearTimeout(timer);
|
|
12029
12022
|
reject(signal?.reason ?? new Error("aborted"));
|
|
@@ -16500,10 +16493,10 @@ function presentFailureTerminal(terminal, io) {
|
|
|
16500
16493
|
}
|
|
16501
16494
|
function defaultNavigatorGraceSleep() {
|
|
16502
16495
|
let timer;
|
|
16503
|
-
const sleep = ((ms) => new Promise((
|
|
16496
|
+
const sleep = ((ms) => new Promise((resolve21) => {
|
|
16504
16497
|
timer = setTimeout(() => {
|
|
16505
16498
|
timer = void 0;
|
|
16506
|
-
|
|
16499
|
+
resolve21();
|
|
16507
16500
|
}, ms);
|
|
16508
16501
|
}));
|
|
16509
16502
|
sleep.cancel = () => {
|
|
@@ -16515,7 +16508,7 @@ function defaultNavigatorGraceSleep() {
|
|
|
16515
16508
|
return sleep;
|
|
16516
16509
|
}
|
|
16517
16510
|
function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep = defaultNavigatorGraceSleep()) {
|
|
16518
|
-
return new Promise((
|
|
16511
|
+
return new Promise((resolve21, reject) => {
|
|
16519
16512
|
let settled = false;
|
|
16520
16513
|
const finish = (action) => {
|
|
16521
16514
|
if (settled) return;
|
|
@@ -16524,11 +16517,11 @@ function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep
|
|
|
16524
16517
|
action();
|
|
16525
16518
|
};
|
|
16526
16519
|
void work.then(
|
|
16527
|
-
(value) => finish(() =>
|
|
16520
|
+
(value) => finish(() => resolve21({ status: "done", value })),
|
|
16528
16521
|
(error) => finish(() => reject(error))
|
|
16529
16522
|
);
|
|
16530
16523
|
void sleep(graceMs).then(() => {
|
|
16531
|
-
finish(() =>
|
|
16524
|
+
finish(() => resolve21({ status: "timeout" }));
|
|
16532
16525
|
});
|
|
16533
16526
|
});
|
|
16534
16527
|
}
|
|
@@ -17534,6 +17527,24 @@ var init_public_run_credentials = __esm({
|
|
|
17534
17527
|
}
|
|
17535
17528
|
});
|
|
17536
17529
|
|
|
17530
|
+
// src/public-cli/process-cancel.ts
|
|
17531
|
+
function processCancelSignalName(signal) {
|
|
17532
|
+
if (signal === void 0 || signal.aborted !== true) return void 0;
|
|
17533
|
+
const reason = signal.reason;
|
|
17534
|
+
if (reason === "SIGTERM" || reason === "SIGINT" || reason === "SIGHUP") {
|
|
17535
|
+
return reason;
|
|
17536
|
+
}
|
|
17537
|
+
return void 0;
|
|
17538
|
+
}
|
|
17539
|
+
function processCancelDiagnostic(signalName) {
|
|
17540
|
+
return `ak-role terminated by ${signalName}`;
|
|
17541
|
+
}
|
|
17542
|
+
var init_process_cancel = __esm({
|
|
17543
|
+
"src/public-cli/process-cancel.ts"() {
|
|
17544
|
+
"use strict";
|
|
17545
|
+
}
|
|
17546
|
+
});
|
|
17547
|
+
|
|
17537
17548
|
// src/public-cli/auto-resume.ts
|
|
17538
17549
|
import { constants as fsConstants2 } from "node:fs";
|
|
17539
17550
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
@@ -17836,6 +17847,10 @@ async function runWithAutoResumeLoop(options) {
|
|
|
17836
17847
|
if (terminal !== void 0) presentTerminal(terminal, options.io);
|
|
17837
17848
|
return result;
|
|
17838
17849
|
}
|
|
17850
|
+
if (processCancelSignalName(options.signal) !== void 0) {
|
|
17851
|
+
if (terminal !== void 0) presentTerminal(terminal, options.io);
|
|
17852
|
+
return result;
|
|
17853
|
+
}
|
|
17839
17854
|
}
|
|
17840
17855
|
if (result !== void 0) {
|
|
17841
17856
|
const terminal = result.terminal;
|
|
@@ -17869,6 +17884,28 @@ async function runWithAutoResumeLoop(options) {
|
|
|
17869
17884
|
terminal
|
|
17870
17885
|
};
|
|
17871
17886
|
}
|
|
17887
|
+
const cancelName = processCancelSignalName(options.signal);
|
|
17888
|
+
if (cancelName !== void 0) {
|
|
17889
|
+
const terminal = await attachDispatchExceptionTerminal(
|
|
17890
|
+
options.admitted,
|
|
17891
|
+
dispatchExceptionFailureTerminal({
|
|
17892
|
+
role: options.admitted.role,
|
|
17893
|
+
runId: options.admitted.runId,
|
|
17894
|
+
causeError: lastThrownError,
|
|
17895
|
+
errorFiles: retainedErrorFiles,
|
|
17896
|
+
autoResumeAttempts,
|
|
17897
|
+
endReason: `ak-role terminated by ${cancelName}`,
|
|
17898
|
+
everyAttemptThrew
|
|
17899
|
+
}),
|
|
17900
|
+
options.io
|
|
17901
|
+
);
|
|
17902
|
+
await finalizeExceptionRunBestEffort(options.admitted.runDirectory, options.io);
|
|
17903
|
+
presentTerminal(terminal, options.io);
|
|
17904
|
+
return {
|
|
17905
|
+
exitCode: 1,
|
|
17906
|
+
terminal
|
|
17907
|
+
};
|
|
17908
|
+
}
|
|
17872
17909
|
if (!await isPrincipalAvailable(options.admitted.principal)) {
|
|
17873
17910
|
const terminal = await attachDispatchExceptionTerminal(
|
|
17874
17911
|
options.admitted,
|
|
@@ -17905,6 +17942,7 @@ var init_auto_resume = __esm({
|
|
|
17905
17942
|
init_role_run_placement();
|
|
17906
17943
|
init_run_lifecycle();
|
|
17907
17944
|
init_config();
|
|
17945
|
+
init_process_cancel();
|
|
17908
17946
|
init_terminal();
|
|
17909
17947
|
init_settlement();
|
|
17910
17948
|
dummyIo = { stdout: () => {
|
|
@@ -17937,6 +17975,36 @@ function describeCaughtError(error) {
|
|
|
17937
17975
|
function isStationChildOfficerDialogue(role, env) {
|
|
17938
17976
|
return env.stationChild === true && isOfficerReviewSeat(role);
|
|
17939
17977
|
}
|
|
17978
|
+
function withProcessCancelSkipAutoResume(result, signal) {
|
|
17979
|
+
if (processCancelSignalName(signal) === void 0) {
|
|
17980
|
+
return result;
|
|
17981
|
+
}
|
|
17982
|
+
return { ...result, skipAutoResume: true };
|
|
17983
|
+
}
|
|
17984
|
+
async function settleProcessCancelAfterTurn(input) {
|
|
17985
|
+
const failed = await settleAfterTurnStarted(
|
|
17986
|
+
input.admitted,
|
|
17987
|
+
withEngineDetourInvocationScope(
|
|
17988
|
+
{
|
|
17989
|
+
timedOut: input.result.timedOut,
|
|
17990
|
+
code: input.result.code,
|
|
17991
|
+
stderr: input.result.stderr,
|
|
17992
|
+
knownDiagnostic: processCancelDiagnostic(input.cancelName)
|
|
17993
|
+
},
|
|
17994
|
+
input.invocationScopeId
|
|
17995
|
+
),
|
|
17996
|
+
input.adapters,
|
|
17997
|
+
input.env.principalAuthority,
|
|
17998
|
+
input.io,
|
|
17999
|
+
input.persistRunState
|
|
18000
|
+
);
|
|
18001
|
+
return {
|
|
18002
|
+
...failed,
|
|
18003
|
+
turnDispatched: true,
|
|
18004
|
+
skipAutoResume: true,
|
|
18005
|
+
...input.deferredPersist
|
|
18006
|
+
};
|
|
18007
|
+
}
|
|
17940
18008
|
function withOnceSuccessfulBeforeDispatch(adapters) {
|
|
17941
18009
|
const hook = adapters.beforeDispatch;
|
|
17942
18010
|
if (hook === void 0) return adapters;
|
|
@@ -18097,6 +18165,31 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18097
18165
|
const finishAfterTurn = async (result) => {
|
|
18098
18166
|
if (afterDispatchApplied) return result;
|
|
18099
18167
|
afterDispatchApplied = true;
|
|
18168
|
+
const cancelBeforeFinish = processCancelSignalName(env.signal);
|
|
18169
|
+
if (cancelBeforeFinish !== void 0 && result.terminal !== void 0 && isLawfulTypedTerminalOutcome(result.terminal.roleOutcome)) {
|
|
18170
|
+
result = {
|
|
18171
|
+
...await settleAfterTurnStarted(
|
|
18172
|
+
admitted,
|
|
18173
|
+
withEngineDetourInvocationScope(
|
|
18174
|
+
{
|
|
18175
|
+
timedOut: false,
|
|
18176
|
+
code: null,
|
|
18177
|
+
stderr: "",
|
|
18178
|
+
knownDiagnostic: processCancelDiagnostic(cancelBeforeFinish),
|
|
18179
|
+
skipRunStateWrite: true
|
|
18180
|
+
},
|
|
18181
|
+
request.invocationScopeId
|
|
18182
|
+
),
|
|
18183
|
+
adapters,
|
|
18184
|
+
env.principalAuthority,
|
|
18185
|
+
io,
|
|
18186
|
+
persistRunState
|
|
18187
|
+
),
|
|
18188
|
+
turnDispatched: true,
|
|
18189
|
+
skipAutoResume: true,
|
|
18190
|
+
...deferredPersist
|
|
18191
|
+
};
|
|
18192
|
+
}
|
|
18100
18193
|
try {
|
|
18101
18194
|
if (admitted.ticketNumber === void 0) {
|
|
18102
18195
|
const rows = await readRecordedSubmissionRows(
|
|
@@ -18243,20 +18336,26 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18243
18336
|
try {
|
|
18244
18337
|
result = await env.roleTurnHost.executeTurn(turnRequest);
|
|
18245
18338
|
} catch (error) {
|
|
18339
|
+
const processCancelName = processCancelSignalName(env.signal);
|
|
18246
18340
|
const settled2 = await settleAfterTurnStarted(
|
|
18247
18341
|
admitted,
|
|
18248
18342
|
withEngineDetourInvocationScope({
|
|
18249
18343
|
timedOut: false,
|
|
18250
18344
|
code: null,
|
|
18251
18345
|
stderr: "",
|
|
18252
|
-
thrown: error
|
|
18346
|
+
thrown: processCancelName === void 0 ? error : new Error(processCancelDiagnostic(processCancelName), { cause: error })
|
|
18253
18347
|
}, request.invocationScopeId),
|
|
18254
18348
|
adapters,
|
|
18255
18349
|
env.principalAuthority,
|
|
18256
18350
|
io,
|
|
18257
18351
|
persistRunState
|
|
18258
18352
|
);
|
|
18259
|
-
return await finishAfterTurn(
|
|
18353
|
+
return await finishAfterTurn(
|
|
18354
|
+
withProcessCancelSkipAutoResume(
|
|
18355
|
+
{ ...settled2, turnDispatched: true, ...deferredPersist },
|
|
18356
|
+
env.signal
|
|
18357
|
+
)
|
|
18358
|
+
);
|
|
18260
18359
|
}
|
|
18261
18360
|
let stderrLogWriteFailure;
|
|
18262
18361
|
try {
|
|
@@ -18296,7 +18395,8 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18296
18395
|
credential: credentialFailure,
|
|
18297
18396
|
runDirectory: admitted.runDirectory
|
|
18298
18397
|
});
|
|
18299
|
-
const
|
|
18398
|
+
const processCancelName = processCancelSignalName(env.signal);
|
|
18399
|
+
const directHostFailureSignal = result.timedOut || result.knownFailure !== void 0 || runnerKnownFailure !== void 0 || credentialFailure !== void 0 || processCancelName !== void 0;
|
|
18300
18400
|
hostSignalFailed = directHostFailureSignal || result.code !== null && result.code !== 0 || resolution.knownFailure !== void 0;
|
|
18301
18401
|
settled = await adapters.trySettle(admitted, env.principalAuthority, courtScope);
|
|
18302
18402
|
if (settled !== void 0) {
|
|
@@ -18304,7 +18404,8 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18304
18404
|
}
|
|
18305
18405
|
const settledIsFreshThisAttempt = settled === void 0 || settled.roleOutcome.kind !== "accepted" && settled.roleOutcome.kind !== "audit_escalation" ? true : await attemptProducedFreshSubmission(admitted, courtScope);
|
|
18306
18406
|
const staleAcceptanceOutranksRealFailure = !settledIsFreshThisAttempt && hostSignalFailed;
|
|
18307
|
-
|
|
18407
|
+
const cancelAfterSettle = processCancelSignalName(env.signal);
|
|
18408
|
+
if (settled !== void 0 && shouldPresent(settled) && !directHostFailureSignal && !staleAcceptanceOutranksRealFailure && stderrLogWriteFailure === void 0 && cancelAfterSettle === void 0) {
|
|
18308
18409
|
if (settled.roleOutcome.kind === "accepted" && request.courtAttemptId !== void 0 && request.courtAttemptId.length > 0) {
|
|
18309
18410
|
try {
|
|
18310
18411
|
await clearCurrentCourt(admitted.runDirectory, request.courtAttemptId);
|
|
@@ -18341,6 +18442,22 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18341
18442
|
return await finishAfterTurn({ ...settledFailure, turnDispatched: true, ...deferredPersist });
|
|
18342
18443
|
}
|
|
18343
18444
|
if (settledOutcome !== void 0) {
|
|
18445
|
+
const lateCancel = processCancelSignalName(env.signal);
|
|
18446
|
+
if (lateCancel !== void 0) {
|
|
18447
|
+
return await finishAfterTurn(
|
|
18448
|
+
await settleProcessCancelAfterTurn({
|
|
18449
|
+
admitted,
|
|
18450
|
+
cancelName: lateCancel,
|
|
18451
|
+
result,
|
|
18452
|
+
adapters,
|
|
18453
|
+
env,
|
|
18454
|
+
io,
|
|
18455
|
+
persistRunState,
|
|
18456
|
+
deferredPersist,
|
|
18457
|
+
invocationScopeId: request.invocationScopeId
|
|
18458
|
+
})
|
|
18459
|
+
);
|
|
18460
|
+
}
|
|
18344
18461
|
if (persistRunState) {
|
|
18345
18462
|
try {
|
|
18346
18463
|
await persistReturnedRunState(admitted, env.principalAuthority, { lawful: true });
|
|
@@ -18359,13 +18476,19 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18359
18476
|
io,
|
|
18360
18477
|
persistRunState
|
|
18361
18478
|
);
|
|
18362
|
-
return await finishAfterTurn(
|
|
18479
|
+
return await finishAfterTurn(
|
|
18480
|
+
withProcessCancelSkipAutoResume(
|
|
18481
|
+
{ ...failed, turnDispatched: true, ...deferredPersist },
|
|
18482
|
+
env.signal
|
|
18483
|
+
)
|
|
18484
|
+
);
|
|
18363
18485
|
}
|
|
18364
18486
|
}
|
|
18365
18487
|
return await finishAfterTurn({ ...settledOutcome, ...deferredPersist });
|
|
18366
18488
|
}
|
|
18367
18489
|
if (hostSignalFailed) {
|
|
18368
18490
|
const resolutionInput = controlledFailureInputFromResolution(resolution);
|
|
18491
|
+
const processCancelName = processCancelSignalName(env.signal);
|
|
18369
18492
|
const stderrLogWriteDetails = stderrLogWriteFailure === void 0 ? void 0 : { stderrLogWriteFailure: describeCaughtError(stderrLogWriteFailure) };
|
|
18370
18493
|
const failed = await settleAfterTurnStarted(
|
|
18371
18494
|
admitted,
|
|
@@ -18374,6 +18497,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18374
18497
|
code: result.code,
|
|
18375
18498
|
stderr: result.stderr,
|
|
18376
18499
|
...resolutionInput,
|
|
18500
|
+
...processCancelName === void 0 ? {} : { knownDiagnostic: processCancelDiagnostic(processCancelName) },
|
|
18377
18501
|
// Secondary fact only — never the cause. Rides on whichever channel
|
|
18378
18502
|
// classification actually reads (knownFailure.details owns it when
|
|
18379
18503
|
// a knownFailure exists; the top-level knownDetails otherwise).
|
|
@@ -18389,7 +18513,12 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18389
18513
|
io,
|
|
18390
18514
|
persistRunState
|
|
18391
18515
|
);
|
|
18392
|
-
return await finishAfterTurn(
|
|
18516
|
+
return await finishAfterTurn(
|
|
18517
|
+
withProcessCancelSkipAutoResume(
|
|
18518
|
+
{ ...failed, turnDispatched: true, ...deferredPersist },
|
|
18519
|
+
env.signal
|
|
18520
|
+
)
|
|
18521
|
+
);
|
|
18393
18522
|
}
|
|
18394
18523
|
if (stderrLogWriteFailure !== void 0) {
|
|
18395
18524
|
const failed = await settleAfterTurnStarted(
|
|
@@ -18412,6 +18541,22 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18412
18541
|
await settleHostEndedNoReceipt(admitted, env.principalAuthority, courtScope),
|
|
18413
18542
|
courtScope
|
|
18414
18543
|
);
|
|
18544
|
+
const noReceiptCancel = processCancelSignalName(env.signal);
|
|
18545
|
+
if (noReceiptCancel !== void 0) {
|
|
18546
|
+
return await finishAfterTurn(
|
|
18547
|
+
await settleProcessCancelAfterTurn({
|
|
18548
|
+
admitted,
|
|
18549
|
+
cancelName: noReceiptCancel,
|
|
18550
|
+
result,
|
|
18551
|
+
adapters,
|
|
18552
|
+
env,
|
|
18553
|
+
io,
|
|
18554
|
+
persistRunState,
|
|
18555
|
+
deferredPersist,
|
|
18556
|
+
invocationScopeId: request.invocationScopeId
|
|
18557
|
+
})
|
|
18558
|
+
);
|
|
18559
|
+
}
|
|
18415
18560
|
if (persistRunState) {
|
|
18416
18561
|
try {
|
|
18417
18562
|
await persistReturnedRunState(admitted, env.principalAuthority, { lawful: true });
|
|
@@ -18430,7 +18575,12 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18430
18575
|
io,
|
|
18431
18576
|
persistRunState
|
|
18432
18577
|
);
|
|
18433
|
-
return await finishAfterTurn(
|
|
18578
|
+
return await finishAfterTurn(
|
|
18579
|
+
withProcessCancelSkipAutoResume(
|
|
18580
|
+
{ ...failed, turnDispatched: true, ...deferredPersist },
|
|
18581
|
+
env.signal
|
|
18582
|
+
)
|
|
18583
|
+
);
|
|
18434
18584
|
}
|
|
18435
18585
|
}
|
|
18436
18586
|
return await finishAfterTurn({
|
|
@@ -18626,6 +18776,7 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
18626
18776
|
io: input.io,
|
|
18627
18777
|
sessionAppender: env.sessionAppender,
|
|
18628
18778
|
autoResumeLimit: env.autoResumeLimit,
|
|
18779
|
+
...env.signal === void 0 ? {} : { signal: env.signal },
|
|
18629
18780
|
buildInitialPayload: () => ({ resumeTurn: false }),
|
|
18630
18781
|
buildResumePayload: () => ({ resumeTurn: true }),
|
|
18631
18782
|
// Same as public manual resume: prior-court sealed acceptance is not a
|
|
@@ -18729,6 +18880,7 @@ async function runPostAdmissionResumable(input) {
|
|
|
18729
18880
|
io,
|
|
18730
18881
|
sessionAppender: env.sessionAppender,
|
|
18731
18882
|
autoResumeLimit: env.autoResumeLimit,
|
|
18883
|
+
...env.signal === void 0 ? {} : { signal: env.signal },
|
|
18732
18884
|
buildInitialPayload: buildScopedInitial,
|
|
18733
18885
|
buildResumePayload: buildScopedResume,
|
|
18734
18886
|
dispatch: async (request, lease, _isFirst, attemptIo) => {
|
|
@@ -18837,6 +18989,7 @@ var init_post_admission = __esm({
|
|
|
18837
18989
|
init_host_transition_prior_native();
|
|
18838
18990
|
init_public_run_credentials();
|
|
18839
18991
|
init_run_lifecycle();
|
|
18992
|
+
init_process_cancel();
|
|
18840
18993
|
init_activation_ledger_topology();
|
|
18841
18994
|
init_settlement();
|
|
18842
18995
|
init_terminal();
|
|
@@ -23082,7 +23235,7 @@ init_sitian_facade();
|
|
|
23082
23235
|
init_submission_ledger();
|
|
23083
23236
|
init_collector_ledger();
|
|
23084
23237
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
23085
|
-
import { readFileSync as readFileSync6, writeSync as
|
|
23238
|
+
import { readFileSync as readFileSync6, writeSync as writeSync3 } from "node:fs";
|
|
23086
23239
|
import { join as join39 } from "node:path";
|
|
23087
23240
|
import { Value as Value4 } from "typebox/value";
|
|
23088
23241
|
|
|
@@ -23124,16 +23277,7 @@ function namedActivationCause(error) {
|
|
|
23124
23277
|
init_activation_ledger_topology();
|
|
23125
23278
|
|
|
23126
23279
|
// src/activation-ledger.ts
|
|
23127
|
-
init_activation_ledger_topology();
|
|
23128
23280
|
init_activation_ledger_git();
|
|
23129
|
-
import {
|
|
23130
|
-
constants as constants2,
|
|
23131
|
-
closeSync as closeSync2,
|
|
23132
|
-
fstatSync,
|
|
23133
|
-
openSync as openSync2,
|
|
23134
|
-
writeSync
|
|
23135
|
-
} from "node:fs";
|
|
23136
|
-
import { dirname as dirname21, isAbsolute as isAbsolute10, resolve as resolve19 } from "node:path";
|
|
23137
23281
|
|
|
23138
23282
|
// src/activation-ledger-session.ts
|
|
23139
23283
|
init_activation_ledger_topology();
|
|
@@ -23237,129 +23381,11 @@ function durableSessionPointer(sessionManager) {
|
|
|
23237
23381
|
|
|
23238
23382
|
// src/activation-ledger.ts
|
|
23239
23383
|
init_activation_ledger_topology();
|
|
23240
|
-
var ACTIVATION_LEDGER_APPEND_OPEN_FLAGS = constants2.O_APPEND | constants2.O_CREAT | constants2.O_WRONLY | constants2.O_NOFOLLOW;
|
|
23241
|
-
var ACCEPTED_ACTIVATION_EVENT = "accepted-activation";
|
|
23242
|
-
var ACCEPTED_ACTIVATION_FACT_KEYS = Object.freeze([
|
|
23243
|
-
"event",
|
|
23244
|
-
"role",
|
|
23245
|
-
"observedAt",
|
|
23246
|
-
"bookKey",
|
|
23247
|
-
"session",
|
|
23248
|
-
"correlation"
|
|
23249
|
-
]);
|
|
23250
|
-
function correlationIdentityFromEnv(env = process.env) {
|
|
23251
|
-
const raw = env.AK_CORRELATION_ID;
|
|
23252
|
-
if (typeof raw === "string" && raw.trim().length > 0) {
|
|
23253
|
-
return { kind: "caller", id: raw };
|
|
23254
|
-
}
|
|
23255
|
-
return { kind: "absent" };
|
|
23256
|
-
}
|
|
23257
|
-
function projectAcceptedActivationFact(input) {
|
|
23258
|
-
const closed = {
|
|
23259
|
-
event: ACCEPTED_ACTIVATION_EVENT,
|
|
23260
|
-
role: input.role,
|
|
23261
|
-
observedAt: input.observedAt,
|
|
23262
|
-
bookKey: input.bookKey,
|
|
23263
|
-
session: { kind: "session-file", path: input.session.path },
|
|
23264
|
-
correlation: input.correlation.kind === "caller" ? { kind: "caller", id: input.correlation.id } : { kind: "absent" }
|
|
23265
|
-
};
|
|
23266
|
-
return Object.fromEntries(
|
|
23267
|
-
ACCEPTED_ACTIVATION_FACT_KEYS.map((key) => [key, closed[key]])
|
|
23268
|
-
);
|
|
23269
|
-
}
|
|
23270
|
-
function buildAcceptedActivationFact(input) {
|
|
23271
|
-
return projectAcceptedActivationFact(input);
|
|
23272
|
-
}
|
|
23273
|
-
function serializeAcceptedActivationFact(fact) {
|
|
23274
|
-
return `${JSON.stringify(projectAcceptedActivationFact(fact))}
|
|
23275
|
-
`;
|
|
23276
|
-
}
|
|
23277
|
-
function appendActivationLedgerLine(ledgerPath, line2, options) {
|
|
23278
|
-
if (!isAbsolute10(options.ledgerHome)) {
|
|
23279
|
-
throw new ActivationLedgerError(
|
|
23280
|
-
`activation ledger home must be absolute: ${options.ledgerHome}`
|
|
23281
|
-
);
|
|
23282
|
-
}
|
|
23283
|
-
const resolvedLedger = resolve19(ledgerPath);
|
|
23284
|
-
const resolvedHome = resolve19(options.ledgerHome);
|
|
23285
|
-
const parent = dirname21(resolvedLedger);
|
|
23286
|
-
ensureRealDirectoryTree(resolvedHome, parent);
|
|
23287
|
-
assertLedgerFileInsideHome(resolvedLedger, resolvedHome);
|
|
23288
|
-
if (typeof constants2.O_NOFOLLOW !== "number") {
|
|
23289
|
-
throw new ActivationLedgerError(
|
|
23290
|
-
"activation ledger append requires O_NOFOLLOW open-flag support (anti-symlink TOCTOU protection must not be silently dropped); refusing to append"
|
|
23291
|
-
);
|
|
23292
|
-
}
|
|
23293
|
-
const bytes = Buffer.isBuffer(line2) ? line2 : Buffer.from(line2);
|
|
23294
|
-
let ledgerFd;
|
|
23295
|
-
let primaryFailure;
|
|
23296
|
-
try {
|
|
23297
|
-
try {
|
|
23298
|
-
ledgerFd = openSync2(resolvedLedger, ACTIVATION_LEDGER_APPEND_OPEN_FLAGS, 420);
|
|
23299
|
-
} catch (error) {
|
|
23300
|
-
throw new ActivationLedgerError(
|
|
23301
|
-
`activation ledger failed to open ledger file (${resolvedLedger}): ${errorText(error)}`,
|
|
23302
|
-
{ cause: error }
|
|
23303
|
-
);
|
|
23304
|
-
}
|
|
23305
|
-
let opened;
|
|
23306
|
-
try {
|
|
23307
|
-
opened = fstatSync(ledgerFd);
|
|
23308
|
-
} catch (error) {
|
|
23309
|
-
throw new ActivationLedgerError(
|
|
23310
|
-
`activation ledger failed to fstat ledger file (${resolvedLedger}): ${errorText(error)}`,
|
|
23311
|
-
{ cause: error }
|
|
23312
|
-
);
|
|
23313
|
-
}
|
|
23314
|
-
if (!opened.isFile()) {
|
|
23315
|
-
throw new ActivationLedgerError(
|
|
23316
|
-
`activation ledger is not a regular file: ${resolvedLedger}`
|
|
23317
|
-
);
|
|
23318
|
-
}
|
|
23319
|
-
const written = writeSync(ledgerFd, bytes, 0, bytes.length, null);
|
|
23320
|
-
if (written !== bytes.length) {
|
|
23321
|
-
throw new ActivationLedgerError(
|
|
23322
|
-
`activation ledger short write: wrote ${written} of ${bytes.length} bytes to ${resolvedLedger}`
|
|
23323
|
-
);
|
|
23324
|
-
}
|
|
23325
|
-
} catch (error) {
|
|
23326
|
-
primaryFailure = error;
|
|
23327
|
-
}
|
|
23328
|
-
if (ledgerFd !== void 0) {
|
|
23329
|
-
try {
|
|
23330
|
-
closeSync2(ledgerFd);
|
|
23331
|
-
} catch (closeFailure) {
|
|
23332
|
-
if (primaryFailure !== void 0) {
|
|
23333
|
-
throw new AggregateError(
|
|
23334
|
-
[primaryFailure, closeFailure],
|
|
23335
|
-
"activation ledger operation and close failed",
|
|
23336
|
-
{ cause: primaryFailure }
|
|
23337
|
-
);
|
|
23338
|
-
}
|
|
23339
|
-
throw closeFailure;
|
|
23340
|
-
}
|
|
23341
|
-
}
|
|
23342
|
-
if (primaryFailure !== void 0) throw primaryFailure;
|
|
23343
|
-
}
|
|
23344
|
-
function appendAcceptedActivationFact(ledgerPath, fact, options) {
|
|
23345
|
-
appendActivationLedgerLine(
|
|
23346
|
-
ledgerPath,
|
|
23347
|
-
Buffer.from(serializeAcceptedActivationFact(fact), "utf8"),
|
|
23348
|
-
{ ledgerHome: options.ledgerHome }
|
|
23349
|
-
);
|
|
23350
|
-
}
|
|
23351
|
-
function appendAcceptedActivationToBook(options) {
|
|
23352
|
-
appendAcceptedActivationFact(
|
|
23353
|
-
activationWaitingLedgerPath(options.ledgerHome, options.fact.bookKey),
|
|
23354
|
-
options.fact,
|
|
23355
|
-
{ ledgerHome: options.ledgerHome }
|
|
23356
|
-
);
|
|
23357
|
-
}
|
|
23358
23384
|
|
|
23359
23385
|
// src/stderr-jsonl.ts
|
|
23360
|
-
import { writeSync
|
|
23386
|
+
import { writeSync } from "node:fs";
|
|
23361
23387
|
var STDERR_JSONL_WRITE_RETRY_LIMIT = 100;
|
|
23362
|
-
function writeStderrJsonlRecord(record4, write =
|
|
23388
|
+
function writeStderrJsonlRecord(record4, write = writeSync) {
|
|
23363
23389
|
const bytes = Buffer.from(`${JSON.stringify(record4)}
|
|
23364
23390
|
`);
|
|
23365
23391
|
let offset = 0;
|
|
@@ -23379,7 +23405,7 @@ function writeStderrJsonlRecord(record4, write = writeSync2) {
|
|
|
23379
23405
|
}
|
|
23380
23406
|
|
|
23381
23407
|
// src/tool-execution-observation.ts
|
|
23382
|
-
import { writeSync as
|
|
23408
|
+
import { writeSync as writeSync2 } from "node:fs";
|
|
23383
23409
|
import { Type as Type15 } from "typebox";
|
|
23384
23410
|
import { Value as Value3 } from "typebox/value";
|
|
23385
23411
|
var TOOL_EXECUTION_UPDATE_THROTTLE_MS = 3e4;
|
|
@@ -23410,7 +23436,7 @@ function validateToolExecutionObservationRecord(record4) {
|
|
|
23410
23436
|
}
|
|
23411
23437
|
return record4;
|
|
23412
23438
|
}
|
|
23413
|
-
function writeToolExecutionObservationRecord(record4, write =
|
|
23439
|
+
function writeToolExecutionObservationRecord(record4, write = writeSync2) {
|
|
23414
23440
|
writeStderrJsonlRecord(validateToolExecutionObservationRecord(record4), write);
|
|
23415
23441
|
}
|
|
23416
23442
|
function isProducingToolUpdate(partialResult) {
|
|
@@ -23647,9 +23673,9 @@ import { join as join38, sep as sep6 } from "node:path";
|
|
|
23647
23673
|
// src/atomic-write.ts
|
|
23648
23674
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
23649
23675
|
import { rename as rename3, rm as rm5, writeFile as writeFile11 } from "node:fs/promises";
|
|
23650
|
-
import { dirname as
|
|
23676
|
+
import { dirname as dirname21, join as join37 } from "node:path";
|
|
23651
23677
|
async function writeFileAtomically(destination, contents) {
|
|
23652
|
-
const parent =
|
|
23678
|
+
const parent = dirname21(destination);
|
|
23653
23679
|
const temporary = join37(parent, `.atomic-write-${randomUUID7()}.tmp`);
|
|
23654
23680
|
try {
|
|
23655
23681
|
await writeFile11(temporary, contents);
|
|
@@ -25155,7 +25181,7 @@ init_submission_errors();
|
|
|
25155
25181
|
init_submission_errors();
|
|
25156
25182
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
25157
25183
|
import { existsSync as existsSync12, lstatSync as lstatSync3, readdirSync as readdirSync3, readFileSync as readFileSync5, rmdirSync, rmSync } from "node:fs";
|
|
25158
|
-
import { resolve as
|
|
25184
|
+
import { resolve as resolve19 } from "node:path";
|
|
25159
25185
|
var WORKER_SUBMISSION_GATE_RECORD_KIND = WORKER_SUBMISSION_GATE_KIND;
|
|
25160
25186
|
var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
|
|
25161
25187
|
var WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE = "commit-reminder-bounce";
|
|
@@ -25204,7 +25230,7 @@ function escapeGitConfigValueRegex(value) {
|
|
|
25204
25230
|
function unsetOwnedHooksPath(file) {
|
|
25205
25231
|
const owned = [];
|
|
25206
25232
|
for (const value of tryGetAll(file, "core.hooksPath")) {
|
|
25207
|
-
if (!ownedHook(
|
|
25233
|
+
if (!ownedHook(resolve19(value, HOOK_FILE))) continue;
|
|
25208
25234
|
try {
|
|
25209
25235
|
gitFile(file, [
|
|
25210
25236
|
"--unset-all",
|
|
@@ -25219,15 +25245,15 @@ function unsetOwnedHooksPath(file) {
|
|
|
25219
25245
|
return owned;
|
|
25220
25246
|
}
|
|
25221
25247
|
function rmOwnedDir(dir) {
|
|
25222
|
-
const hookPath =
|
|
25248
|
+
const hookPath = resolve19(dir, HOOK_FILE);
|
|
25223
25249
|
if (!ownedHook(hookPath)) return;
|
|
25224
25250
|
rmSync(hookPath, { force: true });
|
|
25225
25251
|
if (existsSync12(dir) && readdirSync3(dir).length === 0) rmdirSync(dir);
|
|
25226
25252
|
}
|
|
25227
25253
|
function linkedGitDirs(commonDir) {
|
|
25228
|
-
const root =
|
|
25254
|
+
const root = resolve19(commonDir, "worktrees");
|
|
25229
25255
|
if (!existsSync12(root)) return [];
|
|
25230
|
-
return readdirSync3(root).map((name) =>
|
|
25256
|
+
return readdirSync3(root).map((name) => resolve19(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
|
|
25231
25257
|
}
|
|
25232
25258
|
function uninstallPackageWorkerHooks(cwd) {
|
|
25233
25259
|
let inside;
|
|
@@ -25241,14 +25267,14 @@ function uninstallPackageWorkerHooks(cwd) {
|
|
|
25241
25267
|
const clear = (configFile) => {
|
|
25242
25268
|
for (const hooks of unsetOwnedHooksPath(configFile)) rmOwnedDir(hooks);
|
|
25243
25269
|
};
|
|
25244
|
-
clear(
|
|
25245
|
-
clear(
|
|
25246
|
-
rmOwnedDir(
|
|
25247
|
-
const legacy =
|
|
25270
|
+
clear(resolve19(commonDir, "config"));
|
|
25271
|
+
clear(resolve19(commonDir, "config.worktree"));
|
|
25272
|
+
rmOwnedDir(resolve19(commonDir, HOOKS_DIR));
|
|
25273
|
+
const legacy = resolve19(commonDir, "hooks", HOOK_FILE);
|
|
25248
25274
|
if (ownedHook(legacy)) rmSync(legacy, { force: true });
|
|
25249
25275
|
for (const gitDir of linkedGitDirs(commonDir)) {
|
|
25250
|
-
clear(
|
|
25251
|
-
rmOwnedDir(
|
|
25276
|
+
clear(resolve19(gitDir, "config.worktree"));
|
|
25277
|
+
rmOwnedDir(resolve19(gitDir, HOOKS_DIR));
|
|
25252
25278
|
}
|
|
25253
25279
|
}
|
|
25254
25280
|
function isRecord13(value) {
|
|
@@ -26001,7 +26027,7 @@ async function executeActivationStage(role, stage, infrastructure) {
|
|
|
26001
26027
|
throw activationError;
|
|
26002
26028
|
}
|
|
26003
26029
|
}
|
|
26004
|
-
function writeActivationTraceRecord(record4, write =
|
|
26030
|
+
function writeActivationTraceRecord(record4, write = writeSync3) {
|
|
26005
26031
|
writeStderrJsonlRecord(record4, write);
|
|
26006
26032
|
}
|
|
26007
26033
|
var ActivationBarrierError = class extends Error {
|
|
@@ -27233,11 +27259,8 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27233
27259
|
}
|
|
27234
27260
|
};
|
|
27235
27261
|
try {
|
|
27236
|
-
|
|
27237
|
-
|
|
27238
|
-
const sessionFile = ctx.sessionManager.getSessionFile?.() || ctx.sessionManager.getSessionDir?.();
|
|
27239
|
-
const ledgerHome = resolveActivationLedgerHomeForPath(sessionFile);
|
|
27240
|
-
const session = durableSessionPointer(ctx.sessionManager);
|
|
27262
|
+
resolveBookKeyFromGit(ctx.cwd);
|
|
27263
|
+
durableSessionPointer(ctx.sessionManager);
|
|
27241
27264
|
const isStationChild = roleHost.getFlag(STATION_CHILD_FLAG.name) === true;
|
|
27242
27265
|
if (dependencies.createNavigatorAttendance !== void 0 && entry.role !== "navigator" && !isStationChild) {
|
|
27243
27266
|
navigatorSessionParent = ctx.sessionManager.getSessionFile();
|
|
@@ -27324,16 +27347,6 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27324
27347
|
if (entry.role === "coder") coder.armSubmissionGate(ctx.cwd, ctx.sessionManager);
|
|
27325
27348
|
else fixer.armSubmissionGate(ctx.cwd, ctx.sessionManager);
|
|
27326
27349
|
}
|
|
27327
|
-
appendAcceptedActivationToBook({
|
|
27328
|
-
ledgerHome,
|
|
27329
|
-
fact: buildAcceptedActivationFact({
|
|
27330
|
-
role: entry.role,
|
|
27331
|
-
observedAt: clock(),
|
|
27332
|
-
bookKey,
|
|
27333
|
-
session,
|
|
27334
|
-
correlation
|
|
27335
|
-
})
|
|
27336
|
-
});
|
|
27337
27350
|
admitted = true;
|
|
27338
27351
|
} catch (error) {
|
|
27339
27352
|
failInfrastructure(error, ctx);
|
|
@@ -27418,7 +27431,7 @@ init_engine_detour();
|
|
|
27418
27431
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
27419
27432
|
import { appendFile as appendFile3, mkdir as mkdir7, writeFile as writeFile12 } from "node:fs/promises";
|
|
27420
27433
|
import { createServer } from "node:net";
|
|
27421
|
-
import { dirname as
|
|
27434
|
+
import { dirname as dirname23, join as join42 } from "node:path";
|
|
27422
27435
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
27423
27436
|
|
|
27424
27437
|
// src/gatekeeper-pass-envelope.ts
|
|
@@ -27505,14 +27518,14 @@ async function requireGatekeeperPass(options) {
|
|
|
27505
27518
|
|
|
27506
27519
|
// src/host-native-method.ts
|
|
27507
27520
|
import { lstat as lstat7, mkdir as mkdir6, readlink, realpath as realpath8, symlink } from "node:fs/promises";
|
|
27508
|
-
import { basename as basename10, dirname as
|
|
27521
|
+
import { basename as basename10, dirname as dirname22, join as join41 } from "node:path";
|
|
27509
27522
|
var HOST_METHOD_PLUGIN_NAME = "ak-methods";
|
|
27510
27523
|
var packagedMethodsDir = (root) => join41(root, "resources", "methods");
|
|
27511
27524
|
var packagedMethodPluginDir = (root) => join41(root, "dist", "method-host-plugin");
|
|
27512
27525
|
function hostMethodSkills(methods) {
|
|
27513
27526
|
return Object.freeze(methods.flatMap((method) => {
|
|
27514
27527
|
if (method.kind !== "skill") return [];
|
|
27515
|
-
const name = basename10(
|
|
27528
|
+
const name = basename10(dirname22(method.path));
|
|
27516
27529
|
return name ? [Object.freeze({ name })] : [];
|
|
27517
27530
|
}));
|
|
27518
27531
|
}
|
|
@@ -27549,7 +27562,7 @@ async function installWorkspaceMethodSkills(cwd, packageRoot) {
|
|
|
27549
27562
|
} catch (error) {
|
|
27550
27563
|
if (error.code !== "ENOENT") throw error;
|
|
27551
27564
|
}
|
|
27552
|
-
await mkdir6(
|
|
27565
|
+
await mkdir6(dirname22(link), { recursive: true });
|
|
27553
27566
|
try {
|
|
27554
27567
|
await symlink(target, link);
|
|
27555
27568
|
} catch (error) {
|
|
@@ -27566,11 +27579,11 @@ init_role_activation_flags();
|
|
|
27566
27579
|
init_submission_correctable_error();
|
|
27567
27580
|
init_navigator_invocation_identity();
|
|
27568
27581
|
async function listen(server, path) {
|
|
27569
|
-
await new Promise((
|
|
27582
|
+
await new Promise((resolve21, reject) => {
|
|
27570
27583
|
server.once("error", reject);
|
|
27571
27584
|
server.listen(path, () => {
|
|
27572
27585
|
server.off("error", reject);
|
|
27573
|
-
|
|
27586
|
+
resolve21();
|
|
27574
27587
|
});
|
|
27575
27588
|
});
|
|
27576
27589
|
}
|
|
@@ -27606,7 +27619,7 @@ async function prepareRoleEnvelope(options) {
|
|
|
27606
27619
|
const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID9();
|
|
27607
27620
|
await mkdir7(request.runDirectory, { recursive: true });
|
|
27608
27621
|
let sessionFile = options.sessionFile ?? join42(request.runDirectory, "session", "session.jsonl");
|
|
27609
|
-
await mkdir7(
|
|
27622
|
+
await mkdir7(dirname23(sessionFile), { recursive: true });
|
|
27610
27623
|
if (request.continuation.kind !== "resume") {
|
|
27611
27624
|
try {
|
|
27612
27625
|
await writeFile12(
|
|
@@ -27656,7 +27669,7 @@ async function prepareRoleEnvelope(options) {
|
|
|
27656
27669
|
getLeafEntry: () => sessionEntries.at(-1),
|
|
27657
27670
|
getLeafId: () => runId,
|
|
27658
27671
|
getEntries: () => sessionEntries,
|
|
27659
|
-
getSessionDir: () =>
|
|
27672
|
+
getSessionDir: () => dirname23(sessionFile),
|
|
27660
27673
|
getSessionFile: () => sessionFile,
|
|
27661
27674
|
getHeader: () => ({ type: "session", id: runId }),
|
|
27662
27675
|
setSessionFile(path) {
|
|
@@ -28003,8 +28016,8 @@ async function prepareRoleEnvelope(options) {
|
|
|
28003
28016
|
try {
|
|
28004
28017
|
const closeAll = server.closeAllConnections;
|
|
28005
28018
|
if (typeof closeAll === "function") closeAll.call(server);
|
|
28006
|
-
await new Promise((
|
|
28007
|
-
server.close((error) => error ? reject(error) :
|
|
28019
|
+
await new Promise((resolve21, reject) => {
|
|
28020
|
+
server.close((error) => error ? reject(error) : resolve21());
|
|
28008
28021
|
});
|
|
28009
28022
|
} catch (error) {
|
|
28010
28023
|
cleanupFailures.push(error);
|
|
@@ -28410,7 +28423,7 @@ import { spawn as spawn4, spawnSync } from "node:child_process";
|
|
|
28410
28423
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
28411
28424
|
import { existsSync as existsSync13 } from "node:fs";
|
|
28412
28425
|
import { writeFile as writeFile13 } from "node:fs/promises";
|
|
28413
|
-
import { dirname as
|
|
28426
|
+
import { dirname as dirname24, isAbsolute as isAbsolute10, join as join44, resolve as resolve20 } from "node:path";
|
|
28414
28427
|
|
|
28415
28428
|
// src/external-host-turn-loop.ts
|
|
28416
28429
|
init_host_contracts();
|
|
@@ -28631,7 +28644,7 @@ function cwdIsGitWorkTree(cwd) {
|
|
|
28631
28644
|
let dir = cwd;
|
|
28632
28645
|
for (; ; ) {
|
|
28633
28646
|
if (existsSync13(join44(dir, ".git"))) return true;
|
|
28634
|
-
const parent =
|
|
28647
|
+
const parent = dirname24(dir);
|
|
28635
28648
|
if (parent === dir) return false;
|
|
28636
28649
|
dir = parent;
|
|
28637
28650
|
}
|
|
@@ -28659,10 +28672,10 @@ function resolveGitCommonDir(cwd) {
|
|
|
28659
28672
|
if (raw === "") {
|
|
28660
28673
|
throw new Error("git rev-parse --git-common-dir returned empty stdout");
|
|
28661
28674
|
}
|
|
28662
|
-
return
|
|
28675
|
+
return isAbsolute10(raw) ? raw : resolve20(cwd, raw);
|
|
28663
28676
|
}
|
|
28664
28677
|
function spawnHeadlessTurn(options) {
|
|
28665
|
-
return new Promise((
|
|
28678
|
+
return new Promise((resolve21, reject) => {
|
|
28666
28679
|
if (options.signal?.aborted) {
|
|
28667
28680
|
reject(hostAbortedError("headless host aborted"));
|
|
28668
28681
|
return;
|
|
@@ -28737,7 +28750,7 @@ function spawnHeadlessTurn(options) {
|
|
|
28737
28750
|
reject(stdinDeliveryError);
|
|
28738
28751
|
return;
|
|
28739
28752
|
}
|
|
28740
|
-
|
|
28753
|
+
resolve21({ code, stdout: resultStdout, stderr, timedOut });
|
|
28741
28754
|
};
|
|
28742
28755
|
const onAbort = () => {
|
|
28743
28756
|
child.kill("SIGTERM");
|