@akagilnc/pi-workflow-roles 0.1.4518 → 0.1.4524

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.
@@ -14272,7 +14272,8 @@ function formatTerminalResult(result) {
14272
14272
  lines.push(`autoResumeCount ${encodeTerminalField(String(result.autoResumeCount))}`);
14273
14273
  }
14274
14274
  const payloads = result.roleOutcome.kind === "accepted" || result.roleOutcome.kind === "audit_escalation" ? result.roleOutcome.payloads ?? result.submissions ?? [] : result.roleOutcome.kind === "failure" ? result.roleOutcome.payloads ?? result.submissions ?? [] : result.submissions ?? [];
14275
- for (const payload of payloads) {
14275
+ for (let i = payloads.length - 1; i >= 0; i -= 1) {
14276
+ const payload = payloads[i];
14276
14277
  const rendered = typeof payload === "string" ? payload : JSON.stringify(payload);
14277
14278
  lines.push(`submission ${encodeTerminalField(rendered)}`);
14278
14279
  }
@@ -26739,7 +26740,7 @@ async function prepareRoleEnvelope(options) {
26739
26740
 
26740
26741
  // src/role-runtime-dependencies.ts
26741
26742
  import { readFile as readFile22 } from "node:fs/promises";
26742
- import { fileURLToPath as fileURLToPath3 } from "node:url";
26743
+ import { join as join42 } from "node:path";
26743
26744
 
26744
26745
  // src/canonical-skill-binding.ts
26745
26746
  import { readFile as readFile20, realpath as realpath7 } from "node:fs/promises";
@@ -26940,16 +26941,12 @@ async function loadPackagedCanonicalSkillBinding(packageRoot, name) {
26940
26941
  // src/role-runtime-dependencies.ts
26941
26942
  init_auditor_soul();
26942
26943
  init_session_opening_materials();
26943
- var navigatorRoutePlaybookPath = fileURLToPath3(
26944
- new URL("../resources/navigator-route-playbook.md", import.meta.url)
26945
- );
26946
- var collectorHandbookSeedPath = fileURLToPath3(
26947
- new URL("../resources/collector-bot-handbook.md", import.meta.url)
26948
- );
26949
26944
  function loadPackagedRoleReferenceMaterials(role) {
26950
26945
  return role === "auditor" ? loadAuditorReferenceMaterialsFromSubjectInput() : loadMainRoleReferenceMaterials(role);
26951
26946
  }
26952
26947
  function createRoleRuntimeDependencies(packageRoot) {
26948
+ const navigatorRoutePlaybookPath = join42(packageRoot, "resources/navigator-route-playbook.md");
26949
+ const collectorHandbookSeedPath = join42(packageRoot, "resources/collector-bot-handbook.md");
26953
26950
  const doctorAuditor = createPiDoctorAuditor();
26954
26951
  const navigatorSessionFactory = createNativeNavigatorSessionFactory();
26955
26952
  return {
@@ -27016,9 +27013,9 @@ function createRoleRuntimeDependencies(packageRoot) {
27016
27013
  init_session_identity();
27017
27014
 
27018
27015
  // src/acp-host/description.ts
27019
- import { join as join42 } from "node:path";
27016
+ import { join as join43 } from "node:path";
27020
27017
  function resolveAcpBinary(description, operatorHome) {
27021
- return join42(operatorHome, ...description.binaryFromHome);
27018
+ return join43(operatorHome, ...description.binaryFromHome);
27022
27019
  }
27023
27020
  function acpStdioArgs(description, model, seat) {
27024
27021
  const { prefix, suffix, modelFlag, thinkingFlag } = description.argv;
@@ -27465,12 +27462,12 @@ function createAcpRoleTurnHost(config) {
27465
27462
  // src/acp-host/seat-profile-soul.ts
27466
27463
  import { constants as constants3 } from "node:fs";
27467
27464
  import { access as access4, copyFile, lstat as lstat8, mkdir as mkdir7, readlink as readlink2, symlink as symlink2, unlink as unlink3 } from "node:fs/promises";
27468
- import { dirname as dirname25, join as join43, relative as relative3, resolve as resolve20 } from "node:path";
27465
+ import { dirname as dirname25, join as join44, relative as relative3, resolve as resolve20 } from "node:path";
27469
27466
  function seatProfileName(spec, role) {
27470
27467
  return `${spec.namePrefix}${role}`;
27471
27468
  }
27472
27469
  function packageRoleSoulPath(packageRoot, role) {
27473
- return join43(packageRoot, "souls", `${role}.md`);
27470
+ return join44(packageRoot, "souls", `${role}.md`);
27474
27471
  }
27475
27472
  async function pathExists2(path) {
27476
27473
  try {
@@ -27487,16 +27484,16 @@ async function ensureSeatProfileSoul(options) {
27487
27484
  if (!await pathExists2(soulTarget)) {
27488
27485
  throw new Error(`packaged role soul missing: ${soulTarget}`);
27489
27486
  }
27490
- const profilesRoot = join43(operatorHome, ...spec.profilesRootFromHome);
27491
- const profileDir = join43(profilesRoot, profileName);
27487
+ const profilesRoot = join44(operatorHome, ...spec.profilesRootFromHome);
27488
+ const profileDir = join44(profilesRoot, profileName);
27492
27489
  const hostRoot = dirname25(profilesRoot);
27493
- const soulPath = join43(profileDir, spec.soulFileName);
27490
+ const soulPath = join44(profileDir, spec.soulFileName);
27494
27491
  if (!await pathExists2(profileDir)) {
27495
27492
  await mkdir7(profileDir, { recursive: true });
27496
27493
  for (const name of ["auth.json", ".env", "config.yaml"]) {
27497
- const source = join43(hostRoot, name);
27494
+ const source = join44(hostRoot, name);
27498
27495
  if (!await pathExists2(source)) continue;
27499
- await copyFile(source, join43(profileDir, name));
27496
+ await copyFile(source, join44(profileDir, name));
27500
27497
  }
27501
27498
  } else {
27502
27499
  await mkdir7(profileDir, { recursive: true });
@@ -13739,7 +13739,8 @@ function formatTerminalResult(result) {
13739
13739
  lines.push(`autoResumeCount ${encodeTerminalField(String(result.autoResumeCount))}`);
13740
13740
  }
13741
13741
  const payloads = result.roleOutcome.kind === "accepted" || result.roleOutcome.kind === "audit_escalation" ? result.roleOutcome.payloads ?? result.submissions ?? [] : result.roleOutcome.kind === "failure" ? result.roleOutcome.payloads ?? result.submissions ?? [] : result.submissions ?? [];
13742
- for (const payload of payloads) {
13742
+ for (let i = payloads.length - 1; i >= 0; i -= 1) {
13743
+ const payload = payloads[i];
13743
13744
  const rendered = typeof payload === "string" ? payload : JSON.stringify(payload);
13744
13745
  lines.push(`submission ${encodeTerminalField(rendered)}`);
13745
13746
  }
@@ -20913,7 +20914,7 @@ import { randomUUID as randomUUID10 } from "node:crypto";
20913
20914
 
20914
20915
  // src/role-runtime-dependencies.ts
20915
20916
  import { readFile as readFile22 } from "node:fs/promises";
20916
- import { fileURLToPath as fileURLToPath2 } from "node:url";
20917
+ import { join as join40 } from "node:path";
20917
20918
 
20918
20919
  // src/canonical-skill-binding.ts
20919
20920
  import { readFile, realpath } from "node:fs/promises";
@@ -26295,16 +26296,12 @@ function createRoleRuntimeExtension(dependencies) {
26295
26296
  // src/role-runtime-dependencies.ts
26296
26297
  init_auditor_soul();
26297
26298
  init_session_opening_materials();
26298
- var navigatorRoutePlaybookPath = fileURLToPath2(
26299
- new URL("../resources/navigator-route-playbook.md", import.meta.url)
26300
- );
26301
- var collectorHandbookSeedPath = fileURLToPath2(
26302
- new URL("../resources/collector-bot-handbook.md", import.meta.url)
26303
- );
26304
26299
  function loadPackagedRoleReferenceMaterials(role) {
26305
26300
  return role === "auditor" ? loadAuditorReferenceMaterialsFromSubjectInput() : loadMainRoleReferenceMaterials(role);
26306
26301
  }
26307
26302
  function createRoleRuntimeDependencies(packageRoot) {
26303
+ const navigatorRoutePlaybookPath = join40(packageRoot, "resources/navigator-route-playbook.md");
26304
+ const collectorHandbookSeedPath = join40(packageRoot, "resources/collector-bot-handbook.md");
26308
26305
  const doctorAuditor = createPiDoctorAuditor();
26309
26306
  const navigatorSessionFactory = createNativeNavigatorSessionFactory();
26310
26307
  return {
@@ -26372,8 +26369,8 @@ init_engine_detour();
26372
26369
  import { randomUUID as randomUUID8 } from "node:crypto";
26373
26370
  import { mkdir as mkdir6, writeFile as writeFile12 } from "node:fs/promises";
26374
26371
  import { createServer } from "node:net";
26375
- import { dirname as dirname24, join as join41 } from "node:path";
26376
- import { fileURLToPath as fileURLToPath3 } from "node:url";
26372
+ import { dirname as dirname24, join as join42 } from "node:path";
26373
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
26377
26374
 
26378
26375
  // src/gatekeeper-pass-envelope.ts
26379
26376
  init_archivist_record_entry();
@@ -26459,10 +26456,10 @@ async function requireGatekeeperPass(options) {
26459
26456
 
26460
26457
  // src/host-native-method.ts
26461
26458
  import { lstat as lstat7, mkdir as mkdir5, readlink, realpath as realpath7, symlink } from "node:fs/promises";
26462
- import { basename as basename9, dirname as dirname23, join as join40 } from "node:path";
26459
+ import { basename as basename9, dirname as dirname23, join as join41 } from "node:path";
26463
26460
  var HOST_METHOD_PLUGIN_NAME = "ak-methods";
26464
- var packagedMethodsDir = (root) => join40(root, "resources", "methods");
26465
- var packagedMethodPluginDir = (root) => join40(root, "dist", "method-host-plugin");
26461
+ var packagedMethodsDir = (root) => join41(root, "resources", "methods");
26462
+ var packagedMethodPluginDir = (root) => join41(root, "dist", "method-host-plugin");
26466
26463
  function hostMethodSkills(methods) {
26467
26464
  return Object.freeze(methods.flatMap((method) => {
26468
26465
  if (method.kind !== "skill") return [];
@@ -26492,7 +26489,7 @@ function applyCodexSkillInvocation(methods, prompt) {
26492
26489
  }
26493
26490
  async function installWorkspaceMethodSkills(cwd, packageRoot) {
26494
26491
  const target = await realpath7(packagedMethodsDir(packageRoot));
26495
- const link = join40(cwd, ".agents", "skills");
26492
+ const link = join41(cwd, ".agents", "skills");
26496
26493
  try {
26497
26494
  const stat2 = await lstat7(link);
26498
26495
  if (!stat2.isSymbolicLink() || await realpath7(link) !== target) {
@@ -26559,7 +26556,7 @@ async function prepareRoleEnvelope(options) {
26559
26556
  const hostAbort = new AbortController();
26560
26557
  const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID8();
26561
26558
  await mkdir6(request.runDirectory, { recursive: true });
26562
- let sessionFile = options.sessionFile ?? join41(request.runDirectory, "session", "session.jsonl");
26559
+ let sessionFile = options.sessionFile ?? join42(request.runDirectory, "session", "session.jsonl");
26563
26560
  await mkdir6(dirname24(sessionFile), { recursive: true });
26564
26561
  if (request.continuation.kind !== "resume") {
26565
26562
  try {
@@ -26887,7 +26884,7 @@ async function prepareRoleEnvelope(options) {
26887
26884
  }
26888
26885
  });
26889
26886
  }
26890
- const relay = fileURLToPath3(new URL("./mcp-relay.mjs", import.meta.url));
26887
+ const relay = fileURLToPath2(new URL("./mcp-relay.mjs", import.meta.url));
26891
26888
  await listen(server, options.socketPath);
26892
26889
  let disposed = false;
26893
26890
  const dispose = async () => {
@@ -27034,7 +27031,7 @@ async function prepareRoleEnvelope(options) {
27034
27031
  init_session_identity();
27035
27032
 
27036
27033
  // src/headless-host/description.ts
27037
- import { join as join42 } from "node:path";
27034
+ import { join as join43 } from "node:path";
27038
27035
  function isClaudePrintDescription(description) {
27039
27036
  return description.protocol === "claude-print";
27040
27037
  }
@@ -27042,7 +27039,7 @@ function isCodexExecDescription(description) {
27042
27039
  return description.protocol === "codex-exec";
27043
27040
  }
27044
27041
  function resolveHeadlessBinary(description, operatorHome) {
27045
- return join42(operatorHome, ...description.binaryFromHome);
27042
+ return join43(operatorHome, ...description.binaryFromHome);
27046
27043
  }
27047
27044
  function headlessTurnArgs(options) {
27048
27045
  const { description } = options;
@@ -27298,7 +27295,7 @@ import { spawn as spawn4, spawnSync } from "node:child_process";
27298
27295
  import { randomUUID as randomUUID9 } from "node:crypto";
27299
27296
  import { existsSync as existsSync13 } from "node:fs";
27300
27297
  import { writeFile as writeFile13 } from "node:fs/promises";
27301
- import { dirname as dirname25, isAbsolute as isAbsolute11, join as join43, resolve as resolve20 } from "node:path";
27298
+ import { dirname as dirname25, isAbsolute as isAbsolute11, join as join44, resolve as resolve20 } from "node:path";
27302
27299
 
27303
27300
  // src/external-host-turn-loop.ts
27304
27301
  init_host_contracts();
@@ -27517,7 +27514,7 @@ function formatCodexFailurePayload(payload) {
27517
27514
  function cwdIsGitWorkTree(cwd) {
27518
27515
  let dir = cwd;
27519
27516
  for (; ; ) {
27520
- if (existsSync13(join43(dir, ".git"))) return true;
27517
+ if (existsSync13(join44(dir, ".git"))) return true;
27521
27518
  const parent = dirname25(dir);
27522
27519
  if (parent === dir) return false;
27523
27520
  dir = parent;
@@ -27725,14 +27722,14 @@ function createHeadlessRoleTurnHost(config) {
27725
27722
  await config.sessionIdentity.bind(request.principal, sessionId);
27726
27723
  }
27727
27724
  const env = { ...process.env, ...config.env ?? {} };
27728
- const systemPromptPath = join43(request.runDirectory, "headless-system-prompt.txt");
27725
+ const systemPromptPath = join44(request.runDirectory, "headless-system-prompt.txt");
27729
27726
  await writeFile13(systemPromptPath, systemPrompt, "utf8");
27730
27727
  let mcpConfigPath;
27731
27728
  let outputSchemaPath;
27732
27729
  let pluginDir;
27733
27730
  let applyMethodPrompt = codex ? (prompt) => applyCodexSkillInvocation(request.methods, prompt) : (prompt) => prompt;
27734
27731
  if (codex) {
27735
- outputSchemaPath = join43(request.runDirectory, "headless-output-schema.json");
27732
+ outputSchemaPath = join44(request.runDirectory, "headless-output-schema.json");
27736
27733
  await writeFile13(
27737
27734
  outputSchemaPath,
27738
27735
  `${JSON.stringify(closeJsonSchemaForCodex(prepared.jsonSchema), null, 2)}
@@ -27740,7 +27737,7 @@ function createHeadlessRoleTurnHost(config) {
27740
27737
  "utf8"
27741
27738
  );
27742
27739
  } else {
27743
- mcpConfigPath = join43(request.runDirectory, "headless-mcp-config.json");
27740
+ mcpConfigPath = join44(request.runDirectory, "headless-mcp-config.json");
27744
27741
  await writeFile13(
27745
27742
  mcpConfigPath,
27746
27743
  `${JSON.stringify(headlessMcpConfigDocument(prepared.mcpServers), null, 2)}
@@ -24999,7 +24999,8 @@ function formatTerminalResult(result2) {
24999
24999
  lines.push(`autoResumeCount ${encodeTerminalField(String(result2.autoResumeCount))}`);
25000
25000
  }
25001
25001
  const payloads = result2.roleOutcome.kind === "accepted" || result2.roleOutcome.kind === "audit_escalation" ? result2.roleOutcome.payloads ?? result2.submissions ?? [] : result2.roleOutcome.kind === "failure" ? result2.roleOutcome.payloads ?? result2.submissions ?? [] : result2.submissions ?? [];
25002
- for (const payload of payloads) {
25002
+ for (let i = payloads.length - 1; i >= 0; i -= 1) {
25003
+ const payload = payloads[i];
25003
25004
  const rendered = typeof payload === "string" ? payload : JSON.stringify(payload);
25004
25005
  lines.push(`submission ${encodeTerminalField(rendered)}`);
25005
25006
  }
@@ -117,13 +117,15 @@ export function formatTerminalResult(result) {
117
117
  if (result.autoResumeCount !== undefined) {
118
118
  lines.push(`autoResumeCount\t${encodeTerminalField(String(result.autoResumeCount))}`);
119
119
  }
120
- // Role-result block: original payloads in ledger order (#836 / ADR 0052).
120
+ // Role-result block: original payloads, newest first for humans (#961).
121
+ // Typed payloads/submissions stay ledger order; only this presentation reverses.
121
122
  const payloads = result.roleOutcome.kind === "accepted" || result.roleOutcome.kind === "audit_escalation"
122
123
  ? result.roleOutcome.payloads ?? result.submissions ?? []
123
124
  : result.roleOutcome.kind === "failure"
124
125
  ? result.roleOutcome.payloads ?? result.submissions ?? []
125
126
  : result.submissions ?? [];
126
- for (const payload of payloads) {
127
+ for (let i = payloads.length - 1; i >= 0; i -= 1) {
128
+ const payload = payloads[i];
127
129
  const rendered = typeof payload === "string" ? payload : JSON.stringify(payload);
128
130
  lines.push(`submission\t${encodeTerminalField(rendered)}`);
129
131
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akagilnc/pi-workflow-roles",
3
- "version": "0.1.4518",
3
+ "version": "0.1.4524",
4
4
  "description": "Soul-bound workflow roles for Pi",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -312,14 +312,16 @@ export function formatTerminalResult(result: TerminalResult): string {
312
312
  if (result.autoResumeCount !== undefined) {
313
313
  lines.push(`autoResumeCount\t${encodeTerminalField(String(result.autoResumeCount))}`);
314
314
  }
315
- // Role-result block: original payloads in ledger order (#836 / ADR 0052).
315
+ // Role-result block: original payloads, newest first for humans (#961).
316
+ // Typed payloads/submissions stay ledger order; only this presentation reverses.
316
317
  const payloads =
317
318
  result.roleOutcome.kind === "accepted" || result.roleOutcome.kind === "audit_escalation"
318
319
  ? result.roleOutcome.payloads ?? result.submissions ?? []
319
320
  : result.roleOutcome.kind === "failure"
320
321
  ? result.roleOutcome.payloads ?? result.submissions ?? []
321
322
  : result.submissions ?? [];
322
- for (const payload of payloads) {
323
+ for (let i = payloads.length - 1; i >= 0; i -= 1) {
324
+ const payload = payloads[i]!;
323
325
  const rendered = typeof payload === "string" ? payload : JSON.stringify(payload);
324
326
  lines.push(`submission\t${encodeTerminalField(rendered)}`);
325
327
  }
@@ -1,5 +1,5 @@
1
1
  import { readFile } from "node:fs/promises";
2
- import { fileURLToPath } from "node:url";
2
+ import { join } from "node:path";
3
3
 
4
4
  import { loadCanonicalSkillBinding as loadHomeCanonicalSkillBinding } from "./canonical-skill-binding.ts";
5
5
  import { createGhCollectorGitHubTransport } from "./collector-github.ts";
@@ -20,13 +20,6 @@ import {
20
20
  loadMainRoleSessionMaterials,
21
21
  } from "./session-opening-materials.ts";
22
22
 
23
- const navigatorRoutePlaybookPath = fileURLToPath(
24
- new URL("../resources/navigator-route-playbook.md", import.meta.url),
25
- );
26
- const collectorHandbookSeedPath = fileURLToPath(
27
- new URL("../resources/collector-bot-handbook.md", import.meta.url),
28
- );
29
-
30
23
  /** Single packaged source for reference materials across production composition roots. */
31
24
  export function loadPackagedRoleReferenceMaterials(role: Parameters<NonNullable<RoleRuntimeDependencies["loadRoleReferenceMaterials"]>>[0]): Promise<string> {
32
25
  return role === "auditor"
@@ -36,6 +29,11 @@ export function loadPackagedRoleReferenceMaterials(role: Parameters<NonNullable<
36
29
 
37
30
  /** Host-neutral packaged role runtime deps for the parent-process envelope. */
38
31
  export function createRoleRuntimeDependencies(packageRoot: string): RoleRuntimeDependencies {
32
+ // packageRoot is the install root (resources/ lives there). Never resolve via
33
+ // import.meta.url — headless/acp production-host bundles live under dist/*/
34
+ // and would otherwise look for dist/resources/ (#962).
35
+ const navigatorRoutePlaybookPath = join(packageRoot, "resources/navigator-route-playbook.md");
36
+ const collectorHandbookSeedPath = join(packageRoot, "resources/collector-bot-handbook.md");
39
37
  const doctorAuditor = createPiDoctorAuditor();
40
38
  const navigatorSessionFactory = createNativeNavigatorSessionFactory();
41
39
  return {