agent-transport-system 0.7.1 → 0.7.2

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
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { $ as formatLocalSetupActionDescription, $n as SPACE_PASSWORD_MIN_LENGTH, $t as resolveBuiltinProviderConversationCapability, A as claimExecutionDiagnosticsQuerySchema, An as upsertSpaceDeletionTombstoneResponseSchema, Ar as profileWorkspaceModeSchema, At as normalizeBuiltinControllerProviderId, B as currentDeviceTargetResponseSchema, Bn as CONVERSATION_CONTINUITY_WARNING_PURPOSE, Bt as postNormalMessageBodySchema, C as atsRequestContextSchema, Cn as startSessionWithTokenResponseSchema, Cr as daemonStreamFrameSchema, Ct as listProfileSpaceHistoryResponseSchema, D as canonicalizeBuiltinControllerRef, Dn as submitRuntimeRegistrationBodySchema, Dr as normalizeOptionalWorkingDirectory, Dt as localRuntimesQuerySchema, E as buildControllerRoutingKeyForKind, En as submitRuntimeCapabilityReportsResponseSchema, Er as normalizeMessageEnvelope, Et as listSpaceThreadsResponseSchema, F as createSpaceDiagnosticReportResponseSchema, Fn as AGENT_REPLYING_END_PURPOSE, Ft as observabilityWakeTraceSelectorSchema, G as dispatchBriefSchema, Gn as DISPATCH_ACTIVITY_RETRYING_PURPOSE, Gt as postSpaceThreadSignalResponseSchema, H as daemonRouteObservationResponseSchema, Hn as DAEMON_HUB_SCHEMA_VERSION, Ht as postSpaceMembersBodySchema, I as createSpaceResponseSchema, In as AGENT_REPLYING_PURPOSE, It as patchProfileSpaceHistoryStatusResponseSchema, J as entryBriefSchema, Jn as MAX_SIGNAL_REPLY_TO_PREVIEW_LENGTH, Jt as projectObservabilityWakeCorrelation, K as ensureAgentProfilePrimaryBindingBodySchema, Kn as LEGACY_RUNTIME_DISPATCH_POLICY, Kt as prepareSessionResponseSchema, L as createSpaceThreadBodySchema, Ln as AGENT_REPLY_PREVIEW_END_PURPOSE, Lr as runtimeCoordinatorExecutionTokenEnvelopeSchema, Lt as patchSpaceContractBodySchema, M as continuitySchema, Mn as writeCurrentDeviceObservedMetadataResponseSchema, Mr as resolveMessageEnvelopeTargetField, Mt as normalizeSpaceCursorPatch, N as createSpaceBodySchema, Nn as writeSetupTokenLocalRuntimeObservedMetadataBodySchema, Nr as resolveSingleSpaceMentionLabels, Nt as notifyAgentProfileRouteCatalogChangedBodySchema, O as canonicalizeControllerRefForKind, On as submitRuntimeRegistrationResponseSchema, Or as normalizeSpacePasswordText, Ot as localRuntimesResponseSchema, P as createSpaceDiagnosticReportBodySchema, Pn as writeSetupTokenLocalRuntimeObservedMetadataResponseSchema, Pr as resolveSpaceMentionLabels, Pt as notifyAgentProfileRouteCatalogChangedResponseSchema, Q as formatLocalComponentsSummaryLabel, Qn as SPACE_MENTION_REJECT_NOTICE_PURPOSE, Qt as removeSpaceMembersResponseSchema, R as createSpaceThreadResponseSchema, Rn as AGENT_REPLY_PREVIEW_PURPOSE, Rr as sanitizeSignalTextPreview, Rt as patchSpaceContractResponseSchema, S as atsProfileIdSchema, Sn as startSessionSpaceChoiceResponseSchema, Sr as daemonServiceContractSchema, St as leaveSpaceResponseSchema, T as atsdControlPlaneResponseSchema, Tn as submitRuntimeCapabilityReportsBodySchema, Tr as getSpaceMessageAddressingRelationSupportForTargetKind, Tt as listSpaceThreadSignalsResponseSchema, U as daemonRuntimeLeaseSchema, Un as DISPATCH_ACTIVITY_DISPATCHING_PURPOSE, Ut as postSpaceMembersResponseSchema, V as currentLocalRuntimeReplyReadinessResponseSchema, Vn as CURRENT_DAEMON_EXECUTION_CONTRACT_EPOCH, Vt as postNormalMessageResponseSchema, W as deleteSpaceResponseSchema, Wn as DISPATCH_ACTIVITY_FAILED_PURPOSE, Wt as postSpaceThreadSignalBodySchema, X as forgetCurrentComputerResponseSchema, Xn as SPACE_MEMBER_JOIN_NOTICE_PURPOSE, Xt as providerDispatchRuntimeContextSchema, Y as forgetComputerResponseSchema, Yn as MESSAGE_MENTION_TYPE_VALUES, Yt as projectSpaceDispatchTraceFinalVisibleOutcome, Z as formatLocalComponentsSummaryDescription, Zn as SPACE_MEMBER_REMOVE_NOTICE_PURPOSE, Zt as querySpaceDeletionTombstonesResponseSchema, _ as ATSD_CONTROL_PLANE_SCHEMA_VERSION, _n as startDeviceProjectionSchema, _r as daemonHubHeartbeatResponseSchema, _t as getSpaceWakeProgressResponseSchema, a as runWithHeldLock, an as setLocalRuntimeDisplayNameBodySchema, ar as atsdTaskResultPayloadSchema, at as getAgentExecutionReadinessResponseSchema, b as agentExecutionReadinessRouteParamsSchema, bn as startSessionResponseSchema, br as daemonHubRouteCatalogChangedFramePayloadSchema, bt as installedLocalComponentsSnapshotSchema, c as LEGACY_ATS_RUNTIME_SESSION_ENV_KEY, cn as spaceConversationBindingDeleteResponseSchema, cr as conversationExecutionStateSchema, ct as getPrepareReadinessResponseSchema, d as resolveRuntimeSession, dn as spaceConversationBindingUpsertResponseSchema, dr as daemonHubDeliveryExecutionIdentitySchema, dt as getSpaceConversationStatusResponseSchema, en as resolveSpaceDispatchTraceRootCause, er as SPACE_UPDATES_MAX_LIMIT, et as formatLocalSetupActionLabel, f as resolveRuntimeSessionId, fn as spaceCreatorSchema, fr as daemonHubDispatchLifecycleRequestSchema, ft as getSpaceDispatchLookupResponseSchema, g as resolveMappedPublicAgentFailureReason, gn as spaceViewerMembershipResponseSchema, gr as daemonHubHeartbeatRequestSchema, gt as getSpaceUpdatesResponseSchema, h as resolveBuiltinAgentControllerBrand, hn as spaceMetaSchema, hr as daemonHubDispatchRuntimeEvidenceRequestSchema, ht as getSpaceThreadResponseSchema, i as releaseLock, in as setCurrentDeviceTargetBodySchema, ir as atsdTaskResultOpenClawGatewayVisibilityStatusSchema, it as getAgentExecutionReadinessBatchResponseSchema, j as claimExecutionDiagnosticsResponseSchema, jn as writeCurrentDeviceObservedMetadataBodySchema, jr as resolveBuiltinUpstreamConversationRefKind, jt as normalizeListSignalsReadQuerySemantics, k as catchupResponseSchema, kn as upsertProfileSpaceHistoryResponseSchema, kr as parseOptionalClientMessageId, kt as normalizeBuiltinControllerAgentId, l as listRuntimeSessionStates, ln as spaceConversationBindingImportResponseSchema, lr as createDaemonRouteObservationSummary, lt as getSpaceContractResponseSchema, m as CODEX_UPGRADE_REQUIRED_REASON, mn as spaceMembersSnapshotSchema, mr as daemonHubDispatchPreviewRequestSchema, mt as getSpaceStatusResponseSchema, n as isAtsLockError, nn as resolveStartHandoffResponseSchema, nr as atsSpaceEgressActionSchema, nt as gatewayErrorEnvelopeSchema, o as tryCleanupStaleLock, on as signalEnvelopeSchema, or as buildUpstreamConversationRef, ot as getAgentProfilePrimaryBindingResponseSchema, p as writeRuntimeSessionState, pn as spaceDispatchTraceResponseSchema, pr as daemonHubDispatchPreviewEndRequestSchema, pt as getSpaceDispatchResultResponseSchema, q as ensureAgentProfilePrimaryBindingResponseSchema, qn as MAX_PROFILE_WORKING_DIRECTORY_LENGTH, qt as prepareSessionStreamServerFrameSchema, r as readLockMeta, rn as serverErrorFrameSchema, rr as atsdTaskResultEnvelopeWriteSchema, rt as getAgentExecutionReadinessBatchBodySchema, s as ATS_RUNTIME_SESSION_ENV_KEY, sn as spaceConversationBindingConflictResponseSchema, sr as collectCanonicalMentionTextFragments, st as getPrepareReadinessQuerySchema, t as acquireLock, tn as resolveStartHandoffBodySchema, tr as atsRuntimeProfileIdSchema, tt as gatewayErrorCodeSchema, u as readRuntimeSessionState, un as spaceConversationBindingResponseSchema, ur as daemonHubDeliverDispatchRequestSchema, ut as getSpaceConversationRemoteStatusResponseSchema, v as LOCAL_COMPONENTS_SCHEMA_VERSION, vn as startProfileReadinessSummarySchema, vr as daemonHubRegisterSessionRequestSchema, vt as getSpaceWakeTraceWaterfallResponseSchema, w as atsdControlPlaneRequestSchema, wn as structuredGuidePayloadFromInputSchema, wr as formatCanonicalMentionLiteral, wt as listSpaceThreadEventsResponseSchema, x as agentProfileBindingRouteParamsSchema, xn as startSessionSpaceChoiceBodySchema, xr as daemonHubSubmitTaskResultRequestSchema, xt as isExplicitBuiltinControllerRef, y as SPACE_DISPATCH_TRACE_PROMPT_PREVIEW_MAX_CHARS, yn as startSessionProgressSchema, yr as daemonHubRegisterSessionResponseSchema, yt as incomingServerMessageSchema, z as createStartSessionBodySchema, zn as ATSD_TASK_RESULT_SCHEMA_VERSION, zt as patchStartSessionBodySchema } from "./lock-DMFLCImg.js";
3
+ import { $ as formatLocalSetupActionDescription, $n as SPACE_PASSWORD_MIN_LENGTH, $t as resolveBuiltinProviderConversationCapability, A as claimExecutionDiagnosticsQuerySchema, An as upsertSpaceDeletionTombstoneResponseSchema, Ar as profileWorkspaceModeSchema, At as normalizeBuiltinControllerProviderId, B as currentDeviceTargetResponseSchema, Bn as CONVERSATION_CONTINUITY_WARNING_PURPOSE, Bt as postNormalMessageBodySchema, C as atsRequestContextSchema, Cn as startSessionWithTokenResponseSchema, Cr as daemonStreamFrameSchema, Ct as listProfileSpaceHistoryResponseSchema, D as canonicalizeBuiltinControllerRef, Dn as submitRuntimeRegistrationBodySchema, Dr as normalizeOptionalWorkingDirectory, Dt as localRuntimesQuerySchema, E as buildControllerRoutingKeyForKind, En as submitRuntimeCapabilityReportsResponseSchema, Er as normalizeMessageEnvelope, Et as listSpaceThreadsResponseSchema, F as createSpaceDiagnosticReportResponseSchema, Fn as AGENT_REPLYING_END_PURPOSE, Ft as observabilityWakeTraceSelectorSchema, G as dispatchBriefSchema, Gn as DISPATCH_ACTIVITY_RETRYING_PURPOSE, Gt as postSpaceThreadSignalResponseSchema, H as daemonRouteObservationResponseSchema, Hn as DAEMON_HUB_SCHEMA_VERSION, Ht as postSpaceMembersBodySchema, I as createSpaceResponseSchema, In as AGENT_REPLYING_PURPOSE, It as patchProfileSpaceHistoryStatusResponseSchema, J as entryBriefSchema, Jn as MAX_SIGNAL_REPLY_TO_PREVIEW_LENGTH, Jt as projectObservabilityWakeCorrelation, K as ensureAgentProfilePrimaryBindingBodySchema, Kn as LEGACY_RUNTIME_DISPATCH_POLICY, Kt as prepareSessionResponseSchema, L as createSpaceThreadBodySchema, Ln as AGENT_REPLY_PREVIEW_END_PURPOSE, Lr as runtimeCoordinatorExecutionTokenEnvelopeSchema, Lt as patchSpaceContractBodySchema, M as continuitySchema, Mn as writeCurrentDeviceObservedMetadataResponseSchema, Mr as resolveMessageEnvelopeTargetField, Mt as normalizeSpaceCursorPatch, N as createSpaceBodySchema, Nn as writeSetupTokenLocalRuntimeObservedMetadataBodySchema, Nr as resolveSingleSpaceMentionLabels, Nt as notifyAgentProfileRouteCatalogChangedBodySchema, O as canonicalizeControllerRefForKind, On as submitRuntimeRegistrationResponseSchema, Or as normalizeSpacePasswordText, Ot as localRuntimesResponseSchema, P as createSpaceDiagnosticReportBodySchema, Pn as writeSetupTokenLocalRuntimeObservedMetadataResponseSchema, Pr as resolveSpaceMentionLabels, Pt as notifyAgentProfileRouteCatalogChangedResponseSchema, Q as formatLocalComponentsSummaryLabel, Qn as SPACE_MENTION_REJECT_NOTICE_PURPOSE, Qt as removeSpaceMembersResponseSchema, R as createSpaceThreadResponseSchema, Rn as AGENT_REPLY_PREVIEW_PURPOSE, Rr as sanitizeSignalTextPreview, Rt as patchSpaceContractResponseSchema, S as atsProfileIdSchema, Sn as startSessionSpaceChoiceResponseSchema, Sr as daemonServiceContractSchema, St as leaveSpaceResponseSchema, T as atsdControlPlaneResponseSchema, Tn as submitRuntimeCapabilityReportsBodySchema, Tr as getSpaceMessageAddressingRelationSupportForTargetKind, Tt as listSpaceThreadSignalsResponseSchema, U as daemonRuntimeLeaseSchema, Un as DISPATCH_ACTIVITY_DISPATCHING_PURPOSE, Ut as postSpaceMembersResponseSchema, V as currentLocalRuntimeReplyReadinessResponseSchema, Vn as CURRENT_DAEMON_EXECUTION_CONTRACT_EPOCH, Vt as postNormalMessageResponseSchema, W as deleteSpaceResponseSchema, Wn as DISPATCH_ACTIVITY_FAILED_PURPOSE, Wt as postSpaceThreadSignalBodySchema, X as forgetCurrentComputerResponseSchema, Xn as SPACE_MEMBER_JOIN_NOTICE_PURPOSE, Xt as providerDispatchRuntimeContextSchema, Y as forgetComputerResponseSchema, Yn as MESSAGE_MENTION_TYPE_VALUES, Yt as projectSpaceDispatchTraceFinalVisibleOutcome, Z as formatLocalComponentsSummaryDescription, Zn as SPACE_MEMBER_REMOVE_NOTICE_PURPOSE, Zt as querySpaceDeletionTombstonesResponseSchema, _ as ATSD_CONTROL_PLANE_SCHEMA_VERSION, _n as startDeviceProjectionSchema, _r as daemonHubHeartbeatResponseSchema, _t as getSpaceWakeProgressResponseSchema, a as runWithHeldLock, an as setLocalRuntimeDisplayNameBodySchema, ar as atsdTaskResultPayloadSchema, at as getAgentExecutionReadinessResponseSchema, b as agentExecutionReadinessRouteParamsSchema, bn as startSessionResponseSchema, br as daemonHubRouteCatalogChangedFramePayloadSchema, bt as installedLocalComponentsSnapshotSchema, c as LEGACY_ATS_RUNTIME_SESSION_ENV_KEY, cn as spaceConversationBindingDeleteResponseSchema, cr as conversationExecutionStateSchema, ct as getPrepareReadinessResponseSchema, d as resolveRuntimeSession, dn as spaceConversationBindingUpsertResponseSchema, dr as daemonHubDeliveryExecutionIdentitySchema, dt as getSpaceConversationStatusResponseSchema, en as resolveSpaceDispatchTraceRootCause, er as SPACE_UPDATES_MAX_LIMIT, et as formatLocalSetupActionLabel, f as resolveRuntimeSessionId, fn as spaceCreatorSchema, fr as daemonHubDispatchLifecycleRequestSchema, ft as getSpaceDispatchLookupResponseSchema, g as resolveMappedPublicAgentFailureReason, gn as spaceViewerMembershipResponseSchema, gr as daemonHubHeartbeatRequestSchema, gt as getSpaceUpdatesResponseSchema, h as resolveBuiltinAgentControllerBrand, hn as spaceMetaSchema, hr as daemonHubDispatchRuntimeEvidenceRequestSchema, ht as getSpaceThreadResponseSchema, i as releaseLock, in as setCurrentDeviceTargetBodySchema, ir as atsdTaskResultOpenClawGatewayVisibilityStatusSchema, it as getAgentExecutionReadinessBatchResponseSchema, j as claimExecutionDiagnosticsResponseSchema, jn as writeCurrentDeviceObservedMetadataBodySchema, jr as resolveBuiltinUpstreamConversationRefKind, jt as normalizeListSignalsReadQuerySemantics, k as catchupResponseSchema, kn as upsertProfileSpaceHistoryResponseSchema, kr as parseOptionalClientMessageId, kt as normalizeBuiltinControllerAgentId, l as listRuntimeSessionStates, ln as spaceConversationBindingImportResponseSchema, lr as createDaemonRouteObservationSummary, lt as getSpaceContractResponseSchema, m as CODEX_UPGRADE_REQUIRED_REASON, mn as spaceMembersSnapshotSchema, mr as daemonHubDispatchPreviewRequestSchema, mt as getSpaceStatusResponseSchema, n as isAtsLockError, nn as resolveStartHandoffResponseSchema, nr as atsSpaceEgressActionSchema, nt as gatewayErrorEnvelopeSchema, o as tryCleanupStaleLock, on as signalEnvelopeSchema, or as buildUpstreamConversationRef, ot as getAgentProfilePrimaryBindingResponseSchema, p as writeRuntimeSessionState, pn as spaceDispatchTraceResponseSchema, pr as daemonHubDispatchPreviewEndRequestSchema, pt as getSpaceDispatchResultResponseSchema, q as ensureAgentProfilePrimaryBindingResponseSchema, qn as MAX_PROFILE_WORKING_DIRECTORY_LENGTH, qt as prepareSessionStreamServerFrameSchema, r as readLockMeta, rn as serverErrorFrameSchema, rr as atsdTaskResultEnvelopeWriteSchema, rt as getAgentExecutionReadinessBatchBodySchema, s as ATS_RUNTIME_SESSION_ENV_KEY, sn as spaceConversationBindingConflictResponseSchema, sr as collectCanonicalMentionTextFragments, st as getPrepareReadinessQuerySchema, t as acquireLock, tn as resolveStartHandoffBodySchema, tr as atsRuntimeProfileIdSchema, tt as gatewayErrorCodeSchema, u as readRuntimeSessionState, un as spaceConversationBindingResponseSchema, ur as daemonHubDeliverDispatchRequestSchema, ut as getSpaceConversationRemoteStatusResponseSchema, v as LOCAL_COMPONENTS_SCHEMA_VERSION, vn as startProfileReadinessSummarySchema, vr as daemonHubRegisterSessionRequestSchema, vt as getSpaceWakeTraceWaterfallResponseSchema, w as atsdControlPlaneRequestSchema, wn as structuredGuidePayloadFromInputSchema, wr as formatCanonicalMentionLiteral, wt as listSpaceThreadEventsResponseSchema, x as agentProfileBindingRouteParamsSchema, xn as startSessionSpaceChoiceBodySchema, xr as daemonHubSubmitTaskResultRequestSchema, xt as isExplicitBuiltinControllerRef, y as SPACE_DISPATCH_TRACE_PROMPT_PREVIEW_MAX_CHARS, yn as startSessionProgressSchema, yr as daemonHubRegisterSessionResponseSchema, yt as incomingServerMessageSchema, z as createStartSessionBodySchema, zn as ATSD_TASK_RESULT_SCHEMA_VERSION, zt as patchStartSessionBodySchema } from "./lock-BG0gWBdN.js";
4
4
  import { A as runtimeDir, C as normalizeAtsProfileId, D as resolveAtsEnvPreset, E as resolveAtsCliEntryNameFromArgv, F as systemDir, N as skillsDir, O as resolveAtsRootDir, P as spacesDir, S as normalizeAccountKey, T as profileViewPath, a as accountProfileWorkspacePath, c as atsRootDir, d as deviceOpenClawProfileBootstrapPath, f as deviceOpenClawProfileDir, i as accountProfileViewPath, j as runtimeLogsDir, k as resolveDefaultAtsHomeDirname, n as accountProfileLocalMetaPath, o as accountsDir, p as deviceOpenClawProfileWorkspaceDir, r as accountProfileSpaceCacheDir, s as atsBackupsDir, t as ATS_HOME_ENV_KEY, w as profileDir, y as legacyAccountProfileSpacesDir } from "./paths-DFiopT5Y.js";
