agent-transport-system 0.7.75 → 0.7.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{api-client-foundation-D0EqxvSl.js → api-client-foundation-SXFJ2-50.js} +1 -1
- package/dist/ats-dev.js +2 -2
- package/dist/ats.js +111 -2369
- package/dist/ats.js.map +1 -1
- package/dist/auth-session-DpBr5mtL.js +6 -0
- package/dist/{base-url-DBrhL-hp.js → base-url-DLlv4P6u.js} +2 -2
- package/dist/{base-url-DBrhL-hp.js.map → base-url-DLlv4P6u.js.map} +1 -1
- package/dist/{daemon-runtime-lease-BEzH1CBA.js → daemon-runtime-lease-9c0XHMDh.js} +1 -1
- package/dist/{dist-Cx3cKtBK.js → dist-DHIdvk3W.js} +212 -712
- package/dist/dist-DHIdvk3W.js.map +1 -0
- package/dist/dist-DK4ql7b3.js +6 -0
- package/package.json +2 -2
- package/dist/auth-session-CUkmayoU.js +0 -6
- package/dist/dist-Cx3cKtBK.js.map +0 -1
- package/dist/dist-DT0weBoQ.js +0 -6
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
|
|
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-DLlv4P6u.js";
|
|
4
|
+
import { $ as getSpaceDispatchLookupResponseSchema, $n as normalizeMessageEnvelope, $t as structuredGuidePayloadFromInputSchema, A as dispatchBriefSchema, An as SPACE_MENTION_REJECT_NOTICE_PURPOSE, At as postSpaceMembersResponseSchema, B as gatewayErrorCodeSchema, Bn as buildAgentControllerConversationRef, Bt as setLocalRuntimeDisplayNameBodySchema, C as createSpaceThreadResponseSchema, Cn as MAX_PROFILE_WORKING_DIRECTORY_LENGTH, Cr as runtimeTransportRouteCatalogChangedFramePayloadSchema, Ct as observabilityWakeTraceSelectorSchema, D as daemonRouteObservationResponseSchema, Dn as RUNTIME_TRANSPORT_SCHEMA_VERSION, Dt as postNormalMessageBodySchema, E as daemonRouteCatalogCacheSchema, En as MESSAGE_MENTION_TYPE_VALUES, Et as patchSpaceContractResponseSchema, F as forgetCurrentComputerResponseSchema, Fn as atsdControlPlaneRequestSchema, Ft as projectObservabilityWakeCorrelation, G as getAgentExecutionReadinessResponseSchema, Gn as conversationExecutionStateSchema, Gt as spaceCreatorSchema, H as getActiveSpaceWakeProgressResponseSchema, Hn as canonicalizeAgentControllerRef, Ht as setupPlanAgentViewPayloadSchema, I as formatLocalComponentsSummaryDescription, In as atsdControlPlaneResponseSchema, It as projectSpaceDispatchTraceFinalVisibleOutcome, J as getLocalRuntimeExpectedRoutesResponseSchema, Jn as daemonStreamFrameSchema, Jt as spaceMemberDirectoryEntrySchema, K as getAgentProfilePrimaryBindingResponseSchema, Kn as daemonServiceContractSchema, Kt as spaceDispatchTraceResponseSchema, L as formatLocalComponentsSummaryLabel, Ln as atsdTaskResultEnvelopeWriteSchema, Lt as removeSpaceMembersResponseSchema, M as ensureAgentProfilePrimaryBindingResponseSchema, Mn as SPACE_UPDATES_MAX_LIMIT, Mt as postSpaceThreadSignalResponseSchema, N as entryBriefSchema, Nn as atsRuntimeProfileIdSchema, Nt as prepareSessionResponseSchema, O as daemonRuntimeLeaseSchema, On as SPACE_MEMBER_JOIN_NOTICE_PURPOSE, Ot as postNormalMessageResponseSchema, P as forgetComputerResponseSchema, Pn as atsSpaceEgressActionSchema, Pt as prepareSessionStreamServerFrameSchema, Q as getSpaceContractResponseSchema, Qn as normalizeKnownBuiltinAgentControllerId, Qt as spaceViewerMembershipResponseSchema, R as formatLocalSetupActionDescription, Rn as atsdTaskResultOpenClawGatewayVisibilityStatusSchema, Rt as resolveSpaceDispatchTraceRootCause, S as createSpaceThreadBodySchema, Sn as MAX_PROFILE_ID_LENGTH, Sr as runtimeTransportRegisterSessionResponseSchema, St as notifyAgentProfileRouteCatalogChangedResponseSchema, T as currentLocalRuntimeReplyReadinessResponseSchema, Tn as MAX_VISITED_PROFILE_IDS, Tr as sanitizeSignalTextPreview, Tt as patchSpaceContractBodySchema, U as getAgentExecutionReadinessBatchBodySchema, Un as canonicalizeBuiltinAgentControllerRef, Ut as signalEnvelopeSchema, V as gatewayErrorEnvelopeSchema, Vn as buildAgentControllerRoutingKey, Vt as setupPlanAgentViewEventSchema, W as getAgentExecutionReadinessBatchResponseSchema, Wn as collectCanonicalMentionTextFragments, Wt as spaceBootstrapResponseSchema, X as getPrepareReadinessQuerySchema, Xn as getSpaceMessageAddressingRelationSupportForTargetKind, Xt as spaceMembersSnapshotSchema, Y as getModelCatalogResponseSchema, Yn as formatCanonicalMentionLiteral, Yt as spaceMemberDirectorySchema, Z as getPrepareReadinessResponseSchema, Zn as normalizeBuiltinAgentControllerId, Zt as spaceMetaSchema, _ as continuitySchema, _n as CURRENT_DAEMON_EXECUTION_CONTRACT_EPOCH, _r as runtimeTransportDispatchPreviewRequestSchema, _t as localRuntimesResponseSchema, a as DAEMON_ROUTE_CATALOG_CACHE_SCHEMA_VERSION, an as submitRuntimeRegistrationResponseSchema, ar as providerDispatchRuntimeContextSchema, at as getSpaceWakeProgressResponseSchema, b as createSpaceDiagnosticReportResponseSchema, bn as DISPATCH_ACTIVITY_RETRYING_PURPOSE, br as runtimeTransportHeartbeatResponseSchema, bt as normalizeSpaceCursorPatch, c as SETUP_PLAN_AGENT_VIEW_CODE, cn as writeCurrentDeviceObservedMetadataBodySchema, cr as resolveSingleSpaceMentionLabels, ct as installedLocalComponentsSnapshotSchema, d as accountSpaceIndexResponseSchema, dn as AGENT_REPLYING_PURPOSE, dt as listSpaceThreadEventsResponseSchema, en as submitRuntimeAgentControllerReportsBodySchema, er as normalizeOptionalWorkingDirectory, et as getSpaceDispatchResultResponseSchema, f as agentExecutionReadinessRouteParamsSchema, fn as AGENT_REPLY_PREVIEW_END_PURPOSE, fr as runtimeCoordinatorExecutionTokenEnvelopeSchema, ft as listSpaceThreadSignalsResponseSchema, g as cliJsonOutputEnvelopeSchema, gn as CONVERSATION_CONTINUITY_WARNING_PURPOSE, gr as runtimeTransportDispatchPreviewEndRequestSchema, gt as localRuntimesQuerySchema, h as catchupResponseSchema, hn as ATSD_TASK_RESULT_SCHEMA_VERSION, hr as runtimeTransportDispatchLifecycleRequestSchema, ht as localRuntimeEnrollmentResponseSchema, i as DAEMON_ROUTE_CATALOG_CACHE_SCHEMA_NAME, in as submitRuntimeRegistrationBodySchema, ir as profileWorkspaceModeSchema, it as getSpaceUpdatesResponseSchema, j as ensureAgentProfilePrimaryBindingBodySchema, jn as SPACE_PASSWORD_MIN_LENGTH, jt as postSpaceThreadSignalBodySchema, k as deleteSpaceResponseSchema, kn as SPACE_MEMBER_REMOVE_NOTICE_PURPOSE, kt as postSpaceMembersBodySchema, l as SETUP_PLAN_AGENT_VIEW_SCHEMA_VERSION, ln as writeCurrentDeviceObservedMetadataResponseSchema, lr as resolveSpaceMentionLabels, lt as leaveSpaceResponseSchema, m as atsRequestContextSchema, mn as ATSD_CONTROL_PLANE_SCHEMA_VERSION, mr as runtimeTransportDeliveryExecutionIdentitySchema, mt as localRuntimeEnrollmentBodySchema, n as resolveBuiltinAgentControllerBrand, nn as submitRuntimeProviderConversationProofsBodySchema, nr as parseAgentControllerRef$1, nt as getSpaceStatusResponseSchema, o as LOCAL_COMPONENTS_SCHEMA_VERSION, on as updateAgentProfilePrimaryBindingModelSelectionBodySchema, or as resolveBuiltinAgentControllerConversationKind, ot as getSpaceWakeTraceWaterfallResponseSchema, p as agentProfileBindingRouteParamsSchema, pn as AGENT_REPLY_PREVIEW_PURPOSE, pr as runtimeTransportDeliverDispatchRequestSchema, pt as listSpaceThreadsResponseSchema, q as getLocalRuntimeExpectedRoutesQuerySchema, qn as daemonServiceLaneSchema, qt as spaceIdentityDirectorySchema, r as resolveMappedPublicAgentFailureReason, rn as submitRuntimeProviderConversationProofsResponseSchema, rr as parseOptionalClientMessageId, rt as getSpaceThreadResponseSchema, s as PREPARE_SESSION_STREAM_PROTOCOL_VERSION, sn as upsertProfileSpaceHistoryResponseSchema, sr as resolveMessageEnvelopeTargetField, st as incomingServerMessageSchema, t as CODEX_UPGRADE_REQUIRED_REASON, tn as submitRuntimeAgentControllerReportsResponseSchema, tr as normalizeSpacePasswordText, tt as getSpaceMessageDetailsResponseSchema, u as SPACE_DISPATCH_TRACE_PROMPT_PREVIEW_MAX_CHARS, un as AGENT_REPLYING_END_PURPOSE, ut as listProfileSpaceHistoryResponseSchema, v as createSpaceBodySchema, vn as DISPATCH_ACTIVITY_DISPATCHING_PURPOSE, vr as runtimeTransportDispatchRuntimeEvidenceRequestSchema, vt as modelCatalogSchema, w as currentDeviceTargetResponseSchema, wn as MAX_SIGNAL_REPLY_TO_PREVIEW_LENGTH, wr as runtimeTransportSubmitTaskResultRequestSchema, wt as patchProfileSpaceHistoryStatusResponseSchema, x as createSpaceResponseSchema, xn as LEGACY_RUNTIME_DISPATCH_POLICY, xr as runtimeTransportRegisterSessionRequestSchema, xt as notifyAgentProfileRouteCatalogChangedBodySchema, y as createSpaceDiagnosticReportBodySchema, yn as DISPATCH_ACTIVITY_FAILED_PURPOSE, yr as runtimeTransportHeartbeatRequestSchema, yt as normalizeListSignalsReadQuerySemantics, z as formatLocalSetupActionLabel, zn as atsdTaskResultPayloadSchema, zt as serverErrorFrameSchema } from "./dist-DHIdvk3W.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";
|
|
@@ -30,7 +30,7 @@ import { Box, Container, Editor, Key, ProcessTerminal, TUI, Text, getEditorKeybi
|
|
|
30
30
|
import { ReadStream, WriteStream } from "node:tty";
|
|
31
31
|
|
|
32
32
|
//#region package.json
|
|
33
|
-
var version = "0.7.
|
|
33
|
+
var version = "0.7.76";
|
|
34
34
|
var package_default = {
|
|
35
35
|
$schema: "https://www.schemastore.org/package.json",
|
|
36
36
|
name: "agent-transport-system",
|
|
@@ -98,7 +98,7 @@ var package_default = {
|
|
|
98
98
|
"unplugin-lightningcss": "^0.4.0",
|
|
99
99
|
"vitest": "~3.2.0"
|
|
100
100
|
},
|
|
101
|
-
ats: { "minRequiredCliVersion": "0.7.
|
|
101
|
+
ats: { "minRequiredCliVersion": "0.7.76" }
|
|
102
102
|
};
|
|
103
103
|
|
|
104
104
|
//#endregion
|
|
@@ -3909,7 +3909,7 @@ function resolveAtsAccountContext(input) {
|
|
|
3909
3909
|
};
|
|
3910
3910
|
}
|
|
3911
3911
|
async function resolveCurrentAtsAccountContext() {
|
|
3912
|
-
const { getAuthSessionMetadata } = await import("./auth-session-
|
|
3912
|
+
const { getAuthSessionMetadata } = await import("./auth-session-DpBr5mtL.js");
|
|
3913
3913
|
return resolveAtsAccountContext({ session: await getAuthSessionMetadata().catch(() => null) });
|
|
3914
3914
|
}
|
|
3915
3915
|
function resolveHostKey(baseUrl) {
|
|
@@ -4350,7 +4350,7 @@ async function setDaemonServiceRuntimeState(state, pathInput = {}) {
|
|
|
4350
4350
|
await writeDaemonServiceRuntimeState(state, pathInput);
|
|
4351
4351
|
}
|
|
4352
4352
|
async function clearDaemonServiceRuntimeState(pathInput = {}) {
|
|
4353
|
-
const { clearDaemonRuntimeLease } = await import("./daemon-runtime-lease-
|
|
4353
|
+
const { clearDaemonRuntimeLease } = await import("./daemon-runtime-lease-9c0XHMDh.js");
|
|
4354
4354
|
await Promise.all([rm(daemonServiceRuntimeStatePath(pathInput), { force: true }), clearDaemonRuntimeLease(pathInput)]);
|
|
4355
4355
|
}
|
|
4356
4356
|
async function withDaemonServiceRunLock(callback, meta = {
|
|
@@ -4826,7 +4826,6 @@ const DEFAULT_GATEWAY_CHAIN_TIMEOUT_MS$1 = 3e4;
|
|
|
4826
4826
|
const DEFAULT_REMOTE_SESSION_TIMEOUT_MS = 8e3;
|
|
4827
4827
|
const LOOPBACK_REMOTE_SESSION_TIMEOUT_MS = 1500;
|
|
4828
4828
|
const DEFAULT_WEB_AGENT_SELECTION_TIMEOUT_MS = 1800 * 1e3;
|
|
4829
|
-
const DEFAULT_WEB_AGENT_SELECTION_POLL_INTERVAL_MS = 2e3;
|
|
4830
4829
|
const DEFAULT_SPACE_REQUEST_TIMEOUT_MS = 1e4;
|
|
4831
4830
|
const MIN_SPACE_REQUEST_TIMEOUT_MS = 1e3;
|
|
4832
4831
|
const MAX_SPACE_REQUEST_TIMEOUT_MS = 12e4;
|
|
@@ -12774,7 +12773,7 @@ function resolveLocalServiceFact(input) {
|
|
|
12774
12773
|
reachable: true,
|
|
12775
12774
|
refreshable: true,
|
|
12776
12775
|
reasonCodes: [],
|
|
12777
|
-
source: "
|
|
12776
|
+
source: "runtime_transport"
|
|
12778
12777
|
};
|
|
12779
12778
|
return {
|
|
12780
12779
|
reachable: false,
|
|
@@ -25018,7 +25017,6 @@ function buildLocalRuntimeEnrollmentRoute(deviceId) {
|
|
|
25018
25017
|
}
|
|
25019
25018
|
const FORGET_CURRENT_COMPUTER_ROUTE = "/v1/devices/current/forget";
|
|
25020
25019
|
const CURRENT_LOCAL_RUNTIME_REPLY_READINESS_ROUTE = "/v1/local-runtimes/current/reply-readiness";
|
|
25021
|
-
const CURRENT_LOCAL_RUNTIME_OBSERVED_METADATA_ROUTE = "/v1/local-runtimes/current/observed-metadata";
|
|
25022
25020
|
const LOCAL_RUNTIMES_ROUTE = "/v1/local-runtimes";
|
|
25023
25021
|
function buildLocalRuntimesRoute(input) {
|
|
25024
25022
|
if (!input?.connectionIdentityAdoption) return LOCAL_RUNTIMES_ROUTE;
|
|
@@ -25051,14 +25049,6 @@ function requireValidLocalRuntimesQuery(input = {}) {
|
|
|
25051
25049
|
if (!parsed.success) throw new Error(parsed.error.issues[0]?.message ?? "Invalid local runtimes query.");
|
|
25052
25050
|
return parsed.data;
|
|
25053
25051
|
}
|
|
25054
|
-
function requireValidSetupTokenLocalRuntimeObservedMetadataBody(input) {
|
|
25055
|
-
const parsed = writeSetupTokenLocalRuntimeObservedMetadataBodySchema.safeParse({
|
|
25056
|
-
opaqueToken: input.opaqueToken,
|
|
25057
|
-
metadata: input.metadata
|
|
25058
|
-
});
|
|
25059
|
-
if (!parsed.success) throw new Error(parsed.error.issues[0]?.message ?? "Invalid setup-token local runtime observed metadata body.");
|
|
25060
|
-
return parsed.data;
|
|
25061
|
-
}
|
|
25062
25052
|
function requireValidLocalRuntimeDisplayNameBody(input) {
|
|
25063
25053
|
const parsed = setLocalRuntimeDisplayNameBodySchema.safeParse({ displayName: input.displayName });
|
|
25064
25054
|
if (!parsed.success) throw new Error(parsed.error.issues[0]?.message ?? "Invalid local runtime display name body.");
|
|
@@ -25139,18 +25129,6 @@ const createCurrentDeviceApi = (client) => {
|
|
|
25139
25129
|
schema: writeCurrentDeviceObservedMetadataResponseSchema,
|
|
25140
25130
|
invalidMessage: "Invalid current device observed metadata response."
|
|
25141
25131
|
});
|
|
25142
|
-
},
|
|
25143
|
-
writeSetupTokenObservedMetadata: async (input) => {
|
|
25144
|
-
const body = requireValidSetupTokenLocalRuntimeObservedMetadataBody(input);
|
|
25145
|
-
return await client.requestJson({
|
|
25146
|
-
url: CURRENT_LOCAL_RUNTIME_OBSERVED_METADATA_ROUTE,
|
|
25147
|
-
operation: "local_runtime.setup_token.observed_metadata.write",
|
|
25148
|
-
method: "PUT",
|
|
25149
|
-
headers: { "content-type": "application/json" },
|
|
25150
|
-
body: JSON.stringify(body),
|
|
25151
|
-
schema: writeSetupTokenLocalRuntimeObservedMetadataResponseSchema,
|
|
25152
|
-
invalidMessage: "Invalid setup-token local runtime observed metadata response."
|
|
25153
|
-
});
|
|
25154
25132
|
}
|
|
25155
25133
|
};
|
|
25156
25134
|
};
|
|
@@ -25839,166 +25817,6 @@ const createSpaceApi = (client) => {
|
|
|
25839
25817
|
postThreadSignal: async (input) => await postSpaceThreadSignal(client, input)
|
|
25840
25818
|
};
|
|
25841
25819
|
};
|
|
25842
|
-
function buildStartSessionPath(deviceId) {
|
|
25843
|
-
return `/v1/start/devices/${encodeURIComponent(deviceId)}/session`;
|
|
25844
|
-
}
|
|
25845
|
-
function buildStartSessionTokenPath(deviceId) {
|
|
25846
|
-
return `${buildStartSessionPath(deviceId)}/token`;
|
|
25847
|
-
}
|
|
25848
|
-
function buildStartSessionSpaceChoicePath(deviceId) {
|
|
25849
|
-
return `${buildStartSessionPath(deviceId)}/space-choice`;
|
|
25850
|
-
}
|
|
25851
|
-
function buildStartSessionSpaceChoiceResumePath(deviceId) {
|
|
25852
|
-
return `${buildStartSessionSpaceChoicePath(deviceId)}/resume`;
|
|
25853
|
-
}
|
|
25854
|
-
function buildStartHandoffPath() {
|
|
25855
|
-
return "/v1/start/session/handoff";
|
|
25856
|
-
}
|
|
25857
|
-
async function resolveStartHandoff$1(client, input) {
|
|
25858
|
-
const body = requireValidStartHandoffBody({ opaqueToken: input.opaqueToken });
|
|
25859
|
-
return await client.requestJson({
|
|
25860
|
-
url: buildStartHandoffPath(),
|
|
25861
|
-
operation: "start.handoff.resolve",
|
|
25862
|
-
method: "POST",
|
|
25863
|
-
headers: { "content-type": "application/json" },
|
|
25864
|
-
body: JSON.stringify(body),
|
|
25865
|
-
schema: resolveStartHandoffResponseSchema,
|
|
25866
|
-
invalidMessage: "Invalid start handoff response."
|
|
25867
|
-
});
|
|
25868
|
-
}
|
|
25869
|
-
function requireValidStartHandoffBody(input) {
|
|
25870
|
-
const parsed = resolveStartHandoffBodySchema.safeParse(input);
|
|
25871
|
-
if (!parsed.success) throw new Error(parsed.error.issues[0]?.message ?? "Invalid start handoff request body.");
|
|
25872
|
-
return parsed.data;
|
|
25873
|
-
}
|
|
25874
|
-
async function createStartSession(client, input) {
|
|
25875
|
-
const body = requireValidStartSessionCreateBody({
|
|
25876
|
-
initiator: input.initiator,
|
|
25877
|
-
profileChoice: input.profileChoice,
|
|
25878
|
-
localAgentPreparation: input.localAgentPreparation,
|
|
25879
|
-
...input.spaceMemberSelection === void 0 ? {} : { spaceMemberSelection: input.spaceMemberSelection },
|
|
25880
|
-
spaceChoice: input.spaceChoice,
|
|
25881
|
-
...input.writeMode === void 0 ? {} : { writeMode: input.writeMode }
|
|
25882
|
-
});
|
|
25883
|
-
return await client.requestJson({
|
|
25884
|
-
url: buildStartSessionPath(input.deviceId),
|
|
25885
|
-
operation: "start.session.create",
|
|
25886
|
-
method: "POST",
|
|
25887
|
-
requestContext: input.requestContext,
|
|
25888
|
-
headers: { "content-type": "application/json" },
|
|
25889
|
-
body: JSON.stringify(body),
|
|
25890
|
-
schema: startSessionWithTokenResponseSchema,
|
|
25891
|
-
invalidMessage: "Invalid start session response."
|
|
25892
|
-
});
|
|
25893
|
-
}
|
|
25894
|
-
async function getStartSession(client, input) {
|
|
25895
|
-
return await client.requestJson({
|
|
25896
|
-
url: buildStartSessionPath(input.deviceId),
|
|
25897
|
-
operation: "start.session.read",
|
|
25898
|
-
method: "GET",
|
|
25899
|
-
requestContext: input.requestContext,
|
|
25900
|
-
schema: startSessionResponseSchema,
|
|
25901
|
-
invalidMessage: "Invalid start session response."
|
|
25902
|
-
});
|
|
25903
|
-
}
|
|
25904
|
-
async function patchStartSession(client, input) {
|
|
25905
|
-
const body = requireValidStartSessionPatchBody({
|
|
25906
|
-
...input.profileChoice === void 0 ? {} : { profileChoice: input.profileChoice },
|
|
25907
|
-
...input.localAgentPreparation === void 0 ? {} : { localAgentPreparation: input.localAgentPreparation },
|
|
25908
|
-
...input.spaceMemberSelection === void 0 ? {} : { spaceMemberSelection: input.spaceMemberSelection },
|
|
25909
|
-
...input.spaceChoice === void 0 ? {} : { spaceChoice: input.spaceChoice },
|
|
25910
|
-
...input.targetSpaceId === void 0 ? {} : { targetSpaceId: input.targetSpaceId }
|
|
25911
|
-
});
|
|
25912
|
-
return await client.requestJson({
|
|
25913
|
-
url: buildStartSessionPath(input.deviceId),
|
|
25914
|
-
operation: "start.session.update",
|
|
25915
|
-
method: "PATCH",
|
|
25916
|
-
requestContext: input.requestContext,
|
|
25917
|
-
headers: { "content-type": "application/json" },
|
|
25918
|
-
body: JSON.stringify(body),
|
|
25919
|
-
schema: startSessionResponseSchema,
|
|
25920
|
-
invalidMessage: "Invalid start session response."
|
|
25921
|
-
});
|
|
25922
|
-
}
|
|
25923
|
-
async function submitStartSessionSpaceChoice(client, input) {
|
|
25924
|
-
const body = requireValidStartSessionSpaceChoiceBody({
|
|
25925
|
-
mode: input.mode,
|
|
25926
|
-
...input.mode === "create_new" ? {
|
|
25927
|
-
name: input.name,
|
|
25928
|
-
...input.password === void 0 ? {} : { password: input.password }
|
|
25929
|
-
} : {
|
|
25930
|
-
spaceId: input.spaceId,
|
|
25931
|
-
...input.password === void 0 ? {} : { password: input.password }
|
|
25932
|
-
}
|
|
25933
|
-
});
|
|
25934
|
-
return await client.requestJson({
|
|
25935
|
-
url: buildStartSessionSpaceChoicePath(input.deviceId),
|
|
25936
|
-
operation: "start.session.space_choice.submit",
|
|
25937
|
-
method: "POST",
|
|
25938
|
-
requestContext: input.requestContext,
|
|
25939
|
-
headers: { "content-type": "application/json" },
|
|
25940
|
-
body: JSON.stringify(body),
|
|
25941
|
-
schema: startSessionSpaceChoiceResponseSchema,
|
|
25942
|
-
invalidMessage: "Invalid start session space choice response."
|
|
25943
|
-
});
|
|
25944
|
-
}
|
|
25945
|
-
async function resumeStartSessionSpaceChoice(client, input) {
|
|
25946
|
-
return await client.requestJson({
|
|
25947
|
-
url: buildStartSessionSpaceChoiceResumePath(input.deviceId),
|
|
25948
|
-
operation: "start.session.space_choice.resume",
|
|
25949
|
-
method: "POST",
|
|
25950
|
-
requestContext: input.requestContext,
|
|
25951
|
-
schema: startSessionResponseSchema,
|
|
25952
|
-
invalidMessage: "Invalid start session response."
|
|
25953
|
-
});
|
|
25954
|
-
}
|
|
25955
|
-
function requireValidStartSessionCreateBody(input) {
|
|
25956
|
-
const parsed = createStartSessionBodySchema.safeParse(input);
|
|
25957
|
-
if (!parsed.success) throw new Error(parsed.error.issues[0]?.message ?? "Invalid start session request body.");
|
|
25958
|
-
return parsed.data;
|
|
25959
|
-
}
|
|
25960
|
-
function requireValidStartSessionPatchBody(input) {
|
|
25961
|
-
const parsed = patchStartSessionBodySchema.safeParse(input);
|
|
25962
|
-
if (!parsed.success) throw new Error(parsed.error.issues[0]?.message ?? "Invalid start session patch body.");
|
|
25963
|
-
return parsed.data;
|
|
25964
|
-
}
|
|
25965
|
-
function requireValidStartSessionSpaceChoiceBody(input) {
|
|
25966
|
-
const parsed = startSessionSpaceChoiceBodySchema.safeParse(input);
|
|
25967
|
-
if (!parsed.success) throw new Error(parsed.error.issues[0]?.message ?? "Invalid start session space choice body.");
|
|
25968
|
-
return parsed.data;
|
|
25969
|
-
}
|
|
25970
|
-
async function mintStartSessionToken(client, input) {
|
|
25971
|
-
return await client.requestJson({
|
|
25972
|
-
url: buildStartSessionTokenPath(input.deviceId),
|
|
25973
|
-
operation: "start.session.token.mint",
|
|
25974
|
-
method: "POST",
|
|
25975
|
-
requestContext: input.requestContext,
|
|
25976
|
-
schema: startSessionWithTokenResponseSchema,
|
|
25977
|
-
invalidMessage: "Invalid start session token response."
|
|
25978
|
-
});
|
|
25979
|
-
}
|
|
25980
|
-
async function invalidateStartSessionToken(client, input) {
|
|
25981
|
-
return await client.requestJson({
|
|
25982
|
-
url: buildStartSessionTokenPath(input.deviceId),
|
|
25983
|
-
operation: "start.session.token.invalidate",
|
|
25984
|
-
method: "DELETE",
|
|
25985
|
-
requestContext: input.requestContext,
|
|
25986
|
-
schema: startSessionResponseSchema,
|
|
25987
|
-
invalidMessage: "Invalid start session response."
|
|
25988
|
-
});
|
|
25989
|
-
}
|
|
25990
|
-
const createStartApi = (client) => {
|
|
25991
|
-
return {
|
|
25992
|
-
createSession: (input) => createStartSession(client, input),
|
|
25993
|
-
getSession: (input) => getStartSession(client, input),
|
|
25994
|
-
patchSession: (input) => patchStartSession(client, input),
|
|
25995
|
-
submitSpaceChoice: (input) => submitStartSessionSpaceChoice(client, input),
|
|
25996
|
-
resumeSpaceChoice: (input) => resumeStartSessionSpaceChoice(client, input),
|
|
25997
|
-
resolveHandoff: (input) => resolveStartHandoff$1(client, input),
|
|
25998
|
-
mintSessionToken: (input) => mintStartSessionToken(client, input),
|
|
25999
|
-
invalidateSessionToken: (input) => invalidateStartSessionToken(client, input)
|
|
26000
|
-
};
|
|
26001
|
-
};
|
|
26002
25820
|
function createFetchTransport(input) {
|
|
26003
25821
|
const defaultTimeoutMs = normalizeOptionalTimeoutMs(input.defaultTimeoutMs);
|
|
26004
25822
|
return async function fetchTransport(request) {
|
|
@@ -26770,9 +26588,9 @@ function createModelCatalogReadSession(input) {
|
|
|
26770
26588
|
async function readModelCatalogOnce(baseUrl) {
|
|
26771
26589
|
try {
|
|
26772
26590
|
const [apiClient, baseUrlModule, clientFoundationModule] = await Promise.all([
|
|
26773
|
-
import("./dist-
|
|
26774
|
-
import("./base-url-
|
|
26775
|
-
import("./api-client-foundation-
|
|
26591
|
+
import("./dist-DK4ql7b3.js"),
|
|
26592
|
+
import("./base-url-DLlv4P6u.js").then((n) => n.n),
|
|
26593
|
+
import("./api-client-foundation-SXFJ2-50.js")
|
|
26776
26594
|
]);
|
|
26777
26595
|
if (typeof apiClient.createConfigApi !== "function") throw new Error("config api client is unavailable");
|
|
26778
26596
|
const resolvedBaseUrl = baseUrl ?? await baseUrlModule.resolveBaseUrl();
|
|
@@ -28786,8 +28604,8 @@ function toJournalErrorMessage(error) {
|
|
|
28786
28604
|
//#endregion
|
|
28787
28605
|
//#region src/local-service/dispatch/send-dispatch-result.ts
|
|
28788
28606
|
function sendDispatchResultEnvelopeFrame(input) {
|
|
28789
|
-
const resultRequest =
|
|
28790
|
-
v:
|
|
28607
|
+
const resultRequest = runtimeTransportSubmitTaskResultRequestSchema.safeParse({
|
|
28608
|
+
v: RUNTIME_TRANSPORT_SCHEMA_VERSION,
|
|
28791
28609
|
...input.runtimeCoordinatorExecutionId ? { runtimeCoordinatorExecutionId: input.runtimeCoordinatorExecutionId } : {},
|
|
28792
28610
|
...input.executionTokenEcho ? { executionTokenEcho: input.executionTokenEcho } : {},
|
|
28793
28611
|
dispatchId: input.dispatchId,
|
|
@@ -28808,8 +28626,8 @@ function sendDispatchResultEnvelopeFrame(input) {
|
|
|
28808
28626
|
});
|
|
28809
28627
|
}
|
|
28810
28628
|
function sendDispatchLifecycleFrame(input) {
|
|
28811
|
-
const lifecycleRequest =
|
|
28812
|
-
v:
|
|
28629
|
+
const lifecycleRequest = runtimeTransportDispatchLifecycleRequestSchema.safeParse({
|
|
28630
|
+
v: RUNTIME_TRANSPORT_SCHEMA_VERSION,
|
|
28813
28631
|
...input.runtimeCoordinatorExecutionId ? { runtimeCoordinatorExecutionId: input.runtimeCoordinatorExecutionId } : {},
|
|
28814
28632
|
...input.executionTokenEcho ? { executionTokenEcho: input.executionTokenEcho } : {},
|
|
28815
28633
|
dispatchId: input.dispatchId,
|
|
@@ -28831,8 +28649,8 @@ function sendDispatchLifecycleFrame(input) {
|
|
|
28831
28649
|
});
|
|
28832
28650
|
}
|
|
28833
28651
|
function sendDispatchRuntimeEvidenceFrame(input) {
|
|
28834
|
-
const runtimeEvidenceRequest =
|
|
28835
|
-
v:
|
|
28652
|
+
const runtimeEvidenceRequest = runtimeTransportDispatchRuntimeEvidenceRequestSchema.safeParse({
|
|
28653
|
+
v: RUNTIME_TRANSPORT_SCHEMA_VERSION,
|
|
28836
28654
|
...input.runtimeCoordinatorExecutionId ? { runtimeCoordinatorExecutionId: input.runtimeCoordinatorExecutionId } : {},
|
|
28837
28655
|
...input.executionTokenEcho ? { executionTokenEcho: input.executionTokenEcho } : {},
|
|
28838
28656
|
dispatchId: input.dispatchId,
|
|
@@ -28862,8 +28680,8 @@ function sendDispatchRuntimeEvidenceFrame(input) {
|
|
|
28862
28680
|
});
|
|
28863
28681
|
}
|
|
28864
28682
|
function sendDispatchPreviewFrame(input) {
|
|
28865
|
-
const previewRequest =
|
|
28866
|
-
v:
|
|
28683
|
+
const previewRequest = runtimeTransportDispatchPreviewRequestSchema.safeParse({
|
|
28684
|
+
v: RUNTIME_TRANSPORT_SCHEMA_VERSION,
|
|
28867
28685
|
dispatchId: input.dispatchId,
|
|
28868
28686
|
attemptId: input.attemptId,
|
|
28869
28687
|
daemonSessionId: input.daemonSessionId,
|
|
@@ -28878,8 +28696,8 @@ function sendDispatchPreviewFrame(input) {
|
|
|
28878
28696
|
});
|
|
28879
28697
|
}
|
|
28880
28698
|
function sendDispatchPreviewEndFrame(input) {
|
|
28881
|
-
const previewEndRequest =
|
|
28882
|
-
v:
|
|
28699
|
+
const previewEndRequest = runtimeTransportDispatchPreviewEndRequestSchema.safeParse({
|
|
28700
|
+
v: RUNTIME_TRANSPORT_SCHEMA_VERSION,
|
|
28883
28701
|
dispatchId: input.dispatchId,
|
|
28884
28702
|
attemptId: input.attemptId,
|
|
28885
28703
|
daemonSessionId: input.daemonSessionId,
|
|
@@ -28997,7 +28815,7 @@ function buildFailedTaskResultPayload(input) {
|
|
|
28997
28815
|
}
|
|
28998
28816
|
function sendDaemonFrame$1(inputSocket, input) {
|
|
28999
28817
|
inputSocket.send(JSON.stringify({
|
|
29000
|
-
v:
|
|
28818
|
+
v: RUNTIME_TRANSPORT_SCHEMA_VERSION,
|
|
29001
28819
|
code: input.code,
|
|
29002
28820
|
payload: input.payload
|
|
29003
28821
|
}));
|
|
@@ -33775,7 +33593,7 @@ function enqueueDispatchDeliverFrame(input) {
|
|
|
33775
33593
|
connectionGeneration: normalizePositiveInteger(input.payload.connectionGeneration),
|
|
33776
33594
|
socket: input.socket
|
|
33777
33595
|
};
|
|
33778
|
-
const parsedDeliver =
|
|
33596
|
+
const parsedDeliver = runtimeTransportDeliverDispatchRequestSchema.safeParse(input.payload);
|
|
33779
33597
|
if (!parsedDeliver.success) {
|
|
33780
33598
|
reportInvalidDeliverRequest({
|
|
33781
33599
|
currentSocketRef,
|
|
@@ -33819,7 +33637,7 @@ function enqueueDispatchDeliverFrame(input) {
|
|
|
33819
33637
|
executionTokenRunId: deliverRequest.payload.executionToken?.runId ?? null,
|
|
33820
33638
|
localExecutionLaneKey: queueLogMeta.localExecutionLaneKey,
|
|
33821
33639
|
onQueued: (event) => {
|
|
33822
|
-
const localQueue =
|
|
33640
|
+
const localQueue = toRuntimeTransportDispatchLocalQueueDiagnostics(event.localQueue);
|
|
33823
33641
|
emitDispatchLifecycleTransition({
|
|
33824
33642
|
attemptId: correlation.attemptId,
|
|
33825
33643
|
connectionGeneration: deliverRequest.connectionGeneration,
|
|
@@ -33907,7 +33725,7 @@ function enqueueDispatchDeliverFrame(input) {
|
|
|
33907
33725
|
currentSocketRef,
|
|
33908
33726
|
daemonSessionId: input.daemonSessionId,
|
|
33909
33727
|
dispatchId: correlation.dispatchId,
|
|
33910
|
-
executionIdentityEcho:
|
|
33728
|
+
executionIdentityEcho: toRuntimeTransportResultIdentityEcho(deliverRequest),
|
|
33911
33729
|
executionTokenEcho: toRuntimeCoordinatorExecutionTokenEcho(deliverRequest),
|
|
33912
33730
|
ledgerPaths: input.ledgerPaths,
|
|
33913
33731
|
leaseEpoch: deliverRequest.leaseEpoch,
|
|
@@ -34118,7 +33936,7 @@ function reportInvalidDeliverRequest(input) {
|
|
|
34118
33936
|
function resolveInvalidDeliverRequestIdentity(input) {
|
|
34119
33937
|
const taskPayload = toRecord(input.payload.payload);
|
|
34120
33938
|
const controllerSnapshot = toRecord(taskPayload?.controllerSnapshot);
|
|
34121
|
-
const executionIdentity =
|
|
33939
|
+
const executionIdentity = runtimeTransportDeliveryExecutionIdentitySchema.safeParse(taskPayload?.executionIdentity);
|
|
34122
33940
|
const attemptId = normalizeOptionalText$26(input.payload.attemptId) ?? normalizeOptionalText$26(taskPayload?.attemptId);
|
|
34123
33941
|
const connectionGeneration = normalizePositiveInteger(input.payload.connectionGeneration);
|
|
34124
33942
|
const daemonSessionId = normalizeOptionalText$26(input.payload.daemonSessionId) ?? input.fallbackDaemonSessionId;
|
|
@@ -34136,7 +33954,7 @@ function resolveInvalidDeliverRequestIdentity(input) {
|
|
|
34136
33954
|
agentControllerRef: normalizeOptionalText$26(controllerSnapshot?.agentControllerRef) ?? null,
|
|
34137
33955
|
daemonSessionId,
|
|
34138
33956
|
dispatchId,
|
|
34139
|
-
executionIdentityEcho:
|
|
33957
|
+
executionIdentityEcho: toRuntimeTransportResultIdentityEchoFromDeliveryIdentity(executionIdentity.data),
|
|
34140
33958
|
executionTokenEcho,
|
|
34141
33959
|
leaseEpoch,
|
|
34142
33960
|
runtimeCoordinatorExecutionId,
|
|
@@ -34828,7 +34646,7 @@ async function handleDispatchDeliverFrame(input) {
|
|
|
34828
34646
|
currentSocketRef,
|
|
34829
34647
|
daemonSessionId: input.daemonSessionId,
|
|
34830
34648
|
dispatchId: parsedTask.dispatchId,
|
|
34831
|
-
executionIdentityEcho:
|
|
34649
|
+
executionIdentityEcho: toRuntimeTransportResultIdentityEcho(input.deliverRequest),
|
|
34832
34650
|
executionTokenEcho: parsedTask.executionTokenEcho,
|
|
34833
34651
|
leaseEpoch: input.deliverRequest.leaseEpoch,
|
|
34834
34652
|
payload: resultPayload,
|
|
@@ -36339,7 +36157,7 @@ function sendDispatchRejectionResult(input) {
|
|
|
36339
36157
|
currentSocketRef: input.currentSocketRef,
|
|
36340
36158
|
daemonSessionId: input.daemonSessionId,
|
|
36341
36159
|
dispatchId: input.dispatchId,
|
|
36342
|
-
executionIdentityEcho:
|
|
36160
|
+
executionIdentityEcho: toRuntimeTransportResultIdentityEcho(input.deliverRequest),
|
|
36343
36161
|
executionTokenEcho: toRuntimeCoordinatorExecutionTokenEcho(input.deliverRequest),
|
|
36344
36162
|
ledgerPaths: input.ledgerPaths,
|
|
36345
36163
|
leaseEpoch: input.deliverRequest.leaseEpoch,
|
|
@@ -36932,7 +36750,7 @@ function emitDispatchRuntimeEvidenceTransition(input) {
|
|
|
36932
36750
|
dispatchId: identity.dispatchId,
|
|
36933
36751
|
durationMs: input.durationMs ?? null,
|
|
36934
36752
|
errorName: input.errorName ?? null,
|
|
36935
|
-
executionIdentityEcho:
|
|
36753
|
+
executionIdentityEcho: toRuntimeTransportRuntimeEvidenceIdentityEcho(input.deliverRequest),
|
|
36936
36754
|
executionTokenEcho: toRuntimeCoordinatorExecutionTokenEcho(input.deliverRequest),
|
|
36937
36755
|
leaseEpoch: input.deliverRequest.leaseEpoch,
|
|
36938
36756
|
phase: input.phase,
|
|
@@ -36972,14 +36790,14 @@ function buildDispatchRuntimeEvidenceIdentity(input) {
|
|
|
36972
36790
|
taskId: input.parsedTask?.taskId ?? payload.taskId
|
|
36973
36791
|
};
|
|
36974
36792
|
}
|
|
36975
|
-
function
|
|
36793
|
+
function toRuntimeTransportRuntimeEvidenceIdentityEcho(deliverRequest) {
|
|
36976
36794
|
return {
|
|
36977
36795
|
echoSource: "daemon_delivery_context",
|
|
36978
36796
|
core: deliverRequest.payload.executionIdentity.core
|
|
36979
36797
|
};
|
|
36980
36798
|
}
|
|
36981
|
-
function
|
|
36982
|
-
return
|
|
36799
|
+
function toRuntimeTransportResultIdentityEcho(deliverRequest) {
|
|
36800
|
+
return toRuntimeTransportResultIdentityEchoFromDeliveryIdentity(deliverRequest.payload.executionIdentity);
|
|
36983
36801
|
}
|
|
36984
36802
|
function toRuntimeCoordinatorExecutionTokenEcho(deliverRequest) {
|
|
36985
36803
|
const executionToken = deliverRequest.payload.executionToken;
|
|
@@ -37001,7 +36819,7 @@ function resolveRuntimeCoordinatorExecutionTokenEchoFromRaw(value) {
|
|
|
37001
36819
|
tokenFingerprint: parsed.data.tokenFingerprint
|
|
37002
36820
|
};
|
|
37003
36821
|
}
|
|
37004
|
-
function
|
|
36822
|
+
function toRuntimeTransportResultIdentityEchoFromDeliveryIdentity(executionIdentity) {
|
|
37005
36823
|
return {
|
|
37006
36824
|
echoSource: "daemon_delivery_context",
|
|
37007
36825
|
core: executionIdentity.core
|
|
@@ -37014,7 +36832,7 @@ function resolveRuntimeEvidenceResultReasonCode(payload) {
|
|
|
37014
36832
|
if (payload.status !== "failed") return null;
|
|
37015
36833
|
return normalizeOptionalText$26(payload.errorCode) ?? null;
|
|
37016
36834
|
}
|
|
37017
|
-
function
|
|
36835
|
+
function toRuntimeTransportDispatchLocalQueueDiagnostics(input) {
|
|
37018
36836
|
return {
|
|
37019
36837
|
activeForLane: input.activeForLane,
|
|
37020
36838
|
activeGlobal: input.activeGlobal,
|
|
@@ -37174,7 +36992,7 @@ function parseDaemonFrame(raw) {
|
|
|
37174
36992
|
}
|
|
37175
36993
|
function resolveRegisterResponseFrame(input) {
|
|
37176
36994
|
if (!input.waiters.registerResolver) return;
|
|
37177
|
-
const registerPayload =
|
|
36995
|
+
const registerPayload = runtimeTransportRegisterSessionResponseSchema.safeParse(input.payload);
|
|
37178
36996
|
if (!registerPayload.success) return;
|
|
37179
36997
|
const resolver = input.waiters.registerResolver;
|
|
37180
36998
|
input.waiters.registerResolver = null;
|
|
@@ -37194,7 +37012,7 @@ function resolveRegisterResponseFrame(input) {
|
|
|
37194
37012
|
}
|
|
37195
37013
|
function resolveHeartbeatResponseFrame(input) {
|
|
37196
37014
|
if (!input.waiters.heartbeatResolver) return;
|
|
37197
|
-
const heartbeatPayload =
|
|
37015
|
+
const heartbeatPayload = runtimeTransportHeartbeatResponseSchema.safeParse(input.payload);
|
|
37198
37016
|
if (!heartbeatPayload.success) return;
|
|
37199
37017
|
const resolver = input.waiters.heartbeatResolver;
|
|
37200
37018
|
input.waiters.heartbeatResolver = null;
|
|
@@ -37349,7 +37167,7 @@ function handleDaemonSocketFrame(input) {
|
|
|
37349
37167
|
}
|
|
37350
37168
|
function sendDaemonFrame(inputSocket, input) {
|
|
37351
37169
|
inputSocket.send(JSON.stringify({
|
|
37352
|
-
v:
|
|
37170
|
+
v: RUNTIME_TRANSPORT_SCHEMA_VERSION,
|
|
37353
37171
|
code: input.code,
|
|
37354
37172
|
payload: input.payload
|
|
37355
37173
|
}));
|
|
@@ -37665,8 +37483,8 @@ async function runDaemonSocketSession(input) {
|
|
|
37665
37483
|
profileId,
|
|
37666
37484
|
leaseEpoch
|
|
37667
37485
|
})).sort((left, right) => left.profileId.localeCompare(right.profileId));
|
|
37668
|
-
const heartbeatRequest =
|
|
37669
|
-
v:
|
|
37486
|
+
const heartbeatRequest = runtimeTransportHeartbeatRequestSchema.safeParse({
|
|
37487
|
+
v: RUNTIME_TRANSPORT_SCHEMA_VERSION,
|
|
37670
37488
|
ownerUserId: input.ownerUserId,
|
|
37671
37489
|
deviceId: input.deviceId,
|
|
37672
37490
|
lane: input.lane,
|
|
@@ -37851,8 +37669,8 @@ async function runDaemonSocketSession(input) {
|
|
|
37851
37669
|
});
|
|
37852
37670
|
const registerDaemonSession = async (routeCatalog) => {
|
|
37853
37671
|
const connectionGeneration = Math.max(1, input.reconnectAttempt + 1);
|
|
37854
|
-
const registerPayload =
|
|
37855
|
-
v:
|
|
37672
|
+
const registerPayload = runtimeTransportRegisterSessionRequestSchema.safeParse({
|
|
37673
|
+
v: RUNTIME_TRANSPORT_SCHEMA_VERSION,
|
|
37856
37674
|
ownerUserId: input.ownerUserId,
|
|
37857
37675
|
deviceId: input.deviceId,
|
|
37858
37676
|
lane: input.lane,
|
|
@@ -38156,7 +37974,7 @@ async function runDaemonSocketSession(input) {
|
|
|
38156
37974
|
return;
|
|
38157
37975
|
}
|
|
38158
37976
|
if (parsedFrame.code === "daemon.route_catalog.changed") {
|
|
38159
|
-
const payload =
|
|
37977
|
+
const payload = runtimeTransportRouteCatalogChangedFramePayloadSchema.safeParse(parsedFrame.payload);
|
|
38160
37978
|
requestLocalExecutionEvidenceRefresh({
|
|
38161
37979
|
reason: "local_state_changed",
|
|
38162
37980
|
scheduleReason: "daemon_route_catalog_changed"
|
|
@@ -39481,603 +39299,6 @@ function normalizeOptionalText$14(value) {
|
|
|
39481
39299
|
|
|
39482
39300
|
//#endregion
|
|
39483
39301
|
//#region ../../packages/start/dist/index.js
|
|
39484
|
-
function normalizeProjectionSlot({ availability, observationIssues = [], observedAt, path, schema, value }) {
|
|
39485
|
-
if (availability === "missing" || availability === "unavailable") {
|
|
39486
|
-
if (value != null) return failure([issue({
|
|
39487
|
-
code: "value_not_allowed",
|
|
39488
|
-
message: `${availability} projections must not include a value`,
|
|
39489
|
-
path
|
|
39490
|
-
})]);
|
|
39491
|
-
return success({
|
|
39492
|
-
availability,
|
|
39493
|
-
observationIssues: [...observationIssues],
|
|
39494
|
-
observedAt: null,
|
|
39495
|
-
value: null
|
|
39496
|
-
});
|
|
39497
|
-
}
|
|
39498
|
-
if (value == null) return failure([issue({
|
|
39499
|
-
code: "value_required",
|
|
39500
|
-
message: `${availability} projections must include a value`,
|
|
39501
|
-
path
|
|
39502
|
-
})]);
|
|
39503
|
-
const parsed = schema.safeParse(value);
|
|
39504
|
-
if (!parsed.success) return failure(parsed.error.issues.map((entry) => issue({
|
|
39505
|
-
code: "invalid_shape",
|
|
39506
|
-
message: entry.message,
|
|
39507
|
-
path: [...path, ...normalizeIssuePath(entry.path)]
|
|
39508
|
-
})));
|
|
39509
|
-
return success({
|
|
39510
|
-
availability,
|
|
39511
|
-
observationIssues: [...observationIssues],
|
|
39512
|
-
observedAt: observedAt(parsed.data),
|
|
39513
|
-
value: parsed.data
|
|
39514
|
-
});
|
|
39515
|
-
}
|
|
39516
|
-
function success(value) {
|
|
39517
|
-
return {
|
|
39518
|
-
ok: true,
|
|
39519
|
-
value
|
|
39520
|
-
};
|
|
39521
|
-
}
|
|
39522
|
-
function failure(issues) {
|
|
39523
|
-
return {
|
|
39524
|
-
ok: false,
|
|
39525
|
-
issues
|
|
39526
|
-
};
|
|
39527
|
-
}
|
|
39528
|
-
function issue(entry) {
|
|
39529
|
-
return entry;
|
|
39530
|
-
}
|
|
39531
|
-
function hasDuplicateStrings(values) {
|
|
39532
|
-
const seen = /* @__PURE__ */ new Set();
|
|
39533
|
-
const duplicates = /* @__PURE__ */ new Set();
|
|
39534
|
-
for (const value of values) {
|
|
39535
|
-
if (seen.has(value)) {
|
|
39536
|
-
duplicates.add(value);
|
|
39537
|
-
continue;
|
|
39538
|
-
}
|
|
39539
|
-
seen.add(value);
|
|
39540
|
-
}
|
|
39541
|
-
return [...duplicates];
|
|
39542
|
-
}
|
|
39543
|
-
function normalizeIssuePath(path) {
|
|
39544
|
-
return path.map((entry) => typeof entry === "symbol" ? String(entry) : entry);
|
|
39545
|
-
}
|
|
39546
|
-
function normalizeStartDeviceProjectionSlot(input) {
|
|
39547
|
-
return normalizeProjectionSlot({
|
|
39548
|
-
availability: input.availability,
|
|
39549
|
-
observationIssues: input.observationIssues,
|
|
39550
|
-
observedAt: (value) => value.observedAt,
|
|
39551
|
-
path: ["device"],
|
|
39552
|
-
schema: startDeviceProjectionSchema,
|
|
39553
|
-
value: input.value
|
|
39554
|
-
});
|
|
39555
|
-
}
|
|
39556
|
-
function normalizeStartProfileReadinessEntry(input) {
|
|
39557
|
-
const projection = normalizeProjectionSlot({
|
|
39558
|
-
availability: input.availability,
|
|
39559
|
-
observationIssues: input.observationIssues,
|
|
39560
|
-
observedAt: (value) => value.observedAt,
|
|
39561
|
-
path: ["profileReadiness"],
|
|
39562
|
-
schema: startProfileReadinessSummarySchema,
|
|
39563
|
-
value: input.value
|
|
39564
|
-
});
|
|
39565
|
-
if (!projection.ok) return projection;
|
|
39566
|
-
if (projection.value.value !== null && projection.value.value.profileId !== input.profileId) return failure([issue({
|
|
39567
|
-
code: "profile_id_mismatch",
|
|
39568
|
-
message: "profile readiness projection profileId must match the requested profileId",
|
|
39569
|
-
path: ["profileId"]
|
|
39570
|
-
})]);
|
|
39571
|
-
return success({
|
|
39572
|
-
profileId: input.profileId,
|
|
39573
|
-
projection: projection.value
|
|
39574
|
-
});
|
|
39575
|
-
}
|
|
39576
|
-
function normalizeDaemonRouteObservationSummary(input) {
|
|
39577
|
-
if (!input.observation) return createDaemonRouteObservationSummary({
|
|
39578
|
-
observedAt: input.fallbackObservedAt,
|
|
39579
|
-
status: "unavailable"
|
|
39580
|
-
});
|
|
39581
|
-
return createDaemonRouteObservationSummary({
|
|
39582
|
-
observedAt: input.observation.observedAt,
|
|
39583
|
-
reasonCode: input.observation.reasonCode,
|
|
39584
|
-
status: input.observation.status
|
|
39585
|
-
});
|
|
39586
|
-
}
|
|
39587
|
-
function normalizeStartSessionProgressSlot(input) {
|
|
39588
|
-
return normalizeProjectionSlot({
|
|
39589
|
-
availability: input.availability,
|
|
39590
|
-
observedAt: (value) => value.updatedAt,
|
|
39591
|
-
path: ["session"],
|
|
39592
|
-
schema: startSessionProgressSchema,
|
|
39593
|
-
value: input.value
|
|
39594
|
-
});
|
|
39595
|
-
}
|
|
39596
|
-
function buildStartSharedReadModel(input) {
|
|
39597
|
-
const duplicateProfileIds = hasDuplicateStrings(input.profileReadiness.map((entry) => entry.profileId));
|
|
39598
|
-
if (duplicateProfileIds.length > 0) return failure(duplicateProfileIds.map((profileId) => issue({
|
|
39599
|
-
code: "duplicate_profile_id",
|
|
39600
|
-
message: `profileReadiness must not contain duplicate profileId values: ${profileId}`,
|
|
39601
|
-
path: ["profileReadiness"]
|
|
39602
|
-
})));
|
|
39603
|
-
return success({
|
|
39604
|
-
device: input.device,
|
|
39605
|
-
profileReadiness: input.profileReadiness,
|
|
39606
|
-
session: input.session
|
|
39607
|
-
});
|
|
39608
|
-
}
|
|
39609
|
-
function createPlannerSignal(actionId, reasonCode, profileId = null) {
|
|
39610
|
-
return {
|
|
39611
|
-
actionId,
|
|
39612
|
-
reasonCode,
|
|
39613
|
-
profileId
|
|
39614
|
-
};
|
|
39615
|
-
}
|
|
39616
|
-
function createPlannerDecision(input) {
|
|
39617
|
-
const blocking = input.blocking ?? [];
|
|
39618
|
-
const attention = input.attention ?? [];
|
|
39619
|
-
const followUp = input.followUp ?? [];
|
|
39620
|
-
let status = "ready";
|
|
39621
|
-
let nextAction = input.baseAction;
|
|
39622
|
-
if (blocking.length > 0) {
|
|
39623
|
-
status = "blocking";
|
|
39624
|
-
const firstBlocking = blocking[0];
|
|
39625
|
-
if (firstBlocking) nextAction = firstBlocking;
|
|
39626
|
-
} else if (attention.length > 0) status = "needs_attention";
|
|
39627
|
-
else if (followUp.length > 0) status = "follow_up";
|
|
39628
|
-
return {
|
|
39629
|
-
status,
|
|
39630
|
-
nextAction,
|
|
39631
|
-
blocking,
|
|
39632
|
-
attention,
|
|
39633
|
-
followUp
|
|
39634
|
-
};
|
|
39635
|
-
}
|
|
39636
|
-
function getLocalAgentIds(readModel) {
|
|
39637
|
-
if (readModel.session.availability === "missing" || readModel.session.availability === "unavailable") return [];
|
|
39638
|
-
return [...requireProjectionValue(readModel.session, "Selected agent lookup").localAgentPreparation.localAgentIds];
|
|
39639
|
-
}
|
|
39640
|
-
function getLocalAgentPreparationMode(readModel) {
|
|
39641
|
-
if (readModel.session.availability === "missing" || readModel.session.availability === "unavailable") return "unresolved";
|
|
39642
|
-
return requireProjectionValue(readModel.session, "Agent selection mode lookup").localAgentPreparation.mode;
|
|
39643
|
-
}
|
|
39644
|
-
function requireProjectionValue(slot, context) {
|
|
39645
|
-
if (slot.value === null) throw new Error(`${context} requires a projection value when availability is "${slot.availability}".`);
|
|
39646
|
-
return slot.value;
|
|
39647
|
-
}
|
|
39648
|
-
const SPACE_CHOICE_STEP_ORDER = ["space_choice", "space_entry"];
|
|
39649
|
-
function resolveBaseWorkflowAction(readModel) {
|
|
39650
|
-
if (readModel.session.availability === "missing") return createPlannerSignal("start_session", "session.missing");
|
|
39651
|
-
if (readModel.session.availability === "unavailable") return createPlannerSignal("start_session", "session.unavailable");
|
|
39652
|
-
const session = requireProjectionValue(readModel.session, "Base workflow planning");
|
|
39653
|
-
if (isProfileChoicePending$1(session.profileChoice)) return createPlannerSignal("identity", "identity.required");
|
|
39654
|
-
if (session.localAgentPreparation.mode === "unresolved" && readModel.device.availability === "missing") return createPlannerSignal("device_check", "device_check.pending");
|
|
39655
|
-
if (session.localAgentPreparation.mode === "unresolved") return createPlannerSignal("local_agent_preparation", "local_agent_preparation.pending");
|
|
39656
|
-
if (session.spaceChoice.mode === "unresolved" && SPACE_CHOICE_STEP_ORDER.includes(session.currentStepId)) return createPlannerSignal("space_choice", "space_choice.pending");
|
|
39657
|
-
if (session.spaceChoice.mode !== "unresolved" && session.targetSpaceId === null && SPACE_CHOICE_STEP_ORDER.includes(session.currentStepId)) return createPlannerSignal("space_entry", "space_entry.pending");
|
|
39658
|
-
return buildCurrentStepAction(session);
|
|
39659
|
-
}
|
|
39660
|
-
function isProfileChoicePending$1(profileChoice) {
|
|
39661
|
-
if (profileChoice.mode === "unresolved") return true;
|
|
39662
|
-
return profileChoice.profileId === null;
|
|
39663
|
-
}
|
|
39664
|
-
function buildCurrentStepAction(session) {
|
|
39665
|
-
switch (session.currentStepId) {
|
|
39666
|
-
case "sign_in": return createPlannerSignal("sign_in", "sign_in.required");
|
|
39667
|
-
case "identity": return createPlannerSignal("identity", "identity.required");
|
|
39668
|
-
case "device_check": return createPlannerSignal("device_check", "device_check.pending");
|
|
39669
|
-
case "local_agent_preparation": return createPlannerSignal("local_agent_preparation", "local_agent_preparation.pending");
|
|
39670
|
-
case "space_choice": return createPlannerSignal("space_choice", "space_choice.pending");
|
|
39671
|
-
case "space_entry": return createPlannerSignal("space_entry", "space_entry.pending");
|
|
39672
|
-
default: return createPlannerSignal("space_entry", "space_entry.pending");
|
|
39673
|
-
}
|
|
39674
|
-
}
|
|
39675
|
-
function collectDevicePlannerSignals(readModel) {
|
|
39676
|
-
const localAgentPreparationMode = getLocalAgentPreparationMode(readModel);
|
|
39677
|
-
if (localAgentPreparationMode === "unresolved") {
|
|
39678
|
-
if (readModel.device.availability === "missing") return {
|
|
39679
|
-
attention: [],
|
|
39680
|
-
blocking: [],
|
|
39681
|
-
followUp: [createPlannerSignal("device_check", "device_projection.missing")]
|
|
39682
|
-
};
|
|
39683
|
-
return {
|
|
39684
|
-
attention: [],
|
|
39685
|
-
blocking: [],
|
|
39686
|
-
followUp: []
|
|
39687
|
-
};
|
|
39688
|
-
}
|
|
39689
|
-
const localAgentIds = getLocalAgentIds(readModel);
|
|
39690
|
-
const requiresLocalGates = localAgentPreparationMode === "prepare_local_agents";
|
|
39691
|
-
if (readModel.device.availability === "missing") return requiresLocalGates ? {
|
|
39692
|
-
blocking: [createPlannerSignal("device_check", "device_projection.missing")],
|
|
39693
|
-
attention: [],
|
|
39694
|
-
followUp: []
|
|
39695
|
-
} : {
|
|
39696
|
-
blocking: [],
|
|
39697
|
-
attention: [],
|
|
39698
|
-
followUp: [createPlannerSignal("device_check", "device_projection.missing")]
|
|
39699
|
-
};
|
|
39700
|
-
if (readModel.device.availability === "unavailable") return requiresLocalGates ? {
|
|
39701
|
-
blocking: [createPlannerSignal("device_check", "device_projection.unavailable")],
|
|
39702
|
-
attention: [],
|
|
39703
|
-
followUp: []
|
|
39704
|
-
} : {
|
|
39705
|
-
blocking: [],
|
|
39706
|
-
attention: [],
|
|
39707
|
-
followUp: [createPlannerSignal("device_check", "device_projection.unavailable")]
|
|
39708
|
-
};
|
|
39709
|
-
const attention = [];
|
|
39710
|
-
const blocking = [];
|
|
39711
|
-
const followUp = [];
|
|
39712
|
-
const deviceProjection = requireProjectionValue(readModel.device, "Device gate planning");
|
|
39713
|
-
if (readModel.device.availability === "stale") {
|
|
39714
|
-
const signal = createPlannerSignal("device_check", "device_projection.stale");
|
|
39715
|
-
if (requiresLocalGates) attention.push(signal);
|
|
39716
|
-
else followUp.push(signal);
|
|
39717
|
-
}
|
|
39718
|
-
pushBackgroundHelperSignals({
|
|
39719
|
-
blocking,
|
|
39720
|
-
deviceProjection,
|
|
39721
|
-
followUp,
|
|
39722
|
-
requiresLocalGates
|
|
39723
|
-
});
|
|
39724
|
-
pushDeviceReplyReadinessSignals({
|
|
39725
|
-
blocking,
|
|
39726
|
-
deviceProjection,
|
|
39727
|
-
followUp,
|
|
39728
|
-
requiresLocalGates
|
|
39729
|
-
});
|
|
39730
|
-
pushSkillsReadinessSignals({
|
|
39731
|
-
deviceProjection,
|
|
39732
|
-
followUp
|
|
39733
|
-
});
|
|
39734
|
-
pushSelectedAgentSignals({
|
|
39735
|
-
blocking,
|
|
39736
|
-
deviceProjection,
|
|
39737
|
-
localAgentIds
|
|
39738
|
-
});
|
|
39739
|
-
return {
|
|
39740
|
-
blocking,
|
|
39741
|
-
attention,
|
|
39742
|
-
followUp
|
|
39743
|
-
};
|
|
39744
|
-
}
|
|
39745
|
-
function pushBackgroundHelperSignals(input) {
|
|
39746
|
-
const installSignal = getBackgroundHelperInstallSignal(input.deviceProjection.backgroundHelper.installStatus);
|
|
39747
|
-
const executionCompatibilitySignal = getBackgroundHelperExecutionCompatibilitySignal(input.deviceProjection.backgroundHelper.executionCompatibility);
|
|
39748
|
-
const runtimeSignal = getBackgroundHelperRuntimeSignal(input.deviceProjection.backgroundHelper.runtimeStatus);
|
|
39749
|
-
for (const signal of [
|
|
39750
|
-
installSignal,
|
|
39751
|
-
executionCompatibilitySignal,
|
|
39752
|
-
runtimeSignal
|
|
39753
|
-
]) {
|
|
39754
|
-
if (!signal) continue;
|
|
39755
|
-
if (input.requiresLocalGates) input.blocking.push(signal);
|
|
39756
|
-
else input.followUp.push(signal);
|
|
39757
|
-
}
|
|
39758
|
-
}
|
|
39759
|
-
function getBackgroundHelperInstallSignal(installStatus) {
|
|
39760
|
-
switch (installStatus) {
|
|
39761
|
-
case "not_installed": return createPlannerSignal("device_check", "background_helper.not_installed");
|
|
39762
|
-
case "installed_outdated": return null;
|
|
39763
|
-
case "unknown": return createPlannerSignal("device_check", "background_helper.unknown");
|
|
39764
|
-
case "installed_current": return null;
|
|
39765
|
-
default: return null;
|
|
39766
|
-
}
|
|
39767
|
-
}
|
|
39768
|
-
function getBackgroundHelperExecutionCompatibilitySignal(executionCompatibility) {
|
|
39769
|
-
if (executionCompatibility?.status !== "update_required") return null;
|
|
39770
|
-
return createPlannerSignal("device_check", "background_helper.update_required");
|
|
39771
|
-
}
|
|
39772
|
-
function getBackgroundHelperRuntimeSignal(runtimeStatus) {
|
|
39773
|
-
switch (runtimeStatus) {
|
|
39774
|
-
case "not_running": return createPlannerSignal("device_check", "background_helper.not_running");
|
|
39775
|
-
case "stale": return createPlannerSignal("device_check", "background_helper.stale");
|
|
39776
|
-
case "unknown": return createPlannerSignal("device_check", "background_helper.unknown");
|
|
39777
|
-
case "running": return null;
|
|
39778
|
-
default: return null;
|
|
39779
|
-
}
|
|
39780
|
-
}
|
|
39781
|
-
function pushDeviceReplyReadinessSignals(input) {
|
|
39782
|
-
const signal = getDeviceReplyReadinessSignal(input.deviceProjection.deviceReplyReadiness.level);
|
|
39783
|
-
if (!signal) return;
|
|
39784
|
-
if (input.requiresLocalGates) {
|
|
39785
|
-
input.blocking.push(signal);
|
|
39786
|
-
return;
|
|
39787
|
-
}
|
|
39788
|
-
input.followUp.push(signal);
|
|
39789
|
-
}
|
|
39790
|
-
function getDeviceReplyReadinessSignal(level) {
|
|
39791
|
-
switch (level) {
|
|
39792
|
-
case "blocked": return createPlannerSignal("device_check", "device_reply_readiness.blocked");
|
|
39793
|
-
case "degraded": return createPlannerSignal("device_check", "device_reply_readiness.degraded");
|
|
39794
|
-
case "unknown": return createPlannerSignal("device_check", "device_reply_readiness.unknown");
|
|
39795
|
-
case "ready": return null;
|
|
39796
|
-
default: return null;
|
|
39797
|
-
}
|
|
39798
|
-
}
|
|
39799
|
-
function pushSkillsReadinessSignals(input) {
|
|
39800
|
-
const { status } = input.deviceProjection.skillsReadiness;
|
|
39801
|
-
let signal = null;
|
|
39802
|
-
switch (status) {
|
|
39803
|
-
case "action_required":
|
|
39804
|
-
signal = createPlannerSignal("device_check", "skills_readiness.action_required");
|
|
39805
|
-
break;
|
|
39806
|
-
case "unknown":
|
|
39807
|
-
signal = createPlannerSignal("device_check", "skills_readiness.unknown");
|
|
39808
|
-
break;
|
|
39809
|
-
case "no_targets":
|
|
39810
|
-
case "up_to_date":
|
|
39811
|
-
signal = null;
|
|
39812
|
-
break;
|
|
39813
|
-
default:
|
|
39814
|
-
signal = null;
|
|
39815
|
-
break;
|
|
39816
|
-
}
|
|
39817
|
-
if (!signal) return;
|
|
39818
|
-
input.followUp.push(signal);
|
|
39819
|
-
}
|
|
39820
|
-
function pushSelectedAgentSignals(input) {
|
|
39821
|
-
if (input.localAgentIds.length === 0) return;
|
|
39822
|
-
const catalogById = /* @__PURE__ */ new Map();
|
|
39823
|
-
for (const entry of input.deviceProjection.deviceAgentCatalog.entries) catalogById.set(entry.agentId, entry);
|
|
39824
|
-
for (const localAgentId of input.localAgentIds) {
|
|
39825
|
-
const entry = catalogById.get(localAgentId);
|
|
39826
|
-
if (!entry) {
|
|
39827
|
-
input.blocking.push(createPlannerSignal("device_check", "local_agent_preparation.not_found"));
|
|
39828
|
-
continue;
|
|
39829
|
-
}
|
|
39830
|
-
if (!entry.enabled) input.blocking.push(createPlannerSignal("device_check", "local_agent_preparation.not_enabled"));
|
|
39831
|
-
if (!entry.selectable) input.blocking.push(createPlannerSignal("device_check", "local_agent_preparation.not_selectable"));
|
|
39832
|
-
}
|
|
39833
|
-
}
|
|
39834
|
-
function collectStartTargetProfileIds(session) {
|
|
39835
|
-
const profileIds = /* @__PURE__ */ new Set();
|
|
39836
|
-
const primaryProfileId = session.profileChoice.profileId;
|
|
39837
|
-
if (primaryProfileId) profileIds.add(primaryProfileId);
|
|
39838
|
-
for (const profileId of resolveSpaceMemberProfileIds(session)) profileIds.add(profileId);
|
|
39839
|
-
return [...profileIds];
|
|
39840
|
-
}
|
|
39841
|
-
function resolvePrimaryAndMemberProfiles(session) {
|
|
39842
|
-
return {
|
|
39843
|
-
primaryProfileId: session.profileChoice.profileId ?? null,
|
|
39844
|
-
spaceMemberProfileIds: resolveSpaceMemberProfileIds(session)
|
|
39845
|
-
};
|
|
39846
|
-
}
|
|
39847
|
-
function resolveSpaceMemberProfileIds(input) {
|
|
39848
|
-
const spaceMemberSelection = resolveSpaceMemberSelection(input.spaceMemberSelection);
|
|
39849
|
-
if (spaceMemberSelection.mode !== "selected_profiles") return [];
|
|
39850
|
-
const primaryProfileId = input.profileChoice.profileId;
|
|
39851
|
-
return spaceMemberSelection.selectedProfileIds.filter((profileId) => profileId !== primaryProfileId);
|
|
39852
|
-
}
|
|
39853
|
-
function resolveSpaceMemberSelection(value) {
|
|
39854
|
-
return value ?? {
|
|
39855
|
-
mode: "unresolved",
|
|
39856
|
-
selectedProfileIds: []
|
|
39857
|
-
};
|
|
39858
|
-
}
|
|
39859
|
-
function collectProfileReadinessPlannerSignals(readModel, baseAction) {
|
|
39860
|
-
if (baseAction.actionId === "device_check" && baseAction.reasonCode === "device_check.pending") return {
|
|
39861
|
-
attention: [],
|
|
39862
|
-
blocking: []
|
|
39863
|
-
};
|
|
39864
|
-
if (readModel.session.availability === "missing" || readModel.session.availability === "unavailable") return {
|
|
39865
|
-
attention: [],
|
|
39866
|
-
blocking: []
|
|
39867
|
-
};
|
|
39868
|
-
const { primaryProfileId, spaceMemberProfileIds } = resolvePrimaryAndMemberProfiles(requireProjectionValue(readModel.session, "Profile readiness planning"));
|
|
39869
|
-
if (primaryProfileId === null && spaceMemberProfileIds.length === 0) return {
|
|
39870
|
-
attention: [],
|
|
39871
|
-
blocking: []
|
|
39872
|
-
};
|
|
39873
|
-
const attention = [];
|
|
39874
|
-
const blocking = [];
|
|
39875
|
-
const primaryResult = primaryProfileId === null ? null : collectProfileSignalsForId({
|
|
39876
|
-
readModel,
|
|
39877
|
-
actionId: baseAction.actionId,
|
|
39878
|
-
blockReplyBlocked: baseAction.actionId === "space_entry",
|
|
39879
|
-
profileId: primaryProfileId
|
|
39880
|
-
});
|
|
39881
|
-
if (primaryResult) {
|
|
39882
|
-
attention.push(...primaryResult.attention);
|
|
39883
|
-
blocking.push(...primaryResult.blocking);
|
|
39884
|
-
}
|
|
39885
|
-
for (const profileId of spaceMemberProfileIds) {
|
|
39886
|
-
const memberResult = collectProfileSignalsForId({
|
|
39887
|
-
readModel,
|
|
39888
|
-
actionId: baseAction.actionId,
|
|
39889
|
-
blockReplyBlocked: baseAction.actionId === "space_entry",
|
|
39890
|
-
profileId
|
|
39891
|
-
});
|
|
39892
|
-
attention.push(...memberResult.attention);
|
|
39893
|
-
blocking.push(...memberResult.blocking);
|
|
39894
|
-
}
|
|
39895
|
-
return {
|
|
39896
|
-
attention,
|
|
39897
|
-
blocking
|
|
39898
|
-
};
|
|
39899
|
-
}
|
|
39900
|
-
function collectProfileSignalsForId(input) {
|
|
39901
|
-
const matchingEntry = input.readModel.profileReadiness.find((entry) => entry.profileId === input.profileId);
|
|
39902
|
-
if (!matchingEntry) return {
|
|
39903
|
-
attention: [createPlannerSignal(input.actionId, "profile_readiness.missing", input.profileId)],
|
|
39904
|
-
blocking: []
|
|
39905
|
-
};
|
|
39906
|
-
if (matchingEntry.projection.availability === "missing") return {
|
|
39907
|
-
attention: [createPlannerSignal(input.actionId, "profile_readiness.missing", input.profileId)],
|
|
39908
|
-
blocking: []
|
|
39909
|
-
};
|
|
39910
|
-
if (matchingEntry.projection.availability === "unavailable") return {
|
|
39911
|
-
attention: [createPlannerSignal(input.actionId, "profile_readiness.unavailable", input.profileId)],
|
|
39912
|
-
blocking: []
|
|
39913
|
-
};
|
|
39914
|
-
const attention = [];
|
|
39915
|
-
const blocking = [];
|
|
39916
|
-
if (matchingEntry.projection.availability === "stale") attention.push(createPlannerSignal(input.actionId, "profile_readiness.stale", input.profileId));
|
|
39917
|
-
const projectionValue = requireProjectionValue(matchingEntry.projection, "Profile readiness planning");
|
|
39918
|
-
if (projectionValue.profileKind !== "agent") return {
|
|
39919
|
-
attention,
|
|
39920
|
-
blocking
|
|
39921
|
-
};
|
|
39922
|
-
const { replyReadiness } = projectionValue;
|
|
39923
|
-
if (replyReadiness === null) return {
|
|
39924
|
-
attention,
|
|
39925
|
-
blocking
|
|
39926
|
-
};
|
|
39927
|
-
switch (replyReadiness.level) {
|
|
39928
|
-
case "blocked": {
|
|
39929
|
-
const signal = createPlannerSignal(input.actionId, "profile_readiness.reply_blocked", input.profileId);
|
|
39930
|
-
(input.blockReplyBlocked ? blocking : attention).push(signal);
|
|
39931
|
-
break;
|
|
39932
|
-
}
|
|
39933
|
-
case "degraded":
|
|
39934
|
-
attention.push(createPlannerSignal(input.actionId, "profile_readiness.reply_degraded", input.profileId));
|
|
39935
|
-
break;
|
|
39936
|
-
case "unknown":
|
|
39937
|
-
attention.push(createPlannerSignal(input.actionId, "profile_readiness.reply_unknown", input.profileId));
|
|
39938
|
-
break;
|
|
39939
|
-
case "ready": break;
|
|
39940
|
-
default: break;
|
|
39941
|
-
}
|
|
39942
|
-
return {
|
|
39943
|
-
attention,
|
|
39944
|
-
blocking
|
|
39945
|
-
};
|
|
39946
|
-
}
|
|
39947
|
-
function planStartNextAction(readModel) {
|
|
39948
|
-
if (readModel.session.availability === "missing") return createPlannerDecision({ baseAction: createPlannerSignal("start_session", "session.missing") });
|
|
39949
|
-
if (readModel.session.availability === "unavailable") return createPlannerDecision({
|
|
39950
|
-
baseAction: createPlannerSignal("start_session", "session.unavailable"),
|
|
39951
|
-
blocking: [createPlannerSignal("start_session", "session.unavailable")]
|
|
39952
|
-
});
|
|
39953
|
-
const baseAction = resolveBaseWorkflowAction(readModel);
|
|
39954
|
-
const attention = [];
|
|
39955
|
-
if (readModel.session.availability === "stale") attention.push(createPlannerSignal("start_session", "session.stale"));
|
|
39956
|
-
const deviceSignals = collectDevicePlannerSignals(readModel);
|
|
39957
|
-
const profileReadinessSignals = collectProfileReadinessPlannerSignals(readModel, baseAction);
|
|
39958
|
-
return createPlannerDecision({
|
|
39959
|
-
baseAction,
|
|
39960
|
-
blocking: [...deviceSignals.blocking, ...profileReadinessSignals.blocking],
|
|
39961
|
-
attention: [
|
|
39962
|
-
...attention,
|
|
39963
|
-
...deviceSignals.attention,
|
|
39964
|
-
...profileReadinessSignals.attention
|
|
39965
|
-
],
|
|
39966
|
-
followUp: deviceSignals.followUp
|
|
39967
|
-
});
|
|
39968
|
-
}
|
|
39969
|
-
function buildStartFoundationState(input) {
|
|
39970
|
-
const readModelResult = buildStartSharedReadModel(input);
|
|
39971
|
-
if (!readModelResult.ok) {
|
|
39972
|
-
const issueSummary = readModelResult.issues.map((entry) => `${entry.code} at ${entry.path.join(".") || "<root>"}`).join(", ");
|
|
39973
|
-
throw new Error(`Failed to build start foundation state: ${issueSummary}`);
|
|
39974
|
-
}
|
|
39975
|
-
const readModel = readModelResult.value;
|
|
39976
|
-
return {
|
|
39977
|
-
readModel,
|
|
39978
|
-
decision: planStartNextAction(readModel)
|
|
39979
|
-
};
|
|
39980
|
-
}
|
|
39981
|
-
function deriveStartSessionProgress(seed) {
|
|
39982
|
-
const currentStepId = resolveCurrentStepId(seed);
|
|
39983
|
-
const completedStepIds = resolveCompletedStepIds(seed);
|
|
39984
|
-
const parsed = startSessionProgressSchema.safeParse({
|
|
39985
|
-
sessionId: seed.sessionId,
|
|
39986
|
-
userId: seed.userId,
|
|
39987
|
-
deviceId: seed.deviceId,
|
|
39988
|
-
status: "in_progress",
|
|
39989
|
-
currentStepId,
|
|
39990
|
-
completedStepIds,
|
|
39991
|
-
profileChoice: seed.profileChoice,
|
|
39992
|
-
localAgentPreparation: seed.localAgentPreparation,
|
|
39993
|
-
spaceMemberSelection: seed.spaceMemberSelection,
|
|
39994
|
-
spaceChoice: seed.spaceChoice,
|
|
39995
|
-
targetSpaceId: seed.targetSpaceId,
|
|
39996
|
-
startedAt: seed.startedAt,
|
|
39997
|
-
updatedAt: seed.updatedAt,
|
|
39998
|
-
completedAt: null
|
|
39999
|
-
});
|
|
40000
|
-
if (!parsed.success) {
|
|
40001
|
-
const issueSummary = parsed.error.issues.map((issue) => issue.message).join(", ");
|
|
40002
|
-
throw new Error(`Failed to derive start session progress from shared seed: ${issueSummary}`);
|
|
40003
|
-
}
|
|
40004
|
-
return parsed.data;
|
|
40005
|
-
}
|
|
40006
|
-
function isProfileChoicePending(profileChoice) {
|
|
40007
|
-
if (profileChoice.mode === "unresolved") return true;
|
|
40008
|
-
return profileChoice.profileId === null;
|
|
40009
|
-
}
|
|
40010
|
-
function resolveCurrentStepId(seed) {
|
|
40011
|
-
if (isProfileChoicePending(seed.profileChoice)) return "identity";
|
|
40012
|
-
if (seed.localAgentPreparation.mode === "unresolved") return "local_agent_preparation";
|
|
40013
|
-
if (seed.localAgentPreparation.mode === "prepare_local_agents") return "device_check";
|
|
40014
|
-
if (seed.spaceChoice.mode === "unresolved") return "space_choice";
|
|
40015
|
-
return "space_entry";
|
|
40016
|
-
}
|
|
40017
|
-
function resolveCompletedStepIds(seed) {
|
|
40018
|
-
const completedStepIds = ["sign_in"];
|
|
40019
|
-
if (isProfileChoicePending(seed.profileChoice)) return completedStepIds;
|
|
40020
|
-
completedStepIds.push("identity");
|
|
40021
|
-
if (seed.localAgentPreparation.mode === "unresolved") return completedStepIds;
|
|
40022
|
-
completedStepIds.push("local_agent_preparation");
|
|
40023
|
-
if (seed.spaceChoice.mode !== "unresolved") completedStepIds.push("space_choice");
|
|
40024
|
-
return completedStepIds;
|
|
40025
|
-
}
|
|
40026
|
-
const START_SESSION_PROGRESS_STEP_ORDER$1 = [
|
|
40027
|
-
"sign_in",
|
|
40028
|
-
"identity",
|
|
40029
|
-
"local_agent_preparation",
|
|
40030
|
-
"device_check",
|
|
40031
|
-
"space_choice",
|
|
40032
|
-
"space_entry"
|
|
40033
|
-
];
|
|
40034
|
-
function recordStartSessionProgressFailure(input) {
|
|
40035
|
-
const updatedAt = toIsoTimestamp(input.updatedAt);
|
|
40036
|
-
return buildValidatedStartSessionProgress({
|
|
40037
|
-
...input.progress,
|
|
40038
|
-
status: "in_progress",
|
|
40039
|
-
lastFailure: {
|
|
40040
|
-
...input.failure,
|
|
40041
|
-
occurredAt: toIsoTimestamp(input.failure.occurredAt ?? updatedAt)
|
|
40042
|
-
},
|
|
40043
|
-
updatedAt,
|
|
40044
|
-
completedAt: null
|
|
40045
|
-
});
|
|
40046
|
-
}
|
|
40047
|
-
function advanceStartSessionProgressToStep(input) {
|
|
40048
|
-
const currentStepIndex = getStepOrderIndex$1(input.progress.currentStepId);
|
|
40049
|
-
const nextStepIndex = getStepOrderIndex$1(input.nextStepId);
|
|
40050
|
-
if (nextStepIndex < currentStepIndex) throw new Error(`start session progress cannot move backward: ${input.progress.currentStepId} -> ${input.nextStepId}`);
|
|
40051
|
-
const completedStepIds = new Set(input.progress.completedStepIds);
|
|
40052
|
-
for (let stepIndex = currentStepIndex; stepIndex < nextStepIndex; stepIndex += 1) {
|
|
40053
|
-
const stepId = START_SESSION_PROGRESS_STEP_ORDER$1[stepIndex];
|
|
40054
|
-
if (stepId) completedStepIds.add(stepId);
|
|
40055
|
-
}
|
|
40056
|
-
return buildValidatedStartSessionProgress({
|
|
40057
|
-
...input.progress,
|
|
40058
|
-
currentStepId: input.nextStepId,
|
|
40059
|
-
completedStepIds: [...completedStepIds],
|
|
40060
|
-
lastFailure: null,
|
|
40061
|
-
updatedAt: toIsoTimestamp(input.updatedAt)
|
|
40062
|
-
});
|
|
40063
|
-
}
|
|
40064
|
-
function buildValidatedStartSessionProgress(candidate) {
|
|
40065
|
-
const parsed = startSessionProgressSchema.safeParse(candidate);
|
|
40066
|
-
if (!parsed.success) {
|
|
40067
|
-
const issues = parsed.error.issues.map((issue) => issue.message).join(", ");
|
|
40068
|
-
throw new Error(`start session progress is invalid: ${issues}`);
|
|
40069
|
-
}
|
|
40070
|
-
return parsed.data;
|
|
40071
|
-
}
|
|
40072
|
-
function toIsoTimestamp(value) {
|
|
40073
|
-
if (value instanceof Date) return value.toISOString();
|
|
40074
|
-
return value;
|
|
40075
|
-
}
|
|
40076
|
-
function getStepOrderIndex$1(stepId) {
|
|
40077
|
-
const index = START_SESSION_PROGRESS_STEP_ORDER$1.indexOf(stepId);
|
|
40078
|
-
if (index === -1) throw new Error(`unknown start session step "${stepId}"`);
|
|
40079
|
-
return index;
|
|
40080
|
-
}
|
|
40081
39302
|
const RERUN_SETUP_HINT = "rerun_setup";
|
|
40082
39303
|
function buildOnboardingPlan(facts) {
|
|
40083
39304
|
const decisions = [];
|
|
@@ -44987,9 +44208,6 @@ function formatDaemonServiceMissingRunStepOne() {
|
|
|
44987
44208
|
function formatDaemonServiceMissingRunStepTwo() {
|
|
44988
44209
|
return `\`${formatAtsCliCommand("ats service start")}\``;
|
|
44989
44210
|
}
|
|
44990
|
-
function formatDaemonServiceOutdatedStatus(input) {
|
|
44991
|
-
return `Version differs from this CLI (installed v${input.installedVersion ?? "unknown"}, CLI v${input.expectedVersion}).`;
|
|
44992
|
-
}
|
|
44993
44211
|
function formatDaemonServiceDowngradeBlockedRecommendation(input) {
|
|
44994
44212
|
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)}\`.`;
|
|
44995
44213
|
return `ATS Service is already newer than this CLI. ATS will not downgrade it automatically. Run \`${formatAtsCliCommand(DAEMON_UPGRADE_COMMAND)}\`.`;
|
|
@@ -54864,9 +54082,6 @@ function collectStartLocalBackgroundHelperReadiness() {
|
|
|
54864
54082
|
error: error instanceof Error && error.message.trim().length > 0 ? error.message.trim() : "service readiness unavailable"
|
|
54865
54083
|
}));
|
|
54866
54084
|
}
|
|
54867
|
-
async function resolveStartLocalBackgroundHelperDemand(input) {
|
|
54868
|
-
return await resolveLocalServiceDemand(input);
|
|
54869
|
-
}
|
|
54870
54085
|
|
|
54871
54086
|
//#endregion
|
|
54872
54087
|
//#region src/agents/command-examples.ts
|
|
@@ -58360,9 +57575,6 @@ function collectStartLocalSkillsReadiness() {
|
|
|
58360
57575
|
error: error instanceof Error && error.message.trim().length > 0 ? error.message.trim() : "skills readiness unavailable"
|
|
58361
57576
|
}));
|
|
58362
57577
|
}
|
|
58363
|
-
async function runStartLocalSkillsInstall(input) {
|
|
58364
|
-
return await runSkillsInstall(input);
|
|
58365
|
-
}
|
|
58366
57578
|
|
|
58367
57579
|
//#endregion
|
|
58368
57580
|
//#region src/start-local/readiness.ts
|
|
@@ -58443,9 +57655,6 @@ async function ensureStartAuthentication(input) {
|
|
|
58443
57655
|
})
|
|
58444
57656
|
};
|
|
58445
57657
|
}
|
|
58446
|
-
async function collectStartReadinessSnapshot(input) {
|
|
58447
|
-
return await collectStartLocalReadiness({ auth: input.auth });
|
|
58448
|
-
}
|
|
58449
57658
|
function evaluateStartAuthentication(input) {
|
|
58450
57659
|
return evaluateCommandAuthentication({ gatewayUrl: input.gatewayUrl });
|
|
58451
57660
|
}
|
|
@@ -82439,32 +81648,6 @@ function normalizeRoleInput(value) {
|
|
|
82439
81648
|
return normalized;
|
|
82440
81649
|
}
|
|
82441
81650
|
|
|
82442
|
-
//#endregion
|
|
82443
|
-
//#region src/start-foundation/selectors.ts
|
|
82444
|
-
const BACKGROUND_HELPER_REASON_CODES = new Set([
|
|
82445
|
-
"background_helper.not_installed",
|
|
82446
|
-
"background_helper.installed_outdated",
|
|
82447
|
-
"background_helper.update_required",
|
|
82448
|
-
"background_helper.not_running",
|
|
82449
|
-
"background_helper.stale",
|
|
82450
|
-
"background_helper.unknown"
|
|
82451
|
-
]);
|
|
82452
|
-
function isCliStartBackgroundHelperReasonCode(reasonCode) {
|
|
82453
|
-
return BACKGROUND_HELPER_REASON_CODES.has(reasonCode);
|
|
82454
|
-
}
|
|
82455
|
-
function isCliStartBackgroundHelperSignal(signal) {
|
|
82456
|
-
return signal.actionId === "device_check" && isCliStartBackgroundHelperReasonCode(signal.reasonCode);
|
|
82457
|
-
}
|
|
82458
|
-
function readCliStartDeviceProjection(foundation) {
|
|
82459
|
-
return foundation.foundationState.readModel.device;
|
|
82460
|
-
}
|
|
82461
|
-
function hasCliStartBackgroundHelperBlockingOrAttentionSignal(foundation) {
|
|
82462
|
-
return [...foundation.foundationState.decision.blocking, ...foundation.foundationState.decision.attention].some(isCliStartBackgroundHelperSignal);
|
|
82463
|
-
}
|
|
82464
|
-
function readCliStartCurrentStepId(foundation) {
|
|
82465
|
-
return foundation.foundationState.readModel.session.value?.currentStepId ?? null;
|
|
82466
|
-
}
|
|
82467
|
-
|
|
82468
81651
|
//#endregion
|
|
82469
81652
|
//#region src/commands/start-next-action.ts
|
|
82470
81653
|
const START_NEXT_CREATE = "create";
|
|
@@ -83213,15 +82396,14 @@ async function runStart(input) {
|
|
|
83213
82396
|
resolvedView: runtime.resolvedView,
|
|
83214
82397
|
resolution: selectedProfileWorkspace
|
|
83215
82398
|
});
|
|
83216
|
-
|
|
82399
|
+
if (await runStartSpaceEntryAction({
|
|
83217
82400
|
presenter,
|
|
83218
82401
|
runtime,
|
|
83219
82402
|
gatewayUrl,
|
|
83220
82403
|
profile: selectedProfile,
|
|
83221
82404
|
interactive,
|
|
83222
82405
|
view: input.view
|
|
83223
|
-
});
|
|
83224
|
-
if (nextActionResult === "cancelled" || nextActionResult === "blocked") return;
|
|
82406
|
+
}) === "cancelled") return;
|
|
83225
82407
|
emitStartRecap({
|
|
83226
82408
|
runtime,
|
|
83227
82409
|
presenter,
|
|
@@ -87294,46 +86476,8 @@ function parseProfileFromArgv(argv) {
|
|
|
87294
86476
|
}
|
|
87295
86477
|
|
|
87296
86478
|
//#endregion
|
|
87297
|
-
//#region src/
|
|
87298
|
-
|
|
87299
|
-
const serviceContract = await readDaemonServiceContract().catch(() => null);
|
|
87300
|
-
const deviceId = await readCliStartDeviceId({ serviceContract });
|
|
87301
|
-
if (!deviceId) return unwrapStartNormalization$2(normalizeStartDeviceProjectionSlot({ availability: "unavailable" }), "device projection");
|
|
87302
|
-
const observedAt = input.currentReplyReadiness?.observedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
87303
|
-
const runtimeStatus = input.readiness.service.runtime?.status ?? "unknown";
|
|
87304
|
-
const executionCompatibility = input.readiness.service.executionCompatibility ?? toStartBackgroundHelperExecutionCompatibility(await resolveDaemonRuntimeContractCompatibility({ runtimeStatus }));
|
|
87305
|
-
const deviceProjection = {
|
|
87306
|
-
deviceId,
|
|
87307
|
-
runtimeLane: serviceContract?.lane ?? resolveAtsEnvPreset(),
|
|
87308
|
-
observedAt,
|
|
87309
|
-
backgroundHelper: {
|
|
87310
|
-
installStatus: input.readiness.service.status,
|
|
87311
|
-
runtimeStatus,
|
|
87312
|
-
installedVersion: input.readiness.service.installedVersion,
|
|
87313
|
-
expectedVersion: input.readiness.service.expectedVersion,
|
|
87314
|
-
executionCompatibility
|
|
87315
|
-
},
|
|
87316
|
-
skillsReadiness: {
|
|
87317
|
-
status: input.readiness.skills.status,
|
|
87318
|
-
targetCount: input.readiness.skills.targetCount,
|
|
87319
|
-
summary: input.readiness.skills.summary
|
|
87320
|
-
},
|
|
87321
|
-
deviceAgentCatalog: buildCliStartDeviceAgentCatalog(input.readiness),
|
|
87322
|
-
deviceReplyReadiness: input.currentReplyReadiness ? {
|
|
87323
|
-
level: input.currentReplyReadiness.deviceReplyReadiness.replyReadiness,
|
|
87324
|
-
reasonCodes: input.currentReplyReadiness.deviceReplyReadiness.reasonCodes
|
|
87325
|
-
} : {
|
|
87326
|
-
level: "unknown",
|
|
87327
|
-
reasonCodes: []
|
|
87328
|
-
}
|
|
87329
|
-
};
|
|
87330
|
-
return unwrapStartNormalization$2(normalizeStartDeviceProjectionSlot({
|
|
87331
|
-
availability: "ready",
|
|
87332
|
-
observationIssues: input.observationIssues,
|
|
87333
|
-
value: deviceProjection
|
|
87334
|
-
}), "device projection");
|
|
87335
|
-
}
|
|
87336
|
-
function buildCliStartDeviceAgentCatalog(readiness) {
|
|
86479
|
+
//#region src/local-service/state/current-device-identity.ts
|
|
86480
|
+
function buildLocalAgentCatalogFromReadiness(readiness) {
|
|
87337
86481
|
return {
|
|
87338
86482
|
totalBuiltins: readiness.agents.totalBuiltins,
|
|
87339
86483
|
detectedSupported: readiness.agents.detectedSupported,
|
|
@@ -87353,7 +86497,7 @@ function buildCliStartDeviceAgentCatalog(readiness) {
|
|
|
87353
86497
|
}))
|
|
87354
86498
|
};
|
|
87355
86499
|
}
|
|
87356
|
-
async function
|
|
86500
|
+
async function readCurrentLocalDeviceId(input = {}) {
|
|
87357
86501
|
const contractDeviceId = (input.serviceContract === void 0 ? await readDaemonServiceContract().catch(() => null) : input.serviceContract)?.deviceId;
|
|
87358
86502
|
if (typeof contractDeviceId === "string" && contractDeviceId.trim().length) return contractDeviceId.trim();
|
|
87359
86503
|
const persisted = (await readFile(join(daemonRuntimeRootPath(), "data", DAEMON_DEVICE_ID_FILE), "utf8").catch(() => "")).trim();
|
|
@@ -87369,15 +86513,10 @@ function normalizeSelectableReason(selectableReason) {
|
|
|
87369
86513
|
case "custom_coming_soon": return selectableReason;
|
|
87370
86514
|
default: {
|
|
87371
86515
|
const unexpectedSelectableReason = selectableReason;
|
|
87372
|
-
throw new Error(`Unsupported
|
|
86516
|
+
throw new Error(`Unsupported local-agent selectableReason: ${unexpectedSelectableReason}`);
|
|
87373
86517
|
}
|
|
87374
86518
|
}
|
|
87375
86519
|
}
|
|
87376
|
-
function unwrapStartNormalization$2(result, context) {
|
|
87377
|
-
if (result.ok) return result.value;
|
|
87378
|
-
const issueSummary = result.issues.map((entry) => `${entry.code} at ${entry.path.join(".") || "<root>"}`).join(", ");
|
|
87379
|
-
throw new Error(`Failed to normalize ${context}: ${issueSummary}`);
|
|
87380
|
-
}
|
|
87381
86520
|
|
|
87382
86521
|
//#endregion
|
|
87383
86522
|
//#region src/system/observed-device-metadata.ts
|
|
@@ -87448,7 +86587,7 @@ async function runComputerList(input) {
|
|
|
87448
86587
|
if (response.localRuntimes.length === 0) {
|
|
87449
86588
|
presenter.line({
|
|
87450
86589
|
code: "computer.list.empty",
|
|
87451
|
-
text: "No computers are connected to this account yet. Run `ats
|
|
86590
|
+
text: "No computers are connected to this account yet. Run `ats setup` on a computer to set it up."
|
|
87452
86591
|
});
|
|
87453
86592
|
return;
|
|
87454
86593
|
}
|
|
@@ -87463,8 +86602,8 @@ async function runComputerList(input) {
|
|
|
87463
86602
|
}
|
|
87464
86603
|
async function runComputerCurrent(input) {
|
|
87465
86604
|
const presenter = createPresenter(await resolveRuntimeContext({ view: input.view }));
|
|
87466
|
-
const deviceId = await
|
|
87467
|
-
if (!deviceId) throw new Error("ATS could not identify this computer. Run `ats
|
|
86605
|
+
const deviceId = await readCurrentLocalDeviceId();
|
|
86606
|
+
if (!deviceId) throw new Error("ATS could not identify this computer. Run `ats setup` or `ats service install`, then try again.");
|
|
87468
86607
|
const currentDeviceApi = createCurrentDeviceApi(createCliApiClientFoundation(await resolveBaseUrl()));
|
|
87469
86608
|
await syncCurrentComputerObservation({
|
|
87470
86609
|
currentDeviceApi,
|
|
@@ -87491,8 +86630,8 @@ async function runComputerCurrent(input) {
|
|
|
87491
86630
|
async function runComputerRename(input) {
|
|
87492
86631
|
const presenter = createPresenter(await resolveRuntimeContext({ view: input.view }));
|
|
87493
86632
|
const displayName = resolveRequestedDisplayName(input);
|
|
87494
|
-
const deviceId = await
|
|
87495
|
-
if (!deviceId) throw new Error("ATS could not identify this computer. Run `ats
|
|
86633
|
+
const deviceId = await readCurrentLocalDeviceId();
|
|
86634
|
+
if (!deviceId) throw new Error("ATS could not identify this computer. Run `ats setup` or `ats service install`, then try again.");
|
|
87496
86635
|
const currentDeviceApi = createCurrentDeviceApi(createCliApiClientFoundation(await resolveBaseUrl()));
|
|
87497
86636
|
await syncCurrentComputerObservation({
|
|
87498
86637
|
currentDeviceApi,
|
|
@@ -87530,11 +86669,11 @@ function resolveRequestedDisplayName(input) {
|
|
|
87530
86669
|
}
|
|
87531
86670
|
function findLocalRuntime(response, deviceId) {
|
|
87532
86671
|
const runtime = response.localRuntimes.find((entry) => entry.deviceId === deviceId);
|
|
87533
|
-
if (!runtime) throw new Error("ATS could not find this computer in your account. Run `ats
|
|
86672
|
+
if (!runtime) throw new Error("ATS could not find this computer in your account. Run `ats setup` or `ats service install`, then try again.");
|
|
87534
86673
|
return runtime;
|
|
87535
86674
|
}
|
|
87536
86675
|
async function syncCurrentComputerObservationIfAvailable(input) {
|
|
87537
|
-
const deviceId = await
|
|
86676
|
+
const deviceId = await readCurrentLocalDeviceId();
|
|
87538
86677
|
if (!deviceId) return;
|
|
87539
86678
|
await syncCurrentComputerObservation({
|
|
87540
86679
|
currentDeviceApi: input.currentDeviceApi,
|
|
@@ -93131,260 +92270,45 @@ function renderSetupAgentHandoffCard(input) {
|
|
|
93131
92270
|
}
|
|
93132
92271
|
|
|
93133
92272
|
//#endregion
|
|
93134
|
-
//#region src/
|
|
93135
|
-
function
|
|
93136
|
-
const
|
|
93137
|
-
|
|
93138
|
-
const
|
|
93139
|
-
|
|
93140
|
-
|
|
93141
|
-
|
|
93142
|
-
|
|
93143
|
-
|
|
93144
|
-
|
|
93145
|
-
|
|
93146
|
-
|
|
93147
|
-
uuid.slice(0, 8),
|
|
93148
|
-
uuid.slice(8, 12),
|
|
93149
|
-
uuid.slice(12, 16),
|
|
93150
|
-
uuid.slice(16, 20),
|
|
93151
|
-
uuid.slice(20, 32)
|
|
93152
|
-
].join("-");
|
|
93153
|
-
}
|
|
93154
|
-
|
|
93155
|
-
//#endregion
|
|
93156
|
-
//#region src/start-foundation/profile-readiness.ts
|
|
93157
|
-
function buildCliStartProfileReadinessEntry(input) {
|
|
93158
|
-
const foundationProfileId = resolveCliStartFoundationProfileId(input.profile);
|
|
93159
|
-
if (!input.deviceId) return unwrapStartNormalization$1(normalizeStartProfileReadinessEntry({
|
|
93160
|
-
availability: "unavailable",
|
|
93161
|
-
profileId: foundationProfileId
|
|
93162
|
-
}), "profile readiness");
|
|
93163
|
-
const observedAt = input.currentReplyReadiness?.observedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
93164
|
-
if (input.profile.profileKind !== "agent") return unwrapStartNormalization$1(normalizeStartProfileReadinessEntry({
|
|
93165
|
-
availability: "ready",
|
|
93166
|
-
observationIssues: [],
|
|
93167
|
-
profileId: foundationProfileId,
|
|
93168
|
-
value: {
|
|
93169
|
-
deviceId: input.deviceId,
|
|
93170
|
-
profileId: foundationProfileId,
|
|
93171
|
-
profileKind: input.profile.profileKind,
|
|
93172
|
-
observedAt,
|
|
93173
|
-
routeObservation: {
|
|
93174
|
-
status: "unavailable",
|
|
93175
|
-
reasonCode: "not_requested",
|
|
93176
|
-
observedAt
|
|
93177
|
-
},
|
|
93178
|
-
replyReadiness: null
|
|
93179
|
-
}
|
|
93180
|
-
}), "profile readiness");
|
|
93181
|
-
const routeObservation = normalizeDaemonRouteObservationSummary({
|
|
93182
|
-
fallbackObservedAt: observedAt,
|
|
93183
|
-
observation: input.currentReplyReadiness?.daemonRouteObservation ?? null
|
|
93184
|
-
});
|
|
93185
|
-
const replyReadiness = input.currentReplyReadiness?.agentReplyReadiness ? {
|
|
93186
|
-
level: input.currentReplyReadiness.agentReplyReadiness.replyReadiness,
|
|
93187
|
-
reasonCodes: input.currentReplyReadiness.agentReplyReadiness.reasonCodes
|
|
93188
|
-
} : {
|
|
93189
|
-
level: "unknown",
|
|
93190
|
-
reasonCodes: []
|
|
93191
|
-
};
|
|
93192
|
-
return unwrapStartNormalization$1(normalizeStartProfileReadinessEntry({
|
|
93193
|
-
availability: "ready",
|
|
93194
|
-
observationIssues: input.observationIssues,
|
|
93195
|
-
profileId: foundationProfileId,
|
|
93196
|
-
value: {
|
|
93197
|
-
deviceId: input.deviceId,
|
|
93198
|
-
profileId: foundationProfileId,
|
|
93199
|
-
profileKind: "agent",
|
|
93200
|
-
observedAt,
|
|
93201
|
-
routeObservation,
|
|
93202
|
-
replyReadiness
|
|
93203
|
-
}
|
|
93204
|
-
}), "profile readiness");
|
|
93205
|
-
}
|
|
93206
|
-
function buildUnavailableCliStartProfileReadinessEntry(input) {
|
|
93207
|
-
return unwrapStartNormalization$1(normalizeStartProfileReadinessEntry({
|
|
93208
|
-
availability: "unavailable",
|
|
93209
|
-
observationIssues: input.observationIssues,
|
|
93210
|
-
profileId: input.profileId
|
|
93211
|
-
}), "profile readiness");
|
|
93212
|
-
}
|
|
93213
|
-
function unwrapStartNormalization$1(result, context) {
|
|
93214
|
-
if (result.ok) return result.value;
|
|
93215
|
-
const issueSummary = result.issues.map((entry) => `${entry.code} at ${entry.path.join(".") || "<root>"}`).join(", ");
|
|
93216
|
-
throw new Error(`Failed to normalize ${context}: ${issueSummary}`);
|
|
93217
|
-
}
|
|
93218
|
-
|
|
93219
|
-
//#endregion
|
|
93220
|
-
//#region src/start-foundation/observation.ts
|
|
93221
|
-
async function buildCliStartObservation(input) {
|
|
93222
|
-
const targetProfileIds = collectTargetProfileIds(input);
|
|
93223
|
-
const resolvedProfiles = new Map((input.targetProfiles ?? []).map((profile) => [profile.atsProfileId, profile]));
|
|
93224
|
-
resolvedProfiles.set(input.profile.atsProfileId, input.profile);
|
|
93225
|
-
const primaryObservation = await resolveProfileReplyReadinessObservation({
|
|
93226
|
-
baseUrl: input.baseUrl,
|
|
93227
|
-
profile: input.profile
|
|
93228
|
-
});
|
|
93229
|
-
const device = await buildCliStartDeviceProjectionSlot({
|
|
93230
|
-
currentReplyReadiness: primaryObservation.snapshot,
|
|
93231
|
-
observationIssues: primaryObservation.observationIssues,
|
|
93232
|
-
profile: input.profile,
|
|
93233
|
-
readiness: input.readiness
|
|
92273
|
+
//#region src/commands/setup-current-device.ts
|
|
92274
|
+
async function syncLocalSetupCurrentDeviceTargetFromServiceContract(input) {
|
|
92275
|
+
const serviceContract = await readDaemonServiceContract();
|
|
92276
|
+
const deviceId = serviceContract?.deviceId ?? null;
|
|
92277
|
+
const runtimeLane = serviceContract?.lane ?? null;
|
|
92278
|
+
if (!(serviceContract && deviceId && runtimeLane)) throw new Error(`ATS could not reconnect this computer because ATS Service has not finished starting. Keep ATS Service running, then run \`${formatAtsCliCommand("ats setup --view agent")}\` again. You can also run \`${formatAtsCliCommand("ats service status --view agent")}\` to inspect the local service.`);
|
|
92279
|
+
const currentDeviceApi = createCurrentDeviceApi(createCliApiClientFoundation(input.gatewayUrl));
|
|
92280
|
+
await writeConnectedComputerEnrollmentToServiceContract({
|
|
92281
|
+
connectedComputerId: (await currentDeviceApi.enrollLocalRuntime({
|
|
92282
|
+
deviceId,
|
|
92283
|
+
runtimeLane
|
|
92284
|
+
})).connectedComputerId,
|
|
92285
|
+
serviceContract
|
|
93234
92286
|
});
|
|
93235
|
-
|
|
93236
|
-
|
|
93237
|
-
|
|
93238
|
-
profileReadiness: await Promise.all(targetProfileIds.map(async (profileId) => {
|
|
93239
|
-
const resolvedProfile = resolvedProfiles.get(profileId);
|
|
93240
|
-
if (!resolvedProfile) return buildUnavailableCliStartProfileReadinessEntry({ profileId });
|
|
93241
|
-
if (profileId === input.profile.atsProfileId) return primaryObservation.snapshot === null ? buildUnavailableCliStartProfileReadinessEntry({
|
|
93242
|
-
observationIssues: primaryObservation.observationIssues,
|
|
93243
|
-
profileId
|
|
93244
|
-
}) : buildCliStartProfileReadinessEntry({
|
|
93245
|
-
currentReplyReadiness: primaryObservation.snapshot,
|
|
93246
|
-
deviceId,
|
|
93247
|
-
observationIssues: resolvedProfile.profileKind === "agent" ? primaryObservation.observationIssues : [],
|
|
93248
|
-
profile: resolvedProfile
|
|
93249
|
-
});
|
|
93250
|
-
const observation = await resolveProfileReplyReadinessObservation({
|
|
93251
|
-
baseUrl: input.baseUrl,
|
|
93252
|
-
profile: resolvedProfile
|
|
93253
|
-
});
|
|
93254
|
-
return observation.snapshot === null ? buildUnavailableCliStartProfileReadinessEntry({
|
|
93255
|
-
observationIssues: observation.observationIssues,
|
|
93256
|
-
profileId
|
|
93257
|
-
}) : buildCliStartProfileReadinessEntry({
|
|
93258
|
-
currentReplyReadiness: observation.snapshot,
|
|
93259
|
-
deviceId,
|
|
93260
|
-
observationIssues: resolvedProfile.profileKind === "agent" ? observation.observationIssues : [],
|
|
93261
|
-
profile: resolvedProfile
|
|
93262
|
-
});
|
|
93263
|
-
}))
|
|
93264
|
-
};
|
|
93265
|
-
}
|
|
93266
|
-
function collectTargetProfileIds(input) {
|
|
93267
|
-
const profileIds = new Set([input.profile.atsProfileId]);
|
|
93268
|
-
for (const profileId of input.targetProfileIds ?? []) if (typeof profileId === "string" && profileId.trim().length > 0) profileIds.add(profileId.trim());
|
|
93269
|
-
for (const profile of input.targetProfiles ?? []) if (profile.atsProfileId.trim().length > 0) profileIds.add(profile.atsProfileId.trim());
|
|
93270
|
-
return [...profileIds];
|
|
93271
|
-
}
|
|
93272
|
-
async function resolveProfileReplyReadinessObservation(input) {
|
|
93273
|
-
let observationIssues = [];
|
|
93274
|
-
const snapshot = await resolveCurrentReplyReadinessSnapshot({
|
|
93275
|
-
baseUrl: input.baseUrl,
|
|
93276
|
-
includeDaemonRouteObservation: input.profile.profileKind === "agent",
|
|
93277
|
-
ownerUserId: input.profile.ownerUserId,
|
|
93278
|
-
profile: input.profile
|
|
93279
|
-
}).catch((error) => {
|
|
93280
|
-
observationIssues = [createReplyReadinessObservationIssue({ error })];
|
|
93281
|
-
console.warn("[ats.start.observation.reply_readiness.unavailable]", {
|
|
93282
|
-
baseUrl: input.baseUrl ?? null,
|
|
93283
|
-
ownerUserId: input.profile.ownerUserId,
|
|
93284
|
-
profileKind: input.profile.profileKind,
|
|
93285
|
-
profileId: input.profile.atsProfileId,
|
|
93286
|
-
error: error instanceof Error ? {
|
|
93287
|
-
message: error.message,
|
|
93288
|
-
name: error.name
|
|
93289
|
-
} : String(error)
|
|
93290
|
-
});
|
|
93291
|
-
return null;
|
|
92287
|
+
await currentDeviceApi.writeObservedMetadata({
|
|
92288
|
+
deviceId,
|
|
92289
|
+
metadata: await collectObservedDeviceMetadata()
|
|
93292
92290
|
});
|
|
93293
92291
|
return {
|
|
93294
|
-
observationIssues,
|
|
93295
|
-
snapshot
|
|
93296
|
-
};
|
|
93297
|
-
}
|
|
93298
|
-
function createReplyReadinessObservationIssue(input) {
|
|
93299
|
-
return {
|
|
93300
|
-
source: "reply_readiness_snapshot",
|
|
93301
|
-
code: "source_failure",
|
|
93302
|
-
summary: "ATS couldn't collect the current reply readiness snapshot.",
|
|
93303
|
-
detail: input.error instanceof Error ? input.error.message : String(input.error),
|
|
93304
|
-
observedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
93305
|
-
};
|
|
93306
|
-
}
|
|
93307
|
-
|
|
93308
|
-
//#endregion
|
|
93309
|
-
//#region src/start-foundation/session-progress.ts
|
|
93310
|
-
function buildStandaloneCliStartSessionProgressSlot(input) {
|
|
93311
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
93312
|
-
const foundationProfileId = resolveCliStartFoundationProfileId(input.profile);
|
|
93313
|
-
const sessionLocalAgentPreparation = resolveStandaloneCliSessionLocalAgentPreparation(input.localAgentPreparation, input.profile);
|
|
93314
|
-
return unwrapStartNormalization(normalizeStartSessionProgressSlot({
|
|
93315
|
-
availability: "ready",
|
|
93316
|
-
value: deriveStartSessionProgress({
|
|
93317
|
-
sessionId: buildStandaloneSessionId(foundationProfileId),
|
|
93318
|
-
userId: input.profile.ownerUserId,
|
|
93319
|
-
deviceId: input.deviceId,
|
|
93320
|
-
profileChoice: {
|
|
93321
|
-
mode: "select_existing",
|
|
93322
|
-
profileId: foundationProfileId
|
|
93323
|
-
},
|
|
93324
|
-
localAgentPreparation: sessionLocalAgentPreparation,
|
|
93325
|
-
spaceMemberSelection: {
|
|
93326
|
-
mode: "unresolved",
|
|
93327
|
-
selectedProfileIds: []
|
|
93328
|
-
},
|
|
93329
|
-
spaceChoice: {
|
|
93330
|
-
mode: "unresolved",
|
|
93331
|
-
spaceId: null
|
|
93332
|
-
},
|
|
93333
|
-
targetSpaceId: null,
|
|
93334
|
-
startedAt: now,
|
|
93335
|
-
updatedAt: now
|
|
93336
|
-
})
|
|
93337
|
-
}), "standalone start session");
|
|
93338
|
-
}
|
|
93339
|
-
function resolveStandaloneCliSessionLocalAgentPreparation(localAgentPreparation, profile) {
|
|
93340
|
-
if (profile.profileKind === "human" && localAgentPreparation.mode === "prepare_local_agents") return {
|
|
93341
|
-
mode: "skip_local_agents",
|
|
93342
|
-
localAgentIds: []
|
|
93343
|
-
};
|
|
93344
|
-
return localAgentPreparation;
|
|
93345
|
-
}
|
|
93346
|
-
function buildStandaloneSessionId(profileId) {
|
|
93347
|
-
return `standalone:${profileId}`;
|
|
93348
|
-
}
|
|
93349
|
-
function unwrapStartNormalization(result, context) {
|
|
93350
|
-
if (result.ok) return result.value;
|
|
93351
|
-
const issueSummary = result.issues.map((entry) => `${entry.code} at ${entry.path.join(".") || "<root>"}`).join(", ");
|
|
93352
|
-
throw new Error(`Failed to normalize ${context}: ${issueSummary}`);
|
|
93353
|
-
}
|
|
93354
|
-
|
|
93355
|
-
//#endregion
|
|
93356
|
-
//#region src/start-foundation/foundation.ts
|
|
93357
|
-
async function buildCliStartFoundation(input) {
|
|
93358
|
-
const observation = await buildCliStartObservation({
|
|
93359
|
-
baseUrl: input.baseUrl,
|
|
93360
|
-
profile: input.profile,
|
|
93361
|
-
readiness: input.readiness
|
|
93362
|
-
});
|
|
93363
|
-
const deviceId = observation.device.value?.deviceId ?? null;
|
|
93364
|
-
const session = buildStandaloneCliStartSessionProgressSlot({
|
|
93365
|
-
localAgentPreparation: input.localAgentPreparation,
|
|
93366
92292
|
deviceId,
|
|
93367
|
-
|
|
93368
|
-
}
|
|
93369
|
-
return { foundationState: buildStartFoundationState({
|
|
93370
|
-
device: observation.device,
|
|
93371
|
-
profileReadiness: observation.profileReadiness,
|
|
93372
|
-
session
|
|
93373
|
-
}) };
|
|
92293
|
+
runtimeLane
|
|
92294
|
+
};
|
|
93374
92295
|
}
|
|
93375
|
-
async function
|
|
93376
|
-
|
|
93377
|
-
|
|
93378
|
-
|
|
93379
|
-
|
|
93380
|
-
|
|
93381
|
-
|
|
92296
|
+
async function writeConnectedComputerEnrollmentToServiceContract(input) {
|
|
92297
|
+
if (!input.connectedComputerId) return;
|
|
92298
|
+
await upsertDaemonServiceContract({
|
|
92299
|
+
autoStart: input.serviceContract.autoStart,
|
|
92300
|
+
bundleId: input.serviceContract.bundleId,
|
|
92301
|
+
connectedComputerId: input.connectedComputerId,
|
|
92302
|
+
daemonVersion: input.serviceContract.daemonVersion,
|
|
92303
|
+
desiredState: input.serviceContract.desiredState,
|
|
92304
|
+
deviceId: input.serviceContract.deviceId,
|
|
92305
|
+
gatewayUrl: input.serviceContract.gatewayUrl,
|
|
92306
|
+
heartbeatMs: input.serviceContract.heartbeatMs,
|
|
92307
|
+
lane: input.serviceContract.lane,
|
|
92308
|
+
...input.serviceContract.ownerUserId ? { ownerUserId: input.serviceContract.ownerUserId } : {},
|
|
92309
|
+
...input.serviceContract.profileId ? { profileId: input.serviceContract.profileId } : {},
|
|
92310
|
+
serviceController: input.serviceContract.serviceController
|
|
93382
92311
|
});
|
|
93383
|
-
return { foundationState: buildStartFoundationState({
|
|
93384
|
-
device: observation.device,
|
|
93385
|
-
profileReadiness: observation.profileReadiness,
|
|
93386
|
-
session: input.session
|
|
93387
|
-
}) };
|
|
93388
92312
|
}
|
|
93389
92313
|
|
|
93390
92314
|
//#endregion
|
|
@@ -93445,63 +92369,6 @@ function resolveControllingTerminalSession() {
|
|
|
93445
92369
|
}
|
|
93446
92370
|
}
|
|
93447
92371
|
|
|
93448
|
-
//#endregion
|
|
93449
|
-
//#region src/commands/start-current-device.ts
|
|
93450
|
-
async function syncStandaloneStartCurrentDeviceTarget(input) {
|
|
93451
|
-
const deviceProjection = readCliStartDeviceProjection(input.foundation).value;
|
|
93452
|
-
const deviceId = deviceProjection?.deviceId ?? null;
|
|
93453
|
-
const runtimeLane = deviceProjection?.runtimeLane ?? null;
|
|
93454
|
-
if (!(deviceId && runtimeLane)) return;
|
|
93455
|
-
const currentDeviceApi = createCurrentDeviceApi(createCliApiClientFoundation(input.gatewayUrl));
|
|
93456
|
-
await currentDeviceApi.enrollLocalRuntime({
|
|
93457
|
-
deviceId,
|
|
93458
|
-
runtimeLane
|
|
93459
|
-
});
|
|
93460
|
-
await currentDeviceApi.writeObservedMetadata({
|
|
93461
|
-
deviceId,
|
|
93462
|
-
metadata: await collectObservedDeviceMetadata()
|
|
93463
|
-
});
|
|
93464
|
-
}
|
|
93465
|
-
async function syncLocalSetupCurrentDeviceTargetFromServiceContract(input) {
|
|
93466
|
-
const serviceContract = await readDaemonServiceContract();
|
|
93467
|
-
const deviceId = serviceContract?.deviceId ?? null;
|
|
93468
|
-
const runtimeLane = serviceContract?.lane ?? null;
|
|
93469
|
-
if (!(serviceContract && deviceId && runtimeLane)) throw new Error(`ATS could not reconnect this computer because ATS Service has not finished starting. Keep ATS Service running, then run \`${formatAtsCliCommand("ats setup --view agent")}\` again. You can also run \`${formatAtsCliCommand("ats service status --view agent")}\` to inspect the local service.`);
|
|
93470
|
-
const currentDeviceApi = createCurrentDeviceApi(createCliApiClientFoundation(input.gatewayUrl));
|
|
93471
|
-
await writeConnectedComputerEnrollmentToServiceContract({
|
|
93472
|
-
connectedComputerId: (await currentDeviceApi.enrollLocalRuntime({
|
|
93473
|
-
deviceId,
|
|
93474
|
-
runtimeLane
|
|
93475
|
-
})).connectedComputerId,
|
|
93476
|
-
serviceContract
|
|
93477
|
-
});
|
|
93478
|
-
await currentDeviceApi.writeObservedMetadata({
|
|
93479
|
-
deviceId,
|
|
93480
|
-
metadata: await collectObservedDeviceMetadata()
|
|
93481
|
-
});
|
|
93482
|
-
return {
|
|
93483
|
-
deviceId,
|
|
93484
|
-
runtimeLane
|
|
93485
|
-
};
|
|
93486
|
-
}
|
|
93487
|
-
async function writeConnectedComputerEnrollmentToServiceContract(input) {
|
|
93488
|
-
if (!input.connectedComputerId) return;
|
|
93489
|
-
await upsertDaemonServiceContract({
|
|
93490
|
-
autoStart: input.serviceContract.autoStart,
|
|
93491
|
-
bundleId: input.serviceContract.bundleId,
|
|
93492
|
-
connectedComputerId: input.connectedComputerId,
|
|
93493
|
-
daemonVersion: input.serviceContract.daemonVersion,
|
|
93494
|
-
desiredState: input.serviceContract.desiredState,
|
|
93495
|
-
deviceId: input.serviceContract.deviceId,
|
|
93496
|
-
gatewayUrl: input.serviceContract.gatewayUrl,
|
|
93497
|
-
heartbeatMs: input.serviceContract.heartbeatMs,
|
|
93498
|
-
lane: input.serviceContract.lane,
|
|
93499
|
-
...input.serviceContract.ownerUserId ? { ownerUserId: input.serviceContract.ownerUserId } : {},
|
|
93500
|
-
...input.serviceContract.profileId ? { profileId: input.serviceContract.profileId } : {},
|
|
93501
|
-
serviceController: input.serviceContract.serviceController
|
|
93502
|
-
});
|
|
93503
|
-
}
|
|
93504
|
-
|
|
93505
92372
|
//#endregion
|
|
93506
92373
|
//#region src/commands/prepare-session-executor.ts
|
|
93507
92374
|
const PREPARE_TOKEN_HEADER = "x-ats-prepare-token";
|
|
@@ -93732,7 +92599,7 @@ async function reportLocalAgentCatalogForSelection(input) {
|
|
|
93732
92599
|
const beforeWriteRevision = input.stream.getLatestSnapshot()?.sessionRevision ?? input.snapshot.sessionRevision;
|
|
93733
92600
|
input.stream.writeTerminalLocalAgentCatalog({
|
|
93734
92601
|
connectionEpoch,
|
|
93735
|
-
localAgentCatalog:
|
|
92602
|
+
localAgentCatalog: buildLocalAgentCatalogFromReadiness(readiness)
|
|
93736
92603
|
});
|
|
93737
92604
|
return await input.stream.waitForSnapshot((snapshot) => {
|
|
93738
92605
|
return snapshot.sessionRevision > beforeWriteRevision && snapshot.localAgentCatalog !== null;
|
|
@@ -94359,1041 +93226,11 @@ function errorFromPrepareSessionServerError(input) {
|
|
|
94359
93226
|
return new Error(input.message);
|
|
94360
93227
|
}
|
|
94361
93228
|
|
|
94362
|
-
//#endregion
|
|
94363
|
-
//#region src/start-foundation/handoff-profile.ts
|
|
94364
|
-
async function resolveCliStartHandoffProfile(input) {
|
|
94365
|
-
const authoritativeProfile = await resolveAuthoritativeHandoffProfile(input);
|
|
94366
|
-
if (authoritativeProfile) return authoritativeProfile;
|
|
94367
|
-
return createSyntheticHandoffProfile(input);
|
|
94368
|
-
}
|
|
94369
|
-
async function resolveCliStartHandoffTargetProfiles(input) {
|
|
94370
|
-
const targetProfileIds = collectStartTargetProfileIds(input.session);
|
|
94371
|
-
const targetProfiles = new Map([[input.primaryProfile.atsProfileId, input.primaryProfile]]);
|
|
94372
|
-
for (const profileId of targetProfileIds) {
|
|
94373
|
-
if (targetProfiles.has(profileId)) continue;
|
|
94374
|
-
const profile = await resolveAtsProfileOrNull({
|
|
94375
|
-
atsProfileId: profileId,
|
|
94376
|
-
allowDefaultFallback: false,
|
|
94377
|
-
allowUnauthenticated: true,
|
|
94378
|
-
persistSelection: false
|
|
94379
|
-
});
|
|
94380
|
-
if (profile) targetProfiles.set(profileId, profile);
|
|
94381
|
-
}
|
|
94382
|
-
return {
|
|
94383
|
-
targetProfileIds: [...targetProfileIds],
|
|
94384
|
-
targetProfiles: [...targetProfiles.values()]
|
|
94385
|
-
};
|
|
94386
|
-
}
|
|
94387
|
-
async function resolveAuthoritativeHandoffProfile(input) {
|
|
94388
|
-
return await resolveAtsProfileOrNull({
|
|
94389
|
-
atsProfileId: input.profileId,
|
|
94390
|
-
profileKind: input.profileKind,
|
|
94391
|
-
allowDefaultFallback: false,
|
|
94392
|
-
allowUnauthenticated: true,
|
|
94393
|
-
persistSelection: false
|
|
94394
|
-
});
|
|
94395
|
-
}
|
|
94396
|
-
function createSyntheticHandoffProfile(input) {
|
|
94397
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
94398
|
-
return {
|
|
94399
|
-
atsProfileId: input.profileId,
|
|
94400
|
-
profileName: input.profileName,
|
|
94401
|
-
profileHandle: normalizeProfileHandle(input.profileName, input.profileId),
|
|
94402
|
-
profileKind: input.profileKind,
|
|
94403
|
-
status: "active",
|
|
94404
|
-
ownerUserId: input.ownerUserId,
|
|
94405
|
-
source: "start_handoff",
|
|
94406
|
-
createdByUserId: input.ownerUserId,
|
|
94407
|
-
lastUsedAt: null,
|
|
94408
|
-
createdAt: now,
|
|
94409
|
-
updatedAt: now
|
|
94410
|
-
};
|
|
94411
|
-
}
|
|
94412
|
-
function normalizeProfileHandle(profileName, fallbackId) {
|
|
94413
|
-
const normalized = profileName.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
94414
|
-
return normalized.length > 0 ? normalized : fallbackId;
|
|
94415
|
-
}
|
|
94416
|
-
|
|
94417
|
-
//#endregion
|
|
94418
|
-
//#region src/start-foundation/handoff-progress.ts
|
|
94419
|
-
function advanceCliStartHandoffProgressAfterLocalSetup(input) {
|
|
94420
|
-
return advanceStartSessionProgressToStep({
|
|
94421
|
-
progress: input.progress,
|
|
94422
|
-
nextStepId: input.progress.spaceChoice.mode === "unresolved" ? "space_choice" : "space_entry",
|
|
94423
|
-
updatedAt: input.updatedAt ?? /* @__PURE__ */ new Date()
|
|
94424
|
-
});
|
|
94425
|
-
}
|
|
94426
|
-
function recordCliStartHandoffFailure(input) {
|
|
94427
|
-
return recordStartSessionProgressFailure({
|
|
94428
|
-
progress: input.progress,
|
|
94429
|
-
failure: input.failure,
|
|
94430
|
-
updatedAt: input.updatedAt ?? /* @__PURE__ */ new Date()
|
|
94431
|
-
});
|
|
94432
|
-
}
|
|
94433
|
-
|
|
94434
|
-
//#endregion
|
|
94435
|
-
//#region src/commands/local-runtime-observed-metadata.ts
|
|
94436
|
-
async function syncSetupTokenLocalRuntimeObservedMetadata(input) {
|
|
94437
|
-
await input.currentDeviceApi.writeSetupTokenObservedMetadata({
|
|
94438
|
-
opaqueToken: input.opaqueToken,
|
|
94439
|
-
metadata: await collectObservedDeviceMetadata({ now: input.now })
|
|
94440
|
-
});
|
|
94441
|
-
}
|
|
94442
|
-
function createSetupTokenLocalRuntimeApi(gatewayUrl) {
|
|
94443
|
-
return createCurrentDeviceApi(createAtsApiClient({
|
|
94444
|
-
baseUrl: gatewayUrl,
|
|
94445
|
-
transport: async (request) => await fetchSpaceRequestWithTimeout({
|
|
94446
|
-
url: request.url,
|
|
94447
|
-
operation: request.operation,
|
|
94448
|
-
init: request.init,
|
|
94449
|
-
timeoutMs: request.timeoutMs
|
|
94450
|
-
})
|
|
94451
|
-
}));
|
|
94452
|
-
}
|
|
94453
|
-
|
|
94454
|
-
//#endregion
|
|
94455
|
-
//#region src/commands/start-local-setup.ts
|
|
94456
|
-
async function runStartSkillsStep(input) {
|
|
94457
|
-
const skills = input.readiness.skills;
|
|
94458
|
-
const payloadBase = {
|
|
94459
|
-
status: skills.status,
|
|
94460
|
-
targetCount: skills.targetCount,
|
|
94461
|
-
summary: skills.summary,
|
|
94462
|
-
nextSteps: formatAtsCliCommands([
|
|
94463
|
-
"ats skills check",
|
|
94464
|
-
"ats skills install --all",
|
|
94465
|
-
"ats skills update"
|
|
94466
|
-
]),
|
|
94467
|
-
...skills.error ? { error: skills.error } : {}
|
|
94468
|
-
};
|
|
94469
|
-
if (input.runtime.resolvedView === "agent") {
|
|
94470
|
-
input.presenter.data({
|
|
94471
|
-
code: "start.skills",
|
|
94472
|
-
payload: payloadBase
|
|
94473
|
-
});
|
|
94474
|
-
return "continue";
|
|
94475
|
-
}
|
|
94476
|
-
if (skills.status === "up_to_date" || skills.status === "no_targets") return "continue";
|
|
94477
|
-
if (!(skills.summary.missing > 0 || skills.summary.outdated > 0) && skills.summary.externalConflict > 0) {
|
|
94478
|
-
input.presenter.line({
|
|
94479
|
-
code: "start.skills.external_conflicts",
|
|
94480
|
-
text: formatInlineAtsCliCommands("⚠️ ATS found existing non-ATS skills in detected agent folders. Local setup can continue; later, run `ats skills check` to review them.")
|
|
94481
|
-
});
|
|
94482
|
-
return "continue";
|
|
94483
|
-
}
|
|
94484
|
-
if (!input.interactive) {
|
|
94485
|
-
input.presenter.line({
|
|
94486
|
-
code: "start.skills.non_interactive",
|
|
94487
|
-
text: formatInlineAtsCliCommands("⚠️ ATS skills need setup or updates. Run `ats skills check` to see details, then run `ats skills install --all` or `ats skills update`.")
|
|
94488
|
-
});
|
|
94489
|
-
return "continue";
|
|
94490
|
-
}
|
|
94491
|
-
for (;;) {
|
|
94492
|
-
const decision = await select({
|
|
94493
|
-
message: "Local ATS skills need setup or updates. What do you want to do?",
|
|
94494
|
-
options: [{
|
|
94495
|
-
value: "install",
|
|
94496
|
-
label: "Install or update now (Recommended)"
|
|
94497
|
-
}, {
|
|
94498
|
-
value: "skip",
|
|
94499
|
-
label: "Skip for now"
|
|
94500
|
-
}],
|
|
94501
|
-
initialValue: "install"
|
|
94502
|
-
});
|
|
94503
|
-
if (isCancel(decision)) {
|
|
94504
|
-
cancel("Cancelled.");
|
|
94505
|
-
return "cancelled";
|
|
94506
|
-
}
|
|
94507
|
-
if (decision === "skip") {
|
|
94508
|
-
input.presenter.line({
|
|
94509
|
-
code: "start.skills.skipped",
|
|
94510
|
-
text: formatInlineAtsCliCommands("⏭️ Skills setup skipped. Later, run `ats skills check` and `ats skills install --all`.")
|
|
94511
|
-
});
|
|
94512
|
-
return "continue";
|
|
94513
|
-
}
|
|
94514
|
-
const installResult = await runStartLocalSkillsInstall({
|
|
94515
|
-
view: input.view,
|
|
94516
|
-
allowBackToCaller: true
|
|
94517
|
-
});
|
|
94518
|
-
if (installResult === "back" || installResult === "guided") continue;
|
|
94519
|
-
if (installResult === "cancelled") return "cancelled";
|
|
94520
|
-
return "continue";
|
|
94521
|
-
}
|
|
94522
|
-
}
|
|
94523
|
-
|
|
94524
|
-
//#endregion
|
|
94525
|
-
//#region src/start-shell/service.ts
|
|
94526
|
-
function buildStartServicePayload(input) {
|
|
94527
|
-
return {
|
|
94528
|
-
...input.readiness.service,
|
|
94529
|
-
expectedVersion: input.backgroundHelper.expectedVersion,
|
|
94530
|
-
executionCompatibility: input.backgroundHelper.executionCompatibility ?? input.readiness.service.executionCompatibility,
|
|
94531
|
-
installedVersion: input.backgroundHelper.installedVersion,
|
|
94532
|
-
status: input.backgroundHelper.status,
|
|
94533
|
-
nextSteps: resolveStartServicePayloadNextSteps(input.backgroundHelper)
|
|
94534
|
-
};
|
|
94535
|
-
}
|
|
94536
|
-
function resolveStartBackgroundHelperShellState(input) {
|
|
94537
|
-
const deviceProjection = readCliStartDeviceProjection(input.foundation);
|
|
94538
|
-
if (deviceProjection.availability === "ready" || deviceProjection.availability === "stale") return {
|
|
94539
|
-
status: deviceProjection.value.backgroundHelper.installStatus,
|
|
94540
|
-
installedVersion: deviceProjection.value.backgroundHelper.installedVersion,
|
|
94541
|
-
expectedVersion: deviceProjection.value.backgroundHelper.expectedVersion,
|
|
94542
|
-
executionCompatibility: deviceProjection.value.backgroundHelper.executionCompatibility,
|
|
94543
|
-
runtimeStatus: deviceProjection.value.backgroundHelper.runtimeStatus
|
|
94544
|
-
};
|
|
94545
|
-
return {
|
|
94546
|
-
executionCompatibility: input.readiness.service.executionCompatibility,
|
|
94547
|
-
status: input.readiness.service.status,
|
|
94548
|
-
installedVersion: input.readiness.service.installedVersion,
|
|
94549
|
-
expectedVersion: input.readiness.service.expectedVersion,
|
|
94550
|
-
runtimeStatus: input.readiness.service.runtime?.status ?? "unknown"
|
|
94551
|
-
};
|
|
94552
|
-
}
|
|
94553
|
-
function emitStartServiceNonInteractiveLine(input) {
|
|
94554
|
-
input.presenter.line({
|
|
94555
|
-
code: "start.service.non_interactive",
|
|
94556
|
-
text: formatStartServiceNonInteractiveText(input.backgroundHelper)
|
|
94557
|
-
});
|
|
94558
|
-
}
|
|
94559
|
-
function formatStartServiceNonInteractiveText(backgroundHelper) {
|
|
94560
|
-
if (backgroundHelper.executionCompatibility?.status === "update_required") return formatInlineAtsCliCommands(`⚠️ ATS Service: Update ATS Service. Run \`${formatAtsCliCommand("ats setup")}\`.`);
|
|
94561
|
-
if (backgroundHelper.status === "not_installed") return formatInlineAtsCliCommands(`⚠️ ATS Service: ${formatDaemonServiceMissingStatus()} ${formatDaemonServiceMissingAction()}`);
|
|
94562
|
-
if (backgroundHelper.runtimeStatus !== "running") return formatInlineAtsCliCommands(`⚠️ ATS Service: Installed but not running. Start it with \`${formatAtsCliCommand("ats service start")}\`.`);
|
|
94563
|
-
if (backgroundHelper.status === "installed_current") return formatInlineAtsCliCommands(`⚠️ ATS Service: Installed and running. Check it with \`${formatAtsCliCommand("ats service status")}\`.`);
|
|
94564
|
-
return formatInlineAtsCliCommands(`⚠️ ATS Service: ${formatDaemonServiceOutdatedStatus({
|
|
94565
|
-
installedVersion: backgroundHelper.installedVersion ?? void 0,
|
|
94566
|
-
expectedVersion: backgroundHelper.expectedVersion
|
|
94567
|
-
})} Check it with \`${formatAtsCliCommand("ats service status")}\`.`);
|
|
94568
|
-
}
|
|
94569
|
-
function resolveStartServicePayloadNextSteps(backgroundHelper) {
|
|
94570
|
-
if (backgroundHelper.status === "not_installed") return formatAtsCliCommands(["ats service install", "ats service start"]);
|
|
94571
|
-
if (backgroundHelper.executionCompatibility?.status === "update_required") return formatAtsCliCommands(["ats service update"]);
|
|
94572
|
-
if (backgroundHelper.runtimeStatus !== "running") return formatAtsCliCommands(["ats service start"]);
|
|
94573
|
-
return formatAtsCliCommands(["ats service status"]);
|
|
94574
|
-
}
|
|
94575
|
-
|
|
94576
|
-
//#endregion
|
|
94577
|
-
//#region src/commands/start-service-flow.ts
|
|
94578
|
-
async function runStartServiceStep(input) {
|
|
94579
|
-
const backgroundHelper = resolveStartBackgroundHelperShellState({
|
|
94580
|
-
foundation: input.foundation,
|
|
94581
|
-
readiness: input.readiness
|
|
94582
|
-
});
|
|
94583
|
-
if (!(backgroundHelper.status === "not_installed" || backgroundHelper.status === "unknown" || backgroundHelper.runtimeStatus !== "running" || backgroundHelper.executionCompatibility?.status === "update_required")) return "continue";
|
|
94584
|
-
const forcePrompt = hasCliStartBackgroundHelperBlockingOrAttentionSignal(input.foundation) ? readCliStartCurrentStepId(input.foundation) !== "space_choice" : false;
|
|
94585
|
-
const shouldForcePrompt = input.forcePrompt === true || forcePrompt;
|
|
94586
|
-
const localDemand = await resolveStartLocalBackgroundHelperDemand({ ownerUserId: input.profile?.ownerUserId ?? null });
|
|
94587
|
-
const shouldBlockForService = localDemand.decision === "keep_running" || shouldForcePrompt;
|
|
94588
|
-
if (input.runtime.resolvedView === "human") return await runStartHumanServiceStep({
|
|
94589
|
-
autoRepair: input.autoRepair === true,
|
|
94590
|
-
backgroundHelper,
|
|
94591
|
-
forcePrompt: shouldForcePrompt,
|
|
94592
|
-
gatewayUrl: input.gatewayUrl,
|
|
94593
|
-
interactive: input.runtime.interactive,
|
|
94594
|
-
localDemand,
|
|
94595
|
-
presenter: input.presenter,
|
|
94596
|
-
shouldBlockForService,
|
|
94597
|
-
view: input.view
|
|
94598
|
-
});
|
|
94599
|
-
const payload = buildStartServicePayload({
|
|
94600
|
-
readiness: input.readiness,
|
|
94601
|
-
backgroundHelper
|
|
94602
|
-
});
|
|
94603
|
-
input.presenter.data({
|
|
94604
|
-
code: "start.service",
|
|
94605
|
-
payload
|
|
94606
|
-
});
|
|
94607
|
-
return shouldBlockForService ? "needs_attention" : "continue";
|
|
94608
|
-
}
|
|
94609
|
-
async function runStartHumanServiceStep(input) {
|
|
94610
|
-
if (!input.interactive) {
|
|
94611
|
-
if (input.autoRepair) return await runStartServiceGate(input);
|
|
94612
|
-
if (input.shouldBlockForService) {
|
|
94613
|
-
emitStartServiceNonInteractiveLine({
|
|
94614
|
-
presenter: input.presenter,
|
|
94615
|
-
backgroundHelper: input.backgroundHelper
|
|
94616
|
-
});
|
|
94617
|
-
return "needs_attention";
|
|
94618
|
-
}
|
|
94619
|
-
return "continue";
|
|
94620
|
-
}
|
|
94621
|
-
if (!input.shouldBlockForService) return "continue";
|
|
94622
|
-
return await runStartServiceGate(input);
|
|
94623
|
-
}
|
|
94624
|
-
async function runStartServiceGate(input) {
|
|
94625
|
-
const gateResult = await runDaemonServiceParticipationGate({
|
|
94626
|
-
intent: "start",
|
|
94627
|
-
presenter: input.presenter,
|
|
94628
|
-
resolvedView: "human",
|
|
94629
|
-
allowPrompt: input.interactive,
|
|
94630
|
-
...input.autoRepair ? { autoRepair: true } : {},
|
|
94631
|
-
gatewayUrl: input.gatewayUrl,
|
|
94632
|
-
localDemand: input.localDemand,
|
|
94633
|
-
forcePrompt: input.forcePrompt,
|
|
94634
|
-
view: input.view
|
|
94635
|
-
});
|
|
94636
|
-
if (gateResult.status === "aligned") return "continue";
|
|
94637
|
-
if (gateResult.status === "cancelled") return "cancelled";
|
|
94638
|
-
return "needs_attention";
|
|
94639
|
-
}
|
|
94640
|
-
|
|
94641
|
-
//#endregion
|
|
94642
|
-
//#region src/commands/start-handoff.ts
|
|
94643
|
-
const HANDOFF_ONLY_ALLOWED_FLAGS = new Set([
|
|
94644
|
-
"baseUrl",
|
|
94645
|
-
"startSession",
|
|
94646
|
-
"view"
|
|
94647
|
-
]);
|
|
94648
|
-
const RETURN_TO_WEB_TEXT = "Local setup on this computer is finished. Return to ATS Web; it will continue automatically.";
|
|
94649
|
-
const START_HANDOFF_WAITING_FOR_WEB_AGENT_SELECTION_MESSAGE = "ATS Web still needs a human to choose local agents before this computer can continue setup.";
|
|
94650
|
-
const START_HANDOFF_UNKNOWN_SESSION_DEVICE_MESSAGE = "ATS could not confirm which ATS computer this setup command belongs to. Return to ATS Web, choose the computer again, copy a fresh setup command, and run it in Terminal on that same computer. If you use a custom ATS_HOME, activate the intended ATS_HOME in this terminal before running the command.";
|
|
94651
|
-
const START_HANDOFF_DEVICE_MISMATCH_MESSAGE = "This setup command is linked to a different ATS computer than this terminal is using. Return to ATS Web, choose the computer again, copy a fresh setup command, and run it in Terminal on that same computer. If you use a custom ATS_HOME, activate the intended ATS_HOME in this terminal before running the command.";
|
|
94652
|
-
const HANDOFF_SUPPORT_CODE_RE = /Support code:\s*([A-Za-z0-9._:-]+)/u;
|
|
94653
|
-
async function runStartHandoff(input) {
|
|
94654
|
-
assertValidStartHandoffInput(input);
|
|
94655
|
-
const gatewayUrl = await resolveBaseUrl(input.baseUrl);
|
|
94656
|
-
const startApi = createStartGatewayApi(gatewayUrl);
|
|
94657
|
-
const handoff = await resolveStartHandoff({
|
|
94658
|
-
startApi,
|
|
94659
|
-
opaqueToken: input.startSession
|
|
94660
|
-
});
|
|
94661
|
-
const sessionSlot = requireReadySessionSlot(handoff.state.readModel.session);
|
|
94662
|
-
const sessionDeviceId = requireStartHandoffSessionDeviceId(sessionSlot.value);
|
|
94663
|
-
const localSetupMode = resolveLocalSetupMode({ session: sessionSlot.value });
|
|
94664
|
-
const profile = await resolveCliStartHandoffProfile(handoff.profile);
|
|
94665
|
-
const { targetProfileIds, targetProfiles: resolvedTargetProfiles } = await resolveCliStartHandoffTargetProfiles({
|
|
94666
|
-
primaryProfile: profile,
|
|
94667
|
-
session: sessionSlot.value
|
|
94668
|
-
});
|
|
94669
|
-
let targetProfiles = resolvedTargetProfiles;
|
|
94670
|
-
let readiness = await collectHandoffReadiness(gatewayUrl);
|
|
94671
|
-
await assertValidatedHandoffObservation({
|
|
94672
|
-
baseUrl: gatewayUrl,
|
|
94673
|
-
profile,
|
|
94674
|
-
sessionDeviceId,
|
|
94675
|
-
targetProfileIds,
|
|
94676
|
-
targetProfiles,
|
|
94677
|
-
readiness
|
|
94678
|
-
});
|
|
94679
|
-
await syncSetupTokenLocalRuntimeObservedMetadata({
|
|
94680
|
-
currentDeviceApi: createSetupTokenLocalRuntimeApi(gatewayUrl),
|
|
94681
|
-
opaqueToken: input.startSession
|
|
94682
|
-
});
|
|
94683
|
-
let progress = sessionSlot.value;
|
|
94684
|
-
if (localSetupMode.kind === "await_web_local_agent_preparation") {
|
|
94685
|
-
const waitConfig = resolveWebLocalAgentPreparationWaitConfig();
|
|
94686
|
-
emitHandoffWaitingForWebLocalAgentPreparation({
|
|
94687
|
-
presenter: input.presenter,
|
|
94688
|
-
runtime: input.runtime,
|
|
94689
|
-
startSession: input.startSession,
|
|
94690
|
-
timeoutMs: waitConfig.timeoutMs
|
|
94691
|
-
});
|
|
94692
|
-
if (input.runtime.resolvedView === "human" && input.interactive) {
|
|
94693
|
-
await runWithDelayedSpinner({
|
|
94694
|
-
message: "Waiting for your agent choices in ATS Web",
|
|
94695
|
-
completeMessage: "ATS received your agent choices from ATS Web.",
|
|
94696
|
-
run: async () => await waitForWebLocalAgentPreparation({
|
|
94697
|
-
opaqueToken: input.startSession,
|
|
94698
|
-
startApi,
|
|
94699
|
-
waitConfig
|
|
94700
|
-
})
|
|
94701
|
-
});
|
|
94702
|
-
await runStartHandoff(input);
|
|
94703
|
-
return;
|
|
94704
|
-
}
|
|
94705
|
-
throw new Error(START_HANDOFF_WAITING_FOR_WEB_AGENT_SELECTION_MESSAGE);
|
|
94706
|
-
}
|
|
94707
|
-
let foundation = await buildCliStartHandoffFoundation({
|
|
94708
|
-
baseUrl: gatewayUrl,
|
|
94709
|
-
profile,
|
|
94710
|
-
readiness,
|
|
94711
|
-
session: sessionSlot,
|
|
94712
|
-
targetProfileIds,
|
|
94713
|
-
targetProfiles
|
|
94714
|
-
});
|
|
94715
|
-
if (shouldRunInitialHandoffServiceGate({
|
|
94716
|
-
interactive: input.interactive,
|
|
94717
|
-
localSetupMode,
|
|
94718
|
-
runtime: input.runtime
|
|
94719
|
-
})) {
|
|
94720
|
-
const serviceGateState = await ensureInteractiveHandoffServiceReady({
|
|
94721
|
-
foundation,
|
|
94722
|
-
gatewayUrl,
|
|
94723
|
-
opaqueToken: input.startSession,
|
|
94724
|
-
presenter: input.presenter,
|
|
94725
|
-
profile,
|
|
94726
|
-
progress,
|
|
94727
|
-
readiness,
|
|
94728
|
-
runtime: input.runtime,
|
|
94729
|
-
sessionDeviceId,
|
|
94730
|
-
sessionSlot,
|
|
94731
|
-
startApi,
|
|
94732
|
-
targetProfileIds,
|
|
94733
|
-
targetProfiles,
|
|
94734
|
-
view: input.view
|
|
94735
|
-
});
|
|
94736
|
-
if (serviceGateState === "cancelled") return;
|
|
94737
|
-
({foundation, progress, readiness} = serviceGateState);
|
|
94738
|
-
}
|
|
94739
|
-
if (localSetupMode.kind === "prepare_local_agents") {
|
|
94740
|
-
await runHandoffGateWithFailureSync({
|
|
94741
|
-
gate: "local_agent",
|
|
94742
|
-
progress: () => progress,
|
|
94743
|
-
reasonCode: "local_agent_preparation.not_enabled",
|
|
94744
|
-
retryAction: "change_selection",
|
|
94745
|
-
run: async () => {
|
|
94746
|
-
await runStartLocalAgentsEnable({
|
|
94747
|
-
agent: localSetupMode.localAgentIds,
|
|
94748
|
-
presentation: "handoff",
|
|
94749
|
-
view: input.view
|
|
94750
|
-
});
|
|
94751
|
-
},
|
|
94752
|
-
syncFailureProgress: (nextProgress) => {
|
|
94753
|
-
progress = nextProgress;
|
|
94754
|
-
}
|
|
94755
|
-
});
|
|
94756
|
-
const preparation = await runHandoffGateWithFailureSync({
|
|
94757
|
-
gate: "local_agent",
|
|
94758
|
-
progress: () => progress,
|
|
94759
|
-
reasonCode: "local_agent_preparation.not_selectable",
|
|
94760
|
-
retryAction: "change_selection",
|
|
94761
|
-
run: async () => await prepareLocalAgentReadiness({
|
|
94762
|
-
profiles: targetProfiles,
|
|
94763
|
-
interactive: input.runtime.resolvedView === "human" && input.interactive,
|
|
94764
|
-
view: input.view
|
|
94765
|
-
}),
|
|
94766
|
-
syncFailureProgress: (nextProgress) => {
|
|
94767
|
-
progress = nextProgress;
|
|
94768
|
-
}
|
|
94769
|
-
});
|
|
94770
|
-
if (preparation.status === "cancelled") return;
|
|
94771
|
-
targetProfiles = preparation.profiles;
|
|
94772
|
-
await runHandoffGateWithFailureSync({
|
|
94773
|
-
gate: "runtime_report",
|
|
94774
|
-
progress: () => progress,
|
|
94775
|
-
reasonCode: "runtime.report_rejected",
|
|
94776
|
-
retryAction: "rerun_prepare",
|
|
94777
|
-
run: async () => {
|
|
94778
|
-
assertSelectedAgentControllerReportsAccepted(await submitSelectedAgentControllerReports({
|
|
94779
|
-
readiness: await collectHandoffReadiness(gatewayUrl),
|
|
94780
|
-
localAgentIds: localSetupMode.localAgentIds
|
|
94781
|
-
}));
|
|
94782
|
-
},
|
|
94783
|
-
syncFailureProgress: (nextProgress) => {
|
|
94784
|
-
progress = nextProgress;
|
|
94785
|
-
}
|
|
94786
|
-
});
|
|
94787
|
-
await runHandoffGateWithFailureSync({
|
|
94788
|
-
gate: "binding",
|
|
94789
|
-
progress: () => progress,
|
|
94790
|
-
reasonCode: "agent_profile_binding.unavailable",
|
|
94791
|
-
retryAction: "rerun_prepare",
|
|
94792
|
-
run: async () => await syncHandoffAgentProfileRuntimeBindings({
|
|
94793
|
-
profiles: targetProfiles,
|
|
94794
|
-
startSession: input.startSession
|
|
94795
|
-
}),
|
|
94796
|
-
syncFailureProgress: (nextProgress) => {
|
|
94797
|
-
progress = nextProgress;
|
|
94798
|
-
}
|
|
94799
|
-
});
|
|
94800
|
-
readiness = await collectHandoffReadiness(gatewayUrl);
|
|
94801
|
-
await assertValidatedHandoffObservation({
|
|
94802
|
-
baseUrl: gatewayUrl,
|
|
94803
|
-
profile,
|
|
94804
|
-
sessionDeviceId,
|
|
94805
|
-
targetProfileIds,
|
|
94806
|
-
targetProfiles,
|
|
94807
|
-
readiness
|
|
94808
|
-
});
|
|
94809
|
-
}
|
|
94810
|
-
foundation = await buildCliStartHandoffFoundation({
|
|
94811
|
-
baseUrl: gatewayUrl,
|
|
94812
|
-
profile,
|
|
94813
|
-
readiness,
|
|
94814
|
-
session: sessionSlot,
|
|
94815
|
-
targetProfileIds,
|
|
94816
|
-
targetProfiles
|
|
94817
|
-
});
|
|
94818
|
-
if (input.runtime.resolvedView === "human" && input.interactive && localSetupMode.kind !== "zero_agents") {
|
|
94819
|
-
if (await runHandoffGateWithFailureSync({
|
|
94820
|
-
gate: "local_agent",
|
|
94821
|
-
progress: () => progress,
|
|
94822
|
-
reasonCode: "skills_readiness.action_required",
|
|
94823
|
-
retryAction: "rerun_prepare",
|
|
94824
|
-
run: async () => await runStartSkillsStep({
|
|
94825
|
-
runtime: input.runtime,
|
|
94826
|
-
presenter: input.presenter,
|
|
94827
|
-
interactive: true,
|
|
94828
|
-
readiness,
|
|
94829
|
-
view: input.view
|
|
94830
|
-
}),
|
|
94831
|
-
syncFailureProgress: (nextProgress) => {
|
|
94832
|
-
progress = nextProgress;
|
|
94833
|
-
}
|
|
94834
|
-
}) === "cancelled") return;
|
|
94835
|
-
await runWithDelayedSpinner({
|
|
94836
|
-
message: "Finishing local setup. ATS is checking this computer and updating ATS Web.",
|
|
94837
|
-
completeMessage: "ATS finished checking this computer.",
|
|
94838
|
-
run: async () => {
|
|
94839
|
-
readiness = await collectHandoffReadiness(gatewayUrl);
|
|
94840
|
-
await assertValidatedHandoffObservation({
|
|
94841
|
-
baseUrl: gatewayUrl,
|
|
94842
|
-
profile,
|
|
94843
|
-
sessionDeviceId,
|
|
94844
|
-
targetProfileIds,
|
|
94845
|
-
targetProfiles,
|
|
94846
|
-
readiness
|
|
94847
|
-
});
|
|
94848
|
-
foundation = await buildCliStartHandoffFoundation({
|
|
94849
|
-
baseUrl: gatewayUrl,
|
|
94850
|
-
profile,
|
|
94851
|
-
readiness,
|
|
94852
|
-
session: sessionSlot,
|
|
94853
|
-
targetProfileIds,
|
|
94854
|
-
targetProfiles
|
|
94855
|
-
});
|
|
94856
|
-
}
|
|
94857
|
-
});
|
|
94858
|
-
if (await runHandoffGateWithFailureSync({
|
|
94859
|
-
gate: "service",
|
|
94860
|
-
progress: () => progress,
|
|
94861
|
-
reasonCode: "service.not_ready",
|
|
94862
|
-
retryAction: "rerun_prepare",
|
|
94863
|
-
run: async () => await runStartServiceStep({
|
|
94864
|
-
foundation,
|
|
94865
|
-
runtime: input.runtime,
|
|
94866
|
-
presenter: input.presenter,
|
|
94867
|
-
readiness,
|
|
94868
|
-
profile,
|
|
94869
|
-
gatewayUrl,
|
|
94870
|
-
view: input.view
|
|
94871
|
-
}),
|
|
94872
|
-
syncFailureProgress: (nextProgress) => {
|
|
94873
|
-
progress = nextProgress;
|
|
94874
|
-
}
|
|
94875
|
-
}) !== "continue") {
|
|
94876
|
-
progress = syncHandoffFailureProgress({
|
|
94877
|
-
gate: "service",
|
|
94878
|
-
progress,
|
|
94879
|
-
reasonCode: resolveHandoffServiceFailureReasonCode({ foundation }),
|
|
94880
|
-
retryAction: "rerun_prepare"
|
|
94881
|
-
});
|
|
94882
|
-
throw new Error("ATS Service is not connected yet. Return to ATS Web and run the setup command again.");
|
|
94883
|
-
}
|
|
94884
|
-
await runWithDelayedSpinner({
|
|
94885
|
-
message: "Verifying local agent capability and telling ATS Web this computer can be used.",
|
|
94886
|
-
completeMessage: "ATS Web can now use this computer.",
|
|
94887
|
-
run: async () => {
|
|
94888
|
-
readiness = await collectHandoffReadiness(gatewayUrl);
|
|
94889
|
-
await assertValidatedHandoffObservation({
|
|
94890
|
-
baseUrl: gatewayUrl,
|
|
94891
|
-
profile,
|
|
94892
|
-
sessionDeviceId,
|
|
94893
|
-
targetProfileIds,
|
|
94894
|
-
targetProfiles,
|
|
94895
|
-
readiness
|
|
94896
|
-
});
|
|
94897
|
-
}
|
|
94898
|
-
});
|
|
94899
|
-
progress = advanceCliStartHandoffProgressAfterLocalSetup({ progress });
|
|
94900
|
-
emitHandoffLocalSetupComplete({
|
|
94901
|
-
gatewayUrl,
|
|
94902
|
-
mode: localSetupMode,
|
|
94903
|
-
presenter: input.presenter,
|
|
94904
|
-
runtime: input.runtime
|
|
94905
|
-
});
|
|
94906
|
-
return;
|
|
94907
|
-
}
|
|
94908
|
-
const actionRequired = resolveNonInteractiveHandoffActionRequired({
|
|
94909
|
-
foundation,
|
|
94910
|
-
startSession: input.startSession
|
|
94911
|
-
});
|
|
94912
|
-
if (actionRequired) {
|
|
94913
|
-
if (input.runtime.resolvedView === "agent") input.presenter.data({
|
|
94914
|
-
code: "start.handoff.local_action_required",
|
|
94915
|
-
payload: actionRequired.payload
|
|
94916
|
-
});
|
|
94917
|
-
throw new Error(actionRequired.message);
|
|
94918
|
-
}
|
|
94919
|
-
if (localSetupMode.kind === "prepare_local_agents") progress = advanceCliStartHandoffProgressAfterLocalSetup({ progress });
|
|
94920
|
-
emitHandoffLocalSetupComplete({
|
|
94921
|
-
gatewayUrl,
|
|
94922
|
-
mode: localSetupMode,
|
|
94923
|
-
presenter: input.presenter,
|
|
94924
|
-
runtime: input.runtime
|
|
94925
|
-
});
|
|
94926
|
-
}
|
|
94927
|
-
async function ensureInteractiveHandoffServiceReady(input) {
|
|
94928
|
-
let progress = input.progress;
|
|
94929
|
-
const serviceStepResult = await runHandoffGateWithFailureSync({
|
|
94930
|
-
gate: "service",
|
|
94931
|
-
progress: () => progress,
|
|
94932
|
-
reasonCode: "service.not_ready",
|
|
94933
|
-
retryAction: "rerun_prepare",
|
|
94934
|
-
run: async () => await runStartServiceStep({
|
|
94935
|
-
foundation: input.foundation,
|
|
94936
|
-
runtime: input.runtime,
|
|
94937
|
-
presenter: input.presenter,
|
|
94938
|
-
readiness: input.readiness,
|
|
94939
|
-
profile: input.profile,
|
|
94940
|
-
gatewayUrl: input.gatewayUrl,
|
|
94941
|
-
forcePrompt: true,
|
|
94942
|
-
autoRepair: true,
|
|
94943
|
-
view: input.view
|
|
94944
|
-
}),
|
|
94945
|
-
syncFailureProgress: (nextProgress) => {
|
|
94946
|
-
progress = nextProgress;
|
|
94947
|
-
}
|
|
94948
|
-
});
|
|
94949
|
-
if (serviceStepResult === "cancelled") return "cancelled";
|
|
94950
|
-
if (serviceStepResult !== "continue") {
|
|
94951
|
-
progress = syncHandoffFailureProgress({
|
|
94952
|
-
gate: "service",
|
|
94953
|
-
progress,
|
|
94954
|
-
reasonCode: resolveHandoffServiceFailureReasonCode({ foundation: input.foundation }),
|
|
94955
|
-
retryAction: "rerun_prepare"
|
|
94956
|
-
});
|
|
94957
|
-
throw new Error("ATS Service is not connected yet. Return to ATS Web and run the setup command again.");
|
|
94958
|
-
}
|
|
94959
|
-
const readiness = await collectHandoffReadiness(input.gatewayUrl);
|
|
94960
|
-
await assertValidatedHandoffObservation({
|
|
94961
|
-
baseUrl: input.gatewayUrl,
|
|
94962
|
-
profile: input.profile,
|
|
94963
|
-
sessionDeviceId: input.sessionDeviceId,
|
|
94964
|
-
targetProfileIds: input.targetProfileIds,
|
|
94965
|
-
targetProfiles: input.targetProfiles,
|
|
94966
|
-
readiness
|
|
94967
|
-
});
|
|
94968
|
-
return {
|
|
94969
|
-
foundation: await buildCliStartHandoffFoundation({
|
|
94970
|
-
baseUrl: input.gatewayUrl,
|
|
94971
|
-
profile: input.profile,
|
|
94972
|
-
readiness,
|
|
94973
|
-
session: input.sessionSlot,
|
|
94974
|
-
targetProfileIds: input.targetProfileIds,
|
|
94975
|
-
targetProfiles: input.targetProfiles
|
|
94976
|
-
}),
|
|
94977
|
-
progress,
|
|
94978
|
-
readiness
|
|
94979
|
-
};
|
|
94980
|
-
}
|
|
94981
|
-
async function syncHandoffAgentProfileRuntimeBindings(input) {
|
|
94982
|
-
for (const profile of input.profiles) {
|
|
94983
|
-
if (profile.profileKind !== "agent") continue;
|
|
94984
|
-
const result = await syncAgentProfileRuntimeBindingFromCurrentReadiness({ profile });
|
|
94985
|
-
if (result.agentProfileBindingEnsure.status !== "accepted") {
|
|
94986
|
-
const reasonCode = result.agentProfileBindingEnsure.reasonCodes[0] ?? "agent_profile_binding.unavailable";
|
|
94987
|
-
throw new Error(buildHandoffAgentConnectionFailureMessage({
|
|
94988
|
-
profile,
|
|
94989
|
-
reasonCode,
|
|
94990
|
-
startSession: input.startSession
|
|
94991
|
-
}));
|
|
94992
|
-
}
|
|
94993
|
-
}
|
|
94994
|
-
}
|
|
94995
|
-
function buildHandoffAgentConnectionFailureMessage(input) {
|
|
94996
|
-
const profileName = input.profile.profileName;
|
|
94997
|
-
const localAgentText = "the local agent this profile uses";
|
|
94998
|
-
const nextCommand = formatAtsCliCommands(["ats agents list", buildHandoffContinuationCommand(input.startSession)]);
|
|
94999
|
-
return [
|
|
95000
|
-
`ATS turned on local agents, but ${profileName} cannot reply from this computer yet.`,
|
|
95001
|
-
`What happened: ${formatHandoffAgentConnectionFailureReason({
|
|
95002
|
-
localAgentText,
|
|
95003
|
-
reasonCode: input.reasonCode
|
|
95004
|
-
})}`,
|
|
95005
|
-
"What to do next:",
|
|
95006
|
-
"1. Return to ATS Web and click Refresh.",
|
|
95007
|
-
`2. If ${profileName} still cannot reply, run: ${nextCommand[0]}`,
|
|
95008
|
-
`3. Then run the setup command again: ${nextCommand[1]}`,
|
|
95009
|
-
`Support code: ${input.reasonCode}`
|
|
95010
|
-
].join("\n");
|
|
95011
|
-
}
|
|
95012
|
-
function formatHandoffAgentConnectionFailureReason(input) {
|
|
95013
|
-
switch (input.reasonCode) {
|
|
95014
|
-
case "agent_profile_binding.agent_controller_report_unavailable": return `This computer did not report ${input.localAgentText} as usable for replies.`;
|
|
95015
|
-
case "agent_profile_binding.agent_controller_report_missing": return `This computer did not report ${input.localAgentText}.`;
|
|
95016
|
-
case "agent_profile_binding.agent_controller_report_disabled": return `${input.localAgentText} is turned off on this computer.`;
|
|
95017
|
-
case "agent_profile_binding.agent_controller_report_stale": return `ATS has old local agent capability information for ${input.localAgentText} on this computer.`;
|
|
95018
|
-
case "agent_profile_binding.runtime_owner_mismatch":
|
|
95019
|
-
case "agent_profile_binding.owner_mismatch": return "This Terminal is signed in to a different ATS account than the one used by ATS Web.";
|
|
95020
|
-
case "agent_profile_binding.runtime_reporting_unavailable": return "This computer did not send its latest local-agent agent controller report to ATS Web.";
|
|
95021
|
-
case "agent_profile_binding.write_failed": return "ATS Web could not save this computer as the reply computer for that agent.";
|
|
95022
|
-
default: return "ATS Web could not finish connecting this agent to this computer.";
|
|
95023
|
-
}
|
|
95024
|
-
}
|
|
95025
|
-
function syncHandoffFailureProgress(input) {
|
|
95026
|
-
return recordCliStartHandoffFailure({
|
|
95027
|
-
progress: input.progress,
|
|
95028
|
-
failure: {
|
|
95029
|
-
gate: input.gate,
|
|
95030
|
-
reasonCode: input.reasonCode,
|
|
95031
|
-
retryAction: input.retryAction
|
|
95032
|
-
}
|
|
95033
|
-
});
|
|
95034
|
-
}
|
|
95035
|
-
async function runHandoffGateWithFailureSync(input) {
|
|
95036
|
-
try {
|
|
95037
|
-
return await input.run();
|
|
95038
|
-
} catch (error) {
|
|
95039
|
-
try {
|
|
95040
|
-
input.syncFailureProgress(recordCliStartHandoffFailure({
|
|
95041
|
-
progress: input.progress(),
|
|
95042
|
-
failure: {
|
|
95043
|
-
gate: input.gate,
|
|
95044
|
-
reasonCode: resolveHandoffGateFailureReasonCode({
|
|
95045
|
-
defaultReasonCode: input.reasonCode,
|
|
95046
|
-
error
|
|
95047
|
-
}),
|
|
95048
|
-
retryAction: input.retryAction
|
|
95049
|
-
}
|
|
95050
|
-
}));
|
|
95051
|
-
} catch (syncError) {
|
|
95052
|
-
throw new AggregateError([error, syncError], "ATS local setup failed and the failed outcome could not be synced.");
|
|
95053
|
-
}
|
|
95054
|
-
throw error;
|
|
95055
|
-
}
|
|
95056
|
-
}
|
|
95057
|
-
function resolveHandoffGateFailureReasonCode(input) {
|
|
95058
|
-
const message = input.error instanceof Error ? input.error.message : "";
|
|
95059
|
-
const supportCode = HANDOFF_SUPPORT_CODE_RE.exec(message)?.[1];
|
|
95060
|
-
if (supportCode) return supportCode;
|
|
95061
|
-
if (message.includes("ATS Service is not running")) return "service.not_running";
|
|
95062
|
-
if (message.includes("ATS Service is not installed")) return "service.not_installed";
|
|
95063
|
-
if (message.includes("different ATS account") || message.includes("owner_mismatch")) return "service.account_mismatch";
|
|
95064
|
-
return input.defaultReasonCode;
|
|
95065
|
-
}
|
|
95066
|
-
function resolveHandoffServiceFailureReasonCode(input) {
|
|
95067
|
-
switch (resolvePrimaryHandoffDecisionReasonCode(input.foundation)) {
|
|
95068
|
-
case "background_helper.not_running": return "service.not_running";
|
|
95069
|
-
case "background_helper.not_installed": return "service.not_installed";
|
|
95070
|
-
case "background_helper.update_required": return "service.update_required";
|
|
95071
|
-
case "background_helper.installed_outdated":
|
|
95072
|
-
case "background_helper.stale":
|
|
95073
|
-
case "background_helper.unknown": return "service.stale";
|
|
95074
|
-
default: return "service.not_ready";
|
|
95075
|
-
}
|
|
95076
|
-
}
|
|
95077
|
-
function resolvePrimaryHandoffDecisionReasonCode(foundation) {
|
|
95078
|
-
const decision = foundation.foundationState.decision;
|
|
95079
|
-
const signal = decision.blocking[0] ?? decision.attention[0] ?? null;
|
|
95080
|
-
if (!(signal && typeof signal === "object" && "reasonCode" in signal)) return "";
|
|
95081
|
-
return String(signal.reasonCode ?? "").trim();
|
|
95082
|
-
}
|
|
95083
|
-
async function runWithDelayedSpinner(input) {
|
|
95084
|
-
const spinner = createDelayedSpinner({
|
|
95085
|
-
enabled: true,
|
|
95086
|
-
message: input.message
|
|
95087
|
-
});
|
|
95088
|
-
spinner.start();
|
|
95089
|
-
try {
|
|
95090
|
-
const result = await input.run();
|
|
95091
|
-
spinner.complete(input.completeMessage);
|
|
95092
|
-
return result;
|
|
95093
|
-
} catch (error) {
|
|
95094
|
-
spinner.fail();
|
|
95095
|
-
throw error;
|
|
95096
|
-
}
|
|
95097
|
-
}
|
|
95098
|
-
async function assertValidatedHandoffObservation(input) {
|
|
95099
|
-
assertHandoffObservationMatchesSession({
|
|
95100
|
-
observation: await buildCliStartObservation({
|
|
95101
|
-
baseUrl: input.baseUrl,
|
|
95102
|
-
profile: input.profile,
|
|
95103
|
-
targetProfileIds: input.targetProfileIds,
|
|
95104
|
-
targetProfiles: input.targetProfiles,
|
|
95105
|
-
readiness: input.readiness
|
|
95106
|
-
}),
|
|
95107
|
-
sessionDeviceId: input.sessionDeviceId
|
|
95108
|
-
});
|
|
95109
|
-
}
|
|
95110
|
-
function requireStartHandoffSessionDeviceId(session) {
|
|
95111
|
-
if (session.deviceId) return session.deviceId;
|
|
95112
|
-
throw new Error(START_HANDOFF_UNKNOWN_SESSION_DEVICE_MESSAGE);
|
|
95113
|
-
}
|
|
95114
|
-
function assertHandoffObservationMatchesSession(input) {
|
|
95115
|
-
const mismatchedDeviceIds = [...collectObservedDeviceIds(input.observation)].filter((deviceId) => deviceId !== input.sessionDeviceId);
|
|
95116
|
-
if (mismatchedDeviceIds.length === 0) return;
|
|
95117
|
-
throw new Error(`${START_HANDOFF_DEVICE_MISMATCH_MESSAGE} Expected ATS computer ${input.sessionDeviceId}; this terminal reported ${mismatchedDeviceIds.join(", ")}.`);
|
|
95118
|
-
}
|
|
95119
|
-
function collectObservedDeviceIds(observation) {
|
|
95120
|
-
const deviceIds = /* @__PURE__ */ new Set();
|
|
95121
|
-
if (observation.device.value?.deviceId) deviceIds.add(observation.device.value.deviceId);
|
|
95122
|
-
for (const entry of observation.profileReadiness) if (entry.projection.value?.deviceId) deviceIds.add(entry.projection.value.deviceId);
|
|
95123
|
-
return deviceIds;
|
|
95124
|
-
}
|
|
95125
|
-
async function resolveStartHandoff(input) {
|
|
95126
|
-
try {
|
|
95127
|
-
return await input.startApi.resolveHandoff({ opaqueToken: input.opaqueToken });
|
|
95128
|
-
} catch (error) {
|
|
95129
|
-
throw toStartHandoffResolveError(error);
|
|
95130
|
-
}
|
|
95131
|
-
}
|
|
95132
|
-
function assertValidStartHandoffInput(input) {
|
|
95133
|
-
const conflicts = [
|
|
95134
|
-
["profile", input.profile],
|
|
95135
|
-
["profileId", input.profileId],
|
|
95136
|
-
["kind", input.kind],
|
|
95137
|
-
["profileName", input.profileName],
|
|
95138
|
-
["agentName", input.agentName],
|
|
95139
|
-
["agentModel", input.agentModel],
|
|
95140
|
-
["agentOwner", input.agentOwner],
|
|
95141
|
-
["skillsMode", typeof input.skillsMode === "string" && input.skillsMode.trim() !== "" ? input.skillsMode : void 0]
|
|
95142
|
-
].filter(([, value]) => value !== void 0 && value !== null && `${value}` !== "");
|
|
95143
|
-
if (conflicts.length === 0) return;
|
|
95144
|
-
const firstConflict = conflicts[0]?.[0] ?? "unknown";
|
|
95145
|
-
throw new Error(`--start-session cannot be combined with standalone start option "${formatCliFlag(firstConflict)}". Use only ${[...HANDOFF_ONLY_ALLOWED_FLAGS].map((flag) => formatCliFlag(flag)).join(", ")}.`);
|
|
95146
|
-
}
|
|
95147
|
-
function formatCliFlag(name) {
|
|
95148
|
-
return `--${name.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`)}`;
|
|
95149
|
-
}
|
|
95150
|
-
function requireReadySessionSlot(slot) {
|
|
95151
|
-
if (slot.availability !== "ready" || !slot.value) throw new Error("ATS could not load the current start session state for this computer. Return to ATS Web and start again.");
|
|
95152
|
-
return slot;
|
|
95153
|
-
}
|
|
95154
|
-
function shouldRunInitialHandoffServiceGate(input) {
|
|
95155
|
-
return input.localSetupMode.kind === "prepare_local_agents" && input.runtime.resolvedView === "human" && input.interactive;
|
|
95156
|
-
}
|
|
95157
|
-
function resolveLocalSetupMode(input) {
|
|
95158
|
-
if (input.session.localAgentPreparation.mode === "unresolved") return { kind: "await_web_local_agent_preparation" };
|
|
95159
|
-
if (input.session.localAgentPreparation.mode === "skip_local_agents") return { kind: "zero_agents" };
|
|
95160
|
-
return {
|
|
95161
|
-
kind: "prepare_local_agents",
|
|
95162
|
-
localAgentIds: [...input.session.localAgentPreparation.localAgentIds]
|
|
95163
|
-
};
|
|
95164
|
-
}
|
|
95165
|
-
async function waitForWebLocalAgentPreparation(input) {
|
|
95166
|
-
const deadlineMs = Date.now() + input.waitConfig.timeoutMs;
|
|
95167
|
-
while (true) {
|
|
95168
|
-
if (resolveLocalSetupMode({ session: requireReadySessionSlot((await resolveStartHandoff({
|
|
95169
|
-
startApi: input.startApi,
|
|
95170
|
-
opaqueToken: input.opaqueToken
|
|
95171
|
-
})).state.readModel.session).value }).kind !== "await_web_local_agent_preparation") return;
|
|
95172
|
-
const nowMs = Date.now();
|
|
95173
|
-
if (nowMs >= deadlineMs) throw new Error(`ATS waited ${formatWaitDuration(input.waitConfig.timeoutMs)} for a local-agent choice in ATS Web. Copy a fresh setup command from ATS Web and run it again.`);
|
|
95174
|
-
const sleepMs = Math.min(input.waitConfig.pollIntervalMs, Math.max(0, deadlineMs - nowMs));
|
|
95175
|
-
if (sleepMs > 0) await sleep$1(sleepMs);
|
|
95176
|
-
}
|
|
95177
|
-
}
|
|
95178
|
-
function resolveWebLocalAgentPreparationWaitConfig() {
|
|
95179
|
-
return {
|
|
95180
|
-
timeoutMs: readOptionalNonNegativeIntegerEnv({
|
|
95181
|
-
envName: "ATS_START_HANDOFF_WEB_SELECTION_TIMEOUT_MS",
|
|
95182
|
-
defaultValue: DEFAULT_WEB_AGENT_SELECTION_TIMEOUT_MS
|
|
95183
|
-
}),
|
|
95184
|
-
pollIntervalMs: readOptionalNonNegativeIntegerEnv({
|
|
95185
|
-
envName: "ATS_START_HANDOFF_WEB_SELECTION_POLL_INTERVAL_MS",
|
|
95186
|
-
defaultValue: DEFAULT_WEB_AGENT_SELECTION_POLL_INTERVAL_MS
|
|
95187
|
-
})
|
|
95188
|
-
};
|
|
95189
|
-
}
|
|
95190
|
-
function readOptionalNonNegativeIntegerEnv(input) {
|
|
95191
|
-
const rawValue = process.env[input.envName];
|
|
95192
|
-
if (rawValue === void 0 || rawValue.trim() === "") return input.defaultValue;
|
|
95193
|
-
const value = Number(rawValue);
|
|
95194
|
-
if (!Number.isInteger(value) || value < 0) throw new Error(`${input.envName} must be a non-negative integer number of milliseconds.`);
|
|
95195
|
-
return value;
|
|
95196
|
-
}
|
|
95197
|
-
function formatWaitDuration(timeoutMs) {
|
|
95198
|
-
if (timeoutMs === DEFAULT_WEB_AGENT_SELECTION_TIMEOUT_MS) return "30 minutes";
|
|
95199
|
-
if (timeoutMs < 1e3) return `${timeoutMs} milliseconds`;
|
|
95200
|
-
const seconds = Math.round(timeoutMs / 1e3);
|
|
95201
|
-
if (seconds < 60) return `${seconds} seconds`;
|
|
95202
|
-
return `${Math.round(seconds / 60)} minutes`;
|
|
95203
|
-
}
|
|
95204
|
-
async function collectHandoffReadiness(gatewayUrl) {
|
|
95205
|
-
return await collectStartLocalReadiness({ auth: {
|
|
95206
|
-
status: "valid",
|
|
95207
|
-
email: null,
|
|
95208
|
-
authBaseUrl: null,
|
|
95209
|
-
gatewayUrl
|
|
95210
|
-
} });
|
|
95211
|
-
}
|
|
95212
|
-
function createStartGatewayApi(gatewayUrl) {
|
|
95213
|
-
return createStartApi(createAtsApiClient({
|
|
95214
|
-
baseUrl: gatewayUrl,
|
|
95215
|
-
transport: async (request) => await fetchSpaceRequestWithTimeout({
|
|
95216
|
-
url: request.url,
|
|
95217
|
-
operation: request.operation,
|
|
95218
|
-
init: request.init,
|
|
95219
|
-
timeoutMs: request.timeoutMs
|
|
95220
|
-
})
|
|
95221
|
-
}));
|
|
95222
|
-
}
|
|
95223
|
-
function resolveNonInteractiveHandoffActionRequired(input) {
|
|
95224
|
-
const decision = input.foundation.foundationState.decision;
|
|
95225
|
-
if (decision.status !== "blocking") return null;
|
|
95226
|
-
const reasonCode = resolvePrimaryHandoffDecisionReasonCode(input.foundation);
|
|
95227
|
-
const message = buildLocalActionRequiredMessage({
|
|
95228
|
-
reasonCode,
|
|
95229
|
-
startSession: input.startSession
|
|
95230
|
-
});
|
|
95231
|
-
return {
|
|
95232
|
-
message,
|
|
95233
|
-
payload: {
|
|
95234
|
-
status: decision.status,
|
|
95235
|
-
nextAction: decision.nextAction,
|
|
95236
|
-
blocking: decision.blocking,
|
|
95237
|
-
attention: decision.attention,
|
|
95238
|
-
followUp: decision.followUp,
|
|
95239
|
-
message,
|
|
95240
|
-
nextSteps: buildLocalActionRequiredNextSteps({
|
|
95241
|
-
reasonCode,
|
|
95242
|
-
startSession: input.startSession
|
|
95243
|
-
})
|
|
95244
|
-
}
|
|
95245
|
-
};
|
|
95246
|
-
}
|
|
95247
|
-
function buildLocalActionRequiredMessage(input) {
|
|
95248
|
-
const handoffCommand = buildHandoffContinuationCommand(input.startSession);
|
|
95249
|
-
switch (input.reasonCode) {
|
|
95250
|
-
case "skills_readiness.action_required": return formatInlineAtsCliCommands(`Local ATS skills on this computer need setup. Run \`${handoffCommand}\` in human view, then return to ATS Web.`);
|
|
95251
|
-
case "skills_readiness.unknown": return formatInlineAtsCliCommands(`ATS could not verify local skills on this computer. Run \`${handoffCommand}\` in human view, then return to ATS Web.`);
|
|
95252
|
-
case "background_helper.not_installed": return formatInlineAtsCliCommands(`ATS Service is not connected on this computer. Run \`${handoffCommand}\` in human view, then return to ATS Web.`);
|
|
95253
|
-
case "background_helper.installed_outdated":
|
|
95254
|
-
case "background_helper.update_required": return formatInlineAtsCliCommands(`ATS Service needs an update on this computer. Run \`${handoffCommand}\` in human view, then return to ATS Web.`);
|
|
95255
|
-
case "background_helper.not_running":
|
|
95256
|
-
case "background_helper.stale":
|
|
95257
|
-
case "background_helper.unknown": return formatInlineAtsCliCommands(`ATS Service needs to reconnect on this computer. Run \`${handoffCommand}\` in human view, then return to ATS Web.`);
|
|
95258
|
-
case "local_agent_preparation.not_found": return "ATS could not find the selected local agents on this computer. Return to ATS Web, choose the local agents again, and continue there.";
|
|
95259
|
-
case "local_agent_preparation.not_enabled": return formatInlineAtsCliCommands(`The selected local agents on this computer are not fully prepared yet. Run \`${handoffCommand}\` in human view, then return to ATS Web.`);
|
|
95260
|
-
case "local_agent_preparation.not_selectable": return formatInlineAtsCliCommands(`One or more selected local agents on this computer are not available for ATS yet. Run \`${handoffCommand}\` in human view, then return to ATS Web.`);
|
|
95261
|
-
case "device_projection.missing":
|
|
95262
|
-
case "device_projection.unavailable":
|
|
95263
|
-
case "device_projection.stale": return formatInlineAtsCliCommands(`ATS could not verify this computer's local agent capability yet. Run \`${handoffCommand}\` in human view, then return to ATS Web.`);
|
|
95264
|
-
case "profile_readiness.missing":
|
|
95265
|
-
case "profile_readiness.unavailable":
|
|
95266
|
-
case "profile_readiness.stale":
|
|
95267
|
-
case "profile_readiness.route_offline":
|
|
95268
|
-
case "profile_readiness.route_unavailable":
|
|
95269
|
-
case "profile_readiness.reply_blocked":
|
|
95270
|
-
case "profile_readiness.reply_degraded":
|
|
95271
|
-
case "profile_readiness.reply_unknown": return "ATS still needs to verify whether the selected profile can enter this space. Return to ATS Web to continue there.";
|
|
95272
|
-
default: return formatInlineAtsCliCommands(`This computer still needs local setup before ATS can continue. Run \`${handoffCommand}\` in human view, then return to ATS Web.`);
|
|
95273
|
-
}
|
|
95274
|
-
}
|
|
95275
|
-
function buildLocalActionRequiredNextSteps(input) {
|
|
95276
|
-
if (input.reasonCode === "background_helper.not_installed" || input.reasonCode === "background_helper.installed_outdated" || input.reasonCode === "background_helper.update_required" || input.reasonCode === "background_helper.not_running" || input.reasonCode === "background_helper.stale" || input.reasonCode === "background_helper.unknown" || input.reasonCode === "skills_readiness.action_required" || input.reasonCode === "skills_readiness.unknown") return formatAtsCliCommands([buildHandoffContinuationCommand(input.startSession)]);
|
|
95277
|
-
if (input.reasonCode === "local_agent_preparation.not_found") return ["Return to ATS Web and choose the local agents again."];
|
|
95278
|
-
if (input.reasonCode.startsWith("profile_readiness.")) return ["Return to ATS Web to continue this setup."];
|
|
95279
|
-
if (input.reasonCode === "local_agent_preparation.not_enabled" || input.reasonCode === "local_agent_preparation.not_selectable" || input.reasonCode === "device_projection.missing" || input.reasonCode === "device_projection.unavailable" || input.reasonCode === "device_projection.stale" || input.reasonCode === "") return formatAtsCliCommands([buildHandoffContinuationCommand(input.startSession)]);
|
|
95280
|
-
return [];
|
|
95281
|
-
}
|
|
95282
|
-
function buildHandoffContinuationCommand(startSession) {
|
|
95283
|
-
return `ats setup --start-session ${startSession}`;
|
|
95284
|
-
}
|
|
95285
|
-
function emitZeroAgentHandoffComplete(input) {
|
|
95286
|
-
if (input.runtime.resolvedView === "agent") {
|
|
95287
|
-
input.presenter.data({
|
|
95288
|
-
code: "start.handoff.complete",
|
|
95289
|
-
payload: {
|
|
95290
|
-
mode: "zero_agent",
|
|
95291
|
-
gatewayUrl: input.gatewayUrl,
|
|
95292
|
-
nextStep: "return_to_web"
|
|
95293
|
-
}
|
|
95294
|
-
});
|
|
95295
|
-
return;
|
|
95296
|
-
}
|
|
95297
|
-
input.presenter.line({
|
|
95298
|
-
code: "start.handoff.complete",
|
|
95299
|
-
text: formatInlineAtsCliCommands(`No local agents were selected for this setup. ${RETURN_TO_WEB_TEXT}`)
|
|
95300
|
-
});
|
|
95301
|
-
}
|
|
95302
|
-
function emitSelectedAgentHandoffComplete(input) {
|
|
95303
|
-
if (input.runtime.resolvedView === "agent") {
|
|
95304
|
-
input.presenter.data({
|
|
95305
|
-
code: "start.handoff.complete",
|
|
95306
|
-
payload: {
|
|
95307
|
-
mode: "local_setup_finished",
|
|
95308
|
-
localAgentIds: input.localAgentIds,
|
|
95309
|
-
gatewayUrl: input.gatewayUrl,
|
|
95310
|
-
nextStep: "return_to_web"
|
|
95311
|
-
}
|
|
95312
|
-
});
|
|
95313
|
-
return;
|
|
95314
|
-
}
|
|
95315
|
-
input.presenter.line({
|
|
95316
|
-
code: "start.handoff.complete",
|
|
95317
|
-
text: formatInlineAtsCliCommands(RETURN_TO_WEB_TEXT)
|
|
95318
|
-
});
|
|
95319
|
-
}
|
|
95320
|
-
function emitBootstrapHandoffComplete(input) {
|
|
95321
|
-
if (input.runtime.resolvedView === "agent") {
|
|
95322
|
-
input.presenter.data({
|
|
95323
|
-
code: "start.handoff.complete",
|
|
95324
|
-
payload: {
|
|
95325
|
-
mode: "device_bootstrap_finished",
|
|
95326
|
-
gatewayUrl: input.gatewayUrl,
|
|
95327
|
-
nextStep: "return_to_web"
|
|
95328
|
-
}
|
|
95329
|
-
});
|
|
95330
|
-
return;
|
|
95331
|
-
}
|
|
95332
|
-
input.presenter.line({
|
|
95333
|
-
code: "start.handoff.complete",
|
|
95334
|
-
text: formatInlineAtsCliCommands(RETURN_TO_WEB_TEXT)
|
|
95335
|
-
});
|
|
95336
|
-
}
|
|
95337
|
-
function emitHandoffWaitingForWebLocalAgentPreparation(input) {
|
|
95338
|
-
const payload = {
|
|
95339
|
-
status: "waiting_for_web_local_agent_preparation",
|
|
95340
|
-
nextStep: "choose_agents_in_web",
|
|
95341
|
-
startSession: input.startSession,
|
|
95342
|
-
timeoutMs: input.timeoutMs,
|
|
95343
|
-
message: START_HANDOFF_WAITING_FOR_WEB_AGENT_SELECTION_MESSAGE,
|
|
95344
|
-
nextSteps: ["Choose the local agents in ATS Web.", "Keep this Terminal open so ATS can continue automatically."]
|
|
95345
|
-
};
|
|
95346
|
-
if (input.runtime.resolvedView === "agent") {
|
|
95347
|
-
input.presenter.data({
|
|
95348
|
-
code: "start.handoff.waiting_for_web_local_agent_preparation",
|
|
95349
|
-
payload
|
|
95350
|
-
});
|
|
95351
|
-
return;
|
|
95352
|
-
}
|
|
95353
|
-
input.presenter.line({
|
|
95354
|
-
code: "start.handoff.waiting_for_web_local_agent_preparation",
|
|
95355
|
-
text: "ATS found the local agents on this computer. Choose the agents to use in ATS Web. Keep this Terminal open; ATS will continue automatically."
|
|
95356
|
-
});
|
|
95357
|
-
}
|
|
95358
|
-
function emitHandoffLocalSetupComplete(input) {
|
|
95359
|
-
if (input.mode.kind === "zero_agents") {
|
|
95360
|
-
emitZeroAgentHandoffComplete({
|
|
95361
|
-
gatewayUrl: input.gatewayUrl,
|
|
95362
|
-
presenter: input.presenter,
|
|
95363
|
-
runtime: input.runtime
|
|
95364
|
-
});
|
|
95365
|
-
return;
|
|
95366
|
-
}
|
|
95367
|
-
if (input.mode.kind === "await_web_local_agent_preparation") {
|
|
95368
|
-
emitBootstrapHandoffComplete({
|
|
95369
|
-
gatewayUrl: input.gatewayUrl,
|
|
95370
|
-
presenter: input.presenter,
|
|
95371
|
-
runtime: input.runtime
|
|
95372
|
-
});
|
|
95373
|
-
return;
|
|
95374
|
-
}
|
|
95375
|
-
emitSelectedAgentHandoffComplete({
|
|
95376
|
-
gatewayUrl: input.gatewayUrl,
|
|
95377
|
-
presenter: input.presenter,
|
|
95378
|
-
runtime: input.runtime,
|
|
95379
|
-
localAgentIds: input.mode.localAgentIds
|
|
95380
|
-
});
|
|
95381
|
-
}
|
|
95382
|
-
function toStartHandoffResolveError(error) {
|
|
95383
|
-
const failure = toStructuredApiClientFailure(error);
|
|
95384
|
-
const requestIdSuffix = failure.requestId ? ` Request ID: ${failure.requestId}.` : "";
|
|
95385
|
-
switch (failure.code) {
|
|
95386
|
-
case "start.session.token_invalid": return /* @__PURE__ */ new Error(`This ATS Start link is no longer valid. Return to ATS Web and start again.${requestIdSuffix}`);
|
|
95387
|
-
case "start.session.token_stale": return /* @__PURE__ */ new Error(`This ATS Start link was replaced by a newer setup session. Return to ATS Web and continue from the latest session.${requestIdSuffix}`);
|
|
95388
|
-
case "start.session.profile_unresolved": return /* @__PURE__ */ new Error(`ATS Web still needs you to choose a profile before this computer can continue setup.${requestIdSuffix}`);
|
|
95389
|
-
case "start.session.profile_unavailable": return /* @__PURE__ */ new Error(`ATS could not load the selected profile for this setup. Return to ATS Web and start again.${requestIdSuffix}`);
|
|
95390
|
-
default: return /* @__PURE__ */ new Error(`${failure.message || "ATS could not continue this start handoff."}${requestIdSuffix}`);
|
|
95391
|
-
}
|
|
95392
|
-
}
|
|
95393
|
-
|
|
95394
93229
|
//#endregion
|
|
95395
93230
|
//#region src/commands/setup-local-agent-connection.ts
|
|
95396
93231
|
const LOCAL_AGENT_CONNECTION_CARD_TITLE = "Local Agent Connection";
|
|
93232
|
+
const RETIRED_HUMAN_PROFILE_SETUP_MESSAGE = "This ATS Web setup command is retired. Run `ats setup` to set up this computer, or open ATS Web at `/app/connect` and copy a fresh setup command.";
|
|
93233
|
+
const HUMAN_PROFILE_SETUP_TARGET_MESSAGE = "`ats setup --profile` expects an Agent Profile, not a Human Profile. Run `ats setup` to set up this computer, or copy a fresh setup command from ATS Web at `/app/connect`.";
|
|
95397
93234
|
async function runSetupLocalAgentConnection(input) {
|
|
95398
93235
|
const runtime = await resolveRuntimeContext({
|
|
95399
93236
|
profile: input.profile,
|
|
@@ -95406,11 +93243,25 @@ async function runSetupLocalAgentConnection(input) {
|
|
|
95406
93243
|
presenter,
|
|
95407
93244
|
view: runtime.resolvedView
|
|
95408
93245
|
});
|
|
93246
|
+
if (input.humanProfile) throw new Error(RETIRED_HUMAN_PROFILE_SETUP_MESSAGE);
|
|
95409
93247
|
await maybeLogInWithOneTimeToken$1({
|
|
95410
93248
|
ott: input.ott,
|
|
95411
93249
|
view: input.view
|
|
95412
93250
|
});
|
|
95413
|
-
|
|
93251
|
+
const explicitProfileId = normalizeOptionalString$1(input.profile);
|
|
93252
|
+
let explicitProfile = null;
|
|
93253
|
+
let explicitProfileResolved = false;
|
|
93254
|
+
if (explicitProfileId) {
|
|
93255
|
+
explicitProfile = await resolveAtsProfileOrNull({
|
|
93256
|
+
atsProfileId: explicitProfileId,
|
|
93257
|
+
allowUnauthenticated: true,
|
|
93258
|
+
allowDefaultFallback: false,
|
|
93259
|
+
persistSelection: false
|
|
93260
|
+
});
|
|
93261
|
+
explicitProfileResolved = true;
|
|
93262
|
+
if (isHumanProfile(explicitProfile)) throw new Error(HUMAN_PROFILE_SETUP_TARGET_MESSAGE);
|
|
93263
|
+
}
|
|
93264
|
+
if (!input.startSession) {
|
|
95414
93265
|
if (await runSetupLocalAgentConnectionServiceGate({
|
|
95415
93266
|
interactive,
|
|
95416
93267
|
presenter,
|
|
@@ -95440,20 +93291,6 @@ async function runSetupLocalAgentConnection(input) {
|
|
|
95440
93291
|
status: "completed"
|
|
95441
93292
|
};
|
|
95442
93293
|
}
|
|
95443
|
-
if (input.humanProfile) {
|
|
95444
|
-
await runSetupLocalAgentConnectionWebBootstrap({
|
|
95445
|
-
humanProfileId: input.humanProfile,
|
|
95446
|
-
interactive,
|
|
95447
|
-
presenter,
|
|
95448
|
-
resetThisComputer: input.resetThisComputer === true,
|
|
95449
|
-
runtime,
|
|
95450
|
-
view: input.view
|
|
95451
|
-
});
|
|
95452
|
-
return {
|
|
95453
|
-
setupSessionSnapshot: null,
|
|
95454
|
-
status: "completed"
|
|
95455
|
-
};
|
|
95456
|
-
}
|
|
95457
93294
|
if (input.agent && input.agent.length > 0) {
|
|
95458
93295
|
await runAgentsRepair({
|
|
95459
93296
|
agent: input.agent,
|
|
@@ -95465,26 +93302,13 @@ async function runSetupLocalAgentConnection(input) {
|
|
|
95465
93302
|
status: "completed"
|
|
95466
93303
|
};
|
|
95467
93304
|
}
|
|
95468
|
-
const profile = await resolveAtsProfileOrNull({
|
|
93305
|
+
const profile = explicitProfileResolved ? explicitProfile : await resolveAtsProfileOrNull({
|
|
95469
93306
|
atsProfileId: input.profile,
|
|
95470
93307
|
allowUnauthenticated: true,
|
|
95471
|
-
allowDefaultFallback:
|
|
93308
|
+
allowDefaultFallback: false,
|
|
95472
93309
|
persistSelection: false
|
|
95473
93310
|
});
|
|
95474
|
-
if (
|
|
95475
|
-
await runSetupLocalAgentConnectionWebBootstrap({
|
|
95476
|
-
humanProfileId: profile.atsProfileId,
|
|
95477
|
-
interactive,
|
|
95478
|
-
presenter,
|
|
95479
|
-
resetThisComputer: false,
|
|
95480
|
-
runtime,
|
|
95481
|
-
view: input.view
|
|
95482
|
-
});
|
|
95483
|
-
return {
|
|
95484
|
-
setupSessionSnapshot: null,
|
|
95485
|
-
status: "completed"
|
|
95486
|
-
};
|
|
95487
|
-
}
|
|
93311
|
+
if (isHumanProfile(profile)) throw new Error(HUMAN_PROFILE_SETUP_TARGET_MESSAGE);
|
|
95488
93312
|
if (!isAgentProfile(profile)) {
|
|
95489
93313
|
emitSetupLocalAgentConnectionTargetSelectionRequired({
|
|
95490
93314
|
presenter,
|
|
@@ -95619,88 +93443,6 @@ function assertValidLocalAgentSelectionInput(input) {
|
|
|
95619
93443
|
if (!(facts.hasProfile && facts.hasLocalAgentIds)) return;
|
|
95620
93444
|
if (normalizeLocalAgentIds(input.localAgent).length !== 1) throw new Error("--profile setup accepts exactly one --local-agent <id>.");
|
|
95621
93445
|
}
|
|
95622
|
-
async function runSetupLocalAgentConnectionWebBootstrap(input) {
|
|
95623
|
-
if (input.resetThisComputer) await stopServiceForResetThisComputer({ view: input.view });
|
|
95624
|
-
const gatewayUrl = await resolveBaseUrl();
|
|
95625
|
-
const authentication = await evaluateCommandAuthentication({ gatewayUrl });
|
|
95626
|
-
if (authentication.status !== "valid" || !authentication.session) throw new Error("ATS sign-in is required before continuing the ATS Web local-agent preparation command.");
|
|
95627
|
-
const humanProfile = await resolveAtsProfileOrNull({
|
|
95628
|
-
atsProfileId: input.humanProfileId,
|
|
95629
|
-
profileKind: "human",
|
|
95630
|
-
allowUnauthenticated: false,
|
|
95631
|
-
allowDefaultFallback: false,
|
|
95632
|
-
persistSelection: false
|
|
95633
|
-
});
|
|
95634
|
-
if (!isHumanProfile(humanProfile)) throw new Error("ATS Web local-agent preparation requires a valid human profile.");
|
|
95635
|
-
const foundation = await buildCliStartFoundation({
|
|
95636
|
-
localAgentPreparation: {
|
|
95637
|
-
mode: "unresolved",
|
|
95638
|
-
localAgentIds: []
|
|
95639
|
-
},
|
|
95640
|
-
baseUrl: gatewayUrl,
|
|
95641
|
-
profile: humanProfile,
|
|
95642
|
-
readiness: await collectStartReadinessSnapshot({ auth: {
|
|
95643
|
-
status: "valid",
|
|
95644
|
-
email: authentication.email,
|
|
95645
|
-
authBaseUrl: authentication.authBaseUrl,
|
|
95646
|
-
gatewayUrl
|
|
95647
|
-
} })
|
|
95648
|
-
});
|
|
95649
|
-
const deviceProjection = readCliStartDeviceProjection(foundation).value;
|
|
95650
|
-
if (!deviceProjection) throw new Error("ATS could not determine this computer yet. Finish local ATS setup on this computer, then try again.");
|
|
95651
|
-
await syncStandaloneStartCurrentDeviceTarget({
|
|
95652
|
-
foundation,
|
|
95653
|
-
gatewayUrl
|
|
95654
|
-
});
|
|
95655
|
-
await runStartHandoff({
|
|
95656
|
-
startSession: (await createStartApi(createCliApiClientFoundation(gatewayUrl)).createSession({
|
|
95657
|
-
deviceId: deviceProjection.deviceId,
|
|
95658
|
-
initiator: "web_handoff",
|
|
95659
|
-
profileChoice: {
|
|
95660
|
-
mode: "select_existing",
|
|
95661
|
-
profileId: humanProfile.atsProfileId
|
|
95662
|
-
},
|
|
95663
|
-
localAgentPreparation: {
|
|
95664
|
-
mode: "unresolved",
|
|
95665
|
-
localAgentIds: []
|
|
95666
|
-
},
|
|
95667
|
-
spaceChoice: {
|
|
95668
|
-
mode: "unresolved",
|
|
95669
|
-
spaceId: null
|
|
95670
|
-
},
|
|
95671
|
-
spaceMemberSelection: {
|
|
95672
|
-
mode: "unresolved",
|
|
95673
|
-
selectedProfileIds: []
|
|
95674
|
-
}
|
|
95675
|
-
})).opaqueToken,
|
|
95676
|
-
runtime: input.runtime,
|
|
95677
|
-
presenter: input.presenter,
|
|
95678
|
-
interactive: input.interactive,
|
|
95679
|
-
view: input.view
|
|
95680
|
-
});
|
|
95681
|
-
}
|
|
95682
|
-
async function stopServiceForResetThisComputer(input) {
|
|
95683
|
-
console.info("[ats.reset_this_computer.service_stop_started]", { event: "cli.reset_this_computer.service_stop_started" });
|
|
95684
|
-
try {
|
|
95685
|
-
const stopResult = await runDaemonStop({
|
|
95686
|
-
agentOverviewHandled: true,
|
|
95687
|
-
force: false,
|
|
95688
|
-
view: input.view
|
|
95689
|
-
});
|
|
95690
|
-
if (stopResult.status === "cancelled") throw new Error("ATS Service stop was cancelled.");
|
|
95691
|
-
if (stopResult.status === "warning") throw new Error(`ATS Service stop did not finish cleanly: ${stopResult.errorMessage ?? stopResult.reason}`);
|
|
95692
|
-
console.info("[ats.reset_this_computer.service_stop_completed]", {
|
|
95693
|
-
event: "cli.reset_this_computer.service_stop_completed",
|
|
95694
|
-
status: stopResult.status
|
|
95695
|
-
});
|
|
95696
|
-
} catch (error) {
|
|
95697
|
-
console.warn("[ats.reset_this_computer.service_stop_failed]", {
|
|
95698
|
-
event: "cli.reset_this_computer.service_stop_failed",
|
|
95699
|
-
error: error instanceof Error ? error.message : String(error)
|
|
95700
|
-
});
|
|
95701
|
-
throw error;
|
|
95702
|
-
}
|
|
95703
|
-
}
|
|
95704
93446
|
async function maybeCompleteServiceReadinessAfterPreparation(input) {
|
|
95705
93447
|
if (!input.interactive || input.runtime.resolvedView !== "human") return;
|
|
95706
93448
|
const reasonCodes = collectReadinessReasonCodes(await resolveCurrentReplyReadinessSnapshot({
|
|
@@ -100821,7 +98563,7 @@ withStartOptions(program.command("start").description("Initial onboarding: set u
|
|
|
100821
98563
|
}
|
|
100822
98564
|
});
|
|
100823
98565
|
});
|
|
100824
|
-
program.command("setup").description("Set up this computer for ATS Space Wake.").option("--profile <id>", "Existing ATS agent profile ID to connect to this computer").option("--agent <id...>", "Builtin local agent ID to repair directly when you already know the target").option("--human-profile <id>", "ATS
|
|
98566
|
+
program.command("setup").description("Set up this computer for ATS Space Wake.").option("--profile <id>", "Existing ATS agent profile ID to connect to this computer").option("--agent <id...>", "Builtin local agent ID to repair directly when you already know the target").option("--human-profile <id>", "Retired ATS Web setup flag; copy a fresh setup command from ATS Web instead").option("--ott <token>", "One-time token to sign in on this device before setup").option("--start-session <opaque-token>", "Continue an ATS Web Prepare setup command on this device").option("--local-agents <mode>", "Select local agents during setup: all or none").option("--local-agent <id...>", "Select specific local agent IDs during setup").option("--reset-this-computer", "Stop stale local ATS Service state before reconnecting this computer").addHelpText("after", buildCommandHelpExamples("Primary entry points", [
|
|
100825
98567
|
"ats setup",
|
|
100826
98568
|
"ats setup --start-session <opaque-token> --local-agents all",
|
|
100827
98569
|
"ats setup --profile <agent-profile-id> --local-agent <local-agent-id>"
|
|
@@ -102699,5 +100441,5 @@ main().catch((error) => {
|
|
|
102699
100441
|
});
|
|
102700
100442
|
|
|
102701
100443
|
//#endregion
|
|
102702
|
-
export {
|
|
100444
|
+
export { toStructuredApiClientFailure as A, createRuntimeReportingApi as C, publicSpaceUrls as D, normalizeApiBaseUrl as E, getCurrentAuthOwnerUserId as F, setAuthSession as I, getAuthSession as M, getAuthSessionMetadata as N, resolveAccountSpaceIndexGatewayHost as O, getAuthSessionState as P, createProfileSpaceHistoryApi as S, getModelCatalog as T, createConfigApi as _, createCliApiClientFoundation as a, createLocalRuntimeExpectedRoutesApi as b, buildAccountSpaceIndexPath as c, buildProfileSpaceHistoryStatusPath as d, buildProfileSpaceHistoryUpsertPath as f, createAtsApiClient as g, createAgentProfileBindingApi as h, writeDaemonRuntimeLease as i, clearAuthSession as j, resolveProfileSpaceHistoryGatewayHost as k, buildModelCatalogPath as l, createAccountSpaceIndexApi as m, daemonRuntimeLeasePath as n, AtsApiClientHttpError as o, buildSpaceBootstrapReadPath as p, readDaemonRuntimeLease as r, AtsApiClientInvalidResponseError as s, clearDaemonRuntimeLease as t, buildProfileSpaceHistoryListPath as u, createCurrentDeviceApi as v, createSpaceApi as w, createPrepareReadinessApi as x, createFetchTransport as y };
|
|
102703
100445
|
//# sourceMappingURL=ats.js.map
|