@akagilnc/pi-workflow-roles 0.1.5252 → 0.1.5273

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.
@@ -3227,8 +3227,8 @@ function formatTerminalResult(result) {
3227
3227
  `diagnostic ${encodeTerminalField(result.roleOutcome.diagnostic)}`
3228
3228
  );
3229
3229
  }
3230
- if (result.roleOutcome.kind === "failure" || result.roleOutcome.kind === "no_receipt" || result.roleOutcome.kind === "audit_escalation") {
3231
- const facts = result.roleOutcome.decisiveFacts ?? {};
3230
+ if (result.roleOutcome.kind === "failure" || result.roleOutcome.kind === "no_receipt" || result.roleOutcome.kind === "audit_escalation" || result.roleOutcome.decisiveFacts?.failedAttempts !== void 0) {
3231
+ const facts = result.roleOutcome.kind === "accepted" ? { failedAttempts: result.roleOutcome.decisiveFacts?.failedAttempts } : result.roleOutcome.decisiveFacts ?? {};
3232
3232
  for (const [key, value] of Object.entries(facts)) {
3233
3233
  if (value === void 0) continue;
3234
3234
  const rendered = typeof value === "string" ? value : JSON.stringify(value);
@@ -3486,7 +3486,6 @@ __export(durable_principal_exports, {
3486
3486
  issuePiDurablePrincipalCoordinates: () => issuePiDurablePrincipalCoordinates,
3487
3487
  piDurablePrincipalAuthority: () => piDurablePrincipalAuthority
3488
3488
  });
3489
- import { lstat } from "node:fs/promises";
3490
3489
  import { join as join11 } from "node:path";
3491
3490
  function encode(coordinates) {
3492
3491
  return coordinates;
@@ -3539,15 +3538,6 @@ var init_durable_principal = __esm({
3539
3538
  sessionDirectory: record4.sessionDirectory,
3540
3539
  sessionFile: typeof record4.sessionFile === "string" && record4.sessionFile.trim() !== "" ? record4.sessionFile : join11(record4.sessionDirectory, "session.jsonl")
3541
3540
  };
3542
- },
3543
- async isAvailable(principal) {
3544
- const { sessionFile } = this.decode(principal);
3545
- try {
3546
- const stat2 = await lstat(sessionFile);
3547
- return stat2.isFile() && !stat2.isSymbolicLink();
3548
- } catch {
3549
- return false;
3550
- }
3551
3541
  }
3552
3542
  };
3553
3543
  }
@@ -3946,7 +3936,6 @@ var init_host_descriptions = __esm({
3946
3936
  modelFlag: "--model"
3947
3937
  }),
3948
3938
  modelPassing: "argv",
3949
- boundResume: "session/load",
3950
3939
  sessionBindingFile: "grok-acp-session.json"
3951
3940
  }),
