@akagilnc/pi-workflow-roles 0.1.5037 → 0.1.5066
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 +11 -23
- package/dist/acp-host/production-host.js +410 -878
- package/dist/headless-host/description.js +0 -2
- package/dist/headless-host/production-host.js +413 -914
- package/dist/host-descriptions.js +2 -3
- package/dist/migrate-book-topology.js +4 -10
- package/dist/packaged-role-registry.js +17 -16
- package/dist/pi/role-turn-host.js +3 -27
- package/dist/public-cli/cli.js +6 -0
- package/dist/public-cli/instruction-seat-run.js +12 -40
- package/dist/public-cli/machine-method-skills.js +150 -0
- package/dist/public-cli/main.js +378 -579
- package/dist/public-cli/post-admission.js +2 -0
- package/dist/public-cli/registry.js +2 -1
- package/dist/public-cli/settlement.js +12 -99
- package/dist/public-cli/turn-request.js +16 -8
- package/package.json +3 -1
- package/resources/836-deleted-machine-instruction-inventory.md +1 -1
- 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 +14 -14
- package/src/pi/adapter.ts +0 -27
- package/src/pi/role-turn-host.ts +3 -31
- package/src/public-cli/cli.ts +6 -0
- package/src/public-cli/instruction-seat-run.ts +9 -42
- package/src/public-cli/machine-method-skills.ts +153 -0
- package/src/public-cli/post-admission.ts +2 -0
- package/src/public-cli/registry.ts +1 -0
- package/src/public-cli/settlement.ts +6 -138
- package/src/public-cli/turn-request.ts +24 -16
- 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" }
|
|
@@ -4564,10 +4565,10 @@ __export(session_assistant_usage_exports, {
|
|
|
4564
4565
|
});
|
|
4565
4566
|
import { join as join6 } from "node:path";
|
|
4566
4567
|
async function readAssistantUsageFromSessionFile(sessionFile) {
|
|
4567
|
-
const { readFile:
|
|
4568
|
+
const { readFile: readFile25 } = await import("node:fs/promises");
|
|
4568
4569
|
let text;
|
|
4569
4570
|
try {
|
|
4570
|
-
text = await
|
|
4571
|
+
text = await readFile25(sessionFile, "utf8");
|
|
4571
4572
|
} catch (error) {
|
|
4572
4573
|
if (error?.code === "ENOENT") return void 0;
|
|
4573
4574
|
throw error;
|
|
@@ -4966,7 +4967,7 @@ async function spawnEngineDetourOnce(input) {
|
|
|
4966
4967
|
}
|
|
4967
4968
|
const command = input.argv[0];
|
|
4968
4969
|
const args = input.argv.slice(1);
|
|
4969
|
-
return await new Promise((
|
|
4970
|
+
return await new Promise((resolve21, reject) => {
|
|
4970
4971
|
let settled = false;
|
|
4971
4972
|
const signal = input.signal;
|
|
4972
4973
|
const child = spawn2(command, args, {
|
|
@@ -4996,7 +4997,7 @@ async function spawnEngineDetourOnce(input) {
|
|
|
4996
4997
|
if (signal !== void 0) {
|
|
4997
4998
|
signal.removeEventListener("abort", onAbort);
|
|
4998
4999
|
}
|
|
4999
|
-
|
|
5000
|
+
resolve21(result);
|
|
5000
5001
|
};
|
|
5001
5002
|
const onAbort = () => {
|
|
5002
5003
|
fail4(signal !== void 0 ? abortReasonError(signal) : new Error("aborted"));
|
|
@@ -5490,7 +5491,6 @@ var role_turn_host_exports = {};
|
|
|
5490
5491
|
__export(role_turn_host_exports, {
|
|
5491
5492
|
EXPLICIT_INTERNAL_LOAD_PROBE_ARGS: () => EXPLICIT_INTERNAL_LOAD_PROBE_ARGS,
|
|
5492
5493
|
appendPiSessionCustomEntry: () => appendPiSessionCustomEntry,
|
|
5493
|
-
applyPiNativeSkillInvocation: () => applyPiNativeSkillInvocation,
|
|
5494
5494
|
buildExplicitInternalActivationArgs: () => buildExplicitInternalActivationArgs,
|
|
5495
5495
|
buildPiTurnExtraArgs: () => buildPiTurnExtraArgs,
|
|
5496
5496
|
createDefaultPiSpawnRunner: () => createDefaultPiSpawnRunner,
|
|
@@ -5500,7 +5500,7 @@ __export(role_turn_host_exports, {
|
|
|
5500
5500
|
import { execFile, spawn as spawn3 } from "node:child_process";
|
|
5501
5501
|
import { constants } from "node:fs";
|
|
5502
5502
|
import { access, appendFile, readFile as readFile5, realpath } from "node:fs/promises";
|
|
5503
|
-
import {
|
|
5503
|
+
import { delimiter, dirname as dirname6, isAbsolute as isAbsolute3, join as join11, resolve as resolve4 } from "node:path";
|
|
5504
5504
|
import { platform } from "node:process";
|
|
5505
5505
|
import { promisify } from "node:util";
|
|
5506
5506
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
@@ -5533,24 +5533,11 @@ function buildMethodArgs(methods) {
|
|
|
5533
5533
|
const skillArgs = [];
|
|
5534
5534
|
for (const method of methods) {
|
|
5535
5535
|
if (method.kind === "skill") {
|
|
5536
|
-
skillArgs.push("--skill", method.path);
|
|
5536
|
+
skillArgs.push("--skill", dirname6(method.path));
|
|
5537
5537
|
}
|
|
5538
5538
|
}
|
|
5539
5539
|
return skillArgs;
|
|
5540
5540
|
}
|
|
5541
|
-
function applyPiNativeSkillInvocation(methods, prompt) {
|
|
5542
|
-
const skills = methods.filter((method) => method.kind === "skill");
|
|
5543
|
-
if (skills.length !== 1) return prompt;
|
|
5544
|
-
const name = basename4(dirname6(skills[0].path));
|
|
5545
|
-
if (name.length === 0) return prompt;
|
|
5546
|
-
const token = `/skill:${name}`;
|
|
5547
|
-
const trimmed = prompt.trimStart();
|
|
5548
|
-
if (trimmed === token || trimmed.startsWith(`${token} `) || trimmed.startsWith(`${token}
|
|
5549
|
-
`)) {
|
|
5550
|
-
return prompt;
|
|
5551
|
-
}
|
|
5552
|
-
return prompt.length === 0 ? token : `${token} ${prompt}`;
|
|
5553
|
-
}
|
|
5554
5541
|
function buildPiTurnExtraArgs(request, authority, extraPiArgs = []) {
|
|
5555
5542
|
const { sessionFile, sessionDirectory } = authority.decode(request.principal);
|
|
5556
5543
|
return [
|
|
@@ -5582,7 +5569,7 @@ function piUserDialogueBody(request) {
|
|
|
5582
5569
|
const _exhaustive = request.continuation;
|
|
5583
5570
|
return _exhaustive;
|
|
5584
5571
|
})();
|
|
5585
|
-
return
|
|
5572
|
+
return rawPrompt;
|
|
5586
5573
|
}
|
|
5587
5574
|
async function resolveSelectedPi(command, cwd, env) {
|
|
5588
5575
|
const searchPath = env.PATH ?? (platform === "win32" ? process.env.PATH ?? "" : "/usr/bin:/bin");
|
|
@@ -6864,7 +6851,7 @@ var init_session_dialogue = __esm({
|
|
|
6864
6851
|
// src/ticket-provenance.ts
|
|
6865
6852
|
import { createHash as createHash6 } from "node:crypto";
|
|
6866
6853
|
import { readFile as readFile9, unlink } from "node:fs/promises";
|
|
6867
|
-
import { basename as
|
|
6854
|
+
import { basename as basename4, dirname as dirname8, join as join13, resolve as resolve7 } from "node:path";
|
|
6868
6855
|
function dialogueSessionSourceRoots(home) {
|
|
6869
6856
|
const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
|
|
6870
6857
|
return [
|
|
@@ -6877,7 +6864,7 @@ function isLedgerRoleSessionFile(absolute, home) {
|
|
|
6877
6864
|
const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
|
|
6878
6865
|
const ledgerHome = resolveActivationLedgerHome(machineHome);
|
|
6879
6866
|
if (!physicallyContainedIn(ledgerHome, absolute)) return false;
|
|
6880
|
-
return
|
|
6867
|
+
return basename4(absolute) === "session.jsonl" && basename4(dirname8(absolute)) === "session";
|
|
6881
6868
|
}
|
|
6882
6869
|
function assertDialogueSessionSourcePath(path, home) {
|
|
6883
6870
|
const absolute = resolve7(path);
|
|
@@ -7570,7 +7557,7 @@ __export(run_lifecycle_exports, {
|
|
|
7570
7557
|
writeRoleRunState: () => writeRoleRunState
|
|
7571
7558
|
});
|
|
7572
7559
|
import { chmod, lstat as lstat2, open, readdir as readdir4, readFile as readFile11, unlink as unlink3, writeFile as writeFile3 } from "node:fs/promises";
|
|
7573
|
-
import { basename as
|
|
7560
|
+
import { basename as basename5, join as join15 } from "node:path";
|
|
7574
7561
|
function buildAutoResumeContinuationPrompt(options) {
|
|
7575
7562
|
return appendEngineSessionMaterial(
|
|
7576
7563
|
[RESUME_TRANSPORT_ENVELOPE],
|
|
@@ -8083,7 +8070,7 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
|
8083
8070
|
throw error;
|
|
8084
8071
|
}
|
|
8085
8072
|
for (const runDirectory of runDirectories) {
|
|
8086
|
-
const entry =
|
|
8073
|
+
const entry = basename5(runDirectory);
|
|
8087
8074
|
if (onlyRole === void 0 && (entry === `${runId}@judge` || entry.startsWith(`${runId}@`)) || entry === `${runId}@${onlyRole}`) {
|
|
8088
8075
|
matches.push(runDirectory);
|
|
8089
8076
|
}
|
|
@@ -8152,12 +8139,12 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
8152
8139
|
const suffix = `@${input.role}`;
|
|
8153
8140
|
let best;
|
|
8154
8141
|
for (const runDirectory of runDirectories) {
|
|
8155
|
-
const entry =
|
|
8142
|
+
const entry = basename5(runDirectory);
|
|
8156
8143
|
if (!entry.endsWith(suffix)) continue;
|
|
8157
8144
|
const runId = entry.slice(0, entry.length - suffix.length);
|
|
8158
8145
|
if (runId.length === 0) continue;
|
|
8159
8146
|
const parentPath = await readRunParentPath(runDirectory);
|
|
8160
|
-
if (parentPath !== input.parentRunPath &&
|
|
8147
|
+
if (parentPath !== input.parentRunPath && basename5(parentPath ?? "") !== basename5(input.parentRunPath)) continue;
|
|
8161
8148
|
if (!await runHasFormedSessionPrincipal(runDirectory)) continue;
|
|
8162
8149
|
if (best === void 0 || runId > best) best = runId;
|
|
8163
8150
|
}
|
|
@@ -8432,7 +8419,7 @@ async function loadResumableRunRecord(home, runId, authority, allowUnformedAdmit
|
|
|
8432
8419
|
} else if (mergedSet.tickets !== void 0) {
|
|
8433
8420
|
courtTicketNumbers = mergedSet.tickets;
|
|
8434
8421
|
}
|
|
8435
|
-
const sourceRunLeaf =
|
|
8422
|
+
const sourceRunLeaf = basename5(sourceRunPath ?? "").split("@");
|
|
8436
8423
|
const referencedRunId = sourceRun?.runId ?? sourceRunLeaf[0];
|
|
8437
8424
|
const referencedRole = sourceRun?.role ?? sourceRunLeaf[1];
|
|
8438
8425
|
if (referencedRunId !== void 0 && referencedRunId !== "") {
|
|
@@ -8777,7 +8764,7 @@ var init_run_lifecycle = __esm({
|
|
|
8777
8764
|
});
|
|
8778
8765
|
|
|
8779
8766
|
// src/notary-source-run.ts
|
|
8780
|
-
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";
|
|
8781
8768
|
import { lstat as lstat3, realpath as realpath3 } from "node:fs/promises";
|
|
8782
8769
|
async function readRetainedIdentity(runDirectory) {
|
|
8783
8770
|
try {
|
|
@@ -8818,10 +8805,10 @@ async function requireRunDirectory(candidate, display) {
|
|
|
8818
8805
|
`notary --source-run must be a run directory: ${display}`
|
|
8819
8806
|
);
|
|
8820
8807
|
}
|
|
8821
|
-
const identity = parseRunDirectoryName(
|
|
8808
|
+
const identity = parseRunDirectoryName(basename6(real));
|
|
8822
8809
|
if (identity === void 0) {
|
|
8823
8810
|
throw new NotarySourceRunError(
|
|
8824
|
-
`notary --source-run must be named <runId>@<role>: ${
|
|
8811
|
+
`notary --source-run must be named <runId>@<role>: ${basename6(real)}`
|
|
8825
8812
|
);
|
|
8826
8813
|
}
|
|
8827
8814
|
return real;
|
|
@@ -8841,9 +8828,9 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
8841
8828
|
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join16(bookRunsRoot, `${bare.runId}@${bare.role}`);
|
|
8842
8829
|
} else {
|
|
8843
8830
|
candidate = isAbsolute6(raw) ? raw : resolve8(options.projectRoot, raw);
|
|
8844
|
-
const identity2 = parseRunDirectoryName(
|
|
8831
|
+
const identity2 = parseRunDirectoryName(basename6(candidate));
|
|
8845
8832
|
const subjectDirectory = dirname9(dirname9(candidate));
|
|
8846
|
-
const isLegacyUnboundLocator = identity2 !== void 0 &&
|
|
8833
|
+
const isLegacyUnboundLocator = identity2 !== void 0 && basename6(dirname9(candidate)) === "runs" && basename6(subjectDirectory) === "unbound" && resolve8(dirname9(subjectDirectory)) === resolve8(bookDirectory);
|
|
8847
8834
|
if (isLegacyUnboundLocator) {
|
|
8848
8835
|
candidate = await findRunDirectoryById(
|
|
8849
8836
|
options.home,
|
|
@@ -8854,11 +8841,11 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
8854
8841
|
}
|
|
8855
8842
|
}
|
|
8856
8843
|
const real = await requireRunDirectory(candidate, raw);
|
|
8857
|
-
const identity = parseRunDirectoryName(
|
|
8844
|
+
const identity = parseRunDirectoryName(basename6(real));
|
|
8858
8845
|
const bookIdentity = physicalPathIdentity(bookDirectory);
|
|
8859
8846
|
const parentIdentity = physicalPathIdentity(dirname9(real));
|
|
8860
8847
|
const subjectBookIdentity = physicalPathIdentity(dirname9(dirname9(dirname9(real))));
|
|
8861
|
-
if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(
|
|
8848
|
+
if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename6(dirname9(real)) === "runs" && subjectBookIdentity === bookIdentity)) {
|
|
8862
8849
|
throw new NotarySourceRunError(
|
|
8863
8850
|
"notary --source-run must resolve to a retained run under the project machine-ledger book"
|
|
8864
8851
|
);
|
|
@@ -8892,7 +8879,7 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
8892
8879
|
}
|
|
8893
8880
|
async function loadNotarySourceRunLocator(path) {
|
|
8894
8881
|
const real = await requireRunDirectory(path, path);
|
|
8895
|
-
const identity = parseRunDirectoryName(
|
|
8882
|
+
const identity = parseRunDirectoryName(basename6(real));
|
|
8896
8883
|
const runState = await readRetainedIdentity(real);
|
|
8897
8884
|
if (runState === void 0) {
|
|
8898
8885
|
throw new NotarySourceRunError(
|
|
@@ -8999,7 +8986,8 @@ var init_registry = __esm({
|
|
|
8999
8986
|
"config",
|
|
9000
8987
|
"help",
|
|
9001
8988
|
"resume",
|
|
9002
|
-
"new"
|
|
8989
|
+
"new",
|
|
8990
|
+
"setup"
|
|
9003
8991
|
];
|
|
9004
8992
|
PUBLIC_DETERMINISTIC_COMMANDS = ["analyst"];
|
|
9005
8993
|
}
|
|
@@ -10067,7 +10055,7 @@ import {
|
|
|
10067
10055
|
writeFile as writeFile4
|
|
10068
10056
|
} from "node:fs/promises";
|
|
10069
10057
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
10070
|
-
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";
|
|
10071
10059
|
function issueAdmissionPlacement(authority, request) {
|
|
10072
10060
|
const ledgerHome = resolveActivationLedgerHome(request.home);
|
|
10073
10061
|
const bookKey = resolveBookKeyFromGit(request.cwd);
|
|
@@ -10682,7 +10670,7 @@ async function withPreparedAttachments(attachmentPaths, use) {
|
|
|
10682
10670
|
async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, index) {
|
|
10683
10671
|
const frozenPath = join17(
|
|
10684
10672
|
destinationDir,
|
|
10685
|
-
`${String(index).padStart(2, "0")}-${
|
|
10673
|
+
`${String(index).padStart(2, "0")}-${basename7(provenancePath)}`
|
|
10686
10674
|
);
|
|
10687
10675
|
await writeFile4(frozenPath, bytes);
|
|
10688
10676
|
return {
|
|
@@ -12856,10 +12844,10 @@ function pairGateRounds(volumes) {
|
|
|
12856
12844
|
return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
|
|
12857
12845
|
}
|
|
12858
12846
|
async function resolveOfficerSessionFromPointerFile(pointerPath) {
|
|
12859
|
-
const { readFile:
|
|
12847
|
+
const { readFile: readFile25 } = await import("node:fs/promises");
|
|
12860
12848
|
let raw;
|
|
12861
12849
|
try {
|
|
12862
|
-
raw = JSON.parse(await
|
|
12850
|
+
raw = JSON.parse(await readFile25(pointerPath, "utf8"));
|
|
12863
12851
|
} catch (error) {
|
|
12864
12852
|
throw new Error(
|
|
12865
12853
|
`direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -13958,243 +13946,6 @@ var init_dossier_resolution = __esm({
|
|
|
13958
13946
|
}
|
|
13959
13947
|
});
|
|
13960
13948
|
|
|
13961
|
-
// src/package-resources/method-skill.ts
|
|
13962
|
-
import { createHash as createHash7 } from "node:crypto";
|
|
13963
|
-
import { readFile as readFile15, realpath as realpath5 } from "node:fs/promises";
|
|
13964
|
-
import { join as join26 } from "node:path";
|
|
13965
|
-
function gitBlobOid(bytes) {
|
|
13966
|
-
const body = typeof bytes === "string" ? Buffer.from(bytes, "utf8") : Buffer.from(bytes);
|
|
13967
|
-
const header = Buffer.from(`blob ${body.byteLength}\0`, "utf8");
|
|
13968
|
-
return createHash7("sha1").update(header).update(body).digest("hex");
|
|
13969
|
-
}
|
|
13970
|
-
function stripSkillFrontmatter(content) {
|
|
13971
|
-
if (!content.startsWith("---")) return content;
|
|
13972
|
-
const end = content.indexOf("\n---", 3);
|
|
13973
|
-
if (end === -1) return content;
|
|
13974
|
-
const after = content.slice(end + "\n---".length);
|
|
13975
|
-
return after.replace(/^\r?\n/, "");
|
|
13976
|
-
}
|
|
13977
|
-
function packagedMethodSkillRelativeDirectory(name) {
|
|
13978
|
-
return `${METHOD_SKILL_RELATIVE_ROOT}/${name}`;
|
|
13979
|
-
}
|
|
13980
|
-
function resolvePackagedMethodSkillRoot(packageRoot, name) {
|
|
13981
|
-
return join26(packageRoot, packagedMethodSkillRelativeDirectory(name));
|
|
13982
|
-
}
|
|
13983
|
-
function resolvePackagedMethodSkillPath(packageRoot, name) {
|
|
13984
|
-
return join26(resolvePackagedMethodSkillRoot(packageRoot, name), "SKILL.md");
|
|
13985
|
-
}
|
|
13986
|
-
function isRecord11(value) {
|
|
13987
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13988
|
-
}
|
|
13989
|
-
function parseProvenance(raw, expectedName) {
|
|
13990
|
-
if (!isRecord11(raw)) {
|
|
13991
|
-
throw new Error(`Packaged method provenance must be an object for ${expectedName}`);
|
|
13992
|
-
}
|
|
13993
|
-
if (raw.name !== expectedName) {
|
|
13994
|
-
throw new Error(
|
|
13995
|
-
`Packaged method provenance name mismatch: expected ${expectedName}, got ${String(raw.name)}`
|
|
13996
|
-
);
|
|
13997
|
-
}
|
|
13998
|
-
if (raw.kind !== "role-method-skill") {
|
|
13999
|
-
throw new Error(`Packaged method provenance kind must be role-method-skill`);
|
|
14000
|
-
}
|
|
14001
|
-
if (typeof raw.packageAdaptation !== "string" || raw.packageAdaptation.trim() === "") {
|
|
14002
|
-
throw new Error(`Packaged method provenance packageAdaptation must be nonblank`);
|
|
14003
|
-
}
|
|
14004
|
-
if (!isRecord11(raw.upstream)) {
|
|
14005
|
-
throw new Error(`Packaged method provenance upstream must be an object`);
|
|
14006
|
-
}
|
|
14007
|
-
const upstream = raw.upstream;
|
|
14008
|
-
for (const key of [
|
|
14009
|
-
"repository",
|
|
14010
|
-
"path",
|
|
14011
|
-
"license",
|
|
14012
|
-
"copyright",
|
|
14013
|
-
"attribution"
|
|
14014
|
-
]) {
|
|
14015
|
-
if (typeof upstream[key] !== "string" || upstream[key].trim() === "") {
|
|
14016
|
-
throw new Error(`Packaged method provenance upstream.${key} must be nonblank`);
|
|
14017
|
-
}
|
|
14018
|
-
}
|
|
14019
|
-
if (typeof upstream.commit !== "string" || !GIT_COMMIT_RE.test(upstream.commit)) {
|
|
14020
|
-
throw new Error(
|
|
14021
|
-
`Packaged method provenance upstream.commit must be a 40-char lowercase git object id`
|
|
14022
|
-
);
|
|
14023
|
-
}
|
|
14024
|
-
const tag = typeof upstream.tag === "string" && upstream.tag.trim() !== "" ? upstream.tag.trim() : void 0;
|
|
14025
|
-
const version = typeof upstream.version === "string" && upstream.version.trim() !== "" ? upstream.version.trim() : void 0;
|
|
14026
|
-
if (tag === void 0 && version === void 0) {
|
|
14027
|
-
throw new Error(
|
|
14028
|
-
`Packaged method provenance upstream must include nonblank tag or version`
|
|
14029
|
-
);
|
|
14030
|
-
}
|
|
14031
|
-
if (!isRecord11(raw.files)) {
|
|
14032
|
-
throw new Error(`Packaged method provenance files must be an object`);
|
|
14033
|
-
}
|
|
14034
|
-
const files = {};
|
|
14035
|
-
for (const [rel, entry] of Object.entries(raw.files)) {
|
|
14036
|
-
if (!isRecord11(entry)) {
|
|
14037
|
-
throw new Error(`Packaged method provenance file entry must be an object: ${rel}`);
|
|
14038
|
-
}
|
|
14039
|
-
if (typeof entry.sha256 !== "string" || !SHA256_RE.test(entry.sha256)) {
|
|
14040
|
-
throw new Error(`Packaged method provenance file sha256 invalid: ${rel}`);
|
|
14041
|
-
}
|
|
14042
|
-
if (typeof entry.byteLength !== "number" || !Number.isInteger(entry.byteLength) || entry.byteLength < 0) {
|
|
14043
|
-
throw new Error(`Packaged method provenance file byteLength invalid: ${rel}`);
|
|
14044
|
-
}
|
|
14045
|
-
if (typeof entry.gitBlob !== "string" || !GIT_BLOB_RE.test(entry.gitBlob)) {
|
|
14046
|
-
throw new Error(
|
|
14047
|
-
`Packaged method provenance file gitBlob must be a 40-char lowercase git object id: ${rel}`
|
|
14048
|
-
);
|
|
14049
|
-
}
|
|
14050
|
-
files[rel] = {
|
|
14051
|
-
sha256: entry.sha256,
|
|
14052
|
-
byteLength: entry.byteLength,
|
|
14053
|
-
gitBlob: entry.gitBlob
|
|
14054
|
-
};
|
|
14055
|
-
}
|
|
14056
|
-
if (files["SKILL.md"] === void 0) {
|
|
14057
|
-
throw new Error(`Packaged method provenance must include SKILL.md`);
|
|
14058
|
-
}
|
|
14059
|
-
return Object.freeze({
|
|
14060
|
-
name: expectedName,
|
|
14061
|
-
kind: "role-method-skill",
|
|
14062
|
-
packageAdaptation: raw.packageAdaptation,
|
|
14063
|
-
upstream: Object.freeze({
|
|
14064
|
-
repository: upstream.repository,
|
|
14065
|
-
path: upstream.path,
|
|
14066
|
-
commit: upstream.commit,
|
|
14067
|
-
...tag === void 0 ? {} : { tag },
|
|
14068
|
-
...version === void 0 ? {} : { version },
|
|
14069
|
-
license: upstream.license,
|
|
14070
|
-
copyright: upstream.copyright,
|
|
14071
|
-
attribution: upstream.attribution
|
|
14072
|
-
}),
|
|
14073
|
-
files: Object.freeze(files)
|
|
14074
|
-
});
|
|
14075
|
-
}
|
|
14076
|
-
async function loadPackagedMethodSkillMaterial(packageRoot, name) {
|
|
14077
|
-
const rootDirectory = resolvePackagedMethodSkillRoot(packageRoot, name);
|
|
14078
|
-
const skillPathConfigured = join26(rootDirectory, "SKILL.md");
|
|
14079
|
-
const provenancePath = join26(rootDirectory, "provenance.json");
|
|
14080
|
-
let provenanceRaw;
|
|
14081
|
-
try {
|
|
14082
|
-
provenanceRaw = await readFile15(provenancePath, "utf8");
|
|
14083
|
-
} catch (error) {
|
|
14084
|
-
throw new PackagedMethodSkillUnavailableError(name, provenancePath, error);
|
|
14085
|
-
}
|
|
14086
|
-
let provenanceJson;
|
|
14087
|
-
try {
|
|
14088
|
-
provenanceJson = JSON.parse(provenanceRaw);
|
|
14089
|
-
} catch (error) {
|
|
14090
|
-
throw new Error(`Packaged method provenance is not valid JSON at ${provenancePath}`, {
|
|
14091
|
-
cause: error
|
|
14092
|
-
});
|
|
14093
|
-
}
|
|
14094
|
-
const provenance = parseProvenance(provenanceJson, name);
|
|
14095
|
-
for (const [rel, expected] of Object.entries(provenance.files)) {
|
|
14096
|
-
const absolute = join26(rootDirectory, rel);
|
|
14097
|
-
let bytes;
|
|
14098
|
-
try {
|
|
14099
|
-
bytes = await readFile15(absolute);
|
|
14100
|
-
} catch (error) {
|
|
14101
|
-
throw new PackagedMethodSkillUnavailableError(name, absolute, error);
|
|
14102
|
-
}
|
|
14103
|
-
const actualSha = sha256Hex(bytes);
|
|
14104
|
-
const actualBlob = gitBlobOid(bytes);
|
|
14105
|
-
if (actualSha !== expected.sha256 || bytes.byteLength !== expected.byteLength || actualBlob !== expected.gitBlob) {
|
|
14106
|
-
throw new Error(
|
|
14107
|
-
`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}`
|
|
14108
|
-
);
|
|
14109
|
-
}
|
|
14110
|
-
}
|
|
14111
|
-
let skillPath;
|
|
14112
|
-
let raw;
|
|
14113
|
-
try {
|
|
14114
|
-
skillPath = await realpath5(skillPathConfigured);
|
|
14115
|
-
raw = await readFile15(skillPath, "utf8");
|
|
14116
|
-
} catch (error) {
|
|
14117
|
-
throw new PackagedMethodSkillUnavailableError(name, skillPathConfigured, error);
|
|
14118
|
-
}
|
|
14119
|
-
const body = stripSkillFrontmatter(raw).trim();
|
|
14120
|
-
if (body.length === 0) {
|
|
14121
|
-
throw new Error(`Canonical ${name} Skill is empty at ${skillPath}`);
|
|
14122
|
-
}
|
|
14123
|
-
const companionRelativePaths = REQUIRED_COMPANIONS[name].filter(
|
|
14124
|
-
(rel) => provenance.files[rel] !== void 0
|
|
14125
|
-
);
|
|
14126
|
-
for (const rel of REQUIRED_COMPANIONS[name]) {
|
|
14127
|
-
if (provenance.files[rel] === void 0) {
|
|
14128
|
-
throw new Error(
|
|
14129
|
-
`Packaged method ${name} missing required companion in provenance: ${rel}`
|
|
14130
|
-
);
|
|
14131
|
-
}
|
|
14132
|
-
}
|
|
14133
|
-
return Object.freeze({
|
|
14134
|
-
name,
|
|
14135
|
-
rootDirectory,
|
|
14136
|
-
skillPath,
|
|
14137
|
-
raw,
|
|
14138
|
-
body,
|
|
14139
|
-
provenance,
|
|
14140
|
-
companionRelativePaths: Object.freeze([...companionRelativePaths])
|
|
14141
|
-
});
|
|
14142
|
-
}
|
|
14143
|
-
function observePackagedMethodSkillInvocation(text, expected) {
|
|
14144
|
-
if (!text.startsWith('<skill name="')) return void 0;
|
|
14145
|
-
const nameStart = '<skill name="'.length;
|
|
14146
|
-
const nameEnd = text.indexOf('"', nameStart);
|
|
14147
|
-
if (nameEnd <= nameStart) return void 0;
|
|
14148
|
-
const name = text.slice(nameStart, nameEnd);
|
|
14149
|
-
if (name !== expected.name) return void 0;
|
|
14150
|
-
const locationMarker = '" location="';
|
|
14151
|
-
if (!text.startsWith(locationMarker, nameEnd)) return void 0;
|
|
14152
|
-
const locationStart = nameEnd + locationMarker.length;
|
|
14153
|
-
const locationEnd = text.indexOf('"', locationStart);
|
|
14154
|
-
if (locationEnd <= locationStart) return void 0;
|
|
14155
|
-
const location = text.slice(locationStart, locationEnd);
|
|
14156
|
-
const openTail = ">\n";
|
|
14157
|
-
if (!text.startsWith(openTail, locationEnd + 1)) return void 0;
|
|
14158
|
-
const closeTag = "\n</skill>";
|
|
14159
|
-
const closeAt = text.indexOf(closeTag, locationEnd + 1 + openTail.length);
|
|
14160
|
-
if (closeAt === -1) return void 0;
|
|
14161
|
-
const afterClose = text.slice(closeAt + closeTag.length);
|
|
14162
|
-
if (afterClose.length > 0 && !afterClose.startsWith("\n")) return void 0;
|
|
14163
|
-
if (!expected.allowedLocations.includes(location)) return void 0;
|
|
14164
|
-
return Object.freeze({ name: expected.name, location });
|
|
14165
|
-
}
|
|
14166
|
-
var PackagedMethodSkillUnavailableError, METHOD_SKILL_RELATIVE_ROOT, GIT_COMMIT_RE, GIT_BLOB_RE, SHA256_RE, REQUIRED_COMPANIONS;
|
|
14167
|
-
var init_method_skill = __esm({
|
|
14168
|
-
"src/package-resources/method-skill.ts"() {
|
|
14169
|
-
"use strict";
|
|
14170
|
-
init_sha256();
|
|
14171
|
-
PackagedMethodSkillUnavailableError = class extends Error {
|
|
14172
|
-
constructor(skillName, path, cause) {
|
|
14173
|
-
super(`Canonical ${skillName} Skill is unavailable at ${path}`, { cause });
|
|
14174
|
-
this.skillName = skillName;
|
|
14175
|
-
this.name = "CanonicalSkillUnavailableError";
|
|
14176
|
-
}
|
|
14177
|
-
skillName;
|
|
14178
|
-
code = "canonical-skill-unavailable";
|
|
14179
|
-
};
|
|
14180
|
-
METHOD_SKILL_RELATIVE_ROOT = "resources/methods";
|
|
14181
|
-
GIT_COMMIT_RE = /^[0-9a-f]{40}$/;
|
|
14182
|
-
GIT_BLOB_RE = /^[0-9a-f]{40}$/;
|
|
14183
|
-
SHA256_RE = /^[0-9a-f]{64}$/;
|
|
14184
|
-
REQUIRED_COMPANIONS = {
|
|
14185
|
-
tdd: ["tests.md", "mocking.md", "agents/openai.yaml"],
|
|
14186
|
-
"diagnosing-bugs": ["agents/openai.yaml", "scripts/hitl-loop.template.sh"],
|
|
14187
|
-
"ak-cross-m-review": [
|
|
14188
|
-
"CONTEXT.md",
|
|
14189
|
-
"LICENSE",
|
|
14190
|
-
"prompts/cmr-completeness.md",
|
|
14191
|
-
"prompts/cmr-reviewer.md"
|
|
14192
|
-
],
|
|
14193
|
-
"resolving-merge-conflicts": ["agents/openai.yaml"]
|
|
14194
|
-
};
|
|
14195
|
-
}
|
|
14196
|
-
});
|
|
14197
|
-
|
|
14198
13949
|
// src/work-subject-identity.ts
|
|
14199
13950
|
import { resolve as resolve11 } from "node:path";
|
|
14200
13951
|
function issueRoot(value) {
|
|
@@ -14406,11 +14157,11 @@ var init_navigator_invocation_identity = __esm({
|
|
|
14406
14157
|
});
|
|
14407
14158
|
|
|
14408
14159
|
// src/receipt-delivery-policy.ts
|
|
14409
|
-
function
|
|
14160
|
+
function isRecord11(value) {
|
|
14410
14161
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
14411
14162
|
}
|
|
14412
14163
|
function parseNoReceiptLifecycleFacts(input) {
|
|
14413
|
-
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")) {
|
|
14414
14165
|
throw new TypeError("malformed no-receipt lifecycle facts");
|
|
14415
14166
|
}
|
|
14416
14167
|
return {
|
|
@@ -14518,7 +14269,6 @@ __export(settlement_exports, {
|
|
|
14518
14269
|
formatTerminalResult: () => formatTerminalResult,
|
|
14519
14270
|
inspectJudgeSession: () => inspectJudgeSession,
|
|
14520
14271
|
isLawfulTypedTerminalOutcome: () => isLawfulTypedTerminalOutcome,
|
|
14521
|
-
observedMethodSkillOptions: () => observedMethodSkillOptions,
|
|
14522
14272
|
presentControlledFailure: () => presentControlledFailure,
|
|
14523
14273
|
presentFailureTerminal: () => presentFailureTerminal,
|
|
14524
14274
|
presentStructuralRejection: () => presentStructuralRejection,
|
|
@@ -14545,15 +14295,15 @@ __export(settlement_exports, {
|
|
|
14545
14295
|
withSubmissions: () => withSubmissions
|
|
14546
14296
|
});
|
|
14547
14297
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
14548
|
-
import { appendFile as appendFile2, readFile as
|
|
14549
|
-
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";
|
|
14550
14300
|
function sealedLedgerHome(admitted) {
|
|
14551
14301
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
14552
14302
|
}
|
|
14553
14303
|
function ledgerReadScope(admitted, scope) {
|
|
14554
14304
|
return {
|
|
14555
14305
|
home: sealedLedgerHome(admitted),
|
|
14556
|
-
sessionParent:
|
|
14306
|
+
sessionParent: join26(admitted.runDirectory, "session", "session.jsonl"),
|
|
14557
14307
|
...scope?.courtAttemptId === void 0 || scope.courtAttemptId.length === 0 ? {} : { attemptId: scope.courtAttemptId }
|
|
14558
14308
|
};
|
|
14559
14309
|
}
|
|
@@ -14703,7 +14453,7 @@ function presentControlledFailure(failure2, io) {
|
|
|
14703
14453
|
}
|
|
14704
14454
|
async function inspectJudgeSession(sessionFile) {
|
|
14705
14455
|
try {
|
|
14706
|
-
await
|
|
14456
|
+
await readFile15(sessionFile, "utf8");
|
|
14707
14457
|
return { state: "present" };
|
|
14708
14458
|
} catch (error) {
|
|
14709
14459
|
if (isMissingPathError4(error)) return { state: "missing" };
|
|
@@ -14943,7 +14693,7 @@ function sessionReadFailure(error, fallbackMessage) {
|
|
|
14943
14693
|
return failed;
|
|
14944
14694
|
}
|
|
14945
14695
|
async function readBoundSessionEntries(sessionFile) {
|
|
14946
|
-
const text = await
|
|
14696
|
+
const text = await readFile15(sessionFile, "utf8");
|
|
14947
14697
|
const entries = [];
|
|
14948
14698
|
for (const line2 of text.trim().split("\n").filter(Boolean)) {
|
|
14949
14699
|
try {
|
|
@@ -15009,7 +14759,7 @@ async function readSitianRetainedAuditorProviderStop(sessionFile) {
|
|
|
15009
14759
|
const { records } = await readSitianRecords(recordFile);
|
|
15010
14760
|
for (let i = records.length - 1; i >= 0; i -= 1) {
|
|
15011
14761
|
const payload = records[i]?.payload;
|
|
15012
|
-
if (!
|
|
14762
|
+
if (!isRecord12(payload) || !isRecord12(payload.response)) continue;
|
|
15013
14763
|
if (typeof payload.type === "string") continue;
|
|
15014
14764
|
const stop = sessionProviderStopFromAssistant(payload.response);
|
|
15015
14765
|
if (stop !== void 0) return stop;
|
|
@@ -15039,7 +14789,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
15039
14789
|
}
|
|
15040
14790
|
const parentId = parentEntries.find((entry) => entry.type === "session")?.id;
|
|
15041
14791
|
if (parentId === void 0) return void 0;
|
|
15042
|
-
const childDirectories = [
|
|
14792
|
+
const childDirectories = [join26(dirname14(sessionFile), "auditor-roles")];
|
|
15043
14793
|
const valid = [];
|
|
15044
14794
|
let sawAnyDirectory = false;
|
|
15045
14795
|
for (const childDirectory of childDirectories) {
|
|
@@ -15054,12 +14804,12 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
15054
14804
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
15055
14805
|
let entries;
|
|
15056
14806
|
try {
|
|
15057
|
-
entries = await readBoundSessionEntries(
|
|
14807
|
+
entries = await readBoundSessionEntries(join26(childDirectory, file));
|
|
15058
14808
|
} catch (error) {
|
|
15059
14809
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
15060
14810
|
}
|
|
15061
14811
|
const header = entries.find((entry) => entry.type === "session");
|
|
15062
|
-
if (!
|
|
14812
|
+
if (!isRecord12(header)) continue;
|
|
15063
14813
|
const bindingIndexes = [];
|
|
15064
14814
|
for (let i = 0; i < entries.length; i += 1) {
|
|
15065
14815
|
const entry = entries[i];
|
|
@@ -15073,7 +14823,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
15073
14823
|
end: idx + 1 < bindingIndexes.length ? bindingIndexes[idx + 1] : entries.length
|
|
15074
14824
|
})) : [{ entry: void 0, start: 0, end: entries.length }];
|
|
15075
14825
|
for (const { entry: bindingEntry, start, end } of bindingPasses) {
|
|
15076
|
-
const bindingParent = bindingEntry !== void 0 &&
|
|
14826
|
+
const bindingParent = bindingEntry !== void 0 && isRecord12(bindingEntry.data) && isRecord12(bindingEntry.data.parent) ? bindingEntry.data.parent : void 0;
|
|
15077
14827
|
const attemptEntryId = typeof bindingParent?.attemptEntryId === "string" ? bindingParent.attemptEntryId : void 0;
|
|
15078
14828
|
const boundSessionFile = typeof bindingParent?.sessionFile === "string" ? bindingParent.sessionFile : typeof header.parentSession === "string" ? header.parentSession : void 0;
|
|
15079
14829
|
if (boundSessionFile !== sessionFile) continue;
|
|
@@ -15097,12 +14847,12 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
15097
14847
|
if (stop === void 0) continue;
|
|
15098
14848
|
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
15099
14849
|
const entry = entries[i];
|
|
15100
|
-
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !
|
|
15101
|
-
const parent =
|
|
15102
|
-
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;
|
|
15103
14853
|
if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId) continue;
|
|
15104
14854
|
if (failure2 === void 0) continue;
|
|
15105
|
-
const identity =
|
|
14855
|
+
const identity = isRecord12(failure2.identity) ? failure2.identity : void 0;
|
|
15106
14856
|
const typedCause = failure2.cause === "provider" || failure2.cause === "activation" || failure2.cause === "session" || failure2.cause === "output" || failure2.cause === "timeout" ? failure2.cause : void 0;
|
|
15107
14857
|
return {
|
|
15108
14858
|
...typedCause === void 0 ? {} : { cause: typedCause },
|
|
@@ -15111,7 +14861,7 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
15111
14861
|
...typeof identity.code === "string" || typeof identity.code === "number" ? { code: identity.code } : {}
|
|
15112
14862
|
} },
|
|
15113
14863
|
...typeof failure2.diagnostic === "string" ? { diagnostic: failure2.diagnostic } : {},
|
|
15114
|
-
...
|
|
14864
|
+
...isRecord12(failure2.details) ? { details: failure2.details } : {}
|
|
15115
14865
|
};
|
|
15116
14866
|
}
|
|
15117
14867
|
}
|
|
@@ -15158,9 +14908,9 @@ function typedFailedTerminatingToolKnownFailure(entries) {
|
|
|
15158
14908
|
if (classification.kind !== "infrastructure") continue;
|
|
15159
14909
|
if (typeof message.toolCallId !== "string" || typeof message.toolName !== "string") continue;
|
|
15160
14910
|
if (boundRoleToolCallForResult(attemptEntries, i, message, message.toolName) === void 0) continue;
|
|
15161
|
-
const textPart = Array.isArray(message.content) ? message.content.find((part) =>
|
|
15162
|
-
const diagnostic =
|
|
15163
|
-
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;
|
|
15164
14914
|
return {
|
|
15165
14915
|
cause: "activation",
|
|
15166
14916
|
identity: { name: message.toolName, code: message.toolCallId },
|
|
@@ -15297,7 +15047,7 @@ function controlledFailureInputFromResolution(resolution) {
|
|
|
15297
15047
|
} : {}
|
|
15298
15048
|
};
|
|
15299
15049
|
}
|
|
15300
|
-
function
|
|
15050
|
+
function isRecord12(value) {
|
|
15301
15051
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15302
15052
|
}
|
|
15303
15053
|
function toolResultText(message) {
|
|
@@ -15322,7 +15072,7 @@ function extractCollectorTargetBindRejection(entries) {
|
|
|
15322
15072
|
const diagnostic = toolResultText(message);
|
|
15323
15073
|
if (diagnostic.length === 0) return void 0;
|
|
15324
15074
|
const details = message.details;
|
|
15325
|
-
const code =
|
|
15075
|
+
const code = isRecord12(details) && typeof details.code === "string" && details.code.trim() !== "" ? details.code : void 0;
|
|
15326
15076
|
return code === void 0 ? { diagnostic } : { diagnostic, code };
|
|
15327
15077
|
}
|
|
15328
15078
|
return void 0;
|
|
@@ -15423,7 +15173,7 @@ function boundRoleToolCallForResult(entries, resultIndex, message, outputToolNam
|
|
|
15423
15173
|
const candidateMessage = entries[index]?.message;
|
|
15424
15174
|
if (candidateMessage?.role === "assistant" && Array.isArray(candidateMessage.content)) {
|
|
15425
15175
|
for (const part of candidateMessage.content) {
|
|
15426
|
-
if (!
|
|
15176
|
+
if (!isRecord12(part) || part.type !== "toolCall" || part.id !== callId) {
|
|
15427
15177
|
continue;
|
|
15428
15178
|
}
|
|
15429
15179
|
if (part.name !== outputToolName) return void 0;
|
|
@@ -15494,7 +15244,7 @@ function parseNavigatorAttendanceDetails(details) {
|
|
|
15494
15244
|
if (typeof details.prose === "string" && details.prose.trim() !== "") {
|
|
15495
15245
|
prose = details.prose;
|
|
15496
15246
|
} else {
|
|
15497
|
-
const next =
|
|
15247
|
+
const next = isRecord12(details.next) && typeof details.next.role === "string" ? details.next.role : void 0;
|
|
15498
15248
|
const reason = typeof details.reason === "string" && details.reason.trim() !== "" ? details.reason : void 0;
|
|
15499
15249
|
const command = typeof details.command === "string" && details.command.trim() !== "" ? details.command : void 0;
|
|
15500
15250
|
if (reason !== void 0 && next !== void 0) {
|
|
@@ -15566,8 +15316,8 @@ function projectTerminalGateFact(rounds) {
|
|
|
15566
15316
|
};
|
|
15567
15317
|
}
|
|
15568
15318
|
async function extractGateFactFromSessionDirectory(sessionDirectory, options = {}) {
|
|
15569
|
-
const directories = [
|
|
15570
|
-
const parentSessionFile = options.parentSessionFile ??
|
|
15319
|
+
const directories = [join26(sessionDirectory, "auditor-roles")];
|
|
15320
|
+
const parentSessionFile = options.parentSessionFile ?? join26(sessionDirectory, "session.jsonl");
|
|
15571
15321
|
const rounds = await readAnalystGateCyclesFromAuditorRoles(directories, {
|
|
15572
15322
|
parentSessionFile
|
|
15573
15323
|
});
|
|
@@ -15603,7 +15353,7 @@ function detourGateContext(admitted, scope) {
|
|
|
15603
15353
|
}
|
|
15604
15354
|
async function withOptionalGateProjection(base, sessionDirectory, gateContext = {}) {
|
|
15605
15355
|
const secondaryEvidence = base.roleOutcome.kind === "failure" ? base.roleOutcome.decisiveFacts.secondaryEvidence : void 0;
|
|
15606
|
-
const skipGate =
|
|
15356
|
+
const skipGate = isRecord12(secondaryEvidence) && secondaryEvidence.kind === "role_infrastructure_failure" && packagedSkipsGateOnInfrastructureStage(secondaryEvidence.stage);
|
|
15607
15357
|
let next = base;
|
|
15608
15358
|
if (!skipGate) {
|
|
15609
15359
|
const gate = await extractGateFactFromSessionDirectory(sessionDirectory, gateContext);
|
|
@@ -15647,7 +15397,7 @@ function extractNavigatorFact(entries) {
|
|
|
15647
15397
|
const entry = entries[i];
|
|
15648
15398
|
if (entry?.type === "custom_message" && entry.customType === "ak-navigator-attendance") {
|
|
15649
15399
|
const details = entry.message?.details ?? entry.details;
|
|
15650
|
-
if (!
|
|
15400
|
+
if (!isRecord12(details)) {
|
|
15651
15401
|
return {
|
|
15652
15402
|
disposition: "unavailable",
|
|
15653
15403
|
source: "unknown",
|
|
@@ -15705,10 +15455,10 @@ async function removeFaceIfPresent(path) {
|
|
|
15705
15455
|
async function clearOppositeTerminalArtifactFace(runDirectory) {
|
|
15706
15456
|
const artifactsDir = roleRunArtifactsDirectory(runDirectory);
|
|
15707
15457
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
15708
|
-
await removeFaceIfPresent(
|
|
15458
|
+
await removeFaceIfPresent(join26(artifactsDir, file));
|
|
15709
15459
|
}
|
|
15710
15460
|
for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
15711
|
-
await removeFaceIfPresent(
|
|
15461
|
+
await removeFaceIfPresent(join26(runDirectory, relative3));
|
|
15712
15462
|
}
|
|
15713
15463
|
for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
|
|
15714
15464
|
await removeFaceIfPresent(path);
|
|
@@ -15737,8 +15487,8 @@ async function publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinat
|
|
|
15737
15487
|
roleOutcome
|
|
15738
15488
|
);
|
|
15739
15489
|
const artifactsDir = await ensureTerminalArtifactFace(admitted.runDirectory);
|
|
15740
|
-
const reportPath =
|
|
15741
|
-
const evidencePath =
|
|
15490
|
+
const reportPath = join26(artifactsDir, "report.json");
|
|
15491
|
+
const evidencePath = join26(artifactsDir, "evidence.json");
|
|
15742
15492
|
await writeFile6(
|
|
15743
15493
|
reportPath,
|
|
15744
15494
|
`${JSON.stringify(bodies.report, null, 2)}
|
|
@@ -15756,8 +15506,8 @@ async function publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinat
|
|
|
15756
15506
|
{ kind: "evidence", path: evidencePath }
|
|
15757
15507
|
];
|
|
15758
15508
|
}
|
|
15759
|
-
async function publishSeatAcceptedArtifacts(admitted, roleOutcome, coordinates, entries = []
|
|
15760
|
-
return publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries
|
|
15509
|
+
async function publishSeatAcceptedArtifacts(admitted, roleOutcome, coordinates, entries = []) {
|
|
15510
|
+
return publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries);
|
|
15761
15511
|
}
|
|
15762
15512
|
async function readLawfulSettlementEntries(sessionFile) {
|
|
15763
15513
|
try {
|
|
@@ -15798,7 +15548,7 @@ async function settleSealedAcceptedOrToolResidual(admitted, authority, scope, ro
|
|
|
15798
15548
|
const residual = boundErroredToolCandidate(entries, index, message, residualToolName);
|
|
15799
15549
|
if (residual === void 0) continue;
|
|
15800
15550
|
const candidate = residual.candidate;
|
|
15801
|
-
const details =
|
|
15551
|
+
const details = isRecord12(candidate) ? candidate : { candidate };
|
|
15802
15552
|
const failed = await settleFailureTerminalResult(
|
|
15803
15553
|
admitted,
|
|
15804
15554
|
{
|
|
@@ -15829,7 +15579,7 @@ async function settleSealedAcceptedOrToolResidual(admitted, authority, scope, ro
|
|
|
15829
15579
|
scope
|
|
15830
15580
|
);
|
|
15831
15581
|
}
|
|
15832
|
-
async function settleSeat(admitted, authority, scope
|
|
15582
|
+
async function settleSeat(admitted, authority, scope) {
|
|
15833
15583
|
const record4 = packagedRoleMetadata(admitted.role);
|
|
15834
15584
|
if (record4 === void 0) {
|
|
15835
15585
|
throw new Error(`no settlement for ${admitted.role}`);
|
|
@@ -15837,7 +15587,7 @@ async function settleSeat(admitted, authority, scope, options) {
|
|
|
15837
15587
|
if (record4.settlement === "accepted") {
|
|
15838
15588
|
return trySettleAcceptedSeatTerminalResult(admitted, authority, scope);
|
|
15839
15589
|
}
|
|
15840
|
-
const publish = (roleOutcome, coordinates, entries) => publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries
|
|
15590
|
+
const publish = (roleOutcome, coordinates, entries) => publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries);
|
|
15841
15591
|
if (record4.settlement === "residual") {
|
|
15842
15592
|
return settleSealedAcceptedOrToolResidual(
|
|
15843
15593
|
admitted,
|
|
@@ -15852,11 +15602,11 @@ async function settleSeat(admitted, authority, scope, options) {
|
|
|
15852
15602
|
const accept = "sealedAcceptedOnly" in record4 && record4.sealedAcceptedOnly === true ? (roleOutcome) => roleOutcome.role === admitted.role && roleOutcome.kind === "accepted" : void 0;
|
|
15853
15603
|
return settleSealedLedgerTerminal(admitted, authority, scope, publish, accept);
|
|
15854
15604
|
}
|
|
15855
|
-
async function trySettleSeatTerminalResult(admitted, authority,
|
|
15856
|
-
return settleSeat(admitted, authority, scope
|
|
15605
|
+
async function trySettleSeatTerminalResult(admitted, authority, scope) {
|
|
15606
|
+
return settleSeat(admitted, authority, scope);
|
|
15857
15607
|
}
|
|
15858
|
-
async function settleSeatTerminalResult(admitted, authority,
|
|
15859
|
-
const settled = await settleSeat(admitted, authority, scope
|
|
15608
|
+
async function settleSeatTerminalResult(admitted, authority, scope) {
|
|
15609
|
+
const settled = await settleSeat(admitted, authority, scope);
|
|
15860
15610
|
if (settled === void 0) {
|
|
15861
15611
|
const label = admitted.role.charAt(0).toUpperCase() + admitted.role.slice(1);
|
|
15862
15612
|
throw new Error(
|
|
@@ -15865,41 +15615,6 @@ async function settleSeatTerminalResult(admitted, authority, options = {}, scope
|
|
|
15865
15615
|
}
|
|
15866
15616
|
return settled;
|
|
15867
15617
|
}
|
|
15868
|
-
function sessionMessageText(message) {
|
|
15869
|
-
if (message === void 0) return "";
|
|
15870
|
-
if (typeof message.content === "string") return message.content;
|
|
15871
|
-
if (!Array.isArray(message.content)) return "";
|
|
15872
|
-
const parts = [];
|
|
15873
|
-
for (const part of message.content) {
|
|
15874
|
-
if (typeof part === "object" && part !== null && !Array.isArray(part) && part.type === "text" && typeof part.text === "string") {
|
|
15875
|
-
parts.push(part.text);
|
|
15876
|
-
}
|
|
15877
|
-
}
|
|
15878
|
-
return parts.join("\n");
|
|
15879
|
-
}
|
|
15880
|
-
function observedMethodSkillOptions(packageRoot, material) {
|
|
15881
|
-
return {
|
|
15882
|
-
methodProvenance: material.provenance,
|
|
15883
|
-
methodSkillPath: material.skillPath,
|
|
15884
|
-
methodSkillConfiguredPath: resolvePackagedMethodSkillPath(packageRoot, material.name)
|
|
15885
|
-
};
|
|
15886
|
-
}
|
|
15887
|
-
function extractObservedMethodInvocations(entries, options) {
|
|
15888
|
-
const observed = [];
|
|
15889
|
-
for (const entry of entries) {
|
|
15890
|
-
if (entry?.type !== "message") continue;
|
|
15891
|
-
const message = entry.message;
|
|
15892
|
-
if (message?.role !== "user") continue;
|
|
15893
|
-
const text = sessionMessageText(message);
|
|
15894
|
-
if (text.length === 0) continue;
|
|
15895
|
-
const hit = observePackagedMethodSkillInvocation(text, {
|
|
15896
|
-
name: options.name,
|
|
15897
|
-
allowedLocations: options.allowedLocations
|
|
15898
|
-
});
|
|
15899
|
-
if (hit !== void 0) observed.push(hit);
|
|
15900
|
-
}
|
|
15901
|
-
return Object.freeze(observed);
|
|
15902
|
-
}
|
|
15903
15618
|
function extractDoctorCandidateFacts(entries) {
|
|
15904
15619
|
const scanStart = currentAttemptStartIndex(entries);
|
|
15905
15620
|
for (let i = entries.length - 1; i >= scanStart; i -= 1) {
|
|
@@ -15908,7 +15623,7 @@ function extractDoctorCandidateFacts(entries) {
|
|
|
15908
15623
|
continue;
|
|
15909
15624
|
}
|
|
15910
15625
|
const data = entry.data;
|
|
15911
|
-
if (!
|
|
15626
|
+
if (!isRecord12(data)) return {};
|
|
15912
15627
|
return {
|
|
15913
15628
|
...data.cost === void 0 ? {} : { cost: data.cost },
|
|
15914
15629
|
...data.auditNoReceipt === void 0 ? {} : { auditNoReceipt: data.auditNoReceipt }
|
|
@@ -15952,25 +15667,7 @@ function doctorReportFacts(face, roleOutcome, entries) {
|
|
|
15952
15667
|
...facts.auditNoReceipt === void 0 ? {} : { auditNoReceipt: facts.auditNoReceipt }
|
|
15953
15668
|
};
|
|
15954
15669
|
}
|
|
15955
|
-
function
|
|
15956
|
-
if (face.method === void 0) return {};
|
|
15957
|
-
if (face.method === "optional") {
|
|
15958
|
-
return options.methodProvenance === void 0 ? {} : { methodProvenance: options.methodProvenance };
|
|
15959
|
-
}
|
|
15960
|
-
if (options.methodProvenance === void 0 || options.methodSkillPath === void 0 || options.methodSkillConfiguredPath === void 0) {
|
|
15961
|
-
throw new Error("observed method publication is missing packaged method coordinates");
|
|
15962
|
-
}
|
|
15963
|
-
const methodInvocations = extractObservedMethodInvocations(entries, {
|
|
15964
|
-
name: options.methodProvenance.name,
|
|
15965
|
-
allowedLocations: [options.methodSkillPath, options.methodSkillConfiguredPath]
|
|
15966
|
-
});
|
|
15967
|
-
return {
|
|
15968
|
-
methodProvenance: options.methodProvenance,
|
|
15969
|
-
methodInvocationObserved: methodInvocations.length > 0,
|
|
15970
|
-
methodInvocations
|
|
15971
|
-
};
|
|
15972
|
-
}
|
|
15973
|
-
async function publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries, options = {}) {
|
|
15670
|
+
async function publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries) {
|
|
15974
15671
|
const face = seatArtifactFace(admitted.role);
|
|
15975
15672
|
const phase = face.reportPhase === true ? { phase: readAdmittedPath(admitted, "phase") } : {};
|
|
15976
15673
|
return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
|
|
@@ -15988,8 +15685,7 @@ async function publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates,
|
|
|
15988
15685
|
sessionDirectory: coordinates.sessionDirectory,
|
|
15989
15686
|
sessionFile: coordinates.sessionFile,
|
|
15990
15687
|
admittedRequestPath: admitted.admittedRequestPath,
|
|
15991
|
-
attachments: acceptedArtifactAttachmentRefs(admitted.attachments)
|
|
15992
|
-
...observedMethodTail(face, entries, options)
|
|
15688
|
+
attachments: acceptedArtifactAttachmentRefs(admitted.attachments)
|
|
15993
15689
|
}
|
|
15994
15690
|
});
|
|
15995
15691
|
}
|
|
@@ -16012,7 +15708,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
16012
15708
|
let residual;
|
|
16013
15709
|
for (let index = entries.length - 1; index >= scanStart; index -= 1) {
|
|
16014
15710
|
const entry = entries[index];
|
|
16015
|
-
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") {
|
|
16016
15712
|
thisAttemptHasSeatSuccess = true;
|
|
16017
15713
|
}
|
|
16018
15714
|
const message = entries[index]?.message;
|
|
@@ -16052,7 +15748,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
16052
15748
|
);
|
|
16053
15749
|
}
|
|
16054
15750
|
if (residual !== void 0) {
|
|
16055
|
-
const details =
|
|
15751
|
+
const details = isRecord12(residual.candidate) ? residual.candidate : { candidate: residual.candidate };
|
|
16056
15752
|
const failed = await settleFailureTerminalResult(
|
|
16057
15753
|
admitted,
|
|
16058
15754
|
{
|
|
@@ -16082,11 +15778,8 @@ async function trySettleAcceptedSeatTerminalResult(admitted, authority, scope) {
|
|
|
16082
15778
|
}
|
|
16083
15779
|
return applySecretariatCountersignTerminal(admitted, authority, settled);
|
|
16084
15780
|
}
|
|
16085
|
-
async function trySettlePublicSeat(admitted, authority, scope
|
|
16086
|
-
|
|
16087
|
-
if (face.method === "observed" && material === void 0) return void 0;
|
|
16088
|
-
const options = face.method === "observed" && material !== void 0 ? observedMethodSkillOptions(packageRoot, material) : face.method === "optional" && material !== void 0 ? { methodProvenance: material.provenance } : {};
|
|
16089
|
-
return settleSeat(admitted, authority, scope, options);
|
|
15781
|
+
async function trySettlePublicSeat(admitted, authority, scope) {
|
|
15782
|
+
return settleSeat(admitted, authority, scope);
|
|
16090
15783
|
}
|
|
16091
15784
|
function countersignTerminalFromEntries(entries) {
|
|
16092
15785
|
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
@@ -16105,7 +15798,7 @@ function countersignTerminalFromEntries(entries) {
|
|
|
16105
15798
|
return void 0;
|
|
16106
15799
|
}
|
|
16107
15800
|
function withCountersignTerminalFact(roleOutcome, officer) {
|
|
16108
|
-
const prior = roleOutcome.decisiveFacts !== void 0 &&
|
|
15801
|
+
const prior = roleOutcome.decisiveFacts !== void 0 && isRecord12(roleOutcome.decisiveFacts) ? roleOutcome.decisiveFacts : {};
|
|
16109
15802
|
return {
|
|
16110
15803
|
...roleOutcome,
|
|
16111
15804
|
decisiveFacts: {
|
|
@@ -16118,7 +15811,7 @@ function acceptedSecretariatDefinesOfficerProjection(roleOutcome) {
|
|
|
16118
15811
|
const payloads = roleOutcome.payloads ?? [];
|
|
16119
15812
|
for (let index = payloads.length - 1; index >= 0; index -= 1) {
|
|
16120
15813
|
const payload = payloads[index];
|
|
16121
|
-
if (!
|
|
15814
|
+
if (!isRecord12(payload)) continue;
|
|
16122
15815
|
const status = payload.secretariatStatus;
|
|
16123
15816
|
if (typeof status !== "string") continue;
|
|
16124
15817
|
return status === "converged";
|
|
@@ -16194,7 +15887,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
|
|
|
16194
15887
|
const candidates = [
|
|
16195
15888
|
...preferredCandidates,
|
|
16196
15889
|
// One unique name per fallback dir — collisions on fixed names cannot exhaust this.
|
|
16197
|
-
...uniqueFallbackDirs.map((dir) =>
|
|
15890
|
+
...uniqueFallbackDirs.map((dir) => join26(dir, `${stem}.${randomUUID4()}.json`))
|
|
16198
15891
|
];
|
|
16199
15892
|
for (let i = 0; i < candidates.length; i += 1) {
|
|
16200
15893
|
const path = candidates[i];
|
|
@@ -16255,20 +15948,20 @@ async function publishFailureArtifacts(admitted, failure2, authority) {
|
|
|
16255
15948
|
baseDir
|
|
16256
15949
|
);
|
|
16257
15950
|
const errorCandidates = underArtifacts ? [
|
|
16258
|
-
|
|
16259
|
-
|
|
16260
|
-
|
|
15951
|
+
join26(baseDir, "error.json"),
|
|
15952
|
+
join26(baseDir, "error.settlement.json"),
|
|
15953
|
+
join26(admitted.runDirectory, "error.settlement.json")
|
|
16261
15954
|
] : [
|
|
16262
|
-
|
|
16263
|
-
|
|
15955
|
+
join26(baseDir, "error.settlement.json"),
|
|
15956
|
+
join26(baseDir, "error.json")
|
|
16264
15957
|
];
|
|
16265
15958
|
const evidenceCandidates = underArtifacts ? [
|
|
16266
|
-
|
|
16267
|
-
|
|
16268
|
-
|
|
15959
|
+
join26(baseDir, "evidence.json"),
|
|
15960
|
+
join26(baseDir, "evidence.settlement.json"),
|
|
15961
|
+
join26(admitted.runDirectory, "evidence.settlement.json")
|
|
16269
15962
|
] : [
|
|
16270
|
-
|
|
16271
|
-
|
|
15963
|
+
join26(baseDir, "evidence.settlement.json"),
|
|
15964
|
+
join26(baseDir, "evidence.json")
|
|
16272
15965
|
];
|
|
16273
15966
|
const errorPayloadBase = {
|
|
16274
15967
|
kind: "error",
|
|
@@ -16444,10 +16137,10 @@ function presentFailureTerminal(terminal, io) {
|
|
|
16444
16137
|
}
|
|
16445
16138
|
function defaultNavigatorGraceSleep() {
|
|
16446
16139
|
let timer;
|
|
16447
|
-
const sleep2 = ((ms) => new Promise((
|
|
16140
|
+
const sleep2 = ((ms) => new Promise((resolve21) => {
|
|
16448
16141
|
timer = setTimeout(() => {
|
|
16449
16142
|
timer = void 0;
|
|
16450
|
-
|
|
16143
|
+
resolve21();
|
|
16451
16144
|
}, ms);
|
|
16452
16145
|
}));
|
|
16453
16146
|
sleep2.cancel = () => {
|
|
@@ -16459,7 +16152,7 @@ function defaultNavigatorGraceSleep() {
|
|
|
16459
16152
|
return sleep2;
|
|
16460
16153
|
}
|
|
16461
16154
|
function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2 = defaultNavigatorGraceSleep()) {
|
|
16462
|
-
return new Promise((
|
|
16155
|
+
return new Promise((resolve21, reject) => {
|
|
16463
16156
|
let settled = false;
|
|
16464
16157
|
const finish = (action) => {
|
|
16465
16158
|
if (settled) return;
|
|
@@ -16468,11 +16161,11 @@ function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2
|
|
|
16468
16161
|
action();
|
|
16469
16162
|
};
|
|
16470
16163
|
void work.then(
|
|
16471
|
-
(value) => finish(() =>
|
|
16164
|
+
(value) => finish(() => resolve21({ status: "done", value })),
|
|
16472
16165
|
(error) => finish(() => reject(error))
|
|
16473
16166
|
);
|
|
16474
16167
|
void sleep2(graceMs).then(() => {
|
|
16475
|
-
finish(() =>
|
|
16168
|
+
finish(() => resolve21({ status: "timeout" }));
|
|
16476
16169
|
});
|
|
16477
16170
|
});
|
|
16478
16171
|
}
|
|
@@ -16500,7 +16193,6 @@ var init_settlement = __esm({
|
|
|
16500
16193
|
init_reviewer_output();
|
|
16501
16194
|
init_packaged_role_registry();
|
|
16502
16195
|
init_secretariat_contracts();
|
|
16503
|
-
init_method_skill();
|
|
16504
16196
|
init_navigator_invocation_identity();
|
|
16505
16197
|
init_receipt_delivery_policy();
|
|
16506
16198
|
init_role_run_placement();
|
|
@@ -16547,17 +16239,17 @@ var init_settlement = __esm({
|
|
|
16547
16239
|
});
|
|
16548
16240
|
|
|
16549
16241
|
// src/session-identity.ts
|
|
16550
|
-
import { mkdir as mkdir2, readFile as
|
|
16551
|
-
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";
|
|
16552
16244
|
function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
16553
|
-
const bindingPath = (principal) =>
|
|
16245
|
+
const bindingPath = (principal) => join27(authority.decode(principal).sessionDirectory, sessionBindingFile);
|
|
16554
16246
|
return {
|
|
16555
16247
|
resolveSessionFile(principal) {
|
|
16556
16248
|
return authority.decode(principal).sessionFile;
|
|
16557
16249
|
},
|
|
16558
16250
|
async load(principal) {
|
|
16559
16251
|
try {
|
|
16560
|
-
const value = JSON.parse(await
|
|
16252
|
+
const value = JSON.parse(await readFile16(bindingPath(principal), "utf8"));
|
|
16561
16253
|
if (typeof value !== "object" || value === null || typeof value.sessionId !== "string") {
|
|
16562
16254
|
throw new Error("durable session binding is invalid");
|
|
16563
16255
|
}
|
|
@@ -16608,9 +16300,9 @@ __export(case_dossier_delivery_exports, {
|
|
|
16608
16300
|
loadCaseDossierReadingMaterial: () => loadCaseDossierReadingMaterial,
|
|
16609
16301
|
projectCaseDossierPointerSection: () => projectCaseDossierPointerSection
|
|
16610
16302
|
});
|
|
16611
|
-
import { mkdtemp as mkdtemp3, readFile as
|
|
16303
|
+
import { mkdtemp as mkdtemp3, readFile as readFile17, rm as rm4, writeFile as writeFile8 } from "node:fs/promises";
|
|
16612
16304
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
16613
|
-
import { join as
|
|
16305
|
+
import { join as join28 } from "node:path";
|
|
16614
16306
|
async function projectCaseDossierPointerSection(input) {
|
|
16615
16307
|
if (input.ticketNumber === void 0) {
|
|
16616
16308
|
return [
|
|
@@ -16637,9 +16329,9 @@ async function deliverCaseDossierAsAttachment(input) {
|
|
|
16637
16329
|
projectRoot: input.projectRoot,
|
|
16638
16330
|
home: input.home
|
|
16639
16331
|
});
|
|
16640
|
-
const stagingDir = await mkdtemp3(
|
|
16332
|
+
const stagingDir = await mkdtemp3(join28(tmpdir3(), "ak-case-dossier-"));
|
|
16641
16333
|
try {
|
|
16642
|
-
const stagingPath =
|
|
16334
|
+
const stagingPath = join28(stagingDir, CASE_DOSSIER_ATTACH_FILE);
|
|
16643
16335
|
await writeFile8(stagingPath, `${section}
|
|
16644
16336
|
`, "utf8");
|
|
16645
16337
|
return await freezeAttachmentsIntoRun(
|
|
@@ -16652,7 +16344,7 @@ async function deliverCaseDossierAsAttachment(input) {
|
|
|
16652
16344
|
}
|
|
16653
16345
|
}
|
|
16654
16346
|
async function loadCaseDossierReadingMaterial(runDirectory) {
|
|
16655
|
-
const frozenPath =
|
|
16347
|
+
const frozenPath = join28(
|
|
16656
16348
|
runDirectory,
|
|
16657
16349
|
"attachments",
|
|
16658
16350
|
CASE_DOSSIER_ATTACH_KEY,
|
|
@@ -16660,7 +16352,7 @@ async function loadCaseDossierReadingMaterial(runDirectory) {
|
|
|
16660
16352
|
);
|
|
16661
16353
|
let section;
|
|
16662
16354
|
try {
|
|
16663
|
-
section = await
|
|
16355
|
+
section = await readFile17(frozenPath, "utf8");
|
|
16664
16356
|
} catch (error) {
|
|
16665
16357
|
if (error.code === "ENOENT") return void 0;
|
|
16666
16358
|
throw error;
|
|
@@ -16684,7 +16376,7 @@ var init_case_dossier_delivery = __esm({
|
|
|
16684
16376
|
|
|
16685
16377
|
// src/host-transition-prior-native.ts
|
|
16686
16378
|
import { access as access3, readdir as readdir7 } from "node:fs/promises";
|
|
16687
|
-
import { dirname as dirname16, join as
|
|
16379
|
+
import { dirname as dirname16, join as join29 } from "node:path";
|
|
16688
16380
|
function isEnoent2(error) {
|
|
16689
16381
|
return typeof error === "object" && error !== null && error.code === "ENOENT";
|
|
16690
16382
|
}
|
|
@@ -16709,7 +16401,7 @@ async function listSitianRecordPaths(sessionParent) {
|
|
|
16709
16401
|
const recordPaths = [];
|
|
16710
16402
|
for (const entry of entries) {
|
|
16711
16403
|
if (!entry.isDirectory()) continue;
|
|
16712
|
-
const recordFile =
|
|
16404
|
+
const recordFile = join29(sessionRoot, entry.name, "records.jsonl");
|
|
16713
16405
|
try {
|
|
16714
16406
|
await access3(recordFile);
|
|
16715
16407
|
recordPaths.push(recordFile);
|
|
@@ -16761,7 +16453,7 @@ var init_process_cancel = __esm({
|
|
|
16761
16453
|
import { constants as fsConstants2 } from "node:fs";
|
|
16762
16454
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
16763
16455
|
import { lstat as lstat6, mkdir as mkdir3, open as open2 } from "node:fs/promises";
|
|
16764
|
-
import { join as
|
|
16456
|
+
import { join as join30 } from "node:path";
|
|
16765
16457
|
async function persistReturnedRunState(admitted, authority, options) {
|
|
16766
16458
|
if (options?.lawful === true) {
|
|
16767
16459
|
await markRunTerminal(admitted.runDirectory);
|
|
@@ -16832,7 +16524,7 @@ function jsonSafeReplacer() {
|
|
|
16832
16524
|
};
|
|
16833
16525
|
}
|
|
16834
16526
|
async function writeHardenedArtifactFile(artifactsDir, namePrefix, payload) {
|
|
16835
|
-
const filePath =
|
|
16527
|
+
const filePath = join30(artifactsDir, `${namePrefix}-${randomUUID5()}.json`);
|
|
16836
16528
|
const body = `${JSON.stringify(payload, jsonSafeReplacer(), 2)}
|
|
16837
16529
|
`;
|
|
16838
16530
|
const noFollowFlag = typeof fsConstants2.O_NOFOLLOW === "number" ? fsConstants2.O_NOFOLLOW : 0;
|
|
@@ -17121,7 +16813,7 @@ var init_auto_resume = __esm({
|
|
|
17121
16813
|
// src/public-cli/post-admission.ts
|
|
17122
16814
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
17123
16815
|
import { writeFile as writeFile9 } from "node:fs/promises";
|
|
17124
|
-
import { isAbsolute as isAbsolute8, join as
|
|
16816
|
+
import { isAbsolute as isAbsolute8, join as join31, resolve as resolve12 } from "node:path";
|
|
17125
16817
|
function describeCaughtError(error) {
|
|
17126
16818
|
if (error instanceof Error) {
|
|
17127
16819
|
const code = error.code;
|
|
@@ -17212,7 +16904,7 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
17212
16904
|
try {
|
|
17213
16905
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
17214
16906
|
await writeFile9(
|
|
17215
|
-
|
|
16907
|
+
join31(artifactsDir, `post-admission-diagnostic-${randomUUID6()}.json`),
|
|
17216
16908
|
`${JSON.stringify({ version: 1, ...payload }, null, 2)}
|
|
17217
16909
|
`,
|
|
17218
16910
|
{ encoding: "utf8", flag: "wx" }
|
|
@@ -17229,30 +16921,6 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
17229
16921
|
} catch {
|
|
17230
16922
|
}
|
|
17231
16923
|
}
|
|
17232
|
-
async function resolveResumeMethodMaterialAdapters(input) {
|
|
17233
|
-
if (input.shouldLoad === false) {
|
|
17234
|
-
return { kind: "continue", adapters: input.emptyAdapters };
|
|
17235
|
-
}
|
|
17236
|
-
try {
|
|
17237
|
-
const material = await input.loadMaterial();
|
|
17238
|
-
return { kind: "continue", adapters: input.adaptersWith(material) };
|
|
17239
|
-
} catch (error) {
|
|
17240
|
-
const terminal = await presentControlledFailure2(
|
|
17241
|
-
input.admitted,
|
|
17242
|
-
{
|
|
17243
|
-
timedOut: false,
|
|
17244
|
-
code: null,
|
|
17245
|
-
stderr: "",
|
|
17246
|
-
thrown: error,
|
|
17247
|
-
...input.knownCause === void 0 ? {} : { knownCause: input.knownCause }
|
|
17248
|
-
},
|
|
17249
|
-
input.emptyAdapters,
|
|
17250
|
-
input.authority,
|
|
17251
|
-
input.io
|
|
17252
|
-
);
|
|
17253
|
-
return { kind: "terminal", ...terminal };
|
|
17254
|
-
}
|
|
17255
|
-
}
|
|
17256
16924
|
async function presentControlledFailure2(admitted, failureInput, adapters, authority, io, persistRunState = true) {
|
|
17257
16925
|
const hasThrown = Object.hasOwn(failureInput, "thrown");
|
|
17258
16926
|
const resumeObservation = await resolveControlledFailureResumeObservation({
|
|
@@ -17377,7 +17045,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
17377
17045
|
const rows = await readRecordedSubmissionRows(
|
|
17378
17046
|
admitted.projectRoot,
|
|
17379
17047
|
admitted.runId,
|
|
17380
|
-
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent:
|
|
17048
|
+
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent: join31(admitted.runDirectory, "session", "session.jsonl") }
|
|
17381
17049
|
);
|
|
17382
17050
|
const asserted = rows.filter((row) => row.kind === "accepted" && row.role === admitted.role).map((row) => row.accepted).find((payload) => {
|
|
17383
17051
|
if (payload === null || typeof payload !== "object" || Array.isArray(payload)) return false;
|
|
@@ -17535,7 +17203,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
17535
17203
|
let stderrLogWriteFailure;
|
|
17536
17204
|
try {
|
|
17537
17205
|
await writeFile9(
|
|
17538
|
-
|
|
17206
|
+
join31(admitted.runDirectory, "stderr.log"),
|
|
17539
17207
|
result.stderr,
|
|
17540
17208
|
"utf8"
|
|
17541
17209
|
);
|
|
@@ -17771,6 +17439,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
17771
17439
|
return {
|
|
17772
17440
|
packageRoot: env.packageRoot,
|
|
17773
17441
|
home: env.home,
|
|
17442
|
+
...env.host === void 0 ? {} : { host: env.host },
|
|
17774
17443
|
agentDir: env.agentDir,
|
|
17775
17444
|
...env.model === void 0 ? {} : { model: env.model },
|
|
17776
17445
|
...pickEngineAxis(env),
|
|
@@ -17789,6 +17458,7 @@ function roleTurnOptions(env, admitted, continuation) {
|
|
|
17789
17458
|
return {
|
|
17790
17459
|
packageRoot: env.packageRoot,
|
|
17791
17460
|
home: env.home,
|
|
17461
|
+
...env.host === void 0 ? {} : { host: env.host },
|
|
17792
17462
|
agentDir: env.agentDir,
|
|
17793
17463
|
...env.model === void 0 ? {} : { model: env.model },
|
|
17794
17464
|
...pickEngineAxis(env),
|
|
@@ -17812,7 +17482,7 @@ async function dispatchAfterWriterLease(input) {
|
|
|
17812
17482
|
}
|
|
17813
17483
|
function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
|
|
17814
17484
|
const absolute = isAbsolute8(attachmentPath) ? attachmentPath : resolve12(attachmentPath);
|
|
17815
|
-
return pathContainedIn(
|
|
17485
|
+
return pathContainedIn(join31(runDirectory, "attachments"), absolute);
|
|
17816
17486
|
}
|
|
17817
17487
|
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
17818
17488
|
if (summons === void 0) return void 0;
|
|
@@ -18141,6 +17811,150 @@ var init_seat_ticket_binding = __esm({
|
|
|
18141
17811
|
}
|
|
18142
17812
|
});
|
|
18143
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
|
+
|
|
18144
17958
|
// src/public-cli/turn-request.ts
|
|
18145
17959
|
function projectRoleTurnRequest(admitted, roleDetails, options) {
|
|
18146
17960
|
const cwd = admitted.projectRoot ?? admitted.repoRoot ?? admitted.cwd;
|
|
@@ -18202,7 +18016,7 @@ function activationForAdmitted(admitted) {
|
|
|
18202
18016
|
}
|
|
18203
18017
|
return activation;
|
|
18204
18018
|
}
|
|
18205
|
-
function
|
|
18019
|
+
function requiredMethodSkills(admitted) {
|
|
18206
18020
|
const record4 = packagedRoleMetadata(admitted.role);
|
|
18207
18021
|
const names = [];
|
|
18208
18022
|
if (record4 !== void 0 && "methodSkills" in record4 && record4.methodSkills !== void 0) {
|
|
@@ -18210,33 +18024,40 @@ function methodBindings(admitted, packageRoot) {
|
|
|
18210
18024
|
}
|
|
18211
18025
|
const apply = packagedSettleSkill(admitted);
|
|
18212
18026
|
if (apply !== void 0 && !names.includes(apply)) names.push(apply);
|
|
18213
|
-
return names
|
|
18214
|
-
kind: "skill",
|
|
18215
|
-
path: resolvePackagedMethodSkillPath(packageRoot, name)
|
|
18216
|
-
}));
|
|
18027
|
+
return names;
|
|
18217
18028
|
}
|
|
18218
|
-
function
|
|
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
|
+
});
|
|
18038
|
+
}
|
|
18039
|
+
function admittedSeatTurnDetails(admitted, home, host) {
|
|
18219
18040
|
return {
|
|
18220
18041
|
activation: activationForAdmitted(admitted),
|
|
18221
|
-
methods: methodBindings(admitted,
|
|
18042
|
+
methods: methodBindings(admitted, home, host)
|
|
18222
18043
|
};
|
|
18223
18044
|
}
|
|
18224
18045
|
var init_turn_request = __esm({
|
|
18225
18046
|
"src/public-cli/turn-request.ts"() {
|
|
18226
18047
|
"use strict";
|
|
18227
18048
|
init_engine_material();
|
|
18228
|
-
init_method_skill();
|
|
18229
18049
|
init_packaged_role_registry();
|
|
18050
|
+
init_machine_method_skills();
|
|
18230
18051
|
init_run_lifecycle();
|
|
18231
18052
|
}
|
|
18232
18053
|
});
|
|
18233
18054
|
|
|
18234
18055
|
// src/public-cli/countersign-run.ts
|
|
18235
|
-
function
|
|
18056
|
+
function isRecord13(value) {
|
|
18236
18057
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18237
18058
|
}
|
|
18238
18059
|
function isEscalatePayload(payload) {
|
|
18239
|
-
if (!
|
|
18060
|
+
if (!isRecord13(payload)) return false;
|
|
18240
18061
|
return payload.status === "escalate";
|
|
18241
18062
|
}
|
|
18242
18063
|
function courtDiaristPayloadRows(roleOutcome, submissions) {
|
|
@@ -18439,7 +18260,7 @@ function roleRecord(role) {
|
|
|
18439
18260
|
function buildInstructionSeatTurnRequest(admitted, options) {
|
|
18440
18261
|
return projectRoleTurnRequest(
|
|
18441
18262
|
admitted,
|
|
18442
|
-
admittedSeatTurnDetails(admitted, options.
|
|
18263
|
+
admittedSeatTurnDetails(admitted, options.home, options.host),
|
|
18443
18264
|
options
|
|
18444
18265
|
);
|
|
18445
18266
|
}
|
|
@@ -18472,11 +18293,11 @@ async function bindAndRelocateDiarist(admitted, authority, lease) {
|
|
|
18472
18293
|
}
|
|
18473
18294
|
await relocateAdmittedRunToTicket(admitted, authority, lease);
|
|
18474
18295
|
}
|
|
18475
|
-
function seatAdapters(admitted, env
|
|
18296
|
+
function seatAdapters(admitted, env) {
|
|
18476
18297
|
const record4 = roleRecord(admitted.role);
|
|
18477
18298
|
const present = "presentSettled" in record4 ? record4.presentSettled : "default";
|
|
18478
18299
|
return {
|
|
18479
|
-
trySettle: (seat, authority, scope) => trySettlePublicSeat(seat, authority, scope
|
|
18300
|
+
trySettle: (seat, authority, scope) => trySettlePublicSeat(seat, authority, scope),
|
|
18480
18301
|
...present === "always" ? { shouldPresentSettled: () => true } : {},
|
|
18481
18302
|
...present === "typed" ? { shouldPresentSettled: (terminal) => isLawfulTypedTerminalOutcome(terminal.roleOutcome) } : {},
|
|
18482
18303
|
...infraFailure(admitted.role),
|
|
@@ -18528,23 +18349,8 @@ async function withAuditorSoulEnv(options) {
|
|
|
18528
18349
|
}
|
|
18529
18350
|
async function dispatchAdmitted(admitted, env, io) {
|
|
18530
18351
|
const record4 = roleRecord(admitted.role);
|
|
18531
|
-
|
|
18532
|
-
const
|
|
18533
|
-
if (skill !== void 0) {
|
|
18534
|
-
try {
|
|
18535
|
-
material = await loadPackagedMethodSkillMaterial(env.packageRoot, skill);
|
|
18536
|
-
} catch (error) {
|
|
18537
|
-
const knownCause = packagedMethodLoadFailureCause(admitted.role);
|
|
18538
|
-
return await presentControlledFailure2(admitted, {
|
|
18539
|
-
timedOut: false,
|
|
18540
|
-
code: null,
|
|
18541
|
-
stderr: "",
|
|
18542
|
-
thrown: error,
|
|
18543
|
-
...knownCause === void 0 ? {} : { knownCause }
|
|
18544
|
-
}, seatAdapters(admitted, env), env.principalAuthority, io);
|
|
18545
|
-
}
|
|
18546
|
-
}
|
|
18547
|
-
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);
|
|
18548
18354
|
const execute = async (activeEnv) => {
|
|
18549
18355
|
const auto = "inCallAutoResume" in record4 && record4.inCallAutoResume === true;
|
|
18550
18356
|
if (auto) {
|
|
@@ -19047,21 +18853,9 @@ async function runPublicInstructionSeatResume(request, env, io) {
|
|
|
19047
18853
|
adapters: {
|
|
19048
18854
|
trySettle: async () => void 0
|
|
19049
18855
|
},
|
|
19050
|
-
afterAdmittedLoad: (admitted) => {
|
|
19051
|
-
|
|
19052
|
-
|
|
19053
|
-
return Promise.resolve({ kind: "continue", adapters: seatAdapters(admitted, env) });
|
|
19054
|
-
}
|
|
19055
|
-
const knownCause = packagedMethodLoadFailureCause(admitted.role);
|
|
19056
|
-
return resolveResumeMethodMaterialAdapters({
|
|
19057
|
-
admitted,
|
|
19058
|
-
authority: env.principalAuthority,
|
|
19059
|
-
io,
|
|
19060
|
-
loadMaterial: () => loadPackagedMethodSkillMaterial(env.packageRoot, skill),
|
|
19061
|
-
adaptersWith: (material) => seatAdapters(admitted, env, material),
|
|
19062
|
-
emptyAdapters: seatAdapters(admitted, env),
|
|
19063
|
-
...knownCause === void 0 ? {} : { knownCause }
|
|
19064
|
-
});
|
|
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) };
|
|
19065
18859
|
},
|
|
19066
18860
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
19067
18861
|
});
|
|
@@ -19087,7 +18881,6 @@ var init_instruction_seat_run = __esm({
|
|
|
19087
18881
|
init_run_ticket_number();
|
|
19088
18882
|
init_notary_source_run();
|
|
19089
18883
|
init_engine_material();
|
|
19090
|
-
init_method_skill();
|
|
19091
18884
|
init_packaged_role_registry();
|
|
19092
18885
|
init_auditor_soul();
|
|
19093
18886
|
init_cli_errors();
|
|
@@ -19096,6 +18889,7 @@ var init_instruction_seat_run = __esm({
|
|
|
19096
18889
|
init_run_lifecycle();
|
|
19097
18890
|
init_seat_ticket_binding();
|
|
19098
18891
|
init_settlement();
|
|
18892
|
+
init_machine_method_skills();
|
|
19099
18893
|
init_terminal();
|
|
19100
18894
|
init_turn_request();
|
|
19101
18895
|
init_countersign_run();
|
|
@@ -19103,13 +18897,13 @@ var init_instruction_seat_run = __esm({
|
|
|
19103
18897
|
});
|
|
19104
18898
|
|
|
19105
18899
|
// src/analyst-book-key.ts
|
|
19106
|
-
import { statSync as
|
|
18900
|
+
import { statSync as statSync4 } from "node:fs";
|
|
19107
18901
|
import { isAbsolute as isAbsolute9 } from "node:path";
|
|
19108
18902
|
function resolveAnalystBookKey(projectRoot) {
|
|
19109
18903
|
const identity = physicalPathIdentity(projectRoot);
|
|
19110
18904
|
let stats;
|
|
19111
18905
|
try {
|
|
19112
|
-
stats =
|
|
18906
|
+
stats = statSync4(identity);
|
|
19113
18907
|
} catch (error) {
|
|
19114
18908
|
const code = errnoCode(error);
|
|
19115
18909
|
if (code === "ENOENT" || code === "ENOTDIR") return `root:${identity}`;
|
|
@@ -19158,11 +18952,11 @@ var init_atomic_write = __esm({
|
|
|
19158
18952
|
});
|
|
19159
18953
|
|
|
19160
18954
|
// src/analyst-index.ts
|
|
19161
|
-
import { open as open3, readFile as
|
|
18955
|
+
import { open as open3, readFile as readFile18, unlink as unlink5 } from "node:fs/promises";
|
|
19162
18956
|
import { dirname as dirname18, join as join34 } from "node:path";
|
|
19163
18957
|
function sleep(ms) {
|
|
19164
|
-
return new Promise((
|
|
19165
|
-
setTimeout(
|
|
18958
|
+
return new Promise((resolve21) => {
|
|
18959
|
+
setTimeout(resolve21, ms);
|
|
19166
18960
|
});
|
|
19167
18961
|
}
|
|
19168
18962
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
@@ -19286,7 +19080,7 @@ async function readAnalystLibraryIndexPage(ledgerHome) {
|
|
|
19286
19080
|
const path = analystLibraryIndexPath(ledgerHome);
|
|
19287
19081
|
let raw;
|
|
19288
19082
|
try {
|
|
19289
|
-
raw = await
|
|
19083
|
+
raw = await readFile18(path, "utf8");
|
|
19290
19084
|
} catch (error) {
|
|
19291
19085
|
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR")) {
|
|
19292
19086
|
return void 0;
|
|
@@ -19490,15 +19284,15 @@ var init_analyst_cohort = __esm({
|
|
|
19490
19284
|
});
|
|
19491
19285
|
|
|
19492
19286
|
// src/analyst-ledger.ts
|
|
19493
|
-
import { readdir as readdir8, readFile as
|
|
19494
|
-
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";
|
|
19495
19289
|
function isMissingPathError6(error) {
|
|
19496
19290
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
19497
19291
|
}
|
|
19498
19292
|
function errorText3(error) {
|
|
19499
19293
|
return error instanceof Error ? error.message : String(error);
|
|
19500
19294
|
}
|
|
19501
|
-
function
|
|
19295
|
+
function isRecord14(value) {
|
|
19502
19296
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19503
19297
|
}
|
|
19504
19298
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
@@ -19549,13 +19343,13 @@ async function listLedgerBookNames(booksRoot) {
|
|
|
19549
19343
|
async function readInvocationScopeFields(runDirectory) {
|
|
19550
19344
|
let raw;
|
|
19551
19345
|
try {
|
|
19552
|
-
raw = await
|
|
19346
|
+
raw = await readFile19(join35(runDirectory, "invocation.json"), "utf8");
|
|
19553
19347
|
} catch (error) {
|
|
19554
19348
|
if (isMissingPathError6(error)) return void 0;
|
|
19555
19349
|
throw error;
|
|
19556
19350
|
}
|
|
19557
19351
|
const parsed = JSON.parse(raw);
|
|
19558
|
-
if (!
|
|
19352
|
+
if (!isRecord14(parsed)) return void 0;
|
|
19559
19353
|
if (typeof parsed.projectRoot !== "string" || parsed.projectRoot.trim() === "") {
|
|
19560
19354
|
return void 0;
|
|
19561
19355
|
}
|
|
@@ -19582,9 +19376,9 @@ function decideIssueScope(input) {
|
|
|
19582
19376
|
}
|
|
19583
19377
|
async function resolveSessionFile(runDirectory) {
|
|
19584
19378
|
try {
|
|
19585
|
-
const raw = await
|
|
19379
|
+
const raw = await readFile19(join35(runDirectory, "invocation.json"), "utf8");
|
|
19586
19380
|
const parsed = JSON.parse(raw);
|
|
19587
|
-
if (
|
|
19381
|
+
if (isRecord14(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
19588
19382
|
return parsed.sessionFile;
|
|
19589
19383
|
}
|
|
19590
19384
|
} catch (error) {
|
|
@@ -19861,7 +19655,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
19861
19655
|
throw error;
|
|
19862
19656
|
}
|
|
19863
19657
|
for (const runDirectory of runDirectories) {
|
|
19864
|
-
const runName =
|
|
19658
|
+
const runName = basename8(runDirectory);
|
|
19865
19659
|
const parsed = parseRunDirectoryName2(runName);
|
|
19866
19660
|
if (parsed === void 0) continue;
|
|
19867
19661
|
let scopeFields;
|
|
@@ -19922,7 +19716,7 @@ var init_analyst_ledger = __esm({
|
|
|
19922
19716
|
});
|
|
19923
19717
|
|
|
19924
19718
|
// src/analyst-metric-families/acceptance-success-rework.ts
|
|
19925
|
-
function
|
|
19719
|
+
function isRecord15(value) {
|
|
19926
19720
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19927
19721
|
}
|
|
19928
19722
|
function wallMsFromSpan(span) {
|
|
@@ -19931,21 +19725,21 @@ function wallMsFromSpan(span) {
|
|
|
19931
19725
|
function findCollectorGroups(body) {
|
|
19932
19726
|
if (Array.isArray(body.groups)) return body.groups;
|
|
19933
19727
|
const receipt = body.receipt;
|
|
19934
|
-
if (
|
|
19728
|
+
if (isRecord15(receipt) && Array.isArray(receipt.groups)) return receipt.groups;
|
|
19935
19729
|
const outcome = body.outcome;
|
|
19936
|
-
if (
|
|
19730
|
+
if (isRecord15(outcome)) {
|
|
19937
19731
|
const facts = outcome.decisiveFacts;
|
|
19938
|
-
if (
|
|
19732
|
+
if (isRecord15(facts) && Array.isArray(facts.groups)) return facts.groups;
|
|
19939
19733
|
}
|
|
19940
19734
|
return void 0;
|
|
19941
19735
|
}
|
|
19942
19736
|
function extractStatus(body) {
|
|
19943
19737
|
const outcome = body.outcome;
|
|
19944
|
-
if (
|
|
19738
|
+
if (isRecord15(outcome) && typeof outcome.status === "string" && outcome.status.trim() !== "") {
|
|
19945
19739
|
return outcome.status;
|
|
19946
19740
|
}
|
|
19947
19741
|
const receipt = body.receipt;
|
|
19948
|
-
if (
|
|
19742
|
+
if (isRecord15(receipt) && typeof receipt.status === "string" && receipt.status.trim() !== "") {
|
|
19949
19743
|
return receipt.status;
|
|
19950
19744
|
}
|
|
19951
19745
|
if (typeof body.status === "string" && body.status.trim() !== "") {
|
|
@@ -20571,15 +20365,15 @@ var init_leg_wall_clock = __esm({
|
|
|
20571
20365
|
});
|
|
20572
20366
|
|
|
20573
20367
|
// src/analyst-metric-families/round-timeline.ts
|
|
20574
|
-
function
|
|
20368
|
+
function isRecord16(value) {
|
|
20575
20369
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20576
20370
|
}
|
|
20577
20371
|
function wallMsFromSpan2(startedAt, endedAt) {
|
|
20578
20372
|
return Date.parse(endedAt) - Date.parse(startedAt);
|
|
20579
20373
|
}
|
|
20580
20374
|
function readClassCount(body) {
|
|
20581
|
-
if (!
|
|
20582
|
-
if (!
|
|
20375
|
+
if (!isRecord16(body.outcome)) return void 0;
|
|
20376
|
+
if (!isRecord16(body.outcome.decisiveFacts)) return void 0;
|
|
20583
20377
|
const classCount = body.outcome.decisiveFacts.classCount;
|
|
20584
20378
|
if (typeof classCount !== "number" || !Number.isFinite(classCount)) {
|
|
20585
20379
|
return void 0;
|
|
@@ -20723,7 +20517,7 @@ var init_analyst_metric_family = __esm({
|
|
|
20723
20517
|
});
|
|
20724
20518
|
|
|
20725
20519
|
// src/analyst-page.ts
|
|
20726
|
-
import { createHash as
|
|
20520
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
20727
20521
|
import { dirname as dirname19, join as join36 } from "node:path";
|
|
20728
20522
|
function analystIssuePageKey(address) {
|
|
20729
20523
|
const parts = ["book", address.bookKey];
|
|
@@ -20732,7 +20526,7 @@ function analystIssuePageKey(address) {
|
|
|
20732
20526
|
} else if (address.scopeRootIdentity !== void 0) {
|
|
20733
20527
|
parts.push("root", physicalPathIdentity(address.scopeRootIdentity));
|
|
20734
20528
|
}
|
|
20735
|
-
return
|
|
20529
|
+
return createHash7("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
20736
20530
|
}
|
|
20737
20531
|
function analystIssuePagePath(ledgerHome, address) {
|
|
20738
20532
|
return join36(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
@@ -20871,7 +20665,7 @@ var init_analyst_page = __esm({
|
|
|
20871
20665
|
});
|
|
20872
20666
|
|
|
20873
20667
|
// src/analyst-entry.ts
|
|
20874
|
-
import { readFile as
|
|
20668
|
+
import { readFile as readFile20 } from "node:fs/promises";
|
|
20875
20669
|
import { Type as Type11 } from "typebox";
|
|
20876
20670
|
function isMissingPathError7(error) {
|
|
20877
20671
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
@@ -20902,7 +20696,7 @@ async function readOrComputeAnalystIssuePage(input, options) {
|
|
|
20902
20696
|
...issueNumber === void 0 && input.bookKey === void 0 ? { scopeRootIdentity: projectRoot } : {}
|
|
20903
20697
|
});
|
|
20904
20698
|
try {
|
|
20905
|
-
const raw = await
|
|
20699
|
+
const raw = await readFile20(pagePath, "utf8");
|
|
20906
20700
|
const page = JSON.parse(raw);
|
|
20907
20701
|
if (cachedPageMatchesRequestedScope(page, { bookKey, ...input })) {
|
|
20908
20702
|
const ghostScan = await scanAnalystIssueRuns({
|
|
@@ -21003,7 +20797,7 @@ async function runAnalystModelGroupsMode(input, home) {
|
|
|
21003
20797
|
scopeRootIdentity: projectRoot
|
|
21004
20798
|
});
|
|
21005
20799
|
try {
|
|
21006
|
-
const raw = await
|
|
20800
|
+
const raw = await readFile20(pagePath, "utf8");
|
|
21007
20801
|
JSON.parse(raw);
|
|
21008
20802
|
} catch (error) {
|
|
21009
20803
|
if (!isMissingPathError7(error)) {
|
|
@@ -21101,7 +20895,7 @@ var init_analyst_entry = __esm({
|
|
|
21101
20895
|
});
|
|
21102
20896
|
|
|
21103
20897
|
// src/public-cli/analyst-run.ts
|
|
21104
|
-
import { readFile as
|
|
20898
|
+
import { readFile as readFile21 } from "node:fs/promises";
|
|
21105
20899
|
import { isAbsolute as isAbsolute10, resolve as resolve14 } from "node:path";
|
|
21106
20900
|
import { Value as Value2 } from "typebox/value";
|
|
21107
20901
|
function resolveAnalystIssueBookKeyFromCwd(cwd = process.cwd()) {
|
|
@@ -21155,7 +20949,7 @@ async function buildAnalystSweepModeInputFromAttachmentPaths(attachmentPaths) {
|
|
|
21155
20949
|
const absolute = isAbsolute10(sourcePath) ? sourcePath : resolve14(sourcePath);
|
|
21156
20950
|
let bytes;
|
|
21157
20951
|
try {
|
|
21158
|
-
bytes = await
|
|
20952
|
+
bytes = await readFile21(absolute);
|
|
21159
20953
|
} catch (error) {
|
|
21160
20954
|
throw new CliUsageError(
|
|
21161
20955
|
`analyst sweep attachment is not a readable regular file: ${sourcePath}`,
|
|
@@ -21274,7 +21068,7 @@ __export(cli_exports, {
|
|
|
21274
21068
|
resolveInternalRoleEntrypoint: () => resolveInternalRoleEntrypoint,
|
|
21275
21069
|
runAkRole: () => runAkRole
|
|
21276
21070
|
});
|
|
21277
|
-
import { realpath as
|
|
21071
|
+
import { realpath as realpath5 } from "node:fs/promises";
|
|
21278
21072
|
import { join as join37 } from "node:path";
|
|
21279
21073
|
function publicSeatArgv(owner) {
|
|
21280
21074
|
return {
|
|
@@ -21949,7 +21743,7 @@ async function runAkRole(argv, env) {
|
|
|
21949
21743
|
try {
|
|
21950
21744
|
env = {
|
|
21951
21745
|
...env,
|
|
21952
|
-
packageRoot: await
|
|
21746
|
+
packageRoot: await realpath5(env.packageRoot),
|
|
21953
21747
|
principalAuthority: env.principalAuthority ?? piDurablePrincipalAuthority
|
|
21954
21748
|
};
|
|
21955
21749
|
let parsed = parseArgv(argv);
|
|
@@ -21998,6 +21792,10 @@ async function runAkRole(argv, env) {
|
|
|
21998
21792
|
exitCode: await runConfigCommand(parsed.args, home, env.packageRoot, io)
|
|
21999
21793
|
};
|
|
22000
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
|
+
}
|
|
22001
21799
|
if (parsed.command === "new") {
|
|
22002
21800
|
const role = parsed.args[0];
|
|
22003
21801
|
if (role === void 0) {
|
|
@@ -22121,6 +21919,7 @@ var init_cli = __esm({
|
|
|
22121
21919
|
init_packaged_role_registry();
|
|
22122
21920
|
init_registry();
|
|
22123
21921
|
init_cli_errors();
|
|
21922
|
+
init_machine_method_skills();
|
|
22124
21923
|
init_role_turn_host();
|
|
22125
21924
|
init_role_turn_host_resolution();
|
|
22126
21925
|
init_invocation();
|
|
@@ -22155,7 +21954,7 @@ __export(public_role_summons_exports, {
|
|
|
22155
21954
|
});
|
|
22156
21955
|
import { execFile as execFile3 } from "node:child_process";
|
|
22157
21956
|
import { existsSync as existsSync9 } from "node:fs";
|
|
22158
|
-
import { realpath as
|
|
21957
|
+
import { realpath as realpath6 } from "node:fs/promises";
|
|
22159
21958
|
import { join as join38 } from "node:path";
|
|
22160
21959
|
import { promisify as promisify3 } from "node:util";
|
|
22161
21960
|
function createCapturingIo() {
|
|
@@ -22444,8 +22243,8 @@ function withReviewerLens(argv, lens) {
|
|
|
22444
22243
|
return [...argv.slice(0, separator), "--lens", lens, ...argv.slice(separator)];
|
|
22445
22244
|
}
|
|
22446
22245
|
async function resolveReviewerGitToplevel(projectRoot) {
|
|
22447
|
-
const callerProjectRoot = await
|
|
22448
|
-
return await
|
|
22246
|
+
const callerProjectRoot = await realpath6(projectRoot);
|
|
22247
|
+
return await realpath6((await execFileAsync3(
|
|
22449
22248
|
"git",
|
|
22450
22249
|
["rev-parse", "--show-toplevel"],
|
|
22451
22250
|
{ cwd: callerProjectRoot }
|
|
@@ -22801,7 +22600,7 @@ var init_compliance_transport = __esm({
|
|
|
22801
22600
|
});
|
|
22802
22601
|
|
|
22803
22602
|
// src/archivist-record-topology.ts
|
|
22804
|
-
import { createHash as
|
|
22603
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
22805
22604
|
import { join as join39 } from "node:path";
|
|
22806
22605
|
function resolveNavigatorWorkSubjectPlacement(input) {
|
|
22807
22606
|
let ledgerHome;
|
|
@@ -22812,7 +22611,7 @@ function resolveNavigatorWorkSubjectPlacement(input) {
|
|
|
22812
22611
|
}
|
|
22813
22612
|
}
|
|
22814
22613
|
ledgerHome ??= resolveActivationLedgerHome(input.home);
|
|
22815
|
-
const digest =
|
|
22614
|
+
const digest = createHash8("sha256").update(input.subject).digest("hex").slice(0, 32);
|
|
22816
22615
|
return {
|
|
22817
22616
|
ledgerHome,
|
|
22818
22617
|
sessionDir: join39(
|
|
@@ -22885,7 +22684,7 @@ import {
|
|
|
22885
22684
|
readFileSync as readFileSync4,
|
|
22886
22685
|
readSync,
|
|
22887
22686
|
realpathSync as realpathSync2,
|
|
22888
|
-
statSync as
|
|
22687
|
+
statSync as statSync5,
|
|
22889
22688
|
writeFileSync as writeFileSync2
|
|
22890
22689
|
} from "node:fs";
|
|
22891
22690
|
import { dirname as dirname20, resolve as resolve15, join as join40 } from "node:path";
|
|
@@ -23012,7 +22811,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
|
|
|
23012
22811
|
const filePath = join40(absoluteSessionDir, name);
|
|
23013
22812
|
let st;
|
|
23014
22813
|
try {
|
|
23015
|
-
st =
|
|
22814
|
+
st = statSync5(filePath);
|
|
23016
22815
|
} catch (error) {
|
|
23017
22816
|
throw new ActivationLedgerError(
|
|
23018
22817
|
`archivist navigator session file is not stat-able (${filePath}): ${errorText(error)}`,
|
|
@@ -23206,7 +23005,7 @@ import { randomUUID as randomUUID11 } from "node:crypto";
|
|
|
23206
23005
|
|
|
23207
23006
|
// src/role-runtime-dependencies.ts
|
|
23208
23007
|
init_collector_github();
|
|
23209
|
-
import { readFile as
|
|
23008
|
+
import { readFile as readFile24 } from "node:fs/promises";
|
|
23210
23009
|
import { join as join44 } from "node:path";
|
|
23211
23010
|
|
|
23212
23011
|
// src/doctor-auditor.ts
|
|
@@ -23235,7 +23034,7 @@ function createPiDoctorAuditor() {
|
|
|
23235
23034
|
init_doctor_evidence();
|
|
23236
23035
|
|
|
23237
23036
|
// src/navigator-attendance.ts
|
|
23238
|
-
import { createHash as
|
|
23037
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
23239
23038
|
init_navigator_invocation_identity();
|
|
23240
23039
|
init_packaged_role_registry();
|
|
23241
23040
|
init_activation_ledger_topology();
|
|
@@ -23245,7 +23044,7 @@ import { Type as Type13 } from "typebox";
|
|
|
23245
23044
|
|
|
23246
23045
|
// src/navigator-public-session.ts
|
|
23247
23046
|
init_sitian_facade();
|
|
23248
|
-
import { basename as
|
|
23047
|
+
import { basename as basename9 } from "node:path";
|
|
23249
23048
|
|
|
23250
23049
|
// src/navigator-session-contracts.ts
|
|
23251
23050
|
import { Type as Type12 } from "typebox";
|
|
@@ -23454,7 +23253,7 @@ function exactRecord2(value) {
|
|
|
23454
23253
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23455
23254
|
}
|
|
23456
23255
|
function runIdFromNavigatorDirectory(runDirectory) {
|
|
23457
|
-
const entry =
|
|
23256
|
+
const entry = basename9(runDirectory);
|
|
23458
23257
|
const suffix = "@navigator";
|
|
23459
23258
|
if (!entry.endsWith(suffix)) return void 0;
|
|
23460
23259
|
const runId = entry.slice(0, entry.length - suffix.length);
|
|
@@ -23683,7 +23482,7 @@ function navigatorSubjectKey(subjectRoot, subject, provenance = "role_input") {
|
|
|
23683
23482
|
if (provenance === "placeholder") return subjectRoot;
|
|
23684
23483
|
const normalized = subject.trim().replace(/\s+/g, " ");
|
|
23685
23484
|
if (normalized === "") return subjectRoot;
|
|
23686
|
-
return `${subjectRoot}#${
|
|
23485
|
+
return `${subjectRoot}#${createHash9("sha256").update(normalized).digest("hex").slice(0, 32)}`;
|
|
23687
23486
|
}
|
|
23688
23487
|
function navigatorSubjectKeyForInput(subjectRoot, reference, cwd = process.cwd()) {
|
|
23689
23488
|
if (issueRoot(subjectRoot) !== void 0 || !subjectRoot.includes("/.ak/work/")) return subjectRoot;
|
|
@@ -24199,7 +23998,7 @@ ${helpContext}
|
|
|
24199
23998
|
// src/navigator-work-context.ts
|
|
24200
23999
|
init_doctor_evidence();
|
|
24201
24000
|
init_host_contracts();
|
|
24202
|
-
import { readFile as
|
|
24001
|
+
import { readFile as readFile22 } from "node:fs/promises";
|
|
24203
24002
|
import { resolve as resolve17 } from "node:path";
|
|
24204
24003
|
init_notary_source_run();
|
|
24205
24004
|
init_packaged_role_registry();
|
|
@@ -24213,7 +24012,7 @@ function navigatorInputReference(getFlag, role) {
|
|
|
24213
24012
|
async function loadNavigatorWorkContext(options) {
|
|
24214
24013
|
const reference = navigatorInputReference(options.getFlag, options.role);
|
|
24215
24014
|
const subjectMode = packagedNavigatorSubject(options.role);
|
|
24216
|
-
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");
|
|
24217
24016
|
const subjectRoot = subjectPath(reference ?? options.context.sessionManager.getSessionDir(), options.context.cwd);
|
|
24218
24017
|
let subjectKey = reference === void 0 ? subjectRoot : navigatorSubjectKeyForInput(subjectRoot, reference, options.context.cwd);
|
|
24219
24018
|
let subject = input ?? `work subject: ${subjectKey}`;
|
|
@@ -24270,7 +24069,7 @@ async function loadNavigatorWorkContext(options) {
|
|
|
24270
24069
|
let authorityMaterial;
|
|
24271
24070
|
for (const path of authorityFiles) {
|
|
24272
24071
|
try {
|
|
24273
|
-
const content = await
|
|
24072
|
+
const content = await readFile22(path, "utf8");
|
|
24274
24073
|
if (content.trim() !== "") {
|
|
24275
24074
|
authorityMaterial = content;
|
|
24276
24075
|
break;
|
|
@@ -24294,52 +24093,6 @@ async function loadNavigatorWorkContext(options) {
|
|
|
24294
24093
|
// src/role-runtime-dependencies.ts
|
|
24295
24094
|
init_notary_source_run();
|
|
24296
24095
|
|
|
24297
|
-
// src/package-resources/method-skill-binding.ts
|
|
24298
|
-
import { dirname as dirname23 } from "node:path";
|
|
24299
|
-
|
|
24300
|
-
// src/canonical-skill-binding.ts
|
|
24301
|
-
import { dirname as dirname22, resolve as resolve18 } from "node:path";
|
|
24302
|
-
import { stripFrontmatter } from "@earendil-works/pi-coding-agent";
|
|
24303
|
-
function captureCanonicalSkillExpansion(name, snapshot, configuredPath, evidence, originalRequest) {
|
|
24304
|
-
const matchedPath = evidence?.location === configuredPath ? configuredPath : evidence?.location === snapshot.path ? snapshot.path : void 0;
|
|
24305
|
-
const expectedContent = matchedPath === void 0 ? void 0 : snapshot.body;
|
|
24306
|
-
const prefixedContent = matchedPath === void 0 ? void 0 : `References are relative to ${dirname22(matchedPath)}.
|
|
24307
|
-
|
|
24308
|
-
${snapshot.body}`;
|
|
24309
|
-
if (evidence?.name !== name || matchedPath === void 0 || evidence.content !== expectedContent && evidence.content !== prefixedContent || evidence.userMessage !== originalRequest) {
|
|
24310
|
-
return void 0;
|
|
24311
|
-
}
|
|
24312
|
-
return Object.freeze({ ...evidence, name });
|
|
24313
|
-
}
|
|
24314
|
-
|
|
24315
|
-
// src/package-resources/method-skill-binding.ts
|
|
24316
|
-
init_method_skill();
|
|
24317
|
-
async function loadPackagedCanonicalSkillBinding(packageRoot, name) {
|
|
24318
|
-
const material = await loadPackagedMethodSkillMaterial(packageRoot, name);
|
|
24319
|
-
const configuredPath = resolvePackagedMethodSkillPath(packageRoot, name);
|
|
24320
|
-
const snapshot = Object.freeze({
|
|
24321
|
-
raw: material.raw,
|
|
24322
|
-
path: material.skillPath,
|
|
24323
|
-
baseDir: dirname23(material.skillPath),
|
|
24324
|
-
body: material.body,
|
|
24325
|
-
snapshotIdentity: Object.freeze({ text: material.raw })
|
|
24326
|
-
});
|
|
24327
|
-
const binding = {
|
|
24328
|
-
name,
|
|
24329
|
-
snapshot,
|
|
24330
|
-
captureExpansion(evidence, originalRequest) {
|
|
24331
|
-
return captureCanonicalSkillExpansion(
|
|
24332
|
-
name,
|
|
24333
|
-
snapshot,
|
|
24334
|
-
configuredPath,
|
|
24335
|
-
evidence,
|
|
24336
|
-
originalRequest
|
|
24337
|
-
);
|
|
24338
|
-
}
|
|
24339
|
-
};
|
|
24340
|
-
return Object.freeze(binding);
|
|
24341
|
-
}
|
|
24342
|
-
|
|
24343
24096
|
// src/role-runtime.ts
|
|
24344
24097
|
init_readable_gate_item();
|
|
24345
24098
|
init_host_contracts();
|
|
@@ -24396,10 +24149,10 @@ init_activation_ledger_topology();
|
|
|
24396
24149
|
import {
|
|
24397
24150
|
lstatSync as lstatSync2,
|
|
24398
24151
|
realpathSync as realpathSync3,
|
|
24399
|
-
statSync as
|
|
24152
|
+
statSync as statSync6,
|
|
24400
24153
|
writeFileSync as writeFileSync3
|
|
24401
24154
|
} from "node:fs";
|
|
24402
|
-
import { isAbsolute as isAbsolute11, resolve as
|
|
24155
|
+
import { isAbsolute as isAbsolute11, resolve as resolve18 } from "node:path";
|
|
24403
24156
|
var ActivationSessionFileMissingError = class extends Error {
|
|
24404
24157
|
code = "AK_ACTIVATION_SESSION_FILE_MISSING";
|
|
24405
24158
|
path;
|
|
@@ -24444,7 +24197,7 @@ function durableSessionPointer(sessionManager) {
|
|
|
24444
24197
|
`Workflow role activation requires an absolute durable session file path; got relative path: ${file}`
|
|
24445
24198
|
);
|
|
24446
24199
|
}
|
|
24447
|
-
const resolvedFile =
|
|
24200
|
+
const resolvedFile = resolve18(file);
|
|
24448
24201
|
try {
|
|
24449
24202
|
lstatSync2(resolvedFile);
|
|
24450
24203
|
} catch (error) {
|
|
@@ -24471,7 +24224,7 @@ function durableSessionPointer(sessionManager) {
|
|
|
24471
24224
|
}
|
|
24472
24225
|
let info;
|
|
24473
24226
|
try {
|
|
24474
|
-
info =
|
|
24227
|
+
info = statSync6(realFile);
|
|
24475
24228
|
} catch (error) {
|
|
24476
24229
|
throw new Error(
|
|
24477
24230
|
`Workflow role activation failed to stat durable session file (${realFile}): ${errorText(error)}`,
|
|
@@ -24780,7 +24533,7 @@ init_collector_github();
|
|
|
24780
24533
|
// src/collector-handbook.ts
|
|
24781
24534
|
init_atomic_write();
|
|
24782
24535
|
init_activation_ledger_topology();
|
|
24783
|
-
import { readFile as
|
|
24536
|
+
import { readFile as readFile23 } from "node:fs/promises";
|
|
24784
24537
|
import { join as join42, sep as sep6 } from "node:path";
|
|
24785
24538
|
|
|
24786
24539
|
// src/collector-tool-schemas.ts
|
|
@@ -24924,7 +24677,7 @@ function createCollectorHandbookStore(input) {
|
|
|
24924
24677
|
ensureRealDirectoryTree(input.ledgerHome, parentDir2);
|
|
24925
24678
|
assertLedgerFileInsideHome(path, input.ledgerHome);
|
|
24926
24679
|
try {
|
|
24927
|
-
const body = await
|
|
24680
|
+
const body = await readFile23(path, "utf8");
|
|
24928
24681
|
assertHandbookBudget(body, "\u6B63\u6587");
|
|
24929
24682
|
return body;
|
|
24930
24683
|
} catch (error) {
|
|
@@ -26087,7 +25840,6 @@ var reviewerOutputSchema = withTerminatingOutputDeclarations(
|
|
|
26087
25840
|
);
|
|
26088
25841
|
function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
|
|
26089
25842
|
let soul;
|
|
26090
|
-
let binding;
|
|
26091
25843
|
let registered = false;
|
|
26092
25844
|
let fixedBaseRevision;
|
|
26093
25845
|
return {
|
|
@@ -26095,9 +25847,6 @@ function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
|
|
|
26095
25847
|
soul = (await dependencies.loadSoul()).trim();
|
|
26096
25848
|
if (!soul) throw new Error("Reviewer soul is empty");
|
|
26097
25849
|
fixedBaseRevision = admitted.baseRevision;
|
|
26098
|
-
const loaded = await dependencies.loadCanonicalSkillBinding("ak-cross-m-review");
|
|
26099
|
-
if (loaded.name !== "ak-cross-m-review") throw new Error("Canonical Skill binding loader returned tdd for ak-cross-m-review");
|
|
26100
|
-
binding = loaded;
|
|
26101
25850
|
if (!registered) {
|
|
26102
25851
|
registered = true;
|
|
26103
25852
|
pi.registerTool({
|
|
@@ -26107,7 +25856,7 @@ function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
|
|
|
26107
25856
|
promptSnippet: "\u63D0\u4EA4\u5FA1\u53F2\u53F0\u7EC8\u5C40\u56DE\u6267",
|
|
26108
25857
|
parameters: reviewerOutputSchema,
|
|
26109
25858
|
async execute(_id, parameters) {
|
|
26110
|
-
if (!soul
|
|
25859
|
+
if (!soul) throw new Error("\u5FA1\u53F2\u53F0\u8F93\u5165\u672A\u88C5\u8F7D");
|
|
26111
25860
|
return {
|
|
26112
25861
|
content: [],
|
|
26113
25862
|
details: parameters,
|
|
@@ -26118,11 +25867,9 @@ function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
|
|
|
26118
25867
|
}
|
|
26119
25868
|
const activatedSoul = soul;
|
|
26120
25869
|
const activatedBase = fixedBaseRevision;
|
|
26121
|
-
const activatedBinding = binding;
|
|
26122
25870
|
return Object.freeze({
|
|
26123
25871
|
fixedBaseRevision: activatedBase,
|
|
26124
|
-
soul: activatedSoul
|
|
26125
|
-
skillBinding: activatedBinding
|
|
25872
|
+
soul: activatedSoul
|
|
26126
25873
|
});
|
|
26127
25874
|
}
|
|
26128
25875
|
};
|
|
@@ -26131,7 +25878,6 @@ function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
|
|
|
26131
25878
|
// src/worker-role.ts
|
|
26132
25879
|
init_open_tool_schema();
|
|
26133
25880
|
init_terminating_infrastructure();
|
|
26134
|
-
init_submission_correctable_error();
|
|
26135
25881
|
init_readable_gate_item();
|
|
26136
25882
|
init_audit_escalation();
|
|
26137
25883
|
init_submission_errors();
|
|
@@ -26147,7 +25893,7 @@ init_submission_errors();
|
|
|
26147
25893
|
init_submission_errors();
|
|
26148
25894
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
26149
25895
|
import { existsSync as existsSync12, lstatSync as lstatSync3, readdirSync as readdirSync3, readFileSync as readFileSync5, rmdirSync, rmSync } from "node:fs";
|
|
26150
|
-
import { resolve as
|
|
25896
|
+
import { resolve as resolve19 } from "node:path";
|
|
26151
25897
|
var WORKER_SUBMISSION_GATE_RECORD_KIND = WORKER_SUBMISSION_GATE_KIND;
|
|
26152
25898
|
var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
|
|
26153
25899
|
var WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE = "commit-reminder-bounce";
|
|
@@ -26196,7 +25942,7 @@ function escapeGitConfigValueRegex(value) {
|
|
|
26196
25942
|
function unsetOwnedHooksPath(file) {
|
|
26197
25943
|
const owned = [];
|
|
26198
25944
|
for (const value of tryGetAll(file, "core.hooksPath")) {
|
|
26199
|
-
if (!ownedHook(
|
|
25945
|
+
if (!ownedHook(resolve19(value, HOOK_FILE))) continue;
|
|
26200
25946
|
try {
|
|
26201
25947
|
gitFile(file, [
|
|
26202
25948
|
"--unset-all",
|
|
@@ -26211,15 +25957,15 @@ function unsetOwnedHooksPath(file) {
|
|
|
26211
25957
|
return owned;
|
|
26212
25958
|
}
|
|
26213
25959
|
function rmOwnedDir(dir) {
|
|
26214
|
-
const hookPath =
|
|
25960
|
+
const hookPath = resolve19(dir, HOOK_FILE);
|
|
26215
25961
|
if (!ownedHook(hookPath)) return;
|
|
26216
25962
|
rmSync(hookPath, { force: true });
|
|
26217
25963
|
if (existsSync12(dir) && readdirSync3(dir).length === 0) rmdirSync(dir);
|
|
26218
25964
|
}
|
|
26219
25965
|
function linkedGitDirs(commonDir) {
|
|
26220
|
-
const root =
|
|
25966
|
+
const root = resolve19(commonDir, "worktrees");
|
|
26221
25967
|
if (!existsSync12(root)) return [];
|
|
26222
|
-
return readdirSync3(root).map((name) =>
|
|
25968
|
+
return readdirSync3(root).map((name) => resolve19(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
|
|
26223
25969
|
}
|
|
26224
25970
|
function uninstallPackageWorkerHooks(cwd) {
|
|
26225
25971
|
let inside;
|
|
@@ -26233,17 +25979,17 @@ function uninstallPackageWorkerHooks(cwd) {
|
|
|
26233
25979
|
const clear = (configFile) => {
|
|
26234
25980
|
for (const hooks of unsetOwnedHooksPath(configFile)) rmOwnedDir(hooks);
|
|
26235
25981
|
};
|
|
26236
|
-
clear(
|
|
26237
|
-
clear(
|
|
26238
|
-
rmOwnedDir(
|
|
26239
|
-
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);
|
|
26240
25986
|
if (ownedHook(legacy)) rmSync(legacy, { force: true });
|
|
26241
25987
|
for (const gitDir of linkedGitDirs(commonDir)) {
|
|
26242
|
-
clear(
|
|
26243
|
-
rmOwnedDir(
|
|
25988
|
+
clear(resolve19(gitDir, "config.worktree"));
|
|
25989
|
+
rmOwnedDir(resolve19(gitDir, HOOKS_DIR));
|
|
26244
25990
|
}
|
|
26245
25991
|
}
|
|
26246
|
-
function
|
|
25992
|
+
function isRecord17(value) {
|
|
26247
25993
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26248
25994
|
}
|
|
26249
25995
|
function unfinishedReasonPresent(details) {
|
|
@@ -26259,7 +26005,7 @@ function readGateState(session) {
|
|
|
26259
26005
|
if (entry.type !== "custom") continue;
|
|
26260
26006
|
if (entry.customType === WORKER_COMMIT_BASELINE_ENTRY_TYPE) {
|
|
26261
26007
|
const data = entry.data;
|
|
26262
|
-
if (
|
|
26008
|
+
if (isRecord17(data) && (data.head === null || typeof data.head === "string")) {
|
|
26263
26009
|
baseline = data.head;
|
|
26264
26010
|
}
|
|
26265
26011
|
} else if (entry.customType === WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE) {
|
|
@@ -26452,7 +26198,7 @@ var FIXER_PHASES = ["plan", "apply"];
|
|
|
26452
26198
|
function isWorkerPhase(value) {
|
|
26453
26199
|
return typeof value === "string" && FIXER_PHASES.includes(value);
|
|
26454
26200
|
}
|
|
26455
|
-
function
|
|
26201
|
+
function isRecord18(value) {
|
|
26456
26202
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26457
26203
|
}
|
|
26458
26204
|
var WORKER_ROUTING_STATUSES = /* @__PURE__ */ new Set([
|
|
@@ -26464,7 +26210,7 @@ var WORKER_ROUTING_STATUSES = /* @__PURE__ */ new Set([
|
|
|
26464
26210
|
]);
|
|
26465
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";
|
|
26466
26212
|
function workerStatusOf(output) {
|
|
26467
|
-
return
|
|
26213
|
+
return isRecord18(output) && typeof output.status === "string" ? output.status : void 0;
|
|
26468
26214
|
}
|
|
26469
26215
|
function requireReadableWorkerStatus(output) {
|
|
26470
26216
|
const status = workerStatusOf(output);
|
|
@@ -26641,10 +26387,6 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
|
|
|
26641
26387
|
let soul;
|
|
26642
26388
|
let task;
|
|
26643
26389
|
let phase;
|
|
26644
|
-
let binding;
|
|
26645
|
-
let tddInvocationInjected = false;
|
|
26646
|
-
let originalRequest;
|
|
26647
|
-
let expansionPending = false;
|
|
26648
26390
|
let lifecycleRegistered = false;
|
|
26649
26391
|
const submissionGate = createWorkerSubmissionGate();
|
|
26650
26392
|
pi.registerFlag("ak-coder-task", {
|
|
@@ -26657,9 +26399,6 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
|
|
|
26657
26399
|
});
|
|
26658
26400
|
return {
|
|
26659
26401
|
async activate(ctx) {
|
|
26660
|
-
tddInvocationInjected = false;
|
|
26661
|
-
originalRequest = void 0;
|
|
26662
|
-
expansionPending = false;
|
|
26663
26402
|
soul = (await dependencies.loadSoul()).trim();
|
|
26664
26403
|
if (soul.length === 0) throw new Error("Coder soul is empty");
|
|
26665
26404
|
const selectedPhase = pi.getFlag("ak-coder-phase");
|
|
@@ -26675,24 +26414,6 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
|
|
|
26675
26414
|
}
|
|
26676
26415
|
task = (await dependencies.loadTask(taskPath)).trim();
|
|
26677
26416
|
if (task.length === 0) throw new Error("Coder task is empty");
|
|
26678
|
-
binding = void 0;
|
|
26679
|
-
if (phase === "apply") {
|
|
26680
|
-
if (dependencies.loadCanonicalSkillBinding === void 0) {
|
|
26681
|
-
throw new Error("Coder canonical Skill binding loader is not configured");
|
|
26682
|
-
}
|
|
26683
|
-
try {
|
|
26684
|
-
const loaded = await dependencies.loadCanonicalSkillBinding("tdd");
|
|
26685
|
-
if (loaded.name !== "tdd") {
|
|
26686
|
-
throw new Error(
|
|
26687
|
-
"Canonical Skill binding loader returned ak-cross-m-review for tdd"
|
|
26688
|
-
);
|
|
26689
|
-
}
|
|
26690
|
-
binding = loaded;
|
|
26691
|
-
} catch (error) {
|
|
26692
|
-
if (ctx === void 0) throw error;
|
|
26693
|
-
hostActions.failInfrastructure(error, ctx);
|
|
26694
|
-
}
|
|
26695
|
-
}
|
|
26696
26417
|
if (!lifecycleRegistered) {
|
|
26697
26418
|
lifecycleRegistered = true;
|
|
26698
26419
|
pi.registerTool({
|
|
@@ -26747,28 +26468,8 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
|
|
|
26747
26468
|
};
|
|
26748
26469
|
}
|
|
26749
26470
|
});
|
|
26750
|
-
pi.on("input", (event) => {
|
|
26751
|
-
if (phase !== "apply" || tddInvocationInjected) {
|
|
26752
|
-
return { action: "continue" };
|
|
26753
|
-
}
|
|
26754
|
-
tddInvocationInjected = true;
|
|
26755
|
-
expansionPending = true;
|
|
26756
|
-
originalRequest = binding === void 0 ? event.text : pi.capabilities?.skillOriginalRequest?.(binding.name, event.text) ?? event.text;
|
|
26757
|
-
return { action: "continue" };
|
|
26758
|
-
});
|
|
26759
26471
|
pi.on("before_agent_start", (event, ctx2) => {
|
|
26760
26472
|
if (soul === void 0) throw new Error("\u5C06\u4F5C\u76D1\u804C\u5206\u672A\u88C5\u8F7D");
|
|
26761
|
-
if (phase === "apply") {
|
|
26762
|
-
if (binding === void 0) {
|
|
26763
|
-
hostActions.failInfrastructure(
|
|
26764
|
-
new Error("Coder canonical tdd Skill binding was not initialized"),
|
|
26765
|
-
ctx2
|
|
26766
|
-
);
|
|
26767
|
-
}
|
|
26768
|
-
if (expansionPending) {
|
|
26769
|
-
expansionPending = false;
|
|
26770
|
-
}
|
|
26771
|
-
}
|
|
26772
26473
|
return {
|
|
26773
26474
|
systemPrompt: `${event.systemPrompt}
|
|
26774
26475
|
|
|
@@ -27537,8 +27238,6 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27537
27238
|
let selectedRole;
|
|
27538
27239
|
let roleReferenceMaterials = "";
|
|
27539
27240
|
let activeReviewerParent;
|
|
27540
|
-
let reviewerOriginalRequest;
|
|
27541
|
-
let reviewerExpansionCaptured = false;
|
|
27542
27241
|
let navigatorAttendance;
|
|
27543
27242
|
let pendingNavigatorPresentation;
|
|
27544
27243
|
let pendingNavigatorSettlement;
|
|
@@ -27629,16 +27328,9 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27629
27328
|
() => receiptDelivery.recordAccepted(),
|
|
27630
27329
|
settleNavigatorProjection
|
|
27631
27330
|
);
|
|
27632
|
-
roleHost.on("input", (
|
|
27633
|
-
const text = event.text;
|
|
27331
|
+
roleHost.on("input", (_event) => {
|
|
27634
27332
|
const role = roleHost.getFlag(ROLE_FLAG.name);
|
|
27635
27333
|
if (role !== void 0 && !admitted) return { action: "handled" };
|
|
27636
|
-
if (admitted && activeReviewerParent !== void 0 && selectedRole === role && reviewerOriginalRequest === void 0) {
|
|
27637
|
-
reviewerOriginalRequest = roleHost.capabilities?.skillOriginalRequest?.(
|
|
27638
|
-
activeReviewerParent.skillBinding.name,
|
|
27639
|
-
text
|
|
27640
|
-
) ?? text;
|
|
27641
|
-
}
|
|
27642
27334
|
return { action: "continue" };
|
|
27643
27335
|
});
|
|
27644
27336
|
roleHost.on("before_agent_start", () => roleReferenceMaterials === "" ? void 0 : { readingMaterial: { kind: "role-reference-materials", content: roleReferenceMaterials } });
|
|
@@ -27675,15 +27367,6 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27675
27367
|
}
|
|
27676
27368
|
navigatorAttendance?.prepare();
|
|
27677
27369
|
if (activeReviewerParent !== void 0 && selectedRole === role) {
|
|
27678
|
-
if (!reviewerExpansionCaptured) {
|
|
27679
|
-
if (reviewerOriginalRequest !== void 0) {
|
|
27680
|
-
activeReviewerParent.skillBinding.captureExpansion(
|
|
27681
|
-
roleHost.capabilities?.skillExpansion(prompt),
|
|
27682
|
-
reviewerOriginalRequest
|
|
27683
|
-
);
|
|
27684
|
-
}
|
|
27685
|
-
reviewerExpansionCaptured = true;
|
|
27686
|
-
}
|
|
27687
27370
|
return {
|
|
27688
27371
|
systemPrompt: assembleReviewerParentSystemPrompt({
|
|
27689
27372
|
baseSystemPrompt: event.systemPrompt,
|
|
@@ -27956,9 +27639,6 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27956
27639
|
throw new Error("Coder task loader is not configured");
|
|
27957
27640
|
}
|
|
27958
27641
|
return dependencies.loadCoderTask(path);
|
|
27959
|
-
},
|
|
27960
|
-
...dependencies.loadCanonicalSkillBinding === void 0 ? {} : {
|
|
27961
|
-
loadCanonicalSkillBinding: (name) => dependencies.loadCanonicalSkillBinding(name)
|
|
27962
27642
|
}
|
|
27963
27643
|
},
|
|
27964
27644
|
hostActions
|
|
@@ -27966,13 +27646,7 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27966
27646
|
const reviewer = createReviewerRoleRuntime(
|
|
27967
27647
|
roleHost,
|
|
27968
27648
|
{
|
|
27969
|
-
loadSoul: () => requireRoleSoul("reviewer")
|
|
27970
|
-
async loadCanonicalSkillBinding(name) {
|
|
27971
|
-
if (dependencies.loadCanonicalSkillBinding === void 0) {
|
|
27972
|
-
throw new Error("Reviewer runtime dependencies are not configured");
|
|
27973
|
-
}
|
|
27974
|
-
return dependencies.loadCanonicalSkillBinding(name);
|
|
27975
|
-
}
|
|
27649
|
+
loadSoul: () => requireRoleSoul("reviewer")
|
|
27976
27650
|
},
|
|
27977
27651
|
hostActions
|
|
27978
27652
|
);
|
|
@@ -28207,8 +27881,6 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
28207
27881
|
activeReviewerParent = void 0;
|
|
28208
27882
|
activeCollector = void 0;
|
|
28209
27883
|
collectorFirstDispatchDone = false;
|
|
28210
|
-
reviewerOriginalRequest = void 0;
|
|
28211
|
-
reviewerExpansionCaptured = false;
|
|
28212
27884
|
receiptDelivery = createReceiptDeliveryPolicy();
|
|
28213
27885
|
noReceiptRecorded = false;
|
|
28214
27886
|
observationFace.reset();
|
|
@@ -28372,25 +28044,13 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
28372
28044
|
packageRoot,
|
|
28373
28045
|
loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
|
|
28374
28046
|
loadRoleSoul: loadRegisteredRoleSoul,
|
|
28375
|
-
loadFixPacket: (path) =>
|
|
28376
|
-
loadCoderTask: (path) =>
|
|
28377
|
-
loadCollectorHandbookSeed: () =>
|
|
28047
|
+
loadFixPacket: (path) => readFile24(path, "utf8"),
|
|
28048
|
+
loadCoderTask: (path) => readFile24(path, "utf8"),
|
|
28049
|
+
loadCollectorHandbookSeed: () => readFile24(collectorHandbookSeedPath, "utf8"),
|
|
28378
28050
|
createCollectorTransport: () => createGhCollectorGitHubTransport(),
|
|
28379
28051
|
loadDoctorCase,
|
|
28380
28052
|
loadNotarySourceRun: loadNotarySourceRunLocator,
|
|
28381
|
-
loadMergerInput: async (path) => JSON.parse(await
|
|
28382
|
-
async loadCanonicalSkillBinding(name) {
|
|
28383
|
-
switch (name) {
|
|
28384
|
-
case "tdd":
|
|
28385
|
-
return loadPackagedCanonicalSkillBinding(packageRoot, name);
|
|
28386
|
-
case "ak-cross-m-review":
|
|
28387
|
-
return loadPackagedCanonicalSkillBinding(packageRoot, name);
|
|
28388
|
-
default: {
|
|
28389
|
-
const unexpected = name;
|
|
28390
|
-
throw new Error(`Canonical skill is not packaged: ${String(unexpected)}`);
|
|
28391
|
-
}
|
|
28392
|
-
}
|
|
28393
|
-
},
|
|
28053
|
+
loadMergerInput: async (path) => JSON.parse(await readFile24(path, "utf8")),
|
|
28394
28054
|
// #590: doctor compliance still on disposeCompliance path; judge→auditor is gate queue (#756).
|
|
28395
28055
|
auditDoctorCompliance: (options) => doctorAuditor(options),
|
|
28396
28056
|
loadNavigatorWorkContext: (options) => loadNavigatorWorkContext({
|
|
@@ -28407,7 +28067,7 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
28407
28067
|
authority: options.authority,
|
|
28408
28068
|
invocationId: options.invocationId,
|
|
28409
28069
|
loadSoul: () => loadRegisteredRoleSoul("navigator"),
|
|
28410
|
-
loadRoutePlaybook: () =>
|
|
28070
|
+
loadRoutePlaybook: () => readFile24(navigatorRoutePlaybookPath, "utf8"),
|
|
28411
28071
|
loadRoleHelp: async (role) => formatNavigatorRoleHelp(role),
|
|
28412
28072
|
createSession: navigatorSessionFactory,
|
|
28413
28073
|
...options.contextError === void 0 ? {} : { contextError: options.contextError },
|
|
@@ -28421,7 +28081,7 @@ init_engine_detour();
|
|
|
28421
28081
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
28422
28082
|
import { appendFile as appendFile3, mkdir as mkdir5, writeFile as writeFile11 } from "node:fs/promises";
|
|
28423
28083
|
import { createServer } from "node:net";
|
|
28424
|
-
import { dirname as
|
|
28084
|
+
import { dirname as dirname22, join as join45 } from "node:path";
|
|
28425
28085
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
28426
28086
|
|
|
28427
28087
|
// src/submission-gate.ts
|
|
@@ -28525,141 +28185,6 @@ async function requireSubmissionGate(options) {
|
|
|
28525
28185
|
}
|
|
28526
28186
|
}
|
|
28527
28187
|
|
|
28528
|
-
// src/host-native-method.ts
|
|
28529
|
-
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";
|
|
28530
|
-
import { basename as basename11, dirname as dirname24, join as join45 } from "node:path";
|
|
28531
|
-
var HOST_METHOD_PLUGIN_NAME = "ak-methods";
|
|
28532
|
-
var packagedMethodsDir = (root) => join45(root, "resources", "methods");
|
|
28533
|
-
var packagedMethodPluginDir = (root) => join45(root, "dist", "method-host-plugin");
|
|
28534
|
-
function hostMethodSkills(methods) {
|
|
28535
|
-
return Object.freeze(methods.flatMap((method) => {
|
|
28536
|
-
if (method.kind !== "skill") return [];
|
|
28537
|
-
const name = basename11(dirname24(method.path));
|
|
28538
|
-
return name ? [Object.freeze({ name })] : [];
|
|
28539
|
-
}));
|
|
28540
|
-
}
|
|
28541
|
-
var alreadyPrefixed = (prompt, token) => {
|
|
28542
|
-
const text = prompt.trimStart();
|
|
28543
|
-
return text === token || text.startsWith(`${token} `) || text.startsWith(`${token}
|
|
28544
|
-
`);
|
|
28545
|
-
};
|
|
28546
|
-
function prefixMethodInvocation(token, prompt) {
|
|
28547
|
-
if (alreadyPrefixed(prompt, token)) return prompt;
|
|
28548
|
-
return prompt ? `${token} ${prompt}` : token;
|
|
28549
|
-
}
|
|
28550
|
-
function applyClaudeSkillInvocation(methods, prompt) {
|
|
28551
|
-
const skills = hostMethodSkills(methods);
|
|
28552
|
-
if (skills.length !== 1) return prompt;
|
|
28553
|
-
return prefixMethodInvocation(`/${HOST_METHOD_PLUGIN_NAME}:${skills[0].name}`, prompt);
|
|
28554
|
-
}
|
|
28555
|
-
function applyCodexSkillInvocation(methods, prompt) {
|
|
28556
|
-
return hostMethodSkills(methods).reduceRight(
|
|
28557
|
-
(invocation, skill) => prefixMethodInvocation(`$${skill.name}`, invocation),
|
|
28558
|
-
prompt
|
|
28559
|
-
);
|
|
28560
|
-
}
|
|
28561
|
-
var isEnoent3 = (error) => error.code === "ENOENT";
|
|
28562
|
-
async function packagedMethodSkillNames(packagedMethodsRealpath) {
|
|
28563
|
-
const entries = await readdir9(packagedMethodsRealpath, { withFileTypes: true });
|
|
28564
|
-
const names = [];
|
|
28565
|
-
for (const entry of entries) {
|
|
28566
|
-
if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
|
|
28567
|
-
try {
|
|
28568
|
-
await access4(join45(packagedMethodsRealpath, entry.name, "SKILL.md"));
|
|
28569
|
-
} catch (error) {
|
|
28570
|
-
if (isEnoent3(error)) continue;
|
|
28571
|
-
throw error;
|
|
28572
|
-
}
|
|
28573
|
-
names.push(entry.name);
|
|
28574
|
-
}
|
|
28575
|
-
return names;
|
|
28576
|
-
}
|
|
28577
|
-
async function packagedSkillFileBytes(skillDir) {
|
|
28578
|
-
try {
|
|
28579
|
-
await access4(join45(skillDir, "SKILL.md"));
|
|
28580
|
-
} catch (error) {
|
|
28581
|
-
if (isEnoent3(error)) return void 0;
|
|
28582
|
-
throw error;
|
|
28583
|
-
}
|
|
28584
|
-
const files = /* @__PURE__ */ new Map();
|
|
28585
|
-
async function walk(dir, prefix) {
|
|
28586
|
-
const entries = await readdir9(dir, { withFileTypes: true });
|
|
28587
|
-
for (const entry of entries) {
|
|
28588
|
-
const rel = prefix === "" ? entry.name : `${prefix}/${entry.name}`;
|
|
28589
|
-
const full = join45(dir, entry.name);
|
|
28590
|
-
if (entry.isDirectory()) {
|
|
28591
|
-
await walk(full, rel);
|
|
28592
|
-
continue;
|
|
28593
|
-
}
|
|
28594
|
-
if (entry.isFile()) {
|
|
28595
|
-
files.set(rel, await readFile26(full));
|
|
28596
|
-
}
|
|
28597
|
-
}
|
|
28598
|
-
}
|
|
28599
|
-
await walk(skillDir, "");
|
|
28600
|
-
return files;
|
|
28601
|
-
}
|
|
28602
|
-
async function catalogPublishesPackagedSkill(catalogSkillDir, required) {
|
|
28603
|
-
for (const [rel, bytes] of required) {
|
|
28604
|
-
let other;
|
|
28605
|
-
try {
|
|
28606
|
-
other = await readFile26(join45(catalogSkillDir, rel));
|
|
28607
|
-
} catch (error) {
|
|
28608
|
-
if (isEnoent3(error)) return false;
|
|
28609
|
-
throw error;
|
|
28610
|
-
}
|
|
28611
|
-
if (!bytes.equals(other)) return false;
|
|
28612
|
-
}
|
|
28613
|
-
return true;
|
|
28614
|
-
}
|
|
28615
|
-
async function isCompatibleMethodCatalog(link, packagedMethodsRealpath) {
|
|
28616
|
-
const stat2 = await lstat7(link);
|
|
28617
|
-
if (!stat2.isSymbolicLink()) return false;
|
|
28618
|
-
let resolved;
|
|
28619
|
-
try {
|
|
28620
|
-
resolved = await realpath8(link);
|
|
28621
|
-
} catch (error) {
|
|
28622
|
-
if (isEnoent3(error)) return false;
|
|
28623
|
-
throw error;
|
|
28624
|
-
}
|
|
28625
|
-
if (resolved === packagedMethodsRealpath) return true;
|
|
28626
|
-
const names = await packagedMethodSkillNames(packagedMethodsRealpath);
|
|
28627
|
-
if (names.length === 0) return false;
|
|
28628
|
-
for (const name of names) {
|
|
28629
|
-
const required = await packagedSkillFileBytes(join45(packagedMethodsRealpath, name));
|
|
28630
|
-
if (required === void 0) return false;
|
|
28631
|
-
if (!await catalogPublishesPackagedSkill(join45(resolved, name), required)) return false;
|
|
28632
|
-
}
|
|
28633
|
-
return true;
|
|
28634
|
-
}
|
|
28635
|
-
async function installWorkspaceMethodSkills(cwd, packageRoot) {
|
|
28636
|
-
const target = await realpath8(packagedMethodsDir(packageRoot));
|
|
28637
|
-
const link = join45(cwd, ".agents", "skills");
|
|
28638
|
-
let present;
|
|
28639
|
-
try {
|
|
28640
|
-
await lstat7(link);
|
|
28641
|
-
present = true;
|
|
28642
|
-
} catch (error) {
|
|
28643
|
-
if (!isEnoent3(error)) throw error;
|
|
28644
|
-
present = false;
|
|
28645
|
-
}
|
|
28646
|
-
if (present) {
|
|
28647
|
-
if (await isCompatibleMethodCatalog(link, target)) return;
|
|
28648
|
-
const stat2 = await lstat7(link);
|
|
28649
|
-
const detail = stat2.isSymbolicLink() ? `symlink to ${await readlink(link)}` : "non-symlink entry";
|
|
28650
|
-
throw new Error(`workspace method catalog conflict at ${link}: ${detail}`);
|
|
28651
|
-
}
|
|
28652
|
-
await mkdir4(dirname24(link), { recursive: true });
|
|
28653
|
-
try {
|
|
28654
|
-
await symlink(target, link);
|
|
28655
|
-
} catch (error) {
|
|
28656
|
-
if (error.code !== "EEXIST") throw error;
|
|
28657
|
-
if (!await isCompatibleMethodCatalog(link, target)) {
|
|
28658
|
-
throw new Error(`workspace method catalog conflict at ${link}`);
|
|
28659
|
-
}
|
|
28660
|
-
}
|
|
28661
|
-
}
|
|
28662
|
-
|
|
28663
28188
|
// src/role-envelope.ts
|
|
28664
28189
|
init_packaged_role_registry();
|
|
28665
28190
|
init_role_activation_flags();
|
|
@@ -28667,11 +28192,11 @@ init_submission_correctable_error();
|
|
|
28667
28192
|
init_navigator_invocation_identity();
|
|
28668
28193
|
init_serialize_thrown_value();
|
|
28669
28194
|
async function listen(server, path) {
|
|
28670
|
-
await new Promise((
|
|
28195
|
+
await new Promise((resolve21, reject) => {
|
|
28671
28196
|
server.once("error", reject);
|
|
28672
28197
|
server.listen(path, () => {
|
|
28673
28198
|
server.off("error", reject);
|
|
28674
|
-
|
|
28199
|
+
resolve21();
|
|
28675
28200
|
});
|
|
28676
28201
|
});
|
|
28677
28202
|
}
|
|
@@ -28706,8 +28231,8 @@ async function prepareRoleEnvelope(options) {
|
|
|
28706
28231
|
const hostAbort = new AbortController();
|
|
28707
28232
|
const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID9();
|
|
28708
28233
|
await mkdir5(request.runDirectory, { recursive: true });
|
|
28709
|
-
let sessionFile = options.sessionFile ??
|
|
28710
|
-
await mkdir5(
|
|
28234
|
+
let sessionFile = options.sessionFile ?? join45(request.runDirectory, "session", "session.jsonl");
|
|
28235
|
+
await mkdir5(dirname22(sessionFile), { recursive: true });
|
|
28711
28236
|
if (request.continuation.kind !== "resume") {
|
|
28712
28237
|
try {
|
|
28713
28238
|
await writeFile11(
|
|
@@ -28757,7 +28282,7 @@ async function prepareRoleEnvelope(options) {
|
|
|
28757
28282
|
getLeafEntry: () => sessionEntries.at(-1),
|
|
28758
28283
|
getLeafId: () => runId,
|
|
28759
28284
|
getEntries: () => sessionEntries,
|
|
28760
|
-
getSessionDir: () =>
|
|
28285
|
+
getSessionDir: () => dirname22(sessionFile),
|
|
28761
28286
|
getSessionFile: () => sessionFile,
|
|
28762
28287
|
getHeader: () => ({ type: "session", id: runId }),
|
|
28763
28288
|
setSessionFile(path) {
|
|
@@ -28793,12 +28318,6 @@ async function prepareRoleEnvelope(options) {
|
|
|
28793
28318
|
const host = {
|
|
28794
28319
|
deliverSubmissionRejection(_value) {
|
|
28795
28320
|
},
|
|
28796
|
-
capabilities: {
|
|
28797
|
-
// #922: native loaders own expansion; package does not pre-read bodies (ADR 0032).
|
|
28798
|
-
skillExpansion() {
|
|
28799
|
-
return void 0;
|
|
28800
|
-
}
|
|
28801
|
-
},
|
|
28802
28321
|
registerFlag(name, definition) {
|
|
28803
28322
|
if (!flags.has(name) && definition.default !== void 0) flags.set(name, definition.default);
|
|
28804
28323
|
},
|
|
@@ -29121,8 +28640,8 @@ async function prepareRoleEnvelope(options) {
|
|
|
29121
28640
|
try {
|
|
29122
28641
|
const closeAll = server.closeAllConnections;
|
|
29123
28642
|
if (typeof closeAll === "function") closeAll.call(server);
|
|
29124
|
-
await new Promise((
|
|
29125
|
-
server.close((error) => error ? reject(error) :
|
|
28643
|
+
await new Promise((resolve21, reject) => {
|
|
28644
|
+
server.close((error) => error ? reject(error) : resolve21());
|
|
29126
28645
|
});
|
|
29127
28646
|
} catch (error) {
|
|
29128
28647
|
cleanupFailures.push(error);
|
|
@@ -29217,13 +28736,6 @@ async function prepareRoleEnvelope(options) {
|
|
|
29217
28736
|
throw new Error(`terminating tool not registered after activation: ${terminatingToolName}`);
|
|
29218
28737
|
}
|
|
29219
28738
|
const jsonSchema = terminatingToolJsonSchema(terminating.parameters);
|
|
29220
|
-
if (request.host === "codex" && hostMethodSkills(request.methods).length > 0) {
|
|
29221
|
-
const packageRoot = options.dependencies.packageRoot;
|
|
29222
|
-
if (typeof packageRoot !== "string" || packageRoot === "") {
|
|
29223
|
-
throw new Error("codex project Skill catalog requires packageRoot");
|
|
29224
|
-
}
|
|
29225
|
-
await installWorkspaceMethodSkills(request.cwd, packageRoot);
|
|
29226
|
-
}
|
|
29227
28739
|
return {
|
|
29228
28740
|
mcpServers: [{
|
|
29229
28741
|
name: `ak-${request.activation.role}`,
|
|
@@ -29261,7 +28773,7 @@ async function prepareRoleEnvelope(options) {
|
|
|
29261
28773
|
init_session_identity();
|
|
29262
28774
|
|
|
29263
28775
|
// src/headless-host/description.ts
|
|
29264
|
-
import { join as
|
|
28776
|
+
import { join as join46 } from "node:path";
|
|
29265
28777
|
function isClaudePrintDescription(description) {
|
|
29266
28778
|
return description.protocol === "claude-print";
|
|
29267
28779
|
}
|
|
@@ -29269,7 +28781,7 @@ function isCodexExecDescription(description) {
|
|
|
29269
28781
|
return description.protocol === "codex-exec";
|
|
29270
28782
|
}
|
|
29271
28783
|
function resolveHeadlessBinary(description, operatorHome) {
|
|
29272
|
-
return
|
|
28784
|
+
return join46(operatorHome, ...description.binaryFromHome);
|
|
29273
28785
|
}
|
|
29274
28786
|
function headlessTurnArgs(options) {
|
|
29275
28787
|
const { description } = options;
|
|
@@ -29282,7 +28794,6 @@ function headlessTurnArgs(options) {
|
|
|
29282
28794
|
if (options.jsonSchema !== void 0) {
|
|
29283
28795
|
args.push(description.jsonSchemaFlag, JSON.stringify(options.jsonSchema));
|
|
29284
28796
|
}
|
|
29285
|
-
if (options.pluginDir) args.push("--plugin-dir", options.pluginDir);
|
|
29286
28797
|
if (options.mcpConfigPath !== void 0 && options.mcpConfigPath !== "") {
|
|
29287
28798
|
args.push(description.mcpConfigFlag, options.mcpConfigPath);
|
|
29288
28799
|
}
|
|
@@ -29530,11 +29041,11 @@ function headlessMcpConfigDocument(mcpServers) {
|
|
|
29530
29041
|
}
|
|
29531
29042
|
|
|
29532
29043
|
// src/headless-host/role-turn-host.ts
|
|
29533
|
-
import { spawn as spawn4, spawnSync } from "node:child_process";
|
|
29044
|
+
import { spawn as spawn4, spawnSync as spawnSync2 } from "node:child_process";
|
|
29534
29045
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
29535
29046
|
import { existsSync as existsSync13 } from "node:fs";
|
|
29536
29047
|
import { writeFile as writeFile12 } from "node:fs/promises";
|
|
29537
|
-
import { dirname as
|
|
29048
|
+
import { dirname as dirname23, isAbsolute as isAbsolute12, join as join47, resolve as resolve20 } from "node:path";
|
|
29538
29049
|
|
|
29539
29050
|
// src/external-host-turn-loop.ts
|
|
29540
29051
|
init_packaged_role_registry();
|
|
@@ -29754,8 +29265,8 @@ function formatCodexFailurePayload(payload) {
|
|
|
29754
29265
|
function cwdIsGitWorkTree(cwd) {
|
|
29755
29266
|
let dir = cwd;
|
|
29756
29267
|
for (; ; ) {
|
|
29757
|
-
if (existsSync13(
|
|
29758
|
-
const parent =
|
|
29268
|
+
if (existsSync13(join47(dir, ".git"))) return true;
|
|
29269
|
+
const parent = dirname23(dir);
|
|
29759
29270
|
if (parent === dir) return false;
|
|
29760
29271
|
dir = parent;
|
|
29761
29272
|
}
|
|
@@ -29764,7 +29275,7 @@ function resolveGitCommonDir(cwd) {
|
|
|
29764
29275
|
if (!cwdIsGitWorkTree(cwd)) return void 0;
|
|
29765
29276
|
let result;
|
|
29766
29277
|
try {
|
|
29767
|
-
result =
|
|
29278
|
+
result = spawnSync2("git", ["rev-parse", "--git-common-dir"], {
|
|
29768
29279
|
cwd,
|
|
29769
29280
|
encoding: "utf8"
|
|
29770
29281
|
});
|
|
@@ -29783,10 +29294,10 @@ function resolveGitCommonDir(cwd) {
|
|
|
29783
29294
|
if (raw === "") {
|
|
29784
29295
|
throw new Error("git rev-parse --git-common-dir returned empty stdout");
|
|
29785
29296
|
}
|
|
29786
|
-
return isAbsolute12(raw) ? raw :
|
|
29297
|
+
return isAbsolute12(raw) ? raw : resolve20(cwd, raw);
|
|
29787
29298
|
}
|
|
29788
29299
|
function spawnHeadlessTurn(options) {
|
|
29789
|
-
return new Promise((
|
|
29300
|
+
return new Promise((resolve21, reject) => {
|
|
29790
29301
|
if (options.signal?.aborted) {
|
|
29791
29302
|
reject(hostAbortedError("headless host aborted"));
|
|
29792
29303
|
return;
|
|
@@ -29861,7 +29372,7 @@ function spawnHeadlessTurn(options) {
|
|
|
29861
29372
|
reject(stdinDeliveryError);
|
|
29862
29373
|
return;
|
|
29863
29374
|
}
|
|
29864
|
-
|
|
29375
|
+
resolve21({ code, stdout: resultStdout, stderr, timedOut });
|
|
29865
29376
|
};
|
|
29866
29377
|
const onAbort = () => {
|
|
29867
29378
|
child.kill("SIGTERM");
|
|
@@ -29944,8 +29455,7 @@ function buildTurnArgs(options) {
|
|
|
29944
29455
|
mcpConfigPath: options.mcpConfigPath,
|
|
29945
29456
|
...options.model === void 0 ? {} : { model: options.model },
|
|
29946
29457
|
...options.effort === void 0 ? {} : { effort: options.effort },
|
|
29947
|
-
session: { kind: options.sessionKind, id: options.sessionId }
|
|
29948
|
-
...options.pluginDir === void 0 ? {} : { pluginDir: options.pluginDir }
|
|
29458
|
+
session: { kind: options.sessionKind, id: options.sessionId }
|
|
29949
29459
|
});
|
|
29950
29460
|
}
|
|
29951
29461
|
function createHeadlessRoleTurnHost(config) {
|
|
@@ -29963,15 +29473,13 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
29963
29473
|
await config.sessionIdentity.bind(request.principal, sessionId);
|
|
29964
29474
|
}
|
|
29965
29475
|
const env = { ...process.env, ...config.env ?? {} };
|
|
29966
|
-
const systemPromptPath =
|
|
29476
|
+
const systemPromptPath = join47(request.runDirectory, "headless-system-prompt.txt");
|
|
29967
29477
|
await writeFile12(systemPromptPath, systemPrompt, "utf8");
|
|
29968
29478
|
let mcpConfigPath;
|
|
29969
29479
|
let outputSchemaPath;
|
|
29970
|
-
let pluginDir;
|
|
29971
|
-
let applyMethodPrompt = codex ? (prompt) => applyCodexSkillInvocation(request.methods, prompt) : (prompt) => prompt;
|
|
29972
29480
|
if (codex) {
|
|
29973
29481
|
if (prepared.terminatingToolName !== NAVIGATOR_OUTPUT_TOOL_NAME) {
|
|
29974
|
-
outputSchemaPath =
|
|
29482
|
+
outputSchemaPath = join47(request.runDirectory, "headless-output-schema.json");
|
|
29975
29483
|
await writeFile12(
|
|
29976
29484
|
outputSchemaPath,
|
|
29977
29485
|
`${JSON.stringify(closeJsonSchemaForCodex(prepared.jsonSchema), null, 2)}
|
|
@@ -29980,21 +29488,13 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
29980
29488
|
);
|
|
29981
29489
|
}
|
|
29982
29490
|
} else {
|
|
29983
|
-
mcpConfigPath =
|
|
29491
|
+
mcpConfigPath = join47(request.runDirectory, "headless-mcp-config.json");
|
|
29984
29492
|
await writeFile12(
|
|
29985
29493
|
mcpConfigPath,
|
|
29986
29494
|
`${JSON.stringify(headlessMcpConfigDocument(prepared.mcpServers), null, 2)}
|
|
29987
29495
|
`,
|
|
29988
29496
|
"utf8"
|
|
29989
29497
|
);
|
|
29990
|
-
if (hostMethodSkills(request.methods).length > 0) {
|
|
29991
|
-
const packageRoot = env.AK_PACKAGE_ROOT ?? process.env.AK_PACKAGE_ROOT;
|
|
29992
|
-
if (typeof packageRoot !== "string" || packageRoot === "") {
|
|
29993
|
-
throw new Error("claude method plugin-dir requires AK_PACKAGE_ROOT");
|
|
29994
|
-
}
|
|
29995
|
-
pluginDir = packagedMethodPluginDir(packageRoot);
|
|
29996
|
-
applyMethodPrompt = (prompt) => applyClaudeSkillInvocation(request.methods, prompt);
|
|
29997
|
-
}
|
|
29998
29498
|
}
|
|
29999
29499
|
const sessionParent = config.sessionIdentity.resolveSessionFile(request.principal);
|
|
30000
29500
|
outcome = await driveExternalRoleTurnRounds(prepared, request, {
|
|
@@ -30020,8 +29520,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
30020
29520
|
sessionId,
|
|
30021
29521
|
sessionKind,
|
|
30022
29522
|
cwd: request.cwd,
|
|
30023
|
-
...gitCommonDir === void 0 ? {} : { writableRoots: [gitCommonDir] }
|
|
30024
|
-
...pluginDir === void 0 ? {} : { pluginDir }
|
|
29523
|
+
...gitCommonDir === void 0 ? {} : { writableRoots: [gitCommonDir] }
|
|
30025
29524
|
});
|
|
30026
29525
|
} catch (error) {
|
|
30027
29526
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -30038,7 +29537,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
30038
29537
|
args,
|
|
30039
29538
|
cwd: request.cwd,
|
|
30040
29539
|
env,
|
|
30041
|
-
stdin:
|
|
29540
|
+
stdin: prompt,
|
|
30042
29541
|
...abortSignal === void 0 ? {} : { signal: abortSignal },
|
|
30043
29542
|
...request.timeoutMs === void 0 ? {} : { timeoutMs: request.timeoutMs },
|
|
30044
29543
|
onStdoutLine(line2) {
|