agent-transport-system 0.7.8 → 0.7.10

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/dist/ats.js CHANGED
@@ -27,7 +27,7 @@ import wrapAnsi from "wrap-ansi";
27
27
  import { Box, Container, Editor, Key, ProcessTerminal, TUI, Text, getEditorKeybindings, matchesKey } from "@mariozechner/pi-tui";
28
28
 
29
29
  //#region package.json
30
- var version = "0.7.8";
30
+ var version = "0.7.10";
31
31
  var package_default = {
32
32
  $schema: "https://www.schemastore.org/package.json",
33
33
  name: "agent-transport-system",
@@ -3811,7 +3811,7 @@ async function requestLatestPackageVersion(packageName) {
3811
3811
  if (!version) throw new Error("missing version");
3812
3812
  return version;
3813
3813
  } catch (error) {
3814
- throw new Error(`version check failed: invalid registry response: ${toErrorMessage$40(error)}`);
3814
+ throw new Error(`version check failed: invalid registry response: ${toErrorMessage$38(error)}`);
3815
3815
  }
3816
3816
  }
3817
3817
  function compareSemver(a, b) {
@@ -3876,7 +3876,7 @@ function toNonEmptyString(value) {
3876
3876
  const normalized = value.trim();
3877
3877
  return normalized.length > 0 ? normalized : null;
3878
3878
  }
3879
- function toErrorMessage$40(error) {
3879
+ function toErrorMessage$38(error) {
3880
3880
  if (error instanceof Error) return error.message;
3881
3881
  return String(error);
3882
3882
  }
@@ -5068,7 +5068,7 @@ async function storeAccessToken(input) {
5068
5068
  key
5069
5069
  };
5070
5070
  }
5071
- throw new Error(`failed to store access token in macOS Keychain: ${toErrorMessage$39(error)}`);
5071
+ throw new Error(`failed to store access token in macOS Keychain: ${toErrorMessage$37(error)}`);
5072
5072
  }
