@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.
Files changed (82) hide show
  1. package/README.md +2 -2
  2. package/README.zh-CN.md +2 -2
  3. package/THIRD_PARTY_NOTICES.md +8 -8
  4. package/dist/acp-host/production-host.js +410 -878
  5. package/dist/headless-host/description.js +0 -2
  6. package/dist/headless-host/production-host.js +413 -914
  7. package/dist/host-descriptions.js +2 -3
  8. package/dist/migrate-book-topology.js +4 -10
  9. package/dist/packaged-role-registry.js +17 -16
  10. package/dist/pi/role-turn-host.js +3 -27
  11. package/dist/public-cli/cli.js +6 -0
  12. package/dist/public-cli/instruction-seat-run.js +12 -40
  13. package/dist/public-cli/machine-method-skills.js +150 -0
  14. package/dist/public-cli/main.js +378 -579
  15. package/dist/public-cli/post-admission.js +2 -0
  16. package/dist/public-cli/registry.js +2 -1
  17. package/dist/public-cli/settlement.js +12 -99
  18. package/dist/public-cli/turn-request.js +16 -8
  19. package/package.json +5 -1
  20. package/scripts/build-package.mjs +1 -6
  21. package/src/headless-host/description.ts +0 -3
  22. package/src/headless-host/role-turn-host.ts +2 -23
  23. package/src/host-contracts.ts +2 -23
  24. package/src/host-descriptions.ts +2 -3
  25. package/src/packaged-role-registry.ts +14 -14
  26. package/src/pi/adapter.ts +0 -27
  27. package/src/pi/role-turn-host.ts +3 -31
  28. package/src/public-cli/cli.ts +6 -0
  29. package/src/public-cli/instruction-seat-run.ts +9 -42
  30. package/src/public-cli/machine-method-skills.ts +153 -0
  31. package/src/public-cli/post-admission.ts +2 -0
  32. package/src/public-cli/registry.ts +1 -0
  33. package/src/public-cli/settlement.ts +6 -138
  34. package/src/public-cli/turn-request.ts +24 -16
  35. package/src/reviewer-role.ts +1 -12
  36. package/src/role-envelope.ts +0 -13
  37. package/src/role-runtime-dependencies.ts +0 -13
  38. package/src/role-runtime.ts +4 -56
  39. package/src/worker-role.ts +1 -81
  40. package/dist/method-host-plugin/.claude-plugin/plugin.json +0 -5
  41. package/dist/method-host-plugin/skills/ak-cross-m-review/CONTEXT.md +0 -48
  42. package/dist/method-host-plugin/skills/ak-cross-m-review/LICENSE +0 -21
  43. package/dist/method-host-plugin/skills/ak-cross-m-review/SKILL.md +0 -170
  44. package/dist/method-host-plugin/skills/ak-cross-m-review/prompts/cmr-completeness.md +0 -118
  45. package/dist/method-host-plugin/skills/ak-cross-m-review/prompts/cmr-reviewer.md +0 -128
  46. package/dist/method-host-plugin/skills/ak-cross-m-review/provenance.json +0 -41
  47. package/dist/method-host-plugin/skills/diagnosing-bugs/SKILL.md +0 -134
  48. package/dist/method-host-plugin/skills/diagnosing-bugs/agents/openai.yaml +0 -3
  49. package/dist/method-host-plugin/skills/diagnosing-bugs/provenance.json +0 -31
  50. package/dist/method-host-plugin/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +0 -41
  51. package/dist/method-host-plugin/skills/resolving-merge-conflicts/SKILL.md +0 -14
  52. package/dist/method-host-plugin/skills/resolving-merge-conflicts/agents/openai.yaml +0 -3
  53. package/dist/method-host-plugin/skills/resolving-merge-conflicts/provenance.json +0 -26
  54. package/dist/method-host-plugin/skills/tdd/SKILL.md +0 -38
  55. package/dist/method-host-plugin/skills/tdd/agents/openai.yaml +0 -3
  56. package/dist/method-host-plugin/skills/tdd/mocking.md +0 -59
  57. package/dist/method-host-plugin/skills/tdd/provenance.json +0 -36
  58. package/dist/method-host-plugin/skills/tdd/tests.md +0 -77
  59. package/dist/package-resources/method-skill.js +0 -259
  60. package/resources/method-host-plugin/.claude-plugin/plugin.json +0 -5
  61. package/resources/methods/ak-cross-m-review/CONTEXT.md +0 -48
  62. package/resources/methods/ak-cross-m-review/LICENSE +0 -21
  63. package/resources/methods/ak-cross-m-review/SKILL.md +0 -170
  64. package/resources/methods/ak-cross-m-review/prompts/cmr-completeness.md +0 -118
  65. package/resources/methods/ak-cross-m-review/prompts/cmr-reviewer.md +0 -128
  66. package/resources/methods/ak-cross-m-review/provenance.json +0 -41
  67. package/resources/methods/diagnosing-bugs/SKILL.md +0 -134
  68. package/resources/methods/diagnosing-bugs/agents/openai.yaml +0 -3
  69. package/resources/methods/diagnosing-bugs/provenance.json +0 -31
  70. package/resources/methods/diagnosing-bugs/scripts/hitl-loop.template.sh +0 -41
  71. package/resources/methods/resolving-merge-conflicts/SKILL.md +0 -14
  72. package/resources/methods/resolving-merge-conflicts/agents/openai.yaml +0 -3
  73. package/resources/methods/resolving-merge-conflicts/provenance.json +0 -26
  74. package/resources/methods/tdd/SKILL.md +0 -38
  75. package/resources/methods/tdd/agents/openai.yaml +0 -3
  76. package/resources/methods/tdd/mocking.md +0 -59
  77. package/resources/methods/tdd/provenance.json +0 -36
  78. package/resources/methods/tdd/tests.md +0 -77
  79. package/src/canonical-skill-binding.ts +0 -118
  80. package/src/host-native-method.ts +0 -185
  81. package/src/package-resources/method-skill-binding.ts +0 -60
  82. package/src/package-resources/method-skill.ts +0 -363