5
- import { A as toSpaceCursorUrl, B as toSpaceSignalsUrl, C as resolveDefaultGatewayBaseUrl, D as toDaemonRouteObservationUrl, E as toClaimExecutionDiagnosticsUrl, F as toSpaceMembersUrl, H as toSpaceWsUrl, I as toSpaceMetaUrl, L as toSpacePasswordUrl, M as toSpaceDispatchLookupUrl, N as toSpaceDispatchTraceUrl, O as toSpaceContractUrl, P as toSpaceLeaveUrl, R as toSpaceRemoveMembersUrl, S as resolveBaseUrlOrNull, T as normalizeBaseUrl, V as toSpaceUpdatesUrl, _ as updateConfiguredStartV1OnboardingState, a as getConfiguredDeviceRuntimeState, b as normalizeGatewayBaseUrlOrNull, c as getConfiguredStartV1OnboardingState, d as resolveRuntimeSkillsCustomTargetId, f as setConfiguredBaseUrl, g as updateConfiguredSkillsConfig, h as updateConfiguredOnboardingConfig, i as getConfiguredDaemonDispatchLimits, j as toSpaceDeleteUrl, k as toSpaceCreateUrl, l as getConfiguredViewCustomization, m as updateConfiguredDeviceRuntimeState, n as alignRuntimeConfigStorage, o as getConfiguredOnboardingDisclaimerAcceptedAt, p as setConfiguredSkillsConfig, r as createDefaultRuntimeAgentControllerSettings, s as getConfiguredSkillsConfig, t as DEFAULT_RUNTIME_AGENT_TRANSPORT_MODE, u as getRuntimeConfigReadHealth, w as resolveExplicitGatewayUrlOrThrow, x as resolveBaseUrl, y as normalizeGatewayBaseUrl, z as toSpaceResultUrl } from "./runtime-config-R4-KwMpn.js";
5
+ import { A as toSpaceCursorUrl, B as toSpaceSignalsUrl, C as resolveDefaultGatewayBaseUrl, D as toDaemonRouteObservationUrl, E as toClaimExecutionDiagnosticsUrl, F as toSpaceMembersUrl, H as toSpaceWsUrl, I as toSpaceMetaUrl, L as toSpacePasswordUrl, M as toSpaceDispatchLookupUrl, N as toSpaceDispatchTraceUrl, O as toSpaceContractUrl, P as toSpaceLeaveUrl, R as toSpaceRemoveMembersUrl, S as resolveBaseUrlOrNull, T as normalizeBaseUrl, V as toSpaceUpdatesUrl, _ as updateConfiguredStartV1OnboardingState, a as getConfiguredDeviceRuntimeState, b as normalizeGatewayBaseUrlOrNull, c as getConfiguredStartV1OnboardingState, d as resolveRuntimeSkillsCustomTargetId, f as setConfiguredBaseUrl, g as updateConfiguredSkillsConfig, h as updateConfiguredOnboardingConfig, i as getConfiguredDaemonDispatchLimits, j as toSpaceDeleteUrl, k as toSpaceCreateUrl, l as getConfiguredViewCustomization, m as updateConfiguredDeviceRuntimeState, n as alignRuntimeConfigStorage, o as getConfiguredOnboardingDisclaimerAcceptedAt, p as setConfiguredSkillsConfig, r as createDefaultRuntimeAgentControllerSettings, s as getConfiguredSkillsConfig, t as DEFAULT_RUNTIME_AGENT_TRANSPORT_MODE, u as getRuntimeConfigReadHealth, w as resolveExplicitGatewayUrlOrThrow, x as resolveBaseUrl, y as normalizeGatewayBaseUrl, z as toSpaceResultUrl } from "./runtime-config-D3F15r0W.js";
6
6
  import { createRequire } from "node:module";
7
7
  import { Command, Option } from "commander";
8
8
  import { accessSync, appendFileSync, chmodSync, constants, existsSync, mkdirSync, readFileSync, realpathSync, renameSync, statSync, writeFileSync } from "node:fs";
@@ -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.1";
30
+ var version = "0.7.2";
31
31
  var package_default = {
32
32
  $schema: "https://www.schemastore.org/package.json",
33
33
  name: "agent-transport-system",
@@ -3795,7 +3795,7 @@ async function requestLatestPackageVersion(packageName) {
3795
3795
  if (!version) throw new Error("missing version");
3796
3796
  return version;
3797
3797
  } catch (error) {
3798
- throw new Error(`version check failed: invalid registry response: ${toErrorMessage$38(error)}`);
3798
+ throw new Error(`version check failed: invalid registry response: ${toErrorMessage$40(error)}`);
3799
3799
  }
3800
3800
  }