5073
5073
  if (process.platform === "win32") try {
5074
5074
  await setWindowsDpapiToken({
@@ -5090,7 +5090,7 @@ async function storeAccessToken(input) {
5090
5090
  key
5091
5091
  };
5092
5092
  }
5093
- throw new Error(`failed to store access token via Windows DPAPI: ${toErrorMessage$39(error)}`);
5093
+ throw new Error(`failed to store access token via Windows DPAPI: ${toErrorMessage$37(error)}`);
5094
5094
  }
5095
5095
  if (allowInsecureFallback()) {
5096
5096
  await setInsecureFileToken({
@@ -5342,7 +5342,7 @@ function normalizeToken(value) {
5342
5342
  const normalized = value.trim();
5343
5343
  return normalized.length > 0 ? normalized : null;
5344
5344
  }
5345
- function toErrorMessage$39(error) {
5345
+ function toErrorMessage$37(error) {
5346
5346
  if (error instanceof Error) return error.message;
5347
5347
  return String(error);
5348
5348
  }
@@ -7401,7 +7401,7 @@ function createProfileMenuGuideError() {
7401
7401
  "ats profiles list | ats profiles ls",
7402
7402
  "ats profiles show <profile-id> [--profile <id>]",
7403
7403
  "ats profiles set <profile-id> [--profile <id>]",
7404
- "ats profiles update <profile-id> [--profile <id>] [--name <profileName>] [--controller-kind <builtin|custom>] [--controller-ref <id>] [--controller-enabled <true|false>] [--transport-mode <mode>] [--workspace-mode <ats-managed|custom>] [--workspace-path <path>]",
7404
+ "ats profiles update <profile-id> [--profile <id>] [--name <profileName>] [--workspace-mode <ats-managed|custom>] [--workspace-path <path>]",
7405
7405
  "ats profiles delete <profile-id> [--profile <id>] --force"
7406
7406
  ]
7407
7407
  },
@@ -8450,11 +8450,11 @@ function normalizeOptionalText$46(value) {
8450
8450
  function nowIsoString() {
8451
8451
  return (/* @__PURE__ */ new Date()).toISOString();
8452
8452
  }
8453
- function toErrorMessage$38(error) {
8453
+ function toErrorMessage$36(error) {
8454
8454
  if (error instanceof Error) return error.message;
8455
8455
  return String(error);
8456
8456
  }
8457
- function sleep$10(delayMs) {
8457
+ function sleep$9(delayMs) {
8458
8458
  return new Promise((resolve) => {
8459
8459
  setTimeout(() => {
8460
8460
  resolve();
@@ -10115,7 +10115,7 @@ async function pathExists$4(path) {
10115
10115
  throw error;
10116
10116
  }
10117
10117
  }
10118
- async function sleep$9(ms) {
10118
+ async function sleep$8(ms) {
10119
10119
  await new Promise((resolve) => setTimeout(resolve, ms));
10120
10120
  }
10121
10121
  function buildSystemServiceWaitTimeoutError(input) {
@@ -10127,7 +10127,7 @@ async function waitForCondition(input) {
10127
10127
  const pollMs = input.pollMs ?? SYSTEM_SERVICE_POLL_MS;
10128
10128
  while (Date.now() < deadline) {
10129
10129
  if (await input.until()) return;
10130
- await sleep$9(pollMs);
10130
+ await sleep$8(pollMs);
10131
10131
  }
10132
10132
  throw await input.onTimeout();
10133
10133
  }
@@ -11348,7 +11348,7 @@ const backupAndCleanRuntimeState = async (input) => {
11348
11348
  appliedAt: input.nowIso,
11349
11349
  backupPaths,
11350
11350
  cleanedPaths,
11351
- errorMessage: toErrorMessage$38(error),
11351
+ errorMessage: toErrorMessage$36(error),
11352
11352
  fromEpoch: input.fromEpoch,
11353
11353
  reason: input.reason,
11354
11354
  status: "failed",
@@ -12195,7 +12195,7 @@ function createSpaceRequestTimeoutError(input) {
12195
12195
  return error;
12196
12196
  }
12197
12197
  function createSpaceRequestNetworkError(input) {
12198
- const error = new Error(`${input.operation} request could not reach ${describeRequestTarget(input.url)} (${toErrorMessage$37(input.cause)})`, { cause: input.cause });
12198
+ const error = new Error(`${input.operation} request could not reach ${describeRequestTarget(input.url)} (${toErrorMessage$35(input.cause)})`, { cause: input.cause });
12199
12199
  error.code = "network.request_failed";
12200
12200
  return error;
12201
12201
  }
@@ -12233,7 +12233,7 @@ function describeRequestTarget(url) {
12233
12233
  return url;
12234
12234
  }
12235
12235
  }
12236
- function toErrorMessage$37(error) {
12236
+ function toErrorMessage$35(error) {
12237
12237
  if (error instanceof Error) {
12238
12238
  const message = error.message.trim();
12239
12239
  return message.length > 0 ? message : "request failed";
@@ -12243,7 +12243,7 @@ function toErrorMessage$37(error) {
12243
12243
  }
12244
12244
  function shouldWrapNetworkRequestError(error) {
12245
12245
  if (error instanceof TypeError) return true;
12246
- const message = toErrorMessage$37(error).toLowerCase();
12246
+ const message = toErrorMessage$35(error).toLowerCase();
12247
12247
  return message.includes("fetch failed") || message.includes("failed to fetch") || message.includes("network request failed");
12248
12248
  }
12249
12249
 
@@ -12306,7 +12306,7 @@ function normalizeProfileIdList(value) {
12306
12306
  if (!Array.isArray(value)) return [];
12307
12307
  return value.map((item) => normalize$1(item)).filter((item) => item.length > 0);
12308
12308
  }
12309
- function toErrorMessage$36(err) {
12309
+ function toErrorMessage$34(err) {
12310
12310
  if (err instanceof Error) return err.message;
12311
12311
  return String(err);
12312
12312
  }
@@ -13690,7 +13690,7 @@ async function verifyLaunchContractFiles(input) {
13690
13690
  };
13691
13691
  } catch (error) {
13692
13692
  return {
13693
- errorMessage: toErrorMessage$35(error),
13693
+ errorMessage: toErrorMessage$33(error),
13694
13694
  ok: false
13695
13695
  };
13696
13696
  }
@@ -13717,7 +13717,7 @@ async function verifyCliLaunchContract(input) {
13717
13717
  return fileCheck;
13718
13718
  } catch (error) {
13719
13719
  return {
13720
- errorMessage: `${input.displayName} can't start on this device: ${toErrorMessage$35(error)}`,
13720
+ errorMessage: `${input.displayName} can't start on this device: ${toErrorMessage$33(error)}`,
13721
13721
  ok: false
13722
13722
  };
13723
13723
  }
@@ -13778,7 +13778,7 @@ async function inspectInstalledNodeScriptLaunchCandidate(input) {
13778
13778
  };
13779
13779
  } catch (error) {
13780
13780
  return {
13781
- errorMessage: `${input.displayName} is installed, but ATS could not inspect its launch files: ${toErrorMessage$35(error)}`,
13781
+ errorMessage: `${input.displayName} is installed, but ATS could not inspect its launch files: ${toErrorMessage$33(error)}`,
13782
13782
  ok: false
13783
13783
  };
13784
13784
  }
@@ -13975,7 +13975,7 @@ function shortenPathForDisplay(path) {
13975
13975
  function resolveNodeVersionFromPath(path) {
13976
13976
  return normalizeOptionalText$40(path.match(NODE_VERSION_PATH_RE)?.[1]);
13977
13977
  }
13978
- function toErrorMessage$35(error) {
13978
+ function toErrorMessage$33(error) {
13979
13979
  return error instanceof Error ? error.message : String(error);
13980
13980
  }
13981
13981
 
@@ -14984,7 +14984,7 @@ async function invokeOpenClawWithSingleContextHeal(input) {
14984
14984
  createRebuildFailedError: (error) => new OpenClawRuntimeError({
14985
14985
  code: "context.rebuild_failed",
14986
14986
  errorType: "adapter",
14987
- message: `context.rebuild_failed: ${toErrorMessage$34(error)}`
14987
+ message: `context.rebuild_failed: ${toErrorMessage$32(error)}`
14988
14988
  }),
14989
14989
  invokeOnce: (sessionId) => invokeOpenClawOnce({
14990
14990
  openClawAgentId: input.openClawAgentId,
@@ -15035,11 +15035,11 @@ async function invokeOpenClawOnce(input) {
15035
15035
  throw new OpenClawRuntimeError({
15036
15036
  code: "upstream_unreachable",
15037
15037
  errorType: "adapter",
15038
- message: `upstream_unreachable: ${toErrorMessage$34(error)}`
15038
+ message: `upstream_unreachable: ${toErrorMessage$32(error)}`
15039
15039
  });
15040
15040
  }
15041
15041
  }
15042
- function toErrorMessage$34(error) {
15042
+ function toErrorMessage$32(error) {
15043
15043
  if (error instanceof Error) return error.message;
15044
15044
  return String(error);
15045
15045
  }
@@ -15332,7 +15332,7 @@ function toOpenClawGatewayTransportError(error) {
15332
15332
  });
15333
15333
  const stderr = normalizeOptionalText$32(error?.stderr);
15334
15334
  const stdout = normalizeOptionalText$32(error?.stdout);
15335
- return classifyGatewayFailure(stderr ?? stdout ?? toErrorMessage$33(error));
15335
+ return classifyGatewayFailure(stderr ?? stdout ?? toErrorMessage$31(error));
15336
15336
  }
15337
15337
  function classifyGatewayFailure(message) {
15338
15338
  return new OpenClawGatewayTransportError(classifyOpenClawFailureMessage({ message }));
@@ -15341,7 +15341,7 @@ function normalizeOptionalText$32(value) {
15341
15341
  const normalized = String(value ?? "").trim();
15342
15342
  return normalized.length > 0 ? normalized : null;
15343
15343
  }
15344
- function toErrorMessage$33(error) {
15344
+ function toErrorMessage$31(error) {
15345
15345
  return error instanceof Error ? error.message : String(error);
15346
15346
  }
15347
15347
 
@@ -15613,7 +15613,7 @@ async function runOpenClawJsonCommand(input) {
15613
15613
  try {
15614
15614
  return JSON.parse(stdout);
15615
15615
  } catch (error) {
15616
- throw new Error(`openclaw JSON output could not be parsed: ${toErrorMessage$32(error)}`);
15616
+ throw new Error(`openclaw JSON output could not be parsed: ${toErrorMessage$30(error)}`);
15617
15617
  }
15618
15618
  }
15619
15619
  async function runOpenClawCommand(input) {
@@ -15648,7 +15648,7 @@ function normalizeOptionalText$30(value) {
15648
15648
  const normalized = String(value ?? "").trim();
15649
15649
  return normalized.length > 0 ? normalized : null;
15650
15650
  }
15651
- function toErrorMessage$32(error) {
15651
+ function toErrorMessage$30(error) {
15652
15652
  return error instanceof Error ? error.message : String(error);
15653
15653
  }
15654
15654
  function isExecFileTimeoutError(error) {
@@ -15662,7 +15662,7 @@ function resolveOpenClawCliErrorMessage(error, timeoutMs) {
15662
15662
  const cliMessage = normalizeOptionalText$30(error.stderr) ?? stdout;
15663
15663
  if (timeoutMs !== void 0 && isExecFileTimeoutError(error)) return cliMessage ? `openclaw command timed out after ${String(timeoutMs)}ms: ${cliMessage}` : `openclaw command timed out after ${String(timeoutMs)}ms`;
15664
15664
  if (cliMessage) return cliMessage;
15665
- return `openclaw command failed: ${toErrorMessage$32(error)}`;
15665
+ return `openclaw command failed: ${toErrorMessage$30(error)}`;
15666
15666
  }
15667
15667
  function parseOpenClawAgentSummary(value) {
15668
15668
  if (!value || typeof value !== "object") return null;
@@ -16043,7 +16043,7 @@ async function ensureOpenClawGatewayAgentVisible(input, deps = DEFAULT_OPENCLAW_
16043
16043
  gatewayRestartAttempted: true,
16044
16044
  gatewayVisibility: "missing_before_restart"
16045
16045
  },
16046
- message: `OpenClaw gateway restart failed while making agent '${agentId}' visible: ${toErrorMessage$31(error)}`
16046
+ message: `OpenClaw gateway restart failed while making agent '${agentId}' visible: ${toErrorMessage$29(error)}`
16047
16047
  });
16048
16048
  }
16049
16049
  let lastVisibilityError = null;
@@ -16072,7 +16072,7 @@ async function ensureOpenClawGatewayAgentVisible(input, deps = DEFAULT_OPENCLAW_
16072
16072
  gatewayRestartAttempted: true,
16073
16073
  gatewayVisibility: "missing_after_restart"
16074
16074
  },
16075
- message: lastVisibilityError === null ? `OpenClaw gateway is running but agent '${agentId}' is still not visible after a gateway restart` : `OpenClaw gateway still cannot confirm agent '${agentId}' after a gateway restart: ${toErrorMessage$31(lastVisibilityError)}`
16075
+ message: lastVisibilityError === null ? `OpenClaw gateway is running but agent '${agentId}' is still not visible after a gateway restart` : `OpenClaw gateway still cannot confirm agent '${agentId}' after a gateway restart: ${toErrorMessage$29(lastVisibilityError)}`
16076
16076
  });
16077
16077
  }
16078
16078
  async function maybeCopyOpenClawAuth(input) {
@@ -16113,7 +16113,7 @@ async function ensureParentDirectory(path) {
16113
16113
  async function pathExists$2(path) {
16114
16114
  return await access(path, constants.F_OK).then(() => true).catch(() => false);
16115
16115
  }
16116
- function toErrorMessage$31(error) {
16116
+ function toErrorMessage$29(error) {
16117
16117
  return error instanceof Error ? error.message : String(error);
16118
16118
  }
16119
16119
  function normalizeBootstrapReadError(error) {
@@ -16232,7 +16232,7 @@ function assertOpenClawWorkspaceMatch(input) {
16232
16232
  });
16233
16233
  }
16234
16234
  function isOpenClawAgentAlreadyExistsError(error) {
16235
- const normalizedMessage = toErrorMessage$31(error).toLowerCase();
16235
+ const normalizedMessage = toErrorMessage$29(error).toLowerCase();
16236
16236
  return normalizedMessage.includes("agent") && normalizedMessage.includes("already exists");
16237
16237
  }
16238
16238
  function resolveProviderRuntimeWorkingDirectory(value) {
@@ -16270,7 +16270,7 @@ async function prepareOpenClawRuntime(input, deps = DEFAULT_OPENCLAW_RUNTIME_PRE
16270
16270
  }).catch((error) => {
16271
16271
  throw new DaemonServiceRunError({
16272
16272
  code: "controller.bootstrap.failed",
16273
- message: `controller.bootstrap.failed: ${toErrorMessage$30(error)}`,
16273
+ message: `controller.bootstrap.failed: ${toErrorMessage$28(error)}`,
16274
16274
  providerErrorCode: extractErrorCode$1(error)
16275
16275
  });
16276
16276
  });
@@ -16280,7 +16280,7 @@ async function prepareOpenClawRuntime(input, deps = DEFAULT_OPENCLAW_RUNTIME_PRE
16280
16280
  }).catch((error) => {
16281
16281
  throw new DaemonServiceRunError({
16282
16282
  code: "controller.gateway.unhealthy",
16283
- message: `controller.gateway.unhealthy: ${toErrorMessage$30(error)}`,
16283
+ message: `controller.gateway.unhealthy: ${toErrorMessage$28(error)}`,
16284
16284
  providerErrorCode: extractErrorCode$1(error)
16285
16285
  });
16286
16286
  });
@@ -16292,7 +16292,7 @@ async function prepareOpenClawRuntime(input, deps = DEFAULT_OPENCLAW_RUNTIME_PRE
16292
16292
  const gatewayFailure = buildOpenClawGatewayVisibilityFailure(error);
16293
16293
  throw new DaemonServiceRunError({
16294
16294
  code: "controller.gateway.unhealthy",
16295
- message: `controller.gateway.unhealthy: ${toErrorMessage$30(error)}`,
16295
+ message: `controller.gateway.unhealthy: ${toErrorMessage$28(error)}`,
16296
16296
  providerErrorCode: extractErrorCode$1(error),
16297
16297
  ...gatewayFailure
16298
16298
  });
@@ -16331,7 +16331,7 @@ function resolveOpenClawGatewayVisibilityDiagnostics(error) {
16331
16331
  gatewayVisibility: parsedGatewayVisibility.data
16332
16332
  };
16333
16333
  }
16334
- function toErrorMessage$30(error) {
16334
+ function toErrorMessage$28(error) {
16335
16335
  return error instanceof Error ? error.message : String(error);
16336
16336
  }
16337
16337
 
@@ -16381,7 +16381,7 @@ function createOpenClawLocalDiagnosticsFailure(error) {
16381
16381
  return {
16382
16382
  errorCode: extractErrorCode(error),
16383
16383
  kind: "failed",
16384
- message: toErrorMessage$29(error)
16384
+ message: toErrorMessage$27(error)
16385
16385
  };
16386
16386
  }
16387
16387
  function isOpenClawLocalDiagnosticsFailure(diagnostics) {
@@ -16465,7 +16465,7 @@ async function resolveInspectModeDiagnostics(input) {
16465
16465
  openClawBin: input.openClawBin
16466
16466
  }).then(() => "healthy").catch((error) => ({
16467
16467
  errorCode: extractErrorCode(error),
16468
- message: toErrorMessage$29(error)
16468
+ message: toErrorMessage$27(error)
16469
16469
  }));
16470
16470
  if (gatewayHealth !== "healthy") return {
16471
16471
  ...inspected,
@@ -16545,7 +16545,7 @@ async function resolveInspectGatewayVisibility(input) {
16545
16545
  return {
16546
16546
  errorCode: extractErrorCode(error),
16547
16547
  gatewayVisibility: "not_checked",
16548
- message: toErrorMessage$29(error)
16548
+ message: toErrorMessage$27(error)
16549
16549
  };
16550
16550
  }
16551
16551
  }
@@ -16554,7 +16554,7 @@ function resolveDiagnosticsFailureDetail(input) {
16554
16554
  const inspectedMessage = typeof input.inspected.message === "string" && input.inspected.message.trim().length > 0 ? input.inspected.message.trim() : null;
16555
16555
  return {
16556
16556
  errorCode: inspectedErrorCode ?? extractErrorCode(input.error),
16557
- message: inspectedMessage ?? toErrorMessage$29(input.error)
16557
+ message: inspectedMessage ?? toErrorMessage$27(input.error)
16558
16558
  };
16559
16559
  }
16560
16560
  function resolveDiagnosticsTargetAgent(input) {
@@ -16615,7 +16615,7 @@ function buildBootstrapDiagnosticStatus(bootstrapStatus, errorCode, message) {
16615
16615
  }
16616
16616
  function resolveExplicitBootstrapDiagnostic(error) {
16617
16617
  const explicitErrorCode = extractErrorCode(error);
16618
- const explicitMessage = error ? toErrorMessage$29(error) : null;
16618
+ const explicitMessage = error ? toErrorMessage$27(error) : null;
16619
16619
  switch (explicitErrorCode) {
16620
16620
  case "openclaw.bootstrap.binding_conflict": return buildBootstrapDiagnosticStatus("binding_conflict", explicitErrorCode, explicitMessage);
16621
16621
  case "openclaw.bootstrap.workspace_mismatch": return buildBootstrapDiagnosticStatus("workspace_mismatch", explicitErrorCode, explicitMessage);
@@ -16635,7 +16635,7 @@ function resolveExistingBootstrapStatus(input) {
16635
16635
  }
16636
16636
  function resolveInvalidBootstrapStatus(input) {
16637
16637
  if (input.workspaceAgents.length > 1) return buildBootstrapDiagnosticStatus("workspace_ambiguous", "openclaw.bootstrap.workspace_ambiguous", null);
16638
- return buildBootstrapDiagnosticStatus("invalid", input.bootstrapRead.error?.code ?? extractErrorCode(input.error), input.bootstrapRead.error?.message ?? (input.error ? toErrorMessage$29(input.error) : null));
16638
+ return buildBootstrapDiagnosticStatus("invalid", input.bootstrapRead.error?.code ?? extractErrorCode(input.error), input.bootstrapRead.error?.message ?? (input.error ? toErrorMessage$27(input.error) : null));
16639
16639
  }
16640
16640
  function resolveMissingBootstrapStatus(workspaceAgents, input = {}) {
16641
16641
  if (workspaceAgents.length > 1) return buildBootstrapDiagnosticStatus("workspace_ambiguous", "openclaw.bootstrap.workspace_ambiguous", null);
@@ -16679,7 +16679,7 @@ function extractProviderErrorCode(error) {
16679
16679
  const normalized = String(error.providerErrorCode ?? "").trim();
16680
16680
  return normalized.length > 0 ? normalized : null;
16681
16681
  }
16682
- function toErrorMessage$29(error) {
16682
+ function toErrorMessage$27(error) {
16683
16683
  return error instanceof Error ? error.message : String(error);
16684
16684
  }
16685
16685
 
@@ -19690,7 +19690,7 @@ async function resolveDaemonRuntimeContractCompatibility(input) {
19690
19690
  observedEpoch: null,
19691
19691
  updatedAt: null,
19692
19692
  reasonCode: "daemon.runtime_contract.unavailable",
19693
- errorMessage: toErrorMessage$38(error)
19693
+ errorMessage: toErrorMessage$36(error)
19694
19694
  };
19695
19695
  }
19696
19696
  if (!meta) return {
@@ -20011,7 +20011,7 @@ async function waitForDaemonSystemServiceToStop(input) {
20011
20011
  if (!(await input.manager.status().catch(() => null))?.running && currentRuntime?.status !== "running") return true;
20012
20012
  if (currentRuntime?.status === "stale" && !currentRuntime.managedBySystemService) return true;
20013
20013
  if (currentRuntime?.status === "not_running") return true;
20014
- await sleep$8(pollMs);
20014
+ await sleep$7(pollMs);
20015
20015
  }
20016
20016
  const finalRuntime = await readCurrentObservedDaemonRuntimeStatus().catch(() => null);
20017
20017
  if (finalRuntime?.status === "not_running") return true;
@@ -20019,7 +20019,7 @@ async function waitForDaemonSystemServiceToStop(input) {
20019
20019
  if (finalRuntime?.status === "running") return false;
20020
20020
  return (await input.manager.status().catch(() => null))?.running !== true;
20021
20021
  }
20022
- async function sleep$8(ms) {
20022
+ async function sleep$7(ms) {
20023
20023
  await new Promise((resolve) => setTimeout(resolve, ms));
20024
20024
  }
20025
20025
  async function readObservedRuntimeState() {
@@ -21031,7 +21031,7 @@ async function invokeClaudeWithSingleContextHeal(input) {
21031
21031
  return new ClaudeRuntimeError({
21032
21032
  code: "context.rebuild_failed",
21033
21033
  errorType: "adapter",
21034
- message: `context.rebuild_failed: ${toErrorMessage$28(error)}`,
21034
+ message: `context.rebuild_failed: ${toErrorMessage$26(error)}`,
21035
21035
  ...providerAccessEvidence ? { providerAccessEvidence } : {}
21036
21036
  });
21037
21037
  },
@@ -21091,7 +21091,7 @@ async function invokeClaudeOnce(input) {
21091
21091
  throw new ClaudeRuntimeError({
21092
21092
  code: "upstream_unreachable",
21093
21093
  errorType: "adapter",
21094
- message: `upstream_unreachable: ${toErrorMessage$28(error)}`
21094
+ message: `upstream_unreachable: ${toErrorMessage$26(error)}`
21095
21095
  });
21096
21096
  }
21097
21097
  }
@@ -21101,7 +21101,7 @@ function getClaudeProviderAccessEvidence(error) {
21101
21101
  if (!evidence || typeof evidence !== "object") return null;
21102
21102
  return evidence;
21103
21103
  }
21104
- function toErrorMessage$28(error) {
21104
+ function toErrorMessage$26(error) {
21105
21105
  if (error instanceof Error) return error.message;
21106
21106
  return String(error);
21107
21107
  }
@@ -21720,7 +21720,7 @@ async function invokeCodexWithSingleContextHeal(input) {
21720
21720
  createRebuildFailedError: (error) => new CodexRuntimeError({
21721
21721
  code: "context.rebuild_failed",
21722
21722
  errorType: "adapter",
21723
- message: `context.rebuild_failed: ${toErrorMessage$27(error)}`
21723
+ message: `context.rebuild_failed: ${toErrorMessage$25(error)}`
21724
21724
  }),
21725
21725
  invokeOnce: (threadId) => invokeCodexOnce({
21726
21726
  launchContract: input.launchContract,
@@ -21774,11 +21774,11 @@ async function invokeCodexOnce(input) {
21774
21774
  throw new CodexRuntimeError({
21775
21775
  code: "upstream_unreachable",
21776
21776
  errorType: "adapter",
21777
- message: `upstream_unreachable: ${toErrorMessage$27(error)}`
21777
+ message: `upstream_unreachable: ${toErrorMessage$25(error)}`
21778
21778
  });
21779
21779
  }
21780
21780
  }
21781
- function toErrorMessage$27(error) {
21781
+ function toErrorMessage$25(error) {
21782
21782
  if (error instanceof Error) return error.message;
21783
21783
  return String(error);
21784
21784
  }
@@ -22722,7 +22722,7 @@ async function syncDeviceRuntimeStateProjection(input) {
22722
22722
  const projectedControllers = await loadProjectedControllers();
22723
22723
  const registeredCustomTargetIds = await loadRegisteredCustomTargetIds();
22724
22724
  const targetStates = await listAgentTargetStates().catch((error) => {
22725
- throw new Error(`failed to load ATS agent target states: ${toErrorMessage$26(error)}`);
22725
+ throw new Error(`failed to load ATS agent target states: ${toErrorMessage$24(error)}`);
22726
22726
  });
22727
22727
  const targetStateById = new Map(targetStates.map((state) => [state.agentId, state]));
22728
22728
  const projectedControllerIds = [...projectedControllers.keys()].sort();
@@ -22796,12 +22796,12 @@ async function hasValidAuthSession() {
22796
22796
  }
22797
22797
  async function loadProjectedControllers() {
22798
22798
  return await collectProjectedControllers(await listAtsProfiles().catch((error) => {
22799
- throw new Error(`failed to list ATS profiles: ${toErrorMessage$26(error)}`);
22799
+ throw new Error(`failed to list ATS profiles: ${toErrorMessage$24(error)}`);
22800
22800
  }));
22801
22801
  }
22802
22802
  async function loadRegisteredCustomTargetIds() {
22803
22803
  const customTargets = await listAgentCustomTargets().catch((error) => {
22804
- throw new Error(`failed to list ATS custom targets: ${toErrorMessage$26(error)}`);
22804
+ throw new Error(`failed to list ATS custom targets: ${toErrorMessage$24(error)}`);
22805
22805
  });
22806
22806
  return new Set(customTargets.map((target) => target.id));
22807
22807
  }
@@ -23078,7 +23078,7 @@ function emitProjectionEvidence(result) {
23078
23078
  function normalizeText$1(value) {
23079
23079
  return String(value ?? "").trim();
23080
23080
  }
23081
- function toErrorMessage$26(error) {
23081
+ function toErrorMessage$24(error) {
23082
23082
  if (error instanceof Error) return error.message;
23083
23083
  return String(error);
23084
23084
  }
@@ -23505,7 +23505,7 @@ async function readPrimaryBindingForRouteCatalog(input) {
23505
23505
  } catch (error) {
23506
23506
  throw new DaemonServiceRunError({
23507
23507
  code: "daemon.run.primary_binding_lookup_failed",
23508
- message: `Core primary binding lookup failed for profile ${input.profile.atsProfileId}: ${toErrorMessage$38(error)}`
23508
+ message: `Core primary binding lookup failed for profile ${input.profile.atsProfileId}: ${toErrorMessage$36(error)}`
23509
23509
  });
23510
23510
  }
23511
23511
  }
@@ -23513,7 +23513,7 @@ async function repairLocalReplyStateOrThrow(input) {
23513
23513
  try {
23514
23514
  await syncDeviceRuntimeStateProjection({ mode: "repair" });
23515
23515
  } catch (error) {
23516
- const errorMessage = toErrorMessage$38(error);
23516
+ const errorMessage = toErrorMessage$36(error);
23517
23517
  emitRunLine({
23518
23518
  presenter: input.presenter,
23519
23519
  code: "daemon.run.projection_sync_failed",
@@ -23527,7 +23527,7 @@ async function repairLocalReplyStateOrThrow(input) {
23527
23527
  try {
23528
23528
  await syncProfileWorkspaceState({ mode: "repair" });
23529
23529
  } catch (error) {
23530
- const errorMessage = toErrorMessage$38(error);
23530
+ const errorMessage = toErrorMessage$36(error);
23531
23531
  emitRunLine({
23532
23532
  presenter: input.presenter,
23533
23533
  code: "daemon.run.profile_workspace_sync_failed",
@@ -23569,7 +23569,7 @@ async function syncDaemonRouteCatalogState(input) {
23569
23569
  return {
23570
23570
  status: "failed",
23571
23571
  reason: "load_failed",
23572
- errorMessage: toErrorMessage$38(error)
23572
+ errorMessage: toErrorMessage$36(error)
23573
23573
  };
23574
23574
  }
23575
23575
  const nextFingerprint = buildRouteCatalogFingerprint(nextCatalog);
@@ -23582,7 +23582,7 @@ async function syncDaemonRouteCatalogState(input) {
23582
23582
  return {
23583
23583
  status: "failed",
23584
23584
  reason: "register_failed",
23585
- errorMessage: toErrorMessage$38(error)
23585
+ errorMessage: toErrorMessage$36(error)
23586
23586
  };
23587
23587
  }
23588
23588
  applyAcceptedLeases({
@@ -23613,7 +23613,7 @@ async function syncDaemonRouteCatalogState(input) {
23613
23613
  return {
23614
23614
  status: "failed",
23615
23615
  reason: "register_failed",
23616
- errorMessage: toErrorMessage$38(error)
23616
+ errorMessage: toErrorMessage$36(error)
23617
23617
  };
23618
23618
  }
23619
23619
  const diff = buildRouteCatalogDiff({
@@ -23756,7 +23756,7 @@ async function resolveDaemonLocalServiceDemand(input) {
23756
23756
  decision: "indeterminate",
23757
23757
  hasWakeableLocalRoute: false,
23758
23758
  repairableReplyCandidateCount: 0,
23759
- reason: `failed to load local daemon routes: ${toErrorMessage$38(error)}`,
23759
+ reason: `failed to load local daemon routes: ${toErrorMessage$36(error)}`,
23760
23760
  wakeableLocalRouteCount: 0,
23761
23761
  projection
23762
23762
  };
@@ -23881,7 +23881,7 @@ async function maybeAutoStopIdleBackgroundDaemonService(input) {
23881
23881
  } catch (error) {
23882
23882
  input.presenter.line({
23883
23883
  code: `${input.codePrefix}.auto_stop_failed`,
23884
- text: `ATS could not auto-stop the background service. ${toErrorMessage$38(error)}`
23884
+ text: `ATS could not auto-stop the background service. ${toErrorMessage$36(error)}`
23885
23885
  });
23886
23886
  return {
23887
23887
  autoStopped: false,
@@ -23975,9 +23975,9 @@ async function resolveGatewayChainReadiness(input = {}) {
23975
23975
  applicable: true,
23976
23976
  baseUrl: fallbackBaseUrl,
23977
23977
  checkedAt,
23978
- details: toErrorMessage$36(error),
23978
+ details: toErrorMessage$34(error),
23979
23979
  errorCode: null,
23980
- errorMessage: toErrorMessage$36(error),
23980
+ errorMessage: toErrorMessage$34(error),
23981
23981
  failureKind: "gateway_unreachable",
23982
23982
  ready: false,
23983
23983
  status: null,
@@ -24007,17 +24007,24 @@ function extractGatewayErrorDetails(raw) {
24007
24007
  return resolveGatewayErrorDetails(raw).details;
24008
24008
  }
24009
24009
  function resolveGatewayChainRepairGuidance(input) {
24010
- if (input.failureKind === "dispatch_storage_not_ready") return {
24011
- nextSteps: [
24012
- "pnpm db:migrate:dev",
24013
- "pnpm db:verify:dev",
24014
- "pnpm dev:stop",
24015
- "pnpm dev",
24016
- formatAtsCliCommand("ats service status")
24017
- ],
24018
- summary: "Run `pnpm db:migrate:dev`, then `pnpm db:verify:dev`, then restart the local ATS dev stack with `pnpm dev:stop` and `pnpm dev`, then verify with `ats service status`."
24019
- };
24020
- if ((input.lane ?? resolveAtsEnvPreset()) === "dev-local") {
24010
+ const lane = input.lane ?? resolveAtsEnvPreset();
24011
+ if (input.failureKind === "dispatch_storage_not_ready") {
24012
+ if (lane !== "dev-local") return {
24013
+ nextSteps: ["Retry the ATS command shortly.", "If this continues, contact ATS support with the latest command output."],
24014
+ summary: "ATS cloud execution storage is temporarily unavailable. Retry shortly; if it continues, contact ATS support."
24015
+ };
24016
+ return {
24017
+ nextSteps: [
24018
+ "pnpm db:migrate:dev",
24019
+ "pnpm db:verify:dev",
24020
+ "pnpm dev:stop",
24021
+ "pnpm dev",
24022
+ formatAtsCliCommand("ats service status")
24023
+ ],
24024
+ summary: "Run `pnpm db:migrate:dev`, then `pnpm db:verify:dev`, then restart the local ATS dev stack with `pnpm dev:stop` and `pnpm dev`, then verify with `ats service status`."
24025
+ };
24026
+ }
24027
+ if (lane === "dev-local") {
24021
24028
  const repairCommand = formatAtsCliCommand("ats doctor --repair");
24022
24029
  return {
24023
24030
  nextSteps: [
@@ -24047,7 +24054,7 @@ function describeGatewayChainFailure(failureKind) {
24047
24054
  switch (failureKind) {
24048
24055
  case "local_dev_session_missing": return "ATS gateway can't reach the local ATS auth worker session.";
24049
24056
  case "auth_required": return "Gateway auth chain requires sign-in for this ATS environment.";
24050
- case "dispatch_storage_not_ready": return "Core dispatch storage is unavailable for wake execution yet.";
24057
+ case "dispatch_storage_not_ready": return "ATS cloud execution storage is temporarily unavailable.";
24051
24058
  case "gateway_unreachable": return "Gateway auth chain is unavailable.";
24052
24059
  default: return "Gateway auth chain is unhealthy.";
24053
24060
  }
@@ -24894,7 +24901,7 @@ function buildLookupFailedRouteObservationDetail(input) {
24894
24901
  observedAt: input.observedAt,
24895
24902
  reasonCode: "lookup_failed"
24896
24903
  });
24897
- const rawError = toErrorMessage$25(input.error).trim();
24904
+ const rawError = toErrorMessage$23(input.error).trim();
24898
24905
  if (rawError.length === 0 || rawError === detail) return detail;
24899
24906
  return `${detail} Raw lookup error: ${rawError}`;
24900
24907
  }
@@ -24922,7 +24929,7 @@ function enrichRuntimeStateWithManager(input) {
24922
24929
  serviceController: input.runtimeState.serviceController === "unknown" && input.serviceManager?.controller !== void 0 ? input.serviceManager.controller : input.runtimeState.serviceController
24923
24930
  };
24924
24931
  }
24925
- function toErrorMessage$25(error) {
24932
+ function toErrorMessage$23(error) {
24926
24933
  if (error instanceof Error) return error.message;
24927
24934
  return String(error);
24928
24935
  }
@@ -25341,8 +25348,8 @@ function resolveServiceReadiness(input) {
25341
25348
  nextSteps: guidance.nextSteps,
25342
25349
  reasonCodes,
25343
25350
  runtimeHeadline,
25344
- state: "local_repair_needed",
25345
- summaryText: "Needs repair"
25351
+ state: "unknown",
25352
+ summaryText: "ATS cloud temporarily unavailable"
25346
25353
  };
25347
25354
  }
25348
25355
  if (reasonCodes.some((code) => LOCAL_REPAIR_REASON_CODES.has(code))) {
@@ -25811,7 +25818,7 @@ async function captureDaemonServiceEvidence(input = {}) {
25811
25818
  errorMessage: null
25812
25819
  })).catch((error) => ({
25813
25820
  snapshot: null,
25814
- errorMessage: toErrorMessage$24(error)
25821
+ errorMessage: toErrorMessage$22(error)
25815
25822
  })),
25816
25823
  captureOwnedProcessesArtifact(phaseRootPath),
25817
25824
  captureSystemServiceDiagnosticsArtifact(phaseRootPath)
@@ -25925,7 +25932,7 @@ async function captureDirectoryArtifact(input) {
25925
25932
  };
25926
25933
  } catch (error) {
25927
25934
  return {
25928
- errorMessage: toErrorMessage$24(error),
25935
+ errorMessage: toErrorMessage$22(error),
25929
25936
  relativePath: null,
25930
25937
  sourcePath: input.sourcePath,
25931
25938
  status: "error"
@@ -25951,7 +25958,7 @@ async function captureFileArtifact(input) {
25951
25958
  };
25952
25959
  } catch (error) {
25953
25960
  return {
25954
- errorMessage: toErrorMessage$24(error),
25961
+ errorMessage: toErrorMessage$22(error),
25955
25962
  relativePath: null,
25956
25963
  sourcePath: input.sourcePath,
25957
25964
  status: "error"
@@ -25973,7 +25980,7 @@ async function captureOwnedProcessesArtifact(evidencePath) {
25973
25980
  } };
25974
25981
  } catch (error) {
25975
25982
  return { artifact: {
25976
- errorMessage: toErrorMessage$24(error),
25983
+ errorMessage: toErrorMessage$22(error),
25977
25984
  relativePath: null,
25978
25985
  sourcePath: null,
25979
25986
  status: "error"
@@ -26080,7 +26087,7 @@ async function runCommand$1(command, args, input = {}) {
26080
26087
  child.once("close", handleClose);
26081
26088
  });
26082
26089
  }
26083
- function toErrorMessage$24(error) {
26090
+ function toErrorMessage$22(error) {
26084
26091
  if (error instanceof Error) return error.message;
26085
26092
  return String(error);
26086
26093
  }
@@ -26252,7 +26259,7 @@ async function runDaemonServiceLifecycle(input) {
26252
26259
  failureStage: state.failureStage,
26253
26260
  evidencePath: state.evidencePath,
26254
26261
  recoveryStatus: "failed_before_safe_state",
26255
- errorMessage: toErrorMessage$23(error)
26262
+ errorMessage: toErrorMessage$21(error)
26256
26263
  };
26257
26264
  }
26258
26265
  }
@@ -26392,7 +26399,7 @@ async function executeDaemonServiceLifecycle(input) {
26392
26399
  }
26393
26400
  }
26394
26401
  async function recoverLifecycleFailure(input) {
26395
- const originalErrorMessage = toErrorMessage$23(input.error);
26402
+ const originalErrorMessage = toErrorMessage$21(input.error);
26396
26403
  const originalFailureStage = resolveLifecycleFailureStage(input.error, input.state.failureStage);
26397
26404
  const originalReasonCodes = resolveLifecycleFailureReasonCodes(input.error);
26398
26405
  if (input.restorePoint.trusted) {
@@ -26602,7 +26609,7 @@ async function ensureNoOwnedProcessesRemain() {
26602
26609
  return;
26603
26610
  }
26604
26611
  }
26605
- await sleep$7(STRICT_TEARDOWN_VERIFY_POLL_MS$1);
26612
+ await sleep$6(STRICT_TEARDOWN_VERIFY_POLL_MS$1);
26606
26613
  }
26607
26614
  const [ownedProcesses, runtimeStatus] = await Promise.all([listDaemonOwnedProcesses({ ignoreProcessIds: [process$1.pid, process$1.ppid].filter((pid) => Number.isInteger(pid) && pid > 0) }), readCurrentObservedDaemonRuntimeStatus()]);
26608
26615
  if (ownedProcesses.length > 0) throw new DaemonServiceLifecycleStageError({
@@ -26625,7 +26632,7 @@ async function waitForLegacySharedServiceCleanup(input) {
26625
26632
  });
26626
26633
  lastInventory = inventory;
26627
26634
  if (!(inventory.legacySharedService?.present === true || inventory.anomalies.some((anomaly) => anomaly.code === "legacy_shared_service_present"))) return;
26628
- await sleep$7(STRICT_TEARDOWN_VERIFY_POLL_MS$1);
26635
+ await sleep$6(STRICT_TEARDOWN_VERIFY_POLL_MS$1);
26629
26636
  }
26630
26637
  throw new DaemonServiceLifecycleStageError({
26631
26638
  message: "ATS Service legacy shared registration is still present after cleanup. reason=legacy_shared_service_present",
@@ -26813,7 +26820,7 @@ async function waitForVerifiedLifecycleInventory(input) {
26813
26820
  });
26814
26821
  lastInventory = inventory;
26815
26822
  lastError = verificationError;
26816
- await sleep$7(STRICT_TEARDOWN_VERIFY_POLL_MS$1);
26823
+ await sleep$6(STRICT_TEARDOWN_VERIFY_POLL_MS$1);
26817
26824
  }
26818
26825
  throw new DaemonServiceLifecycleStageError({
26819
26826
  message: lastError ?? "ATS could not verify the final local service inventory state.",
@@ -26910,7 +26917,7 @@ function resolveLifecycleFailureReasonCodes(error) {
26910
26917
  if (error instanceof DaemonServiceLifecycleStageError) return error.reasonCodes;
26911
26918
  return [];
26912
26919
  }
26913
- function toErrorMessage$23(error) {
26920
+ function toErrorMessage$21(error) {
26914
26921
  if (error instanceof Error) return error.message;
26915
26922
  return String(error);
26916
26923
  }
@@ -26927,7 +26934,7 @@ async function stopDaemonProcess$1(pid, signal) {
26927
26934
  process$1.kill(pid, signal);
26928
26935
  } catch (error) {
26929
26936
  if (error instanceof Error && error.code === "ESRCH") return true;
26930
- throw new Error(`Failed to send ${signal} to pid ${String(pid)}: ${toErrorMessage$23(error)}`);
26937
+ throw new Error(`Failed to send ${signal} to pid ${String(pid)}: ${toErrorMessage$21(error)}`);
26931
26938
  }
26932
26939
  if (signal === "SIGKILL") return true;
26933
26940
  return await waitForProcessToExit$1(pid, PROCESS_STOP_WAIT_MS);
@@ -26937,7 +26944,7 @@ async function stopDaemonProcessWithTimeout(pid, signal, timeoutMs) {
26937
26944
  process$1.kill(pid, signal);
26938
26945
  } catch (error) {
26939
26946
  if (error instanceof Error && error.code === "ESRCH") return true;
26940
- throw new Error(`Failed to send ${signal} to pid ${String(pid)}: ${toErrorMessage$23(error)}`);
26947
+ throw new Error(`Failed to send ${signal} to pid ${String(pid)}: ${toErrorMessage$21(error)}`);
26941
26948
  }
26942
26949
  return await waitForProcessToExit$1(pid, timeoutMs);
26943
26950
  }
@@ -26945,16 +26952,16 @@ async function waitForProcessToExit$1(pid, timeoutMs) {
26945
26952
  const deadline = Date.now() + timeoutMs;
26946
26953
  while (Date.now() < deadline) {
26947
26954
  if (!isPidAlive$3(pid)) return true;
26948
- await sleep$7(STRICT_TEARDOWN_VERIFY_POLL_MS$1);
26955
+ await sleep$6(STRICT_TEARDOWN_VERIFY_POLL_MS$1);
26949
26956
  }
26950
26957
  return !isPidAlive$3(pid);
26951
26958
  }
26952
- async function sleep$7(ms) {
26959
+ async function sleep$6(ms) {
26953
26960
  await new Promise((resolve) => setTimeout(resolve, ms));
26954
26961
  }
26955
26962
  function isLaunchdBootstrapIoError(serviceManager, error) {
26956
26963
  if (serviceManager.controller !== "launchd") return false;
26957
- const message = toErrorMessage$23(error).toLowerCase();
26964
+ const message = toErrorMessage$21(error).toLowerCase();
26958
26965
  return message.includes("bootstrap failed") && message.includes("input/output error");
26959
26966
  }
26960
26967
  async function writeLifecycleEvidenceEvent(input) {
@@ -27392,7 +27399,7 @@ async function resolveUpgradeStatus(input) {
27392
27399
  status: "check_failed",
27393
27400
  currentVersion: input.currentVersion,
27394
27401
  checkedAt: input.checkedAt,
27395
- error: toErrorMessage$22(error)
27402
+ error: toErrorMessage$20(error)
27396
27403
  };
27397
27404
  }
27398
27405
  }
@@ -27763,7 +27770,7 @@ function emitUpgradeCompleted(input) {
27763
27770
  text: "ATS CLI upgrade completed."
27764
27771
  });
27765
27772
  }
27766
- function toErrorMessage$22(error) {
27773
+ function toErrorMessage$20(error) {
27767
27774
  if (error instanceof Error) return error.message;
27768
27775
  return String(error);
27769
27776
  }
@@ -31968,7 +31975,7 @@ async function submitPrepareRuntimeCapabilityReports(input) {
31968
31975
  });
31969
31976
  } catch (error) {
31970
31977
  console.warn("[ats.runtime_reporting.write_failed]", {
31971
- error: toErrorMessage$21(error),
31978
+ error: toErrorMessage$19(error),
31972
31979
  event: "cli.runtime_reporting.write_failed",
31973
31980
  profileIds: input.reports.map((report) => report.diagnosticProfileId).filter((profileId) => Boolean(profileId)),
31974
31981
  reportCount: input.reports.length
@@ -32074,7 +32081,7 @@ function failedSubmission(input) {
32074
32081
  status: "failed"
32075
32082
  };
32076
32083
  }
32077
- function toErrorMessage$21(error) {
32084
+ function toErrorMessage$19(error) {
32078
32085
  if (error instanceof Error) {
32079
32086
  const message = error.message.trim();
32080
32087
  return message.length > 0 ? message : "unknown error";
@@ -32201,7 +32208,7 @@ async function ensureAgentProfileRuntimeBinding(input) {
32201
32208
  };
32202
32209
  } catch (error) {
32203
32210
  console.warn("[ats.agent_profile_binding.ensure_failed]", {
32204
- error: toErrorMessage$20(error),
32211
+ error: toErrorMessage$18(error),
32205
32212
  event: "cli.agent_profile_binding.ensure_failed",
32206
32213
  profileId: input.profile.atsProfileId
32207
32214
  });
@@ -32246,7 +32253,7 @@ async function waitForExecutionReadinessAfterBinding(input) {
32246
32253
  requestContext: input.requestContext
32247
32254
  });
32248
32255
  if (isAgentExecutionReadyOrConnecting(latest.agentExecutionReadiness)) return latest;
32249
- await sleep$6(EXECUTION_READINESS_AFTER_BINDING_RETRY_DELAY_MS);
32256
+ await sleep$5(EXECUTION_READINESS_AFTER_BINDING_RETRY_DELAY_MS);
32250
32257
  }
32251
32258
  return latest;
32252
32259
  }
@@ -32319,10 +32326,10 @@ function tryResolveBindingInput(submission) {
32319
32326
  function uniqueReasonCodes(reasonCodes) {
32320
32327
  return [...new Set(reasonCodes)];
32321
32328
  }
32322
- async function sleep$6(durationMs) {
32329
+ async function sleep$5(durationMs) {
32323
32330
  await new Promise((resolve) => setTimeout(resolve, durationMs));
32324
32331
  }
32325
- function toErrorMessage$20(error) {
32332
+ function toErrorMessage$18(error) {
32326
32333
  if (error instanceof Error) {
32327
32334
  const message = error.message.trim();
32328
32335
  return message.length > 0 ? message : "unknown error";
@@ -33936,7 +33943,7 @@ async function runAuthLogin(input) {
33936
33943
  ott: input.ott,
33937
33944
  allowBackToCaller: input.allowBackToCaller === true
33938
33945
  }).catch((error) => {
33939
- if (runtime.resolvedView === "agent") throw createAuthLoginGuideError(toErrorMessage$19(error));
33946
+ if (runtime.resolvedView === "agent") throw createAuthLoginGuideError(toErrorMessage$17(error));
33940
33947
  throw error;
33941
33948
  });
33942
33949
  if (resolved.status !== "submitted") return handleAuthLoginExit({
@@ -34005,7 +34012,7 @@ async function runAuthLogin(input) {
34005
34012
  }
34006
34013
  });
34007
34014
  }
34008
- throw createAuthLoginGuideError(toErrorMessage$19(error));
34015
+ throw createAuthLoginGuideError(toErrorMessage$17(error));
34009
34016
  }
34010
34017
  throw error;
34011
34018
  }
@@ -34342,7 +34349,7 @@ function resolveClientIdForLogin(value, resolvedView) {
34342
34349
  try {
34343
34350
  return resolveClientId(value);
34344
34351
  } catch (error) {
34345
- if (resolvedView === "agent") throw createAuthLoginGuideError(toErrorMessage$19(error));
34352
+ if (resolvedView === "agent") throw createAuthLoginGuideError(toErrorMessage$17(error));
34346
34353
  throw error;
34347
34354
  }
34348
34355
  }
@@ -34765,7 +34772,7 @@ function normalizeOptionalString$14(value) {
34765
34772
  const normalized = String(value ?? "").trim();
34766
34773
  return normalized.length > 0 ? normalized : null;
34767
34774
  }
34768
- function toErrorMessage$19(error) {
34775
+ function toErrorMessage$17(error) {
34769
34776
  if (error instanceof Error) return error.message;
34770
34777
  return String(error);
34771
34778
  }
@@ -38151,13 +38158,13 @@ async function bindImportedUpstreamConversationLocally(input) {
38151
38158
  agentContextLookupKey: seeded.agentContextLookupKey
38152
38159
  };
38153
38160
  } catch (error) {
38154
- if (!snapshot) throw new Error(`local imported upstream conversation bind failed on this device: ${toErrorMessage$18(error)}`);
38161
+ if (!snapshot) throw new Error(`local imported upstream conversation bind failed on this device: ${toErrorMessage$16(error)}`);
38155
38162
  try {
38156
38163
  await restoreImportedConversationExecution({ snapshot });
38157
38164
  } catch (restoreError) {
38158
- throw new LocalImportedUpstreamConversationBindError("daemon.control.local_imported_upstream_conversation_recovery_failed", `local imported upstream conversation bind failed and local recovery also failed on this device: original bind error: ${toErrorMessage$18(error)}; local recovery failed: ${toErrorMessage$18(restoreError)}`, { cause: restoreError });
38165
+ throw new LocalImportedUpstreamConversationBindError("daemon.control.local_imported_upstream_conversation_recovery_failed", `local imported upstream conversation bind failed and local recovery also failed on this device: original bind error: ${toErrorMessage$16(error)}; local recovery failed: ${toErrorMessage$16(restoreError)}`, { cause: restoreError });
38159
38166
  }
38160
- throw new LocalImportedUpstreamConversationBindError("daemon.control.local_imported_upstream_conversation_bind_failed", `local imported upstream conversation bind failed on this device: ${toErrorMessage$18(error)}`, { cause: error });
38167
+ throw new LocalImportedUpstreamConversationBindError("daemon.control.local_imported_upstream_conversation_bind_failed", `local imported upstream conversation bind failed on this device: ${toErrorMessage$16(error)}`, { cause: error });
38161
38168
  }
38162
38169
  }
38163
38170
  async function clearImportedUpstreamConversationLocalStateLocally(input) {
@@ -38170,10 +38177,10 @@ async function clearImportedUpstreamConversationLocalStateLocally(input) {
38170
38177
  transportMode: input.transportMode
38171
38178
  });
38172
38179
  } catch (error) {
38173
- throw new LocalImportedUpstreamConversationBindError("daemon.control.local_imported_upstream_conversation_local_state_clear_failed", "local imported upstream conversation local state clear failed on this device: " + toErrorMessage$18(error), { cause: error });
38180
+ throw new LocalImportedUpstreamConversationBindError("daemon.control.local_imported_upstream_conversation_local_state_clear_failed", "local imported upstream conversation local state clear failed on this device: " + toErrorMessage$16(error), { cause: error });
38174
38181
  }
38175
38182
  }
38176
- function toErrorMessage$18(error) {
38183
+ function toErrorMessage$16(error) {
38177
38184
  if (error instanceof Error && error.message.trim().length > 0) return error.message;
38178
38185
  return String(error);
38179
38186
  }
@@ -38912,7 +38919,7 @@ function flushDispatchResultOutbox(input) {
38912
38919
  return {
38913
38920
  ...record,
38914
38921
  attemptCount: record.attemptCount + 1,
38915
- lastFailureReason: toErrorMessage$38(error),
38922
+ lastFailureReason: toErrorMessage$36(error),
38916
38923
  nextAttemptAtMs: nowMs + resolveOutboxBackoffMs(record.attemptCount + 1),
38917
38924
  updatedAtMs: nowMs
38918
38925
  };
@@ -39086,7 +39093,7 @@ function createLocalExecutionSlots(input) {
39086
39093
  dispatchId: selectedTask.dispatchId,
39087
39094
  durationMs: Math.max(0, Date.now() - startedAtMs),
39088
39095
  errorCode: null,
39089
- errorMessage: toErrorMessage$17(error),
39096
+ errorMessage: toErrorMessage$15(error),
39090
39097
  localQueue: buildLocalQueueDiagnostics({
39091
39098
  profileId: selectedTask.profileId,
39092
39099
  queuePosition: null,
@@ -39229,7 +39236,7 @@ function createLocalExecutionSlots(input) {
39229
39236
  function buildAttemptKey(dispatchId, attemptId) {
39230
39237
  return `${dispatchId}::${attemptId}`;
39231
39238
  }
39232
- function toErrorMessage$17(error) {
39239
+ function toErrorMessage$15(error) {
39233
39240
  if (error instanceof Error && error.message.trim().length > 0) return error.message;
39234
39241
  if (typeof error === "string" && error.trim().length > 0) return error;
39235
39242
  return "unknown error";
@@ -40512,7 +40519,7 @@ function reportInvalidDeliverRequest(input) {
40512
40519
  leaseEpoch: identity.leaseEpoch,
40513
40520
  metadata: {
40514
40521
  ...buildResultDispatchJournalMetadata(resultPayload),
40515
- errorMessage: toErrorMessage$38(error),
40522
+ errorMessage: toErrorMessage$36(error),
40516
40523
  parseIssues: issues
40517
40524
  },
40518
40525
  profileId: identity.targetProfileId,
@@ -40523,10 +40530,10 @@ function reportInvalidDeliverRequest(input) {
40523
40530
  emitRunLine({
40524
40531
  presenter: input.presenter,
40525
40532
  code: "daemon.run.invalid_deliver_result_send_failed",
40526
- text: `failed to send invalid deliver result for dispatch ${identity.dispatchId}: ${toErrorMessage$38(error)}`,
40533
+ text: `failed to send invalid deliver result for dispatch ${identity.dispatchId}: ${toErrorMessage$36(error)}`,
40527
40534
  payload: {
40528
40535
  dispatchId: identity.dispatchId,
40529
- errorMessage: toErrorMessage$38(error),
40536
+ errorMessage: toErrorMessage$36(error),
40530
40537
  result: "failed",
40531
40538
  taskId: identity.taskId
40532
40539
  }
@@ -41720,7 +41727,7 @@ function normalizeResolvedPostMessageAction(input) {
41720
41727
  resolvedSpaceAction: normalizedPostMessageAction.action
41721
41728
  };
41722
41729
  } catch (error) {
41723
- const failureReason = toErrorMessage$38(error);
41730
+ const failureReason = toErrorMessage$36(error);
41724
41731
  emitRunLine({
41725
41732
  presenter: input.presenter,
41726
41733
  code: "daemon.run.post_message_validation_rejected",
@@ -41786,7 +41793,7 @@ function normalizeResolvedThreadAction(input) {
41786
41793
  })
41787
41794
  };
41788
41795
  } catch (error) {
41789
- const failureReason = toErrorMessage$38(error);
41796
+ const failureReason = toErrorMessage$36(error);
41790
41797
  emitRunLine({
41791
41798
  presenter: input.presenter,
41792
41799
  code: "daemon.run.thread_action_validation_rejected",
@@ -41895,7 +41902,7 @@ async function maybeRepairStructuredSpaceAction(input) {
41895
41902
  dispatchId: input.parsedTask.dispatchId,
41896
41903
  ...resolveStructuredActionFailureDiagnostics({
41897
41904
  carrierKind: "none",
41898
- parseError: toErrorMessage$38(error),
41905
+ parseError: toErrorMessage$36(error),
41899
41906
  publicFailureReason: input.failureReason,
41900
41907
  repairMode: "controller_roundtrip",
41901
41908
  runtimeResult: input.runtimeResult
@@ -41911,7 +41918,7 @@ async function maybeRepairStructuredSpaceAction(input) {
41911
41918
  return {
41912
41919
  finalFailureDiagnostics: resolveStructuredActionFailureDiagnostics({
41913
41920
  carrierKind: "none",
41914
- parseError: toErrorMessage$38(error),
41921
+ parseError: toErrorMessage$36(error),
41915
41922
  publicFailureReason: input.failureReason,
41916
41923
  repairMode: "controller_roundtrip",
41917
41924
  runtimeResult: input.runtimeResult
@@ -42640,7 +42647,7 @@ function toTaskExecutionError(error) {
42640
42647
  return {
42641
42648
  errorCode: "dispatch.execution_failed",
42642
42649
  errorType: "internal",
42643
- message: toErrorMessage$38(error)
42650
+ message: toErrorMessage$36(error)
42644
42651
  };
42645
42652
  }
42646
42653
  function normalizeOptionalContextId(contextId) {
@@ -43035,7 +43042,7 @@ function sendResultAndSummarize(input) {
43035
43042
  leaseEpoch: input.leaseEpoch,
43036
43043
  metadata: {
43037
43044
  ...buildResultDispatchJournalMetadata(input.payload),
43038
- errorMessage: toErrorMessage$38(error)
43045
+ errorMessage: toErrorMessage$36(error)
43039
43046
  },
43040
43047
  result: input.payload.status,
43041
43048
  taskId: input.taskId,
@@ -43044,7 +43051,7 @@ function sendResultAndSummarize(input) {
43044
43051
  emitRunLine({
43045
43052
  presenter: input.presenter,
43046
43053
  code: "daemon.run.result_send_failed",
43047
- text: `daemon result send failed for dispatch ${input.dispatchId}: ${toErrorMessage$38(error)}`,
43054
+ text: `daemon result send failed for dispatch ${input.dispatchId}: ${toErrorMessage$36(error)}`,
43048
43055
  payload: {
43049
43056
  attemptId: input.attemptId,
43050
43057
  connectionGeneration: input.connectionGeneration,
@@ -43077,7 +43084,7 @@ function emitDispatchPreviewFrame(input) {
43077
43084
  emitRunLine({
43078
43085
  presenter: input.presenter,
43079
43086
  code: "daemon.run.preview_send_failed",
43080
- text: `daemon preview send failed for dispatch ${input.dispatchId}: ${toErrorMessage$38(error)}`,
43087
+ text: `daemon preview send failed for dispatch ${input.dispatchId}: ${toErrorMessage$36(error)}`,
43081
43088
  payload: {
43082
43089
  attemptId: input.attemptId,
43083
43090
  dispatchId: input.dispatchId,
@@ -43103,7 +43110,7 @@ function emitDispatchPreviewEndFrame(input) {
43103
43110
  emitRunLine({
43104
43111
  presenter: input.presenter,
43105
43112
  code: "daemon.run.preview_end_send_failed",
43106
- text: `daemon preview end send failed for dispatch ${input.dispatchId}: ${toErrorMessage$38(error)}`,
43113
+ text: `daemon preview end send failed for dispatch ${input.dispatchId}: ${toErrorMessage$36(error)}`,
43107
43114
  payload: {
43108
43115
  attemptId: input.attemptId,
43109
43116
  dispatchId: input.dispatchId,
@@ -43146,7 +43153,7 @@ function emitDispatchRuntimeEvidenceTransition(input) {
43146
43153
  emitRunLine({
43147
43154
  presenter: input.presenter,
43148
43155
  code: "daemon.run.runtime_evidence_send_failed",
43149
- text: `daemon runtime evidence ${input.phase} send failed for dispatch ${identity.dispatchId}: ${toErrorMessage$38(error)}`,
43156
+ text: `daemon runtime evidence ${input.phase} send failed for dispatch ${identity.dispatchId}: ${toErrorMessage$36(error)}`,
43150
43157
  payload: {
43151
43158
  attemptId: identity.attemptId,
43152
43159
  dispatchId: identity.dispatchId,
@@ -43245,7 +43252,7 @@ function emitDispatchLifecycleTransition(input) {
43245
43252
  dispatchId: input.dispatchId,
43246
43253
  leaseEpoch: input.leaseEpoch,
43247
43254
  metadata: {
43248
- errorMessage: toErrorMessage$38(error),
43255
+ errorMessage: toErrorMessage$36(error),
43249
43256
  localQueue: input.localQueue ?? null,
43250
43257
  phase: input.phase
43251
43258
  },
@@ -43256,7 +43263,7 @@ function emitDispatchLifecycleTransition(input) {
43256
43263
  emitRunLine({
43257
43264
  presenter: input.presenter,
43258
43265
  code: "daemon.run.lifecycle_send_failed",
43259
- text: `daemon lifecycle ${input.phase} send failed for dispatch ${input.dispatchId}: ${toErrorMessage$38(error)}`,
43266
+ text: `daemon lifecycle ${input.phase} send failed for dispatch ${input.dispatchId}: ${toErrorMessage$36(error)}`,
43260
43267
  payload: {
43261
43268
  attemptId: input.attemptId,
43262
43269
  dispatchId: input.dispatchId,
@@ -43885,7 +43892,7 @@ async function runDaemonSocketSession(input) {
43885
43892
  emitRunLine({
43886
43893
  presenter: input.presenter,
43887
43894
  code: "daemon.run.heartbeat_failed",
43888
- text: `heartbeat failed (${String(consecutiveHeartbeatFailures)}/${String(HEARTBEAT_CONSECUTIVE_FAILURES_BEFORE_CLOSE)}): ${toErrorMessage$38(error)}`
43895
+ text: `heartbeat failed (${String(consecutiveHeartbeatFailures)}/${String(HEARTBEAT_CONSECUTIVE_FAILURES_BEFORE_CLOSE)}): ${toErrorMessage$36(error)}`
43889
43896
  });
43890
43897
  if (shouldCloseSocket) {
43891
43898
  input.socket.close(1011, "heartbeat_failed");
@@ -43918,7 +43925,7 @@ async function runDaemonSocketSession(input) {
43918
43925
  emitRunLine({
43919
43926
  presenter: input.presenter,
43920
43927
  code: "daemon.run.heartbeat_failed",
43921
- text: `heartbeat failed: ${toErrorMessage$38(error)}`
43928
+ text: `heartbeat failed: ${toErrorMessage$36(error)}`
43922
43929
  });
43923
43930
  });
43924
43931
  }, normalizedDelayMs);
@@ -43960,7 +43967,7 @@ async function runDaemonSocketSession(input) {
43960
43967
  emitRunLine({
43961
43968
  presenter: input.presenter,
43962
43969
  code: "daemon.run.catalog_sync_signal_read_failed",
43963
- text: `catalog sync signal read failed: ${toErrorMessage$38(error)}`
43970
+ text: `catalog sync signal read failed: ${toErrorMessage$36(error)}`
43964
43971
  });
43965
43972
  }).finally(() => {
43966
43973
  scheduleCatalogSyncSignalPoll();
@@ -44186,7 +44193,7 @@ async function runDaemonSocketSession(input) {
44186
44193
  emitRunLine({
44187
44194
  presenter: input.presenter,
44188
44195
  code: "daemon.run.runtime_capability_report_sync_failed",
44189
- text: `runtime capability report sync failed: ${toErrorMessage$38(error)}`
44196
+ text: `runtime capability report sync failed: ${toErrorMessage$36(error)}`
44190
44197
  });
44191
44198
  }
44192
44199
  };
@@ -44194,7 +44201,7 @@ async function runDaemonSocketSession(input) {
44194
44201
  emitRunLine({
44195
44202
  presenter: input.presenter,
44196
44203
  code: "daemon.run.socket_error",
44197
- text: `daemon stream socket error: ${toErrorMessage$38(error)}`
44204
+ text: `daemon stream socket error: ${toErrorMessage$36(error)}`
44198
44205
  });
44199
44206
  });
44200
44207
  input.socket.onMessage((raw) => {
@@ -44849,7 +44856,7 @@ const runDaemonServiceLoop = async (input) => {
44849
44856
  action: reconcileDecision.action,
44850
44857
  backoffMs,
44851
44858
  driftClass: reconcileDecision.driftClass,
44852
- error: toErrorMessage$38(error),
44859
+ error: toErrorMessage$36(error),
44853
44860
  foregroundActive: reconcileDecision.foregroundActive,
44854
44861
  lifecycleLocked: reconcileDecision.lifecycleLocked,
44855
44862
  owner: reconcileDecision.owner,
@@ -44860,7 +44867,7 @@ const runDaemonServiceLoop = async (input) => {
44860
44867
  action: reconcileDecision.action,
44861
44868
  backoffMs,
44862
44869
  driftClass: reconcileDecision.driftClass,
44863
- error: toErrorMessage$38(error),
44870
+ error: toErrorMessage$36(error),
44864
44871
  foregroundActive: reconcileDecision.foregroundActive,
44865
44872
  lifecycleLocked: reconcileDecision.lifecycleLocked,
44866
44873
  owner: reconcileDecision.owner,
@@ -44870,14 +44877,14 @@ const runDaemonServiceLoop = async (input) => {
44870
44877
  emitRunLine({
44871
44878
  presenter: input.presenter,
44872
44879
  code: "daemon.run.reconnect",
44873
- text: `daemon stream reconnect scheduled in ${String(backoffMs)}ms (${toErrorMessage$38(error)})`,
44880
+ text: `daemon stream reconnect scheduled in ${String(backoffMs)}ms (${toErrorMessage$36(error)})`,
44874
44881
  payload: {
44875
44882
  attempt: reconnectAttempt,
44876
44883
  backoffMs,
44877
- error: toErrorMessage$38(error)
44884
+ error: toErrorMessage$36(error)
44878
44885
  }
44879
44886
  });
44880
- await sleep$10(backoffMs);
44887
+ await sleep$9(backoffMs);
44881
44888
  }
44882
44889
  } finally {
44883
44890
  process.off("SIGINT", onSigint);
@@ -45347,16 +45354,16 @@ function isLaunchdBootstrapIosError$1(message) {
45347
45354
  }
45348
45355
  function shouldAttemptLaunchdAutoRepair(input) {
45349
45356
  if (input.controller !== "launchd") return false;
45350
- return isLaunchdBootstrapIosError$1(sanitizeSystemServiceErrorMessage$1(toErrorMessage$16(input.error)));
45357
+ return isLaunchdBootstrapIosError$1(sanitizeSystemServiceErrorMessage$1(toErrorMessage$14(input.error)));
45351
45358
  }
45352
45359
  function buildLaunchdAutoRepairFailureError(input) {
45353
45360
  return new Error([
45354
45361
  "launchd auto-repair retry failed.",
45355
- `initial error: ${toErrorMessage$16(input.initialError)}`,
45356
- `retry error: ${toErrorMessage$16(input.retryError)}`
45362
+ `initial error: ${toErrorMessage$14(input.initialError)}`,
45363
+ `retry error: ${toErrorMessage$14(input.retryError)}`
45357
45364
  ].join(" "));
45358
45365
  }
45359
- function toErrorMessage$16(error) {
45366
+ function toErrorMessage$14(error) {
45360
45367
  if (error instanceof Error) return error.message;
45361
45368
  return String(error);
45362
45369
  }
@@ -45719,7 +45726,7 @@ var DaemonReinstallUnexpectedStartError = class extends Error {
45719
45726
  diagnosticDetail;
45720
45727
  outcome;
45721
45728
  constructor(input) {
45722
- super(toErrorMessage$15(input.cause));
45729
+ super(toErrorMessage$13(input.cause));
45723
45730
  this.name = "DaemonReinstallUnexpectedStartError";
45724
45731
  this.cause = input.cause;
45725
45732
  this.diagnosticDetail = input.diagnosticDetail;
@@ -45737,7 +45744,7 @@ var DaemonReinstallFailureError = class extends Error {
45737
45744
  evidencePath;
45738
45745
  failureStage;
45739
45746
  constructor(input) {
45740
- super(toErrorMessage$15(input.cause));
45747
+ super(toErrorMessage$13(input.cause));
45741
45748
  this.name = "DaemonReinstallFailureError";
45742
45749
  this.backupDataPath = input.backupDataPath;
45743
45750
  this.cause = input.cause;
@@ -46435,7 +46442,7 @@ async function runDaemonReinstall(input, options = {}) {
46435
46442
  if (error instanceof DaemonReinstallFailureError) throw new Error(buildDaemonReinstallFailureMessage({
46436
46443
  action: displayAction,
46437
46444
  backupDataPath: error.backupDataPath,
46438
- errorMessage: toErrorMessage$15(error.cause),
46445
+ errorMessage: toErrorMessage$13(error.cause),
46439
46446
  failureStage: error.failureStage,
46440
46447
  evidencePath: error.evidencePath ?? await captureDaemonServiceEvidenceBestEffort({
46441
46448
  runtime,
@@ -46618,14 +46625,14 @@ async function runDaemonAfterReinstallStartWithRetry(input) {
46618
46625
  if (result.ok || isDaemonRunAlreadyRunningReason(result.reason) || normalizeDaemonRunReason(result.reason) === "cancelled") process.exitCode = previousExitCode;
46619
46626
  if (normalizeDaemonRunReason(result.reason) === "start_failed" && attempt < REINSTALL_START_RETRY_ATTEMPTS) {
46620
46627
  process.exitCode = previousExitCode;
46621
- await sleep$5(input.startRetryDelayMs);
46628
+ await sleep$4(input.startRetryDelayMs);
46622
46629
  continue;
46623
46630
  }
46624
46631
  return result.reason;
46625
46632
  } catch (error) {
46626
46633
  if (attempt < REINSTALL_START_RETRY_ATTEMPTS) {
46627
46634
  process.exitCode = previousExitCode;
46628
- await sleep$5(input.startRetryDelayMs);
46635
+ await sleep$4(input.startRetryDelayMs);
46629
46636
  continue;
46630
46637
  }
46631
46638
  const startupDiagnostic = await readDaemonStartFailureLogDiagnostic({ cursor: startFailureLogCursor });
@@ -46662,7 +46669,7 @@ async function applyDaemonReinstallTargetDesiredState(input) {
46662
46669
  }
46663
46670
  function buildDaemonReinstallUnexpectedStartSummary(error, action = "repair") {
46664
46671
  const actionLabel = formatDaemonServiceMaintenanceActionLabel(action);
46665
- const detail = sanitizeSystemServiceErrorMessage(toErrorMessage$15(error));
46672
+ const detail = sanitizeSystemServiceErrorMessage(toErrorMessage$13(error));
46666
46673
  if (!detail) return `ATS hit a local start error right after service ${actionLabel}.`;
46667
46674
  return `ATS hit a local start error right after service ${actionLabel}: ${detail}`;
46668
46675
  }
@@ -46771,7 +46778,7 @@ async function waitForDaemonHealthyAfterReinstall(input) {
46771
46778
  }).catch(() => null);
46772
46779
  if (inventory && isDaemonInventoryRunningAndAligned(inventory)) return inventory.runtimeStatus;
46773
46780
  lastRuntime = inventory?.runtimeStatus ?? await readCurrentObservedDaemonRuntimeStatus();
46774
- await sleep$5(REINSTALL_VERIFY_POLL_MS);
46781
+ await sleep$4(REINSTALL_VERIFY_POLL_MS);
46775
46782
  }
46776
46783
  const statusText = lastRuntime ? describeDaemonRuntimeStatus(lastRuntime) : "No runtime status available.";
46777
46784
  throw new Error(`ATS Service repair verification timed out after ${String(input.verifyWaitMs)}ms. ${statusText}`);
@@ -46878,7 +46885,7 @@ async function stopDaemonForStrictTeardown(input) {
46878
46885
  await input.context.serviceManager.stop().catch((error) => {
46879
46886
  throw createStrictTeardownError({
46880
46887
  reason: input.reason,
46881
- message: `failed to stop system service (${input.context.serviceManager?.controller}): ${toErrorMessage$15(error)}`,
46888
+ message: `failed to stop system service (${input.context.serviceManager?.controller}): ${toErrorMessage$13(error)}`,
46882
46889
  hint: "run `ats service stop --force` and retry",
46883
46890
  stage: "stop-wait"
46884
46891
  });
@@ -46923,7 +46930,7 @@ async function uninstallSystemServiceForStrictTeardown(input) {
46923
46930
  for (const manager of managers) await manager.uninstall().catch((error) => {
46924
46931
  throw createStrictTeardownError({
46925
46932
  reason: input.reason,
46926
- message: `failed to uninstall system service (${manager.controller}): ${toErrorMessage$15(error)}`,
46933
+ message: `failed to uninstall system service (${manager.controller}): ${toErrorMessage$13(error)}`,
46927
46934
  hint: "fix OS service permissions and retry",
46928
46935
  stage: "uninstall-verify"
46929
46936
  });
@@ -46940,7 +46947,7 @@ async function verifySystemServiceRemovedAfterStrictTeardown(input) {
46940
46947
  const finalManagerStatus = await manager.status().catch((error) => {
46941
46948
  throw createStrictTeardownError({
46942
46949
  reason: input.reason,
46943
- message: `failed to verify system service status (${manager.controller}): ${toErrorMessage$15(error)}`,
46950
+ message: `failed to verify system service status (${manager.controller}): ${toErrorMessage$13(error)}`,
46944
46951
  hint: "run `ats service status` and confirm service manager state",
46945
46952
  stage: "uninstall-verify"
46946
46953
  });
@@ -46951,13 +46958,13 @@ async function verifySystemServiceRemovedAfterStrictTeardown(input) {
46951
46958
  }
46952
46959
  }
46953
46960
  if (allRemoved) return;
46954
- await sleep$5(STRICT_TEARDOWN_VERIFY_POLL_MS);
46961
+ await sleep$4(STRICT_TEARDOWN_VERIFY_POLL_MS);
46955
46962
  }
46956
46963
  for (const manager of managers) {
46957
46964
  const finalManagerStatus = await manager.status().catch((error) => {
46958
46965
  throw createStrictTeardownError({
46959
46966
  reason: input.reason,
46960
- message: `failed to verify system service status (${manager.controller}): ${toErrorMessage$15(error)}`,
46967
+ message: `failed to verify system service status (${manager.controller}): ${toErrorMessage$13(error)}`,
46961
46968
  hint: "run `ats service status` and confirm service manager state",
46962
46969
  stage: "uninstall-verify"
46963
46970
  });
@@ -46988,7 +46995,7 @@ async function ensureRuntimeCleanAfterStrictTeardown(input) {
46988
46995
  if ((await input.deps.readCurrentObservedDaemonRuntimeStatus()).status === "not_running") return;
46989
46996
  }
46990
46997
  }
46991
- await sleep$5(STRICT_TEARDOWN_VERIFY_POLL_MS);
46998
+ await sleep$4(STRICT_TEARDOWN_VERIFY_POLL_MS);
46992
46999
  }
46993
47000
  const [ownedProcesses, finalRuntime] = await Promise.all([input.deps.listDaemonOwnedProcesses({ ignoreProcessIds: [process.pid] }), input.deps.readCurrentObservedDaemonRuntimeStatus()]);
46994
47001
  if (finalRuntime.status === "running") throw createStrictTeardownError({
@@ -47789,7 +47796,7 @@ function isLocalControllerSignInRequiredReason(reason) {
47789
47796
  return reason === "sign in required";
47790
47797
  }
47791
47798
  function buildSystemServiceStartupFailureReport(input) {
47792
- const message = sanitizeSystemServiceErrorMessage(toErrorMessage$15(input.error));
47799
+ const message = sanitizeSystemServiceErrorMessage(toErrorMessage$13(input.error));
47793
47800
  const localLogPath = getDaemonSystemServiceLogPath();
47794
47801
  if (isLaunchdBootstrapIosError(message)) {
47795
47802
  const card = buildDaemonStartNeedsAttentionCard({
@@ -47865,7 +47872,7 @@ async function waitForSystemServiceStartup(input) {
47865
47872
  state: "running",
47866
47873
  runtimeStatus: inventory.runtimeStatus
47867
47874
  };
47868
- await sleep$5(input.pollMs);
47875
+ await sleep$4(input.pollMs);
47869
47876
  }
47870
47877
  const finalInventory = await inspectDaemonServiceInventory({
47871
47878
  expectedVersion: input.expectedVersion,
@@ -48131,7 +48138,7 @@ async function runDirectDaemonServiceLoop(input) {
48131
48138
  };
48132
48139
  } catch (error) {
48133
48140
  return await handleDaemonRunStartFailure({
48134
- fallbackRawLine: toErrorMessage$15(error),
48141
+ fallbackRawLine: toErrorMessage$13(error),
48135
48142
  gatewayUrl: input.gatewayUrl,
48136
48143
  presenter: input.presenter,
48137
48144
  runtime: input.runtime,
@@ -48433,11 +48440,11 @@ async function stopRegisteredDaemonServiceManager(input) {
48433
48440
  run: async () => await input.ownerSnapshot.serviceManager?.stop()
48434
48441
  });
48435
48442
  } catch (error) {
48436
- if (input.mode !== "best_effort") throw new Error(`Failed to stop system service (${input.ownerSnapshot.runtimeStatus.serviceController}): ${toErrorMessage$15(error)}`);
48443
+ if (input.mode !== "best_effort") throw new Error(`Failed to stop system service (${input.ownerSnapshot.runtimeStatus.serviceController}): ${toErrorMessage$13(error)}`);
48437
48444
  return buildDaemonStopWarningResult({
48438
48445
  reason: "stop_failed",
48439
48446
  runtimeStatus: input.ownerSnapshot.runtimeStatus,
48440
- errorMessage: toErrorMessage$15(error)
48447
+ errorMessage: toErrorMessage$13(error)
48441
48448
  });
48442
48449
  }
48443
48450
  if (!await waitForDaemonSystemServiceToStop({
@@ -48468,7 +48475,7 @@ async function stopRegisteredDaemonServiceManager(input) {
48468
48475
  return buildDaemonStopWarningResult({
48469
48476
  reason: "stop_failed",
48470
48477
  runtimeStatus: input.ownerSnapshot.runtimeStatus,
48471
- errorMessage: toErrorMessage$15(error)
48478
+ errorMessage: toErrorMessage$13(error)
48472
48479
  });
48473
48480
  }
48474
48481
  const finalOwnerSnapshot = residualCleanupResult.shouldRefresh ? await readCurrentDaemonOwnerSnapshot() : residualCleanupResult.ownerSnapshot;
@@ -48541,7 +48548,7 @@ async function stopCurrentLaneDaemonProcess(input) {
48541
48548
  pid: daemonPid,
48542
48549
  reason: "stop_failed",
48543
48550
  runtimeStatus: input.runtimeStatus,
48544
- errorMessage: toErrorMessage$15(error)
48551
+ errorMessage: toErrorMessage$13(error)
48545
48552
  };
48546
48553
  }
48547
48554
  }
@@ -48625,7 +48632,7 @@ async function stopTrackedDaemonProcess(input) {
48625
48632
  type: "process_stop.action",
48626
48633
  result: "failed",
48627
48634
  metadata: {
48628
- errorMessage: toErrorMessage$15(error),
48635
+ errorMessage: toErrorMessage$13(error),
48629
48636
  pid: input.pid,
48630
48637
  reason: input.reason,
48631
48638
  signal: input.signal
@@ -49649,13 +49656,13 @@ async function runDaemonServiceDetached(input) {
49649
49656
  if (typeof child.pid === "number" && child.pid > 0) await cleanupDetachedRuntimeStateIfOwnedByPid(child.pid).catch(() => {});
49650
49657
  return await handleDaemonRunStartFailure({
49651
49658
  cursor: startFailureLogCursor,
49652
- fallbackRawLine: selectRelevantDaemonStartFailureLogLine(startupOutput.summary()) ?? toErrorMessage$15(error),
49659
+ fallbackRawLine: selectRelevantDaemonStartFailureLogLine(startupOutput.summary()) ?? toErrorMessage$13(error),
49653
49660
  gatewayUrl: input.gatewayUrl,
49654
49661
  presenter: input.presenter,
49655
49662
  runtime: input.runtime,
49656
49663
  genericErrorPayload: {
49657
49664
  codePrefix: "daemon.run.start_failed",
49658
- error: /* @__PURE__ */ new Error(`Failed to start ATS Service process: ${toErrorMessage$15(error)}`)
49665
+ error: /* @__PURE__ */ new Error(`Failed to start ATS Service process: ${toErrorMessage$13(error)}`)
49659
49666
  }
49660
49667
  });
49661
49668
  } finally {
@@ -49754,7 +49761,7 @@ function waitForDetachedChildProcessSpawn(child) {
49754
49761
  child.once("error", onError);
49755
49762
  });
49756
49763
  }
49757
- function sleep$5(milliseconds) {
49764
+ function sleep$4(milliseconds) {
49758
49765
  return new Promise((resolve) => {
49759
49766
  setTimeout(resolve, milliseconds);
49760
49767
  });
@@ -49775,7 +49782,7 @@ async function waitForDetachedBackgroundProcessStartup(child, startupDelayMs, st
49775
49782
  reason: startupLifecycle,
49776
49783
  startupOutput: startupOutput.summary()
49777
49784
  }));
49778
- await sleep$5(startupPollMs);
49785
+ await sleep$4(startupPollMs);
49779
49786
  }
49780
49787
  const finalStatus = await readCurrentObservedDaemonRuntimeStatus().catch(() => null);
49781
49788
  if (finalStatus?.status === "running" && finalStatus.pid === child.pid) return;
@@ -50125,7 +50132,7 @@ function describeDaemonRuntimeStatus(status) {
50125
50132
  if (status.status === "not_running") return "Service is not running.";
50126
50133
  return "Service runtime status is unknown.";
50127
50134
  }
50128
- function toErrorMessage$15(error) {
50135
+ function toErrorMessage$13(error) {
50129
50136
  if (error instanceof Error) return error.message;
50130
50137
  return String(error);
50131
50138
  }
@@ -50155,7 +50162,7 @@ async function stopDaemonProcess(pid, signal) {
50155
50162
  process.kill(pid, signal);
50156
50163
  } catch (error) {
50157
50164
  if (isNodeErrorCode(error, "ESRCH")) return true;
50158
- throw new Error(`Failed to send ${signal} to pid ${String(pid)}: ${toErrorMessage$15(error)}`);
50165
+ throw new Error(`Failed to send ${signal} to pid ${String(pid)}: ${toErrorMessage$13(error)}`);
50159
50166
  }
50160
50167
  if (signal === "SIGKILL") return true;
50161
50168
  return await waitForProcessToExit(pid);
@@ -50464,7 +50471,7 @@ async function runDaemonServiceParticipationRefresh(input) {
50464
50471
  summary: "ATS Service was repaired, but it is not running yet. Local Wake work will keep waiting until ATS Service starts. Run `ats service start`."
50465
50472
  });
50466
50473
  return {
50467
- errorMessage: toErrorMessage$38(error),
50474
+ errorMessage: toErrorMessage$36(error),
50468
50475
  status: "needs_attention"
50469
50476
  };
50470
50477
  }
@@ -50771,7 +50778,7 @@ async function runDaemonServiceAutoHeal(input) {
50771
50778
  cooldownUntil: null
50772
50779
  };
50773
50780
  } catch (error) {
50774
- const errorMessage = toErrorMessage$14(error);
50781
+ const errorMessage = toErrorMessage$12(error);
50775
50782
  await recordDaemonServiceRepairFailure({
50776
50783
  actions: safeActions,
50777
50784
  errorMessage
@@ -50850,7 +50857,7 @@ async function terminateDaemonOwnedProcess(pid) {
50850
50857
  const deadline = Date.now() + AUTO_HEAL_DUPLICATE_WAIT_MS;
50851
50858
  while (Date.now() < deadline) {
50852
50859
  if (!isPidAlive$1(pid)) return;
50853
- await sleep$4(AUTO_HEAL_DUPLICATE_POLL_MS);
50860
+ await sleep$3(AUTO_HEAL_DUPLICATE_POLL_MS);
50854
50861
  }
50855
50862
  if (isPidAlive$1(pid)) process$1.kill(pid, "SIGKILL");
50856
50863
  }
@@ -50875,10 +50882,10 @@ function isPidAlive$1(pid) {
50875
50882
  return !(error instanceof Error && error.code === "ESRCH");
50876
50883
  }
50877
50884
  }
50878
- async function sleep$4(ms) {
50885
+ async function sleep$3(ms) {
50879
50886
  await new Promise((resolve) => setTimeout(resolve, ms));
50880
50887
  }
50881
- function toErrorMessage$14(error) {
50888
+ function toErrorMessage$12(error) {
50882
50889
  if (error instanceof Error && error.message.trim().length > 0) return error.message;
50883
50890
  return String(error);
50884
50891
  }
@@ -51061,7 +51068,7 @@ async function waitForDaemonStartupAlignmentSettlement(input) {
51061
51068
  cliScriptPath: input.cliScriptPath
51062
51069
  }).catch(() => null);
51063
51070
  if (!inventory) {
51064
- await sleep$3(input.pollMs);
51071
+ await sleep$2(input.pollMs);
51065
51072
  continue;
51066
51073
  }
51067
51074
  const decision = resolveDaemonServiceAlignmentDecision({
@@ -51082,11 +51089,11 @@ async function waitForDaemonStartupAlignmentSettlement(input) {
51082
51089
  cooldownUntil: null,
51083
51090
  backupDataPath: null
51084
51091
  };
51085
- await sleep$3(input.pollMs);
51092
+ await sleep$2(input.pollMs);
51086
51093
  }
51087
51094
  return null;
51088
51095
  }
51089
- async function sleep$3(ms) {
51096
+ async function sleep$2(ms) {
51090
51097
  await new Promise((resolve) => {
51091
51098
  setTimeout(resolve, ms);
51092
51099
  });
@@ -58094,7 +58101,7 @@ async function runDoctorProfileCheck(input) {
58094
58101
  }
58095
58102
  atsProfile = {
58096
58103
  ok: false,
58097
- message: `ats-profile failed: ${toErrorMessage$13(error)}`
58104
+ message: `ats-profile failed: ${toErrorMessage$11(error)}`
58098
58105
  };
58099
58106
  }
58100
58107
  emitCheckResult(input.presenter, atsProfile, {
@@ -58481,7 +58488,7 @@ async function runCheck(label, fn) {
58481
58488
  } catch (err) {
58482
58489
  return {
58483
58490
  ok: false,
58484
- message: `${label} failed: ${toErrorMessage$13(err)}`
58491
+ message: `${label} failed: ${toErrorMessage$11(err)}`
58485
58492
  };
58486
58493
  }
58487
58494
  }
@@ -58606,7 +58613,7 @@ async function maybePromptRepairAfterLogin(presenter) {
58606
58613
  function normalizeDoctorHumanText(text) {
58607
58614
  return text.replace(DOCTOR_TEXT_PREFIX_RE, "");
58608
58615
  }
58609
- function toErrorMessage$13(err) {
58616
+ function toErrorMessage$11(err) {
58610
58617
  if (err instanceof Error) return err.message;
58611
58618
  return String(err);
58612
58619
  }
@@ -59360,6 +59367,7 @@ async function runProfileCreate(input) {
59360
59367
  controllerRef: draft.setupResult.controllerRef,
59361
59368
  transportMode: draft.setupResult.transportMode
59362
59369
  });
59370
+ if (created.profileKind === "agent" && draft.localAgentSelection) await ensureAtsManagedProfileWorkspace({ atsProfileId: created.atsProfileId });
59363
59371
  await emitProfileCreateResult({
59364
59372
  runtime,
59365
59373
  presenter,
@@ -59509,7 +59517,7 @@ async function emitProfileCreateResult(input) {
59509
59517
  function emitProfileCreateAgentSetupHint(input) {
59510
59518
  if (!input.setupResult || input.setupResult.status === "configured") return;
59511
59519
  const prepareCommand = formatAtsCliCommand(`ats setup --profile ${input.profile.atsProfileId}`);
59512
- const explicitControllerCreateCommand = formatAtsCliCommand("ats profiles create \"<agent-name>\" --kind agent --controller-kind builtin --controller-ref codex --view agent");
59520
+ const explicitLocalAgentSetupCommand = formatAtsCliCommand(`ats setup --profile ${input.profile.atsProfileId} --local-agent <local-agent-id> --view agent`);
59513
59521
  const summary = input.setupResult.status === "skipped_no_enabled_controllers" ? "No enabled agent controller is available, so the profile was created without one." : "Agent controller setup was skipped, so the profile was created without one.";
59514
59522
  if (input.resolvedView === "agent") {
59515
59523
  input.presenter.line({
@@ -59519,19 +59527,15 @@ function emitProfileCreateAgentSetupHint(input) {
59519
59527
  status: input.setupResult.status,
59520
59528
  ...input.setupResult.status === "skipped_no_enabled_controllers" && input.setupResult.reason ? { reason: input.setupResult.reason } : {},
59521
59529
  profileId: input.profile.atsProfileId,
59522
- nextSteps: [
59523
- `For this existing profile, run ${formatAtsCliCommand(`ats setup --profile ${input.profile.atsProfileId} --local-agent <local-agent-id> --view agent`)} when you know which local agent it should use.`,
59524
- `Or run ${prepareCommand} in an interactive Terminal and choose the local agent there.`,
59525
- `For a new CLI-only Codex profile, run ${explicitControllerCreateCommand}.`
59526
- ],
59527
- cliOnlyCreateCommand: explicitControllerCreateCommand
59530
+ nextSteps: [`For this existing profile, run ${explicitLocalAgentSetupCommand} when you know which local agent it should use.`, `Or run ${prepareCommand} in an interactive Terminal and choose the local agent there.`],
59531
+ localAgentSetupCommand: explicitLocalAgentSetupCommand
59528
59532
  }
59529
59533
  });
59530
59534
  return;
59531
59535
  }
59532
59536
  input.presenter.line({
59533
59537
  code: "profile.create.agent_setup.skipped",
59534
- text: formatInlineAtsCliCommands(`${summary} For this existing profile, run \`ats setup --profile ${input.profile.atsProfileId} --local-agent <local-agent-id>\` when you know which local agent it should use, or run \`${prepareCommand}\` in an interactive Terminal. For a new CLI-only Codex profile, run \`${explicitControllerCreateCommand}\`.`)
59538
+ text: formatInlineAtsCliCommands(`${summary} For this existing profile, run \`ats setup --profile ${input.profile.atsProfileId} --local-agent <local-agent-id>\` when you know which local agent it should use, or run \`${prepareCommand}\` in an interactive Terminal.`)
59535
59539
  });
59536
59540
  }
59537
59541
  async function runProfileSet(input) {
@@ -59670,11 +59674,6 @@ async function runProfileDelete(input) {
59670
59674
  }
59671
59675
  async function runProfileUpdate(input) {
59672
59676
  const runtime = await resolveRuntimeContext({ view: input.view });
59673
- normalizeControllerArgumentInput({
59674
- controllerKind: input.controllerKind,
59675
- controllerRef: input.controllerRef,
59676
- controllerEnabled: input.controllerEnabled
59677
- });
59678
59677
  if (!input.entryChecksHandled) {
59679
59678
  if (!await ensureProfileCommandAuthenticationOrCancel({
59680
59679
  action: "update",
@@ -59697,10 +59696,6 @@ async function runProfileUpdate(input) {
59697
59696
  visibleProfiles,
59698
59697
  currentProfileId: current,
59699
59698
  profileName: input.profileName,
59700
- controllerKind: input.controllerKind,
59701
- controllerRef: input.controllerRef,
59702
- controllerEnabled: input.controllerEnabled,
59703
- transportMode: input.transportMode,
59704
59699
  workspaceMode: input.workspaceMode,
59705
59700
  workspacePath: input.workspacePath
59706
59701
  });
@@ -59762,10 +59757,6 @@ async function resolveProfileUpdateSelection(input) {
59762
59757
  resolvedView: input.resolvedView,
59763
59758
  allowPrompt: input.allowPrompt,
59764
59759
  profileName: input.profileName,
59765
- controllerKind: input.controllerKind,
59766
- controllerRef: input.controllerRef,
59767
- controllerEnabled: input.controllerEnabled,
59768
- transportMode: input.transportMode,
59769
59760
  workspaceMode: input.workspaceMode,
59770
59761
  workspacePath: input.workspacePath
59771
59762
  });
@@ -59786,10 +59777,6 @@ async function resolveProfileUpdateSelectionForProfile(input) {
59786
59777
  allowPrompt: input.allowPrompt,
59787
59778
  resolvedView: input.resolvedView,
59788
59779
  profileName: input.profileName,
59789
- controllerKind: input.controllerKind,
59790
- controllerRef: input.controllerRef,
59791
- controllerEnabled: input.controllerEnabled,
59792
- transportMode: input.transportMode,
59793
59780
  workspaceMode: input.workspaceMode,
59794
59781
  workspacePath: input.workspacePath
59795
59782
  });
@@ -59900,11 +59887,6 @@ function emitProfileUpdateCandidatesForHuman(input) {
59900
59887
  }
59901
59888
  async function resolveProfileUpdatePayload(input) {
59902
59889
  const profileName = normalizeOptionalString$10(input.profileName);
59903
- if (normalizeControllerArgumentInput({
59904
- controllerKind: input.controllerKind,
59905
- controllerRef: input.controllerRef,
59906
- controllerEnabled: input.controllerEnabled
59907
- }).hasAnyControllerInput || normalizeOptionalString$10(input.transportMode)) throw new Error(formatInlineAtsCliCommands("Local agent connections are managed by ATS Core. Open ATS Web setup to choose or change this profile's local agent. To create a new CLI-only Codex profile, run `ats profiles create <agent-name> --kind agent --controller-kind builtin --controller-ref codex --view agent`."));
59908
59890
  const explicitWorkspace = resolveExplicitWorkspacePatchForProfile({
59909
59891
  profile: input.profile,
59910
59892
  workspaceMode: input.workspaceMode,
@@ -61315,7 +61297,7 @@ async function resolvePrepareReadinessApiEvidence(input) {
61315
61297
  } catch (error) {
61316
61298
  console.warn("[ats.prepare_readiness.api_read_failed]", {
61317
61299
  event: "cli.prepare_readiness.api_read_failed",
61318
- error: toErrorMessage$12(error),
61300
+ error: toErrorMessage$10(error),
61319
61301
  profileId: input.profile.atsProfileId
61320
61302
  });
61321
61303
  return unavailableEvidence({
@@ -61356,7 +61338,7 @@ function unavailableEvidence(input) {
61356
61338
  status: "unavailable"
61357
61339
  };
61358
61340
  }
61359
- function toErrorMessage$12(error) {
61341
+ function toErrorMessage$10(error) {
61360
61342
  if (error instanceof Error) {
61361
61343
  const message = error.message.trim();
61362
61344
  return message.length > 0 ? message : "unknown error";
@@ -63621,58 +63603,6 @@ async function collectStartLocalReadiness(input) {
63621
63603
  };
63622
63604
  }
63623
63605
 
63624
- //#endregion
63625
- //#region src/system/current-local-runtime-reply-readiness.ts
63626
- async function readCurrentLocalRuntimeReplyReadiness(input) {
63627
- return await createCurrentDeviceApi(createCliApiClientFoundation(input.gatewayUrl)).getCurrentLocalRuntimeReplyReadiness();
63628
- }
63629
- async function assertCurrentLocalRuntimeCanReceiveWake(input) {
63630
- let response;
63631
- try {
63632
- response = await readCurrentLocalRuntimeReplyReadiness({ gatewayUrl: input.gatewayUrl });
63633
- } catch (error) {
63634
- throw new Error(formatCurrentLocalRuntimeReplyReadinessFailure({
63635
- commandLabel: input.commandLabel,
63636
- detail: toErrorMessage$11(error),
63637
- supportCode: "current_reply_readiness.read_failed"
63638
- }));
63639
- }
63640
- const mismatchSupportCode = resolveCurrentTargetMismatchSupportCode({
63641
- response,
63642
- runtimeIdentity: input.runtimeIdentity
63643
- });
63644
- if (mismatchSupportCode) throw new Error(formatCurrentLocalRuntimeReplyReadinessFailure({
63645
- commandLabel: input.commandLabel,
63646
- supportCode: mismatchSupportCode
63647
- }));
63648
- if (response.canReplyFromThisComputer && response.service.connected && response.service.matchingCurrentRuntime) return response;
63649
- throw new Error(formatCurrentLocalRuntimeReplyReadinessFailure({
63650
- commandLabel: input.commandLabel,
63651
- detail: response.message,
63652
- supportCode: resolveCurrentReplyReadinessSupportCode(response)
63653
- }));
63654
- }
63655
- function resolveCurrentTargetMismatchSupportCode(input) {
63656
- if (input.response.currentTarget.availability !== "resolved") return "current_reply_readiness.current_target_missing";
63657
- if (input.response.currentTarget.deviceId !== input.runtimeIdentity.deviceId) return "current_reply_readiness.device_mismatch";
63658
- if (input.response.currentTarget.runtimeLane !== input.runtimeIdentity.runtimeLane) return "current_reply_readiness.lane_mismatch";
63659
- return null;
63660
- }
63661
- function resolveCurrentReplyReadinessSupportCode(response) {
63662
- return response.service.reasonCodes[0] ?? response.runtime.reasonCodes[0] ?? `current_reply_readiness.${response.primaryBlocker}`;
63663
- }
63664
- function formatCurrentLocalRuntimeReplyReadinessFailure(input) {
63665
- return `ATS Service started, but ATS could not confirm this computer can receive local Wake work yet. Keep ATS Service running, then run ${input.commandLabel ?? "setup"} again from this terminal. Support code: ${input.supportCode}.${input.detail ? ` Detail: ${input.detail}` : ""}`;
63666
- }
63667
- function toErrorMessage$11(error) {
63668
- if (error instanceof Error) {
63669
- const message = error.message.trim();
63670
- return message.length > 0 ? message : "unknown error";
63671
- }
63672
- const message = String(error ?? "").trim();
63673
- return message.length > 0 ? message : "unknown error";
63674
- }
63675
-
63676
63606
  //#endregion
63677
63607
  //#region src/system/selected-local-runtime-reporting.ts
63678
63608
  function resolveSelectedLocalRuntimeReadiness(input) {
@@ -64242,15 +64172,6 @@ async function repairProfileReadinessState(input) {
64242
64172
  workspaceSync
64243
64173
  })) prepared = true;
64244
64174
  }
64245
- if (input.reasonCodes.includes("dispatch.storage_not_ready") || input.reasonCodes.includes("service.gateway_chain_unhealthy")) {
64246
- await runDoctor({
64247
- profile: input.profile.atsProfileId,
64248
- repair: true,
64249
- view: input.view,
64250
- agentOverviewHandled: true
64251
- });
64252
- prepared = true;
64253
- }
64254
64175
  return { prepared };
64255
64176
  }
64256
64177
  function needsControllerSetup(input) {
@@ -64495,8 +64416,6 @@ const PREPARE_SESSION_MAX_RECONNECT_ATTEMPTS = 3;
64495
64416
  const PREPARE_SESSION_RECONNECT_DELAY_MS = 1e3;
64496
64417
  const REPORT_RUNTIME_CONNECTION_MAX_ATTEMPTS = 12;
64497
64418
  const REPORT_RUNTIME_CONNECTION_RETRY_DELAY_MS = 1e3;
64498
- const ROUTE_CATALOG_SYNC_MAX_ATTEMPTS$1 = 12;
64499
- const ROUTE_CATALOG_SYNC_RETRY_DELAY_MS$1 = 1e3;
64500
64419
  const TERMINAL_PREPARE_STEP_ORDER = [
64501
64420
  "prepare_selected_agents",
64502
64421
  "refresh_service",
@@ -64536,7 +64455,7 @@ async function runPrepareSessionExecutor(input) {
64536
64455
  if (error instanceof PrepareSessionConnectionInterruptedError && reconnectAttempts < PREPARE_SESSION_MAX_RECONNECT_ATTEMPTS) {
64537
64456
  reconnectAttempts += 1;
64538
64457
  emitHumanStatus(input, "Reconnecting", ["ATS Web connection was interrupted.", "Reconnecting to the setup session..."]);
64539
- await sleep$2(PREPARE_SESSION_RECONNECT_DELAY_MS);
64458
+ await sleep$1(PREPARE_SESSION_RECONNECT_DELAY_MS);
64540
64459
  initial = await resolvePrepareSessionToken({
64541
64460
  gatewayUrl: input.gatewayUrl,
64542
64461
  opaqueToken: input.startSession
@@ -64936,7 +64855,7 @@ async function connectSelectedLocalAgentsToAts(input) {
64936
64855
  } catch (error) {
64937
64856
  if (!isTransientSelectedAgentConnectionError(error) || attempt >= REPORT_RUNTIME_CONNECTION_MAX_ATTEMPTS) throw error;
64938
64857
  lastTransientError = error;
64939
- await sleep$2(REPORT_RUNTIME_CONNECTION_RETRY_DELAY_MS);
64858
+ await sleep$1(REPORT_RUNTIME_CONNECTION_RETRY_DELAY_MS);
64940
64859
  }
64941
64860
  throw lastTransientError ?? /* @__PURE__ */ new Error("ATS could not connect local agents.");
64942
64861
  }
@@ -64952,22 +64871,14 @@ async function connectSelectedLocalAgentsToAtsOnce(input) {
64952
64871
  readiness,
64953
64872
  localAgentIds: input.localAgentIds
64954
64873
  }));
64955
- if (input.syncRouteCatalog) await waitForConfirmedRouteCatalogSync$1({
64956
- confirmWakeAvailability: async () => {
64957
- await assertCurrentLocalRuntimeCanReceiveWake({
64958
- gatewayUrl: input.gatewayUrl,
64959
- runtimeIdentity
64960
- });
64961
- },
64962
- reason: "prepare_selected_agents_connected"
64963
- });
64874
+ if (input.syncRouteCatalog) await notifyRouteCatalogAfterPrepare({ reason: "prepare_selected_agents_reported" });
64964
64875
  return {
64965
64876
  ...runtimeIdentity,
64966
64877
  localReadinessSnapshot: buildPrepareLocalReadinessSnapshot(readiness)
64967
64878
  };
64968
64879
  }
64969
64880
  function isTransientSelectedAgentConnectionError(error) {
64970
- const rawMessage = toErrorMessage$10(error).toLowerCase();
64881
+ const rawMessage = toErrorMessage$9(error).toLowerCase();
64971
64882
  return rawMessage.includes("service has not finished starting") || rawMessage.includes("ats service is not running") || rawMessage.includes("service.not_running") || rawMessage.includes("service_contract_unavailable") || rawMessage.includes("runtime.reporting.write_failed");
64972
64883
  }
64973
64884
  async function verifySelectedLocalAgentsConnectedToAts(input) {
@@ -64988,10 +64899,6 @@ async function verifySelectedLocalAgentsConnectedToAts(input) {
64988
64899
  runtimeIdentity,
64989
64900
  selectedReadiness
64990
64901
  });
64991
- await assertCurrentLocalRuntimeCanReceiveWake({
64992
- gatewayUrl: input.gatewayUrl,
64993
- runtimeIdentity
64994
- });
64995
64902
  return {
64996
64903
  ...runtimeIdentity,
64997
64904
  localReadinessSnapshot: buildPrepareLocalReadinessSnapshot(readiness)
@@ -65007,20 +64914,8 @@ async function readTerminalRuntimeIdentityFromServiceContract() {
65007
64914
  runtimeLane
65008
64915
  };
65009
64916
  }
65010
- async function waitForConfirmedRouteCatalogSync$1(input) {
65011
- let latestDelivery = null;
65012
- for (let attempt = 1; attempt <= ROUTE_CATALOG_SYNC_MAX_ATTEMPTS$1; attempt++) {
65013
- latestDelivery = await notifyDaemonRouteCatalogChanged({ reason: input.reason });
65014
- if (latestDelivery.delivery === "control_plane") return latestDelivery;
65015
- if (attempt < ROUTE_CATALOG_SYNC_MAX_ATTEMPTS$1) await sleep$2(ROUTE_CATALOG_SYNC_RETRY_DELAY_MS$1);
65016
- }
65017
- if (latestDelivery?.delivery === "signal" && input.confirmWakeAvailability) try {
65018
- await input.confirmWakeAvailability();
65019
- return latestDelivery;
65020
- } catch (error) {
65021
- throw new Error(formatRouteCatalogSyncFailure$1(latestDelivery, error));
65022
- }
65023
- throw new Error(formatRouteCatalogSyncFailure$1(latestDelivery));
64917
+ async function notifyRouteCatalogAfterPrepare(input) {
64918
+ await notifyDaemonRouteCatalogChanged({ reason: input.reason });
65024
64919
  }
65025
64920
  async function assertSelectedRuntimeReadinessIsReadableByAts(input) {
65026
64921
  const capabilityRefs = input.selectedReadiness.map((decision) => decision.capabilityRef);
@@ -65034,12 +64929,7 @@ async function assertSelectedRuntimeReadinessIsReadableByAts(input) {
65034
64929
  const missingCapabilityRef = capabilityRefs.find((capabilityRef) => !runnableCapabilityRefs.has(capabilityRef));
65035
64930
  if (response.status === "ready" && response.runtimeId && !missingCapabilityRef) return;
65036
64931
  const reasonCode = response.summary.reasonCodes[0] ?? response.reason ?? (missingCapabilityRef ? "prepare_readiness.capability_not_ready" : "prepare_readiness.not_ready");
65037
- throw new Error(`ATS could not verify that selected agents are available for Wake yet. Keep ATS Service running, then run \`${formatAtsCliCommand("ats setup --view agent")}\` again. You can also run \`${formatAtsCliCommand("ats service status --view agent")}\` to inspect the local service. Support code: ${reasonCode}.`);
65038
- }
65039
- function formatRouteCatalogSyncFailure$1(latestDelivery, error) {
65040
- const supportCode = latestDelivery?.delivery === "signal" ? `route_catalog_sync.${latestDelivery.fallbackReason}` : "route_catalog_sync.unavailable";
65041
- const detail = error ? ` Detail: ${toErrorMessage$10(error)}` : "";
65042
- return `ATS Service started, but ATS could not confirm that selected agents are available for Wake yet. Keep ATS Service running, then run \`${formatAtsCliCommand("ats setup --view agent")}\` again. You can also run \`${formatAtsCliCommand("ats service status --view agent")}\` to inspect the local service. Support code: ${supportCode}.${detail}`;
64932
+ throw new Error(`ATS could not verify that selected local agents were reported to ATS yet. Keep ATS Service running, then run \`${formatAtsCliCommand("ats setup --view agent")}\` again. You can also run \`${formatAtsCliCommand("ats service status --view agent")}\` to inspect the local service. Support code: ${reasonCode}.`);
65043
64933
  }
65044
64934
  function buildPrepareLocalReadinessSnapshot(readiness) {
65045
64935
  return {
@@ -65286,7 +65176,7 @@ function toStatusCodeSlug(title) {
65286
65176
  const slug = title.toLowerCase().replaceAll(/[^a-z0-9]+/g, "_").replaceAll(/^_+|_+$/g, "");
65287
65177
  return slug.length > 0 ? slug : "status";
65288
65178
  }
65289
- function toErrorMessage$10(error) {
65179
+ function toErrorMessage$9(error) {
65290
65180
  if (error instanceof Error) {
65291
65181
  const message = error.message.trim();
65292
65182
  return message.length > 0 ? message : "unknown error";
@@ -65318,7 +65208,7 @@ function errorFromPrepareSessionServerError(input) {
65318
65208
  if (input.code === "prepare.session.revision_conflict") return new PrepareSessionRevisionConflictError(input.message);
65319
65209
  return new Error(input.message);
65320
65210
  }
65321
- async function sleep$2(ms) {
65211
+ async function sleep$1(ms) {
65322
65212
  await new Promise((resolve) => {
65323
65213
  setTimeout(resolve, ms);
65324
65214
  });
@@ -67295,7 +67185,7 @@ async function waitForWebLocalAgentPreparation(input) {
67295
67185
  const nowMs = Date.now();
67296
67186
  if (nowMs >= deadlineMs) throw new Error(`ATS waited ${formatWaitDuration(input.waitConfig.timeoutMs)} for a local-agent choice in ATS Web. Copy a fresh setup command from ATS Web and run it again.`);
67297
67187
  const sleepMs = Math.min(input.waitConfig.pollIntervalMs, Math.max(0, deadlineMs - nowMs));
67298
- if (sleepMs > 0) await sleep$1(sleepMs);
67188
+ if (sleepMs > 0) await sleep(sleepMs);
67299
67189
  }
67300
67190
  }
67301
67191
  function resolveWebLocalAgentPreparationWaitConfig() {
@@ -67324,7 +67214,7 @@ function formatWaitDuration(timeoutMs) {
67324
67214
  if (seconds < 60) return `${seconds} seconds`;
67325
67215
  return `${Math.round(seconds / 60)} minutes`;
67326
67216
  }
67327
- function sleep$1(ms) {
67217
+ function sleep(ms) {
67328
67218
  return new Promise((resolve) => {
67329
67219
  setTimeout(resolve, ms);
67330
67220
  });
@@ -68266,8 +68156,6 @@ function isAgentProfile(profile) {
68266
68156
 
68267
68157
  //#endregion
68268
68158
  //#region src/commands/setup.ts
68269
- const ROUTE_CATALOG_SYNC_MAX_ATTEMPTS = 8;
68270
- const ROUTE_CATALOG_SYNC_RETRY_DELAY_MS = 750;
68271
68159
  const SETUP_COMMAND_LOCK_PROFILE = "setup";
68272
68160
  const SETUP_COMMAND_LOCK_KEY = "setup-command";
68273
68161
  async function runSetup(input) {
@@ -68352,19 +68240,7 @@ async function runSetupUnlocked(input) {
68352
68240
  localAgentIds: selectedLocalAgentIds
68353
68241
  });
68354
68242
  assertSelectedLocalRuntimeReportsAccepted(runtimeReports);
68355
- const routeCatalogSync = selectedLocalAgentIds.length > 0 ? await waitForConfirmedRouteCatalogSync({
68356
- confirmWakeAvailability: async () => await assertSetupCompletionCanReceiveWake({
68357
- gatewayUrl,
68358
- runtimeIdentity,
68359
- selectedLocalAgentIds
68360
- }),
68361
- reason: "setup_to_wake_path_connected"
68362
- }) : null;
68363
- await assertSetupCompletionCanReceiveWake({
68364
- gatewayUrl,
68365
- runtimeIdentity,
68366
- selectedLocalAgentIds
68367
- });
68243
+ const routeCatalogSync = selectedLocalAgentIds.length > 0 ? await notifyRouteCatalogAfterSetup({ reason: "setup_local_capabilities_reported" }) : null;
68368
68244
  emitSetupStatus(runtime, "Updating ATS skills", ["Updating ATS skills so local agents use the current ATS instructions."]);
68369
68245
  await ensureSetupManagedSkills({ view: input.view });
68370
68246
  emitSetupComplete({
@@ -68441,25 +68317,8 @@ function assertStartLocalAgentsEnableCompleted(result) {
68441
68317
  if (!blockingError) return;
68442
68318
  throw new Error(blockingError.nextSteps?.[0] ? `ATS could not set up ${blockingError.agentId}. Run \`${formatAtsCliCommand(blockingError.nextSteps[0])}\`, then run setup again. Detail: ${blockingError.reason}` : `ATS could not set up ${blockingError.agentId}. Detail: ${blockingError.reason}`);
68443
68319
  }
68444
- async function waitForConfirmedRouteCatalogSync(input) {
68445
- let latestDelivery = null;
68446
- for (let attempt = 1; attempt <= ROUTE_CATALOG_SYNC_MAX_ATTEMPTS; attempt++) {
68447
- latestDelivery = await notifyDaemonRouteCatalogChanged({ reason: input.reason });
68448
- if (latestDelivery.delivery === "control_plane") return latestDelivery;
68449
- if (attempt < ROUTE_CATALOG_SYNC_MAX_ATTEMPTS) await sleep(ROUTE_CATALOG_SYNC_RETRY_DELAY_MS);
68450
- }
68451
- if (latestDelivery?.delivery === "signal" && input.confirmWakeAvailability) try {
68452
- await input.confirmWakeAvailability();
68453
- return latestDelivery;
68454
- } catch (error) {
68455
- throw new Error(formatRouteCatalogSyncFailure(latestDelivery, error));
68456
- }
68457
- throw new Error(formatRouteCatalogSyncFailure(latestDelivery));
68458
- }
68459
- function formatRouteCatalogSyncFailure(latestDelivery, error) {
68460
- const supportCode = latestDelivery?.delivery === "signal" ? `route_catalog_sync.${latestDelivery.fallbackReason}` : "route_catalog_sync.unavailable";
68461
- const detail = error ? ` Detail: ${toErrorMessage$9(error)}` : "";
68462
- return `ATS Service started, but ATS could not confirm that selected agents are available for Wake yet. Keep ATS Service running, then run \`${formatAtsCliCommand("ats setup --view agent")}\` again. You can also run \`${formatAtsCliCommand("ats service status --view agent")}\` to inspect the local service. Support code: ${supportCode}.${detail}`;
68320
+ async function notifyRouteCatalogAfterSetup(input) {
68321
+ return await notifyDaemonRouteCatalogChanged({ reason: input.reason });
68463
68322
  }
68464
68323
  function emitSetupStatus(runtime, title, lines) {
68465
68324
  if (runtime.resolvedView !== "human") return;
@@ -68489,27 +68348,12 @@ async function emitSetupCompleteForDelegatedPath(input) {
68489
68348
  }
68490
68349
  async function resolveDelegatedSetupCompletionFacts(input) {
68491
68350
  const completionFacts = input.setupResult.completionFacts;
68492
- if (completionFacts) {
68493
- const routeCatalogSync = completionFacts.runtimeReports.length > 0 ? await waitForConfirmedRouteCatalogSync({
68494
- confirmWakeAvailability: async () => await assertSetupCompletionCanReceiveWake({
68495
- gatewayUrl: input.gatewayUrl,
68496
- runtimeIdentity: completionFacts.runtimeIdentity,
68497
- selectedLocalAgentIds: completionFacts.selectedLocalAgentIds
68498
- }),
68499
- reason: "setup_profile_connection_path_connected"
68500
- }) : null;
68501
- await assertSetupCompletionCanReceiveWake({
68502
- gatewayUrl: input.gatewayUrl,
68503
- runtimeIdentity: completionFacts.runtimeIdentity,
68504
- selectedLocalAgentIds: completionFacts.selectedLocalAgentIds
68505
- });
68506
- return {
68507
- routeCatalogSync,
68508
- runtimeIdentity: completionFacts.runtimeIdentity,
68509
- runtimeReports: completionFacts.runtimeReports,
68510
- selectedLocalAgentIds: completionFacts.selectedLocalAgentIds
68511
- };
68512
- }
68351
+ if (completionFacts) return {
68352
+ routeCatalogSync: completionFacts.runtimeReports.length > 0 ? await notifyRouteCatalogAfterSetup({ reason: "setup_profile_capability_reported" }) : null,
68353
+ runtimeIdentity: completionFacts.runtimeIdentity,
68354
+ runtimeReports: completionFacts.runtimeReports,
68355
+ selectedLocalAgentIds: completionFacts.selectedLocalAgentIds
68356
+ };
68513
68357
  const sessionSelectedLocalAgentIds = input.setupResult.setupSessionSnapshot?.selectedLocalAgentIds ?? null;
68514
68358
  if (!(sessionSelectedLocalAgentIds || hasExplicitLocalAgentSelection(input.setupInput))) return {
68515
68359
  routeCatalogSync: null,
@@ -68549,34 +68393,13 @@ async function resolveDelegatedSetupCompletionFacts(input) {
68549
68393
  localAgentIds: selectedLocalAgentIds
68550
68394
  });
68551
68395
  assertSelectedLocalRuntimeReportsAccepted(runtimeReports);
68552
- const routeCatalogSync = await waitForConfirmedRouteCatalogSync({
68553
- confirmWakeAvailability: async () => await assertSetupCompletionCanReceiveWake({
68554
- gatewayUrl: input.gatewayUrl,
68555
- runtimeIdentity,
68556
- selectedLocalAgentIds
68557
- }),
68558
- reason: "setup_delegated_path_connected"
68559
- });
68560
- await assertSetupCompletionCanReceiveWake({
68561
- gatewayUrl: input.gatewayUrl,
68562
- runtimeIdentity,
68563
- selectedLocalAgentIds
68564
- });
68565
68396
  return {
68566
- routeCatalogSync,
68397
+ routeCatalogSync: await notifyRouteCatalogAfterSetup({ reason: "setup_session_capabilities_reported" }),
68567
68398
  runtimeIdentity,
68568
68399
  runtimeReports,
68569
68400
  selectedLocalAgentIds
68570
68401
  };
68571
68402
  }
68572
- async function assertSetupCompletionCanReceiveWake(input) {
68573
- if (input.selectedLocalAgentIds.length === 0) return;
68574
- if (!input.runtimeIdentity) throw new Error(`ATS Service started, but ATS could not confirm this computer can receive local Wake work yet. Keep ATS Service running, then run \`${formatAtsCliCommand("ats setup --view agent")}\` again. Support code: current_reply_readiness.current_target_missing.`);
68575
- await assertCurrentLocalRuntimeCanReceiveWake({
68576
- gatewayUrl: input.gatewayUrl,
68577
- runtimeIdentity: input.runtimeIdentity
68578
- });
68579
- }
68580
68403
  function resolveRuntimeIdentityFromSetupSession(snapshot) {
68581
68404
  if (!(snapshot?.deviceId && snapshot.runtimeLane)) return null;
68582
68405
  return {
@@ -68603,13 +68426,14 @@ function emitSetupComplete(input) {
68603
68426
  } : null,
68604
68427
  localAgents: {
68605
68428
  selectedAgentIds: [...input.selectedLocalAgentIds],
68606
- wakeAvailability: input.runtimeReports.map((report) => ({
68429
+ reportedCapabilities: input.runtimeReports.map((report) => ({
68607
68430
  agentId: report.agentId,
68608
68431
  capabilityRef: report.capabilityRef,
68609
- status: report.localParticipationState === "ready" ? "available_for_wake" : "blocked_from_wake",
68432
+ status: report.localParticipationState === "ready" ? "reported" : "blocked",
68610
68433
  reasonCodes: [...report.reasonCodes],
68611
68434
  runtimeId: report.runtimeReportSubmission.runtimeId
68612
- }))
68435
+ })),
68436
+ spaceSetupHint: formatSetupCompleteSpaceSetupHint(input.runtimeReports)
68613
68437
  },
68614
68438
  localComponents: input.localComponents,
68615
68439
  routeCatalogSync: input.routeCatalogSync,
@@ -68636,8 +68460,8 @@ function emitSetupComplete(input) {
68636
68460
  value: formatSetupCompleteLocalAgents(input.selectedLocalAgentIds)
68637
68461
  },
68638
68462
  {
68639
- label: "Wake",
68640
- value: formatSetupCompleteWakeAvailability(input.runtimeReports)
68463
+ label: "Space setup",
68464
+ value: formatSetupCompleteSpaceSetupHint(input.runtimeReports)
68641
68465
  },
68642
68466
  {
68643
68467
  label: "Service",
@@ -68702,15 +68526,14 @@ function emitHumanSetupCompleteAgentHandoff(input) {
68702
68526
  }
68703
68527
  function formatSetupCompleteLocalAgents(selectedLocalAgentIds) {
68704
68528
  if (selectedLocalAgentIds.length === 0) return "No local agents selected";
68705
- return `${selectedLocalAgentIds.length} connected: ${selectedLocalAgentIds.join(", ")}`;
68529
+ return `${selectedLocalAgentIds.length} detected: ${selectedLocalAgentIds.join(", ")}`;
68706
68530
  }
68707
- function formatSetupCompleteWakeAvailability(runtimeReports) {
68708
- if (runtimeReports.length === 0) return "No local agents selected";
68531
+ function formatSetupCompleteSpaceSetupHint(runtimeReports) {
68532
+ if (runtimeReports.length === 0) return "Choose a local agent when creating a Space";
68709
68533
  const availableCount = runtimeReports.filter((report) => report.localParticipationState === "ready").length;
68710
- const blockedCount = runtimeReports.length - availableCount;
68711
- if (blockedCount === 0) return `${availableCount} available for Wake`;
68712
- if (availableCount === 0) return `${blockedCount} blocked from Wake`;
68713
- return `${availableCount} available for Wake, ${blockedCount} blocked`;
68534
+ if (runtimeReports.length - availableCount === 0) return "Choose one detected agent to add to a Space";
68535
+ if (availableCount === 0) return "Resolve local-agent blockers before adding one to a Space";
68536
+ return "Choose a detected agent without blockers, or resolve blockers first";
68714
68537
  }
68715
68538
  function formatSetupCompleteService(runtimeIdentity) {
68716
68539
  if (!runtimeIdentity) return "Not connected";
@@ -68724,19 +68547,6 @@ function normalizeOptionalString$5(value) {
68724
68547
  const normalized = String(value ?? "").trim();
68725
68548
  return normalized.length > 0 ? normalized : null;
68726
68549
  }
68727
- function toErrorMessage$9(error) {
68728
- if (error instanceof Error) {
68729
- const message = error.message.trim();
68730
- return message.length > 0 ? message : "unknown error";
68731
- }
68732
- const message = String(error ?? "").trim();
68733
- return message.length > 0 ? message : "unknown error";
68734
- }
68735
- function sleep(ms) {
68736
- return new Promise((resolve) => {
68737
- setTimeout(resolve, ms);
68738
- });
68739
- }
68740
68550
 
68741
68551
  //#endregion
68742
68552
  //#region src/start-shell/next-action-commands.ts
@@ -84431,7 +84241,7 @@ function emitJoinCreatedProfileCard(input) {
84431
84241
  sanitize: true
84432
84242
  });
84433
84243
  if (!input.setupResult || input.setupResult.status === "configured") return;
84434
- const assignControllerCommand = `ats profile update ${input.profile.atsProfileId} --controller-kind builtin --controller-ref <agent-id> --controller-enabled true`;
84244
+ const assignControllerCommand = `ats setup --profile ${input.profile.atsProfileId} --local-agent <agent-id>`;
84435
84245
  const summary = input.setupResult.status === "skipped_no_enabled_controllers" ? "ATS created this profile without an agent because none is turned on right now." : "ATS created this profile without an agent.";
84436
84246
  input.presenter.line({
84437
84247
  code: "space.join.profile_setup.skipped",
@@ -85737,7 +85547,7 @@ function buildSpaceWebUrl(baseUrl, spaceId) {
85737
85547
  url.port = "";
85738
85548
  url.protocol = "https:";
85739
85549
  }
85740
- url.pathname = `/app/spaces/${encodeURIComponent(spaceId)}`;
85550
+ url.pathname = `/spaces/${encodeURIComponent(spaceId)}`;
85741
85551
  url.search = "";
85742
85552
  url.hash = "";
85743
85553
  return url.toString();
@@ -99523,7 +99333,7 @@ profileCmd.command("show").description("Show one ATS profile.").argument("[profi
99523
99333
  }
99524
99334
  });
99525
99335
  });
99526
- profileCmd.command("update").description("Update an ATS profile.").argument("[profile]", "ATS profile ID").option("--profile <id>", "ATS profile ID").option("--name <profileName>", "ATS profile name").option("--controller-kind <kind>", "Agent controller source for this agent profile: builtin or custom").option("--controller-ref <ref>", "Agent controller ID for this profile").option("--controller-enabled <value>", "Whether the assigned agent controller is enabled for this profile (true|false)").option("--transport-mode <mode>", "Agent controller transport mode for this profile (for example: local-cli)").option("--workspace-mode <mode>", "Workspace mode for this agent profile: ats-managed or custom").option("--workspace-path <path>", "Custom workspace folder for this agent profile").action(async (profile, opts) => {
99336
+ profileCmd.command("update").description("Update an ATS profile.").argument("[profile]", "ATS profile ID").option("--profile <id>", "ATS profile ID").option("--name <profileName>", "ATS profile name").option("--workspace-mode <mode>", "Workspace mode for this agent profile: ats-managed or custom").option("--workspace-path <path>", "Custom workspace folder for this agent profile").action(async (profile, opts) => {
99527
99337
  const outputView = await resolveEffectiveViewForOutput();
99528
99338
  const view = getGlobalViewOption();
99529
99339
  const targetProfile = (typeof profile === "string" ? profile : void 0) ?? opts.profile;
@@ -99539,10 +99349,6 @@ profileCmd.command("update").description("Update an ATS profile.").argument("[pr
99539
99349
  await runProfileUpdate({
99540
99350
  profile: targetProfile,
99541
99351
  profileName: opts.name,
99542
- controllerKind: opts.controllerKind,
99543
- controllerRef: opts.controllerRef,
99544
- controllerEnabled: typeof opts.controllerEnabled === "string" ? parseBooleanOption(opts.controllerEnabled, "--controller-enabled") : void 0,
99545
- transportMode: typeof opts.transportMode === "string" ? opts.transportMode : void 0,
99546
99352
  workspaceMode: typeof opts.workspaceMode === "string" ? opts.workspaceMode : void 0,
99547
99353
  workspacePath: typeof opts.workspacePath === "string" ? opts.workspacePath : void 0,
99548
99354
  view,
@@ -99590,7 +99396,7 @@ function parseBooleanOption(value, optionName) {
99590
99396
  throw new Error(`${optionName} must be true|false`);
99591
99397
  }
99592
99398
  function hasExplicitProfileUpdateField(input) {
99593
- return typeof input.name === "string" || typeof input.controllerKind === "string" || typeof input.controllerRef === "string" || typeof input.controllerEnabled === "string" || typeof input.transportMode === "string" || typeof input.workspaceMode === "string" || typeof input.workspacePath === "string";
99399
+ return typeof input.name === "string" || typeof input.workspaceMode === "string" || typeof input.workspacePath === "string";
99594
99400
  }
99595
99401
  async function maybeRunAgentViewRecoveryAfterSuccess(input) {
99596
99402
  if ((await resolveRuntimeContext({