@@ -15308,7 +15308,7 @@ __export(packaged_role_registry_exports, {
15308
15308
  packagedEmitsAuthorityRefs: () => packagedEmitsAuthorityRefs,
15309
15309
  packagedGateStageLabel: () => packagedGateStageLabel,
15310
15310
  packagedGateSummon: () => packagedGateSummon,
15311
- packagedMethodLoadFailureCause: () => packagedMethodLoadFailureCause,
15311
+ packagedMethodSkillNames: () => packagedMethodSkillNames,
15312
15312
  packagedModelParent: () => packagedModelParent,
15313
15313
  packagedNavigatorSubject: () => packagedNavigatorSubject,
15314
15314
  packagedProjectsTargetBindRejection: () => packagedProjectsTargetBindRejection,
@@ -15330,6 +15330,18 @@ __export(packaged_role_registry_exports, {
15330
15330
  function packagedRoleMetadata(role) {
15331
15331
  return PACKAGED_ROLE_REGISTRY.find((entry) => entry.role === role);
15332
15332
  }
15333
+ function packagedMethodSkillNames() {
15334
+ const names = [];
15335
+ for (const record4 of PACKAGED_ROLE_REGISTRY) {
15336
+ if ("methodSkills" in record4 && record4.methodSkills !== void 0) {
15337
+ for (const name of record4.methodSkills) if (!names.includes(name)) names.push(name);
15338
+ }
15339
+ if ("applyMethod" in record4 && record4.applyMethod !== void 0 && !names.includes(record4.applyMethod)) {
15340
+ names.push(record4.applyMethod);
15341
+ }
15342
+ }
15343
+ return names;
15344
+ }
15333
15345
  function isOfficerReviewSeat(role) {
15334
15346
  const record4 = packagedRoleMetadata(role);
15335
15347
  return record4 !== void 0 && "reviewOfficer" in record4 && record4.reviewOfficer === true;
@@ -15364,11 +15376,6 @@ function packagedRolePhaseFlag(role) {
15364
15376
  function packagedRoleOutputTool(role) {
15365
15377
  return packagedRoleMetadata(role)?.outputTool;
15366
15378
  }
15367
- function packagedMethodLoadFailureCause(role) {
15368
- const record4 = packagedRoleMetadata(role);
15369
- if (record4 === void 0 || !("methodLoadFailureCause" in record4)) return void 0;
15370
- return record4.methodLoadFailureCause;
15371
- }
15372
15379
  function packagedBindsBoardTicket(role) {
15373
15380
  const record4 = packagedRoleMetadata(role);
15374
15381
  return record4?.sameParent === "board-ticket";
@@ -15571,8 +15578,7 @@ var init_packaged_role_registry = __esm({
15571
15578
  { key: "packetPath" },
15572
15579
  { key: "prerequisitesPath", omitUndefined: true },
15573
15580
  { key: "prerequisites" }
15574
- ],
15575
- method: "observed"
15581
+ ]
15576
15582
  },
15577
15583
  boardPlacement: "marshal",
15578
15584
  activationFlags: [
@@ -15598,7 +15604,6 @@ var init_packaged_role_registry = __esm({
15598
15604
  worker: true,
15599
15605
  applyMethod: "tdd",
15600
15606
  /** Method-material load failure keeps the activation cause (not reviewer/fixer). */
15601
- methodLoadFailureCause: "activation",
15602
15607
  boardPlacement: "coder",
15603
15608
  phases: ["plan", "apply"],
15604
15609
  outputTool: CODER_OUTPUT_TOOL_NAME,
@@ -15609,8 +15614,7 @@ var init_packaged_role_registry = __esm({
15609
15614
  leaves: [
15610
15615
  { key: "phase" },
15611
15616
  { key: "taskPath" }
15612
- ],
15613
- method: "optional"
15617
+ ]
15614
15618
  },
15615
15619
  activationFlags: [
15616
15620
  { field: "taskPath", flag: "ak-coder-task", binds: "input" },
@@ -15651,8 +15655,7 @@ var init_packaged_role_registry = __esm({
15651
15655
  { key: "lens" },
15652
15656
  { key: "authorityRefs", copyArray: true },
15653
15657
  { key: "callerProvenance", callerProvenance: true }
15654
- ],
15655
- method: "observed"
15658
+ ]
15656
15659
  },
15657
15660
  /** Frozen base/lens/authority become the initial prompt; instruction follows. */
15658
15661
  transportPrompt: "skill-args",
@@ -15751,7 +15754,6 @@ var init_packaged_role_registry = __esm({
15751
15754
  methodSkills: ["resolving-merge-conflicts"],
15752
15755
  settleMethod: "resolving-merge-conflicts",
15753
15756
  /** Method-material load failure keeps the activation cause (not reviewer/fixer). */
15754
- methodLoadFailureCause: "activation",
15755
15757
  phases: [null],
15756
15758
  outputTool: MERGER_OUTPUT_TOOL_NAME,
15757
15759
  settlement: "residual",
@@ -15763,8 +15765,7 @@ var init_packaged_role_registry = __esm({
15763
15765
  leaves: [
15764
15766
  { key: "mergerInputPath" },
15765
15767
  { key: "derived" }
15766
- ],
15767
- method: "observed"
15768
+ ]
15768
15769
  },
15769
15770
  activationFlags: [
15770
15771
  { field: "inputPath", from: "mergerInputPath", flag: "ak-merger-input", binds: "input" }
@@ -16058,7 +16059,8 @@ var init_registry2 = __esm({
16058
16059
  "config",
16059
16060
  "help",
16060
16061
  "resume",
16061
- "new"
16062
+ "new",
16063
+ "setup"
16062
16064
  ];
16063
16065
  PUBLIC_DETERMINISTIC_COMMANDS = ["analyst"];
16064
16066
  }
@@ -16912,6 +16914,150 @@ var init_cli_errors = __esm({
16912
16914
  }
16913
16915
  });
16914
16916
 
16917
+ // src/public-cli/machine-method-skills.ts
16918
+ import { accessSync, constants, statSync as statSync2 } from "node:fs";
16919
+ import { lstat as lstat2, mkdir as mkdir2, symlink } from "node:fs/promises";
16920
+ import { join as join9 } from "node:path";
16921
+ import { spawnSync } from "node:child_process";
16922
+ function skillRoot(home) {
16923
+ return join9(home, ".agents/skills");
16924
+ }
16925
+ function installedMethodSkillPath(home, name) {
16926
+ return installedSkillPath(skillRoot(home), name);
16927
+ }
16928
+ function installedSkillPath(root, name) {
16929
+ const path = join9(root, name, "SKILL.md");
16930
+ try {
16931
+ if (!statSync2(path).isFile()) return void 0;
16932
+ accessSync(path, constants.R_OK);
16933
+ return path;
16934
+ } catch (error) {
16935
+ const code = error.code;
16936
+ if (code === "ENOENT" || code === "ENOTDIR" || code === "EACCES" || code === "EPERM" || code === "ELOOP") return void 0;
16937
+ throw error;
16938
+ }
16939
+ }
16940
+ function linkedSkillRoot(home, host) {
16941
+ if (host === "claude" || host === "claude-code") {
16942
+ return join9(process.env.CLAUDE_CONFIG_DIR?.trim() || join9(home, ".claude"), "skills");
16943
+ }
16944
+ if (host === "hermes") return join9(home, ".hermes/skills");
16945
+ return void 0;
16946
+ }
16947
+ async function occupied(path) {
16948
+ try {
16949
+ await lstat2(path);
16950
+ return true;
16951
+ } catch (error) {
16952
+ if (error.code !== "ENOENT") throw error;
16953
+ return false;
16954
+ }
16955
+ }
16956
+ function warnOccupied(path, stdout) {
16957
+ stdout(`Warning: ${path} is already occupied; left untouched.
16958
+ `);
16959
+ }
16960
+ async function warnMissingMethodSkills(home, host, role, skills, stdout) {
16961
+ const missing = [];
16962
+ const linkedRoot = linkedSkillRoot(home, host);
16963
+ for (const skill of skills) {
16964
+ if (installedMethodSkillPath(home, skill) === void 0 || linkedRoot !== void 0 && installedSkillPath(linkedRoot, skill) === void 0) missing.push(skill);
16965
+ }
16966
+ for (const skill of missing) {
16967
+ 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.
16968
+ `);
16969
+ }
16970
+ }
16971
+ function runSkillsCli(args, home) {
16972
+ const result = spawnSync("npx", ["--yes", "skills", ...args], {
16973
+ stdio: "inherit",
16974
+ env: { ...process.env, HOME: home }
16975
+ });
16976
+ if (result.error !== void 0) throw result.error;
16977
+ return result.status === 0;
16978
+ }
16979
+ function addSkills(source, skills, home) {
16980
+ if (skills.length === 0) return true;
16981
+ return runSkillsCli([
16982
+ "add",
16983
+ source,
16984
+ ...skills.flatMap((skill) => ["--skill", skill]),
16985
+ "--agent",
16986
+ "codex",
16987
+ "--global",
16988
+ "--yes"
16989
+ ], home);
16990
+ }
16991
+ function updateRequiredSkills(home) {
16992
+ const names = packagedMethodSkillNames();
16993
+ if (names.length === 0) return true;
16994
+ return runSkillsCli(["update", "-g", "-y", ...names], home);
16995
+ }
16996
+ async function runMachineSkillSetup(home, stdout) {
16997
+ const canonical = skillRoot(home);
16998
+ const missingBySource = /* @__PURE__ */ new Map();
16999
+ let unsourced = false;
17000
+ for (const name of packagedMethodSkillNames()) {
17001
+ const path = join9(canonical, name);
17002
+ if (await occupied(path)) {
17003
+ warnOccupied(path, stdout);
17004
+ continue;
17005
+ }
17006
+ const source = SKILL_SOURCE[name];
17007
+ if (source === void 0) {
17008
+ unsourced = true;
17009
+ stdout(`Warning: required machine Skill "${name}" has no install source; setup did not install it.
17010
+ `);
17011
+ continue;
17012
+ }
17013
+ const missing = missingBySource.get(source) ?? [];
17014
+ missing.push(name);
17015
+ missingBySource.set(source, missing);
17016
+ }
17017
+ for (const [source, missing] of missingBySource) {
17018
+ if (!addSkills(source, missing, home)) return 1;
17019
+ }
17020
+ if (unsourced) return 1;
17021
+ for (const host of ["claude-code", "hermes"]) {
17022
+ const root = linkedSkillRoot(home, host);
17023
+ const binaryFromHome = host === "claude-code" ? HEADLESS_HOST_DESCRIPTIONS.claude.binaryFromHome : HOST_DESCRIPTIONS.hermes.binaryFromHome;
17024
+ try {
17025
+ accessSync(join9(home, ...binaryFromHome), constants.X_OK);
17026
+ } catch (error) {
17027
+ if (["ENOENT", "ENOTDIR", "EACCES"].includes(error.code ?? "")) continue;
17028
+ throw error;
17029
+ }
17030
+ for (const name of packagedMethodSkillNames()) {
17031
+ const target = join9(canonical, name);
17032
+ if (installedMethodSkillPath(home, name) === void 0) continue;
17033
+ const link = join9(root, name);
17034
+ if (await occupied(link)) {
17035
+ warnOccupied(link, stdout);
17036
+ continue;
17037
+ }
17038
+ await mkdir2(root, { recursive: true });
17039
+ await symlink(target, link, "dir");
17040
+ }
17041
+ }
17042
+ if (!updateRequiredSkills(home)) return 1;
17043
+ stdout("Machine method Skills setup finished. Existing same-name Skills were left untouched.\n");
17044
+ return 0;
17045
+ }
17046
+ var SKILL_SOURCE;
17047
+ var init_machine_method_skills = __esm({
17048
+ "src/public-cli/machine-method-skills.ts"() {
17049
+ "use strict";
17050
+ init_host_descriptions();
17051
+ init_packaged_role_registry();
17052
+ SKILL_SOURCE = {
17053
+ tdd: "mattpocock/skills",
17054
+ "diagnosing-bugs": "mattpocock/skills",
17055
+ "resolving-merge-conflicts": "mattpocock/skills",
17056
+ "ak-cross-m-review": "Akagilnc/ak-cross-m-review"
17057
+ };
17058
+ }
17059
+ });
17060
+
16915
17061
  // src/host-contracts.ts
16916
17062
  var ExplicitInternalActivationError;
16917
17063
  var init_host_contracts = __esm({
@@ -17032,7 +17178,7 @@ import {
17032
17178
  unlinkSync,
17033
17179
  writeFileSync
17034
17180
  } from "node:fs";
17035
- import { dirname as dirname5, join as join9 } from "node:path";
17181
+ import { dirname as dirname5, join as join10 } from "node:path";
17036
17182
  function isRecord2(value) {
17037
17183
  return typeof value === "object" && value !== null && !Array.isArray(value);
17038
17184
  }
@@ -17190,8 +17336,8 @@ function resolveSitianVolumeCategory(kind) {
17190
17336
  return kind;
17191
17337
  }
17192
17338
  function ticketProvenanceUnderBookPaths(ledgerHome, bookKey, ticketId) {
17193
- const sessionDir = join9(activationBookDirectory(ledgerHome, bookKey), ticketId);
17194
- return { sessionDir, recordFile: join9(sessionDir, SITIAN_RECORDS_LEAF) };
17339
+ const sessionDir = join10(activationBookDirectory(ledgerHome, bookKey), ticketId);
17340
+ return { sessionDir, recordFile: join10(sessionDir, SITIAN_RECORDS_LEAF) };
17195
17341
  }
17196
17342
  function resolveSitianRecordPathInLedger(input, ledgerHome) {
17197
17343
  const category = resolveSitianVolumeCategory(input.kind);
@@ -17208,13 +17354,13 @@ function resolveSitianRecordPathInLedger(input, ledgerHome) {
17208
17354
  recordFile = paths.recordFile;
17209
17355
  } else if (category === "ticket-provenance" && input.runDirectory !== void 0) {
17210
17356
  sessionDir = input.runDirectory;
17211
- recordFile = join9(sessionDir, SITIAN_RECORDS_LEAF);
17357
+ recordFile = join10(sessionDir, SITIAN_RECORDS_LEAF);
17212
17358
  } else {
17213
17359
  if (input.sessionParent === void 0 || input.sessionParent.length === 0 || !physicallyContainedIn(ledgerHome, input.sessionParent)) {
17214
17360
  throw new Error("Sitian record ownership requires a parent session inside the ledger home");
17215
17361
  }
17216
- sessionDir = join9(dirname5(input.sessionParent), category);
17217
- recordFile = join9(sessionDir, SITIAN_RECORDS_LEAF);
17362
+ sessionDir = join10(dirname5(input.sessionParent), category);
17363
+ recordFile = join10(sessionDir, SITIAN_RECORDS_LEAF);
17218
17364
  }
17219
17365
  if (!physicallyContainedIn(ledgerHome, sessionDir)) {
17220
17366
  throw new Error("Sitian record ownership requires a directory inside the ledger home");
@@ -17223,7 +17369,7 @@ function resolveSitianRecordPathInLedger(input, ledgerHome) {
17223
17369
  }
17224
17370
  function projectTicketRecordsPathShape() {
17225
17371
  const { recordFile } = ticketProvenanceUnderBookPaths(
17226
- join9("~", ".ak-roles"),
17372
+ join10("~", ".ak-roles"),
17227
17373
  "<\u7C3F>",
17228
17374
  "<\u7968\u53F7>"
17229
17375
  );
@@ -17349,7 +17495,6 @@ var role_turn_host_exports = {};
17349
17495
  __export(role_turn_host_exports, {
17350
17496
  EXPLICIT_INTERNAL_LOAD_PROBE_ARGS: () => EXPLICIT_INTERNAL_LOAD_PROBE_ARGS,
17351
17497
  appendPiSessionCustomEntry: () => appendPiSessionCustomEntry,
17352
- applyPiNativeSkillInvocation: () => applyPiNativeSkillInvocation,
17353
17498
  buildExplicitInternalActivationArgs: () => buildExplicitInternalActivationArgs,
17354
17499
  buildPiTurnExtraArgs: () => buildPiTurnExtraArgs,
17355
17500
  createDefaultPiSpawnRunner: () => createDefaultPiSpawnRunner,
@@ -17357,14 +17502,14 @@ __export(role_turn_host_exports, {
17357
17502
  resolveInternalRoleEntrypoint: () => resolveInternalRoleEntrypoint
17358
17503
  });
17359
17504
  import { execFile, spawn as spawn2 } from "node:child_process";
17360
- import { constants } from "node:fs";
17505
+ import { constants as constants2 } from "node:fs";
17361
17506
  import { access, appendFile, readFile as readFile5, realpath } from "node:fs/promises";
17362
- import { basename as basename3, delimiter as delimiter2, dirname as dirname6, isAbsolute as isAbsolute3, join as join10, resolve as resolve3 } from "node:path";
17507
+ import { delimiter as delimiter2, dirname as dirname6, isAbsolute as isAbsolute3, join as join11, resolve as resolve3 } from "node:path";
17363
17508
  import { platform } from "node:process";
17364
17509
  import { promisify } from "node:util";
17365
17510
  import { randomUUID as randomUUID2 } from "node:crypto";
17366
17511
  function resolveInternalRoleEntrypoint(packageRoot2) {
17367
- return join10(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
17512
+ return join11(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
17368
17513
  }
17369
17514
  function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
17370
17515
  return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
@@ -17392,24 +17537,11 @@ function buildMethodArgs(methods) {
17392
17537
  const skillArgs = [];
17393
17538
  for (const method of methods) {
17394
17539
  if (method.kind === "skill") {
17395
- skillArgs.push("--skill", method.path);
17540
+ skillArgs.push("--skill", dirname6(method.path));
17396
17541
  }
17397
17542
  }
17398
17543
  return skillArgs;
17399
17544
  }
17400
- function applyPiNativeSkillInvocation(methods, prompt) {
17401
- const skills = methods.filter((method) => method.kind === "skill");
17402
- if (skills.length !== 1) return prompt;
17403
- const name = basename3(dirname6(skills[0].path));
17404
- if (name.length === 0) return prompt;
17405
- const token = `/skill:${name}`;
17406
- const trimmed = prompt.trimStart();
17407
- if (trimmed === token || trimmed.startsWith(`${token} `) || trimmed.startsWith(`${token}
17408
- `)) {
17409
- return prompt;
17410
- }
17411
- return prompt.length === 0 ? token : `${token} ${prompt}`;
17412
- }
17413
17545
  function buildPiTurnExtraArgs(request, authority, extraPiArgs = []) {
17414
17546
  const { sessionFile, sessionDirectory } = authority.decode(request.principal);
17415
17547
  return [
@@ -17441,14 +17573,14 @@ function piUserDialogueBody(request) {
17441
17573
  const _exhaustive = request.continuation;
17442
17574
  return _exhaustive;
17443
17575
  })();
17444
- return request.continuation.kind === "resume" ? rawPrompt : applyPiNativeSkillInvocation(request.methods, rawPrompt);
17576
+ return rawPrompt;
17445
17577
  }
17446
17578
  async function resolveSelectedPi(command, cwd, env) {
17447
17579
  const searchPath = env.PATH ?? (platform === "win32" ? process.env.PATH ?? "" : "/usr/bin:/bin");
17448
17580
  const candidates = isAbsolute3(command) || command.includes("/") ? [resolve3(cwd, command)] : searchPath.split(delimiter2).map((dir) => resolve3(cwd, dir, command));
17449
17581
  for (const candidate of candidates) {
17450
17582
  try {
17451
- await access(candidate, constants.X_OK);
17583
+ await access(candidate, constants2.X_OK);
17452
17584
  } catch (error) {
17453
17585
  const code = error.code;
17454
17586
  if (code === "ENOENT" || code === "ENOTDIR" || code === "EACCES") continue;
@@ -17706,7 +17838,7 @@ __export(run_terminal_artifacts_exports, {
17706
17838
  runIdFromRunDirectory: () => runIdFromRunDirectory
17707
17839
  });
17708
17840
  import { readdir as readdir2, readFile as readFile6 } from "node:fs/promises";
17709
- import { basename as basename4, dirname as dirname7, join as join11 } from "node:path";
17841
+ import { basename as basename3, dirname as dirname7, join as join12 } from "node:path";
17710
17842
  function isMissingPathError2(error) {
17711
17843
  return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
17712
17844
  }
@@ -17781,13 +17913,13 @@ async function listUniqueErrorFallbackPaths(directories) {
17781
17913
  }
17782
17914
  for (const name of names.sort((a, b) => a.localeCompare(b))) {
17783
17915
  if (!UNIQUE_ERROR_FALLBACK_NAME.test(name)) continue;
17784
- found.push(join11(dir, name));
17916
+ found.push(join12(dir, name));
17785
17917
  }
17786
17918
  }
17787
17919
  return found;
17788
17920
  }
17789
17921
  function runIdFromRunDirectory(runDirectory) {
17790
- const name = basename4(runDirectory);
17922
+ const name = basename3(runDirectory);
17791
17923
  const at = name.lastIndexOf("@");
17792
17924
  if (at <= 0 || at === name.length - 1) return void 0;
17793
17925
  return name.slice(0, at);
@@ -17827,11 +17959,11 @@ async function readRunTerminalArtifact(runDirectory) {
17827
17959
  unreadable.push(read);
17828
17960
  };
17829
17961
  for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
17830
- consider(await readTerminalArtifactAtPath(join11(artifactsDir, file), file));
17962
+ consider(await readTerminalArtifactAtPath(join12(artifactsDir, file), file));
17831
17963
  }
17832
17964
  for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
17833
17965
  consider(
17834
- await readTerminalArtifactAtPath(join11(runDirectory, relative3), "error.json")
17966
+ await readTerminalArtifactAtPath(join12(runDirectory, relative3), "error.json")
17835
17967
  );
17836
17968
  }
17837
17969
  for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
@@ -17849,7 +17981,7 @@ async function readRunTerminalArtifact(runDirectory) {
17849
17981
  return { status: "absent" };
17850
17982
  }
17851
17983
  function isUniqueErrorFallbackName(name) {
17852
- return UNIQUE_ERROR_FALLBACK_NAME.test(basename4(name));
17984
+ return UNIQUE_ERROR_FALLBACK_NAME.test(basename3(name));
17853
17985
  }
17854
17986
  var RUN_TERMINAL_ARTIFACT_FILES, RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS, UNIQUE_ERROR_FALLBACK_NAME;
17855
17987
  var init_run_terminal_artifacts = __esm({
@@ -18007,7 +18139,7 @@ var init_compliance_transport = __esm({
18007
18139
  });
18008
18140
 
18009
18141
  // src/role-run-relocation.ts
18010
- import { join as join12, sep as sep2 } from "node:path";
18142
+ import { join as join13, sep as sep2 } from "node:path";
18011
18143
  function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
18012
18144
  if (typeof value !== "string") return value;
18013
18145
  if (value === oldRunDirectory) return newRunDirectory;
@@ -18805,7 +18937,7 @@ var init_session_dialogue = __esm({
18805
18937
 
18806
18938
  // src/ticket-provenance.ts
18807
18939
  import { readFile as readFile10, unlink } from "node:fs/promises";
18808
- import { basename as basename5, dirname as dirname9, join as join13, resolve as resolve6 } from "node:path";
18940
+ import { basename as basename4, dirname as dirname9, join as join14, resolve as resolve6 } from "node:path";
18809
18941
  function ticketProvenanceSubject(ticketNumber) {
18810
18942
  if (!isSafePositiveTicketNumber(ticketNumber)) {
18811
18943
  throw new Error(
@@ -18831,7 +18963,7 @@ function resolveTicketProvenanceVolume(ticketNumber, cwd, home) {
18831
18963
  return { recordFile: path.recordFile, volumeDir: path.sessionDir };
18832
18964
  }
18833
18965
  async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, home) {
18834
- const source = join13(runDirectory, "records.jsonl");
18966
+ const source = join14(runDirectory, "records.jsonl");
18835
18967
  let content;
18836
18968
  try {
18837
18969
  content = await readFile10(source, "utf8");
@@ -18882,9 +19014,9 @@ var init_uuidv7 = __esm({
18882
19014
 
18883
19015
  // src/typed-provider-http.ts
18884
19016
  import { readFile as readFile11, unlink as unlink2, writeFile as writeFile2 } from "node:fs/promises";
18885
- import { join as join14 } from "node:path";
19017
+ import { join as join15 } from "node:path";
18886
19018
  function typedProviderHttpPath(runDirectory) {
18887
- return join14(runDirectory, TYPED_HTTP_FILE);
19019
+ return join15(runDirectory, TYPED_HTTP_FILE);
18888
19020
  }
18889
19021
  async function clearTypedProviderHttpObservation(runDirectory) {
18890
19022
  try {
@@ -18979,8 +19111,8 @@ __export(run_lifecycle_exports, {
18979
19111
  renderResumeCommand: () => renderResumeCommand,
18980
19112
  writeRoleRunState: () => writeRoleRunState
18981
19113
  });
18982
- import { chmod, lstat as lstat2, open, readdir as readdir4, readFile as readFile12, unlink as unlink3, writeFile as writeFile3 } from "node:fs/promises";
18983
- import { basename as basename6, join as join15 } from "node:path";
19114
+ import { chmod, lstat as lstat3, open, readdir as readdir4, readFile as readFile12, unlink as unlink3, writeFile as writeFile3 } from "node:fs/promises";
19115
+ import { basename as basename5, join as join16 } from "node:path";
18984
19116
  function buildAutoResumeContinuationPrompt(options) {
18985
19117
  return appendEngineSessionMaterial(
18986
19118
  [RESUME_TRANSPORT_ENVELOPE],
@@ -19006,7 +19138,7 @@ function renderResumeCommand(runId) {
19006
19138
  async function writeRoleRunState(runDirectory, record4) {
19007
19139
  const payload = { ...record4, runDirectory };
19008
19140
  await writeFile3(
19009
- join15(runDirectory, RUN_STATE_FILE),
19141
+ join16(runDirectory, RUN_STATE_FILE),
19010
19142
  `${JSON.stringify(payload, null, 2)}
19011
19143
  `,
19012
19144
  "utf8"
@@ -19056,7 +19188,7 @@ function parseCurrentCourtState(raw) {
19056
19188
  async function readRoleRunStateRaw(runDirectory) {
19057
19189
  let raw;
19058
19190
  try {
19059
- raw = JSON.parse(await readFile12(join15(runDirectory, RUN_STATE_FILE), "utf8"));
19191
+ raw = JSON.parse(await readFile12(join16(runDirectory, RUN_STATE_FILE), "utf8"));
19060
19192
  } catch (error) {
19061
19193
  if (errorCodeOf2(error) === "ENOENT") return void 0;
19062
19194
  throw error;
@@ -19150,7 +19282,7 @@ async function writeRoleRunStateDisk(runDirectory, disk) {
19150
19282
  ...disk.currentCourt === void 0 ? {} : { currentCourt: disk.currentCourt }
19151
19283
  };
19152
19284
  await writeFile3(
19153
- join15(runDirectory, RUN_STATE_FILE),
19285
+ join16(runDirectory, RUN_STATE_FILE),
19154
19286
  `${JSON.stringify(payload, null, 2)}
19155
19287
  `,
19156
19288
  "utf8"
@@ -19376,7 +19508,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
19376
19508
  },
19377
19509
  relocate(nextRunDirectory) {
19378
19510
  currentRunDirectory = nextRunDirectory;
19379
- currentLockPath = join15(nextRunDirectory, WRITER_LOCK_FILE);
19511
+ currentLockPath = join16(nextRunDirectory, WRITER_LOCK_FILE);
19380
19512
  },
19381
19513
  async release() {
19382
19514
  if (released) return;
@@ -19415,10 +19547,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
19415
19547
  };
19416
19548
  const reportReadFailure = (error) => {
19417
19549
  reportDiagnostic(
19418
- `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join15(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
19550
+ `writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join16(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
19419
19551
  );
19420
19552
  };
19421
- const lockPath = join15(runDirectory, WRITER_LOCK_FILE);
19553
+ const lockPath = join16(runDirectory, WRITER_LOCK_FILE);
19422
19554
  let lastAutopsy = { verdict: "absent" };
19423
19555
  let lastReclaimFailure;
19424
19556
  for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
@@ -19473,7 +19605,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
19473
19605
  async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
19474
19606
  if (runId.trim() === "") return void 0;
19475
19607
  const ledgerHome = resolveActivationLedgerHome(home);
19476
- const booksRoot = join15(ledgerHome, "books");
19608
+ const booksRoot = join16(ledgerHome, "books");
19477
19609
  let bookKeys;
19478
19610
  try {
19479
19611
  bookKeys = await readdir4(booksRoot);
@@ -19493,7 +19625,7 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
19493
19625
  throw error;
19494
19626
  }
19495
19627
  for (const runDirectory of runDirectories) {
19496
- const entry = basename6(runDirectory);
19628
+ const entry = basename5(runDirectory);
19497
19629
  if (onlyRole === void 0 && (entry === `${runId}@judge` || entry.startsWith(`${runId}@`)) || entry === `${runId}@${onlyRole}`) {
19498
19630
  matches.push(runDirectory);
19499
19631
  }
@@ -19514,7 +19646,7 @@ async function readRunParentPath(runDirectory) {
19514
19646
  let raw;
19515
19647
  try {
19516
19648
  raw = JSON.parse(
19517
- await readFile12(join15(runDirectory, "admitted-request.json"), "utf8")
19649
+ await readFile12(join16(runDirectory, "admitted-request.json"), "utf8")
19518
19650
  );
19519
19651
  } catch (error) {
19520
19652
  if (errorCodeOf2(error) === "ENOENT") return void 0;
@@ -19535,9 +19667,9 @@ async function readRunParentPath(runDirectory) {
19535
19667
  async function runHasFormedSessionPrincipal(runDirectory) {
19536
19668
  const disk = await readRoleRunStateDisk(runDirectory);
19537
19669
  if (disk === void 0) return false;
19538
- const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : join15(disk.principalWire.sessionDirectory, "session.jsonl");
19670
+ const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : join16(disk.principalWire.sessionDirectory, "session.jsonl");
19539
19671
  try {
19540
- const stat2 = await lstat2(sessionFile);
19672
+ const stat2 = await lstat3(sessionFile);
19541
19673
  return stat2.isFile() && !stat2.isSymbolicLink();
19542
19674
  } catch (error) {
19543
19675
  if (errorCodeOf2(error) === "ENOENT") return false;
@@ -19553,7 +19685,7 @@ async function findLatestRunIdForSeatTicket(input) {
19553
19685
  let runDirectories;
19554
19686
  try {
19555
19687
  runDirectories = await listBookRunDirectories(
19556
- input.ticketNumber === void 0 ? bookDir : join15(bookDir, String(input.ticketNumber))
19688
+ input.ticketNumber === void 0 ? bookDir : join16(bookDir, String(input.ticketNumber))
19557
19689
  );
19558
19690
  } catch (error) {
19559
19691
  if (errorCodeOf2(error) === "ENOENT") return void 0;
@@ -19562,12 +19694,12 @@ async function findLatestRunIdForSeatTicket(input) {
19562
19694
  const suffix = `@${input.role}`;
19563
19695
  let best;
19564
19696
  for (const runDirectory of runDirectories) {
19565
- const entry = basename6(runDirectory);
19697
+ const entry = basename5(runDirectory);
19566
19698
  if (!entry.endsWith(suffix)) continue;
19567
19699
  const runId = entry.slice(0, entry.length - suffix.length);
19568
19700
  if (runId.length === 0) continue;
19569
19701
  const parentPath = await readRunParentPath(runDirectory);
19570
- if (parentPath !== input.parentRunPath && basename6(parentPath ?? "") !== basename6(input.parentRunPath)) continue;
19702
+ if (parentPath !== input.parentRunPath && basename5(parentPath ?? "") !== basename5(input.parentRunPath)) continue;
19571
19703
  if (!await runHasFormedSessionPrincipal(runDirectory)) continue;
19572
19704
  if (best === void 0 || runId > best) best = runId;
19573
19705
  }
@@ -19803,7 +19935,7 @@ async function loadResumableRunRecord(home, runId, authority, allowUnformedAdmit
19803
19935
  let model;
19804
19936
  try {
19805
19937
  const invocationRaw = JSON.parse(
19806
- await readFile12(join15(run.runDirectory, "invocation.json"), "utf8")
19938
+ await readFile12(join16(run.runDirectory, "invocation.json"), "utf8")
19807
19939
  );
19808
19940
  if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
19809
19941
  const rec = invocationRaw;
@@ -19842,7 +19974,7 @@ async function loadResumableRunRecord(home, runId, authority, allowUnformedAdmit
19842
19974
  } else if (mergedSet.tickets !== void 0) {
19843
19975
  courtTicketNumbers = mergedSet.tickets;
19844
19976
  }
19845
- const sourceRunLeaf = basename6(sourceRunPath ?? "").split("@");
19977
+ const sourceRunLeaf = basename5(sourceRunPath ?? "").split("@");
19846
19978
  const referencedRunId = sourceRun?.runId ?? sourceRunLeaf[0];
19847
19979
  const referencedRole = sourceRun?.role ?? sourceRunLeaf[1];
19848
19980
  if (referencedRunId !== void 0 && referencedRunId !== "") {
@@ -20187,8 +20319,8 @@ var init_run_lifecycle = __esm({
20187
20319
  });
20188
20320
 
20189
20321
  // src/notary-source-run.ts
20190
- import { dirname as dirname10, isAbsolute as isAbsolute6, join as join16, resolve as resolve7, basename as basename7 } from "node:path";
20191
- import { lstat as lstat3, realpath as realpath3 } from "node:fs/promises";
20322
+ import { dirname as dirname10, isAbsolute as isAbsolute6, join as join17, resolve as resolve7, basename as basename6 } from "node:path";
20323
+ import { lstat as lstat4, realpath as realpath3 } from "node:fs/promises";
20192
20324
  async function readRetainedIdentity(runDirectory) {
20193
20325
  try {
20194
20326
  return await readRoleRunIdentity(runDirectory);
@@ -20216,7 +20348,7 @@ async function requireRunDirectory(candidate, display) {
20216
20348
  }
20217
20349
  let stat2;
20218
20350
  try {
20219
- stat2 = await lstat3(real);
20351
+ stat2 = await lstat4(real);
20220
20352
  } catch (error) {
20221
20353
  throw new NotarySourceRunError(
20222
20354
  `notary --source-run is not a readable run directory: ${display}`,
@@ -20228,10 +20360,10 @@ async function requireRunDirectory(candidate, display) {
20228
20360
  `notary --source-run must be a run directory: ${display}`
20229
20361
  );
20230
20362
  }
20231
- const identity = parseRunDirectoryName(basename7(real));
20363
+ const identity = parseRunDirectoryName(basename6(real));
20232
20364
  if (identity === void 0) {
20233
20365
  throw new NotarySourceRunError(
20234
- `notary --source-run must be named <runId>@<role>: ${basename7(real)}`
20366
+ `notary --source-run must be named <runId>@<role>: ${basename6(real)}`
20235
20367
  );
20236
20368
  }
20237
20369
  return real;
@@ -20244,16 +20376,16 @@ async function resolveNotarySourceRunLocator(options) {
20244
20376
  const ledgerHome = resolveActivationLedgerHome(options.home);
20245
20377
  const bookKey = resolveBookKeyFromGit(options.projectRoot);
20246
20378
  const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
20247
- const bookRunsRoot = join16(bookDirectory, "runs");
20379
+ const bookRunsRoot = join17(bookDirectory, "runs");
20248
20380
  let candidate;
20249
20381
  const bare = parseRunDirectoryName(raw);
20250
20382
  if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
20251
- candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join16(bookRunsRoot, `${bare.runId}@${bare.role}`);
20383
+ candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join17(bookRunsRoot, `${bare.runId}@${bare.role}`);
20252
20384
  } else {
20253
20385
  candidate = isAbsolute6(raw) ? raw : resolve7(options.projectRoot, raw);
20254
- const identity2 = parseRunDirectoryName(basename7(candidate));
20386
+ const identity2 = parseRunDirectoryName(basename6(candidate));
20255
20387
  const subjectDirectory = dirname10(dirname10(candidate));
20256
- const isLegacyUnboundLocator = identity2 !== void 0 && basename7(dirname10(candidate)) === "runs" && basename7(subjectDirectory) === "unbound" && resolve7(dirname10(subjectDirectory)) === resolve7(bookDirectory);
20388
+ const isLegacyUnboundLocator = identity2 !== void 0 && basename6(dirname10(candidate)) === "runs" && basename6(subjectDirectory) === "unbound" && resolve7(dirname10(subjectDirectory)) === resolve7(bookDirectory);
20257
20389
  if (isLegacyUnboundLocator) {
20258
20390
  candidate = await findRunDirectoryById(
20259
20391
  options.home,
@@ -20264,11 +20396,11 @@ async function resolveNotarySourceRunLocator(options) {
20264
20396
  }
20265
20397
  }
20266
20398
  const real = await requireRunDirectory(candidate, raw);
20267
- const identity = parseRunDirectoryName(basename7(real));
20399
+ const identity = parseRunDirectoryName(basename6(real));
20268
20400
  const bookIdentity = physicalPathIdentity(bookDirectory);
20269
20401
  const parentIdentity = physicalPathIdentity(dirname10(real));
20270
20402
  const subjectBookIdentity = physicalPathIdentity(dirname10(dirname10(dirname10(real))));
20271
- if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename7(dirname10(real)) === "runs" && subjectBookIdentity === bookIdentity)) {
20403
+ if (parentIdentity !== physicalPathIdentity(bookRunsRoot) && !(basename6(dirname10(real)) === "runs" && subjectBookIdentity === bookIdentity)) {
20272
20404
  throw new NotarySourceRunError(
20273
20405
  "notary --source-run must resolve to a retained run under the project machine-ledger book"
20274
20406
  );
@@ -21370,7 +21502,7 @@ var init_option_definitions = __esm({
21370
21502
  import { execFileSync as execFileSync3 } from "node:child_process";
21371
21503
  import { existsSync as existsSync5 } from "node:fs";
21372
21504
  import {
21373
- lstat as lstat4,
21505
+ lstat as lstat5,
21374
21506
  mkdtemp,
21375
21507
  readFile as readFile13,
21376
21508
  realpath as realpath4,
@@ -21379,7 +21511,7 @@ import {
21379
21511
  writeFile as writeFile4
21380
21512
  } from "node:fs/promises";
21381
21513
  import { tmpdir } from "node:os";
21382
- import { basename as basename8, dirname as dirname11, isAbsolute as isAbsolute7, join as join17, resolve as resolve8, sep as sep4 } from "node:path";
21514
+ import { basename as basename7, dirname as dirname11, isAbsolute as isAbsolute7, join as join18, resolve as resolve8, sep as sep4 } from "node:path";
21383
21515
  function issueAdmissionPlacement(authority, request) {
21384
21516
  const ledgerHome = resolveActivationLedgerHome(request.home);
21385
21517
  const bookKey = resolveBookKeyFromGit(request.cwd);
@@ -21433,14 +21565,14 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
21433
21565
  ...effectiveModelLedgerFields(effectiveModel)
21434
21566
  };
21435
21567
  await writeFile4(
21436
- join17(source.runDirectory, "invocation.json"),
21568
+ join18(source.runDirectory, "invocation.json"),
21437
21569
  `${JSON.stringify(identity, null, 2)}
21438
21570
  `,
21439
21571
  "utf8"
21440
21572
  );
21441
21573
  }
21442
21574
  async function recordEffectiveInvocationModel(runDirectory, model, engine, host, engineModel) {
21443
- const ledgerPath = join17(runDirectory, "invocation.json");
21575
+ const ledgerPath = join18(runDirectory, "invocation.json");
21444
21576
  const current = JSON.parse(await readFile13(ledgerPath, "utf8"));
21445
21577
  const next = { ...current };
21446
21578
  if (model !== void 0) {
@@ -21473,7 +21605,7 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host,
21473
21605
  );
21474
21606
  }
21475
21607
  async function mergeInvocationIdentityPage(runDirectory, fields) {
21476
- const ledgerPath = join17(runDirectory, "invocation.json");
21608
+ const ledgerPath = join18(runDirectory, "invocation.json");
21477
21609
  const current = JSON.parse(await readFile13(ledgerPath, "utf8"));
21478
21610
  await writeFile4(
21479
21611
  ledgerPath,
@@ -21588,7 +21720,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
21588
21720
  const childRunIds = parentPage.childDiaristRunIds;
21589
21721
  for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
21590
21722
  if (typeof childRunId !== "string") continue;
21591
- const childDirectory = join17(dirname11(oldRunDirectory), `${childRunId}@diarist`);
21723
+ const childDirectory = join18(dirname11(oldRunDirectory), `${childRunId}@diarist`);
21592
21724
  if (!existsSync5(childDirectory)) continue;
21593
21725
  const childTarget = roleRunPlacement(ledgerHome, {
21594
21726
  bookKey: admitted.bookKey,
@@ -21645,7 +21777,7 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
21645
21777
  ticketNumber,
21646
21778
  "bindTicketNumberOnRunDirectory"
21647
21779
  );
21648
- const admittedPath = join17(runDirectory, "admitted-request.json");
21780
+ const admittedPath = join18(runDirectory, "admitted-request.json");
21649
21781
  const admitted = JSON.parse(await readFile13(admittedPath, "utf8"));
21650
21782
  if (admitted.ticketNumber === ticketNumber) return;
21651
21783
  await writeFile4(
@@ -21665,7 +21797,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
21665
21797
  async function observeLaunchedRolePackageIdentity(packageRoot2, selectedRoleEntry) {
21666
21798
  const rolePackageRoot = packageRoot2;
21667
21799
  const raw = JSON.parse(
21668
- await readFile13(join17(rolePackageRoot, "package.json"), "utf8")
21800
+ await readFile13(join18(rolePackageRoot, "package.json"), "utf8")
21669
21801
  );
21670
21802
  if (typeof raw.version !== "string" || raw.version.trim() === "") {
21671
21803
  throw new Error(
@@ -21939,7 +22071,7 @@ async function readRegularFileAttachment(sourcePath) {
21939
22071
  const absolute = isAbsolute7(sourcePath) ? sourcePath : resolve8(sourcePath);
21940
22072
  let st;
21941
22073
  try {
21942
- st = await lstat4(absolute);
22074
+ st = await lstat5(absolute);
21943
22075
  } catch (error) {
21944
22076
  throw new CliUsageError(
21945
22077
  `attachment is not a readable regular file: ${sourcePath}`,
@@ -21965,13 +22097,13 @@ async function removePreparedAttachmentDirectory(stagingDirectory) {
21965
22097
  }
21966
22098
  async function withPreparedAttachments(attachmentPaths, use) {
21967
22099
  if (attachmentPaths.length === 0) return await use([]);
21968
- const stagingDirectory = await mkdtemp(join17(tmpdir(), "ak-role-attachments-"));
22100
+ const stagingDirectory = await mkdtemp(join18(tmpdir(), "ak-role-attachments-"));
21969
22101
  const prepared = [];
21970
22102
  let result;
21971
22103
  try {
21972
22104
  for (let index = 0; index < attachmentPaths.length; index += 1) {
21973
22105
  const { absolute, bytes } = await readRegularFileAttachment(attachmentPaths[index]);
21974
- const snapshotPath = join17(stagingDirectory, String(index).padStart(6, "0"));
22106
+ const snapshotPath = join18(stagingDirectory, String(index).padStart(6, "0"));
21975
22107
  await writeFile4(snapshotPath, bytes);
21976
22108
  prepared.push({ absolute, snapshotPath });
21977
22109
  }
@@ -21992,9 +22124,9 @@ async function withPreparedAttachments(attachmentPaths, use) {
21992
22124
  return result;
21993
22125
  }
21994
22126
  async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, index) {
21995
- const frozenPath = join17(
22127
+ const frozenPath = join18(
21996
22128
  destinationDir,
21997
- `${String(index).padStart(2, "0")}-${basename8(provenancePath)}`
22129
+ `${String(index).padStart(2, "0")}-${basename7(provenancePath)}`
21998
22130
  );
21999
22131
  await writeFile4(frozenPath, bytes);
22000
22132
  return {
@@ -22035,14 +22167,14 @@ async function freezeAttachments(attachmentPaths, attachmentsDirectory) {
22035
22167
  async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKey = `s-${Date.now().toString(36)}`) {
22036
22168
  if (attachmentPaths.length === 0) return [];
22037
22169
  const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
22038
- const attachmentsDirectory = join17(runDirectory, "attachments", summonsKey);
22170
+ const attachmentsDirectory = join18(runDirectory, "attachments", summonsKey);
22039
22171
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
22040
22172
  return freezeAttachments(attachmentPaths, attachmentsDirectory);
22041
22173
  }
22042
22174
  async function freezePreparedAttachmentsIntoRun(prepared, runDirectory, summonsKey) {
22043
22175
  if (prepared.length === 0) return [];
22044
22176
  const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
22045
- const attachmentsDirectory = summonsKey === void 0 ? join17(runDirectory, "attachments") : join17(runDirectory, "attachments", summonsKey);
22177
+ const attachmentsDirectory = summonsKey === void 0 ? join18(runDirectory, "attachments") : join18(runDirectory, "attachments", summonsKey);
22046
22178
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
22047
22179
  const attachments = [];
22048
22180
  for (let index = 0; index < prepared.length; index += 1) {
@@ -22119,7 +22251,7 @@ async function admitPublicRole(role, parsed, env, override) {
22119
22251
  attachmentPaths,
22120
22252
  ...project,
22121
22253
  placedFields: async (placed) => {
22122
- const taskPath = join17(placed.runDirectory, "task.md");
22254
+ const taskPath = join18(placed.runDirectory, "task.md");
22123
22255
  await writeFile4(taskPath, instruction, "utf8");
22124
22256
  return { phase, taskPath };
22125
22257
  }
@@ -22165,7 +22297,7 @@ async function admitPublicRole(role, parsed, env, override) {
22165
22297
  placedFields: async (placed) => {
22166
22298
  let prerequisitesPath;
22167
22299
  if (prerequisitesSource !== void 0) {
22168
- prerequisitesPath = join17(placed.runDirectory, "prerequisites.json");
22300
+ prerequisitesPath = join18(placed.runDirectory, "prerequisites.json");
22169
22301
  await writeFile4(
22170
22302
  prerequisitesPath,
22171
22303
  `${JSON.stringify(prerequisites, null, 2)}
@@ -22173,7 +22305,7 @@ async function admitPublicRole(role, parsed, env, override) {
22173
22305
  "utf8"
22174
22306
  );
22175
22307
  }
22176
- const packetPath = join17(placed.runDirectory, "fix-packet.md");
22308
+ const packetPath = join18(placed.runDirectory, "fix-packet.md");
22177
22309
  await writeFile4(packetPath, instruction, "utf8");
22178
22310
  return {
22179
22311
  phase,
@@ -22237,7 +22369,7 @@ async function admitPublicRole(role, parsed, env, override) {
22237
22369
  const prNumber = target.kind === "bound" ? target.prNumber : void 0;
22238
22370
  let requestManifestPath;
22239
22371
  if (manifestCanonicalJson !== void 0) {
22240
- requestManifestPath = join17(placed.runDirectory, "request-manifest.json");
22372
+ requestManifestPath = join18(placed.runDirectory, "request-manifest.json");
22241
22373
  await writeFile4(requestManifestPath, manifestCanonicalJson, "utf8");
22242
22374
  }
22243
22375
  return {
@@ -22428,7 +22560,7 @@ async function admitPublicRole(role, parsed, env, override) {
22428
22560
  resolutionScope: [...derived.resolutionScope],
22429
22561
  authorizedChecks: []
22430
22562
  });
22431
- const mergerInputPath = join17(placed.runDirectory, "merger-input.json");
22563
+ const mergerInputPath = join18(placed.runDirectory, "merger-input.json");
22432
22564
  await writeFile4(
22433
22565
  mergerInputPath,
22434
22566
  `${JSON.stringify(mergerInput, null, 2)}
@@ -22502,7 +22634,7 @@ function persistedAttachmentRefs(attachments) {
22502
22634
  }));
22503
22635
  }
22504
22636
  async function persistPlacedAdmission(admitted, placed, model) {
22505
- const admittedRequestPath = join17(placed.runDirectory, "admitted-request.json");
22637
+ const admittedRequestPath = join18(placed.runDirectory, "admitted-request.json");
22506
22638
  await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
22507
22639
  sessionDirectory: placed.sessionDirectory,
22508
22640
  sessionFile: placed.sessionFile
@@ -22555,7 +22687,7 @@ async function admitStandardMaterialInvocation(role, options) {
22555
22687
  attachments: persistedAttachmentRefs(placed.attachments),
22556
22688
  ...placed.ticketFields
22557
22689
  };
22558
- const admittedRequestPath = defer ? join17(placed.runDirectory, "admitted-request.json") : await persistPlacedAdmission(admitted, placed, options.model);
22690
+ const admittedRequestPath = defer ? join18(placed.runDirectory, "admitted-request.json") : await persistPlacedAdmission(admitted, placed, options.model);
22559
22691
  return {
22560
22692
  role,
22561
22693
  runId: placed.runId,
@@ -22630,7 +22762,7 @@ async function materializeCountersignInvocation(admitted, options) {
22630
22762
  });
22631
22763
  const placement = placed;
22632
22764
  admitted.runDirectory = placement.runDirectory;
22633
- admitted.admittedRequestPath = join17(
22765
+ admitted.admittedRequestPath = join18(
22634
22766
  placement.runDirectory,
22635
22767
  "admitted-request.json"
22636
22768
  );
@@ -22726,7 +22858,7 @@ function parseDoctorIssueNumber(raw) {
22726
22858
  }
22727
22859
  async function resolveDoctorCaseRunsPath(options) {
22728
22860
  const ledgerHome = resolveActivationLedgerHome(options.home);
22729
- const defaultRuns = join17(
22861
+ const defaultRuns = join18(
22730
22862
  activationBookDirectory(ledgerHome, options.bookKey),
22731
22863
  String(options.issueNumber),
22732
22864
  "runs"
@@ -23049,15 +23181,15 @@ var init_invocation = __esm({
23049
23181
 
23050
23182
  // src/public-cli/load-production-acp-host.ts
23051
23183
  import { existsSync as existsSync6 } from "node:fs";
23052
- import { join as join18 } from "node:path";
23184
+ import { join as join19 } from "node:path";
23053
23185
  import { pathToFileURL } from "node:url";
23054
23186
  async function loadProductionAcpHostFactory(packageRoot2, host) {
23055
23187
  const description = lookupHostDescription(host);
23056
23188
  if (description === void 0) {
23057
23189
  throw new Error(`unregistered host: ${host}`);
23058
23190
  }
23059
- const built = join18(packageRoot2, "dist/acp-host/production-host.js");
23060
- const source = join18(packageRoot2, "src/acp-host/production-host.ts");
23191
+ const built = join19(packageRoot2, "dist/acp-host/production-host.js");
23192
+ const source = join19(packageRoot2, "src/acp-host/production-host.ts");
23061
23193
  const target = existsSync6(built) ? built : source;
23062
23194
  const href = pathToFileURL(target).href;
23063
23195
  const mod = await import(href);
@@ -23073,15 +23205,15 @@ var init_load_production_acp_host = __esm({
23073
23205
 
23074
23206
  // src/public-cli/load-production-headless-host.ts
23075
23207
  import { existsSync as existsSync7 } from "node:fs";
23076
- import { join as join19 } from "node:path";
23208
+ import { join as join20 } from "node:path";
23077
23209
  import { pathToFileURL as pathToFileURL2 } from "node:url";
23078
23210
  async function loadProductionHeadlessHostFactory(packageRoot2, host) {
23079
23211
  const description = lookupHeadlessHostDescription(host);
23080
23212
  if (description === void 0) {
23081
23213
  throw new Error(`unregistered headless host: ${host}`);
23082
23214
  }
23083
- const built = join19(packageRoot2, "dist/headless-host/production-host.js");
23084
- const source = join19(packageRoot2, "src/headless-host/production-host.ts");
23215
+ const built = join20(packageRoot2, "dist/headless-host/production-host.js");
23216
+ const source = join20(packageRoot2, "src/headless-host/production-host.ts");
23085
23217
  const target = existsSync7(built) ? built : source;
23086
23218
  const href = pathToFileURL2(target).href;
23087
23219
  const mod = await import(href);
@@ -23206,246 +23338,9 @@ var init_role_turn_host_resolution = __esm({
23206
23338
  }
23207
23339
  });
23208
23340
 
23209
- // src/package-resources/method-skill.ts
23210
- import { createHash as createHash4 } from "node:crypto";
23211
- import { readFile as readFile14, realpath as realpath5 } from "node:fs/promises";
23212
- import { join as join20 } from "node:path";
23213
- function gitBlobOid(bytes) {
23214
- const body = typeof bytes === "string" ? Buffer.from(bytes, "utf8") : Buffer.from(bytes);
23215
- const header = Buffer.from(`blob ${body.byteLength}\0`, "utf8");
23216
- return createHash4("sha1").update(header).update(body).digest("hex");
23217
- }
23218
- function stripSkillFrontmatter(content) {
23219
- if (!content.startsWith("---")) return content;
23220
- const end = content.indexOf("\n---", 3);
23221
- if (end === -1) return content;
23222
- const after = content.slice(end + "\n---".length);
23223
- return after.replace(/^\r?\n/, "");
23224
- }
23225
- function packagedMethodSkillRelativeDirectory(name) {
23226
- return `${METHOD_SKILL_RELATIVE_ROOT}/${name}`;
23227
- }
23228
- function resolvePackagedMethodSkillRoot(packageRoot2, name) {
23229
- return join20(packageRoot2, packagedMethodSkillRelativeDirectory(name));
23230
- }
23231
- function resolvePackagedMethodSkillPath(packageRoot2, name) {
23232
- return join20(resolvePackagedMethodSkillRoot(packageRoot2, name), "SKILL.md");
23233
- }
23234
- function isRecord6(value) {
23235
- return typeof value === "object" && value !== null && !Array.isArray(value);
23236
- }
23237
- function parseProvenance(raw, expectedName) {
23238
- if (!isRecord6(raw)) {
23239
- throw new Error(`Packaged method provenance must be an object for ${expectedName}`);
23240
- }
23241
- if (raw.name !== expectedName) {
23242
- throw new Error(
23243
- `Packaged method provenance name mismatch: expected ${expectedName}, got ${String(raw.name)}`
23244
- );
23245
- }
23246
- if (raw.kind !== "role-method-skill") {
23247
- throw new Error(`Packaged method provenance kind must be role-method-skill`);
23248
- }
23249
- if (typeof raw.packageAdaptation !== "string" || raw.packageAdaptation.trim() === "") {
23250
- throw new Error(`Packaged method provenance packageAdaptation must be nonblank`);
23251
- }
23252
- if (!isRecord6(raw.upstream)) {
23253
- throw new Error(`Packaged method provenance upstream must be an object`);
23254
- }
23255
- const upstream = raw.upstream;
23256
- for (const key of [
23257
- "repository",
23258
- "path",
23259
- "license",
23260
- "copyright",
23261
- "attribution"
23262
- ]) {
23263
- if (typeof upstream[key] !== "string" || upstream[key].trim() === "") {
23264
- throw new Error(`Packaged method provenance upstream.${key} must be nonblank`);
23265
- }
23266
- }
23267
- if (typeof upstream.commit !== "string" || !GIT_COMMIT_RE.test(upstream.commit)) {
23268
- throw new Error(
23269
- `Packaged method provenance upstream.commit must be a 40-char lowercase git object id`
23270
- );
23271
- }
23272
- const tag = typeof upstream.tag === "string" && upstream.tag.trim() !== "" ? upstream.tag.trim() : void 0;
23273
- const version = typeof upstream.version === "string" && upstream.version.trim() !== "" ? upstream.version.trim() : void 0;
23274
- if (tag === void 0 && version === void 0) {
23275
- throw new Error(
23276
- `Packaged method provenance upstream must include nonblank tag or version`
23277
- );
23278
- }
23279
- if (!isRecord6(raw.files)) {
23280
- throw new Error(`Packaged method provenance files must be an object`);
23281
- }
23282
- const files = {};
23283
- for (const [rel, entry] of Object.entries(raw.files)) {
23284
- if (!isRecord6(entry)) {
23285
- throw new Error(`Packaged method provenance file entry must be an object: ${rel}`);
23286
- }
23287
- if (typeof entry.sha256 !== "string" || !SHA256_RE.test(entry.sha256)) {
23288
- throw new Error(`Packaged method provenance file sha256 invalid: ${rel}`);
23289
- }
23290
- if (typeof entry.byteLength !== "number" || !Number.isInteger(entry.byteLength) || entry.byteLength < 0) {
23291
- throw new Error(`Packaged method provenance file byteLength invalid: ${rel}`);
23292
- }
23293
- if (typeof entry.gitBlob !== "string" || !GIT_BLOB_RE.test(entry.gitBlob)) {
23294
- throw new Error(
23295
- `Packaged method provenance file gitBlob must be a 40-char lowercase git object id: ${rel}`
23296
- );
23297
- }
23298
- files[rel] = {
23299
- sha256: entry.sha256,
23300
- byteLength: entry.byteLength,
23301
- gitBlob: entry.gitBlob
23302
- };
23303
- }
23304
- if (files["SKILL.md"] === void 0) {
23305
- throw new Error(`Packaged method provenance must include SKILL.md`);
23306
- }
23307
- return Object.freeze({
23308
- name: expectedName,
23309
- kind: "role-method-skill",
23310
- packageAdaptation: raw.packageAdaptation,
23311
- upstream: Object.freeze({
23312
- repository: upstream.repository,
23313
- path: upstream.path,
23314
- commit: upstream.commit,
23315
- ...tag === void 0 ? {} : { tag },
23316
- ...version === void 0 ? {} : { version },
23317
- license: upstream.license,
23318
- copyright: upstream.copyright,
23319
- attribution: upstream.attribution
23320
- }),
23321
- files: Object.freeze(files)
23322
- });
23323
- }
23324
- async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
23325
- const rootDirectory = resolvePackagedMethodSkillRoot(packageRoot2, name);
23326
- const skillPathConfigured = join20(rootDirectory, "SKILL.md");
23327
- const provenancePath = join20(rootDirectory, "provenance.json");
23328
- let provenanceRaw;
23329
- try {
23330
- provenanceRaw = await readFile14(provenancePath, "utf8");
23331
- } catch (error) {
23332
- throw new PackagedMethodSkillUnavailableError(name, provenancePath, error);
23333
- }
23334
- let provenanceJson;
23335
- try {
23336
- provenanceJson = JSON.parse(provenanceRaw);
23337
- } catch (error) {
23338
- throw new Error(`Packaged method provenance is not valid JSON at ${provenancePath}`, {
23339
- cause: error
23340
- });
23341
- }
23342
- const provenance = parseProvenance(provenanceJson, name);
23343
- for (const [rel, expected] of Object.entries(provenance.files)) {
23344
- const absolute = join20(rootDirectory, rel);
23345
- let bytes;
23346
- try {
23347
- bytes = await readFile14(absolute);
23348
- } catch (error) {
23349
- throw new PackagedMethodSkillUnavailableError(name, absolute, error);
23350
- }
23351
- const actualSha = sha256Hex(bytes);
23352
- const actualBlob = gitBlobOid(bytes);
23353
- if (actualSha !== expected.sha256 || bytes.byteLength !== expected.byteLength || actualBlob !== expected.gitBlob) {
23354
- throw new Error(
23355
- `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}`
23356
- );
23357
- }
23358
- }
23359
- let skillPath;
23360
- let raw;
23361
- try {
23362
- skillPath = await realpath5(skillPathConfigured);
23363
- raw = await readFile14(skillPath, "utf8");
23364
- } catch (error) {
23365
- throw new PackagedMethodSkillUnavailableError(name, skillPathConfigured, error);
23366
- }
23367
- const body = stripSkillFrontmatter(raw).trim();
23368
- if (body.length === 0) {
23369
- throw new Error(`Canonical ${name} Skill is empty at ${skillPath}`);
23370
- }
23371
- const companionRelativePaths = REQUIRED_COMPANIONS[name].filter(
23372
- (rel) => provenance.files[rel] !== void 0
23373
- );
23374
- for (const rel of REQUIRED_COMPANIONS[name]) {
23375
- if (provenance.files[rel] === void 0) {
23376
- throw new Error(
23377
- `Packaged method ${name} missing required companion in provenance: ${rel}`
23378
- );
23379
- }
23380
- }
23381
- return Object.freeze({
23382
- name,
23383
- rootDirectory,
23384
- skillPath,
23385
- raw,
23386
- body,
23387
- provenance,
23388
- companionRelativePaths: Object.freeze([...companionRelativePaths])
23389
- });
23390
- }
23391
- function observePackagedMethodSkillInvocation(text, expected) {
23392
- if (!text.startsWith('<skill name="')) return void 0;
23393
- const nameStart = '<skill name="'.length;
23394
- const nameEnd = text.indexOf('"', nameStart);
23395
- if (nameEnd <= nameStart) return void 0;
23396
- const name = text.slice(nameStart, nameEnd);
23397
- if (name !== expected.name) return void 0;
23398
- const locationMarker = '" location="';
23399
- if (!text.startsWith(locationMarker, nameEnd)) return void 0;
23400
- const locationStart = nameEnd + locationMarker.length;
23401
- const locationEnd = text.indexOf('"', locationStart);
23402
- if (locationEnd <= locationStart) return void 0;
23403
- const location = text.slice(locationStart, locationEnd);
23404
- const openTail = ">\n";
23405
- if (!text.startsWith(openTail, locationEnd + 1)) return void 0;
23406
- const closeTag = "\n</skill>";
23407
- const closeAt = text.indexOf(closeTag, locationEnd + 1 + openTail.length);
23408
- if (closeAt === -1) return void 0;
23409
- const afterClose = text.slice(closeAt + closeTag.length);
23410
- if (afterClose.length > 0 && !afterClose.startsWith("\n")) return void 0;
23411
- if (!expected.allowedLocations.includes(location)) return void 0;
23412
- return Object.freeze({ name: expected.name, location });
23413
- }
23414
- var PackagedMethodSkillUnavailableError, METHOD_SKILL_RELATIVE_ROOT, GIT_COMMIT_RE, GIT_BLOB_RE, SHA256_RE, REQUIRED_COMPANIONS;
23415
- var init_method_skill = __esm({
23416
- "src/package-resources/method-skill.ts"() {
23417
- "use strict";
23418
- init_sha256();
23419
- PackagedMethodSkillUnavailableError = class extends Error {
23420
- constructor(skillName, path, cause) {
23421
- super(`Canonical ${skillName} Skill is unavailable at ${path}`, { cause });
23422
- this.skillName = skillName;
23423
- this.name = "CanonicalSkillUnavailableError";
23424
- }
23425
- skillName;
23426
- code = "canonical-skill-unavailable";
23427
- };
23428
- METHOD_SKILL_RELATIVE_ROOT = "resources/methods";
23429
- GIT_COMMIT_RE = /^[0-9a-f]{40}$/;
23430
- GIT_BLOB_RE = /^[0-9a-f]{40}$/;
23431
- SHA256_RE = /^[0-9a-f]{64}$/;
23432
- REQUIRED_COMPANIONS = {
23433
- tdd: ["tests.md", "mocking.md", "agents/openai.yaml"],
23434
- "diagnosing-bugs": ["agents/openai.yaml", "scripts/hitl-loop.template.sh"],
23435
- "ak-cross-m-review": [
23436
- "CONTEXT.md",
23437
- "LICENSE",
23438
- "prompts/cmr-completeness.md",
23439
- "prompts/cmr-reviewer.md"
23440
- ],
23441
- "resolving-merge-conflicts": ["agents/openai.yaml"]
23442
- };
23443
- }
23444
- });
23445
-
23446
23341
  // src/session-opening-materials.ts
23447
23342
  import { existsSync as existsSync8 } from "node:fs";
23448
- import { readFile as readFile15 } from "node:fs/promises";
23343
+ import { readFile as readFile14 } from "node:fs/promises";
23449
23344
  import { dirname as dirname12, join as join21 } from "node:path";
23450
23345
  import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
23451
23346
  function resolvePackageRootDir(moduleUrl = import.meta.url) {
@@ -23461,7 +23356,7 @@ function resolvePackageRootDir(moduleUrl = import.meta.url) {
23461
23356
  return fileURLToPath(new URL("..", moduleUrl));
23462
23357
  }
23463
23358
  async function readPackageMaterial(relativePath) {
23464
- return readFile15(fileURLToPath(new URL(relativePath, packageRootUrl)), "utf8");
23359
+ return readFile14(fileURLToPath(new URL(relativePath, packageRootUrl)), "utf8");
23465
23360
  }
23466
23361
  async function joinPackageMaterials(relativePaths) {
23467
23362
  const chunks = [];
@@ -23763,7 +23658,7 @@ var init_submission_ledger = __esm({
23763
23658
  });
23764
23659
 
23765
23660
  // src/session-identity.ts
23766
- import { mkdir as mkdir2, readFile as readFile16, rename as rename2, writeFile as writeFile5 } from "node:fs/promises";
23661
+ import { mkdir as mkdir3, readFile as readFile15, rename as rename2, writeFile as writeFile5 } from "node:fs/promises";
23767
23662
  import { dirname as dirname13, join as join23 } from "node:path";
23768
23663
  function createSessionIdentityAuthority(authority, sessionBindingFile) {
23769
23664
  const bindingPath = (principal) => join23(authority.decode(principal).sessionDirectory, sessionBindingFile);
@@ -23773,7 +23668,7 @@ function createSessionIdentityAuthority(authority, sessionBindingFile) {
23773
23668
  },
23774
23669
  async load(principal) {
23775
23670
  try {
23776
- const value = JSON.parse(await readFile16(bindingPath(principal), "utf8"));
23671
+ const value = JSON.parse(await readFile15(bindingPath(principal), "utf8"));
23777
23672
  if (typeof value !== "object" || value === null || typeof value.sessionId !== "string") {
23778
23673
  throw new Error("durable session binding is invalid");
23779
23674
  }
@@ -23785,7 +23680,7 @@ function createSessionIdentityAuthority(authority, sessionBindingFile) {
23785
23680
  },
23786
23681
  async bind(principal, sessionId) {
23787
23682
  const target = bindingPath(principal);
23788
- await mkdir2(dirname13(target), { recursive: true });
23683
+ await mkdir3(dirname13(target), { recursive: true });
23789
23684
  const temporary = `${target}.${process.pid}.tmp`;
23790
23685
  await writeFile5(temporary, `${JSON.stringify({ sessionId })}
23791
23686
  `, { encoding: "utf8", mode: 384 });
@@ -23818,7 +23713,7 @@ var init_session_identity = __esm({
23818
23713
  });
23819
23714
 
23820
23715
  // src/public-cli/case-dossier-delivery.ts
23821
- import { mkdtemp as mkdtemp2, readFile as readFile17, rm as rm2, writeFile as writeFile6 } from "node:fs/promises";
23716
+ import { mkdtemp as mkdtemp2, readFile as readFile16, rm as rm2, writeFile as writeFile6 } from "node:fs/promises";
23822
23717
  import { tmpdir as tmpdir2 } from "node:os";
23823
23718
  import { join as join24 } from "node:path";
23824
23719
  async function projectCaseDossierPointerSection(input) {
@@ -23879,11 +23774,11 @@ var init_case_dossier_delivery = __esm({
23879
23774
  import { randomUUID as randomUUID3 } from "node:crypto";
23880
23775
  import { readFileSync as readFileSync3 } from "node:fs";
23881
23776
  import { dirname as dirname14, join as join25 } from "node:path";
23882
- function isRecord7(value) {
23777
+ function isRecord6(value) {
23883
23778
  return typeof value === "object" && value !== null && !Array.isArray(value);
23884
23779
  }
23885
23780
  function callFactFromSitianPayload(payload, pointer) {
23886
- if (!isRecord7(payload)) return void 0;
23781
+ if (!isRecord6(payload)) return void 0;
23887
23782
  if (payload.tool !== ENGINE_DETOUR_TOOL_NAME) return void 0;
23888
23783
  if (typeof payload.toolCallId !== "string" || payload.toolCallId.length === 0) {
23889
23784
  return void 0;
@@ -23900,11 +23795,11 @@ function callFactFromSitianPayload(payload, pointer) {
23900
23795
  };
23901
23796
  }
23902
23797
  function invocationScopeIdOfRecord(record4) {
23903
- if (isRecord7(record4.subject)) {
23798
+ if (isRecord6(record4.subject)) {
23904
23799
  const fromSubject = record4.subject.invocationScopeId;
23905
23800
  if (typeof fromSubject === "string" && fromSubject.length > 0) return fromSubject;
23906
23801
  }
23907
- if (isRecord7(record4.payload)) {
23802
+ if (isRecord6(record4.payload)) {
23908
23803
  const fromPayload = record4.payload.invocationScopeId;
23909
23804
  if (typeof fromPayload === "string" && fromPayload.length > 0) return fromPayload;
23910
23805
  }
@@ -23964,7 +23859,7 @@ function readInvocationRecord(runDirectory) {
23964
23859
  const raw = JSON.parse(
23965
23860
  readFileSync3(join25(runDirectory, "invocation.json"), "utf8")
23966
23861
  );
23967
- return isRecord7(raw) ? raw : void 0;
23862
+ return isRecord6(raw) ? raw : void 0;
23968
23863
  } catch (error) {
23969
23864
  if (error?.code === "ENOENT") return void 0;
23970
23865
  throw error;
@@ -23982,7 +23877,7 @@ function readInvocationSelectedHost(runDirectory) {
23982
23877
  }
23983
23878
  function withEngineDetourToolUsageFact(outcome, usage) {
23984
23879
  if (usage === void 0) return outcome;
23985
- const prior = isRecord7(outcome.decisiveFacts) ? outcome.decisiveFacts : {};
23880
+ const prior = isRecord6(outcome.decisiveFacts) ? outcome.decisiveFacts : {};
23986
23881
  return {
23987
23882
  ...outcome,
23988
23883
  decisiveFacts: {
@@ -24136,7 +24031,7 @@ var init_process_cancel = __esm({
24136
24031
  // src/analyst-gate-cycles-read.ts
24137
24032
  import { readdir as readdir6 } from "node:fs/promises";
24138
24033
  import { join as join27 } from "node:path";
24139
- function isRecord8(value) {
24034
+ function isRecord7(value) {
24140
24035
  return typeof value === "object" && value !== null && !Array.isArray(value);
24141
24036
  }
24142
24037
  function isParentAttemptBindingRow(row) {
@@ -24166,7 +24061,7 @@ function isGateTerminatingToolName(toolName) {
24166
24061
  function acceptedGateReceiptIds(rows) {
24167
24062
  const accepted = /* @__PURE__ */ new Set();
24168
24063
  for (const row of rows) {
24169
- const message = isRecord8(row.message) ? row.message : void 0;
24064
+ const message = isRecord7(row.message) ? row.message : void 0;
24170
24065
  if (message?.role !== "toolResult") continue;
24171
24066
  if (typeof message.toolCallId !== "string" || message.toolCallId.length === 0) continue;
24172
24067
  if (message.isError === false) accepted.add(message.toolCallId);
@@ -24201,7 +24096,7 @@ function nearestAttemptBindingBefore(rows, beforeIndex) {
24201
24096
  for (let i = beforeIndex - 1; i >= 0; i -= 1) {
24202
24097
  const row = rows[i];
24203
24098
  if (!isParentAttemptBindingRow(row)) continue;
24204
- if (!isRecord8(row.data) || !isRecord8(row.data.parent)) continue;
24099
+ if (!isRecord7(row.data) || !isRecord7(row.data.parent)) continue;
24205
24100
  const id = row.data.parent.attemptEntryId;
24206
24101
  const sessionFile = row.data.parent.sessionFile;
24207
24102
  return {
@@ -24216,10 +24111,10 @@ function extractAllAcceptedGateToolCalls(rows) {
24216
24111
  const out = [];
24217
24112
  for (let rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
24218
24113
  const row = rows[rowIndex];
24219
- const message = isRecord8(row.message) ? row.message : void 0;
24114
+ const message = isRecord7(row.message) ? row.message : void 0;
24220
24115
  if (message?.role !== "assistant" || !Array.isArray(message.content)) continue;
24221
24116
  for (const part of message.content) {
24222
- if (!isRecord8(part) || part.type !== "toolCall") continue;
24117
+ if (!isRecord7(part) || part.type !== "toolCall") continue;
24223
24118
  if (typeof part.id !== "string" || part.id.length === 0) continue;
24224
24119
  if (typeof part.name !== "string" || part.name.length === 0) continue;
24225
24120
  if (!isGateTerminatingToolName(part.name)) continue;
@@ -24227,7 +24122,7 @@ function extractAllAcceptedGateToolCalls(rows) {
24227
24122
  const binding = nearestAttemptBindingBefore(rows, rowIndex);
24228
24123
  out.push({
24229
24124
  toolName: part.name,
24230
- args: isRecord8(part.arguments) ? part.arguments : void 0,
24125
+ args: isRecord7(part.arguments) ? part.arguments : void 0,
24231
24126
  accepted: true,
24232
24127
  rowIndex,
24233
24128
  ...binding
@@ -24350,17 +24245,17 @@ function pairGateRounds(volumes) {
24350
24245
  return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
24351
24246
  }
24352
24247
  async function resolveOfficerSessionFromPointerFile(pointerPath) {
24353
- const { readFile: readFile23 } = await import("node:fs/promises");
24248
+ const { readFile: readFile22 } = await import("node:fs/promises");
24354
24249
  let raw;
24355
24250
  try {
24356
- raw = JSON.parse(await readFile23(pointerPath, "utf8"));
24251
+ raw = JSON.parse(await readFile22(pointerPath, "utf8"));
24357
24252
  } catch (error) {
24358
24253
  throw new Error(
24359
24254
  `direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
24360
24255
  { cause: error }
24361
24256
  );
24362
24257
  }
24363
- if (!isRecord8(raw) || raw.kind !== "direct-officer-run-pointer" || raw.version !== 1) {
24258
+ if (!isRecord7(raw) || raw.kind !== "direct-officer-run-pointer" || raw.version !== 1) {
24364
24259
  throw new Error(`direct officer run pointer has unknown shape in ${pointerPath}`);
24365
24260
  }
24366
24261
  const sessionFile = raw.sessionFile;
@@ -24623,11 +24518,11 @@ var init_navigator_invocation_identity = __esm({
24623
24518
  });
24624
24519
 
24625
24520
  // src/receipt-delivery-policy.ts
24626
- function isRecord9(value) {
24521
+ function isRecord8(value) {
24627
24522
  return typeof value === "object" && value !== null && !Array.isArray(value);
24628
24523
  }
24629
24524
  function parseNoReceiptLifecycleFacts(input) {
24630
- if (!isRecord9(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) => isRecord9(item) && typeof item.reason === "string")) {
24525
+ if (!isRecord8(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) => isRecord8(item) && typeof item.reason === "string")) {
24631
24526
  throw new TypeError("malformed no-receipt lifecycle facts");
24632
24527
  }
24633
24528
  return {
@@ -24693,7 +24588,6 @@ __export(settlement_exports, {
24693
24588
  formatTerminalResult: () => formatTerminalResult,
24694
24589
  inspectJudgeSession: () => inspectJudgeSession,
24695
24590
  isLawfulTypedTerminalOutcome: () => isLawfulTypedTerminalOutcome,
24696
- observedMethodSkillOptions: () => observedMethodSkillOptions,
24697
24591
  presentControlledFailure: () => presentControlledFailure,
24698
24592
  presentFailureTerminal: () => presentFailureTerminal,
24699
24593
  presentStructuralRejection: () => presentStructuralRejection,
@@ -24720,7 +24614,7 @@ __export(settlement_exports, {
24720
24614
  withSubmissions: () => withSubmissions
24721
24615
  });
24722
24616
  import { randomUUID as randomUUID4 } from "node:crypto";
24723
- import { appendFile as appendFile2, readFile as readFile18, readdir as readdir7, rm as rm3, writeFile as writeFile7 } from "node:fs/promises";
24617
+ import { appendFile as appendFile2, readFile as readFile17, readdir as readdir7, rm as rm3, writeFile as writeFile7 } from "node:fs/promises";
24724
24618
  import { dirname as dirname16, join as join28 } from "node:path";
24725
24619
  function sealedLedgerHome(admitted) {
24726
24620
  return homeFromRunDirectory(admitted.runDirectory);
@@ -24878,7 +24772,7 @@ function presentControlledFailure(failure, io) {
24878
24772
  }
24879
24773
  async function inspectJudgeSession(sessionFile) {
24880
24774
  try {
24881
- await readFile18(sessionFile, "utf8");
24775
+ await readFile17(sessionFile, "utf8");
24882
24776
  return { state: "present" };
24883
24777
  } catch (error) {
24884
24778
  if (isMissingPathError4(error)) return { state: "missing" };
@@ -25118,7 +25012,7 @@ function sessionReadFailure(error, fallbackMessage) {
25118
25012
  return failed;
25119
25013
  }
25120
25014
  async function readBoundSessionEntries(sessionFile) {
25121
- const text = await readFile18(sessionFile, "utf8");
25015
+ const text = await readFile17(sessionFile, "utf8");
25122
25016
  const entries = [];
25123
25017
  for (const line2 of text.trim().split("\n").filter(Boolean)) {
25124
25018
  try {
@@ -25184,7 +25078,7 @@ async function readSitianRetainedAuditorProviderStop(sessionFile) {
25184
25078
  const { records } = await readSitianRecords(recordFile);
25185
25079
  for (let i = records.length - 1; i >= 0; i -= 1) {
25186
25080
  const payload = records[i]?.payload;
25187
- if (!isRecord10(payload) || !isRecord10(payload.response)) continue;
25081
+ if (!isRecord9(payload) || !isRecord9(payload.response)) continue;
25188
25082
  if (typeof payload.type === "string") continue;
25189
25083
  const stop = sessionProviderStopFromAssistant(payload.response);
25190
25084
  if (stop !== void 0) return stop;
@@ -25234,7 +25128,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
25234
25128
  throw sessionReadFailure(error, "failed to read discovered auditor session");
25235
25129
  }
25236
25130
  const header = entries.find((entry) => entry.type === "session");
25237
- if (!isRecord10(header)) continue;
25131
+ if (!isRecord9(header)) continue;
25238
25132
  const bindingIndexes = [];
25239
25133
  for (let i = 0; i < entries.length; i += 1) {
25240
25134
  const entry = entries[i];
@@ -25248,7 +25142,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
25248
25142
  end: idx + 1 < bindingIndexes.length ? bindingIndexes[idx + 1] : entries.length
25249
25143
  })) : [{ entry: void 0, start: 0, end: entries.length }];
25250
25144
  for (const { entry: bindingEntry, start, end } of bindingPasses) {
25251
- const bindingParent = bindingEntry !== void 0 && isRecord10(bindingEntry.data) && isRecord10(bindingEntry.data.parent) ? bindingEntry.data.parent : void 0;
25145
+ const bindingParent = bindingEntry !== void 0 && isRecord9(bindingEntry.data) && isRecord9(bindingEntry.data.parent) ? bindingEntry.data.parent : void 0;
25252
25146
  const attemptEntryId = typeof bindingParent?.attemptEntryId === "string" ? bindingParent.attemptEntryId : void 0;
25253
25147
  const boundSessionFile = typeof bindingParent?.sessionFile === "string" ? bindingParent.sessionFile : typeof header.parentSession === "string" ? header.parentSession : void 0;
25254
25148
  if (boundSessionFile !== sessionFile) continue;
@@ -25272,12 +25166,12 @@ function complianceFailureFromAuditorVolumes(volumes) {
25272
25166
  if (stop === void 0) continue;
25273
25167
  for (let i = entries.length - 1; i >= 0; i -= 1) {
25274
25168
  const entry = entries[i];
25275
- if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord10(entry.data)) continue;
25276
- const parent = isRecord10(entry.data.parent) ? entry.data.parent : void 0;
25277
- const failure = isRecord10(entry.data.failure) ? entry.data.failure : void 0;
25169
+ if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord9(entry.data)) continue;
25170
+ const parent = isRecord9(entry.data.parent) ? entry.data.parent : void 0;
25171
+ const failure = isRecord9(entry.data.failure) ? entry.data.failure : void 0;
25278
25172
  if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId) continue;
25279
25173
  if (failure === void 0) continue;
25280
- const identity = isRecord10(failure.identity) ? failure.identity : void 0;
25174
+ const identity = isRecord9(failure.identity) ? failure.identity : void 0;
25281
25175
  const typedCause = failure.cause === "provider" || failure.cause === "activation" || failure.cause === "session" || failure.cause === "output" || failure.cause === "timeout" ? failure.cause : void 0;
25282
25176
  return {
25283
25177
  ...typedCause === void 0 ? {} : { cause: typedCause },
@@ -25286,7 +25180,7 @@ function complianceFailureFromAuditorVolumes(volumes) {
25286
25180
  ...typeof identity.code === "string" || typeof identity.code === "number" ? { code: identity.code } : {}
25287
25181
  } },
25288
25182
  ...typeof failure.diagnostic === "string" ? { diagnostic: failure.diagnostic } : {},
25289
- ...isRecord10(failure.details) ? { details: failure.details } : {}
25183
+ ...isRecord9(failure.details) ? { details: failure.details } : {}
25290
25184
  };
25291
25185
  }
25292
25186
  }
@@ -25333,9 +25227,9 @@ function typedFailedTerminatingToolKnownFailure(entries) {
25333
25227
  if (classification.kind !== "infrastructure") continue;
25334
25228
  if (typeof message.toolCallId !== "string" || typeof message.toolName !== "string") continue;
25335
25229
  if (boundRoleToolCallForResult(attemptEntries, i, message, message.toolName) === void 0) continue;
25336
- const textPart = Array.isArray(message.content) ? message.content.find((part) => isRecord10(part) && part.type === "text" && typeof part.text === "string") : void 0;
25337
- const diagnostic = isRecord10(textPart) ? textPart.text : void 0;
25338
- const details = isRecord10(message.details) ? message.details : classification.fact;
25230
+ const textPart = Array.isArray(message.content) ? message.content.find((part) => isRecord9(part) && part.type === "text" && typeof part.text === "string") : void 0;
25231
+ const diagnostic = isRecord9(textPart) ? textPart.text : void 0;
25232
+ const details = isRecord9(message.details) ? message.details : classification.fact;
25339
25233
  return {
25340
25234
  cause: "activation",
25341
25235
  identity: { name: message.toolName, code: message.toolCallId },
@@ -25472,7 +25366,7 @@ function controlledFailureInputFromResolution(resolution) {
25472
25366
  } : {}
25473
25367
  };
25474
25368
  }
25475
- function isRecord10(value) {
25369
+ function isRecord9(value) {
25476
25370
  return typeof value === "object" && value !== null && !Array.isArray(value);
25477
25371
  }
25478
25372
  function toolResultText(message) {
@@ -25497,7 +25391,7 @@ function extractCollectorTargetBindRejection(entries) {
25497
25391
  const diagnostic = toolResultText(message);
25498
25392
  if (diagnostic.length === 0) return void 0;
25499
25393
  const details = message.details;
25500
- const code = isRecord10(details) && typeof details.code === "string" && details.code.trim() !== "" ? details.code : void 0;
25394
+ const code = isRecord9(details) && typeof details.code === "string" && details.code.trim() !== "" ? details.code : void 0;
25501
25395
  return code === void 0 ? { diagnostic } : { diagnostic, code };
25502
25396
  }
25503
25397
  return void 0;
@@ -25598,7 +25492,7 @@ function boundRoleToolCallForResult(entries, resultIndex, message, outputToolNam
25598
25492
  const candidateMessage = entries[index]?.message;
25599
25493
  if (candidateMessage?.role === "assistant" && Array.isArray(candidateMessage.content)) {
25600
25494
  for (const part of candidateMessage.content) {
25601
- if (!isRecord10(part) || part.type !== "toolCall" || part.id !== callId) {
25495
+ if (!isRecord9(part) || part.type !== "toolCall" || part.id !== callId) {
25602
25496
  continue;
25603
25497
  }
25604
25498
  if (part.name !== outputToolName) return void 0;
@@ -25669,7 +25563,7 @@ function parseNavigatorAttendanceDetails(details) {
25669
25563
  if (typeof details.prose === "string" && details.prose.trim() !== "") {
25670
25564
  prose = details.prose;
25671
25565
  } else {
25672
- const next = isRecord10(details.next) && typeof details.next.role === "string" ? details.next.role : void 0;
25566
+ const next = isRecord9(details.next) && typeof details.next.role === "string" ? details.next.role : void 0;
25673
25567
  const reason = typeof details.reason === "string" && details.reason.trim() !== "" ? details.reason : void 0;
25674
25568
  const command = typeof details.command === "string" && details.command.trim() !== "" ? details.command : void 0;
25675
25569
  if (reason !== void 0 && next !== void 0) {
@@ -25778,7 +25672,7 @@ function detourGateContext(admitted, scope) {
25778
25672
  }
25779
25673
  async function withOptionalGateProjection(base, sessionDirectory, gateContext = {}) {
25780
25674
  const secondaryEvidence = base.roleOutcome.kind === "failure" ? base.roleOutcome.decisiveFacts.secondaryEvidence : void 0;
25781
- const skipGate = isRecord10(secondaryEvidence) && secondaryEvidence.kind === "role_infrastructure_failure" && packagedSkipsGateOnInfrastructureStage(secondaryEvidence.stage);
25675
+ const skipGate = isRecord9(secondaryEvidence) && secondaryEvidence.kind === "role_infrastructure_failure" && packagedSkipsGateOnInfrastructureStage(secondaryEvidence.stage);
25782
25676
  let next = base;
25783
25677
  if (!skipGate) {
25784
25678
  const gate = await extractGateFactFromSessionDirectory(sessionDirectory, gateContext);
@@ -25822,7 +25716,7 @@ function extractNavigatorFact(entries) {
25822
25716
  const entry = entries[i];
25823
25717
  if (entry?.type === "custom_message" && entry.customType === "ak-navigator-attendance") {
25824
25718
  const details = entry.message?.details ?? entry.details;
25825
- if (!isRecord10(details)) {
25719
+ if (!isRecord9(details)) {
25826
25720
  return {
25827
25721
  disposition: "unavailable",
25828
25722
  source: "unknown",
@@ -25931,8 +25825,8 @@ async function publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinat
25931
25825
  { kind: "evidence", path: evidencePath }
25932
25826
  ];
25933
25827
  }
25934
- async function publishSeatAcceptedArtifacts(admitted, roleOutcome, coordinates, entries = [], options = {}) {
25935
- return publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries, options);
25828
+ async function publishSeatAcceptedArtifacts(admitted, roleOutcome, coordinates, entries = []) {
25829
+ return publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries);
25936
25830
  }
25937
25831
  async function readLawfulSettlementEntries(sessionFile) {
25938
25832
  try {
@@ -25973,7 +25867,7 @@ async function settleSealedAcceptedOrToolResidual(admitted, authority, scope, ro
25973
25867
  const residual = boundErroredToolCandidate(entries, index, message, residualToolName);
25974
25868
  if (residual === void 0) continue;
25975
25869
  const candidate = residual.candidate;
25976
- const details = isRecord10(candidate) ? candidate : { candidate };
25870
+ const details = isRecord9(candidate) ? candidate : { candidate };
25977
25871
  const failed = await settleFailureTerminalResult(
25978
25872
  admitted,
25979
25873
  {
@@ -26004,7 +25898,7 @@ async function settleSealedAcceptedOrToolResidual(admitted, authority, scope, ro
26004
25898
  scope
26005
25899
  );
26006
25900
  }
26007
- async function settleSeat(admitted, authority, scope, options) {
25901
+ async function settleSeat(admitted, authority, scope) {
26008
25902
  const record4 = packagedRoleMetadata(admitted.role);
26009
25903
  if (record4 === void 0) {
26010
25904
  throw new Error(`no settlement for ${admitted.role}`);
@@ -26012,7 +25906,7 @@ async function settleSeat(admitted, authority, scope, options) {
26012
25906
  if (record4.settlement === "accepted") {
26013
25907
  return trySettleAcceptedSeatTerminalResult(admitted, authority, scope);
26014
25908
  }
26015
- const publish = (roleOutcome, coordinates, entries) => publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries, options);
25909
+ const publish = (roleOutcome, coordinates, entries) => publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries);
26016
25910
  if (record4.settlement === "residual") {
26017
25911
  return settleSealedAcceptedOrToolResidual(
26018
25912
  admitted,
@@ -26027,11 +25921,11 @@ async function settleSeat(admitted, authority, scope, options) {
26027
25921
  const accept = "sealedAcceptedOnly" in record4 && record4.sealedAcceptedOnly === true ? (roleOutcome) => roleOutcome.role === admitted.role && roleOutcome.kind === "accepted" : void 0;
26028
25922
  return settleSealedLedgerTerminal(admitted, authority, scope, publish, accept);
26029
25923
  }
26030
- async function trySettleSeatTerminalResult(admitted, authority, options = {}, scope) {
26031
- return settleSeat(admitted, authority, scope, options);
25924
+ async function trySettleSeatTerminalResult(admitted, authority, scope) {
25925
+ return settleSeat(admitted, authority, scope);
26032
25926
  }
26033
- async function settleSeatTerminalResult(admitted, authority, options = {}, scope) {
26034
- const settled = await settleSeat(admitted, authority, scope, options);
25927
+ async function settleSeatTerminalResult(admitted, authority, scope) {
25928
+ const settled = await settleSeat(admitted, authority, scope);
26035
25929
  if (settled === void 0) {
26036
25930
  const label = admitted.role.charAt(0).toUpperCase() + admitted.role.slice(1);
26037
25931
  throw new Error(
@@ -26040,41 +25934,6 @@ async function settleSeatTerminalResult(admitted, authority, options = {}, scope
26040
25934
  }
26041
25935
  return settled;
26042
25936
  }
26043
- function sessionMessageText(message) {
26044
- if (message === void 0) return "";
26045
- if (typeof message.content === "string") return message.content;
26046
- if (!Array.isArray(message.content)) return "";
26047
- const parts = [];
26048
- for (const part of message.content) {
26049
- if (typeof part === "object" && part !== null && !Array.isArray(part) && part.type === "text" && typeof part.text === "string") {
26050
- parts.push(part.text);
26051
- }
26052
- }
26053
- return parts.join("\n");
26054
- }
26055
- function observedMethodSkillOptions(packageRoot2, material) {
26056
- return {
26057
- methodProvenance: material.provenance,
26058
- methodSkillPath: material.skillPath,
26059
- methodSkillConfiguredPath: resolvePackagedMethodSkillPath(packageRoot2, material.name)
26060
- };
26061
- }
26062
- function extractObservedMethodInvocations(entries, options) {
26063
- const observed = [];
26064
- for (const entry of entries) {
26065
- if (entry?.type !== "message") continue;
26066
- const message = entry.message;
26067
- if (message?.role !== "user") continue;
26068
- const text = sessionMessageText(message);
26069
- if (text.length === 0) continue;
26070
- const hit = observePackagedMethodSkillInvocation(text, {
26071
- name: options.name,
26072
- allowedLocations: options.allowedLocations
26073
- });
26074
- if (hit !== void 0) observed.push(hit);
26075
- }
26076
- return Object.freeze(observed);
26077
- }
26078
25937
  function extractDoctorCandidateFacts(entries) {
26079
25938
  const scanStart = currentAttemptStartIndex(entries);
26080
25939
  for (let i = entries.length - 1; i >= scanStart; i -= 1) {
@@ -26083,7 +25942,7 @@ function extractDoctorCandidateFacts(entries) {
26083
25942
  continue;
26084
25943
  }
26085
25944
  const data = entry.data;
26086
- if (!isRecord10(data)) return {};
25945
+ if (!isRecord9(data)) return {};
26087
25946
  return {
26088
25947
  ...data.cost === void 0 ? {} : { cost: data.cost },
26089
25948
  ...data.auditNoReceipt === void 0 ? {} : { auditNoReceipt: data.auditNoReceipt }
@@ -26127,25 +25986,7 @@ function doctorReportFacts(face, roleOutcome, entries) {
26127
25986
  ...facts.auditNoReceipt === void 0 ? {} : { auditNoReceipt: facts.auditNoReceipt }
26128
25987
  };
26129
25988
  }
26130
- function observedMethodTail(face, entries, options) {
26131
- if (face.method === void 0) return {};
26132
- if (face.method === "optional") {
26133
- return options.methodProvenance === void 0 ? {} : { methodProvenance: options.methodProvenance };
26134
- }
26135
- if (options.methodProvenance === void 0 || options.methodSkillPath === void 0 || options.methodSkillConfiguredPath === void 0) {
26136
- throw new Error("observed method publication is missing packaged method coordinates");
26137
- }
26138
- const methodInvocations = extractObservedMethodInvocations(entries, {
26139
- name: options.methodProvenance.name,
26140
- allowedLocations: [options.methodSkillPath, options.methodSkillConfiguredPath]
26141
- });
26142
- return {
26143
- methodProvenance: options.methodProvenance,
26144
- methodInvocationObserved: methodInvocations.length > 0,
26145
- methodInvocations
26146
- };
26147
- }
26148
- async function publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries, options = {}) {
25989
+ async function publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates, entries) {
26149
25990
  const face = seatArtifactFace(admitted.role);
26150
25991
  const phase = face.reportPhase === true ? { phase: readAdmittedPath(admitted, "phase") } : {};
26151
25992
  return publishAcceptedTerminalArtifacts(admitted, roleOutcome, coordinates, {
@@ -26163,8 +26004,7 @@ async function publishDeclaredSeatArtifacts(admitted, roleOutcome, coordinates,
26163
26004
  sessionDirectory: coordinates.sessionDirectory,
26164
26005
  sessionFile: coordinates.sessionFile,
26165
26006
  admittedRequestPath: admitted.admittedRequestPath,
26166
- attachments: acceptedArtifactAttachmentRefs(admitted.attachments),
26167
- ...observedMethodTail(face, entries, options)
26007
+ attachments: acceptedArtifactAttachmentRefs(admitted.attachments)
26168
26008
  }
26169
26009
  });
26170
26010
  }
@@ -26187,7 +26027,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
26187
26027
  let residual;
26188
26028
  for (let index = entries.length - 1; index >= scanStart; index -= 1) {
26189
26029
  const entry = entries[index];
26190
- if (entry?.type === "custom" && entry.customType === "ak-role-submission-closure" && isRecord10(entry.data) && entry.data.toolName === spec.toolName && classifyPackagedRoleTerminalResult(entry.data).kind === "accepted") {
26030
+ if (entry?.type === "custom" && entry.customType === "ak-role-submission-closure" && isRecord9(entry.data) && entry.data.toolName === spec.toolName && classifyPackagedRoleTerminalResult(entry.data).kind === "accepted") {
26191
26031
  thisAttemptHasSeatSuccess = true;
26192
26032
  }
26193
26033
  const message = entries[index]?.message;
@@ -26227,7 +26067,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
26227
26067
  );
26228
26068
  }
26229
26069
  if (residual !== void 0) {
26230
- const details = isRecord10(residual.candidate) ? residual.candidate : { candidate: residual.candidate };
26070
+ const details = isRecord9(residual.candidate) ? residual.candidate : { candidate: residual.candidate };
26231
26071
  const failed = await settleFailureTerminalResult(
26232
26072
  admitted,
26233
26073
  {
@@ -26257,11 +26097,8 @@ async function trySettleAcceptedSeatTerminalResult(admitted, authority, scope) {
26257
26097
  }
26258
26098
  return applySecretariatCountersignTerminal(admitted, authority, settled);
26259
26099
  }
26260
- async function trySettlePublicSeat(admitted, authority, scope, material, packageRoot2) {
26261
- const face = seatArtifactFace(admitted.role);
26262
- if (face.method === "observed" && material === void 0) return void 0;
26263
- const options = face.method === "observed" && material !== void 0 ? observedMethodSkillOptions(packageRoot2, material) : face.method === "optional" && material !== void 0 ? { methodProvenance: material.provenance } : {};
26264
- return settleSeat(admitted, authority, scope, options);
26100
+ async function trySettlePublicSeat(admitted, authority, scope) {
26101
+ return settleSeat(admitted, authority, scope);
26265
26102
  }
26266
26103
  function countersignTerminalFromEntries(entries) {
26267
26104
  for (let index = entries.length - 1; index >= 0; index -= 1) {
@@ -26280,7 +26117,7 @@ function countersignTerminalFromEntries(entries) {
26280
26117
  return void 0;
26281
26118
  }
26282
26119
  function withCountersignTerminalFact(roleOutcome, officer) {
26283
- const prior = roleOutcome.decisiveFacts !== void 0 && isRecord10(roleOutcome.decisiveFacts) ? roleOutcome.decisiveFacts : {};
26120
+ const prior = roleOutcome.decisiveFacts !== void 0 && isRecord9(roleOutcome.decisiveFacts) ? roleOutcome.decisiveFacts : {};
26284
26121
  return {
26285
26122
  ...roleOutcome,
26286
26123
  decisiveFacts: {
@@ -26293,7 +26130,7 @@ function acceptedSecretariatDefinesOfficerProjection(roleOutcome) {
26293
26130
  const payloads = roleOutcome.payloads ?? [];
26294
26131
  for (let index = payloads.length - 1; index >= 0; index -= 1) {
26295
26132
  const payload = payloads[index];
26296
- if (!isRecord10(payload)) continue;
26133
+ if (!isRecord9(payload)) continue;
26297
26134
  const status = payload.secretariatStatus;
26298
26135
  if (typeof status !== "string") continue;
26299
26136
  return status === "converged";
@@ -26675,7 +26512,6 @@ var init_settlement = __esm({
26675
26512
  init_reviewer_output();
26676
26513
  init_packaged_role_registry();
26677
26514
  init_secretariat_contracts();
26678
- init_method_skill();
26679
26515
  init_navigator_invocation_identity();
26680
26516
  init_receipt_delivery_policy();
26681
26517
  init_role_run_placement();
@@ -26724,7 +26560,7 @@ var init_settlement = __esm({
26724
26560
  // src/public-cli/auto-resume.ts
26725
26561
  import { constants as fsConstants2 } from "node:fs";
26726
26562
  import { randomUUID as randomUUID5 } from "node:crypto";
26727
- import { lstat as lstat6, mkdir as mkdir3, open as open2 } from "node:fs/promises";
26563
+ import { lstat as lstat7, mkdir as mkdir4, open as open2 } from "node:fs/promises";
26728
26564
  import { join as join29 } from "node:path";
26729
26565
  async function persistReturnedRunState(admitted, authority, options) {
26730
26566
  if (options?.lawful === true) {
@@ -26761,20 +26597,20 @@ async function finalizeExceptionRunBestEffort(runDirectory, io) {
26761
26597
  }
26762
26598
  }
26763
26599
  async function ensureRealArtifactsDirectory(runDirectory) {
26764
- const runStat = await lstat6(runDirectory);
26600
+ const runStat = await lstat7(runDirectory);
26765
26601
  if (runStat.isSymbolicLink() || !runStat.isDirectory()) {
26766
26602
  throw new Error("run artifact retention: run directory is not a real directory");
26767
26603
  }
26768
26604
  const artifactsDir = roleRunArtifactsDirectory(runDirectory);
26769
26605
  try {
26770
- const existing = await lstat6(artifactsDir);
26606
+ const existing = await lstat7(artifactsDir);
26771
26607
  if (existing.isSymbolicLink() || !existing.isDirectory()) {
26772
26608
  throw new Error("run artifact retention: artifacts path is not a real directory");
26773
26609
  }
26774
26610
  } catch (error) {
26775
26611
  if (!isMissingPathError5(error)) throw error;
26776
- await mkdir3(artifactsDir, { recursive: true });
26777
- const created = await lstat6(artifactsDir);
26612
+ await mkdir4(artifactsDir, { recursive: true });
26613
+ const created = await lstat7(artifactsDir);
26778
26614
  if (created.isSymbolicLink() || !created.isDirectory()) {
26779
26615
  throw new Error("run artifact retention: artifacts directory is not a real directory");
26780
26616
  }
@@ -27193,30 +27029,6 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
27193
27029
  } catch {
27194
27030
  }
27195
27031
  }
27196
- async function resolveResumeMethodMaterialAdapters(input) {
27197
- if (input.shouldLoad === false) {
27198
- return { kind: "continue", adapters: input.emptyAdapters };
27199
- }
27200
- try {
27201
- const material = await input.loadMaterial();
27202
- return { kind: "continue", adapters: input.adaptersWith(material) };
27203
- } catch (error) {
27204
- const terminal = await presentControlledFailure2(
27205
- input.admitted,
27206
- {
27207
- timedOut: false,
27208
- code: null,
27209
- stderr: "",
27210
- thrown: error,
27211
- ...input.knownCause === void 0 ? {} : { knownCause: input.knownCause }
27212
- },
27213
- input.emptyAdapters,
27214
- input.authority,
27215
- input.io
27216
- );
27217
- return { kind: "terminal", ...terminal };
27218
- }
27219
- }
27220
27032
  async function presentControlledFailure2(admitted, failureInput, adapters, authority, io, persistRunState = true) {
27221
27033
  const hasThrown = Object.hasOwn(failureInput, "thrown");
27222
27034
  const resumeObservation = await resolveControlledFailureResumeObservation({
@@ -27735,6 +27547,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
27735
27547
  return {
27736
27548
  packageRoot: env.packageRoot,
27737
27549
  home: env.home,
27550
+ ...env.host === void 0 ? {} : { host: env.host },
27738
27551
  agentDir: env.agentDir,
27739
27552
  ...env.model === void 0 ? {} : { model: env.model },
27740
27553
  ...pickEngineAxis(env),
@@ -27753,6 +27566,7 @@ function roleTurnOptions(env, admitted, continuation) {
27753
27566
  return {
27754
27567
  packageRoot: env.packageRoot,
27755
27568
  home: env.home,
27569
+ ...env.host === void 0 ? {} : { host: env.host },
27756
27570
  agentDir: env.agentDir,
27757
27571
  ...env.model === void 0 ? {} : { model: env.model },
27758
27572
  ...pickEngineAxis(env),
@@ -28166,7 +27980,7 @@ function activationForAdmitted(admitted) {
28166
27980
  }
28167
27981
  return activation;
28168
27982
  }
28169
- function methodBindings(admitted, packageRoot2) {
27983
+ function requiredMethodSkills(admitted) {
28170
27984
  const record4 = packagedRoleMetadata(admitted.role);
28171
27985
  const names = [];
28172
27986
  if (record4 !== void 0 && "methodSkills" in record4 && record4.methodSkills !== void 0) {
@@ -28174,23 +27988,30 @@ function methodBindings(admitted, packageRoot2) {
28174
27988
  }
28175
27989
  const apply = packagedSettleSkill(admitted);
28176
27990
  if (apply !== void 0 && !names.includes(apply)) names.push(apply);
28177
- return names.map((name) => ({
28178
- kind: "skill",
28179
- path: resolvePackagedMethodSkillPath(packageRoot2, name)
28180
- }));
27991
+ return names;
27992
+ }
27993
+ function methodBindings(admitted, home, host) {
27994
+ if (host !== void 0 && host !== "pi") return [];
27995
+ return requiredMethodSkills(admitted).flatMap((name) => {
27996
+ const path = installedMethodSkillPath(home, name);
27997
+ return path === void 0 ? [] : [{
27998
+ kind: "skill",
27999
+ path
28000
+ }];
28001
+ });
28181
28002
  }
28182
- function admittedSeatTurnDetails(admitted, packageRoot2) {
28003
+ function admittedSeatTurnDetails(admitted, home, host) {
28183
28004
  return {
28184
28005
  activation: activationForAdmitted(admitted),
28185
- methods: methodBindings(admitted, packageRoot2)
28006
+ methods: methodBindings(admitted, home, host)
28186
28007
  };
28187
28008
  }
28188
28009
  var init_turn_request = __esm({
28189
28010
  "src/public-cli/turn-request.ts"() {
28190
28011
  "use strict";
28191
28012
  init_engine_material();
28192
- init_method_skill();
28193
28013
  init_packaged_role_registry();
28014
+ init_machine_method_skills();
28194
28015
  init_run_lifecycle();
28195
28016
  }
28196
28017
  });
@@ -28206,7 +28027,7 @@ __export(public_role_summons_exports, {
28206
28027
  });
28207
28028
  import { execFile as execFile3 } from "node:child_process";
28208
28029
  import { existsSync as existsSync9 } from "node:fs";
28209
- import { realpath as realpath6 } from "node:fs/promises";
28030
+ import { realpath as realpath5 } from "node:fs/promises";
28210
28031
  import { join as join31 } from "node:path";
28211
28032
  import { promisify as promisify3 } from "node:util";
28212
28033
  function createCapturingIo() {
@@ -28495,8 +28316,8 @@ function withReviewerLens(argv2, lens) {
28495
28316
  return [...argv2.slice(0, separator), "--lens", lens, ...argv2.slice(separator)];
28496
28317
  }
28497
28318
  async function resolveReviewerGitToplevel(projectRoot) {
28498
- const callerProjectRoot = await realpath6(projectRoot);
28499
- return await realpath6((await execFileAsync3(
28319
+ const callerProjectRoot = await realpath5(projectRoot);
28320
+ return await realpath5((await execFileAsync3(
28500
28321
  "git",
28501
28322
  ["rev-parse", "--show-toplevel"],
28502
28323
  { cwd: callerProjectRoot }
@@ -28715,11 +28536,11 @@ var init_public_role_summons = __esm({
28715
28536
  });
28716
28537
 
28717
28538
  // src/public-cli/countersign-run.ts
28718
- function isRecord11(value) {
28539
+ function isRecord10(value) {
28719
28540
  return typeof value === "object" && value !== null && !Array.isArray(value);
28720
28541
  }
28721
28542
  function isEscalatePayload(payload) {
28722
- if (!isRecord11(payload)) return false;
28543
+ if (!isRecord10(payload)) return false;
28723
28544
  return payload.status === "escalate";
28724
28545
  }
28725
28546
  function courtDiaristPayloadRows(roleOutcome, submissions) {
@@ -28922,7 +28743,7 @@ function roleRecord(role) {
28922
28743
  function buildInstructionSeatTurnRequest(admitted, options) {
28923
28744
  return projectRoleTurnRequest(
28924
28745
  admitted,
28925
- admittedSeatTurnDetails(admitted, options.packageRoot),
28746
+ admittedSeatTurnDetails(admitted, options.home, options.host),
28926
28747
  options
28927
28748
  );
28928
28749
  }
@@ -28955,11 +28776,11 @@ async function bindAndRelocateDiarist(admitted, authority, lease) {
28955
28776
  }
28956
28777
  await relocateAdmittedRunToTicket(admitted, authority, lease);
28957
28778
  }
28958
- function seatAdapters(admitted, env, material) {
28779
+ function seatAdapters(admitted, env) {
28959
28780
  const record4 = roleRecord(admitted.role);
28960
28781
  const present = "presentSettled" in record4 ? record4.presentSettled : "default";
28961
28782
  return {
28962
- trySettle: (seat, authority, scope) => trySettlePublicSeat(seat, authority, scope, material, env.packageRoot),
28783
+ trySettle: (seat, authority, scope) => trySettlePublicSeat(seat, authority, scope),
28963
28784
  ...present === "always" ? { shouldPresentSettled: () => true } : {},
28964
28785
  ...present === "typed" ? { shouldPresentSettled: (terminal) => isLawfulTypedTerminalOutcome(terminal.roleOutcome) } : {},
28965
28786
  ...infraFailure(admitted.role),
@@ -29011,23 +28832,8 @@ async function withAuditorSoulEnv(options) {
29011
28832
  }
29012
28833
  async function dispatchAdmitted(admitted, env, io) {
29013
28834
  const record4 = roleRecord(admitted.role);
29014
- let material;
29015
- const skill = packagedSettleSkill(admitted);
29016
- if (skill !== void 0) {
29017
- try {
29018
- material = await loadPackagedMethodSkillMaterial(env.packageRoot, skill);
29019
- } catch (error) {
29020
- const knownCause = packagedMethodLoadFailureCause(admitted.role);
29021
- return await presentControlledFailure2(admitted, {
29022
- timedOut: false,
29023
- code: null,
29024
- stderr: "",
29025
- thrown: error,
29026
- ...knownCause === void 0 ? {} : { knownCause }
29027
- }, seatAdapters(admitted, env), env.principalAuthority, io);
29028
- }
29029
- }
29030
- const adapters = seatAdapters(admitted, env, material);
28835
+ await warnMissingMethodSkills(env.home, env.host, admitted.role, requiredMethodSkills(admitted), io.stdout);
28836
+ const adapters = seatAdapters(admitted, env);
29031
28837
  const execute = async (activeEnv) => {
29032
28838
  const auto = "inCallAutoResume" in record4 && record4.inCallAutoResume === true;
29033
28839
  if (auto) {
@@ -29530,21 +29336,9 @@ async function runPublicInstructionSeatResume(request, env, io) {
29530
29336
  adapters: {
29531
29337
  trySettle: async () => void 0
29532
29338
  },
29533
- afterAdmittedLoad: (admitted) => {
29534
- const skill = packagedSettleSkill(admitted);
29535
- if (skill === void 0) {
29536
- return Promise.resolve({ kind: "continue", adapters: seatAdapters(admitted, env) });
29537
- }
29538
- const knownCause = packagedMethodLoadFailureCause(admitted.role);
29539
- return resolveResumeMethodMaterialAdapters({
29540
- admitted,
29541
- authority: env.principalAuthority,
29542
- io,
29543
- loadMaterial: () => loadPackagedMethodSkillMaterial(env.packageRoot, skill),
29544
- adaptersWith: (material) => seatAdapters(admitted, env, material),
29545
- emptyAdapters: seatAdapters(admitted, env),
29546
- ...knownCause === void 0 ? {} : { knownCause }
29547
- });
29339
+ afterAdmittedLoad: async (admitted) => {
29340
+ await warnMissingMethodSkills(env.home, env.host, admitted.role, requiredMethodSkills(admitted), io.stdout);
29341
+ return { kind: "continue", adapters: seatAdapters(admitted, env) };
29548
29342
  },
29549
29343
  ...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
29550
29344
  });
@@ -29570,7 +29364,6 @@ var init_instruction_seat_run = __esm({
29570
29364
  init_run_ticket_number();
29571
29365
  init_notary_source_run();
29572
29366
  init_engine_material();
29573
- init_method_skill();
29574
29367
  init_packaged_role_registry();
29575
29368
  init_auditor_soul();
29576
29369
  init_cli_errors();
@@ -29579,6 +29372,7 @@ var init_instruction_seat_run = __esm({
29579
29372
  init_run_lifecycle();
29580
29373
  init_seat_ticket_binding();
29581
29374
  init_settlement();
29375
+ init_machine_method_skills();
29582
29376
  init_terminal();
29583
29377
  init_turn_request();
29584
29378
  init_countersign_run();
@@ -29586,13 +29380,13 @@ var init_instruction_seat_run = __esm({
29586
29380
  });
29587
29381
 
29588
29382
  // src/analyst-book-key.ts
29589
- import { statSync as statSync2 } from "node:fs";
29383
+ import { statSync as statSync3 } from "node:fs";
29590
29384
  import { isAbsolute as isAbsolute9 } from "node:path";
29591
29385
  function resolveAnalystBookKey(projectRoot) {
29592
29386
  const identity = physicalPathIdentity(projectRoot);
29593
29387
  let stats;
29594
29388
  try {
29595
- stats = statSync2(identity);
29389
+ stats = statSync3(identity);
29596
29390
  } catch (error) {
29597
29391
  const code = errnoCode(error);
29598
29392
  if (code === "ENOENT" || code === "ENOTDIR") return `root:${identity}`;
@@ -29641,7 +29435,7 @@ var init_atomic_write = __esm({
29641
29435
  });
29642
29436
 
29643
29437
  // src/analyst-index.ts
29644
- import { open as open3, readFile as readFile19, unlink as unlink5 } from "node:fs/promises";
29438
+ import { open as open3, readFile as readFile18, unlink as unlink5 } from "node:fs/promises";
29645
29439
  import { dirname as dirname18, join as join33 } from "node:path";
29646
29440
  function sleep(ms) {
29647
29441
  return new Promise((resolve12) => {
@@ -29769,7 +29563,7 @@ async function readAnalystLibraryIndexPage(ledgerHome) {
29769
29563
  const path = analystLibraryIndexPath(ledgerHome);
29770
29564
  let raw;
29771
29565
  try {
29772
- raw = await readFile19(path, "utf8");
29566
+ raw = await readFile18(path, "utf8");
29773
29567
  } catch (error) {
29774
29568
  if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR")) {
29775
29569
  return void 0;
@@ -29973,15 +29767,15 @@ var init_analyst_cohort = __esm({
29973
29767
  });
29974
29768
 
29975
29769
  // src/analyst-ledger.ts
29976
- import { readdir as readdir8, readFile as readFile20 } from "node:fs/promises";
29977
- import { basename as basename9, join as join34 } from "node:path";
29770
+ import { readdir as readdir8, readFile as readFile19 } from "node:fs/promises";
29771
+ import { basename as basename8, join as join34 } from "node:path";
29978
29772
  function isMissingPathError6(error) {
29979
29773
  return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
29980
29774
  }
29981
29775
  function errorText3(error) {
29982
29776
  return error instanceof Error ? error.message : String(error);
29983
29777
  }
29984
- function isRecord12(value) {
29778
+ function isRecord11(value) {
29985
29779
  return typeof value === "object" && value !== null && !Array.isArray(value);
29986
29780
  }
29987
29781
  async function readExistingRunLifecycleState(runDirectory) {
@@ -30032,13 +29826,13 @@ async function listLedgerBookNames(booksRoot) {
30032
29826
  async function readInvocationScopeFields(runDirectory) {
30033
29827
  let raw;
30034
29828
  try {
30035
- raw = await readFile20(join34(runDirectory, "invocation.json"), "utf8");
29829
+ raw = await readFile19(join34(runDirectory, "invocation.json"), "utf8");
30036
29830
  } catch (error) {
30037
29831
  if (isMissingPathError6(error)) return void 0;
30038
29832
  throw error;
30039
29833
  }
30040
29834
  const parsed = JSON.parse(raw);
30041
- if (!isRecord12(parsed)) return void 0;
29835
+ if (!isRecord11(parsed)) return void 0;
30042
29836
  if (typeof parsed.projectRoot !== "string" || parsed.projectRoot.trim() === "") {
30043
29837
  return void 0;
30044
29838
  }
@@ -30065,9 +29859,9 @@ function decideIssueScope(input) {
30065
29859
  }
30066
29860
  async function resolveSessionFile(runDirectory) {
30067
29861
  try {
30068
- const raw = await readFile20(join34(runDirectory, "invocation.json"), "utf8");
29862
+ const raw = await readFile19(join34(runDirectory, "invocation.json"), "utf8");
30069
29863
  const parsed = JSON.parse(raw);
30070
- if (isRecord12(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
29864
+ if (isRecord11(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
30071
29865
  return parsed.sessionFile;
30072
29866
  }
30073
29867
  } catch (error) {
@@ -30344,7 +30138,7 @@ async function scanAnalystIssueRuns(input) {
30344
30138
  throw error;
30345
30139
  }
30346
30140
  for (const runDirectory of runDirectories) {
30347
- const runName = basename9(runDirectory);
30141
+ const runName = basename8(runDirectory);
30348
30142
  const parsed = parseRunDirectoryName2(runName);
30349
30143
  if (parsed === void 0) continue;
30350
30144
  let scopeFields;
@@ -30405,7 +30199,7 @@ var init_analyst_ledger = __esm({
30405
30199
  });
30406
30200
 
30407
30201
  // src/analyst-metric-families/acceptance-success-rework.ts
30408
- function isRecord13(value) {
30202
+ function isRecord12(value) {
30409
30203
  return typeof value === "object" && value !== null && !Array.isArray(value);
30410
30204
  }
30411
30205
  function wallMsFromSpan(span) {
@@ -30414,21 +30208,21 @@ function wallMsFromSpan(span) {
30414
30208
  function findCollectorGroups(body) {
30415
30209
  if (Array.isArray(body.groups)) return body.groups;
30416
30210
  const receipt = body.receipt;
30417
- if (isRecord13(receipt) && Array.isArray(receipt.groups)) return receipt.groups;
30211
+ if (isRecord12(receipt) && Array.isArray(receipt.groups)) return receipt.groups;
30418
30212
  const outcome = body.outcome;
30419
- if (isRecord13(outcome)) {
30213
+ if (isRecord12(outcome)) {
30420
30214
  const facts = outcome.decisiveFacts;
30421
- if (isRecord13(facts) && Array.isArray(facts.groups)) return facts.groups;
30215
+ if (isRecord12(facts) && Array.isArray(facts.groups)) return facts.groups;
30422
30216
  }
30423
30217
  return void 0;
30424
30218
  }
30425
30219
  function extractStatus(body) {
30426
30220
  const outcome = body.outcome;
30427
- if (isRecord13(outcome) && typeof outcome.status === "string" && outcome.status.trim() !== "") {
30221
+ if (isRecord12(outcome) && typeof outcome.status === "string" && outcome.status.trim() !== "") {
30428
30222
  return outcome.status;
30429
30223
  }
30430
30224
  const receipt = body.receipt;
30431
- if (isRecord13(receipt) && typeof receipt.status === "string" && receipt.status.trim() !== "") {
30225
+ if (isRecord12(receipt) && typeof receipt.status === "string" && receipt.status.trim() !== "") {
30432
30226
  return receipt.status;
30433
30227
  }
30434
30228
  if (typeof body.status === "string" && body.status.trim() !== "") {
@@ -31054,15 +30848,15 @@ var init_leg_wall_clock = __esm({
31054
30848
  });
31055
30849
 
31056
30850
  // src/analyst-metric-families/round-timeline.ts
31057
- function isRecord14(value) {
30851
+ function isRecord13(value) {
31058
30852
  return typeof value === "object" && value !== null && !Array.isArray(value);
31059
30853
  }
31060
30854
  function wallMsFromSpan2(startedAt, endedAt) {
31061
30855
  return Date.parse(endedAt) - Date.parse(startedAt);
31062
30856
  }
31063
30857
  function readClassCount(body) {
31064
- if (!isRecord14(body.outcome)) return void 0;
31065
- if (!isRecord14(body.outcome.decisiveFacts)) return void 0;
30858
+ if (!isRecord13(body.outcome)) return void 0;
30859
+ if (!isRecord13(body.outcome.decisiveFacts)) return void 0;
31066
30860
  const classCount = body.outcome.decisiveFacts.classCount;
31067
30861
  if (typeof classCount !== "number" || !Number.isFinite(classCount)) {
31068
30862
  return void 0;
@@ -31206,7 +31000,7 @@ var init_analyst_metric_family = __esm({
31206
31000
  });
31207
31001
 
31208
31002
  // src/analyst-page.ts
31209
- import { createHash as createHash5 } from "node:crypto";
31003
+ import { createHash as createHash4 } from "node:crypto";
31210
31004
  import { dirname as dirname19, join as join35 } from "node:path";
31211
31005
  function analystIssuePageKey(address) {
31212
31006
  const parts = ["book", address.bookKey];
@@ -31215,7 +31009,7 @@ function analystIssuePageKey(address) {
31215
31009
  } else if (address.scopeRootIdentity !== void 0) {
31216
31010
  parts.push("root", physicalPathIdentity(address.scopeRootIdentity));
31217
31011
  }
31218
- return createHash5("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
31012
+ return createHash4("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
31219
31013
  }
31220
31014
  function analystIssuePagePath(ledgerHome, address) {
31221
31015
  return join35(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
@@ -31354,7 +31148,7 @@ var init_analyst_page = __esm({
31354
31148
  });
31355
31149
 
31356
31150
  // src/analyst-entry.ts
31357
- import { readFile as readFile21 } from "node:fs/promises";
31151
+ import { readFile as readFile20 } from "node:fs/promises";
31358
31152
  function isMissingPathError7(error) {
31359
31153
  return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
31360
31154
  }
@@ -31384,7 +31178,7 @@ async function readOrComputeAnalystIssuePage(input, options) {
31384
31178
  ...issueNumber === void 0 && input.bookKey === void 0 ? { scopeRootIdentity: projectRoot } : {}
31385
31179
  });
31386
31180
  try {
31387
- const raw = await readFile21(pagePath, "utf8");
31181
+ const raw = await readFile20(pagePath, "utf8");
31388
31182
  const page = JSON.parse(raw);
31389
31183
  if (cachedPageMatchesRequestedScope(page, { bookKey, ...input })) {
31390
31184
  const ghostScan = await scanAnalystIssueRuns({
@@ -31485,7 +31279,7 @@ async function runAnalystModelGroupsMode(input, home) {
31485
31279
  scopeRootIdentity: projectRoot
31486
31280
  });
31487
31281
  try {
31488
- const raw = await readFile21(pagePath, "utf8");
31282
+ const raw = await readFile20(pagePath, "utf8");
31489
31283
  JSON.parse(raw);
31490
31284
  } catch (error) {
31491
31285
  if (!isMissingPathError7(error)) {
@@ -31584,7 +31378,7 @@ var init_analyst_entry = __esm({
31584
31378
  });
31585
31379
 
31586
31380
  // src/public-cli/analyst-run.ts
31587
- import { readFile as readFile22 } from "node:fs/promises";
31381
+ import { readFile as readFile21 } from "node:fs/promises";
31588
31382
  import { isAbsolute as isAbsolute10, resolve as resolve11 } from "node:path";
31589
31383
  function resolveAnalystIssueBookKeyFromCwd(cwd = process.cwd()) {
31590
31384
  try {
@@ -31637,7 +31431,7 @@ async function buildAnalystSweepModeInputFromAttachmentPaths(attachmentPaths) {
31637
31431
  const absolute = isAbsolute10(sourcePath) ? sourcePath : resolve11(sourcePath);
31638
31432
  let bytes;
31639
31433
  try {
31640
- bytes = await readFile22(absolute);
31434
+ bytes = await readFile21(absolute);
31641
31435
  } catch (error) {
31642
31436
  throw new CliUsageError(
31643
31437
  `analyst sweep attachment is not a readable regular file: ${sourcePath}`,
@@ -31757,7 +31551,7 @@ __export(cli_exports, {
31757
31551
  resolveInternalRoleEntrypoint: () => resolveInternalRoleEntrypoint,
31758
31552
  runAkRole: () => runAkRole
31759
31553
  });
31760
- import { realpath as realpath7 } from "node:fs/promises";
31554
+ import { realpath as realpath6 } from "node:fs/promises";
31761
31555
  import { join as join36 } from "node:path";
31762
31556
  function publicSeatArgv(owner) {
31763
31557
  return {
@@ -32432,7 +32226,7 @@ async function runAkRole(argv2, env) {
32432
32226
  try {
32433
32227
  env = {
32434
32228
  ...env,
32435
- packageRoot: await realpath7(env.packageRoot),
32229
+ packageRoot: await realpath6(env.packageRoot),
32436
32230
  principalAuthority: env.principalAuthority ?? piDurablePrincipalAuthority
32437
32231
  };
32438
32232
  let parsed = parseArgv(argv2);
@@ -32481,6 +32275,10 @@ async function runAkRole(argv2, env) {
32481
32275
  exitCode: await runConfigCommand(parsed.args, home, env.packageRoot, io)
32482
32276
  };
32483
32277
  }
32278
+ if (parsed.command === "setup") {
32279
+ if (parsed.args.length !== 0) throw new CliUsageError("setup takes no arguments");
32280
+ return { exitCode: await runMachineSkillSetup(home, io.stdout) };
32281
+ }
32484
32282
  if (parsed.command === "new") {
32485
32283
  const role = parsed.args[0];
32486
32284
  if (role === void 0) {
@@ -32604,6 +32402,7 @@ var init_cli = __esm({
32604
32402
  init_packaged_role_registry();
32605
32403
  init_registry2();
32606
32404
  init_cli_errors();
32405
+ init_machine_method_skills();
32607
32406
  init_role_turn_host();
32608
32407
  init_role_turn_host_resolution();
32609
32408
  init_invocation();