@akagilnc/pi-workflow-roles 0.1.2020 → 0.1.2033

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.
@@ -19,6 +19,7 @@ import {
19
19
  type AdmittedJudgeInvocation,
20
20
  } from "./invocation.ts";
21
21
  import {
22
+ buildSeatModelCliArgs,
22
23
  type CredentialProviders,
23
24
  type SeatModelConfig,
24
25
  } from "./config.ts";
@@ -89,17 +90,6 @@ export type JudgeRunEnv = {
89
90
  };
90
91
 
91
92
 
92
- function buildModelArgs(model: SeatModelConfig | undefined): string[] {
93
- if (model === undefined) return [];
94
- return [
95
- "--provider",
96
- model.provider,
97
- "--model",
98
- model.model,
99
- "--thinking",
100
- model.thinking,
101
- ];
102
- }
103
93
 
104
94
  /**
105
95
  * Build Internal activation extra-args for an admitted Judge run
@@ -129,7 +119,7 @@ export function buildJudgeActivationExtraArgs(
129
119
  "judge",
130
120
  "--mode",
131
121
  "json",
132
- ...buildModelArgs(options.model),
122
+ ...buildSeatModelCliArgs(options.model),
133
123
  prompt,
134
124
  ];
135
125
  }
@@ -160,7 +150,7 @@ export function buildJudgeResumeActivationExtraArgs(
160
150
  "judge",
161
151
  "--mode",
162
152
  "json",
163
- ...buildModelArgs(options.model),
153
+ ...buildSeatModelCliArgs(options.model),
164
154
  RESUME_TRANSPORT_ENVELOPE,
165
155
  ];
166
156
  }
@@ -276,7 +266,7 @@ async function dispatchAdmittedJudge(input: {
276
266
  io,
277
267
  );
278
268
  }
279
- await markRunRunning(admitted.runDirectory);
269
+ await markRunRunning(admitted.runDirectory, env.model);
280
270
  // Attempt-scoped observation: drop any prior dispatch's 429 evidence so only
281
271
  // the current initial/resume attempt can qualify v1 resume.
282
272
  await clearTypedProviderHttpObservation(admitted.runDirectory);
@@ -422,6 +412,7 @@ export async function runPublicJudge(
422
412
  attachmentPaths: parsed.attachmentPaths,
423
413
  ...(parsed.project === undefined ? {} : { project: parsed.project }),
424
414
  ...(env.createRunId === undefined ? {} : { createRunId: env.createRunId }),
415
+ ...(env.model === undefined ? {} : { model: env.model }),
425
416
  });
426
417
  } catch (error) {
427
418
  if (error instanceof CliUsageError) {
@@ -29,6 +29,7 @@ import {
29
29
  type AdmittedMergerInvocation,
30
30
  } from "./invocation.ts";
31
31
  import {
32
+ buildSeatModelCliArgs,
32
33
  type CredentialProviders,
33
34
  type SeatModelConfig,
34
35
  } from "./config.ts";
@@ -88,17 +89,6 @@ export type MergerRunEnv = {
88
89
  timeoutMs?: number;
89
90
  };
90
91
 
91
- function buildModelArgs(model: SeatModelConfig | undefined): string[] {
92
- if (model === undefined) return [];
93
- return [
94
- "--provider",
95
- model.provider,
96
- "--model",
97
- model.model,
98
- "--thinking",
99
- model.thinking,
100
- ];
101
- }
102
92
 
103
93
  /**
104
94
  * Build Internal activation extra-args for an admitted Merger run.
@@ -136,7 +126,7 @@ export function buildMergerActivationExtraArgs(
136
126
  admitted.mergerInputPath,
137
127
  "--mode",
138
128
  "json",
139
- ...buildModelArgs(options.model),
129
+ ...buildSeatModelCliArgs(options.model),
140
130
  prompt,
141
131
  ];
142
132
  }
@@ -175,7 +165,7 @@ export function buildMergerResumeActivationExtraArgs(
175
165
  admitted.mergerInputPath,
176
166
  "--mode",
177
167
  "json",
178
- ...buildModelArgs(options.model),
168
+ ...buildSeatModelCliArgs(options.model),
179
169
  RESUME_TRANSPORT_ENVELOPE,
180
170
  ];
181
171
  }
@@ -299,7 +289,7 @@ async function dispatchAdmittedMerger(input: {
299
289
  io,
300
290
  );
301
291
  }
302
- await markRunRunning(admitted.runDirectory);
292
+ await markRunRunning(admitted.runDirectory, env.model);
303
293
  await clearTypedProviderHttpObservation(admitted.runDirectory);
304
294
 
305
295
  const childEnv: NodeJS.ProcessEnv = {
@@ -516,6 +506,7 @@ export async function runPublicMerger(
516
506
  attachmentPaths: parsed.attachmentPaths,
517
507
  ...(parsed.project === undefined ? {} : { project: parsed.project }),
518
508
  ...(env.createRunId === undefined ? {} : { createRunId: env.createRunId }),
509
+ ...(env.model === undefined ? {} : { model: env.model }),
519
510
  });
520
511
  } catch (error) {
521
512
  if (error instanceof CliUsageError) {
@@ -49,7 +49,8 @@ export type PublicThinkingLevel =
49
49
  export type ModelRef = {
50
50
  provider: string;
51
51
  model: string;
52
- thinking: PublicThinkingLevel;
52
+ /** Absent when invocation passed bare provider/model — pi/model default applies. */
53
+ thinking?: PublicThinkingLevel;
53
54
  };
