@akagilnc/pi-workflow-roles 0.1.5015 → 0.1.5063
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 +2 -2
- package/README.zh-CN.md +2 -2
- package/THIRD_PARTY_NOTICES.md +8 -8
- package/dist/acp-host/production-host.js +525 -978
- package/dist/headless-host/description.js +0 -2
- package/dist/headless-host/production-host.js +528 -1014
- package/dist/host-descriptions.js +2 -3
- package/dist/migrate-book-topology.js +7 -12
- package/dist/packaged-role-registry.js +20 -18
- package/dist/pi/role-turn-host.js +3 -27
- package/dist/public-cli/cli.js +23 -2
- package/dist/public-cli/countersign-run.js +13 -8
- package/dist/public-cli/instruction-seat-run.js +75 -107
- package/dist/public-cli/invocation.js +13 -32
- package/dist/public-cli/machine-method-skills.js +150 -0
- package/dist/public-cli/main.js +549 -679
- package/dist/public-cli/post-admission.js +10 -5
- package/dist/public-cli/registry.js +2 -1
- package/dist/public-cli/run-lifecycle.js +12 -15
- package/dist/public-cli/seat-ticket-binding.js +5 -8
- package/dist/public-cli/settlement.js +12 -99
- package/dist/public-cli/turn-request.js +16 -8
- package/dist/public-role-summons.js +8 -3
- package/package.json +5 -1
- package/resources/countersign-ticket-issue.md +5 -0
- package/resources/diarist-collect.md +1 -0
- package/resources/secretariat-ticket-identity.md +15 -0
- package/scripts/build-package.mjs +1 -6
- package/src/headless-host/description.ts +0 -3
- package/src/headless-host/role-turn-host.ts +2 -23
- package/src/host-contracts.ts +2 -23
- package/src/host-descriptions.ts +2 -3
- package/src/packaged-role-registry.ts +17 -16
- package/src/pi/adapter.ts +0 -27
- package/src/pi/role-turn-host.ts +3 -31
- package/src/public-cli/cli.ts +24 -2
- package/src/public-cli/countersign-run.ts +17 -10
- package/src/public-cli/instruction-seat-run.ts +75 -105
- package/src/public-cli/invocation.ts +10 -38
- package/src/public-cli/machine-method-skills.ts +153 -0
- package/src/public-cli/post-admission.ts +12 -6
- package/src/public-cli/registry.ts +1 -0
- package/src/public-cli/run-lifecycle.ts +12 -13
- package/src/public-cli/seat-ticket-binding.ts +5 -8
- package/src/public-cli/settlement.ts +6 -138
- package/src/public-cli/turn-request.ts +24 -16
- package/src/public-role-summons.ts +16 -3
- package/src/reviewer-role.ts +1 -12
- package/src/role-envelope.ts +0 -13
- package/src/role-runtime-dependencies.ts +0 -13
- package/src/role-runtime.ts +4 -56
- package/src/worker-role.ts +1 -81
- package/dist/method-host-plugin/.claude-plugin/plugin.json +0 -5
- package/dist/method-host-plugin/skills/ak-cross-m-review/CONTEXT.md +0 -48
- package/dist/method-host-plugin/skills/ak-cross-m-review/LICENSE +0 -21
- package/dist/method-host-plugin/skills/ak-cross-m-review/SKILL.md +0 -170
- package/dist/method-host-plugin/skills/ak-cross-m-review/prompts/cmr-completeness.md +0 -118
- package/dist/method-host-plugin/skills/ak-cross-m-review/prompts/cmr-reviewer.md +0 -128
- package/dist/method-host-plugin/skills/ak-cross-m-review/provenance.json +0 -41
- package/dist/method-host-plugin/skills/diagnosing-bugs/SKILL.md +0 -134
- package/dist/method-host-plugin/skills/diagnosing-bugs/agents/openai.yaml +0 -3
- package/dist/method-host-plugin/skills/diagnosing-bugs/provenance.json +0 -31
- package/dist/method-host-plugin/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +0 -41
- package/dist/method-host-plugin/skills/resolving-merge-conflicts/SKILL.md +0 -14
- package/dist/method-host-plugin/skills/resolving-merge-conflicts/agents/openai.yaml +0 -3
- package/dist/method-host-plugin/skills/resolving-merge-conflicts/provenance.json +0 -26
- package/dist/method-host-plugin/skills/tdd/SKILL.md +0 -38
- package/dist/method-host-plugin/skills/tdd/agents/openai.yaml +0 -3
- package/dist/method-host-plugin/skills/tdd/mocking.md +0 -59
- package/dist/method-host-plugin/skills/tdd/provenance.json +0 -36
- package/dist/method-host-plugin/skills/tdd/tests.md +0 -77
- package/dist/package-resources/method-skill.js +0 -259
- package/resources/method-host-plugin/.claude-plugin/plugin.json +0 -5
- package/resources/methods/ak-cross-m-review/CONTEXT.md +0 -48
- package/resources/methods/ak-cross-m-review/LICENSE +0 -21
- package/resources/methods/ak-cross-m-review/SKILL.md +0 -170
- package/resources/methods/ak-cross-m-review/prompts/cmr-completeness.md +0 -118
- package/resources/methods/ak-cross-m-review/prompts/cmr-reviewer.md +0 -128
- package/resources/methods/ak-cross-m-review/provenance.json +0 -41
- package/resources/methods/diagnosing-bugs/SKILL.md +0 -134
- package/resources/methods/diagnosing-bugs/agents/openai.yaml +0 -3
- package/resources/methods/diagnosing-bugs/provenance.json +0 -31
- package/resources/methods/diagnosing-bugs/scripts/hitl-loop.template.sh +0 -41
- package/resources/methods/resolving-merge-conflicts/SKILL.md +0 -14
- package/resources/methods/resolving-merge-conflicts/agents/openai.yaml +0 -3
- package/resources/methods/resolving-merge-conflicts/provenance.json +0 -26
- package/resources/methods/tdd/SKILL.md +0 -38
- package/resources/methods/tdd/agents/openai.yaml +0 -3
- package/resources/methods/tdd/mocking.md +0 -59
- package/resources/methods/tdd/provenance.json +0 -36
- package/resources/methods/tdd/tests.md +0 -77
- package/src/canonical-skill-binding.ts +0 -118
- package/src/host-native-method.ts +0 -185
- package/src/package-resources/method-skill-binding.ts +0 -60
- package/src/package-resources/method-skill.ts +0 -363
|
@@ -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(
|
|
@@ -1179,12 +1179,12 @@ function createSystemCollectorClock() {
|
|
|
1179
1179
|
return {
|
|
1180
1180
|
wallNow: () => /* @__PURE__ */ new Date(),
|
|
1181
1181
|
monoNow: () => Number(process.hrtime.bigint() - start) / 1e6,
|
|
1182
|
-
sleep: (ms, signal) => new Promise((
|
|
1182
|
+
sleep: (ms, signal) => new Promise((resolve21, reject) => {
|
|
1183
1183
|
if (signal?.aborted) {
|
|
1184
1184
|
reject(signal.reason ?? new Error("aborted"));
|
|
1185
1185
|
return;
|
|
1186
1186
|
}
|
|
1187
|
-
const timer = setTimeout(
|
|
1187
|
+
const timer = setTimeout(resolve21, ms);
|
|
1188
1188
|
const onAbort = () => {
|
|
1189
1189
|
clearTimeout(timer);
|
|
1190
1190
|
reject(signal?.reason ?? new Error("aborted"));
|
|
@@ -3379,7 +3379,7 @@ __export(packaged_role_registry_exports, {
|
|
|
3379
3379
|
packagedEmitsAuthorityRefs: () => packagedEmitsAuthorityRefs,
|
|
3380
3380
|
packagedGateStageLabel: () => packagedGateStageLabel,
|
|
3381
3381
|
packagedGateSummon: () => packagedGateSummon,
|
|
3382
|
-
|
|
3382
|
+
packagedMethodSkillNames: () => packagedMethodSkillNames,
|
|
3383
3383
|
packagedModelParent: () => packagedModelParent,
|
|
3384
3384
|
packagedNavigatorSubject: () => packagedNavigatorSubject,
|
|
3385
3385
|
packagedProjectsTargetBindRejection: () => packagedProjectsTargetBindRejection,
|
|
@@ -3401,6 +3401,18 @@ __export(packaged_role_registry_exports, {
|
|
|
3401
3401
|
function packagedRoleMetadata(role) {
|
|
3402
3402
|
return PACKAGED_ROLE_REGISTRY.find((entry) => entry.role === role);
|
|
3403
3403
|
}
|
|
3404
|
+
function packagedMethodSkillNames() {
|
|
3405
|
+
const names = [];
|
|
3406
|
+
for (const record4 of PACKAGED_ROLE_REGISTRY) {
|
|
3407
|
+
if ("methodSkills" in record4 && record4.methodSkills !== void 0) {
|
|
3408
|
+
for (const name of record4.methodSkills) if (!names.includes(name)) names.push(name);
|
|
3409
|
+
}
|
|
3410
|
+
if ("applyMethod" in record4 && record4.applyMethod !== void 0 && !names.includes(record4.applyMethod)) {
|
|
3411
|
+
names.push(record4.applyMethod);
|
|
3412
|
+
}
|
|
3413
|
+
}
|
|
3414
|
+
return names;
|
|
3415
|
+
}
|
|
3404
3416
|
function isOfficerReviewSeat(role) {
|
|
3405
3417
|
const record4 = packagedRoleMetadata(role);
|
|
3406
3418
|
return record4 !== void 0 && "reviewOfficer" in record4 && record4.reviewOfficer === true;
|
|
@@ -3435,11 +3447,6 @@ function packagedRolePhaseFlag(role) {
|
|
|
3435
3447
|
function packagedRoleOutputTool(role) {
|
|
3436
3448
|
return packagedRoleMetadata(role)?.outputTool;
|
|
3437
3449
|
}
|
|
3438
|
-
function packagedMethodLoadFailureCause(role) {
|
|
3439
|
-
const record4 = packagedRoleMetadata(role);
|
|
3440
|
-
if (record4 === void 0 || !("methodLoadFailureCause" in record4)) return void 0;
|
|
3441
|
-
return record4.methodLoadFailureCause;
|
|
3442
|
-
}
|
|
3443
3450
|
function packagedBindsBoardTicket(role) {
|
|
3444
3451
|
const record4 = packagedRoleMetadata(role);
|
|
3445
3452
|
return record4?.sameParent === "board-ticket";
|
|
@@ -3642,8 +3649,7 @@ var init_packaged_role_registry = __esm({
|
|
|
3642
3649
|
{ key: "packetPath" },
|
|
3643
3650
|
{ key: "prerequisitesPath", omitUndefined: true },
|
|
3644
3651
|
{ key: "prerequisites" }
|
|
3645
|
-
]
|
|
3646
|
-
method: "observed"
|
|
3652
|
+
]
|
|
3647
3653
|
},
|
|
3648
3654
|
boardPlacement: "marshal",
|
|
3649
3655
|
activationFlags: [
|
|
@@ -3669,7 +3675,6 @@ var init_packaged_role_registry = __esm({
|
|
|
3669
3675
|
worker: true,
|
|
3670
3676
|
applyMethod: "tdd",
|
|
3671
3677
|
/** Method-material load failure keeps the activation cause (not reviewer/fixer). */
|
|
3672
|
-
methodLoadFailureCause: "activation",
|
|
3673
3678
|
boardPlacement: "coder",
|
|
3674
3679
|
phases: ["plan", "apply"],
|
|
3675
3680
|
outputTool: CODER_OUTPUT_TOOL_NAME,
|
|
@@ -3680,8 +3685,7 @@ var init_packaged_role_registry = __esm({
|
|
|
3680
3685
|
leaves: [
|
|
3681
3686
|
{ key: "phase" },
|
|
3682
3687
|
{ key: "taskPath" }
|
|
3683
|
-
]
|
|
3684
|
-
method: "optional"
|
|
3688
|
+
]
|
|
3685
3689
|
},
|
|
3686
3690
|
activationFlags: [
|
|
3687
3691
|
{ field: "taskPath", flag: "ak-coder-task", binds: "input" },
|
|
@@ -3722,8 +3726,7 @@ var init_packaged_role_registry = __esm({
|
|
|
3722
3726
|
{ key: "lens" },
|
|
3723
3727
|
{ key: "authorityRefs", copyArray: true },
|
|
3724
3728
|
{ key: "callerProvenance", callerProvenance: true }
|
|
3725
|
-
]
|
|
3726
|
-
method: "observed"
|
|
3729
|
+
]
|
|
3727
3730
|
},
|
|
3728
3731
|
/** Frozen base/lens/authority become the initial prompt; instruction follows. */
|
|
3729
3732
|
transportPrompt: "skill-args",
|
|
@@ -3822,7 +3825,6 @@ var init_packaged_role_registry = __esm({
|
|
|
3822
3825
|
methodSkills: ["resolving-merge-conflicts"],
|
|
3823
3826
|
settleMethod: "resolving-merge-conflicts",
|
|
3824
3827
|
/** Method-material load failure keeps the activation cause (not reviewer/fixer). */
|
|
3825
|
-
methodLoadFailureCause: "activation",
|
|
3826
3828
|
phases: [null],
|
|
3827
3829
|
outputTool: MERGER_OUTPUT_TOOL_NAME,
|
|
3828
3830
|
settlement: "residual",
|
|
@@ -3834,8 +3836,7 @@ var init_packaged_role_registry = __esm({
|
|
|
3834
3836
|
leaves: [
|
|
3835
3837
|
{ key: "mergerInputPath" },
|
|
3836
3838
|
{ key: "derived" }
|
|
3837
|
-
]
|
|
3838
|
-
method: "observed"
|
|
3839
|
+
]
|
|
3839
3840
|
},
|
|
3840
3841
|
activationFlags: [
|
|
3841
3842
|
{ field: "inputPath", from: "mergerInputPath", flag: "ak-merger-input", binds: "input" }
|
|
@@ -3902,7 +3903,7 @@ var init_packaged_role_registry = __esm({
|
|
|
3902
3903
|
activationStage: "load-and-install",
|
|
3903
3904
|
receiptStatusKey: "status",
|
|
3904
3905
|
// #924: 公用《票面法》三席同装
|
|
3905
|
-
sessionMaterials: ["CLAUDE.md", "souls/countersign.md", "souls/ticket-law.md"]
|
|
3906
|
+
sessionMaterials: ["CLAUDE.md", "souls/countersign.md", "souls/ticket-law.md", "resources/countersign-ticket-issue.md"]
|
|
3906
3907
|
},
|
|
3907
3908
|
{
|
|
3908
3909
|
role: "secretariat",
|
|
@@ -3910,7 +3911,7 @@ var init_packaged_role_registry = __esm({
|
|
|
3910
3911
|
presentSettled: "always",
|
|
3911
3912
|
summonResume: false,
|
|
3912
3913
|
admission: "instruction",
|
|
3913
|
-
sameParent: "
|
|
3914
|
+
sameParent: "none",
|
|
3914
3915
|
phases: [null],
|
|
3915
3916
|
outputTool: SECRETARIAT_OUTPUT_TOOL_NAME,
|
|
3916
3917
|
settlement: "accepted",
|
|
@@ -3926,6 +3927,7 @@ var init_packaged_role_registry = __esm({
|
|
|
3926
3927
|
"CLAUDE.md",
|
|
3927
3928
|
"souls/secretariat.md",
|
|
3928
3929
|
"souls/ticket-law.md",
|
|
3930
|
+
"resources/secretariat-ticket-identity.md",
|
|
3929
3931
|
"souls/countersign.md",
|
|
3930
3932
|
"souls/notary.md"
|
|
3931
3933
|
]
|
|
@@ -4563,10 +4565,10 @@ __export(session_assistant_usage_exports, {
|
|
|
4563
4565
|
});
|
|
4564
4566
|
import { join as join6 } from "node:path";
|
|
4565
4567
|
async function readAssistantUsageFromSessionFile(sessionFile) {
|
|
4566
|
-
const { readFile:
|
|
4568
|
+
const { readFile: readFile25 } = await import("node:fs/promises");
|
|
4567
4569
|
let text;
|
|
4568
4570
|
try {
|
|
4569
|
-
text = await
|
|
4571
|
+
text = await readFile25(sessionFile, "utf8");
|
|
4570
4572
|
} catch (error) {
|
|
4571
4573
|
if (error?.code === "ENOENT") return void 0;
|
|
4572
4574
|
throw error;
|
|
@@ -4965,7 +4967,7 @@ async function spawnEngineDetourOnce(input) {
|
|
|
4965
4967
|
}
|
|
4966
4968
|
const command = input.argv[0];
|
|
4967
4969
|
const args = input.argv.slice(1);
|
|
4968
|
-
return await new Promise((
|
|
4970
|
+
return await new Promise((resolve21, reject) => {
|
|
4969
4971
|
let settled = false;
|
|
4970
4972
|
const signal = input.signal;
|
|
4971
4973
|
const child = spawn2(command, args, {
|
|
@@ -4995,7 +4997,7 @@ async function spawnEngineDetourOnce(input) {
|
|
|
4995
4997
|
if (signal !== void 0) {
|
|
4996
4998
|
signal.removeEventListener("abort", onAbort);
|
|
4997
4999
|
}
|
|
4998
|
-
|
|
5000
|
+
resolve21(result);
|
|
4999
5001
|
};
|
|
5000
5002
|
const onAbort = () => {
|
|
5001
5003
|
fail4(signal !== void 0 ? abortReasonError(signal) : new Error("aborted"));
|
|
@@ -5489,7 +5491,6 @@ var role_turn_host_exports = {};
|
|
|
5489
5491
|
__export(role_turn_host_exports, {
|
|
5490
5492
|
EXPLICIT_INTERNAL_LOAD_PROBE_ARGS: () => EXPLICIT_INTERNAL_LOAD_PROBE_ARGS,
|
|
5491
5493
|
appendPiSessionCustomEntry: () => appendPiSessionCustomEntry,
|
|
5492
|
-
applyPiNativeSkillInvocation: () => applyPiNativeSkillInvocation,
|
|
5493
5494
|
buildExplicitInternalActivationArgs: () => buildExplicitInternalActivationArgs,
|
|
5494
5495
|
buildPiTurnExtraArgs: () => buildPiTurnExtraArgs,
|
|
5495
5496
|
createDefaultPiSpawnRunner: () => createDefaultPiSpawnRunner,
|
|
@@ -5499,7 +5500,7 @@ __export(role_turn_host_exports, {
|
|
|
5499
5500
|
import { execFile, spawn as spawn3 } from "node:child_process";
|
|
5500
5501
|
import { constants } from "node:fs";
|
|
5501
5502
|
import { access, appendFile, readFile as readFile5, realpath } from "node:fs/promises";
|
|
5502
|
-
import {
|
|
5503
|
+
import { delimiter, dirname as dirname6, isAbsolute as isAbsolute3, join as join11, resolve as resolve4 } from "node:path";
|
|
5503
5504
|
import { platform } from "node:process";
|
|
5504
5505
|
import { promisify } from "node:util";
|
|
5505
5506
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
@@ -5532,24 +5533,11 @@ function buildMethodArgs(methods) {
|
|
|
5532
5533
|
const skillArgs = [];
|
|
5533
5534
|
for (const method of methods) {
|
|
5534
5535
|
if (method.kind === "skill") {
|
|
5535
|
-
skillArgs.push("--skill", method.path);
|
|
5536
|
+
skillArgs.push("--skill", dirname6(method.path));
|
|
5536
5537
|
}
|
|
5537
5538
|
}
|
|
5538
5539
|
return skillArgs;
|
|
5539
5540
|
}
|
|
5540
|
-
function applyPiNativeSkillInvocation(methods, prompt) {
|
|
5541
|
-
const skills = methods.filter((method) => method.kind === "skill");
|
|
5542
|
-
if (skills.length !== 1) return prompt;
|
|
5543
|
-
const name = basename4(dirname6(skills[0].path));
|
|
5544
|
-
if (name.length === 0) return prompt;
|
|
5545
|
-
const token = `/skill:${name}`;
|
|
5546
|
-
const trimmed = prompt.trimStart();
|
|
5547
|
-
if (trimmed === token || trimmed.startsWith(`${token} `) || trimmed.startsWith(`${token}
|
|
5548
|
-
`)) {
|
|
5549
|
-
return prompt;
|
|
5550
|
-
}
|
|
5551
|
-
return prompt.length === 0 ? token : `${token} ${prompt}`;
|
|
5552
|
-
}
|
|
5553
5541
|
function buildPiTurnExtraArgs(request, authority, extraPiArgs = []) {
|
|
5554
5542
|
const { sessionFile, sessionDirectory } = authority.decode(request.principal);
|
|
5555
5543
|
return [
|
|
@@ -5581,7 +5569,7 @@ function piUserDialogueBody(request) {
|
|
|
5581
5569
|
const _exhaustive = request.continuation;
|
|
5582
5570
|
return _exhaustive;
|
|
5583
5571
|
})();
|
|
5584
|
-
return
|
|
5572
|
+
return rawPrompt;
|
|
5585
5573
|
}
|
|
5586
5574
|
async function resolveSelectedPi(command, cwd, env) {
|
|
5587
5575
|
const searchPath = env.PATH ?? (platform === "win32" ? process.env.PATH ?? "" : "/usr/bin:/bin");
|
|
@@ -6863,7 +6851,7 @@ var init_session_dialogue = __esm({
|
|
|
6863
6851
|
// src/ticket-provenance.ts
|
|
6864
6852
|
import { createHash as createHash6 } from "node:crypto";
|
|
6865
6853
|
import { readFile as readFile9, unlink } from "node:fs/promises";
|
|
6866
|
-
import { basename as
|
|
6854
|
+
import { basename as basename4, dirname as dirname8, join as join13, resolve as resolve7 } from "node:path";
|
|
6867
6855
|
function dialogueSessionSourceRoots(home) {
|
|
6868
6856
|
const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
|
|
6869
6857
|
return [
|
|
@@ -6876,7 +6864,7 @@ function isLedgerRoleSessionFile(absolute, home) {
|
|
|
6876
6864
|
const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
|
|
6877
6865
|
const ledgerHome = resolveActivationLedgerHome(machineHome);
|
|
6878
6866
|
if (!physicallyContainedIn(ledgerHome, absolute)) return false;
|
|
6879
|
-
return
|
|
6867
|
+
return basename4(absolute) === "session.jsonl" && basename4(dirname8(absolute)) === "session";
|
|
6880
6868
|
}
|
|
6881
6869
|
function assertDialogueSessionSourcePath(path, home) {
|
|
6882
6870
|
const absolute = resolve7(path);
|
|
@@ -7569,7 +7557,7 @@ __export(run_lifecycle_exports, {
|
|
|
7569
7557
|
writeRoleRunState: () => writeRoleRunState
|
|
7570
7558
|
});
|
|
7571
7559
|
import { chmod, lstat as lstat2, open, readdir as readdir4, readFile as readFile11, unlink as unlink3, writeFile as writeFile3 } from "node:fs/promises";
|
|
7572
|
-
import { basename as
|
|
7560
|
+
import { basename as basename5, join as join15 } from "node:path";
|
|
7573
7561
|
function buildAutoResumeContinuationPrompt(options) {
|
|
7574
7562
|
return appendEngineSessionMaterial(
|
|
7575
7563
|
[RESUME_TRANSPORT_ENVELOPE],
|
|
@@ -8082,7 +8070,7 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
|
8082
8070
|
throw error;
|
|
8083
8071
|
}
|
|
8084
8072
|
for (const runDirectory of runDirectories) {
|
|
8085
|
-
const entry =
|
|
8073
|
+
const entry = basename5(runDirectory);
|
|
8086
8074
|
if (onlyRole === void 0 && (entry === `${runId}@judge` || entry.startsWith(`${runId}@`)) || entry === `${runId}@${onlyRole}`) {
|
|
8087
8075
|
matches.push(runDirectory);
|
|
8088
8076
|
}
|
|
@@ -8151,12 +8139,12 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
8151
8139
|
const suffix = `@${input.role}`;
|
|
8152
8140
|
let best;
|
|
8153
8141
|
for (const runDirectory of runDirectories) {
|
|
8154
|
-
const entry =
|
|
8142
|
+
const entry = basename5(runDirectory);
|
|
8155
8143
|
if (!entry.endsWith(suffix)) continue;
|
|
8156
8144
|
const runId = entry.slice(0, entry.length - suffix.length);
|
|
8157
8145
|
if (runId.length === 0) continue;
|
|
8158
8146
|
const parentPath = await readRunParentPath(runDirectory);
|
|
8159
|
-
if (parentPath !== input.parentRunPath) continue;
|
|
8147
|
+
if (parentPath !== input.parentRunPath && basename5(parentPath ?? "") !== basename5(input.parentRunPath)) continue;
|
|
8160
8148
|
if (!await runHasFormedSessionPrincipal(runDirectory)) continue;
|
|
8161
8149
|
if (best === void 0 || runId > best) best = runId;
|
|
8162
8150
|
}
|
|
@@ -8218,7 +8206,7 @@ function restoredTicketFields(fields) {
|
|
|
8218
8206
|
...fields.courtTicketNumbers === void 0 ? {} : { courtTicketNumbers: fields.courtTicketNumbers }
|
|
8219
8207
|
};
|
|
8220
8208
|
}
|
|
8221
|
-
async function loadResumableRunRecord(home, runId, authority) {
|
|
8209
|
+
async function loadResumableRunRecord(home, runId, authority, allowUnformedAdmitted = false) {
|
|
8222
8210
|
const runDirectory = await findRunDirectoryById(home, runId);
|
|
8223
8211
|
if (runDirectory === void 0) {
|
|
8224
8212
|
throw new CliUsageError(`unknown role run id: ${runId}`);
|
|
@@ -8232,7 +8220,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
8232
8220
|
throw new CliUsageError(`unknown role run id: ${runId}`);
|
|
8233
8221
|
}
|
|
8234
8222
|
const { run, principal } = materialized;
|
|
8235
|
-
if (!await isDurablePrincipalAvailable(principal, authority)) {
|
|
8223
|
+
if (!(allowUnformedAdmitted && run.state === "admitted") && !await isDurablePrincipalAvailable(principal, authority)) {
|
|
8236
8224
|
throw new CliUsageError(
|
|
8237
8225
|
`role run Pi session principal is unavailable: ${runId}`
|
|
8238
8226
|
);
|
|
@@ -8431,7 +8419,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
8431
8419
|
} else if (mergedSet.tickets !== void 0) {
|
|
8432
8420
|
courtTicketNumbers = mergedSet.tickets;
|
|
8433
8421
|
}
|
|
8434
|
-
const sourceRunLeaf =
|
|
8422
|
+
const sourceRunLeaf = basename5(sourceRunPath ?? "").split("@");
|
|
8435
8423
|
const referencedRunId = sourceRun?.runId ?? sourceRunLeaf[0];
|
|
8436
8424
|
const referencedRole = sourceRun?.role ?? sourceRunLeaf[1];
|
|
8437
8425
|
if (referencedRunId !== void 0 && referencedRunId !== "") {
|
|
@@ -8513,8 +8501,8 @@ async function peekRoleRunRole(home, runId) {
|
|
|
8513
8501
|
const run = await readRoleRunIdentity(runDirectory);
|
|
8514
8502
|
return run?.role;
|
|
8515
8503
|
}
|
|
8516
|
-
async function loadResumablePublicRole(home, runId, authority) {
|
|
8517
|
-
const loaded = await loadResumableRunRecord(home, runId, authority);
|
|
8504
|
+
async function loadResumablePublicRole(home, runId, authority, allowUnformedAdmitted = false) {
|
|
8505
|
+
const loaded = await loadResumableRunRecord(home, runId, authority, allowUnformedAdmitted);
|
|
8518
8506
|
return seatLoadedResult(loaded, admitResumedRole(loaded));
|
|
8519
8507
|
}
|
|
8520
8508
|
function admitResumedRole(loaded) {
|
|
@@ -8776,7 +8764,7 @@ var init_run_lifecycle = __esm({
|
|
|
8776
8764
|
});
|
|
8777
8765
|
|
|
8778
8766
|
// src/notary-source-run.ts
|
|
8779
|
-
import { dirname as dirname9, isAbsolute as isAbsolute6, join as join16, resolve as resolve8, basename as
|
|
8767
|
+
import { dirname as dirname9, isAbsolute as isAbsolute6, join as join16, resolve as resolve8, basename as basename6 } from "node:path";
|
|
8780
8768
|
import { lstat as lstat3, realpath as realpath3 } from "node:fs/promises";
|
|
8781
8769
|
async function readRetainedIdentity(runDirectory) {
|
|
8782
8770
|
try {
|
|
@@ -8817,10 +8805,10 @@ async function requireRunDirectory(candidate, display) {
|
|
|
8817
8805
|
`notary --source-run must be a run directory: ${display}`
|
|
8818
8806
|
);
|
|
8819
8807
|
}
|
|
8820
|
-
const identity = parseRunDirectoryName(
|
|
8808
|
+
const identity = parseRunDirectoryName(basename6(real));
|
|
8821
8809
|
if (identity === void 0) {
|
|
8822
8810
|
throw new NotarySourceRunError(
|
|
8823
|
-
`notary --source-run must be named <runId>@<role>: ${
|
|
8811
|
+
`notary --source-run must be named <runId>@<role>: ${basename6(real)}`
|
|
8824
8812
|
);
|
|
8825
8813
|
}
|
|
8826
8814
|
return real;
|
|
@@ -8840,9 +8828,9 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
8840
8828
|
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join16(bookRunsRoot, `${bare.runId}@${bare.role}`);
|
|
8841
8829
|
} else {
|
|
8842
8830
|
candidate = isAbsolute6(raw) ? raw : resolve8(options.projectRoot, raw);
|
|
8843
|
-
const identity2 = parseRunDirectoryName(
|
|
8831
|
+
const identity2 = parseRunDirectoryName(basename6(candidate));
|
|
8844
8832
|
const subjectDirectory = dirname9(dirname9(candidate));
|
|
8845
|
-
const isLegacyUnboundLocator = identity2 !== void 0 &&
|
|
8833
|
+
const isLegacyUnboundLocator = identity2 !== void 0 && basename6(dirname9(candidate)) === "runs" && basename6(subjectDirectory) === "unbound" && resolve8(dirname9(subjectDirectory)) === resolve8(bookDirectory);
|
|
8846
8834
|
if (isLegacyUnboundLocator) {
|
|
8847
8835
|
candidate = await findRunDirectoryById(
|
|
8848
8836
|
options.home,
|
|
@@ -8853,11 +8841,11 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
8853
8841
|
}
|
|
8854
8842
|
}
|
|
8855
8843
|
const real = await requireRunDirectory(candidate, raw);
|
|
8856
|
-
const identity = parseRunDirectoryName(
|
|
8844
|
+
const identity = parseRunDirectoryName(basename6(real));
|
|
8857
8845
|
const bookIdentity = physicalPathIdentity(bookDirectory);
|
|
8858
8846
|
const parentIdentity = physicalPathIdentity(dirname9(real));
|
|
8859
8847
|
const subjectBookIdentity = physicalPathIdentity(dirname9(dirname9(dirname9(real))));
|
|
8860
|
-
if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(
|
|
8848
|
+
if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename6(dirname9(real)) === "runs" && subjectBookIdentity === bookIdentity)) {
|
|
8861
8849
|
throw new NotarySourceRunError(
|
|
8862
8850
|
"notary --source-run must resolve to a retained run under the project machine-ledger book"
|
|
8863
8851
|
);
|
|
@@ -8891,7 +8879,7 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
8891
8879
|
}
|
|
8892
8880
|
async function loadNotarySourceRunLocator(path) {
|
|
8893
8881
|
const real = await requireRunDirectory(path, path);
|
|
8894
|
-
const identity = parseRunDirectoryName(
|
|
8882
|
+
const identity = parseRunDirectoryName(basename6(real));
|
|
8895
8883
|
const runState = await readRetainedIdentity(real);
|
|
8896
8884
|
if (runState === void 0) {
|
|
8897
8885
|
throw new NotarySourceRunError(
|
|
@@ -8998,7 +8986,8 @@ var init_registry = __esm({
|
|
|
8998
8986
|
"config",
|
|
8999
8987
|
"help",
|
|
9000
8988
|
"resume",
|
|
9001
|
-
"new"
|
|
8989
|
+
"new",
|
|
8990
|
+
"setup"
|
|
9002
8991
|
];
|
|
9003
8992
|
PUBLIC_DETERMINISTIC_COMMANDS = ["analyst"];
|
|
9004
8993
|
}
|
|
@@ -10066,7 +10055,7 @@ import {
|
|
|
10066
10055
|
writeFile as writeFile4
|
|
10067
10056
|
} from "node:fs/promises";
|
|
10068
10057
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
10069
|
-
import { basename as
|
|
10058
|
+
import { basename as basename7, dirname as dirname10, isAbsolute as isAbsolute7, join as join17, resolve as resolve9, sep as sep4 } from "node:path";
|
|
10070
10059
|
function issueAdmissionPlacement(authority, request) {
|
|
10071
10060
|
const ledgerHome = resolveActivationLedgerHome(request.home);
|
|
10072
10061
|
const bookKey = resolveBookKeyFromGit(request.cwd);
|
|
@@ -10192,12 +10181,7 @@ async function persistAdmittedSourceRunPath(admitted, sourceRunPath) {
|
|
|
10192
10181
|
);
|
|
10193
10182
|
}
|
|
10194
10183
|
async function bindAdmittedTicketNumber(admitted, ticketNumber) {
|
|
10195
|
-
if (admitted.ticketNumber
|
|
10196
|
-
if (admitted.ticketNumber === ticketNumber) return;
|
|
10197
|
-
throw new Error(
|
|
10198
|
-
`bindAdmittedTicketNumber refuses to replace existing ticket #${admitted.ticketNumber} with #${ticketNumber}`
|
|
10199
|
-
);
|
|
10200
|
-
}
|
|
10184
|
+
if (admitted.ticketNumber === ticketNumber) return;
|
|
10201
10185
|
await bindTicketNumberOnRunDirectory(admitted.runDirectory, ticketNumber);
|
|
10202
10186
|
admitted.ticketNumber = ticketNumber;
|
|
10203
10187
|
}
|
|
@@ -10281,6 +10265,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
10281
10265
|
for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
|
|
10282
10266
|
if (typeof childRunId !== "string") continue;
|
|
10283
10267
|
const childDirectory = join17(dirname10(oldRunDirectory), `${childRunId}@diarist`);
|
|
10268
|
+
if (!existsSync4(childDirectory)) continue;
|
|
10284
10269
|
const childTarget = roleRunPlacement(ledgerHome, {
|
|
10285
10270
|
bookKey: admitted.bookKey,
|
|
10286
10271
|
subject: { ticketNumber: admitted.ticketNumber },
|
|
@@ -10288,7 +10273,6 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
10288
10273
|
role: "diarist"
|
|
10289
10274
|
});
|
|
10290
10275
|
authority.seal(childTarget);
|
|
10291
|
-
if (!existsSync4(childDirectory) && existsSync4(childTarget.runDirectory)) continue;
|
|
10292
10276
|
await bindTicketNumberOnRunDirectory(childDirectory, admitted.ticketNumber);
|
|
10293
10277
|
await rehomeUnboundTicketProvenance(childDirectory, admitted.ticketNumber, admitted.projectRoot, homeFromRunDirectory(oldRunDirectory));
|
|
10294
10278
|
ensureRoleRunDirectory(ledgerHome, dirname10(childTarget.runDirectory));
|
|
@@ -10338,25 +10322,8 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
|
10338
10322
|
"bindTicketNumberOnRunDirectory"
|
|
10339
10323
|
);
|
|
10340
10324
|
const admittedPath = join17(runDirectory, "admitted-request.json");
|
|
10341
|
-
const invocationPath = join17(runDirectory, "invocation.json");
|
|
10342
10325
|
const admitted = JSON.parse(await readFile12(admittedPath, "utf8"));
|
|
10343
|
-
|
|
10344
|
-
if (typeof existing === "number") {
|
|
10345
|
-
if (existing === ticketNumber) return;
|
|
10346
|
-
throw new Error(
|
|
10347
|
-
`bindTicketNumberOnRunDirectory refuses to replace existing ticket #${existing} with #${ticketNumber}`
|
|
10348
|
-
);
|
|
10349
|
-
}
|
|
10350
|
-
if (existsSync4(invocationPath)) {
|
|
10351
|
-
const invocation = JSON.parse(
|
|
10352
|
-
await readFile12(invocationPath, "utf8")
|
|
10353
|
-
);
|
|
10354
|
-
if (typeof invocation.ticketNumber === "number" && invocation.ticketNumber !== ticketNumber) {
|
|
10355
|
-
throw new Error(
|
|
10356
|
-
`bindTicketNumberOnRunDirectory refuses to replace invocation ticket #${invocation.ticketNumber} with #${ticketNumber}`
|
|
10357
|
-
);
|
|
10358
|
-
}
|
|
10359
|
-
}
|
|
10326
|
+
if (admitted.ticketNumber === ticketNumber) return;
|
|
10360
10327
|
await writeFile4(
|
|
10361
10328
|
admittedPath,
|
|
10362
10329
|
`${JSON.stringify({ ...admitted, ticketNumber }, null, 2)}
|
|
@@ -10703,7 +10670,7 @@ async function withPreparedAttachments(attachmentPaths, use) {
|
|
|
10703
10670
|
async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, index) {
|
|
10704
10671
|
const frozenPath = join17(
|
|
10705
10672
|
destinationDir,
|
|
10706
|
-
`${String(index).padStart(2, "0")}-${
|
|
10673
|
+
`${String(index).padStart(2, "0")}-${basename7(provenancePath)}`
|
|
10707
10674
|
);
|
|
10708
10675
|
await writeFile4(frozenPath, bytes);
|
|
10709
10676
|
return {
|
|
@@ -12877,10 +12844,10 @@ function pairGateRounds(volumes) {
|
|
|
12877
12844
|
return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
|
|
12878
12845
|
}
|
|
12879
12846
|
async function resolveOfficerSessionFromPointerFile(pointerPath) {
|
|
12880
|
-
const { readFile:
|
|
12847
|
+
const { readFile: readFile25 } = await import("node:fs/promises");
|
|
12881
12848
|
let raw;
|
|
12882
12849
|
try {
|
|
12883
|
-
raw = JSON.parse(await
|
|
12850
|
+
raw = JSON.parse(await readFile25(pointerPath, "utf8"));
|
|
12884
12851
|
} catch (error) {
|
|
12885
12852
|
throw new Error(
|
|
12886
12853
|
`direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -13979,243 +13946,6 @@ var init_dossier_resolution = __esm({
|
|
|
13979
13946
|
}
|
|
13980
13947
|
});
|
|
13981
13948
|
|
|
13982
|
-
// src/package-resources/method-skill.ts
|
|
13983
|
-
import { createHash as createHash7 } from "node:crypto";
|
|
13984
|
-
import { readFile as readFile15, realpath as realpath5 } from "node:fs/promises";
|
|
13985
|
-
import { join as join26 } from "node:path";
|
|
13986
|
-
function gitBlobOid(bytes) {
|
|
13987
|
-
const body = typeof bytes === "string" ? Buffer.from(bytes, "utf8") : Buffer.from(bytes);
|
|
13988
|
-
const header = Buffer.from(`blob ${body.byteLength}\0`, "utf8");
|
|
13989
|
-
return createHash7("sha1").update(header).update(body).digest("hex");
|
|
13990
|
-
}
|
|
13991
|
-
function stripSkillFrontmatter(content) {
|
|
13992
|
-
if (!content.startsWith("---")) return content;
|
|
13993
|
-
const end = content.indexOf("\n---", 3);
|
|
13994
|
-
if (end === -1) return content;
|
|
13995
|
-
const after = content.slice(end + "\n---".length);
|
|
13996
|
-
return after.replace(/^\r?\n/, "");
|
|
13997
|
-
}
|
|
13998
|
-
function packagedMethodSkillRelativeDirectory(name) {
|
|
13999
|
-
return `${METHOD_SKILL_RELATIVE_ROOT}/${name}`;
|
|
14000
|
-
}
|
|
14001
|
-
function resolvePackagedMethodSkillRoot(packageRoot, name) {
|
|
14002
|
-
return join26(packageRoot, packagedMethodSkillRelativeDirectory(name));
|
|
14003
|
-
}
|
|
14004
|
-
function resolvePackagedMethodSkillPath(packageRoot, name) {
|
|
14005
|
-
return join26(resolvePackagedMethodSkillRoot(packageRoot, name), "SKILL.md");
|
|
14006
|
-
}
|
|
14007
|
-
function isRecord11(value) {
|
|
14008
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
14009
|
-
}
|
|
14010
|
-
function parseProvenance(raw, expectedName) {
|
|
14011
|
-
if (!isRecord11(raw)) {
|
|
14012
|
-
throw new Error(`Packaged method provenance must be an object for ${expectedName}`);
|
|
14013
|
-
}
|
|
14014
|
-
if (raw.name !== expectedName) {
|
|
14015
|
-
throw new Error(
|
|
14016
|
-
`Packaged method provenance name mismatch: expected ${expectedName}, got ${String(raw.name)}`
|
|
14017
|
-
);
|
|
14018
|
-
}
|
|
14019
|
-
if (raw.kind !== "role-method-skill") {
|
|
14020
|
-
throw new Error(`Packaged method provenance kind must be role-method-skill`);
|
|
14021
|
-
}
|
|
14022
|
-
if (typeof raw.packageAdaptation !== "string" || raw.packageAdaptation.trim() === "") {
|
|
14023
|
-
throw new Error(`Packaged method provenance packageAdaptation must be nonblank`);
|
|
14024
|
-
}
|
|
14025
|
-
if (!isRecord11(raw.upstream)) {
|
|
14026
|
-
throw new Error(`Packaged method provenance upstream must be an object`);
|
|
14027
|
-
}
|
|
14028
|
-
const upstream = raw.upstream;
|
|
14029
|
-
for (const key of [
|
|
14030
|
-
"repository",
|
|
14031
|
-
"path",
|
|
14032
|
-
"license",
|
|
14033
|
-
"copyright",
|
|
14034
|
-
"attribution"
|
|
14035
|
-
]) {
|
|
14036
|
-
if (typeof upstream[key] !== "string" || upstream[key].trim() === "") {
|
|
14037
|
-
throw new Error(`Packaged method provenance upstream.${key} must be nonblank`);
|
|
14038
|
-
}
|
|
14039
|
-
}
|
|
14040
|
-
if (typeof upstream.commit !== "string" || !GIT_COMMIT_RE.test(upstream.commit)) {
|
|
14041
|
-
throw new Error(
|
|
14042
|
-
`Packaged method provenance upstream.commit must be a 40-char lowercase git object id`
|
|
14043
|
-
);
|
|
14044
|
-
}
|
|
14045
|
-
const tag = typeof upstream.tag === "string" && upstream.tag.trim() !== "" ? upstream.tag.trim() : void 0;
|
|
14046
|
-
const version = typeof upstream.version === "string" && upstream.version.trim() !== "" ? upstream.version.trim() : void 0;
|
|
14047
|
-
if (tag === void 0 && version === void 0) {
|
|
14048
|
-
throw new Error(
|
|
14049
|
-
`Packaged method provenance upstream must include nonblank tag or version`
|
|
14050
|
-
);
|
|
14051
|
-
}
|
|
14052
|
-
if (!isRecord11(raw.files)) {
|
|
14053
|
-
throw new Error(`Packaged method provenance files must be an object`);
|
|
14054
|
-
}
|
|
14055
|
-
const files = {};
|
|
14056
|
-
for (const [rel, entry] of Object.entries(raw.files)) {
|
|
14057
|
-
if (!isRecord11(entry)) {
|
|
14058
|
-
throw new Error(`Packaged method provenance file entry must be an object: ${rel}`);
|
|
14059
|
-
}
|
|
14060
|
-
if (typeof entry.sha256 !== "string" || !SHA256_RE.test(entry.sha256)) {
|
|
14061
|
-
throw new Error(`Packaged method provenance file sha256 invalid: ${rel}`);
|
|
14062
|
-
}
|
|
14063
|
-
if (typeof entry.byteLength !== "number" || !Number.isInteger(entry.byteLength) || entry.byteLength < 0) {
|
|
14064
|
-
throw new Error(`Packaged method provenance file byteLength invalid: ${rel}`);
|
|
14065
|
-
}
|
|
14066
|
-
if (typeof entry.gitBlob !== "string" || !GIT_BLOB_RE.test(entry.gitBlob)) {
|
|
14067
|
-
throw new Error(
|
|
14068
|
-
`Packaged method provenance file gitBlob must be a 40-char lowercase git object id: ${rel}`
|
|
14069
|
-
);
|
|
14070
|
-
}
|
|
14071
|
-
files[rel] = {
|
|
14072
|
-
sha256: entry.sha256,
|
|
14073
|
-
byteLength: entry.byteLength,
|
|
14074
|
-
gitBlob: entry.gitBlob
|
|
14075
|
-
};
|
|
14076
|
-
}
|
|
14077
|
-
if (files["SKILL.md"] === void 0) {
|
|
14078
|
-
throw new Error(`Packaged method provenance must include SKILL.md`);
|
|
14079
|
-
}
|
|
14080
|
-
return Object.freeze({
|
|
14081
|
-
name: expectedName,
|
|
14082
|
-
kind: "role-method-skill",
|
|
14083
|
-
packageAdaptation: raw.packageAdaptation,
|
|
14084
|
-
upstream: Object.freeze({
|
|
14085
|
-
repository: upstream.repository,
|
|
14086
|
-
path: upstream.path,
|
|
14087
|
-
commit: upstream.commit,
|
|
14088
|
-
...tag === void 0 ? {} : { tag },
|
|
14089
|
-
...version === void 0 ? {} : { version },
|
|
14090
|
-
license: upstream.license,
|
|
14091
|
-
copyright: upstream.copyright,
|
|
14092
|
-
attribution: upstream.attribution
|
|
14093
|
-
}),
|
|
14094
|
-
files: Object.freeze(files)
|
|
14095
|
-
});
|
|
14096
|
-
}
|
|
14097
|
-
async function loadPackagedMethodSkillMaterial(packageRoot, name) {
|
|
14098
|
-
const rootDirectory = resolvePackagedMethodSkillRoot(packageRoot, name);
|
|
14099
|
-
const skillPathConfigured = join26(rootDirectory, "SKILL.md");
|
|
14100
|
-
const provenancePath = join26(rootDirectory, "provenance.json");
|
|
14101
|
-
let provenanceRaw;
|
|
14102
|
-
try {
|
|
14103
|
-
provenanceRaw = await readFile15(provenancePath, "utf8");
|
|
14104
|
-
} catch (error) {
|
|
14105
|
-
throw new PackagedMethodSkillUnavailableError(name, provenancePath, error);
|
|
14106
|
-
}
|
|
14107
|
-
let provenanceJson;
|
|
14108
|
-
try {
|
|
14109
|
-
provenanceJson = JSON.parse(provenanceRaw);
|
|
14110
|
-
} catch (error) {
|
|
14111
|
-
throw new Error(`Packaged method provenance is not valid JSON at ${provenancePath}`, {
|
|
14112
|
-
cause: error
|
|
14113
|
-
});
|
|
14114
|
-
}
|
|
14115
|
-
const provenance = parseProvenance(provenanceJson, name);
|
|
14116
|
-
for (const [rel, expected] of Object.entries(provenance.files)) {
|
|
14117
|
-
const absolute = join26(rootDirectory, rel);
|
|
14118
|
-
let bytes;
|
|
14119
|
-
try {
|
|
14120
|
-
bytes = await readFile15(absolute);
|
|
14121
|
-
} catch (error) {
|
|
14122
|
-
throw new PackagedMethodSkillUnavailableError(name, absolute, error);
|
|
14123
|
-
}
|
|
14124
|
-
const actualSha = sha256Hex(bytes);
|
|
14125
|
-
const actualBlob = gitBlobOid(bytes);
|
|
14126
|
-
if (actualSha !== expected.sha256 || bytes.byteLength !== expected.byteLength || actualBlob !== expected.gitBlob) {
|
|
14127
|
-
throw new Error(
|
|
14128
|
-
`Packaged method file digest mismatch for ${name}/${rel}: expected sha256=${expected.sha256} byteLength=${expected.byteLength} gitBlob=${expected.gitBlob}, got sha256=${actualSha} byteLength=${bytes.byteLength} gitBlob=${actualBlob}`
|
|
14129
|
-
);
|
|
14130
|
-
}
|
|
14131
|
-
}
|
|
14132
|
-
let skillPath;
|
|
14133
|
-
let raw;
|
|
14134
|
-
try {
|
|
14135
|
-
skillPath = await realpath5(skillPathConfigured);
|
|
14136
|
-
raw = await readFile15(skillPath, "utf8");
|
|
14137
|
-
} catch (error) {
|
|
14138
|
-
throw new PackagedMethodSkillUnavailableError(name, skillPathConfigured, error);
|
|
14139
|
-
}
|
|
14140
|
-
const body = stripSkillFrontmatter(raw).trim();
|
|
14141
|
-
if (body.length === 0) {
|
|
14142
|
-
throw new Error(`Canonical ${name} Skill is empty at ${skillPath}`);
|
|
14143
|
-
}
|
|
14144
|
-
const companionRelativePaths = REQUIRED_COMPANIONS[name].filter(
|
|
14145
|
-
(rel) => provenance.files[rel] !== void 0
|
|
14146
|
-
);
|
|
14147
|
-
for (const rel of REQUIRED_COMPANIONS[name]) {
|
|
14148
|
-
if (provenance.files[rel] === void 0) {
|
|
14149
|
-
throw new Error(
|
|
14150
|
-
`Packaged method ${name} missing required companion in provenance: ${rel}`
|
|
14151
|
-
);
|
|
14152
|
-
}
|
|
14153
|
-
}
|
|
14154
|
-
return Object.freeze({
|
|
14155
|
-
name,
|
|
14156
|
-
rootDirectory,
|
|
14157
|
-
skillPath,
|
|
14158
|
-
raw,
|
|
14159
|
-
body,
|
|
14160
|
-
provenance,
|
|
14161
|
-
companionRelativePaths: Object.freeze([...companionRelativePaths])
|
|
14162
|
-
});
|
|
14163
|
-
}
|
|
14164
|
-
function observePackagedMethodSkillInvocation(text, expected) {
|
|
14165
|
-
if (!text.startsWith('<skill name="')) return void 0;
|
|
14166
|
-
const nameStart = '<skill name="'.length;
|
|
14167
|
-
const nameEnd = text.indexOf('"', nameStart);
|
|
14168
|
-
if (nameEnd <= nameStart) return void 0;
|
|
14169
|
-
const name = text.slice(nameStart, nameEnd);
|
|
14170
|
-
if (name !== expected.name) return void 0;
|
|
14171
|
-
const locationMarker = '" location="';
|
|
14172
|
-
if (!text.startsWith(locationMarker, nameEnd)) return void 0;
|
|
14173
|
-
const locationStart = nameEnd + locationMarker.length;
|
|
14174
|
-
const locationEnd = text.indexOf('"', locationStart);
|
|
14175
|
-
if (locationEnd <= locationStart) return void 0;
|
|
14176
|
-
const location = text.slice(locationStart, locationEnd);
|
|
14177
|
-
const openTail = ">\n";
|
|
14178
|
-
if (!text.startsWith(openTail, locationEnd + 1)) return void 0;
|
|
14179
|
-
const closeTag = "\n</skill>";
|
|
14180
|
-
const closeAt = text.indexOf(closeTag, locationEnd + 1 + openTail.length);
|
|
14181
|
-
if (closeAt === -1) return void 0;
|
|
14182
|
-
const afterClose = text.slice(closeAt + closeTag.length);
|
|
14183
|
-
if (afterClose.length > 0 && !afterClose.startsWith("\n")) return void 0;
|
|
14184
|
-
if (!expected.allowedLocations.includes(location)) return void 0;
|
|
14185
|
-
return Object.freeze({ name: expected.name, location });
|
|
14186
|
-
}
|
|
14187
|
-
var PackagedMethodSkillUnavailableError, METHOD_SKILL_RELATIVE_ROOT, GIT_COMMIT_RE, GIT_BLOB_RE, SHA256_RE, REQUIRED_COMPANIONS;
|
|
14188
|
-
var init_method_skill = __esm({
|
|
14189
|
-
"src/package-resources/method-skill.ts"() {
|
|
14190
|
-
"use strict";
|
|
14191
|
-
init_sha256();
|
|
14192
|
-
PackagedMethodSkillUnavailableError = class extends Error {
|
|
14193
|
-
constructor(skillName, path, cause) {
|
|
14194
|
-
super(`Canonical ${skillName} Skill is unavailable at ${path}`, { cause });
|
|
14195
|
-
this.skillName = skillName;
|
|
14196
|
-
this.name = "CanonicalSkillUnavailableError";
|
|
14197
|
-
}
|
|
14198
|
-
skillName;
|
|
14199
|
-
code = "canonical-skill-unavailable";
|
|
14200
|
-
};
|
|
14201
|
-
METHOD_SKILL_RELATIVE_ROOT = "resources/methods";
|
|
14202
|
-
GIT_COMMIT_RE = /^[0-9a-f]{40}$/;
|
|
14203
|
-
GIT_BLOB_RE = /^[0-9a-f]{40}$/;
|
|
14204
|
-
SHA256_RE = /^[0-9a-f]{64}$/;
|
|
14205
|
-
REQUIRED_COMPANIONS = {
|
|
14206
|
-
tdd: ["tests.md", "mocking.md", "agents/openai.yaml"],
|
|
14207
|
-
"diagnosing-bugs": ["agents/openai.yaml", "scripts/hitl-loop.template.sh"],
|
|
14208
|
-
"ak-cross-m-review": [
|
|
14209
|
-
"CONTEXT.md",
|
|
14210
|
-
"LICENSE",
|
|
14211
|
-
"prompts/cmr-completeness.md",
|
|
14212
|
-
"prompts/cmr-reviewer.md"
|
|
14213
|
-
],
|
|
14214
|
-
"resolving-merge-conflicts": ["agents/openai.yaml"]
|
|
14215
|
-
};
|
|
14216
|
-
}
|
|
14217
|
-
});
|
|
14218
|
-
|
|
14219
13949
|
// src/work-subject-identity.ts
|
|
14220
13950
|
import { resolve as resolve11 } from "node:path";
|
|
14221
13951
|
function issueRoot(value) {
|
|
@@ -14427,11 +14157,11 @@ var init_navigator_invocation_identity = __esm({
|
|
|
14427
14157
|
});
|
|
14428
14158
|
|
|
14429
14159
|
// src/receipt-delivery-policy.ts
|
|
14430
|
-
function
|
|
14160
|
+
function isRecord11(value) {
|
|
14431
14161
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
14432
14162
|
}
|
|
14433
14163
|
function parseNoReceiptLifecycleFacts(input) {
|
|
14434
|
-
if (!
|
|
14164
|
+
if (!isRecord11(input) || typeof input.terminalToolCalled !== "boolean" || input.deliveryTurns !== RECEIPT_DELIVERY_TURN_LIMIT || input.sessionCompletion !== "settled-without-accepted-receipt" || input.acceptedReceipt !== false || typeof input.runPointer !== "string" || input.runPointer.trim() === "" || typeof input.attemptPointer !== "string" || input.attemptPointer.trim() === "" || !Array.isArray(input.rejectedReceipts) || !input.rejectedReceipts.every((item) => isRecord11(item) && typeof item.reason === "string")) {
|
|
14435
14165
|
throw new TypeError("malformed no-receipt lifecycle facts");
|
|
14436
14166
|
}
|
|
14437
14167
|
return {
|
|
@@ -14539,7 +14269,6 @@ __export(settlement_exports, {
|
|
|
14539
14269
|
formatTerminalResult: () => formatTerminalResult,
|
|
14540
14270
|
inspectJudgeSession: () => inspectJudgeSession,
|
|
14541
14271
|
isLawfulTypedTerminalOutcome: () => isLawfulTypedTerminalOutcome,
|
|
14542
|
-
observedMethodSkillOptions: () => observedMethodSkillOptions,
|
|
14543
14272
|
presentControlledFailure: () => presentControlledFailure,
|
|
14544
14273
|
presentFailureTerminal: () => presentFailureTerminal,
|
|
14545
14274
|
presentStructuralRejection: () => presentStructuralRejection,
|
|
@@ -14566,15 +14295,15 @@ __export(settlement_exports, {
|
|
|
14566
14295
|
withSubmissions: () => withSubmissions
|
|
14567
14296
|
});
|
|
14568
14297
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
14569
|
-
import { appendFile as appendFile2, readFile as
|
|
14570
|
-
import { dirname as dirname14, join as
|
|
14298
|
+
import { appendFile as appendFile2, readFile as readFile15, readdir as readdir6, rm as rm3, writeFile as writeFile6 } from "node:fs/promises";
|
|
14299
|
+
import { dirname as dirname14, join as join26 } from "node:path";
|
|
14571
14300
|
function sealedLedgerHome(admitted) {
|
|
14572
14301
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
14573
14302
|
}
|
|
14574
14303
|
function ledgerReadScope(admitted, scope) {
|
|
14575
14304
|
return {
|
|
14576
14305
|
home: sealedLedgerHome(admitted),
|
|
14577
|
-
sessionParent:
|
|
14306
|
+
sessionParent: join26(admitted.runDirectory, "session", "session.jsonl"),
|
|
14578
14307
|
...scope?.courtAttemptId === void 0 || scope.courtAttemptId.length === 0 ? {} : { attemptId: scope.courtAttemptId }
|
|
14579
14308
|
};
|
|
14580
14309
|
}
|
|
@@ -14724,7 +14453,7 @@ function presentControlledFailure(failure2, io) {
|
|
|
14724
14453
|
}
|
|
14725
14454
|
async function inspectJudgeSession(sessionFile) {
|
|
14726
14455
|
try {
|
|
14727
|
-
await
|
|
14456
|
+
await readFile15(sessionFile, "utf8");
|
|
14728
14457
|
return { state: "present" };
|
|
14729
14458
|
} catch (error) {
|
|
14730
14459
|
if (isMissingPathError4(error)) return { state: "missing" };
|
|
@@ -14964,7 +14693,7 @@ function sessionReadFailure(error, fallbackMessage) {
|
|
|
14964
14693
|
return failed;
|
|
14965
14694
|
}
|
|
14966
14695
|
async function readBoundSessionEntries(sessionFile) {
|
|
14967
|
-
const text = await
|
|
14696
|
+
const text = await readFile15(sessionFile, "utf8");
|
|
14968
14697
|
const entries = [];
|
|
14969
14698
|
for (const line2 of text.trim().split("\n").filter(Boolean)) {
|
|
14970
14699
|
try {
|
|
@@ -15030,7 +14759,7 @@ async function readSitianRetainedAuditorProviderStop(sessionFile) {
|
|
|
15030
14759
|
const { records } = await readSitianRecords(recordFile);
|
|
15031
14760
|
for (let i = records.length - 1; i >= 0; i -= 1) {
|
|
15032
14761
|
const payload = records[i]?.payload;
|
|
15033
|
-
if (!
|
|
14762
|
+
if (!isRecord12(payload) || !isRecord12(payload.response)) continue;
|
|
15034
14763
|
if (typeof payload.type === "string") continue;
|
|
15035
14764
|
const stop = sessionProviderStopFromAssistant(payload.response);
|
|
15036
14765
|
if (stop !== void 0) return stop;
|
|
@@ -15060,7 +14789,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
15060
14789
|
}
|
|
15061
14790
|
const parentId = parentEntries.find((entry) => entry.type === "session")?.id;
|
|
15062
14791
|
if (parentId === void 0) return void 0;
|
|
15063
|
-
const childDirectories = [
|
|
14792
|
+
const childDirectories = [join26(dirname14(sessionFile), "auditor-roles")];
|
|
15064
14793
|
const valid = [];
|
|
15065
14794
|
let sawAnyDirectory = false;
|
|
15066
14795
|
for (const childDirectory of childDirectories) {
|
|
@@ -15075,12 +14804,12 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
15075
14804
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
15076
14805
|
let entries;
|
|
15077
14806
|
try {
|
|
15078
|
-
entries = await readBoundSessionEntries(
|
|
14807
|
+
entries = await readBoundSessionEntries(join26(childDirectory, file));
|
|
15079
14808
|
} catch (error) {
|
|
15080
14809
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
15081
14810
|
}
|
|
15082
14811
|
const header = entries.find((entry) => entry.type === "session");
|
|
15083
|
-
if (!
|
|
14812
|
+
if (!isRecord12(header)) continue;
|
|
15084
14813
|
const bindingIndexes = [];
|
|
15085
14814
|
for (let i = 0; i < entries.length; i += 1) {
|
|
15086
14815
|
const entry = entries[i];
|
|
@@ -15094,7 +14823,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
15094
14823
|
end: idx + 1 < bindingIndexes.length ? bindingIndexes[idx + 1] : entries.length
|
|
15095
14824
|
})) : [{ entry: void 0, start: 0, end: entries.length }];
|
|
15096
14825
|
for (const { entry: bindingEntry, start, end } of bindingPasses) {
|
|
15097
|
-
const bindingParent = bindingEntry !== void 0 &&
|
|
14826
|
+
const bindingParent = bindingEntry !== void 0 && isRecord12(bindingEntry.data) && isRecord12(bindingEntry.data.parent) ? bindingEntry.data.parent : void 0;
|
|
15098
14827
|
const attemptEntryId = typeof bindingParent?.attemptEntryId === "string" ? bindingParent.attemptEntryId : void 0;
|
|
15099
14828
|
const boundSessionFile = typeof bindingParent?.sessionFile === "string" ? bindingParent.sessionFile : typeof header.parentSession === "string" ? header.parentSession : void 0;
|
|
15100
14829
|
if (boundSessionFile !== sessionFile) continue;
|
|
@@ -15118,12 +14847,12 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
15118
14847
|
if (stop === void 0) continue;
|
|
15119
14848
|
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
15120
14849
|
const entry = entries[i];
|
|
15121
|
-
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !
|
|
15122
|
-
const parent =
|
|
15123
|
-
const failure2 =
|
|
14850
|
+
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord12(entry.data)) continue;
|
|
14851
|
+
const parent = isRecord12(entry.data.parent) ? entry.data.parent : void 0;
|
|
14852
|
+
const failure2 = isRecord12(entry.data.failure) ? entry.data.failure : void 0;
|
|
15124
14853
|
if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId) continue;
|
|
15125
14854
|
if (failure2 === void 0) continue;
|
|
15126
|
-
const identity =
|
|
14855
|
+
const identity = isRecord12(failure2.identity) ? failure2.identity : void 0;
|
|
15127
14856
|
const typedCause = failure2.cause === "provider" || failure2.cause === "activation" || failure2.cause === "session" || failure2.cause === "output" || failure2.cause === "timeout" ? failure2.cause : void 0;
|
|
15128
14857
|
return {
|
|
15129
14858
|
...typedCause === void 0 ? {} : { cause: typedCause },
|
|
@@ -15132,7 +14861,7 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
15132
14861
|
...typeof identity.code === "string" || typeof identity.code === "number" ? { code: identity.code } : {}
|
|
15133
14862
|
} },
|
|
15134
14863
|
...typeof failure2.diagnostic === "string" ? { diagnostic: failure2.diagnostic } : {},
|
|
15135
|
-
...
|
|
14864
|
+
...isRecord12(failure2.details) ? { details: failure2.details } : {}
|
|
15136
14865
|
};
|
|
15137
14866
|
}
|
|
15138
14867
|
}
|
|
@@ -15179,9 +14908,9 @@ function typedFailedTerminatingToolKnownFailure(entries) {
|
|
|
15179
14908
|
if (classification.kind !== "infrastructure") continue;
|
|
15180
14909
|
if (typeof message.toolCallId !== "string" || typeof message.toolName !== "string") continue;
|
|
15181
14910
|
if (boundRoleToolCallForResult(attemptEntries, i, message, message.toolName) === void 0) continue;
|
|
15182
|
-
const textPart = Array.isArray(message.content) ? message.content.find((part) =>
|
|
15183
|
-
const diagnostic =
|
|
15184
|
-
const details =
|
|
14911
|
+
const textPart = Array.isArray(message.content) ? message.content.find((part) => isRecord12(part) && part.type === "text" && typeof part.text === "string") : void 0;
|
|
14912
|
+
const diagnostic = isRecord12(textPart) ? textPart.text : void 0;
|
|
14913
|
+
const details = isRecord12(message.details) ? message.details : classification.fact;
|
|
15185
14914
|
return {
|
|
15186
14915
|
cause: "activation",
|
|
15187
14916
|
identity: { name: message.toolName, code: message.toolCallId },
|
|
@@ -15318,7 +15047,7 @@ function controlledFailureInputFromResolution(resolution) {
|
|
|
15318
15047
|
} : {}
|
|
15319
15048
|
};
|
|
15320
15049
|
}
|
|
15321
|
-
function
|
|
15050
|
+
function isRecord12(value) {
|
|
15322
15051
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15323
15052
|
}
|
|
15324
15053
|
function toolResultText(message) {
|
|
@@ -15343,7 +15072,7 @@ function extractCollectorTargetBindRejection(entries) {
|
|
|
15343
15072
|
const diagnostic = toolResultText(message);
|
|
15344
15073
|
if (diagnostic.length === 0) return void 0;
|
|
15345
15074
|
const details = message.details;
|
|
15346
|
-
const code =
|
|
15075
|
+
const code = isRecord12(details) && typeof details.code === "string" && details.code.trim() !== "" ? details.code : void 0;
|
|
15347
15076
|
return code === void 0 ? { diagnostic } : { diagnostic, code };
|
|
15348
15077
|
}
|
|
15349
15078
|
return void 0;
|
|
@@ -15444,7 +15173,7 @@ function boundRoleToolCallForResult(entries, resultIndex, message, outputToolNam
|
|
|
15444
15173
|
const candidateMessage = entries[index]?.message;
|
|
15445
15174
|
if (candidateMessage?.role === "assistant" && Array.isArray(candidateMessage.content)) {
|
|
15446
15175
|
for (const part of candidateMessage.content) {
|
|
15447
|
-
if (!
|
|
15176
|
+
if (!isRecord12(part) || part.type !== "toolCall" || part.id !== callId) {
|
|
15448
15177
|
continue;
|
|
15449
15178
|
}
|
|
15450
15179
|
if (part.name !== outputToolName) return void 0;
|
|
@@ -15515,7 +15244,7 @@ function parseNavigatorAttendanceDetails(details) {
|
|
|
15515
15244
|
if (typeof details.prose === "string" && details.prose.trim() !== "") {
|
|
15516
15245
|
prose = details.prose;
|
|
15517
15246
|
} else {
|
|
15518
|
-
const next =
|
|
15247
|
+
const next = isRecord12(details.next) && typeof details.next.role === "string" ? details.next.role : void 0;
|
|
15519
15248
|
const reason = typeof details.reason === "string" && details.reason.trim() !== "" ? details.reason : void 0;
|
|
15520
15249
|
const command = typeof details.command === "string" && details.command.trim() !== "" ? details.command : void 0;
|
|
15521
15250
|
if (reason !== void 0 && next !== void 0) {
|
|
@@ -15587,8 +15316,8 @@ function projectTerminalGateFact(rounds) {
|
|
|
15587
15316
|
};
|
|
15588
15317
|
}
|
|
15589
15318
|
async function extractGateFactFromSessionDirectory(sessionDirectory, options = {}) {
|
|
15590
|
-
const directories = [
|
|
15591
|
-
const parentSessionFile = options.parentSessionFile ??
|
|
15319
|
+
const directories = [join26(sessionDirectory, "auditor-roles")];
|
|
15320
|
+
const parentSessionFile = options.parentSessionFile ?? join26(sessionDirectory, "session.jsonl");
|
|
15592
15321
|
const rounds = await readAnalystGateCyclesFromAuditorRoles(directories, {
|
|
15593
15322
|
parentSessionFile
|
|
15594
15323
|
});
|
|
@@ -15624,7 +15353,7 @@ function detourGateContext(admitted, scope) {
|
|
|
15624
15353
|
}
|
|
15625
15354
|
async function withOptionalGateProjection(base, sessionDirectory, gateContext = {}) {
|
|
15626
15355
|
const secondaryEvidence = base.roleOutcome.kind === "failure" ? base.roleOutcome.decisiveFacts.secondaryEvidence : void 0;
|
|
15627
|
-
const skipGate =
|
|
15356
|
+
const skipGate = isRecord12(secondaryEvidence) && secondaryEvidence.kind === "role_infrastructure_failure" && packagedSkipsGateOnInfrastructureStage(secondaryEvidence.stage);
|
|
15628
15357
|
let next = base;
|
|
15629
15358
|
if (!skipGate) {
|
|
15630
15359
|
const gate = await extractGateFactFromSessionDirectory(sessionDirectory, gateContext);
|
|
@@ -15668,7 +15397,7 @@ function extractNavigatorFact(entries) {
|
|
|
15668
15397
|
const entry = entries[i];
|
|
15669
15398
|
if (entry?.type === "custom_message" && entry.customType === "ak-navigator-attendance") {
|
|
15670
15399
|
const details = entry.message?.details ?? entry.details;
|
|
15671
|
-
if (!
|
|
15400
|
+
if (!isRecord12(details)) {
|
|
15672
15401
|
return {
|
|
15673
15402
|
disposition: "unavailable",
|
|
15674
15403
|
source: "unknown",
|
|
@@ -15726,10 +15455,10 @@ async function removeFaceIfPresent(path) {
|
|
|
15726
15455
|
async function clearOppositeTerminalArtifactFace(runDirectory) {
|
|
15727
15456
|
const artifactsDir = roleRunArtifactsDirectory(runDirectory);
|
|
15728
15457
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
15729
|
-
await removeFaceIfPresent(
|
|
15458
|
+
await removeFaceIfPresent(join26(artifactsDir, file));
|
|
15730
15459
|
}
|
|
15731
15460
|
for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
15732
|
-
await removeFaceIfPresent(
|
|
15461
|
+
await removeFaceIfPresent(join26(runDirectory, relative3));
|
|
15733
15462
|
}
|
|
15734
15463
|
for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
|
|
15735
15464
|
await removeFaceIfPresent(path);
|
|
@@ -15758,8 +15487,8 @@ async function publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinat
|
|
|
15758
15487
|
roleOutcome
|
|
15759
15488
|
);
|
|
15760
15489
|
const artifactsDir = await ensureTerminalArtifactFace(admitted.runDirectory);
|
|
15761
|
-
const reportPath =
|
|
15762
|
-
const evidencePath =
|
|
15490
|
+
const reportPath = join26(artifactsDir, "report.json");
|
|
15491
|
+
const evidencePath = join26(artifactsDir, "evidence.json");
|
|
15763
15492
|
await writeFile6(
|
|
15764
15493
|
reportPath,
|
|
15765
15494
|
`${JSON.stringify(bodies.report, null, 2)}
|
|
@@ -15777,8 +15506,8 @@ async function publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinat
|
|
|
15777
15506
|
{ kind: "evidence", path: evidencePath }
|
|
15778
15507
|
];
|
|
15779
15508
|
}
|
|
15780
|
-
async function publishSeatAcceptedArtifacts(admitted, roleOutcome, coordinates, entries = []
|
|
15781
|
-
return publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries
|
|
15509
|
+
async function publishSeatAcceptedArtifacts(admitted, roleOutcome, coordinates, entries = []) {
|
|
15510
|
+
return publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries);
|
|
15782
15511
|
}
|
|
15783
15512
|
async function readLawfulSettlementEntries(sessionFile) {
|
|
15784
15513
|
try {
|
|
@@ -15819,7 +15548,7 @@ async function settleSealedAcceptedOrToolResidual(admitted, authority, scope, ro
|
|
|
15819
15548
|
const residual = boundErroredToolCandidate(entries, index, message, residualToolName);
|
|
15820
15549
|
if (residual === void 0) continue;
|
|
15821
15550
|
const candidate = residual.candidate;
|
|
15822
|
-
const details =
|
|
15551
|
+
const details = isRecord12(candidate) ? candidate : { candidate };
|
|
15823
15552
|
const failed = await settleFailureTerminalResult(
|
|
15824
15553
|
admitted,
|
|
15825
15554
|
{
|
|
@@ -15850,7 +15579,7 @@ async function settleSealedAcceptedOrToolResidual(admitted, authority, scope, ro
|
|
|
15850
15579
|
scope
|
|
15851
15580
|
);
|
|
15852
15581
|
}
|
|
15853
|
-
async function settleSeat(admitted, authority, scope
|
|
15582
|
+
async function settleSeat(admitted, authority, scope) {
|
|
15854
15583
|
const record4 = packagedRoleMetadata(admitted.role);
|
|
15855
15584
|
if (record4 === void 0) {
|
|
15856
15585
|
throw new Error(`no settlement for ${admitted.role}`);
|
|
@@ -15858,7 +15587,7 @@ async function settleSeat(admitted, authority, scope, options) {
|
|
|
15858
15587
|
if (record4.settlement === "accepted") {
|
|
15859
15588
|
return trySettleAcceptedSeatTerminalResult(admitted, authority, scope);
|
|
15860
15589
|
}
|
|
15861
|
-
const publish = (roleOutcome, coordinates, entries) => publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries
|
|
15590
|
+
const publish = (roleOutcome, coordinates, entries) => publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries);
|
|
15862
15591
|
if (record4.settlement === "residual") {
|
|
15863
15592
|
return settleSealedAcceptedOrToolResidual(
|
|
15864
15593
|
admitted,
|
|
@@ -15873,11 +15602,11 @@ async function settleSeat(admitted, authority, scope, options) {
|
|
|
15873
15602
|
const accept = "sealedAcceptedOnly" in record4 && record4.sealedAcceptedOnly === true ? (roleOutcome) => roleOutcome.role === admitted.role && roleOutcome.kind === "accepted" : void 0;
|
|
15874
15603
|
return settleSealedLedgerTerminal(admitted, authority, scope, publish, accept);
|
|
15875
15604
|
}
|
|
15876
|
-
async function trySettleSeatTerminalResult(admitted, authority,
|
|
15877
|
-
return settleSeat(admitted, authority, scope
|
|
15605
|
+
async function trySettleSeatTerminalResult(admitted, authority, scope) {
|
|
15606
|
+
return settleSeat(admitted, authority, scope);
|
|
15878
15607
|
}
|
|
15879
|
-
async function settleSeatTerminalResult(admitted, authority,
|
|
15880
|
-
const settled = await settleSeat(admitted, authority, scope
|
|
15608
|
+
async function settleSeatTerminalResult(admitted, authority, scope) {
|
|
15609
|
+
const settled = await settleSeat(admitted, authority, scope);
|
|
15881
15610
|
if (settled === void 0) {
|
|
15882
15611
|
const label = admitted.role.charAt(0).toUpperCase() + admitted.role.slice(1);
|
|
15883
15612
|
throw new Error(
|
|
@@ -15886,41 +15615,6 @@ async function settleSeatTerminalResult(admitted, authority, options = {}, scope
|
|
|
15886
15615
|
}
|
|
15887
15616
|
return settled;
|
|
15888
15617
|
}
|
|
15889
|
-
function sessionMessageText(message) {
|
|
15890
|
-
if (message === void 0) return "";
|
|
15891
|
-
if (typeof message.content === "string") return message.content;
|
|
15892
|
-
if (!Array.isArray(message.content)) return "";
|
|
15893
|
-
const parts = [];
|
|
15894
|
-
for (const part of message.content) {
|
|
15895
|
-
if (typeof part === "object" && part !== null && !Array.isArray(part) && part.type === "text" && typeof part.text === "string") {
|
|
15896
|
-
parts.push(part.text);
|
|
15897
|
-
}
|
|
15898
|
-
}
|
|
15899
|
-
return parts.join("\n");
|
|
15900
|
-
}
|
|
15901
|
-
function observedMethodSkillOptions(packageRoot, material) {
|
|
15902
|
-
return {
|
|
15903
|
-
methodProvenance: material.provenance,
|
|
15904
|
-
methodSkillPath: material.skillPath,
|
|
15905
|
-
methodSkillConfiguredPath: resolvePackagedMethodSkillPath(packageRoot, material.name)
|
|
15906
|
-
};
|
|
15907
|
-
}
|
|
15908
|
-
function extractObservedMethodInvocations(entries, options) {
|
|
15909
|
-
const observed = [];
|
|
15910
|
-
for (const entry of entries) {
|
|
15911
|
-
if (entry?.type !== "message") continue;
|
|
15912
|
-
const message = entry.message;
|
|
15913
|
-
if (message?.role !== "user") continue;
|
|
15914
|
-
const text = sessionMessageText(message);
|
|
15915
|
-
if (text.length === 0) continue;
|
|
15916
|
-
const hit = observePackagedMethodSkillInvocation(text, {
|
|
15917
|
-
name: options.name,
|
|
15918
|
-
allowedLocations: options.allowedLocations
|
|
15919
|
-
});
|
|
15920
|
-
if (hit !== void 0) observed.push(hit);
|
|
15921
|
-
}
|
|
15922
|
-
return Object.freeze(observed);
|
|
15923
|
-
}
|
|
15924
15618
|
function extractDoctorCandidateFacts(entries) {
|
|
15925
15619
|
const scanStart = currentAttemptStartIndex(entries);
|
|
15926
15620
|
for (let i = entries.length - 1; i >= scanStart; i -= 1) {
|
|
@@ -15929,7 +15623,7 @@ function extractDoctorCandidateFacts(entries) {
|
|
|
15929
15623
|
continue;
|
|
15930
15624
|
}
|
|
15931
15625
|
const data = entry.data;
|
|
15932
|
-
if (!
|
|
15626
|
+
if (!isRecord12(data)) return {};
|
|
15933
15627
|
return {
|
|
15934
15628
|
...data.cost === void 0 ? {} : { cost: data.cost },
|
|
15935
15629
|
...data.auditNoReceipt === void 0 ? {} : { auditNoReceipt: data.auditNoReceipt }
|
|
@@ -15973,25 +15667,7 @@ function doctorReportFacts(face, roleOutcome, entries) {
|
|
|
15973
15667
|
...facts.auditNoReceipt === void 0 ? {} : { auditNoReceipt: facts.auditNoReceipt }
|
|
15974
15668
|
};
|
|
15975
15669
|
}
|
|
15976
|
-
function
|
|
15977
|
-
if (face.method === void 0) return {};
|
|
15978
|
-
if (face.method === "optional") {
|
|
15979
|
-
return options.methodProvenance === void 0 ? {} : { methodProvenance: options.methodProvenance };
|
|
15980
|
-
}
|
|
15981
|
-
if (options.methodProvenance === void 0 || options.methodSkillPath === void 0 || options.methodSkillConfiguredPath === void 0) {
|
|
15982
|
-
throw new Error("observed method publication is missing packaged method coordinates");
|
|
15983
|
-
}
|
|
15984
|
-
const methodInvocations = extractObservedMethodInvocations(entries, {
|
|
15985
|
-
name: options.methodProvenance.name,
|
|
15986
|
-
allowedLocations: [options.methodSkillPath, options.methodSkillConfiguredPath]
|
|
15987
|
-
});
|
|
15988
|
-
return {
|
|
15989
|
-
methodProvenance: options.methodProvenance,
|
|
15990
|
-
methodInvocationObserved: methodInvocations.length > 0,
|
|
15991
|
-
methodInvocations
|
|
15992
|
-
};
|
|
15993
|
-
}
|
|
15994
|
-
async function publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries, options = {}) {
|
|
15670
|
+
async function publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries) {
|
|
15995
15671
|
const face = seatArtifactFace(admitted.role);
|
|
15996
15672
|
const phase = face.reportPhase === true ? { phase: readAdmittedPath(admitted, "phase") } : {};
|
|
15997
15673
|
return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
|
|
@@ -16009,8 +15685,7 @@ async function publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates,
|
|
|
16009
15685
|
sessionDirectory: coordinates.sessionDirectory,
|
|
16010
15686
|
sessionFile: coordinates.sessionFile,
|
|
16011
15687
|
admittedRequestPath: admitted.admittedRequestPath,
|
|
16012
|
-
attachments: acceptedArtifactAttachmentRefs(admitted.attachments)
|
|
16013
|
-
...observedMethodTail(face, entries, options)
|
|
15688
|
+
attachments: acceptedArtifactAttachmentRefs(admitted.attachments)
|
|
16014
15689
|
}
|
|
16015
15690
|
});
|
|
16016
15691
|
}
|
|
@@ -16033,7 +15708,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
16033
15708
|
let residual;
|
|
16034
15709
|
for (let index = entries.length - 1; index >= scanStart; index -= 1) {
|
|
16035
15710
|
const entry = entries[index];
|
|
16036
|
-
if (entry?.type === "custom" && entry.customType === "ak-role-submission-closure" &&
|
|
15711
|
+
if (entry?.type === "custom" && entry.customType === "ak-role-submission-closure" && isRecord12(entry.data) && entry.data.toolName === spec.toolName && classifyPackagedRoleTerminalResult(entry.data).kind === "accepted") {
|
|
16037
15712
|
thisAttemptHasSeatSuccess = true;
|
|
16038
15713
|
}
|
|
16039
15714
|
const message = entries[index]?.message;
|
|
@@ -16073,7 +15748,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
16073
15748
|
);
|
|
16074
15749
|
}
|
|
16075
15750
|
if (residual !== void 0) {
|
|
16076
|
-
const details =
|
|
15751
|
+
const details = isRecord12(residual.candidate) ? residual.candidate : { candidate: residual.candidate };
|
|
16077
15752
|
const failed = await settleFailureTerminalResult(
|
|
16078
15753
|
admitted,
|
|
16079
15754
|
{
|
|
@@ -16103,11 +15778,8 @@ async function trySettleAcceptedSeatTerminalResult(admitted, authority, scope) {
|
|
|
16103
15778
|
}
|
|
16104
15779
|
return applySecretariatCountersignTerminal(admitted, authority, settled);
|
|
16105
15780
|
}
|
|
16106
|
-
async function trySettlePublicSeat(admitted, authority, scope
|
|
16107
|
-
|
|
16108
|
-
if (face.method === "observed" && material === void 0) return void 0;
|
|
16109
|
-
const options = face.method === "observed" && material !== void 0 ? observedMethodSkillOptions(packageRoot, material) : face.method === "optional" && material !== void 0 ? { methodProvenance: material.provenance } : {};
|
|
16110
|
-
return settleSeat(admitted, authority, scope, options);
|
|
15781
|
+
async function trySettlePublicSeat(admitted, authority, scope) {
|
|
15782
|
+
return settleSeat(admitted, authority, scope);
|
|
16111
15783
|
}
|
|
16112
15784
|
function countersignTerminalFromEntries(entries) {
|
|
16113
15785
|
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
@@ -16126,7 +15798,7 @@ function countersignTerminalFromEntries(entries) {
|
|
|
16126
15798
|
return void 0;
|
|
16127
15799
|
}
|
|
16128
15800
|
function withCountersignTerminalFact(roleOutcome, officer) {
|
|
16129
|
-
const prior = roleOutcome.decisiveFacts !== void 0 &&
|
|
15801
|
+
const prior = roleOutcome.decisiveFacts !== void 0 && isRecord12(roleOutcome.decisiveFacts) ? roleOutcome.decisiveFacts : {};
|
|
16130
15802
|
return {
|
|
16131
15803
|
...roleOutcome,
|
|
16132
15804
|
decisiveFacts: {
|
|
@@ -16139,7 +15811,7 @@ function acceptedSecretariatDefinesOfficerProjection(roleOutcome) {
|
|
|
16139
15811
|
const payloads = roleOutcome.payloads ?? [];
|
|
16140
15812
|
for (let index = payloads.length - 1; index >= 0; index -= 1) {
|
|
16141
15813
|
const payload = payloads[index];
|
|
16142
|
-
if (!
|
|
15814
|
+
if (!isRecord12(payload)) continue;
|
|
16143
15815
|
const status = payload.secretariatStatus;
|
|
16144
15816
|
if (typeof status !== "string") continue;
|
|
16145
15817
|
return status === "converged";
|
|
@@ -16215,7 +15887,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
|
|
|
16215
15887
|
const candidates = [
|
|
16216
15888
|
...preferredCandidates,
|
|
16217
15889
|
// One unique name per fallback dir — collisions on fixed names cannot exhaust this.
|
|
16218
|
-
...uniqueFallbackDirs.map((dir) =>
|
|
15890
|
+
...uniqueFallbackDirs.map((dir) => join26(dir, `${stem}.${randomUUID4()}.json`))
|
|
16219
15891
|
];
|
|
16220
15892
|
for (let i = 0; i < candidates.length; i += 1) {
|
|
16221
15893
|
const path = candidates[i];
|
|
@@ -16276,20 +15948,20 @@ async function publishFailureArtifacts(admitted, failure2, authority) {
|
|
|
16276
15948
|
baseDir
|
|
16277
15949
|
);
|
|
16278
15950
|
const errorCandidates = underArtifacts ? [
|
|
16279
|
-
|
|
16280
|
-
|
|
16281
|
-
|
|
15951
|
+
join26(baseDir, "error.json"),
|
|
15952
|
+
join26(baseDir, "error.settlement.json"),
|
|
15953
|
+
join26(admitted.runDirectory, "error.settlement.json")
|
|
16282
15954
|
] : [
|
|
16283
|
-
|
|
16284
|
-
|
|
15955
|
+
join26(baseDir, "error.settlement.json"),
|
|
15956
|
+
join26(baseDir, "error.json")
|
|
16285
15957
|
];
|
|
16286
15958
|
const evidenceCandidates = underArtifacts ? [
|
|
16287
|
-
|
|
16288
|
-
|
|
16289
|
-
|
|
15959
|
+
join26(baseDir, "evidence.json"),
|
|
15960
|
+
join26(baseDir, "evidence.settlement.json"),
|
|
15961
|
+
join26(admitted.runDirectory, "evidence.settlement.json")
|
|
16290
15962
|
] : [
|
|
16291
|
-
|
|
16292
|
-
|
|
15963
|
+
join26(baseDir, "evidence.settlement.json"),
|
|
15964
|
+
join26(baseDir, "evidence.json")
|
|
16293
15965
|
];
|
|
16294
15966
|
const errorPayloadBase = {
|
|
16295
15967
|
kind: "error",
|
|
@@ -16465,10 +16137,10 @@ function presentFailureTerminal(terminal, io) {
|
|
|
16465
16137
|
}
|
|
16466
16138
|
function defaultNavigatorGraceSleep() {
|
|
16467
16139
|
let timer;
|
|
16468
|
-
const sleep2 = ((ms) => new Promise((
|
|
16140
|
+
const sleep2 = ((ms) => new Promise((resolve21) => {
|
|
16469
16141
|
timer = setTimeout(() => {
|
|
16470
16142
|
timer = void 0;
|
|
16471
|
-
|
|
16143
|
+
resolve21();
|
|
16472
16144
|
}, ms);
|
|
16473
16145
|
}));
|
|
16474
16146
|
sleep2.cancel = () => {
|
|
@@ -16480,7 +16152,7 @@ function defaultNavigatorGraceSleep() {
|
|
|
16480
16152
|
return sleep2;
|
|
16481
16153
|
}
|
|
16482
16154
|
function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2 = defaultNavigatorGraceSleep()) {
|
|
16483
|
-
return new Promise((
|
|
16155
|
+
return new Promise((resolve21, reject) => {
|
|
16484
16156
|
let settled = false;
|
|
16485
16157
|
const finish = (action) => {
|
|
16486
16158
|
if (settled) return;
|
|
@@ -16489,11 +16161,11 @@ function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2
|
|
|
16489
16161
|
action();
|
|
16490
16162
|
};
|
|
16491
16163
|
void work.then(
|
|
16492
|
-
(value) => finish(() =>
|
|
16164
|
+
(value) => finish(() => resolve21({ status: "done", value })),
|
|
16493
16165
|
(error) => finish(() => reject(error))
|
|
16494
16166
|
);
|
|
16495
16167
|
void sleep2(graceMs).then(() => {
|
|
16496
|
-
finish(() =>
|
|
16168
|
+
finish(() => resolve21({ status: "timeout" }));
|
|
16497
16169
|
});
|
|
16498
16170
|
});
|
|
16499
16171
|
}
|
|
@@ -16521,7 +16193,6 @@ var init_settlement = __esm({
|
|
|
16521
16193
|
init_reviewer_output();
|
|
16522
16194
|
init_packaged_role_registry();
|
|
16523
16195
|
init_secretariat_contracts();
|
|
16524
|
-
init_method_skill();
|
|
16525
16196
|
init_navigator_invocation_identity();
|
|
16526
16197
|
init_receipt_delivery_policy();
|
|
16527
16198
|
init_role_run_placement();
|
|
@@ -16568,17 +16239,17 @@ var init_settlement = __esm({
|
|
|
16568
16239
|
});
|
|
16569
16240
|
|
|
16570
16241
|
// src/session-identity.ts
|
|
16571
|
-
import { mkdir as mkdir2, readFile as
|
|
16572
|
-
import { dirname as dirname15, join as
|
|
16242
|
+
import { mkdir as mkdir2, readFile as readFile16, rename as rename2, writeFile as writeFile7 } from "node:fs/promises";
|
|
16243
|
+
import { dirname as dirname15, join as join27 } from "node:path";
|
|
16573
16244
|
function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
16574
|
-
const bindingPath = (principal) =>
|
|
16245
|
+
const bindingPath = (principal) => join27(authority.decode(principal).sessionDirectory, sessionBindingFile);
|
|
16575
16246
|
return {
|
|
16576
16247
|
resolveSessionFile(principal) {
|
|
16577
16248
|
return authority.decode(principal).sessionFile;
|
|
16578
16249
|
},
|
|
16579
16250
|
async load(principal) {
|
|
16580
16251
|
try {
|
|
16581
|
-
const value = JSON.parse(await
|
|
16252
|
+
const value = JSON.parse(await readFile16(bindingPath(principal), "utf8"));
|
|
16582
16253
|
if (typeof value !== "object" || value === null || typeof value.sessionId !== "string") {
|
|
16583
16254
|
throw new Error("durable session binding is invalid");
|
|
16584
16255
|
}
|
|
@@ -16629,9 +16300,9 @@ __export(case_dossier_delivery_exports, {
|
|
|
16629
16300
|
loadCaseDossierReadingMaterial: () => loadCaseDossierReadingMaterial,
|
|
16630
16301
|
projectCaseDossierPointerSection: () => projectCaseDossierPointerSection
|
|
16631
16302
|
});
|
|
16632
|
-
import { mkdtemp as mkdtemp3, readFile as
|
|
16303
|
+
import { mkdtemp as mkdtemp3, readFile as readFile17, rm as rm4, writeFile as writeFile8 } from "node:fs/promises";
|
|
16633
16304
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
16634
|
-
import { join as
|
|
16305
|
+
import { join as join28 } from "node:path";
|
|
16635
16306
|
async function projectCaseDossierPointerSection(input) {
|
|
16636
16307
|
if (input.ticketNumber === void 0) {
|
|
16637
16308
|
return [
|
|
@@ -16658,9 +16329,9 @@ async function deliverCaseDossierAsAttachment(input) {
|
|
|
16658
16329
|
projectRoot: input.projectRoot,
|
|
16659
16330
|
home: input.home
|
|
16660
16331
|
});
|
|
16661
|
-
const stagingDir = await mkdtemp3(
|
|
16332
|
+
const stagingDir = await mkdtemp3(join28(tmpdir3(), "ak-case-dossier-"));
|
|
16662
16333
|
try {
|
|
16663
|
-
const stagingPath =
|
|
16334
|
+
const stagingPath = join28(stagingDir, CASE_DOSSIER_ATTACH_FILE);
|
|
16664
16335
|
await writeFile8(stagingPath, `${section}
|
|
16665
16336
|
`, "utf8");
|
|
16666
16337
|
return await freezeAttachmentsIntoRun(
|
|
@@ -16673,7 +16344,7 @@ async function deliverCaseDossierAsAttachment(input) {
|
|
|
16673
16344
|
}
|
|
16674
16345
|
}
|
|
16675
16346
|
async function loadCaseDossierReadingMaterial(runDirectory) {
|
|
16676
|
-
const frozenPath =
|
|
16347
|
+
const frozenPath = join28(
|
|
16677
16348
|
runDirectory,
|
|
16678
16349
|
"attachments",
|
|
16679
16350
|
CASE_DOSSIER_ATTACH_KEY,
|
|
@@ -16681,7 +16352,7 @@ async function loadCaseDossierReadingMaterial(runDirectory) {
|
|
|
16681
16352
|
);
|
|
16682
16353
|
let section;
|
|
16683
16354
|
try {
|
|
16684
|
-
section = await
|
|
16355
|
+
section = await readFile17(frozenPath, "utf8");
|
|
16685
16356
|
} catch (error) {
|
|
16686
16357
|
if (error.code === "ENOENT") return void 0;
|
|
16687
16358
|
throw error;
|
|
@@ -16705,7 +16376,7 @@ var init_case_dossier_delivery = __esm({
|
|
|
16705
16376
|
|
|
16706
16377
|
// src/host-transition-prior-native.ts
|
|
16707
16378
|
import { access as access3, readdir as readdir7 } from "node:fs/promises";
|
|
16708
|
-
import { dirname as dirname16, join as
|
|
16379
|
+
import { dirname as dirname16, join as join29 } from "node:path";
|
|
16709
16380
|
function isEnoent2(error) {
|
|
16710
16381
|
return typeof error === "object" && error !== null && error.code === "ENOENT";
|
|
16711
16382
|
}
|
|
@@ -16730,7 +16401,7 @@ async function listSitianRecordPaths(sessionParent) {
|
|
|
16730
16401
|
const recordPaths = [];
|
|
16731
16402
|
for (const entry of entries) {
|
|
16732
16403
|
if (!entry.isDirectory()) continue;
|
|
16733
|
-
const recordFile =
|
|
16404
|
+
const recordFile = join29(sessionRoot, entry.name, "records.jsonl");
|
|
16734
16405
|
try {
|
|
16735
16406
|
await access3(recordFile);
|
|
16736
16407
|
recordPaths.push(recordFile);
|
|
@@ -16782,7 +16453,7 @@ var init_process_cancel = __esm({
|
|
|
16782
16453
|
import { constants as fsConstants2 } from "node:fs";
|
|
16783
16454
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
16784
16455
|
import { lstat as lstat6, mkdir as mkdir3, open as open2 } from "node:fs/promises";
|
|
16785
|
-
import { join as
|
|
16456
|
+
import { join as join30 } from "node:path";
|
|
16786
16457
|
async function persistReturnedRunState(admitted, authority, options) {
|
|
16787
16458
|
if (options?.lawful === true) {
|
|
16788
16459
|
await markRunTerminal(admitted.runDirectory);
|
|
@@ -16853,7 +16524,7 @@ function jsonSafeReplacer() {
|
|
|
16853
16524
|
};
|
|
16854
16525
|
}
|
|
16855
16526
|
async function writeHardenedArtifactFile(artifactsDir, namePrefix, payload) {
|
|
16856
|
-
const filePath =
|
|
16527
|
+
const filePath = join30(artifactsDir, `${namePrefix}-${randomUUID5()}.json`);
|
|
16857
16528
|
const body = `${JSON.stringify(payload, jsonSafeReplacer(), 2)}
|
|
16858
16529
|
`;
|
|
16859
16530
|
const noFollowFlag = typeof fsConstants2.O_NOFOLLOW === "number" ? fsConstants2.O_NOFOLLOW : 0;
|
|
@@ -17142,7 +16813,7 @@ var init_auto_resume = __esm({
|
|
|
17142
16813
|
// src/public-cli/post-admission.ts
|
|
17143
16814
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
17144
16815
|
import { writeFile as writeFile9 } from "node:fs/promises";
|
|
17145
|
-
import { isAbsolute as isAbsolute8, join as
|
|
16816
|
+
import { isAbsolute as isAbsolute8, join as join31, resolve as resolve12 } from "node:path";
|
|
17146
16817
|
function describeCaughtError(error) {
|
|
17147
16818
|
if (error instanceof Error) {
|
|
17148
16819
|
const code = error.code;
|
|
@@ -17213,8 +16884,9 @@ function withOnceSuccessfulBeforeDispatch(adapters) {
|
|
|
17213
16884
|
...adapters,
|
|
17214
16885
|
beforeDispatch: async (admitted, lease) => {
|
|
17215
16886
|
if (succeeded) return;
|
|
17216
|
-
await hook(admitted, lease);
|
|
16887
|
+
const result = await hook(admitted, lease);
|
|
17217
16888
|
succeeded = true;
|
|
16889
|
+
return result;
|
|
17218
16890
|
}
|
|
17219
16891
|
};
|
|
17220
16892
|
}
|
|
@@ -17232,7 +16904,7 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
17232
16904
|
try {
|
|
17233
16905
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
17234
16906
|
await writeFile9(
|
|
17235
|
-
|
|
16907
|
+
join31(artifactsDir, `post-admission-diagnostic-${randomUUID6()}.json`),
|
|
17236
16908
|
`${JSON.stringify({ version: 1, ...payload }, null, 2)}
|
|
17237
16909
|
`,
|
|
17238
16910
|
{ encoding: "utf8", flag: "wx" }
|
|
@@ -17249,30 +16921,6 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
17249
16921
|
} catch {
|
|
17250
16922
|
}
|
|
17251
16923
|
}
|
|
17252
|
-
async function resolveResumeMethodMaterialAdapters(input) {
|
|
17253
|
-
if (input.shouldLoad === false) {
|
|
17254
|
-
return { kind: "continue", adapters: input.emptyAdapters };
|
|
17255
|
-
}
|
|
17256
|
-
try {
|
|
17257
|
-
const material = await input.loadMaterial();
|
|
17258
|
-
return { kind: "continue", adapters: input.adaptersWith(material) };
|
|
17259
|
-
} catch (error) {
|
|
17260
|
-
const terminal = await presentControlledFailure2(
|
|
17261
|
-
input.admitted,
|
|
17262
|
-
{
|
|
17263
|
-
timedOut: false,
|
|
17264
|
-
code: null,
|
|
17265
|
-
stderr: "",
|
|
17266
|
-
thrown: error,
|
|
17267
|
-
...input.knownCause === void 0 ? {} : { knownCause: input.knownCause }
|
|
17268
|
-
},
|
|
17269
|
-
input.emptyAdapters,
|
|
17270
|
-
input.authority,
|
|
17271
|
-
input.io
|
|
17272
|
-
);
|
|
17273
|
-
return { kind: "terminal", ...terminal };
|
|
17274
|
-
}
|
|
17275
|
-
}
|
|
17276
16924
|
async function presentControlledFailure2(admitted, failureInput, adapters, authority, io, persistRunState = true) {
|
|
17277
16925
|
const hasThrown = Object.hasOwn(failureInput, "thrown");
|
|
17278
16926
|
const resumeObservation = await resolveControlledFailureResumeObservation({
|
|
@@ -17397,7 +17045,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
17397
17045
|
const rows = await readRecordedSubmissionRows(
|
|
17398
17046
|
admitted.projectRoot,
|
|
17399
17047
|
admitted.runId,
|
|
17400
|
-
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent:
|
|
17048
|
+
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent: join31(admitted.runDirectory, "session", "session.jsonl") }
|
|
17401
17049
|
);
|
|
17402
17050
|
const asserted = rows.filter((row) => row.kind === "accepted" && row.role === admitted.role).map((row) => row.accepted).find((payload) => {
|
|
17403
17051
|
if (payload === null || typeof payload !== "object" || Array.isArray(payload)) return false;
|
|
@@ -17476,7 +17124,10 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
17476
17124
|
await clearTypedProviderHttpObservation(admitted.runDirectory);
|
|
17477
17125
|
if (adapters.beforeDispatch !== void 0) {
|
|
17478
17126
|
try {
|
|
17479
|
-
await adapters.beforeDispatch(admitted, lease);
|
|
17127
|
+
const paused = await adapters.beforeDispatch(admitted, lease);
|
|
17128
|
+
if (paused !== void 0) {
|
|
17129
|
+
return { exitCode: 0, admitted, terminal: paused, skipAutoResume: true };
|
|
17130
|
+
}
|
|
17480
17131
|
} catch (error) {
|
|
17481
17132
|
const settled2 = await presentControlledFailure2(
|
|
17482
17133
|
admitted,
|
|
@@ -17552,7 +17203,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
17552
17203
|
let stderrLogWriteFailure;
|
|
17553
17204
|
try {
|
|
17554
17205
|
await writeFile9(
|
|
17555
|
-
|
|
17206
|
+
join31(admitted.runDirectory, "stderr.log"),
|
|
17556
17207
|
result.stderr,
|
|
17557
17208
|
"utf8"
|
|
17558
17209
|
);
|
|
@@ -17788,6 +17439,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
17788
17439
|
return {
|
|
17789
17440
|
packageRoot: env.packageRoot,
|
|
17790
17441
|
home: env.home,
|
|
17442
|
+
...env.host === void 0 ? {} : { host: env.host },
|
|
17791
17443
|
agentDir: env.agentDir,
|
|
17792
17444
|
...env.model === void 0 ? {} : { model: env.model },
|
|
17793
17445
|
...pickEngineAxis(env),
|
|
@@ -17806,6 +17458,7 @@ function roleTurnOptions(env, admitted, continuation) {
|
|
|
17806
17458
|
return {
|
|
17807
17459
|
packageRoot: env.packageRoot,
|
|
17808
17460
|
home: env.home,
|
|
17461
|
+
...env.host === void 0 ? {} : { host: env.host },
|
|
17809
17462
|
agentDir: env.agentDir,
|
|
17810
17463
|
...env.model === void 0 ? {} : { model: env.model },
|
|
17811
17464
|
...pickEngineAxis(env),
|
|
@@ -17829,7 +17482,7 @@ async function dispatchAfterWriterLease(input) {
|
|
|
17829
17482
|
}
|
|
17830
17483
|
function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
|
|
17831
17484
|
const absolute = isAbsolute8(attachmentPath) ? attachmentPath : resolve12(attachmentPath);
|
|
17832
|
-
return pathContainedIn(
|
|
17485
|
+
return pathContainedIn(join31(runDirectory, "attachments"), absolute);
|
|
17833
17486
|
}
|
|
17834
17487
|
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
17835
17488
|
if (summons === void 0) return void 0;
|
|
@@ -18158,6 +17811,150 @@ var init_seat_ticket_binding = __esm({
|
|
|
18158
17811
|
}
|
|
18159
17812
|
});
|
|
18160
17813
|
|
|
17814
|
+
// src/public-cli/machine-method-skills.ts
|
|
17815
|
+
import { accessSync, constants as constants2, statSync as statSync3 } from "node:fs";
|
|
17816
|
+
import { lstat as lstat7, mkdir as mkdir4, symlink } from "node:fs/promises";
|
|
17817
|
+
import { join as join32 } from "node:path";
|
|
17818
|
+
import { spawnSync } from "node:child_process";
|
|
17819
|
+
function skillRoot(home) {
|
|
17820
|
+
return join32(home, ".agents/skills");
|
|
17821
|
+
}
|
|
17822
|
+
function installedMethodSkillPath(home, name) {
|
|
17823
|
+
return installedSkillPath(skillRoot(home), name);
|
|
17824
|
+
}
|
|
17825
|
+
function installedSkillPath(root, name) {
|
|
17826
|
+
const path = join32(root, name, "SKILL.md");
|
|
17827
|
+
try {
|
|
17828
|
+
if (!statSync3(path).isFile()) return void 0;
|
|
17829
|
+
accessSync(path, constants2.R_OK);
|
|
17830
|
+
return path;
|
|
17831
|
+
} catch (error) {
|
|
17832
|
+
const code = error.code;
|
|
17833
|
+
if (code === "ENOENT" || code === "ENOTDIR" || code === "EACCES" || code === "EPERM" || code === "ELOOP") return void 0;
|
|
17834
|
+
throw error;
|
|
17835
|
+
}
|
|
17836
|
+
}
|
|
17837
|
+
function linkedSkillRoot(home, host) {
|
|
17838
|
+
if (host === "claude" || host === "claude-code") {
|
|
17839
|
+
return join32(process.env.CLAUDE_CONFIG_DIR?.trim() || join32(home, ".claude"), "skills");
|
|
17840
|
+
}
|
|
17841
|
+
if (host === "hermes") return join32(home, ".hermes/skills");
|
|
17842
|
+
return void 0;
|
|
17843
|
+
}
|
|
17844
|
+
async function occupied(path) {
|
|
17845
|
+
try {
|
|
17846
|
+
await lstat7(path);
|
|
17847
|
+
return true;
|
|
17848
|
+
} catch (error) {
|
|
17849
|
+
if (error.code !== "ENOENT") throw error;
|
|
17850
|
+
return false;
|
|
17851
|
+
}
|
|
17852
|
+
}
|
|
17853
|
+
function warnOccupied(path, stdout) {
|
|
17854
|
+
stdout(`Warning: ${path} is already occupied; left untouched.
|
|
17855
|
+
`);
|
|
17856
|
+
}
|
|
17857
|
+
async function warnMissingMethodSkills(home, host, role, skills, stdout) {
|
|
17858
|
+
const missing = [];
|
|
17859
|
+
const linkedRoot = linkedSkillRoot(home, host);
|
|
17860
|
+
for (const skill of skills) {
|
|
17861
|
+
if (installedMethodSkillPath(home, skill) === void 0 || linkedRoot !== void 0 && installedSkillPath(linkedRoot, skill) === void 0) missing.push(skill);
|
|
17862
|
+
}
|
|
17863
|
+
for (const skill of missing) {
|
|
17864
|
+
stdout(`Warning: required machine Skill "${skill}" is missing for ${role}; its method guidance may be unavailable and reduce work quality. Run \`ak-role setup\` to install required Skills.
|
|
17865
|
+
`);
|
|
17866
|
+
}
|
|
17867
|
+
}
|
|
17868
|
+
function runSkillsCli(args, home) {
|
|
17869
|
+
const result = spawnSync("npx", ["--yes", "skills", ...args], {
|
|
17870
|
+
stdio: "inherit",
|
|
17871
|
+
env: { ...process.env, HOME: home }
|
|
17872
|
+
});
|
|
17873
|
+
if (result.error !== void 0) throw result.error;
|
|
17874
|
+
return result.status === 0;
|
|
17875
|
+
}
|
|
17876
|
+
function addSkills(source, skills, home) {
|
|
17877
|
+
if (skills.length === 0) return true;
|
|
17878
|
+
return runSkillsCli([
|
|
17879
|
+
"add",
|
|
17880
|
+
source,
|
|
17881
|
+
...skills.flatMap((skill) => ["--skill", skill]),
|
|
17882
|
+
"--agent",
|
|
17883
|
+
"codex",
|
|
17884
|
+
"--global",
|
|
17885
|
+
"--yes"
|
|
17886
|
+
], home);
|
|
17887
|
+
}
|
|
17888
|
+
function updateRequiredSkills(home) {
|
|
17889
|
+
const names = packagedMethodSkillNames();
|
|
17890
|
+
if (names.length === 0) return true;
|
|
17891
|
+
return runSkillsCli(["update", "-g", "-y", ...names], home);
|
|
17892
|
+
}
|
|
17893
|
+
async function runMachineSkillSetup(home, stdout) {
|
|
17894
|
+
const canonical = skillRoot(home);
|
|
17895
|
+
const missingBySource = /* @__PURE__ */ new Map();
|
|
17896
|
+
let unsourced = false;
|
|
17897
|
+
for (const name of packagedMethodSkillNames()) {
|
|
17898
|
+
const path = join32(canonical, name);
|
|
17899
|
+
if (await occupied(path)) {
|
|
17900
|
+
warnOccupied(path, stdout);
|
|
17901
|
+
continue;
|
|
17902
|
+
}
|
|
17903
|
+
const source = SKILL_SOURCE[name];
|
|
17904
|
+
if (source === void 0) {
|
|
17905
|
+
unsourced = true;
|
|
17906
|
+
stdout(`Warning: required machine Skill "${name}" has no install source; setup did not install it.
|
|
17907
|
+
`);
|
|
17908
|
+
continue;
|
|
17909
|
+
}
|
|
17910
|
+
const missing = missingBySource.get(source) ?? [];
|
|
17911
|
+
missing.push(name);
|
|
17912
|
+
missingBySource.set(source, missing);
|
|
17913
|
+
}
|
|
17914
|
+
for (const [source, missing] of missingBySource) {
|
|
17915
|
+
if (!addSkills(source, missing, home)) return 1;
|
|
17916
|
+
}
|
|
17917
|
+
if (unsourced) return 1;
|
|
17918
|
+
for (const host of ["claude-code", "hermes"]) {
|
|
17919
|
+
const root = linkedSkillRoot(home, host);
|
|
17920
|
+
const binaryFromHome = host === "claude-code" ? HEADLESS_HOST_DESCRIPTIONS.claude.binaryFromHome : HOST_DESCRIPTIONS.hermes.binaryFromHome;
|
|
17921
|
+
try {
|
|
17922
|
+
accessSync(join32(home, ...binaryFromHome), constants2.X_OK);
|
|
17923
|
+
} catch (error) {
|
|
17924
|
+
if (["ENOENT", "ENOTDIR", "EACCES"].includes(error.code ?? "")) continue;
|
|
17925
|
+
throw error;
|
|
17926
|
+
}
|
|
17927
|
+
for (const name of packagedMethodSkillNames()) {
|
|
17928
|
+
const target = join32(canonical, name);
|
|
17929
|
+
if (installedMethodSkillPath(home, name) === void 0) continue;
|
|
17930
|
+
const link = join32(root, name);
|
|
17931
|
+
if (await occupied(link)) {
|
|
17932
|
+
warnOccupied(link, stdout);
|
|
17933
|
+
continue;
|
|
17934
|
+
}
|
|
17935
|
+
await mkdir4(root, { recursive: true });
|
|
17936
|
+
await symlink(target, link, "dir");
|
|
17937
|
+
}
|
|
17938
|
+
}
|
|
17939
|
+
if (!updateRequiredSkills(home)) return 1;
|
|
17940
|
+
stdout("Machine method Skills setup finished. Existing same-name Skills were left untouched.\n");
|
|
17941
|
+
return 0;
|
|
17942
|
+
}
|
|
17943
|
+
var SKILL_SOURCE;
|
|
17944
|
+
var init_machine_method_skills = __esm({
|
|
17945
|
+
"src/public-cli/machine-method-skills.ts"() {
|
|
17946
|
+
"use strict";
|
|
17947
|
+
init_host_descriptions();
|
|
17948
|
+
init_packaged_role_registry();
|
|
17949
|
+
SKILL_SOURCE = {
|
|
17950
|
+
tdd: "mattpocock/skills",
|
|
17951
|
+
"diagnosing-bugs": "mattpocock/skills",
|
|
17952
|
+
"resolving-merge-conflicts": "mattpocock/skills",
|
|
17953
|
+
"ak-cross-m-review": "Akagilnc/ak-cross-m-review"
|
|
17954
|
+
};
|
|
17955
|
+
}
|
|
17956
|
+
});
|
|
17957
|
+
|
|
18161
17958
|
// src/public-cli/turn-request.ts
|
|
18162
17959
|
function projectRoleTurnRequest(admitted, roleDetails, options) {
|
|
18163
17960
|
const cwd = admitted.projectRoot ?? admitted.repoRoot ?? admitted.cwd;
|
|
@@ -18219,7 +18016,7 @@ function activationForAdmitted(admitted) {
|
|
|
18219
18016
|
}
|
|
18220
18017
|
return activation;
|
|
18221
18018
|
}
|
|
18222
|
-
function
|
|
18019
|
+
function requiredMethodSkills(admitted) {
|
|
18223
18020
|
const record4 = packagedRoleMetadata(admitted.role);
|
|
18224
18021
|
const names = [];
|
|
18225
18022
|
if (record4 !== void 0 && "methodSkills" in record4 && record4.methodSkills !== void 0) {
|
|
@@ -18227,38 +18024,40 @@ function methodBindings(admitted, packageRoot) {
|
|
|
18227
18024
|
}
|
|
18228
18025
|
const apply = packagedSettleSkill(admitted);
|
|
18229
18026
|
if (apply !== void 0 && !names.includes(apply)) names.push(apply);
|
|
18230
|
-
return names
|
|
18231
|
-
|
|
18232
|
-
|
|
18233
|
-
|
|
18027
|
+
return names;
|
|
18028
|
+
}
|
|
18029
|
+
function methodBindings(admitted, home, host) {
|
|
18030
|
+
if (host !== void 0 && host !== "pi") return [];
|
|
18031
|
+
return requiredMethodSkills(admitted).flatMap((name) => {
|
|
18032
|
+
const path = installedMethodSkillPath(home, name);
|
|
18033
|
+
return path === void 0 ? [] : [{
|
|
18034
|
+
kind: "skill",
|
|
18035
|
+
path
|
|
18036
|
+
}];
|
|
18037
|
+
});
|
|
18234
18038
|
}
|
|
18235
|
-
function admittedSeatTurnDetails(admitted,
|
|
18039
|
+
function admittedSeatTurnDetails(admitted, home, host) {
|
|
18236
18040
|
return {
|
|
18237
18041
|
activation: activationForAdmitted(admitted),
|
|
18238
|
-
methods: methodBindings(admitted,
|
|
18042
|
+
methods: methodBindings(admitted, home, host)
|
|
18239
18043
|
};
|
|
18240
18044
|
}
|
|
18241
18045
|
var init_turn_request = __esm({
|
|
18242
18046
|
"src/public-cli/turn-request.ts"() {
|
|
18243
18047
|
"use strict";
|
|
18244
18048
|
init_engine_material();
|
|
18245
|
-
init_method_skill();
|
|
18246
18049
|
init_packaged_role_registry();
|
|
18050
|
+
init_machine_method_skills();
|
|
18247
18051
|
init_run_lifecycle();
|
|
18248
18052
|
}
|
|
18249
18053
|
});
|
|
18250
18054
|
|
|
18251
18055
|
// src/public-cli/countersign-run.ts
|
|
18252
|
-
|
|
18253
|
-
__export(countersign_run_exports, {
|
|
18254
|
-
invokeCourtDiarist: () => invokeCourtDiarist,
|
|
18255
|
-
runCountersignCourtDiaristStation: () => runCountersignCourtDiaristStation
|
|
18256
|
-
});
|
|
18257
|
-
function isRecord14(value) {
|
|
18056
|
+
function isRecord13(value) {
|
|
18258
18057
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18259
18058
|
}
|
|
18260
18059
|
function isEscalatePayload(payload) {
|
|
18261
|
-
if (!
|
|
18060
|
+
if (!isRecord13(payload)) return false;
|
|
18262
18061
|
return payload.status === "escalate";
|
|
18263
18062
|
}
|
|
18264
18063
|
function courtDiaristPayloadRows(roleOutcome, submissions) {
|
|
@@ -18353,7 +18152,8 @@ async function invokeCourtDiarist(input, env, io) {
|
|
|
18353
18152
|
kind: "escalate",
|
|
18354
18153
|
diagnostic: courtDiaristEscalateDiagnostic(roleOutcome, submissions)
|
|
18355
18154
|
},
|
|
18356
|
-
...result.admitted === void 0 ? {} : { admitted: result.admitted }
|
|
18155
|
+
...result.admitted === void 0 ? {} : { admitted: result.admitted },
|
|
18156
|
+
...result.terminal === void 0 ? {} : { terminal: result.terminal }
|
|
18357
18157
|
};
|
|
18358
18158
|
}
|
|
18359
18159
|
if (result.exitCode !== 0) {
|
|
@@ -18387,7 +18187,7 @@ async function invokeCourtDiarist(input, env, io) {
|
|
|
18387
18187
|
...result.admitted === void 0 ? {} : { admitted: result.admitted }
|
|
18388
18188
|
};
|
|
18389
18189
|
}
|
|
18390
|
-
async function runCountersignCourtDiaristStation(admitted, env, io) {
|
|
18190
|
+
async function runCountersignCourtDiaristStation(admitted, env, io, afterTicketNumber) {
|
|
18391
18191
|
if (env.runCourtDiaristStation !== void 0) {
|
|
18392
18192
|
await env.runCourtDiaristStation(admitted);
|
|
18393
18193
|
return;
|
|
@@ -18404,7 +18204,8 @@ async function runCountersignCourtDiaristStation(admitted, env, io) {
|
|
|
18404
18204
|
} else {
|
|
18405
18205
|
refreshTickets = [admitted.ticketNumber];
|
|
18406
18206
|
}
|
|
18407
|
-
|
|
18207
|
+
const completedIndex = afterTicketNumber === void 0 ? -1 : refreshTickets.indexOf(afterTicketNumber);
|
|
18208
|
+
for (const ticketNumber of refreshTickets.slice(completedIndex + 1)) {
|
|
18408
18209
|
const outcome = await invokeCourtDiarist(
|
|
18409
18210
|
{
|
|
18410
18211
|
instruction: `\u6574\u7406 #${ticketNumber} \u7684\u672C\u6848\u4F9D\u636E\u3002`,
|
|
@@ -18417,14 +18218,17 @@ async function runCountersignCourtDiaristStation(admitted, env, io) {
|
|
|
18417
18218
|
env,
|
|
18418
18219
|
io
|
|
18419
18220
|
);
|
|
18420
|
-
if (outcome.identity.kind === "escalate") {
|
|
18421
|
-
throw new StationChildExhaustedError(outcome.identity.diagnostic);
|
|
18422
|
-
}
|
|
18423
18221
|
if (outcome.failedWithoutEscalate !== void 0) {
|
|
18424
18222
|
throw new StationChildExhaustedError(
|
|
18425
18223
|
outcome.failedWithoutEscalate.diagnostic
|
|
18426
18224
|
);
|
|
18427
18225
|
}
|
|
18226
|
+
if (outcome.identity.kind === "escalate" && outcome.terminal !== void 0) {
|
|
18227
|
+
return {
|
|
18228
|
+
terminal: outcome.terminal,
|
|
18229
|
+
...outcome.admitted === void 0 ? {} : { childRunId: outcome.admitted.runId }
|
|
18230
|
+
};
|
|
18231
|
+
}
|
|
18428
18232
|
}
|
|
18429
18233
|
}
|
|
18430
18234
|
var init_countersign_run = __esm({
|
|
@@ -18441,6 +18245,7 @@ var init_countersign_run = __esm({
|
|
|
18441
18245
|
var instruction_seat_run_exports = {};
|
|
18442
18246
|
__export(instruction_seat_run_exports, {
|
|
18443
18247
|
buildInstructionSeatTurnRequest: () => buildInstructionSeatTurnRequest,
|
|
18248
|
+
continueParentAfterChild: () => continueParentAfterChild,
|
|
18444
18249
|
runPublicInstructionSeat: () => runPublicInstructionSeat,
|
|
18445
18250
|
runPublicInstructionSeatResume: () => runPublicInstructionSeatResume
|
|
18446
18251
|
});
|
|
@@ -18455,7 +18260,7 @@ function roleRecord(role) {
|
|
|
18455
18260
|
function buildInstructionSeatTurnRequest(admitted, options) {
|
|
18456
18261
|
return projectRoleTurnRequest(
|
|
18457
18262
|
admitted,
|
|
18458
|
-
admittedSeatTurnDetails(admitted, options.
|
|
18263
|
+
admittedSeatTurnDetails(admitted, options.home, options.host),
|
|
18459
18264
|
options
|
|
18460
18265
|
);
|
|
18461
18266
|
}
|
|
@@ -18488,11 +18293,11 @@ async function bindAndRelocateDiarist(admitted, authority, lease) {
|
|
|
18488
18293
|
}
|
|
18489
18294
|
await relocateAdmittedRunToTicket(admitted, authority, lease);
|
|
18490
18295
|
}
|
|
18491
|
-
function seatAdapters(admitted, env
|
|
18296
|
+
function seatAdapters(admitted, env) {
|
|
18492
18297
|
const record4 = roleRecord(admitted.role);
|
|
18493
18298
|
const present = "presentSettled" in record4 ? record4.presentSettled : "default";
|
|
18494
18299
|
return {
|
|
18495
|
-
trySettle: (seat, authority, scope) => trySettlePublicSeat(seat, authority, scope
|
|
18300
|
+
trySettle: (seat, authority, scope) => trySettlePublicSeat(seat, authority, scope),
|
|
18496
18301
|
...present === "always" ? { shouldPresentSettled: () => true } : {},
|
|
18497
18302
|
...present === "typed" ? { shouldPresentSettled: (terminal) => isLawfulTypedTerminalOutcome(terminal.roleOutcome) } : {},
|
|
18498
18303
|
...infraFailure(admitted.role),
|
|
@@ -18544,23 +18349,8 @@ async function withAuditorSoulEnv(options) {
|
|
|
18544
18349
|
}
|
|
18545
18350
|
async function dispatchAdmitted(admitted, env, io) {
|
|
18546
18351
|
const record4 = roleRecord(admitted.role);
|
|
18547
|
-
|
|
18548
|
-
const
|
|
18549
|
-
if (skill !== void 0) {
|
|
18550
|
-
try {
|
|
18551
|
-
material = await loadPackagedMethodSkillMaterial(env.packageRoot, skill);
|
|
18552
|
-
} catch (error) {
|
|
18553
|
-
const knownCause = packagedMethodLoadFailureCause(admitted.role);
|
|
18554
|
-
return await presentControlledFailure2(admitted, {
|
|
18555
|
-
timedOut: false,
|
|
18556
|
-
code: null,
|
|
18557
|
-
stderr: "",
|
|
18558
|
-
thrown: error,
|
|
18559
|
-
...knownCause === void 0 ? {} : { knownCause }
|
|
18560
|
-
}, seatAdapters(admitted, env), env.principalAuthority, io);
|
|
18561
|
-
}
|
|
18562
|
-
}
|
|
18563
|
-
const adapters = seatAdapters(admitted, env, material);
|
|
18352
|
+
await warnMissingMethodSkills(env.home, env.host, admitted.role, requiredMethodSkills(admitted), io.stdout);
|
|
18353
|
+
const adapters = seatAdapters(admitted, env);
|
|
18564
18354
|
const execute = async (activeEnv) => {
|
|
18565
18355
|
const auto = "inCallAutoResume" in record4 && record4.inCallAutoResume === true;
|
|
18566
18356
|
if (auto) {
|
|
@@ -18666,7 +18456,7 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
18666
18456
|
projectRoot: resolve13(parsed.project ?? env.cwd),
|
|
18667
18457
|
role: "countersign",
|
|
18668
18458
|
parentRunPath: gateParentRunPath,
|
|
18669
|
-
...env.boundTicketNumber
|
|
18459
|
+
...isSafePositiveTicketNumber(env.boundTicketNumber) ? { ticketNumber: env.boundTicketNumber } : {},
|
|
18670
18460
|
freshSummons: env.freshSummons,
|
|
18671
18461
|
summons: {
|
|
18672
18462
|
sourceRunPath: gateParentRunPath,
|
|
@@ -18703,14 +18493,16 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
18703
18493
|
let typedTicket;
|
|
18704
18494
|
let typedCourtTicketNumbers;
|
|
18705
18495
|
let identityDiaristRan = false;
|
|
18706
|
-
let
|
|
18707
|
-
|
|
18496
|
+
let childDiaristRunId;
|
|
18497
|
+
let pausedDiaristTerminal;
|
|
18498
|
+
if (gateParentRunPath === void 0 && env.runCourtDiaristStation === void 0) {
|
|
18708
18499
|
let outcome;
|
|
18709
18500
|
try {
|
|
18710
18501
|
outcome = await invokeCourtDiarist({
|
|
18711
18502
|
instruction: parsed.instruction ?? "",
|
|
18712
18503
|
projectRoot: admitted.projectRoot,
|
|
18713
18504
|
failureLabel: "unbound summons",
|
|
18505
|
+
correlationId: admitted.runId,
|
|
18714
18506
|
...env.boundTicketNumber === void 0 ? {} : { boundTicketNumber: env.boundTicketNumber }
|
|
18715
18507
|
}, env, io);
|
|
18716
18508
|
} catch (error) {
|
|
@@ -18726,15 +18518,16 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
18726
18518
|
}, seatAdapters(admitted, env), env.principalAuthority, io);
|
|
18727
18519
|
}
|
|
18728
18520
|
identityDiaristRan = true;
|
|
18521
|
+
if (outcome.identity.kind === "escalate") pausedDiaristTerminal = outcome.terminal;
|
|
18729
18522
|
if (outcome.admitted?.runDirectory.includes(`${sep5}unbound${sep5}runs${sep5}`)) {
|
|
18730
|
-
|
|
18523
|
+
childDiaristRunId = outcome.admitted.runId;
|
|
18731
18524
|
}
|
|
18732
|
-
if (outcome.
|
|
18733
|
-
const diagnostic = outcome.
|
|
18525
|
+
if (outcome.failedWithoutEscalate !== void 0) {
|
|
18526
|
+
const diagnostic = outcome.failedWithoutEscalate.diagnostic;
|
|
18734
18527
|
await materializeAdmission(
|
|
18735
18528
|
isSafePositiveTicketNumber(env.boundTicketNumber) ? env.boundTicketNumber : void 0
|
|
18736
18529
|
);
|
|
18737
|
-
if (
|
|
18530
|
+
if (childDiaristRunId !== void 0) await recordChildDiaristRun(admitted, childDiaristRunId);
|
|
18738
18531
|
await markRunAdmitted(admitted, env.principalAuthority);
|
|
18739
18532
|
return await presentControlledFailure2(admitted, {
|
|
18740
18533
|
timedOut: false,
|
|
@@ -18744,16 +18537,18 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
18744
18537
|
}, seatAdapters(admitted, env), env.principalAuthority, io);
|
|
18745
18538
|
}
|
|
18746
18539
|
if (outcome.identity.kind === "ticket") {
|
|
18747
|
-
typedTicket =
|
|
18540
|
+
typedTicket = outcome.identity.ticketNumber;
|
|
18748
18541
|
typedCourtTicketNumbers = outcome.identity.courtTicketNumbers;
|
|
18749
|
-
} else if (isSafePositiveTicketNumber(env.boundTicketNumber)) {
|
|
18750
|
-
typedTicket = env.boundTicketNumber;
|
|
18751
18542
|
}
|
|
18752
18543
|
}
|
|
18753
18544
|
await materializeAdmission(typedTicket);
|
|
18754
18545
|
await markRunAdmitted(admitted, env.principalAuthority);
|
|
18755
|
-
if (
|
|
18756
|
-
await recordChildDiaristRun(admitted,
|
|
18546
|
+
if (childDiaristRunId !== void 0) {
|
|
18547
|
+
await recordChildDiaristRun(admitted, childDiaristRunId);
|
|
18548
|
+
}
|
|
18549
|
+
if (pausedDiaristTerminal !== void 0) {
|
|
18550
|
+
io.stdout(formatTerminalResult(pausedDiaristTerminal));
|
|
18551
|
+
return { exitCode: 0, admitted, terminal: pausedDiaristTerminal };
|
|
18757
18552
|
}
|
|
18758
18553
|
if (gateParentRunPath !== void 0) {
|
|
18759
18554
|
await persistAdmittedSourceRunPath(admitted, gateParentRunPath);
|
|
@@ -18803,7 +18598,11 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
18803
18598
|
beforeDispatch: async (admittedSeat, lease) => {
|
|
18804
18599
|
if (!packagedAdmitsCountersign(admittedSeat.role)) return;
|
|
18805
18600
|
if (!identityDiaristRan || typedTicket !== void 0) {
|
|
18806
|
-
await runCountersignCourtDiaristStation(admittedSeat, env, io);
|
|
18601
|
+
const refresh = await runCountersignCourtDiaristStation(admittedSeat, env, io);
|
|
18602
|
+
if (refresh !== void 0) {
|
|
18603
|
+
io.stdout(formatTerminalResult(refresh.terminal));
|
|
18604
|
+
return refresh.terminal;
|
|
18605
|
+
}
|
|
18807
18606
|
}
|
|
18808
18607
|
await relocateAdmittedRunToTicket(admittedSeat, env.principalAuthority, lease);
|
|
18809
18608
|
Object.assign(turnRequest, buildInstructionSeatTurnRequest(admittedSeat, turnProjection));
|
|
@@ -18880,7 +18679,6 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
18880
18679
|
projectRoot,
|
|
18881
18680
|
role,
|
|
18882
18681
|
parentRunPath: sourceDirectory,
|
|
18883
|
-
...auditorTicket === void 0 ? {} : { ticketNumber: auditorTicket },
|
|
18884
18682
|
freshSummons: env.freshSummons,
|
|
18885
18683
|
summons,
|
|
18886
18684
|
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
@@ -18906,7 +18704,6 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
18906
18704
|
projectRoot,
|
|
18907
18705
|
role,
|
|
18908
18706
|
parentRunPath,
|
|
18909
|
-
...env.boundTicketNumber === void 0 ? {} : { ticketNumber: env.boundTicketNumber },
|
|
18910
18707
|
freshSummons: env.freshSummons,
|
|
18911
18708
|
summons,
|
|
18912
18709
|
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
@@ -18934,7 +18731,6 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
18934
18731
|
throw error;
|
|
18935
18732
|
}
|
|
18936
18733
|
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
|
|
18937
|
-
const knownTicket = await readBoardTicketNumber(source.runDirectory) ?? env.boundTicketNumber;
|
|
18938
18734
|
const summons = {
|
|
18939
18735
|
sourceRunPath: source.runDirectory,
|
|
18940
18736
|
sourceRun: source,
|
|
@@ -18945,7 +18741,6 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
18945
18741
|
projectRoot,
|
|
18946
18742
|
role,
|
|
18947
18743
|
parentRunPath: source.runDirectory,
|
|
18948
|
-
...knownTicket === void 0 ? {} : { ticketNumber: knownTicket },
|
|
18949
18744
|
freshSummons: env.freshSummons,
|
|
18950
18745
|
summons,
|
|
18951
18746
|
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
@@ -18982,50 +18777,38 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
18982
18777
|
}
|
|
18983
18778
|
const runAdmitted = async () => {
|
|
18984
18779
|
await markRunAdmitted(admitted, env.principalAuthority);
|
|
18985
|
-
if (
|
|
18986
|
-
|
|
18987
|
-
|
|
18988
|
-
|
|
18989
|
-
|
|
18990
|
-
|
|
18991
|
-
|
|
18992
|
-
|
|
18993
|
-
|
|
18994
|
-
|
|
18995
|
-
|
|
18996
|
-
|
|
18997
|
-
|
|
18998
|
-
|
|
18999
|
-
|
|
19000
|
-
|
|
19001
|
-
|
|
18780
|
+
if (role === "secretariat") {
|
|
18781
|
+
let outcome;
|
|
18782
|
+
try {
|
|
18783
|
+
outcome = await invokeCourtDiarist({
|
|
18784
|
+
instruction: parsed.instruction ?? "",
|
|
18785
|
+
projectRoot: admitted.projectRoot,
|
|
18786
|
+
failureLabel: "secretariat unbound summons",
|
|
18787
|
+
attachmentPaths: admitted.attachments.map((attachment) => attachment.frozenPath),
|
|
18788
|
+
correlationId: admitted.runId
|
|
18789
|
+
}, env, io);
|
|
18790
|
+
} catch (error) {
|
|
18791
|
+
return await presentControlledFailure2(admitted, {
|
|
18792
|
+
timedOut: false,
|
|
18793
|
+
code: null,
|
|
18794
|
+
stderr: "",
|
|
18795
|
+
thrown: error
|
|
18796
|
+
}, seatAdapters(admitted, env), env.principalAuthority, io);
|
|
18797
|
+
}
|
|
19002
18798
|
if (outcome.admitted?.runDirectory.includes(`${sep5}unbound${sep5}runs${sep5}`)) {
|
|
19003
18799
|
await recordChildDiaristRun(admitted, outcome.admitted.runId);
|
|
19004
18800
|
}
|
|
19005
|
-
if (outcome.
|
|
19006
|
-
const diagnostic = outcome.identity.kind === "escalate" ? outcome.identity.diagnostic : outcome.failedWithoutEscalate?.diagnostic ?? "";
|
|
18801
|
+
if (outcome.failedWithoutEscalate !== void 0) {
|
|
19007
18802
|
return await presentControlledFailure2(admitted, {
|
|
19008
18803
|
timedOut: false,
|
|
19009
18804
|
code: null,
|
|
19010
18805
|
stderr: "",
|
|
19011
|
-
thrown: new Error(diagnostic)
|
|
18806
|
+
thrown: new Error(outcome.failedWithoutEscalate.diagnostic)
|
|
19012
18807
|
}, seatAdapters(admitted, env), env.principalAuthority, io);
|
|
19013
18808
|
}
|
|
19014
|
-
if (outcome.identity.kind === "
|
|
19015
|
-
|
|
19016
|
-
|
|
19017
|
-
await bindAdmittedTicketNumber(outcome.admitted, outcome.identity.ticketNumber);
|
|
19018
|
-
await relocateAdmittedRunToTicket(outcome.admitted, env.principalAuthority);
|
|
19019
|
-
await bindAdmittedTicketNumber(admitted, outcome.identity.ticketNumber);
|
|
19020
|
-
await relocateAdmittedRunToTicket(admitted, env.principalAuthority);
|
|
19021
|
-
} catch (error) {
|
|
19022
|
-
return await presentControlledFailure2(admitted, {
|
|
19023
|
-
timedOut: false,
|
|
19024
|
-
code: null,
|
|
19025
|
-
stderr: "",
|
|
19026
|
-
thrown: error
|
|
19027
|
-
}, seatAdapters(admitted, env), env.principalAuthority, io);
|
|
19028
|
-
}
|
|
18809
|
+
if (outcome.identity.kind === "escalate" && outcome.terminal !== void 0) {
|
|
18810
|
+
io.stdout(formatTerminalResult(outcome.terminal));
|
|
18811
|
+
return { exitCode: 0, admitted, terminal: outcome.terminal };
|
|
19029
18812
|
}
|
|
19030
18813
|
}
|
|
19031
18814
|
return dispatchAdmitted(admitted, env, io);
|
|
@@ -19070,32 +18853,34 @@ async function runPublicInstructionSeatResume(request, env, io) {
|
|
|
19070
18853
|
adapters: {
|
|
19071
18854
|
trySettle: async () => void 0
|
|
19072
18855
|
},
|
|
19073
|
-
afterAdmittedLoad: (admitted) => {
|
|
19074
|
-
|
|
19075
|
-
|
|
19076
|
-
return Promise.resolve({ kind: "continue", adapters: seatAdapters(admitted, env) });
|
|
19077
|
-
}
|
|
19078
|
-
const knownCause = packagedMethodLoadFailureCause(admitted.role);
|
|
19079
|
-
return resolveResumeMethodMaterialAdapters({
|
|
19080
|
-
admitted,
|
|
19081
|
-
authority: env.principalAuthority,
|
|
19082
|
-
io,
|
|
19083
|
-
loadMaterial: () => loadPackagedMethodSkillMaterial(env.packageRoot, skill),
|
|
19084
|
-
adaptersWith: (material) => seatAdapters(admitted, env, material),
|
|
19085
|
-
emptyAdapters: seatAdapters(admitted, env),
|
|
19086
|
-
...knownCause === void 0 ? {} : { knownCause }
|
|
19087
|
-
});
|
|
18856
|
+
afterAdmittedLoad: async (admitted) => {
|
|
18857
|
+
await warnMissingMethodSkills(env.home, env.host, admitted.role, requiredMethodSkills(admitted), io.stdout);
|
|
18858
|
+
return { kind: "continue", adapters: seatAdapters(admitted, env) };
|
|
19088
18859
|
},
|
|
19089
18860
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
19090
18861
|
});
|
|
19091
18862
|
}
|
|
18863
|
+
async function continueParentAfterChild(parentRunId, child, env, io) {
|
|
18864
|
+
const loaded = await loadResumablePublicRole(env.home, parentRunId, env.principalAuthority, true);
|
|
18865
|
+
if (loaded.run.state !== "admitted") {
|
|
18866
|
+
return runPublicInstructionSeatResume({ runId: parentRunId }, env, io);
|
|
18867
|
+
}
|
|
18868
|
+
const admitted = loaded.admitted;
|
|
18869
|
+
if (admitted.role === "countersign" && admitted.ticketNumber !== void 0) {
|
|
18870
|
+
const refresh = await runCountersignCourtDiaristStation(admitted, env, io, child.ticketNumber);
|
|
18871
|
+
if (refresh !== void 0) {
|
|
18872
|
+
io.stdout(formatTerminalResult(refresh.terminal));
|
|
18873
|
+
return { exitCode: 0, admitted, terminal: refresh.terminal };
|
|
18874
|
+
}
|
|
18875
|
+
}
|
|
18876
|
+
return dispatchAdmitted(admitted, env, io);
|
|
18877
|
+
}
|
|
19092
18878
|
var init_instruction_seat_run = __esm({
|
|
19093
18879
|
"src/public-cli/instruction-seat-run.ts"() {
|
|
19094
18880
|
"use strict";
|
|
19095
18881
|
init_run_ticket_number();
|
|
19096
18882
|
init_notary_source_run();
|
|
19097
18883
|
init_engine_material();
|
|
19098
|
-
init_method_skill();
|
|
19099
18884
|
init_packaged_role_registry();
|
|
19100
18885
|
init_auditor_soul();
|
|
19101
18886
|
init_cli_errors();
|
|
@@ -19104,6 +18889,7 @@ var init_instruction_seat_run = __esm({
|
|
|
19104
18889
|
init_run_lifecycle();
|
|
19105
18890
|
init_seat_ticket_binding();
|
|
19106
18891
|
init_settlement();
|
|
18892
|
+
init_machine_method_skills();
|
|
19107
18893
|
init_terminal();
|
|
19108
18894
|
init_turn_request();
|
|
19109
18895
|
init_countersign_run();
|
|
@@ -19111,13 +18897,13 @@ var init_instruction_seat_run = __esm({
|
|
|
19111
18897
|
});
|
|
19112
18898
|
|
|
19113
18899
|
// src/analyst-book-key.ts
|
|
19114
|
-
import { statSync as
|
|
18900
|
+
import { statSync as statSync4 } from "node:fs";
|
|
19115
18901
|
import { isAbsolute as isAbsolute9 } from "node:path";
|
|
19116
18902
|
function resolveAnalystBookKey(projectRoot) {
|
|
19117
18903
|
const identity = physicalPathIdentity(projectRoot);
|
|
19118
18904
|
let stats;
|
|
19119
18905
|
try {
|
|
19120
|
-
stats =
|
|
18906
|
+
stats = statSync4(identity);
|
|
19121
18907
|
} catch (error) {
|
|
19122
18908
|
const code = errnoCode(error);
|
|
19123
18909
|
if (code === "ENOENT" || code === "ENOTDIR") return `root:${identity}`;
|
|
@@ -19166,11 +18952,11 @@ var init_atomic_write = __esm({
|
|
|
19166
18952
|
});
|
|
19167
18953
|
|
|
19168
18954
|
// src/analyst-index.ts
|
|
19169
|
-
import { open as open3, readFile as
|
|
18955
|
+
import { open as open3, readFile as readFile18, unlink as unlink5 } from "node:fs/promises";
|
|
19170
18956
|
import { dirname as dirname18, join as join34 } from "node:path";
|
|
19171
18957
|
function sleep(ms) {
|
|
19172
|
-
return new Promise((
|
|
19173
|
-
setTimeout(
|
|
18958
|
+
return new Promise((resolve21) => {
|
|
18959
|
+
setTimeout(resolve21, ms);
|
|
19174
18960
|
});
|
|
19175
18961
|
}
|
|
19176
18962
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
@@ -19294,7 +19080,7 @@ async function readAnalystLibraryIndexPage(ledgerHome) {
|
|
|
19294
19080
|
const path = analystLibraryIndexPath(ledgerHome);
|
|
19295
19081
|
let raw;
|
|
19296
19082
|
try {
|
|
19297
|
-
raw = await
|
|
19083
|
+
raw = await readFile18(path, "utf8");
|
|
19298
19084
|
} catch (error) {
|
|
19299
19085
|
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR")) {
|
|
19300
19086
|
return void 0;
|
|
@@ -19498,15 +19284,15 @@ var init_analyst_cohort = __esm({
|
|
|
19498
19284
|
});
|
|
19499
19285
|
|
|
19500
19286
|
// src/analyst-ledger.ts
|
|
19501
|
-
import { readdir as readdir8, readFile as
|
|
19502
|
-
import { basename as
|
|
19287
|
+
import { readdir as readdir8, readFile as readFile19 } from "node:fs/promises";
|
|
19288
|
+
import { basename as basename8, join as join35 } from "node:path";
|
|
19503
19289
|
function isMissingPathError6(error) {
|
|
19504
19290
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
19505
19291
|
}
|
|
19506
19292
|
function errorText3(error) {
|
|
19507
19293
|
return error instanceof Error ? error.message : String(error);
|
|
19508
19294
|
}
|
|
19509
|
-
function
|
|
19295
|
+
function isRecord14(value) {
|
|
19510
19296
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19511
19297
|
}
|
|
19512
19298
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
@@ -19557,13 +19343,13 @@ async function listLedgerBookNames(booksRoot) {
|
|
|
19557
19343
|
async function readInvocationScopeFields(runDirectory) {
|
|
19558
19344
|
let raw;
|
|
19559
19345
|
try {
|
|
19560
|
-
raw = await
|
|
19346
|
+
raw = await readFile19(join35(runDirectory, "invocation.json"), "utf8");
|
|
19561
19347
|
} catch (error) {
|
|
19562
19348
|
if (isMissingPathError6(error)) return void 0;
|
|
19563
19349
|
throw error;
|
|
19564
19350
|
}
|
|
19565
19351
|
const parsed = JSON.parse(raw);
|
|
19566
|
-
if (!
|
|
19352
|
+
if (!isRecord14(parsed)) return void 0;
|
|
19567
19353
|
if (typeof parsed.projectRoot !== "string" || parsed.projectRoot.trim() === "") {
|
|
19568
19354
|
return void 0;
|
|
19569
19355
|
}
|
|
@@ -19590,9 +19376,9 @@ function decideIssueScope(input) {
|
|
|
19590
19376
|
}
|
|
19591
19377
|
async function resolveSessionFile(runDirectory) {
|
|
19592
19378
|
try {
|
|
19593
|
-
const raw = await
|
|
19379
|
+
const raw = await readFile19(join35(runDirectory, "invocation.json"), "utf8");
|
|
19594
19380
|
const parsed = JSON.parse(raw);
|
|
19595
|
-
if (
|
|
19381
|
+
if (isRecord14(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
19596
19382
|
return parsed.sessionFile;
|
|
19597
19383
|
}
|
|
19598
19384
|
} catch (error) {
|
|
@@ -19869,7 +19655,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
19869
19655
|
throw error;
|
|
19870
19656
|
}
|
|
19871
19657
|
for (const runDirectory of runDirectories) {
|
|
19872
|
-
const runName =
|
|
19658
|
+
const runName = basename8(runDirectory);
|
|
19873
19659
|
const parsed = parseRunDirectoryName2(runName);
|
|
19874
19660
|
if (parsed === void 0) continue;
|
|
19875
19661
|
let scopeFields;
|
|
@@ -19930,7 +19716,7 @@ var init_analyst_ledger = __esm({
|
|
|
19930
19716
|
});
|
|
19931
19717
|
|
|
19932
19718
|
// src/analyst-metric-families/acceptance-success-rework.ts
|
|
19933
|
-
function
|
|
19719
|
+
function isRecord15(value) {
|
|
19934
19720
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19935
19721
|
}
|
|
19936
19722
|
function wallMsFromSpan(span) {
|
|
@@ -19939,21 +19725,21 @@ function wallMsFromSpan(span) {
|
|
|
19939
19725
|
function findCollectorGroups(body) {
|
|
19940
19726
|
if (Array.isArray(body.groups)) return body.groups;
|
|
19941
19727
|
const receipt = body.receipt;
|
|
19942
|
-
if (
|
|
19728
|
+
if (isRecord15(receipt) && Array.isArray(receipt.groups)) return receipt.groups;
|
|
19943
19729
|
const outcome = body.outcome;
|
|
19944
|
-
if (
|
|
19730
|
+
if (isRecord15(outcome)) {
|
|
19945
19731
|
const facts = outcome.decisiveFacts;
|
|
19946
|
-
if (
|
|
19732
|
+
if (isRecord15(facts) && Array.isArray(facts.groups)) return facts.groups;
|
|
19947
19733
|
}
|
|
19948
19734
|
return void 0;
|
|
19949
19735
|
}
|
|
19950
19736
|
function extractStatus(body) {
|
|
19951
19737
|
const outcome = body.outcome;
|
|
19952
|
-
if (
|
|
19738
|
+
if (isRecord15(outcome) && typeof outcome.status === "string" && outcome.status.trim() !== "") {
|
|
19953
19739
|
return outcome.status;
|
|
19954
19740
|
}
|
|
19955
19741
|
const receipt = body.receipt;
|
|
19956
|
-
if (
|
|
19742
|
+
if (isRecord15(receipt) && typeof receipt.status === "string" && receipt.status.trim() !== "") {
|
|
19957
19743
|
return receipt.status;
|
|
19958
19744
|
}
|
|
19959
19745
|
if (typeof body.status === "string" && body.status.trim() !== "") {
|
|
@@ -20579,15 +20365,15 @@ var init_leg_wall_clock = __esm({
|
|
|
20579
20365
|
});
|
|
20580
20366
|
|
|
20581
20367
|
// src/analyst-metric-families/round-timeline.ts
|
|
20582
|
-
function
|
|
20368
|
+
function isRecord16(value) {
|
|
20583
20369
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20584
20370
|
}
|
|
20585
20371
|
function wallMsFromSpan2(startedAt, endedAt) {
|
|
20586
20372
|
return Date.parse(endedAt) - Date.parse(startedAt);
|
|
20587
20373
|
}
|
|
20588
20374
|
function readClassCount(body) {
|
|
20589
|
-
if (!
|
|
20590
|
-
if (!
|
|
20375
|
+
if (!isRecord16(body.outcome)) return void 0;
|
|
20376
|
+
if (!isRecord16(body.outcome.decisiveFacts)) return void 0;
|
|
20591
20377
|
const classCount = body.outcome.decisiveFacts.classCount;
|
|
20592
20378
|
if (typeof classCount !== "number" || !Number.isFinite(classCount)) {
|
|
20593
20379
|
return void 0;
|
|
@@ -20731,7 +20517,7 @@ var init_analyst_metric_family = __esm({
|
|
|
20731
20517
|
});
|
|
20732
20518
|
|
|
20733
20519
|
// src/analyst-page.ts
|
|
20734
|
-
import { createHash as
|
|
20520
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
20735
20521
|
import { dirname as dirname19, join as join36 } from "node:path";
|
|
20736
20522
|
function analystIssuePageKey(address) {
|
|
20737
20523
|
const parts = ["book", address.bookKey];
|
|
@@ -20740,7 +20526,7 @@ function analystIssuePageKey(address) {
|
|
|
20740
20526
|
} else if (address.scopeRootIdentity !== void 0) {
|
|
20741
20527
|
parts.push("root", physicalPathIdentity(address.scopeRootIdentity));
|
|
20742
20528
|
}
|
|
20743
|
-
return
|
|
20529
|
+
return createHash7("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
20744
20530
|
}
|
|
20745
20531
|
function analystIssuePagePath(ledgerHome, address) {
|
|
20746
20532
|
return join36(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
@@ -20879,7 +20665,7 @@ var init_analyst_page = __esm({
|
|
|
20879
20665
|
});
|
|
20880
20666
|
|
|
20881
20667
|
// src/analyst-entry.ts
|
|
20882
|
-
import { readFile as
|
|
20668
|
+
import { readFile as readFile20 } from "node:fs/promises";
|
|
20883
20669
|
import { Type as Type11 } from "typebox";
|
|
20884
20670
|
function isMissingPathError7(error) {
|
|
20885
20671
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
@@ -20910,7 +20696,7 @@ async function readOrComputeAnalystIssuePage(input, options) {
|
|
|
20910
20696
|
...issueNumber === void 0 && input.bookKey === void 0 ? { scopeRootIdentity: projectRoot } : {}
|
|
20911
20697
|
});
|
|
20912
20698
|
try {
|
|
20913
|
-
const raw = await
|
|
20699
|
+
const raw = await readFile20(pagePath, "utf8");
|
|
20914
20700
|
const page = JSON.parse(raw);
|
|
20915
20701
|
if (cachedPageMatchesRequestedScope(page, { bookKey, ...input })) {
|
|
20916
20702
|
const ghostScan = await scanAnalystIssueRuns({
|
|
@@ -21011,7 +20797,7 @@ async function runAnalystModelGroupsMode(input, home) {
|
|
|
21011
20797
|
scopeRootIdentity: projectRoot
|
|
21012
20798
|
});
|
|
21013
20799
|
try {
|
|
21014
|
-
const raw = await
|
|
20800
|
+
const raw = await readFile20(pagePath, "utf8");
|
|
21015
20801
|
JSON.parse(raw);
|
|
21016
20802
|
} catch (error) {
|
|
21017
20803
|
if (!isMissingPathError7(error)) {
|
|
@@ -21109,7 +20895,7 @@ var init_analyst_entry = __esm({
|
|
|
21109
20895
|
});
|
|
21110
20896
|
|
|
21111
20897
|
// src/public-cli/analyst-run.ts
|
|
21112
|
-
import { readFile as
|
|
20898
|
+
import { readFile as readFile21 } from "node:fs/promises";
|
|
21113
20899
|
import { isAbsolute as isAbsolute10, resolve as resolve14 } from "node:path";
|
|
21114
20900
|
import { Value as Value2 } from "typebox/value";
|
|
21115
20901
|
function resolveAnalystIssueBookKeyFromCwd(cwd = process.cwd()) {
|
|
@@ -21163,7 +20949,7 @@ async function buildAnalystSweepModeInputFromAttachmentPaths(attachmentPaths) {
|
|
|
21163
20949
|
const absolute = isAbsolute10(sourcePath) ? sourcePath : resolve14(sourcePath);
|
|
21164
20950
|
let bytes;
|
|
21165
20951
|
try {
|
|
21166
|
-
bytes = await
|
|
20952
|
+
bytes = await readFile21(absolute);
|
|
21167
20953
|
} catch (error) {
|
|
21168
20954
|
throw new CliUsageError(
|
|
21169
20955
|
`analyst sweep attachment is not a readable regular file: ${sourcePath}`,
|
|
@@ -21282,7 +21068,7 @@ __export(cli_exports, {
|
|
|
21282
21068
|
resolveInternalRoleEntrypoint: () => resolveInternalRoleEntrypoint,
|
|
21283
21069
|
runAkRole: () => runAkRole
|
|
21284
21070
|
});
|
|
21285
|
-
import { realpath as
|
|
21071
|
+
import { realpath as realpath5 } from "node:fs/promises";
|
|
21286
21072
|
import { join as join37 } from "node:path";
|
|
21287
21073
|
function publicSeatArgv(owner) {
|
|
21288
21074
|
return {
|
|
@@ -21957,7 +21743,7 @@ async function runAkRole(argv, env) {
|
|
|
21957
21743
|
try {
|
|
21958
21744
|
env = {
|
|
21959
21745
|
...env,
|
|
21960
|
-
packageRoot: await
|
|
21746
|
+
packageRoot: await realpath5(env.packageRoot),
|
|
21961
21747
|
principalAuthority: env.principalAuthority ?? piDurablePrincipalAuthority
|
|
21962
21748
|
};
|
|
21963
21749
|
let parsed = parseArgv(argv);
|
|
@@ -22006,6 +21792,10 @@ async function runAkRole(argv, env) {
|
|
|
22006
21792
|
exitCode: await runConfigCommand(parsed.args, home, env.packageRoot, io)
|
|
22007
21793
|
};
|
|
22008
21794
|
}
|
|
21795
|
+
if (parsed.command === "setup") {
|
|
21796
|
+
if (parsed.args.length !== 0) throw new CliUsageError("setup takes no arguments");
|
|
21797
|
+
return { exitCode: await runMachineSkillSetup(home, io.stdout) };
|
|
21798
|
+
}
|
|
22009
21799
|
if (parsed.command === "new") {
|
|
22010
21800
|
const role = parsed.args[0];
|
|
22011
21801
|
if (role === void 0) {
|
|
@@ -22048,7 +21838,24 @@ async function runAkRole(argv, env) {
|
|
|
22048
21838
|
}),
|
|
22049
21839
|
io
|
|
22050
21840
|
);
|
|
22051
|
-
|
|
21841
|
+
let current = result;
|
|
21842
|
+
while (current.exitCode === 0 && current.admitted?.correlationId !== void 0 && current.terminal?.roleOutcome.kind === "accepted" && !courtDiaristEscalated(current.terminal.roleOutcome)) {
|
|
21843
|
+
const parentRunId = current.admitted.correlationId;
|
|
21844
|
+
const parentRole = await peekRoleRunRole(home, parentRunId);
|
|
21845
|
+
if (parentRole === void 0) break;
|
|
21846
|
+
const parentSeat = resolveEffectiveSeat(config, parentRole, credentials, invocationFromParsed(parsed));
|
|
21847
|
+
const parentEnv = createRoleEnvironment(env, {
|
|
21848
|
+
role: parentRole,
|
|
21849
|
+
home,
|
|
21850
|
+
agentDir,
|
|
21851
|
+
cwd,
|
|
21852
|
+
credentials,
|
|
21853
|
+
seat: parentSeat,
|
|
21854
|
+
config
|
|
21855
|
+
});
|
|
21856
|
+
current = await continueParentAfterChild(parentRunId, current.admitted, parentEnv, io);
|
|
21857
|
+
}
|
|
21858
|
+
return cliResultFromRoleRun(current);
|
|
22052
21859
|
}
|
|
22053
21860
|
if (parsed.command !== void 0 && isPublicCliSupportCommand(parsed.command)) {
|
|
22054
21861
|
throw new CliUsageError(`unhandled support command: ${parsed.command}`);
|
|
@@ -22112,11 +21919,13 @@ var init_cli = __esm({
|
|
|
22112
21919
|
init_packaged_role_registry();
|
|
22113
21920
|
init_registry();
|
|
22114
21921
|
init_cli_errors();
|
|
21922
|
+
init_machine_method_skills();
|
|
22115
21923
|
init_role_turn_host();
|
|
22116
21924
|
init_role_turn_host_resolution();
|
|
22117
21925
|
init_invocation();
|
|
22118
21926
|
init_option_definitions();
|
|
22119
21927
|
init_instruction_seat_run();
|
|
21928
|
+
init_countersign_run();
|
|
22120
21929
|
init_analyst_run();
|
|
22121
21930
|
init_run_lifecycle();
|
|
22122
21931
|
init_registry();
|
|
@@ -22145,7 +21954,7 @@ __export(public_role_summons_exports, {
|
|
|
22145
21954
|
});
|
|
22146
21955
|
import { execFile as execFile3 } from "node:child_process";
|
|
22147
21956
|
import { existsSync as existsSync9 } from "node:fs";
|
|
22148
|
-
import { realpath as
|
|
21957
|
+
import { realpath as realpath6 } from "node:fs/promises";
|
|
22149
21958
|
import { join as join38 } from "node:path";
|
|
22150
21959
|
import { promisify as promisify3 } from "node:util";
|
|
22151
21960
|
function createCapturingIo() {
|
|
@@ -22416,7 +22225,10 @@ async function summonPublicRole(options) {
|
|
|
22416
22225
|
result = stepped.ok;
|
|
22417
22226
|
}
|
|
22418
22227
|
const stderr = captured?.stderrText();
|
|
22419
|
-
const runDirectory = result.
|
|
22228
|
+
const runDirectory = result.terminal !== void 0 && result.terminal.roleOutcome.role !== options.role && typeof result.terminal.runId === "string" ? await (await Promise.resolve().then(() => (init_run_lifecycle(), run_lifecycle_exports))).findRunDirectoryById(
|
|
22229
|
+
home,
|
|
22230
|
+
result.terminal.runId
|
|
22231
|
+
) : result.admitted?.runDirectory;
|
|
22420
22232
|
return {
|
|
22421
22233
|
exitCode: result.exitCode,
|
|
22422
22234
|
...result.terminal === void 0 ? {} : { terminal: result.terminal },
|
|
@@ -22431,8 +22243,8 @@ function withReviewerLens(argv, lens) {
|
|
|
22431
22243
|
return [...argv.slice(0, separator), "--lens", lens, ...argv.slice(separator)];
|
|
22432
22244
|
}
|
|
22433
22245
|
async function resolveReviewerGitToplevel(projectRoot) {
|
|
22434
|
-
const callerProjectRoot = await
|
|
22435
|
-
return await
|
|
22246
|
+
const callerProjectRoot = await realpath6(projectRoot);
|
|
22247
|
+
return await realpath6((await execFileAsync3(
|
|
22436
22248
|
"git",
|
|
22437
22249
|
["rev-parse", "--show-toplevel"],
|
|
22438
22250
|
{ cwd: callerProjectRoot }
|
|
@@ -22620,8 +22432,10 @@ async function summonGateOfficer(options) {
|
|
|
22620
22432
|
`countersign gate summon requires parent runId from sourceRunDirectory: ${options.sourceRunDirectory}`
|
|
22621
22433
|
);
|
|
22622
22434
|
}
|
|
22623
|
-
const { readBoardTicketNumber: readBoardTicketNumber2 } = await Promise.resolve().then(() => (init_run_ticket_number(), run_ticket_number_exports));
|
|
22435
|
+
const { isSafePositiveTicketNumber: isSafePositiveTicketNumber2, readBoardTicketNumber: readBoardTicketNumber2 } = await Promise.resolve().then(() => (init_run_ticket_number(), run_ticket_number_exports));
|
|
22624
22436
|
const parentTicket = await readBoardTicketNumber2(options.sourceRunDirectory);
|
|
22437
|
+
const submittedTicket = options.submission !== null && typeof options.submission === "object" && !Array.isArray(options.submission) ? options.submission.ticketNumber : void 0;
|
|
22438
|
+
const courtTicket = isSafePositiveTicketNumber2(submittedTicket) ? submittedTicket : parentTicket;
|
|
22625
22439
|
const instruction = options.reask ?? gateReviewInstruction ?? "";
|
|
22626
22440
|
return summonPublicRole({
|
|
22627
22441
|
role: options.officer,
|
|
@@ -22629,7 +22443,7 @@ async function summonGateOfficer(options) {
|
|
|
22629
22443
|
...common,
|
|
22630
22444
|
correlationId,
|
|
22631
22445
|
parentRunPath: options.sourceRunDirectory,
|
|
22632
|
-
...
|
|
22446
|
+
...courtTicket === void 0 ? {} : { boundTicketNumber: courtTicket }
|
|
22633
22447
|
});
|
|
22634
22448
|
}
|
|
22635
22449
|
return summonPublicRole({
|
|
@@ -22786,7 +22600,7 @@ var init_compliance_transport = __esm({
|
|
|
22786
22600
|
});
|
|
22787
22601
|
|
|
22788
22602
|
// src/archivist-record-topology.ts
|
|
22789
|
-
import { createHash as
|
|
22603
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
22790
22604
|
import { join as join39 } from "node:path";
|
|
22791
22605
|
function resolveNavigatorWorkSubjectPlacement(input) {
|
|
22792
22606
|
let ledgerHome;
|
|
@@ -22797,7 +22611,7 @@ function resolveNavigatorWorkSubjectPlacement(input) {
|
|
|
22797
22611
|
}
|
|
22798
22612
|
}
|
|
22799
22613
|
ledgerHome ??= resolveActivationLedgerHome(input.home);
|
|
22800
|
-
const digest =
|
|
22614
|
+
const digest = createHash8("sha256").update(input.subject).digest("hex").slice(0, 32);
|
|
22801
22615
|
return {
|
|
22802
22616
|
ledgerHome,
|
|
22803
22617
|
sessionDir: join39(
|
|
@@ -22870,7 +22684,7 @@ import {
|
|
|
22870
22684
|
readFileSync as readFileSync4,
|
|
22871
22685
|
readSync,
|
|
22872
22686
|
realpathSync as realpathSync2,
|
|
22873
|
-
statSync as
|
|
22687
|
+
statSync as statSync5,
|
|
22874
22688
|
writeFileSync as writeFileSync2
|
|
22875
22689
|
} from "node:fs";
|
|
22876
22690
|
import { dirname as dirname20, resolve as resolve15, join as join40 } from "node:path";
|
|
@@ -22997,7 +22811,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
|
|
|
22997
22811
|
const filePath = join40(absoluteSessionDir, name);
|
|
22998
22812
|
let st;
|
|
22999
22813
|
try {
|
|
23000
|
-
st =
|
|
22814
|
+
st = statSync5(filePath);
|
|
23001
22815
|
} catch (error) {
|
|
23002
22816
|
throw new ActivationLedgerError(
|
|
23003
22817
|
`archivist navigator session file is not stat-able (${filePath}): ${errorText(error)}`,
|
|
@@ -23191,7 +23005,7 @@ import { randomUUID as randomUUID11 } from "node:crypto";
|
|
|
23191
23005
|
|
|
23192
23006
|
// src/role-runtime-dependencies.ts
|
|
23193
23007
|
init_collector_github();
|
|
23194
|
-
import { readFile as
|
|
23008
|
+
import { readFile as readFile24 } from "node:fs/promises";
|
|
23195
23009
|
import { join as join44 } from "node:path";
|
|
23196
23010
|
|
|
23197
23011
|
// src/doctor-auditor.ts
|
|
@@ -23220,7 +23034,7 @@ function createPiDoctorAuditor() {
|
|
|
23220
23034
|
init_doctor_evidence();
|
|
23221
23035
|
|
|
23222
23036
|
// src/navigator-attendance.ts
|
|
23223
|
-
import { createHash as
|
|
23037
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
23224
23038
|
init_navigator_invocation_identity();
|
|
23225
23039
|
init_packaged_role_registry();
|
|
23226
23040
|
init_activation_ledger_topology();
|
|
@@ -23230,7 +23044,7 @@ import { Type as Type13 } from "typebox";
|
|
|
23230
23044
|
|
|
23231
23045
|
// src/navigator-public-session.ts
|
|
23232
23046
|
init_sitian_facade();
|
|
23233
|
-
import { basename as
|
|
23047
|
+
import { basename as basename9 } from "node:path";
|
|
23234
23048
|
|
|
23235
23049
|
// src/navigator-session-contracts.ts
|
|
23236
23050
|
import { Type as Type12 } from "typebox";
|
|
@@ -23439,7 +23253,7 @@ function exactRecord2(value) {
|
|
|
23439
23253
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23440
23254
|
}
|
|
23441
23255
|
function runIdFromNavigatorDirectory(runDirectory) {
|
|
23442
|
-
const entry =
|
|
23256
|
+
const entry = basename9(runDirectory);
|
|
23443
23257
|
const suffix = "@navigator";
|
|
23444
23258
|
if (!entry.endsWith(suffix)) return void 0;
|
|
23445
23259
|
const runId = entry.slice(0, entry.length - suffix.length);
|
|
@@ -23668,7 +23482,7 @@ function navigatorSubjectKey(subjectRoot, subject, provenance = "role_input") {
|
|
|
23668
23482
|
if (provenance === "placeholder") return subjectRoot;
|
|
23669
23483
|
const normalized = subject.trim().replace(/\s+/g, " ");
|
|
23670
23484
|
if (normalized === "") return subjectRoot;
|
|
23671
|
-
return `${subjectRoot}#${
|
|
23485
|
+
return `${subjectRoot}#${createHash9("sha256").update(normalized).digest("hex").slice(0, 32)}`;
|
|
23672
23486
|
}
|
|
23673
23487
|
function navigatorSubjectKeyForInput(subjectRoot, reference, cwd = process.cwd()) {
|
|
23674
23488
|
if (issueRoot(subjectRoot) !== void 0 || !subjectRoot.includes("/.ak/work/")) return subjectRoot;
|
|
@@ -24184,7 +23998,7 @@ ${helpContext}
|
|
|
24184
23998
|
// src/navigator-work-context.ts
|
|
24185
23999
|
init_doctor_evidence();
|
|
24186
24000
|
init_host_contracts();
|
|
24187
|
-
import { readFile as
|
|
24001
|
+
import { readFile as readFile22 } from "node:fs/promises";
|
|
24188
24002
|
import { resolve as resolve17 } from "node:path";
|
|
24189
24003
|
init_notary_source_run();
|
|
24190
24004
|
init_packaged_role_registry();
|
|
@@ -24198,7 +24012,7 @@ function navigatorInputReference(getFlag, role) {
|
|
|
24198
24012
|
async function loadNavigatorWorkContext(options) {
|
|
24199
24013
|
const reference = navigatorInputReference(options.getFlag, options.role);
|
|
24200
24014
|
const subjectMode = packagedNavigatorSubject(options.role);
|
|
24201
|
-
const input = reference === void 0 || subjectMode === "case" || subjectMode === "source-run" ? void 0 : await
|
|
24015
|
+
const input = reference === void 0 || subjectMode === "case" || subjectMode === "source-run" ? void 0 : await readFile22(reference, "utf8");
|
|
24202
24016
|
const subjectRoot = subjectPath(reference ?? options.context.sessionManager.getSessionDir(), options.context.cwd);
|
|
24203
24017
|
let subjectKey = reference === void 0 ? subjectRoot : navigatorSubjectKeyForInput(subjectRoot, reference, options.context.cwd);
|
|
24204
24018
|
let subject = input ?? `work subject: ${subjectKey}`;
|
|
@@ -24255,7 +24069,7 @@ async function loadNavigatorWorkContext(options) {
|
|
|
24255
24069
|
let authorityMaterial;
|
|
24256
24070
|
for (const path of authorityFiles) {
|
|
24257
24071
|
try {
|
|
24258
|
-
const content = await
|
|
24072
|
+
const content = await readFile22(path, "utf8");
|
|
24259
24073
|
if (content.trim() !== "") {
|
|
24260
24074
|
authorityMaterial = content;
|
|
24261
24075
|
break;
|
|
@@ -24279,52 +24093,6 @@ async function loadNavigatorWorkContext(options) {
|
|
|
24279
24093
|
// src/role-runtime-dependencies.ts
|
|
24280
24094
|
init_notary_source_run();
|
|
24281
24095
|
|
|
24282
|
-
// src/package-resources/method-skill-binding.ts
|
|
24283
|
-
import { dirname as dirname23 } from "node:path";
|
|
24284
|
-
|
|
24285
|
-
// src/canonical-skill-binding.ts
|
|
24286
|
-
import { dirname as dirname22, resolve as resolve18 } from "node:path";
|
|
24287
|
-
import { stripFrontmatter } from "@earendil-works/pi-coding-agent";
|
|
24288
|
-
function captureCanonicalSkillExpansion(name, snapshot, configuredPath, evidence, originalRequest) {
|
|
24289
|
-
const matchedPath = evidence?.location === configuredPath ? configuredPath : evidence?.location === snapshot.path ? snapshot.path : void 0;
|
|
24290
|
-
const expectedContent = matchedPath === void 0 ? void 0 : snapshot.body;
|
|
24291
|
-
const prefixedContent = matchedPath === void 0 ? void 0 : `References are relative to ${dirname22(matchedPath)}.
|
|
24292
|
-
|
|
24293
|
-
${snapshot.body}`;
|
|
24294
|
-
if (evidence?.name !== name || matchedPath === void 0 || evidence.content !== expectedContent && evidence.content !== prefixedContent || evidence.userMessage !== originalRequest) {
|
|
24295
|
-
return void 0;
|
|
24296
|
-
}
|
|
24297
|
-
return Object.freeze({ ...evidence, name });
|
|
24298
|
-
}
|
|
24299
|
-
|
|
24300
|
-
// src/package-resources/method-skill-binding.ts
|
|
24301
|
-
init_method_skill();
|
|
24302
|
-
async function loadPackagedCanonicalSkillBinding(packageRoot, name) {
|
|
24303
|
-
const material = await loadPackagedMethodSkillMaterial(packageRoot, name);
|
|
24304
|
-
const configuredPath = resolvePackagedMethodSkillPath(packageRoot, name);
|
|
24305
|
-
const snapshot = Object.freeze({
|
|
24306
|
-
raw: material.raw,
|
|
24307
|
-
path: material.skillPath,
|
|
24308
|
-
baseDir: dirname23(material.skillPath),
|
|
24309
|
-
body: material.body,
|
|
24310
|
-
snapshotIdentity: Object.freeze({ text: material.raw })
|
|
24311
|
-
});
|
|
24312
|
-
const binding = {
|
|
24313
|
-
name,
|
|
24314
|
-
snapshot,
|
|
24315
|
-
captureExpansion(evidence, originalRequest) {
|
|
24316
|
-
return captureCanonicalSkillExpansion(
|
|
24317
|
-
name,
|
|
24318
|
-
snapshot,
|
|
24319
|
-
configuredPath,
|
|
24320
|
-
evidence,
|
|
24321
|
-
originalRequest
|
|
24322
|
-
);
|
|
24323
|
-
}
|
|
24324
|
-
};
|
|
24325
|
-
return Object.freeze(binding);
|
|
24326
|
-
}
|
|
24327
|
-
|
|
24328
24096
|
// src/role-runtime.ts
|
|
24329
24097
|
init_readable_gate_item();
|
|
24330
24098
|
init_host_contracts();
|
|
@@ -24381,10 +24149,10 @@ init_activation_ledger_topology();
|
|
|
24381
24149
|
import {
|
|
24382
24150
|
lstatSync as lstatSync2,
|
|
24383
24151
|
realpathSync as realpathSync3,
|
|
24384
|
-
statSync as
|
|
24152
|
+
statSync as statSync6,
|
|
24385
24153
|
writeFileSync as writeFileSync3
|
|
24386
24154
|
} from "node:fs";
|
|
24387
|
-
import { isAbsolute as isAbsolute11, resolve as
|
|
24155
|
+
import { isAbsolute as isAbsolute11, resolve as resolve18 } from "node:path";
|
|
24388
24156
|
var ActivationSessionFileMissingError = class extends Error {
|
|
24389
24157
|
code = "AK_ACTIVATION_SESSION_FILE_MISSING";
|
|
24390
24158
|
path;
|
|
@@ -24429,7 +24197,7 @@ function durableSessionPointer(sessionManager) {
|
|
|
24429
24197
|
`Workflow role activation requires an absolute durable session file path; got relative path: ${file}`
|
|
24430
24198
|
);
|
|
24431
24199
|
}
|
|
24432
|
-
const resolvedFile =
|
|
24200
|
+
const resolvedFile = resolve18(file);
|
|
24433
24201
|
try {
|
|
24434
24202
|
lstatSync2(resolvedFile);
|
|
24435
24203
|
} catch (error) {
|
|
@@ -24456,7 +24224,7 @@ function durableSessionPointer(sessionManager) {
|
|
|
24456
24224
|
}
|
|
24457
24225
|
let info;
|
|
24458
24226
|
try {
|
|
24459
|
-
info =
|
|
24227
|
+
info = statSync6(realFile);
|
|
24460
24228
|
} catch (error) {
|
|
24461
24229
|
throw new Error(
|
|
24462
24230
|
`Workflow role activation failed to stat durable session file (${realFile}): ${errorText(error)}`,
|
|
@@ -24765,7 +24533,7 @@ init_collector_github();
|
|
|
24765
24533
|
// src/collector-handbook.ts
|
|
24766
24534
|
init_atomic_write();
|
|
24767
24535
|
init_activation_ledger_topology();
|
|
24768
|
-
import { readFile as
|
|
24536
|
+
import { readFile as readFile23 } from "node:fs/promises";
|
|
24769
24537
|
import { join as join42, sep as sep6 } from "node:path";
|
|
24770
24538
|
|
|
24771
24539
|
// src/collector-tool-schemas.ts
|
|
@@ -24909,7 +24677,7 @@ function createCollectorHandbookStore(input) {
|
|
|
24909
24677
|
ensureRealDirectoryTree(input.ledgerHome, parentDir2);
|
|
24910
24678
|
assertLedgerFileInsideHome(path, input.ledgerHome);
|
|
24911
24679
|
try {
|
|
24912
|
-
const body = await
|
|
24680
|
+
const body = await readFile23(path, "utf8");
|
|
24913
24681
|
assertHandbookBudget(body, "\u6B63\u6587");
|
|
24914
24682
|
return body;
|
|
24915
24683
|
} catch (error) {
|
|
@@ -26072,7 +25840,6 @@ var reviewerOutputSchema = withTerminatingOutputDeclarations(
|
|
|
26072
25840
|
);
|
|
26073
25841
|
function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
|
|
26074
25842
|
let soul;
|
|
26075
|
-
let binding;
|
|
26076
25843
|
let registered = false;
|
|
26077
25844
|
let fixedBaseRevision;
|
|
26078
25845
|
return {
|
|
@@ -26080,9 +25847,6 @@ function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
|
|
|
26080
25847
|
soul = (await dependencies.loadSoul()).trim();
|
|
26081
25848
|
if (!soul) throw new Error("Reviewer soul is empty");
|
|
26082
25849
|
fixedBaseRevision = admitted.baseRevision;
|
|
26083
|
-
const loaded = await dependencies.loadCanonicalSkillBinding("ak-cross-m-review");
|
|
26084
|
-
if (loaded.name !== "ak-cross-m-review") throw new Error("Canonical Skill binding loader returned tdd for ak-cross-m-review");
|
|
26085
|
-
binding = loaded;
|
|
26086
25850
|
if (!registered) {
|
|
26087
25851
|
registered = true;
|
|
26088
25852
|
pi.registerTool({
|
|
@@ -26092,7 +25856,7 @@ function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
|
|
|
26092
25856
|
promptSnippet: "\u63D0\u4EA4\u5FA1\u53F2\u53F0\u7EC8\u5C40\u56DE\u6267",
|
|
26093
25857
|
parameters: reviewerOutputSchema,
|
|
26094
25858
|
async execute(_id, parameters) {
|
|
26095
|
-
if (!soul
|
|
25859
|
+
if (!soul) throw new Error("\u5FA1\u53F2\u53F0\u8F93\u5165\u672A\u88C5\u8F7D");
|
|
26096
25860
|
return {
|
|
26097
25861
|
content: [],
|
|
26098
25862
|
details: parameters,
|
|
@@ -26103,11 +25867,9 @@ function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
|
|
|
26103
25867
|
}
|
|
26104
25868
|
const activatedSoul = soul;
|
|
26105
25869
|
const activatedBase = fixedBaseRevision;
|
|
26106
|
-
const activatedBinding = binding;
|
|
26107
25870
|
return Object.freeze({
|
|
26108
25871
|
fixedBaseRevision: activatedBase,
|
|
26109
|
-
soul: activatedSoul
|
|
26110
|
-
skillBinding: activatedBinding
|
|
25872
|
+
soul: activatedSoul
|
|
26111
25873
|
});
|
|
26112
25874
|
}
|
|
26113
25875
|
};
|
|
@@ -26116,7 +25878,6 @@ function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
|
|
|
26116
25878
|
// src/worker-role.ts
|
|
26117
25879
|
init_open_tool_schema();
|
|
26118
25880
|
init_terminating_infrastructure();
|
|
26119
|
-
init_submission_correctable_error();
|
|
26120
25881
|
init_readable_gate_item();
|
|
26121
25882
|
init_audit_escalation();
|
|
26122
25883
|
init_submission_errors();
|
|
@@ -26132,7 +25893,7 @@ init_submission_errors();
|
|
|
26132
25893
|
init_submission_errors();
|
|
26133
25894
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
26134
25895
|
import { existsSync as existsSync12, lstatSync as lstatSync3, readdirSync as readdirSync3, readFileSync as readFileSync5, rmdirSync, rmSync } from "node:fs";
|
|
26135
|
-
import { resolve as
|
|
25896
|
+
import { resolve as resolve19 } from "node:path";
|
|
26136
25897
|
var WORKER_SUBMISSION_GATE_RECORD_KIND = WORKER_SUBMISSION_GATE_KIND;
|
|
26137
25898
|
var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
|
|
26138
25899
|
var WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE = "commit-reminder-bounce";
|
|
@@ -26181,7 +25942,7 @@ function escapeGitConfigValueRegex(value) {
|
|
|
26181
25942
|
function unsetOwnedHooksPath(file) {
|
|
26182
25943
|
const owned = [];
|
|
26183
25944
|
for (const value of tryGetAll(file, "core.hooksPath")) {
|
|
26184
|
-
if (!ownedHook(
|
|
25945
|
+
if (!ownedHook(resolve19(value, HOOK_FILE))) continue;
|
|
26185
25946
|
try {
|
|
26186
25947
|
gitFile(file, [
|
|
26187
25948
|
"--unset-all",
|
|
@@ -26196,15 +25957,15 @@ function unsetOwnedHooksPath(file) {
|
|
|
26196
25957
|
return owned;
|
|
26197
25958
|
}
|
|
26198
25959
|
function rmOwnedDir(dir) {
|
|
26199
|
-
const hookPath =
|
|
25960
|
+
const hookPath = resolve19(dir, HOOK_FILE);
|
|
26200
25961
|
if (!ownedHook(hookPath)) return;
|
|
26201
25962
|
rmSync(hookPath, { force: true });
|
|
26202
25963
|
if (existsSync12(dir) && readdirSync3(dir).length === 0) rmdirSync(dir);
|
|
26203
25964
|
}
|
|
26204
25965
|
function linkedGitDirs(commonDir) {
|
|
26205
|
-
const root =
|
|
25966
|
+
const root = resolve19(commonDir, "worktrees");
|
|
26206
25967
|
if (!existsSync12(root)) return [];
|
|
26207
|
-
return readdirSync3(root).map((name) =>
|
|
25968
|
+
return readdirSync3(root).map((name) => resolve19(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
|
|
26208
25969
|
}
|
|
26209
25970
|
function uninstallPackageWorkerHooks(cwd) {
|
|
26210
25971
|
let inside;
|
|
@@ -26218,17 +25979,17 @@ function uninstallPackageWorkerHooks(cwd) {
|
|
|
26218
25979
|
const clear = (configFile) => {
|
|
26219
25980
|
for (const hooks of unsetOwnedHooksPath(configFile)) rmOwnedDir(hooks);
|
|
26220
25981
|
};
|
|
26221
|
-
clear(
|
|
26222
|
-
clear(
|
|
26223
|
-
rmOwnedDir(
|
|
26224
|
-
const legacy =
|
|
25982
|
+
clear(resolve19(commonDir, "config"));
|
|
25983
|
+
clear(resolve19(commonDir, "config.worktree"));
|
|
25984
|
+
rmOwnedDir(resolve19(commonDir, HOOKS_DIR));
|
|
25985
|
+
const legacy = resolve19(commonDir, "hooks", HOOK_FILE);
|
|
26225
25986
|
if (ownedHook(legacy)) rmSync(legacy, { force: true });
|
|
26226
25987
|
for (const gitDir of linkedGitDirs(commonDir)) {
|
|
26227
|
-
clear(
|
|
26228
|
-
rmOwnedDir(
|
|
25988
|
+
clear(resolve19(gitDir, "config.worktree"));
|
|
25989
|
+
rmOwnedDir(resolve19(gitDir, HOOKS_DIR));
|
|
26229
25990
|
}
|
|
26230
25991
|
}
|
|
26231
|
-
function
|
|
25992
|
+
function isRecord17(value) {
|
|
26232
25993
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26233
25994
|
}
|
|
26234
25995
|
function unfinishedReasonPresent(details) {
|
|
@@ -26244,7 +26005,7 @@ function readGateState(session) {
|
|
|
26244
26005
|
if (entry.type !== "custom") continue;
|
|
26245
26006
|
if (entry.customType === WORKER_COMMIT_BASELINE_ENTRY_TYPE) {
|
|
26246
26007
|
const data = entry.data;
|
|
26247
|
-
if (
|
|
26008
|
+
if (isRecord17(data) && (data.head === null || typeof data.head === "string")) {
|
|
26248
26009
|
baseline = data.head;
|
|
26249
26010
|
}
|
|
26250
26011
|
} else if (entry.customType === WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE) {
|
|
@@ -26437,7 +26198,7 @@ var FIXER_PHASES = ["plan", "apply"];
|
|
|
26437
26198
|
function isWorkerPhase(value) {
|
|
26438
26199
|
return typeof value === "string" && FIXER_PHASES.includes(value);
|
|
26439
26200
|
}
|
|
26440
|
-
function
|
|
26201
|
+
function isRecord18(value) {
|
|
26441
26202
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26442
26203
|
}
|
|
26443
26204
|
var WORKER_ROUTING_STATUSES = /* @__PURE__ */ new Set([
|
|
@@ -26449,7 +26210,7 @@ var WORKER_ROUTING_STATUSES = /* @__PURE__ */ new Set([
|
|
|
26449
26210
|
]);
|
|
26450
26211
|
var WORKER_STATUS_REASK = "status \u4E0D\u662F planned\u3001completed\u3001refused\u3001partially_completed\u3001unfinished \u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
|
|
26451
26212
|
function workerStatusOf(output) {
|
|
26452
|
-
return
|
|
26213
|
+
return isRecord18(output) && typeof output.status === "string" ? output.status : void 0;
|
|
26453
26214
|
}
|
|
26454
26215
|
function requireReadableWorkerStatus(output) {
|
|
26455
26216
|
const status = workerStatusOf(output);
|
|
@@ -26626,10 +26387,6 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
|
|
|
26626
26387
|
let soul;
|
|
26627
26388
|
let task;
|
|
26628
26389
|
let phase;
|
|
26629
|
-
let binding;
|
|
26630
|
-
let tddInvocationInjected = false;
|
|
26631
|
-
let originalRequest;
|
|
26632
|
-
let expansionPending = false;
|
|
26633
26390
|
let lifecycleRegistered = false;
|
|
26634
26391
|
const submissionGate = createWorkerSubmissionGate();
|
|
26635
26392
|
pi.registerFlag("ak-coder-task", {
|
|
@@ -26642,9 +26399,6 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
|
|
|
26642
26399
|
});
|
|
26643
26400
|
return {
|
|
26644
26401
|
async activate(ctx) {
|
|
26645
|
-
tddInvocationInjected = false;
|
|
26646
|
-
originalRequest = void 0;
|
|
26647
|
-
expansionPending = false;
|
|
26648
26402
|
soul = (await dependencies.loadSoul()).trim();
|
|
26649
26403
|
if (soul.length === 0) throw new Error("Coder soul is empty");
|
|
26650
26404
|
const selectedPhase = pi.getFlag("ak-coder-phase");
|
|
@@ -26660,24 +26414,6 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
|
|
|
26660
26414
|
}
|
|
26661
26415
|
task = (await dependencies.loadTask(taskPath)).trim();
|
|
26662
26416
|
if (task.length === 0) throw new Error("Coder task is empty");
|
|
26663
|
-
binding = void 0;
|
|
26664
|
-
if (phase === "apply") {
|
|
26665
|
-
if (dependencies.loadCanonicalSkillBinding === void 0) {
|
|
26666
|
-
throw new Error("Coder canonical Skill binding loader is not configured");
|
|
26667
|
-
}
|
|
26668
|
-
try {
|
|
26669
|
-
const loaded = await dependencies.loadCanonicalSkillBinding("tdd");
|
|
26670
|
-
if (loaded.name !== "tdd") {
|
|
26671
|
-
throw new Error(
|
|
26672
|
-
"Canonical Skill binding loader returned ak-cross-m-review for tdd"
|
|
26673
|
-
);
|
|
26674
|
-
}
|
|
26675
|
-
binding = loaded;
|
|
26676
|
-
} catch (error) {
|
|
26677
|
-
if (ctx === void 0) throw error;
|
|
26678
|
-
hostActions.failInfrastructure(error, ctx);
|
|
26679
|
-
}
|
|
26680
|
-
}
|
|
26681
26417
|
if (!lifecycleRegistered) {
|
|
26682
26418
|
lifecycleRegistered = true;
|
|
26683
26419
|
pi.registerTool({
|
|
@@ -26732,28 +26468,8 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
|
|
|
26732
26468
|
};
|
|
26733
26469
|
}
|
|
26734
26470
|
});
|
|
26735
|
-
pi.on("input", (event) => {
|
|
26736
|
-
if (phase !== "apply" || tddInvocationInjected) {
|
|
26737
|
-
return { action: "continue" };
|
|
26738
|
-
}
|
|
26739
|
-
tddInvocationInjected = true;
|
|
26740
|
-
expansionPending = true;
|
|
26741
|
-
originalRequest = binding === void 0 ? event.text : pi.capabilities?.skillOriginalRequest?.(binding.name, event.text) ?? event.text;
|
|
26742
|
-
return { action: "continue" };
|
|
26743
|
-
});
|
|
26744
26471
|
pi.on("before_agent_start", (event, ctx2) => {
|
|
26745
26472
|
if (soul === void 0) throw new Error("\u5C06\u4F5C\u76D1\u804C\u5206\u672A\u88C5\u8F7D");
|
|
26746
|
-
if (phase === "apply") {
|
|
26747
|
-
if (binding === void 0) {
|
|
26748
|
-
hostActions.failInfrastructure(
|
|
26749
|
-
new Error("Coder canonical tdd Skill binding was not initialized"),
|
|
26750
|
-
ctx2
|
|
26751
|
-
);
|
|
26752
|
-
}
|
|
26753
|
-
if (expansionPending) {
|
|
26754
|
-
expansionPending = false;
|
|
26755
|
-
}
|
|
26756
|
-
}
|
|
26757
26473
|
return {
|
|
26758
26474
|
systemPrompt: `${event.systemPrompt}
|
|
26759
26475
|
|
|
@@ -27522,8 +27238,6 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27522
27238
|
let selectedRole;
|
|
27523
27239
|
let roleReferenceMaterials = "";
|
|
27524
27240
|
let activeReviewerParent;
|
|
27525
|
-
let reviewerOriginalRequest;
|
|
27526
|
-
let reviewerExpansionCaptured = false;
|
|
27527
27241
|
let navigatorAttendance;
|
|
27528
27242
|
let pendingNavigatorPresentation;
|
|
27529
27243
|
let pendingNavigatorSettlement;
|
|
@@ -27614,16 +27328,9 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27614
27328
|
() => receiptDelivery.recordAccepted(),
|
|
27615
27329
|
settleNavigatorProjection
|
|
27616
27330
|
);
|
|
27617
|
-
roleHost.on("input", (
|
|
27618
|
-
const text = event.text;
|
|
27331
|
+
roleHost.on("input", (_event) => {
|
|
27619
27332
|
const role = roleHost.getFlag(ROLE_FLAG.name);
|
|
27620
27333
|
if (role !== void 0 && !admitted) return { action: "handled" };
|
|
27621
|
-
if (admitted && activeReviewerParent !== void 0 && selectedRole === role && reviewerOriginalRequest === void 0) {
|
|
27622
|
-
reviewerOriginalRequest = roleHost.capabilities?.skillOriginalRequest?.(
|
|
27623
|
-
activeReviewerParent.skillBinding.name,
|
|
27624
|
-
text
|
|
27625
|
-
) ?? text;
|
|
27626
|
-
}
|
|
27627
27334
|
return { action: "continue" };
|
|
27628
27335
|
});
|
|
27629
27336
|
roleHost.on("before_agent_start", () => roleReferenceMaterials === "" ? void 0 : { readingMaterial: { kind: "role-reference-materials", content: roleReferenceMaterials } });
|
|
@@ -27660,15 +27367,6 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27660
27367
|
}
|
|
27661
27368
|
navigatorAttendance?.prepare();
|
|
27662
27369
|
if (activeReviewerParent !== void 0 && selectedRole === role) {
|
|
27663
|
-
if (!reviewerExpansionCaptured) {
|
|
27664
|
-
if (reviewerOriginalRequest !== void 0) {
|
|
27665
|
-
activeReviewerParent.skillBinding.captureExpansion(
|
|
27666
|
-
roleHost.capabilities?.skillExpansion(prompt),
|
|
27667
|
-
reviewerOriginalRequest
|
|
27668
|
-
);
|
|
27669
|
-
}
|
|
27670
|
-
reviewerExpansionCaptured = true;
|
|
27671
|
-
}
|
|
27672
27370
|
return {
|
|
27673
27371
|
systemPrompt: assembleReviewerParentSystemPrompt({
|
|
27674
27372
|
baseSystemPrompt: event.systemPrompt,
|
|
@@ -27941,9 +27639,6 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27941
27639
|
throw new Error("Coder task loader is not configured");
|
|
27942
27640
|
}
|
|
27943
27641
|
return dependencies.loadCoderTask(path);
|
|
27944
|
-
},
|
|
27945
|
-
...dependencies.loadCanonicalSkillBinding === void 0 ? {} : {
|
|
27946
|
-
loadCanonicalSkillBinding: (name) => dependencies.loadCanonicalSkillBinding(name)
|
|
27947
27642
|
}
|
|
27948
27643
|
},
|
|
27949
27644
|
hostActions
|
|
@@ -27951,13 +27646,7 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27951
27646
|
const reviewer = createReviewerRoleRuntime(
|
|
27952
27647
|
roleHost,
|
|
27953
27648
|
{
|
|
27954
|
-
loadSoul: () => requireRoleSoul("reviewer")
|
|
27955
|
-
async loadCanonicalSkillBinding(name) {
|
|
27956
|
-
if (dependencies.loadCanonicalSkillBinding === void 0) {
|
|
27957
|
-
throw new Error("Reviewer runtime dependencies are not configured");
|
|
27958
|
-
}
|
|
27959
|
-
return dependencies.loadCanonicalSkillBinding(name);
|
|
27960
|
-
}
|
|
27649
|
+
loadSoul: () => requireRoleSoul("reviewer")
|
|
27961
27650
|
},
|
|
27962
27651
|
hostActions
|
|
27963
27652
|
);
|
|
@@ -28192,8 +27881,6 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
28192
27881
|
activeReviewerParent = void 0;
|
|
28193
27882
|
activeCollector = void 0;
|
|
28194
27883
|
collectorFirstDispatchDone = false;
|
|
28195
|
-
reviewerOriginalRequest = void 0;
|
|
28196
|
-
reviewerExpansionCaptured = false;
|
|
28197
27884
|
receiptDelivery = createReceiptDeliveryPolicy();
|
|
28198
27885
|
noReceiptRecorded = false;
|
|
28199
27886
|
observationFace.reset();
|
|
@@ -28357,25 +28044,13 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
28357
28044
|
packageRoot,
|
|
28358
28045
|
loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
|
|
28359
28046
|
loadRoleSoul: loadRegisteredRoleSoul,
|
|
28360
|
-
loadFixPacket: (path) =>
|
|
28361
|
-
loadCoderTask: (path) =>
|
|
28362
|
-
loadCollectorHandbookSeed: () =>
|
|
28047
|
+
loadFixPacket: (path) => readFile24(path, "utf8"),
|
|
28048
|
+
loadCoderTask: (path) => readFile24(path, "utf8"),
|
|
28049
|
+
loadCollectorHandbookSeed: () => readFile24(collectorHandbookSeedPath, "utf8"),
|
|
28363
28050
|
createCollectorTransport: () => createGhCollectorGitHubTransport(),
|
|
28364
28051
|
loadDoctorCase,
|
|
28365
28052
|
loadNotarySourceRun: loadNotarySourceRunLocator,
|
|
28366
|
-
loadMergerInput: async (path) => JSON.parse(await
|
|
28367
|
-
async loadCanonicalSkillBinding(name) {
|
|
28368
|
-
switch (name) {
|
|
28369
|
-
case "tdd":
|
|
28370
|
-
return loadPackagedCanonicalSkillBinding(packageRoot, name);
|
|
28371
|
-
case "ak-cross-m-review":
|
|
28372
|
-
return loadPackagedCanonicalSkillBinding(packageRoot, name);
|
|
28373
|
-
default: {
|
|
28374
|
-
const unexpected = name;
|
|
28375
|
-
throw new Error(`Canonical skill is not packaged: ${String(unexpected)}`);
|
|
28376
|
-
}
|
|
28377
|
-
}
|
|
28378
|
-
},
|
|
28053
|
+
loadMergerInput: async (path) => JSON.parse(await readFile24(path, "utf8")),
|
|
28379
28054
|
// #590: doctor compliance still on disposeCompliance path; judge→auditor is gate queue (#756).
|
|
28380
28055
|
auditDoctorCompliance: (options) => doctorAuditor(options),
|
|
28381
28056
|
loadNavigatorWorkContext: (options) => loadNavigatorWorkContext({
|
|
@@ -28392,7 +28067,7 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
28392
28067
|
authority: options.authority,
|
|
28393
28068
|
invocationId: options.invocationId,
|
|
28394
28069
|
loadSoul: () => loadRegisteredRoleSoul("navigator"),
|
|
28395
|
-
loadRoutePlaybook: () =>
|
|
28070
|
+
loadRoutePlaybook: () => readFile24(navigatorRoutePlaybookPath, "utf8"),
|
|
28396
28071
|
loadRoleHelp: async (role) => formatNavigatorRoleHelp(role),
|
|
28397
28072
|
createSession: navigatorSessionFactory,
|
|
28398
28073
|
...options.contextError === void 0 ? {} : { contextError: options.contextError },
|
|
@@ -28406,7 +28081,7 @@ init_engine_detour();
|
|
|
28406
28081
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
28407
28082
|
import { appendFile as appendFile3, mkdir as mkdir5, writeFile as writeFile11 } from "node:fs/promises";
|
|
28408
28083
|
import { createServer } from "node:net";
|
|
28409
|
-
import { dirname as
|
|
28084
|
+
import { dirname as dirname22, join as join45 } from "node:path";
|
|
28410
28085
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
28411
28086
|
|
|
28412
28087
|
// src/submission-gate.ts
|
|
@@ -28510,141 +28185,6 @@ async function requireSubmissionGate(options) {
|
|
|
28510
28185
|
}
|
|
28511
28186
|
}
|
|
28512
28187
|
|
|
28513
|
-
// src/host-native-method.ts
|
|
28514
|
-
import { access as access4, lstat as lstat7, mkdir as mkdir4, readdir as readdir9, readFile as readFile26, readlink, realpath as realpath8, symlink } from "node:fs/promises";
|
|
28515
|
-
import { basename as basename11, dirname as dirname24, join as join45 } from "node:path";
|
|
28516
|
-
var HOST_METHOD_PLUGIN_NAME = "ak-methods";
|
|
28517
|
-
var packagedMethodsDir = (root) => join45(root, "resources", "methods");
|
|
28518
|
-
var packagedMethodPluginDir = (root) => join45(root, "dist", "method-host-plugin");
|
|
28519
|
-
function hostMethodSkills(methods) {
|
|
28520
|
-
return Object.freeze(methods.flatMap((method) => {
|
|
28521
|
-
if (method.kind !== "skill") return [];
|
|
28522
|
-
const name = basename11(dirname24(method.path));
|
|
28523
|
-
return name ? [Object.freeze({ name })] : [];
|
|
28524
|
-
}));
|
|
28525
|
-
}
|
|
28526
|
-
var alreadyPrefixed = (prompt, token) => {
|
|
28527
|
-
const text = prompt.trimStart();
|
|
28528
|
-
return text === token || text.startsWith(`${token} `) || text.startsWith(`${token}
|
|
28529
|
-
`);
|
|
28530
|
-
};
|
|
28531
|
-
function prefixMethodInvocation(token, prompt) {
|
|
28532
|
-
if (alreadyPrefixed(prompt, token)) return prompt;
|
|
28533
|
-
return prompt ? `${token} ${prompt}` : token;
|
|
28534
|
-
}
|
|
28535
|
-
function applyClaudeSkillInvocation(methods, prompt) {
|
|
28536
|
-
const skills = hostMethodSkills(methods);
|
|
28537
|
-
if (skills.length !== 1) return prompt;
|
|
28538
|
-
return prefixMethodInvocation(`/${HOST_METHOD_PLUGIN_NAME}:${skills[0].name}`, prompt);
|
|
28539
|
-
}
|
|
28540
|
-
function applyCodexSkillInvocation(methods, prompt) {
|
|
28541
|
-
return hostMethodSkills(methods).reduceRight(
|
|
28542
|
-
(invocation, skill) => prefixMethodInvocation(`$${skill.name}`, invocation),
|
|
28543
|
-
prompt
|
|
28544
|
-
);
|
|
28545
|
-
}
|
|
28546
|
-
var isEnoent3 = (error) => error.code === "ENOENT";
|
|
28547
|
-
async function packagedMethodSkillNames(packagedMethodsRealpath) {
|
|
28548
|
-
const entries = await readdir9(packagedMethodsRealpath, { withFileTypes: true });
|
|
28549
|
-
const names = [];
|
|
28550
|
-
for (const entry of entries) {
|
|
28551
|
-
if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
|
|
28552
|
-
try {
|
|
28553
|
-
await access4(join45(packagedMethodsRealpath, entry.name, "SKILL.md"));
|
|
28554
|
-
} catch (error) {
|
|
28555
|
-
if (isEnoent3(error)) continue;
|
|
28556
|
-
throw error;
|
|
28557
|
-
}
|
|
28558
|
-
names.push(entry.name);
|
|
28559
|
-
}
|
|
28560
|
-
return names;
|
|
28561
|
-
}
|
|
28562
|
-
async function packagedSkillFileBytes(skillDir) {
|
|
28563
|
-
try {
|
|
28564
|
-
await access4(join45(skillDir, "SKILL.md"));
|
|
28565
|
-
} catch (error) {
|
|
28566
|
-
if (isEnoent3(error)) return void 0;
|
|
28567
|
-
throw error;
|
|
28568
|
-
}
|
|
28569
|
-
const files = /* @__PURE__ */ new Map();
|
|
28570
|
-
async function walk(dir, prefix) {
|
|
28571
|
-
const entries = await readdir9(dir, { withFileTypes: true });
|
|
28572
|
-
for (const entry of entries) {
|
|
28573
|
-
const rel = prefix === "" ? entry.name : `${prefix}/${entry.name}`;
|
|
28574
|
-
const full = join45(dir, entry.name);
|
|
28575
|
-
if (entry.isDirectory()) {
|
|
28576
|
-
await walk(full, rel);
|
|
28577
|
-
continue;
|
|
28578
|
-
}
|
|
28579
|
-
if (entry.isFile()) {
|
|
28580
|
-
files.set(rel, await readFile26(full));
|
|
28581
|
-
}
|
|
28582
|
-
}
|
|
28583
|
-
}
|
|
28584
|
-
await walk(skillDir, "");
|
|
28585
|
-
return files;
|
|
28586
|
-
}
|
|
28587
|
-
async function catalogPublishesPackagedSkill(catalogSkillDir, required) {
|
|
28588
|
-
for (const [rel, bytes] of required) {
|
|
28589
|
-
let other;
|
|
28590
|
-
try {
|
|
28591
|
-
other = await readFile26(join45(catalogSkillDir, rel));
|
|
28592
|
-
} catch (error) {
|
|
28593
|
-
if (isEnoent3(error)) return false;
|
|
28594
|
-
throw error;
|
|
28595
|
-
}
|
|
28596
|
-
if (!bytes.equals(other)) return false;
|
|
28597
|
-
}
|
|
28598
|
-
return true;
|
|
28599
|
-
}
|
|
28600
|
-
async function isCompatibleMethodCatalog(link, packagedMethodsRealpath) {
|
|
28601
|
-
const stat2 = await lstat7(link);
|
|
28602
|
-
if (!stat2.isSymbolicLink()) return false;
|
|
28603
|
-
let resolved;
|
|
28604
|
-
try {
|
|
28605
|
-
resolved = await realpath8(link);
|
|
28606
|
-
} catch (error) {
|
|
28607
|
-
if (isEnoent3(error)) return false;
|
|
28608
|
-
throw error;
|
|
28609
|
-
}
|
|
28610
|
-
if (resolved === packagedMethodsRealpath) return true;
|
|
28611
|
-
const names = await packagedMethodSkillNames(packagedMethodsRealpath);
|
|
28612
|
-
if (names.length === 0) return false;
|
|
28613
|
-
for (const name of names) {
|
|
28614
|
-
const required = await packagedSkillFileBytes(join45(packagedMethodsRealpath, name));
|
|
28615
|
-
if (required === void 0) return false;
|
|
28616
|
-
if (!await catalogPublishesPackagedSkill(join45(resolved, name), required)) return false;
|
|
28617
|
-
}
|
|
28618
|
-
return true;
|
|
28619
|
-
}
|
|
28620
|
-
async function installWorkspaceMethodSkills(cwd, packageRoot) {
|
|
28621
|
-
const target = await realpath8(packagedMethodsDir(packageRoot));
|
|
28622
|
-
const link = join45(cwd, ".agents", "skills");
|
|
28623
|
-
let present;
|
|
28624
|
-
try {
|
|
28625
|
-
await lstat7(link);
|
|
28626
|
-
present = true;
|
|
28627
|
-
} catch (error) {
|
|
28628
|
-
if (!isEnoent3(error)) throw error;
|
|
28629
|
-
present = false;
|
|
28630
|
-
}
|
|
28631
|
-
if (present) {
|
|
28632
|
-
if (await isCompatibleMethodCatalog(link, target)) return;
|
|
28633
|
-
const stat2 = await lstat7(link);
|
|
28634
|
-
const detail = stat2.isSymbolicLink() ? `symlink to ${await readlink(link)}` : "non-symlink entry";
|
|
28635
|
-
throw new Error(`workspace method catalog conflict at ${link}: ${detail}`);
|
|
28636
|
-
}
|
|
28637
|
-
await mkdir4(dirname24(link), { recursive: true });
|
|
28638
|
-
try {
|
|
28639
|
-
await symlink(target, link);
|
|
28640
|
-
} catch (error) {
|
|
28641
|
-
if (error.code !== "EEXIST") throw error;
|
|
28642
|
-
if (!await isCompatibleMethodCatalog(link, target)) {
|
|
28643
|
-
throw new Error(`workspace method catalog conflict at ${link}`);
|
|
28644
|
-
}
|
|
28645
|
-
}
|
|
28646
|
-
}
|
|
28647
|
-
|
|
28648
28188
|
// src/role-envelope.ts
|
|
28649
28189
|
init_packaged_role_registry();
|
|
28650
28190
|
init_role_activation_flags();
|
|
@@ -28652,11 +28192,11 @@ init_submission_correctable_error();
|
|
|
28652
28192
|
init_navigator_invocation_identity();
|
|
28653
28193
|
init_serialize_thrown_value();
|
|
28654
28194
|
async function listen(server, path) {
|
|
28655
|
-
await new Promise((
|
|
28195
|
+
await new Promise((resolve21, reject) => {
|
|
28656
28196
|
server.once("error", reject);
|
|
28657
28197
|
server.listen(path, () => {
|
|
28658
28198
|
server.off("error", reject);
|
|
28659
|
-
|
|
28199
|
+
resolve21();
|
|
28660
28200
|
});
|
|
28661
28201
|
});
|
|
28662
28202
|
}
|
|
@@ -28691,8 +28231,8 @@ async function prepareRoleEnvelope(options) {
|
|
|
28691
28231
|
const hostAbort = new AbortController();
|
|
28692
28232
|
const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID9();
|
|
28693
28233
|
await mkdir5(request.runDirectory, { recursive: true });
|
|
28694
|
-
let sessionFile = options.sessionFile ??
|
|
28695
|
-
await mkdir5(
|
|
28234
|
+
let sessionFile = options.sessionFile ?? join45(request.runDirectory, "session", "session.jsonl");
|
|
28235
|
+
await mkdir5(dirname22(sessionFile), { recursive: true });
|
|
28696
28236
|
if (request.continuation.kind !== "resume") {
|
|
28697
28237
|
try {
|
|
28698
28238
|
await writeFile11(
|
|
@@ -28742,7 +28282,7 @@ async function prepareRoleEnvelope(options) {
|
|
|
28742
28282
|
getLeafEntry: () => sessionEntries.at(-1),
|
|
28743
28283
|
getLeafId: () => runId,
|
|
28744
28284
|
getEntries: () => sessionEntries,
|
|
28745
|
-
getSessionDir: () =>
|
|
28285
|
+
getSessionDir: () => dirname22(sessionFile),
|
|
28746
28286
|
getSessionFile: () => sessionFile,
|
|
28747
28287
|
getHeader: () => ({ type: "session", id: runId }),
|
|
28748
28288
|
setSessionFile(path) {
|
|
@@ -28778,12 +28318,6 @@ async function prepareRoleEnvelope(options) {
|
|
|
28778
28318
|
const host = {
|
|
28779
28319
|
deliverSubmissionRejection(_value) {
|
|
28780
28320
|
},
|
|
28781
|
-
capabilities: {
|
|
28782
|
-
// #922: native loaders own expansion; package does not pre-read bodies (ADR 0032).
|
|
28783
|
-
skillExpansion() {
|
|
28784
|
-
return void 0;
|
|
28785
|
-
}
|
|
28786
|
-
},
|
|
28787
28321
|
registerFlag(name, definition) {
|
|
28788
28322
|
if (!flags.has(name) && definition.default !== void 0) flags.set(name, definition.default);
|
|
28789
28323
|
},
|
|
@@ -29106,8 +28640,8 @@ async function prepareRoleEnvelope(options) {
|
|
|
29106
28640
|
try {
|
|
29107
28641
|
const closeAll = server.closeAllConnections;
|
|
29108
28642
|
if (typeof closeAll === "function") closeAll.call(server);
|
|
29109
|
-
await new Promise((
|
|
29110
|
-
server.close((error) => error ? reject(error) :
|
|
28643
|
+
await new Promise((resolve21, reject) => {
|
|
28644
|
+
server.close((error) => error ? reject(error) : resolve21());
|
|
29111
28645
|
});
|
|
29112
28646
|
} catch (error) {
|
|
29113
28647
|
cleanupFailures.push(error);
|
|
@@ -29202,13 +28736,6 @@ async function prepareRoleEnvelope(options) {
|
|
|
29202
28736
|
throw new Error(`terminating tool not registered after activation: ${terminatingToolName}`);
|
|
29203
28737
|
}
|
|
29204
28738
|
const jsonSchema = terminatingToolJsonSchema(terminating.parameters);
|
|
29205
|
-
if (request.host === "codex" && hostMethodSkills(request.methods).length > 0) {
|
|
29206
|
-
const packageRoot = options.dependencies.packageRoot;
|
|
29207
|
-
if (typeof packageRoot !== "string" || packageRoot === "") {
|
|
29208
|
-
throw new Error("codex project Skill catalog requires packageRoot");
|
|
29209
|
-
}
|
|
29210
|
-
await installWorkspaceMethodSkills(request.cwd, packageRoot);
|
|
29211
|
-
}
|
|
29212
28739
|
return {
|
|
29213
28740
|
mcpServers: [{
|
|
29214
28741
|
name: `ak-${request.activation.role}`,
|
|
@@ -29246,7 +28773,7 @@ async function prepareRoleEnvelope(options) {
|
|
|
29246
28773
|
init_session_identity();
|
|
29247
28774
|
|
|
29248
28775
|
// src/headless-host/description.ts
|
|
29249
|
-
import { join as
|
|
28776
|
+
import { join as join46 } from "node:path";
|
|
29250
28777
|
function isClaudePrintDescription(description) {
|
|
29251
28778
|
return description.protocol === "claude-print";
|
|
29252
28779
|
}
|
|
@@ -29254,7 +28781,7 @@ function isCodexExecDescription(description) {
|
|
|
29254
28781
|
return description.protocol === "codex-exec";
|
|
29255
28782
|
}
|
|
29256
28783
|
function resolveHeadlessBinary(description, operatorHome) {
|
|
29257
|
-
return
|
|
28784
|
+
return join46(operatorHome, ...description.binaryFromHome);
|
|
29258
28785
|
}
|
|
29259
28786
|
function headlessTurnArgs(options) {
|
|
29260
28787
|
const { description } = options;
|
|
@@ -29267,7 +28794,6 @@ function headlessTurnArgs(options) {
|
|
|
29267
28794
|
if (options.jsonSchema !== void 0) {
|
|
29268
28795
|
args.push(description.jsonSchemaFlag, JSON.stringify(options.jsonSchema));
|
|
29269
28796
|
}
|
|
29270
|
-
if (options.pluginDir) args.push("--plugin-dir", options.pluginDir);
|
|
29271
28797
|
if (options.mcpConfigPath !== void 0 && options.mcpConfigPath !== "") {
|
|
29272
28798
|
args.push(description.mcpConfigFlag, options.mcpConfigPath);
|
|
29273
28799
|
}
|
|
@@ -29515,11 +29041,11 @@ function headlessMcpConfigDocument(mcpServers) {
|
|
|
29515
29041
|
}
|
|
29516
29042
|
|
|
29517
29043
|
// src/headless-host/role-turn-host.ts
|
|
29518
|
-
import { spawn as spawn4, spawnSync } from "node:child_process";
|
|
29044
|
+
import { spawn as spawn4, spawnSync as spawnSync2 } from "node:child_process";
|
|
29519
29045
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
29520
29046
|
import { existsSync as existsSync13 } from "node:fs";
|
|
29521
29047
|
import { writeFile as writeFile12 } from "node:fs/promises";
|
|
29522
|
-
import { dirname as
|
|
29048
|
+
import { dirname as dirname23, isAbsolute as isAbsolute12, join as join47, resolve as resolve20 } from "node:path";
|
|
29523
29049
|
|
|
29524
29050
|
// src/external-host-turn-loop.ts
|
|
29525
29051
|
init_packaged_role_registry();
|
|
@@ -29739,8 +29265,8 @@ function formatCodexFailurePayload(payload) {
|
|
|
29739
29265
|
function cwdIsGitWorkTree(cwd) {
|
|
29740
29266
|
let dir = cwd;
|
|
29741
29267
|
for (; ; ) {
|
|
29742
|
-
if (existsSync13(
|
|
29743
|
-
const parent =
|
|
29268
|
+
if (existsSync13(join47(dir, ".git"))) return true;
|
|
29269
|
+
const parent = dirname23(dir);
|
|
29744
29270
|
if (parent === dir) return false;
|
|
29745
29271
|
dir = parent;
|
|
29746
29272
|
}
|
|
@@ -29749,7 +29275,7 @@ function resolveGitCommonDir(cwd) {
|
|
|
29749
29275
|
if (!cwdIsGitWorkTree(cwd)) return void 0;
|
|
29750
29276
|
let result;
|
|
29751
29277
|
try {
|
|
29752
|
-
result =
|
|
29278
|
+
result = spawnSync2("git", ["rev-parse", "--git-common-dir"], {
|
|
29753
29279
|
cwd,
|
|
29754
29280
|
encoding: "utf8"
|
|
29755
29281
|
});
|
|
@@ -29768,10 +29294,10 @@ function resolveGitCommonDir(cwd) {
|
|
|
29768
29294
|
if (raw === "") {
|
|
29769
29295
|
throw new Error("git rev-parse --git-common-dir returned empty stdout");
|
|
29770
29296
|
}
|
|
29771
|
-
return isAbsolute12(raw) ? raw :
|
|
29297
|
+
return isAbsolute12(raw) ? raw : resolve20(cwd, raw);
|
|
29772
29298
|
}
|
|
29773
29299
|
function spawnHeadlessTurn(options) {
|
|
29774
|
-
return new Promise((
|
|
29300
|
+
return new Promise((resolve21, reject) => {
|
|
29775
29301
|
if (options.signal?.aborted) {
|
|
29776
29302
|
reject(hostAbortedError("headless host aborted"));
|
|
29777
29303
|
return;
|
|
@@ -29846,7 +29372,7 @@ function spawnHeadlessTurn(options) {
|
|
|
29846
29372
|
reject(stdinDeliveryError);
|
|
29847
29373
|
return;
|
|
29848
29374
|
}
|
|
29849
|
-
|
|
29375
|
+
resolve21({ code, stdout: resultStdout, stderr, timedOut });
|
|
29850
29376
|
};
|
|
29851
29377
|
const onAbort = () => {
|
|
29852
29378
|
child.kill("SIGTERM");
|
|
@@ -29929,8 +29455,7 @@ function buildTurnArgs(options) {
|
|
|
29929
29455
|
mcpConfigPath: options.mcpConfigPath,
|
|
29930
29456
|
...options.model === void 0 ? {} : { model: options.model },
|
|
29931
29457
|
...options.effort === void 0 ? {} : { effort: options.effort },
|
|
29932
|
-
session: { kind: options.sessionKind, id: options.sessionId }
|
|
29933
|
-
...options.pluginDir === void 0 ? {} : { pluginDir: options.pluginDir }
|
|
29458
|
+
session: { kind: options.sessionKind, id: options.sessionId }
|
|
29934
29459
|
});
|
|
29935
29460
|
}
|
|
29936
29461
|
function createHeadlessRoleTurnHost(config) {
|
|
@@ -29948,15 +29473,13 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
29948
29473
|
await config.sessionIdentity.bind(request.principal, sessionId);
|
|
29949
29474
|
}
|
|
29950
29475
|
const env = { ...process.env, ...config.env ?? {} };
|
|
29951
|
-
const systemPromptPath =
|
|
29476
|
+
const systemPromptPath = join47(request.runDirectory, "headless-system-prompt.txt");
|
|
29952
29477
|
await writeFile12(systemPromptPath, systemPrompt, "utf8");
|
|
29953
29478
|
let mcpConfigPath;
|
|
29954
29479
|
let outputSchemaPath;
|
|
29955
|
-
let pluginDir;
|
|
29956
|
-
let applyMethodPrompt = codex ? (prompt) => applyCodexSkillInvocation(request.methods, prompt) : (prompt) => prompt;
|
|
29957
29480
|
if (codex) {
|
|
29958
29481
|
if (prepared.terminatingToolName !== NAVIGATOR_OUTPUT_TOOL_NAME) {
|
|
29959
|
-
outputSchemaPath =
|
|
29482
|
+
outputSchemaPath = join47(request.runDirectory, "headless-output-schema.json");
|
|
29960
29483
|
await writeFile12(
|
|
29961
29484
|
outputSchemaPath,
|
|
29962
29485
|
`${JSON.stringify(closeJsonSchemaForCodex(prepared.jsonSchema), null, 2)}
|
|
@@ -29965,21 +29488,13 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
29965
29488
|
);
|
|
29966
29489
|
}
|
|
29967
29490
|
} else {
|
|
29968
|
-
mcpConfigPath =
|
|
29491
|
+
mcpConfigPath = join47(request.runDirectory, "headless-mcp-config.json");
|
|
29969
29492
|
await writeFile12(
|
|
29970
29493
|
mcpConfigPath,
|
|
29971
29494
|
`${JSON.stringify(headlessMcpConfigDocument(prepared.mcpServers), null, 2)}
|
|
29972
29495
|
`,
|
|
29973
29496
|
"utf8"
|
|
29974
29497
|
);
|
|
29975
|
-
if (hostMethodSkills(request.methods).length > 0) {
|
|
29976
|
-
const packageRoot = env.AK_PACKAGE_ROOT ?? process.env.AK_PACKAGE_ROOT;
|
|
29977
|
-
if (typeof packageRoot !== "string" || packageRoot === "") {
|
|
29978
|
-
throw new Error("claude method plugin-dir requires AK_PACKAGE_ROOT");
|
|
29979
|
-
}
|
|
29980
|
-
pluginDir = packagedMethodPluginDir(packageRoot);
|
|
29981
|
-
applyMethodPrompt = (prompt) => applyClaudeSkillInvocation(request.methods, prompt);
|
|
29982
|
-
}
|
|
29983
29498
|
}
|
|
29984
29499
|
const sessionParent = config.sessionIdentity.resolveSessionFile(request.principal);
|
|
29985
29500
|
outcome = await driveExternalRoleTurnRounds(prepared, request, {
|
|
@@ -30005,8 +29520,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
30005
29520
|
sessionId,
|
|
30006
29521
|
sessionKind,
|
|
30007
29522
|
cwd: request.cwd,
|
|
30008
|
-
...gitCommonDir === void 0 ? {} : { writableRoots: [gitCommonDir] }
|
|
30009
|
-
...pluginDir === void 0 ? {} : { pluginDir }
|
|
29523
|
+
...gitCommonDir === void 0 ? {} : { writableRoots: [gitCommonDir] }
|
|
30010
29524
|
});
|
|
30011
29525
|
} catch (error) {
|
|
30012
29526
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -30023,7 +29537,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
30023
29537
|
args,
|
|
30024
29538
|
cwd: request.cwd,
|
|
30025
29539
|
env,
|
|
30026
|
-
stdin:
|
|
29540
|
+
stdin: prompt,
|
|
30027
29541
|
...abortSignal === void 0 ? {} : { signal: abortSignal },
|
|
30028
29542
|
...request.timeoutMs === void 0 ? {} : { timeoutMs: request.timeoutMs },
|
|
30029
29543
|
onStdoutLine(line2) {
|