@akagilnc/pi-workflow-roles 0.1.5368 → 0.1.5375

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 (165) hide show
  1. package/dist/acp-host/production-host.js +719 -776
  2. package/dist/activation-ledger-git.js +2 -2
  3. package/dist/activation-ledger-topology.js +1 -7
  4. package/dist/analyst-entry.js +4 -8
  5. package/dist/analyst-gate-cycles-read.js +3 -11
  6. package/dist/analyst-index.js +3 -9
  7. package/dist/analyst-ledger.js +1 -11
  8. package/dist/analyst-metric-families/acceptance-success-rework.js +1 -3
  9. package/dist/analyst-metric-families/round-timeline.js +1 -3
  10. package/dist/analyst-page.js +2 -2
  11. package/dist/archivist-record-topology.js +2 -2
  12. package/dist/audit-escalation.js +2 -1
  13. package/dist/auditor-soul.js +2 -1
  14. package/dist/collector-config.js +6 -8
  15. package/dist/compliance-transport.js +2 -1
  16. package/dist/countersign-contracts.js +2 -1
  17. package/dist/diarist-contracts.js +3 -2
  18. package/dist/doctor-contracts.js +1 -3
  19. package/dist/doctor-evidence.js +7 -8
  20. package/dist/dossier-resolution.js +1 -3
  21. package/dist/engine-detour-usage.js +1 -3
  22. package/dist/gatekeeper-role.js +2 -9
  23. package/dist/gleaner-left-contracts.js +2 -1
  24. package/dist/headless-host/description.js +14 -17
  25. package/dist/headless-host/production-host.js +721 -780
  26. package/dist/host-session-record.js +3 -2
  27. package/dist/inspector-contracts.js +2 -1
  28. package/dist/ledger-session-read.js +1 -3
  29. package/dist/merger-contracts.js +9 -9
  30. package/dist/migrate-book-topology.js +348 -314
  31. package/dist/navigator-attendance.js +9 -11
  32. package/dist/navigator-invocation-identity.js +3 -2
  33. package/dist/navigator-public-session.js +3 -5
  34. package/dist/navigator-session-contracts.js +8 -10
  35. package/dist/navigator-work-base.js +5 -8
  36. package/dist/notary-contracts.js +3 -5
  37. package/dist/package-contracts/auditor-output.js +1 -3
  38. package/dist/package-contracts/fixer-packet.js +3 -6
  39. package/dist/package-contracts/gatekeeper-output.js +1 -3
  40. package/dist/package-contracts/navigator-output.js +8 -8
  41. package/dist/package-contracts/terminating-infrastructure.js +5 -9
  42. package/dist/package-contracts/terminating-tools.js +4 -3
  43. package/dist/public-cli/analyst-run.js +3 -2
  44. package/dist/public-cli/auto-resume.js +3 -8
  45. package/dist/public-cli/cli.js +9 -8
  46. package/dist/public-cli/config.js +8 -11
  47. package/dist/public-cli/countersign-run.js +1 -3
  48. package/dist/public-cli/host-providers.js +7 -14
  49. package/dist/public-cli/instruction-seat-run.js +4 -3
  50. package/dist/public-cli/invocation.js +9 -8
  51. package/dist/public-cli/main.js +1531 -1567
  52. package/dist/public-cli/post-admission.js +4 -3
  53. package/dist/public-cli/run-lifecycle.js +14 -26
  54. package/dist/public-cli/settlement.js +10 -26
  55. package/dist/public-role-summons.js +3 -2
  56. package/dist/receipt-delivery-policy.js +1 -3
  57. package/dist/role-run-placement.js +3 -5
  58. package/dist/role-run-relocation.js +12 -19
  59. package/dist/run-terminal-artifacts.js +1 -11
  60. package/dist/run-ticket-number.js +2 -4
  61. package/dist/session-assistant-usage.js +2 -1
  62. package/dist/session-dialogue.js +1 -14
  63. package/dist/sitian-reader.js +2 -4
  64. package/dist/submission-correctable-error.js +2 -1
  65. package/dist/submission-errors.js +2 -1
  66. package/dist/submission-gate.js +2 -1
  67. package/dist/submission-ledger.js +4 -5
  68. package/dist/ticket-provenance-contracts.js +1 -3
  69. package/dist/ticket-provenance.js +2 -1
  70. package/dist/typed-provider-http.js +4 -7
  71. package/dist/unknown-value.js +28 -0
  72. package/dist/user-dialogue-stdin.js +2 -1
  73. package/package.json +1 -1
  74. package/src/acp-host/role-turn-host.ts +4 -2
  75. package/src/activation-ledger-git.ts +3 -2
  76. package/src/activation-ledger-topology.ts +4 -12
  77. package/src/analyst-entry.ts +3 -11
  78. package/src/analyst-gate-cycles-read.ts +3 -15
  79. package/src/analyst-index.ts +3 -13
  80. package/src/analyst-ledger.ts +2 -16
  81. package/src/analyst-metric-families/acceptance-success-rework.ts +2 -4
  82. package/src/analyst-metric-families/round-timeline.ts +2 -4
  83. package/src/analyst-page.ts +2 -2
  84. package/src/archivist-record-topology.ts +2 -2
  85. package/src/audit-escalation.ts +2 -1
  86. package/src/auditor-soul.ts +3 -1
  87. package/src/book-topology-migration-placement.ts +5 -16
  88. package/src/book-topology-migrators-t11.ts +16 -15
  89. package/src/book-topology-mixed-volume-migrators.ts +3 -6
  90. package/src/book-topology-record-class-migrators.ts +7 -10
  91. package/src/book-topology-runs-migrator.ts +4 -3
  92. package/src/collector-config.ts +7 -9
  93. package/src/compliance-transport.ts +2 -1
  94. package/src/countersign-contracts.ts +2 -1
  95. package/src/diarist-contracts.ts +3 -2
  96. package/src/doctor-contracts.ts +3 -1
  97. package/src/doctor-evidence.ts +8 -7
  98. package/src/doctor-role.ts +4 -2
  99. package/src/dossier-resolution.ts +2 -4
  100. package/src/engine-detour-tool.ts +0 -2
  101. package/src/engine-detour-usage.ts +2 -4
  102. package/src/external-host-turn-loop.ts +3 -1
  103. package/src/factory-board.ts +1 -8
  104. package/src/gatekeeper-role.ts +2 -10
  105. package/src/gleaner-left-contracts.ts +3 -1
  106. package/src/headless-host/description.ts +15 -18
  107. package/src/headless-host/role-turn-host.ts +10 -9
  108. package/src/host-session-record.ts +4 -2
  109. package/src/inspector-contracts.ts +2 -1
  110. package/src/ledger-session-read.ts +2 -5
  111. package/src/merger-contracts.ts +10 -9
  112. package/src/navigator-attendance.ts +10 -12
  113. package/src/navigator-invocation-identity.ts +3 -2
  114. package/src/navigator-public-session.ts +4 -6
  115. package/src/navigator-session-contracts.ts +8 -11
  116. package/src/navigator-work-base.ts +5 -8
  117. package/src/navigator-work-context.ts +2 -1
  118. package/src/notary-contracts.ts +4 -6
  119. package/src/oauth-keepalive.ts +5 -18
  120. package/src/package-contracts/auditor-output.ts +2 -4
  121. package/src/package-contracts/fixer-packet.ts +4 -6
  122. package/src/package-contracts/gatekeeper-output.ts +2 -4
  123. package/src/package-contracts/judge-output.ts +0 -1
  124. package/src/package-contracts/navigator-output.ts +8 -8
  125. package/src/package-contracts/terminating-infrastructure.ts +6 -20
  126. package/src/package-contracts/terminating-tools.ts +8 -12
  127. package/src/pi/adapter.ts +0 -1
  128. package/src/pi/role-turn-host.ts +0 -1
  129. package/src/public-cli/analyst-run.ts +4 -2
  130. package/src/public-cli/auto-resume.ts +4 -11
  131. package/src/public-cli/cli.ts +10 -10
  132. package/src/public-cli/config.ts +8 -27
  133. package/src/public-cli/countersign-run.ts +2 -4
  134. package/src/public-cli/host-providers.ts +10 -27
  135. package/src/public-cli/instruction-seat-run.ts +5 -3
  136. package/src/public-cli/invocation.ts +11 -10
  137. package/src/public-cli/post-admission.ts +5 -3
  138. package/src/public-cli/run-lifecycle.ts +20 -41
  139. package/src/public-cli/settlement.ts +11 -33
  140. package/src/public-role-summons.ts +4 -3
  141. package/src/receipt-delivery-policy.ts +1 -4
  142. package/src/reviewer-role.ts +0 -1
  143. package/src/role-envelope.ts +5 -3
  144. package/src/role-run-placement.ts +4 -10
  145. package/src/role-run-relocation.ts +13 -23
  146. package/src/role-runtime.ts +9 -15
  147. package/src/run-terminal-artifacts.ts +2 -16
  148. package/src/run-ticket-number.ts +4 -10
  149. package/src/session-assistant-usage.ts +3 -1
  150. package/src/session-dialogue.ts +1 -4
  151. package/src/session-identity.ts +0 -1
  152. package/src/sitian-reader.ts +2 -4
  153. package/src/submission-correctable-error.ts +3 -1
  154. package/src/submission-errors.ts +2 -1
  155. package/src/submission-gate.ts +3 -1
  156. package/src/submission-ledger.ts +5 -6
  157. package/src/ticket-provenance-contracts.ts +1 -4
  158. package/src/ticket-provenance.ts +3 -1
  159. package/src/ticket-snapshot.ts +2 -4
  160. package/src/ticket-trajectory.ts +1 -8
  161. package/src/typed-provider-http.ts +5 -15
  162. package/src/unknown-value.ts +34 -0
  163. package/src/user-dialogue-stdin.ts +3 -1
  164. package/src/worker-role.ts +2 -5
  165. package/src/worker-submission-gates.ts +5 -7
