@akagilnc/pi-workflow-roles 0.1.4800 → 0.1.4870

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 (143) hide show
  1. package/dist/acp-host/production-host.js +19434 -18218
  2. package/dist/analyst-book-key.js +63 -0
  3. package/dist/analyst-cohort.js +167 -0
  4. package/dist/analyst-entry.js +320 -0
  5. package/dist/analyst-index.js +247 -0
  6. package/dist/analyst-ledger.js +561 -0
  7. package/dist/analyst-median.js +16 -0
  8. package/dist/analyst-metric-families/acceptance-success-rework.js +249 -0
  9. package/dist/analyst-metric-families/b2-frame-buckets-actions.js +189 -0
  10. package/dist/analyst-metric-families/gate-cycles.js +77 -0
  11. package/dist/analyst-metric-families/leg-wall-clock.js +56 -0
  12. package/dist/analyst-metric-families/round-timeline.js +126 -0
  13. package/dist/analyst-metric-families.js +23 -0
  14. package/dist/analyst-metric-family.js +11 -0
  15. package/dist/analyst-model-groups.js +135 -0
  16. package/dist/analyst-page.js +182 -0
  17. package/dist/atomic-write.js +23 -0
  18. package/dist/auditor-soul.js +1 -1
  19. package/dist/countersign-contracts.js +0 -2
  20. package/dist/diarist-contracts.js +0 -1
  21. package/dist/doctor-contracts.js +2 -2
  22. package/dist/gatekeeper-role.js +15 -16
  23. package/dist/gleaner-left-contracts.js +0 -2
  24. package/dist/headless-host/production-host.js +16967 -15749
  25. package/dist/host-contracts.js +0 -4
  26. package/dist/inspector-contracts.js +0 -2
  27. package/dist/institutional-resolution.js +4 -2
  28. package/dist/merger-contracts.js +0 -2
  29. package/dist/migrate-book-topology.js +3908 -3089
  30. package/dist/navigator-public-session.js +4 -3
  31. package/dist/notary-contracts.js +0 -2
  32. package/dist/package-contracts/auditor-output.js +0 -1
  33. package/dist/package-contracts/collector-output.js +0 -2
  34. package/dist/package-contracts/fixer-output.js +0 -2
  35. package/dist/package-contracts/gatekeeper-output.js +0 -2
  36. package/dist/package-contracts/judge-output.js +0 -2
  37. package/dist/package-contracts/navigator-output.js +0 -2
  38. package/dist/package-contracts/reviewer-output.js +0 -2
  39. package/dist/package-contracts/terminating-tools.js +32 -92
  40. package/dist/package-contracts/worker-output.js +0 -4
  41. package/dist/packaged-role-registry.js +518 -36
  42. package/dist/pi/role-turn-host.js +2 -1
  43. package/dist/public-cli/analyst-run.js +185 -0
  44. package/dist/public-cli/cli.js +885 -0
  45. package/dist/public-cli/config.js +12 -9
  46. package/dist/public-cli/countersign-run.js +4 -311
  47. package/dist/public-cli/instruction-seat-run.js +628 -158
  48. package/dist/public-cli/invocation.js +806 -1550
  49. package/dist/public-cli/main.js +6962 -9882
  50. package/dist/public-cli/option-definitions.js +51 -99
  51. package/dist/public-cli/post-admission.js +30 -2
  52. package/dist/public-cli/run-lifecycle.js +234 -353
  53. package/dist/public-cli/seat-ticket-binding.js +6 -0
  54. package/dist/public-cli/settlement.js +261 -675
  55. package/dist/public-cli/turn-request.js +76 -0
  56. package/dist/public-role-summons.js +38 -112
  57. package/dist/role-activation-flags.js +23 -45
  58. package/dist/secretariat-contracts.js +0 -2
  59. package/dist/session-identity.js +17 -8
  60. package/dist/session-opening-materials.js +3 -2
  61. package/extensions/role-runtime.ts +6 -80
  62. package/package.json +1 -1
  63. package/souls/coder.md +1 -2
  64. package/src/acp-host/role-turn-host.ts +4 -1
  65. package/src/analyst-metric-families/acceptance-success-rework.ts +3 -2
  66. package/src/auditor-role.ts +1 -2
  67. package/src/auditor-soul.ts +1 -1
  68. package/src/collector-role.ts +2 -2
  69. package/src/countersign-contracts.ts +0 -1
  70. package/src/countersign-role.ts +1 -1
  71. package/src/diarist-contracts.ts +0 -1
  72. package/src/diarist-role.ts +0 -1
  73. package/src/doctor-auditor.ts +1 -2
  74. package/src/doctor-contracts.ts +1 -1
  75. package/src/doctor-role.ts +3 -2
  76. package/src/external-host-turn-loop.ts +1 -1
  77. package/src/factory-board.ts +10 -7
  78. package/src/gatekeeper-role.ts +16 -10
  79. package/src/gleaner-left-contracts.ts +0 -1
  80. package/src/gleaner-left-role.ts +0 -1
  81. package/src/headless-host/role-turn-host.ts +7 -1
  82. package/src/host-contracts.ts +10 -6
  83. package/src/inspector-contracts.ts +0 -1
  84. package/src/inspector-role.ts +0 -2
  85. package/src/institutional-resolution.ts +6 -4
  86. package/src/judge-role.ts +3 -3
  87. package/src/merger-contracts.ts +0 -1
  88. package/src/merger-role.ts +2 -2
  89. package/src/navigator-public-session.ts +7 -6
  90. package/src/navigator-work-context.ts +6 -8
  91. package/src/notary-contracts.ts +0 -1
  92. package/src/notary-role.ts +2 -3
  93. package/src/package-contracts/auditor-output.ts +0 -1
  94. package/src/package-contracts/collector-output.ts +0 -1
  95. package/src/package-contracts/fixer-output.ts +0 -1
  96. package/src/package-contracts/gatekeeper-output.ts +0 -1
  97. package/src/package-contracts/judge-output.ts +0 -1
  98. package/src/package-contracts/navigator-output.ts +0 -1
  99. package/src/package-contracts/reviewer-output.ts +0 -1
  100. package/src/package-contracts/terminating-tools.ts +27 -99
  101. package/src/package-contracts/worker-output.ts +0 -2
  102. package/src/packaged-role-registry.ts +604 -35
  103. package/src/pi/role-turn-host.ts +2 -1
  104. package/src/public-cli/cli.ts +64 -259
  105. package/src/public-cli/config.ts +18 -10
  106. package/src/public-cli/countersign-run.ts +14 -449
  107. package/src/public-cli/instruction-seat-run.ts +758 -277
  108. package/src/public-cli/invocation.ts +1097 -2051
  109. package/src/public-cli/option-definitions.ts +62 -127
  110. package/src/public-cli/post-admission.ts +47 -2
  111. package/src/public-cli/run-lifecycle.ts +303 -613
  112. package/src/public-cli/seat-ticket-binding.ts +6 -0
  113. package/src/public-cli/settlement.ts +399 -1185
  114. package/src/public-cli/turn-request.ts +92 -1
  115. package/src/public-role-summons.ts +44 -128
  116. package/src/reviewer-role.ts +3 -2
  117. package/src/role-activation-flags.ts +20 -41
  118. package/src/role-runtime-dependencies.ts +25 -26
  119. package/src/role-runtime.ts +121 -232
  120. package/src/secretariat-contracts.ts +0 -1
  121. package/src/secretariat-role.ts +0 -2
  122. package/src/session-identity.ts +23 -8
  123. package/src/session-opening-materials.ts +2 -1
  124. package/src/worker-role.ts +3 -4
  125. package/dist/doctor-auditor.js +0 -25
  126. package/dist/public-cli/diarist-run.js +0 -130
  127. package/dist/public-cli/doctor-run.js +0 -87
  128. package/dist/public-cli/inspector-run.js +0 -151
  129. package/dist/public-cli/judge-run.js +0 -114
  130. package/dist/public-cli/notary-run.js +0 -174
  131. package/dist/public-cli/reviewer-run.js +0 -339
  132. package/src/public-cli/coder-run.ts +0 -255
  133. package/src/public-cli/collector-run.ts +0 -189
  134. package/src/public-cli/diarist-run.ts +0 -233
  135. package/src/public-cli/doctor-run.ts +0 -167
  136. package/src/public-cli/fixer-run.ts +0 -265
  137. package/src/public-cli/gleaner-left-run.ts +0 -167
  138. package/src/public-cli/inspector-run.ts +0 -261
  139. package/src/public-cli/judge-run.ts +0 -196
  140. package/src/public-cli/merger-run.ts +0 -294
  141. package/src/public-cli/notary-run.ts +0 -279
  142. package/src/public-cli/reviewer-run.ts +0 -480
  143. package/src/public-cli/secretariat-run.ts +0 -265
