@akagilnc/pi-workflow-roles 0.1.4259 → 0.1.4274

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.
@@ -15177,9 +15177,6 @@ function seatModelOnly(seat) {
15177
15177
  if (seat?.provider === void 0 || seat.model === void 0) return void 0;
15178
15178
  return seat.thinking === void 0 ? { provider: seat.provider, model: seat.model } : { provider: seat.provider, model: seat.model, thinking: seat.thinking };
15179
15179
  }
15180
- function publicStartupCandidates(seat) {
15181
- return STARTUP_CANDIDATES[seat];
15182
- }
15183
15180
  function listHelpCapabilities() {
15184
15181
  const support = PUBLIC_CLI_SUPPORT_COMMANDS.map((name) => ({
15185
15182
  kind: "support",
@@ -15212,7 +15209,7 @@ function isPublicConfigurableSeat(value) {
15212
15209
  function isPublicCliSupportCommand(value) {
15213
15210
  return PUBLIC_CLI_SUPPORT_COMMANDS.includes(value);
15214
15211
  }
15215
- var INTERNAL_ROLE_ENTRYPOINT_RELATIVE, PUBLIC_CALLABLE_ROLES, PUBLIC_CONFIGURABLE_SEATS, PUBLIC_CLI_SUPPORT_COMMANDS, STARTUP_CANDIDATES, PUBLIC_DETERMINISTIC_COMMANDS;
15212
+ var INTERNAL_ROLE_ENTRYPOINT_RELATIVE, PUBLIC_CALLABLE_ROLES, PUBLIC_CONFIGURABLE_SEATS, PUBLIC_CLI_SUPPORT_COMMANDS, PUBLIC_DETERMINISTIC_COMMANDS;
15216
15213
  var init_registry2 = __esm({
15217
15214
  "src/public-cli/registry.ts"() {
15218
15215
  "use strict";
@@ -15231,59 +15228,6 @@ var init_registry2 = __esm({
15231
15228
  "resume",
15232
15229
  "new"
15233
15230
  ];
15234
- STARTUP_CANDIDATES = {
15235
- judge: [
15236
- { provider: "openai-codex", model: "gpt-5.6-sol", thinking: "high" },
15237
- { provider: "xai", model: "grok-4.5", thinking: "high" }
15238
- ],
15239
- countersign: [
15240
- { provider: "openai-codex", model: "gpt-5.6-sol", thinking: "high" },
15241
- { provider: "xai", model: "grok-4.5", thinking: "high" }
15242
- ],
15243
- "gleaner-left": [
15244
- { provider: "openai-codex", model: "gpt-5.6-sol", thinking: "medium" },
15245
- { provider: "xai", model: "grok-4.5", thinking: "high" }
15246
- ],
15247
- reviewer: [
15248
- { provider: "openai-codex", model: "gpt-5.6-sol", thinking: "medium" },
15249
- { provider: "xai", model: "grok-4.5", thinking: "high" }
15250
- ],
15251
- coder: [
15252
- { provider: "openai-codex", model: "gpt-5.6-luna", thinking: "high" },
15253
- { provider: "xai", model: "grok-4.5", thinking: "high" }
15254
- ],
15255
- fixer: [
15256
- { provider: "openai-codex", model: "gpt-5.6-luna", thinking: "high" },
15257
- { provider: "xai", model: "grok-4.5", thinking: "high" }
15258
- ],
15259
- collector: [
15260
- { provider: "openai-codex", model: "gpt-5.6-luna", thinking: "high" },
15261
- { provider: "xai", model: "grok-4.5", thinking: "high" }
15262
- ],
15263
- doctor: [
15264
- { provider: "openai-codex", model: "gpt-5.6-luna", thinking: "high" },
15265
- { provider: "xai", model: "grok-4.5", thinking: "high" }
15266
- ],
15267
- merger: [
15268
- { provider: "openai-codex", model: "gpt-5.6-luna", thinking: "high" },
15269
- { provider: "xai", model: "grok-4.5", thinking: "high" }
15270
- ],
15271
- // #620: subordinate officers inherit gatekeeper; no package startup model.
15272
- notary: [],
15273
- // #453/#620/#639: gatekeeper callable but no package startup model — caller
15274
- // configures it or inherits on the province path.
15275
- gatekeeper: [],
15276
- inspector: [],
15277
- navigator: [
15278
- { provider: "openai-codex", model: "gpt-5.6-luna", thinking: "medium" },
15279
- { provider: "xai", model: "grok-4.5", thinking: "high" }
15280
- ],
15281
- // #675: auditor public seat — no package startup; caller configures.
15282
- auditor: [],
15283
- // #708 `diarist-seat-default`: owner-set initial value; changed in the seat
15284
- // table like any other seat. No engine axis, package-default host.
15285
- diarist: [{ provider: "xai", model: "grok-4.5", thinking: "medium" }]
15286
- };
15287
15231
  PUBLIC_DETERMINISTIC_COMMANDS = ["analyst"];
15288
15232
  }
15289
15233
  });
@@ -15439,11 +15383,13 @@ __export(config_exports, {
15439
15383
  loadCredentialProviders: () => loadCredentialProviders,
15440
15384
  loadPublicCliConfig: () => loadPublicCliConfig,
15441
15385
  missingPublicProviderCredential: () => missingPublicProviderCredential,
15386
+ missingResolvedSeatModelMessage: () => missingResolvedSeatModelMessage,
15442
15387
  parseAutoResumeLimit: () => parseAutoResumeLimit,
15443
15388
  parseModelSpec: () => parseModelSpec,
15444
15389
  providerConfigured: () => providerConfigured,
15445
15390
  publicCliConfigPath: () => publicCliConfigPath,
15446
15391
  resolveEffectiveSeat: () => resolveEffectiveSeat,
15392
+ resolvedSeatWithModel: () => resolvedSeatWithModel,
15447
15393
  savePublicCliConfig: () => savePublicCliConfig,
15448
15394
  setAutoResumeLimit: () => setAutoResumeLimit,
15449
15395
  setPersistentSeatConfig: () => setPersistentSeatConfig,
@@ -15794,13 +15740,16 @@ function missingPublicProviderCredential(provider, credentials) {
15794
15740
  if (provider !== "openai-codex" && provider !== "xai") return false;
15795
15741
  return !providerConfigured(credentials, provider);
15796
15742
  }
15797
- function pickStartupCandidate(seat, credentials) {
15798
- for (const candidate of publicStartupCandidates(seat)) {
15799
- if (providerConfigured(credentials, candidate.provider)) {
15800
- return { ...candidate };
15801
- }
15743
+ function resolvedSeatWithModel(seat) {
15744
+ if (seat.selection === void 0) return void 0;
15745
+ return seat;
15746
+ }
15747
+ function missingResolvedSeatModelMessage(seat, remediation = "config") {
15748
+ const configSet = `ak-role config set ${seat} <provider/model[:thinking]>`;
15749
+ if (remediation === "invocation-or-config") {
15750
+ return `seat ${seat} has no model configured; set with --model <provider/model[:thinking]> or ${configSet}`;
15802
15751
  }
15803
- return void 0;
15752
+ return `seat ${seat} has no model configured; set with ${configSet}`;
15804
15753
  }
15805
15754
  function attachHostAxis(seat, config, invocation) {
15806
15755
  if (invocation?.host !== void 0) return { ...seat, host: invocation.host, hostSource: "invocation" };
@@ -15843,7 +15792,7 @@ function attachEngineAxis(seat, config, invocation) {
15843
15792
  engineSource: "unconfigured"
15844
15793
  };
15845
15794
  }
15846
- function resolveBaseSeat(config, seat, credentials) {
15795
+ function resolveBaseSeat(config, seat) {
15847
15796
  if (seat === "notary" || seat === "inspector") {
15848
15797
  const resolved = resolveConfiguredProvinceOfficer(config, seat);
15849
15798
  return {
@@ -15862,22 +15811,14 @@ function resolveBaseSeat(config, seat, credentials) {
15862
15811
  engineSource: "unconfigured"
15863
15812
  };
15864
15813
  }
15865
- const startup = pickStartupCandidate(seat, credentials);
15866
- if (startup !== void 0) {
15867
- return {
15868
- seat,
15869
- source: "startup",
15870
- selection: startup,
15871
- engineSource: "unconfigured"
15872
- };
15873
- }
15874
15814
  return { seat, source: "unconfigured", engineSource: "unconfigured" };
15875
15815
  }
15876
15816
  function resolveEffectiveSeat(config, seat, credentials, invocation) {
15877
15817
  const hasModelInvocation = invocation !== void 0 && (invocation.model !== void 0 || invocation.thinking !== void 0);
15818
+ void credentials;
15878
15819
  let modelSeat;
15879
15820
  if (!hasModelInvocation || invocation === void 0) {
15880
- modelSeat = resolveBaseSeat(config, seat, credentials);
15821
+ modelSeat = resolveBaseSeat(config, seat);
15881
15822
  } else if (invocation.model !== void 0) {
15882
15823
  const spec = invocation.model.includes(":") || invocation.thinking === void 0 ? invocation.model : `${invocation.model}:${invocation.thinking}`;
15883
15824
  modelSeat = {
@@ -15887,7 +15828,7 @@ function resolveEffectiveSeat(config, seat, credentials, invocation) {
15887
15828
  engineSource: "unconfigured"
15888
15829
  };
15889
15830
  } else {
15890
- const base = resolveBaseSeat(config, seat, credentials);
15831
+ const base = resolveBaseSeat(config, seat);
15891
15832
  if (base.selection === void 0 || invocation.thinking === void 0) {
15892
15833
  modelSeat = {
15893
15834
  seat,
@@ -16131,6 +16072,10 @@ var init_host_providers = __esm({
16131
16072
  });
16132
16073
 
16133
16074
  // src/public-cli/cli-errors.ts
16075
+ var cli_errors_exports = {};
16076
+ __export(cli_errors_exports, {
16077
+ CliUsageError: () => CliUsageError
16078
+ });
16134
16079
  var CliUsageError;
16135
16080
  var init_cli_errors = __esm({
16136
16081
  "src/public-cli/cli-errors.ts"() {
@@ -24923,6 +24868,86 @@ var init_terminal = __esm({
24923
24868
  });
24924
24869
 
24925
24870
  // src/public-cli/settlement.ts
24871
+ var settlement_exports = {};
24872
+ __export(settlement_exports, {
24873
+ ATTEMPT_HISTORY_ENTRY_TYPE: () => ATTEMPT_HISTORY_ENTRY_TYPE,
24874
+ NAVIGATOR_POST_ROLE_GRACE_MS: () => NAVIGATOR_POST_ROLE_GRACE_MS,
24875
+ appendRunAttemptHistory: () => appendRunAttemptHistory,
24876
+ attachRecordedSubmissions: () => attachRecordedSubmissions,
24877
+ attemptProducedFreshSubmission: () => attemptProducedFreshSubmission,
24878
+ classifyPostAdmissionFailure: () => classifyPostAdmissionFailure,
24879
+ conciseChildDiagnostic: () => conciseChildDiagnostic,
24880
+ controlledFailureInputFromResolution: () => controlledFailureInputFromResolution,
24881
+ exitCodeForTerminalOutcome: () => exitCodeForTerminalOutcome,
24882
+ explicitInternalKnownFailureClassificationInput: () => explicitInternalKnownFailureClassificationInput,
24883
+ extractCollectorInfrastructureFailure: () => extractCollectorInfrastructureFailure,
24884
+ extractEngineDetourInfrastructureFailure: () => extractEngineDetourInfrastructureFailure,
24885
+ extractFixerMethodInvocations: () => extractFixerMethodInvocations,
24886
+ extractGateFactFromSessionDirectory: () => extractGateFactFromSessionDirectory,
24887
+ extractMergerMethodInvocations: () => extractMergerMethodInvocations,
24888
+ extractNavigatorFact: () => extractNavigatorFact,
24889
+ extractReviewerMethodInvocations: () => extractReviewerMethodInvocations,
24890
+ extractSessionProviderStop: () => extractSessionProviderStop,
24891
+ formatCliDiagnostic: () => formatCliDiagnostic,
24892
+ formatErrorCauseDetail: () => formatErrorCauseDetail,
24893
+ formatFailureStderrDiagnostic: () => formatFailureStderrDiagnostic,
24894
+ formatTerminalResult: () => formatTerminalResult,
24895
+ inspectJudgeSession: () => inspectJudgeSession,
24896
+ isLawfulTypedTerminalOutcome: () => isLawfulTypedTerminalOutcome,
24897
+ presentControlledFailure: () => presentControlledFailure,
24898
+ presentFailureTerminal: () => presentFailureTerminal,
24899
+ presentStructuralRejection: () => presentStructuralRejection,
24900
+ projectTerminalGateFact: () => projectTerminalGateFact,
24901
+ projectThrownFailureLeaf: () => projectThrownFailureLeaf,
24902
+ publishCoderArtifacts: () => publishCoderArtifacts,
24903
+ publishCollectorArtifacts: () => publishCollectorArtifacts,
24904
+ publishDoctorArtifacts: () => publishDoctorArtifacts,
24905
+ publishFailureArtifacts: () => publishFailureArtifacts,
24906
+ publishFixerArtifacts: () => publishFixerArtifacts,
24907
+ publishJudgeArtifacts: () => publishJudgeArtifacts,
24908
+ publishMergerArtifacts: () => publishMergerArtifacts,
24909
+ publishReviewerArtifacts: () => publishReviewerArtifacts,
24910
+ raceNavigatorGrace: () => raceNavigatorGrace,
24911
+ readBoundAuditorKnownFailure: () => readBoundAuditorKnownFailure,
24912
+ readBoundEvidenceChildKnownFailure: () => readBoundEvidenceChildKnownFailure,
24913
+ readCollectorInfrastructureFailure: () => readCollectorInfrastructureFailure,
24914
+ readEngineDetourInfrastructureFailure: () => readEngineDetourInfrastructureFailure,
24915
+ readLawfulJudgeRoleOutcome: () => readLawfulJudgeRoleOutcome,
24916
+ readSessionProviderStop: () => readSessionProviderStop,
24917
+ recordedSubmissionPayloads: () => recordedSubmissionPayloads,
24918
+ resolveAuditedRunnerFailureResolution: () => resolveAuditedRunnerFailureResolution,
24919
+ resolveAuditedRunnerKnownFailure: () => resolveAuditedRunnerKnownFailure,
24920
+ resolveControlledFailureResumeObservation: () => resolveControlledFailureResumeObservation,
24921
+ settleCoderTerminalResult: () => settleCoderTerminalResult,
24922
+ settleCollectorTerminalResult: () => settleCollectorTerminalResult,
24923
+ settleCountersignTerminalResult: () => settleCountersignTerminalResult,
24924
+ settleDoctorTerminalResult: () => settleDoctorTerminalResult,
24925
+ settleFailureTerminalResult: () => settleFailureTerminalResult,
24926
+ settleFixerTerminalResult: () => settleFixerTerminalResult,
24927
+ settleGleanerLeftTerminalResult: () => settleGleanerLeftTerminalResult,
24928
+ settleHostEndedNoReceipt: () => settleHostEndedNoReceipt,
24929
+ settleJudgeFailureTerminalResult: () => settleJudgeFailureTerminalResult,
24930
+ settleJudgeTerminalResult: () => settleJudgeTerminalResult,
24931
+ settleMergerTerminalResult: () => settleMergerTerminalResult,
24932
+ settleNotaryTerminalResult: () => settleNotaryTerminalResult,
24933
+ settleReviewerTerminalResult: () => settleReviewerTerminalResult,
24934
+ trySettleAuditorTerminalResult: () => trySettleAuditorTerminalResult,
24935
+ trySettleCoderTerminalResult: () => trySettleCoderTerminalResult,
24936
+ trySettleCollectorTerminalResult: () => trySettleCollectorTerminalResult,
24937
+ trySettleCountersignTerminalResult: () => trySettleCountersignTerminalResult,
24938
+ trySettleDiaristTerminalResult: () => trySettleDiaristTerminalResult,
24939
+ trySettleDoctorTerminalResult: () => trySettleDoctorTerminalResult,
24940
+ trySettleFixerTerminalResult: () => trySettleFixerTerminalResult,
24941
+ trySettleGatekeeperTerminalResult: () => trySettleGatekeeperTerminalResult,
24942
+ trySettleGleanerLeftTerminalResult: () => trySettleGleanerLeftTerminalResult,
24943
+ trySettleInspectorTerminalResult: () => trySettleInspectorTerminalResult,
24944
+ trySettleJudgeTerminalResult: () => trySettleJudgeTerminalResult,
24945
+ trySettleMergerTerminalResult: () => trySettleMergerTerminalResult,
24946
+ trySettleNavigatorTerminalResult: () => trySettleNavigatorTerminalResult,
24947
+ trySettleNotaryTerminalResult: () => trySettleNotaryTerminalResult,
24948
+ trySettleReviewerTerminalResult: () => trySettleReviewerTerminalResult,
24949
+ withSubmissions: () => withSubmissions
24950
+ });
24926
24951
  import { randomUUID as randomUUID5 } from "node:crypto";
24927
24952
  import { appendFile as appendFile2, readFile as readFile17, readdir as readdir7, writeFile as writeFile7 } from "node:fs/promises";
24928
24953
  import { dirname as dirname14, join as join26 } from "node:path";
@@ -25549,6 +25574,11 @@ function providerStopFallbackFromAuditorVolumes(volumes) {
25549
25574
  }
25550
25575
  return void 0;
25551
25576
  }
25577
+ async function readBoundAuditorKnownFailure(sessionFile) {
25578
+ const volumes = await loadBoundAuditorVolumes(sessionFile);
25579
+ if (volumes === void 0) return void 0;
25580
+ return complianceFailureFromAuditorVolumes(volumes) ?? providerStopFallbackFromAuditorVolumes(volumes);
25581
+ }
25552
25582
  async function readBoundAuditorComplianceFailure(sessionFile) {
25553
25583
  const volumes = await loadBoundAuditorVolumes(sessionFile);
25554
25584
  if (volumes === void 0) return void 0;
@@ -25702,6 +25732,9 @@ async function resolveAuditedRunnerFailureResolution(input) {
25702
25732
  typedHttp
25703
25733
  );
25704
25734
  }
25735
+ async function resolveAuditedRunnerKnownFailure(input) {
25736
+ return (await resolveAuditedRunnerFailureResolution(input)).knownFailure;
25737
+ }
25705
25738
  async function resolveControlledFailureResumeObservation(input) {
25706
25739
  if (input.typedHttpObservationSettled === true) {
25707
25740
  const observation = input.typedHttpObservation;
@@ -25805,6 +25838,12 @@ async function readInfrastructureToolFailure(sessionFile, spec, options = {}) {
25805
25838
  return void 0;
25806
25839
  }
25807
25840
  }
25841
+ function extractCollectorInfrastructureFailure(entries) {
25842
+ return extractInfrastructureToolFailure(
25843
+ entries,
25844
+ COLLECTOR_INFRASTRUCTURE_FAILURE_SPEC
25845
+ );
25846
+ }
25808
25847
  async function readCollectorInfrastructureFailure(sessionFile) {
25809
25848
  return readInfrastructureToolFailure(
25810
25849
  sessionFile,
@@ -25814,6 +25853,12 @@ async function readCollectorInfrastructureFailure(sessionFile) {
25814
25853
  { currentAttemptOnly: true }
25815
25854
  );
25816
25855
  }
25856
+ function extractEngineDetourInfrastructureFailure(entries) {
25857
+ return extractInfrastructureToolFailure(
25858
+ entries,
25859
+ ENGINE_DETOUR_INFRASTRUCTURE_FAILURE_SPEC
25860
+ );
25861
+ }
25817
25862
  async function readEngineDetourInfrastructureFailure(sessionFile) {
25818
25863
  return readInfrastructureToolFailure(
25819
25864
  sessionFile,
@@ -26229,6 +26274,15 @@ async function settleLawfulJudgeTerminalResult(admitted, authority, scope) {
26229
26274
  detourGateContext(admitted, scope)
26230
26275
  );
26231
26276
  }
26277
+ async function settleJudgeTerminalResult(admitted, authority, scope) {
26278
+ const settled = await settleLawfulJudgeTerminalResult(admitted, authority, scope);
26279
+ if (settled === void 0) {
26280
+ throw new Error(
26281
+ "Judge Role run completed without a lawful typed terminal result"
26282
+ );
26283
+ }
26284
+ return settled;
26285
+ }
26232
26286
  async function trySettleJudgeTerminalResult(admitted, authority, scope) {
26233
26287
  return settleLawfulJudgeTerminalResult(admitted, authority, scope);
26234
26288
  }
@@ -26258,6 +26312,15 @@ async function settleLawfulCoderTerminalResult(admitted, authority, options = {}
26258
26312
  detourGateContext(admitted, scope)
26259
26313
  );
26260
26314
  }
26315
+ async function settleCoderTerminalResult(admitted, authority, options = {}, scope) {
26316
+ const settled = await settleLawfulCoderTerminalResult(admitted, authority, options, scope);
26317
+ if (settled === void 0) {
26318
+ throw new Error(
26319
+ "Coder Role run completed without a lawful typed terminal result"
26320
+ );
26321
+ }
26322
+ return settled;
26323
+ }
26261
26324
  function sessionMessageText(message) {
26262
26325
  if (message === void 0) return "";
26263
26326
  if (typeof message.content === "string") return message.content;
@@ -26375,6 +26438,15 @@ async function settleLawfulFixerTerminalResult(admitted, authority, options, sco
26375
26438
  detourGateContext(admitted, scope)
26376
26439
  );
26377
26440
  }
26441
+ async function settleFixerTerminalResult(admitted, authority, options, scope) {
26442
+ const settled = await settleLawfulFixerTerminalResult(admitted, authority, options, scope);
26443
+ if (settled === void 0) {
26444
+ throw new Error(
26445
+ "Fixer Role run completed without a lawful typed terminal result"
26446
+ );
26447
+ }
26448
+ return settled;
26449
+ }
26378
26450
  async function publishCollectorArtifacts(admitted, roleOutcome, coordinates) {
26379
26451
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
26380
26452
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
@@ -26474,6 +26546,15 @@ async function settleLawfulCollectorTerminalResult(admitted, authority, scope) {
26474
26546
  scope
26475
26547
  );
26476
26548
  }
26549
+ async function settleCollectorTerminalResult(admitted, authority, scope) {
26550
+ const settled = await settleLawfulCollectorTerminalResult(admitted, authority, scope);
26551
+ if (settled === void 0) {
26552
+ throw new Error(
26553
+ "Collector Role run completed without a lawful typed terminal result"
26554
+ );
26555
+ }
26556
+ return settled;
26557
+ }
26477
26558
  async function trySettleCollectorTerminalResult(admitted, authority, scope) {
26478
26559
  return settleLawfulCollectorTerminalResult(admitted, authority, scope);
26479
26560
  }
@@ -26593,6 +26674,15 @@ async function settleLawfulDoctorTerminalResult(admitted, authority, scope) {
26593
26674
  detourGateContext(admitted, scope)
26594
26675
  );
26595
26676
  }
26677
+ async function settleDoctorTerminalResult(admitted, authority, scope) {
26678
+ const settled = await settleLawfulDoctorTerminalResult(admitted, authority, scope);
26679
+ if (settled === void 0) {
26680
+ throw new Error(
26681
+ "Doctor Role run completed without a lawful typed terminal result"
26682
+ );
26683
+ }
26684
+ return settled;
26685
+ }
26596
26686
  async function trySettleDoctorTerminalResult(admitted, authority, scope) {
26597
26687
  return settleLawfulDoctorTerminalResult(admitted, authority, scope);
26598
26688
  }
@@ -26676,6 +26766,15 @@ async function settleLawfulNotaryTerminalResult(admitted, authority, scope) {
26676
26766
  toolName: NOTARY_OUTPUT_TOOL_NAME
26677
26767
  }, scope);
26678
26768
  }
26769
+ async function settleNotaryTerminalResult(admitted, authority, scope) {
26770
+ const settled = await settleLawfulNotaryTerminalResult(admitted, authority, scope);
26771
+ if (settled === void 0) {
26772
+ throw new Error(
26773
+ "Notary Role run completed without a lawful typed terminal result"
26774
+ );
26775
+ }
26776
+ return settled;
26777
+ }
26679
26778
  async function trySettleNotaryTerminalResult(admitted, authority, scope) {
26680
26779
  return settleLawfulNotaryTerminalResult(admitted, authority, scope);
26681
26780
  }
@@ -26685,6 +26784,15 @@ async function settleLawfulCountersignTerminalResult(admitted, authority, scope)
26685
26784
  toolName: COUNTERSIGN_OUTPUT_TOOL_NAME
26686
26785
  }, scope);
26687
26786
  }
26787
+ async function settleCountersignTerminalResult(admitted, authority, scope) {
26788
+ const settled = await settleLawfulCountersignTerminalResult(admitted, authority, scope);
26789
+ if (settled === void 0) {
26790
+ throw new Error(
26791
+ "Countersign Role run completed without a lawful typed terminal result"
26792
+ );
26793
+ }
26794
+ return settled;
26795
+ }
26688
26796
  async function trySettleCountersignTerminalResult(admitted, authority, scope) {
26689
26797
  return settleLawfulCountersignTerminalResult(admitted, authority, scope);
26690
26798
  }
@@ -26694,6 +26802,15 @@ async function settleLawfulGleanerLeftTerminalResult(admitted, authority, scope)
26694
26802
  toolName: GLEANER_LEFT_OUTPUT_TOOL_NAME
26695
26803
  }, scope);
26696
26804
  }
26805
+ async function settleGleanerLeftTerminalResult(admitted, authority, scope) {
26806
+ const settled = await settleLawfulGleanerLeftTerminalResult(admitted, authority, scope);
26807
+ if (settled === void 0) {
26808
+ throw new Error(
26809
+ "Gleaner-Left Role run completed without a lawful typed terminal result"
26810
+ );
26811
+ }
26812
+ return settled;
26813
+ }
26697
26814
  async function trySettleGleanerLeftTerminalResult(admitted, authority, scope) {
26698
26815
  return settleLawfulGleanerLeftTerminalResult(admitted, authority, scope);
26699
26816
  }
@@ -26851,6 +26968,15 @@ async function settleLawfulReviewerTerminalResult(admitted, authority, options,
26851
26968
  detourGateContext(admitted, scope)
26852
26969
  );
26853
26970
  }
26971
+ async function settleReviewerTerminalResult(admitted, authority, options, scope) {
26972
+ const settled = await settleLawfulReviewerTerminalResult(admitted, authority, options, scope);
26973
+ if (settled === void 0) {
26974
+ throw new Error(
26975
+ "Reviewer Role run completed without a lawful typed terminal result"
26976
+ );
26977
+ }
26978
+ return settled;
26979
+ }
26854
26980
  async function trySettleReviewerTerminalResult(admitted, authority, options, scope) {
26855
26981
  return settleLawfulReviewerTerminalResult(admitted, authority, options, scope);
26856
26982
  }
@@ -26977,6 +27103,15 @@ async function settleLawfulMergerTerminalResult(admitted, authority, options, sc
26977
27103
  scope
26978
27104
  );
26979
27105
  }
27106
+ async function settleMergerTerminalResult(admitted, authority, options, scope) {
27107
+ const settled = await settleLawfulMergerTerminalResult(admitted, authority, options, scope);
27108
+ if (settled === void 0) {
27109
+ throw new Error(
27110
+ "Merger Role run completed without a lawful typed terminal result"
27111
+ );
27112
+ }
27113
+ return settled;
27114
+ }
26980
27115
  async function trySettleMergerTerminalResult(admitted, authority, options, scope) {
26981
27116
  return settleLawfulMergerTerminalResult(admitted, authority, options, scope);
26982
27117
  }
@@ -27228,6 +27363,9 @@ async function settleFailureTerminalResult(admitted, failure, authority, options
27228
27363
  detourGateContext(admitted, options)
27229
27364
  );
27230
27365
  }
27366
+ async function settleJudgeFailureTerminalResult(admitted, failure, authority, options = {}) {
27367
+ return settleFailureTerminalResult(admitted, failure, authority, options);
27368
+ }
27231
27369
  function presentFailureTerminal(terminal, io) {
27232
27370
  if (terminal.roleOutcome.kind !== "failure" && terminal.roleOutcome.kind !== "no_receipt") {
27233
27371
  throw new TypeError("presentFailureTerminal requires a failure or no-receipt role outcome");
@@ -27248,7 +27386,41 @@ function presentFailureTerminal(terminal, io) {
27248
27386
  }));
27249
27387
  }
27250
27388
  }
27251
- var COLLECTOR_INFRASTRUCTURE_TOOLS, COLLECTOR_INFRASTRUCTURE_FAILURE_SPEC, ENGINE_DETOUR_INFRASTRUCTURE_FAILURE_SPEC, ATTEMPT_HISTORY_ENTRY_TYPE;
27389
+ function defaultNavigatorGraceSleep() {
27390
+ let timer;
27391
+ const sleep2 = ((ms) => new Promise((resolve10) => {
27392
+ timer = setTimeout(() => {
27393
+ timer = void 0;
27394
+ resolve10();
27395
+ }, ms);
27396
+ }));
27397
+ sleep2.cancel = () => {
27398
+ if (timer !== void 0) {
27399
+ clearTimeout(timer);
27400
+ timer = void 0;
27401
+ }
27402
+ };
27403
+ return sleep2;
27404
+ }
27405
+ function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2 = defaultNavigatorGraceSleep()) {
27406
+ return new Promise((resolve10, reject) => {
27407
+ let settled = false;
27408
+ const finish = (action) => {
27409
+ if (settled) return;
27410
+ settled = true;
27411
+ sleep2.cancel?.();
27412
+ action();
27413
+ };
27414
+ void work.then(
27415
+ (value) => finish(() => resolve10({ status: "done", value })),
27416
+ (error) => finish(() => reject(error))
27417
+ );
27418
+ void sleep2(graceMs).then(() => {
27419
+ finish(() => resolve10({ status: "timeout" }));
27420
+ });
27421
+ });
27422
+ }
27423
+ var NAVIGATOR_POST_ROLE_GRACE_MS, COLLECTOR_INFRASTRUCTURE_TOOLS, COLLECTOR_INFRASTRUCTURE_FAILURE_SPEC, ENGINE_DETOUR_INFRASTRUCTURE_FAILURE_SPEC, ATTEMPT_HISTORY_ENTRY_TYPE;
27252
27424
  var init_settlement = __esm({
27253
27425
  "src/public-cli/settlement.ts"() {
27254
27426
  "use strict";
@@ -27287,6 +27459,7 @@ var init_settlement = __esm({
27287
27459
  init_role_run_placement();
27288
27460
  init_invocation();
27289
27461
  init_terminal();
27462
+ NAVIGATOR_POST_ROLE_GRACE_MS = 1e4;
27290
27463
  COLLECTOR_INFRASTRUCTURE_TOOLS = /* @__PURE__ */ new Set([
27291
27464
  COLLECTOR_OBSERVE_TOOL,
27292
27465
  COLLECTOR_READ_TOOL,
@@ -30276,11 +30449,17 @@ function hostSelectionFailureFromUnknown(error) {
30276
30449
  const failure = error.failure;
30277
30450
  return failure;
30278
30451
  }
30279
- async function createSummonEnv(options) {
30280
- const [{ piDurablePrincipalAuthority: piDurablePrincipalAuthority2 }, { appendPiSessionCustomEntry: appendPiSessionCustomEntry2 }, { resolveRoleTurnHost: resolveRoleTurnHost2 }] = await Promise.all([
30452
+ async function createSummonEnv(options, afterHost) {
30453
+ const [
30454
+ { piDurablePrincipalAuthority: piDurablePrincipalAuthority2 },
30455
+ { appendPiSessionCustomEntry: appendPiSessionCustomEntry2 },
30456
+ { resolveRoleTurnHost: resolveRoleTurnHost2 },
30457
+ { missingResolvedSeatModelMessage: missingResolvedSeatModelMessage2, resolvedSeatWithModel: resolvedSeatWithModel2 }
30458
+ ] = await Promise.all([
30281
30459
  Promise.resolve().then(() => (init_durable_principal(), durable_principal_exports)),
30282
30460
  Promise.resolve().then(() => (init_role_turn_host(), role_turn_host_exports)),
30283
- Promise.resolve().then(() => (init_role_turn_host_resolution(), role_turn_host_resolution_exports))
30461
+ Promise.resolve().then(() => (init_role_turn_host_resolution(), role_turn_host_resolution_exports)),
30462
+ Promise.resolve().then(() => (init_config2(), config_exports))
30284
30463
  ]);
30285
30464
  const principalAuthority = piDurablePrincipalAuthority2;
30286
30465
  const roleTurnHost = resolveRoleTurnHost2(
@@ -30292,26 +30471,37 @@ async function createSummonEnv(options) {
30292
30471
  },
30293
30472
  { role: options.role, seat: options.seat, principalAuthority }
30294
30473
  );
30295
- const hostName = options.seat.host ?? "pi";
30474
+ afterHost?.();
30475
+ const seatWithModel = resolvedSeatWithModel2(options.seat);
30476
+ if (seatWithModel === void 0) {
30477
+ return {
30478
+ ok: false,
30479
+ missingModelMessage: missingResolvedSeatModelMessage2(options.role)
30480
+ };
30481
+ }
30482
+ const hostName = seatWithModel.host ?? "pi";
30296
30483
  const { loadHostProvidersTable: loadHostProvidersTable2, projectHostFacingProvider: projectHostFacingProvider2 } = await Promise.resolve().then(() => (init_host_providers(), host_providers_exports));
30297
- const hostFacingSelection = options.seat.selection === void 0 ? void 0 : projectHostFacingProvider2(
30298
- options.seat.selection,
30484
+ const hostFacingSelection = projectHostFacingProvider2(
30485
+ seatWithModel.selection,
30299
30486
  hostName,
30300
30487
  loadHostProvidersTable2(options.home),
30301
30488
  options.home
30302
30489
  );
30303
30490
  return {
30304
- home: options.home,
30305
- principalAuthority,
30306
- agentDir: options.agentDir,
30307
- sessionAppender: appendPiSessionCustomEntry2,
30308
- packageRoot: options.packageRoot,
30309
- roleTurnHost,
30310
- cwd: options.cwd,
30311
- credentials: options.credentials,
30312
- ...hostFacingSelection === void 0 ? {} : { model: hostFacingSelection },
30313
- ...projectSeatEngine(options.seat),
30314
- ...projectSeatHost(options.seat)
30491
+ ok: true,
30492
+ env: {
30493
+ home: options.home,
30494
+ principalAuthority,
30495
+ agentDir: options.agentDir,
30496
+ sessionAppender: appendPiSessionCustomEntry2,
30497
+ packageRoot: options.packageRoot,
30498
+ roleTurnHost,
30499
+ cwd: options.cwd,
30500
+ credentials: options.credentials,
30501
+ ...hostFacingSelection === void 0 ? {} : { model: hostFacingSelection },
30502
+ ...projectSeatEngine(seatWithModel),
30503
+ ...projectSeatHost(seatWithModel)
30504
+ }
30315
30505
  };
30316
30506
  }
30317
30507
  async function summonPublicRole(options) {
@@ -30326,46 +30516,72 @@ async function summonPublicRole(options) {
30326
30516
  const credentials = options.credentials ?? await loadCredentialProviders2(agentDir);
30327
30517
  const config = await loadPublicCliConfig2(home);
30328
30518
  const seat = resolveEffectiveSeat2(config, options.role, credentials);
30329
- let summonEnv;
30330
- try {
30331
- summonEnv = await createSummonEnv({
30332
- role: options.role,
30333
- home,
30334
- agentDir,
30335
- cwd: options.cwd,
30336
- packageRoot: packageRoot2,
30337
- credentials,
30338
- seat,
30339
- ...options.extraPiArgs === void 0 ? {} : { extraPiArgs: options.extraPiArgs },
30340
- ...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
30341
- ...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters }
30342
- });
30343
- } catch (error) {
30344
- const failure = hostSelectionFailureFromUnknown(error);
30345
- if (failure !== void 0) {
30346
- const { formatHostSelectionFailure: formatHostSelectionFailure2 } = await Promise.resolve().then(() => (init_role_turn_host_resolution(), role_turn_host_resolution_exports));
30347
- return { exitCode: 1, stderr: formatHostSelectionFailure2(failure) };
30348
- }
30349
- throw error;
30350
- }
30351
- const env = {
30352
- ...summonEnv,
30353
- // Station child role run (#840): omit automatic navigator attendance.
30354
- stationChild: true,
30355
- // Host config passthrough only — same face as public CLI (#422 / #675).
30356
- ...config.autoResumeLimit === void 0 ? {} : { autoResumeLimit: config.autoResumeLimit },
30357
- // Parent cancellation reaches the nested activation's own turn dispatch.
30358
- ...options.signal === void 0 ? {} : { signal: options.signal },
30359
- // #753: reask rides the existing notary same-ticket resume summons.instruction.
30360
- ...options.reviewReask === void 0 ? {} : { reviewReask: options.reviewReask },
30361
- // #879: verbatim submission body on officer dialogue content channel.
30362
- ...options.gateReviewInstruction === void 0 ? {} : { gateReviewInstruction: options.gateReviewInstruction },
30363
- ...options.boundTicketNumber === void 0 ? {} : { boundTicketNumber: options.boundTicketNumber },
30364
- // createRunId is the only remaining env overlay — host is seat-selected above.
30365
- ...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
30366
- };
30367
30519
  const captured = options.io === void 0 ? createCapturingIo() : void 0;
30368
30520
  const io = options.io ?? captured.io;
30521
+ const summonEnvInput = {
30522
+ role: options.role,
30523
+ home,
30524
+ agentDir,
30525
+ cwd: options.cwd,
30526
+ packageRoot: packageRoot2,
30527
+ credentials,
30528
+ seat,
30529
+ ...options.extraPiArgs === void 0 ? {} : { extraPiArgs: options.extraPiArgs },
30530
+ ...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
30531
+ ...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters }
30532
+ };
30533
+ async function prepareSummonEnv(afterHost) {
30534
+ try {
30535
+ const built = await createSummonEnv(summonEnvInput, afterHost);
30536
+ if (!built.ok) {
30537
+ return { ok: false, exitCode: 1, stderr: built.missingModelMessage };
30538
+ }
30539
+ return {
30540
+ ok: true,
30541
+ env: {
30542
+ ...built.env,
30543
+ stationChild: true,
30544
+ ...config.autoResumeLimit === void 0 ? {} : { autoResumeLimit: config.autoResumeLimit },
30545
+ ...options.signal === void 0 ? {} : { signal: options.signal },
30546
+ ...options.reviewReask === void 0 ? {} : { reviewReask: options.reviewReask },
30547
+ ...options.gateReviewInstruction === void 0 ? {} : { gateReviewInstruction: options.gateReviewInstruction },
30548
+ ...options.boundTicketNumber === void 0 ? {} : { boundTicketNumber: options.boundTicketNumber },
30549
+ ...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
30550
+ }
30551
+ };
30552
+ } catch (error) {
30553
+ const failure = hostSelectionFailureFromUnknown(error);
30554
+ if (failure !== void 0) {
30555
+ const { formatHostSelectionFailure: formatHostSelectionFailure2 } = await Promise.resolve().then(() => (init_role_turn_host_resolution(), role_turn_host_resolution_exports));
30556
+ return { ok: false, exitCode: 1, stderr: formatHostSelectionFailure2(failure) };
30557
+ }
30558
+ const { CliUsageError: CliUsageError2 } = await Promise.resolve().then(() => (init_cli_errors(), cli_errors_exports));
30559
+ if (error instanceof CliUsageError2) {
30560
+ const { presentStructuralRejection: presentStructuralRejection2 } = await Promise.resolve().then(() => (init_settlement(), settlement_exports));
30561
+ presentStructuralRejection2(error, io);
30562
+ return { ok: false, exitCode: 2 };
30563
+ }
30564
+ throw error;
30565
+ }
30566
+ }
30567
+ function projectPrepareFailure(prepared) {
30568
+ const parts = [prepared.stderr, captured?.stderrText()].filter(
30569
+ (s) => typeof s === "string" && s !== ""
30570
+ );
30571
+ const stderr2 = parts.length === 0 ? void 0 : parts.join("");
30572
+ return {
30573
+ exitCode: prepared.exitCode,
30574
+ ...stderr2 === void 0 ? {} : { stderr: stderr2 }
30575
+ };
30576
+ }
30577
+ async function runPrepared(parse, run) {
30578
+ let parsedArgv;
30579
+ const prepared = await prepareSummonEnv(() => {
30580
+ parsedArgv = parse(options.argv);
30581
+ });
30582
+ if (!prepared.ok) return { fail: projectPrepareFailure(prepared) };
30583
+ return { ok: await run(prepared.env, () => parsedArgv) };
30584
+ }
30369
30585
  let result2;
30370
30586
  switch (options.role) {
30371
30587
  case "notary": {
@@ -30373,7 +30589,9 @@ async function summonPublicRole(options) {
30373
30589
  Promise.resolve().then(() => (init_notary_run(), notary_run_exports)),
30374
30590
  Promise.resolve().then(() => (init_invocation(), invocation_exports))
30375
30591
  ]);
30376
- result2 = await runPublicNotary2(options.argv, env, io, parseNotaryArgv2);
30592
+ const stepped = await runPrepared(parseNotaryArgv2, (env, once) => runPublicNotary2(options.argv, env, io, once));
30593
+ if ("fail" in stepped) return stepped.fail;
30594
+ result2 = stepped.ok;
30377
30595
  break;
30378
30596
  }
30379
30597
  case "inspector": {
@@ -30381,49 +30599,23 @@ async function summonPublicRole(options) {
30381
30599
  Promise.resolve().then(() => (init_inspector_run(), inspector_run_exports)),
30382
30600
  Promise.resolve().then(() => (init_invocation(), invocation_exports))
30383
30601
  ]);
30384
- result2 = await runPublicInspector2(options.argv, env, io, parseInspectorArgv2);
30385
- break;
30386
- }
30387
- case "auditor": {
30388
- const [{ runPublicInstructionSeat: runPublicInstructionSeat2 }, { parseAuditorArgv: parseAuditorArgv2 }] = await Promise.all([
30389
- Promise.resolve().then(() => (init_instruction_seat_run(), instruction_seat_run_exports)),
30390
- Promise.resolve().then(() => (init_invocation(), invocation_exports))
30391
- ]);
30392
- result2 = await runPublicInstructionSeat2(
30393
- options.argv,
30394
- env,
30395
- io,
30396
- "auditor",
30397
- parseAuditorArgv2
30398
- );
30399
- break;
30400
- }
30401
- case "navigator": {
30402
- const [{ runPublicInstructionSeat: runPublicInstructionSeat2 }, { parseNavigatorArgv: parseNavigatorArgv2 }] = await Promise.all([
30403
- Promise.resolve().then(() => (init_instruction_seat_run(), instruction_seat_run_exports)),
30404
- Promise.resolve().then(() => (init_invocation(), invocation_exports))
30405
- ]);
30406
- result2 = await runPublicInstructionSeat2(
30407
- options.argv,
30408
- env,
30409
- io,
30410
- "navigator",
30411
- parseNavigatorArgv2
30412
- );
30602
+ const stepped = await runPrepared(parseInspectorArgv2, (env, once) => runPublicInspector2(options.argv, env, io, once));
30603
+ if ("fail" in stepped) return stepped.fail;
30604
+ result2 = stepped.ok;
30413
30605
  break;
30414
30606
  }
30607
+ case "auditor":
30608
+ case "navigator":
30415
30609
  case "gatekeeper": {
30416
- const [{ runPublicInstructionSeat: runPublicInstructionSeat2 }, { parseGatekeeperArgv: parseGatekeeperArgv2 }] = await Promise.all([
30610
+ const seat2 = options.role;
30611
+ const [{ runPublicInstructionSeat: runPublicInstructionSeat2 }, invocation] = await Promise.all([
30417
30612
  Promise.resolve().then(() => (init_instruction_seat_run(), instruction_seat_run_exports)),
30418
30613
  Promise.resolve().then(() => (init_invocation(), invocation_exports))
30419
30614
  ]);
30420
- result2 = await runPublicInstructionSeat2(
30421
- options.argv,
30422
- env,
30423
- io,
30424
- "gatekeeper",
30425
- parseGatekeeperArgv2
30426
- );
30615
+ const parse = seat2 === "auditor" ? invocation.parseAuditorArgv : seat2 === "navigator" ? invocation.parseNavigatorArgv : invocation.parseGatekeeperArgv;
30616
+ const stepped = await runPrepared(parse, (env, once) => runPublicInstructionSeat2(options.argv, env, io, seat2, once));
30617
+ if ("fail" in stepped) return stepped.fail;
30618
+ result2 = stepped.ok;
30427
30619
  break;
30428
30620
  }
30429
30621
  case "judge": {
@@ -30431,7 +30623,9 @@ async function summonPublicRole(options) {
30431
30623
  Promise.resolve().then(() => (init_judge_run(), judge_run_exports)),
30432
30624
  Promise.resolve().then(() => (init_invocation(), invocation_exports))
30433
30625
  ]);
30434
- result2 = await runPublicJudge2(options.argv, env, io, parseJudgeArgv2);
30626
+ const stepped = await runPrepared(parseJudgeArgv2, (env, once) => runPublicJudge2(options.argv, env, io, once));
30627
+ if ("fail" in stepped) return stepped.fail;
30628
+ result2 = stepped.ok;
30435
30629
  break;
30436
30630
  }
30437
30631
  case "doctor": {
@@ -30439,7 +30633,9 @@ async function summonPublicRole(options) {
30439
30633
  Promise.resolve().then(() => (init_doctor_run(), doctor_run_exports)),
30440
30634
  Promise.resolve().then(() => (init_invocation(), invocation_exports))
30441
30635
  ]);
30442
- result2 = await runPublicDoctor2(options.argv, env, io, parseDoctorArgv2);
30636
+ const stepped = await runPrepared(parseDoctorArgv2, (env, once) => runPublicDoctor2(options.argv, env, io, once));
30637
+ if ("fail" in stepped) return stepped.fail;
30638
+ result2 = stepped.ok;
30443
30639
  break;
30444
30640
  }
30445
30641
  case "diarist": {
@@ -30447,7 +30643,9 @@ async function summonPublicRole(options) {
30447
30643
  Promise.resolve().then(() => (init_diarist_run(), diarist_run_exports)),
30448
30644
  Promise.resolve().then(() => (init_invocation(), invocation_exports))
30449
30645
  ]);
30450
- result2 = await runPublicDiarist2(options.argv, env, io, parseDiaristArgv2);
30646
+ const stepped = await runPrepared(parseDiaristArgv2, (env, once) => runPublicDiarist2(options.argv, env, io, once));
30647
+ if ("fail" in stepped) return stepped.fail;
30648
+ result2 = stepped.ok;
30451
30649
  break;
30452
30650
  }
30453
30651
  }
@@ -33657,7 +33855,7 @@ function takePublicGlobalFlag(argv, index, options) {
33657
33855
  }
33658
33856
  return void 0;
33659
33857
  }
33660
- function createRoleEnvironment(env, options) {
33858
+ function createRoleEnvironment(env, options, afterHost) {
33661
33859
  const role = options.role;
33662
33860
  const extraPiArgs = role === "coder" ? env.coderExtraPiArgs : role === "fixer" ? env.fixerExtraPiArgs : role === "reviewer" ? env.reviewerExtraPiArgs : role === "merger" ? env.mergerExtraPiArgs : role === "judge" ? env.judgeExtraPiArgs : role === "collector" ? env.collectorExtraPiArgs : role === "doctor" ? env.doctorExtraPiArgs : role === "notary" ? env.notaryExtraPiArgs : void 0;
33663
33861
  const timeoutMs = role === "coder" ? env.coderTimeoutMs : role === "fixer" ? env.fixerTimeoutMs : role === "reviewer" ? env.reviewerTimeoutMs : role === "merger" ? env.mergerTimeoutMs : role === "judge" ? env.judgeTimeoutMs : role === "collector" ? env.collectorTimeoutMs : role === "doctor" ? env.doctorTimeoutMs : role === "notary" ? env.notaryTimeoutMs : void 0;
@@ -33675,9 +33873,16 @@ function createRoleEnvironment(env, options) {
33675
33873
  role,
33676
33874
  seat: options.seat
33677
33875
  });
33678
- const hostFacingSelection = options.seat.selection === void 0 ? void 0 : projectHostFacingProvider(
33679
- options.seat.selection,
33680
- options.seat.host,
33876
+ afterHost?.();
33877
+ const seatWithModel = resolvedSeatWithModel(options.seat);
33878
+ if (seatWithModel === void 0) {
33879
+ throw new CliUsageError(
33880
+ missingResolvedSeatModelMessage(options.seat.seat, "invocation-or-config")
33881
+ );
33882
+ }
33883
+ const hostFacingSelection = projectHostFacingProvider(
33884
+ seatWithModel.selection,
33885
+ seatWithModel.host,
33681
33886
  loadHostProvidersTable(options.home),
33682
33887
  options.home
33683
33888
  );
@@ -33701,6 +33906,34 @@ function createRoleEnvironment(env, options) {
33701
33906
  ...env.freshSummons === true ? { freshSummons: true } : {}
33702
33907
  };
33703
33908
  }
33909
+ async function dispatchPublicRoleCommand(env, home, io, parsed, role, parse, run) {
33910
+ const agentDir = resolveAgentDir(env, home);
33911
+ const cwd = env.cwd ?? process.cwd();
33912
+ const config = await loadAndValidateConfig(home, env.packageRoot);
33913
+ const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
33914
+ const seat = resolveEffectiveSeat(
33915
+ config,
33916
+ role,
33917
+ credentials,
33918
+ invocationFromParsed(parsed)
33919
+ );
33920
+ let parsedRoleArgv;
33921
+ const result2 = await run(
33922
+ parsed.args,
33923
+ createRoleEnvironment(
33924
+ env,
33925
+ { role, home, agentDir, cwd, credentials, seat, config },
33926
+ () => {
33927
+ parsedRoleArgv = parse(parsed.args);
33928
+ }
33929
+ ),
33930
+ () => parsedRoleArgv
33931
+ );
33932
+ return {
33933
+ exitCode: result2.exitCode,
33934
+ ...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
33935
+ };
33936
+ }
33704
33937
  function cliResultFromRoleRun(result2) {
33705
33938
  return {
33706
33939
  exitCode: result2.exitCode,
@@ -33938,6 +34171,7 @@ function renderHelp() {
33938
34171
  "Persistent engine (callable roles): ak-role config set-engine <seat> <name> [model] | unset-engine <seat> | set-engine-model <seat> <model> | unset-engine-model <seat>",
33939
34172
  "Persistent host (callable roles): ak-role config set-host <seat> <name> | unset-host <seat>",
33940
34173
  "Host providers: ~/.ak-roles/host-providers.json (owner-edited; table > unique host directory > fail)",
34174
+ "Model resolution: --model \u2192 persistent seat \u2192 officer inherit (#620); still none \u2192 error (#178)",
33941
34175
  "Host resolution: --host \u2192 persistent seat host \u2192 pi (resume uses the same order; #617)",
33942
34176
  "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)",
33943
34177
  "Effective seats: ak-role roles"
@@ -34339,291 +34573,148 @@ async function runAkRole(argv, env) {
34339
34573
  throw new CliUsageError(`unhandled support command: ${parsed.command}`);
34340
34574
  }
34341
34575
  if (parsed.command === "judge") {
34342
- const agentDir = resolveAgentDir(env, home);
34343
- const cwd = env.cwd ?? process.cwd();
34344
- const config = await loadAndValidateConfig(home, env.packageRoot);
34345
- const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
34346
- const seat = resolveEffectiveSeat(
34347
- config,
34348
- "judge",
34349
- credentials,
34350
- invocationFromParsed(parsed)
34351
- );
34352
- const result2 = await runPublicJudge(
34353
- parsed.args,
34354
- createRoleEnvironment(env, { role: "judge", home, agentDir, cwd, credentials, seat, config }),
34576
+ return await dispatchPublicRoleCommand(
34577
+ env,
34578
+ home,
34355
34579
  io,
34356
- PUBLIC_ROLE_ARGV.judge.parse
34580
+ parsed,
34581
+ "judge",
34582
+ PUBLIC_ROLE_ARGV.judge.parse,
34583
+ (args, roleEnv, once) => runPublicJudge(args, roleEnv, io, once)
34357
34584
  );
34358
- return {
34359
- exitCode: result2.exitCode,
34360
- ...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
34361
- };
34362
34585
  }
34363
34586
  if (parsed.command === "countersign") {
34364
- const agentDir = resolveAgentDir(env, home);
34365
- const cwd = env.cwd ?? process.cwd();
34366
- const config = await loadAndValidateConfig(home, env.packageRoot);
34367
- const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
34368
- const seat = resolveEffectiveSeat(
34369
- config,
34370
- "countersign",
34371
- credentials,
34372
- invocationFromParsed(parsed)
34373
- );
34374
- const result2 = await runPublicCountersign(
34375
- parsed.args,
34376
- createRoleEnvironment(env, { role: "countersign", home, agentDir, cwd, credentials, seat, config }),
34587
+ return await dispatchPublicRoleCommand(
34588
+ env,
34589
+ home,
34377
34590
  io,
34378
- PUBLIC_ROLE_ARGV.countersign.parse
34591
+ parsed,
34592
+ "countersign",
34593
+ PUBLIC_ROLE_ARGV.countersign.parse,
34594
+ (args, roleEnv, once) => runPublicCountersign(args, roleEnv, io, once)
34379
34595
  );
34380
- return {
34381
- exitCode: result2.exitCode,
34382
- ...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
34383
- };
34384
34596
  }
34385
34597
  if (parsed.command === "gleaner-left") {
34386
- const agentDir = resolveAgentDir(env, home);
34387
- const cwd = env.cwd ?? process.cwd();
34388
- const config = await loadAndValidateConfig(home, env.packageRoot);
34389
- const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
34390
- const seat = resolveEffectiveSeat(
34391
- config,
34392
- "gleaner-left",
34393
- credentials,
34394
- invocationFromParsed(parsed)
34395
- );
34396
- const result2 = await runPublicGleanerLeft(
34397
- parsed.args,
34398
- createRoleEnvironment(env, { role: "gleaner-left", home, agentDir, cwd, credentials, seat, config }),
34598
+ return await dispatchPublicRoleCommand(
34599
+ env,
34600
+ home,
34399
34601
  io,
34400
- PUBLIC_ROLE_ARGV["gleaner-left"].parse
34602
+ parsed,
34603
+ "gleaner-left",
34604
+ PUBLIC_ROLE_ARGV["gleaner-left"].parse,
34605
+ (args, roleEnv, once) => runPublicGleanerLeft(args, roleEnv, io, once)
34401
34606
  );
34402
- return {
34403
- exitCode: result2.exitCode,
34404
- ...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
34405
- };
34406
34607
  }
34407
34608
  if (parsed.command === "diarist") {
34408
- const agentDir = resolveAgentDir(env, home);
34409
- const cwd = env.cwd ?? process.cwd();
34410
- const config = await loadAndValidateConfig(home, env.packageRoot);
34411
- const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
34412
- const seat = resolveEffectiveSeat(
34413
- config,
34414
- "diarist",
34415
- credentials,
34416
- invocationFromParsed(parsed)
34417
- );
34418
- const result2 = await runPublicDiarist(
34419
- parsed.args,
34420
- createRoleEnvironment(env, { role: "diarist", home, agentDir, cwd, credentials, seat, config }),
34609
+ return await dispatchPublicRoleCommand(
34610
+ env,
34611
+ home,
34421
34612
  io,
34422
- PUBLIC_ROLE_ARGV.diarist.parse
34613
+ parsed,
34614
+ "diarist",
34615
+ PUBLIC_ROLE_ARGV.diarist.parse,
34616
+ (args, roleEnv, once) => runPublicDiarist(args, roleEnv, io, once)
34423
34617
  );
34424
- return {
34425
- exitCode: result2.exitCode,
34426
- ...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
34427
- };
34428
34618
  }
34429
34619
  if (parsed.command === "coder") {
34430
- const agentDir = resolveAgentDir(env, home);
34431
- const cwd = env.cwd ?? process.cwd();
34432
- const config = await loadAndValidateConfig(home, env.packageRoot);
34433
- const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
34434
- const seat = resolveEffectiveSeat(
34435
- config,
34436
- "coder",
34437
- credentials,
34438
- invocationFromParsed(parsed)
34439
- );
34440
- const result2 = await runPublicCoder(
34441
- parsed.args,
34442
- createRoleEnvironment(env, { role: "coder", home, agentDir, cwd, credentials, seat, config }),
34620
+ return await dispatchPublicRoleCommand(
34621
+ env,
34622
+ home,
34443
34623
  io,
34444
- PUBLIC_ROLE_ARGV.coder.parse
34624
+ parsed,
34625
+ "coder",
34626
+ PUBLIC_ROLE_ARGV.coder.parse,
34627
+ (args, roleEnv, once) => runPublicCoder(args, roleEnv, io, once)
34445
34628
  );
34446
- return {
34447
- exitCode: result2.exitCode,
34448
- ...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
34449
- };
34450
34629
  }
34451
34630
  if (parsed.command === "fixer") {
34452
- const agentDir = resolveAgentDir(env, home);
34453
- const cwd = env.cwd ?? process.cwd();
34454
- const config = await loadAndValidateConfig(home, env.packageRoot);
34455
- const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
34456
- const seat = resolveEffectiveSeat(
34457
- config,
34458
- "fixer",
34459
- credentials,
34460
- invocationFromParsed(parsed)
34461
- );
34462
- const result2 = await runPublicFixer(
34463
- parsed.args,
34464
- createRoleEnvironment(env, { role: "fixer", home, agentDir, cwd, credentials, seat, config }),
34631
+ return await dispatchPublicRoleCommand(
34632
+ env,
34633
+ home,
34465
34634
  io,
34466
- PUBLIC_ROLE_ARGV.fixer.parse
34635
+ parsed,
34636
+ "fixer",
34637
+ PUBLIC_ROLE_ARGV.fixer.parse,
34638
+ (args, roleEnv, once) => runPublicFixer(args, roleEnv, io, once)
34467
34639
  );
34468
- return {
34469
- exitCode: result2.exitCode,
34470
- ...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
34471
- };
34472
34640
  }
34473
34641
  if (parsed.command === "collector") {
34474
- const agentDir = resolveAgentDir(env, home);
34475
- const cwd = env.cwd ?? process.cwd();
34476
- const config = await loadAndValidateConfig(home, env.packageRoot);
34477
- const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
34478
- const seat = resolveEffectiveSeat(
34479
- config,
34480
- "collector",
34481
- credentials,
34482
- invocationFromParsed(parsed)
34483
- );
34484
- const result2 = await runPublicCollector(
34485
- parsed.args,
34486
- createRoleEnvironment(env, { role: "collector", home, agentDir, cwd, credentials, seat, config }),
34642
+ return await dispatchPublicRoleCommand(
34643
+ env,
34644
+ home,
34487
34645
  io,
34488
- PUBLIC_ROLE_ARGV.collector.parse
34646
+ parsed,
34647
+ "collector",
34648
+ PUBLIC_ROLE_ARGV.collector.parse,
34649
+ (args, roleEnv, once) => runPublicCollector(args, roleEnv, io, once)
34489
34650
  );
34490
- return {
34491
- exitCode: result2.exitCode,
34492
- ...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
34493
- };
34494
34651
  }
34495
34652
  if (parsed.command === "reviewer") {
34496
- const agentDir = resolveAgentDir(env, home);
34497
- const cwd = env.cwd ?? process.cwd();
34498
- const config = await loadAndValidateConfig(home, env.packageRoot);
34499
- const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
34500
- const seat = resolveEffectiveSeat(
34501
- config,
34502
- "reviewer",
34503
- credentials,
34504
- invocationFromParsed(parsed)
34505
- );
34506
- const result2 = await runPublicReviewer(
34507
- parsed.args,
34508
- createRoleEnvironment(env, { role: "reviewer", home, agentDir, cwd, credentials, seat, config }),
34653
+ return await dispatchPublicRoleCommand(
34654
+ env,
34655
+ home,
34509
34656
  io,
34510
- PUBLIC_ROLE_ARGV.reviewer.parse
34657
+ parsed,
34658
+ "reviewer",
34659
+ PUBLIC_ROLE_ARGV.reviewer.parse,
34660
+ (args, roleEnv, once) => runPublicReviewer(args, roleEnv, io, once)
34511
34661
  );
34512
- return {
34513
- exitCode: result2.exitCode,
34514
- ...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
34515
- };
34516
34662
  }
34517
34663
  if (parsed.command === "doctor") {
34518
- const agentDir = resolveAgentDir(env, home);
34519
- const cwd = env.cwd ?? process.cwd();
34520
- const config = await loadAndValidateConfig(home, env.packageRoot);
34521
- const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
34522
- const seat = resolveEffectiveSeat(
34523
- config,
34524
- "doctor",
34525
- credentials,
34526
- invocationFromParsed(parsed)
34527
- );
34528
- const result2 = await runPublicDoctor(
34529
- parsed.args,
34530
- createRoleEnvironment(env, { role: "doctor", home, agentDir, cwd, credentials, seat, config }),
34664
+ return await dispatchPublicRoleCommand(
34665
+ env,
34666
+ home,
34531
34667
  io,
34532
- PUBLIC_ROLE_ARGV.doctor.parse
34668
+ parsed,
34669
+ "doctor",
34670
+ PUBLIC_ROLE_ARGV.doctor.parse,
34671
+ (args, roleEnv, once) => runPublicDoctor(args, roleEnv, io, once)
34533
34672
  );
34534
- return {
34535
- exitCode: result2.exitCode,
34536
- ...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
34537
- };
34538
34673
  }
34539
34674
  if (parsed.command === "notary") {
34540
- const agentDir = resolveAgentDir(env, home);
34541
- const cwd = env.cwd ?? process.cwd();
34542
- const config = await loadAndValidateConfig(home, env.packageRoot);
34543
- const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
34544
- const seat = resolveEffectiveSeat(
34545
- config,
34546
- "notary",
34547
- credentials,
34548
- invocationFromParsed(parsed)
34549
- );
34550
- const result2 = await runPublicNotary(
34551
- parsed.args,
34552
- createRoleEnvironment(env, { role: "notary", home, agentDir, cwd, credentials, seat, config }),
34675
+ return await dispatchPublicRoleCommand(
34676
+ env,
34677
+ home,
34553
34678
  io,
34554
- PUBLIC_ROLE_ARGV.notary.parse
34679
+ parsed,
34680
+ "notary",
34681
+ PUBLIC_ROLE_ARGV.notary.parse,
34682
+ (args, roleEnv, once) => runPublicNotary(args, roleEnv, io, once)
34555
34683
  );
34556
- return {
34557
- exitCode: result2.exitCode,
34558
- ...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
34559
- };
34560
34684
  }
34561
34685
  if (parsed.command === "inspector") {
34562
- const agentDir = resolveAgentDir(env, home);
34563
- const cwd = env.cwd ?? process.cwd();
34564
- const config = await loadAndValidateConfig(home, env.packageRoot);
34565
- const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
34566
- const seat = resolveEffectiveSeat(
34567
- config,
34568
- "inspector",
34569
- credentials,
34570
- invocationFromParsed(parsed)
34571
- );
34572
- const result2 = await runPublicInspector(
34573
- parsed.args,
34574
- createRoleEnvironment(env, { role: "inspector", home, agentDir, cwd, credentials, seat, config }),
34686
+ return await dispatchPublicRoleCommand(
34687
+ env,
34688
+ home,
34575
34689
  io,
34576
- PUBLIC_ROLE_ARGV.inspector.parse
34690
+ parsed,
34691
+ "inspector",
34692
+ PUBLIC_ROLE_ARGV.inspector.parse,
34693
+ (args, roleEnv, once) => runPublicInspector(args, roleEnv, io, once)
34577
34694
  );
34578
- return {
34579
- exitCode: result2.exitCode,
34580
- ...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
34581
- };
34582
34695
  }
34583
34696
  if (parsed.command === "merger") {
34584
- const agentDir = resolveAgentDir(env, home);
34585
- const cwd = env.cwd ?? process.cwd();
34586
- const config = await loadAndValidateConfig(home, env.packageRoot);
34587
- const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
34588
- const seat = resolveEffectiveSeat(
34589
- config,
34590
- "merger",
34591
- credentials,
34592
- invocationFromParsed(parsed)
34593
- );
34594
- const result2 = await runPublicMerger(
34595
- parsed.args,
34596
- createRoleEnvironment(env, { role: "merger", home, agentDir, cwd, credentials, seat, config }),
34697
+ return await dispatchPublicRoleCommand(
34698
+ env,
34699
+ home,
34597
34700
  io,
34598
- PUBLIC_ROLE_ARGV.merger.parse
34701
+ parsed,
34702
+ "merger",
34703
+ PUBLIC_ROLE_ARGV.merger.parse,
34704
+ (args, roleEnv, once) => runPublicMerger(args, roleEnv, io, once)
34599
34705
  );
34600
- return {
34601
- exitCode: result2.exitCode,
34602
- ...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
34603
- };
34604
34706
  }
34605
34707
  if (parsed.command === "gatekeeper" || parsed.command === "navigator" || parsed.command === "auditor") {
34606
- const agentDir = resolveAgentDir(env, home);
34607
- const cwd = env.cwd ?? process.cwd();
34608
- const config = await loadAndValidateConfig(home, env.packageRoot);
34609
- const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
34610
- const seat = resolveEffectiveSeat(
34611
- config,
34612
- parsed.command,
34613
- credentials,
34614
- invocationFromParsed(parsed)
34615
- );
34616
- const result2 = await runPublicInstructionSeat(
34617
- parsed.args,
34618
- createRoleEnvironment(env, { role: parsed.command, home, agentDir, cwd, credentials, seat, config }),
34708
+ const seat = parsed.command;
34709
+ return await dispatchPublicRoleCommand(
34710
+ env,
34711
+ home,
34619
34712
  io,
34620
- parsed.command,
34621
- PUBLIC_ROLE_ARGV[parsed.command].parse
34713
+ parsed,
34714
+ seat,
34715
+ PUBLIC_ROLE_ARGV[seat].parse,
34716
+ (args, roleEnv, once) => runPublicInstructionSeat(args, roleEnv, io, seat, once)
34622
34717
  );
34623
- return {
34624
- exitCode: result2.exitCode,
34625
- ...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
34626
- };
34627
34718
  }
34628
34719
  if (parsed.command === "analyst") {
34629
34720
  const result2 = await runPublicAnalyst(