@@ -10,6 +10,7 @@
10
10
  */
11
11
  import { readFileSync } from "node:fs";
12
12
  import { join } from "node:path";
13
+ import { isEnoent, isRecord } from "../unknown-value.js";
13
14
  export function hostProvidersPath(home) {
14
15
  if (typeof home !== "string" || home.trim() === "") {
15
16
  throw new Error("home must be explicitly provided");
@@ -21,7 +22,7 @@ export function hermesProviderModelsCachePath(home) {
21
22
  return join(home, ".hermes", "provider_models_cache.json");
22
23
  }
23
24
  export function parseHostProvidersTable(value) {
24
- if (value === null || typeof value !== "object" || Array.isArray(value)) {
25
+ if (!isRecord(value)) {
25
26
  throw new Error("host-providers.json must be an object");
26
27
  }
27
28
  const out = {};
@@ -29,9 +30,7 @@ export function parseHostProvidersTable(value) {
29
30
  if (host.trim() === "") {
30
31
  throw new Error("host-providers.json host key must be non-empty");
31
32
  }
32
- if (byProvider === null ||
33
- typeof byProvider !== "object" ||
34
- Array.isArray(byProvider)) {
33
+ if (!isRecord(byProvider)) {
35
34
  throw new Error(`host-providers.json[${host}] must be an object`);
36
35
  }
37
36
  const providers = {};
@@ -61,11 +60,8 @@ export function loadHostProvidersTable(home) {
61
60
  return parseHostProvidersTable(JSON.parse(raw));
62
61
  }
63
62
  catch (error) {
64
- if (error instanceof Error &&
65
- "code" in error &&
66
- error.code === "ENOENT") {
63
+ if (isEnoent(error))
67
64
  return {};
68
- }
69
65
  throw error;
70
66
  }
71
67
  }
@@ -86,20 +82,17 @@ export function listHermesProvidersForModel(home, seatModel) {
86
82
  text = readFileSync(path, "utf8");
87
83
  }
88
84
  catch (error) {
89
- if (error instanceof Error &&
90
- "code" in error &&
91
- error.code === "ENOENT") {
85
+ if (isEnoent(error))
92
86
  return [];
93
- }
94
87
  throw error;
95
88
  }
96
89
  const raw = JSON.parse(text);
97
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
90
+ if (!isRecord(raw)) {
98
91
  throw new Error(`hermes provider_models_cache.json must be an object: ${path}`);
99
92
  }
100
93
  const found = [];
101
94
  for (const [provider, entry] of Object.entries(raw)) {
102
- if (entry === null || typeof entry !== "object" || Array.isArray(entry)) {
95
+ if (!isRecord(entry)) {
103
96
  continue;
104
97
  }
105
98
  const models = entry.models;
@@ -34,6 +34,7 @@ import { warnMissingMethodSkills } from "./machine-method-skills.js";
34
34
  import { formatTerminalResult, isLawfulTypedTerminalOutcome, } from "./terminal.js";
35
35
  import { admittedSeatTurnDetails, projectPublicTurnAxes, projectRoleTurnRequest, requiredMethodSkills, } from "./turn-request.js";
36
36
  import { invokeCourtDiarist, latestPayloadEscalated, } from "./countersign-run.js";
37
+ import { isRecord, errorText } from "../unknown-value.js";
37
38
  const AUDITED_ROLES = new Set(["judge", "fixer", "coder", "secretariat", "countersign", "doctor"]);
38
39
  const SECRETARIAT_STATUS_REASK = "secretariatStatus 不是 converged、escalate 之一。请重新交卷,secretariatStatus 写明其一。";
39
40
  const COUNTERSIGN_STATUS_REASK = "status 不是 converged、continue、escalate 三态之一。请重新交卷,status 写明其一。";
@@ -74,7 +75,7 @@ function unreadablePostSubmissionStatus(admitted, terminal) {
74
75
  if (route === undefined)
75
76
  return undefined;
76
77
  const payload = terminal.roleOutcome.payloads?.at(-1);
77
- const status = payload !== null && typeof payload === "object" && !Array.isArray(payload)
78
+ const status = isRecord(payload)
78
79
  ? payload.status
79
80
  : undefined;
80
81
  return typeof status === "string" && route.statuses.has(status)
@@ -484,7 +485,7 @@ export async function runPublicInstructionSeat(argv, env, io, role, parseArgv) {
484
485
  auditorTicket = await readBoardTicketNumber(resolved.runDirectory);
485
486
  }
486
487
  catch (error) {
487
- presentStructuralRejection(new CliUsageError(error instanceof Error ? error.message : String(error)), io);
488
+ presentStructuralRejection(new CliUsageError(errorText(error)), io);
488
489
  return { exitCode: 2 };
489
490
  }
490
491
  if (auditorSource === undefined)
@@ -785,7 +786,7 @@ async function auditSubmittedRole(turn, env, io, passedOfficer, passedReceipt, p
785
786
  const accepted = turn.terminal.roleOutcome.payloads?.at(-1);
786
787
  if (accepted === undefined)
787
788
  throw new Error("accepted submission has no payload");
788
- const record = accepted !== null && typeof accepted === "object" && !Array.isArray(accepted)
789
+ const record = isRecord(accepted)
789
790
  ? accepted : undefined;
790
791
  const status = admitted.role === "secretariat" ? record?.secretariatStatus : record?.status;
791
792
  if (admitted.role === "secretariat" && status !== "converged" && status !== "escalate") {
@@ -27,6 +27,7 @@ import { NotarySourceRunError, resolveNotarySourceRunLocator, } from "../notary-
27
27
  import { appendEngineSessionMaterial, } from "../package-resources/engine-material.js";
28
28
  import { CliUsageError } from "./cli-errors.js";
29
29
  import { REJECTED_PUBLIC_SPELLINGS, createTypedOptionConsumer, evaluateAnalystModeOptionContract, optionsForOwner, resolveAnalystMode, } from "./option-definitions.js";
30
+ import { errorText, isRecord } from "../unknown-value.js";
30
31
  /** Issue a principal from the single authoritative role-run placement. */
31
32
  export function issueAdmissionPlacement(authority, request) {
32
33
  const ledgerHome = resolveActivationLedgerHome(request.home);
@@ -880,7 +881,7 @@ export async function admitPublicRole(role, parsed, env, override) {
880
881
  repository = parseCollectorRepository(parsed.repo);
881
882
  }
882
883
  catch (error) {
883
- const detail = error instanceof Error ? error.message : String(error);
884
+ const detail = errorText(error);
884
885
  throw new CliUsageError(detail, { cause: error });
885
886
  }
886
887
  }
@@ -895,7 +896,7 @@ export async function admitPublicRole(role, parsed, env, override) {
895
896
  manifestCanonicalJson = manifest.canonicalJson;
896
897
  }
897
898
  catch (error) {
898
- throw new CliUsageError(error instanceof Error ? error.message : String(error), { cause: error });
899
+ throw new CliUsageError(errorText(error), { cause: error });
899
900
  }
900
901
  }
901
902
  const manifestDigest = manifest.digest;
@@ -948,7 +949,7 @@ export async function admitPublicRole(role, parsed, env, override) {
948
949
  catch (error) {
949
950
  if (error instanceof CliUsageError)
950
951
  throw error;
951
- const detail = error instanceof Error ? error.message : String(error);
952
+ const detail = errorText(error);
952
953
  throw new CliUsageError(detail, { cause: error });
953
954
  }
954
955
  if (parsed.runs === undefined) {
@@ -966,7 +967,7 @@ export async function admitPublicRole(role, parsed, env, override) {
966
967
  catch (error) {
967
968
  if (error instanceof CliUsageError)
968
969
  throw error;
969
- const detail = error instanceof Error ? error.message : String(error);
970
+ const detail = errorText(error);
970
971
  throw new CliUsageError(`doctor case could not be constructed from retained evidence: ${detail}`, { cause: error });
971
972
  }
972
973
  frozenAttachments = await freezeAttachments(attachmentPaths, placed.attachmentsDirectory);
@@ -1322,7 +1323,7 @@ export async function materializeCountersignInvocation(admitted, options) {
1322
1323
  export async function loadAdmittedJudgeRequest(runDirectory) {
1323
1324
  try {
1324
1325
  const raw = JSON.parse(await readFile(join(runDirectory, "admitted-request.json"), "utf8"));
1325
- if (raw === null || typeof raw !== "object" || Array.isArray(raw))
1326
+ if (!isRecord(raw))
1326
1327
  return undefined;
1327
1328
  const record = raw;
1328
1329
  if (!packagedPublicInstructionSubject(record.role))
@@ -1354,7 +1355,7 @@ function parsePositivePrOption(raw) {
1354
1355
  return parseCollectorPrNumber(raw);
1355
1356
  }
1356
1357
  catch (error) {
1357
- throw new CliUsageError(error instanceof Error ? error.message : String(error), { cause: error });
1358
+ throw new CliUsageError(errorText(error), { cause: error });
1358
1359
  }
1359
1360
  }
1360
1361
  function parseRepoOption(raw) {
@@ -1396,7 +1397,7 @@ export function resolveGitHubRemoteRepository(projectRoot) {
1396
1397
  return parseCollectorRepository(ownerRepo);
1397
1398
  }
1398
1399
  catch (error) {
1399
- const detail = error instanceof Error ? error.message : String(error);
1400
+ const detail = errorText(error);
1400
1401
  throw new CliUsageError(detail, { cause: error });
1401
1402
  }
1402
1403
  }
@@ -1456,7 +1457,7 @@ export async function resolveDoctorCaseRunsPath(options) {
1456
1457
  real = await realpath(resolved);
1457
1458
  }
1458
1459
  catch (error) {
1459
- const detail = error instanceof Error ? error.message : String(error);
1460
+ const detail = errorText(error);
1460
1461
  throw new CliUsageError(`doctor --runs is not a readable retained runs root: ${detail}`, { cause: error });
1461
1462
  }
1462
1463
  const normalized = real.split(sep).join("/");