@akagilnc/pi-workflow-roles 0.1.3565 → 0.1.3621

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 (142) hide show
  1. package/README.md +4 -1
  2. package/README.zh-CN.md +1 -1
  3. package/dist/acp-host/production-host.js +18477 -8099
  4. package/dist/analyst-gate-cycles-read.js +387 -0
  5. package/dist/archivist-record-entry.js +22 -1
  6. package/dist/audit-escalation.js +6 -0
  7. package/dist/auditor-soul.js +74 -0
  8. package/dist/collector-config.js +86 -0
  9. package/dist/collector-evidence.js +316 -0
  10. package/dist/collector-github.js +527 -0
  11. package/dist/collector-ledger.js +853 -0
  12. package/dist/collector-tool-schemas.js +33 -0
  13. package/dist/compliance-transport.js +104 -52
  14. package/dist/diarist-contracts.js +72 -0
  15. package/dist/diarist-mechanical.js +411 -0
  16. package/dist/diarist-ticket-resolution.js +177 -0
  17. package/dist/diarist.js +311 -0
  18. package/dist/doctor-auditor.js +25 -0
  19. package/dist/doctor-contracts.js +2 -0
  20. package/dist/doctor-evidence.js +142 -0
  21. package/dist/gatekeeper-role.js +104 -81
  22. package/dist/host-transition-prior-native.js +78 -0
  23. package/dist/institutional-resolution.js +1 -95
  24. package/dist/judge-auditor.js +26 -0
  25. package/dist/ledger-session-read.js +227 -0
  26. package/dist/merger-git-state.js +78 -0
  27. package/dist/navigator-attendance.js +15 -7
  28. package/dist/navigator-public-session.js +170 -0
  29. package/dist/navigator-session-contracts.js +36 -40
  30. package/dist/notary-source-run.js +122 -0
  31. package/dist/package-contracts/auditor-output.js +66 -0
  32. package/dist/package-contracts/evidence-child-output.js +34 -0
  33. package/dist/package-contracts/judge-output.js +2 -0
  34. package/dist/package-contracts/terminating-tools.js +44 -3
  35. package/dist/package-resources/method-skill.js +254 -0
  36. package/dist/packaged-role-registry.js +56 -0
  37. package/dist/pi/durable-principal.js +61 -0
  38. package/dist/pi/in-process-session.js +25 -6
  39. package/dist/pi/known-failure.js +52 -0
  40. package/dist/pi/role-turn-host.js +430 -0
  41. package/dist/public-cli/auto-resume.js +414 -0
  42. package/dist/public-cli/cli-errors.js +8 -0
  43. package/dist/public-cli/cli-io.js +1 -0
  44. package/dist/public-cli/command-renderer.js +5 -0
  45. package/dist/public-cli/doctor-run.js +84 -0
  46. package/dist/public-cli/inspector-run.js +136 -0
  47. package/dist/public-cli/instruction-seat-run.js +256 -0
  48. package/dist/public-cli/invocation.js +2225 -0
  49. package/dist/public-cli/judge-run.js +118 -0
  50. package/dist/public-cli/load-production-acp-host.js +40 -0
  51. package/dist/public-cli/main.js +1511 -1124
  52. package/dist/public-cli/notary-run.js +161 -0
  53. package/dist/public-cli/option-definitions.js +1192 -0
  54. package/dist/public-cli/post-admission.js +667 -0
  55. package/dist/public-cli/public-run-credentials.js +49 -0
  56. package/dist/public-cli/registry.js +8 -2
  57. package/dist/public-cli/reviewer-dispatch-rejection.js +77 -0
  58. package/dist/public-cli/run-lifecycle.js +1344 -0
  59. package/dist/public-cli/seat-ticket-binding.js +113 -0
  60. package/dist/public-cli/settlement.js +3441 -0
  61. package/dist/public-cli/terminal.js +135 -0
  62. package/dist/public-cli/turn-request.js +25 -0
  63. package/dist/public-role-summons.js +301 -0
  64. package/dist/receipt-delivery-policy.js +10 -0
  65. package/dist/reviewer-child-executor.js +80 -8
  66. package/dist/reviewer-execution-ledger.js +2 -1
  67. package/dist/run-terminal-artifacts.js +195 -0
  68. package/dist/run-ticket-number.js +40 -0
  69. package/dist/session-assistant-usage.js +107 -0
  70. package/dist/shape-unreadable-failure.js +34 -0
  71. package/dist/submission-errors.js +3 -0
  72. package/dist/submission-ledger.js +388 -0
  73. package/dist/ticket-provenance-contracts.js +115 -0
  74. package/dist/ticket-provenance.js +340 -0
  75. package/extensions/role-runtime.ts +8 -0
  76. package/package.json +1 -1
  77. package/resources/diarist-collect.md +6 -10
  78. package/scripts/build-package.mjs +2 -1
  79. package/souls/diarist.md +9 -0
  80. package/souls/doctor-auditor.md +1 -0
  81. package/souls/evidence-child.md +1 -0
  82. package/src/acp-host/production-host.ts +4 -0
  83. package/src/acp-host/role-envelope.ts +4 -3
  84. package/src/acp-host/role-turn-host.ts +9 -1
  85. package/src/analyst-gate-cycles-read.ts +37 -2
  86. package/src/archivist-record-entry.ts +45 -1
  87. package/src/audit-escalation.ts +17 -0
  88. package/src/auditor-role.ts +22 -0
  89. package/src/auditor-soul.ts +42 -0
  90. package/src/compliance-transport.ts +177 -66
  91. package/src/diarist-contracts.ts +88 -0
  92. package/src/diarist-role.ts +60 -0
  93. package/src/diarist.ts +253 -179
  94. package/src/doctor-auditor.ts +10 -14
  95. package/src/doctor-contracts.ts +1 -0
  96. package/src/doctor-role.ts +2 -2
  97. package/src/evidence-child-role.ts +22 -0
  98. package/src/gatekeeper-pass-envelope.ts +109 -0
  99. package/src/gatekeeper-role.ts +145 -104
  100. package/src/host-contracts.ts +15 -2
  101. package/src/institutional-resolution.ts +8 -163
  102. package/src/judge-auditor.ts +10 -15
  103. package/src/judge-role.ts +8 -0
  104. package/src/navigator-attendance.ts +25 -9
  105. package/src/navigator-public-session.ts +217 -0
  106. package/src/navigator-session-contracts.ts +61 -54
  107. package/src/notary-source-run.ts +3 -1
  108. package/src/package-contracts/auditor-output.ts +82 -0
  109. package/src/package-contracts/evidence-child-output.ts +51 -0
  110. package/src/package-contracts/judge-output.ts +1 -0
  111. package/src/package-contracts/reviewer-output.ts +2 -2
  112. package/src/package-contracts/terminating-tools.ts +53 -3
  113. package/src/packaged-role-registry.ts +63 -0
  114. package/src/pi/adapter.ts +2 -1
  115. package/src/pi/in-process-session.ts +38 -12
  116. package/src/pi/role-turn-host.ts +42 -0
  117. package/src/public-cli/cli.ts +43 -6
  118. package/src/public-cli/countersign-run.ts +9 -129
  119. package/src/public-cli/diarist-run.ts +312 -0
  120. package/src/public-cli/instruction-seat-run.ts +289 -50
  121. package/src/public-cli/invocation.ts +87 -25
  122. package/src/public-cli/option-definitions.ts +79 -0
  123. package/src/public-cli/post-admission.ts +9 -3
  124. package/src/public-cli/registry.ts +7 -1
  125. package/src/public-cli/run-lifecycle.ts +53 -6
  126. package/src/public-cli/settlement.ts +170 -7
  127. package/src/public-cli/terminal.ts +4 -1
  128. package/src/public-role-summons.ts +431 -0
  129. package/src/receipt-delivery-policy.ts +10 -0
  130. package/src/reviewer-agent.ts +1 -1
  131. package/src/reviewer-child-executor.ts +114 -12
  132. package/src/reviewer-execution-ledger.ts +3 -2
  133. package/src/role-runtime.ts +275 -23
  134. package/src/session-assistant-usage.ts +119 -0
  135. package/src/session-opening-materials.ts +1 -1
  136. package/src/shape-unreadable-failure.ts +49 -0
  137. package/src/submission-errors.ts +3 -0
  138. package/src/ticket-provenance-contracts.ts +1 -0
  139. package/src/ticket-provenance.ts +0 -23
  140. package/dist/evidence-child-executor.js +0 -829
  141. package/src/diarist-llm-collector.ts +0 -324
  142. package/src/evidence-child-executor.ts +0 -1140
