@akagilnc/pi-workflow-roles 0.1.3625 → 0.1.3631

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.
@@ -3207,6 +3207,7 @@ function notaryDecisiveFacts(output) {
3207
3207
  if (status === "pass" || status === "bounce") {
3208
3208
  const findings = output.findings;
3209
3209
  facts.findingsCount = Array.isArray(findings) ? findings.length : 0;
3210
+ facts.findings = Array.isArray(findings) ? findings : [];
3210
3211
  }
3211
3212
  if (status === "bounce") {
3212
3213
  facts.disposition = "rewrite";
@@ -4209,10 +4210,35 @@ var init_engine_material = __esm({
4209
4210
 
4210
4211
  // src/public-cli/run-lifecycle.ts
4211
4212
  import { chmod, open, readdir as readdir2, readFile as readFile8, unlink as unlink2, writeFile as writeFile3 } from "node:fs/promises";
4212
- import { join as join11 } from "node:path";
4213
+ import { isAbsolute as isAbsolute4, join as join11 } from "node:path";
4214
+ function resumeRereadInstruction(materialPath, handbook) {
4215
+ return handbook ? `\u91CD\u65B0\u8BFB ${materialPath}\uFF0C\u518D\u7EC4\u88C5\u5916\u5305 argv` : `\u91CD\u65B0\u8BFB ${materialPath}`;
4216
+ }
4217
+ function instructResumeHandbookRead(prompt, engineMaterial) {
4218
+ const handbookPath = engineMaterial?.materialPath;
4219
+ return prompt.split("\n").map((line2) => {
4220
+ if (!line2.startsWith("- ")) return line2;
4221
+ const value = line2.slice(2);
4222
+ if (handbookPath !== void 0 && value === handbookPath) {
4223
+ return resumeRereadInstruction(handbookPath, true);
4224
+ }
4225
+ if (isAbsolute4(value)) return resumeRereadInstruction(value, false);
4226
+ return line2;
4227
+ }).join("\n");
4228
+ }
4229
+ function appendResumeMaterialReread(prompt, materialPath) {
4230
+ const instruction = resumeRereadInstruction(materialPath, false);
4231
+ const lines = prompt.split("\n");
4232
+ if (lines.includes(instruction)) return prompt;
4233
+ return prompt.length === 0 ? instruction : `${prompt}
4234
+ ${instruction}`;
4235
+ }
4213
4236
  function selectResumeContinuationPrompt(message, engineMaterial) {
4214
4237
  const base = message !== void 0 ? message : RESUME_TRANSPORT_ENVELOPE;
4215
- return appendEngineSessionMaterial([base], engineMaterial).join("\n");
4238
+ return instructResumeHandbookRead(
4239
+ appendEngineSessionMaterial([base], engineMaterial).join("\n"),
4240
+ engineMaterial
4241
+ );
4216
4242
  }
4217
4243
  function buildResumeContinuationPrompt(options) {
4218
4244
  return selectResumeContinuationPrompt(
@@ -5083,7 +5109,7 @@ __export(notary_source_run_exports, {
5083
5109
  loadNotarySourceRunLocator: () => loadNotarySourceRunLocator,
5084
5110
  resolveNotarySourceRunLocator: () => resolveNotarySourceRunLocator
5085
5111
  });
5086
- import { dirname as dirname7, isAbsolute as isAbsolute4, join as join12, resolve as resolve8, basename as basename4 } from "node:path";
5112
+ import { dirname as dirname7, isAbsolute as isAbsolute5, join as join12, resolve as resolve8, basename as basename4 } from "node:path";
5087
5113
  import { lstat as lstat2, realpath as realpath4 } from "node:fs/promises";
5088
5114
  function parseRunDirectoryName(name) {
5089
5115
  const match = RUN_DIR_NAME.exec(name);
@@ -5135,7 +5161,7 @@ async function resolveNotarySourceRunLocator(options) {
5135
5161
  if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
5136
5162
  candidate = join12(bookRunsRoot, `${bare.runId}@${bare.role}`);
5137
5163
  } else {
5138
- candidate = isAbsolute4(raw) ? raw : resolve8(options.projectRoot, raw);
5164
+ candidate = isAbsolute5(raw) ? raw : resolve8(options.projectRoot, raw);
5139
5165
  }
5140
5166
  const real = await requireRunDirectory(candidate, raw);
5141
5167
  const identity = parseRunDirectoryName(basename4(real));
@@ -6278,7 +6304,7 @@ import {
6278
6304
  realpath as realpath5,
6279
6305
  writeFile as writeFile4
6280
6306
  } from "node:fs/promises";
6281
- import { basename as basename5, isAbsolute as isAbsolute5, join as join13, resolve as resolve9, sep as sep3 } from "node:path";
6307
+ import { basename as basename5, isAbsolute as isAbsolute6, join as join13, resolve as resolve9, sep as sep3 } from "node:path";
6282
6308
  function issueAdmissionPlacement(authority, request) {
6283
6309
  const principal = authority.issue(request);
6284
6310
  const { sessionDirectory, sessionFile } = authority.decode(principal);
@@ -6676,7 +6702,7 @@ function parseFixerArgv(args) {
6676
6702
  };
6677
6703
  }
6678
6704
  async function freezeRegularFileAttachment(sourcePath, destinationDir, index) {
6679
- const absolute = isAbsolute5(sourcePath) ? sourcePath : resolve9(sourcePath);
6705
+ const absolute = isAbsolute6(sourcePath) ? sourcePath : resolve9(sourcePath);
6680
6706
  let st;
6681
6707
  try {
6682
6708
  st = await lstat3(absolute);
@@ -7026,7 +7052,7 @@ async function admitFixerInvocation(options) {
7026
7052
  let prerequisites = Object.freeze([]);
7027
7053
  let prerequisitesSource;
7028
7054
  if (options.prerequisitesPath !== void 0) {
7029
- const absolutePrereq = isAbsolute5(options.prerequisitesPath) ? options.prerequisitesPath : resolve9(options.prerequisitesPath);
7055
+ const absolutePrereq = isAbsolute6(options.prerequisitesPath) ? options.prerequisitesPath : resolve9(options.prerequisitesPath);
7030
7056
  try {
7031
7057
  prerequisitesSource = await readFile9(absolutePrereq, "utf8");
7032
7058
  } catch (error) {
@@ -7451,7 +7477,7 @@ async function resolveDoctorCaseRunsPath(options) {
7451
7477
  if (raw === "") {
7452
7478
  throw new CliUsageError("doctor --runs requires a path");
7453
7479
  }
7454
- if (isAbsolute5(raw)) {
7480
+ if (isAbsolute6(raw)) {
7455
7481
  throw new CliUsageError(
7456
7482
  "doctor --runs must be a project-relative path"
7457
7483
  );
@@ -10634,7 +10660,7 @@ function failureReason(error) {
10634
10660
  }
10635
10661
  function asStringArray3(value) {
10636
10662
  if (!Array.isArray(value)) return [];
10637
- return value.filter((item) => typeof item === "string");
10663
+ return value.map((item) => typeof item === "string" ? item : JSON.stringify(item));
10638
10664
  }
10639
10665
  function isRecord14(value) {
10640
10666
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -16297,7 +16323,7 @@ var init_auto_resume = __esm({
16297
16323
  // src/public-cli/post-admission.ts
16298
16324
  import { randomUUID as randomUUID5 } from "node:crypto";
16299
16325
  import { readFile as readFile16, writeFile as writeFile7 } from "node:fs/promises";
16300
- import { isAbsolute as isAbsolute6, join as join26, resolve as resolve12 } from "node:path";
16326
+ import { isAbsolute as isAbsolute7, join as join26, resolve as resolve12 } from "node:path";
16301
16327
  async function readInvocationHost(runDirectory) {
16302
16328
  try {
16303
16329
  const raw = JSON.parse(await readFile16(join26(runDirectory, "invocation.json"), "utf8"));
@@ -16513,12 +16539,15 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
16513
16539
  let prompt;
16514
16540
  if (request.message !== void 0) {
16515
16541
  if (summonsPrepared !== void 0 && summonsPrepared.attachments.length > 0) {
16516
- prompt = buildInstructionTransportPrompt(
16517
- {
16518
- instruction: request.message,
16519
- instructionEmpty: false,
16520
- attachments: summonsPrepared.attachments
16521
- },
16542
+ prompt = instructResumeHandbookRead(
16543
+ buildInstructionTransportPrompt(
16544
+ {
16545
+ instruction: request.message,
16546
+ instructionEmpty: false,
16547
+ attachments: summonsPrepared.attachments
16548
+ },
16549
+ engineMaterial
16550
+ ),
16522
16551
  engineMaterial
16523
16552
  );
16524
16553
  } else {
@@ -16529,7 +16558,10 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
16529
16558
  });
16530
16559
  }
16531
16560
  } else if (summonsPrepared !== void 0) {
16532
- prompt = buildInstructionTransportPrompt(summonsPrepared, engineMaterial);
16561
+ prompt = instructResumeHandbookRead(
16562
+ buildInstructionTransportPrompt(summonsPrepared, engineMaterial),
16563
+ engineMaterial
16564
+ );
16533
16565
  } else {
16534
16566
  prompt = buildResumeContinuationPrompt({
16535
16567
  packageRoot: env.packageRoot,
@@ -16551,7 +16583,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
16551
16583
  };
16552
16584
  }
16553
16585
  function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
16554
- const absolute = isAbsolute6(attachmentPath) ? attachmentPath : resolve12(attachmentPath);
16586
+ const absolute = isAbsolute7(attachmentPath) ? attachmentPath : resolve12(attachmentPath);
16555
16587
  return pathContainedIn(join26(runDirectory, "attachments"), absolute);
16556
16588
  }
16557
16589
  async function prepareSummonsResumeMaterials(runDirectory, summons) {
@@ -16889,6 +16921,7 @@ __export(notary_run_exports, {
16889
16921
  runPublicNotary: () => runPublicNotary,
16890
16922
  runPublicNotaryResume: () => runPublicNotaryResume
16891
16923
  });
16924
+ import { existsSync as existsSync9 } from "node:fs";
16892
16925
  function buildNotaryTurnRequest(admitted, options) {
16893
16926
  return projectRoleTurnRequest(
16894
16927
  admitted,
@@ -17031,10 +17064,19 @@ async function runPublicNotaryResume(request, env, io) {
17031
17064
  }
17032
17065
  return loaded;
17033
17066
  },
17034
- buildTurnRequest: (admitted, effective) => buildNotaryTurnRequest(
17035
- admitted,
17036
- resumeTurnRequestProjectionOptions(admitted, effective, env)
17037
- ),
17067
+ buildTurnRequest: (admitted, effective) => {
17068
+ const projection = resumeTurnRequestProjectionOptions(
17069
+ admitted,
17070
+ effective,
17071
+ env
17072
+ );
17073
+ const candidatePath = gateSubmissionCandidatePath(admitted.sourceRunPath);
17074
+ const prompt = existsSync9(candidatePath) ? appendResumeMaterialReread(projection.continuation.prompt, candidatePath) : projection.continuation.prompt;
17075
+ return buildNotaryTurnRequest(admitted, {
17076
+ ...projection,
17077
+ continuation: { kind: "resume", prompt }
17078
+ });
17079
+ },
17038
17080
  adapters: notaryAdapters(),
17039
17081
  ...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
17040
17082
  });
@@ -17042,6 +17084,7 @@ async function runPublicNotaryResume(request, env, io) {
17042
17084
  var init_notary_run = __esm({
17043
17085
  "src/public-cli/notary-run.ts"() {
17044
17086
  "use strict";
17087
+ init_auditor_dossier_tool();
17045
17088
  init_notary_source_run();
17046
17089
  init_engine_material();
17047
17090
  init_run_ticket_number();
@@ -17719,7 +17762,7 @@ __export(public_role_summons_exports, {
17719
17762
  summonGateOfficer: () => summonGateOfficer,
17720
17763
  summonPublicRole: () => summonPublicRole
17721
17764
  });
17722
- import { existsSync as existsSync9 } from "node:fs";
17765
+ import { existsSync as existsSync10 } from "node:fs";
17723
17766
  import { join as join27 } from "node:path";
17724
17767
  function createCapturingIo() {
17725
17768
  const chunks = [];
@@ -17743,7 +17786,7 @@ function parentDir(path) {
17743
17786
  function walkPackageRoot(start) {
17744
17787
  let dir = start;
17745
17788
  for (let i = 0; i < 12; i += 1) {
17746
- if (existsSync9(join27(dir, "package.json")) && existsSync9(join27(dir, "souls"))) {
17789
+ if (existsSync10(join27(dir, "package.json")) && existsSync10(join27(dir, "souls"))) {
17747
17790
  return dir;
17748
17791
  }
17749
17792
  const parent = parentDir(dir);
@@ -18204,7 +18247,7 @@ __export(archivist_record_entry_exports, {
18204
18247
  createRecordSessionOpen: () => createRecordSessionOpen,
18205
18248
  subjectKeyedRecordDirectory: () => subjectKeyedRecordDirectory
18206
18249
  });
18207
- import { existsSync as existsSync10, mkdirSync as mkdirSync4, readFileSync as readFileSync5, realpathSync as realpathSync2, writeFileSync as writeFileSync5 } from "node:fs";
18250
+ import { existsSync as existsSync11, mkdirSync as mkdirSync4, readFileSync as readFileSync5, realpathSync as realpathSync2, writeFileSync as writeFileSync5 } from "node:fs";
18208
18251
  import { dirname as dirname13, resolve as resolve13, join as join29 } from "node:path";
18209
18252
  import { SessionManager } from "@earendil-works/pi-coding-agent";
18210
18253
  function readCurrentSession(sessionDir) {
@@ -18287,7 +18330,7 @@ function createRecordSessionOpen(options) {
18287
18330
  sessionDir = physicallyContainedIn(ledgerHome, parentResolved) ? join29(dirname13(parentResolved), options.kind) : join29(activationBookDirectory(ledgerHome, resolveBookKeyFromGit(cwd)), options.kind);
18288
18331
  parentSession = parentFile;
18289
18332
  }
18290
- const nestAlreadyExists = existsSync10(sessionDir);
18333
+ const nestAlreadyExists = existsSync11(sessionDir);
18291
18334
  ensureRealDirectoryTree(ledgerHome, sessionDir);
18292
18335
  const mayResumeSameNest = options.subject !== void 0 || options.kind === WORKER_SUBMISSION_GATE_KIND;
18293
18336
  if (mayResumeSameNest && nestAlreadyExists) {
@@ -18305,7 +18348,7 @@ function createRecordSessionOpen(options) {
18305
18348
  );
18306
18349
  if (session.isPersisted()) {
18307
18350
  const file = session.getSessionFile();
18308
- if (file !== void 0 && !existsSync10(file)) {
18351
+ if (file !== void 0 && !existsSync11(file)) {
18309
18352
  const header = session.getHeader();
18310
18353
  if (header !== null && header.type === "session") {
18311
18354
  writeFileSync5(file, `${JSON.stringify(header)}
@@ -19966,7 +20009,7 @@ import {
19966
20009
  openSync,
19967
20010
  writeSync
19968
20011
  } from "node:fs";
19969
- import { dirname as dirname16, isAbsolute as isAbsolute8, resolve as resolve17 } from "node:path";
20012
+ import { dirname as dirname16, isAbsolute as isAbsolute9, resolve as resolve17 } from "node:path";
19970
20013
 
19971
20014
  // src/activation-ledger-session.ts
19972
20015
  init_activation_ledger_topology();
@@ -19976,7 +20019,7 @@ import {
19976
20019
  statSync as statSync3,
19977
20020
  writeFileSync as writeFileSync6
19978
20021
  } from "node:fs";
19979
- import { isAbsolute as isAbsolute7, resolve as resolve16 } from "node:path";
20022
+ import { isAbsolute as isAbsolute8, resolve as resolve16 } from "node:path";
19980
20023
  var ActivationSessionFileMissingError = class extends Error {
19981
20024
  code = "AK_ACTIVATION_SESSION_FILE_MISSING";
19982
20025
  path;
@@ -20016,7 +20059,7 @@ function durableSessionPointer(sessionManager) {
20016
20059
  "Workflow role activation requires a durable Pi session file principal (getSessionFile); directory-only or --no-session invocations are rejected"
20017
20060
  );
20018
20061
  }
20019
- if (!isAbsolute7(file)) {
20062
+ if (!isAbsolute8(file)) {
20020
20063
  throw new Error(
20021
20064
  `Workflow role activation requires an absolute durable session file path; got relative path: ${file}`
20022
20065
  );
@@ -20108,7 +20151,7 @@ function serializeAcceptedActivationFact(fact) {
20108
20151
  `;
20109
20152
  }
20110
20153
  function appendActivationLedgerLine(ledgerPath, line2, options) {
20111
- if (!isAbsolute8(options.ledgerHome)) {
20154
+ if (!isAbsolute9(options.ledgerHome)) {
20112
20155
  throw new ActivationLedgerError(
20113
20156
  `activation ledger home must be absolute: ${options.ledgerHome}`
20114
20157
  );
@@ -21955,7 +21998,7 @@ init_sitian_facade();
21955
21998
  init_submission_errors();
21956
21999
  init_submission_errors();
21957
22000
  import { execFileSync as execFileSync4 } from "node:child_process";
21958
- import { existsSync as existsSync11, lstatSync as lstatSync3, readdirSync as readdirSync2, readFileSync as readFileSync6, rmdirSync, rmSync } from "node:fs";
22001
+ import { existsSync as existsSync12, lstatSync as lstatSync3, readdirSync as readdirSync2, readFileSync as readFileSync6, rmdirSync, rmSync } from "node:fs";
21959
22002
  import { resolve as resolve18 } from "node:path";
21960
22003
  var WORKER_SUBMISSION_GATE_RECORD_KIND = WORKER_SUBMISSION_GATE_KIND;
21961
22004
  var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
@@ -21986,7 +22029,7 @@ function statusOf(error) {
21986
22029
  return typeof error === "object" && error !== null && "status" in error ? error.status : void 0;
21987
22030
  }
21988
22031
  function tryGetAll(file, key) {
21989
- if (!existsSync11(file)) return [];
22032
+ if (!existsSync12(file)) return [];
21990
22033
  try {
21991
22034
  const out = gitFile(file, ["--get-all", key]);
21992
22035
  return out.length === 0 ? [] : out.split("\n");
@@ -21996,7 +22039,7 @@ function tryGetAll(file, key) {
21996
22039
  }
21997
22040
  }
21998
22041
  function ownedHook(path) {
21999
- if (!existsSync11(path)) return false;
22042
+ if (!existsSync12(path)) return false;
22000
22043
  return readFileSync6(path, "utf8").includes(HOOK_MARKER);
22001
22044
  }
22002
22045
  function escapeGitConfigValueRegex(value) {
@@ -22023,11 +22066,11 @@ function rmOwnedDir(dir) {
22023
22066
  const hookPath = resolve18(dir, HOOK_FILE);
22024
22067
  if (!ownedHook(hookPath)) return;
22025
22068
  rmSync(hookPath, { force: true });
22026
- if (existsSync11(dir) && readdirSync2(dir).length === 0) rmdirSync(dir);
22069
+ if (existsSync12(dir) && readdirSync2(dir).length === 0) rmdirSync(dir);
22027
22070
  }
22028
22071
  function linkedGitDirs(commonDir) {
22029
22072
  const root = resolve18(commonDir, "worktrees");
22030
- if (!existsSync11(root)) return [];
22073
+ if (!existsSync12(root)) return [];
22031
22074
  return readdirSync2(root).map((name) => resolve18(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
22032
22075
  }
22033
22076
  function uninstallPackageWorkerHooks(cwd) {
@@ -24625,13 +24668,11 @@ async function prepareAcpRoleEnvelope(options) {
24625
24668
  });
24626
24669
  reply(socket, rpc.id, {
24627
24670
  content: projected.content,
24628
- structuredContent: projected.details,
24629
24671
  isError: true
24630
24672
  });
24631
24673
  } catch {
24632
24674
  reply(socket, rpc.id, {
24633
24675
  content: declared.content,
24634
- structuredContent: declared.details,
24635
24676
  isError: true
24636
24677
  });
24637
24678
  }
@@ -24644,7 +24685,7 @@ async function prepareAcpRoleEnvelope(options) {
24644
24685
  details: result.details,
24645
24686
  isError: false
24646
24687
  });
24647
- reply(socket, rpc.id, { content: projected.content, structuredContent: projected.details, ...projected.isError ? { isError: true } : {} });
24688
+ reply(socket, rpc.id, { content: projected.content, ...projected.isError ? { isError: true } : {} });
24648
24689
  } catch (error) {
24649
24690
  let content;
24650
24691
  let details;
@@ -24668,7 +24709,7 @@ async function prepareAcpRoleEnvelope(options) {
24668
24709
  details,
24669
24710
  isError: true
24670
24711
  });
24671
- reply(socket, rpc.id, { content: projected.content, structuredContent: projected.details, ...projected.isError ? { isError: true } : {} });
24712
+ reply(socket, rpc.id, { content: projected.content, ...projected.isError ? { isError: true } : {} });
24672
24713
  }
24673
24714
  } catch (error) {
24674
24715
  reply(socket, rpc.id, void 0, error);
@@ -51,7 +51,9 @@ function failureReason(error) {
51
51
  function asStringArray(value) {
52
52
  if (!Array.isArray(value))
53
53
  return [];
54
- return value.filter((item) => typeof item === "string");
54
+ // Officer findings may be structured objects (category/law/evidence); the
55
+ // parent role must see them verbatim, not an empty list (#750 evidence).
56
+ return value.map((item) => (typeof item === "string" ? item : JSON.stringify(item)));
55
57
  }
56
58
  /** Serializable stand-in when the child tool call had no arguments object. */
57
59
  export const MISSING_ARGUMENTS_SUBMISSION = Object.freeze({ missing: "arguments" });
@@ -80,6 +80,7 @@ function notaryDecisiveFacts(output) {
80
80
  if (status === "pass" || status === "bounce") {
81
81
  const findings = output.findings;
82
82
  facts.findingsCount = Array.isArray(findings) ? findings.length : 0;
83
+ facts.findings = Array.isArray(findings) ? findings : [];
83
84
  }
84
85
  if (status === "bounce") {
85
86
  facts.disposition = "rewrite";