3952
3941
  /**
@@ -3964,7 +3953,6 @@ var init_host_descriptions = __esm({
3964
3953
  thinkingFlag: "--reasoning"
3965
3954
  }),
3966
3955
  modelPassing: "set_model",
3967
- boundResume: "session/load",
3968
3956
  sessionBindingFile: "hermes-acp-session.json",
3969
3957
  seatProfileSoul: Object.freeze({
3970
3958
  flag: "-p",
@@ -4986,7 +4974,7 @@ var init_uuidv7 = __esm({
4986
4974
 
4987
4975
  // src/notary-source-run.ts
4988
4976
  import { dirname as dirname9, isAbsolute as isAbsolute5, join as join14, resolve as resolve8, basename as basename5 } from "node:path";
4989
- import { lstat as lstat2, realpath as realpath3 } from "node:fs/promises";
4977
+ import { lstat, realpath as realpath3 } from "node:fs/promises";
4990
4978
  async function readRetainedIdentity(runDirectory) {
4991
4979
  try {
4992
4980
  return await readRoleRunIdentity(runDirectory);
@@ -5014,7 +5002,7 @@ async function requireRunDirectory(candidate, display) {
5014
5002
  }
5015
5003
  let stat2;
5016
5004
  try {
5017
- stat2 = await lstat2(real);
5005
+ stat2 = await lstat(real);
5018
5006
  } catch (error) {
5019
5007
  throw new NotarySourceRunError(
5020
5008
  `notary --source-run is not a readable run directory: ${display}`,
@@ -6252,7 +6240,7 @@ var init_option_definitions = __esm({
6252
6240
  import { execFileSync as execFileSync2 } from "node:child_process";
6253
6241
  import { existsSync as existsSync3 } from "node:fs";
6254
6242
  import {
6255
- lstat as lstat3,
6243
+ lstat as lstat2,
6256
6244
  mkdtemp as mkdtemp2,
6257
6245
  readFile as readFile11,
6258
6246
  realpath as realpath4,
@@ -6814,7 +6802,7 @@ async function readRegularFileAttachment(sourcePath) {
6814
6802
  const absolute = isAbsolute6(sourcePath) ? sourcePath : resolve9(sourcePath);
6815
6803
  let st;
6816
6804
  try {
6817
- st = await lstat3(absolute);
6805
+ st = await lstat2(absolute);
6818
6806
  } catch (error) {
6819
6807
  throw new CliUsageError(
6820
6808
  `attachment is not a readable regular file: ${sourcePath}`,
@@ -12158,12 +12146,6 @@ function createSessionIdentityAuthority(authority, sessionBindingFile) {
12158
12146
  }
12159
12147
  };
12160
12148
  }
12161
- function resolveHostAwareSessionAvailability(host, principalAuthority) {
12162
- if (host === void 0 || host === DEFAULT_ROLE_TURN_HOST) {
12163
- return (principal) => principalAuthority.isAvailable(principal);
12164
- }
12165
- return async (principal) => await readStoredHostSessionId(host, principalAuthority, principal) !== void 0;
12166
- }
12167
12149
  async function readStoredHostSessionId(host, authority, principal) {
12168
12150
  if (host === void 0 || host === DEFAULT_ROLE_TURN_HOST) return void 0;
12169
12151
  const description = lookupHostDescription(host) ?? lookupHeadlessHostDescription(host);
@@ -12463,9 +12445,9 @@ var init_host_session_record = __esm({
12463
12445
  // src/public-cli/auto-resume.ts
12464
12446
  import { constants as fsConstants2 } from "node:fs";
12465
12447
  import { randomUUID as randomUUID5 } from "node:crypto";
12466
- import { lstat as lstat5, mkdir as mkdir3, open } from "node:fs/promises";
12448
+ import { lstat as lstat4, mkdir as mkdir3, open } from "node:fs/promises";
12467
12449
  import { join as join28 } from "node:path";
12468
- async function persistReturnedRunState(admitted, authority, options) {
12450
+ async function persistReturnedRunState(admitted, options) {
12469
12451
  if (options?.lawful === true) {
12470
12452
  await markRunTerminal(admitted.runDirectory);
12471
12453
  return;
@@ -12475,10 +12457,8 @@ async function persistReturnedRunState(admitted, authority, options) {
12475
12457
  });
12476
12458
  const typedHttp429 = resumeObservation.typedHttp429;
12477
12459
  if (admitted.principal !== void 0 && typedHttp429 !== void 0) {
12478
- if (await authority.isAvailable(admitted.principal)) {
12479
- await markRunResumable(admitted.runDirectory, typedHttp429);
12480
- return;
12481
- }
12460
+ await markRunResumable(admitted.runDirectory, typedHttp429);
12461
+ return;
12482
12462
  }
12483
12463
  await markRunTerminal(admitted.runDirectory);
12484
12464
  }
@@ -12500,20 +12480,20 @@ async function finalizeExceptionRunBestEffort(runDirectory, io) {
12500
12480
  }
12501
12481
  }
12502
12482
  async function ensureRealArtifactsDirectory(runDirectory) {
12503
- const runStat = await lstat5(runDirectory);
12483
+ const runStat = await lstat4(runDirectory);
12504
12484
  if (runStat.isSymbolicLink() || !runStat.isDirectory()) {
12505
12485
  throw new Error("run artifact retention: run directory is not a real directory");
12506
12486
  }
12507
12487
  const artifactsDir = roleRunArtifactsDirectory(runDirectory);
12508
12488
  try {
12509
- const existing = await lstat5(artifactsDir);
12489
+ const existing = await lstat4(artifactsDir);
12510
12490
  if (existing.isSymbolicLink() || !existing.isDirectory()) {
12511
12491
  throw new Error("run artifact retention: artifacts path is not a real directory");
12512
12492
  }
12513
12493
  } catch (error) {
12514
12494
  if (!isMissingPathError5(error)) throw error;
12515
12495
  await mkdir3(artifactsDir, { recursive: true });
12516
- const created = await lstat5(artifactsDir);
12496
+ const created = await lstat4(artifactsDir);
12517
12497
  if (created.isSymbolicLink() || !created.isDirectory()) {
12518
12498
  throw new Error("run artifact retention: artifacts directory is not a real directory");
12519
12499
  }
@@ -12644,7 +12624,6 @@ function dispatchExceptionFailureTerminal(input) {
12644
12624
  async function runWithAutoResumeLoop(options) {
12645
12625
  const limit = options.autoResumeLimit ?? AUTO_RESUME_LIMIT;
12646
12626
  parseAutoResumeLimit(limit);
12647
- const isPrincipalAvailable = options.isPrincipalAvailable ?? ((principal) => options.principalAuthority.isAvailable(principal));
12648
12627
  let autoResumeAttempts = 0;
12649
12628
  let isFirst = true;
12650
12629
  let currentPayload = options.buildInitialPayload();
@@ -12652,6 +12631,9 @@ async function runWithAutoResumeLoop(options) {
12652
12631
  let lastThrownError;
12653
12632
  let everyAttemptThrew = true;
12654
12633
  const retainedErrorFiles = [];
12634
+ const failedAttempts = [];
12635
+ let stoppedResult;
12636
+ let endReason;
12655
12637
  while (true) {
12656
12638
  let result;
12657
12639
  let turnStartedBeforeThrow = false;
@@ -12660,6 +12642,11 @@ async function runWithAutoResumeLoop(options) {
12660
12642
  result = await options.dispatch(currentPayload, lease, isFirst, dummyIo);
12661
12643
  } catch (error) {
12662
12644
  lastThrownError = error;
12645
+ const failedAttempt = {
12646
+ attempt: dispatchOrdinal,
12647
+ diagnostic: describeErrorIdentity(unwrapTurnDispatchedFailure(error))
12648
+ };
12649
+ failedAttempts.push(failedAttempt);
12663
12650
  turnStartedBeforeThrow = error instanceof TurnDispatchedFailure;
12664
12651
  const attempt = dispatchOrdinal;
12665
12652
  try {
@@ -12671,6 +12658,7 @@ async function runWithAutoResumeLoop(options) {
12671
12658
  error
12672
12659
  );
12673
12660
  retainedErrorFiles.push(file);
12661
+ failedAttempt.errorFile = file;
12674
12662
  options.io.stderr(
12675
12663
  `dispatch attempt ${attempt} threw (${describeErrorIdentity(error)}); full error retained at ${file}
12676
12664
  `
@@ -12691,100 +12679,30 @@ async function runWithAutoResumeLoop(options) {
12691
12679
  dispatchOrdinal += 1;
12692
12680
  if (result !== void 0) {
12693
12681
  everyAttemptThrew = false;
12694
- const terminal = result.terminal;
12695
- if (terminal !== void 0) {
12696
- terminal.autoResumeCount = autoResumeAttempts;
12697
- }
12698
- const lawful = terminal !== void 0 && isLawfulTypedTerminalOutcome(terminal.roleOutcome);
12699
- if (lawful) {
12700
- if (terminal !== void 0) {
12701
- options.io.stdout(formatTerminalResult(terminal));
12682
+ const terminal2 = result.terminal;
12683
+ if (terminal2 !== void 0) {
12684
+ terminal2.autoResumeCount = autoResumeAttempts;
12685
+ if (terminal2.roleOutcome.kind === "failure") {
12686
+ failedAttempts.push({
12687
+ attempt: dispatchOrdinal - 1,
12688
+ diagnostic: terminal2.roleOutcome.diagnostic,
12689
+ decisiveFacts: terminal2.roleOutcome.decisiveFacts
12690
+ });
12702
12691
  }
12703
- return result;
12704
- }
12705
- if (result.skipAutoResume === true) {
12706
- if (terminal !== void 0) presentTerminal(terminal, options.io);
12707
- return result;
12708
12692
  }
12709
- if (processCancelSignalName(options.signal) !== void 0) {
12710
- if (terminal !== void 0) presentTerminal(terminal, options.io);
12711
- return result;
12712
- }
12713
- }
12714
- if (result !== void 0) {
12715
- const terminal = result.terminal;
12716
- if (autoResumeAttempts >= limit) {
12717
- if (terminal !== void 0) presentTerminal(terminal, options.io);
12718
- return result;
12719
- }
12720
- if (result.turnDispatched === true && !await isPrincipalAvailable(options.admitted.principal)) {
12721
- if (terminal !== void 0) presentTerminal(terminal, options.io);
12722
- return result;
12693
+ if (terminal2 !== void 0 && isLawfulTypedTerminalOutcome(terminal2.roleOutcome) || result.skipAutoResume === true || autoResumeAttempts >= limit || processCancelSignalName(options.signal) !== void 0) {
12694
+ stoppedResult = result;
12695
+ break;
12723
12696
  }
12724
12697
  } else {
12725
12698
  if (autoResumeAttempts >= limit) {
12726
- const terminal = await attachDispatchExceptionTerminal(
12727
- options.admitted,
12728
- dispatchExceptionFailureTerminal({
12729
- role: options.admitted.role,
12730
- runId: options.admitted.runId,
12731
- causeError: lastThrownError,
12732
- errorFiles: retainedErrorFiles,
12733
- autoResumeAttempts,
12734
- endReason: "auto-resume budget exhausted",
12735
- everyAttemptThrew
12736
- }),
12737
- options.io
12738
- );
12739
- await finalizeExceptionRunBestEffort(options.admitted.runDirectory, options.io);
12740
- presentTerminal(terminal, options.io);
12741
- return {
12742
- exitCode: 1,
12743
- terminal
12744
- };
12699
+ endReason = "auto-resume budget exhausted";
12700
+ break;
12745
12701
  }
12746
12702
  const cancelName = processCancelSignalName(options.signal);
12747
12703
  if (cancelName !== void 0) {
12748
- const terminal = await attachDispatchExceptionTerminal(
12749
- options.admitted,
12750
- dispatchExceptionFailureTerminal({
12751
- role: options.admitted.role,
12752
- runId: options.admitted.runId,
12753
- causeError: lastThrownError,
12754
- errorFiles: retainedErrorFiles,
12755
- autoResumeAttempts,
12756
- endReason: `ak-role terminated by ${cancelName}`,
12757
- everyAttemptThrew
12758
- }),
12759
- options.io
12760
- );
12761
- await finalizeExceptionRunBestEffort(options.admitted.runDirectory, options.io);
12762
- presentTerminal(terminal, options.io);
12763
- return {
12764
- exitCode: 1,
12765
- terminal
12766
- };
12767
- }
12768
- if (!await isPrincipalAvailable(options.admitted.principal)) {
12769
- const terminal = await attachDispatchExceptionTerminal(
12770
- options.admitted,
12771
- dispatchExceptionFailureTerminal({
12772
- role: options.admitted.role,
12773
- runId: options.admitted.runId,
12774
- causeError: lastThrownError,
12775
- errorFiles: retainedErrorFiles,
12776
- autoResumeAttempts,
12777
- endReason: "session principal unavailable before further resume",
12778
- everyAttemptThrew
12779
- }),
12780
- options.io
12781
- );
12782
- await finalizeExceptionRunBestEffort(options.admitted.runDirectory, options.io);
12783
- presentTerminal(terminal, options.io);
12784
- return {
12785
- exitCode: 1,
12786
- terminal
12787
- };
12704
+ endReason = `ak-role terminated by ${cancelName}`;
12705
+ break;
12788
12706
  }
12789
12707
  }
12790
12708
  autoResumeAttempts++;
@@ -12793,6 +12711,34 @@ async function runWithAutoResumeLoop(options) {
12793
12711
  isFirst = false;
12794
12712
  }
12795
12713
  }
12714
+ const terminal = stoppedResult === void 0 ? await attachDispatchExceptionTerminal(
12715
+ options.admitted,
12716
+ dispatchExceptionFailureTerminal({
12717
+ role: options.admitted.role,
12718
+ runId: options.admitted.runId,
12719
+ causeError: lastThrownError,
12720
+ errorFiles: retainedErrorFiles,
12721
+ autoResumeAttempts,
12722
+ endReason,
12723
+ everyAttemptThrew
12724
+ }),
12725
+ options.io
12726
+ ) : stoppedResult.terminal;
12727
+ if (stoppedResult === void 0) {
12728
+ await finalizeExceptionRunBestEffort(options.admitted.runDirectory, options.io);
12729
+ }
12730
+ const complete = terminal !== void 0 && failedAttempts.length > 0 ? { ...terminal, roleOutcome: {
12731
+ ...terminal.roleOutcome,
12732
+ decisiveFacts: { ...terminal.roleOutcome.decisiveFacts, failedAttempts }
12733
+ } } : terminal;
12734
+ if (complete !== void 0) {
12735
+ if (isLawfulTypedTerminalOutcome(complete.roleOutcome)) {
12736
+ options.io.stdout(formatTerminalResult(complete));
12737
+ } else {
12738
+ presentTerminal(complete, options.io);
12739
+ }
12740
+ }
12741
+ return stoppedResult === void 0 ? { exitCode: 1, terminal: complete } : { ...stoppedResult, ...complete === void 0 ? {} : { terminal: complete } };
12796
12742
  }
12797
12743
  var dummyIo, TurnDispatchedFailure, DISPATCH_ERROR_RETENTION_ENTRY_TYPE;
12798
12744
  var init_auto_resume = __esm({
@@ -12961,14 +12907,9 @@ async function presentControlledFailure2(admitted, failureInput, adapters, autho
12961
12907
  ...failureInput.knownDiagnostic === void 0 ? {} : { knownDiagnostic: failureInput.knownDiagnostic },
12962
12908
  ...session === void 0 ? {} : { session }
12963
12909
  });
12964
- let resumable = false;
12965
- const typedHttp429 = resumeObservation.typedHttp429;
12966
- if (admitted.principal !== void 0) {
12967
- const sessionPrincipalAvailable = await authority.isAvailable(admitted.principal);
12968
- resumable = sessionPrincipalAvailable && typedHttp429 !== void 0;
12969
- }
12910
+ const resumable = admitted.principal !== void 0 && resumeObservation.typedHttp429 !== void 0;
12970
12911
  if (persistRunState && !failureInput.skipRunStateWrite) {
12971
- await persistReturnedRunState(admitted, authority);
12912
+ await persistReturnedRunState(admitted);
12972
12913
  }
12973
12914
  let publishedErrorPath;
12974
12915
  let terminal;
@@ -13013,7 +12954,7 @@ async function settleDeferredPersist(admitted, authority, adapters, io, result)
13013
12954
  const { needsPersist: _needsPersist, ...settledResult } = result;
13014
12955
  const lawful = isLawfulTypedTerminalOutcome(result.terminal.roleOutcome);
13015
12956
  try {
13016
- await persistReturnedRunState(admitted, authority, lawful ? { lawful: true } : void 0);
12957
+ await persistReturnedRunState(admitted, lawful ? { lawful: true } : void 0);
13017
12958
  return settledResult;
13018
12959
  } catch (error) {
13019
12960
  const failed = await settleAfterTurnStarted(
@@ -13291,7 +13232,7 @@ async function dispatchPostAdmissionTurn(input) {
13291
13232
  }
13292
13233
  if (persistRunState) {
13293
13234
  try {
13294
- await persistReturnedRunState(admitted, env.principalAuthority, { lawful: true });
13235
+ await persistReturnedRunState(admitted, { lawful: true });
13295
13236
  } catch (error) {
13296
13237
  await recordBestEffortPostDispatchDiagnostic(
13297
13238
  admitted,
@@ -13376,7 +13317,7 @@ async function dispatchPostAdmissionTurn(input) {
13376
13317
  }
13377
13318
  if (persistRunState) {
13378
13319
  try {
13379
- await persistReturnedRunState(admitted, env.principalAuthority, { lawful: true });
13320
+ await persistReturnedRunState(admitted, { lawful: true });
13380
13321
  } catch (error) {
13381
13322
  await recordBestEffortPostDispatchDiagnostic(
13382
13323
  admitted,
@@ -13593,10 +13534,6 @@ async function runPostAdmissionSeatResume(input) {
13593
13534
  return await runWithAutoResumeLoop({
13594
13535
  admitted: loaded.admitted,
13595
13536
  principalAuthority: env.principalAuthority,
13596
- isPrincipalAvailable: resolveHostAwareSessionAvailability(
13597
- env.host,
13598
- env.principalAuthority
13599
- ),
13600
13537
  io: input.io,
13601
13538
  sessionAppender: env.sessionAppender,
13602
13539
  autoResumeLimit: env.autoResumeLimit,
@@ -13784,7 +13721,6 @@ async function runPostAdmissionResumable(input) {
13784
13721
  return runWithAutoResumeLoop({
13785
13722
  admitted,
13786
13723
  principalAuthority: env.principalAuthority,
13787
- isPrincipalAvailable: resolveHostAwareSessionAvailability(env.host, env.principalAuthority),
13788
13724
  io,
13789
13725
  sessionAppender: env.sessionAppender,
13790
13726
  autoResumeLimit: env.autoResumeLimit,
@@ -13906,7 +13842,7 @@ var init_seat_ticket_binding = __esm({
13906
13842
 
13907
13843
  // src/public-cli/machine-method-skills.ts
13908
13844
  import { accessSync, constants as constants2, statSync as statSync4 } from "node:fs";
13909
- import { lstat as lstat6, mkdir as mkdir4, symlink } from "node:fs/promises";
13845
+ import { lstat as lstat5, mkdir as mkdir4, symlink } from "node:fs/promises";
13910
13846
  import { join as join30 } from "node:path";
13911
13847
  import { spawnSync as spawnSync2 } from "node:child_process";
13912
13848
  function skillRoot(home) {
@@ -13936,7 +13872,7 @@ function linkedSkillRoot(home, host) {
13936
13872
  }
13937
13873
  async function occupied(path) {
13938
13874
  try {
13939
- await lstat6(path);
13875
+ await lstat5(path);
13940
13876
  return true;
13941
13877
  } catch (error) {
13942
13878
  if (error.code !== "ENOENT") throw error;
@@ -15021,7 +14957,7 @@ async function runPublicInstructionSeatResume(request, env, io) {
15021
14957
  };
15022
14958
  let binding;
15023
14959
  try {
15024
- const loaded = await loadResumablePublicRole(env.home, request.runId, env.principalAuthority, true);
14960
+ const loaded = await loadResumablePublicRole(env.home, request.runId, env.principalAuthority);
15025
14961
  binding = loaded.admitted.role === "auditor" ? await readAuditorResumeBinding(loaded.admitted.runDirectory) : void 0;
15026
14962
  } catch (error) {
15027
14963
  if (!(error instanceof CliUsageError)) throw error;
@@ -15064,7 +15000,7 @@ async function queueConclusionFromChild(child, env, io) {
15064
15000
  }
15065
15001
  }
15066
15002
  async function continueParentAfterChild(parentRunId, child, env, io) {
15067
- const loaded = await loadResumablePublicRole(env.home, parentRunId, env.principalAuthority, true);
15003
+ const loaded = await loadResumablePublicRole(env.home, parentRunId, env.principalAuthority);
15068
15004
  if (loaded.run.state !== "admitted" && !AUDITED_ROLES.has(loaded.admitted.role)) {
15069
15005
  return runPublicInstructionSeatResume({ runId: parentRunId }, env, io);
15070
15006
  }
@@ -15259,7 +15195,7 @@ async function auditSubmittedRole(turn, env, io, passedOfficer, passedReceipt, p
15259
15195
  const escalation = chain.passes.at(-1);
15260
15196
  const escalatedRunId = escalation?.runId ?? (escalation?.runDirectory === void 0 ? void 0 : runIdFromRunDirectory(escalation.runDirectory));
15261
15197
  if (escalatedRunId === void 0) throw new Error("escalated audit has no resumable run identity");
15262
- const officer = await loadResumablePublicRole(env.home, escalatedRunId, env.principalAuthority, true);
15198
+ const officer = await loadResumablePublicRole(env.home, escalatedRunId, env.principalAuthority);
15263
15199
  const terminal2 = await trySettlePublicSeat(officer.admitted, env.principalAuthority, void 0);
15264
15200
  if (terminal2 === void 0) throw new Error("escalated audit has no terminal result");
15265
15201
  io.stdout(formatTerminalResult(terminal2));
@@ -19204,7 +19140,6 @@ __export(run_lifecycle_exports, {
19204
19140
  describeErrorIdentity: () => describeErrorIdentity,
19205
19141
  findLatestRunIdForSeatTicket: () => findLatestRunIdForSeatTicket,
19206
19142
  findRunDirectoryById: () => findRunDirectoryById,
19207
- isDurablePrincipalAvailable: () => isDurablePrincipalAvailable,
19208
19143
  isV1ResumableProvider: () => isV1ResumableProvider,
19209
19144
  loadResumablePublicRole: () => loadResumablePublicRole,
19210
19145
  markRunAdmitted: () => markRunAdmitted,
@@ -19224,7 +19159,7 @@ __export(run_lifecycle_exports, {
19224
19159
  renderResumeCommand: () => renderResumeCommand,
19225
19160
  writeRoleRunState: () => writeRoleRunState
19226
19161
  });
19227
- import { chmod, lstat as lstat7, open as open3, readdir as readdir7, readFile as readFile21, unlink as unlink5, writeFile as writeFile9 } from "node:fs/promises";
19162
+ import { chmod, lstat as lstat6, open as open3, readdir as readdir7, readFile as readFile21, unlink as unlink5, writeFile as writeFile9 } from "node:fs/promises";
19228
19163
  import { basename as basename9, join as join38 } from "node:path";
19229
19164
  function buildAutoResumeContinuationPrompt(options) {
19230
19165
  return appendEngineSessionMaterial(
@@ -19538,9 +19473,6 @@ async function clearCurrentCourt(runDirectory, expectedCourtAttemptId) {
19538
19473
  ...current.resumable === void 0 ? {} : { resumable: current.resumable }
19539
19474
  });
19540
19475
  }
19541
- async function isDurablePrincipalAvailable(principal, authority) {
19542
- return authority.isAvailable(principal);
19543
- }
19544
19476
  function describeErrorIdentity(error) {
19545
19477
  const candidate = error;
19546
19478
  const name = typeof candidate?.name === "string" && candidate.name !== "" ? candidate.name : typeof error;
@@ -19782,7 +19714,7 @@ async function runHasFormedSessionPrincipal(runDirectory) {
19782
19714
  if (disk === void 0) return false;
19783
19715
  const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : join38(disk.principalWire.sessionDirectory, "session.jsonl");
19784
19716
  try {
19785
- const stat2 = await lstat7(sessionFile);
19717
+ const stat2 = await lstat6(sessionFile);
19786
19718
  return stat2.isFile() && !stat2.isSymbolicLink();
19787
19719
  } catch (error) {
19788
19720
  if (errorCodeOf(error) === "ENOENT") return false;
@@ -19874,7 +19806,7 @@ function restoredTicketFields(fields) {
19874
19806
  ...fields.courtTicketNumbers === void 0 ? {} : { courtTicketNumbers: fields.courtTicketNumbers }
19875
19807
  };
19876
19808
  }
19877
- async function loadResumableRunRecord(home, runId, authority, allowUnformedAdmitted = false) {
19809
+ async function loadResumableRunRecord(home, runId, authority) {
19878
19810
  const runDirectory = await findRunDirectoryById(home, runId);
19879
19811
  if (runDirectory === void 0) {
19880
19812
  throw new CliUsageError(`unknown role run id: ${runId}`);
@@ -19888,11 +19820,6 @@ async function loadResumableRunRecord(home, runId, authority, allowUnformedAdmit
19888
19820
  throw new CliUsageError(`unknown role run id: ${runId}`);
19889
19821
  }
19890
19822
  const { run, principal } = materialized;
19891
- if (!(allowUnformedAdmitted && run.state === "admitted") && !await isDurablePrincipalAvailable(principal, authority)) {
19892
- throw new CliUsageError(
19893
- `role run Pi session principal is unavailable: ${runId}`
19894
- );
19895
- }
19896
19823
  let instruction = "";
19897
19824
  let instructionEmpty = true;
19898
19825
  let attachments = [];
@@ -20169,8 +20096,8 @@ async function peekRoleRunRole(home, runId) {
20169
20096
  const run = await readRoleRunIdentity(runDirectory);
20170
20097
  return run?.role;
20171
20098
  }
20172
- async function loadResumablePublicRole(home, runId, authority, allowUnformedAdmitted = false) {
20173
- const loaded = await loadResumableRunRecord(home, runId, authority, allowUnformedAdmitted);
20099
+ async function loadResumablePublicRole(home, runId, authority) {
20100
+ const loaded = await loadResumableRunRecord(home, runId, authority);
20174
20101
  return seatLoadedResult(loaded, admitResumedRole(loaded));
20175
20102
  }
20176
20103
  function admitResumedRole(loaded) {
@@ -22544,9 +22471,14 @@ function createNativeNavigatorSessionFactory(deps) {
22544
22471
  }
22545
22472
  if (outcome.kind === "failure") {
22546
22473
  providerFailure = navigatorProviderFailureFromPublicTerminal(outcome);
22474
+ const failedAttempts = outcome.decisiveFacts.failedAttempts;
22475
+ const attemptReasons = Array.isArray(failedAttempts) ? failedAttempts.map((entry, index) => {
22476
+ const fact = entry !== null && typeof entry === "object" ? entry : void 0;
22477
+ return `${typeof fact?.attempt === "number" ? fact.attempt + 1 : index + 1}: ${typeof fact?.diagnostic === "string" ? fact.diagnostic : outcome.diagnostic}`;
22478
+ }) : [];
22547
22479
  throw navigatorUnavailableError(
22548
22480
  providerFailure.source,
22549
- new Error(outcome.diagnostic),
22481
+ new Error(attemptReasons.length > 0 ? attemptReasons.join("\n") : outcome.diagnostic),
22550
22482
  providerFailure.cause
22551
22483
  );
22552
22484
  }
@@ -26119,17 +26051,25 @@ function createAcpRoleTurnHost(config) {
26119
26051
  });
26120
26052
  return loadedId;
26121
26053
  };
26122
- if (request.continuation.kind === "resume" && config.boundResume === "session/load") {
26054
+ let sessionReady = true;
26055
+ if (request.continuation.kind === "resume") {
26123
26056
  const explicitHostSessionId = request.continuation.hostSessionId;
26124
26057
  const boundSessionId = explicitHostSessionId !== void 0 && explicitHostSessionId !== "" ? explicitHostSessionId : await config.sessionIdentity.load(request.principal);
26125
26058
  if (boundSessionId !== void 0 && boundSessionId !== "") {
26126
26059
  sessionId = boundSessionId;
26127
26060
  sessionId = await loadSession(boundSessionId);
26128
26061
  sessionOpened = true;
26062
+ } else {
26063
+ outcome = failure(
26064
+ "session",
26065
+ "AcpSessionFailure",
26066
+ "session-id-missing",
26067
+ void 0,
26068
+ "resume requires a bound session id"
26069
+ );
26070
+ sessionReady = false;
26129
26071
  }
26130
- }
26131
- let sessionReady = true;
26132
- if (sessionId === void 0) {
26072
+ } else {
26133
26073
  const session = await rpc("session/new", sessionBindParams);
26134
26074
  sessionId = typeof session.sessionId === "string" ? session.sessionId : void 0;
26135
26075
  if (sessionId === void 0 || sessionId === "") {
@@ -26243,7 +26183,7 @@ function createAcpRoleTurnHost(config) {
26243
26183
 
26244
26184
  // src/acp-host/seat-profile-soul.ts
26245
26185
  import { constants as constants3 } from "node:fs";
26246
- import { access as access3, copyFile, lstat as lstat8, mkdir as mkdir6, readlink, symlink as symlink2, unlink as unlink6 } from "node:fs/promises";
26186
+ import { access as access3, copyFile, lstat as lstat7, mkdir as mkdir6, readlink, symlink as symlink2, unlink as unlink6 } from "node:fs/promises";
26247
26187
  import { dirname as dirname26, join as join48, relative as relative3, resolve as resolve21 } from "node:path";
26248
26188
  function seatProfileName(spec, role) {
26249
26189
  return `${spec.namePrefix}${role}`;
@@ -26283,7 +26223,7 @@ async function ensureSeatProfileSoul(options) {
26283
26223
  const desiredLink = relative3(profileDir, soulTarget);
26284
26224
  let current;
26285
26225
  try {
26286
- const st = await lstat8(soulPath);
26226
+ const st = await lstat7(soulPath);
26287
26227
  if (st.isSymbolicLink()) {
26288
26228
  current = await readlink(soulPath);
26289
26229
  }
@@ -26321,7 +26261,6 @@ function createProductionAcpRoleTurnHost(options) {
26321
26261
  return createComposedAcpRoleTurnHost({
26322
26262
  hostName,
26323
26263
  sessionIdentity: createSessionIdentityAuthority(principalAuthority, description.sessionBindingFile),
26324
- boundResume: description.boundResume,
26325
26264
  modelPassing: description.modelPassing,
26326
26265
  roleRuntimeDependencies: createRoleRuntimeDependencies(packageRoot),
26327
26266
  async connect(request) {