3801
3801
  function compareSemver(a, b) {
@@ -3860,7 +3860,7 @@ function toNonEmptyString(value) {
3860
3860
  const normalized = value.trim();
3861
3861
  return normalized.length > 0 ? normalized : null;
3862
3862
  }
3863
- function toErrorMessage$38(error) {
3863
+ function toErrorMessage$40(error) {
3864
3864
  if (error instanceof Error) return error.message;
3865
3865
  return String(error);
3866
3866
  }
@@ -4336,7 +4336,7 @@ async function setDaemonServiceRuntimeState(state, pathInput = {}) {
4336
4336
  await writeDaemonServiceRuntimeState(state, pathInput);
4337
4337
  }
4338
4338
  async function clearDaemonServiceRuntimeState(pathInput = {}) {
4339
- const { clearDaemonRuntimeLease } = await import("./daemon-runtime-lease-VVFugyeo.js");
4339
+ const { clearDaemonRuntimeLease } = await import("./daemon-runtime-lease-DYVTk_Z6.js");
4340
4340
  await Promise.all([rm(daemonServiceRuntimeStatePath(pathInput), { force: true }), clearDaemonRuntimeLease(pathInput)]);
4341
4341
  }
4342
4342
  async function withDaemonServiceRunLock(callback, meta = {
@@ -5052,7 +5052,7 @@ async function storeAccessToken(input) {
5052
5052
  key
5053
5053
  };
5054
5054
  }
5055
- throw new Error(`failed to store access token in macOS Keychain: ${toErrorMessage$37(error)}`);
5055
+ throw new Error(`failed to store access token in macOS Keychain: ${toErrorMessage$39(error)}`);
5056
5056
  }
5057
5057
  if (process.platform === "win32") try {
5058
5058
  await setWindowsDpapiToken({
@@ -5074,7 +5074,7 @@ async function storeAccessToken(input) {
5074
5074
  key
5075
5075
  };
5076
5076
  }
5077
- throw new Error(`failed to store access token via Windows DPAPI: ${toErrorMessage$37(error)}`);
5077
+ throw new Error(`failed to store access token via Windows DPAPI: ${toErrorMessage$39(error)}`);
5078
5078
  }
5079
5079
  if (allowInsecureFallback()) {
5080
5080
  await setInsecureFileToken({
@@ -5326,7 +5326,7 @@ function normalizeToken(value) {
5326
5326
  const normalized = value.trim();
5327
5327
  return normalized.length > 0 ? normalized : null;
5328
5328
  }
5329
- function toErrorMessage$37(error) {
5329
+ function toErrorMessage$39(error) {
5330
5330
  if (error instanceof Error) return error.message;
5331
5331
  return String(error);
5332
5332
  }
@@ -8434,7 +8434,7 @@ function normalizeOptionalText$46(value) {
8434
8434
  function nowIsoString() {
8435
8435
  return (/* @__PURE__ */ new Date()).toISOString();
8436
8436
  }
8437
- function toErrorMessage$36(error) {
8437
+ function toErrorMessage$38(error) {
8438
8438
  if (error instanceof Error) return error.message;
8439
8439
  return String(error);
8440
8440
  }
@@ -11332,7 +11332,7 @@ const backupAndCleanRuntimeState = async (input) => {
11332
11332
  appliedAt: input.nowIso,
11333
11333
  backupPaths,
11334
11334
  cleanedPaths,
11335
- errorMessage: toErrorMessage$36(error),
11335
+ errorMessage: toErrorMessage$38(error),
11336
11336
  fromEpoch: input.fromEpoch,
11337
11337
  reason: input.reason,
11338
11338
  status: "failed",
@@ -12179,7 +12179,7 @@ function createSpaceRequestTimeoutError(input) {
12179
12179
  return error;
12180
12180
  }
12181
12181
  function createSpaceRequestNetworkError(input) {
12182
- const error = new Error(`${input.operation} request could not reach ${describeRequestTarget(input.url)} (${toErrorMessage$35(input.cause)})`, { cause: input.cause });
12182
+ const error = new Error(`${input.operation} request could not reach ${describeRequestTarget(input.url)} (${toErrorMessage$37(input.cause)})`, { cause: input.cause });
12183
12183
  error.code = "network.request_failed";
12184
12184
  return error;
12185
12185
  }
@@ -12217,7 +12217,7 @@ function describeRequestTarget(url) {
12217
12217
  return url;
12218
12218
  }
12219
12219
  }
12220
- function toErrorMessage$35(error) {
12220
+ function toErrorMessage$37(error) {
12221
12221
  if (error instanceof Error) {
12222
12222
  const message = error.message.trim();
12223
12223
  return message.length > 0 ? message : "request failed";
@@ -12227,7 +12227,7 @@ function toErrorMessage$35(error) {
12227
12227
  }
12228
12228
  function shouldWrapNetworkRequestError(error) {
12229
12229
  if (error instanceof TypeError) return true;
12230
- const message = toErrorMessage$35(error).toLowerCase();
12230
+ const message = toErrorMessage$37(error).toLowerCase();
12231
12231
  return message.includes("fetch failed") || message.includes("failed to fetch") || message.includes("network request failed");
12232
12232
  }
12233
12233
 
@@ -12290,7 +12290,7 @@ function normalizeProfileIdList(value) {
12290
12290
  if (!Array.isArray(value)) return [];
12291
12291
  return value.map((item) => normalize$1(item)).filter((item) => item.length > 0);
12292
12292
  }
12293
- function toErrorMessage$34(err) {
12293
+ function toErrorMessage$36(err) {
12294
12294
  if (err instanceof Error) return err.message;
12295
12295
  return String(err);
12296
12296
  }
@@ -13674,7 +13674,7 @@ async function verifyLaunchContractFiles(input) {
13674
13674
  };
13675
13675
  } catch (error) {
13676
13676
  return {
13677
- errorMessage: toErrorMessage$33(error),
13677
+ errorMessage: toErrorMessage$35(error),
13678
13678
  ok: false
13679
13679
  };
13680
13680
  }
@@ -13701,7 +13701,7 @@ async function verifyCliLaunchContract(input) {
13701
13701
  return fileCheck;
13702
13702
  } catch (error) {
13703
13703
  return {
13704
- errorMessage: `${input.displayName} can't start on this device: ${toErrorMessage$33(error)}`,
13704
+ errorMessage: `${input.displayName} can't start on this device: ${toErrorMessage$35(error)}`,
13705
13705
  ok: false
13706
13706
  };
13707
13707
  }
@@ -13762,7 +13762,7 @@ async function inspectInstalledNodeScriptLaunchCandidate(input) {
13762
13762
  };
13763
13763
  } catch (error) {
13764
13764
  return {
13765
- errorMessage: `${input.displayName} is installed, but ATS could not inspect its launch files: ${toErrorMessage$33(error)}`,
13765
+ errorMessage: `${input.displayName} is installed, but ATS could not inspect its launch files: ${toErrorMessage$35(error)}`,
13766
13766
  ok: false
13767
13767
  };
13768
13768
  }
@@ -13959,7 +13959,7 @@ function shortenPathForDisplay(path) {
13959
13959
  function resolveNodeVersionFromPath(path) {
13960
13960
  return normalizeOptionalText$40(path.match(NODE_VERSION_PATH_RE)?.[1]);
13961
13961
  }
13962
- function toErrorMessage$33(error) {
13962
+ function toErrorMessage$35(error) {
13963
13963
  return error instanceof Error ? error.message : String(error);
13964
13964
  }
13965
13965
 
@@ -14968,7 +14968,7 @@ async function invokeOpenClawWithSingleContextHeal(input) {
14968
14968
  createRebuildFailedError: (error) => new OpenClawRuntimeError({
14969
14969
  code: "context.rebuild_failed",
14970
14970
  errorType: "adapter",
14971
- message: `context.rebuild_failed: ${toErrorMessage$32(error)}`
14971
+ message: `context.rebuild_failed: ${toErrorMessage$34(error)}`
14972
14972
  }),
14973
14973
  invokeOnce: (sessionId) => invokeOpenClawOnce({
14974
14974
  openClawAgentId: input.openClawAgentId,
@@ -15019,11 +15019,11 @@ async function invokeOpenClawOnce(input) {
15019
15019
  throw new OpenClawRuntimeError({
15020
15020
  code: "upstream_unreachable",
15021
15021
  errorType: "adapter",
15022
- message: `upstream_unreachable: ${toErrorMessage$32(error)}`
15022
+ message: `upstream_unreachable: ${toErrorMessage$34(error)}`
15023
15023
  });
15024
15024
  }
15025
15025
  }
15026
- function toErrorMessage$32(error) {
15026
+ function toErrorMessage$34(error) {
15027
15027
  if (error instanceof Error) return error.message;
15028
15028
  return String(error);
15029
15029
  }
@@ -15316,7 +15316,7 @@ function toOpenClawGatewayTransportError(error) {
15316
15316
  });
15317
15317
  const stderr = normalizeOptionalText$32(error?.stderr);
15318
15318
  const stdout = normalizeOptionalText$32(error?.stdout);
15319
- return classifyGatewayFailure(stderr ?? stdout ?? toErrorMessage$31(error));
15319
+ return classifyGatewayFailure(stderr ?? stdout ?? toErrorMessage$33(error));
15320
15320
  }
15321
15321
  function classifyGatewayFailure(message) {
15322
15322
  return new OpenClawGatewayTransportError(classifyOpenClawFailureMessage({ message }));
@@ -15325,7 +15325,7 @@ function normalizeOptionalText$32(value) {
15325
15325
  const normalized = String(value ?? "").trim();
15326
15326
  return normalized.length > 0 ? normalized : null;
15327
15327
  }
15328
- function toErrorMessage$31(error) {
15328
+ function toErrorMessage$33(error) {
15329
15329
  return error instanceof Error ? error.message : String(error);
15330
15330
  }
15331
15331
 
@@ -15597,7 +15597,7 @@ async function runOpenClawJsonCommand(input) {
15597
15597
  try {
15598
15598
  return JSON.parse(stdout);
15599
15599
  } catch (error) {
15600
- throw new Error(`openclaw JSON output could not be parsed: ${toErrorMessage$30(error)}`);
15600
+ throw new Error(`openclaw JSON output could not be parsed: ${toErrorMessage$32(error)}`);
15601
15601
  }
15602
15602
  }
15603
15603
  async function runOpenClawCommand(input) {
@@ -15632,7 +15632,7 @@ function normalizeOptionalText$30(value) {
15632
15632
  const normalized = String(value ?? "").trim();
15633
15633
  return normalized.length > 0 ? normalized : null;
15634
15634
  }
15635
- function toErrorMessage$30(error) {
15635
+ function toErrorMessage$32(error) {
15636
15636
  return error instanceof Error ? error.message : String(error);
15637
15637
  }
15638
15638
  function isExecFileTimeoutError(error) {
@@ -15646,7 +15646,7 @@ function resolveOpenClawCliErrorMessage(error, timeoutMs) {
15646
15646
  const cliMessage = normalizeOptionalText$30(error.stderr) ?? stdout;
15647
15647
  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`;
15648
15648
  if (cliMessage) return cliMessage;
15649
- return `openclaw command failed: ${toErrorMessage$30(error)}`;
15649
+ return `openclaw command failed: ${toErrorMessage$32(error)}`;
15650
15650
  }
15651
15651
  function parseOpenClawAgentSummary(value) {
15652
15652
  if (!value || typeof value !== "object") return null;
@@ -16027,7 +16027,7 @@ async function ensureOpenClawGatewayAgentVisible(input, deps = DEFAULT_OPENCLAW_
16027
16027
  gatewayRestartAttempted: true,
16028
16028
  gatewayVisibility: "missing_before_restart"
16029
16029
  },
16030
- message: `OpenClaw gateway restart failed while making agent '${agentId}' visible: ${toErrorMessage$29(error)}`
16030
+ message: `OpenClaw gateway restart failed while making agent '${agentId}' visible: ${toErrorMessage$31(error)}`
16031
16031
  });
16032
16032
  }
16033
16033
  let lastVisibilityError = null;
@@ -16056,7 +16056,7 @@ async function ensureOpenClawGatewayAgentVisible(input, deps = DEFAULT_OPENCLAW_
16056
16056
  gatewayRestartAttempted: true,
16057
16057
  gatewayVisibility: "missing_after_restart"
16058
16058
  },
16059
- 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)}`
16059
+ 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)}`
16060
16060
  });
16061
16061
  }
16062
16062
  async function maybeCopyOpenClawAuth(input) {
@@ -16097,7 +16097,7 @@ async function ensureParentDirectory(path) {
16097
16097
  async function pathExists$2(path) {
16098
16098
  return await access(path, constants.F_OK).then(() => true).catch(() => false);
16099
16099
  }
16100
- function toErrorMessage$29(error) {
16100
+ function toErrorMessage$31(error) {
16101
16101
  return error instanceof Error ? error.message : String(error);
16102
16102
  }
16103
16103
  function normalizeBootstrapReadError(error) {
@@ -16216,7 +16216,7 @@ function assertOpenClawWorkspaceMatch(input) {
16216
16216
  });
16217
16217
  }
16218
16218
  function isOpenClawAgentAlreadyExistsError(error) {
16219
- const normalizedMessage = toErrorMessage$29(error).toLowerCase();
16219
+ const normalizedMessage = toErrorMessage$31(error).toLowerCase();
16220
16220
  return normalizedMessage.includes("agent") && normalizedMessage.includes("already exists");
16221
16221
  }
16222
16222
  function resolveProviderRuntimeWorkingDirectory(value) {
@@ -16254,7 +16254,7 @@ async function prepareOpenClawRuntime(input, deps = DEFAULT_OPENCLAW_RUNTIME_PRE
16254
16254
  }).catch((error) => {
16255
16255
  throw new DaemonServiceRunError({
16256
16256
  code: "controller.bootstrap.failed",
16257
- message: `controller.bootstrap.failed: ${toErrorMessage$28(error)}`,
16257
+ message: `controller.bootstrap.failed: ${toErrorMessage$30(error)}`,
16258
16258
  providerErrorCode: extractErrorCode$1(error)
16259
16259
  });
16260
16260
  });
@@ -16264,7 +16264,7 @@ async function prepareOpenClawRuntime(input, deps = DEFAULT_OPENCLAW_RUNTIME_PRE
16264
16264
  }).catch((error) => {
16265
16265
  throw new DaemonServiceRunError({
16266
16266
  code: "controller.gateway.unhealthy",
16267
- message: `controller.gateway.unhealthy: ${toErrorMessage$28(error)}`,
16267
+ message: `controller.gateway.unhealthy: ${toErrorMessage$30(error)}`,
16268
16268
  providerErrorCode: extractErrorCode$1(error)
16269
16269
  });
16270
16270
  });
@@ -16276,7 +16276,7 @@ async function prepareOpenClawRuntime(input, deps = DEFAULT_OPENCLAW_RUNTIME_PRE
16276
16276
  const gatewayFailure = buildOpenClawGatewayVisibilityFailure(error);
16277
16277
  throw new DaemonServiceRunError({
16278
16278
  code: "controller.gateway.unhealthy",
16279
- message: `controller.gateway.unhealthy: ${toErrorMessage$28(error)}`,
16279
+ message: `controller.gateway.unhealthy: ${toErrorMessage$30(error)}`,
16280
16280
  providerErrorCode: extractErrorCode$1(error),
16281
16281
  ...gatewayFailure
16282
16282
  });
@@ -16315,7 +16315,7 @@ function resolveOpenClawGatewayVisibilityDiagnostics(error) {
16315
16315
  gatewayVisibility: parsedGatewayVisibility.data
16316
16316
  };
16317
16317
  }
16318
- function toErrorMessage$28(error) {
16318
+ function toErrorMessage$30(error) {
16319
16319
  return error instanceof Error ? error.message : String(error);
16320
16320
  }
16321
16321
 
@@ -16365,7 +16365,7 @@ function createOpenClawLocalDiagnosticsFailure(error) {
16365
16365
  return {
16366
16366
  errorCode: extractErrorCode(error),
16367
16367
  kind: "failed",
16368
- message: toErrorMessage$27(error)
16368
+ message: toErrorMessage$29(error)
16369
16369
  };
16370
16370
  }
16371
16371
  function isOpenClawLocalDiagnosticsFailure(diagnostics) {
@@ -16449,7 +16449,7 @@ async function resolveInspectModeDiagnostics(input) {
16449
16449
  openClawBin: input.openClawBin
16450
16450
  }).then(() => "healthy").catch((error) => ({
16451
16451
  errorCode: extractErrorCode(error),
16452
- message: toErrorMessage$27(error)
16452
+ message: toErrorMessage$29(error)
16453
16453
  }));
16454
16454
  if (gatewayHealth !== "healthy") return {
16455
16455
  ...inspected,
@@ -16529,7 +16529,7 @@ async function resolveInspectGatewayVisibility(input) {
16529
16529
  return {
16530
16530
  errorCode: extractErrorCode(error),
16531
16531
  gatewayVisibility: "not_checked",
16532
- message: toErrorMessage$27(error)
16532
+ message: toErrorMessage$29(error)
16533
16533
  };
16534
16534
  }
16535
16535
  }
@@ -16538,7 +16538,7 @@ function resolveDiagnosticsFailureDetail(input) {
16538
16538
  const inspectedMessage = typeof input.inspected.message === "string" && input.inspected.message.trim().length > 0 ? input.inspected.message.trim() : null;
16539
16539
  return {
16540
16540
  errorCode: inspectedErrorCode ?? extractErrorCode(input.error),
16541
- message: inspectedMessage ?? toErrorMessage$27(input.error)
16541
+ message: inspectedMessage ?? toErrorMessage$29(input.error)
16542
16542
  };
16543
16543
  }
16544
16544
  function resolveDiagnosticsTargetAgent(input) {
@@ -16599,7 +16599,7 @@ function buildBootstrapDiagnosticStatus(bootstrapStatus, errorCode, message) {
16599
16599
  }
16600
16600
  function resolveExplicitBootstrapDiagnostic(error) {
16601
16601
  const explicitErrorCode = extractErrorCode(error);
16602
- const explicitMessage = error ? toErrorMessage$27(error) : null;
16602
+ const explicitMessage = error ? toErrorMessage$29(error) : null;
16603
16603
  switch (explicitErrorCode) {
16604
16604
  case "openclaw.bootstrap.binding_conflict": return buildBootstrapDiagnosticStatus("binding_conflict", explicitErrorCode, explicitMessage);
16605
16605
  case "openclaw.bootstrap.workspace_mismatch": return buildBootstrapDiagnosticStatus("workspace_mismatch", explicitErrorCode, explicitMessage);
@@ -16619,7 +16619,7 @@ function resolveExistingBootstrapStatus(input) {
16619
16619
  }
16620
16620
  function resolveInvalidBootstrapStatus(input) {
16621
16621
  if (input.workspaceAgents.length > 1) return buildBootstrapDiagnosticStatus("workspace_ambiguous", "openclaw.bootstrap.workspace_ambiguous", null);
16622
- return buildBootstrapDiagnosticStatus("invalid", input.bootstrapRead.error?.code ?? extractErrorCode(input.error), input.bootstrapRead.error?.message ?? (input.error ? toErrorMessage$27(input.error) : null));
16622
+ return buildBootstrapDiagnosticStatus("invalid", input.bootstrapRead.error?.code ?? extractErrorCode(input.error), input.bootstrapRead.error?.message ?? (input.error ? toErrorMessage$29(input.error) : null));
16623
16623
  }
16624
16624
  function resolveMissingBootstrapStatus(workspaceAgents, input = {}) {
16625
16625
  if (workspaceAgents.length > 1) return buildBootstrapDiagnosticStatus("workspace_ambiguous", "openclaw.bootstrap.workspace_ambiguous", null);
@@ -16663,7 +16663,7 @@ function extractProviderErrorCode(error) {
16663
16663
  const normalized = String(error.providerErrorCode ?? "").trim();
16664
16664
  return normalized.length > 0 ? normalized : null;
16665
16665
  }
16666
- function toErrorMessage$27(error) {
16666
+ function toErrorMessage$29(error) {
16667
16667
  return error instanceof Error ? error.message : String(error);
16668
16668
  }
16669
16669
 
@@ -19674,7 +19674,7 @@ async function resolveDaemonRuntimeContractCompatibility(input) {
19674
19674
  observedEpoch: null,
19675
19675
  updatedAt: null,
19676
19676
  reasonCode: "daemon.runtime_contract.unavailable",
19677
- errorMessage: toErrorMessage$36(error)
19677
+ errorMessage: toErrorMessage$38(error)
19678
19678
  };
19679
19679
  }
19680
19680
  if (!meta) return {
@@ -21015,7 +21015,7 @@ async function invokeClaudeWithSingleContextHeal(input) {
21015
21015
  return new ClaudeRuntimeError({
21016
21016
  code: "context.rebuild_failed",
21017
21017
  errorType: "adapter",
21018
- message: `context.rebuild_failed: ${toErrorMessage$26(error)}`,
21018
+ message: `context.rebuild_failed: ${toErrorMessage$28(error)}`,
21019
21019
  ...providerAccessEvidence ? { providerAccessEvidence } : {}
21020
21020
  });
21021
21021
  },
@@ -21075,7 +21075,7 @@ async function invokeClaudeOnce(input) {
21075
21075
  throw new ClaudeRuntimeError({
21076
21076
  code: "upstream_unreachable",
21077
21077
  errorType: "adapter",
21078
- message: `upstream_unreachable: ${toErrorMessage$26(error)}`
21078
+ message: `upstream_unreachable: ${toErrorMessage$28(error)}`
21079
21079
  });
21080
21080
  }
21081
21081
  }
@@ -21085,7 +21085,7 @@ function getClaudeProviderAccessEvidence(error) {
21085
21085
  if (!evidence || typeof evidence !== "object") return null;
21086
21086
  return evidence;
21087
21087
  }
21088
- function toErrorMessage$26(error) {
21088
+ function toErrorMessage$28(error) {
21089
21089
  if (error instanceof Error) return error.message;
21090
21090
  return String(error);
21091
21091
  }
@@ -21702,7 +21702,7 @@ async function invokeCodexWithSingleContextHeal(input) {
21702
21702
  createRebuildFailedError: (error) => new CodexRuntimeError({
21703
21703
  code: "context.rebuild_failed",
21704
21704
  errorType: "adapter",
21705
- message: `context.rebuild_failed: ${toErrorMessage$25(error)}`
21705
+ message: `context.rebuild_failed: ${toErrorMessage$27(error)}`
21706
21706
  }),
21707
21707
  invokeOnce: (threadId) => invokeCodexOnce({
21708
21708
  launchContract: input.launchContract,
@@ -21756,11 +21756,11 @@ async function invokeCodexOnce(input) {
21756
21756
  throw new CodexRuntimeError({
21757
21757
  code: "upstream_unreachable",
21758
21758
  errorType: "adapter",
21759
- message: `upstream_unreachable: ${toErrorMessage$25(error)}`
21759
+ message: `upstream_unreachable: ${toErrorMessage$27(error)}`
21760
21760
  });
21761
21761
  }
21762
21762
  }
21763
- function toErrorMessage$25(error) {
21763
+ function toErrorMessage$27(error) {
21764
21764
  if (error instanceof Error) return error.message;
21765
21765
  return String(error);
21766
21766
  }
@@ -22704,7 +22704,7 @@ async function syncDeviceRuntimeStateProjection(input) {
22704
22704
  const projectedControllers = await loadProjectedControllers();
22705
22705
  const registeredCustomTargetIds = await loadRegisteredCustomTargetIds();
22706
22706
  const targetStates = await listAgentTargetStates().catch((error) => {
22707
- throw new Error(`failed to load ATS agent target states: ${toErrorMessage$24(error)}`);
22707
+ throw new Error(`failed to load ATS agent target states: ${toErrorMessage$26(error)}`);
22708
22708
  });
22709
22709
  const targetStateById = new Map(targetStates.map((state) => [state.agentId, state]));
22710
22710
  const projectedControllerIds = [...projectedControllers.keys()].sort();
@@ -22778,12 +22778,12 @@ async function hasValidAuthSession() {
22778
22778
  }
22779
22779
  async function loadProjectedControllers() {
22780
22780
  return await collectProjectedControllers(await listAtsProfiles().catch((error) => {
22781
- throw new Error(`failed to list ATS profiles: ${toErrorMessage$24(error)}`);
22781
+ throw new Error(`failed to list ATS profiles: ${toErrorMessage$26(error)}`);
22782
22782
  }));
22783
22783
  }
22784
22784
  async function loadRegisteredCustomTargetIds() {
22785
22785
  const customTargets = await listAgentCustomTargets().catch((error) => {
22786
- throw new Error(`failed to list ATS custom targets: ${toErrorMessage$24(error)}`);
22786
+ throw new Error(`failed to list ATS custom targets: ${toErrorMessage$26(error)}`);
22787
22787
  });
22788
22788
  return new Set(customTargets.map((target) => target.id));
22789
22789
  }
@@ -23060,7 +23060,7 @@ function emitProjectionEvidence(result) {
23060
23060
  function normalizeText$1(value) {
23061
23061
  return String(value ?? "").trim();
23062
23062
  }
23063
- function toErrorMessage$24(error) {
23063
+ function toErrorMessage$26(error) {
23064
23064
  if (error instanceof Error) return error.message;
23065
23065
  return String(error);
23066
23066
  }
@@ -23487,7 +23487,7 @@ async function readPrimaryBindingForRouteCatalog(input) {
23487
23487
  } catch (error) {
23488
23488
  throw new DaemonServiceRunError({
23489
23489
  code: "daemon.run.primary_binding_lookup_failed",
23490
- message: `Core primary binding lookup failed for profile ${input.profile.atsProfileId}: ${toErrorMessage$36(error)}`
23490
+ message: `Core primary binding lookup failed for profile ${input.profile.atsProfileId}: ${toErrorMessage$38(error)}`
23491
23491
  });
23492
23492
  }
23493
23493
  }
@@ -23495,7 +23495,7 @@ async function repairLocalReplyStateOrThrow(input) {
23495
23495
  try {
23496
23496
  await syncDeviceRuntimeStateProjection({ mode: "repair" });
23497
23497
  } catch (error) {
23498
- const errorMessage = toErrorMessage$36(error);
23498
+ const errorMessage = toErrorMessage$38(error);
23499
23499
  emitRunLine({
23500
23500
  presenter: input.presenter,
23501
23501
  code: "daemon.run.projection_sync_failed",
@@ -23509,7 +23509,7 @@ async function repairLocalReplyStateOrThrow(input) {
23509
23509
  try {
23510
23510
  await syncProfileWorkspaceState({ mode: "repair" });
23511
23511
  } catch (error) {
23512
- const errorMessage = toErrorMessage$36(error);
23512
+ const errorMessage = toErrorMessage$38(error);
23513
23513
  emitRunLine({
23514
23514
  presenter: input.presenter,
23515
23515
  code: "daemon.run.profile_workspace_sync_failed",
@@ -23551,12 +23551,12 @@ async function syncDaemonRouteCatalogState(input) {
23551
23551
  return {
23552
23552
  status: "failed",
23553
23553
  reason: "load_failed",
23554
- errorMessage: toErrorMessage$36(error)
23554
+ errorMessage: toErrorMessage$38(error)
23555
23555
  };
23556
23556
  }
23557
23557
  const nextFingerprint = buildRouteCatalogFingerprint(nextCatalog);
23558
23558
  if (nextFingerprint === input.catalogState.fingerprint) {
23559
- if (input.forceRegister && nextCatalog.profileIds.length > 0) {
23559
+ if ((input.forceRegister || nextCatalog.profileIds.some((profileId) => !input.leasesByProfileId.has(profileId))) && nextCatalog.profileIds.length > 0) {
23560
23560
  let registerResponse;
23561
23561
  try {
23562
23562
  registerResponse = await input.registerCatalog(nextCatalog.profileIds);
@@ -23564,7 +23564,7 @@ async function syncDaemonRouteCatalogState(input) {
23564
23564
  return {
23565
23565
  status: "failed",
23566
23566
  reason: "register_failed",
23567
- errorMessage: toErrorMessage$36(error)
23567
+ errorMessage: toErrorMessage$38(error)
23568
23568
  };
23569
23569
  }
23570
23570
  applyAcceptedLeases({
@@ -23595,7 +23595,7 @@ async function syncDaemonRouteCatalogState(input) {
23595
23595
  return {
23596
23596
  status: "failed",
23597
23597
  reason: "register_failed",
23598
- errorMessage: toErrorMessage$36(error)
23598
+ errorMessage: toErrorMessage$38(error)
23599
23599
  };
23600
23600
  }
23601
23601
  const diff = buildRouteCatalogDiff({
@@ -23738,7 +23738,7 @@ async function resolveDaemonLocalServiceDemand(input) {
23738
23738
  decision: "indeterminate",
23739
23739
  hasWakeableLocalRoute: false,
23740
23740
  repairableReplyCandidateCount: 0,
23741
- reason: `failed to load local daemon routes: ${toErrorMessage$36(error)}`,
23741
+ reason: `failed to load local daemon routes: ${toErrorMessage$38(error)}`,
23742
23742
  wakeableLocalRouteCount: 0,
23743
23743
  projection
23744
23744
  };
@@ -23863,7 +23863,7 @@ async function maybeAutoStopIdleBackgroundDaemonService(input) {
23863
23863
  } catch (error) {
23864
23864
  input.presenter.line({
23865
23865
  code: `${input.codePrefix}.auto_stop_failed`,
23866
- text: `ATS could not auto-stop the background service. ${toErrorMessage$36(error)}`
23866
+ text: `ATS could not auto-stop the background service. ${toErrorMessage$38(error)}`
23867
23867
  });
23868
23868
  return {
23869
23869
  autoStopped: false,
@@ -23957,9 +23957,9 @@ async function resolveGatewayChainReadiness(input = {}) {
23957
23957
  applicable: true,
23958
23958
  baseUrl: fallbackBaseUrl,
23959
23959
  checkedAt,
23960
- details: toErrorMessage$34(error),
23960
+ details: toErrorMessage$36(error),
23961
23961
  errorCode: null,
23962
- errorMessage: toErrorMessage$34(error),
23962
+ errorMessage: toErrorMessage$36(error),
23963
23963
  failureKind: "gateway_unreachable",
23964
23964
  ready: false,
23965
23965
  status: null,
@@ -24876,7 +24876,7 @@ function buildLookupFailedRouteObservationDetail(input) {
24876
24876
  observedAt: input.observedAt,
24877
24877
  reasonCode: "lookup_failed"
24878
24878
  });
24879
- const rawError = toErrorMessage$23(input.error).trim();
24879
+ const rawError = toErrorMessage$25(input.error).trim();
24880
24880
  if (rawError.length === 0 || rawError === detail) return detail;
24881
24881
  return `${detail} Raw lookup error: ${rawError}`;
24882
24882
  }
@@ -24904,7 +24904,7 @@ function enrichRuntimeStateWithManager(input) {
24904
24904
  serviceController: input.runtimeState.serviceController === "unknown" && input.serviceManager?.controller !== void 0 ? input.serviceManager.controller : input.runtimeState.serviceController
24905
24905
  };
24906
24906
  }
24907
- function toErrorMessage$23(error) {
24907
+ function toErrorMessage$25(error) {
24908
24908
  if (error instanceof Error) return error.message;
24909
24909
  return String(error);
24910
24910
  }
@@ -25793,7 +25793,7 @@ async function captureDaemonServiceEvidence(input = {}) {
25793
25793
  errorMessage: null
25794
25794
  })).catch((error) => ({
25795
25795
  snapshot: null,
25796
- errorMessage: toErrorMessage$22(error)
25796
+ errorMessage: toErrorMessage$24(error)
25797
25797
  })),
25798
25798
  captureOwnedProcessesArtifact(phaseRootPath),
25799
25799
  captureSystemServiceDiagnosticsArtifact(phaseRootPath)
@@ -25907,7 +25907,7 @@ async function captureDirectoryArtifact(input) {
25907
25907
  };
25908
25908
  } catch (error) {
25909
25909
  return {
25910
- errorMessage: toErrorMessage$22(error),
25910
+ errorMessage: toErrorMessage$24(error),
25911
25911
  relativePath: null,
25912
25912
  sourcePath: input.sourcePath,
25913
25913
  status: "error"
@@ -25933,7 +25933,7 @@ async function captureFileArtifact(input) {
25933
25933
  };
25934
25934
  } catch (error) {
25935
25935
  return {
25936
- errorMessage: toErrorMessage$22(error),
25936
+ errorMessage: toErrorMessage$24(error),
25937
25937
  relativePath: null,
25938
25938
  sourcePath: input.sourcePath,
25939
25939
  status: "error"
@@ -25955,7 +25955,7 @@ async function captureOwnedProcessesArtifact(evidencePath) {
25955
25955
  } };
25956
25956
  } catch (error) {
25957
25957
  return { artifact: {
25958
- errorMessage: toErrorMessage$22(error),
25958
+ errorMessage: toErrorMessage$24(error),
25959
25959
  relativePath: null,
25960
25960
  sourcePath: null,
25961
25961
  status: "error"
@@ -26062,7 +26062,7 @@ async function runCommand$1(command, args, input = {}) {
26062
26062
  child.once("close", handleClose);
26063
26063
  });
26064
26064
  }
26065
- function toErrorMessage$22(error) {
26065
+ function toErrorMessage$24(error) {
26066
26066
  if (error instanceof Error) return error.message;
26067
26067
  return String(error);
26068
26068
  }
@@ -26234,7 +26234,7 @@ async function runDaemonServiceLifecycle(input) {
26234
26234
  failureStage: state.failureStage,
26235
26235
  evidencePath: state.evidencePath,
26236
26236
  recoveryStatus: "failed_before_safe_state",
26237
- errorMessage: toErrorMessage$21(error)
26237
+ errorMessage: toErrorMessage$23(error)
26238
26238
  };
26239
26239
  }
26240
26240
  }
@@ -26374,7 +26374,7 @@ async function executeDaemonServiceLifecycle(input) {
26374
26374
  }
26375
26375
  }
26376
26376
  async function recoverLifecycleFailure(input) {
26377
- const originalErrorMessage = toErrorMessage$21(input.error);
26377
+ const originalErrorMessage = toErrorMessage$23(input.error);
26378
26378
  const originalFailureStage = resolveLifecycleFailureStage(input.error, input.state.failureStage);
26379
26379
  const originalReasonCodes = resolveLifecycleFailureReasonCodes(input.error);
26380
26380
  if (input.restorePoint.trusted) {
@@ -26892,7 +26892,7 @@ function resolveLifecycleFailureReasonCodes(error) {
26892
26892
  if (error instanceof DaemonServiceLifecycleStageError) return error.reasonCodes;
26893
26893
  return [];
26894
26894
  }
26895
- function toErrorMessage$21(error) {
26895
+ function toErrorMessage$23(error) {
26896
26896
  if (error instanceof Error) return error.message;
26897
26897
  return String(error);
26898
26898
  }
@@ -26909,7 +26909,7 @@ async function stopDaemonProcess$1(pid, signal) {
26909
26909
  process$1.kill(pid, signal);
26910
26910
  } catch (error) {
26911
26911
  if (error instanceof Error && error.code === "ESRCH") return true;
26912
- throw new Error(`Failed to send ${signal} to pid ${String(pid)}: ${toErrorMessage$21(error)}`);
26912
+ throw new Error(`Failed to send ${signal} to pid ${String(pid)}: ${toErrorMessage$23(error)}`);
26913
26913
  }
26914
26914
  if (signal === "SIGKILL") return true;
26915
26915
  return await waitForProcessToExit$1(pid, PROCESS_STOP_WAIT_MS);
@@ -26919,7 +26919,7 @@ async function stopDaemonProcessWithTimeout(pid, signal, timeoutMs) {
26919
26919
  process$1.kill(pid, signal);
26920
26920
  } catch (error) {
26921
26921
  if (error instanceof Error && error.code === "ESRCH") return true;
26922
- throw new Error(`Failed to send ${signal} to pid ${String(pid)}: ${toErrorMessage$21(error)}`);
26922
+ throw new Error(`Failed to send ${signal} to pid ${String(pid)}: ${toErrorMessage$23(error)}`);
26923
26923
  }
26924
26924
  return await waitForProcessToExit$1(pid, timeoutMs);
26925
26925
  }
@@ -26936,7 +26936,7 @@ async function sleep$7(ms) {
26936
26936
  }
26937
26937
  function isLaunchdBootstrapIoError(serviceManager, error) {
26938
26938
  if (serviceManager.controller !== "launchd") return false;
26939
- const message = toErrorMessage$21(error).toLowerCase();
26939
+ const message = toErrorMessage$23(error).toLowerCase();
26940
26940
  return message.includes("bootstrap failed") && message.includes("input/output error");
26941
26941
  }
26942
26942
  async function writeLifecycleEvidenceEvent(input) {
@@ -27374,7 +27374,7 @@ async function resolveUpgradeStatus(input) {
27374
27374
  status: "check_failed",
27375
27375
  currentVersion: input.currentVersion,
27376
27376
  checkedAt: input.checkedAt,
27377
- error: toErrorMessage$20(error)
27377
+ error: toErrorMessage$22(error)
27378
27378
  };
27379
27379
  }
27380
27380
  }
@@ -27745,7 +27745,7 @@ function emitUpgradeCompleted(input) {
27745
27745
  text: "ATS CLI upgrade completed."
27746
27746
  });
27747
27747
  }
27748
- function toErrorMessage$20(error) {
27748
+ function toErrorMessage$22(error) {
27749
27749
  if (error instanceof Error) return error.message;
27750
27750
  return String(error);
27751
27751
  }
@@ -31806,7 +31806,7 @@ async function submitPrepareRuntimeCapabilityReports(input) {
31806
31806
  });
31807
31807
  } catch (error) {
31808
31808
  console.warn("[ats.runtime_reporting.write_failed]", {
31809
- error: toErrorMessage$19(error),
31809
+ error: toErrorMessage$21(error),
31810
31810
  event: "cli.runtime_reporting.write_failed",
31811
31811
  profileIds: input.reports.map((report) => report.diagnosticProfileId).filter((profileId) => Boolean(profileId)),
31812
31812
  reportCount: input.reports.length
@@ -31912,7 +31912,7 @@ function failedSubmission(input) {
31912
31912
  status: "failed"
31913
31913
  };
31914
31914
  }
31915
- function toErrorMessage$19(error) {
31915
+ function toErrorMessage$21(error) {
31916
31916
  if (error instanceof Error) {
31917
31917
  const message = error.message.trim();
31918
31918
  return message.length > 0 ? message : "unknown error";
@@ -32039,7 +32039,7 @@ async function ensureAgentProfileRuntimeBinding(input) {
32039
32039
  };
32040
32040
  } catch (error) {
32041
32041
  console.warn("[ats.agent_profile_binding.ensure_failed]", {
32042
- error: toErrorMessage$18(error),
32042
+ error: toErrorMessage$20(error),
32043
32043
  event: "cli.agent_profile_binding.ensure_failed",
32044
32044
  profileId: input.profile.atsProfileId
32045
32045
  });
@@ -32160,7 +32160,7 @@ function uniqueReasonCodes(reasonCodes) {
32160
32160
  async function sleep$6(durationMs) {
32161
32161
  await new Promise((resolve) => setTimeout(resolve, durationMs));
32162
32162
  }
32163
- function toErrorMessage$18(error) {
32163
+ function toErrorMessage$20(error) {
32164
32164
  if (error instanceof Error) {
32165
32165
  const message = error.message.trim();
32166
32166
  return message.length > 0 ? message : "unknown error";
@@ -33774,7 +33774,7 @@ async function runAuthLogin(input) {
33774
33774
  ott: input.ott,
33775
33775
  allowBackToCaller: input.allowBackToCaller === true
33776
33776
  }).catch((error) => {
33777
- if (runtime.resolvedView === "agent") throw createAuthLoginGuideError(toErrorMessage$17(error));
33777
+ if (runtime.resolvedView === "agent") throw createAuthLoginGuideError(toErrorMessage$19(error));
33778
33778
  throw error;
33779
33779
  });
33780
33780
  if (resolved.status !== "submitted") return handleAuthLoginExit({
@@ -33843,7 +33843,7 @@ async function runAuthLogin(input) {
33843
33843
  }
33844
33844
  });
33845
33845
  }
33846
- throw createAuthLoginGuideError(toErrorMessage$17(error));
33846
+ throw createAuthLoginGuideError(toErrorMessage$19(error));
33847
33847
  }
33848
33848
  throw error;
33849
33849
  }
@@ -34180,7 +34180,7 @@ function resolveClientIdForLogin(value, resolvedView) {
34180
34180
  try {
34181
34181
  return resolveClientId(value);
34182
34182
  } catch (error) {
34183
- if (resolvedView === "agent") throw createAuthLoginGuideError(toErrorMessage$17(error));
34183
+ if (resolvedView === "agent") throw createAuthLoginGuideError(toErrorMessage$19(error));
34184
34184
  throw error;
34185
34185
  }
34186
34186
  }
@@ -34603,7 +34603,7 @@ function normalizeOptionalString$14(value) {
34603
34603
  const normalized = String(value ?? "").trim();
34604
34604
  return normalized.length > 0 ? normalized : null;
34605
34605
  }
34606
- function toErrorMessage$17(error) {
34606
+ function toErrorMessage$19(error) {
34607
34607
  if (error instanceof Error) return error.message;
34608
34608
  return String(error);
34609
34609
  }
@@ -35532,6 +35532,7 @@ const historySizeByPath = /* @__PURE__ */ new Map();
35532
35532
  const HISTORY_ROTATION_MAX_BYTES = 4 * 1024 * 1024;
35533
35533
  const HISTORY_ROTATION_MAX_ARCHIVES = 3;
35534
35534
  const DEDUPE_RETENTION_MS = 2880 * 60 * 1e3;
35535
+ const INFLIGHT_RETENTION_MS = DEDUPE_RETENTION_MS;
35535
35536
  const AGENT_CONTEXT_RETENTION_MS = 720 * 60 * 60 * 1e3;
35536
35537
  const AGENT_CONTEXT_MAX_ENTRIES = 2e3;
35537
35538
  const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
@@ -35771,9 +35772,10 @@ const compactLedgerState = (input) => {
35771
35772
  state: input.state
35772
35773
  });
35773
35774
  const dedupeCutoffMs = referenceNowMs - DEDUPE_RETENTION_MS;
35775
+ const inflightCutoffMs = referenceNowMs - INFLIGHT_RETENTION_MS;
35774
35776
  const agentContextCutoffMs = referenceNowMs - AGENT_CONTEXT_RETENTION_MS;
35775
35777
  const nextDedupeFirstSeenByKey = Object.fromEntries(Object.entries(input.state.dedupeFirstSeenByKey).filter(([, firstSeenAtMs]) => firstSeenAtMs >= dedupeCutoffMs));
35776
- const nextInflightByTaskId = Object.fromEntries(Object.entries(input.state.inflightByTaskId).map(([taskId, taskState]) => [taskId, { ...taskState }]));
35778
+ const nextInflightByTaskId = Object.fromEntries(Object.entries(input.state.inflightByTaskId).filter(([, taskState]) => taskState.firstSeenAtMs >= inflightCutoffMs).map(([taskId, taskState]) => [taskId, { ...taskState }]));
35777
35779
  const inflightTaskIdSet = new Set(Object.keys(nextInflightByTaskId));
35778
35780
  const nextReplayedTaskIds = Object.fromEntries(Object.entries(input.state.replayedTaskIds).filter(([taskId, replayed]) => replayed === true && inflightTaskIdSet.has(taskId)));
35779
35781
  const filteredAgentContexts = Object.entries(input.state.agentContextByLookupKey).filter(([, context]) => context.updatedAtMs >= agentContextCutoffMs).sort((left, right) => {
@@ -37975,13 +37977,13 @@ async function bindImportedUpstreamConversationLocally(input) {
37975
37977
  agentContextLookupKey: seeded.agentContextLookupKey
37976
37978
  };
37977
37979
  } catch (error) {
37978
- if (!snapshot) throw new Error(`local imported upstream conversation bind failed on this device: ${toErrorMessage$16(error)}`);
37980
+ if (!snapshot) throw new Error(`local imported upstream conversation bind failed on this device: ${toErrorMessage$18(error)}`);
37979
37981
  try {
37980
37982
  await restoreImportedConversationExecution({ snapshot });
37981
37983
  } catch (restoreError) {
37982
- 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 });
37984
+ 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 });
37983
37985
  }
37984
- 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 });
37986
+ 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 });
37985
37987
  }
37986
37988
  }
37987
37989
  async function clearImportedUpstreamConversationLocalStateLocally(input) {
@@ -37994,10 +37996,10 @@ async function clearImportedUpstreamConversationLocalStateLocally(input) {
37994
37996
  transportMode: input.transportMode
37995
37997
  });
37996
37998
  } catch (error) {
37997
- 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 });
37999
+ 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 });
37998
38000
  }
37999
38001
  }
38000
- function toErrorMessage$16(error) {
38002
+ function toErrorMessage$18(error) {
38001
38003
  if (error instanceof Error && error.message.trim().length > 0) return error.message;
38002
38004
  return String(error);
38003
38005
  }
@@ -38736,7 +38738,7 @@ function flushDispatchResultOutbox(input) {
38736
38738
  return {
38737
38739
  ...record,
38738
38740
  attemptCount: record.attemptCount + 1,
38739
- lastFailureReason: toErrorMessage$36(error),
38741
+ lastFailureReason: toErrorMessage$38(error),
38740
38742
  nextAttemptAtMs: nowMs + resolveOutboxBackoffMs(record.attemptCount + 1),
38741
38743
  updatedAtMs: nowMs
38742
38744
  };
@@ -38910,7 +38912,7 @@ function createLocalExecutionSlots(input) {
38910
38912
  dispatchId: selectedTask.dispatchId,
38911
38913
  durationMs: Math.max(0, Date.now() - startedAtMs),
38912
38914
  errorCode: null,
38913
- errorMessage: toErrorMessage$15(error),
38915
+ errorMessage: toErrorMessage$17(error),
38914
38916
  localQueue: buildLocalQueueDiagnostics({
38915
38917
  profileId: selectedTask.profileId,
38916
38918
  queuePosition: null,
@@ -39053,7 +39055,7 @@ function createLocalExecutionSlots(input) {
39053
39055
  function buildAttemptKey(dispatchId, attemptId) {
39054
39056
  return `${dispatchId}::${attemptId}`;
39055
39057
  }
39056
- function toErrorMessage$15(error) {
39058
+ function toErrorMessage$17(error) {
39057
39059
  if (error instanceof Error && error.message.trim().length > 0) return error.message;
39058
39060
  if (typeof error === "string" && error.trim().length > 0) return error;
39059
39061
  return "unknown error";
@@ -40336,7 +40338,7 @@ function reportInvalidDeliverRequest(input) {
40336
40338
  leaseEpoch: identity.leaseEpoch,
40337
40339
  metadata: {
40338
40340
  ...buildResultDispatchJournalMetadata(resultPayload),
40339
- errorMessage: toErrorMessage$36(error),
40341
+ errorMessage: toErrorMessage$38(error),
40340
40342
  parseIssues: issues
40341
40343
  },
40342
40344
  profileId: identity.targetProfileId,
@@ -40347,10 +40349,10 @@ function reportInvalidDeliverRequest(input) {
40347
40349
  emitRunLine({
40348
40350
  presenter: input.presenter,
40349
40351
  code: "daemon.run.invalid_deliver_result_send_failed",
40350
- text: `failed to send invalid deliver result for dispatch ${identity.dispatchId}: ${toErrorMessage$36(error)}`,
40352
+ text: `failed to send invalid deliver result for dispatch ${identity.dispatchId}: ${toErrorMessage$38(error)}`,
40351
40353
  payload: {
40352
40354
  dispatchId: identity.dispatchId,
40353
- errorMessage: toErrorMessage$36(error),
40355
+ errorMessage: toErrorMessage$38(error),
40354
40356
  result: "failed",
40355
40357
  taskId: identity.taskId
40356
40358
  }
@@ -41544,7 +41546,7 @@ function normalizeResolvedPostMessageAction(input) {
41544
41546
  resolvedSpaceAction: normalizedPostMessageAction.action
41545
41547
  };
41546
41548
  } catch (error) {
41547
- const failureReason = toErrorMessage$36(error);
41549
+ const failureReason = toErrorMessage$38(error);
41548
41550
  emitRunLine({
41549
41551
  presenter: input.presenter,
41550
41552
  code: "daemon.run.post_message_validation_rejected",
@@ -41610,7 +41612,7 @@ function normalizeResolvedThreadAction(input) {
41610
41612
  })
41611
41613
  };
41612
41614
  } catch (error) {
41613
- const failureReason = toErrorMessage$36(error);
41615
+ const failureReason = toErrorMessage$38(error);
41614
41616
  emitRunLine({
41615
41617
  presenter: input.presenter,
41616
41618
  code: "daemon.run.thread_action_validation_rejected",
@@ -41719,7 +41721,7 @@ async function maybeRepairStructuredSpaceAction(input) {
41719
41721
  dispatchId: input.parsedTask.dispatchId,
41720
41722
  ...resolveStructuredActionFailureDiagnostics({
41721
41723
  carrierKind: "none",
41722
- parseError: toErrorMessage$36(error),
41724
+ parseError: toErrorMessage$38(error),
41723
41725
  publicFailureReason: input.failureReason,
41724
41726
  repairMode: "controller_roundtrip",
41725
41727
  runtimeResult: input.runtimeResult
@@ -41735,7 +41737,7 @@ async function maybeRepairStructuredSpaceAction(input) {
41735
41737
  return {
41736
41738
  finalFailureDiagnostics: resolveStructuredActionFailureDiagnostics({
41737
41739
  carrierKind: "none",
41738
- parseError: toErrorMessage$36(error),
41740
+ parseError: toErrorMessage$38(error),
41739
41741
  publicFailureReason: input.failureReason,
41740
41742
  repairMode: "controller_roundtrip",
41741
41743
  runtimeResult: input.runtimeResult
@@ -42464,7 +42466,7 @@ function toTaskExecutionError(error) {
42464
42466
  return {
42465
42467
  errorCode: "dispatch.execution_failed",
42466
42468
  errorType: "internal",
42467
- message: toErrorMessage$36(error)
42469
+ message: toErrorMessage$38(error)
42468
42470
  };
42469
42471
  }
42470
42472
  function normalizeOptionalContextId(contextId) {
@@ -42859,7 +42861,7 @@ function sendResultAndSummarize(input) {
42859
42861
  leaseEpoch: input.leaseEpoch,
42860
42862
  metadata: {
42861
42863
  ...buildResultDispatchJournalMetadata(input.payload),
42862
- errorMessage: toErrorMessage$36(error)
42864
+ errorMessage: toErrorMessage$38(error)
42863
42865
  },
42864
42866
  result: input.payload.status,
42865
42867
  taskId: input.taskId,
@@ -42868,7 +42870,7 @@ function sendResultAndSummarize(input) {
42868
42870
  emitRunLine({
42869
42871
  presenter: input.presenter,
42870
42872
  code: "daemon.run.result_send_failed",
42871
- text: `daemon result send failed for dispatch ${input.dispatchId}: ${toErrorMessage$36(error)}`,
42873
+ text: `daemon result send failed for dispatch ${input.dispatchId}: ${toErrorMessage$38(error)}`,
42872
42874
  payload: {
42873
42875
  attemptId: input.attemptId,
42874
42876
  connectionGeneration: input.connectionGeneration,
@@ -42901,7 +42903,7 @@ function emitDispatchPreviewFrame(input) {
42901
42903
  emitRunLine({
42902
42904
  presenter: input.presenter,
42903
42905
  code: "daemon.run.preview_send_failed",
42904
- text: `daemon preview send failed for dispatch ${input.dispatchId}: ${toErrorMessage$36(error)}`,
42906
+ text: `daemon preview send failed for dispatch ${input.dispatchId}: ${toErrorMessage$38(error)}`,
42905
42907
  payload: {
42906
42908
  attemptId: input.attemptId,
42907
42909
  dispatchId: input.dispatchId,
@@ -42927,7 +42929,7 @@ function emitDispatchPreviewEndFrame(input) {
42927
42929
  emitRunLine({
42928
42930
  presenter: input.presenter,
42929
42931
  code: "daemon.run.preview_end_send_failed",
42930
- text: `daemon preview end send failed for dispatch ${input.dispatchId}: ${toErrorMessage$36(error)}`,
42932
+ text: `daemon preview end send failed for dispatch ${input.dispatchId}: ${toErrorMessage$38(error)}`,
42931
42933
  payload: {
42932
42934
  attemptId: input.attemptId,
42933
42935
  dispatchId: input.dispatchId,
@@ -42970,7 +42972,7 @@ function emitDispatchRuntimeEvidenceTransition(input) {
42970
42972
  emitRunLine({
42971
42973
  presenter: input.presenter,
42972
42974
  code: "daemon.run.runtime_evidence_send_failed",
42973
- text: `daemon runtime evidence ${input.phase} send failed for dispatch ${identity.dispatchId}: ${toErrorMessage$36(error)}`,
42975
+ text: `daemon runtime evidence ${input.phase} send failed for dispatch ${identity.dispatchId}: ${toErrorMessage$38(error)}`,
42974
42976
  payload: {
42975
42977
  attemptId: identity.attemptId,
42976
42978
  dispatchId: identity.dispatchId,
@@ -43069,7 +43071,7 @@ function emitDispatchLifecycleTransition(input) {
43069
43071
  dispatchId: input.dispatchId,
43070
43072
  leaseEpoch: input.leaseEpoch,
43071
43073
  metadata: {
43072
- errorMessage: toErrorMessage$36(error),
43074
+ errorMessage: toErrorMessage$38(error),
43073
43075
  localQueue: input.localQueue ?? null,
43074
43076
  phase: input.phase
43075
43077
  },
@@ -43080,7 +43082,7 @@ function emitDispatchLifecycleTransition(input) {
43080
43082
  emitRunLine({
43081
43083
  presenter: input.presenter,
43082
43084
  code: "daemon.run.lifecycle_send_failed",
43083
- text: `daemon lifecycle ${input.phase} send failed for dispatch ${input.dispatchId}: ${toErrorMessage$36(error)}`,
43085
+ text: `daemon lifecycle ${input.phase} send failed for dispatch ${input.dispatchId}: ${toErrorMessage$38(error)}`,
43084
43086
  payload: {
43085
43087
  attemptId: input.attemptId,
43086
43088
  dispatchId: input.dispatchId,
@@ -43709,7 +43711,7 @@ async function runDaemonSocketSession(input) {
43709
43711
  emitRunLine({
43710
43712
  presenter: input.presenter,
43711
43713
  code: "daemon.run.heartbeat_failed",
43712
- text: `heartbeat failed (${String(consecutiveHeartbeatFailures)}/${String(HEARTBEAT_CONSECUTIVE_FAILURES_BEFORE_CLOSE)}): ${toErrorMessage$36(error)}`
43714
+ text: `heartbeat failed (${String(consecutiveHeartbeatFailures)}/${String(HEARTBEAT_CONSECUTIVE_FAILURES_BEFORE_CLOSE)}): ${toErrorMessage$38(error)}`
43713
43715
  });
43714
43716
  if (shouldCloseSocket) {
43715
43717
  input.socket.close(1011, "heartbeat_failed");
@@ -43742,7 +43744,7 @@ async function runDaemonSocketSession(input) {
43742
43744
  emitRunLine({
43743
43745
  presenter: input.presenter,
43744
43746
  code: "daemon.run.heartbeat_failed",
43745
- text: `heartbeat failed: ${toErrorMessage$36(error)}`
43747
+ text: `heartbeat failed: ${toErrorMessage$38(error)}`
43746
43748
  });
43747
43749
  });
43748
43750
  }, normalizedDelayMs);
@@ -43784,7 +43786,7 @@ async function runDaemonSocketSession(input) {
43784
43786
  emitRunLine({
43785
43787
  presenter: input.presenter,
43786
43788
  code: "daemon.run.catalog_sync_signal_read_failed",
43787
- text: `catalog sync signal read failed: ${toErrorMessage$36(error)}`
43789
+ text: `catalog sync signal read failed: ${toErrorMessage$38(error)}`
43788
43790
  });
43789
43791
  }).finally(() => {
43790
43792
  scheduleCatalogSyncSignalPoll();
@@ -44010,7 +44012,7 @@ async function runDaemonSocketSession(input) {
44010
44012
  emitRunLine({
44011
44013
  presenter: input.presenter,
44012
44014
  code: "daemon.run.runtime_capability_report_sync_failed",
44013
- text: `runtime capability report sync failed: ${toErrorMessage$36(error)}`
44015
+ text: `runtime capability report sync failed: ${toErrorMessage$38(error)}`
44014
44016
  });
44015
44017
  }
44016
44018
  };
@@ -44018,7 +44020,7 @@ async function runDaemonSocketSession(input) {
44018
44020
  emitRunLine({
44019
44021
  presenter: input.presenter,
44020
44022
  code: "daemon.run.socket_error",
44021
- text: `daemon stream socket error: ${toErrorMessage$36(error)}`
44023
+ text: `daemon stream socket error: ${toErrorMessage$38(error)}`
44022
44024
  });
44023
44025
  });
44024
44026
  input.socket.onMessage((raw) => {
@@ -44673,7 +44675,7 @@ const runDaemonServiceLoop = async (input) => {
44673
44675
  action: reconcileDecision.action,
44674
44676
  backoffMs,
44675
44677
  driftClass: reconcileDecision.driftClass,
44676
- error: toErrorMessage$36(error),
44678
+ error: toErrorMessage$38(error),
44677
44679
  foregroundActive: reconcileDecision.foregroundActive,
44678
44680
  lifecycleLocked: reconcileDecision.lifecycleLocked,
44679
44681
  owner: reconcileDecision.owner,
@@ -44684,7 +44686,7 @@ const runDaemonServiceLoop = async (input) => {
44684
44686
  action: reconcileDecision.action,
44685
44687
  backoffMs,
44686
44688
  driftClass: reconcileDecision.driftClass,
44687
- error: toErrorMessage$36(error),
44689
+ error: toErrorMessage$38(error),
44688
44690
  foregroundActive: reconcileDecision.foregroundActive,
44689
44691
  lifecycleLocked: reconcileDecision.lifecycleLocked,
44690
44692
  owner: reconcileDecision.owner,
@@ -44694,11 +44696,11 @@ const runDaemonServiceLoop = async (input) => {
44694
44696
  emitRunLine({
44695
44697
  presenter: input.presenter,
44696
44698
  code: "daemon.run.reconnect",
44697
- text: `daemon stream reconnect scheduled in ${String(backoffMs)}ms (${toErrorMessage$36(error)})`,
44699
+ text: `daemon stream reconnect scheduled in ${String(backoffMs)}ms (${toErrorMessage$38(error)})`,
44698
44700
  payload: {
44699
44701
  attempt: reconnectAttempt,
44700
44702
  backoffMs,
44701
- error: toErrorMessage$36(error)
44703
+ error: toErrorMessage$38(error)
44702
44704
  }
44703
44705
  });
44704
44706
  await sleep$10(backoffMs);
@@ -45171,16 +45173,16 @@ function isLaunchdBootstrapIosError$1(message) {
45171
45173
  }
45172
45174
  function shouldAttemptLaunchdAutoRepair(input) {
45173
45175
  if (input.controller !== "launchd") return false;
45174
- return isLaunchdBootstrapIosError$1(sanitizeSystemServiceErrorMessage$1(toErrorMessage$14(input.error)));
45176
+ return isLaunchdBootstrapIosError$1(sanitizeSystemServiceErrorMessage$1(toErrorMessage$16(input.error)));
45175
45177
  }
45176
45178
  function buildLaunchdAutoRepairFailureError(input) {
45177
45179
  return new Error([
45178
45180
  "launchd auto-repair retry failed.",
45179
- `initial error: ${toErrorMessage$14(input.initialError)}`,
45180
- `retry error: ${toErrorMessage$14(input.retryError)}`
45181
+ `initial error: ${toErrorMessage$16(input.initialError)}`,
45182
+ `retry error: ${toErrorMessage$16(input.retryError)}`
45181
45183
  ].join(" "));
45182
45184
  }
45183
- function toErrorMessage$14(error) {
45185
+ function toErrorMessage$16(error) {
45184
45186
  if (error instanceof Error) return error.message;
45185
45187
  return String(error);
45186
45188
  }
@@ -45543,7 +45545,7 @@ var DaemonReinstallUnexpectedStartError = class extends Error {
45543
45545
  diagnosticDetail;
45544
45546
  outcome;
45545
45547
  constructor(input) {
45546
- super(toErrorMessage$13(input.cause));
45548
+ super(toErrorMessage$15(input.cause));
45547
45549
  this.name = "DaemonReinstallUnexpectedStartError";
45548
45550
  this.cause = input.cause;
45549
45551
  this.diagnosticDetail = input.diagnosticDetail;
@@ -45561,7 +45563,7 @@ var DaemonReinstallFailureError = class extends Error {
45561
45563
  evidencePath;
45562
45564
  failureStage;
45563
45565
  constructor(input) {
45564
- super(toErrorMessage$13(input.cause));
45566
+ super(toErrorMessage$15(input.cause));
45565
45567
  this.name = "DaemonReinstallFailureError";
45566
45568
  this.backupDataPath = input.backupDataPath;
45567
45569
  this.cause = input.cause;
@@ -46259,7 +46261,7 @@ async function runDaemonReinstall(input, options = {}) {
46259
46261
  if (error instanceof DaemonReinstallFailureError) throw new Error(buildDaemonReinstallFailureMessage({
46260
46262
  action: displayAction,
46261
46263
  backupDataPath: error.backupDataPath,
46262
- errorMessage: toErrorMessage$13(error.cause),
46264
+ errorMessage: toErrorMessage$15(error.cause),
46263
46265
  failureStage: error.failureStage,
46264
46266
  evidencePath: error.evidencePath ?? await captureDaemonServiceEvidenceBestEffort({
46265
46267
  runtime,
@@ -46486,7 +46488,7 @@ async function applyDaemonReinstallTargetDesiredState(input) {
46486
46488
  }
46487
46489
  function buildDaemonReinstallUnexpectedStartSummary(error, action = "repair") {
46488
46490
  const actionLabel = formatDaemonServiceMaintenanceActionLabel(action);
46489
- const detail = sanitizeSystemServiceErrorMessage(toErrorMessage$13(error));
46491
+ const detail = sanitizeSystemServiceErrorMessage(toErrorMessage$15(error));
46490
46492
  if (!detail) return `ATS hit a local start error right after service ${actionLabel}.`;
46491
46493
  return `ATS hit a local start error right after service ${actionLabel}: ${detail}`;
46492
46494
  }
@@ -46702,7 +46704,7 @@ async function stopDaemonForStrictTeardown(input) {
46702
46704
  await input.context.serviceManager.stop().catch((error) => {
46703
46705
  throw createStrictTeardownError({
46704
46706
  reason: input.reason,
46705
- message: `failed to stop system service (${input.context.serviceManager?.controller}): ${toErrorMessage$13(error)}`,
46707
+ message: `failed to stop system service (${input.context.serviceManager?.controller}): ${toErrorMessage$15(error)}`,
46706
46708
  hint: "run `ats service stop --force` and retry",
46707
46709
  stage: "stop-wait"
46708
46710
  });
@@ -46747,7 +46749,7 @@ async function uninstallSystemServiceForStrictTeardown(input) {
46747
46749
  for (const manager of managers) await manager.uninstall().catch((error) => {
46748
46750
  throw createStrictTeardownError({
46749
46751
  reason: input.reason,
46750
- message: `failed to uninstall system service (${manager.controller}): ${toErrorMessage$13(error)}`,
46752
+ message: `failed to uninstall system service (${manager.controller}): ${toErrorMessage$15(error)}`,
46751
46753
  hint: "fix OS service permissions and retry",
46752
46754
  stage: "uninstall-verify"
46753
46755
  });
@@ -46764,7 +46766,7 @@ async function verifySystemServiceRemovedAfterStrictTeardown(input) {
46764
46766
  const finalManagerStatus = await manager.status().catch((error) => {
46765
46767
  throw createStrictTeardownError({
46766
46768
  reason: input.reason,
46767
- message: `failed to verify system service status (${manager.controller}): ${toErrorMessage$13(error)}`,
46769
+ message: `failed to verify system service status (${manager.controller}): ${toErrorMessage$15(error)}`,
46768
46770
  hint: "run `ats service status` and confirm service manager state",
46769
46771
  stage: "uninstall-verify"
46770
46772
  });
@@ -46781,7 +46783,7 @@ async function verifySystemServiceRemovedAfterStrictTeardown(input) {
46781
46783
  const finalManagerStatus = await manager.status().catch((error) => {
46782
46784
  throw createStrictTeardownError({
46783
46785
  reason: input.reason,
46784
- message: `failed to verify system service status (${manager.controller}): ${toErrorMessage$13(error)}`,
46786
+ message: `failed to verify system service status (${manager.controller}): ${toErrorMessage$15(error)}`,
46785
46787
  hint: "run `ats service status` and confirm service manager state",
46786
46788
  stage: "uninstall-verify"
46787
46789
  });
@@ -47613,7 +47615,7 @@ function isLocalControllerSignInRequiredReason(reason) {
47613
47615
  return reason === "sign in required";
47614
47616
  }
47615
47617
  function buildSystemServiceStartupFailureReport(input) {
47616
- const message = sanitizeSystemServiceErrorMessage(toErrorMessage$13(input.error));
47618
+ const message = sanitizeSystemServiceErrorMessage(toErrorMessage$15(input.error));
47617
47619
  const localLogPath = getDaemonSystemServiceLogPath();
47618
47620
  if (isLaunchdBootstrapIosError(message)) {
47619
47621
  const card = buildDaemonStartNeedsAttentionCard({
@@ -47955,7 +47957,7 @@ async function runDirectDaemonServiceLoop(input) {
47955
47957
  };
47956
47958
  } catch (error) {
47957
47959
  return await handleDaemonRunStartFailure({
47958
- fallbackRawLine: toErrorMessage$13(error),
47960
+ fallbackRawLine: toErrorMessage$15(error),
47959
47961
  gatewayUrl: input.gatewayUrl,
47960
47962
  presenter: input.presenter,
47961
47963
  runtime: input.runtime,
@@ -48257,11 +48259,11 @@ async function stopRegisteredDaemonServiceManager(input) {
48257
48259
  run: async () => await input.ownerSnapshot.serviceManager?.stop()
48258
48260
  });
48259
48261
  } catch (error) {
48260
- if (input.mode !== "best_effort") throw new Error(`Failed to stop system service (${input.ownerSnapshot.runtimeStatus.serviceController}): ${toErrorMessage$13(error)}`);
48262
+ if (input.mode !== "best_effort") throw new Error(`Failed to stop system service (${input.ownerSnapshot.runtimeStatus.serviceController}): ${toErrorMessage$15(error)}`);
48261
48263
  return buildDaemonStopWarningResult({
48262
48264
  reason: "stop_failed",
48263
48265
  runtimeStatus: input.ownerSnapshot.runtimeStatus,
48264
- errorMessage: toErrorMessage$13(error)
48266
+ errorMessage: toErrorMessage$15(error)
48265
48267
  });
48266
48268
  }
48267
48269
  if (!await waitForDaemonSystemServiceToStop({
@@ -48292,7 +48294,7 @@ async function stopRegisteredDaemonServiceManager(input) {
48292
48294
  return buildDaemonStopWarningResult({
48293
48295
  reason: "stop_failed",
48294
48296
  runtimeStatus: input.ownerSnapshot.runtimeStatus,
48295
- errorMessage: toErrorMessage$13(error)
48297
+ errorMessage: toErrorMessage$15(error)
48296
48298
  });
48297
48299
  }
48298
48300
  const finalOwnerSnapshot = residualCleanupResult.shouldRefresh ? await readCurrentDaemonOwnerSnapshot() : residualCleanupResult.ownerSnapshot;
@@ -48365,7 +48367,7 @@ async function stopCurrentLaneDaemonProcess(input) {
48365
48367
  pid: daemonPid,
48366
48368
  reason: "stop_failed",
48367
48369
  runtimeStatus: input.runtimeStatus,
48368
- errorMessage: toErrorMessage$13(error)
48370
+ errorMessage: toErrorMessage$15(error)
48369
48371
  };
48370
48372
  }
48371
48373
  }
@@ -48449,7 +48451,7 @@ async function stopTrackedDaemonProcess(input) {
48449
48451
  type: "process_stop.action",
48450
48452
  result: "failed",
48451
48453
  metadata: {
48452
- errorMessage: toErrorMessage$13(error),
48454
+ errorMessage: toErrorMessage$15(error),
48453
48455
  pid: input.pid,
48454
48456
  reason: input.reason,
48455
48457
  signal: input.signal
@@ -49473,13 +49475,13 @@ async function runDaemonServiceDetached(input) {
49473
49475
  if (typeof child.pid === "number" && child.pid > 0) await cleanupDetachedRuntimeStateIfOwnedByPid(child.pid).catch(() => {});
49474
49476
  return await handleDaemonRunStartFailure({
49475
49477
  cursor: startFailureLogCursor,
49476
- fallbackRawLine: selectRelevantDaemonStartFailureLogLine(startupOutput.summary()) ?? toErrorMessage$13(error),
49478
+ fallbackRawLine: selectRelevantDaemonStartFailureLogLine(startupOutput.summary()) ?? toErrorMessage$15(error),
49477
49479
  gatewayUrl: input.gatewayUrl,
49478
49480
  presenter: input.presenter,
49479
49481
  runtime: input.runtime,
49480
49482
  genericErrorPayload: {
49481
49483
  codePrefix: "daemon.run.start_failed",
49482
- error: /* @__PURE__ */ new Error(`Failed to start ATS Service process: ${toErrorMessage$13(error)}`)
49484
+ error: /* @__PURE__ */ new Error(`Failed to start ATS Service process: ${toErrorMessage$15(error)}`)
49483
49485
  }
49484
49486
  });
49485
49487
  } finally {
@@ -49949,7 +49951,7 @@ function describeDaemonRuntimeStatus(status) {
49949
49951
  if (status.status === "not_running") return "Service is not running.";
49950
49952
  return "Service runtime status is unknown.";
49951
49953
  }
49952
- function toErrorMessage$13(error) {
49954
+ function toErrorMessage$15(error) {
49953
49955
  if (error instanceof Error) return error.message;
49954
49956
  return String(error);
49955
49957
  }
@@ -49979,7 +49981,7 @@ async function stopDaemonProcess(pid, signal) {
49979
49981
  process.kill(pid, signal);
49980
49982
  } catch (error) {
49981
49983
  if (isNodeErrorCode(error, "ESRCH")) return true;
49982
- throw new Error(`Failed to send ${signal} to pid ${String(pid)}: ${toErrorMessage$13(error)}`);
49984
+ throw new Error(`Failed to send ${signal} to pid ${String(pid)}: ${toErrorMessage$15(error)}`);
49983
49985
  }
49984
49986
  if (signal === "SIGKILL") return true;
49985
49987
  return await waitForProcessToExit(pid);
@@ -50288,7 +50290,7 @@ async function runDaemonServiceParticipationRefresh(input) {
50288
50290
  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`."
50289
50291
  });
50290
50292
  return {
50291
- errorMessage: toErrorMessage$36(error),
50293
+ errorMessage: toErrorMessage$38(error),
50292
50294
  status: "needs_attention"
50293
50295
  };
50294
50296
  }
@@ -50595,7 +50597,7 @@ async function runDaemonServiceAutoHeal(input) {
50595
50597
  cooldownUntil: null
50596
50598
  };
50597
50599
  } catch (error) {
50598
- const errorMessage = toErrorMessage$12(error);
50600
+ const errorMessage = toErrorMessage$14(error);
50599
50601
  await recordDaemonServiceRepairFailure({
50600
50602
  actions: safeActions,
50601
50603
  errorMessage
@@ -50702,7 +50704,7 @@ function isPidAlive$1(pid) {
50702
50704
  async function sleep$4(ms) {
50703
50705
  await new Promise((resolve) => setTimeout(resolve, ms));
50704
50706
  }
50705
- function toErrorMessage$12(error) {
50707
+ function toErrorMessage$14(error) {
50706
50708
  if (error instanceof Error && error.message.trim().length > 0) return error.message;
50707
50709
  return String(error);
50708
50710
  }
@@ -57918,7 +57920,7 @@ async function runDoctorProfileCheck(input) {
57918
57920
  }
57919
57921
  atsProfile = {
57920
57922
  ok: false,
57921
- message: `ats-profile failed: ${toErrorMessage$11(error)}`
57923
+ message: `ats-profile failed: ${toErrorMessage$13(error)}`
57922
57924
  };
57923
57925
  }
57924
57926
  emitCheckResult(input.presenter, atsProfile, {
@@ -58305,7 +58307,7 @@ async function runCheck(label, fn) {
58305
58307
  } catch (err) {
58306
58308
  return {
58307
58309
  ok: false,
58308
- message: `${label} failed: ${toErrorMessage$11(err)}`
58310
+ message: `${label} failed: ${toErrorMessage$13(err)}`
58309
58311
  };
58310
58312
  }
58311
58313
  }
@@ -58430,7 +58432,7 @@ async function maybePromptRepairAfterLogin(presenter) {
58430
58432
  function normalizeDoctorHumanText(text) {
58431
58433
  return text.replace(DOCTOR_TEXT_PREFIX_RE, "");
58432
58434
  }
58433
- function toErrorMessage$11(err) {
58435
+ function toErrorMessage$13(err) {
58434
58436
  if (err instanceof Error) return err.message;
58435
58437
  return String(err);
58436
58438
  }
@@ -61144,7 +61146,7 @@ async function resolvePrepareReadinessApiEvidence(input) {
61144
61146
  } catch (error) {
61145
61147
  console.warn("[ats.prepare_readiness.api_read_failed]", {
61146
61148
  event: "cli.prepare_readiness.api_read_failed",
61147
- error: toErrorMessage$10(error),
61149
+ error: toErrorMessage$12(error),
61148
61150
  profileId: input.profile.atsProfileId
61149
61151
  });
61150
61152
  return unavailableEvidence({
@@ -61185,7 +61187,7 @@ function unavailableEvidence(input) {
61185
61187
  status: "unavailable"
61186
61188
  };
61187
61189
  }
61188
- function toErrorMessage$10(error) {
61190
+ function toErrorMessage$12(error) {
61189
61191
  if (error instanceof Error) {
61190
61192
  const message = error.message.trim();
61191
61193
  return message.length > 0 ? message : "unknown error";
@@ -63458,7 +63460,7 @@ async function assertCurrentLocalRuntimeCanReceiveWake(input) {
63458
63460
  } catch (error) {
63459
63461
  throw new Error(formatCurrentLocalRuntimeReplyReadinessFailure({
63460
63462
  commandLabel: input.commandLabel,
63461
- detail: toErrorMessage$9(error),
63463
+ detail: toErrorMessage$11(error),
63462
63464
  supportCode: "current_reply_readiness.read_failed"
63463
63465
  }));
63464
63466
  }
@@ -63487,9 +63489,9 @@ function resolveCurrentReplyReadinessSupportCode(response) {
63487
63489
  return response.service.reasonCodes[0] ?? response.runtime.reasonCodes[0] ?? `current_reply_readiness.${response.primaryBlocker}`;
63488
63490
  }
63489
63491
  function formatCurrentLocalRuntimeReplyReadinessFailure(input) {
63490
- return `ATS Service started, but ATS Web could not confirm this computer can receive local Wake work yet. Keep ATS Service running, then copy a fresh setup command from ATS Web and run ${input.commandLabel ?? "setup"} again. Support code: ${input.supportCode}.${input.detail ? ` Detail: ${input.detail}` : ""}`;
63492
+ 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}` : ""}`;
63491
63493
  }
63492
- function toErrorMessage$9(error) {
63494
+ function toErrorMessage$11(error) {
63493
63495
  if (error instanceof Error) {
63494
63496
  const message = error.message.trim();
63495
63497
  return message.length > 0 ? message : "unknown error";
@@ -64244,7 +64246,7 @@ async function syncLocalSetupCurrentDeviceTargetFromServiceContract(input) {
64244
64246
  const serviceContract = await readDaemonServiceContract();
64245
64247
  const deviceId = serviceContract?.deviceId ?? null;
64246
64248
  const runtimeLane = serviceContract?.lane ?? null;
64247
- if (!(serviceContract && deviceId && runtimeLane)) throw new Error("ATS could not reconnect this computer because ATS Service has not finished starting. Keep ATS Service running, then copy a fresh setup command from ATS Web and run setup again.");
64249
+ if (!(serviceContract && deviceId && runtimeLane)) throw new Error(`ATS could not reconnect this computer because ATS Service has not finished starting. 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.`);
64248
64250
  const currentDeviceApi = createCurrentDeviceApi(createCliApiClientFoundation(input.gatewayUrl));
64249
64251
  const currentTarget = await currentDeviceApi.setCurrentTarget({
64250
64252
  activationSource: "local_setup",
@@ -64733,7 +64735,13 @@ async function connectSelectedLocalAgentsToAts(input) {
64733
64735
  readiness,
64734
64736
  localAgentIds: input.localAgentIds
64735
64737
  }));
64736
- if (input.syncRouteCatalog) await waitForConfirmedRouteCatalogSync$1({ reason: "prepare_selected_agents_connected" });
64738
+ if (input.syncRouteCatalog) await waitForConfirmedRouteCatalogSync$1({
64739
+ confirmWakeAvailability: async () => await assertCurrentLocalRuntimeCanReceiveWake({
64740
+ gatewayUrl: input.gatewayUrl,
64741
+ runtimeIdentity
64742
+ }),
64743
+ reason: "prepare_selected_agents_connected"
64744
+ });
64737
64745
  return {
64738
64746
  ...runtimeIdentity,
64739
64747
  localReadinessSnapshot: buildPrepareLocalReadinessSnapshot(readiness)
@@ -64770,7 +64778,7 @@ async function readTerminalRuntimeIdentityFromServiceContract() {
64770
64778
  const serviceContract = await readDaemonServiceContract();
64771
64779
  const deviceId = serviceContract?.deviceId;
64772
64780
  const runtimeLane = serviceContract?.lane;
64773
- if (!(deviceId && runtimeLane)) throw new Error("ATS could not verify selected agents because ATS Service did not provide this computer's device identity yet. Keep ATS Service running, then copy a fresh setup command from ATS Web and run setup again.");
64781
+ if (!(deviceId && runtimeLane)) throw new Error(`ATS could not verify selected agents because ATS Service did not provide this computer's device identity 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.`);
64774
64782
  return {
64775
64783
  deviceId,
64776
64784
  runtimeLane
@@ -64783,6 +64791,12 @@ async function waitForConfirmedRouteCatalogSync$1(input) {
64783
64791
  if (latestDelivery.delivery === "control_plane") return latestDelivery;
64784
64792
  if (attempt < ROUTE_CATALOG_SYNC_MAX_ATTEMPTS$1) await sleep$2(ROUTE_CATALOG_SYNC_RETRY_DELAY_MS$1);
64785
64793
  }
64794
+ if (latestDelivery?.delivery === "signal" && input.confirmWakeAvailability) try {
64795
+ await input.confirmWakeAvailability();
64796
+ return latestDelivery;
64797
+ } catch (error) {
64798
+ throw new Error(formatRouteCatalogSyncFailure$1(latestDelivery, error));
64799
+ }
64786
64800
  throw new Error(formatRouteCatalogSyncFailure$1(latestDelivery));
64787
64801
  }
64788
64802
  async function assertSelectedRuntimeReadinessIsReadableByAts(input) {
@@ -64797,10 +64811,12 @@ async function assertSelectedRuntimeReadinessIsReadableByAts(input) {
64797
64811
  const missingCapabilityRef = capabilityRefs.find((capabilityRef) => !runnableCapabilityRefs.has(capabilityRef));
64798
64812
  if (response.status === "ready" && response.runtimeId && !missingCapabilityRef) return;
64799
64813
  const reasonCode = response.summary.reasonCodes[0] ?? response.reason ?? (missingCapabilityRef ? "prepare_readiness.capability_not_ready" : "prepare_readiness.not_ready");
64800
- throw new Error(`ATS could not verify that selected agents are connected to ATS yet. Keep ATS Service running, then copy a fresh setup command from ATS Web and run setup again. Support code: ${reasonCode}.`);
64814
+ 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}.`);
64801
64815
  }
64802
- function formatRouteCatalogSyncFailure$1(latestDelivery) {
64803
- return `ATS Service started, but ATS could not confirm that selected agents are available for Wake yet. Keep ATS Service running, then copy a fresh setup command from ATS Web and run setup again. Support code: ${latestDelivery?.delivery === "signal" ? `route_catalog_sync.${latestDelivery.fallbackReason}` : "route_catalog_sync.unavailable"}.`;
64816
+ function formatRouteCatalogSyncFailure$1(latestDelivery, error) {
64817
+ const supportCode = latestDelivery?.delivery === "signal" ? `route_catalog_sync.${latestDelivery.fallbackReason}` : "route_catalog_sync.unavailable";
64818
+ const detail = error ? ` Detail: ${toErrorMessage$10(error)}` : "";
64819
+ 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}`;
64804
64820
  }
64805
64821
  function buildPrepareLocalReadinessSnapshot(readiness) {
64806
64822
  return {
@@ -65048,6 +65064,14 @@ function toStatusCodeSlug(title) {
65048
65064
  const slug = title.toLowerCase().replaceAll(/[^a-z0-9]+/g, "_").replaceAll(/^_+|_+$/g, "");
65049
65065
  return slug.length > 0 ? slug : "status";
65050
65066
  }
65067
+ function toErrorMessage$10(error) {
65068
+ if (error instanceof Error) {
65069
+ const message = error.message.trim();
65070
+ return message.length > 0 ? message : "unknown error";
65071
+ }
65072
+ const message = String(error ?? "").trim();
65073
+ return message.length > 0 ? message : "unknown error";
65074
+ }
65051
65075
  var PrepareSessionTerminalReplacedError = class extends Error {
65052
65076
  constructor(message) {
65053
65077
  super(message);
@@ -68074,7 +68098,14 @@ async function runSetup(input) {
68074
68098
  localAgentIds: selectedLocalAgentIds
68075
68099
  });
68076
68100
  assertSelectedLocalRuntimeReportsAccepted(runtimeReports);
68077
- const routeCatalogSync = selectedLocalAgentIds.length > 0 ? await waitForConfirmedRouteCatalogSync({ reason: "setup_to_wake_path_connected" }) : null;
68101
+ const routeCatalogSync = selectedLocalAgentIds.length > 0 ? await waitForConfirmedRouteCatalogSync({
68102
+ confirmWakeAvailability: async () => await assertSetupCompletionCanReceiveWake({
68103
+ gatewayUrl,
68104
+ runtimeIdentity,
68105
+ selectedLocalAgentIds
68106
+ }),
68107
+ reason: "setup_to_wake_path_connected"
68108
+ }) : null;
68078
68109
  await assertSetupCompletionCanReceiveWake({
68079
68110
  gatewayUrl,
68080
68111
  runtimeIdentity,
@@ -68136,10 +68167,18 @@ async function waitForConfirmedRouteCatalogSync(input) {
68136
68167
  if (latestDelivery.delivery === "control_plane") return latestDelivery;
68137
68168
  if (attempt < ROUTE_CATALOG_SYNC_MAX_ATTEMPTS) await sleep(ROUTE_CATALOG_SYNC_RETRY_DELAY_MS);
68138
68169
  }
68170
+ if (latestDelivery?.delivery === "signal" && input.confirmWakeAvailability) try {
68171
+ await input.confirmWakeAvailability();
68172
+ return latestDelivery;
68173
+ } catch (error) {
68174
+ throw new Error(formatRouteCatalogSyncFailure(latestDelivery, error));
68175
+ }
68139
68176
  throw new Error(formatRouteCatalogSyncFailure(latestDelivery));
68140
68177
  }
68141
- function formatRouteCatalogSyncFailure(latestDelivery) {
68142
- return `ATS Service started, but ATS could not confirm that selected agents are available for Wake yet. Keep ATS Service running, then copy a fresh setup command from ATS Web and run setup again. Support code: ${latestDelivery?.delivery === "signal" ? `route_catalog_sync.${latestDelivery.fallbackReason}` : "route_catalog_sync.unavailable"}.`;
68178
+ function formatRouteCatalogSyncFailure(latestDelivery, error) {
68179
+ const supportCode = latestDelivery?.delivery === "signal" ? `route_catalog_sync.${latestDelivery.fallbackReason}` : "route_catalog_sync.unavailable";
68180
+ const detail = error ? ` Detail: ${toErrorMessage$9(error)}` : "";
68181
+ 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}`;
68143
68182
  }
68144
68183
  function emitSetupStatus(runtime, title, lines) {
68145
68184
  if (runtime.resolvedView !== "human") return;
@@ -68169,7 +68208,14 @@ async function emitSetupCompleteForDelegatedPath(input) {
68169
68208
  }
68170
68209
  async function resolveDelegatedSetupCompletionFacts(input) {
68171
68210
  if (input.setupResult.completionFacts) {
68172
- const routeCatalogSync = input.setupResult.completionFacts.runtimeReports.length > 0 ? await waitForConfirmedRouteCatalogSync({ reason: "setup_profile_connection_path_connected" }) : null;
68211
+ const routeCatalogSync = input.setupResult.completionFacts.runtimeReports.length > 0 ? await waitForConfirmedRouteCatalogSync({
68212
+ confirmWakeAvailability: async () => await assertSetupCompletionCanReceiveWake({
68213
+ gatewayUrl: input.gatewayUrl,
68214
+ runtimeIdentity: input.setupResult.completionFacts.runtimeIdentity,
68215
+ selectedLocalAgentIds: input.setupResult.completionFacts.selectedLocalAgentIds
68216
+ }),
68217
+ reason: "setup_profile_connection_path_connected"
68218
+ }) : null;
68173
68219
  await assertSetupCompletionCanReceiveWake({
68174
68220
  gatewayUrl: input.gatewayUrl,
68175
68221
  runtimeIdentity: input.setupResult.completionFacts.runtimeIdentity,
@@ -68221,7 +68267,14 @@ async function resolveDelegatedSetupCompletionFacts(input) {
68221
68267
  localAgentIds: selectedLocalAgentIds
68222
68268
  });
68223
68269
  assertSelectedLocalRuntimeReportsAccepted(runtimeReports);
68224
- const routeCatalogSync = await waitForConfirmedRouteCatalogSync({ reason: "setup_delegated_path_connected" });
68270
+ const routeCatalogSync = await waitForConfirmedRouteCatalogSync({
68271
+ confirmWakeAvailability: async () => await assertSetupCompletionCanReceiveWake({
68272
+ gatewayUrl: input.gatewayUrl,
68273
+ runtimeIdentity,
68274
+ selectedLocalAgentIds
68275
+ }),
68276
+ reason: "setup_delegated_path_connected"
68277
+ });
68225
68278
  await assertSetupCompletionCanReceiveWake({
68226
68279
  gatewayUrl: input.gatewayUrl,
68227
68280
  runtimeIdentity,
@@ -68236,7 +68289,7 @@ async function resolveDelegatedSetupCompletionFacts(input) {
68236
68289
  }
68237
68290
  async function assertSetupCompletionCanReceiveWake(input) {
68238
68291
  if (input.selectedLocalAgentIds.length === 0) return;
68239
- if (!input.runtimeIdentity) throw new Error("ATS Service started, but ATS Web could not confirm this computer can receive local Wake work yet. Keep ATS Service running, then copy a fresh setup command from ATS Web and run setup again. Support code: current_reply_readiness.current_target_missing.");
68292
+ 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.`);
68240
68293
  await assertCurrentLocalRuntimeCanReceiveWake({
68241
68294
  gatewayUrl: input.gatewayUrl,
68242
68295
  runtimeIdentity: input.runtimeIdentity
@@ -68389,6 +68442,14 @@ function normalizeOptionalString$5(value) {
68389
68442
  const normalized = String(value ?? "").trim();
68390
68443
  return normalized.length > 0 ? normalized : null;
68391
68444
  }
68445
+ function toErrorMessage$9(error) {
68446
+ if (error instanceof Error) {
68447
+ const message = error.message.trim();
68448
+ return message.length > 0 ? message : "unknown error";
68449
+ }
68450
+ const message = String(error ?? "").trim();
68451
+ return message.length > 0 ? message : "unknown error";
68452
+ }
68392
68453
  function sleep(ms) {
68393
68454
  return new Promise((resolve) => {
68394
68455
  setTimeout(resolve, ms);