@@ -0,0 +1,118 @@
1
+ import { engineSessionMaterialFromOptions } from "../package-resources/engine-material.js";
2
+ import { CliUsageError } from "./cli-errors.js";
3
+ import { admitJudgeInvocation, buildJudgeTransportPrompt, } from "./invocation.js";
4
+ import { resolveSeatTicketBinding } from "./seat-ticket-binding.js";
5
+ import { loadResumableJudgeRun, markRunAdmitted, buildResumeContinuationPrompt, } from "./run-lifecycle.js";
6
+ import { presentStructuralRejection, readEngineDetourInfrastructureFailure, trySettleJudgeTerminalResult, } from "./settlement.js";
7
+ import { projectRoleTurnRequest, } from "./turn-request.js";
8
+ import { runPostAdmissionResumable, runPostAdmissionSeatResume, resumeTurnRequestProjectionOptions, } from "./post-admission.js";
9
+ /** Project admitted invocation onto the host-neutral turn request. */
10
+ export function buildJudgeTurnRequest(admitted, options) {
11
+ return projectRoleTurnRequest(admitted, { activation: { role: "judge" } }, options);
12
+ }
13
+ function judgeAdapters() {
14
+ return {
15
+ trySettle: (admitted, authority) => trySettleJudgeTerminalResult(admitted, authority),
16
+ resolveRunnerKnownFailure: async ({ result, sessionFile }) => {
17
+ const infrastructureFailure = await readEngineDetourInfrastructureFailure(sessionFile);
18
+ return (result.knownFailure ??
19
+ (infrastructureFailure === undefined
20
+ ? undefined
21
+ : {
22
+ cause: infrastructureFailure.cause,
23
+ diagnostic: infrastructureFailure.diagnostic,
24
+ ...(infrastructureFailure.identity === undefined
25
+ ? {}
26
+ : { identity: infrastructureFailure.identity }),
27
+ }));
28
+ },
29
+ };
30
+ }
31
+ export async function runPublicJudge(argv, env, io, parseJudgeArgv) {
32
+ let admitted;
33
+ try {
34
+ const parsed = parseJudgeArgv(argv);
35
+ admitted = await admitJudgeInvocation({
36
+ home: env.home,
37
+ principalAuthority: env.principalAuthority,
38
+ cwd: env.cwd,
39
+ instruction: parsed.instruction,
40
+ attachmentPaths: parsed.attachmentPaths,
41
+ ...(parsed.project === undefined ? {} : { project: parsed.project }),
42
+ ...(env.createRunId === undefined ? {} : { createRunId: env.createRunId }),
43
+ ...(env.model === undefined ? {} : { model: env.model }),
44
+ });
45
+ }
46
+ catch (error) {
47
+ if (error instanceof CliUsageError) {
48
+ presentStructuralRejection(error, io);
49
+ return { exitCode: 2 };
50
+ }
51
+ throw error;
52
+ }
53
+ await markRunAdmitted(admitted, env.principalAuthority);
54
+ return await runPostAdmissionResumable({
55
+ admitted,
56
+ env,
57
+ io,
58
+ buildInitialRequest: () => buildJudgeTurnRequest(admitted, {
59
+ packageRoot: env.packageRoot,
60
+ home: env.home,
61
+ agentDir: env.agentDir,
62
+ ...(env.model === undefined ? {} : { model: env.model }),
63
+ ...(env.engine === undefined ? {} : { engine: env.engine }),
64
+ ...(env.timeoutMs === undefined ? {} : { timeoutMs: env.timeoutMs }),
65
+ ...(admitted.correlationId === undefined && env.correlationId === undefined
66
+ ? {}
67
+ : { correlationId: admitted.correlationId ?? env.correlationId }),
68
+ continuation: {
69
+ kind: "initial",
70
+ prompt: buildJudgeTransportPrompt(admitted, engineSessionMaterialFromOptions({
71
+ ...(env.engine === undefined ? {} : { engine: env.engine }),
72
+ packageRoot: env.packageRoot,
73
+ })),
74
+ },
75
+ }),
76
+ buildResumeRequest: () => buildJudgeTurnRequest(admitted, {
77
+ packageRoot: env.packageRoot,
78
+ home: env.home,
79
+ agentDir: env.agentDir,
80
+ ...(env.model === undefined ? {} : { model: env.model }),
81
+ ...(env.engine === undefined ? {} : { engine: env.engine }),
82
+ ...(env.timeoutMs === undefined ? {} : { timeoutMs: env.timeoutMs }),
83
+ ...(admitted.correlationId === undefined && env.correlationId === undefined
84
+ ? {}
85
+ : { correlationId: admitted.correlationId ?? env.correlationId }),
86
+ continuation: {
87
+ kind: "resume",
88
+ prompt: buildResumeContinuationPrompt({
89
+ packageRoot: env.packageRoot,
90
+ ...(env.engine === undefined ? {} : { engine: env.engine }),
91
+ }),
92
+ },
93
+ }),
94
+ adapters: {
95
+ ...judgeAdapters(),
96
+ beforeDispatch: async (admittedSeat) => {
97
+ await resolveSeatTicketBinding(admittedSeat, env);
98
+ },
99
+ },
100
+ ...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
101
+ });
102
+ }
103
+ /**
104
+ * Resume a previously admitted Role run after a typed HTTP 429 interruption.
105
+ * Restores role/project/instruction/attachments/session identity; model override
106
+ * is temporary for this invocation only.
107
+ */
108
+ export async function runPublicResume(request, env, io) {
109
+ return await runPostAdmissionSeatResume({
110
+ request,
111
+ env,
112
+ io,
113
+ load: (effective) => loadResumableJudgeRun(env.home, effective.runId, env.principalAuthority),
114
+ buildTurnRequest: (admitted, effective) => buildJudgeTurnRequest(admitted, resumeTurnRequestProjectionOptions(admitted, effective, env)),
115
+ adapters: judgeAdapters(),
116
+ ...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
117
+ });
118
+ }
@@ -0,0 +1,40 @@
1
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
+ });
6
+ }
7
+ return path;
8
+ };
9
+ /**
10
+ * Deferred loader for the packaged generic ACP RoleTurnHost factory.
11
+ *
12
+ * Public ak-role bin must not statically value-import the production host (or its
13
+ * role-runtime / pi-coding-agent edges). Specifier is runtime-constructed so
14
+ * esbuild leaves this import external (ADR 0052 discovery stays peer-free).
15
+ *
16
+ * Host selection is a description-table lookup: the row for the seat's host key
17
+ * is the factory input. There is no host-name fork here.
18
+ */
19
+ import { existsSync } from "node:fs";
20
+ import { join } from "node:path";
21
+ import { pathToFileURL } from "node:url";
22
+ import { lookupHostDescription } from "../host-descriptions.js";
23
+ /**
24
+ * Resolve the production ACP host factory for one registered host key without a
25
+ * static graph edge into the public CLI bundle.
26
+ */
27
+ export async function loadProductionAcpHostFactory(packageRoot, host) {
28
+ const description = lookupHostDescription(host);
29
+ if (description === undefined) {
30
+ throw new Error(`unregistered host: ${host}`);
31
+ }
32
+ const built = join(packageRoot, "dist/acp-host/production-host.js");
33
+ const source = join(packageRoot, "src/acp-host/production-host.ts");
34
+ // Prefer the built artifact (plain node); fall back to source under tsx tests.
35
+ const target = existsSync(built) ? built : source;
36
+ const href = pathToFileURL(target).href;
37
+ const mod = (await import(__rewriteRelativeImportExtension(href)));
38
+ const create = mod.createProductionAcpRoleTurnHost;
39
+ return (options) => create({ ...options, description });
40
+ }