agent-transport-system 0.7.97 → 0.7.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/{add-me-membership-CT_vAgoU.js → add-me-membership-Cfi5fbyb.js} +3 -3
- package/dist/{add-me-membership-CT_vAgoU.js.map → add-me-membership-Cfi5fbyb.js.map} +1 -1
- package/dist/{api-client-foundation-DFdzzDaR.js → api-client-foundation-CBoyrvoT.js} +1 -1
- package/dist/ats-dev.js +2 -2
- package/dist/ats.js +1403 -875
- package/dist/ats.js.map +1 -1
- package/dist/{auth-session-DBnyC4LY.js → auth-session-DbA1IFeL.js} +1 -1
- package/dist/{base-url-SXaImoj4.js → base-url-CiDhrDeP.js} +2 -2
- package/dist/{base-url-SXaImoj4.js.map → base-url-CiDhrDeP.js.map} +1 -1
- package/dist/{daemon-runtime-lease-DzRz8pH5.js → daemon-runtime-lease-D1x-3a2_.js} +1 -1
- package/dist/{dist-zUuzNkK0.js → dist-DV2pViNq.js} +1 -1
- package/dist/{dist-CyQTYZTj.js → dist-DkHDSnUA.js} +103 -31
- package/dist/dist-DkHDSnUA.js.map +1 -0
- package/package.json +1 -1
- package/dist/dist-CyQTYZTj.js.map +0 -1
package/dist/ats.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { C as updateConfiguredSkillsConfig, S as updateConfiguredOnboardingConfig, _ as getRuntimeConfigReadHealth, a as resolveBaseUrl, b as setConfiguredSkillsConfig, c as resolveExplicitGatewayUrlOrThrow, d as createDefaultRuntimeAgentControllerSettings, f as getConfiguredDaemonDispatchLimits, g as getConfiguredViewCustomization, h as getConfiguredSkillsConfig, i as normalizeGatewayBaseUrlOrNull, l as DEFAULT_RUNTIME_AGENT_TRANSPORT_MODE, m as getConfiguredOnboardingDisclaimerAcceptedAt, o as resolveBaseUrlOrNull, p as getConfiguredDeviceRuntimeState, r as normalizeGatewayBaseUrl, s as resolveDefaultGatewayBaseUrl, u as alignRuntimeConfigStorage, v as resolveRuntimeSkillsCustomTargetId, w as updateConfiguredStartV1OnboardingState, x as updateConfiguredDeviceRuntimeState, y as setConfiguredBaseUrl } from "./base-url-
|
|
4
|
-
import { $ as getSpaceStatusResponseSchema, $n as
|
|
3
|
+
import { C as updateConfiguredSkillsConfig, S as updateConfiguredOnboardingConfig, _ as getRuntimeConfigReadHealth, a as resolveBaseUrl, b as setConfiguredSkillsConfig, c as resolveExplicitGatewayUrlOrThrow, d as createDefaultRuntimeAgentControllerSettings, f as getConfiguredDaemonDispatchLimits, g as getConfiguredViewCustomization, h as getConfiguredSkillsConfig, i as normalizeGatewayBaseUrlOrNull, l as DEFAULT_RUNTIME_AGENT_TRANSPORT_MODE, m as getConfiguredOnboardingDisclaimerAcceptedAt, o as resolveBaseUrlOrNull, p as getConfiguredDeviceRuntimeState, r as normalizeGatewayBaseUrl, s as resolveDefaultGatewayBaseUrl, u as alignRuntimeConfigStorage, v as resolveRuntimeSkillsCustomTargetId, w as updateConfiguredStartV1OnboardingState, x as updateConfiguredDeviceRuntimeState, y as setConfiguredBaseUrl } from "./base-url-CiDhrDeP.js";
|
|
4
|
+
import { $ as getSpaceStatusResponseSchema, $n as canonicalizeBuiltinAgentControllerRef, $t as spaceCreatorSchema, A as deleteSpaceResponseSchema, An as LEGACY_RUNTIME_DISPATCH_POLICY, Ar as runtimeTransportDeliverDispatchRequestSchema, At as postSpaceThreadSignalResponseSchema, B as getAgentExecutionReadinessBatchBodySchema, Bn as SPACE_MENTION_REJECT_NOTICE_PURPOSE, Br as runtimeTransportLocalAgentControlRefreshCatalogFramePayloadSchema, Bt as refreshCurrentLocalAgentCatalogResponseSchema, C as createSpaceThreadBodySchema, Cn as ATSD_CONTROL_PLANE_SCHEMA_VERSION, Cr as resolveBuiltinAgentControllerConversationKind, Ct as patchSpaceContractBodySchema, D as daemonRouteCatalogCacheSchema, Dn as DISPATCH_ACTIVITY_DISPATCHING_PURPOSE, Dt as postSpaceMembersBodySchema, E as currentLocalRuntimeReplyReadinessResponseSchema, En as CURRENT_DAEMON_EXECUTION_CONTRACT_EPOCH, Er as resolveSpaceMentionLabels, Et as postNormalMessageResponseSchema, F as forgetComputerResponseSchema, Fn as MAX_VISITED_PROFILE_IDS, Fr as runtimeTransportDispatchRuntimeEvidenceRequestSchema, Ft as projectObservabilityWakeCorrelation, G as getLocalRuntimeExpectedRoutesResponseSchema, Gn as atsdControlPlaneRequestSchema, Gr as runtimeTransportSubmitTaskResultRequestSchema, Gt as setCurrentLocalAgentEnabledResponseSchema, H as getAgentExecutionReadinessResponseSchema, Hn as SPACE_UPDATES_MAX_LIMIT, Hr as runtimeTransportRegisterSessionRequestSchema, Ht as resolveSpaceDispatchTraceRootCause, I as forgetCurrentComputerResponseSchema, In as MESSAGE_MENTION_TYPE_VALUES, Ir as runtimeTransportHeartbeatRequestSchema, It as projectSpaceDispatchTraceFinalVisibleOutcome, J as getPrepareReadinessResponseSchema, Jn as atsdTaskResultOpenClawGatewayVisibilityStatusSchema, Jt as setupPlanAgentViewEventSchema, K as getModelCatalogResponseSchema, Kn as atsdControlPlaneResponseSchema, Kr as sanitizeSignalTextPreview, Kt as setLocalRuntimeDisplayNameBodySchema, L as gatewayErrorCodeSchema, Ln as RUNTIME_TRANSPORT_SCHEMA_VERSION, Lr as runtimeTransportHeartbeatResponseSchema, Lt as redactPrepareStepDiagnosticsBundle, M as ensureAgentProfilePrimaryBindingBodySchema, Mn as MAX_PROFILE_ID_LENGTH, Mr as runtimeTransportDispatchLifecycleRequestSchema, Mt as prepareSessionStreamServerFrameSchema, N as ensureAgentProfilePrimaryBindingResponseSchema, Nn as MAX_PROFILE_WORKING_DIRECTORY_LENGTH, Nr as runtimeTransportDispatchPreviewEndRequestSchema, Nt as prepareSetupBootstrapWriteSchema, O as daemonRouteObservationResponseSchema, On as DISPATCH_ACTIVITY_FAILED_PURPOSE, Ot as postSpaceMembersResponseSchema, P as entryBriefSchema, Pn as MAX_SIGNAL_REPLY_TO_PREVIEW_LENGTH, Pr as runtimeTransportDispatchPreviewRequestSchema, Pt as prepareStepDiagnosticsBundleSchema, Q as getSpaceMessageDetailsResponseSchema, Qn as canonicalizeAgentControllerRef, Qt as spaceBootstrapResponseSchema, R as gatewayErrorEnvelopeSchema, Rn as SPACE_MEMBER_JOIN_NOTICE_PURPOSE, Rr as runtimeTransportLocalAgentControlCancelFramePayloadSchema, Rt as redactPrepareStepDiagnosticsText, S as createSpaceResponseSchema, Sn as AGENT_REPLY_PREVIEW_PURPOSE, Sr as providerDispatchRuntimeContextSchema, St as patchProfileSpaceHistoryStatusResponseSchema, T as currentDeviceTargetResponseSchema, Tn as CONVERSATION_CONTINUITY_WARNING_PURPOSE, Tr as resolveSingleSpaceMentionLabels, Tt as postNormalMessageBodySchema, U as getAgentProfilePrimaryBindingResponseSchema, Un as atsRuntimeProfileIdSchema, Ur as runtimeTransportRegisterSessionResponseSchema, Ut as serverErrorFrameSchema, V as getAgentExecutionReadinessBatchResponseSchema, Vn as SPACE_PASSWORD_MIN_LENGTH, Vr as runtimeTransportLocalAgentControlSetEnabledFramePayloadSchema, Vt as removeSpaceMembersResponseSchema, W as getLocalRuntimeExpectedRoutesQuerySchema, Wn as atsSpaceEgressActionSchema, Wr as runtimeTransportRouteCatalogChangedFramePayloadSchema, Wt as setCurrentLocalAgentEnabledBodySchema, X as getSpaceDispatchLookupResponseSchema, Xn as buildAgentControllerConversationRef, Xt as signalEnvelopeSchema, Y as getSpaceContractResponseSchema, Yn as atsdTaskResultPayloadSchema, Yt as setupPlanAgentViewPayloadSchema, Z as getSpaceDispatchResultResponseSchema, Zn as buildAgentControllerRoutingKey, Zt as spaceAccessModeStateSchema, _ as cliJsonOutputEnvelopeSchema, _n as writeCurrentDeviceObservedMetadataBodySchema, _r as parseAgentControllerRef$1, _t as normalizeSpaceCursorPatch, a as DAEMON_ROUTE_CATALOG_CACHE_SCHEMA_VERSION, an as spaceMetaSchema, ar as formatCanonicalMentionLiteral, at as leaveSpaceResponseSchema, b as createSpaceDiagnosticReportBodySchema, bn as AGENT_REPLYING_PURPOSE, br as postSpaceWakeStopResponseSchema, bt as notifyAgentProfilesRouteCatalogChangedBodySchema, c as SETUP_PLAN_AGENT_VIEW_CODE, cn as submitRuntimeAgentControllerReportsBodySchema, cr as formatLocalSetupActionDescription, ct as listSpaceThreadSignalsResponseSchema, d as accountSpaceIndexResponseSchema, dn as submitRuntimeProviderConversationProofsResponseSchema, dr as installedLocalComponentsSnapshotSchema, dt as localRuntimeEnrollmentBodySchema, en as spaceDispatchTraceResponseSchema, er as collectCanonicalMentionTextFragments, et as getSpaceThreadResponseSchema, f as agentControllerPermissionModeSchema, fn as submitRuntimeRegistrationBodySchema, fr as normalizeBuiltinAgentControllerId, ft as localRuntimeEnrollmentResponseSchema, g as catchupResponseSchema, gn as upsertProfileSpaceHistoryResponseSchema, gr as normalizeSpacePasswordText, gt as normalizeListSignalsReadQuerySemantics, h as atsRequestContextSchema, hn as updateAgentProfilePrimaryBindingModelSelectionBodySchema, hr as normalizeOptionalWorkingDirectory, ht as modelCatalogSchema, i as DAEMON_ROUTE_CATALOG_CACHE_SCHEMA_NAME, in as spaceMembersSnapshotSchema, ir as daemonStreamFrameSchema, it as incomingServerMessageSchema, j as dispatchBriefSchema, jn as LOCAL_COMPONENTS_SCHEMA_VERSION, jr as runtimeTransportDeliveryExecutionIdentitySchema, jt as prepareSessionResponseSchema, k as daemonRuntimeLeaseSchema, kn as DISPATCH_ACTIVITY_RETRYING_PURPOSE, kr as runtimeCoordinatorExecutionTokenEnvelopeSchema, kt as postSpaceThreadSignalBodySchema, l as SETUP_PLAN_AGENT_VIEW_SCHEMA_VERSION, ln as submitRuntimeAgentControllerReportsResponseSchema, lr as formatLocalSetupActionLabel, lt as listSpaceThreadsResponseSchema, m as agentProfileBindingRouteParamsSchema, mn as updateAgentProfilePrimaryBindingAgentControllerPermissionModeBodySchema, mr as normalizeMessageEnvelope, mt as localRuntimesResponseSchema, n as resolveBuiltinAgentControllerBrand, nn as spaceMemberDirectoryEntrySchema, nr as daemonServiceContractSchema, nt as getSpaceWakeProgressResponseSchema, o as PREPARE_SESSION_STREAM_PROTOCOL_VERSION, on as spaceViewerMembershipResponseSchema, or as formatLocalComponentsSummaryDescription, ot as listProfileSpaceHistoryResponseSchema, p as agentExecutionReadinessRouteParamsSchema, pn as submitRuntimeRegistrationResponseSchema, pr as normalizeKnownBuiltinAgentControllerId, pt as localRuntimesQuerySchema, q as getPrepareReadinessQuerySchema, qn as atsdTaskResultEnvelopeWriteSchema, qt as setSpaceAccessModeBodySchema, r as resolveMappedPublicAgentFailureReason, rn as spaceMemberDirectorySchema, rr as daemonServiceLaneSchema, rt as getSpaceWakeTraceWaterfallResponseSchema, s as PREPARE_STEP_DIAGNOSTICS_MAX_CHARS, sn as structuredGuidePayloadFromInputSchema, sr as formatLocalComponentsSummaryLabel, st as listSpaceThreadEventsResponseSchema, t as CODEX_UPGRADE_REQUIRED_REASON, tn as spaceIdentityDirectorySchema, tr as conversationExecutionStateSchema, tt as getSpaceUpdatesResponseSchema, u as SPACE_DISPATCH_TRACE_PROMPT_PREVIEW_MAX_CHARS, un as submitRuntimeProviderConversationProofsBodySchema, ur as getSpaceMessageAddressingRelationSupportForTargetKind, ut as localAgentCatalogSchema, v as continuitySchema, vn as writeCurrentDeviceObservedMetadataResponseSchema, vr as parseOptionalClientMessageId, vt as notifyAgentProfileRouteCatalogChangedBodySchema, w as createSpaceThreadResponseSchema, wn as ATSD_TASK_RESULT_SCHEMA_VERSION, wr as resolveMessageEnvelopeTargetField, wt as patchSpaceContractResponseSchema, x as createSpaceDiagnosticReportResponseSchema, xn as AGENT_REPLY_PREVIEW_END_PURPOSE, xr as profileWorkspaceModeSchema, xt as observabilityWakeTraceSelectorSchema, y as createSpaceBodySchema, yn as AGENT_REPLYING_END_PURPOSE, yr as postSpaceWakeStopBodySchema, yt as notifyAgentProfileRouteCatalogChangedResponseSchema, z as getActiveSpaceWakeProgressResponseSchema, zn as SPACE_MEMBER_REMOVE_NOTICE_PURPOSE, zr as runtimeTransportLocalAgentControlInterruptFramePayloadSchema, zt as redactPrepareStepDiagnosticsValue } from "./dist-DkHDSnUA.js";
|
|
5
5
|
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-DP4LBid2.js";
|
|
6
6
|
import { a as runWithHeldLock, c as LEGACY_ATS_CLI_CONTEXT_ENV_KEY, d as resolveCliContext, f as resolveCliContextId, i as releaseLock, l as listCliContextStates, n as isAtsLockError, o as tryCleanupStaleLock, p as writeCliContextState, r as readLockMeta, s as ATS_CLI_CONTEXT_ENV_KEY, t as acquireLock, u as readCliContextState } from "./lock-CBIWEyt0.js";
|
|
7
7
|
import { _ as toSpaceWsUrl, a as toSpaceCursorUrl, c as toSpaceDispatchTraceUrl, d as toSpaceMetaUrl, f as toSpacePasswordUrl, g as toSpaceUpdatesUrl, h as toSpaceSignalsUrl, i as toSpaceCreateUrl, l as toSpaceLeaveUrl, m as toSpaceResultUrl, n as toDaemonRouteObservationUrl, o as toSpaceDeleteUrl, p as toSpaceRemoveMembersUrl, r as toSpaceContractUrl, s as toSpaceDispatchLookupUrl, t as normalizeBaseUrl, u as toSpaceMembersUrl } from "./urls-B8ZoQgpS.js";
|
|
@@ -20,7 +20,7 @@ import { execFile, spawn } from "node:child_process";
|
|
|
20
20
|
import { clearLine, createInterface, cursorTo, emitKeypressEvents, moveCursor } from "node:readline";
|
|
21
21
|
import { Writable } from "node:stream";
|
|
22
22
|
import stringWidth from "string-width";
|
|
23
|
-
import { accessSync, appendFileSync, chmodSync, closeSync, constants, existsSync, mkdirSync, openSync, readFileSync, realpathSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
23
|
+
import { accessSync, appendFileSync, chmodSync, closeSync, constants, existsSync, mkdirSync, openSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
24
24
|
import { query } from "@anthropic-ai/claude-agent-sdk";
|
|
25
25
|
import { createConnection, createServer } from "node:net";
|
|
26
26
|
import { fileURLToPath } from "node:url";
|
|
@@ -32,7 +32,7 @@ import { ReadStream, WriteStream } from "node:tty";
|
|
|
32
32
|
import { performance } from "node:perf_hooks";
|
|
33
33
|
|
|
34
34
|
//#region package.json
|
|
35
|
-
var version = "0.7.
|
|
35
|
+
var version = "0.7.98";
|
|
36
36
|
var package_default = {
|
|
37
37
|
$schema: "https://www.schemastore.org/package.json",
|
|
38
38
|
name: "agent-transport-system",
|
|
@@ -3898,15 +3898,15 @@ function parseLegacySelectionPayload(raw) {
|
|
|
3898
3898
|
try {
|
|
3899
3899
|
const payload = JSON.parse(raw);
|
|
3900
3900
|
if (payload.v !== 1) return null;
|
|
3901
|
-
const sessionId = normalizeOptionalString$
|
|
3902
|
-
const atsProfileId = normalizeOptionalString$
|
|
3901
|
+
const sessionId = normalizeOptionalString$29(payload.sessionId);
|
|
3902
|
+
const atsProfileId = normalizeOptionalString$29(payload.atsProfileId);
|
|
3903
3903
|
if (!(sessionId && atsProfileId)) return null;
|
|
3904
3904
|
return {
|
|
3905
3905
|
v: 1,
|
|
3906
3906
|
sessionId,
|
|
3907
|
-
sessionSource: normalizeOptionalString$
|
|
3907
|
+
sessionSource: normalizeOptionalString$29(payload.sessionSource) ?? "manual",
|
|
3908
3908
|
atsProfileId,
|
|
3909
|
-
updatedAt: normalizeOptionalString$
|
|
3909
|
+
updatedAt: normalizeOptionalString$29(payload.updatedAt) ?? (/* @__PURE__ */ new Date(0)).toISOString()
|
|
3910
3910
|
};
|
|
3911
3911
|
} catch {
|
|
3912
3912
|
return null;
|
|
@@ -3936,12 +3936,12 @@ function toSafeSessionFile(value) {
|
|
|
3936
3936
|
const maxBaseLength = Math.max(1, SESSION_FILE_MAX_LENGTH - SESSION_FILE_HASH_LENGTH - 1);
|
|
3937
3937
|
return `${safeBase.slice(0, maxBaseLength)}-${hash}`;
|
|
3938
3938
|
}
|
|
3939
|
-
function normalizeOptionalString$
|
|
3939
|
+
function normalizeOptionalString$29(value) {
|
|
3940
3940
|
const normalized = String(value ?? "").trim();
|
|
3941
3941
|
return normalized.length > 0 ? normalized : null;
|
|
3942
3942
|
}
|
|
3943
3943
|
function normalizeRequiredString$1(value, field) {
|
|
3944
|
-
const normalized = normalizeOptionalString$
|
|
3944
|
+
const normalized = normalizeOptionalString$29(value);
|
|
3945
3945
|
if (!normalized) throw new Error(`${field} is required`);
|
|
3946
3946
|
return normalized;
|
|
3947
3947
|
}
|
|
@@ -3967,13 +3967,13 @@ function resolveAtsAccountContext(input) {
|
|
|
3967
3967
|
key: normalizeAccountKey({}),
|
|
3968
3968
|
source: "fallback"
|
|
3969
3969
|
};
|
|
3970
|
-
const normalizedBaseUrl = normalizeOptionalString$
|
|
3970
|
+
const normalizedBaseUrl = normalizeOptionalString$28(session.authBaseUrl);
|
|
3971
3971
|
const hostKey = resolveHostKey(normalizedBaseUrl);
|
|
3972
3972
|
const user = normalizeUser(session.user);
|
|
3973
3973
|
const userKey = user?.id ?? user?.email ?? buildSessionScopedUserKey({
|
|
3974
3974
|
authBaseUrl: normalizedBaseUrl,
|
|
3975
|
-
clientId: normalizeOptionalString$
|
|
3976
|
-
createdAt: normalizeOptionalString$
|
|
3975
|
+
clientId: normalizeOptionalString$28(session.clientId),
|
|
3976
|
+
createdAt: normalizeOptionalString$28(session.createdAt)
|
|
3977
3977
|
});
|
|
3978
3978
|
return {
|
|
3979
3979
|
key: normalizeAccountKey({
|
|
@@ -3986,7 +3986,7 @@ function resolveAtsAccountContext(input) {
|
|
|
3986
3986
|
};
|
|
3987
3987
|
}
|
|
3988
3988
|
async function resolveCurrentAtsAccountContext() {
|
|
3989
|
-
const { getAuthSessionMetadata } = await import("./auth-session-
|
|
3989
|
+
const { getAuthSessionMetadata } = await import("./auth-session-DbA1IFeL.js");
|
|
3990
3990
|
return resolveAtsAccountContext({ session: await getAuthSessionMetadata().catch(() => null) });
|
|
3991
3991
|
}
|
|
3992
3992
|
function resolveHostKey(baseUrl) {
|
|
@@ -4009,9 +4009,9 @@ function buildSessionScopedUserKey(input) {
|
|
|
4009
4009
|
function normalizeUser(value) {
|
|
4010
4010
|
if (!(value && typeof value === "object")) return null;
|
|
4011
4011
|
const record = value;
|
|
4012
|
-
const id = normalizeOptionalString$
|
|
4013
|
-
const email = normalizeOptionalString$
|
|
4014
|
-
const name = normalizeOptionalString$
|
|
4012
|
+
const id = normalizeOptionalString$28(record.id);
|
|
4013
|
+
const email = normalizeOptionalString$28(record.email);
|
|
4014
|
+
const name = normalizeOptionalString$28(record.name);
|
|
4015
4015
|
if (!(id || email || name)) return null;
|
|
4016
4016
|
return {
|
|
4017
4017
|
...id ? { id } : {},
|
|
@@ -4019,7 +4019,7 @@ function normalizeUser(value) {
|
|
|
4019
4019
|
...name ? { name } : {}
|
|
4020
4020
|
};
|
|
4021
4021
|
}
|
|
4022
|
-
function normalizeOptionalString$
|
|
4022
|
+
function normalizeOptionalString$28(value) {
|
|
4023
4023
|
if (typeof value !== "string") return null;
|
|
4024
4024
|
const normalized = value.trim();
|
|
4025
4025
|
return normalized.length > 0 ? normalized : null;
|
|
@@ -4131,9 +4131,9 @@ function createAuthenticationError(input) {
|
|
|
4131
4131
|
return new AtsAuthenticationError(resolveAuthenticationGuidance(input));
|
|
4132
4132
|
}
|
|
4133
4133
|
function resolveAuthenticationGuidance(input) {
|
|
4134
|
-
const action = normalizeOptionalString$
|
|
4135
|
-
const authBaseUrl = normalizeOptionalString$
|
|
4136
|
-
const gatewayUrl = normalizeOptionalString$
|
|
4134
|
+
const action = normalizeOptionalString$27(input.action);
|
|
4135
|
+
const authBaseUrl = normalizeOptionalString$27(input.authBaseUrl);
|
|
4136
|
+
const gatewayUrl = normalizeOptionalString$27(input.gatewayUrl);
|
|
4137
4137
|
if (input.reason === "mismatch") return {
|
|
4138
4138
|
reason: input.reason,
|
|
4139
4139
|
action,
|
|
@@ -4157,7 +4157,7 @@ function resolveAuthenticationGuidance(input) {
|
|
|
4157
4157
|
};
|
|
4158
4158
|
}
|
|
4159
4159
|
function buildCommandAuthenticationPromptMessage$1(action) {
|
|
4160
|
-
const normalizedAction = normalizeOptionalString$
|
|
4160
|
+
const normalizedAction = normalizeOptionalString$27(action);
|
|
4161
4161
|
if (!normalizedAction) return "Sign in is required to continue. What do you want to do?";
|
|
4162
4162
|
return `Sign in is required before ${normalizedAction}. What do you want to do?`;
|
|
4163
4163
|
}
|
|
@@ -4246,7 +4246,7 @@ function resolveAuthenticationGuidanceFromMessage(message) {
|
|
|
4246
4246
|
function extractAuthenticationPromptAction(promptMessage) {
|
|
4247
4247
|
const normalizedMessage = String(promptMessage ?? "").trim();
|
|
4248
4248
|
if (normalizedMessage.length === 0) return null;
|
|
4249
|
-
return normalizeOptionalString$
|
|
4249
|
+
return normalizeOptionalString$27(AUTH_PROMPT_ACTION_RE.exec(normalizedMessage)?.groups?.action);
|
|
4250
4250
|
}
|
|
4251
4251
|
function resolveRequiredAuthenticationGuidance(reason) {
|
|
4252
4252
|
switch (reason) {
|
|
@@ -4316,7 +4316,7 @@ function buildAgentAuthenticationNotes(guidance) {
|
|
|
4316
4316
|
if (guidance.gatewayUrl) notes.push(`Current gateway: ${guidance.gatewayUrl}`);
|
|
4317
4317
|
return notes;
|
|
4318
4318
|
}
|
|
4319
|
-
function normalizeOptionalString$
|
|
4319
|
+
function normalizeOptionalString$27(value) {
|
|
4320
4320
|
const normalized = String(value ?? "").trim();
|
|
4321
4321
|
return normalized.length > 0 ? normalized : null;
|
|
4322
4322
|
}
|
|
@@ -4437,7 +4437,7 @@ async function setDaemonServiceRuntimeState(state, pathInput = {}) {
|
|
|
4437
4437
|
await writeDaemonServiceRuntimeState(state, pathInput);
|
|
4438
4438
|
}
|
|
4439
4439
|
async function clearDaemonServiceRuntimeState(pathInput = {}) {
|
|
4440
|
-
const { clearDaemonRuntimeLease } = await import("./daemon-runtime-lease-
|
|
4440
|
+
const { clearDaemonRuntimeLease } = await import("./daemon-runtime-lease-D1x-3a2_.js");
|
|
4441
4441
|
await Promise.all([rm(daemonServiceRuntimeStatePath(pathInput), { force: true }), clearDaemonRuntimeLease(pathInput)]);
|
|
4442
4442
|
}
|
|
4443
4443
|
async function withDaemonServiceRunLock(callback, meta = {
|
|
@@ -4932,6 +4932,7 @@ const DEFAULT_HEARTBEAT_INTERVAL_MS$1 = 25e3;
|
|
|
4932
4932
|
const MIN_HEARTBEAT_INTERVAL_MS$2 = 5e3;
|
|
4933
4933
|
const MAX_HEARTBEAT_INTERVAL_MS$2 = 6e4;
|
|
4934
4934
|
const DAEMON_STREAM_KEEPALIVE_INTERVAL_MS$1 = 2e4;
|
|
4935
|
+
const DAEMON_STREAM_KEEPALIVE_PONG_TIMEOUT_MS$1 = 1e4;
|
|
4935
4936
|
const CATALOG_SYNC_RETRY_INTERVAL_MS$1 = 5e3;
|
|
4936
4937
|
const CATALOG_SYNC_SIGNAL_POLL_INTERVAL_MS$1 = 1e3;
|
|
4937
4938
|
const RUNTIME_AGENT_CONTROLLER_REPORT_SYNC_INTERVAL_MS$1 = 5 * 6e4;
|
|
@@ -5034,10 +5035,17 @@ async function storeAccessToken(input) {
|
|
|
5034
5035
|
throw new Error(`secure token storage is unavailable on platform "${process.platform}". Use ${INSECURE_FALLBACK_ENV_KEY}=1 only for local testing fallback.`);
|
|
5035
5036
|
}
|
|
5036
5037
|
async function readAccessToken(ref) {
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5038
|
+
try {
|
|
5039
|
+
if (ref.provider === "macos-keychain") return toAccessTokenReadResult(await getMacOsKeychainToken(ref));
|
|
5040
|
+
if (ref.provider === "windows-dpapi") return toAccessTokenReadResult(await getWindowsDpapiToken(ref));
|
|
5041
|
+
if (ref.provider === "insecure-file") return toAccessTokenReadResult(await getInsecureFileToken(ref));
|
|
5042
|
+
return { status: "missing" };
|
|
5043
|
+
} catch (error) {
|
|
5044
|
+
return {
|
|
5045
|
+
errorMessage: toErrorMessage$44(error),
|
|
5046
|
+
status: "unavailable"
|
|
5047
|
+
};
|
|
5048
|
+
}
|
|
5041
5049
|
}
|
|
5042
5050
|
async function deleteAccessToken(ref) {
|
|
5043
5051
|
if (ref.provider === "macos-keychain") {
|
|
@@ -5115,7 +5123,10 @@ async function setWindowsDpapiToken(input) {
|
|
|
5115
5123
|
});
|
|
5116
5124
|
}
|
|
5117
5125
|
async function getWindowsDpapiToken(input) {
|
|
5118
|
-
const encrypted = await readFile(windowsDpapiTokenPath(input.key), "utf8").catch(() =>
|
|
5126
|
+
const encrypted = await readFile(windowsDpapiTokenPath(input.key), "utf8").catch((error) => {
|
|
5127
|
+
if (isFileNotFoundError$4(error)) return null;
|
|
5128
|
+
throw error;
|
|
5129
|
+
});
|
|
5119
5130
|
if (!encrypted) return null;
|
|
5120
5131
|
return runPowerShellScript(WINDOWS_DPAPI_DECRYPT_SCRIPT, encrypted.trim(), input.key);
|
|
5121
5132
|
}
|
|
@@ -5130,7 +5141,10 @@ async function setInsecureFileToken(input) {
|
|
|
5130
5141
|
});
|
|
5131
5142
|
}
|
|
5132
5143
|
async function getInsecureFileToken(input) {
|
|
5133
|
-
const raw = await readFile(insecureTokenPath(input.key), "utf8").catch(() =>
|
|
5144
|
+
const raw = await readFile(insecureTokenPath(input.key), "utf8").catch((error) => {
|
|
5145
|
+
if (isFileNotFoundError$4(error)) return null;
|
|
5146
|
+
throw error;
|
|
5147
|
+
});
|
|
5134
5148
|
return raw ? raw.trim() : null;
|
|
5135
5149
|
}
|
|
5136
5150
|
async function deleteInsecureFileToken(input) {
|
|
@@ -5271,10 +5285,21 @@ function normalizeToken(value) {
|
|
|
5271
5285
|
const normalized = value.trim();
|
|
5272
5286
|
return normalized.length > 0 ? normalized : null;
|
|
5273
5287
|
}
|
|
5288
|
+
function toAccessTokenReadResult(value) {
|
|
5289
|
+
const accessToken = normalizeToken(value);
|
|
5290
|
+
if (!accessToken) return { status: "missing" };
|
|
5291
|
+
return {
|
|
5292
|
+
accessToken,
|
|
5293
|
+
status: "found"
|
|
5294
|
+
};
|
|
5295
|
+
}
|
|
5274
5296
|
function toErrorMessage$44(error) {
|
|
5275
5297
|
if (error instanceof Error) return error.message;
|
|
5276
5298
|
return String(error);
|
|
5277
5299
|
}
|
|
5300
|
+
function isFileNotFoundError$4(error) {
|
|
5301
|
+
return Boolean(error && typeof error === "object" && "code" in error && error.code === "ENOENT");
|
|
5302
|
+
}
|
|
5278
5303
|
const WINDOWS_DPAPI_ENCRYPT_SCRIPT = [
|
|
5279
5304
|
"$ErrorActionPreference='Stop'",
|
|
5280
5305
|
"$rawInput = [Console]::In.ReadToEnd()",
|
|
@@ -5310,8 +5335,8 @@ async function getAuthSessionState(options = {}) {
|
|
|
5310
5335
|
const remoteState = await getRemoteAuthSessionState(localState.session);
|
|
5311
5336
|
if (remoteState === "valid") return localState;
|
|
5312
5337
|
if (remoteState === "unknown") return localState;
|
|
5313
|
-
await clearAuthSession();
|
|
5314
5338
|
return {
|
|
5339
|
+
reasonCode: resolveRemoteAuthSessionReasonCode(remoteState),
|
|
5315
5340
|
state: remoteState,
|
|
5316
5341
|
session: null
|
|
5317
5342
|
};
|
|
@@ -5360,9 +5385,9 @@ async function getAuthSession() {
|
|
|
5360
5385
|
async function getAuthSessionMetadata() {
|
|
5361
5386
|
const payload = await readSessionPayload();
|
|
5362
5387
|
if (payload?.v !== 1) return null;
|
|
5363
|
-
const authBaseUrl = normalizeOptionalString$
|
|
5364
|
-
const clientId = normalizeOptionalString$
|
|
5365
|
-
const createdAt = normalizeOptionalString$
|
|
5388
|
+
const authBaseUrl = normalizeOptionalString$26(payload.authBaseUrl);
|
|
5389
|
+
const clientId = normalizeOptionalString$26(payload.clientId);
|
|
5390
|
+
const createdAt = normalizeOptionalString$26(payload.createdAt);
|
|
5366
5391
|
if (!(authBaseUrl && clientId && createdAt)) return null;
|
|
5367
5392
|
return {
|
|
5368
5393
|
authBaseUrl,
|
|
@@ -5381,39 +5406,40 @@ async function clearAuthSession() {
|
|
|
5381
5406
|
async function getLocalAuthSessionState() {
|
|
5382
5407
|
const payload = await readSessionPayload();
|
|
5383
5408
|
if (payload?.v !== 1) return {
|
|
5409
|
+
reasonCode: "session_missing",
|
|
5384
5410
|
state: "missing",
|
|
5385
5411
|
session: null
|
|
5386
5412
|
};
|
|
5387
5413
|
const tokenRef = normalizeTokenRef(payload.tokenRef);
|
|
5388
|
-
if (!tokenRef) {
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
const
|
|
5396
|
-
const
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
}
|
|
5414
|
+
if (!tokenRef) return {
|
|
5415
|
+
reasonCode: "session_token_ref_invalid",
|
|
5416
|
+
state: "invalid",
|
|
5417
|
+
session: null
|
|
5418
|
+
};
|
|
5419
|
+
const tokenType = normalizeOptionalString$26(payload.tokenType);
|
|
5420
|
+
const authBaseUrl = normalizeOptionalString$26(payload.authBaseUrl);
|
|
5421
|
+
const clientId = normalizeOptionalString$26(payload.clientId);
|
|
5422
|
+
const createdAt = normalizeOptionalString$26(payload.createdAt);
|
|
5423
|
+
if (!(tokenType && authBaseUrl && clientId && createdAt)) return {
|
|
5424
|
+
reasonCode: "session_metadata_invalid",
|
|
5425
|
+
state: "invalid",
|
|
5426
|
+
session: null
|
|
5427
|
+
};
|
|
5428
|
+
const accessToken = await readAccessToken(tokenRef);
|
|
5429
|
+
if (accessToken.status === "missing") return {
|
|
5430
|
+
reasonCode: "session_token_missing",
|
|
5431
|
+
state: "invalid",
|
|
5432
|
+
session: null
|
|
5433
|
+
};
|
|
5434
|
+
if (accessToken.status === "unavailable") return {
|
|
5435
|
+
errorMessage: accessToken.errorMessage,
|
|
5436
|
+
reasonCode: "session_token_unavailable",
|
|
5437
|
+
state: "invalid",
|
|
5438
|
+
session: null
|
|
5439
|
+
};
|
|
5414
5440
|
const session = {
|
|
5415
5441
|
v: 1,
|
|
5416
|
-
accessToken,
|
|
5442
|
+
accessToken: accessToken.accessToken,
|
|
5417
5443
|
tokenType,
|
|
5418
5444
|
authBaseUrl,
|
|
5419
5445
|
clientId,
|
|
@@ -5423,6 +5449,7 @@ async function getLocalAuthSessionState() {
|
|
|
5423
5449
|
...buildAuthUserPayload(payload.user)
|
|
5424
5450
|
};
|
|
5425
5451
|
if (isExpired(session.expiresAt)) return {
|
|
5452
|
+
reasonCode: "session_expired",
|
|
5426
5453
|
state: "expired",
|
|
5427
5454
|
session
|
|
5428
5455
|
};
|
|
@@ -5481,10 +5508,15 @@ function isExpired(expiresAt) {
|
|
|
5481
5508
|
if (Number.isNaN(expiresAtMs)) return false;
|
|
5482
5509
|
return expiresAtMs <= Date.now();
|
|
5483
5510
|
}
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5511
|
+
function resolveRemoteAuthSessionReasonCode(state) {
|
|
5512
|
+
switch (state) {
|
|
5513
|
+
case "invalid": return "remote_session_invalid";
|
|
5514
|
+
case "revoked": return "remote_session_revoked";
|
|
5515
|
+
default: {
|
|
5516
|
+
const exhaustiveState = state;
|
|
5517
|
+
throw new Error(`unsupported remote auth session state: ${exhaustiveState}`);
|
|
5518
|
+
}
|
|
5519
|
+
}
|
|
5488
5520
|
}
|
|
5489
5521
|
async function readSessionPayload() {
|
|
5490
5522
|
const raw = await readFile(authSessionPath(), "utf8").catch(() => null);
|
|
@@ -5517,9 +5549,9 @@ async function writeSessionPayloadAtomically(path, payload) {
|
|
|
5517
5549
|
function buildAuthUserPayload(value) {
|
|
5518
5550
|
if (!(value && typeof value === "object")) return {};
|
|
5519
5551
|
const record = value;
|
|
5520
|
-
const id = normalizeOptionalString$
|
|
5521
|
-
const email = normalizeOptionalString$
|
|
5522
|
-
const name = normalizeOptionalString$
|
|
5552
|
+
const id = normalizeOptionalString$26(record.id);
|
|
5553
|
+
const email = normalizeOptionalString$26(record.email);
|
|
5554
|
+
const name = normalizeOptionalString$26(record.name);
|
|
5523
5555
|
if (!(id || email || name)) return {};
|
|
5524
5556
|
return { user: {
|
|
5525
5557
|
...id ? { id } : {},
|
|
@@ -5531,7 +5563,7 @@ function normalizeTokenType$2(value) {
|
|
|
5531
5563
|
const normalized = value.trim();
|
|
5532
5564
|
return normalized.length > 0 ? normalized : "Bearer";
|
|
5533
5565
|
}
|
|
5534
|
-
function normalizeOptionalString$
|
|
5566
|
+
function normalizeOptionalString$26(value) {
|
|
5535
5567
|
const normalized = String(value ?? "").trim();
|
|
5536
5568
|
return normalized.length > 0 ? normalized : null;
|
|
5537
5569
|
}
|
|
@@ -5580,7 +5612,7 @@ var AuthProfilesApiError = class extends Error {
|
|
|
5580
5612
|
this.name = "AuthProfilesApiError";
|
|
5581
5613
|
this.status = input.status;
|
|
5582
5614
|
this.endpoint = input.endpoint;
|
|
5583
|
-
this.code = normalizeOptionalString$
|
|
5615
|
+
this.code = normalizeOptionalString$25(input.code);
|
|
5584
5616
|
}
|
|
5585
5617
|
};
|
|
5586
5618
|
function isAuthProfilesApiError(error) {
|
|
@@ -5597,13 +5629,13 @@ async function resolveAtsProfile(input) {
|
|
|
5597
5629
|
method: "POST",
|
|
5598
5630
|
path: "/v1/profiles/resolve",
|
|
5599
5631
|
body: {
|
|
5600
|
-
...normalizeOptionalString$
|
|
5632
|
+
...normalizeOptionalString$25(input.atsProfileId) ? { atsProfileId: normalizeOptionalString$25(input.atsProfileId) } : {},
|
|
5601
5633
|
...input.profileKind ? { profileKind: input.profileKind } : {}
|
|
5602
5634
|
}
|
|
5603
5635
|
}), "profile"));
|
|
5604
5636
|
}
|
|
5605
5637
|
async function resolveAtsProfileByIdOrName(input) {
|
|
5606
|
-
const profileIdentifier = normalizeOptionalString$
|
|
5638
|
+
const profileIdentifier = normalizeOptionalString$25(input.profileIdentifier);
|
|
5607
5639
|
if (!profileIdentifier) throw new Error("profile identifier is required");
|
|
5608
5640
|
try {
|
|
5609
5641
|
return await resolveAtsProfile({
|
|
@@ -5622,8 +5654,8 @@ async function resolveAtsProfileByIdOrName(input) {
|
|
|
5622
5654
|
}
|
|
5623
5655
|
}
|
|
5624
5656
|
function createAtsAgentProfile(input) {
|
|
5625
|
-
const profileName = normalizeOptionalString$
|
|
5626
|
-
const creatorProfileId = normalizeOptionalString$
|
|
5657
|
+
const profileName = normalizeOptionalString$25(input.profileName);
|
|
5658
|
+
const creatorProfileId = normalizeOptionalString$25(input.creatorProfileId) ?? void 0;
|
|
5627
5659
|
if (!profileName) throw new Error("profile name is required");
|
|
5628
5660
|
return createAtsAgentProfileRequest({
|
|
5629
5661
|
profileName,
|
|
@@ -5631,8 +5663,8 @@ function createAtsAgentProfile(input) {
|
|
|
5631
5663
|
});
|
|
5632
5664
|
}
|
|
5633
5665
|
function ensureAtsManagedAgentProfile(input) {
|
|
5634
|
-
const profileName = normalizeOptionalString$
|
|
5635
|
-
const creatorProfileId = normalizeOptionalString$
|
|
5666
|
+
const profileName = normalizeOptionalString$25(input.profileName);
|
|
5667
|
+
const creatorProfileId = normalizeOptionalString$25(input.creatorProfileId) ?? void 0;
|
|
5636
5668
|
if (!profileName) throw new Error("profile name is required");
|
|
5637
5669
|
return ensureAtsManagedAgentProfileRequest({
|
|
5638
5670
|
profileName,
|
|
@@ -5641,8 +5673,8 @@ function ensureAtsManagedAgentProfile(input) {
|
|
|
5641
5673
|
});
|
|
5642
5674
|
}
|
|
5643
5675
|
async function createAtsHumanProfile(input) {
|
|
5644
|
-
const profileName = normalizeOptionalString$
|
|
5645
|
-
const creatorProfileId = normalizeOptionalString$
|
|
5676
|
+
const profileName = normalizeOptionalString$25(input.profileName);
|
|
5677
|
+
const creatorProfileId = normalizeOptionalString$25(input.creatorProfileId) ?? void 0;
|
|
5646
5678
|
if (!profileName) throw new Error("profile name is required");
|
|
5647
5679
|
const created = parseAtsProfileItem(readRecordField(await requestAtsProfilesApi({
|
|
5648
5680
|
method: "POST",
|
|
@@ -5656,9 +5688,9 @@ async function createAtsHumanProfile(input) {
|
|
|
5656
5688
|
return created;
|
|
5657
5689
|
}
|
|
5658
5690
|
async function updateAtsProfile(input) {
|
|
5659
|
-
const atsProfileId = normalizeOptionalString$
|
|
5691
|
+
const atsProfileId = normalizeOptionalString$25(input.atsProfileId);
|
|
5660
5692
|
if (!atsProfileId) throw new Error("atsProfileId is required");
|
|
5661
|
-
const profileName = normalizeOptionalString$
|
|
5693
|
+
const profileName = normalizeOptionalString$25(input.profileName);
|
|
5662
5694
|
if (!Boolean(profileName)) throw new Error("profileName is required");
|
|
5663
5695
|
const updated = parseAtsProfileItem(readRecordField(await requestAtsProfilesApi({
|
|
5664
5696
|
method: "PATCH",
|
|
@@ -5669,7 +5701,7 @@ async function updateAtsProfile(input) {
|
|
|
5669
5701
|
return updated;
|
|
5670
5702
|
}
|
|
5671
5703
|
async function deleteAtsProfile(input) {
|
|
5672
|
-
const atsProfileId = normalizeOptionalString$
|
|
5704
|
+
const atsProfileId = normalizeOptionalString$25(input.atsProfileId);
|
|
5673
5705
|
if (!atsProfileId) throw new Error("atsProfileId is required");
|
|
5674
5706
|
const deleted = parseAtsProfileItem(readRecordField(await requestAtsProfilesApi({
|
|
5675
5707
|
method: "DELETE",
|
|
@@ -5866,12 +5898,12 @@ function readArrayField(input, field) {
|
|
|
5866
5898
|
return value.filter(isRecord$4);
|
|
5867
5899
|
}
|
|
5868
5900
|
function readRequiredStringField(input, field) {
|
|
5869
|
-
const value = normalizeOptionalString$
|
|
5901
|
+
const value = normalizeOptionalString$25(input[field]);
|
|
5870
5902
|
if (!value) throw new Error(`invalid profile payload: missing ${field}`);
|
|
5871
5903
|
return value;
|
|
5872
5904
|
}
|
|
5873
5905
|
function readOptionalStringField$1(input, field) {
|
|
5874
|
-
return normalizeOptionalString$
|
|
5906
|
+
return normalizeOptionalString$25(input[field]);
|
|
5875
5907
|
}
|
|
5876
5908
|
function readBooleanField(input, field) {
|
|
5877
5909
|
return input[field] === true;
|
|
@@ -5881,7 +5913,7 @@ function readOptionalBooleanField(input, field) {
|
|
|
5881
5913
|
if (typeof value === "boolean") return value;
|
|
5882
5914
|
return null;
|
|
5883
5915
|
}
|
|
5884
|
-
function normalizeOptionalString$
|
|
5916
|
+
function normalizeOptionalString$25(value) {
|
|
5885
5917
|
const normalized = String(value ?? "").trim();
|
|
5886
5918
|
return normalized.length > 0 ? normalized : null;
|
|
5887
5919
|
}
|
|
@@ -5907,7 +5939,7 @@ async function parseResponseJson$1(response) {
|
|
|
5907
5939
|
}
|
|
5908
5940
|
function extractApiErrorMessage$1(payload, status) {
|
|
5909
5941
|
const record = isRecord$4(payload) ? payload : {};
|
|
5910
|
-
const message = normalizeOptionalString$
|
|
5942
|
+
const message = normalizeOptionalString$25(record.message) ?? normalizeOptionalString$25(record.error_description) ?? normalizeOptionalString$25(record.error);
|
|
5911
5943
|
if (message) return message;
|
|
5912
5944
|
return `request failed with status ${status}`;
|
|
5913
5945
|
}
|
|
@@ -5962,7 +5994,7 @@ function isSelectedAtsProfileRequiredError(error) {
|
|
|
5962
5994
|
return error.message.startsWith(PROFILE_REQUIRED_ERROR_PREFIX) && error.message.endsWith(PROFILE_REQUIRED_ERROR_SUFFIX);
|
|
5963
5995
|
}
|
|
5964
5996
|
async function resolveAtsProfileOrNull(input = {}) {
|
|
5965
|
-
const explicitAtsProfileId = normalizeOptionalString$
|
|
5997
|
+
const explicitAtsProfileId = normalizeOptionalString$24(input.atsProfileId);
|
|
5966
5998
|
if (explicitAtsProfileId) return await resolveExplicitAtsProfile(explicitAtsProfileId, {
|
|
5967
5999
|
profileKind: input.profileKind,
|
|
5968
6000
|
allowUnauthenticated: input.allowUnauthenticated === true,
|
|
@@ -6035,7 +6067,7 @@ async function resolveSelectedAtsProfile(selectedAtsProfileId, input) {
|
|
|
6035
6067
|
throw error;
|
|
6036
6068
|
}
|
|
6037
6069
|
}
|
|
6038
|
-
function normalizeOptionalString$
|
|
6070
|
+
function normalizeOptionalString$24(value) {
|
|
6039
6071
|
const normalized = String(value ?? "").trim();
|
|
6040
6072
|
return normalized.length > 0 ? normalized : null;
|
|
6041
6073
|
}
|
|
@@ -6050,13 +6082,13 @@ function isProfileMissingError(error) {
|
|
|
6050
6082
|
//#endregion
|
|
6051
6083
|
//#region src/config/view-profile-key.ts
|
|
6052
6084
|
async function resolveViewProfileKey(inputProfile) {
|
|
6053
|
-
const explicit = normalizeOptionalString$
|
|
6085
|
+
const explicit = normalizeOptionalString$23(inputProfile);
|
|
6054
6086
|
if (explicit) return (await resolveAtsProfileByIdOrName({ profileIdentifier: explicit }).catch(() => null))?.atsProfileId ?? explicit;
|
|
6055
6087
|
const selected = await getSelectedAtsProfileId();
|
|
6056
6088
|
if (selected) return selected;
|
|
6057
6089
|
return null;
|
|
6058
6090
|
}
|
|
6059
|
-
function normalizeOptionalString$
|
|
6091
|
+
function normalizeOptionalString$23(value) {
|
|
6060
6092
|
const normalized = String(value ?? "").trim();
|
|
6061
6093
|
return normalized.length > 0 ? normalized : null;
|
|
6062
6094
|
}
|
|
@@ -6488,7 +6520,7 @@ function buildStartRecapItems() {
|
|
|
6488
6520
|
//#endregion
|
|
6489
6521
|
//#region src/start-shell/notices.ts
|
|
6490
6522
|
function renderStartWelcome(input) {
|
|
6491
|
-
const email = normalizeOptionalString$
|
|
6523
|
+
const email = normalizeOptionalString$22(input.session.user?.email) ?? "(unknown)";
|
|
6492
6524
|
if (input.runtime.resolvedView === "agent") {
|
|
6493
6525
|
input.presenter.data({
|
|
6494
6526
|
code: "start.welcome",
|
|
@@ -6502,10 +6534,10 @@ function renderStartWelcome(input) {
|
|
|
6502
6534
|
note([`Signed In: ${email}`, `Gateway: ${input.gatewayUrl}`].join("\n"), "Welcome");
|
|
6503
6535
|
}
|
|
6504
6536
|
function emitStartCompatibilityNotice(input) {
|
|
6505
|
-
const normalizedSkillsMode = normalizeOptionalString$
|
|
6537
|
+
const normalizedSkillsMode = normalizeOptionalString$22(input.input.skillsMode)?.toLowerCase();
|
|
6506
6538
|
const ignoredFlags = [
|
|
6507
|
-
normalizeOptionalString$
|
|
6508
|
-
normalizeOptionalString$
|
|
6539
|
+
normalizeOptionalString$22(input.input.agentModel) ? "--agent-model" : null,
|
|
6540
|
+
normalizeOptionalString$22(input.input.agentOwner) ? "--agent-owner" : null,
|
|
6509
6541
|
normalizedSkillsMode && normalizedSkillsMode !== "auto" ? "--skills-mode" : null
|
|
6510
6542
|
].filter((value) => value !== null);
|
|
6511
6543
|
if (ignoredFlags.length === 0) return;
|
|
@@ -6556,7 +6588,7 @@ function emitStartSetupHint(input) {
|
|
|
6556
6588
|
text: formatInlineAtsCliCommands("If this computer needs local service or agent setup, run `ats setup`.")
|
|
6557
6589
|
});
|
|
6558
6590
|
}
|
|
6559
|
-
function normalizeOptionalString$
|
|
6591
|
+
function normalizeOptionalString$22(value) {
|
|
6560
6592
|
if (typeof value !== "string") return null;
|
|
6561
6593
|
const normalized = value.trim();
|
|
6562
6594
|
return normalized.length > 0 ? normalized : null;
|
|
@@ -6771,7 +6803,7 @@ async function readProfileWorkspaceConfigForAccount(input) {
|
|
|
6771
6803
|
path,
|
|
6772
6804
|
status: "missing"
|
|
6773
6805
|
};
|
|
6774
|
-
const parsedJson = safeParseJson$
|
|
6806
|
+
const parsedJson = safeParseJson$2(raw);
|
|
6775
6807
|
if (parsedJson === null) return {
|
|
6776
6808
|
path,
|
|
6777
6809
|
reason: "invalid_json",
|
|
@@ -6967,7 +6999,7 @@ function buildWorkspacePayload(value) {
|
|
|
6967
6999
|
async function readExistingEnvelopeDraft(input) {
|
|
6968
7000
|
const raw = await readOptionalFile(input.path);
|
|
6969
7001
|
if (raw === null) return null;
|
|
6970
|
-
const parsed = safeParseJson$
|
|
7002
|
+
const parsed = safeParseJson$2(raw);
|
|
6971
7003
|
if (!(parsed && typeof parsed === "object")) return null;
|
|
6972
7004
|
const record = parsed;
|
|
6973
7005
|
if (record.v !== PROFILE_LOCAL_META_ENVELOPE_VERSION) return null;
|
|
@@ -7079,7 +7111,7 @@ function hasOnlyExpectedKeys(record, expectedKeys) {
|
|
|
7079
7111
|
const allowedKeys = new Set(expectedKeys);
|
|
7080
7112
|
return Object.keys(record).every((key) => allowedKeys.has(key));
|
|
7081
7113
|
}
|
|
7082
|
-
function safeParseJson$
|
|
7114
|
+
function safeParseJson$2(raw) {
|
|
7083
7115
|
try {
|
|
7084
7116
|
return JSON.parse(raw);
|
|
7085
7117
|
} catch {
|
|
@@ -8239,7 +8271,7 @@ function buildAuthStatusSnapshot(input) {
|
|
|
8239
8271
|
expiresIn: null,
|
|
8240
8272
|
expired: false
|
|
8241
8273
|
};
|
|
8242
|
-
const expiresAt = normalizeOptionalString$
|
|
8274
|
+
const expiresAt = normalizeOptionalString$21(session.expiresAt);
|
|
8243
8275
|
const expiresAtMs = expiresAt ? Date.parse(expiresAt) : NaN;
|
|
8244
8276
|
const hasValidExpiresAt = Number.isFinite(expiresAtMs);
|
|
8245
8277
|
const expiresInMs = hasValidExpiresAt ? expiresAtMs - Date.now() : NaN;
|
|
@@ -8247,14 +8279,14 @@ function buildAuthStatusSnapshot(input) {
|
|
|
8247
8279
|
return {
|
|
8248
8280
|
signedIn: input.state === "valid",
|
|
8249
8281
|
state: input.state,
|
|
8250
|
-
userId: normalizeOptionalString$
|
|
8251
|
-
userEmail: normalizeOptionalString$
|
|
8252
|
-
userName: normalizeOptionalString$
|
|
8253
|
-
clientId: normalizeOptionalString$
|
|
8254
|
-
authBaseUrl: normalizeOptionalString$
|
|
8255
|
-
tokenType: normalizeOptionalString$
|
|
8256
|
-
scope: normalizeOptionalString$
|
|
8257
|
-
createdAt: normalizeOptionalString$
|
|
8282
|
+
userId: normalizeOptionalString$21(session.user?.id),
|
|
8283
|
+
userEmail: normalizeOptionalString$21(session.user?.email),
|
|
8284
|
+
userName: normalizeOptionalString$21(session.user?.name),
|
|
8285
|
+
clientId: normalizeOptionalString$21(session.clientId),
|
|
8286
|
+
authBaseUrl: normalizeOptionalString$21(session.authBaseUrl),
|
|
8287
|
+
tokenType: normalizeOptionalString$21(session.tokenType),
|
|
8288
|
+
scope: normalizeOptionalString$21(session.scope),
|
|
8289
|
+
createdAt: normalizeOptionalString$21(session.createdAt),
|
|
8258
8290
|
expiresAt,
|
|
8259
8291
|
expiresIn: hasValidExpiresAt ? formatRemainingDuration(expiresInMs) : null,
|
|
8260
8292
|
expired
|
|
@@ -8329,7 +8361,7 @@ function appendRowIfValue(rows, label, value) {
|
|
|
8329
8361
|
value
|
|
8330
8362
|
});
|
|
8331
8363
|
}
|
|
8332
|
-
function normalizeOptionalString$
|
|
8364
|
+
function normalizeOptionalString$21(value) {
|
|
8333
8365
|
const normalized = String(value ?? "").trim();
|
|
8334
8366
|
return normalized.length > 0 ? normalized : null;
|
|
8335
8367
|
}
|
|
@@ -8684,7 +8716,7 @@ async function readDaemonLocalStateFile(input) {
|
|
|
8684
8716
|
throw error;
|
|
8685
8717
|
});
|
|
8686
8718
|
if (raw === null) return null;
|
|
8687
|
-
const parsedJson = safeParseJson(raw);
|
|
8719
|
+
const parsedJson = safeParseJson$1(raw);
|
|
8688
8720
|
if (parsedJson === null) return null;
|
|
8689
8721
|
const parsed = input.schema.safeParse(parsedJson);
|
|
8690
8722
|
return parsed.success ? parsed.data : null;
|
|
@@ -8707,7 +8739,7 @@ async function writeDaemonLocalStateFile(input) {
|
|
|
8707
8739
|
if (shouldCleanupTemp) await rm(tempPath, { force: true }).catch(() => void 0);
|
|
8708
8740
|
}
|
|
8709
8741
|
}
|
|
8710
|
-
function safeParseJson(raw) {
|
|
8742
|
+
function safeParseJson$1(raw) {
|
|
8711
8743
|
try {
|
|
8712
8744
|
return JSON.parse(raw);
|
|
8713
8745
|
} catch {
|
|
@@ -15576,14 +15608,14 @@ const createAuthorityAtsServiceRuntimeId = (input) => {
|
|
|
15576
15608
|
source: RUNTIME_REGISTRY_AUTHORITY_SOURCE
|
|
15577
15609
|
};
|
|
15578
15610
|
};
|
|
15579
|
-
const normalizeOptionalString$
|
|
15611
|
+
const normalizeOptionalString$20 = (value) => {
|
|
15580
15612
|
const normalized = String(value ?? "").trim();
|
|
15581
15613
|
return normalized.length > 0 ? normalized : void 0;
|
|
15582
15614
|
};
|
|
15583
15615
|
const createAgentProfileBindingModelSelection = (input) => {
|
|
15584
|
-
const modelId = normalizeOptionalString$
|
|
15616
|
+
const modelId = normalizeOptionalString$20(input?.modelId);
|
|
15585
15617
|
if (!modelId) return;
|
|
15586
|
-
const reasoningLevel = normalizeOptionalString$
|
|
15618
|
+
const reasoningLevel = normalizeOptionalString$20(input?.reasoningLevel);
|
|
15587
15619
|
return {
|
|
15588
15620
|
modelId,
|
|
15589
15621
|
...reasoningLevel ? { reasoningLevel } : {}
|
|
@@ -21327,16 +21359,16 @@ function renderRegistryOriginLaunchCommand(input) {
|
|
|
21327
21359
|
function parseAgentsRegistryDocument(value, registryPath) {
|
|
21328
21360
|
const objectValue = readObjectValue(value, `agents registry file '${registryPath}'`);
|
|
21329
21361
|
return {
|
|
21330
|
-
schemaVersion: readStringValue(objectValue.schemaVersion, "schemaVersion"),
|
|
21362
|
+
schemaVersion: readStringValue$1(objectValue.schemaVersion, "schemaVersion"),
|
|
21331
21363
|
agents: readArrayValue(objectValue.agents, "agents").map((agent, index) => parseAgentsRegistryAgent(agent, `agents[${String(index)}]`))
|
|
21332
21364
|
};
|
|
21333
21365
|
}
|
|
21334
21366
|
function parseAgentsRegistryAgent(value, context) {
|
|
21335
21367
|
const objectValue = readObjectValue(value, context);
|
|
21336
|
-
const id = readStringValue(objectValue.id, `${context}.id`);
|
|
21337
|
-
const displayName = readStringValue(objectValue.displayName, `${context}.displayName`);
|
|
21368
|
+
const id = readStringValue$1(objectValue.id, `${context}.id`);
|
|
21369
|
+
const displayName = readStringValue$1(objectValue.displayName, `${context}.displayName`);
|
|
21338
21370
|
const category = readEnumValue(objectValue.category, `${context}.category`, ["builtin", "custom"]);
|
|
21339
|
-
const skillsDir = readStringValue(objectValue.skillsDir, `${context}.skillsDir`);
|
|
21371
|
+
const skillsDir = readStringValue$1(objectValue.skillsDir, `${context}.skillsDir`);
|
|
21340
21372
|
const globalSkillsDir = readOptionalStringOrStringArray(objectValue.globalSkillsDir, `${context}.globalSkillsDir`);
|
|
21341
21373
|
const detection = parseAgentsRegistryDetection(objectValue.detection, `${context}.detection`);
|
|
21342
21374
|
const service = parseAgentsRegistryServiceCapability(objectValue.service, `${context}.service`);
|
|
@@ -21397,7 +21429,7 @@ function parseAgentsRegistryDetectionCheck(value, context) {
|
|
|
21397
21429
|
"envTruthy"
|
|
21398
21430
|
]);
|
|
21399
21431
|
if (!SUPPORTED_DETECTION_CHECK_KINDS.has(kind)) throw new Error(`Unsupported detection check kind at ${context}.kind: ${kind}`);
|
|
21400
|
-
const detectionValue = readStringValue(objectValue.value, `${context}.value`);
|
|
21432
|
+
const detectionValue = readStringValue$1(objectValue.value, `${context}.value`);
|
|
21401
21433
|
const platform = readOptionalEnumValue(objectValue.platform, `${context}.platform`, [
|
|
21402
21434
|
"all",
|
|
21403
21435
|
"darwin",
|
|
@@ -21427,7 +21459,7 @@ function parseAgentsRegistryRuntimeSupport(value, context) {
|
|
|
21427
21459
|
}
|
|
21428
21460
|
function parseAgentsRegistryAdapterBinding(value, context) {
|
|
21429
21461
|
const objectValue = readObjectValue(value, context);
|
|
21430
|
-
const adapterId = readStringValue(objectValue.adapterId, `${context}.adapterId`);
|
|
21462
|
+
const adapterId = readStringValue$1(objectValue.adapterId, `${context}.adapterId`);
|
|
21431
21463
|
const controllerRefMatcher = parseAgentsRegistryAgentControllerRefMatcher(objectValue.controllerRefMatcher, `${context}.controllerRefMatcher`);
|
|
21432
21464
|
const transportModes = readArrayValue(objectValue.transportModes, `${context}.transportModes`).map((transportMode, index) => parseTransportMode$1(transportMode, `${context}.transportModes[${String(index)}]`));
|
|
21433
21465
|
const capabilityDeclaration = parseAgentsRegistryRuntimeCapabilityDeclaration(objectValue.capabilityDeclaration, `${context}.capabilityDeclaration`);
|
|
@@ -21471,7 +21503,7 @@ function parseAgentsRegistryAgentControllerRefMatcher(value, context) {
|
|
|
21471
21503
|
"regex"
|
|
21472
21504
|
]);
|
|
21473
21505
|
if (!SUPPORTED_RUNTIME_MATCHER_KINDS.has(kind)) throw new Error(`Unsupported controller matcher kind at ${context}.kind: ${kind}`);
|
|
21474
|
-
const values = readArrayValue(objectValue.values, `${context}.values`).map((entry, index) => readStringValue(entry, `${context}.values[${String(index)}]`));
|
|
21506
|
+
const values = readArrayValue(objectValue.values, `${context}.values`).map((entry, index) => readStringValue$1(entry, `${context}.values[${String(index)}]`));
|
|
21475
21507
|
if (values.length === 0) throw new Error(`Expected non-empty matcher values at ${context}.values`);
|
|
21476
21508
|
return {
|
|
21477
21509
|
kind,
|
|
@@ -21484,7 +21516,7 @@ function parseOptionalTransportModes(value, context) {
|
|
|
21484
21516
|
}
|
|
21485
21517
|
function parseOptionalOriginLaunch(value, context) {
|
|
21486
21518
|
if (value === void 0 || value === null) return null;
|
|
21487
|
-
const commandTemplate = readStringValue(readObjectValue(value, context).commandTemplate, `${context}.commandTemplate`);
|
|
21519
|
+
const commandTemplate = readStringValue$1(readObjectValue(value, context).commandTemplate, `${context}.commandTemplate`);
|
|
21488
21520
|
const placeholderMatches = [...commandTemplate.matchAll(ANY_BRACE_TOKEN_RE)];
|
|
21489
21521
|
if (placeholderMatches.length === 0) throw new Error(`Expected origin launch placeholder token at ${context}.commandTemplate`);
|
|
21490
21522
|
for (const match of placeholderMatches) {
|
|
@@ -21615,7 +21647,7 @@ function readArrayValue(value, context) {
|
|
|
21615
21647
|
if (!Array.isArray(value)) throw new Error(`Expected array at ${context}`);
|
|
21616
21648
|
return value;
|
|
21617
21649
|
}
|
|
21618
|
-
function readStringValue(value, context) {
|
|
21650
|
+
function readStringValue$1(value, context) {
|
|
21619
21651
|
if (typeof value !== "string") throw new Error(`Expected string at ${context}`);
|
|
21620
21652
|
const trimmed = value.trim();
|
|
21621
21653
|
if (!trimmed) throw new Error(`Expected non-empty string at ${context}`);
|
|
@@ -21636,8 +21668,8 @@ function readOptionalEnumValue(value, context, allowed) {
|
|
|
21636
21668
|
}
|
|
21637
21669
|
function readOptionalStringOrStringArray(value, context) {
|
|
21638
21670
|
if (value === void 0 || value === null) return null;
|
|
21639
|
-
if (typeof value === "string") return readStringValue(value, context);
|
|
21640
|
-
if (Array.isArray(value)) return value.map((item, index) => readStringValue(item, `${context}[${String(index)}]`));
|
|
21671
|
+
if (typeof value === "string") return readStringValue$1(value, context);
|
|
21672
|
+
if (Array.isArray(value)) return value.map((item, index) => readStringValue$1(item, `${context}[${String(index)}]`));
|
|
21641
21673
|
throw new Error(`Expected string or string[] at ${context}`);
|
|
21642
21674
|
}
|
|
21643
21675
|
function isMissingFileError(error) {
|
|
@@ -22679,6 +22711,7 @@ const CATALOG_SYNC_SIGNAL_POLL_INTERVAL_MS = CATALOG_SYNC_SIGNAL_POLL_INTERVAL_M
|
|
|
22679
22711
|
const DAEMON_RUNTIME_CONTRACT_EPOCH = DAEMON_RUNTIME_CONTRACT_EPOCH$1;
|
|
22680
22712
|
const DAEMON_STREAM_CONNECT_TIMEOUT_MS = DAEMON_STREAM_CONNECT_TIMEOUT_MS$1;
|
|
22681
22713
|
const DAEMON_STREAM_KEEPALIVE_INTERVAL_MS = DAEMON_STREAM_KEEPALIVE_INTERVAL_MS$1;
|
|
22714
|
+
const DAEMON_STREAM_KEEPALIVE_PONG_TIMEOUT_MS = DAEMON_STREAM_KEEPALIVE_PONG_TIMEOUT_MS$1;
|
|
22682
22715
|
const DEFAULT_HEARTBEAT_INTERVAL_MS = DEFAULT_HEARTBEAT_INTERVAL_MS$1;
|
|
22683
22716
|
const HEARTBEAT_RESPONSE_TIMEOUT_MS = HEARTBEAT_RESPONSE_TIMEOUT_MS$1;
|
|
22684
22717
|
const MAX_HEARTBEAT_INTERVAL_MS = MAX_HEARTBEAT_INTERVAL_MS$2;
|
|
@@ -29280,8 +29313,8 @@ function buildSpaceSignalsReadSearchParams(query) {
|
|
|
29280
29313
|
return searchParams;
|
|
29281
29314
|
}
|
|
29282
29315
|
function normalizeSpaceSignalsReadQuery(query) {
|
|
29283
|
-
const afterSignalId = normalizeOptionalString$
|
|
29284
|
-
const aroundSignalId = normalizeOptionalString$
|
|
29316
|
+
const afterSignalId = normalizeOptionalString$19(query?.afterSignalId);
|
|
29317
|
+
const aroundSignalId = normalizeOptionalString$19(query?.aroundSignalId);
|
|
29285
29318
|
const beforeCount = normalizeOptionalNonNegativeInteger(query?.beforeCount);
|
|
29286
29319
|
const afterCount = normalizeOptionalNonNegativeInteger(query?.afterCount);
|
|
29287
29320
|
const limit = normalizeOptionalNonNegativeInteger(query?.limit);
|
|
@@ -29309,7 +29342,7 @@ function normalizeSpaceSignalsReadQuery(query) {
|
|
|
29309
29342
|
kinds
|
|
29310
29343
|
};
|
|
29311
29344
|
}
|
|
29312
|
-
function normalizeOptionalString$
|
|
29345
|
+
function normalizeOptionalString$19(value) {
|
|
29313
29346
|
if (typeof value !== "string") return null;
|
|
29314
29347
|
const normalized = value.trim();
|
|
29315
29348
|
return normalized.length > 0 ? normalized : null;
|
|
@@ -29322,7 +29355,7 @@ function normalizeOptionalNonNegativeInteger(value) {
|
|
|
29322
29355
|
function normalizeUniqueStrings(values) {
|
|
29323
29356
|
const deduped = /* @__PURE__ */ new Set();
|
|
29324
29357
|
for (const value of values) {
|
|
29325
|
-
const normalized = normalizeOptionalString$
|
|
29358
|
+
const normalized = normalizeOptionalString$19(value);
|
|
29326
29359
|
if (normalized) deduped.add(normalized);
|
|
29327
29360
|
}
|
|
29328
29361
|
return [...deduped];
|
|
@@ -30936,9 +30969,9 @@ function createModelCatalogReadSession(input) {
|
|
|
30936
30969
|
async function readModelCatalogOnce(baseUrl) {
|
|
30937
30970
|
try {
|
|
30938
30971
|
const [apiClient, baseUrlModule, clientFoundationModule] = await Promise.all([
|
|
30939
|
-
import("./dist-
|
|
30940
|
-
import("./base-url-
|
|
30941
|
-
import("./api-client-foundation-
|
|
30972
|
+
import("./dist-DV2pViNq.js"),
|
|
30973
|
+
import("./base-url-CiDhrDeP.js").then((n) => n.n),
|
|
30974
|
+
import("./api-client-foundation-CBoyrvoT.js")
|
|
30942
30975
|
]);
|
|
30943
30976
|
if (typeof apiClient.createConfigApi !== "function") throw new Error("config api client is unavailable");
|
|
30944
30977
|
const resolvedBaseUrl = baseUrl ?? await baseUrlModule.resolveBaseUrl();
|
|
@@ -32014,7 +32047,7 @@ function isDaemonBundleSourceAllowedForLane(input) {
|
|
|
32014
32047
|
}
|
|
32015
32048
|
async function readDaemonActiveBundleState() {
|
|
32016
32049
|
const raw = await readFile(daemonServiceActiveBundlePath(), "utf8").catch((error) => {
|
|
32017
|
-
if (getErrorCode$
|
|
32050
|
+
if (getErrorCode$4(error) === "ENOENT") return null;
|
|
32018
32051
|
throw error;
|
|
32019
32052
|
});
|
|
32020
32053
|
if (raw === null) return null;
|
|
@@ -32290,7 +32323,7 @@ async function listDaemonSourceDistFiles(path) {
|
|
|
32290
32323
|
async function collectDaemonBundleRuntimeDependencyClosure(input) {
|
|
32291
32324
|
const packageManifestPath = join(input.sourcePackageRootPath, "package.json");
|
|
32292
32325
|
const packageManifestRaw = await readFile(packageManifestPath, "utf8").catch((error) => {
|
|
32293
|
-
if (getErrorCode$
|
|
32326
|
+
if (getErrorCode$4(error) === "ENOENT") throw new Error(`ATS could not find the CLI package manifest for background service bundling at ${packageManifestPath}.`);
|
|
32294
32327
|
throw error;
|
|
32295
32328
|
});
|
|
32296
32329
|
const packageManifest = JSON.parse(packageManifestRaw);
|
|
@@ -32352,7 +32385,7 @@ async function readDaemonBundleDependencyManifest(input) {
|
|
|
32352
32385
|
if (!dependencyPackageRootPath) return null;
|
|
32353
32386
|
const dependencyManifestPath = join(dependencyPackageRootPath, "package.json");
|
|
32354
32387
|
const dependencyManifestRaw = await readFile(dependencyManifestPath, "utf8").catch((error) => {
|
|
32355
|
-
if (getErrorCode$
|
|
32388
|
+
if (getErrorCode$4(error) === "ENOENT") {
|
|
32356
32389
|
if (!input.required) return null;
|
|
32357
32390
|
throw new Error(`ATS could not find runtime dependency ${input.dependencyName} for background service bundling at ${dependencyManifestPath}. Run \`pnpm install\` and retry.`);
|
|
32358
32391
|
}
|
|
@@ -32707,7 +32740,7 @@ function quoteShellSingle(value) {
|
|
|
32707
32740
|
}
|
|
32708
32741
|
async function readDirectoryNames(path) {
|
|
32709
32742
|
return (await readdir(path, { withFileTypes: true }).catch((error) => {
|
|
32710
|
-
if (getErrorCode$
|
|
32743
|
+
if (getErrorCode$4(error) === "ENOENT") return [];
|
|
32711
32744
|
throw error;
|
|
32712
32745
|
})).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
32713
32746
|
}
|
|
@@ -32725,7 +32758,7 @@ function isDaemonBundleSourceKind(value) {
|
|
|
32725
32758
|
return value === DAEMON_BUNDLE_SOURCE_KIND_WORKSPACE || value === DAEMON_BUNDLE_SOURCE_KIND_PACKAGE_INSTALL || value === DAEMON_BUNDLE_SOURCE_KIND_NPX_CACHE || value === DAEMON_BUNDLE_SOURCE_KIND_UNKNOWN;
|
|
32726
32759
|
}
|
|
32727
32760
|
function isPackageEntryResolutionError(error) {
|
|
32728
|
-
const code = getErrorCode$
|
|
32761
|
+
const code = getErrorCode$4(error);
|
|
32729
32762
|
return code === "MODULE_NOT_FOUND" || code === "ERR_PACKAGE_PATH_NOT_EXPORTED";
|
|
32730
32763
|
}
|
|
32731
32764
|
function normalizeOptionalText$27(value) {
|
|
@@ -32737,7 +32770,7 @@ async function pathExists$6(path) {
|
|
|
32737
32770
|
await stat(path);
|
|
32738
32771
|
return true;
|
|
32739
32772
|
} catch (error) {
|
|
32740
|
-
if (getErrorCode$
|
|
32773
|
+
if (getErrorCode$4(error) === "ENOENT") return false;
|
|
32741
32774
|
throw error;
|
|
32742
32775
|
}
|
|
32743
32776
|
}
|
|
@@ -32765,7 +32798,7 @@ function buildPreferredCliScriptNames(rawPath) {
|
|
|
32765
32798
|
function isSupportedDaemonCliEntryName(value) {
|
|
32766
32799
|
return DAEMON_CLI_ENTRY_NAMES.includes(value);
|
|
32767
32800
|
}
|
|
32768
|
-
function getErrorCode$
|
|
32801
|
+
function getErrorCode$4(error) {
|
|
32769
32802
|
if (!error || typeof error !== "object") return;
|
|
32770
32803
|
const code = error.code;
|
|
32771
32804
|
return typeof code === "string" ? code : void 0;
|
|
@@ -33417,7 +33450,7 @@ async function computeDirectoryContentHash(input) {
|
|
|
33417
33450
|
}
|
|
33418
33451
|
async function collectFiles(input) {
|
|
33419
33452
|
const entries = await readdir(input.dir, { withFileTypes: true }).catch((error) => {
|
|
33420
|
-
if (getErrorCode$
|
|
33453
|
+
if (getErrorCode$3(error) === "ENOENT") return [];
|
|
33421
33454
|
warnDirectoryReadError(input.dir, error);
|
|
33422
33455
|
throw error;
|
|
33423
33456
|
});
|
|
@@ -33446,7 +33479,7 @@ async function collectFiles(input) {
|
|
|
33446
33479
|
function normalizeRelativePath(value) {
|
|
33447
33480
|
return value.split("\\").join("/");
|
|
33448
33481
|
}
|
|
33449
|
-
function getErrorCode$
|
|
33482
|
+
function getErrorCode$3(error) {
|
|
33450
33483
|
if (!error || typeof error !== "object") return;
|
|
33451
33484
|
const code = error.code;
|
|
33452
33485
|
return typeof code === "string" ? code : void 0;
|
|
@@ -33719,7 +33752,7 @@ async function withSkillsInstallLock(run) {
|
|
|
33719
33752
|
acquired = true;
|
|
33720
33753
|
break;
|
|
33721
33754
|
} catch (error) {
|
|
33722
|
-
if (getErrorCode$
|
|
33755
|
+
if (getErrorCode$2(error) !== "EEXIST") throw error;
|
|
33723
33756
|
if (!await recoverStaleSkillsInstallLock(lockPath)) throw new Error("another skills installation is already running; retry after it finishes");
|
|
33724
33757
|
try {
|
|
33725
33758
|
await writeFile(lockPath, lockContents, {
|
|
@@ -33729,7 +33762,7 @@ async function withSkillsInstallLock(run) {
|
|
|
33729
33762
|
acquired = true;
|
|
33730
33763
|
break;
|
|
33731
33764
|
} catch (retryError) {
|
|
33732
|
-
if (getErrorCode$
|
|
33765
|
+
if (getErrorCode$2(retryError) !== "EEXIST") throw retryError;
|
|
33733
33766
|
}
|
|
33734
33767
|
}
|
|
33735
33768
|
if (!acquired) throw new Error("another skills installation is already running; retry after it finishes");
|
|
@@ -33741,14 +33774,14 @@ async function withSkillsInstallLock(run) {
|
|
|
33741
33774
|
}
|
|
33742
33775
|
async function recoverStaleSkillsInstallLock(lockPath) {
|
|
33743
33776
|
const lockRaw = await readFile(lockPath, "utf8").catch((error) => {
|
|
33744
|
-
if (getErrorCode$
|
|
33777
|
+
if (getErrorCode$2(error) === "ENOENT") return "";
|
|
33745
33778
|
throw error;
|
|
33746
33779
|
});
|
|
33747
33780
|
if (!lockRaw) return true;
|
|
33748
33781
|
const pid = resolveLockPid(parseLockMeta(lockRaw));
|
|
33749
33782
|
if (pid && isPidAlive$4(pid)) return false;
|
|
33750
33783
|
const latestLockRaw = await readFile(lockPath, "utf8").catch((error) => {
|
|
33751
|
-
if (getErrorCode$
|
|
33784
|
+
if (getErrorCode$2(error) === "ENOENT") return "";
|
|
33752
33785
|
throw error;
|
|
33753
33786
|
});
|
|
33754
33787
|
if (!latestLockRaw) return true;
|
|
@@ -33759,7 +33792,7 @@ async function recoverStaleSkillsInstallLock(lockPath) {
|
|
|
33759
33792
|
afterPid: resolveLockPid(parseLockMeta(latestLockRaw))
|
|
33760
33793
|
})) return false;
|
|
33761
33794
|
await rm(lockPath, { force: true }).catch((error) => {
|
|
33762
|
-
if (getErrorCode$
|
|
33795
|
+
if (getErrorCode$2(error) === "ENOENT") return;
|
|
33763
33796
|
throw error;
|
|
33764
33797
|
});
|
|
33765
33798
|
return true;
|
|
@@ -33781,10 +33814,10 @@ function isPidAlive$4(pid) {
|
|
|
33781
33814
|
process$1.kill(pid, 0);
|
|
33782
33815
|
return true;
|
|
33783
33816
|
} catch (error) {
|
|
33784
|
-
return getErrorCode$
|
|
33817
|
+
return getErrorCode$2(error) !== "ESRCH";
|
|
33785
33818
|
}
|
|
33786
33819
|
}
|
|
33787
|
-
function getErrorCode$
|
|
33820
|
+
function getErrorCode$2(error) {
|
|
33788
33821
|
if (!error || typeof error !== "object") return;
|
|
33789
33822
|
const code = error.code;
|
|
33790
33823
|
return typeof code === "string" ? code : void 0;
|
|
@@ -37528,9 +37561,23 @@ async function pathExists$5(path) {
|
|
|
37528
37561
|
throw error;
|
|
37529
37562
|
}
|
|
37530
37563
|
}
|
|
37564
|
+
var DaemonServiceWaitTimeoutError = class extends Error {
|
|
37565
|
+
jobDiagnostics;
|
|
37566
|
+
constructor(input) {
|
|
37567
|
+
super(input.message);
|
|
37568
|
+
this.name = "DaemonServiceWaitTimeoutError";
|
|
37569
|
+
this.jobDiagnostics = input.jobDiagnostics ?? null;
|
|
37570
|
+
}
|
|
37571
|
+
};
|
|
37572
|
+
function isDaemonServiceWaitTimeoutError(error) {
|
|
37573
|
+
return error instanceof DaemonServiceWaitTimeoutError;
|
|
37574
|
+
}
|
|
37531
37575
|
function buildSystemServiceWaitTimeoutError(input) {
|
|
37532
37576
|
const detailSuffix = input.details && input.details.trim().length > 0 ? ` Last observed state: ${input.details.trim()}` : "";
|
|
37533
|
-
return
|
|
37577
|
+
return new DaemonServiceWaitTimeoutError({
|
|
37578
|
+
message: `timed out waiting for ${input.controller} service to become ${input.action}.${detailSuffix}`,
|
|
37579
|
+
jobDiagnostics: input.jobDiagnostics ?? null
|
|
37580
|
+
});
|
|
37534
37581
|
}
|
|
37535
37582
|
async function waitForCondition(input) {
|
|
37536
37583
|
const deadline = Date.now() + (input.waitMs ?? SYSTEM_SERVICE_WAIT_MS);
|
|
@@ -38074,10 +38121,14 @@ function buildLaunchdManager(pathInput = {}) {
|
|
|
38074
38121
|
await waitForCondition({
|
|
38075
38122
|
until: async () => (await buildLaunchdManager(pathInput).status()).running,
|
|
38076
38123
|
onTimeout: async () => {
|
|
38124
|
+
const manager = buildLaunchdManager(pathInput);
|
|
38125
|
+
const status = await manager.status();
|
|
38126
|
+
const jobDiagnostics = manager.readJobDiagnostics ? await manager.readJobDiagnostics().catch(() => null) : null;
|
|
38077
38127
|
return buildSystemServiceWaitTimeoutError({
|
|
38078
38128
|
action: "running",
|
|
38079
38129
|
controller: LAUNCHD_CONTROLLER,
|
|
38080
|
-
details: formatManagerStatusDetails(
|
|
38130
|
+
details: formatManagerStatusDetails(status),
|
|
38131
|
+
jobDiagnostics
|
|
38081
38132
|
});
|
|
38082
38133
|
}
|
|
38083
38134
|
});
|
|
@@ -39413,266 +39464,6 @@ function mergeOwnedProcesses(currentLaneProcesses, legacySharedProcesses) {
|
|
|
39413
39464
|
return merged;
|
|
39414
39465
|
}
|
|
39415
39466
|
|
|
39416
|
-
//#endregion
|
|
39417
|
-
//#region src/local-service/lifecycle/daemon-service-anomaly-groups.ts
|
|
39418
|
-
const DAEMON_SERVICE_FULL_ALIGNMENT_ANOMALIES = new Set([
|
|
39419
|
-
"legacy_shared_service_present",
|
|
39420
|
-
"version_outdated",
|
|
39421
|
-
"legacy_detached_runtime",
|
|
39422
|
-
"multiple_active_owners",
|
|
39423
|
-
"runtime_bundle_mismatch",
|
|
39424
|
-
"runtime_contract_missing",
|
|
39425
|
-
"runtime_contract_mismatch",
|
|
39426
|
-
"runtime_contract_unavailable",
|
|
39427
|
-
"bundle_missing",
|
|
39428
|
-
"bundle_content_drift",
|
|
39429
|
-
"bundle_id_drift",
|
|
39430
|
-
"bundle_version_drift",
|
|
39431
|
-
"bundle_lane_drift",
|
|
39432
|
-
"bundle_strategy_legacy",
|
|
39433
|
-
"bundle_provenance_drift",
|
|
39434
|
-
"bundle_path_invalid",
|
|
39435
|
-
"duplicate_owned_processes"
|
|
39436
|
-
]);
|
|
39437
|
-
const DAEMON_SERVICE_AUTO_HEAL_ANOMALIES = new Set([
|
|
39438
|
-
"runtime_stale",
|
|
39439
|
-
"manager_running_without_runtime",
|
|
39440
|
-
"service_manager_path_drift"
|
|
39441
|
-
]);
|
|
39442
|
-
const DAEMON_SERVICE_REPAIR_ANOMALIES = new Set([
|
|
39443
|
-
"runtime_stale",
|
|
39444
|
-
"manager_running_without_runtime",
|
|
39445
|
-
"legacy_detached_runtime",
|
|
39446
|
-
"multiple_active_owners",
|
|
39447
|
-
"runtime_bundle_mismatch",
|
|
39448
|
-
"runtime_contract_missing",
|
|
39449
|
-
"runtime_contract_mismatch",
|
|
39450
|
-
"runtime_contract_unavailable",
|
|
39451
|
-
"bundle_missing",
|
|
39452
|
-
"bundle_content_drift",
|
|
39453
|
-
"bundle_id_drift",
|
|
39454
|
-
"bundle_version_drift",
|
|
39455
|
-
"bundle_lane_drift",
|
|
39456
|
-
"bundle_strategy_legacy",
|
|
39457
|
-
"bundle_provenance_drift",
|
|
39458
|
-
"bundle_path_invalid",
|
|
39459
|
-
"service_manager_path_drift",
|
|
39460
|
-
"duplicate_owned_processes"
|
|
39461
|
-
]);
|
|
39462
|
-
const DAEMON_SERVICE_ARTIFACT_DRIFT_ANOMALIES = new Set([
|
|
39463
|
-
"background_foreground_conflict",
|
|
39464
|
-
"bundle_lane_drift",
|
|
39465
|
-
"bundle_missing",
|
|
39466
|
-
"bundle_content_drift",
|
|
39467
|
-
"bundle_id_drift",
|
|
39468
|
-
"bundle_path_invalid",
|
|
39469
|
-
"bundle_provenance_drift",
|
|
39470
|
-
"bundle_strategy_legacy",
|
|
39471
|
-
"bundle_version_drift",
|
|
39472
|
-
"manager_running_without_runtime",
|
|
39473
|
-
"runtime_bundle_mismatch",
|
|
39474
|
-
"runtime_contract_missing",
|
|
39475
|
-
"runtime_contract_mismatch",
|
|
39476
|
-
"runtime_contract_unavailable",
|
|
39477
|
-
"runtime_stale",
|
|
39478
|
-
"service_manager_path_drift",
|
|
39479
|
-
"version_outdated"
|
|
39480
|
-
]);
|
|
39481
|
-
const DAEMON_SERVICE_RUN_BLOCKING_ANOMALIES = new Set([
|
|
39482
|
-
...[...DAEMON_SERVICE_ARTIFACT_DRIFT_ANOMALIES].filter((code) => code !== "runtime_stale" && code !== "version_outdated" && code !== "bundle_version_drift"),
|
|
39483
|
-
"duplicate_owned_processes",
|
|
39484
|
-
"foreground_background_conflict"
|
|
39485
|
-
]);
|
|
39486
|
-
const DAEMON_SERVICE_WAKEABILITY_HARD_BLOCKER_ANOMALIES = new Set([
|
|
39487
|
-
"duplicate_owned_processes",
|
|
39488
|
-
"manager_running_without_runtime",
|
|
39489
|
-
"multiple_active_owners",
|
|
39490
|
-
"runtime_bundle_mismatch",
|
|
39491
|
-
"runtime_contract_mismatch"
|
|
39492
|
-
]);
|
|
39493
|
-
const DAEMON_SERVICE_WAKEABILITY_CONDITIONAL_ANOMALIES = new Set(["bundle_missing", "bundle_path_invalid"]);
|
|
39494
|
-
const DAEMON_SERVICE_WAKEABILITY_ADVISORY_ANOMALIES = new Set([
|
|
39495
|
-
"bundle_content_drift",
|
|
39496
|
-
"bundle_id_drift",
|
|
39497
|
-
"bundle_lane_drift",
|
|
39498
|
-
"bundle_provenance_drift",
|
|
39499
|
-
"bundle_strategy_legacy",
|
|
39500
|
-
"bundle_version_drift",
|
|
39501
|
-
"runtime_contract_missing",
|
|
39502
|
-
"runtime_contract_unavailable",
|
|
39503
|
-
"service_manager_path_drift",
|
|
39504
|
-
"version_outdated"
|
|
39505
|
-
]);
|
|
39506
|
-
function classifyDaemonServiceWakeability(input) {
|
|
39507
|
-
const anomalyCodes = collectUniqueAnomalyCodes(input.inventory);
|
|
39508
|
-
const executionEvidenceSafe = hasVerifiedRunningDaemonExecutionEvidence({
|
|
39509
|
-
anomalyCodes,
|
|
39510
|
-
inventory: input.inventory
|
|
39511
|
-
});
|
|
39512
|
-
const blockingCodes = [];
|
|
39513
|
-
const advisoryCodes = [];
|
|
39514
|
-
const conditionalCodes = [];
|
|
39515
|
-
for (const code of anomalyCodes) {
|
|
39516
|
-
if (DAEMON_SERVICE_WAKEABILITY_HARD_BLOCKER_ANOMALIES.has(code)) {
|
|
39517
|
-
blockingCodes.push(code);
|
|
39518
|
-
continue;
|
|
39519
|
-
}
|
|
39520
|
-
if (DAEMON_SERVICE_WAKEABILITY_CONDITIONAL_ANOMALIES.has(code)) {
|
|
39521
|
-
conditionalCodes.push(code);
|
|
39522
|
-
if (shouldBlockConditionalWakeabilityAnomaly({
|
|
39523
|
-
code,
|
|
39524
|
-
executionEvidenceSafe
|
|
39525
|
-
})) blockingCodes.push(code);
|
|
39526
|
-
else advisoryCodes.push(code);
|
|
39527
|
-
continue;
|
|
39528
|
-
}
|
|
39529
|
-
if (DAEMON_SERVICE_WAKEABILITY_ADVISORY_ANOMALIES.has(code)) advisoryCodes.push(code);
|
|
39530
|
-
}
|
|
39531
|
-
return {
|
|
39532
|
-
advisoryCodes,
|
|
39533
|
-
blockingCodes,
|
|
39534
|
-
blocksWake: blockingCodes.length > 0,
|
|
39535
|
-
conditionalCodes,
|
|
39536
|
-
executionEvidenceSafe
|
|
39537
|
-
};
|
|
39538
|
-
}
|
|
39539
|
-
function classifyDaemonServiceRunStartability(input) {
|
|
39540
|
-
const anomalyCodes = collectUniqueAnomalyCodes(input.inventory);
|
|
39541
|
-
const executionEvidenceSafe = hasVerifiedRunningDaemonExecutionEvidence({
|
|
39542
|
-
anomalyCodes,
|
|
39543
|
-
inventory: input.inventory
|
|
39544
|
-
});
|
|
39545
|
-
const blockingCodes = anomalyCodes.filter((code) => {
|
|
39546
|
-
if (!DAEMON_SERVICE_RUN_BLOCKING_ANOMALIES.has(code)) return false;
|
|
39547
|
-
return !(executionEvidenceSafe && DAEMON_SERVICE_WAKEABILITY_ADVISORY_ANOMALIES.has(code));
|
|
39548
|
-
});
|
|
39549
|
-
return {
|
|
39550
|
-
blockingCodes,
|
|
39551
|
-
blocksStart: blockingCodes.length > 0
|
|
39552
|
-
};
|
|
39553
|
-
}
|
|
39554
|
-
function shouldBlockConditionalWakeabilityAnomaly(input) {
|
|
39555
|
-
return !input.executionEvidenceSafe;
|
|
39556
|
-
}
|
|
39557
|
-
function hasVerifiedRunningDaemonExecutionEvidence(input) {
|
|
39558
|
-
const inventory = input.inventory;
|
|
39559
|
-
if (inventory?.runtimeStatus.status !== "running") return false;
|
|
39560
|
-
if (inventory.runtimeContractCompatibility?.status !== "compatible") return false;
|
|
39561
|
-
if (!hasUsableServiceContract(inventory.serviceContract)) return false;
|
|
39562
|
-
if (!(inventory.activeBundleEntryPath && inventory.runtimeCommandEntryPath && inventory.runtimeCommandPathExists === true)) return false;
|
|
39563
|
-
return !input.anomalyCodes.some((code) => DAEMON_SERVICE_WAKEABILITY_HARD_BLOCKER_ANOMALIES.has(code));
|
|
39564
|
-
}
|
|
39565
|
-
function hasUsableServiceContract(contract) {
|
|
39566
|
-
return Boolean(contract?.deviceId && contract.gatewayUrl && contract.lane && Number.isFinite(contract.heartbeatMs) && contract.heartbeatMs > 0);
|
|
39567
|
-
}
|
|
39568
|
-
function collectUniqueAnomalyCodes(inventory) {
|
|
39569
|
-
const codes = [];
|
|
39570
|
-
for (const anomaly of inventory?.anomalies ?? []) if (!codes.includes(anomaly.code)) codes.push(anomaly.code);
|
|
39571
|
-
return codes;
|
|
39572
|
-
}
|
|
39573
|
-
|
|
39574
|
-
//#endregion
|
|
39575
|
-
//#region src/system/local-service-install-attention.ts
|
|
39576
|
-
const DAEMON_INSTALL_DECISION_CHOICE = {
|
|
39577
|
-
install: "install",
|
|
39578
|
-
notNow: "not_now"
|
|
39579
|
-
};
|
|
39580
|
-
const DAEMON_INSTALL_COMMAND = "ats service install";
|
|
39581
|
-
const DAEMON_UPGRADE_COMMAND = "ats upgrade";
|
|
39582
|
-
const DAEMON_DECISION_RECOMMENDED_HINT = "Recommended";
|
|
39583
|
-
const DAEMON_INSTALL_DECISION_COPY = {
|
|
39584
|
-
missing: {
|
|
39585
|
-
question: "ATS Service is missing. Install it now?",
|
|
39586
|
-
explanation: "Without it, this computer can't receive local Wake work.",
|
|
39587
|
-
primaryLabel: "Yes, install it for me",
|
|
39588
|
-
deferred: "ATS Service is still missing. Install it later with `ats service install` so this computer can receive local Wake work.",
|
|
39589
|
-
failed: "ATS Service could not be installed. Run `ats service install` so this computer can receive local Wake work."
|
|
39590
|
-
},
|
|
39591
|
-
outdated: {
|
|
39592
|
-
question: "ATS Service update required. Update it now?",
|
|
39593
|
-
explanation: "This service artifact is not compatible with current local Wake execution.",
|
|
39594
|
-
primaryLabel: "Yes, update it for me",
|
|
39595
|
-
deferred: "ATS Service update skipped. Run `ats service update` before using local Wake work.",
|
|
39596
|
-
failed: "ATS Service was not updated. Run `ats service update`."
|
|
39597
|
-
}
|
|
39598
|
-
};
|
|
39599
|
-
function buildDaemonInstallDecisionPromptConfig(input) {
|
|
39600
|
-
const copy = DAEMON_INSTALL_DECISION_COPY[input.kind];
|
|
39601
|
-
const detailLine = input.kind === "outdated" && typeof input.installedVersion === "string" && typeof input.expectedVersion === "string" ? `Installed v${input.installedVersion}, expected v${input.expectedVersion}.` : null;
|
|
39602
|
-
return {
|
|
39603
|
-
message: [
|
|
39604
|
-
copy.question,
|
|
39605
|
-
copy.explanation,
|
|
39606
|
-
detailLine
|
|
39607
|
-
].filter((line) => typeof line === "string" && line.length > 0).join("\n"),
|
|
39608
|
-
initialValue: DAEMON_INSTALL_DECISION_CHOICE.install,
|
|
39609
|
-
options: [{
|
|
39610
|
-
value: DAEMON_INSTALL_DECISION_CHOICE.install,
|
|
39611
|
-
label: copy.primaryLabel,
|
|
39612
|
-
hint: DAEMON_DECISION_RECOMMENDED_HINT
|
|
39613
|
-
}, {
|
|
39614
|
-
value: DAEMON_INSTALL_DECISION_CHOICE.notNow,
|
|
39615
|
-
label: "Not now"
|
|
39616
|
-
}]
|
|
39617
|
-
};
|
|
39618
|
-
}
|
|
39619
|
-
async function promptForDaemonInstallDecision(input) {
|
|
39620
|
-
const choice = await select(buildDaemonInstallDecisionPromptConfig(input));
|
|
39621
|
-
if (isCancel(choice)) return "cancelled";
|
|
39622
|
-
return choice === DAEMON_INSTALL_DECISION_CHOICE.install ? DAEMON_INSTALL_DECISION_CHOICE.install : DAEMON_INSTALL_DECISION_CHOICE.notNow;
|
|
39623
|
-
}
|
|
39624
|
-
async function runDaemonInstallDecisionPrompt(input) {
|
|
39625
|
-
const decision = await promptForDaemonInstallDecision({
|
|
39626
|
-
kind: input.kind,
|
|
39627
|
-
installedVersion: input.installedVersion,
|
|
39628
|
-
expectedVersion: input.expectedVersion
|
|
39629
|
-
});
|
|
39630
|
-
if (decision === DAEMON_INSTALL_DECISION_CHOICE.install) try {
|
|
39631
|
-
await input.installService();
|
|
39632
|
-
return "install";
|
|
39633
|
-
} catch {
|
|
39634
|
-
await input.emitLine(formatDaemonInstallFailedMessage(input.kind));
|
|
39635
|
-
return "failed";
|
|
39636
|
-
}
|
|
39637
|
-
if (decision === "cancelled") return "cancelled";
|
|
39638
|
-
await input.emitLine(formatDaemonInstallDeferredMessage(input.kind));
|
|
39639
|
-
return decision;
|
|
39640
|
-
}
|
|
39641
|
-
function formatDaemonInstallDeferredMessage(kind) {
|
|
39642
|
-
return formatInlineAtsCliCommands(DAEMON_INSTALL_DECISION_COPY[kind].deferred);
|
|
39643
|
-
}
|
|
39644
|
-
function formatDaemonInstallFailedMessage(kind) {
|
|
39645
|
-
return formatInlineAtsCliCommands(DAEMON_INSTALL_DECISION_COPY[kind].failed);
|
|
39646
|
-
}
|
|
39647
|
-
function formatDaemonServiceMissingRecommendation() {
|
|
39648
|
-
return "ATS Service is not installed yet. Install it so this computer can receive local Wake work.";
|
|
39649
|
-
}
|
|
39650
|
-
function formatDaemonServiceMissingStatus() {
|
|
39651
|
-
return "Not installed yet.";
|
|
39652
|
-
}
|
|
39653
|
-
function formatDaemonServiceMissingMeaning() {
|
|
39654
|
-
return "Missing — install ATS Service before this computer can receive local Wake work.";
|
|
39655
|
-
}
|
|
39656
|
-
function formatDaemonServiceMissingAction() {
|
|
39657
|
-
return `Run \`${formatAtsCliCommand(DAEMON_INSTALL_COMMAND)}\` to set it up.`;
|
|
39658
|
-
}
|
|
39659
|
-
function formatDaemonServiceMissingRunStepOne() {
|
|
39660
|
-
return `\`${formatAtsCliCommand(DAEMON_INSTALL_COMMAND)}\``;
|
|
39661
|
-
}
|
|
39662
|
-
function formatDaemonServiceMissingRunStepTwo() {
|
|
39663
|
-
return `\`${formatAtsCliCommand("ats service start")}\``;
|
|
39664
|
-
}
|
|
39665
|
-
function formatDaemonServiceDowngradeBlockedRecommendation(input) {
|
|
39666
|
-
if (input.installedVersion) return `ATS Service is already newer (installed v${input.installedVersion}, current CLI v${input.expectedVersion}). ATS will not downgrade it automatically. Run \`${formatAtsCliCommand(DAEMON_UPGRADE_COMMAND)}\`.`;
|
|
39667
|
-
return `ATS Service is already newer than this CLI. ATS will not downgrade it automatically. Run \`${formatAtsCliCommand(DAEMON_UPGRADE_COMMAND)}\`.`;
|
|
39668
|
-
}
|
|
39669
|
-
function getDaemonDowngradeBlockedTitle() {
|
|
39670
|
-
return "⛔ ATS Service Downgrade Blocked";
|
|
39671
|
-
}
|
|
39672
|
-
function formatDaemonDowngradeBlockedNextStep() {
|
|
39673
|
-
return `Run \`${formatAtsCliCommand(DAEMON_UPGRADE_COMMAND)}\`.`;
|
|
39674
|
-
}
|
|
39675
|
-
|
|
39676
39467
|
//#endregion
|
|
39677
39468
|
//#region src/local-service/lifecycle/daemon-service-repair-guidance.ts
|
|
39678
39469
|
const DAEMON_SERVICE_SETUP_COMMAND = "ats setup";
|
|
@@ -39878,6 +39669,465 @@ function formatDaemonStartStartedNextStep() {
|
|
|
39878
39669
|
return "Use `ats service status` if you want to check the local service link and cloud connection.";
|
|
39879
39670
|
}
|
|
39880
39671
|
|
|
39672
|
+
//#endregion
|
|
39673
|
+
//#region src/commands/service-error-text.ts
|
|
39674
|
+
const ROOT_ERROR_PATTERN$1 = /\s*Try re-running the command as root for richer errors\.?/i;
|
|
39675
|
+
function sanitizeSystemServiceErrorMessage$1(message) {
|
|
39676
|
+
return message.replace(ROOT_ERROR_PATTERN$1, "");
|
|
39677
|
+
}
|
|
39678
|
+
|
|
39679
|
+
//#endregion
|
|
39680
|
+
//#region src/commands/service-start-failure.ts
|
|
39681
|
+
const DAEMON_STARTUP_BLOCKING_ANOMALIES = new Set([
|
|
39682
|
+
"duplicate_owned_processes",
|
|
39683
|
+
"multiple_active_owners",
|
|
39684
|
+
"runtime_bundle_mismatch",
|
|
39685
|
+
"runtime_contract_mismatch"
|
|
39686
|
+
]);
|
|
39687
|
+
var SystemServiceStartupTimeoutError = class extends Error {
|
|
39688
|
+
code = "ats.service.startup_timeout";
|
|
39689
|
+
inventory;
|
|
39690
|
+
managerStatus;
|
|
39691
|
+
runtimeStatus;
|
|
39692
|
+
jobDiagnostics;
|
|
39693
|
+
constructor(input) {
|
|
39694
|
+
super(buildSystemServiceStartupTimeoutMessage(input));
|
|
39695
|
+
this.name = "SystemServiceStartupTimeoutError";
|
|
39696
|
+
this.inventory = input.inventory;
|
|
39697
|
+
this.managerStatus = input.managerStatus;
|
|
39698
|
+
this.runtimeStatus = input.runtimeStatus;
|
|
39699
|
+
this.jobDiagnostics = input.jobDiagnostics ?? null;
|
|
39700
|
+
}
|
|
39701
|
+
};
|
|
39702
|
+
function resolveSystemServiceStartupFailureVerdict(input) {
|
|
39703
|
+
return {
|
|
39704
|
+
controller: input.controller,
|
|
39705
|
+
jobDiagnostics: isSystemServiceStartupTimeoutError(input.error) ? input.error.jobDiagnostics ?? null : null,
|
|
39706
|
+
message: sanitizeSystemServiceErrorMessage$1(toErrorMessage$43(input.error)),
|
|
39707
|
+
detail: input.detail ?? null
|
|
39708
|
+
};
|
|
39709
|
+
}
|
|
39710
|
+
function buildSystemServiceStartupFailureReport(input) {
|
|
39711
|
+
return buildSystemServiceStartupFailureReportFromVerdict(resolveSystemServiceStartupFailureVerdict({
|
|
39712
|
+
controller: input.controller,
|
|
39713
|
+
error: input.error,
|
|
39714
|
+
detail: input.detail
|
|
39715
|
+
}), { autoRepairAttempted: input.autoRepairAttempted });
|
|
39716
|
+
}
|
|
39717
|
+
function buildSystemServiceStartupFailureReportFromVerdict(verdict, options) {
|
|
39718
|
+
const autoRepairAttempted = options?.autoRepairAttempted;
|
|
39719
|
+
const { message, detail, jobDiagnostics } = verdict;
|
|
39720
|
+
const localLogPath = getDaemonSystemServiceLogPath();
|
|
39721
|
+
if (jobDiagnostics && isDaemonServiceJobNeverSpawned(jobDiagnostics)) {
|
|
39722
|
+
const summary = "macOS is blocking the ATS Service background item, so ATS Service never launched.";
|
|
39723
|
+
const card = buildDaemonStartNeedsAttentionCard({
|
|
39724
|
+
summary,
|
|
39725
|
+
nextStep: formatInlineAtsCliCommands("Path A (recommended): open System Settings > General > Login Items & Extensions, enable the ATS background item, then run `ats service start` again. Power users can audit Background Task Management with `sfltool dumpbtm`. Path B: if you would rather not change System Settings, open a separate terminal window, run `ats service start --mode foreground`, and keep that window open — but note ATS Service stops the moment you close that window or restart your Mac, so Wake will not be received."),
|
|
39726
|
+
autoRepairAttempted,
|
|
39727
|
+
detail: detail ?? formatDaemonServiceJobDiagnosticsEvidence(jobDiagnostics)
|
|
39728
|
+
});
|
|
39729
|
+
return {
|
|
39730
|
+
title: card.title,
|
|
39731
|
+
summary,
|
|
39732
|
+
rows: card.rows
|
|
39733
|
+
};
|
|
39734
|
+
}
|
|
39735
|
+
const crashExitCode = jobDiagnostics ? readDaemonServiceJobCrashExitCode(jobDiagnostics) : null;
|
|
39736
|
+
if (jobDiagnostics && crashExitCode !== null) {
|
|
39737
|
+
const summary = `ATS Service launched but keeps exiting (launchd reports ${jobDiagnostics.runs} runs, last exit code ${crashExitCode}).`;
|
|
39738
|
+
const card = buildDaemonStartNeedsAttentionCard({
|
|
39739
|
+
summary,
|
|
39740
|
+
nextStep: formatInlineAtsCliCommands(`Run \`ats service start --mode foreground\` to see the live error. The latest local service log is at \`${localLogPath}\`. If it still fails, run \`ats service repair\`.`),
|
|
39741
|
+
autoRepairAttempted,
|
|
39742
|
+
detail: detail ?? formatDaemonServiceJobDiagnosticsEvidence(jobDiagnostics)
|
|
39743
|
+
});
|
|
39744
|
+
return {
|
|
39745
|
+
title: card.title,
|
|
39746
|
+
summary,
|
|
39747
|
+
rows: card.rows
|
|
39748
|
+
};
|
|
39749
|
+
}
|
|
39750
|
+
if (isLaunchdBootstrapIosError$1(message)) {
|
|
39751
|
+
const card = buildDaemonStartNeedsAttentionCard({
|
|
39752
|
+
summary: "ATS could not finish starting ATS Service on this Mac.",
|
|
39753
|
+
nextStep: formatInlineAtsCliCommands(`Run \`launchctl enable gui/$(id -u)/${getDaemonServiceLaunchdLabel()}\`, then retry with \`ats service start\`. The latest local service log is at \`${localLogPath}\`. If it still fails, run \`ats service repair\`.`),
|
|
39754
|
+
autoRepairAttempted,
|
|
39755
|
+
detail: detail ?? void 0
|
|
39756
|
+
});
|
|
39757
|
+
return {
|
|
39758
|
+
title: card.title,
|
|
39759
|
+
summary: "ATS could not finish starting ATS Service on this Mac.",
|
|
39760
|
+
rows: card.rows
|
|
39761
|
+
};
|
|
39762
|
+
}
|
|
39763
|
+
if (isPermissionOrAuthorizationError(message)) {
|
|
39764
|
+
const card = buildDaemonStartNeedsAttentionCard({
|
|
39765
|
+
summary: "ATS needs local OS permission before it can start ATS Service.",
|
|
39766
|
+
nextStep: formatInlineAtsCliCommands(`Approve the local permission prompt or OS setting, then run \`ats service start\` again. The latest local service log is at \`${localLogPath}\`.`),
|
|
39767
|
+
autoRepairAttempted,
|
|
39768
|
+
detail: detail ?? void 0
|
|
39769
|
+
});
|
|
39770
|
+
return {
|
|
39771
|
+
title: card.title,
|
|
39772
|
+
summary: "ATS needs local OS permission before it can start ATS Service.",
|
|
39773
|
+
rows: card.rows
|
|
39774
|
+
};
|
|
39775
|
+
}
|
|
39776
|
+
const card = buildDaemonStartNeedsAttentionCard({
|
|
39777
|
+
summary: "ATS could not finish starting ATS Service.",
|
|
39778
|
+
nextStep: formatInlineAtsCliCommands(`Run \`ats service start --mode foreground\` to see the live error. The latest local service log is at \`${localLogPath}\`. If it still fails, run \`ats service repair\`.`),
|
|
39779
|
+
autoRepairAttempted,
|
|
39780
|
+
detail: detail ?? void 0
|
|
39781
|
+
});
|
|
39782
|
+
return {
|
|
39783
|
+
title: card.title,
|
|
39784
|
+
summary: `ATS could not finish starting ATS Service (${verdict.controller}).`,
|
|
39785
|
+
rows: card.rows
|
|
39786
|
+
};
|
|
39787
|
+
}
|
|
39788
|
+
function buildSystemServiceStartupFailureMessage(input) {
|
|
39789
|
+
const report = buildSystemServiceStartupFailureReport(input);
|
|
39790
|
+
const rowLines = report.rows.map((row) => formatSystemServiceFailureRow(row)).filter((line) => line.length > 0);
|
|
39791
|
+
return [report.summary, ...rowLines].join("\n");
|
|
39792
|
+
}
|
|
39793
|
+
function buildSystemServiceStartupFailureDiagnostics(input) {
|
|
39794
|
+
const timeoutError = isSystemServiceStartupTimeoutError(input.error) ? input.error : null;
|
|
39795
|
+
return {
|
|
39796
|
+
anomalies: timeoutError?.inventory?.anomalies ?? [],
|
|
39797
|
+
autoRepairAttempted: input.autoRepairAttempted === true,
|
|
39798
|
+
controller: input.controller ?? null,
|
|
39799
|
+
jobDiagnostics: timeoutError?.jobDiagnostics ?? null,
|
|
39800
|
+
launchdLabel: (input.controller ?? null) === "launchd" ? getDaemonServiceLaunchdLabel() : null,
|
|
39801
|
+
lifecycleJournalPath: daemonLifecycleJournalPath(),
|
|
39802
|
+
managerStatus: timeoutError?.managerStatus ?? null,
|
|
39803
|
+
nextSteps: [formatAtsCliCommand("ats service start --mode foreground"), formatAtsCliCommand("ats service repair")],
|
|
39804
|
+
recovery: input.recovery,
|
|
39805
|
+
runtimeStatus: timeoutError?.runtimeStatus ?? null,
|
|
39806
|
+
serviceLogPath: getDaemonSystemServiceLogPath()
|
|
39807
|
+
};
|
|
39808
|
+
}
|
|
39809
|
+
function buildSystemServiceStartupTimeoutMessage(input) {
|
|
39810
|
+
const base = `ATS Service failed to reach a running local service state in time. runtime=${input.runtimeStatus?.status ?? "unknown"}, reason=${input.runtimeStatus?.reason || "unknown"}, managerRunning=${String(input.managerStatus?.running ?? false)}, anomalies=${input.inventory?.anomalies.map((anomaly) => anomaly.code).join(",") || "unknown"}`;
|
|
39811
|
+
if (!input.jobDiagnostics) return base;
|
|
39812
|
+
return `${base}; ${formatDaemonServiceJobDiagnosticsEvidence(input.jobDiagnostics)}`;
|
|
39813
|
+
}
|
|
39814
|
+
function isSystemServiceStartupTimeoutError(error) {
|
|
39815
|
+
return error instanceof SystemServiceStartupTimeoutError || typeof error === "object" && error !== null && "code" in error && error.code === "ats.service.startup_timeout";
|
|
39816
|
+
}
|
|
39817
|
+
function formatSystemServiceFailureRow(row) {
|
|
39818
|
+
const label = row.label.trim();
|
|
39819
|
+
const value = formatAtsCliTextBlock(row.value).trim();
|
|
39820
|
+
if (label.length === 0 && value.length === 0) return "";
|
|
39821
|
+
if (value.length === 0) return `${row.label}:`;
|
|
39822
|
+
if (label.length === 0) return row.value;
|
|
39823
|
+
return `${row.label}: ${row.value}`;
|
|
39824
|
+
}
|
|
39825
|
+
function isLaunchdBootstrapIosError$1(message) {
|
|
39826
|
+
const normalized = message.toLowerCase();
|
|
39827
|
+
return normalized.includes("bootstrap failed") && normalized.includes("input/output error");
|
|
39828
|
+
}
|
|
39829
|
+
function isPermissionOrAuthorizationError(message) {
|
|
39830
|
+
const normalized = message.toLowerCase();
|
|
39831
|
+
return normalized.includes("permission") || normalized.includes("operation not permitted") || normalized.includes("access is denied") || normalized.includes("requires admin") || normalized.includes("elevation") || normalized.includes("access denied") || normalized.includes("not authorized");
|
|
39832
|
+
}
|
|
39833
|
+
function isDaemonInventoryRunningAndStartReady(inventory) {
|
|
39834
|
+
if (inventory.runtimeStatus.status !== "running") return false;
|
|
39835
|
+
if (inventory.runtimeStatus.mode !== "background") return false;
|
|
39836
|
+
if (inventory.runtimeStatus.managedBySystemService !== true) return false;
|
|
39837
|
+
return !inventory.anomalies.some((anomaly) => DAEMON_STARTUP_BLOCKING_ANOMALIES.has(anomaly.code));
|
|
39838
|
+
}
|
|
39839
|
+
async function waitForSystemServiceStartup(input) {
|
|
39840
|
+
const deadlineMs = Date.now() + input.waitMs;
|
|
39841
|
+
while (Date.now() < deadlineMs) {
|
|
39842
|
+
const inventory = await inspectDaemonServiceInventory({
|
|
39843
|
+
expectedVersion: input.expectedVersion,
|
|
39844
|
+
intendedMode: "background",
|
|
39845
|
+
intent: "run_background"
|
|
39846
|
+
}).catch(() => null);
|
|
39847
|
+
if (inventory && isDaemonInventoryRunningAndStartReady(inventory)) return {
|
|
39848
|
+
state: "running",
|
|
39849
|
+
runtimeStatus: inventory.runtimeStatus
|
|
39850
|
+
};
|
|
39851
|
+
await sleep$1(input.pollMs);
|
|
39852
|
+
}
|
|
39853
|
+
const finalInventory = await inspectDaemonServiceInventory({
|
|
39854
|
+
expectedVersion: input.expectedVersion,
|
|
39855
|
+
intendedMode: "background",
|
|
39856
|
+
intent: "run_background"
|
|
39857
|
+
}).catch(() => null);
|
|
39858
|
+
if (finalInventory && isDaemonInventoryRunningAndStartReady(finalInventory)) return {
|
|
39859
|
+
state: "running",
|
|
39860
|
+
runtimeStatus: finalInventory.runtimeStatus
|
|
39861
|
+
};
|
|
39862
|
+
const finalRuntimeStatus = await readCurrentObservedDaemonRuntimeStatus().catch(() => null);
|
|
39863
|
+
throw new SystemServiceStartupTimeoutError({
|
|
39864
|
+
inventory: finalInventory,
|
|
39865
|
+
managerStatus: await input.manager.status().catch(() => null),
|
|
39866
|
+
runtimeStatus: finalRuntimeStatus,
|
|
39867
|
+
jobDiagnostics: await input.manager.readJobDiagnostics?.().catch(() => null) ?? null
|
|
39868
|
+
});
|
|
39869
|
+
}
|
|
39870
|
+
|
|
39871
|
+
//#endregion
|
|
39872
|
+
//#region src/local-service/lifecycle/daemon-service-anomaly-groups.ts
|
|
39873
|
+
const DAEMON_SERVICE_FULL_ALIGNMENT_ANOMALIES = new Set([
|
|
39874
|
+
"legacy_shared_service_present",
|
|
39875
|
+
"version_outdated",
|
|
39876
|
+
"legacy_detached_runtime",
|
|
39877
|
+
"multiple_active_owners",
|
|
39878
|
+
"runtime_bundle_mismatch",
|
|
39879
|
+
"runtime_contract_missing",
|
|
39880
|
+
"runtime_contract_mismatch",
|
|
39881
|
+
"runtime_contract_unavailable",
|
|
39882
|
+
"bundle_missing",
|
|
39883
|
+
"bundle_content_drift",
|
|
39884
|
+
"bundle_id_drift",
|
|
39885
|
+
"bundle_version_drift",
|
|
39886
|
+
"bundle_lane_drift",
|
|
39887
|
+
"bundle_strategy_legacy",
|
|
39888
|
+
"bundle_provenance_drift",
|
|
39889
|
+
"bundle_path_invalid",
|
|
39890
|
+
"duplicate_owned_processes"
|
|
39891
|
+
]);
|
|
39892
|
+
const DAEMON_SERVICE_AUTO_HEAL_ANOMALIES = new Set([
|
|
39893
|
+
"runtime_stale",
|
|
39894
|
+
"manager_running_without_runtime",
|
|
39895
|
+
"service_manager_path_drift"
|
|
39896
|
+
]);
|
|
39897
|
+
const DAEMON_SERVICE_REPAIR_ANOMALIES = new Set([
|
|
39898
|
+
"runtime_stale",
|
|
39899
|
+
"manager_running_without_runtime",
|
|
39900
|
+
"legacy_detached_runtime",
|
|
39901
|
+
"multiple_active_owners",
|
|
39902
|
+
"runtime_bundle_mismatch",
|
|
39903
|
+
"runtime_contract_missing",
|
|
39904
|
+
"runtime_contract_mismatch",
|
|
39905
|
+
"runtime_contract_unavailable",
|
|
39906
|
+
"bundle_missing",
|
|
39907
|
+
"bundle_content_drift",
|
|
39908
|
+
"bundle_id_drift",
|
|
39909
|
+
"bundle_version_drift",
|
|
39910
|
+
"bundle_lane_drift",
|
|
39911
|
+
"bundle_strategy_legacy",
|
|
39912
|
+
"bundle_provenance_drift",
|
|
39913
|
+
"bundle_path_invalid",
|
|
39914
|
+
"service_manager_path_drift",
|
|
39915
|
+
"duplicate_owned_processes"
|
|
39916
|
+
]);
|
|
39917
|
+
const DAEMON_SERVICE_ARTIFACT_DRIFT_ANOMALIES = new Set([
|
|
39918
|
+
"background_foreground_conflict",
|
|
39919
|
+
"bundle_lane_drift",
|
|
39920
|
+
"bundle_missing",
|
|
39921
|
+
"bundle_content_drift",
|
|
39922
|
+
"bundle_id_drift",
|
|
39923
|
+
"bundle_path_invalid",
|
|
39924
|
+
"bundle_provenance_drift",
|
|
39925
|
+
"bundle_strategy_legacy",
|
|
39926
|
+
"bundle_version_drift",
|
|
39927
|
+
"manager_running_without_runtime",
|
|
39928
|
+
"runtime_bundle_mismatch",
|
|
39929
|
+
"runtime_contract_missing",
|
|
39930
|
+
"runtime_contract_mismatch",
|
|
39931
|
+
"runtime_contract_unavailable",
|
|
39932
|
+
"runtime_stale",
|
|
39933
|
+
"service_manager_path_drift",
|
|
39934
|
+
"version_outdated"
|
|
39935
|
+
]);
|
|
39936
|
+
const DAEMON_SERVICE_RUN_BLOCKING_ANOMALIES = new Set([
|
|
39937
|
+
...[...DAEMON_SERVICE_ARTIFACT_DRIFT_ANOMALIES].filter((code) => code !== "runtime_stale" && code !== "version_outdated" && code !== "bundle_version_drift"),
|
|
39938
|
+
"duplicate_owned_processes",
|
|
39939
|
+
"foreground_background_conflict"
|
|
39940
|
+
]);
|
|
39941
|
+
const DAEMON_SERVICE_WAKEABILITY_HARD_BLOCKER_ANOMALIES = new Set([
|
|
39942
|
+
"duplicate_owned_processes",
|
|
39943
|
+
"manager_running_without_runtime",
|
|
39944
|
+
"multiple_active_owners",
|
|
39945
|
+
"runtime_bundle_mismatch",
|
|
39946
|
+
"runtime_contract_mismatch"
|
|
39947
|
+
]);
|
|
39948
|
+
const DAEMON_SERVICE_WAKEABILITY_CONDITIONAL_ANOMALIES = new Set(["bundle_missing", "bundle_path_invalid"]);
|
|
39949
|
+
const DAEMON_SERVICE_WAKEABILITY_ADVISORY_ANOMALIES = new Set([
|
|
39950
|
+
"bundle_content_drift",
|
|
39951
|
+
"bundle_id_drift",
|
|
39952
|
+
"bundle_lane_drift",
|
|
39953
|
+
"bundle_provenance_drift",
|
|
39954
|
+
"bundle_strategy_legacy",
|
|
39955
|
+
"bundle_version_drift",
|
|
39956
|
+
"runtime_contract_missing",
|
|
39957
|
+
"runtime_contract_unavailable",
|
|
39958
|
+
"service_manager_path_drift",
|
|
39959
|
+
"version_outdated"
|
|
39960
|
+
]);
|
|
39961
|
+
function classifyDaemonServiceWakeability(input) {
|
|
39962
|
+
const anomalyCodes = collectUniqueAnomalyCodes(input.inventory);
|
|
39963
|
+
const executionEvidenceSafe = hasVerifiedRunningDaemonExecutionEvidence({
|
|
39964
|
+
anomalyCodes,
|
|
39965
|
+
inventory: input.inventory
|
|
39966
|
+
});
|
|
39967
|
+
const blockingCodes = [];
|
|
39968
|
+
const advisoryCodes = [];
|
|
39969
|
+
const conditionalCodes = [];
|
|
39970
|
+
for (const code of anomalyCodes) {
|
|
39971
|
+
if (DAEMON_SERVICE_WAKEABILITY_HARD_BLOCKER_ANOMALIES.has(code)) {
|
|
39972
|
+
blockingCodes.push(code);
|
|
39973
|
+
continue;
|
|
39974
|
+
}
|
|
39975
|
+
if (DAEMON_SERVICE_WAKEABILITY_CONDITIONAL_ANOMALIES.has(code)) {
|
|
39976
|
+
conditionalCodes.push(code);
|
|
39977
|
+
if (shouldBlockConditionalWakeabilityAnomaly({
|
|
39978
|
+
code,
|
|
39979
|
+
executionEvidenceSafe
|
|
39980
|
+
})) blockingCodes.push(code);
|
|
39981
|
+
else advisoryCodes.push(code);
|
|
39982
|
+
continue;
|
|
39983
|
+
}
|
|
39984
|
+
if (DAEMON_SERVICE_WAKEABILITY_ADVISORY_ANOMALIES.has(code)) advisoryCodes.push(code);
|
|
39985
|
+
}
|
|
39986
|
+
return {
|
|
39987
|
+
advisoryCodes,
|
|
39988
|
+
blockingCodes,
|
|
39989
|
+
blocksWake: blockingCodes.length > 0,
|
|
39990
|
+
conditionalCodes,
|
|
39991
|
+
executionEvidenceSafe
|
|
39992
|
+
};
|
|
39993
|
+
}
|
|
39994
|
+
function classifyDaemonServiceRunStartability(input) {
|
|
39995
|
+
const anomalyCodes = collectUniqueAnomalyCodes(input.inventory);
|
|
39996
|
+
const executionEvidenceSafe = hasVerifiedRunningDaemonExecutionEvidence({
|
|
39997
|
+
anomalyCodes,
|
|
39998
|
+
inventory: input.inventory
|
|
39999
|
+
});
|
|
40000
|
+
const blockingCodes = anomalyCodes.filter((code) => {
|
|
40001
|
+
if (!DAEMON_SERVICE_RUN_BLOCKING_ANOMALIES.has(code)) return false;
|
|
40002
|
+
return !(executionEvidenceSafe && DAEMON_SERVICE_WAKEABILITY_ADVISORY_ANOMALIES.has(code));
|
|
40003
|
+
});
|
|
40004
|
+
return {
|
|
40005
|
+
blockingCodes,
|
|
40006
|
+
blocksStart: blockingCodes.length > 0
|
|
40007
|
+
};
|
|
40008
|
+
}
|
|
40009
|
+
function shouldBlockConditionalWakeabilityAnomaly(input) {
|
|
40010
|
+
return !input.executionEvidenceSafe;
|
|
40011
|
+
}
|
|
40012
|
+
function hasVerifiedRunningDaemonExecutionEvidence(input) {
|
|
40013
|
+
const inventory = input.inventory;
|
|
40014
|
+
if (inventory?.runtimeStatus.status !== "running") return false;
|
|
40015
|
+
if (inventory.runtimeContractCompatibility?.status !== "compatible") return false;
|
|
40016
|
+
if (!hasUsableServiceContract(inventory.serviceContract)) return false;
|
|
40017
|
+
if (!(inventory.activeBundleEntryPath && inventory.runtimeCommandEntryPath && inventory.runtimeCommandPathExists === true)) return false;
|
|
40018
|
+
return !input.anomalyCodes.some((code) => DAEMON_SERVICE_WAKEABILITY_HARD_BLOCKER_ANOMALIES.has(code));
|
|
40019
|
+
}
|
|
40020
|
+
function hasUsableServiceContract(contract) {
|
|
40021
|
+
return Boolean(contract?.deviceId && contract.gatewayUrl && contract.lane && Number.isFinite(contract.heartbeatMs) && contract.heartbeatMs > 0);
|
|
40022
|
+
}
|
|
40023
|
+
function collectUniqueAnomalyCodes(inventory) {
|
|
40024
|
+
const codes = [];
|
|
40025
|
+
for (const anomaly of inventory?.anomalies ?? []) if (!codes.includes(anomaly.code)) codes.push(anomaly.code);
|
|
40026
|
+
return codes;
|
|
40027
|
+
}
|
|
40028
|
+
|
|
40029
|
+
//#endregion
|
|
40030
|
+
//#region src/system/local-service-install-attention.ts
|
|
40031
|
+
const DAEMON_INSTALL_DECISION_CHOICE = {
|
|
40032
|
+
install: "install",
|
|
40033
|
+
notNow: "not_now"
|
|
40034
|
+
};
|
|
40035
|
+
const DAEMON_INSTALL_COMMAND = "ats service install";
|
|
40036
|
+
const DAEMON_UPGRADE_COMMAND = "ats upgrade";
|
|
40037
|
+
const DAEMON_DECISION_RECOMMENDED_HINT = "Recommended";
|
|
40038
|
+
const DAEMON_INSTALL_DECISION_COPY = {
|
|
40039
|
+
missing: {
|
|
40040
|
+
question: "ATS Service is missing. Install it now?",
|
|
40041
|
+
explanation: "Without it, this computer can't receive local Wake work.",
|
|
40042
|
+
primaryLabel: "Yes, install it for me",
|
|
40043
|
+
deferred: "ATS Service is still missing. Install it later with `ats service install` so this computer can receive local Wake work.",
|
|
40044
|
+
failed: "ATS Service could not be installed. Run `ats service install` so this computer can receive local Wake work."
|
|
40045
|
+
},
|
|
40046
|
+
outdated: {
|
|
40047
|
+
question: "ATS Service update required. Update it now?",
|
|
40048
|
+
explanation: "This service artifact is not compatible with current local Wake execution.",
|
|
40049
|
+
primaryLabel: "Yes, update it for me",
|
|
40050
|
+
deferred: "ATS Service update skipped. Run `ats service update` before using local Wake work.",
|
|
40051
|
+
failed: "ATS Service was not updated. Run `ats service update`."
|
|
40052
|
+
}
|
|
40053
|
+
};
|
|
40054
|
+
function buildDaemonInstallDecisionPromptConfig(input) {
|
|
40055
|
+
const copy = DAEMON_INSTALL_DECISION_COPY[input.kind];
|
|
40056
|
+
const detailLine = input.kind === "outdated" && typeof input.installedVersion === "string" && typeof input.expectedVersion === "string" ? `Installed v${input.installedVersion}, expected v${input.expectedVersion}.` : null;
|
|
40057
|
+
return {
|
|
40058
|
+
message: [
|
|
40059
|
+
copy.question,
|
|
40060
|
+
copy.explanation,
|
|
40061
|
+
detailLine
|
|
40062
|
+
].filter((line) => typeof line === "string" && line.length > 0).join("\n"),
|
|
40063
|
+
initialValue: DAEMON_INSTALL_DECISION_CHOICE.install,
|
|
40064
|
+
options: [{
|
|
40065
|
+
value: DAEMON_INSTALL_DECISION_CHOICE.install,
|
|
40066
|
+
label: copy.primaryLabel,
|
|
40067
|
+
hint: DAEMON_DECISION_RECOMMENDED_HINT
|
|
40068
|
+
}, {
|
|
40069
|
+
value: DAEMON_INSTALL_DECISION_CHOICE.notNow,
|
|
40070
|
+
label: "Not now"
|
|
40071
|
+
}]
|
|
40072
|
+
};
|
|
40073
|
+
}
|
|
40074
|
+
async function promptForDaemonInstallDecision(input) {
|
|
40075
|
+
const choice = await select(buildDaemonInstallDecisionPromptConfig(input));
|
|
40076
|
+
if (isCancel(choice)) return "cancelled";
|
|
40077
|
+
return choice === DAEMON_INSTALL_DECISION_CHOICE.install ? DAEMON_INSTALL_DECISION_CHOICE.install : DAEMON_INSTALL_DECISION_CHOICE.notNow;
|
|
40078
|
+
}
|
|
40079
|
+
async function runDaemonInstallDecisionPrompt(input) {
|
|
40080
|
+
const decision = await promptForDaemonInstallDecision({
|
|
40081
|
+
kind: input.kind,
|
|
40082
|
+
installedVersion: input.installedVersion,
|
|
40083
|
+
expectedVersion: input.expectedVersion
|
|
40084
|
+
});
|
|
40085
|
+
if (decision === DAEMON_INSTALL_DECISION_CHOICE.install) try {
|
|
40086
|
+
await input.installService();
|
|
40087
|
+
return "install";
|
|
40088
|
+
} catch {
|
|
40089
|
+
await input.emitLine(formatDaemonInstallFailedMessage(input.kind));
|
|
40090
|
+
return "failed";
|
|
40091
|
+
}
|
|
40092
|
+
if (decision === "cancelled") return "cancelled";
|
|
40093
|
+
await input.emitLine(formatDaemonInstallDeferredMessage(input.kind));
|
|
40094
|
+
return decision;
|
|
40095
|
+
}
|
|
40096
|
+
function formatDaemonInstallDeferredMessage(kind) {
|
|
40097
|
+
return formatInlineAtsCliCommands(DAEMON_INSTALL_DECISION_COPY[kind].deferred);
|
|
40098
|
+
}
|
|
40099
|
+
function formatDaemonInstallFailedMessage(kind) {
|
|
40100
|
+
return formatInlineAtsCliCommands(DAEMON_INSTALL_DECISION_COPY[kind].failed);
|
|
40101
|
+
}
|
|
40102
|
+
function formatDaemonServiceMissingRecommendation() {
|
|
40103
|
+
return "ATS Service is not installed yet. Install it so this computer can receive local Wake work.";
|
|
40104
|
+
}
|
|
40105
|
+
function formatDaemonServiceMissingStatus() {
|
|
40106
|
+
return "Not installed yet.";
|
|
40107
|
+
}
|
|
40108
|
+
function formatDaemonServiceMissingMeaning() {
|
|
40109
|
+
return "Missing — install ATS Service before this computer can receive local Wake work.";
|
|
40110
|
+
}
|
|
40111
|
+
function formatDaemonServiceMissingAction() {
|
|
40112
|
+
return `Run \`${formatAtsCliCommand(DAEMON_INSTALL_COMMAND)}\` to set it up.`;
|
|
40113
|
+
}
|
|
40114
|
+
function formatDaemonServiceMissingRunStepOne() {
|
|
40115
|
+
return `\`${formatAtsCliCommand(DAEMON_INSTALL_COMMAND)}\``;
|
|
40116
|
+
}
|
|
40117
|
+
function formatDaemonServiceMissingRunStepTwo() {
|
|
40118
|
+
return `\`${formatAtsCliCommand("ats service start")}\``;
|
|
40119
|
+
}
|
|
40120
|
+
function formatDaemonServiceDowngradeBlockedRecommendation(input) {
|
|
40121
|
+
if (input.installedVersion) return `ATS Service is already newer (installed v${input.installedVersion}, current CLI v${input.expectedVersion}). ATS will not downgrade it automatically. Run \`${formatAtsCliCommand(DAEMON_UPGRADE_COMMAND)}\`.`;
|
|
40122
|
+
return `ATS Service is already newer than this CLI. ATS will not downgrade it automatically. Run \`${formatAtsCliCommand(DAEMON_UPGRADE_COMMAND)}\`.`;
|
|
40123
|
+
}
|
|
40124
|
+
function getDaemonDowngradeBlockedTitle() {
|
|
40125
|
+
return "⛔ ATS Service Downgrade Blocked";
|
|
40126
|
+
}
|
|
40127
|
+
function formatDaemonDowngradeBlockedNextStep() {
|
|
40128
|
+
return `Run \`${formatAtsCliCommand(DAEMON_UPGRADE_COMMAND)}\`.`;
|
|
40129
|
+
}
|
|
40130
|
+
|
|
39881
40131
|
//#endregion
|
|
39882
40132
|
//#region src/system/local-service-participation-gate.ts
|
|
39883
40133
|
function shouldRequireDaemonServiceParticipation(localDemand) {
|
|
@@ -40195,12 +40445,26 @@ async function runDaemonServiceParticipationRefresh(input) {
|
|
|
40195
40445
|
}
|
|
40196
40446
|
return startMapped;
|
|
40197
40447
|
}
|
|
40448
|
+
if (!refreshOutcome.ok && (refreshOutcome.result === "start_failed" || refreshOutcome.result === "start_blocked") && refreshOutcome.startFailureVerdict?.jobDiagnostics) {
|
|
40449
|
+
const report = buildSystemServiceStartupFailureReportFromVerdict(refreshOutcome.startFailureVerdict, { autoRepairAttempted: true });
|
|
40450
|
+
renderInfoCard({
|
|
40451
|
+
presenter: input.input.presenter,
|
|
40452
|
+
title: report.title,
|
|
40453
|
+
codePrefix: `${input.codePrefix}.failed`,
|
|
40454
|
+
rows: report.rows
|
|
40455
|
+
});
|
|
40456
|
+
return {
|
|
40457
|
+
errorMessage: report.summary,
|
|
40458
|
+
status: "needs_attention"
|
|
40459
|
+
};
|
|
40460
|
+
}
|
|
40198
40461
|
if (!(refreshOutcome.ok && refreshOutcome.result === "completed" && refreshOutcome.serviceState === "running")) throw new Error(`ATS Service refresh did not complete: ${refreshOutcome.result}`);
|
|
40199
40462
|
} catch (error) {
|
|
40200
40463
|
renderDaemonStartNeedsAttention({
|
|
40201
40464
|
presenter: input.input.presenter,
|
|
40202
40465
|
codePrefix: input.codePrefix,
|
|
40203
|
-
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`."
|
|
40466
|
+
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`.",
|
|
40467
|
+
autoRepairAttempted: true
|
|
40204
40468
|
});
|
|
40205
40469
|
return {
|
|
40206
40470
|
errorMessage: toErrorMessage$30(error),
|
|
@@ -40321,7 +40585,12 @@ function renderDaemonStartDeferred(input) {
|
|
|
40321
40585
|
});
|
|
40322
40586
|
}
|
|
40323
40587
|
function renderDaemonStartNeedsAttention(input) {
|
|
40324
|
-
const card = buildDaemonStartNeedsAttentionCard({
|
|
40588
|
+
const card = buildDaemonStartNeedsAttentionCard({
|
|
40589
|
+
summary: input.summary,
|
|
40590
|
+
...input.nextStep ? { nextStep: input.nextStep } : {},
|
|
40591
|
+
...input.detail ? { detail: input.detail } : {},
|
|
40592
|
+
...input.autoRepairAttempted ? { autoRepairAttempted: input.autoRepairAttempted } : {}
|
|
40593
|
+
});
|
|
40325
40594
|
renderInfoCard({
|
|
40326
40595
|
presenter: input.presenter,
|
|
40327
40596
|
title: card.title,
|
|
@@ -40450,8 +40719,8 @@ function resolveLocalComponentsSetupAction(input) {
|
|
|
40450
40719
|
return "none";
|
|
40451
40720
|
}
|
|
40452
40721
|
function resolveCliComponentStatus(input) {
|
|
40453
|
-
const latestPackageVersion = normalizeOptionalString$
|
|
40454
|
-
const requiredCommandContractVersion = normalizeOptionalString$
|
|
40722
|
+
const latestPackageVersion = normalizeOptionalString$18(input.latestPackageVersion);
|
|
40723
|
+
const requiredCommandContractVersion = normalizeOptionalString$18(input.requiredCommandContractVersion);
|
|
40455
40724
|
const reasonCodes = [];
|
|
40456
40725
|
let status = "ok";
|
|
40457
40726
|
if (requiredCommandContractVersion && requiredCommandContractVersion !== ATS_CLI_COMMAND_CONTRACT_VERSION) {
|
|
@@ -40573,7 +40842,7 @@ function resolveInstalledServiceVersion(participation) {
|
|
|
40573
40842
|
default: return null;
|
|
40574
40843
|
}
|
|
40575
40844
|
}
|
|
40576
|
-
function normalizeOptionalString$
|
|
40845
|
+
function normalizeOptionalString$18(value) {
|
|
40577
40846
|
const normalized = String(value ?? "").trim();
|
|
40578
40847
|
return normalized.length > 0 ? normalized : null;
|
|
40579
40848
|
}
|
|
@@ -40615,14 +40884,14 @@ function emitDaemonDispatchJournalEvent(input) {
|
|
|
40615
40884
|
lane: resolveAtsEnvPreset(input.pathInput),
|
|
40616
40885
|
pid: process$1.pid,
|
|
40617
40886
|
sessionId: resolveCliContextId(),
|
|
40618
|
-
attemptId: normalizeOptionalString$
|
|
40887
|
+
attemptId: normalizeOptionalString$17(input.attemptId),
|
|
40619
40888
|
connectionGeneration: normalizeOptionalInteger(input.connectionGeneration),
|
|
40620
|
-
daemonSessionId: normalizeOptionalString$
|
|
40889
|
+
daemonSessionId: normalizeOptionalString$17(input.daemonSessionId),
|
|
40621
40890
|
dispatchId: input.dispatchId,
|
|
40622
40891
|
leaseEpoch: normalizeOptionalInteger(input.leaseEpoch),
|
|
40623
|
-
profileId: normalizeOptionalString$
|
|
40624
|
-
result: normalizeOptionalString$
|
|
40625
|
-
taskId: normalizeOptionalString$
|
|
40892
|
+
profileId: normalizeOptionalString$17(input.profileId),
|
|
40893
|
+
result: normalizeOptionalString$17(input.result),
|
|
40894
|
+
taskId: normalizeOptionalString$17(input.taskId),
|
|
40626
40895
|
...input.metadata ? { metadata: input.metadata } : {}
|
|
40627
40896
|
};
|
|
40628
40897
|
if (!isDaemonDispatchJournalEvent(event)) {
|
|
@@ -40638,7 +40907,7 @@ function emitDaemonDispatchJournalEvent(input) {
|
|
|
40638
40907
|
}
|
|
40639
40908
|
}
|
|
40640
40909
|
function readRecentDaemonDispatchJournalEvents(input) {
|
|
40641
|
-
const normalizedDispatchId = normalizeOptionalString$
|
|
40910
|
+
const normalizedDispatchId = normalizeOptionalString$17(input.dispatchId);
|
|
40642
40911
|
if (!normalizedDispatchId) return [];
|
|
40643
40912
|
const limit = Math.max(1, Math.min(100, input.limit ?? 20));
|
|
40644
40913
|
const journalPath = daemonDispatchJournalPath(input.pathInput);
|
|
@@ -40663,7 +40932,7 @@ function isDaemonDispatchJournalEvent(value) {
|
|
|
40663
40932
|
const candidate = value;
|
|
40664
40933
|
return candidate.schema === "ats-daemon-dispatch-event-v1" && candidate.v === 1 && DAEMON_DISPATCH_EVENT_TYPES.includes(candidate.type) && typeof candidate.timestamp === "string" && candidate.timestamp.length > 0 && typeof candidate.lane === "string" && candidate.lane.length > 0 && typeof candidate.pid === "number" && Number.isInteger(candidate.pid) && candidate.pid > 0 && (candidate.sessionId === null || typeof candidate.sessionId === "string" && candidate.sessionId.length > 0) && (candidate.attemptId === null || typeof candidate.attemptId === "string" && candidate.attemptId.length > 0) && (candidate.connectionGeneration === null || typeof candidate.connectionGeneration === "number" && Number.isInteger(candidate.connectionGeneration)) && (candidate.daemonSessionId === null || typeof candidate.daemonSessionId === "string" && candidate.daemonSessionId.length > 0) && typeof candidate.dispatchId === "string" && candidate.dispatchId.length > 0 && (candidate.leaseEpoch === null || typeof candidate.leaseEpoch === "number" && Number.isInteger(candidate.leaseEpoch)) && (candidate.profileId === null || typeof candidate.profileId === "string" && candidate.profileId.length > 0) && (candidate.result === null || typeof candidate.result === "string" && candidate.result.length > 0) && (candidate.taskId === null || typeof candidate.taskId === "string" && candidate.taskId.length > 0);
|
|
40665
40934
|
}
|
|
40666
|
-
function normalizeOptionalString$
|
|
40935
|
+
function normalizeOptionalString$17(value) {
|
|
40667
40936
|
const normalized = String(value ?? "").trim();
|
|
40668
40937
|
return normalized.length > 0 ? normalized : null;
|
|
40669
40938
|
}
|
|
@@ -41177,6 +41446,53 @@ function summarizeSubmissions(submissions) {
|
|
|
41177
41446
|
};
|
|
41178
41447
|
}
|
|
41179
41448
|
|
|
41449
|
+
//#endregion
|
|
41450
|
+
//#region src/local-service/carrier/daemon-stream-keepalive.ts
|
|
41451
|
+
function createDaemonStreamKeepalive(input) {
|
|
41452
|
+
const intervalMs = input.intervalMs ?? DAEMON_STREAM_KEEPALIVE_INTERVAL_MS;
|
|
41453
|
+
const pongTimeoutMs = input.pongTimeoutMs ?? DAEMON_STREAM_KEEPALIVE_PONG_TIMEOUT_MS;
|
|
41454
|
+
let pingTimer = null;
|
|
41455
|
+
let pongDeadlineTimer = null;
|
|
41456
|
+
const clearPongDeadline = () => {
|
|
41457
|
+
if (!pongDeadlineTimer) return;
|
|
41458
|
+
clearTimeout(pongDeadlineTimer);
|
|
41459
|
+
pongDeadlineTimer = null;
|
|
41460
|
+
};
|
|
41461
|
+
const stop = () => {
|
|
41462
|
+
if (pingTimer) {
|
|
41463
|
+
clearInterval(pingTimer);
|
|
41464
|
+
pingTimer = null;
|
|
41465
|
+
}
|
|
41466
|
+
clearPongDeadline();
|
|
41467
|
+
};
|
|
41468
|
+
const armPongDeadline = () => {
|
|
41469
|
+
clearPongDeadline();
|
|
41470
|
+
pongDeadlineTimer = setTimeout(() => {
|
|
41471
|
+
pongDeadlineTimer = null;
|
|
41472
|
+
stop();
|
|
41473
|
+
input.onPongTimeout();
|
|
41474
|
+
}, pongTimeoutMs);
|
|
41475
|
+
};
|
|
41476
|
+
return {
|
|
41477
|
+
observePong() {
|
|
41478
|
+
clearPongDeadline();
|
|
41479
|
+
},
|
|
41480
|
+
start() {
|
|
41481
|
+
stop();
|
|
41482
|
+
pingTimer = setInterval(() => {
|
|
41483
|
+
let sent = false;
|
|
41484
|
+
try {
|
|
41485
|
+
sent = input.sendPing();
|
|
41486
|
+
} catch {
|
|
41487
|
+
sent = false;
|
|
41488
|
+
}
|
|
41489
|
+
if (sent) armPongDeadline();
|
|
41490
|
+
}, intervalMs);
|
|
41491
|
+
},
|
|
41492
|
+
stop
|
|
41493
|
+
};
|
|
41494
|
+
}
|
|
41495
|
+
|
|
41180
41496
|
//#endregion
|
|
41181
41497
|
//#region src/provider-hosts/openclaw/bootstrap-lock.ts
|
|
41182
41498
|
const OPENCLAW_BOOTSTRAP_LOCK_KEY = "openclaw-bootstrap";
|
|
@@ -44016,11 +44332,6 @@ async function handleDispatchDeliverFrame(input) {
|
|
|
44016
44332
|
profileOwnerUserId: input.profileOwnerUserId,
|
|
44017
44333
|
parsedTask
|
|
44018
44334
|
});
|
|
44019
|
-
emitSendTargetReferenceLoadFailureIfNeeded({
|
|
44020
|
-
parsedTask,
|
|
44021
|
-
presenter: input.presenter,
|
|
44022
|
-
sendTargetReference: bootstrapContext.sendTargetReference
|
|
44023
|
-
});
|
|
44024
44335
|
let localRuntimeContextPlan = null;
|
|
44025
44336
|
let agentControllerConversationResumePlan = null;
|
|
44026
44337
|
let contextIdForDispatch = null;
|
|
@@ -44058,10 +44369,17 @@ async function handleDispatchDeliverFrame(input) {
|
|
|
44058
44369
|
targetProfileId: parsedTask.targetProfileId
|
|
44059
44370
|
});
|
|
44060
44371
|
effectiveRuntimeContext = runtimePreparation.effectiveRuntimeContext;
|
|
44372
|
+
const sendTargetReference = await bootstrapContext.sendTargetReferencePromise;
|
|
44373
|
+
emitSendTargetReferenceLoadFailureIfNeeded({
|
|
44374
|
+
parsedTask,
|
|
44375
|
+
presenter: input.presenter,
|
|
44376
|
+
sendTargetReference
|
|
44377
|
+
});
|
|
44061
44378
|
const spaceActionRuntimeContext = createDispatchSpaceActionRuntimeContext({
|
|
44062
44379
|
bootstrapContext,
|
|
44063
44380
|
parsedTask,
|
|
44064
|
-
runtimePreparation
|
|
44381
|
+
runtimePreparation,
|
|
44382
|
+
sendTargetReference
|
|
44065
44383
|
});
|
|
44066
44384
|
dispatchSpaceActionContext = spaceActionRuntimeContext.dispatchSpaceActionContext;
|
|
44067
44385
|
runtimeEnvOverrides = spaceActionRuntimeContext.runtimeEnvOverrides;
|
|
@@ -44147,6 +44465,7 @@ async function handleDispatchDeliverFrame(input) {
|
|
|
44147
44465
|
parsedTask,
|
|
44148
44466
|
profileOwnerName: input.profileOwnerName,
|
|
44149
44467
|
profileOwnerUserId: input.profileOwnerUserId,
|
|
44468
|
+
sendTargetReference,
|
|
44150
44469
|
shouldInjectBootstrap: bootstrapPlan.shouldInject
|
|
44151
44470
|
});
|
|
44152
44471
|
emitRunLine({
|
|
@@ -44412,7 +44731,7 @@ async function handleDispatchDeliverFrame(input) {
|
|
|
44412
44731
|
cliEntry: bootstrapContext.cliEntry,
|
|
44413
44732
|
dispatchSpaceActionContext,
|
|
44414
44733
|
runtimeResult,
|
|
44415
|
-
sendTargetReference
|
|
44734
|
+
sendTargetReference,
|
|
44416
44735
|
runtimeContext: activeRuntimeContext,
|
|
44417
44736
|
runtimeEnvOverrides,
|
|
44418
44737
|
runtimeControllerSupport,
|
|
@@ -44809,17 +45128,19 @@ async function resolveDispatchBootstrapContext(input) {
|
|
|
44809
45128
|
targetProfileNamePresent: targetProfileContext.targetProfileName !== null,
|
|
44810
45129
|
targetProfileRolePresent: targetProfileContext.targetProfileRole !== null
|
|
44811
45130
|
});
|
|
44812
|
-
const
|
|
45131
|
+
const sendTargetReferencePromise = resolveDispatchSendTargetReference({
|
|
44813
45132
|
agentControllerRef: input.parsedTask.agentControllerRef,
|
|
44814
45133
|
dispatchTask: input.parsedTask,
|
|
44815
45134
|
profileOwnerName: input.profileOwnerName,
|
|
44816
45135
|
profileOwnerUserId: input.profileOwnerUserId,
|
|
44817
45136
|
targetProfileName: targetProfileContext.targetProfileName
|
|
44818
|
-
})
|
|
44819
|
-
|
|
44820
|
-
|
|
44821
|
-
|
|
44822
|
-
|
|
45137
|
+
}).then((sendTargetReference) => {
|
|
45138
|
+
input.onPhase?.("send_target_reference_ready", {
|
|
45139
|
+
sendTargetReferenceCount: sendTargetReference.status === "loaded" ? sendTargetReference.projection.length : null,
|
|
45140
|
+
sendTargetReferenceStatus: sendTargetReference.status,
|
|
45141
|
+
source: "dispatch_send_target_reference"
|
|
45142
|
+
});
|
|
45143
|
+
return sendTargetReference;
|
|
44823
45144
|
});
|
|
44824
45145
|
const cliEntry = resolveDispatchOwnedRuntimeActionCliEntryCommand();
|
|
44825
45146
|
const serviceFreshnessWarningLines = await resolveDispatchServiceFreshnessWarningLines({ cliEntry });
|
|
@@ -44840,7 +45161,7 @@ async function resolveDispatchBootstrapContext(input) {
|
|
|
44840
45161
|
cliEntry,
|
|
44841
45162
|
mentionSourceMentionLabel: mentionSourceContext.mentionSourceMentionLabel ?? null,
|
|
44842
45163
|
mentionSourceProfileName: mentionSourceContext.mentionSourceProfileName,
|
|
44843
|
-
|
|
45164
|
+
sendTargetReferencePromise,
|
|
44844
45165
|
serviceFreshnessWarningLines,
|
|
44845
45166
|
spaceOwnerProfileId,
|
|
44846
45167
|
targetProfileMentionLabel: targetProfileContext.targetProfileMentionLabel,
|
|
@@ -44868,7 +45189,7 @@ function buildDispatchRuntimePrompt(input) {
|
|
|
44868
45189
|
prompt: input.parsedTask.prompt,
|
|
44869
45190
|
recipientExplicitlyAddressedByActivationTargets: input.parsedTask.recipientExplicitlyAddressedByActivationTargets,
|
|
44870
45191
|
sourceMessageEnvelope: input.parsedTask.sourceMessageEnvelope,
|
|
44871
|
-
sendTargetReferenceLines: input.
|
|
45192
|
+
sendTargetReferenceLines: input.sendTargetReference.referenceLines,
|
|
44872
45193
|
serviceFreshnessWarningLines: input.bootstrapContext.serviceFreshnessWarningLines,
|
|
44873
45194
|
spaceId: input.parsedTask.spaceId,
|
|
44874
45195
|
spaceOwnerProfileId: input.bootstrapContext.spaceOwnerProfileId,
|
|
@@ -44897,7 +45218,7 @@ function createDispatchSpaceActionRuntimeContext(input) {
|
|
|
44897
45218
|
dispatchId: input.parsedTask.dispatchId,
|
|
44898
45219
|
env: process.env,
|
|
44899
45220
|
replyToSignalId: input.parsedTask.replyToSnapshot?.signalId ?? null,
|
|
44900
|
-
sendTargetReference: input.
|
|
45221
|
+
sendTargetReference: input.sendTargetReference,
|
|
44901
45222
|
sourceEventId: input.parsedTask.sourceEventId,
|
|
44902
45223
|
spaceContractSnapshot: input.parsedTask.spaceContractSnapshot,
|
|
44903
45224
|
spaceId: input.parsedTask.spaceId,
|
|
@@ -46838,7 +47159,25 @@ async function runDaemonSocketSession(input) {
|
|
|
46838
47159
|
let routeCatalogSyncInFlight = false;
|
|
46839
47160
|
let heartbeatTimer = null;
|
|
46840
47161
|
let heartbeatTimerDueAtMs = null;
|
|
46841
|
-
|
|
47162
|
+
const keepalive = createDaemonStreamKeepalive({
|
|
47163
|
+
onPongTimeout: () => {
|
|
47164
|
+
emitRunLine({
|
|
47165
|
+
presenter: input.presenter,
|
|
47166
|
+
code: "daemon.run.keepalive_pong_timeout",
|
|
47167
|
+
text: "daemon stream keepalive PONG missing; terminating half-open socket for reconnect",
|
|
47168
|
+
payload: {
|
|
47169
|
+
connectionGeneration: activeConnectionGeneration,
|
|
47170
|
+
daemonSessionId: input.daemonSessionId
|
|
47171
|
+
}
|
|
47172
|
+
});
|
|
47173
|
+
input.socket.terminate();
|
|
47174
|
+
},
|
|
47175
|
+
sendPing: () => {
|
|
47176
|
+
if (closed) return false;
|
|
47177
|
+
input.socket.send(DAEMON_STREAM_KEEPALIVE_PING);
|
|
47178
|
+
return true;
|
|
47179
|
+
}
|
|
47180
|
+
});
|
|
46842
47181
|
let lastDispatchActivityAtMs = null;
|
|
46843
47182
|
let lastHeartbeatSentAtMs = null;
|
|
46844
47183
|
let consecutiveHeartbeatFailures = 0;
|
|
@@ -47007,20 +47346,6 @@ async function runDaemonSocketSession(input) {
|
|
|
47007
47346
|
heartbeatTimer = null;
|
|
47008
47347
|
heartbeatTimerDueAtMs = null;
|
|
47009
47348
|
};
|
|
47010
|
-
const clearKeepalivePingTimer = () => {
|
|
47011
|
-
if (!keepalivePingTimer) return;
|
|
47012
|
-
clearInterval(keepalivePingTimer);
|
|
47013
|
-
keepalivePingTimer = null;
|
|
47014
|
-
};
|
|
47015
|
-
const startKeepalivePing = () => {
|
|
47016
|
-
clearKeepalivePingTimer();
|
|
47017
|
-
keepalivePingTimer = setInterval(() => {
|
|
47018
|
-
if (closed) return;
|
|
47019
|
-
try {
|
|
47020
|
-
input.socket.send(DAEMON_STREAM_KEEPALIVE_PING);
|
|
47021
|
-
} catch {}
|
|
47022
|
-
}, DAEMON_STREAM_KEEPALIVE_INTERVAL_MS);
|
|
47023
|
-
};
|
|
47024
47349
|
const resolvePendingRouteCatalogSyncRequests = (result) => {
|
|
47025
47350
|
const pending = pendingRouteCatalogSyncRequests.splice(0, pendingRouteCatalogSyncRequests.length);
|
|
47026
47351
|
for (const request of pending) request.resolve(result);
|
|
@@ -47746,7 +48071,10 @@ async function runDaemonSocketSession(input) {
|
|
|
47746
48071
|
});
|
|
47747
48072
|
});
|
|
47748
48073
|
input.socket.onMessage((raw) => {
|
|
47749
|
-
if (raw === DAEMON_STREAM_KEEPALIVE_PONG)
|
|
48074
|
+
if (raw === DAEMON_STREAM_KEEPALIVE_PONG) {
|
|
48075
|
+
keepalive.observePong();
|
|
48076
|
+
return;
|
|
48077
|
+
}
|
|
47750
48078
|
const parsedFrame = parseDaemonFrame(raw);
|
|
47751
48079
|
if (!parsedFrame) {
|
|
47752
48080
|
emitRunLine({
|
|
@@ -47879,7 +48207,7 @@ async function runDaemonSocketSession(input) {
|
|
|
47879
48207
|
latestCatalogSyncSignalUpdatedAtMs = (await readDaemonCatalogSyncSignal().catch(() => null))?.updatedAtMs ?? 0;
|
|
47880
48208
|
scheduleCatalogSyncSignalPoll();
|
|
47881
48209
|
await sendHeartbeat();
|
|
47882
|
-
|
|
48210
|
+
keepalive.start();
|
|
47883
48211
|
await waitForClose;
|
|
47884
48212
|
if (currentSocketRef.socket === input.socket) {
|
|
47885
48213
|
currentSocketRef.socket = null;
|
|
@@ -47887,7 +48215,7 @@ async function runDaemonSocketSession(input) {
|
|
|
47887
48215
|
}
|
|
47888
48216
|
input.attachRouteCatalogSyncInvoker?.(null);
|
|
47889
48217
|
clearHeartbeatTimer();
|
|
47890
|
-
|
|
48218
|
+
keepalive.stop();
|
|
47891
48219
|
clearCatalogSyncSignalTimer();
|
|
47892
48220
|
if (closeCode === 1e3 && closeReason === "shutdown") await localExecutionSlots.drain();
|
|
47893
48221
|
else {
|
|
@@ -49534,7 +49862,7 @@ async function resolveLocalServiceDemand(input) {
|
|
|
49534
49862
|
expectedRoutesRead: input.expectedRoutesRead,
|
|
49535
49863
|
mode: "check"
|
|
49536
49864
|
}).catch(() => null) : input.projection;
|
|
49537
|
-
const ownerUserId = normalizeOptionalString$
|
|
49865
|
+
const ownerUserId = normalizeOptionalString$16(input.ownerUserId);
|
|
49538
49866
|
if (!ownerUserId) return {
|
|
49539
49867
|
decision: "indeterminate",
|
|
49540
49868
|
hasLocalExecutionRoute: false,
|
|
@@ -49710,7 +50038,7 @@ function formatLocalServiceAutoStoppedMessage(localDemand) {
|
|
|
49710
50038
|
if (localDemand.projection?.status === "ok" && localDemand.projection.projectedControllerIds.length === 0) return "ATS stopped the background service because this device currently has no projected local agent controllers.";
|
|
49711
50039
|
return "ATS stopped the background service because this device currently has no local execution routes.";
|
|
49712
50040
|
}
|
|
49713
|
-
function normalizeOptionalString$
|
|
50041
|
+
function normalizeOptionalString$16(value) {
|
|
49714
50042
|
const normalized = String(value ?? "").trim();
|
|
49715
50043
|
return normalized.length > 0 ? normalized : null;
|
|
49716
50044
|
}
|
|
@@ -52501,7 +52829,15 @@ async function executeDaemonServiceLifecycle(input) {
|
|
|
52501
52829
|
});
|
|
52502
52830
|
input.state.failureStage = "wait_running";
|
|
52503
52831
|
await input.emitPhase("wait_running");
|
|
52504
|
-
await
|
|
52832
|
+
await runDaemonServiceManagerAction({
|
|
52833
|
+
action: "wait_running",
|
|
52834
|
+
controller: input.context.serviceManager.controller,
|
|
52835
|
+
intent: toLifecycleIntent(input.operation),
|
|
52836
|
+
resolveErrorMetadata: (error) => isDaemonServiceWaitTimeoutError(error) && error.jobDiagnostics ? { jobDiagnostics: error.jobDiagnostics } : null,
|
|
52837
|
+
run: async () => {
|
|
52838
|
+
await input.context.serviceManager.waitUntilRunning();
|
|
52839
|
+
}
|
|
52840
|
+
});
|
|
52505
52841
|
}
|
|
52506
52842
|
input.state.failureStage = "verify_final_inventory";
|
|
52507
52843
|
await input.emitPhase("verify_final_inventory");
|
|
@@ -53240,7 +53576,7 @@ async function writeLifecycleEvidenceEvent(input) {
|
|
|
53240
53576
|
|
|
53241
53577
|
//#endregion
|
|
53242
53578
|
//#region src/local-service/lifecycle/daemon-service-start-recovery.ts
|
|
53243
|
-
const ROOT_ERROR_PATTERN
|
|
53579
|
+
const ROOT_ERROR_PATTERN = /\s*Try re-running the command as root for richer errors\.?/i;
|
|
53244
53580
|
async function startDaemonSystemServiceWithAutoRepair(input) {
|
|
53245
53581
|
let autoRepairAttempted = false;
|
|
53246
53582
|
try {
|
|
@@ -53268,16 +53604,16 @@ async function startDaemonSystemServiceWithAutoRepair(input) {
|
|
|
53268
53604
|
}
|
|
53269
53605
|
}
|
|
53270
53606
|
}
|
|
53271
|
-
function sanitizeSystemServiceErrorMessage
|
|
53272
|
-
return message.replace(ROOT_ERROR_PATTERN
|
|
53607
|
+
function sanitizeSystemServiceErrorMessage(message) {
|
|
53608
|
+
return message.replace(ROOT_ERROR_PATTERN, "");
|
|
53273
53609
|
}
|
|
53274
|
-
function isLaunchdBootstrapIosError
|
|
53610
|
+
function isLaunchdBootstrapIosError(message) {
|
|
53275
53611
|
const normalized = message.toLowerCase();
|
|
53276
53612
|
return normalized.includes("bootstrap failed") && normalized.includes("input/output error");
|
|
53277
53613
|
}
|
|
53278
53614
|
function shouldAttemptLaunchdAutoRepair(input) {
|
|
53279
53615
|
if (input.controller !== "launchd") return false;
|
|
53280
|
-
return isLaunchdBootstrapIosError
|
|
53616
|
+
return isLaunchdBootstrapIosError(sanitizeSystemServiceErrorMessage(toErrorMessage$17(input.error)));
|
|
53281
53617
|
}
|
|
53282
53618
|
function buildLaunchdAutoRepairFailureError(input) {
|
|
53283
53619
|
return new Error([
|
|
@@ -53667,7 +54003,7 @@ async function recordDaemonServiceRepairFailure(input) {
|
|
|
53667
54003
|
}
|
|
53668
54004
|
async function readDaemonServiceRepairJournal() {
|
|
53669
54005
|
const raw = await readFile(daemonServiceRepairJournalPath(), "utf8").catch((error) => {
|
|
53670
|
-
if (getErrorCode(error) === "ENOENT") return null;
|
|
54006
|
+
if (getErrorCode$1(error) === "ENOENT") return null;
|
|
53671
54007
|
throw error;
|
|
53672
54008
|
});
|
|
53673
54009
|
if (raw === null) return createEmptyDaemonServiceRepairJournalState();
|
|
@@ -53704,7 +54040,7 @@ function createEmptyDaemonServiceRepairJournalState() {
|
|
|
53704
54040
|
function isDaemonServiceRepairJournalRecord(value) {
|
|
53705
54041
|
return !!value && typeof value === "object" && "actionKey" in value && typeof value.actionKey === "string" && "consecutiveFailures" in value && typeof value.consecutiveFailures === "number" && "lastAttemptAt" in value && typeof value.lastAttemptAt === "string" && "lastFailureAt" in value && (typeof value.lastFailureAt === "string" || value.lastFailureAt === null) && "lastSuccessAt" in value && (typeof value.lastSuccessAt === "string" || value.lastSuccessAt === null) && "cooldownUntil" in value && (typeof value.cooldownUntil === "string" || value.cooldownUntil === null) && "lastErrorMessage" in value && (typeof value.lastErrorMessage === "string" || value.lastErrorMessage === null);
|
|
53706
54042
|
}
|
|
53707
|
-
function getErrorCode(error) {
|
|
54043
|
+
function getErrorCode$1(error) {
|
|
53708
54044
|
if (error && typeof error === "object" && "code" in error) return typeof error.code === "string" ? error.code : null;
|
|
53709
54045
|
return null;
|
|
53710
54046
|
}
|
|
@@ -54896,6 +55232,11 @@ function buildRuntimeDetailRows(input) {
|
|
|
54896
55232
|
serviceManagerStatus: input.serviceManagerStatus
|
|
54897
55233
|
})]);
|
|
54898
55234
|
}
|
|
55235
|
+
function formatDaemonRunModeLabel(mode) {
|
|
55236
|
+
if (mode === "foreground") return "foreground — stops when the terminal closes";
|
|
55237
|
+
if (mode === "background") return "background service";
|
|
55238
|
+
return "unknown";
|
|
55239
|
+
}
|
|
54899
55240
|
function buildCoreRuntimeStateRows(input) {
|
|
54900
55241
|
const rows = [{
|
|
54901
55242
|
label: "⚙️ Runtime",
|
|
@@ -54904,7 +55245,7 @@ function buildCoreRuntimeStateRows(input) {
|
|
|
54904
55245
|
if (input.runtimeState.status === "running") {
|
|
54905
55246
|
rows.push({
|
|
54906
55247
|
label: "🎚️ Mode",
|
|
54907
|
-
value: input.runtimeState.mode
|
|
55248
|
+
value: formatDaemonRunModeLabel(input.runtimeState.mode)
|
|
54908
55249
|
}, {
|
|
54909
55250
|
label: "🧬 PID",
|
|
54910
55251
|
value: input.runtimeState.pid === null ? "not available" : String(input.runtimeState.pid)
|
|
@@ -54920,7 +55261,7 @@ function buildCoreRuntimeStateRows(input) {
|
|
|
54920
55261
|
if (input.effectiveStatus === "running") {
|
|
54921
55262
|
rows.push({
|
|
54922
55263
|
label: "🎚️ Mode",
|
|
54923
|
-
value: input.runtimeState.mode
|
|
55264
|
+
value: formatDaemonRunModeLabel(input.runtimeState.mode)
|
|
54924
55265
|
}, {
|
|
54925
55266
|
label: "🧬 PID",
|
|
54926
55267
|
value: input.runtimeState.pid === null ? "being managed by OS service manager" : String(input.runtimeState.pid)
|
|
@@ -55029,8 +55370,8 @@ function mapLocalControllerStatusReason(reason) {
|
|
|
55029
55370
|
}
|
|
55030
55371
|
function describeDaemonRuntimeStatus(status) {
|
|
55031
55372
|
if (!status) return "No runtime status available.";
|
|
55032
|
-
if (status.status === "running") return `Service is running (
|
|
55033
|
-
if (status.status === "stale") return `Service status is stale (
|
|
55373
|
+
if (status.status === "running") return `Service is running (${formatDaemonRunModeLabel(status.mode)}, pid=${String(status.pid)}, started=${status.startedAt || "unknown"}).`;
|
|
55374
|
+
if (status.status === "stale") return `Service status is stale (${formatDaemonRunModeLabel(status.mode)}, pid=${String(status.pid)}, reason=${status.reason || "unknown"}).`;
|
|
55034
55375
|
if (status.status === "not_running") return "Service is not running.";
|
|
55035
55376
|
return "Service runtime status is unknown.";
|
|
55036
55377
|
}
|
|
@@ -55263,13 +55604,6 @@ function capitalizeDaemonControlCommand(command) {
|
|
|
55263
55604
|
return command === "cancel" ? "Cancel" : "Interrupt";
|
|
55264
55605
|
}
|
|
55265
55606
|
|
|
55266
|
-
//#endregion
|
|
55267
|
-
//#region src/commands/service-error-text.ts
|
|
55268
|
-
const ROOT_ERROR_PATTERN = /\s*Try re-running the command as root for richer errors\.?/i;
|
|
55269
|
-
function sanitizeSystemServiceErrorMessage(message) {
|
|
55270
|
-
return message.replace(ROOT_ERROR_PATTERN, "");
|
|
55271
|
-
}
|
|
55272
|
-
|
|
55273
55607
|
//#endregion
|
|
55274
55608
|
//#region src/commands/service-reinstall-view.ts
|
|
55275
55609
|
var DaemonReinstallUnexpectedStartError = class extends Error {
|
|
@@ -55388,7 +55722,8 @@ function createDaemonReinstallStartFailedOutcome(input) {
|
|
|
55388
55722
|
forceUsed: input.forceUsed,
|
|
55389
55723
|
backupDataPath: input.backupDataPath,
|
|
55390
55724
|
...input.failureStage ? { failureStage: input.failureStage } : {},
|
|
55391
|
-
...input.evidencePath ? { evidencePath: input.evidencePath } : {}
|
|
55725
|
+
...input.evidencePath ? { evidencePath: input.evidencePath } : {},
|
|
55726
|
+
...input.startFailureVerdict ? { startFailureVerdict: input.startFailureVerdict } : {}
|
|
55392
55727
|
};
|
|
55393
55728
|
}
|
|
55394
55729
|
function createDaemonReinstallStartBlockedOutcome(input) {
|
|
@@ -55398,7 +55733,8 @@ function createDaemonReinstallStartBlockedOutcome(input) {
|
|
|
55398
55733
|
blockReason: input.blockReason,
|
|
55399
55734
|
desiredState: input.desiredState,
|
|
55400
55735
|
forceUsed: input.forceUsed,
|
|
55401
|
-
backupDataPath: input.backupDataPath
|
|
55736
|
+
backupDataPath: input.backupDataPath,
|
|
55737
|
+
...input.startFailureVerdict ? { startFailureVerdict: input.startFailureVerdict } : {}
|
|
55402
55738
|
};
|
|
55403
55739
|
}
|
|
55404
55740
|
async function attachDaemonReinstallEvidence(input) {
|
|
@@ -55679,7 +56015,7 @@ function summarizeDaemonReinstallJournalResult(outcome) {
|
|
|
55679
56015
|
}
|
|
55680
56016
|
function buildDaemonReinstallUnexpectedStartSummary(error, action = "repair") {
|
|
55681
56017
|
const actionLabel = formatDaemonServiceMaintenanceActionLabel(action);
|
|
55682
|
-
const detail = sanitizeSystemServiceErrorMessage(toErrorMessage$43(error));
|
|
56018
|
+
const detail = sanitizeSystemServiceErrorMessage$1(toErrorMessage$43(error));
|
|
55683
56019
|
if (!detail) return `ATS hit a local start error right after service ${actionLabel}.`;
|
|
55684
56020
|
return `ATS hit a local start error right after service ${actionLabel}: ${detail}`;
|
|
55685
56021
|
}
|
|
@@ -55753,183 +56089,6 @@ function createDaemonAlreadyRunningResult() {
|
|
|
55753
56089
|
};
|
|
55754
56090
|
}
|
|
55755
56091
|
|
|
55756
|
-
//#endregion
|
|
55757
|
-
//#region src/commands/service-start-failure.ts
|
|
55758
|
-
const DAEMON_STARTUP_BLOCKING_ANOMALIES = new Set([
|
|
55759
|
-
"duplicate_owned_processes",
|
|
55760
|
-
"multiple_active_owners",
|
|
55761
|
-
"runtime_bundle_mismatch",
|
|
55762
|
-
"runtime_contract_mismatch"
|
|
55763
|
-
]);
|
|
55764
|
-
var SystemServiceStartupTimeoutError = class extends Error {
|
|
55765
|
-
code = "ats.service.startup_timeout";
|
|
55766
|
-
inventory;
|
|
55767
|
-
managerStatus;
|
|
55768
|
-
runtimeStatus;
|
|
55769
|
-
jobDiagnostics;
|
|
55770
|
-
constructor(input) {
|
|
55771
|
-
super(buildSystemServiceStartupTimeoutMessage(input));
|
|
55772
|
-
this.name = "SystemServiceStartupTimeoutError";
|
|
55773
|
-
this.inventory = input.inventory;
|
|
55774
|
-
this.managerStatus = input.managerStatus;
|
|
55775
|
-
this.runtimeStatus = input.runtimeStatus;
|
|
55776
|
-
this.jobDiagnostics = input.jobDiagnostics ?? null;
|
|
55777
|
-
}
|
|
55778
|
-
};
|
|
55779
|
-
function buildSystemServiceStartupFailureReport(input) {
|
|
55780
|
-
const message = sanitizeSystemServiceErrorMessage(toErrorMessage$43(input.error));
|
|
55781
|
-
const localLogPath = getDaemonSystemServiceLogPath();
|
|
55782
|
-
const jobDiagnostics = isSystemServiceStartupTimeoutError(input.error) ? input.error.jobDiagnostics ?? null : null;
|
|
55783
|
-
if (jobDiagnostics && isDaemonServiceJobNeverSpawned(jobDiagnostics)) {
|
|
55784
|
-
const summary = "macOS is blocking the ATS Service background item, so ATS Service never launched.";
|
|
55785
|
-
const card = buildDaemonStartNeedsAttentionCard({
|
|
55786
|
-
summary,
|
|
55787
|
-
nextStep: formatInlineAtsCliCommands("Open System Settings > General > Login Items & Extensions, enable the ATS background item, then run `ats service start` again. Power users can audit Background Task Management with `sfltool dumpbtm`."),
|
|
55788
|
-
autoRepairAttempted: input.autoRepairAttempted,
|
|
55789
|
-
detail: input.detail ?? formatDaemonServiceJobDiagnosticsEvidence(jobDiagnostics)
|
|
55790
|
-
});
|
|
55791
|
-
return {
|
|
55792
|
-
title: card.title,
|
|
55793
|
-
summary,
|
|
55794
|
-
rows: card.rows
|
|
55795
|
-
};
|
|
55796
|
-
}
|
|
55797
|
-
const crashExitCode = jobDiagnostics ? readDaemonServiceJobCrashExitCode(jobDiagnostics) : null;
|
|
55798
|
-
if (jobDiagnostics && crashExitCode !== null) {
|
|
55799
|
-
const summary = `ATS Service launched but keeps exiting (launchd reports ${jobDiagnostics.runs} runs, last exit code ${crashExitCode}).`;
|
|
55800
|
-
const card = buildDaemonStartNeedsAttentionCard({
|
|
55801
|
-
summary,
|
|
55802
|
-
nextStep: formatInlineAtsCliCommands(`Run \`ats service start --mode foreground\` to see the live error. The latest local service log is at \`${localLogPath}\`. If it still fails, run \`ats service repair\`.`),
|
|
55803
|
-
autoRepairAttempted: input.autoRepairAttempted,
|
|
55804
|
-
detail: input.detail ?? formatDaemonServiceJobDiagnosticsEvidence(jobDiagnostics)
|
|
55805
|
-
});
|
|
55806
|
-
return {
|
|
55807
|
-
title: card.title,
|
|
55808
|
-
summary,
|
|
55809
|
-
rows: card.rows
|
|
55810
|
-
};
|
|
55811
|
-
}
|
|
55812
|
-
if (isLaunchdBootstrapIosError(message)) {
|
|
55813
|
-
const card = buildDaemonStartNeedsAttentionCard({
|
|
55814
|
-
summary: "ATS could not finish starting ATS Service on this Mac.",
|
|
55815
|
-
nextStep: formatInlineAtsCliCommands(`Run \`launchctl enable gui/$(id -u)/${getDaemonServiceLaunchdLabel()}\`, then retry with \`ats service start\`. The latest local service log is at \`${localLogPath}\`. If it still fails, run \`ats service repair\`.`),
|
|
55816
|
-
autoRepairAttempted: input.autoRepairAttempted,
|
|
55817
|
-
detail: input.detail ?? void 0
|
|
55818
|
-
});
|
|
55819
|
-
return {
|
|
55820
|
-
title: card.title,
|
|
55821
|
-
summary: "ATS could not finish starting ATS Service on this Mac.",
|
|
55822
|
-
rows: card.rows
|
|
55823
|
-
};
|
|
55824
|
-
}
|
|
55825
|
-
if (isPermissionOrAuthorizationError(message)) {
|
|
55826
|
-
const card = buildDaemonStartNeedsAttentionCard({
|
|
55827
|
-
summary: "ATS needs local OS permission before it can start ATS Service.",
|
|
55828
|
-
nextStep: formatInlineAtsCliCommands(`Approve the local permission prompt or OS setting, then run \`ats service start\` again. The latest local service log is at \`${localLogPath}\`.`),
|
|
55829
|
-
autoRepairAttempted: input.autoRepairAttempted,
|
|
55830
|
-
detail: input.detail ?? void 0
|
|
55831
|
-
});
|
|
55832
|
-
return {
|
|
55833
|
-
title: card.title,
|
|
55834
|
-
summary: "ATS needs local OS permission before it can start ATS Service.",
|
|
55835
|
-
rows: card.rows
|
|
55836
|
-
};
|
|
55837
|
-
}
|
|
55838
|
-
const card = buildDaemonStartNeedsAttentionCard({
|
|
55839
|
-
summary: "ATS could not finish starting ATS Service.",
|
|
55840
|
-
nextStep: formatInlineAtsCliCommands(`Run \`ats service start --mode foreground\` to see the live error. The latest local service log is at \`${localLogPath}\`. If it still fails, run \`ats service repair\`.`),
|
|
55841
|
-
autoRepairAttempted: input.autoRepairAttempted,
|
|
55842
|
-
detail: input.detail ?? void 0
|
|
55843
|
-
});
|
|
55844
|
-
return {
|
|
55845
|
-
title: card.title,
|
|
55846
|
-
summary: `ATS could not finish starting ATS Service (${input.controller}).`,
|
|
55847
|
-
rows: card.rows
|
|
55848
|
-
};
|
|
55849
|
-
}
|
|
55850
|
-
function buildSystemServiceStartupFailureMessage(input) {
|
|
55851
|
-
const report = buildSystemServiceStartupFailureReport(input);
|
|
55852
|
-
const rowLines = report.rows.map((row) => formatSystemServiceFailureRow(row)).filter((line) => line.length > 0);
|
|
55853
|
-
return [report.summary, ...rowLines].join("\n");
|
|
55854
|
-
}
|
|
55855
|
-
function buildSystemServiceStartupFailureDiagnostics(input) {
|
|
55856
|
-
const timeoutError = isSystemServiceStartupTimeoutError(input.error) ? input.error : null;
|
|
55857
|
-
return {
|
|
55858
|
-
anomalies: timeoutError?.inventory?.anomalies ?? [],
|
|
55859
|
-
autoRepairAttempted: input.autoRepairAttempted === true,
|
|
55860
|
-
controller: input.controller ?? null,
|
|
55861
|
-
jobDiagnostics: timeoutError?.jobDiagnostics ?? null,
|
|
55862
|
-
launchdLabel: (input.controller ?? null) === "launchd" ? getDaemonServiceLaunchdLabel() : null,
|
|
55863
|
-
lifecycleJournalPath: daemonLifecycleJournalPath(),
|
|
55864
|
-
managerStatus: timeoutError?.managerStatus ?? null,
|
|
55865
|
-
nextSteps: [formatAtsCliCommand("ats service start --mode foreground"), formatAtsCliCommand("ats service repair")],
|
|
55866
|
-
recovery: input.recovery,
|
|
55867
|
-
runtimeStatus: timeoutError?.runtimeStatus ?? null,
|
|
55868
|
-
serviceLogPath: getDaemonSystemServiceLogPath()
|
|
55869
|
-
};
|
|
55870
|
-
}
|
|
55871
|
-
function buildSystemServiceStartupTimeoutMessage(input) {
|
|
55872
|
-
const base = `ATS Service failed to reach a running local service state in time. runtime=${input.runtimeStatus?.status ?? "unknown"}, reason=${input.runtimeStatus?.reason || "unknown"}, managerRunning=${String(input.managerStatus?.running ?? false)}, anomalies=${input.inventory?.anomalies.map((anomaly) => anomaly.code).join(",") || "unknown"}`;
|
|
55873
|
-
if (!input.jobDiagnostics) return base;
|
|
55874
|
-
return `${base}; ${formatDaemonServiceJobDiagnosticsEvidence(input.jobDiagnostics)}`;
|
|
55875
|
-
}
|
|
55876
|
-
function isSystemServiceStartupTimeoutError(error) {
|
|
55877
|
-
return error instanceof SystemServiceStartupTimeoutError || typeof error === "object" && error !== null && "code" in error && error.code === "ats.service.startup_timeout";
|
|
55878
|
-
}
|
|
55879
|
-
function formatSystemServiceFailureRow(row) {
|
|
55880
|
-
const label = row.label.trim();
|
|
55881
|
-
const value = formatAtsCliTextBlock(row.value).trim();
|
|
55882
|
-
if (label.length === 0 && value.length === 0) return "";
|
|
55883
|
-
if (value.length === 0) return `${row.label}:`;
|
|
55884
|
-
if (label.length === 0) return row.value;
|
|
55885
|
-
return `${row.label}: ${row.value}`;
|
|
55886
|
-
}
|
|
55887
|
-
function isLaunchdBootstrapIosError(message) {
|
|
55888
|
-
const normalized = message.toLowerCase();
|
|
55889
|
-
return normalized.includes("bootstrap failed") && normalized.includes("input/output error");
|
|
55890
|
-
}
|
|
55891
|
-
function isPermissionOrAuthorizationError(message) {
|
|
55892
|
-
const normalized = message.toLowerCase();
|
|
55893
|
-
return normalized.includes("permission") || normalized.includes("operation not permitted") || normalized.includes("access is denied") || normalized.includes("requires admin") || normalized.includes("elevation") || normalized.includes("access denied") || normalized.includes("not authorized");
|
|
55894
|
-
}
|
|
55895
|
-
function isDaemonInventoryRunningAndStartReady(inventory) {
|
|
55896
|
-
if (inventory.runtimeStatus.status !== "running") return false;
|
|
55897
|
-
if (inventory.runtimeStatus.mode !== "background") return false;
|
|
55898
|
-
if (inventory.runtimeStatus.managedBySystemService !== true) return false;
|
|
55899
|
-
return !inventory.anomalies.some((anomaly) => DAEMON_STARTUP_BLOCKING_ANOMALIES.has(anomaly.code));
|
|
55900
|
-
}
|
|
55901
|
-
async function waitForSystemServiceStartup(input) {
|
|
55902
|
-
const deadlineMs = Date.now() + input.waitMs;
|
|
55903
|
-
while (Date.now() < deadlineMs) {
|
|
55904
|
-
const inventory = await inspectDaemonServiceInventory({
|
|
55905
|
-
expectedVersion: input.expectedVersion,
|
|
55906
|
-
intendedMode: "background",
|
|
55907
|
-
intent: "run_background"
|
|
55908
|
-
}).catch(() => null);
|
|
55909
|
-
if (inventory && isDaemonInventoryRunningAndStartReady(inventory)) return {
|
|
55910
|
-
state: "running",
|
|
55911
|
-
runtimeStatus: inventory.runtimeStatus
|
|
55912
|
-
};
|
|
55913
|
-
await sleep$1(input.pollMs);
|
|
55914
|
-
}
|
|
55915
|
-
const finalInventory = await inspectDaemonServiceInventory({
|
|
55916
|
-
expectedVersion: input.expectedVersion,
|
|
55917
|
-
intendedMode: "background",
|
|
55918
|
-
intent: "run_background"
|
|
55919
|
-
}).catch(() => null);
|
|
55920
|
-
if (finalInventory && isDaemonInventoryRunningAndStartReady(finalInventory)) return {
|
|
55921
|
-
state: "running",
|
|
55922
|
-
runtimeStatus: finalInventory.runtimeStatus
|
|
55923
|
-
};
|
|
55924
|
-
const finalRuntimeStatus = await readCurrentObservedDaemonRuntimeStatus().catch(() => null);
|
|
55925
|
-
throw new SystemServiceStartupTimeoutError({
|
|
55926
|
-
inventory: finalInventory,
|
|
55927
|
-
managerStatus: await input.manager.status().catch(() => null),
|
|
55928
|
-
runtimeStatus: finalRuntimeStatus,
|
|
55929
|
-
jobDiagnostics: await input.manager.readJobDiagnostics?.().catch(() => null) ?? null
|
|
55930
|
-
});
|
|
55931
|
-
}
|
|
55932
|
-
|
|
55933
56092
|
//#endregion
|
|
55934
56093
|
//#region src/commands/service-stop-command.ts
|
|
55935
56094
|
const STOP_WAIT_MS = 2e3;
|
|
@@ -57057,7 +57216,7 @@ async function autoStartDaemonAfterReinstall(input) {
|
|
|
57057
57216
|
startRetryDelayMs: input.resolved.startRetryDelayMs,
|
|
57058
57217
|
view: input.runtime.resolvedView
|
|
57059
57218
|
});
|
|
57060
|
-
if (startOutcome === "cancelled") {
|
|
57219
|
+
if (startOutcome.reason === "cancelled") {
|
|
57061
57220
|
await clearDaemonStartFailureStateSafely();
|
|
57062
57221
|
return createDaemonReinstallCompletedOutcome({
|
|
57063
57222
|
backupDataPath: null,
|
|
@@ -57066,7 +57225,7 @@ async function autoStartDaemonAfterReinstall(input) {
|
|
|
57066
57225
|
serviceState: "stopped"
|
|
57067
57226
|
});
|
|
57068
57227
|
}
|
|
57069
|
-
const blockReason = resolveDaemonReinstallStartBlockedReason(startOutcome);
|
|
57228
|
+
const blockReason = resolveDaemonReinstallStartBlockedReason(startOutcome.reason);
|
|
57070
57229
|
if (blockReason) {
|
|
57071
57230
|
const recheckedInventory = await inspectDaemonServiceInventory({
|
|
57072
57231
|
expectedVersion: input.resolved.daemonVersion,
|
|
@@ -57086,13 +57245,15 @@ async function autoStartDaemonAfterReinstall(input) {
|
|
|
57086
57245
|
backupDataPath: null,
|
|
57087
57246
|
blockReason,
|
|
57088
57247
|
desiredState: input.desiredState,
|
|
57089
|
-
forceUsed: input.forceUsed
|
|
57248
|
+
forceUsed: input.forceUsed,
|
|
57249
|
+
startFailureVerdict: startOutcome.startFailureVerdict
|
|
57090
57250
|
});
|
|
57091
57251
|
}
|
|
57092
|
-
if (startOutcome === "start_failed") return createDaemonReinstallStartFailedOutcome({
|
|
57252
|
+
if (startOutcome.reason === "start_failed") return createDaemonReinstallStartFailedOutcome({
|
|
57093
57253
|
backupDataPath: null,
|
|
57094
57254
|
desiredState: input.desiredState,
|
|
57095
|
-
forceUsed: input.forceUsed
|
|
57255
|
+
forceUsed: input.forceUsed,
|
|
57256
|
+
startFailureVerdict: startOutcome.startFailureVerdict
|
|
57096
57257
|
});
|
|
57097
57258
|
await waitForDaemonHealthyAfterReinstall({
|
|
57098
57259
|
expectedVersion: input.resolved.daemonVersion,
|
|
@@ -57126,7 +57287,10 @@ async function runDaemonAfterReinstallStartWithRetry(input) {
|
|
|
57126
57287
|
await sleep$1(input.startRetryDelayMs);
|
|
57127
57288
|
continue;
|
|
57128
57289
|
}
|
|
57129
|
-
return
|
|
57290
|
+
return {
|
|
57291
|
+
reason: result.reason,
|
|
57292
|
+
startFailureVerdict: result.ok === false ? result.startFailureVerdict ?? null : null
|
|
57293
|
+
};
|
|
57130
57294
|
} catch (error) {
|
|
57131
57295
|
if (attempt < REINSTALL_START_RETRY_ATTEMPTS) {
|
|
57132
57296
|
process.exitCode = previousExitCode;
|
|
@@ -57142,7 +57306,10 @@ async function runDaemonAfterReinstallStartWithRetry(input) {
|
|
|
57142
57306
|
});
|
|
57143
57307
|
}
|
|
57144
57308
|
}
|
|
57145
|
-
return
|
|
57309
|
+
return {
|
|
57310
|
+
reason: "start_failed",
|
|
57311
|
+
startFailureVerdict: null
|
|
57312
|
+
};
|
|
57146
57313
|
}
|
|
57147
57314
|
async function resolveDaemonReinstallTargetDesiredState() {
|
|
57148
57315
|
const currentContract = await readDaemonServiceContract().catch(() => null);
|
|
@@ -57610,9 +57777,15 @@ async function handleDaemonRunStartFailure(input) {
|
|
|
57610
57777
|
});
|
|
57611
57778
|
}
|
|
57612
57779
|
process.exitCode = 1;
|
|
57780
|
+
const startFailureVerdict = input.genericErrorPayload.controller ? resolveSystemServiceStartupFailureVerdict({
|
|
57781
|
+
controller: input.genericErrorPayload.controller,
|
|
57782
|
+
error: input.genericErrorPayload.error,
|
|
57783
|
+
detail: failure?.detail ?? null
|
|
57784
|
+
}) : null;
|
|
57613
57785
|
return {
|
|
57614
57786
|
ok: false,
|
|
57615
|
-
reason: "start_failed"
|
|
57787
|
+
reason: "start_failed",
|
|
57788
|
+
...startFailureVerdict ? { startFailureVerdict } : {}
|
|
57616
57789
|
};
|
|
57617
57790
|
}
|
|
57618
57791
|
async function runDirectDaemonServiceLoop(input) {
|
|
@@ -59778,7 +59951,7 @@ async function runAuthMenu(input) {
|
|
|
59778
59951
|
}
|
|
59779
59952
|
async function resolveAuthLoginRequest(input) {
|
|
59780
59953
|
const explicitMethod = parseAuthLoginMethod(input.method);
|
|
59781
|
-
const providedToken = normalizeOptionalString$
|
|
59954
|
+
const providedToken = normalizeOptionalString$15(input.ott);
|
|
59782
59955
|
const isInteractiveHuman = input.runtime.resolvedView === "human" && canUseInteractivePrompts(input.runtime);
|
|
59783
59956
|
if (providedToken && explicitMethod === LOGIN_METHOD_DEVICE) throw new Error("`--ott` cannot be used with `--method device`");
|
|
59784
59957
|
const explicitRequest = await resolveExplicitAuthLoginRequest({
|
|
@@ -59960,7 +60133,7 @@ async function runDeviceLoginFlow(input) {
|
|
|
59960
60133
|
authBaseUrl: input.authBaseUrl,
|
|
59961
60134
|
clientId: input.clientId,
|
|
59962
60135
|
expiresAt: resolveExpiresAt(token.expires_in),
|
|
59963
|
-
scope: normalizeOptionalString$
|
|
60136
|
+
scope: normalizeOptionalString$15(token.scope) ?? void 0,
|
|
59964
60137
|
user: authUser ?? void 0
|
|
59965
60138
|
});
|
|
59966
60139
|
emitLineWithHumanSpacer({
|
|
@@ -60004,7 +60177,7 @@ async function assertOneTimeTokenAuthSessionSaved(input) {
|
|
|
60004
60177
|
const authState = await getAuthSessionState({ validateRemote: false }).catch(() => null);
|
|
60005
60178
|
if (authState?.state !== "valid" || !authState.session) throw new OneTimeTokenAuthError("session_not_saved", `one-time token verified, but ATS could not save a usable local sign-in session (${authState?.state ?? "unknown"}); copy a fresh setup command from ATS Web and retry`);
|
|
60006
60179
|
if (authState.session.accessToken !== input.accessToken) throw new OneTimeTokenAuthError("session_not_saved", "one-time token verified, but ATS saved a different local sign-in session; copy a fresh setup command from ATS Web and retry");
|
|
60007
|
-
if (!normalizeOptionalString$
|
|
60180
|
+
if (!normalizeOptionalString$15(authState.session.user?.id)) throw new OneTimeTokenAuthError("session_not_saved", "one-time token verified, but the saved local sign-in is missing its ATS account ID; copy a fresh setup command from ATS Web and retry");
|
|
60008
60181
|
}
|
|
60009
60182
|
async function promptOneTimeTokenForHuman(input) {
|
|
60010
60183
|
const result = await promptTextEntry({
|
|
@@ -60013,10 +60186,10 @@ async function promptOneTimeTokenForHuman(input) {
|
|
|
60013
60186
|
allowBack: input.allowBack,
|
|
60014
60187
|
backLabel: input.backLabel,
|
|
60015
60188
|
requiredMessage: "Enter a one-time sign-in token.",
|
|
60016
|
-
validate: (value) => normalizeOptionalString$
|
|
60189
|
+
validate: (value) => normalizeOptionalString$15(value) ? null : "Enter a one-time sign-in token."
|
|
60017
60190
|
});
|
|
60018
60191
|
if (result.status !== "submitted") return result;
|
|
60019
|
-
const token = normalizeOptionalString$
|
|
60192
|
+
const token = normalizeOptionalString$15(result.value);
|
|
60020
60193
|
if (!token) throw new OneTimeTokenAuthError("missing_access_token", "one-time token is required");
|
|
60021
60194
|
return {
|
|
60022
60195
|
status: "submitted",
|
|
@@ -60313,7 +60486,7 @@ async function verifyOneTimeToken(input) {
|
|
|
60313
60486
|
if (normalizedMessage.includes("invalid")) throw new OneTimeTokenAuthError("invalid_token", "invalid one-time token; generate a new token and retry");
|
|
60314
60487
|
throw new OneTimeTokenAuthError("unknown", `one-time token verification failed: ${message}`);
|
|
60315
60488
|
}
|
|
60316
|
-
const accessToken = normalizeOptionalString$
|
|
60489
|
+
const accessToken = normalizeOptionalString$15(response.headers.get("set-auth-token"));
|
|
60317
60490
|
if (!accessToken) throw new OneTimeTokenAuthError("missing_access_token", "one-time token verified but auth response is missing set-auth-token");
|
|
60318
60491
|
return {
|
|
60319
60492
|
accessToken,
|
|
@@ -60348,8 +60521,8 @@ async function requestDeviceCode(input) {
|
|
|
60348
60521
|
return {
|
|
60349
60522
|
device_code: normalizeRequiredString(readStringField$2(payload, "device_code"), "missing device_code in device code response"),
|
|
60350
60523
|
user_code: normalizeRequiredString(readStringField$2(payload, "user_code"), "missing user_code in device code response"),
|
|
60351
|
-
verification_uri: normalizeOptionalString$
|
|
60352
|
-
verification_uri_complete: normalizeOptionalString$
|
|
60524
|
+
verification_uri: normalizeOptionalString$15(readStringField$2(payload, "verification_uri")) ?? void 0,
|
|
60525
|
+
verification_uri_complete: normalizeOptionalString$15(readStringField$2(payload, "verification_uri_complete")) ?? void 0,
|
|
60353
60526
|
expires_in: readNumberField(payload, "expires_in"),
|
|
60354
60527
|
interval: readNumberField(payload, "interval")
|
|
60355
60528
|
};
|
|
@@ -60371,17 +60544,17 @@ async function requestDeviceToken(input) {
|
|
|
60371
60544
|
ok: true,
|
|
60372
60545
|
data: {
|
|
60373
60546
|
access_token: normalizeRequiredString(readStringField$2(payload, "access_token"), "missing access_token in device token response"),
|
|
60374
|
-
token_type: normalizeOptionalString$
|
|
60547
|
+
token_type: normalizeOptionalString$15(readStringField$2(payload, "token_type")) ?? void 0,
|
|
60375
60548
|
expires_in: readNumberField(payload, "expires_in"),
|
|
60376
|
-
scope: normalizeOptionalString$
|
|
60549
|
+
scope: normalizeOptionalString$15(readStringField$2(payload, "scope")) ?? void 0
|
|
60377
60550
|
}
|
|
60378
60551
|
};
|
|
60379
60552
|
return {
|
|
60380
60553
|
ok: false,
|
|
60381
60554
|
error: {
|
|
60382
|
-
error: normalizeOptionalString$
|
|
60383
|
-
error_description: normalizeOptionalString$
|
|
60384
|
-
message: normalizeOptionalString$
|
|
60555
|
+
error: normalizeOptionalString$15(readStringField$2(payload, "error")) ?? void 0,
|
|
60556
|
+
error_description: normalizeOptionalString$15(readStringField$2(payload, "error_description")) ?? void 0,
|
|
60557
|
+
message: normalizeOptionalString$15(readStringField$2(payload, "message")) ?? void 0
|
|
60385
60558
|
},
|
|
60386
60559
|
status: response.status
|
|
60387
60560
|
};
|
|
@@ -60398,7 +60571,7 @@ async function pollForDeviceToken(input) {
|
|
|
60398
60571
|
deviceCode: input.deviceCode
|
|
60399
60572
|
});
|
|
60400
60573
|
if (result.ok) return result.data;
|
|
60401
|
-
const errorCode = normalizeOptionalString$
|
|
60574
|
+
const errorCode = normalizeOptionalString$15(result.error.error);
|
|
60402
60575
|
if (errorCode === "authorization_pending") {
|
|
60403
60576
|
input.onProgress?.({
|
|
60404
60577
|
event: "authorization_pending",
|
|
@@ -60428,7 +60601,7 @@ async function pollForDeviceToken(input) {
|
|
|
60428
60601
|
throw new DeviceAuthError("expired_token", "browser sign-in timed out; sign in again");
|
|
60429
60602
|
}
|
|
60430
60603
|
function resolveVerificationUrl(response, authBaseUrl) {
|
|
60431
|
-
const raw = normalizeOptionalString$
|
|
60604
|
+
const raw = normalizeOptionalString$15(response.verification_uri_complete) ?? normalizeOptionalString$15(response.verification_uri);
|
|
60432
60605
|
if (!raw) throw new Error("missing verification_uri in device code response");
|
|
60433
60606
|
const url = toAbsoluteUrl(raw, authBaseUrl);
|
|
60434
60607
|
if (!url.searchParams.has("user_code")) url.searchParams.set("user_code", response.user_code);
|
|
@@ -60469,16 +60642,16 @@ function clampInteger(value, min, max) {
|
|
|
60469
60642
|
return Math.max(min, Math.min(max, Math.floor(value)));
|
|
60470
60643
|
}
|
|
60471
60644
|
function resolveClientId(value) {
|
|
60472
|
-
const clientId = normalizeOptionalString$
|
|
60645
|
+
const clientId = normalizeOptionalString$15(value) ?? normalizeOptionalString$15(process.env.ATS_AUTH_CLIENT_ID) ?? DEFAULT_DEVICE_CLIENT_ID;
|
|
60473
60646
|
if (!DEVICE_CLIENT_ID_PATTERN.test(clientId)) throw new Error(`invalid client_id "${clientId}" (allowed: letters, numbers, . _ : -)`);
|
|
60474
60647
|
return clientId;
|
|
60475
60648
|
}
|
|
60476
60649
|
function normalizeRequiredString(value, message) {
|
|
60477
|
-
const normalized = normalizeOptionalString$
|
|
60650
|
+
const normalized = normalizeOptionalString$15(value);
|
|
60478
60651
|
if (!normalized) throw new Error(message);
|
|
60479
60652
|
return normalized;
|
|
60480
60653
|
}
|
|
60481
|
-
function normalizeOptionalString$
|
|
60654
|
+
function normalizeOptionalString$15(value) {
|
|
60482
60655
|
const normalized = String(value ?? "").trim();
|
|
60483
60656
|
return normalized.length > 0 ? normalized : null;
|
|
60484
60657
|
}
|
|
@@ -60506,13 +60679,13 @@ async function parseResponseJson(response) {
|
|
|
60506
60679
|
}
|
|
60507
60680
|
}
|
|
60508
60681
|
function extractApiErrorMessage(payload, status) {
|
|
60509
|
-
const errorDescription = normalizeOptionalString$
|
|
60682
|
+
const errorDescription = normalizeOptionalString$15(readStringField$2(payload, "error_description"));
|
|
60510
60683
|
if (errorDescription) return errorDescription;
|
|
60511
|
-
const detail = normalizeOptionalString$
|
|
60684
|
+
const detail = normalizeOptionalString$15(readStringField$2(payload, "detail"));
|
|
60512
60685
|
if (detail) return detail;
|
|
60513
|
-
const message = normalizeOptionalString$
|
|
60686
|
+
const message = normalizeOptionalString$15(readStringField$2(payload, "message"));
|
|
60514
60687
|
if (message) return message;
|
|
60515
|
-
const errorCode = normalizeOptionalString$
|
|
60688
|
+
const errorCode = normalizeOptionalString$15(readStringField$2(payload, "error"));
|
|
60516
60689
|
if (errorCode) return errorCode;
|
|
60517
60690
|
return `HTTP ${status}`;
|
|
60518
60691
|
}
|
|
@@ -60586,14 +60759,14 @@ function readAuthUserFromSessionPayload(payload) {
|
|
|
60586
60759
|
};
|
|
60587
60760
|
}
|
|
60588
60761
|
function resolveHumanLoginSuccessText(user) {
|
|
60589
|
-
const email = normalizeOptionalString$
|
|
60762
|
+
const email = normalizeOptionalString$15(user?.email);
|
|
60590
60763
|
if (email) return `✅ Welcome ${email}`;
|
|
60591
60764
|
return "✅ Signed in.";
|
|
60592
60765
|
}
|
|
60593
60766
|
function readOptionalStringField(input, key) {
|
|
60594
60767
|
const value = input[key];
|
|
60595
60768
|
if (typeof value !== "string") return;
|
|
60596
|
-
return normalizeOptionalString$
|
|
60769
|
+
return normalizeOptionalString$15(value) ?? void 0;
|
|
60597
60770
|
}
|
|
60598
60771
|
function toDeviceAuthError(error) {
|
|
60599
60772
|
if (error instanceof DeviceAuthError) return error;
|
|
@@ -60665,8 +60838,8 @@ const COMMAND_AUTH_ACTION_CANCEL = "__command_auth_cancel__";
|
|
|
60665
60838
|
async function evaluateCommandAuthentication(input) {
|
|
60666
60839
|
const authState = await getAuthSessionState({ validateRemote: true }).catch(() => null);
|
|
60667
60840
|
const session = authState?.session ?? null;
|
|
60668
|
-
const authBaseUrl = normalizeOptionalString$
|
|
60669
|
-
const email = normalizeOptionalString$
|
|
60841
|
+
const authBaseUrl = normalizeOptionalString$14(session?.authBaseUrl);
|
|
60842
|
+
const email = normalizeOptionalString$14(session?.user?.email);
|
|
60670
60843
|
const isCompatibleWithGateway = authState?.state === "valid" && session !== null && (!(input?.gatewayUrl && input.gatewayUrl.trim().length > 0) || canAttachAuthTokenToRequest(session, input.gatewayUrl));
|
|
60671
60844
|
return {
|
|
60672
60845
|
status: authState?.state === "valid" && session !== null && !isCompatibleWithGateway ? "mismatch" : authState?.state ?? "unknown",
|
|
@@ -60677,7 +60850,7 @@ async function evaluateCommandAuthentication(input) {
|
|
|
60677
60850
|
}
|
|
60678
60851
|
async function ensureCommandAuthenticationOrCancel(input) {
|
|
60679
60852
|
const currentState = getCurrentCommandCheckState();
|
|
60680
|
-
if (isCurrentCommandCheckScopeActive() && currentState.signIn && currentState.signIn.status === "valid" && currentState.signIn.checkedGatewayUrl === normalizeOptionalString$
|
|
60853
|
+
if (isCurrentCommandCheckScopeActive() && currentState.signIn && currentState.signIn.status === "valid" && currentState.signIn.checkedGatewayUrl === normalizeOptionalString$14(input.gatewayUrl)) return true;
|
|
60681
60854
|
const auth = input.evaluated ?? await evaluateCommandAuthentication({ gatewayUrl: input.gatewayUrl });
|
|
60682
60855
|
if (auth.status === "valid" && auth.session) return true;
|
|
60683
60856
|
const canPrompt = input.allowPrompt ?? input.runtime.interactive;
|
|
@@ -60727,12 +60900,12 @@ async function ensureCommandAuthenticationOrCancel(input) {
|
|
|
60727
60900
|
return false;
|
|
60728
60901
|
}
|
|
60729
60902
|
if (isCurrentCommandCheckScopeActive()) currentState.signIn = {
|
|
60730
|
-
checkedGatewayUrl: normalizeOptionalString$
|
|
60903
|
+
checkedGatewayUrl: normalizeOptionalString$14(input.gatewayUrl),
|
|
60731
60904
|
status: "valid"
|
|
60732
60905
|
};
|
|
60733
60906
|
return true;
|
|
60734
60907
|
}
|
|
60735
|
-
function normalizeOptionalString$
|
|
60908
|
+
function normalizeOptionalString$14(value) {
|
|
60736
60909
|
const normalized = String(value ?? "").trim();
|
|
60737
60910
|
return normalized.length > 0 ? normalized : null;
|
|
60738
60911
|
}
|
|
@@ -61029,7 +61202,7 @@ function formatStatusTextForHuman(value) {
|
|
|
61029
61202
|
const normalized = value.replaceAll("_", " ");
|
|
61030
61203
|
return normalized[0]?.toUpperCase() + normalized.slice(1);
|
|
61031
61204
|
}
|
|
61032
|
-
function normalizeOptionalString$
|
|
61205
|
+
function normalizeOptionalString$13(value) {
|
|
61033
61206
|
if (typeof value !== "string") return null;
|
|
61034
61207
|
const trimmed = value.trim();
|
|
61035
61208
|
return trimmed.length > 0 ? trimmed : null;
|
|
@@ -62103,8 +62276,8 @@ async function promptInteractiveCustomAgentAddDetails(input) {
|
|
|
62103
62276
|
status: "submitted",
|
|
62104
62277
|
value: {
|
|
62105
62278
|
dir: dirResult.value,
|
|
62106
|
-
id: normalizeOptionalString$
|
|
62107
|
-
idInput: normalizeOptionalString$
|
|
62279
|
+
id: normalizeOptionalString$13(idResult.value) ?? void 0,
|
|
62280
|
+
idInput: normalizeOptionalString$13(idResult.value) ?? void 0
|
|
62108
62281
|
}
|
|
62109
62282
|
};
|
|
62110
62283
|
}
|
|
@@ -62194,7 +62367,7 @@ async function promptRequiredInteractiveText(input) {
|
|
|
62194
62367
|
});
|
|
62195
62368
|
if (valueResult.status === "cancelled" || valueResult.status === "back") return valueResult;
|
|
62196
62369
|
if (valueResult.status !== "selected") continue;
|
|
62197
|
-
const normalizedValue = normalizeOptionalString$
|
|
62370
|
+
const normalizedValue = normalizeOptionalString$13(valueResult.value);
|
|
62198
62371
|
if (!normalizedValue) {
|
|
62199
62372
|
process.stderr.write(`${input.requiredMessage}\n`);
|
|
62200
62373
|
continue;
|
|
@@ -62777,7 +62950,7 @@ async function runAgentsEnable(input) {
|
|
|
62777
62950
|
handled: input.presentation === "handoff"
|
|
62778
62951
|
});
|
|
62779
62952
|
const explicitIds = normalizeAgentIds(input.agent ?? []);
|
|
62780
|
-
const explicitInstallId = normalizeOptionalString$
|
|
62953
|
+
const explicitInstallId = normalizeOptionalString$13(input.install);
|
|
62781
62954
|
validateBuiltinAgentSelectionInput({
|
|
62782
62955
|
all: input.all,
|
|
62783
62956
|
command: "enable",
|
|
@@ -62874,7 +63047,7 @@ async function runAgentsRepair(input) {
|
|
|
62874
63047
|
handled: input.presentation === "handoff"
|
|
62875
63048
|
});
|
|
62876
63049
|
const explicitIds = normalizeAgentIds(input.agent ?? []);
|
|
62877
|
-
const explicitInstallId = normalizeOptionalString$
|
|
63050
|
+
const explicitInstallId = normalizeOptionalString$13(input.install);
|
|
62878
63051
|
validateBuiltinAgentSelectionInput({
|
|
62879
63052
|
all: input.all,
|
|
62880
63053
|
command: "repair",
|
|
@@ -63534,11 +63707,11 @@ async function runAgentsCustomAdd(input) {
|
|
|
63534
63707
|
resolvedView: runtime.resolvedView,
|
|
63535
63708
|
command: "custom_add"
|
|
63536
63709
|
});
|
|
63537
|
-
const name = normalizeOptionalString$
|
|
63538
|
-
const dir = normalizeOptionalString$
|
|
63710
|
+
const name = normalizeOptionalString$13(input.name);
|
|
63711
|
+
const dir = normalizeOptionalString$13(input.dir);
|
|
63539
63712
|
if (!(name && dir)) throw new Error("agents.custom.invalid_argument: provide --name <name> and --dir <dir>");
|
|
63540
63713
|
if (!isAbsolute(dir)) throw new Error("agents.custom.invalid_argument: --dir must be an absolute path");
|
|
63541
|
-
const id = normalizeOptionalString$
|
|
63714
|
+
const id = normalizeOptionalString$13(input.id) ?? void 0;
|
|
63542
63715
|
const target = await addAgentCustomTarget({
|
|
63543
63716
|
name,
|
|
63544
63717
|
dir,
|
|
@@ -63578,8 +63751,8 @@ async function runAgentsCustomUpdate(input) {
|
|
|
63578
63751
|
});
|
|
63579
63752
|
const id = normalizeAgentId(input.id ?? "");
|
|
63580
63753
|
if (!id) throw new Error("agents.custom.invalid_argument: provide --id <id>");
|
|
63581
|
-
const name = normalizeOptionalString$
|
|
63582
|
-
const dir = normalizeOptionalString$
|
|
63754
|
+
const name = normalizeOptionalString$13(input.name) ?? void 0;
|
|
63755
|
+
const dir = normalizeOptionalString$13(input.dir) ?? void 0;
|
|
63583
63756
|
if (name === void 0 && dir === void 0) throw new Error("agents.custom.invalid_argument: provide at least one option (--name/--dir)");
|
|
63584
63757
|
if (dir && !isAbsolute(dir)) throw new Error("agents.custom.invalid_argument: --dir must be an absolute path");
|
|
63585
63758
|
const updated = await updateAgentCustomTarget({
|
|
@@ -65288,9 +65461,9 @@ async function prepareAuthenticatedSpaceCommandContext(input) {
|
|
|
65288
65461
|
};
|
|
65289
65462
|
}
|
|
65290
65463
|
async function ensureSpaceCommandGatewayAuthenticationOrCancel(input) {
|
|
65291
|
-
const targetGatewayUrl = normalizeOptionalString$
|
|
65292
|
-
if (!targetGatewayUrl) return normalizeOptionalString$
|
|
65293
|
-
const authenticatedGatewayUrl = normalizeOptionalString$
|
|
65464
|
+
const targetGatewayUrl = normalizeOptionalString$12(input.gatewayUrl);
|
|
65465
|
+
if (!targetGatewayUrl) return normalizeOptionalString$12(input.authenticatedGatewayUrl);
|
|
65466
|
+
const authenticatedGatewayUrl = normalizeOptionalString$12(input.authenticatedGatewayUrl);
|
|
65294
65467
|
if (authenticatedGatewayUrl !== null && authenticatedGatewayUrl === targetGatewayUrl) return authenticatedGatewayUrl;
|
|
65295
65468
|
if (!await ensureHumanSpaceCommandAuthenticationOrCancel({
|
|
65296
65469
|
runtime: input.runtime,
|
|
@@ -65359,7 +65532,7 @@ function isValidSpaceId$1(space) {
|
|
|
65359
65532
|
function isProfileKindSupportedForSpaceCommand(profileKind) {
|
|
65360
65533
|
return profileKind === "human" || profileKind === "agent";
|
|
65361
65534
|
}
|
|
65362
|
-
function normalizeOptionalString$
|
|
65535
|
+
function normalizeOptionalString$12(value) {
|
|
65363
65536
|
const normalized = String(value ?? "").trim();
|
|
65364
65537
|
return normalized.length > 0 ? normalized : null;
|
|
65365
65538
|
}
|
|
@@ -65573,7 +65746,7 @@ function toErrorMessage$13(error) {
|
|
|
65573
65746
|
//#endregion
|
|
65574
65747
|
//#region src/space/command-http-errors.ts
|
|
65575
65748
|
const HTTP_STATUS_IN_TEXT_REGEX = /^HTTP\s+(\d{3}):/i;
|
|
65576
|
-
function normalizeOptionalString$
|
|
65749
|
+
function normalizeOptionalString$11(value) {
|
|
65577
65750
|
if (typeof value !== "string") return null;
|
|
65578
65751
|
const normalized = value.trim();
|
|
65579
65752
|
return normalized.length > 0 ? normalized : null;
|
|
@@ -65822,13 +65995,13 @@ function resolveKnownSpaceSortKey(space) {
|
|
|
65822
65995
|
};
|
|
65823
65996
|
}
|
|
65824
65997
|
function parseKnownSpaceTimestamp(value) {
|
|
65825
|
-
const normalized = normalizeOptionalString$
|
|
65998
|
+
const normalized = normalizeOptionalString$11(value);
|
|
65826
65999
|
if (!normalized) return null;
|
|
65827
66000
|
const timestamp = Date.parse(normalized);
|
|
65828
66001
|
return Number.isFinite(timestamp) ? timestamp : null;
|
|
65829
66002
|
}
|
|
65830
66003
|
function normalizeKnownSpaceSortName(value) {
|
|
65831
|
-
return normalizeOptionalString$
|
|
66004
|
+
return normalizeOptionalString$11(value)?.toLowerCase() ?? "untitled-space";
|
|
65832
66005
|
}
|
|
65833
66006
|
function normalizeKnownSpaceVisibilityScope(visibilityScope) {
|
|
65834
66007
|
return visibilityScope === "owner" ? "owner" : "profile";
|
|
@@ -65975,7 +66148,7 @@ function buildKnownSpaceDisplayProjection(input) {
|
|
|
65975
66148
|
});
|
|
65976
66149
|
}
|
|
65977
66150
|
function resolveKnownSpaceJoinedTimestamp(space) {
|
|
65978
|
-
return normalizeOptionalString$
|
|
66151
|
+
return normalizeOptionalString$11(space.lastJoinedAt) ?? resolveKnownSpaceLastSeenTimestamp(space.lastSeenTs);
|
|
65979
66152
|
}
|
|
65980
66153
|
function resolveKnownSpaceLastSeenTimestamp(value) {
|
|
65981
66154
|
if (typeof value !== "number" || !Number.isFinite(value) || value < 0xe8d4a51000) return null;
|
|
@@ -66066,7 +66239,7 @@ function resolveSpaceMemberJoinOnlyReason(candidate) {
|
|
|
66066
66239
|
if (candidate.controllerEnabled !== true || typeof candidate.agentControllerRef !== "string" || candidate.agentControllerRef.trim().length === 0) return "Not connected to a local agent on this device yet.";
|
|
66067
66240
|
if (candidate.localParticipationReadiness === "not_running") return "ATS Service is not running on this device.";
|
|
66068
66241
|
if (candidate.localParticipationReadiness === "not_installed") return "ATS Service is not installed on this device.";
|
|
66069
|
-
const reasonText = normalizeOptionalString$
|
|
66242
|
+
const reasonText = normalizeOptionalString$11(candidate.localParticipationReasonText);
|
|
66070
66243
|
if (reasonText) {
|
|
66071
66244
|
const sanitizedReasonText = sanitizeSingleLinePromptText(reasonText);
|
|
66072
66245
|
if (sanitizedReasonText) return sanitizedReasonText.endsWith(".") ? sanitizedReasonText : `${sanitizedReasonText}.`;
|
|
@@ -66098,7 +66271,7 @@ function formatSpaceMemberRecoveryNextAction(action) {
|
|
|
66098
66271
|
return `Use \`${formatAtsCliCommand(action.command)}\` to check the local reply path.`;
|
|
66099
66272
|
}
|
|
66100
66273
|
function resolveSpaceMemberTerminalProfileLabel(profileName) {
|
|
66101
|
-
return sanitizeSingleLinePromptText(normalizeOptionalString$
|
|
66274
|
+
return sanitizeSingleLinePromptText(normalizeOptionalString$11(profileName)) || "This agent";
|
|
66102
66275
|
}
|
|
66103
66276
|
function resolveSpaceMemberTerminalLocalTargetLabel(input) {
|
|
66104
66277
|
const displayName = sanitizeSingleLinePromptText(input.displayName);
|
|
@@ -66152,8 +66325,8 @@ function formatKnownSpaceDeletedNoticeMessage(deletedNotices) {
|
|
|
66152
66325
|
}
|
|
66153
66326
|
function formatKnownSpaceDeletedNoticeLabel(item, resolvedView) {
|
|
66154
66327
|
const name = sanitizeSingleLinePromptText(item.spaceName) || shortenSpaceId(item.spaceId);
|
|
66155
|
-
const deletedByName = normalizeOptionalString$
|
|
66156
|
-
const deletedById = normalizeOptionalString$
|
|
66328
|
+
const deletedByName = normalizeOptionalString$11(item.deletedByProfileName);
|
|
66329
|
+
const deletedById = normalizeOptionalString$11(item.deletedByProfileId);
|
|
66157
66330
|
if (resolvedView === "human") return deletedByName ? `${name} (deleted by ${sanitizeSingleLinePromptText(deletedByName)})` : `${name} (deleted)`;
|
|
66158
66331
|
if (deletedByName && deletedById) return `${name} (deleted by ${sanitizeSingleLinePromptText(deletedByName)} · ${sanitizeSingleLinePromptText(deletedById)})`;
|
|
66159
66332
|
if (deletedByName) return `${name} (deleted by ${sanitizeSingleLinePromptText(deletedByName)})`;
|
|
@@ -66842,7 +67015,7 @@ function buildHumanKnownSpaceSearchText(input) {
|
|
|
66842
67015
|
formatSpaceDisplayValue(projection.spaceName, ""),
|
|
66843
67016
|
formatSpaceDisplayValue(projection.creatorProfileName, ""),
|
|
66844
67017
|
formatSpaceDisplayValue(projection.creatorProfileId, ""),
|
|
66845
|
-
sanitizeSingleLinePromptText(normalizeOptionalString$
|
|
67018
|
+
sanitizeSingleLinePromptText(normalizeOptionalString$11(input.space.creatorOwnerUserId)),
|
|
66846
67019
|
formatSpaceDisplayValue(projection.availableViaProfileName, ""),
|
|
66847
67020
|
formatSpaceDisplayValue(projection.availableViaProfileId, ""),
|
|
66848
67021
|
formatSpaceDisplayValue(projection.creatorDisplayName, ""),
|
|
@@ -67240,15 +67413,15 @@ function requireReadableSpaceConfigList(result, operation) {
|
|
|
67240
67413
|
return result.items;
|
|
67241
67414
|
}
|
|
67242
67415
|
function filterKnownSpacesCreatedByProfile(input) {
|
|
67243
|
-
const profileId = normalizeOptionalString$
|
|
67416
|
+
const profileId = normalizeOptionalString$11(input.profileId);
|
|
67244
67417
|
if (!profileId) return [];
|
|
67245
67418
|
return input.known.filter((item) => {
|
|
67246
|
-
return (typeof item.creatorProfileId === "string" ? normalizeOptionalString$
|
|
67419
|
+
return (typeof item.creatorProfileId === "string" ? normalizeOptionalString$11(item.creatorProfileId) : null) === profileId;
|
|
67247
67420
|
});
|
|
67248
67421
|
}
|
|
67249
67422
|
async function resolveOwnedKnownSpacesForDelete(input) {
|
|
67250
|
-
const currentProfileId = normalizeOptionalString$
|
|
67251
|
-
const currentOwnerUserId = normalizeOptionalString$
|
|
67423
|
+
const currentProfileId = normalizeOptionalString$11(input.atsProfileId);
|
|
67424
|
+
const currentOwnerUserId = normalizeOptionalString$11(input.ownerUserId);
|
|
67252
67425
|
if (!currentProfileId) return [];
|
|
67253
67426
|
const owned = [];
|
|
67254
67427
|
for (const candidate of input.known) {
|
|
@@ -67326,21 +67499,21 @@ async function findKnownSpaceForDeleteBySpaceId(input) {
|
|
|
67326
67499
|
}
|
|
67327
67500
|
function classifyKnownSpaceOwnershipForDelete(input) {
|
|
67328
67501
|
const creatorKind = resolveMetaCreatorKind(input.item.creatorKind);
|
|
67329
|
-
const creatorProfileId = normalizeOptionalString$
|
|
67502
|
+
const creatorProfileId = normalizeOptionalString$11(input.item.creatorProfileId);
|
|
67330
67503
|
if (!creatorKind) return "unknown";
|
|
67331
67504
|
if (creatorKind === "system") return "foreign";
|
|
67332
67505
|
if (creatorKind === "human") {
|
|
67333
67506
|
if (!creatorProfileId) return "unknown";
|
|
67334
67507
|
return creatorProfileId === input.currentProfileId ? "owned" : "foreign";
|
|
67335
67508
|
}
|
|
67336
|
-
const creatorOwnerUserId = normalizeOptionalString$
|
|
67509
|
+
const creatorOwnerUserId = normalizeOptionalString$11(input.item.creatorOwnerUserId);
|
|
67337
67510
|
if (!(creatorOwnerUserId && input.currentOwnerUserId)) return "unknown";
|
|
67338
67511
|
return creatorOwnerUserId === input.currentOwnerUserId ? "owned" : "foreign";
|
|
67339
67512
|
}
|
|
67340
67513
|
function shouldHydrateCreatorProfileNameForDelete(input) {
|
|
67341
|
-
if (normalizeOptionalString$
|
|
67514
|
+
if (normalizeOptionalString$11(input.item.creatorProfileName)) return false;
|
|
67342
67515
|
const creatorKind = resolveMetaCreatorKind(input.item.creatorKind);
|
|
67343
|
-
const creatorProfileId = normalizeOptionalString$
|
|
67516
|
+
const creatorProfileId = normalizeOptionalString$11(input.item.creatorProfileId);
|
|
67344
67517
|
if (creatorKind === "human" && creatorProfileId === input.currentProfileId) return false;
|
|
67345
67518
|
return true;
|
|
67346
67519
|
}
|
|
@@ -67357,9 +67530,9 @@ async function hydrateKnownSpaceForDeleteFromMeta(input) {
|
|
|
67357
67530
|
const creatorProfileName = resolveMetaCreatorProfileName(meta.creator);
|
|
67358
67531
|
const creatorOwnerUserId = resolveMetaCreatorOwnerUserId(meta.creator);
|
|
67359
67532
|
const creatorKind = resolveMetaCreatorKind(meta.creator?.kind);
|
|
67360
|
-
const spaceName = typeof meta.name === "string" ? normalizeOptionalString$
|
|
67361
|
-
const spaceCreatedAt = typeof meta.createdAt === "string" ? normalizeOptionalString$
|
|
67362
|
-
const spaceUpdatedAt = typeof meta.updatedAt === "string" ? normalizeOptionalString$
|
|
67533
|
+
const spaceName = typeof meta.name === "string" ? normalizeOptionalString$11(meta.name) : null;
|
|
67534
|
+
const spaceCreatedAt = typeof meta.createdAt === "string" ? normalizeOptionalString$11(meta.createdAt) : null;
|
|
67535
|
+
const spaceUpdatedAt = typeof meta.updatedAt === "string" ? normalizeOptionalString$11(meta.updatedAt) : null;
|
|
67363
67536
|
return {
|
|
67364
67537
|
...input.item,
|
|
67365
67538
|
...spaceName === null ? {} : { name: spaceName },
|
|
@@ -67375,11 +67548,11 @@ async function hydrateKnownSpaceForDeleteFromMeta(input) {
|
|
|
67375
67548
|
}
|
|
67376
67549
|
}
|
|
67377
67550
|
function applyKnownSpaceDeleteCreatorFallback(input) {
|
|
67378
|
-
const creatorProfileName = normalizeOptionalString$
|
|
67379
|
-
const creatorOwnerUserId = normalizeOptionalString$
|
|
67380
|
-
const creatorProfileId = normalizeOptionalString$
|
|
67381
|
-
const nextCreatorProfileName = creatorProfileName ?? (creatorProfileId === input.currentProfileId ? normalizeOptionalString$
|
|
67382
|
-
const nextCreatorOwnerUserId = creatorOwnerUserId ?? normalizeOptionalString$
|
|
67551
|
+
const creatorProfileName = normalizeOptionalString$11(input.item.creatorProfileName);
|
|
67552
|
+
const creatorOwnerUserId = normalizeOptionalString$11(input.item.creatorOwnerUserId);
|
|
67553
|
+
const creatorProfileId = normalizeOptionalString$11(input.item.creatorProfileId);
|
|
67554
|
+
const nextCreatorProfileName = creatorProfileName ?? (creatorProfileId === input.currentProfileId ? normalizeOptionalString$11(input.currentProfileName) : null);
|
|
67555
|
+
const nextCreatorOwnerUserId = creatorOwnerUserId ?? normalizeOptionalString$11(input.currentOwnerUserId);
|
|
67383
67556
|
if (nextCreatorProfileName === creatorProfileName && nextCreatorOwnerUserId === creatorOwnerUserId) return input.item;
|
|
67384
67557
|
return {
|
|
67385
67558
|
...input.item,
|
|
@@ -67549,9 +67722,9 @@ function maybeEmitSpaceCacheMaintenanceNotice(input) {
|
|
|
67549
67722
|
function normalizeMetaForHistory(meta) {
|
|
67550
67723
|
const creatorProfileId = resolveMetaCreatorProfileId(meta.creator);
|
|
67551
67724
|
const creatorKind = resolveMetaCreatorKind(meta.creator?.kind);
|
|
67552
|
-
const spaceName = typeof meta.name === "string" ? normalizeOptionalString$
|
|
67553
|
-
const spaceCreatedAt = typeof meta.createdAt === "string" ? normalizeOptionalString$
|
|
67554
|
-
const spaceUpdatedAt = typeof meta.updatedAt === "string" ? normalizeOptionalString$
|
|
67725
|
+
const spaceName = typeof meta.name === "string" ? normalizeOptionalString$11(meta.name) : null;
|
|
67726
|
+
const spaceCreatedAt = typeof meta.createdAt === "string" ? normalizeOptionalString$11(meta.createdAt) : null;
|
|
67727
|
+
const spaceUpdatedAt = typeof meta.updatedAt === "string" ? normalizeOptionalString$11(meta.updatedAt) : null;
|
|
67555
67728
|
if (!(spaceName !== null || creatorProfileId !== null || creatorKind !== null || spaceCreatedAt !== null || spaceUpdatedAt !== null)) return null;
|
|
67556
67729
|
return {
|
|
67557
67730
|
...spaceName === null ? {} : { spaceName },
|
|
@@ -67563,19 +67736,19 @@ function normalizeMetaForHistory(meta) {
|
|
|
67563
67736
|
}
|
|
67564
67737
|
function resolveMetaCreatorProfileId(creator) {
|
|
67565
67738
|
if (!creator || typeof creator !== "object") return null;
|
|
67566
|
-
if (typeof creator.profileId === "string") return normalizeOptionalString$
|
|
67567
|
-
if (typeof creator.profile === "string") return normalizeOptionalString$
|
|
67739
|
+
if (typeof creator.profileId === "string") return normalizeOptionalString$11(creator.profileId);
|
|
67740
|
+
if (typeof creator.profile === "string") return normalizeOptionalString$11(creator.profile);
|
|
67568
67741
|
return null;
|
|
67569
67742
|
}
|
|
67570
67743
|
function resolveMetaCreatorProfileName(creator) {
|
|
67571
67744
|
if (!creator || typeof creator !== "object") return null;
|
|
67572
67745
|
if (typeof creator.profileName !== "string") return null;
|
|
67573
|
-
return normalizeOptionalString$
|
|
67746
|
+
return normalizeOptionalString$11(creator.profileName);
|
|
67574
67747
|
}
|
|
67575
67748
|
function resolveMetaCreatorOwnerUserId(creator) {
|
|
67576
67749
|
if (!creator || typeof creator !== "object") return null;
|
|
67577
67750
|
if (typeof creator.ownerUserId !== "string") return null;
|
|
67578
|
-
return normalizeOptionalString$
|
|
67751
|
+
return normalizeOptionalString$11(creator.ownerUserId);
|
|
67579
67752
|
}
|
|
67580
67753
|
function resolveMetaCreatorKind(kind) {
|
|
67581
67754
|
if (kind === "human" || kind === "agent" || kind === "system") return kind;
|
|
@@ -82055,18 +82228,18 @@ function normalizeSpaceJoinMembershipCandidate(value) {
|
|
|
82055
82228
|
profileKind,
|
|
82056
82229
|
alreadyJoined: candidate.alreadyJoined === true,
|
|
82057
82230
|
needsActivation: candidate.needsActivation === true,
|
|
82058
|
-
profileHandle: normalizeOptionalString$
|
|
82059
|
-
ownerProfileName: normalizeOptionalString$
|
|
82060
|
-
ownerUserId: normalizeOptionalString$
|
|
82061
|
-
ownerName: normalizeOptionalString$
|
|
82062
|
-
agentControllerRef: normalizeOptionalString$
|
|
82231
|
+
profileHandle: normalizeOptionalString$10(candidate.profileHandle),
|
|
82232
|
+
ownerProfileName: normalizeOptionalString$10(candidate.ownerProfileName),
|
|
82233
|
+
ownerUserId: normalizeOptionalString$10(candidate.ownerUserId),
|
|
82234
|
+
ownerName: normalizeOptionalString$10(candidate.ownerName),
|
|
82235
|
+
agentControllerRef: normalizeOptionalString$10(candidate.agentControllerRef),
|
|
82063
82236
|
controllerEnabled: candidate.controllerEnabled === true
|
|
82064
82237
|
};
|
|
82065
82238
|
}
|
|
82066
82239
|
function resolveSpaceJoinMembershipProfileKind(value) {
|
|
82067
82240
|
return value === "human" || value === "agent" ? value : null;
|
|
82068
82241
|
}
|
|
82069
|
-
function normalizeOptionalString$
|
|
82242
|
+
function normalizeOptionalString$10(value) {
|
|
82070
82243
|
return typeof value === "string" ? value : void 0;
|
|
82071
82244
|
}
|
|
82072
82245
|
function buildLocallyCreatedPendingSpaceJoinMembershipCandidate(profile) {
|
|
@@ -83209,7 +83382,7 @@ async function syncProfileSpaceHistoryForCreate(input) {
|
|
|
83209
83382
|
const gatewayHost = resolveGatewayHost(input.baseUrl);
|
|
83210
83383
|
if (!gatewayHost) return;
|
|
83211
83384
|
const normalizedMeta = input.meta ? normalizeMetaForHistory(input.meta) : null;
|
|
83212
|
-
const fallbackSpaceName = normalizeOptionalString$
|
|
83385
|
+
const fallbackSpaceName = normalizeOptionalString$11(input.fallbackSpaceName);
|
|
83213
83386
|
const historySpaceName = normalizedMeta?.spaceName === void 0 ? fallbackSpaceName : normalizedMeta.spaceName;
|
|
83214
83387
|
const requestContext = buildAtsRequestContextFromProfile({ atsProfile: input.atsProfile });
|
|
83215
83388
|
await upsertProfileSpaceHistory({
|
|
@@ -84032,7 +84205,7 @@ async function runSpaceList(input) {
|
|
|
84032
84205
|
});
|
|
84033
84206
|
}
|
|
84034
84207
|
function resolveSpaceListAccountIndexScope(input) {
|
|
84035
|
-
if (normalizeOptionalString$
|
|
84208
|
+
if (normalizeOptionalString$11(input.explicitProfile)) return "profile";
|
|
84036
84209
|
if (input.atsProfile.profileKind === "human" && input.atsProfile.isDefault === true) return "account";
|
|
84037
84210
|
return "profile";
|
|
84038
84211
|
}
|
|
@@ -84072,13 +84245,13 @@ function buildSpaceListProofPayload() {
|
|
|
84072
84245
|
}
|
|
84073
84246
|
async function runSpaceAddMembers(input) {
|
|
84074
84247
|
const hasExplicitBaseUrlInput = String(input.baseUrl ?? "").trim().length > 0;
|
|
84075
|
-
const explicitMemberIds = (input.members ?? []).map((memberId) => normalizeOptionalString$
|
|
84248
|
+
const explicitMemberIds = (input.members ?? []).map((memberId) => normalizeOptionalString$11(memberId)).filter((memberId) => Boolean(memberId));
|
|
84076
84249
|
if (input.all === true || explicitMemberIds.length > 0) validateSpaceMemberSelectionInput({
|
|
84077
84250
|
all: input.all === true,
|
|
84078
84251
|
command: resolveSpaceAddMembersSelectionCommand(input.mode ?? "profiles"),
|
|
84079
84252
|
explicitMemberIds
|
|
84080
84253
|
});
|
|
84081
|
-
const currentProfileId = normalizeOptionalString$
|
|
84254
|
+
const currentProfileId = normalizeOptionalString$11(input.profile) ?? getCurrentCommandCheckState().selectedProfile?.profile?.atsProfileId ?? null;
|
|
84082
84255
|
if (currentProfileId && explicitMemberIds.includes(currentProfileId) && input.allowCurrentProfileMember !== true) throw createSpaceAddMembersCurrentProfileGuideError({ profileId: currentProfileId });
|
|
84083
84256
|
const context = await prepareAuthenticatedSpaceCommandContext({
|
|
84084
84257
|
profile: input.profile,
|
|
@@ -84155,8 +84328,8 @@ async function runSpaceAddMembers(input) {
|
|
|
84155
84328
|
}
|
|
84156
84329
|
async function runSpaceRemoveMembers(input) {
|
|
84157
84330
|
const hasExplicitBaseUrlInput = String(input.baseUrl ?? "").trim().length > 0;
|
|
84158
|
-
const explicitMemberIds = (input.members ?? []).map((memberId) => normalizeOptionalString$
|
|
84159
|
-
const currentProfileId = normalizeOptionalString$
|
|
84331
|
+
const explicitMemberIds = (input.members ?? []).map((memberId) => normalizeOptionalString$11(memberId)).filter((memberId) => Boolean(memberId));
|
|
84332
|
+
const currentProfileId = normalizeOptionalString$11(input.profile) ?? getCurrentCommandCheckState().selectedProfile?.profile?.atsProfileId ?? null;
|
|
84160
84333
|
if (currentProfileId && explicitMemberIds.includes(currentProfileId)) throw createSpaceRemoveMembersCurrentProfileGuideError({ profileId: currentProfileId });
|
|
84161
84334
|
const context = await prepareAuthenticatedSpaceCommandContext({
|
|
84162
84335
|
profile: input.profile,
|
|
@@ -85244,7 +85417,7 @@ async function runSpaceDelete(input) {
|
|
|
85244
85417
|
if (atsProfile.profileKind !== "human") throw createSpaceDeleteHumanApprovalGuideError("space delete requires a human ATS profile.");
|
|
85245
85418
|
const atsProfileId = atsProfile.atsProfileId;
|
|
85246
85419
|
const accountContext = await resolveCurrentAtsAccountContext().catch(() => null);
|
|
85247
|
-
const ownerUserIdForDelete = normalizeOptionalString$
|
|
85420
|
+
const ownerUserIdForDelete = normalizeOptionalString$11(atsProfile.ownerUserId) ?? normalizeOptionalString$11(accountContext?.user?.id) ?? void 0;
|
|
85248
85421
|
for (;;) {
|
|
85249
85422
|
const targets = await resolveSpaceDeleteTargets({
|
|
85250
85423
|
atsProfile: {
|
|
@@ -85454,7 +85627,7 @@ async function deleteSpaceTargetWithCleanup(input) {
|
|
|
85454
85627
|
return true;
|
|
85455
85628
|
}
|
|
85456
85629
|
async function deleteSpaceWithHumanFallback(input) {
|
|
85457
|
-
const approvedAgentCreatorProfileId = input.target.creatorKind === "agent" ? normalizeOptionalString$
|
|
85630
|
+
const approvedAgentCreatorProfileId = input.target.creatorKind === "agent" ? normalizeOptionalString$11(input.target.creatorProfileId) ?? void 0 : void 0;
|
|
85458
85631
|
let nextDeletePassword = input.password;
|
|
85459
85632
|
let lastPasswordError = null;
|
|
85460
85633
|
for (let attempt = 0; attempt < MAX_DELETE_PASSWORD_PROMPT_ATTEMPTS; attempt += 1) try {
|
|
@@ -85589,7 +85762,7 @@ function isAuthUpstreamUnavailableError(input) {
|
|
|
85589
85762
|
function summarizeFailedDeleteTargets(failures) {
|
|
85590
85763
|
const MAX_VISIBLE = 3;
|
|
85591
85764
|
const names = failures.slice(0, MAX_VISIBLE).map((item) => {
|
|
85592
|
-
const label = normalizeOptionalString$
|
|
85765
|
+
const label = normalizeOptionalString$11(item.target.name);
|
|
85593
85766
|
if (label) return label;
|
|
85594
85767
|
return item.target.space;
|
|
85595
85768
|
});
|
|
@@ -86112,7 +86285,7 @@ async function resolveSpaceLeaveTarget(input) {
|
|
|
86112
86285
|
async function confirmSpaceLeave(input) {
|
|
86113
86286
|
if (!(input.allowPrompt && input.resolvedView === "human")) return "confirmed";
|
|
86114
86287
|
const confirmed = await confirm({
|
|
86115
|
-
message: `Leave space ${normalizeOptionalString$
|
|
86288
|
+
message: `Leave space ${normalizeOptionalString$11(input.target.name) ?? input.target.space}? You will stop seeing this space in your active list.`,
|
|
86116
86289
|
initialValue: false
|
|
86117
86290
|
});
|
|
86118
86291
|
if (isCancel(confirmed)) {
|
|
@@ -86314,7 +86487,7 @@ async function resolveSpaceMemberCandidatesForRemove(input) {
|
|
|
86314
86487
|
requestContext: buildAtsRequestContextFromProfile({ atsProfile: input.currentProfile }),
|
|
86315
86488
|
...input.password === void 0 ? {} : { spacePassword: input.password }
|
|
86316
86489
|
});
|
|
86317
|
-
const currentOwnerUserId = normalizeOptionalString$
|
|
86490
|
+
const currentOwnerUserId = normalizeOptionalString$11(input.currentOwnerUserId);
|
|
86318
86491
|
const creatorProfileIds = /* @__PURE__ */ new Set();
|
|
86319
86492
|
const allProfiles = await listAtsProfiles();
|
|
86320
86493
|
const localProfileById = new Map(allProfiles.map((profile) => [profile.atsProfileId, profile]));
|
|
@@ -86323,7 +86496,7 @@ async function resolveSpaceMemberCandidatesForRemove(input) {
|
|
|
86323
86496
|
for (const member of snapshotMembers) if (member.memberSource === "space_creator") creatorProfileIds.add(member.profileId);
|
|
86324
86497
|
const activeMembers = snapshotMembers.filter((member) => {
|
|
86325
86498
|
if (!currentOwnerUserId) return true;
|
|
86326
|
-
return normalizeOptionalString$
|
|
86499
|
+
return normalizeOptionalString$11(member.ownerUserId) === currentOwnerUserId;
|
|
86327
86500
|
}).filter((member) => member.profileId !== input.currentProfile.atsProfileId).filter((member) => member.memberSource !== "space_creator").map((member) => hydrateSpaceRemoveMemberCandidate({
|
|
86328
86501
|
candidate: toSpaceRemoveMemberCandidateFromSnapshot({
|
|
86329
86502
|
member,
|
|
@@ -86340,7 +86513,7 @@ async function resolveSpaceMemberCandidatesForRemove(input) {
|
|
|
86340
86513
|
const { profileKind } = profile;
|
|
86341
86514
|
if (profile.status !== "active" || !isSpaceMembershipProfileKind(profileKind)) continue;
|
|
86342
86515
|
if (profile.atsProfileId === input.currentProfile.atsProfileId) continue;
|
|
86343
|
-
if (currentOwnerUserId && normalizeOptionalString$
|
|
86516
|
+
if (currentOwnerUserId && normalizeOptionalString$11(profile.ownerUserId) !== currentOwnerUserId) continue;
|
|
86344
86517
|
explicitFallbackById.set(profile.atsProfileId, toSpaceRemoveMemberCandidateFromProfile({
|
|
86345
86518
|
...profile,
|
|
86346
86519
|
profileKind
|
|
@@ -86356,8 +86529,8 @@ function buildOwnerProfileNameByOwnerUserId(profiles) {
|
|
|
86356
86529
|
const ownerProfileMap = /* @__PURE__ */ new Map();
|
|
86357
86530
|
const activeHumanProfiles = profiles.filter((profile) => profile.status === "active").filter((profile) => profile.profileKind === "human");
|
|
86358
86531
|
for (const profile of activeHumanProfiles) {
|
|
86359
|
-
const ownerUserId = normalizeOptionalString$
|
|
86360
|
-
const profileName = normalizeOptionalString$
|
|
86532
|
+
const ownerUserId = normalizeOptionalString$11(profile.ownerUserId);
|
|
86533
|
+
const profileName = normalizeOptionalString$11(profile.profileName);
|
|
86361
86534
|
if (!(ownerUserId && profileName)) continue;
|
|
86362
86535
|
if (!ownerProfileMap.has(ownerUserId)) {
|
|
86363
86536
|
ownerProfileMap.set(ownerUserId, profileName);
|
|
@@ -86671,7 +86844,7 @@ async function applySpaceAddMembers(input) {
|
|
|
86671
86844
|
const alreadyMemberProfileIds = new Set(response.alreadyMemberIds);
|
|
86672
86845
|
const responseItemByProfileId = new Map(response.items.map((item) => [item.profileId, item]));
|
|
86673
86846
|
const lastJoinedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
86674
|
-
const spaceName = normalizeOptionalString$
|
|
86847
|
+
const spaceName = normalizeOptionalString$11(input.spaceName);
|
|
86675
86848
|
for (const candidate of selectedCandidates) {
|
|
86676
86849
|
const nextCandidate = hydrateSpaceMemberCandidateFromResponseItem({
|
|
86677
86850
|
candidate,
|
|
@@ -86714,14 +86887,14 @@ function hydrateSpaceMemberCandidateFromResponseItem(input) {
|
|
|
86714
86887
|
...input.candidate,
|
|
86715
86888
|
profileName: input.item.profileName,
|
|
86716
86889
|
profileKind: input.item.profileKind,
|
|
86717
|
-
ownerUserId: normalizeOptionalString$
|
|
86718
|
-
ownerName: normalizeOptionalString$
|
|
86890
|
+
ownerUserId: normalizeOptionalString$11(input.item.ownerUserId) ?? void 0,
|
|
86891
|
+
ownerName: normalizeOptionalString$11(input.item.ownerName) ?? void 0,
|
|
86719
86892
|
targetMentionLabel: resolvePrimaryMentionLabelFromSpaceMemberItem(input.item),
|
|
86720
|
-
...input.item.profileKind === "agent" ? { agentControllerRef: normalizeOptionalString$
|
|
86893
|
+
...input.item.profileKind === "agent" ? { agentControllerRef: normalizeOptionalString$11(input.item.agentControllerRef) ?? input.candidate.agentControllerRef } : {}
|
|
86721
86894
|
};
|
|
86722
86895
|
}
|
|
86723
86896
|
function resolvePrimaryMentionLabelFromSpaceMemberItem(item) {
|
|
86724
|
-
const mentionAlias = normalizeOptionalString$
|
|
86897
|
+
const mentionAlias = normalizeOptionalString$11(item.mentionAlias);
|
|
86725
86898
|
if (mentionAlias) return mentionAlias;
|
|
86726
86899
|
return resolveSingleSpaceMentionLabels({
|
|
86727
86900
|
mentionAlias,
|
|
@@ -87150,7 +87323,7 @@ async function persistSpaceAddMembersJoinNotices(input) {
|
|
|
87150
87323
|
function buildKnownMentionLabelByProfileId(members) {
|
|
87151
87324
|
const labelsByProfileId = /* @__PURE__ */ new Map();
|
|
87152
87325
|
for (const member of members) {
|
|
87153
|
-
const targetMentionLabel = normalizeOptionalString$
|
|
87326
|
+
const targetMentionLabel = normalizeOptionalString$11(member.targetMentionLabel);
|
|
87154
87327
|
if (targetMentionLabel) labelsByProfileId.set(member.profileId, targetMentionLabel);
|
|
87155
87328
|
}
|
|
87156
87329
|
return labelsByProfileId;
|
|
@@ -87290,9 +87463,9 @@ function buildHumanSpaceRemoveMemberCandidateSearchText(candidate) {
|
|
|
87290
87463
|
sanitizeSingleLinePromptText(candidate.profileId),
|
|
87291
87464
|
sanitizeSingleLinePromptText(candidate.profileName),
|
|
87292
87465
|
sanitizeSingleLinePromptText(candidate.profileKind),
|
|
87293
|
-
sanitizeSingleLinePromptText(normalizeOptionalString$
|
|
87294
|
-
sanitizeSingleLinePromptText(normalizeOptionalString$
|
|
87295
|
-
sanitizeSingleLinePromptText(normalizeOptionalString$
|
|
87466
|
+
sanitizeSingleLinePromptText(normalizeOptionalString$11(candidate.profileHandle)),
|
|
87467
|
+
sanitizeSingleLinePromptText(normalizeOptionalString$11(candidate.ownerName)),
|
|
87468
|
+
sanitizeSingleLinePromptText(normalizeOptionalString$11(candidate.ownerUserId))
|
|
87296
87469
|
].filter((value) => typeof value === "string").join("\n");
|
|
87297
87470
|
}
|
|
87298
87471
|
function formatSpaceMemberCandidateLabel(candidate) {
|
|
@@ -87326,10 +87499,10 @@ function buildHumanSpaceMemberCandidateSearchText(candidate) {
|
|
|
87326
87499
|
sanitizeSingleLinePromptText(candidate.profileId),
|
|
87327
87500
|
sanitizeSingleLinePromptText(candidate.profileName),
|
|
87328
87501
|
sanitizeSingleLinePromptText(candidate.profileKind),
|
|
87329
|
-
sanitizeSingleLinePromptText(normalizeOptionalString$
|
|
87330
|
-
sanitizeSingleLinePromptText(normalizeOptionalString$
|
|
87331
|
-
sanitizeSingleLinePromptText(normalizeOptionalString$
|
|
87332
|
-
sanitizeSingleLinePromptText(normalizeOptionalString$
|
|
87502
|
+
sanitizeSingleLinePromptText(normalizeOptionalString$11(candidate.ownerProfileName)),
|
|
87503
|
+
sanitizeSingleLinePromptText(normalizeOptionalString$11(candidate.ownerName)),
|
|
87504
|
+
sanitizeSingleLinePromptText(normalizeOptionalString$11(candidate.ownerUserId)),
|
|
87505
|
+
sanitizeSingleLinePromptText(normalizeOptionalString$11(candidate.agentControllerRef)),
|
|
87333
87506
|
...resolveSpaceMemberCandidateStatusBadges(candidate),
|
|
87334
87507
|
candidate.alreadyJoined ? "already in this space" : null,
|
|
87335
87508
|
candidate.needsActivation ? "needs mention setup" : null
|
|
@@ -87350,15 +87523,15 @@ function toSpaceRemoveMemberCandidateFromSnapshot(input) {
|
|
|
87350
87523
|
profileId: input.member.profileId,
|
|
87351
87524
|
profileName: input.member.profileName,
|
|
87352
87525
|
profileKind: input.member.profileKind,
|
|
87353
|
-
targetMentionLabel: normalizeOptionalString$
|
|
87354
|
-
ownerUserId: normalizeOptionalString$
|
|
87355
|
-
ownerName: normalizeOptionalString$
|
|
87356
|
-
creatorProfileId: input.member.memberSource === "space_creator" ? normalizeOptionalString$
|
|
87526
|
+
targetMentionLabel: normalizeOptionalString$11(input.targetMentionLabel),
|
|
87527
|
+
ownerUserId: normalizeOptionalString$11(input.member.ownerUserId),
|
|
87528
|
+
ownerName: normalizeOptionalString$11(input.member.ownerName),
|
|
87529
|
+
creatorProfileId: input.member.memberSource === "space_creator" ? normalizeOptionalString$11(input.member.profileId) : null
|
|
87357
87530
|
};
|
|
87358
87531
|
}
|
|
87359
87532
|
function hydrateSpaceRemoveMemberCandidate(input) {
|
|
87360
87533
|
if (input.candidate.profileHandle) return input.candidate;
|
|
87361
|
-
const profileHandle = normalizeOptionalString$
|
|
87534
|
+
const profileHandle = normalizeOptionalString$11(input.profile?.profileHandle);
|
|
87362
87535
|
if (!profileHandle) return input.candidate;
|
|
87363
87536
|
return {
|
|
87364
87537
|
...input.candidate,
|
|
@@ -87372,8 +87545,8 @@ function toSpaceRemoveMemberCandidateFromProfile(profile) {
|
|
|
87372
87545
|
profileName: profile.profileName,
|
|
87373
87546
|
profileKind: profile.profileKind,
|
|
87374
87547
|
targetMentionLabel: null,
|
|
87375
|
-
ownerUserId: normalizeOptionalString$
|
|
87376
|
-
ownerName: normalizeOptionalString$
|
|
87548
|
+
ownerUserId: normalizeOptionalString$11(profile.ownerUserId),
|
|
87549
|
+
ownerName: normalizeOptionalString$11(profile.ownerName),
|
|
87377
87550
|
creatorProfileId: null
|
|
87378
87551
|
};
|
|
87379
87552
|
}
|
|
@@ -87647,7 +87820,7 @@ async function deleteSpace(input) {
|
|
|
87647
87820
|
atsProfile: input.atsProfile,
|
|
87648
87821
|
spacePassword: input.password
|
|
87649
87822
|
});
|
|
87650
|
-
const approvedAgentCreatorProfileId = normalizeOptionalString$
|
|
87823
|
+
const approvedAgentCreatorProfileId = normalizeOptionalString$11(input.approvedAgentCreatorProfileId);
|
|
87651
87824
|
if (approvedAgentCreatorProfileId) headers["content-type"] = "application/json";
|
|
87652
87825
|
const response = await fetchSpaceRequestWithTimeout({
|
|
87653
87826
|
url: endpoint,
|
|
@@ -87930,7 +88103,7 @@ function ensureStartAgentIdentityPreflight(input) {
|
|
|
87930
88103
|
}
|
|
87931
88104
|
function shouldEnsureDefaultHumanProfile(input) {
|
|
87932
88105
|
if (input.resolvedView !== "human") return false;
|
|
87933
|
-
if (normalizeOptionalString$
|
|
88106
|
+
if (normalizeOptionalString$9(input.profileId) ?? normalizeOptionalString$9(input.profile)) return false;
|
|
87934
88107
|
return resolveCreateProfileInputFromArgs(input) === null;
|
|
87935
88108
|
}
|
|
87936
88109
|
function renderDefaultHumanProfileCard(input) {
|
|
@@ -88028,9 +88201,9 @@ async function resolveStartSelectedProfileFromArguments(input) {
|
|
|
88028
88201
|
return { handled: false };
|
|
88029
88202
|
}
|
|
88030
88203
|
function resolveExplicitStartProfile(input) {
|
|
88031
|
-
const explicitProfileId = normalizeOptionalString$
|
|
88204
|
+
const explicitProfileId = normalizeOptionalString$9(input.profileId);
|
|
88032
88205
|
if (explicitProfileId) return resolveAtsProfile({ atsProfileId: explicitProfileId });
|
|
88033
|
-
const explicitProfile = normalizeOptionalString$
|
|
88206
|
+
const explicitProfile = normalizeOptionalString$9(input.profile);
|
|
88034
88207
|
if (!explicitProfile) return Promise.resolve(null);
|
|
88035
88208
|
return resolveAtsProfile({ atsProfileId: explicitProfile }).catch(async () => {
|
|
88036
88209
|
const matched = (await listAtsProfiles()).find((profile) => profile.profileName.toLowerCase() === explicitProfile.toLowerCase());
|
|
@@ -88140,7 +88313,7 @@ async function resolveInteractiveStartProfileSearchSelection(input) {
|
|
|
88140
88313
|
}
|
|
88141
88314
|
function resolveCreateProfileInputFromArgs(input) {
|
|
88142
88315
|
const kind = parseStartProfileKind(input.kind);
|
|
88143
|
-
const profileName = normalizeOptionalString$
|
|
88316
|
+
const profileName = normalizeOptionalString$9(input.profileName) ?? (kind === "agent" ? normalizeOptionalString$9(input.agentName) : null);
|
|
88144
88317
|
if (!(kind && profileName)) return null;
|
|
88145
88318
|
return {
|
|
88146
88319
|
kind,
|
|
@@ -88148,11 +88321,11 @@ function resolveCreateProfileInputFromArgs(input) {
|
|
|
88148
88321
|
};
|
|
88149
88322
|
}
|
|
88150
88323
|
function inspectStartAgentIdentityInput(input) {
|
|
88151
|
-
if (normalizeOptionalString$
|
|
88152
|
-
const rawKind = normalizeOptionalString$
|
|
88324
|
+
if (normalizeOptionalString$9(input.profileId) ?? normalizeOptionalString$9(input.profile)) return { status: "valid" };
|
|
88325
|
+
const rawKind = normalizeOptionalString$9(input.kind);
|
|
88153
88326
|
const parsedKind = parseStartProfileKind(input.kind);
|
|
88154
|
-
const rawProfileName = normalizeOptionalString$
|
|
88155
|
-
const rawAgentName = normalizeOptionalString$
|
|
88327
|
+
const rawProfileName = normalizeOptionalString$9(input.profileName);
|
|
88328
|
+
const rawAgentName = normalizeOptionalString$9(input.agentName);
|
|
88156
88329
|
if (parsedKind === "human") return {
|
|
88157
88330
|
status: "error",
|
|
88158
88331
|
summary: "agent view cannot create human profiles. use --kind agent, or switch to human view."
|
|
@@ -88352,7 +88525,7 @@ function throwStartAgentIdentityGuide(input) {
|
|
|
88352
88525
|
function formatStartProfileKindLabel(profileKind) {
|
|
88353
88526
|
return profileKind === "agent" ? "AI agent" : "human";
|
|
88354
88527
|
}
|
|
88355
|
-
function normalizeOptionalString$
|
|
88528
|
+
function normalizeOptionalString$9(value) {
|
|
88356
88529
|
const normalized = String(value ?? "").trim();
|
|
88357
88530
|
return normalized.length > 0 ? normalized : null;
|
|
88358
88531
|
}
|
|
@@ -90955,7 +91128,7 @@ const CHOOSE_PROFILE = "__command_entry_choose_profile__";
|
|
|
90955
91128
|
const CREATE_PROFILE = "__command_entry_create_profile__";
|
|
90956
91129
|
const CANCEL_PROFILE = "__command_entry_cancel_profile__";
|
|
90957
91130
|
async function runSelectedProfileCheck(input) {
|
|
90958
|
-
const explicitProfileArg = normalizeOptionalString$
|
|
91131
|
+
const explicitProfileArg = normalizeOptionalString$8(input.context.profileArg);
|
|
90959
91132
|
const hasExplicitProfileArg = explicitProfileArg !== null;
|
|
90960
91133
|
const requiresConfirmation = input.requirement.mode === "confirm" && input.context.runtime.resolvedView === "human" && input.context.allowPrompt && !hasExplicitProfileArg;
|
|
90961
91134
|
const currentState = getCurrentCommandCheckState();
|
|
@@ -91128,7 +91301,7 @@ function ensureCurrentProfileIsVisible(input) {
|
|
|
91128
91301
|
function resolveProfileConfirmationMessage(entryName) {
|
|
91129
91302
|
return entryName === "space.join" ? SPACE_JOIN_PROFILE_SELECTION_MESSAGE : SPACE_COMMAND_PROFILE_SELECTION_MESSAGE;
|
|
91130
91303
|
}
|
|
91131
|
-
function normalizeOptionalString$
|
|
91304
|
+
function normalizeOptionalString$8(value) {
|
|
91132
91305
|
const normalized = String(value ?? "").trim();
|
|
91133
91306
|
return normalized.length > 0 ? normalized : null;
|
|
91134
91307
|
}
|
|
@@ -91758,7 +91931,7 @@ async function runCommandWithEntryChecks(input) {
|
|
|
91758
91931
|
allowPrompt: runtime.interactive,
|
|
91759
91932
|
environmentTarget,
|
|
91760
91933
|
gatewayUrl: normalizedGatewayUrl,
|
|
91761
|
-
profileArg: normalizeOptionalString$
|
|
91934
|
+
profileArg: normalizeOptionalString$7(input.profile),
|
|
91762
91935
|
jsonOutput
|
|
91763
91936
|
}),
|
|
91764
91937
|
jsonOutput
|
|
@@ -91767,7 +91940,7 @@ async function runCommandWithEntryChecks(input) {
|
|
|
91767
91940
|
finishCurrentCommandCheckScope();
|
|
91768
91941
|
}
|
|
91769
91942
|
}
|
|
91770
|
-
function normalizeOptionalString$
|
|
91943
|
+
function normalizeOptionalString$7(value) {
|
|
91771
91944
|
const normalized = String(value ?? "").trim();
|
|
91772
91945
|
return normalized.length > 0 ? normalized : null;
|
|
91773
91946
|
}
|
|
@@ -93716,7 +93889,7 @@ async function resolveAgentControllerPermissionModeInput(input) {
|
|
|
93716
93889
|
value: input.agentControllerPermissionModeInput
|
|
93717
93890
|
});
|
|
93718
93891
|
if (!agentControllerPermissionMode) return { hasAnyAgentControllerPermissionModeInput: false };
|
|
93719
|
-
const agentControllerRef = normalizeOptionalString$
|
|
93892
|
+
const agentControllerRef = normalizeOptionalString$6(input.agentControllerRef);
|
|
93720
93893
|
assertAgentControllerPermissionModeSupported({
|
|
93721
93894
|
agentControllerPermissionMode,
|
|
93722
93895
|
agentControllerRef,
|
|
@@ -93737,7 +93910,7 @@ async function resolveAgentControllerPermissionModeInput(input) {
|
|
|
93737
93910
|
};
|
|
93738
93911
|
}
|
|
93739
93912
|
function normalizeAgentControllerPermissionModeCliInput(input) {
|
|
93740
|
-
const raw = normalizeOptionalString$
|
|
93913
|
+
const raw = normalizeOptionalString$6(input.value);
|
|
93741
93914
|
if (!raw) return null;
|
|
93742
93915
|
const options = listAgentControllerPermissionModeOptions(input.agentControllerRef ? { agentControllerRef: input.agentControllerRef } : void 0);
|
|
93743
93916
|
for (const option of options) if (raw === option.value) return option.value;
|
|
@@ -93795,7 +93968,7 @@ const AGENT_CONTROLLER_PERMISSION_MODE_BY_CLI_VALUE = {
|
|
|
93795
93968
|
custom: "codex:customConfig",
|
|
93796
93969
|
customconfig: "codex:customConfig"
|
|
93797
93970
|
};
|
|
93798
|
-
function normalizeOptionalString$
|
|
93971
|
+
function normalizeOptionalString$6(value) {
|
|
93799
93972
|
const normalized = String(value ?? "").trim();
|
|
93800
93973
|
return normalized.length > 0 ? normalized : null;
|
|
93801
93974
|
}
|
|
@@ -94164,7 +94337,7 @@ async function runProfileShow(input) {
|
|
|
94164
94337
|
}
|
|
94165
94338
|
const presenter = createPresenter(runtime);
|
|
94166
94339
|
const allowPrompt = canUseInteractivePrompts(runtime);
|
|
94167
|
-
const explicitProfileId = normalizeOptionalString$
|
|
94340
|
+
const explicitProfileId = normalizeOptionalString$5(input.profile);
|
|
94168
94341
|
const visibleProfiles = explicitProfileId ? [] : await listVisibleProfilesForListByView(runtime.resolvedView);
|
|
94169
94342
|
const current = explicitProfileId ? null : await resolveCurrentProfileId({
|
|
94170
94343
|
profiles: visibleProfiles,
|
|
@@ -94646,7 +94819,7 @@ async function runProfileUpdate(input) {
|
|
|
94646
94819
|
}
|
|
94647
94820
|
const presenter = createPresenter(runtime);
|
|
94648
94821
|
const allowPrompt = canUseInteractivePrompts(runtime);
|
|
94649
|
-
const explicitProfileId = normalizeOptionalString$
|
|
94822
|
+
const explicitProfileId = normalizeOptionalString$5(input.profile);
|
|
94650
94823
|
const visibleProfiles = explicitProfileId ? [] : await listVisibleProfilesForListByView(runtime.resolvedView);
|
|
94651
94824
|
const current = explicitProfileId ? null : await resolveCurrentProfileId({
|
|
94652
94825
|
profiles: visibleProfiles,
|
|
@@ -94880,7 +95053,7 @@ function emitProfileUpdateCandidatesForHuman(input) {
|
|
|
94880
95053
|
}
|
|
94881
95054
|
}
|
|
94882
95055
|
async function resolveProfileUpdatePayload(input) {
|
|
94883
|
-
const profileName = normalizeOptionalString$
|
|
95056
|
+
const profileName = normalizeOptionalString$5(input.profileName);
|
|
94884
95057
|
const explicitAgentController = await resolveExplicitAgentControllerPatchForProfile({
|
|
94885
95058
|
agentController: input.agentController,
|
|
94886
95059
|
agentControllerConversationId: input.agentControllerConversationId,
|
|
@@ -94925,7 +95098,7 @@ async function resolveProfileUpdatePayload(input) {
|
|
|
94925
95098
|
}
|
|
94926
95099
|
function resolveExplicitWorkspacePatchForProfile(input) {
|
|
94927
95100
|
const normalizedMode = normalizeWorkspaceModeInput(input.workspaceMode);
|
|
94928
|
-
const normalizedWorkspacePath = normalizeOptionalString$
|
|
95101
|
+
const normalizedWorkspacePath = normalizeOptionalString$5(input.workspacePath);
|
|
94929
95102
|
if (!(normalizedMode || normalizedWorkspacePath)) return null;
|
|
94930
95103
|
if (input.profile.profileKind !== "agent") throw new Error("Workspace can only be configured for agent profiles.");
|
|
94931
95104
|
if (!normalizedMode) throw new Error("--workspace-path can only be used with --workspace-mode custom.");
|
|
@@ -94958,7 +95131,7 @@ function resolveExplicitModelSelectionPatchForProfile(input) {
|
|
|
94958
95131
|
};
|
|
94959
95132
|
}
|
|
94960
95133
|
async function resolveExplicitAgentControllerPermissionModePatchForProfile(input) {
|
|
94961
|
-
if (!normalizeOptionalString$
|
|
95134
|
+
if (!normalizeOptionalString$5(input.agentControllerPermissionModeInput)) return null;
|
|
94962
95135
|
if (input.profile.profileKind !== "agent") throw new Error("Agent Controller Permission Mode can only be configured for agent profiles.");
|
|
94963
95136
|
const currentBinding = input.agentControllerRef ? null : await resolveAgentProfilePrimaryAgentControllerReport({ profile: input.profile });
|
|
94964
95137
|
const agentControllerRef = input.agentControllerRef ?? currentBinding?.agentControllerRef ?? null;
|
|
@@ -94977,8 +95150,8 @@ async function resolveExplicitAgentControllerPermissionModePatchForProfile(input
|
|
|
94977
95150
|
};
|
|
94978
95151
|
}
|
|
94979
95152
|
async function resolveExplicitAgentControllerPatchForProfile(input) {
|
|
94980
|
-
const agentController = normalizeOptionalString$
|
|
94981
|
-
const agentControllerConversationId = normalizeOptionalString$
|
|
95153
|
+
const agentController = normalizeOptionalString$5(input.agentController);
|
|
95154
|
+
const agentControllerConversationId = normalizeOptionalString$5(input.agentControllerConversationId);
|
|
94982
95155
|
if (!(agentController || agentControllerConversationId)) return null;
|
|
94983
95156
|
if (input.profile.profileKind !== "agent") throw new Error("Agent controller can only be configured for agent profiles.");
|
|
94984
95157
|
if (!agentController) throw new Error("--agent-controller-conversation-id requires --agent-controller.");
|
|
@@ -94992,7 +95165,7 @@ async function resolveExplicitAgentControllerPatchForProfile(input) {
|
|
|
94992
95165
|
};
|
|
94993
95166
|
}
|
|
94994
95167
|
async function applyAgentProfileControllerBinding(input) {
|
|
94995
|
-
const agentControllerRef = normalizeOptionalString$
|
|
95168
|
+
const agentControllerRef = normalizeOptionalString$5(input.agentControllerRef);
|
|
94996
95169
|
const hasModelSelectionPatch = input.modelId !== void 0;
|
|
94997
95170
|
if (!(agentControllerRef || hasModelSelectionPatch)) return;
|
|
94998
95171
|
if (input.profile.profileKind !== "agent") throw new Error("Agent controller can only be configured for agent profiles.");
|
|
@@ -95125,7 +95298,7 @@ async function promptWorkspacePayload(profile) {
|
|
|
95125
95298
|
});
|
|
95126
95299
|
if (workspacePath.status === "cancelled") return { status: "cancelled" };
|
|
95127
95300
|
if (workspacePath.status === "back") continue;
|
|
95128
|
-
const customWorkspacePath = normalizeOptionalString$
|
|
95301
|
+
const customWorkspacePath = normalizeOptionalString$5(workspacePath.value);
|
|
95129
95302
|
if (!customWorkspacePath) throw new Error("Custom workspace path is required.");
|
|
95130
95303
|
return {
|
|
95131
95304
|
status: "submitted",
|
|
@@ -95216,7 +95389,7 @@ async function promptProfileNamePayload(currentProfileName) {
|
|
|
95216
95389
|
});
|
|
95217
95390
|
if (nextName.status === "cancelled") return { status: "cancelled" };
|
|
95218
95391
|
if (nextName.status === "back") return { status: "back" };
|
|
95219
|
-
const profileName = normalizeOptionalString$
|
|
95392
|
+
const profileName = normalizeOptionalString$5(nextName.value);
|
|
95220
95393
|
if (!profileName) throw new Error("profileName is required");
|
|
95221
95394
|
return {
|
|
95222
95395
|
status: "submitted",
|
|
@@ -95472,11 +95645,11 @@ function buildProfileSearchItem(input) {
|
|
|
95472
95645
|
function buildProfileSearchText(profile) {
|
|
95473
95646
|
return [
|
|
95474
95647
|
profile.atsProfileId,
|
|
95475
|
-
normalizeOptionalString$
|
|
95648
|
+
normalizeOptionalString$5(profile.profileName),
|
|
95476
95649
|
profile.profileKind,
|
|
95477
|
-
normalizeOptionalString$
|
|
95478
|
-
normalizeOptionalString$
|
|
95479
|
-
normalizeOptionalString$
|
|
95650
|
+
normalizeOptionalString$5(profile.ownerUserId),
|
|
95651
|
+
normalizeOptionalString$5(profile.ownerName),
|
|
95652
|
+
normalizeOptionalString$5(profile.source)
|
|
95480
95653
|
].filter((value) => typeof value === "string").join("\n");
|
|
95481
95654
|
}
|
|
95482
95655
|
function resolveProfileSelectLabel(input) {
|
|
@@ -95527,7 +95700,7 @@ function normalizeProfileDisplayName(profile) {
|
|
|
95527
95700
|
}
|
|
95528
95701
|
function normalizeAgentControllerArgumentInput(input) {
|
|
95529
95702
|
const agentController = String(input.agentController ?? "").trim();
|
|
95530
|
-
const agentControllerConversationId = normalizeOptionalString$
|
|
95703
|
+
const agentControllerConversationId = normalizeOptionalString$5(input.agentControllerConversationId);
|
|
95531
95704
|
const hasControllerEnabled = typeof input.controllerEnabled === "boolean";
|
|
95532
95705
|
const hasAnyAgentControllerInput = Boolean(agentController) || Boolean(agentControllerConversationId) || hasControllerEnabled;
|
|
95533
95706
|
return {
|
|
@@ -95734,7 +95907,7 @@ function resolveProfileUpdateCommandExamples() {
|
|
|
95734
95907
|
function toProfileActionGuideExamples(_input) {
|
|
95735
95908
|
return {};
|
|
95736
95909
|
}
|
|
95737
|
-
function normalizeOptionalString$
|
|
95910
|
+
function normalizeOptionalString$5(value) {
|
|
95738
95911
|
const normalized = String(value ?? "").trim();
|
|
95739
95912
|
return normalized.length > 0 ? normalized : null;
|
|
95740
95913
|
}
|
|
@@ -95745,8 +95918,8 @@ function normalizeWorkspaceModeInput(value) {
|
|
|
95745
95918
|
throw new Error("--workspace-mode must be ats-managed|custom");
|
|
95746
95919
|
}
|
|
95747
95920
|
function normalizeModelSelectionInput(input) {
|
|
95748
|
-
const modelId = normalizeOptionalString$
|
|
95749
|
-
const reasoningLevel = normalizeOptionalString$
|
|
95921
|
+
const modelId = normalizeOptionalString$5(input.model);
|
|
95922
|
+
const reasoningLevel = normalizeOptionalString$5(input.reasoningEffort);
|
|
95750
95923
|
if (!(modelId || reasoningLevel)) return { hasAnyModelSelectionInput: false };
|
|
95751
95924
|
if (!modelId) throw new Error("--reasoning-effort requires --model.");
|
|
95752
95925
|
return {
|
|
@@ -96782,10 +96955,10 @@ function resolveDaemonDispatchJournalEvidence(dispatchId) {
|
|
|
96782
96955
|
};
|
|
96783
96956
|
}
|
|
96784
96957
|
async function resolveDispatchTraceSelection(input) {
|
|
96785
|
-
const dispatchSelector = normalizeOptionalString$
|
|
96786
|
-
const sourceSignalSelector = normalizeOptionalString$
|
|
96787
|
-
const clientMessageSelector = normalizeOptionalString$
|
|
96788
|
-
const targetProfileSelector = normalizeOptionalString$
|
|
96958
|
+
const dispatchSelector = normalizeOptionalString$4(input.dispatchId);
|
|
96959
|
+
const sourceSignalSelector = normalizeOptionalString$4(input.sourceSignalId);
|
|
96960
|
+
const clientMessageSelector = normalizeOptionalString$4(input.clientMessageId);
|
|
96961
|
+
const targetProfileSelector = normalizeOptionalString$4(input.targetProfileId);
|
|
96789
96962
|
if (Number(dispatchSelector !== null) + Number(sourceSignalSelector !== null) + Number(clientMessageSelector !== null) !== 1) throw new Error("exactly one of dispatchId, sourceSignalId, or clientMessageId is required");
|
|
96790
96963
|
if (dispatchSelector) return {
|
|
96791
96964
|
dispatchId: dispatchSelector,
|
|
@@ -97283,7 +97456,7 @@ function parenthesizedDetail(value, label) {
|
|
|
97283
97456
|
return detail.length > 0 ? detail : null;
|
|
97284
97457
|
}
|
|
97285
97458
|
async function resolveServiceTraceActorProfile(input) {
|
|
97286
|
-
if (normalizeOptionalString$
|
|
97459
|
+
if (normalizeOptionalString$4(input.explicitProfileId) || !canUseInteractivePrompts(input.runtime)) return input.actingProfile;
|
|
97287
97460
|
while (true) {
|
|
97288
97461
|
const selectedAction = await select({
|
|
97289
97462
|
message: `Use ${input.actingProfile.profileName} (${input.actingProfile.atsProfileId}) to read this dispatch trace?`,
|
|
@@ -98107,7 +98280,7 @@ function truncateText(text, maxLength) {
|
|
|
98107
98280
|
if (text.length <= maxLength) return text;
|
|
98108
98281
|
return `${text.slice(0, maxLength)}...`;
|
|
98109
98282
|
}
|
|
98110
|
-
function normalizeOptionalString$
|
|
98283
|
+
function normalizeOptionalString$4(value) {
|
|
98111
98284
|
const normalized = String(value ?? "").trim();
|
|
98112
98285
|
return normalized.length > 0 ? normalized : null;
|
|
98113
98286
|
}
|
|
@@ -98959,6 +99132,289 @@ function readErrorName(error) {
|
|
|
98959
99132
|
return error instanceof Error && error.name.trim().length > 0 ? error.name : null;
|
|
98960
99133
|
}
|
|
98961
99134
|
|
|
99135
|
+
//#endregion
|
|
99136
|
+
//#region src/commands/setup-command-lock.ts
|
|
99137
|
+
const SETUP_COMMAND_LOCK_PROFILE = "setup";
|
|
99138
|
+
const SETUP_COMMAND_LOCK_KEY = "setup-command";
|
|
99139
|
+
const SETUP_GLOBAL_DEADLINE_MS = 900 * 1e3;
|
|
99140
|
+
const SETUP_TAKEOVER_WINDOW_MS = 1e4;
|
|
99141
|
+
const SETUP_TAKEOVER_POLL_MS = 250;
|
|
99142
|
+
const SETUP_DEADLINE_SUPPORT_CODE = "setup.deadline_exceeded";
|
|
99143
|
+
const SETUP_SUPERSEDED_SUPPORT_CODE = "setup.superseded";
|
|
99144
|
+
async function withSetupCommandLock(input) {
|
|
99145
|
+
const acquisition = await acquireSetupCommandLockWithTakeover({
|
|
99146
|
+
lockMeta: input.lockMeta,
|
|
99147
|
+
startSession: input.startSession
|
|
99148
|
+
});
|
|
99149
|
+
if (acquisition.status === "contended") throw buildSetupLockContentionError({
|
|
99150
|
+
contention: acquisition,
|
|
99151
|
+
view: input.view
|
|
99152
|
+
});
|
|
99153
|
+
const { lock } = acquisition;
|
|
99154
|
+
const standDown = installSetupStandDownHandler({
|
|
99155
|
+
lock,
|
|
99156
|
+
view: input.view
|
|
99157
|
+
});
|
|
99158
|
+
const deadline = createSetupGlobalDeadline({ onExpire: () => handleSetupGlobalDeadlineExpiry({
|
|
99159
|
+
lock,
|
|
99160
|
+
view: input.view
|
|
99161
|
+
}) });
|
|
99162
|
+
deadline.arm();
|
|
99163
|
+
try {
|
|
99164
|
+
return await runWithHeldLock({
|
|
99165
|
+
lock,
|
|
99166
|
+
run: input.run,
|
|
99167
|
+
releaseContext: {
|
|
99168
|
+
atsProfileId: SETUP_COMMAND_LOCK_PROFILE,
|
|
99169
|
+
component: "setup_command",
|
|
99170
|
+
lockKey: SETUP_COMMAND_LOCK_KEY
|
|
99171
|
+
}
|
|
99172
|
+
});
|
|
99173
|
+
} finally {
|
|
99174
|
+
deadline.disarm();
|
|
99175
|
+
standDown.remove();
|
|
99176
|
+
}
|
|
99177
|
+
}
|
|
99178
|
+
async function acquireSetupCommandLockWithTakeover(input) {
|
|
99179
|
+
const deps = {
|
|
99180
|
+
...defaultTakeoverDeps(),
|
|
99181
|
+
...input.deps
|
|
99182
|
+
};
|
|
99183
|
+
const first = await deps.tryAcquire(input.lockMeta);
|
|
99184
|
+
if (first.ok) return {
|
|
99185
|
+
lock: first.lock,
|
|
99186
|
+
status: "acquired"
|
|
99187
|
+
};
|
|
99188
|
+
const lockError = first.error;
|
|
99189
|
+
const pid = resolveLockHolderPid(lockError);
|
|
99190
|
+
const startedAtLabel = resolveLockStartedAtLabel(lockError);
|
|
99191
|
+
const contendedBase = {
|
|
99192
|
+
lockError,
|
|
99193
|
+
pid,
|
|
99194
|
+
startedAtLabel
|
|
99195
|
+
};
|
|
99196
|
+
if (!(normalizeOptionalString$3(input.startSession) !== null && pid !== null && pid !== deps.selfPid && deps.probePid(pid) === "alive")) return {
|
|
99197
|
+
status: "contended",
|
|
99198
|
+
...contendedBase,
|
|
99199
|
+
takeoverAttempted: false
|
|
99200
|
+
};
|
|
99201
|
+
if (deps.sendTerm(pid) === "not_permitted") return {
|
|
99202
|
+
status: "contended",
|
|
99203
|
+
...contendedBase,
|
|
99204
|
+
takeoverAttempted: true
|
|
99205
|
+
};
|
|
99206
|
+
let lastError = lockError;
|
|
99207
|
+
const until = deps.now() + deps.takeoverWindowMs;
|
|
99208
|
+
while (deps.now() < until) {
|
|
99209
|
+
const retry = await deps.tryAcquire(input.lockMeta);
|
|
99210
|
+
if (retry.ok) return {
|
|
99211
|
+
lock: retry.lock,
|
|
99212
|
+
status: "acquired"
|
|
99213
|
+
};
|
|
99214
|
+
lastError = retry.error;
|
|
99215
|
+
await deps.sleep(deps.pollIntervalMs);
|
|
99216
|
+
}
|
|
99217
|
+
const finalTry = await deps.tryAcquire(input.lockMeta);
|
|
99218
|
+
if (finalTry.ok) return {
|
|
99219
|
+
lock: finalTry.lock,
|
|
99220
|
+
status: "acquired"
|
|
99221
|
+
};
|
|
99222
|
+
return {
|
|
99223
|
+
status: "contended",
|
|
99224
|
+
lockError: finalTry.ok ? lastError : finalTry.error,
|
|
99225
|
+
pid,
|
|
99226
|
+
startedAtLabel,
|
|
99227
|
+
takeoverAttempted: true
|
|
99228
|
+
};
|
|
99229
|
+
}
|
|
99230
|
+
function buildSetupLockContentionError(input) {
|
|
99231
|
+
if (input.view === "agent") return input.contention.lockError;
|
|
99232
|
+
return new Error(buildHumanSetupLockLine(input.contention));
|
|
99233
|
+
}
|
|
99234
|
+
function buildHumanSetupLockLine(contention) {
|
|
99235
|
+
const descriptorParts = [];
|
|
99236
|
+
if (contention.startedAtLabel) descriptorParts.push(`started ${contention.startedAtLabel}`);
|
|
99237
|
+
if (contention.pid !== null) descriptorParts.push(`pid ${contention.pid}`);
|
|
99238
|
+
return `Another ATS setup${descriptorParts.length > 0 ? ` (${descriptorParts.join(", ")})` : ""} ${contention.takeoverAttempted ? "did not stop after ATS asked it to stand down" : "is still running"} on this computer. ${contention.pid === null ? "Close that Terminal window, then run this command again." : `Close that Terminal window, or run \`kill ${contention.pid}\`, then run this command again.`}`;
|
|
99239
|
+
}
|
|
99240
|
+
function createSetupGlobalDeadline(input) {
|
|
99241
|
+
const clock = input.clock ?? realDeadlineClock;
|
|
99242
|
+
const deadlineMs = input.deadlineMs ?? SETUP_GLOBAL_DEADLINE_MS;
|
|
99243
|
+
let handle = null;
|
|
99244
|
+
return {
|
|
99245
|
+
arm() {
|
|
99246
|
+
if (handle !== null) return;
|
|
99247
|
+
handle = clock.setTimer(() => {
|
|
99248
|
+
handle = null;
|
|
99249
|
+
input.onExpire();
|
|
99250
|
+
}, deadlineMs);
|
|
99251
|
+
},
|
|
99252
|
+
disarm() {
|
|
99253
|
+
if (handle === null) return;
|
|
99254
|
+
clock.clearTimer(handle);
|
|
99255
|
+
handle = null;
|
|
99256
|
+
}
|
|
99257
|
+
};
|
|
99258
|
+
}
|
|
99259
|
+
function handleSetupGlobalDeadlineExpiry(input) {
|
|
99260
|
+
const deadlineMs = input.deadlineMs ?? SETUP_GLOBAL_DEADLINE_MS;
|
|
99261
|
+
const message = `ATS setup did not finish within ${Math.max(1, Math.round(deadlineMs / 6e4))} minutes on this computer and was stopped. This computer's setup lock has been released. Copy a fresh setup command from ATS Web and run setup again.`;
|
|
99262
|
+
runSafely(() => (input.releaseLockSync ?? defaultReleaseLockSync)(input.lock.path));
|
|
99263
|
+
runSafely(() => {
|
|
99264
|
+
if (input.view === "agent") {
|
|
99265
|
+
(input.emitAgent ?? defaultEmitAgent)({
|
|
99266
|
+
code: SETUP_DEADLINE_SUPPORT_CODE,
|
|
99267
|
+
message,
|
|
99268
|
+
type: "error"
|
|
99269
|
+
});
|
|
99270
|
+
return;
|
|
99271
|
+
}
|
|
99272
|
+
(input.emitHuman ?? defaultEmitErrorLine)(`error: ${message} (support code: ${SETUP_DEADLINE_SUPPORT_CODE})`);
|
|
99273
|
+
});
|
|
99274
|
+
(input.exit ?? defaultExit)(1);
|
|
99275
|
+
}
|
|
99276
|
+
function installSetupStandDownHandler(input) {
|
|
99277
|
+
const message = "ATS setup was asked to stop and has released this computer's setup lock. You can close this window.";
|
|
99278
|
+
const handler = () => {
|
|
99279
|
+
runSafely(() => (input.releaseLockSync ?? defaultReleaseLockSync)(input.lock.path));
|
|
99280
|
+
runSafely(() => {
|
|
99281
|
+
if (input.view === "agent") {
|
|
99282
|
+
(input.emitAgent ?? defaultEmitAgent)({
|
|
99283
|
+
code: SETUP_SUPERSEDED_SUPPORT_CODE,
|
|
99284
|
+
message,
|
|
99285
|
+
type: "info"
|
|
99286
|
+
});
|
|
99287
|
+
return;
|
|
99288
|
+
}
|
|
99289
|
+
(input.emitHuman ?? defaultEmitOutLine)(message);
|
|
99290
|
+
});
|
|
99291
|
+
(input.exit ?? defaultExit)(0);
|
|
99292
|
+
};
|
|
99293
|
+
const register = input.register ?? ((h) => process$1.once("SIGTERM", h));
|
|
99294
|
+
const unregister = input.unregister ?? ((h) => {
|
|
99295
|
+
process$1.removeListener("SIGTERM", h);
|
|
99296
|
+
});
|
|
99297
|
+
register(handler);
|
|
99298
|
+
return { remove() {
|
|
99299
|
+
unregister(handler);
|
|
99300
|
+
} };
|
|
99301
|
+
}
|
|
99302
|
+
const realDeadlineClock = {
|
|
99303
|
+
clearTimer: (handle) => {
|
|
99304
|
+
clearTimeout(handle);
|
|
99305
|
+
},
|
|
99306
|
+
setTimer: (callback, ms) => setTimeout(callback, ms)
|
|
99307
|
+
};
|
|
99308
|
+
function defaultTakeoverDeps() {
|
|
99309
|
+
return {
|
|
99310
|
+
now: () => Date.now(),
|
|
99311
|
+
pollIntervalMs: SETUP_TAKEOVER_POLL_MS,
|
|
99312
|
+
probePid: defaultProbePid,
|
|
99313
|
+
selfPid: process$1.pid,
|
|
99314
|
+
sendTerm: defaultSendTerm,
|
|
99315
|
+
sleep: (ms) => new Promise((resolve) => {
|
|
99316
|
+
setTimeout(resolve, ms);
|
|
99317
|
+
}),
|
|
99318
|
+
takeoverWindowMs: SETUP_TAKEOVER_WINDOW_MS,
|
|
99319
|
+
tryAcquire: defaultTryAcquireSetupLock
|
|
99320
|
+
};
|
|
99321
|
+
}
|
|
99322
|
+
async function defaultTryAcquireSetupLock(meta) {
|
|
99323
|
+
try {
|
|
99324
|
+
return {
|
|
99325
|
+
lock: await acquireLock({
|
|
99326
|
+
atsProfileId: SETUP_COMMAND_LOCK_PROFILE,
|
|
99327
|
+
key: SETUP_COMMAND_LOCK_KEY,
|
|
99328
|
+
meta
|
|
99329
|
+
}),
|
|
99330
|
+
ok: true
|
|
99331
|
+
};
|
|
99332
|
+
} catch (error) {
|
|
99333
|
+
if (isAtsLockError(error)) return {
|
|
99334
|
+
error,
|
|
99335
|
+
ok: false
|
|
99336
|
+
};
|
|
99337
|
+
throw error;
|
|
99338
|
+
}
|
|
99339
|
+
}
|
|
99340
|
+
function defaultProbePid(pid) {
|
|
99341
|
+
try {
|
|
99342
|
+
process$1.kill(pid, 0);
|
|
99343
|
+
return "alive";
|
|
99344
|
+
} catch (error) {
|
|
99345
|
+
return getErrorCode(error) === "ESRCH" ? "dead" : "unsignalable";
|
|
99346
|
+
}
|
|
99347
|
+
}
|
|
99348
|
+
function defaultSendTerm(pid) {
|
|
99349
|
+
try {
|
|
99350
|
+
process$1.kill(pid, "SIGTERM");
|
|
99351
|
+
return "sent";
|
|
99352
|
+
} catch (error) {
|
|
99353
|
+
return getErrorCode(error) === "ESRCH" ? "gone" : "not_permitted";
|
|
99354
|
+
}
|
|
99355
|
+
}
|
|
99356
|
+
function defaultReleaseLockSync(path) {
|
|
99357
|
+
rmSync(path, { force: true });
|
|
99358
|
+
}
|
|
99359
|
+
function defaultEmitAgent(payload) {
|
|
99360
|
+
outJsonLine(payload);
|
|
99361
|
+
}
|
|
99362
|
+
function defaultEmitErrorLine(line) {
|
|
99363
|
+
errLine(line);
|
|
99364
|
+
}
|
|
99365
|
+
function defaultEmitOutLine(line) {
|
|
99366
|
+
outLine(line);
|
|
99367
|
+
}
|
|
99368
|
+
function defaultExit(code) {
|
|
99369
|
+
process$1.exit(code);
|
|
99370
|
+
}
|
|
99371
|
+
function runSafely(action) {
|
|
99372
|
+
try {
|
|
99373
|
+
action();
|
|
99374
|
+
} catch {}
|
|
99375
|
+
}
|
|
99376
|
+
function resolveLockHolderPid(error) {
|
|
99377
|
+
const fromMeta = readPidValue(error.meta);
|
|
99378
|
+
if (fromMeta !== null) return fromMeta;
|
|
99379
|
+
return readPidValue(safeParseJson(error.metaRaw));
|
|
99380
|
+
}
|
|
99381
|
+
function resolveLockStartedAtLabel(error) {
|
|
99382
|
+
const at = readStringValue(error.meta, "at") ?? readStringValue(safeParseJson(error.metaRaw), "at");
|
|
99383
|
+
if (!at) return null;
|
|
99384
|
+
const date = new Date(at);
|
|
99385
|
+
if (Number.isNaN(date.getTime())) return null;
|
|
99386
|
+
return `${String(date.getHours()).padStart(2, "0")}:${String(date.getMinutes()).padStart(2, "0")}`;
|
|
99387
|
+
}
|
|
99388
|
+
function readPidValue(source) {
|
|
99389
|
+
if (!source || typeof source !== "object") return null;
|
|
99390
|
+
const pid = source.pid;
|
|
99391
|
+
return typeof pid === "number" && Number.isInteger(pid) && pid > 0 ? pid : null;
|
|
99392
|
+
}
|
|
99393
|
+
function readStringValue(source, key) {
|
|
99394
|
+
if (!source || typeof source !== "object") return null;
|
|
99395
|
+
const value = source[key];
|
|
99396
|
+
if (typeof value !== "string") return null;
|
|
99397
|
+
const normalized = value.trim();
|
|
99398
|
+
return normalized.length > 0 ? normalized : null;
|
|
99399
|
+
}
|
|
99400
|
+
function safeParseJson(value) {
|
|
99401
|
+
if (typeof value !== "string") return null;
|
|
99402
|
+
try {
|
|
99403
|
+
return JSON.parse(value);
|
|
99404
|
+
} catch {
|
|
99405
|
+
return null;
|
|
99406
|
+
}
|
|
99407
|
+
}
|
|
99408
|
+
function getErrorCode(error) {
|
|
99409
|
+
if (!error || typeof error !== "object") return;
|
|
99410
|
+
const code = error.code;
|
|
99411
|
+
return typeof code === "string" ? code : void 0;
|
|
99412
|
+
}
|
|
99413
|
+
function normalizeOptionalString$3(value) {
|
|
99414
|
+
const normalized = String(value ?? "").trim();
|
|
99415
|
+
return normalized.length > 0 ? normalized : null;
|
|
99416
|
+
}
|
|
99417
|
+
|
|
98962
99418
|
//#endregion
|
|
98963
99419
|
//#region src/commands/setup-current-device.ts
|
|
98964
99420
|
async function syncLocalSetupCurrentDeviceTargetFromServiceContract(input) {
|
|
@@ -99005,11 +99461,21 @@ async function writeConnectedComputerEnrollmentToServiceContract(input) {
|
|
|
99005
99461
|
//#region src/commands/prepare-step-diagnostics.ts
|
|
99006
99462
|
const PREPARE_STEP_DIAGNOSTICS_PAYLOAD_MAX_CHARS = Math.min(16e3, PREPARE_STEP_DIAGNOSTICS_MAX_CHARS);
|
|
99007
99463
|
const ATS_NO_DIAGNOSTICS_ENV = "ATS_NO_DIAGNOSTICS";
|
|
99464
|
+
const PREPARE_STEP_DIAGNOSTICS_BUNDLE_VERSION = 2;
|
|
99008
99465
|
const LIFECYCLE_JOURNAL_TAIL_MAX_ENTRIES = 10;
|
|
99009
99466
|
const SERVICE_LOG_TAIL_MAX_LINES = 30;
|
|
99010
99467
|
const SERVICE_LOG_LINE_MAX_CHARS = 320;
|
|
99011
99468
|
const JOURNAL_ENTRY_MAX_CHARS = 700;
|
|
99012
99469
|
const SOURCE_TIMEOUT_MS = 2e3;
|
|
99470
|
+
const LIFECYCLE_JOURNAL_METADATA_WHITELIST = [
|
|
99471
|
+
"action",
|
|
99472
|
+
"ok",
|
|
99473
|
+
"errorMessage",
|
|
99474
|
+
"jobDiagnostics",
|
|
99475
|
+
"durationMs",
|
|
99476
|
+
"reason"
|
|
99477
|
+
];
|
|
99478
|
+
const LIFECYCLE_JOURNAL_METADATA_COMPACT_WHITELIST = LIFECYCLE_JOURNAL_METADATA_WHITELIST.filter((key) => key !== "jobDiagnostics");
|
|
99013
99479
|
function isPrepareStepDiagnosticsOptedOut(env = process$1.env) {
|
|
99014
99480
|
return String(env[ATS_NO_DIAGNOSTICS_ENV] ?? "").trim() === "1";
|
|
99015
99481
|
}
|
|
@@ -99018,7 +99484,7 @@ async function collectPrepareStepDiagnostics(input) {
|
|
|
99018
99484
|
if (isPrepareStepDiagnosticsOptedOut(input.env)) return null;
|
|
99019
99485
|
const sources = input.sources ?? {};
|
|
99020
99486
|
const collectionErrors = [];
|
|
99021
|
-
const [lifecycleJournalTail,
|
|
99487
|
+
const [lifecycleJournalTail, serviceLog, inventoryAnomalies, serviceJob, deviceId] = await Promise.all([
|
|
99022
99488
|
collectDiagnosticsSource({
|
|
99023
99489
|
collectionErrors,
|
|
99024
99490
|
sourceName: "lifecycle_journal",
|
|
@@ -99027,7 +99493,7 @@ async function collectPrepareStepDiagnostics(input) {
|
|
|
99027
99493
|
collectDiagnosticsSource({
|
|
99028
99494
|
collectionErrors,
|
|
99029
99495
|
sourceName: "service_log",
|
|
99030
|
-
read: sources.readServiceLogTail ??
|
|
99496
|
+
read: sources.readServiceLogTail ?? readServiceLogTailWithPresence
|
|
99031
99497
|
}),
|
|
99032
99498
|
collectDiagnosticsSource({
|
|
99033
99499
|
collectionErrors,
|
|
@@ -99038,14 +99504,22 @@ async function collectPrepareStepDiagnostics(input) {
|
|
|
99038
99504
|
collectionErrors,
|
|
99039
99505
|
sourceName: "service_job",
|
|
99040
99506
|
read: sources.readServiceJobDiagnostics ?? readServiceJobDiagnostics
|
|
99507
|
+
}),
|
|
99508
|
+
collectDiagnosticsSource({
|
|
99509
|
+
collectionErrors,
|
|
99510
|
+
sourceName: "device_id",
|
|
99511
|
+
read: sources.readDeviceId ?? readDaemonServiceContractDeviceId
|
|
99041
99512
|
})
|
|
99042
99513
|
]);
|
|
99514
|
+
const serviceLogNote = serviceLog?.note ?? null;
|
|
99515
|
+
const serviceLogTail = serviceLog === null || serviceLogNote !== null ? null : serviceLog.lines.map(boundServiceLogLine);
|
|
99043
99516
|
const cliVersion = getCliVersionInfo().version;
|
|
99044
99517
|
return serializeBoundedPrepareStepDiagnostics({
|
|
99045
|
-
bundleVersion:
|
|
99518
|
+
bundleVersion: PREPARE_STEP_DIAGNOSTICS_BUNDLE_VERSION,
|
|
99046
99519
|
collectedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
99047
99520
|
supportCode: input.supportCode,
|
|
99048
99521
|
stepId: input.stepId,
|
|
99522
|
+
...deviceId ? { deviceId } : {},
|
|
99049
99523
|
cliVersion,
|
|
99050
99524
|
os: {
|
|
99051
99525
|
platform: process$1.platform,
|
|
@@ -99054,7 +99528,8 @@ async function collectPrepareStepDiagnostics(input) {
|
|
|
99054
99528
|
inventoryAnomalies,
|
|
99055
99529
|
serviceJob,
|
|
99056
99530
|
lifecycleJournalTail: lifecycleJournalTail === null ? null : lifecycleJournalTail.map(boundLifecycleJournalEntry),
|
|
99057
|
-
serviceLogTail
|
|
99531
|
+
serviceLogTail,
|
|
99532
|
+
...serviceLogNote ? { serviceLogNote } : {},
|
|
99058
99533
|
collectionErrors,
|
|
99059
99534
|
truncated: false
|
|
99060
99535
|
});
|
|
@@ -99063,9 +99538,17 @@ async function collectPrepareStepDiagnostics(input) {
|
|
|
99063
99538
|
}
|
|
99064
99539
|
}
|
|
99065
99540
|
function serializeBoundedPrepareStepDiagnostics(bundle) {
|
|
99066
|
-
|
|
99541
|
+
const cappedForSchema = (bundle.inventoryAnomalies?.length ?? 0) > 32 || (bundle.lifecycleJournalTail?.length ?? 0) > LIFECYCLE_JOURNAL_TAIL_MAX_ENTRIES || (bundle.serviceLogTail?.length ?? 0) > SERVICE_LOG_TAIL_MAX_LINES || bundle.collectionErrors.length > 8;
|
|
99542
|
+
let candidate = redactPrepareStepDiagnosticsBundle({
|
|
99543
|
+
...bundle,
|
|
99544
|
+
inventoryAnomalies: bundle.inventoryAnomalies === null ? null : bundle.inventoryAnomalies.slice(-32),
|
|
99545
|
+
lifecycleJournalTail: bundle.lifecycleJournalTail === null ? null : bundle.lifecycleJournalTail.slice(-LIFECYCLE_JOURNAL_TAIL_MAX_ENTRIES),
|
|
99546
|
+
serviceLogTail: bundle.serviceLogTail === null ? null : bundle.serviceLogTail.slice(-SERVICE_LOG_TAIL_MAX_LINES).map(boundServiceLogLine),
|
|
99547
|
+
collectionErrors: bundle.collectionErrors.slice(-8),
|
|
99548
|
+
truncated: bundle.truncated || cappedForSchema
|
|
99549
|
+
});
|
|
99067
99550
|
let serialized = JSON.stringify(candidate);
|
|
99068
|
-
if (serialized.length <= PREPARE_STEP_DIAGNOSTICS_PAYLOAD_MAX_CHARS) return
|
|
99551
|
+
if (serialized.length <= PREPARE_STEP_DIAGNOSTICS_PAYLOAD_MAX_CHARS) return finalizePrepareStepDiagnosticsSerialization(candidate);
|
|
99069
99552
|
candidate = {
|
|
99070
99553
|
...candidate,
|
|
99071
99554
|
truncated: true
|
|
@@ -99093,7 +99576,7 @@ function serializeBoundedPrepareStepDiagnostics(bundle) {
|
|
|
99093
99576
|
}
|
|
99094
99577
|
serialized = JSON.stringify(candidate);
|
|
99095
99578
|
}
|
|
99096
|
-
return
|
|
99579
|
+
return finalizePrepareStepDiagnosticsSerialization(candidate);
|
|
99097
99580
|
}
|
|
99098
99581
|
async function collectDiagnosticsSource(input) {
|
|
99099
99582
|
let timer = null;
|
|
@@ -99114,16 +99597,65 @@ async function readInventoryAnomalyCodes() {
|
|
|
99114
99597
|
async function readServiceJobDiagnostics() {
|
|
99115
99598
|
return await (await resolveDaemonServiceManager())?.readJobDiagnostics?.() ?? null;
|
|
99116
99599
|
}
|
|
99117
|
-
function
|
|
99118
|
-
|
|
99600
|
+
async function resolvePrepareServiceJobVerdict() {
|
|
99601
|
+
const diagnostics = await readServiceJobDiagnostics().catch(() => null);
|
|
99602
|
+
if (!diagnostics) return null;
|
|
99603
|
+
if (isDaemonServiceJobNeverSpawned(diagnostics)) return "never_spawned";
|
|
99604
|
+
if (readDaemonServiceJobCrashExitCode(diagnostics) !== null) return "crashed";
|
|
99605
|
+
return null;
|
|
99606
|
+
}
|
|
99607
|
+
async function readDaemonServiceContractDeviceId() {
|
|
99608
|
+
return (await readDaemonServiceContract())?.deviceId ?? null;
|
|
99609
|
+
}
|
|
99610
|
+
async function readServiceLogTailWithPresence() {
|
|
99611
|
+
const stats = await stat(getDaemonSystemServiceLogPath()).catch(() => null);
|
|
99612
|
+
if (!stats?.isFile()) return {
|
|
99613
|
+
lines: [],
|
|
99614
|
+
note: "file_missing"
|
|
99615
|
+
};
|
|
99616
|
+
if (stats.size === 0) return {
|
|
99617
|
+
lines: [],
|
|
99618
|
+
note: "file_empty"
|
|
99619
|
+
};
|
|
99119
99620
|
return {
|
|
99621
|
+
lines: await readDaemonStartFailureLogTailLines({ maxLines: SERVICE_LOG_TAIL_MAX_LINES }),
|
|
99622
|
+
note: null
|
|
99623
|
+
};
|
|
99624
|
+
}
|
|
99625
|
+
function selectWhitelistedJournalMetadata(metadata, keys) {
|
|
99626
|
+
const selected = {};
|
|
99627
|
+
for (const key of keys) if (Object.hasOwn(metadata, key)) selected[key] = metadata[key];
|
|
99628
|
+
return selected;
|
|
99629
|
+
}
|
|
99630
|
+
function boundLifecycleJournalEntry(entry) {
|
|
99631
|
+
if (!entry.metadata) return redactPrepareStepDiagnosticsValue(entry);
|
|
99632
|
+
const whitelisted = redactPrepareStepDiagnosticsValue({
|
|
99120
99633
|
...entry,
|
|
99634
|
+
metadata: selectWhitelistedJournalMetadata(entry.metadata, LIFECYCLE_JOURNAL_METADATA_WHITELIST)
|
|
99635
|
+
});
|
|
99636
|
+
if (JSON.stringify(whitelisted).length <= JOURNAL_ENTRY_MAX_CHARS) return whitelisted;
|
|
99637
|
+
const compact = redactPrepareStepDiagnosticsValue({
|
|
99638
|
+
...entry,
|
|
99639
|
+
metadata: {
|
|
99640
|
+
...selectWhitelistedJournalMetadata(entry.metadata, LIFECYCLE_JOURNAL_METADATA_COMPACT_WHITELIST),
|
|
99641
|
+
truncated: true
|
|
99642
|
+
}
|
|
99643
|
+
});
|
|
99644
|
+
if (JSON.stringify(compact).length <= JOURNAL_ENTRY_MAX_CHARS) return compact;
|
|
99645
|
+
return {
|
|
99646
|
+
...whitelisted,
|
|
99121
99647
|
metadata: { truncated: true }
|
|
99122
99648
|
};
|
|
99123
99649
|
}
|
|
99124
99650
|
function boundServiceLogLine(line) {
|
|
99125
|
-
|
|
99126
|
-
|
|
99651
|
+
const redactedLine = redactPrepareStepDiagnosticsText(line);
|
|
99652
|
+
if (redactedLine.length <= SERVICE_LOG_LINE_MAX_CHARS) return redactedLine;
|
|
99653
|
+
return `${redactedLine.slice(0, SERVICE_LOG_LINE_MAX_CHARS - 1).trimEnd()}…`;
|
|
99654
|
+
}
|
|
99655
|
+
function finalizePrepareStepDiagnosticsSerialization(bundle) {
|
|
99656
|
+
const parsed = prepareStepDiagnosticsBundleSchema.safeParse(bundle);
|
|
99657
|
+
if (!parsed.success) return null;
|
|
99658
|
+
return JSON.stringify(parsed.data);
|
|
99127
99659
|
}
|
|
99128
99660
|
|
|
99129
99661
|
//#endregion
|
|
@@ -99570,13 +100102,19 @@ async function runTerminalStep(input) {
|
|
|
99570
100102
|
throw error;
|
|
99571
100103
|
}
|
|
99572
100104
|
const rawMessage = error instanceof Error && error.message.trim().length > 0 ? error.message.trim() : "Setup could not continue.";
|
|
100105
|
+
const serviceJobVerdict = await resolveRefreshServiceJobVerdict({
|
|
100106
|
+
stepId: input.stepId,
|
|
100107
|
+
resolveServiceJobVerdict: input.resolveServiceJobVerdict
|
|
100108
|
+
});
|
|
99573
100109
|
const message = formatTerminalStepFailureMessage({
|
|
99574
100110
|
stepId: input.stepId,
|
|
99575
|
-
rawMessage
|
|
100111
|
+
rawMessage,
|
|
100112
|
+
serviceJobVerdict
|
|
99576
100113
|
});
|
|
99577
100114
|
const reasonCode = resolveTerminalStepFailureReasonCode({
|
|
99578
100115
|
rawMessage,
|
|
99579
|
-
stepId: input.stepId
|
|
100116
|
+
stepId: input.stepId,
|
|
100117
|
+
serviceJobVerdict
|
|
99580
100118
|
});
|
|
99581
100119
|
const diagnostics = await (input.collectDiagnostics ?? collectPrepareStepDiagnostics)({
|
|
99582
100120
|
stepId: input.stepId,
|
|
@@ -100050,9 +100588,15 @@ function buildPrepareLocalReadinessSnapshot(readiness) {
|
|
|
100050
100588
|
}
|
|
100051
100589
|
};
|
|
100052
100590
|
}
|
|
100591
|
+
async function resolveRefreshServiceJobVerdict(input) {
|
|
100592
|
+
if (input.stepId !== "refresh_service") return null;
|
|
100593
|
+
return await (input.resolveServiceJobVerdict ?? resolvePrepareServiceJobVerdict)().catch(() => null);
|
|
100594
|
+
}
|
|
100053
100595
|
function formatTerminalStepFailureMessage(input) {
|
|
100054
100596
|
if (input.rawMessage.includes("prepare session revision conflict")) return "This setup changed while Terminal was working. Copy a fresh setup command from ATS Web and run setup again to continue from the latest step.";
|
|
100055
100597
|
if (input.stepId === "refresh_service") {
|
|
100598
|
+
if (input.serviceJobVerdict === "never_spawned") return `macOS is blocking the ATS Service background item, so ATS Service never launched. Path A: open System Settings > General > Login Items & Extensions, enable the ATS background item, then copy a fresh setup command from ATS Web and run setup again. Path B: run \`${formatAtsCliCommand("ats service start --mode foreground")}\` in a separate terminal and keep it open (Wake stops when you close that window), then run setup again.`;
|
|
100599
|
+
if (input.serviceJobVerdict === "crashed") return `ATS Service started but keeps exiting on this Mac. Run \`${formatAtsCliCommand("ats service start --mode foreground")}\` to see the live error, fix it, then copy a fresh setup command from ATS Web and run setup again.`;
|
|
100056
100600
|
const detail = formatTerminalStepFailureDetail(input.rawMessage);
|
|
100057
100601
|
return `ATS Service did not report a running local connection during setup. Copy a fresh setup command from ATS Web and run setup again to continue from this step. If it fails again, run \`${formatAtsCliCommand("ats service start --mode foreground")}\` to see live startup logs, then copy a fresh setup command from ATS Web and run setup again.${detail ? ` Detail: ${detail}` : ""}`;
|
|
100058
100602
|
}
|
|
@@ -100066,6 +100610,10 @@ function formatTerminalStepFailureDetail(rawMessage) {
|
|
|
100066
100610
|
}
|
|
100067
100611
|
function resolveTerminalStepFailureReasonCode(input) {
|
|
100068
100612
|
if (input.rawMessage.includes("runtime.registration.device_forgotten")) return "runtime.registration.device_forgotten";
|
|
100613
|
+
if (input.stepId === "refresh_service") {
|
|
100614
|
+
if (input.serviceJobVerdict === "never_spawned") return "prepare.refresh_service.service_never_spawned";
|
|
100615
|
+
if (input.serviceJobVerdict === "crashed") return "prepare.refresh_service.service_crash_loop";
|
|
100616
|
+
}
|
|
100069
100617
|
return `prepare.${input.stepId}.failed`;
|
|
100070
100618
|
}
|
|
100071
100619
|
function findStep(snapshot, stepId) {
|
|
@@ -101088,11 +101636,18 @@ function isAgentProfile(profile) {
|
|
|
101088
101636
|
|
|
101089
101637
|
//#endregion
|
|
101090
101638
|
//#region src/commands/setup.ts
|
|
101091
|
-
const SETUP_COMMAND_LOCK_PROFILE = "setup";
|
|
101092
|
-
const SETUP_COMMAND_LOCK_KEY = "setup-command";
|
|
101093
101639
|
async function runSetup(input) {
|
|
101094
|
-
return await withSetupCommandLock(
|
|
101095
|
-
|
|
101640
|
+
return await withSetupCommandLock({
|
|
101641
|
+
lockMeta: {
|
|
101642
|
+
command: "ats setup",
|
|
101643
|
+
path: shouldUseSetupLocalAgentConnection(input) ? "delegated_or_profile_setup" : "local_setup",
|
|
101644
|
+
view: input.view ?? null
|
|
101645
|
+
},
|
|
101646
|
+
run: async () => {
|
|
101647
|
+
await runSetupUnlocked(input);
|
|
101648
|
+
},
|
|
101649
|
+
startSession: input.startSession,
|
|
101650
|
+
view: input.view
|
|
101096
101651
|
});
|
|
101097
101652
|
}
|
|
101098
101653
|
async function runSetupUnlocked(input) {
|
|
@@ -101251,33 +101806,6 @@ async function runSetupUnlocked(input) {
|
|
|
101251
101806
|
async function runSetupStartupLocalStateRepair() {
|
|
101252
101807
|
await runLocalStateAlignment({ mode: "repair" });
|
|
101253
101808
|
}
|
|
101254
|
-
async function withSetupCommandLock(input, run) {
|
|
101255
|
-
try {
|
|
101256
|
-
return await runWithHeldLock({
|
|
101257
|
-
lock: await acquireLock({
|
|
101258
|
-
atsProfileId: SETUP_COMMAND_LOCK_PROFILE,
|
|
101259
|
-
key: SETUP_COMMAND_LOCK_KEY,
|
|
101260
|
-
meta: {
|
|
101261
|
-
command: "ats setup",
|
|
101262
|
-
path: shouldUseSetupLocalAgentConnection(input) ? "delegated_or_profile_setup" : "local_setup",
|
|
101263
|
-
view: input.view ?? null
|
|
101264
|
-
}
|
|
101265
|
-
}),
|
|
101266
|
-
run,
|
|
101267
|
-
releaseContext: {
|
|
101268
|
-
atsProfileId: SETUP_COMMAND_LOCK_PROFILE,
|
|
101269
|
-
component: "setup_command",
|
|
101270
|
-
lockKey: SETUP_COMMAND_LOCK_KEY
|
|
101271
|
-
}
|
|
101272
|
-
});
|
|
101273
|
-
} catch (error) {
|
|
101274
|
-
if (isAtsLockError(error)) throw new Error(buildSetupCommandLockMessage(error));
|
|
101275
|
-
throw error;
|
|
101276
|
-
}
|
|
101277
|
-
}
|
|
101278
|
-
function buildSetupCommandLockMessage(error) {
|
|
101279
|
-
return `Another ATS setup is already running on this computer. Wait for it to finish, then run setup again.${error.metaRaw ? ` Existing setup: ${error.metaRaw}` : ""}`;
|
|
101280
|
-
}
|
|
101281
101809
|
function shouldUseSetupLocalAgentConnection(input) {
|
|
101282
101810
|
return Boolean(normalizeOptionalString$1(input.startSession) ?? normalizeOptionalString$1(input.humanProfile) ?? normalizeOptionalString$1(input.profile) ?? (input.agent && input.agent.length > 0 ? "agent" : null));
|
|
101283
101811
|
}
|
|
@@ -104235,7 +104763,7 @@ function normalizeOptionalString(value) {
|
|
|
104235
104763
|
return normalized.length > 0 ? normalized : null;
|
|
104236
104764
|
}
|
|
104237
104765
|
async function runDefaultSpaceAddMeMembership(input) {
|
|
104238
|
-
const { runSpaceAddMeMembership } = await import("./add-me-membership-
|
|
104766
|
+
const { runSpaceAddMeMembership } = await import("./add-me-membership-Cfi5fbyb.js");
|
|
104239
104767
|
return await runSpaceAddMeMembership(input);
|
|
104240
104768
|
}
|
|
104241
104769
|
|
|
@@ -107151,10 +107679,10 @@ serviceCmd.command("trace").description("Read a Space delivery trace for debuggi
|
|
|
107151
107679
|
profile: opts.profile,
|
|
107152
107680
|
gatewayUrl: opts.gatewayUrl,
|
|
107153
107681
|
run: async () => {
|
|
107154
|
-
const dispatchId = normalizeOptionalString$
|
|
107155
|
-
const sourceSignalId = normalizeOptionalString$
|
|
107156
|
-
const clientMessageId = normalizeOptionalString$
|
|
107157
|
-
const targetProfileId = normalizeOptionalString$
|
|
107682
|
+
const dispatchId = normalizeOptionalString$7(opts.dispatch);
|
|
107683
|
+
const sourceSignalId = normalizeOptionalString$7(opts.sourceSignal);
|
|
107684
|
+
const clientMessageId = normalizeOptionalString$7(opts.clientMessage);
|
|
107685
|
+
const targetProfileId = normalizeOptionalString$7(opts.targetProfile);
|
|
107158
107686
|
if (Number(dispatchId !== null) + Number(sourceSignalId !== null) + Number(clientMessageId !== null) !== 1) throw new Error("exactly one of --dispatch, --source-signal, or --client-message is required");
|
|
107159
107687
|
await runServiceTrace({
|
|
107160
107688
|
profile: opts.profile,
|
|
@@ -107344,7 +107872,7 @@ spaceActionCmd.command("help").description("Show ATS Space Action help.").action
|
|
|
107344
107872
|
withSpaceProfileOption(spaceCmd.command("create").description("Create a new space and print its space ID.").option("--name <name>", "Space name (<=80 chars; prompted in human interactive mode)").option("--guide <text>", "Optional space guide").option("--password <value>", "Optional space password (minimum 6 characters; numbers/letters/symbols accepted)").option("--join", "Join immediately after create").option("--no-join", "Do not ask to join after create").option("--output <mode>", "Output mode when auto-joining: ndjson|text", "text")).action(async (opts, command) => {
|
|
107345
107873
|
const cliOptions = resolveSpaceCommandCliOptions(command, opts);
|
|
107346
107874
|
const view = getGlobalViewOption();
|
|
107347
|
-
if (view === "agent" && normalizeOptionalString$
|
|
107875
|
+
if (view === "agent" && normalizeOptionalString$7(opts.name) === null) {
|
|
107348
107876
|
await runSpaceCreate({
|
|
107349
107877
|
profile: cliOptions.profile,
|
|
107350
107878
|
baseUrl: cliOptions.gatewayUrl,
|
|
@@ -107401,7 +107929,7 @@ withSpaceProfileOption(spaceCmd.command("join").description("Join a space and ch
|
|
|
107401
107929
|
const cliOptions = resolveSpaceCommandCliOptions(command, opts);
|
|
107402
107930
|
const localEcho = opts.noLocalEcho !== true;
|
|
107403
107931
|
const view = getGlobalViewOption();
|
|
107404
|
-
if (view === "agent" && normalizeOptionalString$
|
|
107932
|
+
if (view === "agent" && normalizeOptionalString$7(space) === null) {
|
|
107405
107933
|
await runSpaceJoin({
|
|
107406
107934
|
profile: cliOptions.profile,
|
|
107407
107935
|
baseUrl: cliOptions.gatewayUrl,
|
|
@@ -107896,8 +108424,8 @@ withSpaceProfileOption(spaceCmd.command("updates").description("Read formal upda
|
|
|
107896
108424
|
withSpaceProfileOption(spaceCmd.command("result").description("Read one formal dispatch result scoped to this space.").argument("[space]", "Space ID (64-character hex)").option("--dispatch <dispatch-id>", "Lookup by dispatch ID").option("--result-ref <result-ref>", "Lookup by dispatch result ref").option("--json", "Print canonical JSON", false).option("--password <value>", "Space password for protected access")).action(async (space, opts, command) => {
|
|
107897
108425
|
const cliOptions = resolveSpaceCommandCliOptions(command, opts);
|
|
107898
108426
|
const spaceValue = String(space ?? "").trim();
|
|
107899
|
-
const dispatchId = normalizeOptionalString$
|
|
107900
|
-
const resultRef = normalizeOptionalString$
|
|
108427
|
+
const dispatchId = normalizeOptionalString$7(opts.dispatch);
|
|
108428
|
+
const resultRef = normalizeOptionalString$7(opts.resultRef);
|
|
107901
108429
|
const selectorCount = Number(dispatchId !== null) + Number(resultRef !== null);
|
|
107902
108430
|
const outputView = await resolveEffectiveViewForOutput();
|
|
107903
108431
|
if ((spaceValue.length === 0 || selectorCount !== 1) && outputView === "agent") throw createSpaceResultGuideError();
|