54
55
 
55
56
  /**
@@ -27,6 +27,7 @@ import {
27
27
  type AdmittedReviewerInvocation,
28
28
  } from "./invocation.ts";
29
29
  import {
30
+ buildSeatModelCliArgs,
30
31
  type CredentialProviders,
31
32
  type SeatModelConfig,
32
33
  } from "./config.ts";
@@ -88,17 +89,6 @@ export type ReviewerRunEnv = {
88
89
  timeoutMs?: number;
89
90
  };
90
91
 
91
- function buildModelArgs(model: SeatModelConfig | undefined): string[] {
92
- if (model === undefined) return [];
93
- return [
94
- "--provider",
95
- model.provider,
96
- "--model",
97
- model.model,
98
- "--thinking",
99
- model.thinking,
100
- ];
101
- }
102
92
 
103
93
  /** Encode admitted ticketNumber as CLI argv for activation/resume (no defaults). */
104
94
  function buildReviewerTicketNumberArgs(
@@ -152,7 +142,7 @@ export function buildReviewerActivationExtraArgs(
152
142
  ...ticketNumberArgs,
153
143
  "--mode",
154
144
  "json",
155
- ...buildModelArgs(options.model),
145
+ ...buildSeatModelCliArgs(options.model),
156
146
  prompt,
157
147
  ];
158
148
  }
@@ -198,7 +188,7 @@ export function buildReviewerResumeActivationExtraArgs(
198
188
  ...ticketNumberArgs,
199
189
  "--mode",
200
190
  "json",
201
- ...buildModelArgs(options.model),
191
+ ...buildSeatModelCliArgs(options.model),
202
192
  RESUME_TRANSPORT_ENVELOPE,
203
193
  ];
204
194
  }
@@ -306,7 +296,7 @@ async function dispatchAdmittedReviewer(input: {
306
296
  io,
307
297
  );
308
298
  }
309
- await markRunRunning(admitted.runDirectory);
299
+ await markRunRunning(admitted.runDirectory, env.model);
310
300
  await clearTypedProviderHttpObservation(admitted.runDirectory);
311
301
  await clearReviewerDispatchRejection(admitted.runDirectory);
312
302
 
@@ -463,6 +453,7 @@ export async function runPublicReviewer(
463
453
  authorityRefs: parsed.authorityRefs,
464
454
  ...(parsed.project === undefined ? {} : { project: parsed.project }),
465
455
  ...(env.createRunId === undefined ? {} : { createRunId: env.createRunId }),
456
+ ...(env.model === undefined ? {} : { model: env.model }),
466
457
  });
467
458
  } catch (error) {
468
459
  if (error instanceof CliUsageError) {
@@ -24,6 +24,7 @@ export {
24
24
  import type { FixerPhase } from "../package-contracts/fixer-output.ts";
25
25
  import type { FixerPrerequisite } from "../package-contracts/fixer-packet.ts";
26
26
  import {
27
+ recordEffectiveInvocationModel,
27
28
  requireAuthorityRef,
28
29
  type AdmittedCoderInvocation,
29
30
  type AdmittedFixerInvocation,
@@ -34,6 +35,7 @@ import {
34
35
  type CoderPhase,
35
36
  type DerivedMergerEnvelope,
36
37
  type FrozenAttachment,
38
+ type InvocationEffectiveModel,
37
39
  } from "./invocation.ts";
38
40
 
39
41
  /** Providers eligible for v1 typed-429 resume (Codex / xAI only). */
@@ -226,7 +228,18 @@ export async function markRunAdmitted(
226
228
  });
227
229
  }
228
230
 
229
- export async function markRunRunning(runDirectory: string): Promise<void> {
231
+ /**
232
+ * Shared dispatch execution seam: record the effective launch model (initial or
233
+ * resume override) onto invocation.json when known, then transition to running.
234
+ * Role runners must not coordinate lifecycle ledger writes themselves.
235
+ */
236
+ export async function markRunRunning(
237
+ runDirectory: string,
238
+ effectiveModel?: InvocationEffectiveModel,
239
+ ): Promise<void> {
240
+ if (effectiveModel !== undefined) {
241
+ await recordEffectiveInvocationModel(runDirectory, effectiveModel);
242
+ }
230
243
  const current = await readRoleRunState(runDirectory);
231
244
  if (current === undefined) {
232
245
  throw new Error("cannot mark running: run state missing");
@@ -288,11 +288,15 @@ async function readInvocation(runDir: string): Promise<InvocationInfo | undefine
288
288
  const info: InvocationInfo = {};
289
289
  if (typeof parsed.role === "string" && parsed.role.trim()) info.role = parsed.role.trim();
290
290
  if (typeof parsed.thinking === "string" && parsed.thinking.trim()) info.thinking = parsed.thinking.trim();
291
+ if (typeof parsed.provider === "string" && parsed.provider.trim()) {
292
+ info.provider = parsed.provider.trim();
293
+ }
291
294
  if (typeof parsed.model === "string" && parsed.model.trim()) {
292
295
  const rawModel = parsed.model.trim();
293
296
  if (rawModel.includes("/")) {
294
297
  const slash = rawModel.indexOf("/");
295
- info.provider = rawModel.slice(0, slash);
298
+ // Combined provider/model form (legacy pages).
299
+ if (info.provider === undefined) info.provider = rawModel.slice(0, slash);
296
300
  info.model = rawModel.slice(slash + 1);
297
301
  } else {
298
302
  info.model = rawModel;