@akagilnc/pi-workflow-roles 0.1.3886 → 0.1.3898

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.
@@ -19477,8 +19477,8 @@ var init_option_definitions = __esm({
19477
19477
  repeatable: false,
19478
19478
  form: "option",
19479
19479
  description: {
19480
- en: "Override the effective seat model for this invocation (before or after the command).",
19481
- zh: "\u8986\u76D6\u672C\u8C03\u7528\u6709\u6548\u5E2D\u4F4D\u6A21\u578B\uFF08\u53EF\u7F6E\u4E8E\u5B50\u547D\u4EE4\u524D\u6216\u540E\uFF09\u3002"
19480
+ en: "Override the effective seat model for this invocation (before or after the command name).",
19481
+ zh: "\u8986\u76D6\u672C\u8C03\u7528\u6709\u6548\u5E2D\u4F4D\u6A21\u578B\uFF08\u53EF\u7F6E\u4E8E\u5B50\u547D\u4EE4\u540D\u524D\u6216\u540E\uFF09\u3002"
19482
19482
  }
19483
19483
  },
19484
19484
  {
@@ -20196,13 +20196,14 @@ var init_option_definitions = __esm({
20196
20196
  },
20197
20197
  resume: {
20198
20198
  command: "resume",
20199
- summary: "Resume a role run under the live seat table (model/host/engine); session principal must still exist. [message] applies only to seats that accept caller instruction; Notary/\u7B26\u5B9D\u90CE must omit message and derives evidence from the existing source-run/dossier binding.",
20199
+ summary: "Resume a role run under the live seat table (model/host/engine); session principal must still exist. [message] applies only to seats that accept caller instruction; Notary/\u7B26\u5B9D\u90CE must omit message and derives evidence from the existing source-run/dossier binding. Global --model/--thinking/--host/--engine must be placed before <runId> (either before `resume` or between `resume` and <runId>); the one argv after <runId> is the opaque message, not a flag position (#471).",
20200
20200
  usage: ["ak-role resume <runId> [message]"],
20201
20201
  examples: [
20202
20202
  "ak-role resume 01abc\u2026",
20203
20203
  'ak-role resume 01abc\u2026 "owner ruling"',
20204
20204
  "ak-role --host grok-build resume 01abc\u2026",
20205
- "ak-role --engine agy resume 01abc\u2026"
20205
+ "ak-role --engine agy resume 01abc\u2026",
20206
+ 'ak-role resume --model xai/grok-4.5 01abc\u2026 "owner ruling"'
20206
20207
  ]
20207
20208
  },
20208
20209
  new: {
@@ -23236,7 +23237,6 @@ async function readSealedSubmission(cwd, runId, homeOrScope) {
23236
23237
  const scoped = recordsForAttempt(owned, scope.attemptId);
23237
23238
  for (let index = scoped.length - 1; index >= 0; index -= 1) {
23238
23239
  const record4 = scoped[index];
23239
- if (record4?.kind === "post-seal-anomaly") return void 0;
23240
23240
  if (record4?.kind !== "sealed") continue;
23241
23241
  const payload = record4.payload;
23242
23242
  if (payload?.type === "sealed" && isAcceptedProjection(payload.projection)) return payload.projection;
@@ -25206,8 +25206,8 @@ async function readLawfulSettlementEntries(sessionFile) {
25206
25206
  throw error instanceof Error && error.knownCause === "session" ? error : sessionReadFailure(error, "session unreadable");
25207
25207
  }
25208
25208
  }
25209
- async function readLawfulJudgeRoleOutcome(admitted, authority) {
25210
- const sealed = await sealedLedgerOutcome(admitted);
25209
+ async function readLawfulJudgeRoleOutcome(admitted, authority, scope) {
25210
+ const sealed = await sealedLedgerOutcome(admitted, scope);
25211
25211
  if (sealed?.role === "judge") {
25212
25212
  const details = sealed.decisiveFacts;
25213
25213
  return {
@@ -25218,10 +25218,10 @@ async function readLawfulJudgeRoleOutcome(admitted, authority) {
25218
25218
  decisiveFacts: withAuditNoReceiptFacts(details)
25219
25219
  };
25220
25220
  }
25221
- return auditEscalationLedgerOutcome(admitted, "judge");
25221
+ return auditEscalationLedgerOutcome(admitted, "judge", scope);
25222
25222
  }
25223
- async function settleLawfulJudgeTerminalResult(admitted, authority) {
25224
- const roleOutcome = await readLawfulJudgeRoleOutcome(admitted, authority);
25223
+ async function settleLawfulJudgeTerminalResult(admitted, authority, scope) {
25224
+ const roleOutcome = await readLawfulJudgeRoleOutcome(admitted, authority, scope);
25225
25225
  if (roleOutcome === void 0) return void 0;
25226
25226
  const coordinates = coordinatesFromAdmitted(authority, admitted);
25227
25227
  const entries = await readLawfulSettlementEntries(coordinates.sessionFile) ?? [];
@@ -25241,11 +25241,11 @@ async function settleLawfulJudgeTerminalResult(admitted, authority) {
25241
25241
  coordinates.sessionDirectory
25242
25242
  );
25243
25243
  }
25244
- async function trySettleJudgeTerminalResult(admitted, authority) {
25245
- return settleLawfulJudgeTerminalResult(admitted, authority);
25244
+ async function trySettleJudgeTerminalResult(admitted, authority, scope) {
25245
+ return settleLawfulJudgeTerminalResult(admitted, authority, scope);
25246
25246
  }
25247
- async function settleLawfulCoderTerminalResult(admitted, authority, options = {}) {
25248
- const ledgerOutcome = await closedLedgerOutcome(admitted, "coder");
25247
+ async function settleLawfulCoderTerminalResult(admitted, authority, options = {}, scope) {
25248
+ const ledgerOutcome = await closedLedgerOutcome(admitted, "coder", scope);
25249
25249
  if (ledgerOutcome === void 0) return void 0;
25250
25250
  const roleOutcome = ledgerOutcome;
25251
25251
  const output = ledgerOutcome.kind === "accepted" ? ledgerOutcome.decisiveFacts : void 0;
@@ -25355,8 +25355,8 @@ async function publishFixerArtifacts(admitted, roleOutcome, coordinates, options
25355
25355
  { kind: "evidence", path: evidencePath }
25356
25356
  ];
25357
25357
  }
25358
- async function settleLawfulFixerTerminalResult(admitted, authority, options) {
25359
- const ledgerOutcome = await closedLedgerOutcome(admitted, "fixer");
25358
+ async function settleLawfulFixerTerminalResult(admitted, authority, options, scope) {
25359
+ const ledgerOutcome = await closedLedgerOutcome(admitted, "fixer", scope);
25360
25360
  if (ledgerOutcome === void 0) return void 0;
25361
25361
  const roleOutcome = ledgerOutcome;
25362
25362
  const output = ledgerOutcome.kind === "accepted" ? ledgerOutcome.decisiveFacts : void 0;
@@ -25440,11 +25440,11 @@ async function publishCollectorArtifacts(admitted, roleOutcome, coordinates, opt
25440
25440
  { kind: "evidence", path: evidencePath }
25441
25441
  ];
25442
25442
  }
25443
- async function settleLawfulCollectorTerminalResult(admitted, authority) {
25443
+ async function settleLawfulCollectorTerminalResult(admitted, authority, scope) {
25444
25444
  const coordinates = coordinatesFromAdmitted(authority, admitted);
25445
25445
  const { sessionDirectory, sessionFile } = coordinates;
25446
25446
  const entries = await readLawfulSettlementEntries(sessionFile) ?? [];
25447
- const roleOutcome = await sealedLedgerOutcome(admitted);
25447
+ const roleOutcome = await sealedLedgerOutcome(admitted, scope);
25448
25448
  if (roleOutcome?.role !== "collector") {
25449
25449
  const scanStart = currentAttemptStartIndex(entries);
25450
25450
  for (let index = entries.length - 1; index >= scanStart; index -= 1) {
@@ -25495,8 +25495,8 @@ async function settleLawfulCollectorTerminalResult(admitted, authority) {
25495
25495
  sessionDirectory
25496
25496
  );
25497
25497
  }
25498
- async function trySettleCollectorTerminalResult(admitted, authority) {
25499
- return settleLawfulCollectorTerminalResult(admitted, authority);
25498
+ async function trySettleCollectorTerminalResult(admitted, authority, scope) {
25499
+ return settleLawfulCollectorTerminalResult(admitted, authority, scope);
25500
25500
  }
25501
25501
  async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
25502
25502
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
@@ -25548,13 +25548,13 @@ async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, option
25548
25548
  { kind: "evidence", path: evidencePath }
25549
25549
  ];
25550
25550
  }
25551
- async function settleLawfulDoctorTerminalResult(admitted, authority) {
25552
- const sealed = await sealedLedgerOutcome(admitted);
25551
+ async function settleLawfulDoctorTerminalResult(admitted, authority, scope) {
25552
+ const sealed = await sealedLedgerOutcome(admitted, scope);
25553
25553
  const coordinates = coordinatesFromAdmitted(authority, admitted);
25554
25554
  const { sessionDirectory, sessionFile } = coordinates;
25555
25555
  const entries = await readLawfulSettlementEntries(sessionFile) ?? [];
25556
25556
  if (sealed?.role !== "doctor") {
25557
- const escalation = await auditEscalationLedgerOutcome(admitted, "doctor");
25557
+ const escalation = await auditEscalationLedgerOutcome(admitted, "doctor", scope);
25558
25558
  if (escalation === void 0) return void 0;
25559
25559
  const artifacts2 = await publishDoctorArtifacts(admitted, escalation, coordinates);
25560
25560
  return withOptionalGateProjection(
@@ -25602,8 +25602,8 @@ async function settleLawfulDoctorTerminalResult(admitted, authority) {
25602
25602
  sessionDirectory
25603
25603
  );
25604
25604
  }
25605
- async function trySettleDoctorTerminalResult(admitted, authority) {
25606
- return settleLawfulDoctorTerminalResult(admitted, authority);
25605
+ async function trySettleDoctorTerminalResult(admitted, authority, scope) {
25606
+ return settleLawfulDoctorTerminalResult(admitted, authority, scope);
25607
25607
  }
25608
25608
  function currentAttemptStartIndex(entries) {
25609
25609
  for (let i = entries.length - 1; i >= 0; i -= 1) {
@@ -25737,11 +25737,11 @@ async function settleLawfulAuditorTerminalResult(admitted, authority, scope) {
25737
25737
  async function trySettleAuditorTerminalResult(admitted, authority, scope) {
25738
25738
  return settleLawfulAuditorTerminalResult(admitted, authority, scope);
25739
25739
  }
25740
- async function trySettleCoderTerminalResult(admitted, authority, options = {}) {
25741
- return settleLawfulCoderTerminalResult(admitted, authority, options);
25740
+ async function trySettleCoderTerminalResult(admitted, authority, options = {}, scope) {
25741
+ return settleLawfulCoderTerminalResult(admitted, authority, options, scope);
25742
25742
  }
25743
- async function trySettleFixerTerminalResult(admitted, authority, options) {
25744
- return settleLawfulFixerTerminalResult(admitted, authority, options);
25743
+ async function trySettleFixerTerminalResult(admitted, authority, options, scope) {
25744
+ return settleLawfulFixerTerminalResult(admitted, authority, options, scope);
25745
25745
  }
25746
25746
  function extractReviewerMethodInvocations(entries, options) {
25747
25747
  const observed = [];
@@ -25815,8 +25815,8 @@ async function publishReviewerArtifacts(admitted, roleOutcome, coordinates, opti
25815
25815
  { kind: "evidence", path: evidencePath }
25816
25816
  ];
25817
25817
  }
25818
- async function settleLawfulReviewerTerminalResult(admitted, authority, options) {
25819
- const sealed = await sealedLedgerOutcome(admitted);
25818
+ async function settleLawfulReviewerTerminalResult(admitted, authority, options, scope) {
25819
+ const sealed = await sealedLedgerOutcome(admitted, scope);
25820
25820
  if (sealed?.role !== "reviewer") return void 0;
25821
25821
  const coordinates = coordinatesFromAdmitted(authority, admitted);
25822
25822
  const { sessionDirectory, sessionFile } = coordinates;
@@ -25855,8 +25855,8 @@ async function settleLawfulReviewerTerminalResult(admitted, authority, options)
25855
25855
  sessionDirectory
25856
25856
  );
25857
25857
  }
25858
- async function trySettleReviewerTerminalResult(admitted, authority, options) {
25859
- return settleLawfulReviewerTerminalResult(admitted, authority, options);
25858
+ async function trySettleReviewerTerminalResult(admitted, authority, options, scope) {
25859
+ return settleLawfulReviewerTerminalResult(admitted, authority, options, scope);
25860
25860
  }
25861
25861
  function extractMergerMethodInvocations(entries, options) {
25862
25862
  const observed = [];
@@ -25926,16 +25926,16 @@ async function publishMergerArtifacts(admitted, roleOutcome, coordinates, option
25926
25926
  { kind: "evidence", path: evidencePath }
25927
25927
  ];
25928
25928
  }
25929
- async function settleLawfulMergerTerminalResult(admitted, authority, options) {
25929
+ async function settleLawfulMergerTerminalResult(admitted, authority, options, scope) {
25930
25930
  const coordinates = coordinatesFromAdmitted(authority, admitted);
25931
25931
  const { sessionDirectory, sessionFile } = coordinates;
25932
25932
  const entries = await readLawfulSettlementEntries(sessionFile) ?? [];
25933
- const roleOutcome = await sealedLedgerOutcome(admitted);
25933
+ const roleOutcome = await sealedLedgerOutcome(admitted, scope);
25934
25934
  if (roleOutcome?.role !== "merger") {
25935
25935
  const latestOutcome = await readLatestSubmissionOutcome(
25936
25936
  admitted.projectRoot,
25937
25937
  admitted.runId,
25938
- sealedLedgerHome(admitted)
25938
+ ledgerReadScope(admitted, scope)
25939
25939
  );
25940
25940
  if (latestOutcome?.outcome === "correctable-rejection" && latestOutcome.code === "non-sole-round") {
25941
25941
  return void 0;
@@ -25995,8 +25995,8 @@ async function settleLawfulMergerTerminalResult(admitted, authority, options) {
25995
25995
  sessionDirectory
25996
25996
  );
25997
25997
  }
25998
- async function trySettleMergerTerminalResult(admitted, authority, options) {
25999
- return settleLawfulMergerTerminalResult(admitted, authority, options);
25998
+ async function trySettleMergerTerminalResult(admitted, authority, options, scope) {
25999
+ return settleLawfulMergerTerminalResult(admitted, authority, options, scope);
26000
26000
  }
26001
26001
  function publicationAttemptFromError(path, error) {
26002
26002
  if (error instanceof Error) {
@@ -26385,7 +26385,8 @@ function projectRoleTurnRequest(admitted, roleDetails, options) {
26385
26385
  agentDir: options.agentDir,
26386
26386
  runDirectory: admitted.runDirectory,
26387
26387
  ...options.correlationId === void 0 || options.correlationId.trim() === "" ? {} : { correlationId: options.correlationId },
26388
- ...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
26388
+ ...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs },
26389
+ ...options.courtAttemptId === void 0 || options.courtAttemptId.length === 0 ? {} : { courtAttemptId: options.courtAttemptId }
26389
26390
  };
26390
26391
  }
26391
26392
  var init_turn_request = __esm({
@@ -26935,6 +26936,30 @@ async function readInvocationHost(runDirectory) {
26935
26936
  throw error;
26936
26937
  }
26937
26938
  }
26939
+ async function resolveResumeMethodMaterialAdapters(input) {
26940
+ if (input.shouldLoad === false) {
26941
+ return { kind: "continue", adapters: input.emptyAdapters };
26942
+ }
26943
+ try {
26944
+ const material = await input.loadMaterial();
26945
+ return { kind: "continue", adapters: input.adaptersWith(material) };
26946
+ } catch (error) {
26947
+ const terminal = await presentControlledFailure2(
26948
+ input.admitted,
26949
+ {
26950
+ timedOut: false,
26951
+ code: null,
26952
+ stderr: "",
26953
+ thrown: error,
26954
+ ...input.knownCause === void 0 ? {} : { knownCause: input.knownCause }
26955
+ },
26956
+ input.emptyAdapters,
26957
+ input.authority,
26958
+ input.io
26959
+ );
26960
+ return { kind: "terminal", ...terminal };
26961
+ }
26962
+ }
26938
26963
  async function presentControlledFailure2(admitted, failureInput, adapters, authority, io) {
26939
26964
  const hasThrown = Object.hasOwn(failureInput, "thrown");
26940
26965
  const resumeObservation = await resolveControlledFailureResumeObservation({
@@ -27186,7 +27211,8 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
27186
27211
  continuation: {
27187
27212
  kind: "resume",
27188
27213
  prompt
27189
- }
27214
+ },
27215
+ ...request.message === void 0 ? {} : { courtAttemptId: randomUUID5() }
27190
27216
  };
27191
27217
  }
27192
27218
  function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
@@ -27221,14 +27247,25 @@ async function runPostAdmissionSeatResume(input) {
27221
27247
  }
27222
27248
  throw error;
27223
27249
  }
27250
+ let adapters = input.adapters;
27251
+ if (input.afterAdmittedLoad !== void 0) {
27252
+ const prepared = await input.afterAdmittedLoad(loaded.admitted);
27253
+ if (prepared.kind === "terminal") {
27254
+ return {
27255
+ exitCode: prepared.exitCode,
27256
+ admitted: prepared.admitted,
27257
+ terminal: prepared.terminal
27258
+ };
27259
+ }
27260
+ adapters = prepared.adapters;
27261
+ }
27224
27262
  try {
27225
27263
  return await runPostAdmissionManualResume({
27226
27264
  admitted: loaded.admitted,
27227
27265
  env: input.env,
27228
27266
  io: input.io,
27229
- adapters: input.adapters,
27267
+ adapters,
27230
27268
  ...input.effectiveEngine === void 0 ? {} : { effectiveEngine: input.effectiveEngine },
27231
- forceContinuation: true,
27232
27269
  buildRequestAfterLease: async () => {
27233
27270
  let openCourtAttemptId;
27234
27271
  let admittedForBuild = loaded.admitted;
@@ -27280,7 +27317,7 @@ async function runPostAdmissionSeatResume(input) {
27280
27317
  }
27281
27318
  }
27282
27319
  let turnRequest = await input.buildTurnRequest(admittedForBuild, request);
27283
- if (openCourtAttemptId !== void 0 || request.summons !== void 0) {
27320
+ if (openCourtAttemptId !== void 0 || request.summons !== void 0 || request.message !== void 0) {
27284
27321
  const courtAttemptId = openCourtAttemptId ?? (turnRequest.courtAttemptId !== void 0 && turnRequest.courtAttemptId.length > 0 ? turnRequest.courtAttemptId : randomUUID5());
27285
27322
  turnRequest = { ...turnRequest, courtAttemptId };
27286
27323
  if (openCourtAttemptId === void 0) {
@@ -27353,38 +27390,6 @@ async function runPostAdmissionResumable(input) {
27353
27390
  })
27354
27391
  });
27355
27392
  }
27356
- async function presentSealedAcceptedManualResumeIfAny(input) {
27357
- const { admitted, env, io, adapters, shouldPresent } = input;
27358
- try {
27359
- const existing = await adapters.trySettle(admitted, env.principalAuthority);
27360
- if (existing !== void 0 && existing.roleOutcome.kind === "accepted" && shouldPresent(existing)) {
27361
- existing.autoResumeCount = 0;
27362
- io.stdout(formatTerminalResult(existing));
27363
- return {
27364
- exitCode: exitCodeForTerminalOutcome(existing.roleOutcome),
27365
- admitted,
27366
- terminal: existing
27367
- };
27368
- }
27369
- } catch (error) {
27370
- const disposition = await sealedAcceptanceRedispatchDisposition(admitted);
27371
- if (disposition.kind === "block") {
27372
- return await presentControlledFailure2(
27373
- admitted,
27374
- {
27375
- timedOut: false,
27376
- code: null,
27377
- stderr: "",
27378
- thrown: disposition.reason === "authority-failed" ? disposition.cause : error
27379
- },
27380
- adapters,
27381
- env.principalAuthority,
27382
- io
27383
- );
27384
- }
27385
- }
27386
- return void 0;
27387
- }
27388
27393
  async function runPostAdmissionManualResume(input) {
27389
27394
  const {
27390
27395
  admitted,
@@ -27392,25 +27397,10 @@ async function runPostAdmissionManualResume(input) {
27392
27397
  io,
27393
27398
  adapters,
27394
27399
  effectiveEngine,
27395
- forceContinuation,
27396
27400
  buildRequestAfterLease
27397
27401
  } = input;
27398
27402
  let request = input.request;
27399
27403
  const effectiveModel = env.model;
27400
- const shouldPresent = adapters.shouldPresentSettled ?? ((terminal) => isLawfulTypedTerminalOutcome(terminal.roleOutcome));
27401
- const sealedIdempotenceInput = {
27402
- admitted,
27403
- env,
27404
- io,
27405
- adapters,
27406
- shouldPresent
27407
- };
27408
- if (forceContinuation !== true && request !== void 0) {
27409
- const presented = await presentSealedAcceptedManualResumeIfAny(
27410
- sealedIdempotenceInput
27411
- );
27412
- if (presented !== void 0) return presented;
27413
- }
27414
27404
  let lease;
27415
27405
  let staleWriterLeaseReclaimed;
27416
27406
  try {
@@ -27437,17 +27427,6 @@ async function runPostAdmissionManualResume(input) {
27437
27427
  );
27438
27428
  }
27439
27429
  request = await buildRequestAfterLease();
27440
- if (request.courtAttemptId === void 0 || request.courtAttemptId.length === 0) {
27441
- const presented = await presentSealedAcceptedManualResumeIfAny(
27442
- sealedIdempotenceInput
27443
- );
27444
- if (presented !== void 0) {
27445
- return {
27446
- ...presented,
27447
- ...staleWriterLeaseReclaimed === true ? { staleWriterLeaseReclaimed: true } : {}
27448
- };
27449
- }
27450
- }
27451
27430
  }
27452
27431
  handedOffToDispatch = true;
27453
27432
  const result2 = await dispatchPostAdmissionTurn({
@@ -27515,9 +27494,14 @@ function buildCoderTurnRequest(admitted, options) {
27515
27494
  }
27516
27495
  function coderAdapters(methodProvenance) {
27517
27496
  return {
27518
- trySettle: (admitted, authority) => trySettleCoderTerminalResult(admitted, authority, {
27519
- ...methodProvenance === void 0 ? {} : { methodProvenance }
27520
- })
27497
+ trySettle: (admitted, authority, scope) => trySettleCoderTerminalResult(
27498
+ admitted,
27499
+ authority,
27500
+ {
27501
+ ...methodProvenance === void 0 ? {} : { methodProvenance }
27502
+ },
27503
+ scope
27504
+ )
27521
27505
  };
27522
27506
  }
27523
27507
  async function runPublicCoder(argv, env, io, parseCoderArgv2) {
@@ -27611,51 +27595,27 @@ async function runPublicCoder(argv, env, io, parseCoderArgv2) {
27611
27595
  });
27612
27596
  }
27613
27597
  async function runPublicCoderResume(request, env, io) {
27614
- let loaded;
27615
- try {
27616
- loaded = await loadResumableCoderRun(env.home, request.runId, env.principalAuthority);
27617
- } catch (error) {
27618
- if (error instanceof CliUsageError) {
27619
- presentStructuralRejection(error, io);
27620
- return { exitCode: 2 };
27621
- }
27622
- throw error;
27623
- }
27624
- const { admitted } = loaded;
27625
- let methodProvenance;
27626
- if (admitted.phase === "apply") {
27627
- try {
27628
- const material = await loadPackagedMethodSkillMaterial(
27629
- env.packageRoot,
27630
- "tdd"
27631
- );
27632
- methodProvenance = material.provenance;
27633
- } catch (error) {
27634
- return await presentControlledFailure2(
27635
- admitted,
27636
- {
27637
- timedOut: false,
27638
- code: null,
27639
- stderr: "",
27640
- thrown: error,
27641
- knownCause: "activation"
27642
- },
27643
- coderAdapters(),
27644
- env.principalAuthority,
27645
- io
27646
- );
27647
- }
27648
- }
27649
- const turnRequest = buildCoderTurnRequest(
27650
- admitted,
27651
- resumeTurnRequestProjectionOptions(admitted, request, env)
27652
- );
27653
- return await runPostAdmissionManualResume({
27654
- admitted,
27598
+ return await runPostAdmissionSeatResume({
27599
+ request,
27655
27600
  env,
27656
27601
  io,
27657
- request: turnRequest,
27658
- adapters: coderAdapters(methodProvenance),
27602
+ load: (effective) => loadResumableCoderRun(env.home, effective.runId, env.principalAuthority),
27603
+ buildTurnRequest: (admitted, effective) => buildCoderTurnRequest(
27604
+ admitted,
27605
+ resumeTurnRequestProjectionOptions(admitted, effective, env)
27606
+ ),
27607
+ adapters: coderAdapters(),
27608
+ // Apply-only method; plan resume keeps empty provenance (same as initial).
27609
+ afterAdmittedLoad: (admitted) => resolveResumeMethodMaterialAdapters({
27610
+ admitted,
27611
+ authority: env.principalAuthority,
27612
+ io,
27613
+ shouldLoad: admitted.phase === "apply",
27614
+ loadMaterial: () => loadPackagedMethodSkillMaterial(env.packageRoot, "tdd"),
27615
+ adaptersWith: (material) => coderAdapters(material.provenance),
27616
+ emptyAdapters: coderAdapters(),
27617
+ knownCause: "activation"
27618
+ }),
27659
27619
  ...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
27660
27620
  });
27661
27621
  }
@@ -28036,7 +27996,7 @@ async function runPublicCollector(argv, env, io, parseCollectorArgv2) {
28036
27996
  }
28037
27997
  function collectorAdapters() {
28038
27998
  return {
28039
- trySettle: (admitted, authority) => trySettleCollectorTerminalResult(admitted, authority),
27999
+ trySettle: (admitted, authority, scope) => trySettleCollectorTerminalResult(admitted, authority, scope),
28040
28000
  shouldPresentSettled: () => true,
28041
28001
  resolveRunnerKnownFailure: async ({ result: result2, sessionFile }) => {
28042
28002
  const infrastructureFailure = await readCollectorInfrastructureFailure(sessionFile);
@@ -28696,7 +28656,7 @@ async function runPublicDoctor(argv, env, io, parseDoctorArgv2) {
28696
28656
  }
28697
28657
  function doctorAdapters() {
28698
28658
  return {
28699
- trySettle: (admitted, authority) => trySettleDoctorTerminalResult(admitted, authority),
28659
+ trySettle: (admitted, authority, scope) => trySettleDoctorTerminalResult(admitted, authority, scope),
28700
28660
  shouldPresentSettled: (terminal) => isLawfulTypedTerminalOutcome(terminal.roleOutcome)
28701
28661
  };
28702
28662
  }
@@ -28756,14 +28716,19 @@ function buildFixerTurnRequest(admitted, options) {
28756
28716
  }
28757
28717
  function fixerAdapters(packageRoot2, methodMaterial) {
28758
28718
  return {
28759
- trySettle: (admitted, authority) => methodMaterial === void 0 ? Promise.resolve(void 0) : trySettleFixerTerminalResult(admitted, authority, {
28760
- methodProvenance: methodMaterial.provenance,
28761
- methodSkillPath: methodMaterial.skillPath,
28762
- methodSkillConfiguredPath: resolvePackagedMethodSkillPath(
28763
- packageRoot2,
28764
- "diagnosing-bugs"
28765
- )
28766
- })
28719
+ trySettle: (admitted, authority, scope) => methodMaterial === void 0 ? Promise.resolve(void 0) : trySettleFixerTerminalResult(
28720
+ admitted,
28721
+ authority,
28722
+ {
28723
+ methodProvenance: methodMaterial.provenance,
28724
+ methodSkillPath: methodMaterial.skillPath,
28725
+ methodSkillConfiguredPath: resolvePackagedMethodSkillPath(
28726
+ packageRoot2,
28727
+ "diagnosing-bugs"
28728
+ )
28729
+ },
28730
+ scope
28731
+ )
28767
28732
  };
28768
28733
  }
28769
28734
  async function loadFixerMethodMaterial(packageRoot2) {
@@ -28854,44 +28819,24 @@ async function runPublicFixer(argv, env, io, parseFixerArgv2) {
28854
28819
  });
28855
28820
  }
28856
28821
  async function runPublicFixerResume(request, env, io) {
28857
- let loaded;
28858
- try {
28859
- loaded = await loadResumableFixerRun(env.home, request.runId, env.principalAuthority);
28860
- } catch (error) {
28861
- if (error instanceof CliUsageError) {
28862
- presentStructuralRejection(error, io);
28863
- return { exitCode: 2 };
28864
- }
28865
- throw error;
28866
- }
28867
- const { admitted } = loaded;
28868
- let methodMaterial;
28869
- try {
28870
- methodMaterial = await loadFixerMethodMaterial(env.packageRoot);
28871
- } catch (error) {
28872
- return await presentControlledFailure2(
28873
- admitted,
28874
- {
28875
- timedOut: false,
28876
- code: null,
28877
- stderr: "",
28878
- thrown: error
28879
- },
28880
- fixerAdapters(env.packageRoot),
28881
- env.principalAuthority,
28882
- io
28883
- );
28884
- }
28885
- const turnRequest = buildFixerTurnRequest(
28886
- admitted,
28887
- resumeTurnRequestProjectionOptions(admitted, request, env)
28888
- );
28889
- return await runPostAdmissionManualResume({
28890
- admitted,
28822
+ return await runPostAdmissionSeatResume({
28823
+ request,
28891
28824
  env,
28892
28825
  io,
28893
- request: turnRequest,
28894
- adapters: fixerAdapters(env.packageRoot, methodMaterial),
28826
+ load: (effective) => loadResumableFixerRun(env.home, effective.runId, env.principalAuthority),
28827
+ buildTurnRequest: (admitted, effective) => buildFixerTurnRequest(
28828
+ admitted,
28829
+ resumeTurnRequestProjectionOptions(admitted, effective, env)
28830
+ ),
28831
+ adapters: fixerAdapters(env.packageRoot),
28832
+ afterAdmittedLoad: (admitted) => resolveResumeMethodMaterialAdapters({
28833
+ admitted,
28834
+ authority: env.principalAuthority,
28835
+ io,
28836
+ loadMaterial: () => loadFixerMethodMaterial(env.packageRoot),
28837
+ adaptersWith: (material) => fixerAdapters(env.packageRoot, material),
28838
+ emptyAdapters: fixerAdapters(env.packageRoot)
28839
+ }),
28895
28840
  ...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
28896
28841
  });
28897
28842
  }
@@ -29257,7 +29202,7 @@ function buildJudgeTurnRequest(admitted, options) {
29257
29202
  }
29258
29203
  function judgeAdapters() {
29259
29204
  return {
29260
- trySettle: (admitted, authority) => trySettleJudgeTerminalResult(admitted, authority),
29205
+ trySettle: (admitted, authority, scope) => trySettleJudgeTerminalResult(admitted, authority, scope),
29261
29206
  resolveRunnerKnownFailure: async ({ result: result2, sessionFile }) => {
29262
29207
  const infrastructureFailure = await readEngineDetourInfrastructureFailure(sessionFile);
29263
29208
  return result2.knownFailure ?? (infrastructureFailure === void 0 ? void 0 : {
@@ -29384,14 +29329,19 @@ function buildMergerTurnRequest(admitted, options) {
29384
29329
  }
29385
29330
  function mergerAdapters(packageRoot2, methodMaterial) {
29386
29331
  return {
29387
- trySettle: (admitted, authority) => methodMaterial === void 0 ? Promise.resolve(void 0) : trySettleMergerTerminalResult(admitted, authority, {
29388
- methodProvenance: methodMaterial.provenance,
29389
- methodSkillPath: methodMaterial.skillPath,
29390
- methodSkillConfiguredPath: resolvePackagedMethodSkillPath(
29391
- packageRoot2,
29392
- "resolving-merge-conflicts"
29393
- )
29394
- }),
29332
+ trySettle: (admitted, authority, scope) => methodMaterial === void 0 ? Promise.resolve(void 0) : trySettleMergerTerminalResult(
29333
+ admitted,
29334
+ authority,
29335
+ {
29336
+ methodProvenance: methodMaterial.provenance,
29337
+ methodSkillPath: methodMaterial.skillPath,
29338
+ methodSkillConfiguredPath: resolvePackagedMethodSkillPath(
29339
+ packageRoot2,
29340
+ "resolving-merge-conflicts"
29341
+ )
29342
+ },
29343
+ scope
29344
+ ),
29395
29345
  shouldPresentSettled: (t) => isLawfulTypedTerminalOutcome(t.roleOutcome) || t.roleOutcome.kind === "incomplete"
29396
29346
  };
29397
29347
  }
@@ -29499,45 +29449,25 @@ async function runPublicMerger(argv, env, io, parseMergerArgv2) {
29499
29449
  });
29500
29450
  }
29501
29451
  async function runPublicMergerResume(request, env, io) {
29502
- let loaded;
29503
- try {
29504
- loaded = await loadResumableMergerRun(env.home, request.runId, env.principalAuthority);
29505
- } catch (error) {
29506
- if (error instanceof CliUsageError) {
29507
- presentStructuralRejection(error, io);
29508
- return { exitCode: 2 };
29509
- }
29510
- throw error;
29511
- }
29512
- const { admitted } = loaded;
29513
- let methodMaterial;
29514
- try {
29515
- methodMaterial = await loadMergerMethodMaterial(env.packageRoot);
29516
- } catch (error) {
29517
- return await presentControlledFailure2(
29518
- admitted,
29519
- {
29520
- timedOut: false,
29521
- code: null,
29522
- stderr: "",
29523
- thrown: error,
29524
- knownCause: "activation"
29525
- },
29526
- mergerAdapters(env.packageRoot),
29527
- env.principalAuthority,
29528
- io
29529
- );
29530
- }
29531
- const turnRequest = buildMergerTurnRequest(
29532
- admitted,
29533
- resumeTurnRequestProjectionOptions(admitted, request, env)
29534
- );
29535
- return await runPostAdmissionManualResume({
29536
- admitted,
29452
+ return await runPostAdmissionSeatResume({
29453
+ request,
29537
29454
  env,
29538
29455
  io,
29539
- request: turnRequest,
29540
- adapters: mergerAdapters(env.packageRoot, methodMaterial),
29456
+ load: (effective) => loadResumableMergerRun(env.home, effective.runId, env.principalAuthority),
29457
+ buildTurnRequest: (admitted, effective) => buildMergerTurnRequest(
29458
+ admitted,
29459
+ resumeTurnRequestProjectionOptions(admitted, effective, env)
29460
+ ),
29461
+ adapters: mergerAdapters(env.packageRoot),
29462
+ afterAdmittedLoad: (admitted) => resolveResumeMethodMaterialAdapters({
29463
+ admitted,
29464
+ authority: env.principalAuthority,
29465
+ io,
29466
+ loadMaterial: () => loadMergerMethodMaterial(env.packageRoot),
29467
+ adaptersWith: (material) => mergerAdapters(env.packageRoot, material),
29468
+ emptyAdapters: mergerAdapters(env.packageRoot),
29469
+ knownCause: "activation"
29470
+ }),
29541
29471
  ...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
29542
29472
  });
29543
29473
  }
@@ -29577,14 +29507,19 @@ function buildReviewerTurnRequest(admitted, options) {
29577
29507
  function reviewerAdapters(packageRoot2, methodMaterial) {
29578
29508
  return {
29579
29509
  beforeDispatch: (admitted) => clearReviewerDispatchRejection(admitted.runDirectory),
29580
- trySettle: (admitted, authority) => methodMaterial === void 0 ? Promise.resolve(void 0) : trySettleReviewerTerminalResult(admitted, authority, {
29581
- methodProvenance: methodMaterial.provenance,
29582
- methodSkillPath: methodMaterial.skillPath,
29583
- methodSkillConfiguredPath: resolvePackagedMethodSkillPath(
29584
- packageRoot2,
29585
- "code-review"
29586
- )
29587
- }),
29510
+ trySettle: (admitted, authority, scope) => methodMaterial === void 0 ? Promise.resolve(void 0) : trySettleReviewerTerminalResult(
29511
+ admitted,
29512
+ authority,
29513
+ {
29514
+ methodProvenance: methodMaterial.provenance,
29515
+ methodSkillPath: methodMaterial.skillPath,
29516
+ methodSkillConfiguredPath: resolvePackagedMethodSkillPath(
29517
+ packageRoot2,
29518
+ "code-review"
29519
+ )
29520
+ },
29521
+ scope
29522
+ ),
29588
29523
  resolveRunnerKnownFailure: async ({ result: result2, sessionFile }) => {
29589
29524
  const infrastructureFailure = await readEngineDetourInfrastructureFailure(sessionFile);
29590
29525
  return infrastructureFailure === void 0 ? result2.knownFailure : {
@@ -29683,45 +29618,25 @@ async function runPublicReviewer(argv, env, io, parseReviewerArgv2) {
29683
29618
  });
29684
29619
  }
29685
29620
  async function runPublicReviewerResume(request, env, io) {
29686
- let loaded;
29687
- try {
29688
- loaded = await loadResumableReviewerRun(env.home, request.runId, env.principalAuthority);
29689
- } catch (error) {
29690
- if (error instanceof CliUsageError) {
29691
- presentStructuralRejection(error, io);
29692
- return { exitCode: 2 };
29693
- }
29694
- throw error;
29695
- }
29696
- const { admitted } = loaded;
29697
- let methodMaterial;
29698
- try {
29699
- methodMaterial = await loadReviewerMethodMaterial(env.packageRoot);
29700
- } catch (error) {
29701
- return await presentControlledFailure2(
29702
- admitted,
29703
- {
29704
- timedOut: false,
29705
- code: null,
29706
- stderr: "",
29707
- thrown: error
29708
- },
29709
- reviewerAdapters(env.packageRoot),
29710
- env.principalAuthority,
29711
- io
29712
- );
29713
- }
29714
- const turnRequest = buildReviewerTurnRequest(
29715
- admitted,
29716
- resumeTurnRequestProjectionOptions(admitted, request, env)
29717
- );
29718
- return await runPostAdmissionManualResume({
29719
- admitted,
29621
+ return await runPostAdmissionSeatResume({
29622
+ request,
29720
29623
  env,
29721
29624
  io,
29722
- request: turnRequest,
29723
- ...env.engine === void 0 ? {} : { effectiveEngine: env.engine },
29724
- adapters: reviewerAdapters(env.packageRoot, methodMaterial)
29625
+ load: (effective) => loadResumableReviewerRun(env.home, effective.runId, env.principalAuthority),
29626
+ buildTurnRequest: (admitted, effective) => buildReviewerTurnRequest(
29627
+ admitted,
29628
+ resumeTurnRequestProjectionOptions(admitted, effective, env)
29629
+ ),
29630
+ adapters: reviewerAdapters(env.packageRoot),
29631
+ afterAdmittedLoad: (admitted) => resolveResumeMethodMaterialAdapters({
29632
+ admitted,
29633
+ authority: env.principalAuthority,
29634
+ io,
29635
+ loadMaterial: () => loadReviewerMethodMaterial(env.packageRoot),
29636
+ adaptersWith: (material) => reviewerAdapters(env.packageRoot, material),
29637
+ emptyAdapters: reviewerAdapters(env.packageRoot)
29638
+ }),
29639
+ ...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
29725
29640
  });
29726
29641
  }
29727
29642
  var init_reviewer_run = __esm({
@@ -32067,10 +31982,10 @@ function parseArgv(argv) {
32067
31982
  function parseResumeRequest(args) {
32068
31983
  const runId = args[0];
32069
31984
  if (runId === void 0 || runId.trim() === "" || runId.startsWith("-")) {
32070
- throw new CliUsageError("usage: ak-role resume <runId> [message]");
31985
+ throw new CliUsageError(RESUME_USAGE_ERROR);
32071
31986
  }
32072
31987
  if (args.length > 2) {
32073
- throw new CliUsageError("usage: ak-role resume <runId> [message]");
31988
+ throw new CliUsageError(RESUME_USAGE_ERROR);
32074
31989
  }
32075
31990
  if (args.length === 2) {
32076
31991
  return { runId, message: args[1] };
@@ -32200,6 +32115,7 @@ function renderHelp() {
32200
32115
  "Persistent host (callable roles): ak-role config set-host <seat> <name> | unset-host <seat>",
32201
32116
  "Host providers: ~/.ak-roles/host-providers.json (owner-edited; table > unique host directory > fail)",
32202
32117
  "Host resolution: --host \u2192 persistent seat host \u2192 pi (resume uses the same order; #617)",
32118
+ "Resume flag position: --model/--thinking/--host/--engine go before <runId> (before `resume` or between `resume` and <runId>); the one argv after <runId> is always the opaque message, never a flag (#471)",
32203
32119
  "Effective seats: ak-role roles"
32204
32120
  );
32205
32121
  return `${lines.join("\n")}
@@ -32873,7 +32789,7 @@ async function runAkRole(argv, env) {
32873
32789
  return { exitCode: 1 };
32874
32790
  }
32875
32791
  }
32876
- var RESUME_SEAT_DISPATCH, PUBLIC_ROLE_ARGV, PUBLIC_GLOBAL_OPTIONS, HostSelectionError;
32792
+ var RESUME_SEAT_DISPATCH, PUBLIC_ROLE_ARGV, PUBLIC_GLOBAL_OPTIONS, HostSelectionError, RESUME_USAGE_ERROR;
32877
32793
  var init_cli = __esm({
32878
32794
  "src/public-cli/cli.ts"() {
32879
32795
  "use strict";
@@ -32953,6 +32869,7 @@ var init_cli = __esm({
32953
32869
  }
32954
32870
  failure;
32955
32871
  };
32872
+ RESUME_USAGE_ERROR = "usage: ak-role resume <runId> [message] (put --model/--thinking/--host/--engine before <runId>; the one argv after <runId> is the opaque message, #471)";
32956
32873
  }
32957
32874
  });
32958
32875