@akagilnc/pi-workflow-roles 0.1.5037 → 0.1.5063
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/THIRD_PARTY_NOTICES.md +8 -8
- package/dist/acp-host/production-host.js +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 +5 -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
|
@@ -62,7 +62,7 @@ async function spawnEngineDetourOnce(input) {
|
|
|
62
62
|
}
|
|
63
63
|
const command = input.argv[0];
|
|
64
64
|
const args = input.argv.slice(1);
|
|
65
|
-
return await new Promise((
|
|
65
|
+
return await new Promise((resolve21, reject) => {
|
|
66
66
|
let settled = false;
|
|
67
67
|
const signal = input.signal;
|
|
68
68
|
const child = spawn(command, args, {
|
|
@@ -92,7 +92,7 @@ async function spawnEngineDetourOnce(input) {
|
|
|
92
92
|
if (signal !== void 0) {
|
|
93
93
|
signal.removeEventListener("abort", onAbort);
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
resolve21(result);
|
|
96
96
|
};
|
|
97
97
|
const onAbort = () => {
|
|
98
98
|
fail4(signal !== void 0 ? abortReasonError(signal) : new Error("aborted"));
|
|
@@ -1172,12 +1172,12 @@ function createSystemCollectorClock() {
|
|
|
1172
1172
|
return {
|
|
1173
1173
|
wallNow: () => /* @__PURE__ */ new Date(),
|
|
1174
1174
|
monoNow: () => Number(process.hrtime.bigint() - start) / 1e6,
|
|
1175
|
-
sleep: (ms, signal) => new Promise((
|
|
1175
|
+
sleep: (ms, signal) => new Promise((resolve21, reject) => {
|
|
1176
1176
|
if (signal?.aborted) {
|
|
1177
1177
|
reject(signal.reason ?? new Error("aborted"));
|
|
1178
1178
|
return;
|
|
1179
1179
|
}
|
|
1180
|
-
const timer = setTimeout(
|
|
1180
|
+
const timer = setTimeout(resolve21, ms);
|
|
1181
1181
|
const onAbort = () => {
|
|
1182
1182
|
clearTimeout(timer);
|
|
1183
1183
|
reject(signal?.reason ?? new Error("aborted"));
|
|
@@ -1863,7 +1863,7 @@ function normalizeReviewComment(raw) {
|
|
|
1863
1863
|
function createGhApiRunner(options = {}) {
|
|
1864
1864
|
const spawnImpl = options.spawnImpl ?? spawn2;
|
|
1865
1865
|
return async (args, runOptions = {}) => {
|
|
1866
|
-
return await new Promise((
|
|
1866
|
+
return await new Promise((resolve21, reject) => {
|
|
1867
1867
|
const signal = runOptions.signal;
|
|
1868
1868
|
if (signal?.aborted) {
|
|
1869
1869
|
reject(signal.reason ?? new Error("aborted"));
|
|
@@ -1936,11 +1936,11 @@ function createGhApiRunner(options = {}) {
|
|
|
1936
1936
|
const value = line2.slice(idx + 1).trim();
|
|
1937
1937
|
headers[name] = value;
|
|
1938
1938
|
}
|
|
1939
|
-
|
|
1939
|
+
resolve21({ status, headers, bodyText });
|
|
1940
1940
|
return;
|
|
1941
1941
|
}
|
|
1942
1942
|
if (code === 0) {
|
|
1943
|
-
|
|
1943
|
+
resolve21({ status: 200, headers: {}, bodyText: stdout });
|
|
1944
1944
|
return;
|
|
1945
1945
|
}
|
|
1946
1946
|
const failure2 = new Error(
|
|
@@ -4045,7 +4045,7 @@ __export(packaged_role_registry_exports, {
|
|
|
4045
4045
|
packagedEmitsAuthorityRefs: () => packagedEmitsAuthorityRefs,
|
|
4046
4046
|
packagedGateStageLabel: () => packagedGateStageLabel,
|
|
4047
4047
|
packagedGateSummon: () => packagedGateSummon,
|
|
4048
|
-
|
|
4048
|
+
packagedMethodSkillNames: () => packagedMethodSkillNames,
|
|
4049
4049
|
packagedModelParent: () => packagedModelParent,
|
|
4050
4050
|
packagedNavigatorSubject: () => packagedNavigatorSubject,
|
|
4051
4051
|
packagedProjectsTargetBindRejection: () => packagedProjectsTargetBindRejection,
|
|
@@ -4067,6 +4067,18 @@ __export(packaged_role_registry_exports, {
|
|
|
4067
4067
|
function packagedRoleMetadata(role) {
|
|
4068
4068
|
return PACKAGED_ROLE_REGISTRY.find((entry) => entry.role === role);
|
|
4069
4069
|
}
|
|
4070
|
+
function packagedMethodSkillNames() {
|
|
4071
|
+
const names = [];
|
|
4072
|
+
for (const record4 of PACKAGED_ROLE_REGISTRY) {
|
|
4073
|
+
if ("methodSkills" in record4 && record4.methodSkills !== void 0) {
|
|
4074
|
+
for (const name of record4.methodSkills) if (!names.includes(name)) names.push(name);
|
|
4075
|
+
}
|
|
4076
|
+
if ("applyMethod" in record4 && record4.applyMethod !== void 0 && !names.includes(record4.applyMethod)) {
|
|
4077
|
+
names.push(record4.applyMethod);
|
|
4078
|
+
}
|
|
4079
|
+
}
|
|
4080
|
+
return names;
|
|
4081
|
+
}
|
|
4070
4082
|
function isOfficerReviewSeat(role) {
|
|
4071
4083
|
const record4 = packagedRoleMetadata(role);
|
|
4072
4084
|
return record4 !== void 0 && "reviewOfficer" in record4 && record4.reviewOfficer === true;
|
|
@@ -4101,11 +4113,6 @@ function packagedRolePhaseFlag(role) {
|
|
|
4101
4113
|
function packagedRoleOutputTool(role) {
|
|
4102
4114
|
return packagedRoleMetadata(role)?.outputTool;
|
|
4103
4115
|
}
|
|
4104
|
-
function packagedMethodLoadFailureCause(role) {
|
|
4105
|
-
const record4 = packagedRoleMetadata(role);
|
|
4106
|
-
if (record4 === void 0 || !("methodLoadFailureCause" in record4)) return void 0;
|
|
4107
|
-
return record4.methodLoadFailureCause;
|
|
4108
|
-
}
|
|
4109
4116
|
function packagedBindsBoardTicket(role) {
|
|
4110
4117
|
const record4 = packagedRoleMetadata(role);
|
|
4111
4118
|
return record4?.sameParent === "board-ticket";
|
|
@@ -4308,8 +4315,7 @@ var init_packaged_role_registry = __esm({
|
|
|
4308
4315
|
{ key: "packetPath" },
|
|
4309
4316
|
{ key: "prerequisitesPath", omitUndefined: true },
|
|
4310
4317
|
{ key: "prerequisites" }
|
|
4311
|
-
]
|
|
4312
|
-
method: "observed"
|
|
4318
|
+
]
|
|
4313
4319
|
},
|
|
4314
4320
|
boardPlacement: "marshal",
|
|
4315
4321
|
activationFlags: [
|
|
@@ -4335,7 +4341,6 @@ var init_packaged_role_registry = __esm({
|
|
|
4335
4341
|
worker: true,
|
|
4336
4342
|
applyMethod: "tdd",
|
|
4337
4343
|
/** Method-material load failure keeps the activation cause (not reviewer/fixer). */
|
|
4338
|
-
methodLoadFailureCause: "activation",
|
|
4339
4344
|
boardPlacement: "coder",
|
|
4340
4345
|
phases: ["plan", "apply"],
|
|
4341
4346
|
outputTool: CODER_OUTPUT_TOOL_NAME,
|
|
@@ -4346,8 +4351,7 @@ var init_packaged_role_registry = __esm({
|
|
|
4346
4351
|
leaves: [
|
|
4347
4352
|
{ key: "phase" },
|
|
4348
4353
|
{ key: "taskPath" }
|
|
4349
|
-
]
|
|
4350
|
-
method: "optional"
|
|
4354
|
+
]
|
|
4351
4355
|
},
|
|
4352
4356
|
activationFlags: [
|
|
4353
4357
|
{ field: "taskPath", flag: "ak-coder-task", binds: "input" },
|
|
@@ -4388,8 +4392,7 @@ var init_packaged_role_registry = __esm({
|
|
|
4388
4392
|
{ key: "lens" },
|
|
4389
4393
|
{ key: "authorityRefs", copyArray: true },
|
|
4390
4394
|
{ key: "callerProvenance", callerProvenance: true }
|
|
4391
|
-
]
|
|
4392
|
-
method: "observed"
|
|
4395
|
+
]
|
|
4393
4396
|
},
|
|
4394
4397
|
/** Frozen base/lens/authority become the initial prompt; instruction follows. */
|
|
4395
4398
|
transportPrompt: "skill-args",
|
|
@@ -4488,7 +4491,6 @@ var init_packaged_role_registry = __esm({
|
|
|
4488
4491
|
methodSkills: ["resolving-merge-conflicts"],
|
|
4489
4492
|
settleMethod: "resolving-merge-conflicts",
|
|
4490
4493
|
/** Method-material load failure keeps the activation cause (not reviewer/fixer). */
|
|
4491
|
-
methodLoadFailureCause: "activation",
|
|
4492
4494
|
phases: [null],
|
|
4493
4495
|
outputTool: MERGER_OUTPUT_TOOL_NAME,
|
|
4494
4496
|
settlement: "residual",
|
|
@@ -4500,8 +4502,7 @@ var init_packaged_role_registry = __esm({
|
|
|
4500
4502
|
leaves: [
|
|
4501
4503
|
{ key: "mergerInputPath" },
|
|
4502
4504
|
{ key: "derived" }
|
|
4503
|
-
]
|
|
4504
|
-
method: "observed"
|
|
4505
|
+
]
|
|
4505
4506
|
},
|
|
4506
4507
|
activationFlags: [
|
|
4507
4508
|
{ field: "inputPath", from: "mergerInputPath", flag: "ak-merger-input", binds: "input" }
|
|
@@ -5122,10 +5123,10 @@ __export(session_assistant_usage_exports, {
|
|
|
5122
5123
|
});
|
|
5123
5124
|
import { join as join9 } from "node:path";
|
|
5124
5125
|
async function readAssistantUsageFromSessionFile(sessionFile) {
|
|
5125
|
-
const { readFile:
|
|
5126
|
+
const { readFile: readFile25 } = await import("node:fs/promises");
|
|
5126
5127
|
let text;
|
|
5127
5128
|
try {
|
|
5128
|
-
text = await
|
|
5129
|
+
text = await readFile25(sessionFile, "utf8");
|
|
5129
5130
|
} catch (error) {
|
|
5130
5131
|
if (error?.code === "ENOENT") return void 0;
|
|
5131
5132
|
throw error;
|
|
@@ -5783,7 +5784,6 @@ var role_turn_host_exports = {};
|
|
|
5783
5784
|
__export(role_turn_host_exports, {
|
|
5784
5785
|
EXPLICIT_INTERNAL_LOAD_PROBE_ARGS: () => EXPLICIT_INTERNAL_LOAD_PROBE_ARGS,
|
|
5785
5786
|
appendPiSessionCustomEntry: () => appendPiSessionCustomEntry,
|
|
5786
|
-
applyPiNativeSkillInvocation: () => applyPiNativeSkillInvocation,
|
|
5787
5787
|
buildExplicitInternalActivationArgs: () => buildExplicitInternalActivationArgs,
|
|
5788
5788
|
buildPiTurnExtraArgs: () => buildPiTurnExtraArgs,
|
|
5789
5789
|
createDefaultPiSpawnRunner: () => createDefaultPiSpawnRunner,
|
|
@@ -5793,7 +5793,7 @@ __export(role_turn_host_exports, {
|
|
|
5793
5793
|
import { execFile, spawn as spawn3 } from "node:child_process";
|
|
5794
5794
|
import { constants } from "node:fs";
|
|
5795
5795
|
import { access, appendFile, readFile as readFile5, realpath } from "node:fs/promises";
|
|
5796
|
-
import {
|
|
5796
|
+
import { delimiter, dirname as dirname7, isAbsolute as isAbsolute3, join as join13, resolve as resolve5 } from "node:path";
|
|
5797
5797
|
import { platform } from "node:process";
|
|
5798
5798
|
import { promisify } from "node:util";
|
|
5799
5799
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
@@ -5826,24 +5826,11 @@ function buildMethodArgs(methods) {
|
|
|
5826
5826
|
const skillArgs = [];
|
|
5827
5827
|
for (const method of methods) {
|
|
5828
5828
|
if (method.kind === "skill") {
|
|
5829
|
-
skillArgs.push("--skill", method.path);
|
|
5829
|
+
skillArgs.push("--skill", dirname7(method.path));
|
|
5830
5830
|
}
|
|
5831
5831
|
}
|
|
5832
5832
|
return skillArgs;
|
|
5833
5833
|
}
|
|
5834
|
-
function applyPiNativeSkillInvocation(methods, prompt) {
|
|
5835
|
-
const skills = methods.filter((method) => method.kind === "skill");
|
|
5836
|
-
if (skills.length !== 1) return prompt;
|
|
5837
|
-
const name = basename4(dirname7(skills[0].path));
|
|
5838
|
-
if (name.length === 0) return prompt;
|
|
5839
|
-
const token = `/skill:${name}`;
|
|
5840
|
-
const trimmed = prompt.trimStart();
|
|
5841
|
-
if (trimmed === token || trimmed.startsWith(`${token} `) || trimmed.startsWith(`${token}
|
|
5842
|
-
`)) {
|
|
5843
|
-
return prompt;
|
|
5844
|
-
}
|
|
5845
|
-
return prompt.length === 0 ? token : `${token} ${prompt}`;
|
|
5846
|
-
}
|
|
5847
5834
|
function buildPiTurnExtraArgs(request, authority, extraPiArgs = []) {
|
|
5848
5835
|
const { sessionFile, sessionDirectory } = authority.decode(request.principal);
|
|
5849
5836
|
return [
|
|
@@ -5875,7 +5862,7 @@ function piUserDialogueBody(request) {
|
|
|
5875
5862
|
const _exhaustive = request.continuation;
|
|
5876
5863
|
return _exhaustive;
|
|
5877
5864
|
})();
|
|
5878
|
-
return
|
|
5865
|
+
return rawPrompt;
|
|
5879
5866
|
}
|
|
5880
5867
|
async function resolveSelectedPi(command, cwd, env) {
|
|
5881
5868
|
const searchPath = env.PATH ?? (platform === "win32" ? process.env.PATH ?? "" : "/usr/bin:/bin");
|
|
@@ -7402,7 +7389,7 @@ var init_session_dialogue = __esm({
|
|
|
7402
7389
|
// src/ticket-provenance.ts
|
|
7403
7390
|
import { createHash as createHash7 } from "node:crypto";
|
|
7404
7391
|
import { readFile as readFile9, unlink } from "node:fs/promises";
|
|
7405
|
-
import { basename as
|
|
7392
|
+
import { basename as basename4, dirname as dirname9, join as join15, resolve as resolve8 } from "node:path";
|
|
7406
7393
|
function dialogueSessionSourceRoots(home) {
|
|
7407
7394
|
const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
|
|
7408
7395
|
return [
|
|
@@ -7415,7 +7402,7 @@ function isLedgerRoleSessionFile(absolute, home) {
|
|
|
7415
7402
|
const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
|
|
7416
7403
|
const ledgerHome = resolveActivationLedgerHome(machineHome);
|
|
7417
7404
|
if (!physicallyContainedIn(ledgerHome, absolute)) return false;
|
|
7418
|
-
return
|
|
7405
|
+
return basename4(absolute) === "session.jsonl" && basename4(dirname9(absolute)) === "session";
|
|
7419
7406
|
}
|
|
7420
7407
|
function assertDialogueSessionSourcePath(path, home) {
|
|
7421
7408
|
const absolute = resolve8(path);
|
|
@@ -8108,7 +8095,7 @@ __export(run_lifecycle_exports, {
|
|
|
8108
8095
|
writeRoleRunState: () => writeRoleRunState
|
|
8109
8096
|
});
|
|
8110
8097
|
import { chmod, lstat as lstat2, open, readdir as readdir4, readFile as readFile11, unlink as unlink3, writeFile as writeFile3 } from "node:fs/promises";
|
|
8111
|
-
import { basename as
|
|
8098
|
+
import { basename as basename5, join as join17 } from "node:path";
|
|
8112
8099
|
function buildAutoResumeContinuationPrompt(options) {
|
|
8113
8100
|
return appendEngineSessionMaterial(
|
|
8114
8101
|
[RESUME_TRANSPORT_ENVELOPE],
|
|
@@ -8621,7 +8608,7 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
|
8621
8608
|
throw error;
|
|
8622
8609
|
}
|
|
8623
8610
|
for (const runDirectory of runDirectories) {
|
|
8624
|
-
const entry =
|
|
8611
|
+
const entry = basename5(runDirectory);
|
|
8625
8612
|
if (onlyRole === void 0 && (entry === `${runId}@judge` || entry.startsWith(`${runId}@`)) || entry === `${runId}@${onlyRole}`) {
|
|
8626
8613
|
matches.push(runDirectory);
|
|
8627
8614
|
}
|
|
@@ -8690,12 +8677,12 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
8690
8677
|
const suffix = `@${input.role}`;
|
|
8691
8678
|
let best;
|
|
8692
8679
|
for (const runDirectory of runDirectories) {
|
|
8693
|
-
const entry =
|
|
8680
|
+
const entry = basename5(runDirectory);
|
|
8694
8681
|
if (!entry.endsWith(suffix)) continue;
|
|
8695
8682
|
const runId = entry.slice(0, entry.length - suffix.length);
|
|
8696
8683
|
if (runId.length === 0) continue;
|
|
8697
8684
|
const parentPath = await readRunParentPath(runDirectory);
|
|
8698
|
-
if (parentPath !== input.parentRunPath &&
|
|
8685
|
+
if (parentPath !== input.parentRunPath && basename5(parentPath ?? "") !== basename5(input.parentRunPath)) continue;
|
|
8699
8686
|
if (!await runHasFormedSessionPrincipal(runDirectory)) continue;
|
|
8700
8687
|
if (best === void 0 || runId > best) best = runId;
|
|
8701
8688
|
}
|
|
@@ -8970,7 +8957,7 @@ async function loadResumableRunRecord(home, runId, authority, allowUnformedAdmit
|
|
|
8970
8957
|
} else if (mergedSet.tickets !== void 0) {
|
|
8971
8958
|
courtTicketNumbers = mergedSet.tickets;
|
|
8972
8959
|
}
|
|
8973
|
-
const sourceRunLeaf =
|
|
8960
|
+
const sourceRunLeaf = basename5(sourceRunPath ?? "").split("@");
|
|
8974
8961
|
const referencedRunId = sourceRun?.runId ?? sourceRunLeaf[0];
|
|
8975
8962
|
const referencedRole = sourceRun?.role ?? sourceRunLeaf[1];
|
|
8976
8963
|
if (referencedRunId !== void 0 && referencedRunId !== "") {
|
|
@@ -9315,7 +9302,7 @@ var init_run_lifecycle = __esm({
|
|
|
9315
9302
|
});
|
|
9316
9303
|
|
|
9317
9304
|
// src/notary-source-run.ts
|
|
9318
|
-
import { dirname as dirname10, isAbsolute as isAbsolute6, join as join18, resolve as resolve9, basename as
|
|
9305
|
+
import { dirname as dirname10, isAbsolute as isAbsolute6, join as join18, resolve as resolve9, basename as basename6 } from "node:path";
|
|
9319
9306
|
import { lstat as lstat3, realpath as realpath3 } from "node:fs/promises";
|
|
9320
9307
|
async function readRetainedIdentity(runDirectory) {
|
|
9321
9308
|
try {
|
|
@@ -9356,10 +9343,10 @@ async function requireRunDirectory(candidate, display) {
|
|
|
9356
9343
|
`notary --source-run must be a run directory: ${display}`
|
|
9357
9344
|
);
|
|
9358
9345
|
}
|
|
9359
|
-
const identity = parseRunDirectoryName(
|
|
9346
|
+
const identity = parseRunDirectoryName(basename6(real));
|
|
9360
9347
|
if (identity === void 0) {
|
|
9361
9348
|
throw new NotarySourceRunError(
|
|
9362
|
-
`notary --source-run must be named <runId>@<role>: ${
|
|
9349
|
+
`notary --source-run must be named <runId>@<role>: ${basename6(real)}`
|
|
9363
9350
|
);
|
|
9364
9351
|
}
|
|
9365
9352
|
return real;
|
|
@@ -9379,9 +9366,9 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
9379
9366
|
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join18(bookRunsRoot, `${bare.runId}@${bare.role}`);
|
|
9380
9367
|
} else {
|
|
9381
9368
|
candidate = isAbsolute6(raw) ? raw : resolve9(options.projectRoot, raw);
|
|
9382
|
-
const identity2 = parseRunDirectoryName(
|
|
9369
|
+
const identity2 = parseRunDirectoryName(basename6(candidate));
|
|
9383
9370
|
const subjectDirectory = dirname10(dirname10(candidate));
|
|
9384
|
-
const isLegacyUnboundLocator = identity2 !== void 0 &&
|
|
9371
|
+
const isLegacyUnboundLocator = identity2 !== void 0 && basename6(dirname10(candidate)) === "runs" && basename6(subjectDirectory) === "unbound" && resolve9(dirname10(subjectDirectory)) === resolve9(bookDirectory);
|
|
9385
9372
|
if (isLegacyUnboundLocator) {
|
|
9386
9373
|
candidate = await findRunDirectoryById(
|
|
9387
9374
|
options.home,
|
|
@@ -9392,11 +9379,11 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
9392
9379
|
}
|
|
9393
9380
|
}
|
|
9394
9381
|
const real = await requireRunDirectory(candidate, raw);
|
|
9395
|
-
const identity = parseRunDirectoryName(
|
|
9382
|
+
const identity = parseRunDirectoryName(basename6(real));
|
|
9396
9383
|
const bookIdentity = physicalPathIdentity(bookDirectory);
|
|
9397
9384
|
const parentIdentity = physicalPathIdentity(dirname10(real));
|
|
9398
9385
|
const subjectBookIdentity = physicalPathIdentity(dirname10(dirname10(dirname10(real))));
|
|
9399
|
-
if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(
|
|
9386
|
+
if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename6(dirname10(real)) === "runs" && subjectBookIdentity === bookIdentity)) {
|
|
9400
9387
|
throw new NotarySourceRunError(
|
|
9401
9388
|
"notary --source-run must resolve to a retained run under the project machine-ledger book"
|
|
9402
9389
|
);
|
|
@@ -9430,7 +9417,7 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
9430
9417
|
}
|
|
9431
9418
|
async function loadNotarySourceRunLocator(path) {
|
|
9432
9419
|
const real = await requireRunDirectory(path, path);
|
|
9433
|
-
const identity = parseRunDirectoryName(
|
|
9420
|
+
const identity = parseRunDirectoryName(basename6(real));
|
|
9434
9421
|
const runState = await readRetainedIdentity(real);
|
|
9435
9422
|
if (runState === void 0) {
|
|
9436
9423
|
throw new NotarySourceRunError(
|
|
@@ -9537,7 +9524,8 @@ var init_registry = __esm({
|
|
|
9537
9524
|
"config",
|
|
9538
9525
|
"help",
|
|
9539
9526
|
"resume",
|
|
9540
|
-
"new"
|
|
9527
|
+
"new",
|
|
9528
|
+
"setup"
|
|
9541
9529
|
];
|
|
9542
9530
|
PUBLIC_DETERMINISTIC_COMMANDS = ["analyst"];
|
|
9543
9531
|
}
|
|
@@ -10605,7 +10593,7 @@ import {
|
|
|
10605
10593
|
writeFile as writeFile4
|
|
10606
10594
|
} from "node:fs/promises";
|
|
10607
10595
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
10608
|
-
import { basename as
|
|
10596
|
+
import { basename as basename7, dirname as dirname11, isAbsolute as isAbsolute7, join as join19, resolve as resolve10, sep as sep4 } from "node:path";
|
|
10609
10597
|
function issueAdmissionPlacement(authority, request) {
|
|
10610
10598
|
const ledgerHome = resolveActivationLedgerHome(request.home);
|
|
10611
10599
|
const bookKey = resolveBookKeyFromGit(request.cwd);
|
|
@@ -11220,7 +11208,7 @@ async function withPreparedAttachments(attachmentPaths, use) {
|
|
|
11220
11208
|
async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, index) {
|
|
11221
11209
|
const frozenPath = join19(
|
|
11222
11210
|
destinationDir,
|
|
11223
|
-
`${String(index).padStart(2, "0")}-${
|
|
11211
|
+
`${String(index).padStart(2, "0")}-${basename7(provenancePath)}`
|
|
11224
11212
|
);
|
|
11225
11213
|
await writeFile4(frozenPath, bytes);
|
|
11226
11214
|
return {
|
|
@@ -13394,10 +13382,10 @@ function pairGateRounds(volumes) {
|
|
|
13394
13382
|
return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
|
|
13395
13383
|
}
|
|
13396
13384
|
async function resolveOfficerSessionFromPointerFile(pointerPath) {
|
|
13397
|
-
const { readFile:
|
|
13385
|
+
const { readFile: readFile25 } = await import("node:fs/promises");
|
|
13398
13386
|
let raw;
|
|
13399
13387
|
try {
|
|
13400
|
-
raw = JSON.parse(await
|
|
13388
|
+
raw = JSON.parse(await readFile25(pointerPath, "utf8"));
|
|
13401
13389
|
} catch (error) {
|
|
13402
13390
|
throw new Error(
|
|
13403
13391
|
`direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -14496,243 +14484,6 @@ var init_dossier_resolution = __esm({
|
|
|
14496
14484
|
}
|
|
14497
14485
|
});
|
|
14498
14486
|
|
|
14499
|
-
// src/package-resources/method-skill.ts
|
|
14500
|
-
import { createHash as createHash8 } from "node:crypto";
|
|
14501
|
-
import { readFile as readFile15, realpath as realpath5 } from "node:fs/promises";
|
|
14502
|
-
import { join as join28 } from "node:path";
|
|
14503
|
-
function gitBlobOid(bytes) {
|
|
14504
|
-
const body = typeof bytes === "string" ? Buffer.from(bytes, "utf8") : Buffer.from(bytes);
|
|
14505
|
-
const header = Buffer.from(`blob ${body.byteLength}\0`, "utf8");
|
|
14506
|
-
return createHash8("sha1").update(header).update(body).digest("hex");
|
|
14507
|
-
}
|
|
14508
|
-
function stripSkillFrontmatter(content) {
|
|
14509
|
-
if (!content.startsWith("---")) return content;
|
|
14510
|
-
const end = content.indexOf("\n---", 3);
|
|
14511
|
-
if (end === -1) return content;
|
|
14512
|
-
const after = content.slice(end + "\n---".length);
|
|
14513
|
-
return after.replace(/^\r?\n/, "");
|
|
14514
|
-
}
|
|
14515
|
-
function packagedMethodSkillRelativeDirectory(name) {
|
|
14516
|
-
return `${METHOD_SKILL_RELATIVE_ROOT}/${name}`;
|
|
14517
|
-
}
|
|
14518
|
-
function resolvePackagedMethodSkillRoot(packageRoot, name) {
|
|
14519
|
-
return join28(packageRoot, packagedMethodSkillRelativeDirectory(name));
|
|
14520
|
-
}
|
|
14521
|
-
function resolvePackagedMethodSkillPath(packageRoot, name) {
|
|
14522
|
-
return join28(resolvePackagedMethodSkillRoot(packageRoot, name), "SKILL.md");
|
|
14523
|
-
}
|
|
14524
|
-
function isRecord11(value) {
|
|
14525
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
14526
|
-
}
|
|
14527
|
-
function parseProvenance(raw, expectedName) {
|
|
14528
|
-
if (!isRecord11(raw)) {
|
|
14529
|
-
throw new Error(`Packaged method provenance must be an object for ${expectedName}`);
|
|
14530
|
-
}
|
|
14531
|
-
if (raw.name !== expectedName) {
|
|
14532
|
-
throw new Error(
|
|
14533
|
-
`Packaged method provenance name mismatch: expected ${expectedName}, got ${String(raw.name)}`
|
|
14534
|
-
);
|
|
14535
|
-
}
|
|
14536
|
-
if (raw.kind !== "role-method-skill") {
|
|
14537
|
-
throw new Error(`Packaged method provenance kind must be role-method-skill`);
|
|
14538
|
-
}
|
|
14539
|
-
if (typeof raw.packageAdaptation !== "string" || raw.packageAdaptation.trim() === "") {
|
|
14540
|
-
throw new Error(`Packaged method provenance packageAdaptation must be nonblank`);
|
|
14541
|
-
}
|
|
14542
|
-
if (!isRecord11(raw.upstream)) {
|
|
14543
|
-
throw new Error(`Packaged method provenance upstream must be an object`);
|
|
14544
|
-
}
|
|
14545
|
-
const upstream = raw.upstream;
|
|
14546
|
-
for (const key of [
|
|
14547
|
-
"repository",
|
|
14548
|
-
"path",
|
|
14549
|
-
"license",
|
|
14550
|
-
"copyright",
|
|
14551
|
-
"attribution"
|
|
14552
|
-
]) {
|
|
14553
|
-
if (typeof upstream[key] !== "string" || upstream[key].trim() === "") {
|
|
14554
|
-
throw new Error(`Packaged method provenance upstream.${key} must be nonblank`);
|
|
14555
|
-
}
|
|
14556
|
-
}
|
|
14557
|
-
if (typeof upstream.commit !== "string" || !GIT_COMMIT_RE.test(upstream.commit)) {
|
|
14558
|
-
throw new Error(
|
|
14559
|
-
`Packaged method provenance upstream.commit must be a 40-char lowercase git object id`
|
|
14560
|
-
);
|
|
14561
|
-
}
|
|
14562
|
-
const tag = typeof upstream.tag === "string" && upstream.tag.trim() !== "" ? upstream.tag.trim() : void 0;
|
|
14563
|
-
const version = typeof upstream.version === "string" && upstream.version.trim() !== "" ? upstream.version.trim() : void 0;
|
|
14564
|
-
if (tag === void 0 && version === void 0) {
|
|
14565
|
-
throw new Error(
|
|
14566
|
-
`Packaged method provenance upstream must include nonblank tag or version`
|
|
14567
|
-
);
|
|
14568
|
-
}
|
|
14569
|
-
if (!isRecord11(raw.files)) {
|
|
14570
|
-
throw new Error(`Packaged method provenance files must be an object`);
|
|
14571
|
-
}
|
|
14572
|
-
const files = {};
|
|
14573
|
-
for (const [rel, entry] of Object.entries(raw.files)) {
|
|
14574
|
-
if (!isRecord11(entry)) {
|
|
14575
|
-
throw new Error(`Packaged method provenance file entry must be an object: ${rel}`);
|
|
14576
|
-
}
|
|
14577
|
-
if (typeof entry.sha256 !== "string" || !SHA256_RE.test(entry.sha256)) {
|
|
14578
|
-
throw new Error(`Packaged method provenance file sha256 invalid: ${rel}`);
|
|
14579
|
-
}
|
|
14580
|
-
if (typeof entry.byteLength !== "number" || !Number.isInteger(entry.byteLength) || entry.byteLength < 0) {
|
|
14581
|
-
throw new Error(`Packaged method provenance file byteLength invalid: ${rel}`);
|
|
14582
|
-
}
|
|
14583
|
-
if (typeof entry.gitBlob !== "string" || !GIT_BLOB_RE.test(entry.gitBlob)) {
|
|
14584
|
-
throw new Error(
|
|
14585
|
-
`Packaged method provenance file gitBlob must be a 40-char lowercase git object id: ${rel}`
|
|
14586
|
-
);
|
|
14587
|
-
}
|
|
14588
|
-
files[rel] = {
|
|
14589
|
-
sha256: entry.sha256,
|
|
14590
|
-
byteLength: entry.byteLength,
|
|
14591
|
-
gitBlob: entry.gitBlob
|
|
14592
|
-
};
|
|
14593
|
-
}
|
|
14594
|
-
if (files["SKILL.md"] === void 0) {
|
|
14595
|
-
throw new Error(`Packaged method provenance must include SKILL.md`);
|
|
14596
|
-
}
|
|
14597
|
-
return Object.freeze({
|
|
14598
|
-
name: expectedName,
|
|
14599
|
-
kind: "role-method-skill",
|
|
14600
|
-
packageAdaptation: raw.packageAdaptation,
|
|
14601
|
-
upstream: Object.freeze({
|
|
14602
|
-
repository: upstream.repository,
|
|
14603
|
-
path: upstream.path,
|
|
14604
|
-
commit: upstream.commit,
|
|
14605
|
-
...tag === void 0 ? {} : { tag },
|
|
14606
|
-
...version === void 0 ? {} : { version },
|
|
14607
|
-
license: upstream.license,
|
|
14608
|
-
copyright: upstream.copyright,
|
|
14609
|
-
attribution: upstream.attribution
|
|
14610
|
-
}),
|
|
14611
|
-
files: Object.freeze(files)
|
|
14612
|
-
});
|
|
14613
|
-
}
|
|
14614
|
-
async function loadPackagedMethodSkillMaterial(packageRoot, name) {
|
|
14615
|
-
const rootDirectory = resolvePackagedMethodSkillRoot(packageRoot, name);
|
|
14616
|
-
const skillPathConfigured = join28(rootDirectory, "SKILL.md");
|
|
14617
|
-
const provenancePath = join28(rootDirectory, "provenance.json");
|
|
14618
|
-
let provenanceRaw;
|
|
14619
|
-
try {
|
|
14620
|
-
provenanceRaw = await readFile15(provenancePath, "utf8");
|
|
14621
|
-
} catch (error) {
|
|
14622
|
-
throw new PackagedMethodSkillUnavailableError(name, provenancePath, error);
|
|
14623
|
-
}
|
|
14624
|
-
let provenanceJson;
|
|
14625
|
-
try {
|
|
14626
|
-
provenanceJson = JSON.parse(provenanceRaw);
|
|
14627
|
-
} catch (error) {
|
|
14628
|
-
throw new Error(`Packaged method provenance is not valid JSON at ${provenancePath}`, {
|
|
14629
|
-
cause: error
|
|
14630
|
-
});
|
|
14631
|
-
}
|
|
14632
|
-
const provenance = parseProvenance(provenanceJson, name);
|
|
14633
|
-
for (const [rel, expected] of Object.entries(provenance.files)) {
|
|
14634
|
-
const absolute = join28(rootDirectory, rel);
|
|
14635
|
-
let bytes;
|
|
14636
|
-
try {
|
|
14637
|
-
bytes = await readFile15(absolute);
|
|
14638
|
-
} catch (error) {
|
|
14639
|
-
throw new PackagedMethodSkillUnavailableError(name, absolute, error);
|
|
14640
|
-
}
|
|
14641
|
-
const actualSha = sha256Hex(bytes);
|
|
14642
|
-
const actualBlob = gitBlobOid(bytes);
|
|
14643
|
-
if (actualSha !== expected.sha256 || bytes.byteLength !== expected.byteLength || actualBlob !== expected.gitBlob) {
|
|
14644
|
-
throw new Error(
|
|
14645
|
-
`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}`
|
|
14646
|
-
);
|
|
14647
|
-
}
|
|
14648
|
-
}
|
|
14649
|
-
let skillPath;
|
|
14650
|
-
let raw;
|
|
14651
|
-
try {
|
|
14652
|
-
skillPath = await realpath5(skillPathConfigured);
|
|
14653
|
-
raw = await readFile15(skillPath, "utf8");
|
|
14654
|
-
} catch (error) {
|
|
14655
|
-
throw new PackagedMethodSkillUnavailableError(name, skillPathConfigured, error);
|
|
14656
|
-
}
|
|
14657
|
-
const body = stripSkillFrontmatter(raw).trim();
|
|
14658
|
-
if (body.length === 0) {
|
|
14659
|
-
throw new Error(`Canonical ${name} Skill is empty at ${skillPath}`);
|
|
14660
|
-
}
|
|
14661
|
-
const companionRelativePaths = REQUIRED_COMPANIONS[name].filter(
|
|
14662
|
-
(rel) => provenance.files[rel] !== void 0
|
|
14663
|
-
);
|
|
14664
|
-
for (const rel of REQUIRED_COMPANIONS[name]) {
|
|
14665
|
-
if (provenance.files[rel] === void 0) {
|
|
14666
|
-
throw new Error(
|
|
14667
|
-
`Packaged method ${name} missing required companion in provenance: ${rel}`
|
|
14668
|
-
);
|
|
14669
|
-
}
|
|
14670
|
-
}
|
|
14671
|
-
return Object.freeze({
|
|
14672
|
-
name,
|
|
14673
|
-
rootDirectory,
|
|
14674
|
-
skillPath,
|
|
14675
|
-
raw,
|
|
14676
|
-
body,
|
|
14677
|
-
provenance,
|
|
14678
|
-
companionRelativePaths: Object.freeze([...companionRelativePaths])
|
|
14679
|
-
});
|
|
14680
|
-
}
|
|
14681
|
-
function observePackagedMethodSkillInvocation(text, expected) {
|
|
14682
|
-
if (!text.startsWith('<skill name="')) return void 0;
|
|
14683
|
-
const nameStart = '<skill name="'.length;
|
|
14684
|
-
const nameEnd = text.indexOf('"', nameStart);
|
|
14685
|
-
if (nameEnd <= nameStart) return void 0;
|
|
14686
|
-
const name = text.slice(nameStart, nameEnd);
|
|
14687
|
-
if (name !== expected.name) return void 0;
|
|
14688
|
-
const locationMarker = '" location="';
|
|
14689
|
-
if (!text.startsWith(locationMarker, nameEnd)) return void 0;
|
|
14690
|
-
const locationStart = nameEnd + locationMarker.length;
|
|
14691
|
-
const locationEnd = text.indexOf('"', locationStart);
|
|
14692
|
-
if (locationEnd <= locationStart) return void 0;
|
|
14693
|
-
const location = text.slice(locationStart, locationEnd);
|
|
14694
|
-
const openTail = ">\n";
|
|
14695
|
-
if (!text.startsWith(openTail, locationEnd + 1)) return void 0;
|
|
14696
|
-
const closeTag = "\n</skill>";
|
|
14697
|
-
const closeAt = text.indexOf(closeTag, locationEnd + 1 + openTail.length);
|
|
14698
|
-
if (closeAt === -1) return void 0;
|
|
14699
|
-
const afterClose = text.slice(closeAt + closeTag.length);
|
|
14700
|
-
if (afterClose.length > 0 && !afterClose.startsWith("\n")) return void 0;
|
|
14701
|
-
if (!expected.allowedLocations.includes(location)) return void 0;
|
|
14702
|
-
return Object.freeze({ name: expected.name, location });
|
|
14703
|
-
}
|
|
14704
|
-
var PackagedMethodSkillUnavailableError, METHOD_SKILL_RELATIVE_ROOT, GIT_COMMIT_RE, GIT_BLOB_RE, SHA256_RE, REQUIRED_COMPANIONS;
|
|
14705
|
-
var init_method_skill = __esm({
|
|
14706
|
-
"src/package-resources/method-skill.ts"() {
|
|
14707
|
-
"use strict";
|
|
14708
|
-
init_sha256();
|
|
14709
|
-
PackagedMethodSkillUnavailableError = class extends Error {
|
|
14710
|
-
constructor(skillName, path, cause) {
|
|
14711
|
-
super(`Canonical ${skillName} Skill is unavailable at ${path}`, { cause });
|
|
14712
|
-
this.skillName = skillName;
|
|
14713
|
-
this.name = "CanonicalSkillUnavailableError";
|
|
14714
|
-
}
|
|
14715
|
-
skillName;
|
|
14716
|
-
code = "canonical-skill-unavailable";
|
|
14717
|
-
};
|
|
14718
|
-
METHOD_SKILL_RELATIVE_ROOT = "resources/methods";
|
|
14719
|
-
GIT_COMMIT_RE = /^[0-9a-f]{40}$/;
|
|
14720
|
-
GIT_BLOB_RE = /^[0-9a-f]{40}$/;
|
|
14721
|
-
SHA256_RE = /^[0-9a-f]{64}$/;
|
|
14722
|
-
REQUIRED_COMPANIONS = {
|
|
14723
|
-
tdd: ["tests.md", "mocking.md", "agents/openai.yaml"],
|
|
14724
|
-
"diagnosing-bugs": ["agents/openai.yaml", "scripts/hitl-loop.template.sh"],
|
|
14725
|
-
"ak-cross-m-review": [
|
|
14726
|
-
"CONTEXT.md",
|
|
14727
|
-
"LICENSE",
|
|
14728
|
-
"prompts/cmr-completeness.md",
|
|
14729
|
-
"prompts/cmr-reviewer.md"
|
|
14730
|
-
],
|
|
14731
|
-
"resolving-merge-conflicts": ["agents/openai.yaml"]
|
|
14732
|
-
};
|
|
14733
|
-
}
|
|
14734
|
-
});
|
|
14735
|
-
|
|
14736
14487
|
// src/work-subject-identity.ts
|
|
14737
14488
|
import { resolve as resolve12 } from "node:path";
|
|
14738
14489
|
function issueRoot(value) {
|
|
@@ -14944,11 +14695,11 @@ var init_navigator_invocation_identity = __esm({
|
|
|
14944
14695
|
});
|
|
14945
14696
|
|
|
14946
14697
|
// src/receipt-delivery-policy.ts
|
|
14947
|
-
function
|
|
14698
|
+
function isRecord11(value) {
|
|
14948
14699
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
14949
14700
|
}
|
|
14950
14701
|
function parseNoReceiptLifecycleFacts(input) {
|
|
14951
|
-
if (!
|
|
14702
|
+
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")) {
|
|
14952
14703
|
throw new TypeError("malformed no-receipt lifecycle facts");
|
|
14953
14704
|
}
|
|
14954
14705
|
return {
|
|
@@ -15056,7 +14807,6 @@ __export(settlement_exports, {
|
|
|
15056
14807
|
formatTerminalResult: () => formatTerminalResult,
|
|
15057
14808
|
inspectJudgeSession: () => inspectJudgeSession,
|
|
15058
14809
|
isLawfulTypedTerminalOutcome: () => isLawfulTypedTerminalOutcome,
|
|
15059
|
-
observedMethodSkillOptions: () => observedMethodSkillOptions,
|
|
15060
14810
|
presentControlledFailure: () => presentControlledFailure,
|
|
15061
14811
|
presentFailureTerminal: () => presentFailureTerminal,
|
|
15062
14812
|
presentStructuralRejection: () => presentStructuralRejection,
|
|
@@ -15083,15 +14833,15 @@ __export(settlement_exports, {
|
|
|
15083
14833
|
withSubmissions: () => withSubmissions
|
|
15084
14834
|
});
|
|
15085
14835
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
15086
|
-
import { appendFile as appendFile2, readFile as
|
|
15087
|
-
import { dirname as dirname15, join as
|
|
14836
|
+
import { appendFile as appendFile2, readFile as readFile15, readdir as readdir6, rm as rm3, writeFile as writeFile6 } from "node:fs/promises";
|
|
14837
|
+
import { dirname as dirname15, join as join28 } from "node:path";
|
|
15088
14838
|
function sealedLedgerHome(admitted) {
|
|
15089
14839
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
15090
14840
|
}
|
|
15091
14841
|
function ledgerReadScope(admitted, scope) {
|
|
15092
14842
|
return {
|
|
15093
14843
|
home: sealedLedgerHome(admitted),
|
|
15094
|
-
sessionParent:
|
|
14844
|
+
sessionParent: join28(admitted.runDirectory, "session", "session.jsonl"),
|
|
15095
14845
|
...scope?.courtAttemptId === void 0 || scope.courtAttemptId.length === 0 ? {} : { attemptId: scope.courtAttemptId }
|
|
15096
14846
|
};
|
|
15097
14847
|
}
|
|
@@ -15241,7 +14991,7 @@ function presentControlledFailure(failure2, io) {
|
|
|
15241
14991
|
}
|
|
15242
14992
|
async function inspectJudgeSession(sessionFile) {
|
|
15243
14993
|
try {
|
|
15244
|
-
await
|
|
14994
|
+
await readFile15(sessionFile, "utf8");
|
|
15245
14995
|
return { state: "present" };
|
|
15246
14996
|
} catch (error) {
|
|
15247
14997
|
if (isMissingPathError4(error)) return { state: "missing" };
|
|
@@ -15481,7 +15231,7 @@ function sessionReadFailure(error, fallbackMessage) {
|
|
|
15481
15231
|
return failed;
|
|
15482
15232
|
}
|
|
15483
15233
|
async function readBoundSessionEntries(sessionFile) {
|
|
15484
|
-
const text = await
|
|
15234
|
+
const text = await readFile15(sessionFile, "utf8");
|
|
15485
15235
|
const entries = [];
|
|
15486
15236
|
for (const line2 of text.trim().split("\n").filter(Boolean)) {
|
|
15487
15237
|
try {
|
|
@@ -15547,7 +15297,7 @@ async function readSitianRetainedAuditorProviderStop(sessionFile) {
|
|
|
15547
15297
|
const { records } = await readSitianRecords(recordFile);
|
|
15548
15298
|
for (let i = records.length - 1; i >= 0; i -= 1) {
|
|
15549
15299
|
const payload = records[i]?.payload;
|
|
15550
|
-
if (!
|
|
15300
|
+
if (!isRecord12(payload) || !isRecord12(payload.response)) continue;
|
|
15551
15301
|
if (typeof payload.type === "string") continue;
|
|
15552
15302
|
const stop = sessionProviderStopFromAssistant(payload.response);
|
|
15553
15303
|
if (stop !== void 0) return stop;
|
|
@@ -15577,7 +15327,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
15577
15327
|
}
|
|
15578
15328
|
const parentId = parentEntries.find((entry) => entry.type === "session")?.id;
|
|
15579
15329
|
if (parentId === void 0) return void 0;
|
|
15580
|
-
const childDirectories = [
|
|
15330
|
+
const childDirectories = [join28(dirname15(sessionFile), "auditor-roles")];
|
|
15581
15331
|
const valid = [];
|
|
15582
15332
|
let sawAnyDirectory = false;
|
|
15583
15333
|
for (const childDirectory of childDirectories) {
|
|
@@ -15592,12 +15342,12 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
15592
15342
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
15593
15343
|
let entries;
|
|
15594
15344
|
try {
|
|
15595
|
-
entries = await readBoundSessionEntries(
|
|
15345
|
+
entries = await readBoundSessionEntries(join28(childDirectory, file));
|
|
15596
15346
|
} catch (error) {
|
|
15597
15347
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
15598
15348
|
}
|
|
15599
15349
|
const header = entries.find((entry) => entry.type === "session");
|
|
15600
|
-
if (!
|
|
15350
|
+
if (!isRecord12(header)) continue;
|
|
15601
15351
|
const bindingIndexes = [];
|
|
15602
15352
|
for (let i = 0; i < entries.length; i += 1) {
|
|
15603
15353
|
const entry = entries[i];
|
|
@@ -15611,7 +15361,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
15611
15361
|
end: idx + 1 < bindingIndexes.length ? bindingIndexes[idx + 1] : entries.length
|
|
15612
15362
|
})) : [{ entry: void 0, start: 0, end: entries.length }];
|
|
15613
15363
|
for (const { entry: bindingEntry, start, end } of bindingPasses) {
|
|
15614
|
-
const bindingParent = bindingEntry !== void 0 &&
|
|
15364
|
+
const bindingParent = bindingEntry !== void 0 && isRecord12(bindingEntry.data) && isRecord12(bindingEntry.data.parent) ? bindingEntry.data.parent : void 0;
|
|
15615
15365
|
const attemptEntryId = typeof bindingParent?.attemptEntryId === "string" ? bindingParent.attemptEntryId : void 0;
|
|
15616
15366
|
const boundSessionFile = typeof bindingParent?.sessionFile === "string" ? bindingParent.sessionFile : typeof header.parentSession === "string" ? header.parentSession : void 0;
|
|
15617
15367
|
if (boundSessionFile !== sessionFile) continue;
|
|
@@ -15635,12 +15385,12 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
15635
15385
|
if (stop === void 0) continue;
|
|
15636
15386
|
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
15637
15387
|
const entry = entries[i];
|
|
15638
|
-
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !
|
|
15639
|
-
const parent =
|
|
15640
|
-
const failure2 =
|
|
15388
|
+
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord12(entry.data)) continue;
|
|
15389
|
+
const parent = isRecord12(entry.data.parent) ? entry.data.parent : void 0;
|
|
15390
|
+
const failure2 = isRecord12(entry.data.failure) ? entry.data.failure : void 0;
|
|
15641
15391
|
if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId) continue;
|
|
15642
15392
|
if (failure2 === void 0) continue;
|
|
15643
|
-
const identity =
|
|
15393
|
+
const identity = isRecord12(failure2.identity) ? failure2.identity : void 0;
|
|
15644
15394
|
const typedCause = failure2.cause === "provider" || failure2.cause === "activation" || failure2.cause === "session" || failure2.cause === "output" || failure2.cause === "timeout" ? failure2.cause : void 0;
|
|
15645
15395
|
return {
|
|
15646
15396
|
...typedCause === void 0 ? {} : { cause: typedCause },
|
|
@@ -15649,7 +15399,7 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
15649
15399
|
...typeof identity.code === "string" || typeof identity.code === "number" ? { code: identity.code } : {}
|
|
15650
15400
|
} },
|
|
15651
15401
|
...typeof failure2.diagnostic === "string" ? { diagnostic: failure2.diagnostic } : {},
|
|
15652
|
-
...
|
|
15402
|
+
...isRecord12(failure2.details) ? { details: failure2.details } : {}
|
|
15653
15403
|
};
|
|
15654
15404
|
}
|
|
15655
15405
|
}
|
|
@@ -15696,9 +15446,9 @@ function typedFailedTerminatingToolKnownFailure(entries) {
|
|
|
15696
15446
|
if (classification.kind !== "infrastructure") continue;
|
|
15697
15447
|
if (typeof message.toolCallId !== "string" || typeof message.toolName !== "string") continue;
|
|
15698
15448
|
if (boundRoleToolCallForResult(attemptEntries, i, message, message.toolName) === void 0) continue;
|
|
15699
|
-
const textPart = Array.isArray(message.content) ? message.content.find((part) =>
|
|
15700
|
-
const diagnostic =
|
|
15701
|
-
const details =
|
|
15449
|
+
const textPart = Array.isArray(message.content) ? message.content.find((part) => isRecord12(part) && part.type === "text" && typeof part.text === "string") : void 0;
|
|
15450
|
+
const diagnostic = isRecord12(textPart) ? textPart.text : void 0;
|
|
15451
|
+
const details = isRecord12(message.details) ? message.details : classification.fact;
|
|
15702
15452
|
return {
|
|
15703
15453
|
cause: "activation",
|
|
15704
15454
|
identity: { name: message.toolName, code: message.toolCallId },
|
|
@@ -15835,7 +15585,7 @@ function controlledFailureInputFromResolution(resolution) {
|
|
|
15835
15585
|
} : {}
|
|
15836
15586
|
};
|
|
15837
15587
|
}
|
|
15838
|
-
function
|
|
15588
|
+
function isRecord12(value) {
|
|
15839
15589
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15840
15590
|
}
|
|
15841
15591
|
function toolResultText(message) {
|
|
@@ -15860,7 +15610,7 @@ function extractCollectorTargetBindRejection(entries) {
|
|
|
15860
15610
|
const diagnostic = toolResultText(message);
|
|
15861
15611
|
if (diagnostic.length === 0) return void 0;
|
|
15862
15612
|
const details = message.details;
|
|
15863
|
-
const code =
|
|
15613
|
+
const code = isRecord12(details) && typeof details.code === "string" && details.code.trim() !== "" ? details.code : void 0;
|
|
15864
15614
|
return code === void 0 ? { diagnostic } : { diagnostic, code };
|
|
15865
15615
|
}
|
|
15866
15616
|
return void 0;
|
|
@@ -15961,7 +15711,7 @@ function boundRoleToolCallForResult(entries, resultIndex, message, outputToolNam
|
|
|
15961
15711
|
const candidateMessage = entries[index]?.message;
|
|
15962
15712
|
if (candidateMessage?.role === "assistant" && Array.isArray(candidateMessage.content)) {
|
|
15963
15713
|
for (const part of candidateMessage.content) {
|
|
15964
|
-
if (!
|
|
15714
|
+
if (!isRecord12(part) || part.type !== "toolCall" || part.id !== callId) {
|
|
15965
15715
|
continue;
|
|
15966
15716
|
}
|
|
15967
15717
|
if (part.name !== outputToolName) return void 0;
|
|
@@ -16032,7 +15782,7 @@ function parseNavigatorAttendanceDetails(details) {
|
|
|
16032
15782
|
if (typeof details.prose === "string" && details.prose.trim() !== "") {
|
|
16033
15783
|
prose = details.prose;
|
|
16034
15784
|
} else {
|
|
16035
|
-
const next =
|
|
15785
|
+
const next = isRecord12(details.next) && typeof details.next.role === "string" ? details.next.role : void 0;
|
|
16036
15786
|
const reason = typeof details.reason === "string" && details.reason.trim() !== "" ? details.reason : void 0;
|
|
16037
15787
|
const command = typeof details.command === "string" && details.command.trim() !== "" ? details.command : void 0;
|
|
16038
15788
|
if (reason !== void 0 && next !== void 0) {
|
|
@@ -16104,8 +15854,8 @@ function projectTerminalGateFact(rounds) {
|
|
|
16104
15854
|
};
|
|
16105
15855
|
}
|
|
16106
15856
|
async function extractGateFactFromSessionDirectory(sessionDirectory, options = {}) {
|
|
16107
|
-
const directories = [
|
|
16108
|
-
const parentSessionFile = options.parentSessionFile ??
|
|
15857
|
+
const directories = [join28(sessionDirectory, "auditor-roles")];
|
|
15858
|
+
const parentSessionFile = options.parentSessionFile ?? join28(sessionDirectory, "session.jsonl");
|
|
16109
15859
|
const rounds = await readAnalystGateCyclesFromAuditorRoles(directories, {
|
|
16110
15860
|
parentSessionFile
|
|
16111
15861
|
});
|
|
@@ -16141,7 +15891,7 @@ function detourGateContext(admitted, scope) {
|
|
|
16141
15891
|
}
|
|
16142
15892
|
async function withOptionalGateProjection(base, sessionDirectory, gateContext = {}) {
|
|
16143
15893
|
const secondaryEvidence = base.roleOutcome.kind === "failure" ? base.roleOutcome.decisiveFacts.secondaryEvidence : void 0;
|
|
16144
|
-
const skipGate =
|
|
15894
|
+
const skipGate = isRecord12(secondaryEvidence) && secondaryEvidence.kind === "role_infrastructure_failure" && packagedSkipsGateOnInfrastructureStage(secondaryEvidence.stage);
|
|
16145
15895
|
let next = base;
|
|
16146
15896
|
if (!skipGate) {
|
|
16147
15897
|
const gate = await extractGateFactFromSessionDirectory(sessionDirectory, gateContext);
|
|
@@ -16185,7 +15935,7 @@ function extractNavigatorFact(entries) {
|
|
|
16185
15935
|
const entry = entries[i];
|
|
16186
15936
|
if (entry?.type === "custom_message" && entry.customType === "ak-navigator-attendance") {
|
|
16187
15937
|
const details = entry.message?.details ?? entry.details;
|
|
16188
|
-
if (!
|
|
15938
|
+
if (!isRecord12(details)) {
|
|
16189
15939
|
return {
|
|
16190
15940
|
disposition: "unavailable",
|
|
16191
15941
|
source: "unknown",
|
|
@@ -16243,10 +15993,10 @@ async function removeFaceIfPresent(path) {
|
|
|
16243
15993
|
async function clearOppositeTerminalArtifactFace(runDirectory) {
|
|
16244
15994
|
const artifactsDir = roleRunArtifactsDirectory(runDirectory);
|
|
16245
15995
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
16246
|
-
await removeFaceIfPresent(
|
|
15996
|
+
await removeFaceIfPresent(join28(artifactsDir, file));
|
|
16247
15997
|
}
|
|
16248
15998
|
for (const relative4 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
16249
|
-
await removeFaceIfPresent(
|
|
15999
|
+
await removeFaceIfPresent(join28(runDirectory, relative4));
|
|
16250
16000
|
}
|
|
16251
16001
|
for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
|
|
16252
16002
|
await removeFaceIfPresent(path);
|
|
@@ -16275,8 +16025,8 @@ async function publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinat
|
|
|
16275
16025
|
roleOutcome
|
|
16276
16026
|
);
|
|
16277
16027
|
const artifactsDir = await ensureTerminalArtifactFace(admitted.runDirectory);
|
|
16278
|
-
const reportPath =
|
|
16279
|
-
const evidencePath =
|
|
16028
|
+
const reportPath = join28(artifactsDir, "report.json");
|
|
16029
|
+
const evidencePath = join28(artifactsDir, "evidence.json");
|
|
16280
16030
|
await writeFile6(
|
|
16281
16031
|
reportPath,
|
|
16282
16032
|
`${JSON.stringify(bodies.report, null, 2)}
|
|
@@ -16294,8 +16044,8 @@ async function publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinat
|
|
|
16294
16044
|
{ kind: "evidence", path: evidencePath }
|
|
16295
16045
|
];
|
|
16296
16046
|
}
|
|
16297
|
-
async function publishSeatAcceptedArtifacts(admitted, roleOutcome, coordinates, entries = []
|
|
16298
|
-
return publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries
|
|
16047
|
+
async function publishSeatAcceptedArtifacts(admitted, roleOutcome, coordinates, entries = []) {
|
|
16048
|
+
return publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries);
|
|
16299
16049
|
}
|
|
16300
16050
|
async function readLawfulSettlementEntries(sessionFile) {
|
|
16301
16051
|
try {
|
|
@@ -16336,7 +16086,7 @@ async function settleSealedAcceptedOrToolResidual(admitted, authority, scope, ro
|
|
|
16336
16086
|
const residual = boundErroredToolCandidate(entries, index, message, residualToolName);
|
|
16337
16087
|
if (residual === void 0) continue;
|
|
16338
16088
|
const candidate = residual.candidate;
|
|
16339
|
-
const details =
|
|
16089
|
+
const details = isRecord12(candidate) ? candidate : { candidate };
|
|
16340
16090
|
const failed = await settleFailureTerminalResult(
|
|
16341
16091
|
admitted,
|
|
16342
16092
|
{
|
|
@@ -16367,7 +16117,7 @@ async function settleSealedAcceptedOrToolResidual(admitted, authority, scope, ro
|
|
|
16367
16117
|
scope
|
|
16368
16118
|
);
|
|
16369
16119
|
}
|
|
16370
|
-
async function settleSeat(admitted, authority, scope
|
|
16120
|
+
async function settleSeat(admitted, authority, scope) {
|
|
16371
16121
|
const record4 = packagedRoleMetadata(admitted.role);
|
|
16372
16122
|
if (record4 === void 0) {
|
|
16373
16123
|
throw new Error(`no settlement for ${admitted.role}`);
|
|
@@ -16375,7 +16125,7 @@ async function settleSeat(admitted, authority, scope, options) {
|
|
|
16375
16125
|
if (record4.settlement === "accepted") {
|
|
16376
16126
|
return trySettleAcceptedSeatTerminalResult(admitted, authority, scope);
|
|
16377
16127
|
}
|
|
16378
|
-
const publish = (roleOutcome, coordinates, entries) => publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries
|
|
16128
|
+
const publish = (roleOutcome, coordinates, entries) => publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries);
|
|
16379
16129
|
if (record4.settlement === "residual") {
|
|
16380
16130
|
return settleSealedAcceptedOrToolResidual(
|
|
16381
16131
|
admitted,
|
|
@@ -16390,11 +16140,11 @@ async function settleSeat(admitted, authority, scope, options) {
|
|
|
16390
16140
|
const accept = "sealedAcceptedOnly" in record4 && record4.sealedAcceptedOnly === true ? (roleOutcome) => roleOutcome.role === admitted.role && roleOutcome.kind === "accepted" : void 0;
|
|
16391
16141
|
return settleSealedLedgerTerminal(admitted, authority, scope, publish, accept);
|
|
16392
16142
|
}
|
|
16393
|
-
async function trySettleSeatTerminalResult(admitted, authority,
|
|
16394
|
-
return settleSeat(admitted, authority, scope
|
|
16143
|
+
async function trySettleSeatTerminalResult(admitted, authority, scope) {
|
|
16144
|
+
return settleSeat(admitted, authority, scope);
|
|
16395
16145
|
}
|
|
16396
|
-
async function settleSeatTerminalResult(admitted, authority,
|
|
16397
|
-
const settled = await settleSeat(admitted, authority, scope
|
|
16146
|
+
async function settleSeatTerminalResult(admitted, authority, scope) {
|
|
16147
|
+
const settled = await settleSeat(admitted, authority, scope);
|
|
16398
16148
|
if (settled === void 0) {
|
|
16399
16149
|
const label = admitted.role.charAt(0).toUpperCase() + admitted.role.slice(1);
|
|
16400
16150
|
throw new Error(
|
|
@@ -16403,41 +16153,6 @@ async function settleSeatTerminalResult(admitted, authority, options = {}, scope
|
|
|
16403
16153
|
}
|
|
16404
16154
|
return settled;
|
|
16405
16155
|
}
|
|
16406
|
-
function sessionMessageText(message) {
|
|
16407
|
-
if (message === void 0) return "";
|
|
16408
|
-
if (typeof message.content === "string") return message.content;
|
|
16409
|
-
if (!Array.isArray(message.content)) return "";
|
|
16410
|
-
const parts = [];
|
|
16411
|
-
for (const part of message.content) {
|
|
16412
|
-
if (typeof part === "object" && part !== null && !Array.isArray(part) && part.type === "text" && typeof part.text === "string") {
|
|
16413
|
-
parts.push(part.text);
|
|
16414
|
-
}
|
|
16415
|
-
}
|
|
16416
|
-
return parts.join("\n");
|
|
16417
|
-
}
|
|
16418
|
-
function observedMethodSkillOptions(packageRoot, material) {
|
|
16419
|
-
return {
|
|
16420
|
-
methodProvenance: material.provenance,
|
|
16421
|
-
methodSkillPath: material.skillPath,
|
|
16422
|
-
methodSkillConfiguredPath: resolvePackagedMethodSkillPath(packageRoot, material.name)
|
|
16423
|
-
};
|
|
16424
|
-
}
|
|
16425
|
-
function extractObservedMethodInvocations(entries, options) {
|
|
16426
|
-
const observed = [];
|
|
16427
|
-
for (const entry of entries) {
|
|
16428
|
-
if (entry?.type !== "message") continue;
|
|
16429
|
-
const message = entry.message;
|
|
16430
|
-
if (message?.role !== "user") continue;
|
|
16431
|
-
const text = sessionMessageText(message);
|
|
16432
|
-
if (text.length === 0) continue;
|
|
16433
|
-
const hit = observePackagedMethodSkillInvocation(text, {
|
|
16434
|
-
name: options.name,
|
|
16435
|
-
allowedLocations: options.allowedLocations
|
|
16436
|
-
});
|
|
16437
|
-
if (hit !== void 0) observed.push(hit);
|
|
16438
|
-
}
|
|
16439
|
-
return Object.freeze(observed);
|
|
16440
|
-
}
|
|
16441
16156
|
function extractDoctorCandidateFacts(entries) {
|
|
16442
16157
|
const scanStart = currentAttemptStartIndex(entries);
|
|
16443
16158
|
for (let i = entries.length - 1; i >= scanStart; i -= 1) {
|
|
@@ -16446,7 +16161,7 @@ function extractDoctorCandidateFacts(entries) {
|
|
|
16446
16161
|
continue;
|
|
16447
16162
|
}
|
|
16448
16163
|
const data = entry.data;
|
|
16449
|
-
if (!
|
|
16164
|
+
if (!isRecord12(data)) return {};
|
|
16450
16165
|
return {
|
|
16451
16166
|
...data.cost === void 0 ? {} : { cost: data.cost },
|
|
16452
16167
|
...data.auditNoReceipt === void 0 ? {} : { auditNoReceipt: data.auditNoReceipt }
|
|
@@ -16490,25 +16205,7 @@ function doctorReportFacts(face, roleOutcome, entries) {
|
|
|
16490
16205
|
...facts.auditNoReceipt === void 0 ? {} : { auditNoReceipt: facts.auditNoReceipt }
|
|
16491
16206
|
};
|
|
16492
16207
|
}
|
|
16493
|
-
function
|
|
16494
|
-
if (face.method === void 0) return {};
|
|
16495
|
-
if (face.method === "optional") {
|
|
16496
|
-
return options.methodProvenance === void 0 ? {} : { methodProvenance: options.methodProvenance };
|
|
16497
|
-
}
|
|
16498
|
-
if (options.methodProvenance === void 0 || options.methodSkillPath === void 0 || options.methodSkillConfiguredPath === void 0) {
|
|
16499
|
-
throw new Error("observed method publication is missing packaged method coordinates");
|
|
16500
|
-
}
|
|
16501
|
-
const methodInvocations = extractObservedMethodInvocations(entries, {
|
|
16502
|
-
name: options.methodProvenance.name,
|
|
16503
|
-
allowedLocations: [options.methodSkillPath, options.methodSkillConfiguredPath]
|
|
16504
|
-
});
|
|
16505
|
-
return {
|
|
16506
|
-
methodProvenance: options.methodProvenance,
|
|
16507
|
-
methodInvocationObserved: methodInvocations.length > 0,
|
|
16508
|
-
methodInvocations
|
|
16509
|
-
};
|
|
16510
|
-
}
|
|
16511
|
-
async function publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries, options = {}) {
|
|
16208
|
+
async function publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries) {
|
|
16512
16209
|
const face = seatArtifactFace(admitted.role);
|
|
16513
16210
|
const phase = face.reportPhase === true ? { phase: readAdmittedPath(admitted, "phase") } : {};
|
|
16514
16211
|
return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
|
|
@@ -16526,8 +16223,7 @@ async function publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates,
|
|
|
16526
16223
|
sessionDirectory: coordinates.sessionDirectory,
|
|
16527
16224
|
sessionFile: coordinates.sessionFile,
|
|
16528
16225
|
admittedRequestPath: admitted.admittedRequestPath,
|
|
16529
|
-
attachments: acceptedArtifactAttachmentRefs(admitted.attachments)
|
|
16530
|
-
...observedMethodTail(face, entries, options)
|
|
16226
|
+
attachments: acceptedArtifactAttachmentRefs(admitted.attachments)
|
|
16531
16227
|
}
|
|
16532
16228
|
});
|
|
16533
16229
|
}
|
|
@@ -16550,7 +16246,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
16550
16246
|
let residual;
|
|
16551
16247
|
for (let index = entries.length - 1; index >= scanStart; index -= 1) {
|
|
16552
16248
|
const entry = entries[index];
|
|
16553
|
-
if (entry?.type === "custom" && entry.customType === "ak-role-submission-closure" &&
|
|
16249
|
+
if (entry?.type === "custom" && entry.customType === "ak-role-submission-closure" && isRecord12(entry.data) && entry.data.toolName === spec.toolName && classifyPackagedRoleTerminalResult(entry.data).kind === "accepted") {
|
|
16554
16250
|
thisAttemptHasSeatSuccess = true;
|
|
16555
16251
|
}
|
|
16556
16252
|
const message = entries[index]?.message;
|
|
@@ -16590,7 +16286,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
16590
16286
|
);
|
|
16591
16287
|
}
|
|
16592
16288
|
if (residual !== void 0) {
|
|
16593
|
-
const details =
|
|
16289
|
+
const details = isRecord12(residual.candidate) ? residual.candidate : { candidate: residual.candidate };
|
|
16594
16290
|
const failed = await settleFailureTerminalResult(
|
|
16595
16291
|
admitted,
|
|
16596
16292
|
{
|
|
@@ -16620,11 +16316,8 @@ async function trySettleAcceptedSeatTerminalResult(admitted, authority, scope) {
|
|
|
16620
16316
|
}
|
|
16621
16317
|
return applySecretariatCountersignTerminal(admitted, authority, settled);
|
|
16622
16318
|
}
|
|
16623
|
-
async function trySettlePublicSeat(admitted, authority, scope
|
|
16624
|
-
|
|
16625
|
-
if (face.method === "observed" && material === void 0) return void 0;
|
|
16626
|
-
const options = face.method === "observed" && material !== void 0 ? observedMethodSkillOptions(packageRoot, material) : face.method === "optional" && material !== void 0 ? { methodProvenance: material.provenance } : {};
|
|
16627
|
-
return settleSeat(admitted, authority, scope, options);
|
|
16319
|
+
async function trySettlePublicSeat(admitted, authority, scope) {
|
|
16320
|
+
return settleSeat(admitted, authority, scope);
|
|
16628
16321
|
}
|
|
16629
16322
|
function countersignTerminalFromEntries(entries) {
|
|
16630
16323
|
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
@@ -16643,7 +16336,7 @@ function countersignTerminalFromEntries(entries) {
|
|
|
16643
16336
|
return void 0;
|
|
16644
16337
|
}
|
|
16645
16338
|
function withCountersignTerminalFact(roleOutcome, officer) {
|
|
16646
|
-
const prior = roleOutcome.decisiveFacts !== void 0 &&
|
|
16339
|
+
const prior = roleOutcome.decisiveFacts !== void 0 && isRecord12(roleOutcome.decisiveFacts) ? roleOutcome.decisiveFacts : {};
|
|
16647
16340
|
return {
|
|
16648
16341
|
...roleOutcome,
|
|
16649
16342
|
decisiveFacts: {
|
|
@@ -16656,7 +16349,7 @@ function acceptedSecretariatDefinesOfficerProjection(roleOutcome) {
|
|
|
16656
16349
|
const payloads = roleOutcome.payloads ?? [];
|
|
16657
16350
|
for (let index = payloads.length - 1; index >= 0; index -= 1) {
|
|
16658
16351
|
const payload = payloads[index];
|
|
16659
|
-
if (!
|
|
16352
|
+
if (!isRecord12(payload)) continue;
|
|
16660
16353
|
const status = payload.secretariatStatus;
|
|
16661
16354
|
if (typeof status !== "string") continue;
|
|
16662
16355
|
return status === "converged";
|
|
@@ -16732,7 +16425,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
|
|
|
16732
16425
|
const candidates = [
|
|
16733
16426
|
...preferredCandidates,
|
|
16734
16427
|
// One unique name per fallback dir — collisions on fixed names cannot exhaust this.
|
|
16735
|
-
...uniqueFallbackDirs.map((dir) =>
|
|
16428
|
+
...uniqueFallbackDirs.map((dir) => join28(dir, `${stem}.${randomUUID4()}.json`))
|
|
16736
16429
|
];
|
|
16737
16430
|
for (let i = 0; i < candidates.length; i += 1) {
|
|
16738
16431
|
const path = candidates[i];
|
|
@@ -16793,20 +16486,20 @@ async function publishFailureArtifacts(admitted, failure2, authority) {
|
|
|
16793
16486
|
baseDir
|
|
16794
16487
|
);
|
|
16795
16488
|
const errorCandidates = underArtifacts ? [
|
|
16796
|
-
|
|
16797
|
-
|
|
16798
|
-
|
|
16489
|
+
join28(baseDir, "error.json"),
|
|
16490
|
+
join28(baseDir, "error.settlement.json"),
|
|
16491
|
+
join28(admitted.runDirectory, "error.settlement.json")
|
|
16799
16492
|
] : [
|
|
16800
|
-
|
|
16801
|
-
|
|
16493
|
+
join28(baseDir, "error.settlement.json"),
|
|
16494
|
+
join28(baseDir, "error.json")
|
|
16802
16495
|
];
|
|
16803
16496
|
const evidenceCandidates = underArtifacts ? [
|
|
16804
|
-
|
|
16805
|
-
|
|
16806
|
-
|
|
16497
|
+
join28(baseDir, "evidence.json"),
|
|
16498
|
+
join28(baseDir, "evidence.settlement.json"),
|
|
16499
|
+
join28(admitted.runDirectory, "evidence.settlement.json")
|
|
16807
16500
|
] : [
|
|
16808
|
-
|
|
16809
|
-
|
|
16501
|
+
join28(baseDir, "evidence.settlement.json"),
|
|
16502
|
+
join28(baseDir, "evidence.json")
|
|
16810
16503
|
];
|
|
16811
16504
|
const errorPayloadBase = {
|
|
16812
16505
|
kind: "error",
|
|
@@ -16982,10 +16675,10 @@ function presentFailureTerminal(terminal, io) {
|
|
|
16982
16675
|
}
|
|
16983
16676
|
function defaultNavigatorGraceSleep() {
|
|
16984
16677
|
let timer;
|
|
16985
|
-
const sleep2 = ((ms) => new Promise((
|
|
16678
|
+
const sleep2 = ((ms) => new Promise((resolve21) => {
|
|
16986
16679
|
timer = setTimeout(() => {
|
|
16987
16680
|
timer = void 0;
|
|
16988
|
-
|
|
16681
|
+
resolve21();
|
|
16989
16682
|
}, ms);
|
|
16990
16683
|
}));
|
|
16991
16684
|
sleep2.cancel = () => {
|
|
@@ -16997,7 +16690,7 @@ function defaultNavigatorGraceSleep() {
|
|
|
16997
16690
|
return sleep2;
|
|
16998
16691
|
}
|
|
16999
16692
|
function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2 = defaultNavigatorGraceSleep()) {
|
|
17000
|
-
return new Promise((
|
|
16693
|
+
return new Promise((resolve21, reject) => {
|
|
17001
16694
|
let settled = false;
|
|
17002
16695
|
const finish = (action) => {
|
|
17003
16696
|
if (settled) return;
|
|
@@ -17006,11 +16699,11 @@ function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2
|
|
|
17006
16699
|
action();
|
|
17007
16700
|
};
|
|
17008
16701
|
void work.then(
|
|
17009
|
-
(value) => finish(() =>
|
|
16702
|
+
(value) => finish(() => resolve21({ status: "done", value })),
|
|
17010
16703
|
(error) => finish(() => reject(error))
|
|
17011
16704
|
);
|
|
17012
16705
|
void sleep2(graceMs).then(() => {
|
|
17013
|
-
finish(() =>
|
|
16706
|
+
finish(() => resolve21({ status: "timeout" }));
|
|
17014
16707
|
});
|
|
17015
16708
|
});
|
|
17016
16709
|
}
|
|
@@ -17038,7 +16731,6 @@ var init_settlement = __esm({
|
|
|
17038
16731
|
init_reviewer_output();
|
|
17039
16732
|
init_packaged_role_registry();
|
|
17040
16733
|
init_secretariat_contracts();
|
|
17041
|
-
init_method_skill();
|
|
17042
16734
|
init_navigator_invocation_identity();
|
|
17043
16735
|
init_receipt_delivery_policy();
|
|
17044
16736
|
init_role_run_placement();
|
|
@@ -17085,17 +16777,17 @@ var init_settlement = __esm({
|
|
|
17085
16777
|
});
|
|
17086
16778
|
|
|
17087
16779
|
// src/session-identity.ts
|
|
17088
|
-
import { mkdir as mkdir2, readFile as
|
|
17089
|
-
import { dirname as dirname16, join as
|
|
16780
|
+
import { mkdir as mkdir2, readFile as readFile16, rename as rename2, writeFile as writeFile7 } from "node:fs/promises";
|
|
16781
|
+
import { dirname as dirname16, join as join29 } from "node:path";
|
|
17090
16782
|
function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
17091
|
-
const bindingPath = (principal) =>
|
|
16783
|
+
const bindingPath = (principal) => join29(authority.decode(principal).sessionDirectory, sessionBindingFile);
|
|
17092
16784
|
return {
|
|
17093
16785
|
resolveSessionFile(principal) {
|
|
17094
16786
|
return authority.decode(principal).sessionFile;
|
|
17095
16787
|
},
|
|
17096
16788
|
async load(principal) {
|
|
17097
16789
|
try {
|
|
17098
|
-
const value = JSON.parse(await
|
|
16790
|
+
const value = JSON.parse(await readFile16(bindingPath(principal), "utf8"));
|
|
17099
16791
|
if (typeof value !== "object" || value === null || typeof value.sessionId !== "string") {
|
|
17100
16792
|
throw new Error("durable session binding is invalid");
|
|
17101
16793
|
}
|
|
@@ -17146,9 +16838,9 @@ __export(case_dossier_delivery_exports, {
|
|
|
17146
16838
|
loadCaseDossierReadingMaterial: () => loadCaseDossierReadingMaterial,
|
|
17147
16839
|
projectCaseDossierPointerSection: () => projectCaseDossierPointerSection
|
|
17148
16840
|
});
|
|
17149
|
-
import { mkdtemp as mkdtemp3, readFile as
|
|
16841
|
+
import { mkdtemp as mkdtemp3, readFile as readFile17, rm as rm4, writeFile as writeFile8 } from "node:fs/promises";
|
|
17150
16842
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
17151
|
-
import { join as
|
|
16843
|
+
import { join as join30 } from "node:path";
|
|
17152
16844
|
async function projectCaseDossierPointerSection(input) {
|
|
17153
16845
|
if (input.ticketNumber === void 0) {
|
|
17154
16846
|
return [
|
|
@@ -17175,9 +16867,9 @@ async function deliverCaseDossierAsAttachment(input) {
|
|
|
17175
16867
|
projectRoot: input.projectRoot,
|
|
17176
16868
|
home: input.home
|
|
17177
16869
|
});
|
|
17178
|
-
const stagingDir = await mkdtemp3(
|
|
16870
|
+
const stagingDir = await mkdtemp3(join30(tmpdir3(), "ak-case-dossier-"));
|
|
17179
16871
|
try {
|
|
17180
|
-
const stagingPath =
|
|
16872
|
+
const stagingPath = join30(stagingDir, CASE_DOSSIER_ATTACH_FILE);
|
|
17181
16873
|
await writeFile8(stagingPath, `${section}
|
|
17182
16874
|
`, "utf8");
|
|
17183
16875
|
return await freezeAttachmentsIntoRun(
|
|
@@ -17190,7 +16882,7 @@ async function deliverCaseDossierAsAttachment(input) {
|
|
|
17190
16882
|
}
|
|
17191
16883
|
}
|
|
17192
16884
|
async function loadCaseDossierReadingMaterial(runDirectory) {
|
|
17193
|
-
const frozenPath =
|
|
16885
|
+
const frozenPath = join30(
|
|
17194
16886
|
runDirectory,
|
|
17195
16887
|
"attachments",
|
|
17196
16888
|
CASE_DOSSIER_ATTACH_KEY,
|
|
@@ -17198,7 +16890,7 @@ async function loadCaseDossierReadingMaterial(runDirectory) {
|
|
|
17198
16890
|
);
|
|
17199
16891
|
let section;
|
|
17200
16892
|
try {
|
|
17201
|
-
section = await
|
|
16893
|
+
section = await readFile17(frozenPath, "utf8");
|
|
17202
16894
|
} catch (error) {
|
|
17203
16895
|
if (error.code === "ENOENT") return void 0;
|
|
17204
16896
|
throw error;
|
|
@@ -17222,7 +16914,7 @@ var init_case_dossier_delivery = __esm({
|
|
|
17222
16914
|
|
|
17223
16915
|
// src/host-transition-prior-native.ts
|
|
17224
16916
|
import { access as access3, readdir as readdir7 } from "node:fs/promises";
|
|
17225
|
-
import { dirname as dirname17, join as
|
|
16917
|
+
import { dirname as dirname17, join as join31 } from "node:path";
|
|
17226
16918
|
function isEnoent2(error) {
|
|
17227
16919
|
return typeof error === "object" && error !== null && error.code === "ENOENT";
|
|
17228
16920
|
}
|
|
@@ -17247,7 +16939,7 @@ async function listSitianRecordPaths(sessionParent) {
|
|
|
17247
16939
|
const recordPaths = [];
|
|
17248
16940
|
for (const entry of entries) {
|
|
17249
16941
|
if (!entry.isDirectory()) continue;
|
|
17250
|
-
const recordFile =
|
|
16942
|
+
const recordFile = join31(sessionRoot, entry.name, "records.jsonl");
|
|
17251
16943
|
try {
|
|
17252
16944
|
await access3(recordFile);
|
|
17253
16945
|
recordPaths.push(recordFile);
|
|
@@ -17299,7 +16991,7 @@ var init_process_cancel = __esm({
|
|
|
17299
16991
|
import { constants as fsConstants2 } from "node:fs";
|
|
17300
16992
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
17301
16993
|
import { lstat as lstat6, mkdir as mkdir3, open as open2 } from "node:fs/promises";
|
|
17302
|
-
import { join as
|
|
16994
|
+
import { join as join32 } from "node:path";
|
|
17303
16995
|
async function persistReturnedRunState(admitted, authority, options) {
|
|
17304
16996
|
if (options?.lawful === true) {
|
|
17305
16997
|
await markRunTerminal(admitted.runDirectory);
|
|
@@ -17370,7 +17062,7 @@ function jsonSafeReplacer() {
|
|
|
17370
17062
|
};
|
|
17371
17063
|
}
|
|
17372
17064
|
async function writeHardenedArtifactFile(artifactsDir, namePrefix, payload) {
|
|
17373
|
-
const filePath =
|
|
17065
|
+
const filePath = join32(artifactsDir, `${namePrefix}-${randomUUID5()}.json`);
|
|
17374
17066
|
const body = `${JSON.stringify(payload, jsonSafeReplacer(), 2)}
|
|
17375
17067
|
`;
|
|
17376
17068
|
const noFollowFlag = typeof fsConstants2.O_NOFOLLOW === "number" ? fsConstants2.O_NOFOLLOW : 0;
|
|
@@ -17659,7 +17351,7 @@ var init_auto_resume = __esm({
|
|
|
17659
17351
|
// src/public-cli/post-admission.ts
|
|
17660
17352
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
17661
17353
|
import { writeFile as writeFile9 } from "node:fs/promises";
|
|
17662
|
-
import { isAbsolute as isAbsolute8, join as
|
|
17354
|
+
import { isAbsolute as isAbsolute8, join as join33, resolve as resolve13 } from "node:path";
|
|
17663
17355
|
function describeCaughtError(error) {
|
|
17664
17356
|
if (error instanceof Error) {
|
|
17665
17357
|
const code = error.code;
|
|
@@ -17750,7 +17442,7 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
17750
17442
|
try {
|
|
17751
17443
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
17752
17444
|
await writeFile9(
|
|
17753
|
-
|
|
17445
|
+
join33(artifactsDir, `post-admission-diagnostic-${randomUUID6()}.json`),
|
|
17754
17446
|
`${JSON.stringify({ version: 1, ...payload }, null, 2)}
|
|
17755
17447
|
`,
|
|
17756
17448
|
{ encoding: "utf8", flag: "wx" }
|
|
@@ -17767,30 +17459,6 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
17767
17459
|
} catch {
|
|
17768
17460
|
}
|
|
17769
17461
|
}
|
|
17770
|
-
async function resolveResumeMethodMaterialAdapters(input) {
|
|
17771
|
-
if (input.shouldLoad === false) {
|
|
17772
|
-
return { kind: "continue", adapters: input.emptyAdapters };
|
|
17773
|
-
}
|
|
17774
|
-
try {
|
|
17775
|
-
const material = await input.loadMaterial();
|
|
17776
|
-
return { kind: "continue", adapters: input.adaptersWith(material) };
|
|
17777
|
-
} catch (error) {
|
|
17778
|
-
const terminal = await presentControlledFailure2(
|
|
17779
|
-
input.admitted,
|
|
17780
|
-
{
|
|
17781
|
-
timedOut: false,
|
|
17782
|
-
code: null,
|
|
17783
|
-
stderr: "",
|
|
17784
|
-
thrown: error,
|
|
17785
|
-
...input.knownCause === void 0 ? {} : { knownCause: input.knownCause }
|
|
17786
|
-
},
|
|
17787
|
-
input.emptyAdapters,
|
|
17788
|
-
input.authority,
|
|
17789
|
-
input.io
|
|
17790
|
-
);
|
|
17791
|
-
return { kind: "terminal", ...terminal };
|
|
17792
|
-
}
|
|
17793
|
-
}
|
|
17794
17462
|
async function presentControlledFailure2(admitted, failureInput, adapters, authority, io, persistRunState = true) {
|
|
17795
17463
|
const hasThrown = Object.hasOwn(failureInput, "thrown");
|
|
17796
17464
|
const resumeObservation = await resolveControlledFailureResumeObservation({
|
|
@@ -17915,7 +17583,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
17915
17583
|
const rows = await readRecordedSubmissionRows(
|
|
17916
17584
|
admitted.projectRoot,
|
|
17917
17585
|
admitted.runId,
|
|
17918
|
-
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent:
|
|
17586
|
+
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent: join33(admitted.runDirectory, "session", "session.jsonl") }
|
|
17919
17587
|
);
|
|
17920
17588
|
const asserted = rows.filter((row) => row.kind === "accepted" && row.role === admitted.role).map((row) => row.accepted).find((payload) => {
|
|
17921
17589
|
if (payload === null || typeof payload !== "object" || Array.isArray(payload)) return false;
|
|
@@ -18073,7 +17741,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18073
17741
|
let stderrLogWriteFailure;
|
|
18074
17742
|
try {
|
|
18075
17743
|
await writeFile9(
|
|
18076
|
-
|
|
17744
|
+
join33(admitted.runDirectory, "stderr.log"),
|
|
18077
17745
|
result.stderr,
|
|
18078
17746
|
"utf8"
|
|
18079
17747
|
);
|
|
@@ -18309,6 +17977,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
18309
17977
|
return {
|
|
18310
17978
|
packageRoot: env.packageRoot,
|
|
18311
17979
|
home: env.home,
|
|
17980
|
+
...env.host === void 0 ? {} : { host: env.host },
|
|
18312
17981
|
agentDir: env.agentDir,
|
|
18313
17982
|
...env.model === void 0 ? {} : { model: env.model },
|
|
18314
17983
|
...pickEngineAxis(env),
|
|
@@ -18327,6 +17996,7 @@ function roleTurnOptions(env, admitted, continuation) {
|
|
|
18327
17996
|
return {
|
|
18328
17997
|
packageRoot: env.packageRoot,
|
|
18329
17998
|
home: env.home,
|
|
17999
|
+
...env.host === void 0 ? {} : { host: env.host },
|
|
18330
18000
|
agentDir: env.agentDir,
|
|
18331
18001
|
...env.model === void 0 ? {} : { model: env.model },
|
|
18332
18002
|
...pickEngineAxis(env),
|
|
@@ -18350,7 +18020,7 @@ async function dispatchAfterWriterLease(input) {
|
|
|
18350
18020
|
}
|
|
18351
18021
|
function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
|
|
18352
18022
|
const absolute = isAbsolute8(attachmentPath) ? attachmentPath : resolve13(attachmentPath);
|
|
18353
|
-
return pathContainedIn(
|
|
18023
|
+
return pathContainedIn(join33(runDirectory, "attachments"), absolute);
|
|
18354
18024
|
}
|
|
18355
18025
|
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
18356
18026
|
if (summons === void 0) return void 0;
|
|
@@ -18679,6 +18349,150 @@ var init_seat_ticket_binding = __esm({
|
|
|
18679
18349
|
}
|
|
18680
18350
|
});
|
|
18681
18351
|
|
|
18352
|
+
// src/public-cli/machine-method-skills.ts
|
|
18353
|
+
import { accessSync, constants as constants2, statSync as statSync4 } from "node:fs";
|
|
18354
|
+
import { lstat as lstat7, mkdir as mkdir4, symlink } from "node:fs/promises";
|
|
18355
|
+
import { join as join34 } from "node:path";
|
|
18356
|
+
import { spawnSync } from "node:child_process";
|
|
18357
|
+
function skillRoot(home) {
|
|
18358
|
+
return join34(home, ".agents/skills");
|
|
18359
|
+
}
|
|
18360
|
+
function installedMethodSkillPath(home, name) {
|
|
18361
|
+
return installedSkillPath(skillRoot(home), name);
|
|
18362
|
+
}
|
|
18363
|
+
function installedSkillPath(root, name) {
|
|
18364
|
+
const path = join34(root, name, "SKILL.md");
|
|
18365
|
+
try {
|
|
18366
|
+
if (!statSync4(path).isFile()) return void 0;
|
|
18367
|
+
accessSync(path, constants2.R_OK);
|
|
18368
|
+
return path;
|
|
18369
|
+
} catch (error) {
|
|
18370
|
+
const code = error.code;
|
|
18371
|
+
if (code === "ENOENT" || code === "ENOTDIR" || code === "EACCES" || code === "EPERM" || code === "ELOOP") return void 0;
|
|
18372
|
+
throw error;
|
|
18373
|
+
}
|
|
18374
|
+
}
|
|
18375
|
+
function linkedSkillRoot(home, host) {
|
|
18376
|
+
if (host === "claude" || host === "claude-code") {
|
|
18377
|
+
return join34(process.env.CLAUDE_CONFIG_DIR?.trim() || join34(home, ".claude"), "skills");
|
|
18378
|
+
}
|
|
18379
|
+
if (host === "hermes") return join34(home, ".hermes/skills");
|
|
18380
|
+
return void 0;
|
|
18381
|
+
}
|
|
18382
|
+
async function occupied(path) {
|
|
18383
|
+
try {
|
|
18384
|
+
await lstat7(path);
|
|
18385
|
+
return true;
|
|
18386
|
+
} catch (error) {
|
|
18387
|
+
if (error.code !== "ENOENT") throw error;
|
|
18388
|
+
return false;
|
|
18389
|
+
}
|
|
18390
|
+
}
|
|
18391
|
+
function warnOccupied(path, stdout) {
|
|
18392
|
+
stdout(`Warning: ${path} is already occupied; left untouched.
|
|
18393
|
+
`);
|
|
18394
|
+
}
|
|
18395
|
+
async function warnMissingMethodSkills(home, host, role, skills, stdout) {
|
|
18396
|
+
const missing = [];
|
|
18397
|
+
const linkedRoot = linkedSkillRoot(home, host);
|
|
18398
|
+
for (const skill of skills) {
|
|
18399
|
+
if (installedMethodSkillPath(home, skill) === void 0 || linkedRoot !== void 0 && installedSkillPath(linkedRoot, skill) === void 0) missing.push(skill);
|
|
18400
|
+
}
|
|
18401
|
+
for (const skill of missing) {
|
|
18402
|
+
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.
|
|
18403
|
+
`);
|
|
18404
|
+
}
|
|
18405
|
+
}
|
|
18406
|
+
function runSkillsCli(args, home) {
|
|
18407
|
+
const result = spawnSync("npx", ["--yes", "skills", ...args], {
|
|
18408
|
+
stdio: "inherit",
|
|
18409
|
+
env: { ...process.env, HOME: home }
|
|
18410
|
+
});
|
|
18411
|
+
if (result.error !== void 0) throw result.error;
|
|
18412
|
+
return result.status === 0;
|
|
18413
|
+
}
|
|
18414
|
+
function addSkills(source, skills, home) {
|
|
18415
|
+
if (skills.length === 0) return true;
|
|
18416
|
+
return runSkillsCli([
|
|
18417
|
+
"add",
|
|
18418
|
+
source,
|
|
18419
|
+
...skills.flatMap((skill) => ["--skill", skill]),
|
|
18420
|
+
"--agent",
|
|
18421
|
+
"codex",
|
|
18422
|
+
"--global",
|
|
18423
|
+
"--yes"
|
|
18424
|
+
], home);
|
|
18425
|
+
}
|
|
18426
|
+
function updateRequiredSkills(home) {
|
|
18427
|
+
const names = packagedMethodSkillNames();
|
|
18428
|
+
if (names.length === 0) return true;
|
|
18429
|
+
return runSkillsCli(["update", "-g", "-y", ...names], home);
|
|
18430
|
+
}
|
|
18431
|
+
async function runMachineSkillSetup(home, stdout) {
|
|
18432
|
+
const canonical = skillRoot(home);
|
|
18433
|
+
const missingBySource = /* @__PURE__ */ new Map();
|
|
18434
|
+
let unsourced = false;
|
|
18435
|
+
for (const name of packagedMethodSkillNames()) {
|
|
18436
|
+
const path = join34(canonical, name);
|
|
18437
|
+
if (await occupied(path)) {
|
|
18438
|
+
warnOccupied(path, stdout);
|
|
18439
|
+
continue;
|
|
18440
|
+
}
|
|
18441
|
+
const source = SKILL_SOURCE[name];
|
|
18442
|
+
if (source === void 0) {
|
|
18443
|
+
unsourced = true;
|
|
18444
|
+
stdout(`Warning: required machine Skill "${name}" has no install source; setup did not install it.
|
|
18445
|
+
`);
|
|
18446
|
+
continue;
|
|
18447
|
+
}
|
|
18448
|
+
const missing = missingBySource.get(source) ?? [];
|
|
18449
|
+
missing.push(name);
|
|
18450
|
+
missingBySource.set(source, missing);
|
|
18451
|
+
}
|
|
18452
|
+
for (const [source, missing] of missingBySource) {
|
|
18453
|
+
if (!addSkills(source, missing, home)) return 1;
|
|
18454
|
+
}
|
|
18455
|
+
if (unsourced) return 1;
|
|
18456
|
+
for (const host of ["claude-code", "hermes"]) {
|
|
18457
|
+
const root = linkedSkillRoot(home, host);
|
|
18458
|
+
const binaryFromHome = host === "claude-code" ? HEADLESS_HOST_DESCRIPTIONS.claude.binaryFromHome : HOST_DESCRIPTIONS.hermes.binaryFromHome;
|
|
18459
|
+
try {
|
|
18460
|
+
accessSync(join34(home, ...binaryFromHome), constants2.X_OK);
|
|
18461
|
+
} catch (error) {
|
|
18462
|
+
if (["ENOENT", "ENOTDIR", "EACCES"].includes(error.code ?? "")) continue;
|
|
18463
|
+
throw error;
|
|
18464
|
+
}
|
|
18465
|
+
for (const name of packagedMethodSkillNames()) {
|
|
18466
|
+
const target = join34(canonical, name);
|
|
18467
|
+
if (installedMethodSkillPath(home, name) === void 0) continue;
|
|
18468
|
+
const link = join34(root, name);
|
|
18469
|
+
if (await occupied(link)) {
|
|
18470
|
+
warnOccupied(link, stdout);
|
|
18471
|
+
continue;
|
|
18472
|
+
}
|
|
18473
|
+
await mkdir4(root, { recursive: true });
|
|
18474
|
+
await symlink(target, link, "dir");
|
|
18475
|
+
}
|
|
18476
|
+
}
|
|
18477
|
+
if (!updateRequiredSkills(home)) return 1;
|
|
18478
|
+
stdout("Machine method Skills setup finished. Existing same-name Skills were left untouched.\n");
|
|
18479
|
+
return 0;
|
|
18480
|
+
}
|
|
18481
|
+
var SKILL_SOURCE;
|
|
18482
|
+
var init_machine_method_skills = __esm({
|
|
18483
|
+
"src/public-cli/machine-method-skills.ts"() {
|
|
18484
|
+
"use strict";
|
|
18485
|
+
init_host_descriptions();
|
|
18486
|
+
init_packaged_role_registry();
|
|
18487
|
+
SKILL_SOURCE = {
|
|
18488
|
+
tdd: "mattpocock/skills",
|
|
18489
|
+
"diagnosing-bugs": "mattpocock/skills",
|
|
18490
|
+
"resolving-merge-conflicts": "mattpocock/skills",
|
|
18491
|
+
"ak-cross-m-review": "Akagilnc/ak-cross-m-review"
|
|
18492
|
+
};
|
|
18493
|
+
}
|
|
18494
|
+
});
|
|
18495
|
+
|
|
18682
18496
|
// src/public-cli/turn-request.ts
|
|
18683
18497
|
function projectRoleTurnRequest(admitted, roleDetails, options) {
|
|
18684
18498
|
const cwd = admitted.projectRoot ?? admitted.repoRoot ?? admitted.cwd;
|
|
@@ -18740,7 +18554,7 @@ function activationForAdmitted(admitted) {
|
|
|
18740
18554
|
}
|
|
18741
18555
|
return activation;
|
|
18742
18556
|
}
|
|
18743
|
-
function
|
|
18557
|
+
function requiredMethodSkills(admitted) {
|
|
18744
18558
|
const record4 = packagedRoleMetadata(admitted.role);
|
|
18745
18559
|
const names = [];
|
|
18746
18560
|
if (record4 !== void 0 && "methodSkills" in record4 && record4.methodSkills !== void 0) {
|
|
@@ -18748,33 +18562,40 @@ function methodBindings(admitted, packageRoot) {
|
|
|
18748
18562
|
}
|
|
18749
18563
|
const apply = packagedSettleSkill(admitted);
|
|
18750
18564
|
if (apply !== void 0 && !names.includes(apply)) names.push(apply);
|
|
18751
|
-
return names
|
|
18752
|
-
kind: "skill",
|
|
18753
|
-
path: resolvePackagedMethodSkillPath(packageRoot, name)
|
|
18754
|
-
}));
|
|
18565
|
+
return names;
|
|
18755
18566
|
}
|
|
18756
|
-
function
|
|
18567
|
+
function methodBindings(admitted, home, host) {
|
|
18568
|
+
if (host !== void 0 && host !== "pi") return [];
|
|
18569
|
+
return requiredMethodSkills(admitted).flatMap((name) => {
|
|
18570
|
+
const path = installedMethodSkillPath(home, name);
|
|
18571
|
+
return path === void 0 ? [] : [{
|
|
18572
|
+
kind: "skill",
|
|
18573
|
+
path
|
|
18574
|
+
}];
|
|
18575
|
+
});
|
|
18576
|
+
}
|
|
18577
|
+
function admittedSeatTurnDetails(admitted, home, host) {
|
|
18757
18578
|
return {
|
|
18758
18579
|
activation: activationForAdmitted(admitted),
|
|
18759
|
-
methods: methodBindings(admitted,
|
|
18580
|
+
methods: methodBindings(admitted, home, host)
|
|
18760
18581
|
};
|
|
18761
18582
|
}
|
|
18762
18583
|
var init_turn_request = __esm({
|
|
18763
18584
|
"src/public-cli/turn-request.ts"() {
|
|
18764
18585
|
"use strict";
|
|
18765
18586
|
init_engine_material();
|
|
18766
|
-
init_method_skill();
|
|
18767
18587
|
init_packaged_role_registry();
|
|
18588
|
+
init_machine_method_skills();
|
|
18768
18589
|
init_run_lifecycle();
|
|
18769
18590
|
}
|
|
18770
18591
|
});
|
|
18771
18592
|
|
|
18772
18593
|
// src/public-cli/countersign-run.ts
|
|
18773
|
-
function
|
|
18594
|
+
function isRecord13(value) {
|
|
18774
18595
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18775
18596
|
}
|
|
18776
18597
|
function isEscalatePayload(payload) {
|
|
18777
|
-
if (!
|
|
18598
|
+
if (!isRecord13(payload)) return false;
|
|
18778
18599
|
return payload.status === "escalate";
|
|
18779
18600
|
}
|
|
18780
18601
|
function courtDiaristPayloadRows(roleOutcome, submissions) {
|
|
@@ -18977,7 +18798,7 @@ function roleRecord(role) {
|
|
|
18977
18798
|
function buildInstructionSeatTurnRequest(admitted, options) {
|
|
18978
18799
|
return projectRoleTurnRequest(
|
|
18979
18800
|
admitted,
|
|
18980
|
-
admittedSeatTurnDetails(admitted, options.
|
|
18801
|
+
admittedSeatTurnDetails(admitted, options.home, options.host),
|
|
18981
18802
|
options
|
|
18982
18803
|
);
|
|
18983
18804
|
}
|
|
@@ -19010,11 +18831,11 @@ async function bindAndRelocateDiarist(admitted, authority, lease) {
|
|
|
19010
18831
|
}
|
|
19011
18832
|
await relocateAdmittedRunToTicket(admitted, authority, lease);
|
|
19012
18833
|
}
|
|
19013
|
-
function seatAdapters(admitted, env
|
|
18834
|
+
function seatAdapters(admitted, env) {
|
|
19014
18835
|
const record4 = roleRecord(admitted.role);
|
|
19015
18836
|
const present = "presentSettled" in record4 ? record4.presentSettled : "default";
|
|
19016
18837
|
return {
|
|
19017
|
-
trySettle: (seat, authority, scope) => trySettlePublicSeat(seat, authority, scope
|
|
18838
|
+
trySettle: (seat, authority, scope) => trySettlePublicSeat(seat, authority, scope),
|
|
19018
18839
|
...present === "always" ? { shouldPresentSettled: () => true } : {},
|
|
19019
18840
|
...present === "typed" ? { shouldPresentSettled: (terminal) => isLawfulTypedTerminalOutcome(terminal.roleOutcome) } : {},
|
|
19020
18841
|
...infraFailure(admitted.role),
|
|
@@ -19066,23 +18887,8 @@ async function withAuditorSoulEnv(options) {
|
|
|
19066
18887
|
}
|
|
19067
18888
|
async function dispatchAdmitted(admitted, env, io) {
|
|
19068
18889
|
const record4 = roleRecord(admitted.role);
|
|
19069
|
-
|
|
19070
|
-
const
|
|
19071
|
-
if (skill !== void 0) {
|
|
19072
|
-
try {
|
|
19073
|
-
material = await loadPackagedMethodSkillMaterial(env.packageRoot, skill);
|
|
19074
|
-
} catch (error) {
|
|
19075
|
-
const knownCause = packagedMethodLoadFailureCause(admitted.role);
|
|
19076
|
-
return await presentControlledFailure2(admitted, {
|
|
19077
|
-
timedOut: false,
|
|
19078
|
-
code: null,
|
|
19079
|
-
stderr: "",
|
|
19080
|
-
thrown: error,
|
|
19081
|
-
...knownCause === void 0 ? {} : { knownCause }
|
|
19082
|
-
}, seatAdapters(admitted, env), env.principalAuthority, io);
|
|
19083
|
-
}
|
|
19084
|
-
}
|
|
19085
|
-
const adapters = seatAdapters(admitted, env, material);
|
|
18890
|
+
await warnMissingMethodSkills(env.home, env.host, admitted.role, requiredMethodSkills(admitted), io.stdout);
|
|
18891
|
+
const adapters = seatAdapters(admitted, env);
|
|
19086
18892
|
const execute = async (activeEnv) => {
|
|
19087
18893
|
const auto = "inCallAutoResume" in record4 && record4.inCallAutoResume === true;
|
|
19088
18894
|
if (auto) {
|
|
@@ -19585,21 +19391,9 @@ async function runPublicInstructionSeatResume(request, env, io) {
|
|
|
19585
19391
|
adapters: {
|
|
19586
19392
|
trySettle: async () => void 0
|
|
19587
19393
|
},
|
|
19588
|
-
afterAdmittedLoad: (admitted) => {
|
|
19589
|
-
|
|
19590
|
-
|
|
19591
|
-
return Promise.resolve({ kind: "continue", adapters: seatAdapters(admitted, env) });
|
|
19592
|
-
}
|
|
19593
|
-
const knownCause = packagedMethodLoadFailureCause(admitted.role);
|
|
19594
|
-
return resolveResumeMethodMaterialAdapters({
|
|
19595
|
-
admitted,
|
|
19596
|
-
authority: env.principalAuthority,
|
|
19597
|
-
io,
|
|
19598
|
-
loadMaterial: () => loadPackagedMethodSkillMaterial(env.packageRoot, skill),
|
|
19599
|
-
adaptersWith: (material) => seatAdapters(admitted, env, material),
|
|
19600
|
-
emptyAdapters: seatAdapters(admitted, env),
|
|
19601
|
-
...knownCause === void 0 ? {} : { knownCause }
|
|
19602
|
-
});
|
|
19394
|
+
afterAdmittedLoad: async (admitted) => {
|
|
19395
|
+
await warnMissingMethodSkills(env.home, env.host, admitted.role, requiredMethodSkills(admitted), io.stdout);
|
|
19396
|
+
return { kind: "continue", adapters: seatAdapters(admitted, env) };
|
|
19603
19397
|
},
|
|
19604
19398
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
19605
19399
|
});
|
|
@@ -19625,7 +19419,6 @@ var init_instruction_seat_run = __esm({
|
|
|
19625
19419
|
init_run_ticket_number();
|
|
19626
19420
|
init_notary_source_run();
|
|
19627
19421
|
init_engine_material();
|
|
19628
|
-
init_method_skill();
|
|
19629
19422
|
init_packaged_role_registry();
|
|
19630
19423
|
init_auditor_soul();
|
|
19631
19424
|
init_cli_errors();
|
|
@@ -19634,6 +19427,7 @@ var init_instruction_seat_run = __esm({
|
|
|
19634
19427
|
init_run_lifecycle();
|
|
19635
19428
|
init_seat_ticket_binding();
|
|
19636
19429
|
init_settlement();
|
|
19430
|
+
init_machine_method_skills();
|
|
19637
19431
|
init_terminal();
|
|
19638
19432
|
init_turn_request();
|
|
19639
19433
|
init_countersign_run();
|
|
@@ -19641,13 +19435,13 @@ var init_instruction_seat_run = __esm({
|
|
|
19641
19435
|
});
|
|
19642
19436
|
|
|
19643
19437
|
// src/analyst-book-key.ts
|
|
19644
|
-
import { statSync as
|
|
19438
|
+
import { statSync as statSync5 } from "node:fs";
|
|
19645
19439
|
import { isAbsolute as isAbsolute9 } from "node:path";
|
|
19646
19440
|
function resolveAnalystBookKey(projectRoot) {
|
|
19647
19441
|
const identity = physicalPathIdentity(projectRoot);
|
|
19648
19442
|
let stats;
|
|
19649
19443
|
try {
|
|
19650
|
-
stats =
|
|
19444
|
+
stats = statSync5(identity);
|
|
19651
19445
|
} catch (error) {
|
|
19652
19446
|
const code = errnoCode(error);
|
|
19653
19447
|
if (code === "ENOENT" || code === "ENOTDIR") return `root:${identity}`;
|
|
@@ -19696,11 +19490,11 @@ var init_atomic_write = __esm({
|
|
|
19696
19490
|
});
|
|
19697
19491
|
|
|
19698
19492
|
// src/analyst-index.ts
|
|
19699
|
-
import { open as open3, readFile as
|
|
19493
|
+
import { open as open3, readFile as readFile18, unlink as unlink5 } from "node:fs/promises";
|
|
19700
19494
|
import { dirname as dirname19, join as join36 } from "node:path";
|
|
19701
19495
|
function sleep(ms) {
|
|
19702
|
-
return new Promise((
|
|
19703
|
-
setTimeout(
|
|
19496
|
+
return new Promise((resolve21) => {
|
|
19497
|
+
setTimeout(resolve21, ms);
|
|
19704
19498
|
});
|
|
19705
19499
|
}
|
|
19706
19500
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
@@ -19824,7 +19618,7 @@ async function readAnalystLibraryIndexPage(ledgerHome) {
|
|
|
19824
19618
|
const path = analystLibraryIndexPath(ledgerHome);
|
|
19825
19619
|
let raw;
|
|
19826
19620
|
try {
|
|
19827
|
-
raw = await
|
|
19621
|
+
raw = await readFile18(path, "utf8");
|
|
19828
19622
|
} catch (error) {
|
|
19829
19623
|
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR")) {
|
|
19830
19624
|
return void 0;
|
|
@@ -20028,15 +19822,15 @@ var init_analyst_cohort = __esm({
|
|
|
20028
19822
|
});
|
|
20029
19823
|
|
|
20030
19824
|
// src/analyst-ledger.ts
|
|
20031
|
-
import { readdir as readdir8, readFile as
|
|
20032
|
-
import { basename as
|
|
19825
|
+
import { readdir as readdir8, readFile as readFile19 } from "node:fs/promises";
|
|
19826
|
+
import { basename as basename8, join as join37 } from "node:path";
|
|
20033
19827
|
function isMissingPathError6(error) {
|
|
20034
19828
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
20035
19829
|
}
|
|
20036
19830
|
function errorText3(error) {
|
|
20037
19831
|
return error instanceof Error ? error.message : String(error);
|
|
20038
19832
|
}
|
|
20039
|
-
function
|
|
19833
|
+
function isRecord14(value) {
|
|
20040
19834
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20041
19835
|
}
|
|
20042
19836
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
@@ -20087,13 +19881,13 @@ async function listLedgerBookNames(booksRoot) {
|
|
|
20087
19881
|
async function readInvocationScopeFields(runDirectory) {
|
|
20088
19882
|
let raw;
|
|
20089
19883
|
try {
|
|
20090
|
-
raw = await
|
|
19884
|
+
raw = await readFile19(join37(runDirectory, "invocation.json"), "utf8");
|
|
20091
19885
|
} catch (error) {
|
|
20092
19886
|
if (isMissingPathError6(error)) return void 0;
|
|
20093
19887
|
throw error;
|
|
20094
19888
|
}
|
|
20095
19889
|
const parsed = JSON.parse(raw);
|
|
20096
|
-
if (!
|
|
19890
|
+
if (!isRecord14(parsed)) return void 0;
|
|
20097
19891
|
if (typeof parsed.projectRoot !== "string" || parsed.projectRoot.trim() === "") {
|
|
20098
19892
|
return void 0;
|
|
20099
19893
|
}
|
|
@@ -20120,9 +19914,9 @@ function decideIssueScope(input) {
|
|
|
20120
19914
|
}
|
|
20121
19915
|
async function resolveSessionFile(runDirectory) {
|
|
20122
19916
|
try {
|
|
20123
|
-
const raw = await
|
|
19917
|
+
const raw = await readFile19(join37(runDirectory, "invocation.json"), "utf8");
|
|
20124
19918
|
const parsed = JSON.parse(raw);
|
|
20125
|
-
if (
|
|
19919
|
+
if (isRecord14(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
20126
19920
|
return parsed.sessionFile;
|
|
20127
19921
|
}
|
|
20128
19922
|
} catch (error) {
|
|
@@ -20399,7 +20193,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
20399
20193
|
throw error;
|
|
20400
20194
|
}
|
|
20401
20195
|
for (const runDirectory of runDirectories) {
|
|
20402
|
-
const runName =
|
|
20196
|
+
const runName = basename8(runDirectory);
|
|
20403
20197
|
const parsed = parseRunDirectoryName2(runName);
|
|
20404
20198
|
if (parsed === void 0) continue;
|
|
20405
20199
|
let scopeFields;
|
|
@@ -20460,7 +20254,7 @@ var init_analyst_ledger = __esm({
|
|
|
20460
20254
|
});
|
|
20461
20255
|
|
|
20462
20256
|
// src/analyst-metric-families/acceptance-success-rework.ts
|
|
20463
|
-
function
|
|
20257
|
+
function isRecord15(value) {
|
|
20464
20258
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20465
20259
|
}
|
|
20466
20260
|
function wallMsFromSpan(span) {
|
|
@@ -20469,21 +20263,21 @@ function wallMsFromSpan(span) {
|
|
|
20469
20263
|
function findCollectorGroups(body) {
|
|
20470
20264
|
if (Array.isArray(body.groups)) return body.groups;
|
|
20471
20265
|
const receipt = body.receipt;
|
|
20472
|
-
if (
|
|
20266
|
+
if (isRecord15(receipt) && Array.isArray(receipt.groups)) return receipt.groups;
|
|
20473
20267
|
const outcome = body.outcome;
|
|
20474
|
-
if (
|
|
20268
|
+
if (isRecord15(outcome)) {
|
|
20475
20269
|
const facts = outcome.decisiveFacts;
|
|
20476
|
-
if (
|
|
20270
|
+
if (isRecord15(facts) && Array.isArray(facts.groups)) return facts.groups;
|
|
20477
20271
|
}
|
|
20478
20272
|
return void 0;
|
|
20479
20273
|
}
|
|
20480
20274
|
function extractStatus(body) {
|
|
20481
20275
|
const outcome = body.outcome;
|
|
20482
|
-
if (
|
|
20276
|
+
if (isRecord15(outcome) && typeof outcome.status === "string" && outcome.status.trim() !== "") {
|
|
20483
20277
|
return outcome.status;
|
|
20484
20278
|
}
|
|
20485
20279
|
const receipt = body.receipt;
|
|
20486
|
-
if (
|
|
20280
|
+
if (isRecord15(receipt) && typeof receipt.status === "string" && receipt.status.trim() !== "") {
|
|
20487
20281
|
return receipt.status;
|
|
20488
20282
|
}
|
|
20489
20283
|
if (typeof body.status === "string" && body.status.trim() !== "") {
|
|
@@ -21109,15 +20903,15 @@ var init_leg_wall_clock = __esm({
|
|
|
21109
20903
|
});
|
|
21110
20904
|
|
|
21111
20905
|
// src/analyst-metric-families/round-timeline.ts
|
|
21112
|
-
function
|
|
20906
|
+
function isRecord16(value) {
|
|
21113
20907
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21114
20908
|
}
|
|
21115
20909
|
function wallMsFromSpan2(startedAt, endedAt) {
|
|
21116
20910
|
return Date.parse(endedAt) - Date.parse(startedAt);
|
|
21117
20911
|
}
|
|
21118
20912
|
function readClassCount(body) {
|
|
21119
|
-
if (!
|
|
21120
|
-
if (!
|
|
20913
|
+
if (!isRecord16(body.outcome)) return void 0;
|
|
20914
|
+
if (!isRecord16(body.outcome.decisiveFacts)) return void 0;
|
|
21121
20915
|
const classCount = body.outcome.decisiveFacts.classCount;
|
|
21122
20916
|
if (typeof classCount !== "number" || !Number.isFinite(classCount)) {
|
|
21123
20917
|
return void 0;
|
|
@@ -21261,7 +21055,7 @@ var init_analyst_metric_family = __esm({
|
|
|
21261
21055
|
});
|
|
21262
21056
|
|
|
21263
21057
|
// src/analyst-page.ts
|
|
21264
|
-
import { createHash as
|
|
21058
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
21265
21059
|
import { dirname as dirname20, join as join38 } from "node:path";
|
|
21266
21060
|
function analystIssuePageKey(address) {
|
|
21267
21061
|
const parts = ["book", address.bookKey];
|
|
@@ -21270,7 +21064,7 @@ function analystIssuePageKey(address) {
|
|
|
21270
21064
|
} else if (address.scopeRootIdentity !== void 0) {
|
|
21271
21065
|
parts.push("root", physicalPathIdentity(address.scopeRootIdentity));
|
|
21272
21066
|
}
|
|
21273
|
-
return
|
|
21067
|
+
return createHash8("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
21274
21068
|
}
|
|
21275
21069
|
function analystIssuePagePath(ledgerHome, address) {
|
|
21276
21070
|
return join38(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
@@ -21409,7 +21203,7 @@ var init_analyst_page = __esm({
|
|
|
21409
21203
|
});
|
|
21410
21204
|
|
|
21411
21205
|
// src/analyst-entry.ts
|
|
21412
|
-
import { readFile as
|
|
21206
|
+
import { readFile as readFile20 } from "node:fs/promises";
|
|
21413
21207
|
import { Type as Type11 } from "typebox";
|
|
21414
21208
|
function isMissingPathError7(error) {
|
|
21415
21209
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
@@ -21440,7 +21234,7 @@ async function readOrComputeAnalystIssuePage(input, options) {
|
|
|
21440
21234
|
...issueNumber === void 0 && input.bookKey === void 0 ? { scopeRootIdentity: projectRoot } : {}
|
|
21441
21235
|
});
|
|
21442
21236
|
try {
|
|
21443
|
-
const raw = await
|
|
21237
|
+
const raw = await readFile20(pagePath, "utf8");
|
|
21444
21238
|
const page = JSON.parse(raw);
|
|
21445
21239
|
if (cachedPageMatchesRequestedScope(page, { bookKey, ...input })) {
|
|
21446
21240
|
const ghostScan = await scanAnalystIssueRuns({
|
|
@@ -21541,7 +21335,7 @@ async function runAnalystModelGroupsMode(input, home) {
|
|
|
21541
21335
|
scopeRootIdentity: projectRoot
|
|
21542
21336
|
});
|
|
21543
21337
|
try {
|
|
21544
|
-
const raw = await
|
|
21338
|
+
const raw = await readFile20(pagePath, "utf8");
|
|
21545
21339
|
JSON.parse(raw);
|
|
21546
21340
|
} catch (error) {
|
|
21547
21341
|
if (!isMissingPathError7(error)) {
|
|
@@ -21639,7 +21433,7 @@ var init_analyst_entry = __esm({
|
|
|
21639
21433
|
});
|
|
21640
21434
|
|
|
21641
21435
|
// src/public-cli/analyst-run.ts
|
|
21642
|
-
import { readFile as
|
|
21436
|
+
import { readFile as readFile21 } from "node:fs/promises";
|
|
21643
21437
|
import { isAbsolute as isAbsolute10, resolve as resolve15 } from "node:path";
|
|
21644
21438
|
import { Value as Value2 } from "typebox/value";
|
|
21645
21439
|
function resolveAnalystIssueBookKeyFromCwd(cwd = process.cwd()) {
|
|
@@ -21693,7 +21487,7 @@ async function buildAnalystSweepModeInputFromAttachmentPaths(attachmentPaths) {
|
|
|
21693
21487
|
const absolute = isAbsolute10(sourcePath) ? sourcePath : resolve15(sourcePath);
|
|
21694
21488
|
let bytes;
|
|
21695
21489
|
try {
|
|
21696
|
-
bytes = await
|
|
21490
|
+
bytes = await readFile21(absolute);
|
|
21697
21491
|
} catch (error) {
|
|
21698
21492
|
throw new CliUsageError(
|
|
21699
21493
|
`analyst sweep attachment is not a readable regular file: ${sourcePath}`,
|
|
@@ -21812,7 +21606,7 @@ __export(cli_exports, {
|
|
|
21812
21606
|
resolveInternalRoleEntrypoint: () => resolveInternalRoleEntrypoint,
|
|
21813
21607
|
runAkRole: () => runAkRole
|
|
21814
21608
|
});
|
|
21815
|
-
import { realpath as
|
|
21609
|
+
import { realpath as realpath5 } from "node:fs/promises";
|
|
21816
21610
|
import { join as join39 } from "node:path";
|
|
21817
21611
|
function publicSeatArgv(owner) {
|
|
21818
21612
|
return {
|
|
@@ -22487,7 +22281,7 @@ async function runAkRole(argv, env) {
|
|
|
22487
22281
|
try {
|
|
22488
22282
|
env = {
|
|
22489
22283
|
...env,
|
|
22490
|
-
packageRoot: await
|
|
22284
|
+
packageRoot: await realpath5(env.packageRoot),
|
|
22491
22285
|
principalAuthority: env.principalAuthority ?? piDurablePrincipalAuthority
|
|
22492
22286
|
};
|
|
22493
22287
|
let parsed = parseArgv(argv);
|
|
@@ -22536,6 +22330,10 @@ async function runAkRole(argv, env) {
|
|
|
22536
22330
|
exitCode: await runConfigCommand(parsed.args, home, env.packageRoot, io)
|
|
22537
22331
|
};
|
|
22538
22332
|
}
|
|
22333
|
+
if (parsed.command === "setup") {
|
|
22334
|
+
if (parsed.args.length !== 0) throw new CliUsageError("setup takes no arguments");
|
|
22335
|
+
return { exitCode: await runMachineSkillSetup(home, io.stdout) };
|
|
22336
|
+
}
|
|
22539
22337
|
if (parsed.command === "new") {
|
|
22540
22338
|
const role = parsed.args[0];
|
|
22541
22339
|
if (role === void 0) {
|
|
@@ -22659,6 +22457,7 @@ var init_cli = __esm({
|
|
|
22659
22457
|
init_packaged_role_registry();
|
|
22660
22458
|
init_registry();
|
|
22661
22459
|
init_cli_errors();
|
|
22460
|
+
init_machine_method_skills();
|
|
22662
22461
|
init_role_turn_host();
|
|
22663
22462
|
init_role_turn_host_resolution();
|
|
22664
22463
|
init_invocation();
|
|
@@ -22693,7 +22492,7 @@ __export(public_role_summons_exports, {
|
|
|
22693
22492
|
});
|
|
22694
22493
|
import { execFile as execFile3 } from "node:child_process";
|
|
22695
22494
|
import { existsSync as existsSync11 } from "node:fs";
|
|
22696
|
-
import { realpath as
|
|
22495
|
+
import { realpath as realpath6 } from "node:fs/promises";
|
|
22697
22496
|
import { join as join40 } from "node:path";
|
|
22698
22497
|
import { promisify as promisify3 } from "node:util";
|
|
22699
22498
|
function createCapturingIo() {
|
|
@@ -22982,8 +22781,8 @@ function withReviewerLens(argv, lens) {
|
|
|
22982
22781
|
return [...argv.slice(0, separator), "--lens", lens, ...argv.slice(separator)];
|
|
22983
22782
|
}
|
|
22984
22783
|
async function resolveReviewerGitToplevel(projectRoot) {
|
|
22985
|
-
const callerProjectRoot = await
|
|
22986
|
-
return await
|
|
22784
|
+
const callerProjectRoot = await realpath6(projectRoot);
|
|
22785
|
+
return await realpath6((await execFileAsync3(
|
|
22987
22786
|
"git",
|
|
22988
22787
|
["rev-parse", "--show-toplevel"],
|
|
22989
22788
|
{ cwd: callerProjectRoot }
|
|
@@ -23209,7 +23008,7 @@ init_engine_detour();
|
|
|
23209
23008
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
23210
23009
|
import { appendFile as appendFile3, mkdir as mkdir5, writeFile as writeFile11 } from "node:fs/promises";
|
|
23211
23010
|
import { createServer } from "node:net";
|
|
23212
|
-
import { dirname as
|
|
23011
|
+
import { dirname as dirname22, join as join44 } from "node:path";
|
|
23213
23012
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
23214
23013
|
|
|
23215
23014
|
// src/submission-gate.ts
|
|
@@ -23313,119 +23112,6 @@ async function requireSubmissionGate(options) {
|
|
|
23313
23112
|
}
|
|
23314
23113
|
}
|
|
23315
23114
|
|
|
23316
|
-
// src/host-native-method.ts
|
|
23317
|
-
import { access as access4, lstat as lstat7, mkdir as mkdir4, readdir as readdir9, readFile as readFile23, readlink, realpath as realpath8, symlink } from "node:fs/promises";
|
|
23318
|
-
import { basename as basename10, dirname as dirname21, join as join41 } from "node:path";
|
|
23319
|
-
var packagedMethodsDir = (root) => join41(root, "resources", "methods");
|
|
23320
|
-
function hostMethodSkills(methods) {
|
|
23321
|
-
return Object.freeze(methods.flatMap((method) => {
|
|
23322
|
-
if (method.kind !== "skill") return [];
|
|
23323
|
-
const name = basename10(dirname21(method.path));
|
|
23324
|
-
return name ? [Object.freeze({ name })] : [];
|
|
23325
|
-
}));
|
|
23326
|
-
}
|
|
23327
|
-
var isEnoent3 = (error) => error.code === "ENOENT";
|
|
23328
|
-
async function packagedMethodSkillNames(packagedMethodsRealpath) {
|
|
23329
|
-
const entries = await readdir9(packagedMethodsRealpath, { withFileTypes: true });
|
|
23330
|
-
const names = [];
|
|
23331
|
-
for (const entry of entries) {
|
|
23332
|
-
if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
|
|
23333
|
-
try {
|
|
23334
|
-
await access4(join41(packagedMethodsRealpath, entry.name, "SKILL.md"));
|
|
23335
|
-
} catch (error) {
|
|
23336
|
-
if (isEnoent3(error)) continue;
|
|
23337
|
-
throw error;
|
|
23338
|
-
}
|
|
23339
|
-
names.push(entry.name);
|
|
23340
|
-
}
|
|
23341
|
-
return names;
|
|
23342
|
-
}
|
|
23343
|
-
async function packagedSkillFileBytes(skillDir) {
|
|
23344
|
-
try {
|
|
23345
|
-
await access4(join41(skillDir, "SKILL.md"));
|
|
23346
|
-
} catch (error) {
|
|
23347
|
-
if (isEnoent3(error)) return void 0;
|
|
23348
|
-
throw error;
|
|
23349
|
-
}
|
|
23350
|
-
const files = /* @__PURE__ */ new Map();
|
|
23351
|
-
async function walk(dir, prefix) {
|
|
23352
|
-
const entries = await readdir9(dir, { withFileTypes: true });
|
|
23353
|
-
for (const entry of entries) {
|
|
23354
|
-
const rel = prefix === "" ? entry.name : `${prefix}/${entry.name}`;
|
|
23355
|
-
const full = join41(dir, entry.name);
|
|
23356
|
-
if (entry.isDirectory()) {
|
|
23357
|
-
await walk(full, rel);
|
|
23358
|
-
continue;
|
|
23359
|
-
}
|
|
23360
|
-
if (entry.isFile()) {
|
|
23361
|
-
files.set(rel, await readFile23(full));
|
|
23362
|
-
}
|
|
23363
|
-
}
|
|
23364
|
-
}
|
|
23365
|
-
await walk(skillDir, "");
|
|
23366
|
-
return files;
|
|
23367
|
-
}
|
|
23368
|
-
async function catalogPublishesPackagedSkill(catalogSkillDir, required) {
|
|
23369
|
-
for (const [rel, bytes] of required) {
|
|
23370
|
-
let other;
|
|
23371
|
-
try {
|
|
23372
|
-
other = await readFile23(join41(catalogSkillDir, rel));
|
|
23373
|
-
} catch (error) {
|
|
23374
|
-
if (isEnoent3(error)) return false;
|
|
23375
|
-
throw error;
|
|
23376
|
-
}
|
|
23377
|
-
if (!bytes.equals(other)) return false;
|
|
23378
|
-
}
|
|
23379
|
-
return true;
|
|
23380
|
-
}
|
|
23381
|
-
async function isCompatibleMethodCatalog(link, packagedMethodsRealpath) {
|
|
23382
|
-
const stat2 = await lstat7(link);
|
|
23383
|
-
if (!stat2.isSymbolicLink()) return false;
|
|
23384
|
-
let resolved;
|
|
23385
|
-
try {
|
|
23386
|
-
resolved = await realpath8(link);
|
|
23387
|
-
} catch (error) {
|
|
23388
|
-
if (isEnoent3(error)) return false;
|
|
23389
|
-
throw error;
|
|
23390
|
-
}
|
|
23391
|
-
if (resolved === packagedMethodsRealpath) return true;
|
|
23392
|
-
const names = await packagedMethodSkillNames(packagedMethodsRealpath);
|
|
23393
|
-
if (names.length === 0) return false;
|
|
23394
|
-
for (const name of names) {
|
|
23395
|
-
const required = await packagedSkillFileBytes(join41(packagedMethodsRealpath, name));
|
|
23396
|
-
if (required === void 0) return false;
|
|
23397
|
-
if (!await catalogPublishesPackagedSkill(join41(resolved, name), required)) return false;
|
|
23398
|
-
}
|
|
23399
|
-
return true;
|
|
23400
|
-
}
|
|
23401
|
-
async function installWorkspaceMethodSkills(cwd, packageRoot) {
|
|
23402
|
-
const target = await realpath8(packagedMethodsDir(packageRoot));
|
|
23403
|
-
const link = join41(cwd, ".agents", "skills");
|
|
23404
|
-
let present;
|
|
23405
|
-
try {
|
|
23406
|
-
await lstat7(link);
|
|
23407
|
-
present = true;
|
|
23408
|
-
} catch (error) {
|
|
23409
|
-
if (!isEnoent3(error)) throw error;
|
|
23410
|
-
present = false;
|
|
23411
|
-
}
|
|
23412
|
-
if (present) {
|
|
23413
|
-
if (await isCompatibleMethodCatalog(link, target)) return;
|
|
23414
|
-
const stat2 = await lstat7(link);
|
|
23415
|
-
const detail = stat2.isSymbolicLink() ? `symlink to ${await readlink(link)}` : "non-symlink entry";
|
|
23416
|
-
throw new Error(`workspace method catalog conflict at ${link}: ${detail}`);
|
|
23417
|
-
}
|
|
23418
|
-
await mkdir4(dirname21(link), { recursive: true });
|
|
23419
|
-
try {
|
|
23420
|
-
await symlink(target, link);
|
|
23421
|
-
} catch (error) {
|
|
23422
|
-
if (error.code !== "EEXIST") throw error;
|
|
23423
|
-
if (!await isCompatibleMethodCatalog(link, target)) {
|
|
23424
|
-
throw new Error(`workspace method catalog conflict at ${link}`);
|
|
23425
|
-
}
|
|
23426
|
-
}
|
|
23427
|
-
}
|
|
23428
|
-
|
|
23429
23115
|
// src/role-envelope.ts
|
|
23430
23116
|
init_packaged_role_registry();
|
|
23431
23117
|
|
|
@@ -23437,7 +23123,7 @@ init_submission_ledger();
|
|
|
23437
23123
|
init_collector_ledger();
|
|
23438
23124
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
23439
23125
|
import { readFileSync as readFileSync6, writeSync as writeSync3 } from "node:fs";
|
|
23440
|
-
import { join as
|
|
23126
|
+
import { join as join43 } from "node:path";
|
|
23441
23127
|
import { Value as Value5 } from "typebox/value";
|
|
23442
23128
|
|
|
23443
23129
|
// src/activation-trace.ts
|
|
@@ -23485,7 +23171,7 @@ init_activation_ledger_topology();
|
|
|
23485
23171
|
import {
|
|
23486
23172
|
lstatSync as lstatSync2,
|
|
23487
23173
|
realpathSync as realpathSync3,
|
|
23488
|
-
statSync as
|
|
23174
|
+
statSync as statSync6,
|
|
23489
23175
|
writeFileSync as writeFileSync3
|
|
23490
23176
|
} from "node:fs";
|
|
23491
23177
|
import { isAbsolute as isAbsolute11, resolve as resolve16 } from "node:path";
|
|
@@ -23560,7 +23246,7 @@ function durableSessionPointer(sessionManager) {
|
|
|
23560
23246
|
}
|
|
23561
23247
|
let info;
|
|
23562
23248
|
try {
|
|
23563
|
-
info =
|
|
23249
|
+
info = statSync6(realFile);
|
|
23564
23250
|
} catch (error) {
|
|
23565
23251
|
throw new Error(
|
|
23566
23252
|
`Workflow role activation failed to stat durable session file (${realFile}): ${errorText(error)}`,
|
|
@@ -23869,8 +23555,8 @@ init_collector_github();
|
|
|
23869
23555
|
// src/collector-handbook.ts
|
|
23870
23556
|
init_atomic_write();
|
|
23871
23557
|
init_activation_ledger_topology();
|
|
23872
|
-
import { readFile as
|
|
23873
|
-
import { join as
|
|
23558
|
+
import { readFile as readFile22 } from "node:fs/promises";
|
|
23559
|
+
import { join as join41, sep as sep6 } from "node:path";
|
|
23874
23560
|
|
|
23875
23561
|
// src/collector-tool-schemas.ts
|
|
23876
23562
|
init_open_tool_schema();
|
|
@@ -23985,7 +23671,7 @@ function resolveCollectorHandbookRoot(sessionPath) {
|
|
|
23985
23671
|
throw new Error(`\u901A\u8FDB\u53F8\u624B\u518C\u62D2\u7EDD\u4E0D\u5B89\u5168 bookKey ${JSON.stringify(bookKey)}`);
|
|
23986
23672
|
}
|
|
23987
23673
|
const ledgerHome = resolveActivationLedgerHomeForPath(sessionPath);
|
|
23988
|
-
const root =
|
|
23674
|
+
const root = join41(activationBookDirectory(ledgerHome, bookKey), "collector-handbook");
|
|
23989
23675
|
return { ledgerHome, bookKey, root };
|
|
23990
23676
|
}
|
|
23991
23677
|
function collectorHandbookRepoFileName(repositoryCanonical) {
|
|
@@ -23997,9 +23683,9 @@ function collectorHandbookRepoFileName(repositoryCanonical) {
|
|
|
23997
23683
|
return `${repositoryCanonical.replaceAll("/", "__")}.md`;
|
|
23998
23684
|
}
|
|
23999
23685
|
function createCollectorHandbookStore(input) {
|
|
24000
|
-
const generalPath =
|
|
24001
|
-
const repoDir =
|
|
24002
|
-
const repoPath =
|
|
23686
|
+
const generalPath = join41(input.handbookRoot, "general.md");
|
|
23687
|
+
const repoDir = join41(input.handbookRoot, "repos");
|
|
23688
|
+
const repoPath = join41(repoDir, collectorHandbookRepoFileName(input.repositoryCanonical));
|
|
24003
23689
|
const assertHandbookBudget = (body, label) => {
|
|
24004
23690
|
const byteLength = Buffer.byteLength(body, "utf8");
|
|
24005
23691
|
if (byteLength > COLLECTOR_HANDBOOK_MAX_BYTES) {
|
|
@@ -24013,7 +23699,7 @@ function createCollectorHandbookStore(input) {
|
|
|
24013
23699
|
ensureRealDirectoryTree(input.ledgerHome, parentDir2);
|
|
24014
23700
|
assertLedgerFileInsideHome(path, input.ledgerHome);
|
|
24015
23701
|
try {
|
|
24016
|
-
const body = await
|
|
23702
|
+
const body = await readFile22(path, "utf8");
|
|
24017
23703
|
assertHandbookBudget(body, "\u6B63\u6587");
|
|
24018
23704
|
return body;
|
|
24019
23705
|
} catch (error) {
|
|
@@ -25031,7 +24717,7 @@ var AUDITOR_TOOL_SPEC = {
|
|
|
25031
24717
|
};
|
|
25032
24718
|
|
|
25033
24719
|
// src/navigator-attendance.ts
|
|
25034
|
-
import { createHash as
|
|
24720
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
25035
24721
|
init_navigator_invocation_identity();
|
|
25036
24722
|
init_packaged_role_registry();
|
|
25037
24723
|
init_activation_ledger_topology();
|
|
@@ -25041,7 +24727,7 @@ import { Type as Type20 } from "typebox";
|
|
|
25041
24727
|
|
|
25042
24728
|
// src/navigator-public-session.ts
|
|
25043
24729
|
init_sitian_facade();
|
|
25044
|
-
import { basename as
|
|
24730
|
+
import { basename as basename9 } from "node:path";
|
|
25045
24731
|
|
|
25046
24732
|
// src/navigator-session-contracts.ts
|
|
25047
24733
|
import { Type as Type19 } from "typebox";
|
|
@@ -25250,7 +24936,7 @@ function exactRecord2(value) {
|
|
|
25250
24936
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25251
24937
|
}
|
|
25252
24938
|
function runIdFromNavigatorDirectory(runDirectory) {
|
|
25253
|
-
const entry =
|
|
24939
|
+
const entry = basename9(runDirectory);
|
|
25254
24940
|
const suffix = "@navigator";
|
|
25255
24941
|
if (!entry.endsWith(suffix)) return void 0;
|
|
25256
24942
|
const runId = entry.slice(0, entry.length - suffix.length);
|
|
@@ -25479,7 +25165,7 @@ function navigatorSubjectKey(subjectRoot, subject, provenance = "role_input") {
|
|
|
25479
25165
|
if (provenance === "placeholder") return subjectRoot;
|
|
25480
25166
|
const normalized = subject.trim().replace(/\s+/g, " ");
|
|
25481
25167
|
if (normalized === "") return subjectRoot;
|
|
25482
|
-
return `${subjectRoot}#${
|
|
25168
|
+
return `${subjectRoot}#${createHash9("sha256").update(normalized).digest("hex").slice(0, 32)}`;
|
|
25483
25169
|
}
|
|
25484
25170
|
function navigatorSubjectKeyForInput(subjectRoot, reference, cwd = process.cwd()) {
|
|
25485
25171
|
if (issueRoot(subjectRoot) !== void 0 || !subjectRoot.includes("/.ak/work/")) return subjectRoot;
|
|
@@ -26138,7 +25824,6 @@ var reviewerOutputSchema = withTerminatingOutputDeclarations(
|
|
|
26138
25824
|
);
|
|
26139
25825
|
function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
|
|
26140
25826
|
let soul;
|
|
26141
|
-
let binding;
|
|
26142
25827
|
let registered = false;
|
|
26143
25828
|
let fixedBaseRevision;
|
|
26144
25829
|
return {
|
|
@@ -26146,9 +25831,6 @@ function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
|
|
|
26146
25831
|
soul = (await dependencies.loadSoul()).trim();
|
|
26147
25832
|
if (!soul) throw new Error("Reviewer soul is empty");
|
|
26148
25833
|
fixedBaseRevision = admitted.baseRevision;
|
|
26149
|
-
const loaded = await dependencies.loadCanonicalSkillBinding("ak-cross-m-review");
|
|
26150
|
-
if (loaded.name !== "ak-cross-m-review") throw new Error("Canonical Skill binding loader returned tdd for ak-cross-m-review");
|
|
26151
|
-
binding = loaded;
|
|
26152
25834
|
if (!registered) {
|
|
26153
25835
|
registered = true;
|
|
26154
25836
|
pi.registerTool({
|
|
@@ -26158,7 +25840,7 @@ function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
|
|
|
26158
25840
|
promptSnippet: "\u63D0\u4EA4\u5FA1\u53F2\u53F0\u7EC8\u5C40\u56DE\u6267",
|
|
26159
25841
|
parameters: reviewerOutputSchema,
|
|
26160
25842
|
async execute(_id, parameters) {
|
|
26161
|
-
if (!soul
|
|
25843
|
+
if (!soul) throw new Error("\u5FA1\u53F2\u53F0\u8F93\u5165\u672A\u88C5\u8F7D");
|
|
26162
25844
|
return {
|
|
26163
25845
|
content: [],
|
|
26164
25846
|
details: parameters,
|
|
@@ -26169,11 +25851,9 @@ function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
|
|
|
26169
25851
|
}
|
|
26170
25852
|
const activatedSoul = soul;
|
|
26171
25853
|
const activatedBase = fixedBaseRevision;
|
|
26172
|
-
const activatedBinding = binding;
|
|
26173
25854
|
return Object.freeze({
|
|
26174
25855
|
fixedBaseRevision: activatedBase,
|
|
26175
|
-
soul: activatedSoul
|
|
26176
|
-
skillBinding: activatedBinding
|
|
25856
|
+
soul: activatedSoul
|
|
26177
25857
|
});
|
|
26178
25858
|
}
|
|
26179
25859
|
};
|
|
@@ -26182,7 +25862,6 @@ function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
|
|
|
26182
25862
|
// src/worker-role.ts
|
|
26183
25863
|
init_open_tool_schema();
|
|
26184
25864
|
init_terminating_infrastructure();
|
|
26185
|
-
init_submission_correctable_error();
|
|
26186
25865
|
init_readable_gate_item();
|
|
26187
25866
|
init_audit_escalation();
|
|
26188
25867
|
init_submission_errors();
|
|
@@ -26294,7 +25973,7 @@ function uninstallPackageWorkerHooks(cwd) {
|
|
|
26294
25973
|
rmOwnedDir(resolve18(gitDir, HOOKS_DIR));
|
|
26295
25974
|
}
|
|
26296
25975
|
}
|
|
26297
|
-
function
|
|
25976
|
+
function isRecord17(value) {
|
|
26298
25977
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26299
25978
|
}
|
|
26300
25979
|
function unfinishedReasonPresent(details) {
|
|
@@ -26310,7 +25989,7 @@ function readGateState(session) {
|
|
|
26310
25989
|
if (entry.type !== "custom") continue;
|
|
26311
25990
|
if (entry.customType === WORKER_COMMIT_BASELINE_ENTRY_TYPE) {
|
|
26312
25991
|
const data = entry.data;
|
|
26313
|
-
if (
|
|
25992
|
+
if (isRecord17(data) && (data.head === null || typeof data.head === "string")) {
|
|
26314
25993
|
baseline = data.head;
|
|
26315
25994
|
}
|
|
26316
25995
|
} else if (entry.customType === WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE) {
|
|
@@ -26503,7 +26182,7 @@ var FIXER_PHASES = ["plan", "apply"];
|
|
|
26503
26182
|
function isWorkerPhase(value) {
|
|
26504
26183
|
return typeof value === "string" && FIXER_PHASES.includes(value);
|
|
26505
26184
|
}
|
|
26506
|
-
function
|
|
26185
|
+
function isRecord18(value) {
|
|
26507
26186
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26508
26187
|
}
|
|
26509
26188
|
var WORKER_ROUTING_STATUSES = /* @__PURE__ */ new Set([
|
|
@@ -26515,7 +26194,7 @@ var WORKER_ROUTING_STATUSES = /* @__PURE__ */ new Set([
|
|
|
26515
26194
|
]);
|
|
26516
26195
|
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";
|
|
26517
26196
|
function workerStatusOf(output) {
|
|
26518
|
-
return
|
|
26197
|
+
return isRecord18(output) && typeof output.status === "string" ? output.status : void 0;
|
|
26519
26198
|
}
|
|
26520
26199
|
function requireReadableWorkerStatus(output) {
|
|
26521
26200
|
const status = workerStatusOf(output);
|
|
@@ -26692,10 +26371,6 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
|
|
|
26692
26371
|
let soul;
|
|
26693
26372
|
let task;
|
|
26694
26373
|
let phase;
|
|
26695
|
-
let binding;
|
|
26696
|
-
let tddInvocationInjected = false;
|
|
26697
|
-
let originalRequest;
|
|
26698
|
-
let expansionPending = false;
|
|
26699
26374
|
let lifecycleRegistered = false;
|
|
26700
26375
|
const submissionGate = createWorkerSubmissionGate();
|
|
26701
26376
|
pi.registerFlag("ak-coder-task", {
|
|
@@ -26708,9 +26383,6 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
|
|
|
26708
26383
|
});
|
|
26709
26384
|
return {
|
|
26710
26385
|
async activate(ctx) {
|
|
26711
|
-
tddInvocationInjected = false;
|
|
26712
|
-
originalRequest = void 0;
|
|
26713
|
-
expansionPending = false;
|
|
26714
26386
|
soul = (await dependencies.loadSoul()).trim();
|
|
26715
26387
|
if (soul.length === 0) throw new Error("Coder soul is empty");
|
|
26716
26388
|
const selectedPhase = pi.getFlag("ak-coder-phase");
|
|
@@ -26726,24 +26398,6 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
|
|
|
26726
26398
|
}
|
|
26727
26399
|
task = (await dependencies.loadTask(taskPath)).trim();
|
|
26728
26400
|
if (task.length === 0) throw new Error("Coder task is empty");
|
|
26729
|
-
binding = void 0;
|
|
26730
|
-
if (phase === "apply") {
|
|
26731
|
-
if (dependencies.loadCanonicalSkillBinding === void 0) {
|
|
26732
|
-
throw new Error("Coder canonical Skill binding loader is not configured");
|
|
26733
|
-
}
|
|
26734
|
-
try {
|
|
26735
|
-
const loaded = await dependencies.loadCanonicalSkillBinding("tdd");
|
|
26736
|
-
if (loaded.name !== "tdd") {
|
|
26737
|
-
throw new Error(
|
|
26738
|
-
"Canonical Skill binding loader returned ak-cross-m-review for tdd"
|
|
26739
|
-
);
|
|
26740
|
-
}
|
|
26741
|
-
binding = loaded;
|
|
26742
|
-
} catch (error) {
|
|
26743
|
-
if (ctx === void 0) throw error;
|
|
26744
|
-
hostActions.failInfrastructure(error, ctx);
|
|
26745
|
-
}
|
|
26746
|
-
}
|
|
26747
26401
|
if (!lifecycleRegistered) {
|
|
26748
26402
|
lifecycleRegistered = true;
|
|
26749
26403
|
pi.registerTool({
|
|
@@ -26798,28 +26452,8 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
|
|
|
26798
26452
|
};
|
|
26799
26453
|
}
|
|
26800
26454
|
});
|
|
26801
|
-
pi.on("input", (event) => {
|
|
26802
|
-
if (phase !== "apply" || tddInvocationInjected) {
|
|
26803
|
-
return { action: "continue" };
|
|
26804
|
-
}
|
|
26805
|
-
tddInvocationInjected = true;
|
|
26806
|
-
expansionPending = true;
|
|
26807
|
-
originalRequest = binding === void 0 ? event.text : pi.capabilities?.skillOriginalRequest?.(binding.name, event.text) ?? event.text;
|
|
26808
|
-
return { action: "continue" };
|
|
26809
|
-
});
|
|
26810
26455
|
pi.on("before_agent_start", (event, ctx2) => {
|
|
26811
26456
|
if (soul === void 0) throw new Error("\u5C06\u4F5C\u76D1\u804C\u5206\u672A\u88C5\u8F7D");
|
|
26812
|
-
if (phase === "apply") {
|
|
26813
|
-
if (binding === void 0) {
|
|
26814
|
-
hostActions.failInfrastructure(
|
|
26815
|
-
new Error("Coder canonical tdd Skill binding was not initialized"),
|
|
26816
|
-
ctx2
|
|
26817
|
-
);
|
|
26818
|
-
}
|
|
26819
|
-
if (expansionPending) {
|
|
26820
|
-
expansionPending = false;
|
|
26821
|
-
}
|
|
26822
|
-
}
|
|
26823
26457
|
return {
|
|
26824
26458
|
systemPrompt: `${event.systemPrompt}
|
|
26825
26459
|
|
|
@@ -27326,7 +26960,7 @@ function readDiaristTicketAssertion(submitted) {
|
|
|
27326
26960
|
function readRoleRunCoordinates(ctx, label) {
|
|
27327
26961
|
const runDirectory = runDirectoryFromHostContext(ctx);
|
|
27328
26962
|
if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
|
|
27329
|
-
const admittedPath =
|
|
26963
|
+
const admittedPath = join43(runDirectory, "admitted-request.json");
|
|
27330
26964
|
const admitted = JSON.parse(readFileSync6(admittedPath, "utf8"));
|
|
27331
26965
|
if (typeof admitted.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
|
|
27332
26966
|
throw new Error(`${label} admitted-request missing projectRoot (${admittedPath})`);
|
|
@@ -27612,8 +27246,6 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27612
27246
|
let selectedRole;
|
|
27613
27247
|
let roleReferenceMaterials = "";
|
|
27614
27248
|
let activeReviewerParent;
|
|
27615
|
-
let reviewerOriginalRequest;
|
|
27616
|
-
let reviewerExpansionCaptured = false;
|
|
27617
27249
|
let navigatorAttendance;
|
|
27618
27250
|
let pendingNavigatorPresentation;
|
|
27619
27251
|
let pendingNavigatorSettlement;
|
|
@@ -27704,16 +27336,9 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27704
27336
|
() => receiptDelivery.recordAccepted(),
|
|
27705
27337
|
settleNavigatorProjection
|
|
27706
27338
|
);
|
|
27707
|
-
roleHost.on("input", (
|
|
27708
|
-
const text = event.text;
|
|
27339
|
+
roleHost.on("input", (_event) => {
|
|
27709
27340
|
const role = roleHost.getFlag(ROLE_FLAG.name);
|
|
27710
27341
|
if (role !== void 0 && !admitted) return { action: "handled" };
|
|
27711
|
-
if (admitted && activeReviewerParent !== void 0 && selectedRole === role && reviewerOriginalRequest === void 0) {
|
|
27712
|
-
reviewerOriginalRequest = roleHost.capabilities?.skillOriginalRequest?.(
|
|
27713
|
-
activeReviewerParent.skillBinding.name,
|
|
27714
|
-
text
|
|
27715
|
-
) ?? text;
|
|
27716
|
-
}
|
|
27717
27342
|
return { action: "continue" };
|
|
27718
27343
|
});
|
|
27719
27344
|
roleHost.on("before_agent_start", () => roleReferenceMaterials === "" ? void 0 : { readingMaterial: { kind: "role-reference-materials", content: roleReferenceMaterials } });
|
|
@@ -27750,15 +27375,6 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27750
27375
|
}
|
|
27751
27376
|
navigatorAttendance?.prepare();
|
|
27752
27377
|
if (activeReviewerParent !== void 0 && selectedRole === role) {
|
|
27753
|
-
if (!reviewerExpansionCaptured) {
|
|
27754
|
-
if (reviewerOriginalRequest !== void 0) {
|
|
27755
|
-
activeReviewerParent.skillBinding.captureExpansion(
|
|
27756
|
-
roleHost.capabilities?.skillExpansion(prompt),
|
|
27757
|
-
reviewerOriginalRequest
|
|
27758
|
-
);
|
|
27759
|
-
}
|
|
27760
|
-
reviewerExpansionCaptured = true;
|
|
27761
|
-
}
|
|
27762
27378
|
return {
|
|
27763
27379
|
systemPrompt: assembleReviewerParentSystemPrompt({
|
|
27764
27380
|
baseSystemPrompt: event.systemPrompt,
|
|
@@ -28031,9 +27647,6 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
28031
27647
|
throw new Error("Coder task loader is not configured");
|
|
28032
27648
|
}
|
|
28033
27649
|
return dependencies.loadCoderTask(path);
|
|
28034
|
-
},
|
|
28035
|
-
...dependencies.loadCanonicalSkillBinding === void 0 ? {} : {
|
|
28036
|
-
loadCanonicalSkillBinding: (name) => dependencies.loadCanonicalSkillBinding(name)
|
|
28037
27650
|
}
|
|
28038
27651
|
},
|
|
28039
27652
|
hostActions
|
|
@@ -28041,13 +27654,7 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
28041
27654
|
const reviewer = createReviewerRoleRuntime(
|
|
28042
27655
|
roleHost,
|
|
28043
27656
|
{
|
|
28044
|
-
loadSoul: () => requireRoleSoul("reviewer")
|
|
28045
|
-
async loadCanonicalSkillBinding(name) {
|
|
28046
|
-
if (dependencies.loadCanonicalSkillBinding === void 0) {
|
|
28047
|
-
throw new Error("Reviewer runtime dependencies are not configured");
|
|
28048
|
-
}
|
|
28049
|
-
return dependencies.loadCanonicalSkillBinding(name);
|
|
28050
|
-
}
|
|
27657
|
+
loadSoul: () => requireRoleSoul("reviewer")
|
|
28051
27658
|
},
|
|
28052
27659
|
hostActions
|
|
28053
27660
|
);
|
|
@@ -28282,8 +27889,6 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
28282
27889
|
activeReviewerParent = void 0;
|
|
28283
27890
|
activeCollector = void 0;
|
|
28284
27891
|
collectorFirstDispatchDone = false;
|
|
28285
|
-
reviewerOriginalRequest = void 0;
|
|
28286
|
-
reviewerExpansionCaptured = false;
|
|
28287
27892
|
receiptDelivery = createReceiptDeliveryPolicy();
|
|
28288
27893
|
noReceiptRecorded = false;
|
|
28289
27894
|
observationFace.reset();
|
|
@@ -28430,11 +28035,11 @@ init_submission_correctable_error();
|
|
|
28430
28035
|
init_navigator_invocation_identity();
|
|
28431
28036
|
init_serialize_thrown_value();
|
|
28432
28037
|
async function listen(server, path) {
|
|
28433
|
-
await new Promise((
|
|
28038
|
+
await new Promise((resolve21, reject) => {
|
|
28434
28039
|
server.once("error", reject);
|
|
28435
28040
|
server.listen(path, () => {
|
|
28436
28041
|
server.off("error", reject);
|
|
28437
|
-
|
|
28042
|
+
resolve21();
|
|
28438
28043
|
});
|
|
28439
28044
|
});
|
|
28440
28045
|
}
|
|
@@ -28469,8 +28074,8 @@ async function prepareRoleEnvelope(options) {
|
|
|
28469
28074
|
const hostAbort = new AbortController();
|
|
28470
28075
|
const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID9();
|
|
28471
28076
|
await mkdir5(request.runDirectory, { recursive: true });
|
|
28472
|
-
let sessionFile = options.sessionFile ??
|
|
28473
|
-
await mkdir5(
|
|
28077
|
+
let sessionFile = options.sessionFile ?? join44(request.runDirectory, "session", "session.jsonl");
|
|
28078
|
+
await mkdir5(dirname22(sessionFile), { recursive: true });
|
|
28474
28079
|
if (request.continuation.kind !== "resume") {
|
|
28475
28080
|
try {
|
|
28476
28081
|
await writeFile11(
|
|
@@ -28520,7 +28125,7 @@ async function prepareRoleEnvelope(options) {
|
|
|
28520
28125
|
getLeafEntry: () => sessionEntries.at(-1),
|
|
28521
28126
|
getLeafId: () => runId,
|
|
28522
28127
|
getEntries: () => sessionEntries,
|
|
28523
|
-
getSessionDir: () =>
|
|
28128
|
+
getSessionDir: () => dirname22(sessionFile),
|
|
28524
28129
|
getSessionFile: () => sessionFile,
|
|
28525
28130
|
getHeader: () => ({ type: "session", id: runId }),
|
|
28526
28131
|
setSessionFile(path) {
|
|
@@ -28556,12 +28161,6 @@ async function prepareRoleEnvelope(options) {
|
|
|
28556
28161
|
const host = {
|
|
28557
28162
|
deliverSubmissionRejection(_value) {
|
|
28558
28163
|
},
|
|
28559
|
-
capabilities: {
|
|
28560
|
-
// #922: native loaders own expansion; package does not pre-read bodies (ADR 0032).
|
|
28561
|
-
skillExpansion() {
|
|
28562
|
-
return void 0;
|
|
28563
|
-
}
|
|
28564
|
-
},
|
|
28565
28164
|
registerFlag(name, definition) {
|
|
28566
28165
|
if (!flags.has(name) && definition.default !== void 0) flags.set(name, definition.default);
|
|
28567
28166
|
},
|
|
@@ -28884,8 +28483,8 @@ async function prepareRoleEnvelope(options) {
|
|
|
28884
28483
|
try {
|
|
28885
28484
|
const closeAll = server.closeAllConnections;
|
|
28886
28485
|
if (typeof closeAll === "function") closeAll.call(server);
|
|
28887
|
-
await new Promise((
|
|
28888
|
-
server.close((error) => error ? reject(error) :
|
|
28486
|
+
await new Promise((resolve21, reject) => {
|
|
28487
|
+
server.close((error) => error ? reject(error) : resolve21());
|
|
28889
28488
|
});
|
|
28890
28489
|
} catch (error) {
|
|
28891
28490
|
cleanupFailures.push(error);
|
|
@@ -28980,13 +28579,6 @@ async function prepareRoleEnvelope(options) {
|
|
|
28980
28579
|
throw new Error(`terminating tool not registered after activation: ${terminatingToolName}`);
|
|
28981
28580
|
}
|
|
28982
28581
|
const jsonSchema = terminatingToolJsonSchema(terminating.parameters);
|
|
28983
|
-
if (request.host === "codex" && hostMethodSkills(request.methods).length > 0) {
|
|
28984
|
-
const packageRoot = options.dependencies.packageRoot;
|
|
28985
|
-
if (typeof packageRoot !== "string" || packageRoot === "") {
|
|
28986
|
-
throw new Error("codex project Skill catalog requires packageRoot");
|
|
28987
|
-
}
|
|
28988
|
-
await installWorkspaceMethodSkills(request.cwd, packageRoot);
|
|
28989
|
-
}
|
|
28990
28582
|
return {
|
|
28991
28583
|
mcpServers: [{
|
|
28992
28584
|
name: `ak-${request.activation.role}`,
|
|
@@ -29022,14 +28614,14 @@ async function prepareRoleEnvelope(options) {
|
|
|
29022
28614
|
|
|
29023
28615
|
// src/role-runtime-dependencies.ts
|
|
29024
28616
|
init_collector_github();
|
|
29025
|
-
import { readFile as
|
|
29026
|
-
import { join as
|
|
28617
|
+
import { readFile as readFile24 } from "node:fs/promises";
|
|
28618
|
+
import { join as join45 } from "node:path";
|
|
29027
28619
|
init_doctor_evidence();
|
|
29028
28620
|
|
|
29029
28621
|
// src/navigator-work-context.ts
|
|
29030
28622
|
init_doctor_evidence();
|
|
29031
28623
|
init_host_contracts();
|
|
29032
|
-
import { readFile as
|
|
28624
|
+
import { readFile as readFile23 } from "node:fs/promises";
|
|
29033
28625
|
import { resolve as resolve19 } from "node:path";
|
|
29034
28626
|
init_notary_source_run();
|
|
29035
28627
|
init_packaged_role_registry();
|
|
@@ -29043,7 +28635,7 @@ function navigatorInputReference(getFlag, role) {
|
|
|
29043
28635
|
async function loadNavigatorWorkContext(options) {
|
|
29044
28636
|
const reference = navigatorInputReference(options.getFlag, options.role);
|
|
29045
28637
|
const subjectMode = packagedNavigatorSubject(options.role);
|
|
29046
|
-
const input = reference === void 0 || subjectMode === "case" || subjectMode === "source-run" ? void 0 : await
|
|
28638
|
+
const input = reference === void 0 || subjectMode === "case" || subjectMode === "source-run" ? void 0 : await readFile23(reference, "utf8");
|
|
29047
28639
|
const subjectRoot = subjectPath(reference ?? options.context.sessionManager.getSessionDir(), options.context.cwd);
|
|
29048
28640
|
let subjectKey = reference === void 0 ? subjectRoot : navigatorSubjectKeyForInput(subjectRoot, reference, options.context.cwd);
|
|
29049
28641
|
let subject = input ?? `work subject: ${subjectKey}`;
|
|
@@ -29100,7 +28692,7 @@ async function loadNavigatorWorkContext(options) {
|
|
|
29100
28692
|
let authorityMaterial;
|
|
29101
28693
|
for (const path of authorityFiles) {
|
|
29102
28694
|
try {
|
|
29103
|
-
const content = await
|
|
28695
|
+
const content = await readFile23(path, "utf8");
|
|
29104
28696
|
if (content.trim() !== "") {
|
|
29105
28697
|
authorityMaterial = content;
|
|
29106
28698
|
break;
|
|
@@ -29123,54 +28715,6 @@ async function loadNavigatorWorkContext(options) {
|
|
|
29123
28715
|
|
|
29124
28716
|
// src/role-runtime-dependencies.ts
|
|
29125
28717
|
init_notary_source_run();
|
|
29126
|
-
|
|
29127
|
-
// src/package-resources/method-skill-binding.ts
|
|
29128
|
-
import { dirname as dirname25 } from "node:path";
|
|
29129
|
-
|
|
29130
|
-
// src/canonical-skill-binding.ts
|
|
29131
|
-
import { dirname as dirname24, resolve as resolve20 } from "node:path";
|
|
29132
|
-
import { stripFrontmatter } from "@earendil-works/pi-coding-agent";
|
|
29133
|
-
function captureCanonicalSkillExpansion(name, snapshot, configuredPath, evidence, originalRequest) {
|
|
29134
|
-
const matchedPath = evidence?.location === configuredPath ? configuredPath : evidence?.location === snapshot.path ? snapshot.path : void 0;
|
|
29135
|
-
const expectedContent = matchedPath === void 0 ? void 0 : snapshot.body;
|
|
29136
|
-
const prefixedContent = matchedPath === void 0 ? void 0 : `References are relative to ${dirname24(matchedPath)}.
|
|
29137
|
-
|
|
29138
|
-
${snapshot.body}`;
|
|
29139
|
-
if (evidence?.name !== name || matchedPath === void 0 || evidence.content !== expectedContent && evidence.content !== prefixedContent || evidence.userMessage !== originalRequest) {
|
|
29140
|
-
return void 0;
|
|
29141
|
-
}
|
|
29142
|
-
return Object.freeze({ ...evidence, name });
|
|
29143
|
-
}
|
|
29144
|
-
|
|
29145
|
-
// src/package-resources/method-skill-binding.ts
|
|
29146
|
-
init_method_skill();
|
|
29147
|
-
async function loadPackagedCanonicalSkillBinding(packageRoot, name) {
|
|
29148
|
-
const material = await loadPackagedMethodSkillMaterial(packageRoot, name);
|
|
29149
|
-
const configuredPath = resolvePackagedMethodSkillPath(packageRoot, name);
|
|
29150
|
-
const snapshot = Object.freeze({
|
|
29151
|
-
raw: material.raw,
|
|
29152
|
-
path: material.skillPath,
|
|
29153
|
-
baseDir: dirname25(material.skillPath),
|
|
29154
|
-
body: material.body,
|
|
29155
|
-
snapshotIdentity: Object.freeze({ text: material.raw })
|
|
29156
|
-
});
|
|
29157
|
-
const binding = {
|
|
29158
|
-
name,
|
|
29159
|
-
snapshot,
|
|
29160
|
-
captureExpansion(evidence, originalRequest) {
|
|
29161
|
-
return captureCanonicalSkillExpansion(
|
|
29162
|
-
name,
|
|
29163
|
-
snapshot,
|
|
29164
|
-
configuredPath,
|
|
29165
|
-
evidence,
|
|
29166
|
-
originalRequest
|
|
29167
|
-
);
|
|
29168
|
-
}
|
|
29169
|
-
};
|
|
29170
|
-
return Object.freeze(binding);
|
|
29171
|
-
}
|
|
29172
|
-
|
|
29173
|
-
// src/role-runtime-dependencies.ts
|
|
29174
28718
|
init_auditor_soul();
|
|
29175
28719
|
init_packaged_role_registry();
|
|
29176
28720
|
init_session_opening_materials();
|
|
@@ -29185,33 +28729,21 @@ function loadRegisteredRoleSoul(role) {
|
|
|
29185
28729
|
return usesSubjectSoul(role) ? loadAuditorSoulFromSubjectInput() : loadMainRoleSessionMaterials(role);
|
|
29186
28730
|
}
|
|
29187
28731
|
function createRoleRuntimeDependencies(packageRoot) {
|
|
29188
|
-
const navigatorRoutePlaybookPath =
|
|
29189
|
-
const collectorHandbookSeedPath =
|
|
28732
|
+
const navigatorRoutePlaybookPath = join45(packageRoot, "resources/navigator-route-playbook.md");
|
|
28733
|
+
const collectorHandbookSeedPath = join45(packageRoot, "resources/collector-bot-handbook.md");
|
|
29190
28734
|
const doctorAuditor = createPiDoctorAuditor();
|
|
29191
28735
|
const navigatorSessionFactory = createNativeNavigatorSessionFactory();
|
|
29192
28736
|
return {
|
|
29193
28737
|
packageRoot,
|
|
29194
28738
|
loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
|
|
29195
28739
|
loadRoleSoul: loadRegisteredRoleSoul,
|
|
29196
|
-
loadFixPacket: (path) =>
|
|
29197
|
-
loadCoderTask: (path) =>
|
|
29198
|
-
loadCollectorHandbookSeed: () =>
|
|
28740
|
+
loadFixPacket: (path) => readFile24(path, "utf8"),
|
|
28741
|
+
loadCoderTask: (path) => readFile24(path, "utf8"),
|
|
28742
|
+
loadCollectorHandbookSeed: () => readFile24(collectorHandbookSeedPath, "utf8"),
|
|
29199
28743
|
createCollectorTransport: () => createGhCollectorGitHubTransport(),
|
|
29200
28744
|
loadDoctorCase,
|
|
29201
28745
|
loadNotarySourceRun: loadNotarySourceRunLocator,
|
|
29202
|
-
loadMergerInput: async (path) => JSON.parse(await
|
|
29203
|
-
async loadCanonicalSkillBinding(name) {
|
|
29204
|
-
switch (name) {
|
|
29205
|
-
case "tdd":
|
|
29206
|
-
return loadPackagedCanonicalSkillBinding(packageRoot, name);
|
|
29207
|
-
case "ak-cross-m-review":
|
|
29208
|
-
return loadPackagedCanonicalSkillBinding(packageRoot, name);
|
|
29209
|
-
default: {
|
|
29210
|
-
const unexpected = name;
|
|
29211
|
-
throw new Error(`Canonical skill is not packaged: ${String(unexpected)}`);
|
|
29212
|
-
}
|
|
29213
|
-
}
|
|
29214
|
-
},
|
|
28746
|
+
loadMergerInput: async (path) => JSON.parse(await readFile24(path, "utf8")),
|
|
29215
28747
|
// #590: doctor compliance still on disposeCompliance path; judge→auditor is gate queue (#756).
|
|
29216
28748
|
auditDoctorCompliance: (options) => doctorAuditor(options),
|
|
29217
28749
|
loadNavigatorWorkContext: (options) => loadNavigatorWorkContext({
|
|
@@ -29228,7 +28760,7 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
29228
28760
|
authority: options.authority,
|
|
29229
28761
|
invocationId: options.invocationId,
|
|
29230
28762
|
loadSoul: () => loadRegisteredRoleSoul("navigator"),
|
|
29231
|
-
loadRoutePlaybook: () =>
|
|
28763
|
+
loadRoutePlaybook: () => readFile24(navigatorRoutePlaybookPath, "utf8"),
|
|
29232
28764
|
loadRoleHelp: async (role) => formatNavigatorRoleHelp(role),
|
|
29233
28765
|
createSession: navigatorSessionFactory,
|
|
29234
28766
|
...options.contextError === void 0 ? {} : { contextError: options.contextError },
|
|
@@ -29241,9 +28773,9 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
29241
28773
|
init_session_identity();
|
|
29242
28774
|
|
|
29243
28775
|
// src/acp-host/description.ts
|
|
29244
|
-
import { join as
|
|
28776
|
+
import { join as join46 } from "node:path";
|
|
29245
28777
|
function resolveAcpBinary(description, operatorHome) {
|
|
29246
|
-
return
|
|
28778
|
+
return join46(operatorHome, ...description.binaryFromHome);
|
|
29247
28779
|
}
|
|
29248
28780
|
function acpStdioArgs(description, model, seat) {
|
|
29249
28781
|
const { prefix, suffix, modelFlag, thinkingFlag } = description.argv;
|
|
@@ -29292,7 +28824,7 @@ function hostAbortedError(message = "host aborted") {
|
|
|
29292
28824
|
function raceAgainstHostAbort(work, abortSignal, message = "host aborted") {
|
|
29293
28825
|
if (abortSignal?.aborted) return Promise.reject(hostAbortedError(message));
|
|
29294
28826
|
if (abortSignal === void 0) return work;
|
|
29295
|
-
return new Promise((
|
|
28827
|
+
return new Promise((resolve21, reject) => {
|
|
29296
28828
|
let settled = false;
|
|
29297
28829
|
const onAbort = () => {
|
|
29298
28830
|
if (settled) return;
|
|
@@ -29307,7 +28839,7 @@ function raceAgainstHostAbort(work, abortSignal, message = "host aborted") {
|
|
|
29307
28839
|
if (settled) return;
|
|
29308
28840
|
settled = true;
|
|
29309
28841
|
abortSignal.removeEventListener("abort", onAbort);
|
|
29310
|
-
|
|
28842
|
+
resolve21(value);
|
|
29311
28843
|
},
|
|
29312
28844
|
(error) => {
|
|
29313
28845
|
if (settled) return;
|
|
@@ -29559,8 +29091,8 @@ function connectAcpStdio(options) {
|
|
|
29559
29091
|
request(method, params) {
|
|
29560
29092
|
if (closed) return Promise.reject(terminalError ?? acpError("acp-connection-closed", "ACP connection is closed"));
|
|
29561
29093
|
const id = ++nextId;
|
|
29562
|
-
return new Promise((
|
|
29563
|
-
pending.set(id, { resolve:
|
|
29094
|
+
return new Promise((resolve21, reject) => {
|
|
29095
|
+
pending.set(id, { resolve: resolve21, reject });
|
|
29564
29096
|
child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", id, method, params })}
|
|
29565
29097
|
`, (error) => {
|
|
29566
29098
|
if (error === null || error === void 0) return;
|
|
@@ -29587,7 +29119,7 @@ function connectAcpStdio(options) {
|
|
|
29587
29119
|
settleClosed(acpError("acp-connection-closed", "ACP connection is closed"));
|
|
29588
29120
|
child.stdin.end();
|
|
29589
29121
|
child.kill("SIGTERM");
|
|
29590
|
-
await new Promise((
|
|
29122
|
+
await new Promise((resolve21) => child.once("close", () => resolve21()));
|
|
29591
29123
|
}
|
|
29592
29124
|
});
|
|
29593
29125
|
}
|
|
@@ -29807,18 +29339,18 @@ function createAcpRoleTurnHost(config) {
|
|
|
29807
29339
|
}
|
|
29808
29340
|
|
|
29809
29341
|
// src/acp-host/seat-profile-soul.ts
|
|
29810
|
-
import { constants as
|
|
29811
|
-
import { access as
|
|
29812
|
-
import { dirname as
|
|
29342
|
+
import { constants as constants3 } from "node:fs";
|
|
29343
|
+
import { access as access4, copyFile, lstat as lstat8, mkdir as mkdir6, readlink, symlink as symlink2, unlink as unlink6 } from "node:fs/promises";
|
|
29344
|
+
import { dirname as dirname23, join as join47, relative as relative3, resolve as resolve20 } from "node:path";
|
|
29813
29345
|
function seatProfileName(spec, role) {
|
|
29814
29346
|
return `${spec.namePrefix}${role}`;
|
|
29815
29347
|
}
|
|
29816
29348
|
function packageRoleSoulPath(packageRoot, role) {
|
|
29817
|
-
return
|
|
29349
|
+
return join47(packageRoot, "souls", `${role}.md`);
|
|
29818
29350
|
}
|
|
29819
29351
|
async function pathExists2(path) {
|
|
29820
29352
|
try {
|
|
29821
|
-
await
|
|
29353
|
+
await access4(path, constants3.F_OK);
|
|
29822
29354
|
return true;
|
|
29823
29355
|
} catch {
|
|
29824
29356
|
return false;
|
|
@@ -29827,20 +29359,20 @@ async function pathExists2(path) {
|
|
|
29827
29359
|
async function ensureSeatProfileSoul(options) {
|
|
29828
29360
|
const { spec, operatorHome, packageRoot, role } = options;
|
|
29829
29361
|
const profileName = seatProfileName(spec, role);
|
|
29830
|
-
const soulTarget =
|
|
29362
|
+
const soulTarget = resolve20(packageRoleSoulPath(packageRoot, role));
|
|
29831
29363
|
if (!await pathExists2(soulTarget)) {
|
|
29832
29364
|
throw new Error(`packaged role soul missing: ${soulTarget}`);
|
|
29833
29365
|
}
|
|
29834
|
-
const profilesRoot =
|
|
29835
|
-
const profileDir =
|
|
29836
|
-
const hostRoot =
|
|
29837
|
-
const soulPath =
|
|
29366
|
+
const profilesRoot = join47(operatorHome, ...spec.profilesRootFromHome);
|
|
29367
|
+
const profileDir = join47(profilesRoot, profileName);
|
|
29368
|
+
const hostRoot = dirname23(profilesRoot);
|
|
29369
|
+
const soulPath = join47(profileDir, spec.soulFileName);
|
|
29838
29370
|
if (!await pathExists2(profileDir)) {
|
|
29839
29371
|
await mkdir6(profileDir, { recursive: true });
|
|
29840
29372
|
for (const name of ["auth.json", ".env", "config.yaml"]) {
|
|
29841
|
-
const source =
|
|
29373
|
+
const source = join47(hostRoot, name);
|
|
29842
29374
|
if (!await pathExists2(source)) continue;
|
|
29843
|
-
await copyFile(source,
|
|
29375
|
+
await copyFile(source, join47(profileDir, name));
|
|
29844
29376
|
}
|
|
29845
29377
|
} else {
|
|
29846
29378
|
await mkdir6(profileDir, { recursive: true });
|
|
@@ -29850,7 +29382,7 @@ async function ensureSeatProfileSoul(options) {
|
|
|
29850
29382
|
try {
|
|
29851
29383
|
const st = await lstat8(soulPath);
|
|
29852
29384
|
if (st.isSymbolicLink()) {
|
|
29853
|
-
current = await
|
|
29385
|
+
current = await readlink(soulPath);
|
|
29854
29386
|
}
|
|
29855
29387
|
} catch {
|
|
29856
29388
|
current = void 0;
|