@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.
package/README.md CHANGED
@@ -25,7 +25,7 @@ ak-role judge --attach ./plan.md "Review this plan." > result.txt
25
25
 
26
26
  Exit status reports lifecycle honesty, not business success: every lawful typed result (including `audit_escalation`) exits zero; a failure without a lawful result exits nonzero, and its Terminal carries the Error Artifact ref and original cause instead of a fabricated receipt.
27
27
 
28
- `ak-role resume <runId> [message]` reopens that run under the **current seat table** for model / host / engine — the same resolution as starting a new leg (`--flag` → persistent seat → package default). Standard chain after a role `escalate`s: take the owner ruling and feed it back with `ak-role resume <runId> "<ruling>"` so the same run continues to a terminal. `[message]` applies only to seats that accept caller instruction: for those seats the optional `message` after `runId` is passed through unchanged as the continuation prompt (opaque: not parsed as flags); omit it to use the package resume envelope. Notary/符宝郎 must omit `message` and derives evidence from the existing source-run/dossier binding. Global `--model` / `--host` / `--engine` override the table for that resume only. On a real host switch (live seat host differs from the previous invocation host), prior native records of the previous host are delivered once as context to the target host; same-host resume does not re-inject. Each host writes only its native volume (Pi: `session/session.jsonl`; Grok CLI journals stay in the operator grok home, factory dossier is sitian records on the run), with unified ledger entries recorded in 司天台 (Sitian). Whether to resume is the caller's decision: the command does not require a typed HTTP 429 or a `resumable` state. Unknown run IDs and missing session principals are rejected. Every callable role accepts manual resume; Countersign and Gleaner-Left gained it in #599, Collector, Doctor, Notary, and Inspector in #633.
28
+ `ak-role resume <runId> [message]` reopens that run under the **current seat table** for model / host / engine — the same resolution as starting a new leg (`--flag` → persistent seat → package default). Standard chain after a role `escalate`s: take the owner ruling and feed it back with `ak-role resume <runId> "<ruling>"` so the same run continues to a terminal. `[message]` applies only to seats that accept caller instruction: for those seats the optional `message` after `runId` is passed through unchanged as the continuation prompt (opaque: not parsed as flags); omit it to use the package resume envelope. Notary/符宝郎 must omit `message` and derives evidence from the existing source-run/dossier binding. Global `--model` / `--thinking` / `--host` / `--engine` override the table for that resume only — place them before `<runId>` (either before `resume` or between `resume` and `<runId>`, e.g. `ak-role --model xai/grok-4.5 resume 01abc…` or `ak-role resume --model xai/grok-4.5 01abc…`); the one argv after `<runId>` is always the opaque message, never a flag (#471). On a real host switch (live seat host differs from the previous invocation host), prior native records of the previous host are delivered once as context to the target host; same-host resume does not re-inject. Each host writes only its native volume (Pi: `session/session.jsonl`; Grok CLI journals stay in the operator grok home, factory dossier is sitian records on the run), with unified ledger entries recorded in 司天台 (Sitian). Whether to resume is the caller's decision: the command does not require a typed HTTP 429 or a `resumable` state. Unknown run IDs and missing session principals are rejected. Every callable role accepts manual resume; Countersign and Gleaner-Left gained it in #599, Collector, Doctor, Notary, and Inspector in #633.
29
29
 
30
30
  Judge, coder, fixer, reviewer, and merger also retry a non-lawful LLM call in place (same `runId` and session) up to `autoResumeLimit` times. Unset defaults to 2; `ak-role config set-auto-resume-limit <N>` writes the ceiling (`0` disables). Lawful typed terminals (`accepted`, `audit_escalation`, `no_receipt`) stop immediately. Manual `ak-role resume` stays available.
31
31
 
package/README.zh-CN.md CHANGED
@@ -25,7 +25,7 @@ ak-role judge --attach ./plan.md "Review this plan." > result.txt
25
25
 
26
26
  退出码报的是生命周期诚实,不是业务成败:一切合法 typed 终态(含 `audit_escalation`)退出零;无合法终态的失败退出非零,其 Terminal 携带 Error Artifact 引用与原始原因,不伪造回执。
27
27
 
28
- `ak-role resume <runId> [message]` 按**现行席位表**的 model / host / engine 续跑该次运行——与新起角色腿同一解析(调用旗 → 席位持久 → 包默认)。角色 `escalate`(直通御前)后拿到 owner 裁定,标准续跑是 `ak-role resume <runId> "<裁定>"`——把裁定喂回同一 run,角色继续走到终局。`[message]` 只适用于接收 caller instruction 的席位:对这些席位,`runId` 后可选的 `message` 原样作为续跑 prompt(opaque:不进全局旗标语法);省略则用包自带 resume envelope。Notary/符宝郎必须省略 `message`,仅从既有 source-run/案卷绑定自取证。全局 `--model` / `--host` / `--engine` 仅覆盖本次 resume。真实换宿主时(现行席位 host 与上一次 invocation host 不同),将前序宿主原生卷宗一次性作为 context 交付目标宿主;同宿主续跑不重复注入。各宿主仅直写自身原生卷宗(Pi:`session/session.jsonl`;Grok CLI 原始会话留在操作员 grok 家,工厂卷宗为该 run 的司天台记录),统一账目归入司天台。要不要续跑由调用者决定:不再要求 typed HTTP 429,也不要求 `resumable` 状态。未知 run ID、session 主体不在则拒绝。所有可调用角色均可手动 resume:给事中、左拾遗始于 #599,通进司、太医署、符宝郎、察院始于 #633。
28
+ `ak-role resume <runId> [message]` 按**现行席位表**的 model / host / engine 续跑该次运行——与新起角色腿同一解析(调用旗 → 席位持久 → 包默认)。角色 `escalate`(直通御前)后拿到 owner 裁定,标准续跑是 `ak-role resume <runId> "<裁定>"`——把裁定喂回同一 run,角色继续走到终局。`[message]` 只适用于接收 caller instruction 的席位:对这些席位,`runId` 后可选的 `message` 原样作为续跑 prompt(opaque:不进全局旗标语法);省略则用包自带 resume envelope。Notary/符宝郎必须省略 `message`,仅从既有 source-run/案卷绑定自取证。全局 `--model` / `--thinking` / `--host` / `--engine` 仅覆盖本次 resume——须置于 `<runId>` 之前(放 `resume` 之前或 `resume` 与 `<runId>` 之间均可,例如 `ak-role --model xai/grok-4.5 resume 01abc…` 或 `ak-role resume --model xai/grok-4.5 01abc…`);`<runId>` 之后的那一个 argv 恒为原样透传的 message,绝非旗位(#471)。真实换宿主时(现行席位 host 与上一次 invocation host 不同),将前序宿主原生卷宗一次性作为 context 交付目标宿主;同宿主续跑不重复注入。各宿主仅直写自身原生卷宗(Pi:`session/session.jsonl`;Grok CLI 原始会话留在操作员 grok 家,工厂卷宗为该 run 的司天台记录),统一账目归入司天台。要不要续跑由调用者决定:不再要求 typed HTTP 429,也不要求 `resumable` 状态。未知 run ID、session 主体不在则拒绝。所有可调用角色均可手动 resume:给事中、左拾遗始于 #599,通进司、太医署、符宝郎、察院始于 #633。
29
29
 
30
30
  大理寺、将作监、修内司、御史台、校书郎在单次调用内对非 lawful LLM 终态原地续跑(同一 `runId` 与 session),次数上限为 `autoResumeLimit`。缺键默认 2;`ak-role config set-auto-resume-limit <N>` 写入(`0` 关闭自动续)。lawful typed 终态(`accepted` / `audit_escalation` / `no_receipt`)立即停止。手动 `ak-role resume` 仍可用。
31
31
 
@@ -6128,8 +6128,8 @@ var init_option_definitions = __esm({
6128
6128
  repeatable: false,
6129
6129
  form: "option",
6130
6130
  description: {
6131
- en: "Override the effective seat model for this invocation (before or after the command).",
6132
- zh: "\u8986\u76D6\u672C\u8C03\u7528\u6709\u6548\u5E2D\u4F4D\u6A21\u578B\uFF08\u53EF\u7F6E\u4E8E\u5B50\u547D\u4EE4\u524D\u6216\u540E\uFF09\u3002"
6131
+ en: "Override the effective seat model for this invocation (before or after the command name).",
6132
+ 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"
6133
6133
  }
6134
6134
  },
6135
6135
  {
@@ -6846,13 +6846,14 @@ var init_option_definitions = __esm({
6846
6846
  },
6847
6847
  resume: {
6848
6848
  command: "resume",
6849
- 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.",
6849
+ 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).",
6850
6850
  usage: ["ak-role resume <runId> [message]"],
6851
6851
  examples: [
6852
6852
  "ak-role resume 01abc\u2026",
6853
6853
  'ak-role resume 01abc\u2026 "owner ruling"',
6854
6854
  "ak-role --host grok-build resume 01abc\u2026",
6855
- "ak-role --engine agy resume 01abc\u2026"
6855
+ "ak-role --engine agy resume 01abc\u2026",
6856
+ 'ak-role resume --model xai/grok-4.5 01abc\u2026 "owner ruling"'
6856
6857
  ]
6857
6858
  },
6858
6859
  new: {
@@ -10578,7 +10579,6 @@ async function readSealedSubmission(cwd, runId, homeOrScope) {
10578
10579
  const scoped = recordsForAttempt(owned, scope.attemptId);
10579
10580
  for (let index = scoped.length - 1; index >= 0; index -= 1) {
10580
10581
  const record4 = scoped[index];
10581
- if (record4?.kind === "post-seal-anomaly") return void 0;
10582
10582
  if (record4?.kind !== "sealed") continue;
10583
10583
  const payload = record4.payload;
10584
10584
  if (payload?.type === "sealed" && isAcceptedProjection(payload.projection)) return payload.projection;
@@ -15608,8 +15608,8 @@ async function readLawfulSettlementEntries(sessionFile) {
15608
15608
  throw error instanceof Error && error.knownCause === "session" ? error : sessionReadFailure(error, "session unreadable");
15609
15609
  }
15610
15610
  }
15611
- async function readLawfulJudgeRoleOutcome(admitted, authority) {
15612
- const sealed = await sealedLedgerOutcome(admitted);
15611
+ async function readLawfulJudgeRoleOutcome(admitted, authority, scope) {
15612
+ const sealed = await sealedLedgerOutcome(admitted, scope);
15613
15613
  if (sealed?.role === "judge") {
15614
15614
  const details = sealed.decisiveFacts;
15615
15615
  return {
@@ -15620,10 +15620,10 @@ async function readLawfulJudgeRoleOutcome(admitted, authority) {
15620
15620
  decisiveFacts: withAuditNoReceiptFacts(details)
15621
15621
  };
15622
15622
  }
15623
- return auditEscalationLedgerOutcome(admitted, "judge");
15623
+ return auditEscalationLedgerOutcome(admitted, "judge", scope);
15624
15624
  }
15625
- async function settleLawfulJudgeTerminalResult(admitted, authority) {
15626
- const roleOutcome = await readLawfulJudgeRoleOutcome(admitted, authority);
15625
+ async function settleLawfulJudgeTerminalResult(admitted, authority, scope) {
15626
+ const roleOutcome = await readLawfulJudgeRoleOutcome(admitted, authority, scope);
15627
15627
  if (roleOutcome === void 0) return void 0;
15628
15628
  const coordinates = coordinatesFromAdmitted(authority, admitted);
15629
15629
  const entries = await readLawfulSettlementEntries(coordinates.sessionFile) ?? [];
@@ -15643,8 +15643,8 @@ async function settleLawfulJudgeTerminalResult(admitted, authority) {
15643
15643
  coordinates.sessionDirectory
15644
15644
  );
15645
15645
  }
15646
- async function trySettleJudgeTerminalResult(admitted, authority) {
15647
- return settleLawfulJudgeTerminalResult(admitted, authority);
15646
+ async function trySettleJudgeTerminalResult(admitted, authority, scope) {
15647
+ return settleLawfulJudgeTerminalResult(admitted, authority, scope);
15648
15648
  }
15649
15649
  async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
15650
15650
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
@@ -15696,13 +15696,13 @@ async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, option
15696
15696
  { kind: "evidence", path: evidencePath }
15697
15697
  ];
15698
15698
  }
15699
- async function settleLawfulDoctorTerminalResult(admitted, authority) {
15700
- const sealed = await sealedLedgerOutcome(admitted);
15699
+ async function settleLawfulDoctorTerminalResult(admitted, authority, scope) {
15700
+ const sealed = await sealedLedgerOutcome(admitted, scope);
15701
15701
  const coordinates = coordinatesFromAdmitted(authority, admitted);
15702
15702
  const { sessionDirectory, sessionFile } = coordinates;
15703
15703
  const entries = await readLawfulSettlementEntries(sessionFile) ?? [];
15704
15704
  if (sealed?.role !== "doctor") {
15705
- const escalation = await auditEscalationLedgerOutcome(admitted, "doctor");
15705
+ const escalation = await auditEscalationLedgerOutcome(admitted, "doctor", scope);
15706
15706
  if (escalation === void 0) return void 0;
15707
15707
  const artifacts2 = await publishDoctorArtifacts(admitted, escalation, coordinates);
15708
15708
  return withOptionalGateProjection(
@@ -15750,8 +15750,8 @@ async function settleLawfulDoctorTerminalResult(admitted, authority) {
15750
15750
  sessionDirectory
15751
15751
  );
15752
15752
  }
15753
- async function trySettleDoctorTerminalResult(admitted, authority) {
15754
- return settleLawfulDoctorTerminalResult(admitted, authority);
15753
+ async function trySettleDoctorTerminalResult(admitted, authority, scope) {
15754
+ return settleLawfulDoctorTerminalResult(admitted, authority, scope);
15755
15755
  }
15756
15756
  function currentAttemptStartIndex(entries) {
15757
15757
  for (let i = entries.length - 1; i >= 0; i -= 1) {
@@ -16871,7 +16871,8 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
16871
16871
  continuation: {
16872
16872
  kind: "resume",
16873
16873
  prompt
16874
- }
16874
+ },
16875
+ ...request.message === void 0 ? {} : { courtAttemptId: randomUUID5() }
16875
16876
  };
16876
16877
  }
16877
16878
  function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
@@ -16906,14 +16907,25 @@ async function runPostAdmissionSeatResume(input) {
16906
16907
  }
16907
16908
  throw error;
16908
16909
  }
16910
+ let adapters = input.adapters;
16911
+ if (input.afterAdmittedLoad !== void 0) {
16912
+ const prepared = await input.afterAdmittedLoad(loaded.admitted);
16913
+ if (prepared.kind === "terminal") {
16914
+ return {
16915
+ exitCode: prepared.exitCode,
16916
+ admitted: prepared.admitted,
16917
+ terminal: prepared.terminal
16918
+ };
16919
+ }
16920
+ adapters = prepared.adapters;
16921
+ }
16909
16922
  try {
16910
16923
  return await runPostAdmissionManualResume({
16911
16924
  admitted: loaded.admitted,
16912
16925
  env: input.env,
16913
16926
  io: input.io,
16914
- adapters: input.adapters,
16927
+ adapters,
16915
16928
  ...input.effectiveEngine === void 0 ? {} : { effectiveEngine: input.effectiveEngine },
16916
- forceContinuation: true,
16917
16929
  buildRequestAfterLease: async () => {
16918
16930
  let openCourtAttemptId;
16919
16931
  let admittedForBuild = loaded.admitted;
@@ -16965,7 +16977,7 @@ async function runPostAdmissionSeatResume(input) {
16965
16977
  }
16966
16978
  }
16967
16979
  let turnRequest = await input.buildTurnRequest(admittedForBuild, request);
16968
- if (openCourtAttemptId !== void 0 || request.summons !== void 0) {
16980
+ if (openCourtAttemptId !== void 0 || request.summons !== void 0 || request.message !== void 0) {
16969
16981
  const courtAttemptId = openCourtAttemptId ?? (turnRequest.courtAttemptId !== void 0 && turnRequest.courtAttemptId.length > 0 ? turnRequest.courtAttemptId : randomUUID5());
16970
16982
  turnRequest = { ...turnRequest, courtAttemptId };
16971
16983
  if (openCourtAttemptId === void 0) {
@@ -17038,38 +17050,6 @@ async function runPostAdmissionResumable(input) {
17038
17050
  })
17039
17051
  });
17040
17052
  }
17041
- async function presentSealedAcceptedManualResumeIfAny(input) {
17042
- const { admitted, env, io, adapters, shouldPresent } = input;
17043
- try {
17044
- const existing = await adapters.trySettle(admitted, env.principalAuthority);
17045
- if (existing !== void 0 && existing.roleOutcome.kind === "accepted" && shouldPresent(existing)) {
17046
- existing.autoResumeCount = 0;
17047
- io.stdout(formatTerminalResult(existing));
17048
- return {
17049
- exitCode: exitCodeForTerminalOutcome(existing.roleOutcome),
17050
- admitted,
17051
- terminal: existing
17052
- };
17053
- }
17054
- } catch (error) {
17055
- const disposition = await sealedAcceptanceRedispatchDisposition(admitted);
17056
- if (disposition.kind === "block") {
17057
- return await presentControlledFailure(
17058
- admitted,
17059
- {
17060
- timedOut: false,
17061
- code: null,
17062
- stderr: "",
17063
- thrown: disposition.reason === "authority-failed" ? disposition.cause : error
17064
- },
17065
- adapters,
17066
- env.principalAuthority,
17067
- io
17068
- );
17069
- }
17070
- }
17071
- return void 0;
17072
- }
17073
17053
  async function runPostAdmissionManualResume(input) {
17074
17054
  const {
17075
17055
  admitted,
@@ -17077,25 +17057,10 @@ async function runPostAdmissionManualResume(input) {
17077
17057
  io,
17078
17058
  adapters,
17079
17059
  effectiveEngine,
17080
- forceContinuation,
17081
17060
  buildRequestAfterLease
17082
17061
  } = input;
17083
17062
  let request = input.request;
17084
17063
  const effectiveModel = env.model;
17085
- const shouldPresent = adapters.shouldPresentSettled ?? ((terminal) => isLawfulTypedTerminalOutcome(terminal.roleOutcome));
17086
- const sealedIdempotenceInput = {
17087
- admitted,
17088
- env,
17089
- io,
17090
- adapters,
17091
- shouldPresent
17092
- };
17093
- if (forceContinuation !== true && request !== void 0) {
17094
- const presented = await presentSealedAcceptedManualResumeIfAny(
17095
- sealedIdempotenceInput
17096
- );
17097
- if (presented !== void 0) return presented;
17098
- }
17099
17064
  let lease;
17100
17065
  let staleWriterLeaseReclaimed;
17101
17066
  try {
@@ -17122,17 +17087,6 @@ async function runPostAdmissionManualResume(input) {
17122
17087
  );
17123
17088
  }
17124
17089
  request = await buildRequestAfterLease();
17125
- if (request.courtAttemptId === void 0 || request.courtAttemptId.length === 0) {
17126
- const presented = await presentSealedAcceptedManualResumeIfAny(
17127
- sealedIdempotenceInput
17128
- );
17129
- if (presented !== void 0) {
17130
- return {
17131
- ...presented,
17132
- ...staleWriterLeaseReclaimed === true ? { staleWriterLeaseReclaimed: true } : {}
17133
- };
17134
- }
17135
- }
17136
17090
  }
17137
17091
  handedOffToDispatch = true;
17138
17092
  const result = await dispatchPostAdmissionTurn({
@@ -17197,7 +17151,8 @@ function projectRoleTurnRequest(admitted, roleDetails, options) {
17197
17151
  agentDir: options.agentDir,
17198
17152
  runDirectory: admitted.runDirectory,
17199
17153
  ...options.correlationId === void 0 || options.correlationId.trim() === "" ? {} : { correlationId: options.correlationId },
17200
- ...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
17154
+ ...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs },
17155
+ ...options.courtAttemptId === void 0 || options.courtAttemptId.length === 0 ? {} : { courtAttemptId: options.courtAttemptId }
17201
17156
  };
17202
17157
  }
17203
17158
  var init_turn_request = __esm({
@@ -17850,7 +17805,7 @@ function buildJudgeTurnRequest(admitted, options) {
17850
17805
  }
17851
17806
  function judgeAdapters() {
17852
17807
  return {
17853
- trySettle: (admitted, authority) => trySettleJudgeTerminalResult(admitted, authority),
17808
+ trySettle: (admitted, authority, scope) => trySettleJudgeTerminalResult(admitted, authority, scope),
17854
17809
  resolveRunnerKnownFailure: async ({ result, sessionFile }) => {
17855
17810
  const infrastructureFailure = await readEngineDetourInfrastructureFailure(sessionFile);
17856
17811
  return result.knownFailure ?? (infrastructureFailure === void 0 ? void 0 : {
@@ -18017,7 +17972,7 @@ async function runPublicDoctor(argv, env, io, parseDoctorArgv2) {
18017
17972
  }
18018
17973
  function doctorAdapters() {
18019
17974
  return {
18020
- trySettle: (admitted, authority) => trySettleDoctorTerminalResult(admitted, authority),
17975
+ trySettle: (admitted, authority, scope) => trySettleDoctorTerminalResult(admitted, authority, scope),
18021
17976
  shouldPresentSettled: (terminal) => isLawfulTypedTerminalOutcome(terminal.roleOutcome)
18022
17977
  };
18023
17978
  }
@@ -6049,8 +6049,8 @@ var init_option_definitions = __esm({
6049
6049
  repeatable: false,
6050
6050
  form: "option",
6051
6051
  description: {
6052
- en: "Override the effective seat model for this invocation (before or after the command).",
6053
- zh: "\u8986\u76D6\u672C\u8C03\u7528\u6709\u6548\u5E2D\u4F4D\u6A21\u578B\uFF08\u53EF\u7F6E\u4E8E\u5B50\u547D\u4EE4\u524D\u6216\u540E\uFF09\u3002"
6052
+ en: "Override the effective seat model for this invocation (before or after the command name).",
6053
+ 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"
6054
6054
  }
6055
6055
  },
6056
6056
  {
@@ -6767,13 +6767,14 @@ var init_option_definitions = __esm({
6767
6767
  },
6768
6768
  resume: {
6769
6769
  command: "resume",
6770
- 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.",
6770
+ 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).",
6771
6771
  usage: ["ak-role resume <runId> [message]"],
6772
6772
  examples: [
6773
6773
  "ak-role resume 01abc\u2026",
6774
6774
  'ak-role resume 01abc\u2026 "owner ruling"',
6775
6775
  "ak-role --host grok-build resume 01abc\u2026",
6776
- "ak-role --engine agy resume 01abc\u2026"
6776
+ "ak-role --engine agy resume 01abc\u2026",
6777
+ 'ak-role resume --model xai/grok-4.5 01abc\u2026 "owner ruling"'
6777
6778
  ]
6778
6779
  },
6779
6780
  new: {
@@ -10499,7 +10500,6 @@ async function readSealedSubmission(cwd, runId, homeOrScope) {
10499
10500
  const scoped = recordsForAttempt(owned, scope.attemptId);
10500
10501
  for (let index = scoped.length - 1; index >= 0; index -= 1) {
10501
10502
  const record4 = scoped[index];
10502
- if (record4?.kind === "post-seal-anomaly") return void 0;
10503
10503
  if (record4?.kind !== "sealed") continue;
10504
10504
  const payload = record4.payload;
10505
10505
  if (payload?.type === "sealed" && isAcceptedProjection(payload.projection)) return payload.projection;
@@ -15222,8 +15222,8 @@ async function readLawfulSettlementEntries(sessionFile) {
15222
15222
  throw error instanceof Error && error.knownCause === "session" ? error : sessionReadFailure(error, "session unreadable");
15223
15223
  }
15224
15224
  }
15225
- async function readLawfulJudgeRoleOutcome(admitted, authority) {
15226
- const sealed = await sealedLedgerOutcome(admitted);
15225
+ async function readLawfulJudgeRoleOutcome(admitted, authority, scope) {
15226
+ const sealed = await sealedLedgerOutcome(admitted, scope);
15227
15227
  if (sealed?.role === "judge") {
15228
15228
  const details = sealed.decisiveFacts;
15229
15229
  return {
@@ -15234,10 +15234,10 @@ async function readLawfulJudgeRoleOutcome(admitted, authority) {
15234
15234
  decisiveFacts: withAuditNoReceiptFacts(details)
15235
15235
  };
15236
15236
  }
15237
- return auditEscalationLedgerOutcome(admitted, "judge");
15237
+ return auditEscalationLedgerOutcome(admitted, "judge", scope);
15238
15238
  }
15239
- async function settleLawfulJudgeTerminalResult(admitted, authority) {
15240
- const roleOutcome = await readLawfulJudgeRoleOutcome(admitted, authority);
15239
+ async function settleLawfulJudgeTerminalResult(admitted, authority, scope) {
15240
+ const roleOutcome = await readLawfulJudgeRoleOutcome(admitted, authority, scope);
15241
15241
  if (roleOutcome === void 0) return void 0;
15242
15242
  const coordinates = coordinatesFromAdmitted(authority, admitted);
15243
15243
  const entries = await readLawfulSettlementEntries(coordinates.sessionFile) ?? [];
@@ -15257,8 +15257,8 @@ async function settleLawfulJudgeTerminalResult(admitted, authority) {
15257
15257
  coordinates.sessionDirectory
15258
15258
  );
15259
15259
  }
15260
- async function trySettleJudgeTerminalResult(admitted, authority) {
15261
- return settleLawfulJudgeTerminalResult(admitted, authority);
15260
+ async function trySettleJudgeTerminalResult(admitted, authority, scope) {
15261
+ return settleLawfulJudgeTerminalResult(admitted, authority, scope);
15262
15262
  }
15263
15263
  async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
15264
15264
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
@@ -15310,13 +15310,13 @@ async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, option
15310
15310
  { kind: "evidence", path: evidencePath }
15311
15311
  ];
15312
15312
  }
15313
- async function settleLawfulDoctorTerminalResult(admitted, authority) {
15314
- const sealed = await sealedLedgerOutcome(admitted);
15313
+ async function settleLawfulDoctorTerminalResult(admitted, authority, scope) {
15314
+ const sealed = await sealedLedgerOutcome(admitted, scope);
15315
15315
  const coordinates = coordinatesFromAdmitted(authority, admitted);
15316
15316
  const { sessionDirectory, sessionFile } = coordinates;
15317
15317
  const entries = await readLawfulSettlementEntries(sessionFile) ?? [];
15318
15318
  if (sealed?.role !== "doctor") {
15319
- const escalation = await auditEscalationLedgerOutcome(admitted, "doctor");
15319
+ const escalation = await auditEscalationLedgerOutcome(admitted, "doctor", scope);
15320
15320
  if (escalation === void 0) return void 0;
15321
15321
  const artifacts2 = await publishDoctorArtifacts(admitted, escalation, coordinates);
15322
15322
  return withOptionalGateProjection(
@@ -15364,8 +15364,8 @@ async function settleLawfulDoctorTerminalResult(admitted, authority) {
15364
15364
  sessionDirectory
15365
15365
  );
15366
15366
  }
15367
- async function trySettleDoctorTerminalResult(admitted, authority) {
15368
- return settleLawfulDoctorTerminalResult(admitted, authority);
15367
+ async function trySettleDoctorTerminalResult(admitted, authority, scope) {
15368
+ return settleLawfulDoctorTerminalResult(admitted, authority, scope);
15369
15369
  }
15370
15370
  function currentAttemptStartIndex(entries) {
15371
15371
  for (let i = entries.length - 1; i >= 0; i -= 1) {
@@ -16485,7 +16485,8 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
16485
16485
  continuation: {
16486
16486
  kind: "resume",
16487
16487
  prompt
16488
- }
16488
+ },
16489
+ ...request.message === void 0 ? {} : { courtAttemptId: randomUUID5() }
16489
16490
  };
16490
16491
  }
16491
16492
  function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
@@ -16520,14 +16521,25 @@ async function runPostAdmissionSeatResume(input) {
16520
16521
  }
16521
16522
  throw error;
16522
16523
  }
16524
+ let adapters = input.adapters;
16525
+ if (input.afterAdmittedLoad !== void 0) {
16526
+ const prepared = await input.afterAdmittedLoad(loaded.admitted);
16527
+ if (prepared.kind === "terminal") {
16528
+ return {
16529
+ exitCode: prepared.exitCode,
16530
+ admitted: prepared.admitted,
16531
+ terminal: prepared.terminal
16532
+ };
16533
+ }
16534
+ adapters = prepared.adapters;
16535
+ }
16523
16536
  try {
16524
16537
  return await runPostAdmissionManualResume({
16525
16538
  admitted: loaded.admitted,
16526
16539
  env: input.env,
16527
16540
  io: input.io,
16528
- adapters: input.adapters,
16541
+ adapters,
16529
16542
  ...input.effectiveEngine === void 0 ? {} : { effectiveEngine: input.effectiveEngine },
16530
- forceContinuation: true,
16531
16543
  buildRequestAfterLease: async () => {
16532
16544
  let openCourtAttemptId;
16533
16545
  let admittedForBuild = loaded.admitted;
@@ -16579,7 +16591,7 @@ async function runPostAdmissionSeatResume(input) {
16579
16591
  }
16580
16592
  }
16581
16593
  let turnRequest = await input.buildTurnRequest(admittedForBuild, request);
16582
- if (openCourtAttemptId !== void 0 || request.summons !== void 0) {
16594
+ if (openCourtAttemptId !== void 0 || request.summons !== void 0 || request.message !== void 0) {
16583
16595
  const courtAttemptId = openCourtAttemptId ?? (turnRequest.courtAttemptId !== void 0 && turnRequest.courtAttemptId.length > 0 ? turnRequest.courtAttemptId : randomUUID5());
16584
16596
  turnRequest = { ...turnRequest, courtAttemptId };
16585
16597
  if (openCourtAttemptId === void 0) {
@@ -16652,38 +16664,6 @@ async function runPostAdmissionResumable(input) {
16652
16664
  })
16653
16665
  });
16654
16666
  }
16655
- async function presentSealedAcceptedManualResumeIfAny(input) {
16656
- const { admitted, env, io, adapters, shouldPresent } = input;
16657
- try {
16658
- const existing = await adapters.trySettle(admitted, env.principalAuthority);
16659
- if (existing !== void 0 && existing.roleOutcome.kind === "accepted" && shouldPresent(existing)) {
16660
- existing.autoResumeCount = 0;
16661
- io.stdout(formatTerminalResult(existing));
16662
- return {
16663
- exitCode: exitCodeForTerminalOutcome(existing.roleOutcome),
16664
- admitted,
16665
- terminal: existing
16666
- };
16667
- }
16668
- } catch (error) {
16669
- const disposition = await sealedAcceptanceRedispatchDisposition(admitted);
16670
- if (disposition.kind === "block") {
16671
- return await presentControlledFailure(
16672
- admitted,
16673
- {
16674
- timedOut: false,
16675
- code: null,
16676
- stderr: "",
16677
- thrown: disposition.reason === "authority-failed" ? disposition.cause : error
16678
- },
16679
- adapters,
16680
- env.principalAuthority,
16681
- io
16682
- );
16683
- }
16684
- }
16685
- return void 0;
16686
- }
16687
16667
  async function runPostAdmissionManualResume(input) {
16688
16668
  const {
16689
16669
  admitted,
@@ -16691,25 +16671,10 @@ async function runPostAdmissionManualResume(input) {
16691
16671
  io,
16692
16672
  adapters,
16693
16673
  effectiveEngine,
16694
- forceContinuation,
16695
16674
  buildRequestAfterLease
16696
16675
  } = input;
16697
16676
  let request = input.request;
16698
16677
  const effectiveModel = env.model;
16699
- const shouldPresent = adapters.shouldPresentSettled ?? ((terminal) => isLawfulTypedTerminalOutcome(terminal.roleOutcome));
16700
- const sealedIdempotenceInput = {
16701
- admitted,
16702
- env,
16703
- io,
16704
- adapters,
16705
- shouldPresent
16706
- };
16707
- if (forceContinuation !== true && request !== void 0) {
16708
- const presented = await presentSealedAcceptedManualResumeIfAny(
16709
- sealedIdempotenceInput
16710
- );
16711
- if (presented !== void 0) return presented;
16712
- }
16713
16678
  let lease;
16714
16679
  let staleWriterLeaseReclaimed;
16715
16680
  try {
@@ -16736,17 +16701,6 @@ async function runPostAdmissionManualResume(input) {
16736
16701
  );
16737
16702
  }
16738
16703
  request = await buildRequestAfterLease();
16739
- if (request.courtAttemptId === void 0 || request.courtAttemptId.length === 0) {
16740
- const presented = await presentSealedAcceptedManualResumeIfAny(
16741
- sealedIdempotenceInput
16742
- );
16743
- if (presented !== void 0) {
16744
- return {
16745
- ...presented,
16746
- ...staleWriterLeaseReclaimed === true ? { staleWriterLeaseReclaimed: true } : {}
16747
- };
16748
- }
16749
- }
16750
16704
  }
16751
16705
  handedOffToDispatch = true;
16752
16706
  const result = await dispatchPostAdmissionTurn({
@@ -16811,7 +16765,8 @@ function projectRoleTurnRequest(admitted, roleDetails, options) {
16811
16765
  agentDir: options.agentDir,
16812
16766
  runDirectory: admitted.runDirectory,
16813
16767
  ...options.correlationId === void 0 || options.correlationId.trim() === "" ? {} : { correlationId: options.correlationId },
16814
- ...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
16768
+ ...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs },
16769
+ ...options.courtAttemptId === void 0 || options.courtAttemptId.length === 0 ? {} : { courtAttemptId: options.courtAttemptId }
16815
16770
  };
16816
16771
  }
16817
16772
  var init_turn_request = __esm({
@@ -17464,7 +17419,7 @@ function buildJudgeTurnRequest(admitted, options) {
17464
17419
  }
17465
17420
  function judgeAdapters() {
17466
17421
  return {
17467
- trySettle: (admitted, authority) => trySettleJudgeTerminalResult(admitted, authority),
17422
+ trySettle: (admitted, authority, scope) => trySettleJudgeTerminalResult(admitted, authority, scope),
17468
17423
  resolveRunnerKnownFailure: async ({ result, sessionFile }) => {
17469
17424
  const infrastructureFailure = await readEngineDetourInfrastructureFailure(sessionFile);
17470
17425
  return result.knownFailure ?? (infrastructureFailure === void 0 ? void 0 : {
@@ -17631,7 +17586,7 @@ async function runPublicDoctor(argv, env, io, parseDoctorArgv2) {
17631
17586
  }
17632
17587
  function doctorAdapters() {
17633
17588
  return {
17634
- trySettle: (admitted, authority) => trySettleDoctorTerminalResult(admitted, authority),
17589
+ trySettle: (admitted, authority, scope) => trySettleDoctorTerminalResult(admitted, authority, scope),
17635
17590
  shouldPresentSettled: (terminal) => isLawfulTypedTerminalOutcome(terminal.roleOutcome)
17636
17591
  };
17637
17592
  }
@@ -63,7 +63,7 @@ export async function runPublicDoctor(argv, env, io, parseDoctorArgv) {
63
63
  }
64
64
  function doctorAdapters() {
65
65
  return {
66
- trySettle: (admitted, authority) => trySettleDoctorTerminalResult(admitted, authority),
66
+ trySettle: (admitted, authority, scope) => trySettleDoctorTerminalResult(admitted, authority, scope),
67
67
  shouldPresentSettled: (terminal) => isLawfulTypedTerminalOutcome(terminal.roleOutcome),
68
68
  };
69
69
  }
@@ -11,7 +11,7 @@ export function buildJudgeTurnRequest(admitted, options) {
11
11
  }
12
12
  function judgeAdapters() {
13
13
  return {
14
- trySettle: (admitted, authority) => trySettleJudgeTerminalResult(admitted, authority),
14
+ trySettle: (admitted, authority, scope) => trySettleJudgeTerminalResult(admitted, authority, scope),
15
15
  resolveRunnerKnownFailure: async ({ result, sessionFile }) => {
16
16
  const infrastructureFailure = await readEngineDetourInfrastructureFailure(sessionFile);
17
17
  return (result.knownFailure ??