@@ -1,167 +0,0 @@
1
- /**
2
- * Public Doctor Role run: admit Issue → retained case via #78 → shared post-admission
3
- * coordinator → settle Terminal result (#113 / #517). Lifecycle is the shared
4
- * post-admission seam; this module keeps only Doctor adapters.
5
- */
6
- import type { DurablePrincipalAuthority, RoleTurnRequest } from "../host-contracts.ts";
7
- import { engineSessionMaterialFromOptions, pickEngineAxis } from "../package-resources/engine-material.ts";
8
- import { CliUsageError } from "./cli-errors.ts";
9
- import {
10
- admitDoctorInvocation,
11
- buildDoctorTransportPrompt,
12
- type AdmittedDoctorInvocation,
13
- type ParseDoctorArgvResult
14
- } from "./invocation.ts";
15
- import {
16
- runPostAdmissionOneShot,
17
- type PostAdmissionAdapters,
18
- type PostAdmissionEnv,
19
- runPostAdmissionSeatResume,
20
- resumeTurnRequestProjectionOptions,
21
- } from "./post-admission.ts";
22
- import {
23
- loadResumableDoctorRun,
24
- markRunAdmitted,
25
- type PublicResumeRequest,
26
- } from "./run-lifecycle.ts";
27
- import {
28
- presentStructuralRejection,
29
- trySettleDoctorTerminalResult,
30
- } from "./settlement.ts";
31
- import type { CliIo } from "./cli-io.ts";
32
- import {
33
- isLawfulTypedTerminalOutcome,
34
- type TerminalResult,
35
- } from "./terminal.ts";
36
- import {
37
- projectRoleTurnRequest,
38
- type RoleTurnRequestProjectionOptions,
39
- } from "./turn-request.ts";
40
-
41
- export type DoctorRunEnv = PostAdmissionEnv & {
42
- principalAuthority: DurablePrincipalAuthority;
43
- createRunId?: () => string;
44
- };
45
-
46
- /** Project admitted invocation onto the host-neutral turn request. */
47
- export function buildDoctorTurnRequest(
48
- admitted: AdmittedDoctorInvocation,
49
- options: RoleTurnRequestProjectionOptions,
50
- ): RoleTurnRequest {
51
- return projectRoleTurnRequest(
52
- admitted,
53
- {
54
- activation: { role: "doctor" as const, casePath: admitted.caseRunsPath },
55
- },
56
- options,
57
- );
58
- }
59
-
60
- export async function runPublicDoctor(
61
- argv: readonly string[],
62
- env: DoctorRunEnv,
63
- io: CliIo,
64
- parseDoctorArgv: (args: readonly string[]) => ParseDoctorArgvResult,
65
- ): Promise<{
66
- exitCode: number;
67
- admitted?: AdmittedDoctorInvocation;
68
- terminal?: TerminalResult;
69
- }> {
70
- let admitted: AdmittedDoctorInvocation;
71
- try {
72
- const parsed = parseDoctorArgv(argv);
73
- admitted = await admitDoctorInvocation({
74
- home: env.home,
75
- principalAuthority: env.principalAuthority,
76
- cwd: env.cwd,
77
- issueNumber: parsed.issueNumber,
78
- instruction: parsed.instruction,
79
- attachmentPaths: parsed.attachmentPaths,
80
- ...(parsed.project === undefined ? {} : { project: parsed.project }),
81
- ...(parsed.runs === undefined ? {} : { runs: parsed.runs }),
82
- ...(env.createRunId === undefined ? {} : { createRunId: env.createRunId }),
83
- ...(env.model === undefined ? {} : { model: env.model }),
84
- });
85
- } catch (error) {
86
- if (error instanceof CliUsageError) {
87
- presentStructuralRejection(error, io);
88
- return { exitCode: 2 };
89
- }
90
- throw error;
91
- }
92
-
93
- await markRunAdmitted(admitted, env.principalAuthority);
94
-
95
- const turnRequest = buildDoctorTurnRequest(admitted, {
96
- packageRoot: env.packageRoot,
97
- home: env.home,
98
- agentDir: env.agentDir,
99
- ...(env.model === undefined ? {} : { model: env.model }),
100
- ...pickEngineAxis(env),
101
- ...(env.timeoutMs === undefined ? {} : { timeoutMs: env.timeoutMs }),
102
- ...(env.correlationId === undefined || env.correlationId.trim() === ""
103
- ? {}
104
- : { correlationId: env.correlationId }),
105
- continuation: {
106
- kind: "initial",
107
- prompt: buildDoctorTransportPrompt(
108
- admitted,
109
- engineSessionMaterialFromOptions({
110
- ...pickEngineAxis(env),
111
- packageRoot: env.packageRoot,
112
- }),
113
- ),
114
- },
115
- });
116
-
117
- return await runPostAdmissionOneShot({
118
- admitted,
119
- env,
120
- io,
121
- request: turnRequest,
122
- adapters: doctorAdapters(),
123
- ...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
124
- });
125
- }
126
-
127
- function doctorAdapters(): PostAdmissionAdapters<AdmittedDoctorInvocation> {
128
- return {
129
- trySettle: (admitted, authority, scope) =>
130
- trySettleDoctorTerminalResult(admitted, authority, scope),
131
- shouldPresentSettled: (terminal) =>
132
- isLawfulTypedTerminalOutcome(terminal.roleOutcome),
133
- };
134
- }
135
-
136
- /**
137
- * Resume a previously admitted Doctor run (#633). Issue + retained case
138
- * identity restore from the durable admitted request; the session principal reopens.
139
- */
140
- export async function runPublicDoctorResume(
141
- request: PublicResumeRequest,
142
- env: DoctorRunEnv,
143
- io: CliIo,
144
- ): Promise<{
145
- exitCode: number;
146
- admitted?: AdmittedDoctorInvocation;
147
- terminal?: TerminalResult;
148
- }> {
149
- return await runPostAdmissionSeatResume({
150
- request,
151
- env,
152
- io,
153
- load: (effective) =>
154
- loadResumableDoctorRun(
155
- env.home,
156
- effective.runId,
157
- env.principalAuthority,
158
- ),
159
- buildTurnRequest: (admitted, effective) =>
160
- buildDoctorTurnRequest(
161
- admitted,
162
- resumeTurnRequestProjectionOptions(admitted, effective, env),
163
- ),
164
- adapters: doctorAdapters(),
165
- ...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
166
- });
167
- }
@@ -1,265 +0,0 @@
1
- /**
2
- * Public Fixer Role run: admit → post-admission coordinator → settle Terminal result (#110 / #517).
3
- * #110/#177: package-owned diagnosing-bugs and tdd methods (available, not forced),
4
- * common Invocation + structural prerequisites, default apply / explicit plan,
5
- * shared #106 success interface. Controlled-failure settlement reuses #107.
6
- * #526: execution via RoleTurnHost; argv is Pi adapter internal.
7
- */
8
- import type {
9
- DurablePrincipalAuthority,
10
- MethodBinding,
11
- RoleTurnKnownFailure,
12
- RoleTurnRequest,
13
- } from "../host-contracts.ts";
14
- import { engineSessionMaterialFromOptions, pickEngineAxis } from "../package-resources/engine-material.ts";
15
- import {
16
- loadPackagedMethodSkillMaterial,
17
- resolvePackagedMethodSkillPath,
18
- type PackagedMethodSkillMaterial,
19
- type PackagedMethodSkillProvenance,
20
- } from "../package-resources/method-skill.ts";
21
- import { CliUsageError } from "./cli-errors.ts";
22
- import {
23
- admitFixerInvocation,
24
- buildFixerTransportPrompt,
25
- type AdmittedFixerInvocation,
26
- } from "./invocation.ts";
27
- import {
28
- buildAutoResumeContinuationPrompt,
29
- loadResumableFixerRun,
30
- markRunAdmitted,
31
- type PublicResumeRequest,
32
- } from "./run-lifecycle.ts";
33
- import {
34
- presentStructuralRejection,
35
- trySettleFixerTerminalResult,
36
- } from "./settlement.ts";
37
- import type { CliIo } from "./cli-io.ts";
38
- import type { TerminalResult } from "./terminal.ts";
39
- import {
40
- projectRoleTurnRequest,
41
- type RoleTurnRequestProjectionOptions,
42
- } from "./turn-request.ts";
43
- import {
44
- presentControlledFailure,
45
- resolveResumeMethodMaterialAdapters,
46
- runPostAdmissionResumable,
47
- runPostAdmissionSeatResume,
48
- type PostAdmissionAdapters,
49
- type PostAdmissionEnv,
50
- resumeTurnRequestProjectionOptions,
51
- } from "./post-admission.ts";
52
-
53
- export type FixerRunEnv = PostAdmissionEnv & {
54
- createRunId?: () => string;
55
- };
56
-
57
- function fixerMethods(packageRoot: string): readonly MethodBinding[] {
58
- return [
59
- { kind: "skill", path: resolvePackagedMethodSkillPath(packageRoot, "diagnosing-bugs") },
60
- { kind: "skill", path: resolvePackagedMethodSkillPath(packageRoot, "tdd") },
61
- ];
62
- }
63
-
64
- /** Project admitted Fixer invocation onto the host-neutral turn request. */
65
- export function buildFixerTurnRequest(
66
- admitted: AdmittedFixerInvocation,
67
- options: RoleTurnRequestProjectionOptions,
68
- ): RoleTurnRequest {
69
- return projectRoleTurnRequest(
70
- admitted,
71
- {
72
- activation: {
73
- role: "fixer",
74
- phase: admitted.phase,
75
- packetPath: admitted.packetPath,
76
- ...(admitted.prerequisitesPath === undefined
77
- ? {}
78
- : { prerequisitesPath: admitted.prerequisitesPath }),
79
- },
80
- methods: fixerMethods(options.packageRoot),
81
- },
82
- options,
83
- );
84
- }
85
-
86
- function fixerAdapters(
87
- packageRoot: string,
88
- methodMaterial?: PackagedMethodSkillMaterial,
89
- ): PostAdmissionAdapters<AdmittedFixerInvocation> {
90
- return {
91
- trySettle: (admitted, authority, scope) =>
92
- methodMaterial === undefined
93
- ? Promise.resolve(undefined)
94
- : trySettleFixerTerminalResult(
95
- admitted,
96
- authority,
97
- {
98
- methodProvenance: methodMaterial.provenance,
99
- methodSkillPath: methodMaterial.skillPath,
100
- methodSkillConfiguredPath: resolvePackagedMethodSkillPath(
101
- packageRoot,
102
- "diagnosing-bugs",
103
- ),
104
- },
105
- scope,
106
- ),
107
- };
108
- }
109
-
110
- async function loadFixerMethodMaterial(
111
- packageRoot: string,
112
- ): Promise<PackagedMethodSkillMaterial> {
113
- return await loadPackagedMethodSkillMaterial(packageRoot, "diagnosing-bugs");
114
- }
115
-
116
- export async function runPublicFixer(
117
- argv: readonly string[],
118
- env: FixerRunEnv,
119
- io: CliIo,
120
- parseFixerArgv: (args: readonly string[]) => {
121
- phase: "plan" | "apply";
122
- instruction: string;
123
- attachmentPaths: string[];
124
- prerequisitesPath?: string;
125
- project?: string;
126
- },
127
- ): Promise<{
128
- exitCode: number;
129
- admitted?: AdmittedFixerInvocation;
130
- terminal?: TerminalResult;
131
- }> {
132
- let admitted: AdmittedFixerInvocation;
133
- try {
134
- const parsed = parseFixerArgv(argv);
135
- admitted = await admitFixerInvocation({
136
- home: env.home,
137
- principalAuthority: env.principalAuthority,
138
- cwd: env.cwd,
139
- phase: parsed.phase,
140
- instruction: parsed.instruction,
141
- attachmentPaths: parsed.attachmentPaths,
142
- ...(parsed.prerequisitesPath === undefined
143
- ? {}
144
- : { prerequisitesPath: parsed.prerequisitesPath }),
145
- ...(parsed.project === undefined ? {} : { project: parsed.project }),
146
- ...(env.createRunId === undefined ? {} : { createRunId: env.createRunId }),
147
- ...(env.model === undefined ? {} : { model: env.model }),
148
- });
149
- } catch (error) {
150
- if (error instanceof CliUsageError) {
151
- presentStructuralRejection(error, io);
152
- return { exitCode: 2 };
153
- }
154
- throw error;
155
- }
156
-
157
- await markRunAdmitted(admitted, env.principalAuthority);
158
-
159
- let methodMaterial: PackagedMethodSkillMaterial;
160
- try {
161
- methodMaterial = await loadFixerMethodMaterial(env.packageRoot);
162
- } catch (error) {
163
- return (await presentControlledFailure(
164
- admitted,
165
- {
166
- timedOut: false,
167
- code: null,
168
- stderr: "",
169
- thrown: error,
170
- },
171
- fixerAdapters(env.packageRoot),
172
- env.principalAuthority,
173
- io,
174
- )) as { exitCode: number; admitted: AdmittedFixerInvocation; terminal: TerminalResult };
175
- }
176
-
177
- return await runPostAdmissionResumable({
178
- admitted,
179
- env,
180
- io,
181
- buildInitialRequest: () =>
182
- buildFixerTurnRequest(admitted, {
183
- packageRoot: env.packageRoot,
184
- home: env.home,
185
- agentDir: env.agentDir,
186
- ...(env.model === undefined ? {} : { model: env.model }),
187
- ...pickEngineAxis(env),
188
- ...(env.timeoutMs === undefined ? {} : { timeoutMs: env.timeoutMs }),
189
- ...(admitted.correlationId === undefined && env.correlationId === undefined
190
- ? {}
191
- : { correlationId: admitted.correlationId ?? env.correlationId }),
192
- continuation: {
193
- kind: "initial",
194
- prompt: buildFixerTransportPrompt(
195
- admitted,
196
- engineSessionMaterialFromOptions({
197
- ...pickEngineAxis(env),
198
- packageRoot: env.packageRoot,
199
- }),
200
- ),
201
- },
202
- }),
203
- buildResumeRequest: () =>
204
- buildFixerTurnRequest(admitted, {
205
- packageRoot: env.packageRoot,
206
- home: env.home,
207
- agentDir: env.agentDir,
208
- ...(env.model === undefined ? {} : { model: env.model }),
209
- ...pickEngineAxis(env),
210
- ...(env.timeoutMs === undefined ? {} : { timeoutMs: env.timeoutMs }),
211
- ...(admitted.correlationId === undefined && env.correlationId === undefined
212
- ? {}
213
- : { correlationId: admitted.correlationId ?? env.correlationId }),
214
- continuation: {
215
- kind: "resume",
216
- prompt: buildAutoResumeContinuationPrompt({
217
- packageRoot: env.packageRoot,
218
- ...pickEngineAxis(env),
219
- }),
220
- },
221
- }),
222
- adapters: fixerAdapters(env.packageRoot, methodMaterial),
223
- ...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
224
- });
225
- }
226
-
227
- /**
228
- * Resume a previously admitted Fixer Role run after a typed HTTP 429.
229
- * Restores role/phase/packet/prerequisites/session identity; model override is temporary.
230
- */
231
- export async function runPublicFixerResume(
232
- request: PublicResumeRequest,
233
- env: FixerRunEnv,
234
- io: CliIo,
235
- ): Promise<{
236
- exitCode: number;
237
- admitted?: AdmittedFixerInvocation;
238
- terminal?: TerminalResult;
239
- }> {
240
- return await runPostAdmissionSeatResume({
241
- request,
242
- env,
243
- io,
244
- load: (effective) =>
245
- loadResumableFixerRun(env.home, effective.runId, env.principalAuthority),
246
- buildTurnRequest: (admitted, effective) =>
247
- buildFixerTurnRequest(
248
- admitted,
249
- resumeTurnRequestProjectionOptions(admitted, effective, env),
250
- ),
251
- adapters: fixerAdapters(env.packageRoot),
252
- afterAdmittedLoad: (admitted) =>
253
- resolveResumeMethodMaterialAdapters({
254
- admitted,
255
- authority: env.principalAuthority,
256
- io,
257
- loadMaterial: () => loadFixerMethodMaterial(env.packageRoot),
258
- adaptersWith: (material) => fixerAdapters(env.packageRoot, material),
259
- emptyAdapters: fixerAdapters(env.packageRoot),
260
- }),
261
- ...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
262
- });
263
- }
264
-
265
- export type { RoleTurnKnownFailure, PackagedMethodSkillProvenance };
@@ -1,167 +0,0 @@
1
- /**
2
- * Public Gleaner-Left Role run: admit (instruction may be empty; --base required)
3
- * → shared post-admission coordinator → settle Terminal result (#502 / ADR 0067).
4
- * #599: manual resume continues the exact session; 只上弹章.
5
- */
6
- import type { DurablePrincipalAuthority, RoleTurnRequest } from "../host-contracts.ts";
7
- import { engineSessionMaterialFromOptions, pickEngineAxis } from "../package-resources/engine-material.ts";
8
- import { CliUsageError } from "./cli-errors.ts";
9
- import {
10
- admitGleanerLeftInvocation,
11
- buildGleanerLeftTransportPrompt,
12
- type AdmittedGleanerLeftInvocation,
13
- type ParseGleanerLeftArgvResult,
14
- } from "./invocation.ts";
15
- import {
16
- runPostAdmissionOneShot,
17
- type PostAdmissionEnv,
18
- runPostAdmissionSeatResume,
19
- resumeTurnRequestProjectionOptions,
20
- } from "./post-admission.ts";
21
- import {
22
- loadResumableGleanerLeftRun,
23
- markRunAdmitted,
24
- type PublicResumeRequest,
25
- } from "./run-lifecycle.ts";
26
- import {
27
- presentStructuralRejection,
28
- trySettleGleanerLeftTerminalResult,
29
- } from "./settlement.ts";
30
- import type { CliIo } from "./cli-io.ts";
31
- import type { TerminalResult } from "./terminal.ts";
32
- import {
33
- projectRoleTurnRequest,
34
- type RoleTurnRequestProjectionOptions,
35
- } from "./turn-request.ts";
36
-
37
- export type GleanerLeftRunEnv = PostAdmissionEnv & {
38
- principalAuthority: DurablePrincipalAuthority;
39
- createRunId?: () => string;
40
- };
41
-
42
- /** Project admitted invocation onto the host-neutral turn request. */
43
- export function buildGleanerLeftTurnRequest(
44
- admitted: AdmittedGleanerLeftInvocation,
45
- options: RoleTurnRequestProjectionOptions,
46
- ): RoleTurnRequest {
47
- return projectRoleTurnRequest(
48
- admitted,
49
- {
50
- activation: {
51
- role: "gleaner-left" as const,
52
- baseRevision: admitted.baseRevision,
53
- },
54
- },
55
- options,
56
- );
57
- }
58
-
59
- export async function runPublicGleanerLeft(
60
- argv: readonly string[],
61
- env: GleanerLeftRunEnv,
62
- io: CliIo,
63
- parseGleanerLeftArgv: (args: readonly string[]) => ParseGleanerLeftArgvResult,
64
- ): Promise<{
65
- exitCode: number;
66
- admitted?: AdmittedGleanerLeftInvocation;
67
- terminal?: TerminalResult;
68
- }> {
69
- let admitted: AdmittedGleanerLeftInvocation;
70
- try {
71
- const parsed = parseGleanerLeftArgv(argv);
72
- admitted = await admitGleanerLeftInvocation({
73
- home: env.home,
74
- principalAuthority: env.principalAuthority,
75
- cwd: env.cwd,
76
- instruction: parsed.instruction,
77
- baseRevision: parsed.baseRevision,
78
- ...(parsed.project === undefined ? {} : { project: parsed.project }),
79
- ...(env.createRunId === undefined ? {} : { createRunId: env.createRunId }),
80
- ...(env.model === undefined ? {} : { model: env.model }),
81
- ...(env.correlationId === undefined ? {} : { correlationId: env.correlationId }),
82
- });
83
- } catch (error) {
84
- if (error instanceof CliUsageError) {
85
- presentStructuralRejection(error, io);
86
- return { exitCode: 2 };
87
- }
88
- throw error;
89
- }
90
-
91
- await markRunAdmitted(admitted, env.principalAuthority);
92
-
93
- const turnRequest = buildGleanerLeftTurnRequest(admitted, {
94
- packageRoot: env.packageRoot,
95
- home: env.home,
96
- agentDir: env.agentDir,
97
- ...(env.model === undefined ? {} : { model: env.model }),
98
- ...pickEngineAxis(env),
99
- ...(env.timeoutMs === undefined ? {} : { timeoutMs: env.timeoutMs }),
100
- ...(env.correlationId === undefined || env.correlationId.trim() === ""
101
- ? {}
102
- : { correlationId: env.correlationId }),
103
- continuation: {
104
- kind: "initial",
105
- prompt: buildGleanerLeftTransportPrompt(
106
- admitted,
107
- engineSessionMaterialFromOptions({
108
- ...pickEngineAxis(env),
109
- packageRoot: env.packageRoot,
110
- }),
111
- ),
112
- },
113
- });
114
-
115
- return await runPostAdmissionOneShot({
116
- admitted,
117
- env,
118
- io,
119
- request: turnRequest,
120
- adapters: gleanerLeftAdapters(),
121
- ...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
122
- });
123
- }
124
-
125
- function gleanerLeftAdapters() {
126
- return {
127
- trySettle: (
128
- admitted: AdmittedGleanerLeftInvocation,
129
- authority: DurablePrincipalAuthority,
130
- scope?: { readonly courtAttemptId?: string },
131
- ) => trySettleGleanerLeftTerminalResult(admitted, authority, scope),
132
- shouldPresentSettled: () => true,
133
- };
134
- }
135
-
136
- /**
137
- * Resume a previously admitted Gleaner-Left run (#599 / DK-3).
138
- * Restores role/base/session identity; model override is temporary.
139
- */
140
- export async function runPublicGleanerLeftResume(
141
- request: PublicResumeRequest,
142
- env: GleanerLeftRunEnv,
143
- io: CliIo,
144
- ): Promise<{
145
- exitCode: number;
146
- admitted?: AdmittedGleanerLeftInvocation;
147
- terminal?: TerminalResult;
148
- }> {
149
- return await runPostAdmissionSeatResume({
150
- request,
151
- env,
152
- io,
153
- load: (effective) =>
154
- loadResumableGleanerLeftRun(
155
- env.home,
156
- effective.runId,
157
- env.principalAuthority,
158
- ),
159
- buildTurnRequest: (admitted, effective) =>
160
- buildGleanerLeftTurnRequest(
161
- admitted,
162
- resumeTurnRequestProjectionOptions(admitted, effective, env),
163
- ),
164
- adapters: gleanerLeftAdapters(),
165
- ...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
166
- });
167
- }