agent-transport-system 0.7.17 → 0.7.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ats-dev.js +2 -2
- package/dist/ats.js +160 -15
- package/dist/ats.js.map +1 -1
- package/dist/{daemon-runtime-lease-b5ZWtWKt.js → daemon-runtime-lease-Bwn8-GTu.js} +1 -1
- package/dist/{lock-_FpCKRtr.js → lock-CiHfZzrM.js} +53 -9
- package/dist/lock-CiHfZzrM.js.map +1 -0
- package/dist/{runtime-config-Bm9Cq3yW.js → runtime-config-p7Wvlo1Q.js} +2 -2
- package/dist/{runtime-config-Bm9Cq3yW.js.map → runtime-config-p7Wvlo1Q.js.map} +1 -1
- package/package.json +1 -1
- package/dist/lock-_FpCKRtr.js.map +0 -1
package/dist/ats-dev.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import "./lock-
|
|
4
|
-
import { v as DEV_LOCAL_GATEWAY_BASE_URL } from "./runtime-config-
|
|
3
|
+
import "./lock-CiHfZzrM.js";
|
|
4
|
+
import { v as DEV_LOCAL_GATEWAY_BASE_URL } from "./runtime-config-p7Wvlo1Q.js";
|
|
5
5
|
|
|
6
6
|
//#region src/ats-dev.ts
|
|
7
7
|
const LOCAL_GATEWAY_URL = DEV_LOCAL_GATEWAY_BASE_URL;
|
package/dist/ats.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { $ as
|
|
3
|
+
import { $ as formatLocalSetupActionLabel, $n as conversationExecutionStateSchema, $t as signalEnvelopeSchema, A as continuitySchema, An as DAEMON_HUB_SCHEMA_VERSION, At as patchProfileSpaceHistoryStatusResponseSchema, B as daemonRouteCatalogCacheSchema, Bn as SPACE_MENTION_REJECT_NOTICE_PURPOSE, Bt as prepareSessionResponseSchema, C as atsProfileIdSchema, Cn as AGENT_REPLYING_END_PURPOSE, Cr as parseOptionalClientMessageId, Ct as localRuntimesQuerySchema, D as catchupResponseSchema, Dn as ATSD_TASK_RESULT_SCHEMA_VERSION, Dr as resolveSingleSpaceMentionLabels, Dt as notifyAgentProfileRouteCatalogChangedBodySchema, E as atsdControlPlaneResponseSchema, En as AGENT_REPLY_PREVIEW_PURPOSE, Er as resolveMessageEnvelopeTargetField, Et as normalizeSpaceCursorPatch, F as createSpaceThreadBodySchema, Fn as MAX_PROFILE_WORKING_DIRECTORY_LENGTH, Ft as postNormalMessageResponseSchema, G as ensureAgentProfilePrimaryBindingBodySchema, Gn as atsdTaskResultEnvelopeWriteSchema, Gt as querySpaceDeletionTombstonesResponseSchema, H as daemonRuntimeLeaseSchema, Hn as SPACE_UPDATES_MAX_LIMIT, Ht as projectObservabilityWakeCorrelation, I as createSpaceThreadResponseSchema, In as MAX_SIGNAL_REPLY_TO_PREVIEW_LENGTH, It as postSpaceMembersBodySchema, J as forgetComputerResponseSchema, Jn as buildAgentControllerConversationRef, Jt as resolveStartHandoffBodySchema, K as ensureAgentProfilePrimaryBindingResponseSchema, Kn as atsdTaskResultOpenClawGatewayVisibilityStatusSchema, Kt as removeSpaceMembersResponseSchema, L as createStartSessionBodySchema, Ln as MESSAGE_MENTION_TYPE_VALUES, Lt as postSpaceMembersResponseSchema, M as createSpaceDiagnosticReportBodySchema, Mn as DISPATCH_ACTIVITY_FAILED_PURPOSE, Mr as sanitizeSignalTextPreview, Mt as patchSpaceContractResponseSchema, N as createSpaceDiagnosticReportResponseSchema, Nn as DISPATCH_ACTIVITY_RETRYING_PURPOSE, Nt as patchStartSessionBodySchema, O as claimExecutionDiagnosticsQuerySchema, On as CONVERSATION_CONTINUITY_WARNING_PURPOSE, Or as resolveSpaceMentionLabels, Ot as notifyAgentProfileRouteCatalogChangedResponseSchema, P as createSpaceResponseSchema, Pn as LEGACY_RUNTIME_DISPATCH_POLICY, Pt as postNormalMessageBodySchema, Q as formatLocalSetupActionDescription, Qn as collectCanonicalMentionTextFragments, Qt as setLocalRuntimeDisplayNameBodySchema, R as currentDeviceTargetResponseSchema, Rn as SPACE_MEMBER_JOIN_NOTICE_PURPOSE, Rt as postSpaceThreadSignalBodySchema, S as agentProfileBindingRouteParamsSchema, Sn as writeSetupTokenLocalRuntimeObservedMetadataResponseSchema, Sr as parseAgentControllerRef$1, St as listSpaceThreadsResponseSchema, T as atsdControlPlaneRequestSchema, Tn as AGENT_REPLY_PREVIEW_END_PURPOSE, Tr as resolveBuiltinAgentControllerConversationKind, Tt as normalizeListSignalsReadQuerySemantics, U as deleteSpaceResponseSchema, Un as atsRuntimeProfileIdSchema, Ut as projectSpaceDispatchTraceFinalVisibleOutcome, V as daemonRouteObservationResponseSchema, Vn as SPACE_PASSWORD_MIN_LENGTH, Vt as prepareSessionStreamServerFrameSchema, W as dispatchBriefSchema, Wn as atsSpaceEgressActionSchema, Wt as providerDispatchRuntimeContextSchema, X as formatLocalComponentsSummaryDescription, Xn as canonicalizeAgentControllerRef, Xt as serverErrorFrameSchema, Y as forgetCurrentComputerResponseSchema, Yn as buildAgentControllerRoutingKey, Yt as resolveStartHandoffResponseSchema, Z as formatLocalComponentsSummaryLabel, Zn as canonicalizeBuiltinAgentControllerRef, Zt as setCurrentDeviceTargetBodySchema, _ as ATSD_CONTROL_PLANE_SCHEMA_VERSION, _n as upsertProfileSpaceHistoryResponseSchema, _r as normalizeBuiltinAgentControllerId, _t as installedLocalComponentsSnapshotSchema, a as runWithHeldLock, an as startDeviceProjectionSchema, ar as daemonHubDispatchPreviewRequestSchema, at as getAgentProfilePrimaryBindingResponseSchema, b as SPACE_DISPATCH_TRACE_PROMPT_PREVIEW_MAX_CHARS, bn as writeCurrentDeviceObservedMetadataResponseSchema, br as normalizeOptionalWorkingDirectory, bt as listSpaceThreadEventsResponseSchema, c as LEGACY_ATS_CLI_CONTEXT_ENV_KEY, cn as startSessionResponseSchema, cr as daemonHubHeartbeatResponseSchema, ct as getSpaceContractResponseSchema, d as resolveCliContext, dn as startSessionWithTokenResponseSchema, dr as daemonHubRouteCatalogChangedFramePayloadSchema, dt as getSpaceStatusResponseSchema, en as spaceCreatorSchema, er as createDaemonRouteObservationSummary, et as gatewayErrorCodeSchema, f as resolveCliContextId, fn as structuredGuidePayloadFromInputSchema, fr as daemonHubSubmitTaskResultRequestSchema, ft as getSpaceThreadResponseSchema, g as resolveMappedPublicAgentFailureReason, gn as submitRuntimeRegistrationResponseSchema, gr as getSpaceMessageAddressingRelationSupportForTargetKind, gt as incomingServerMessageSchema, h as resolveBuiltinAgentControllerBrand, hn as submitRuntimeRegistrationBodySchema, hr as formatCanonicalMentionLiteral, ht as getSpaceWakeTraceWaterfallResponseSchema, i as releaseLock, in as spaceViewerMembershipResponseSchema, ir as daemonHubDispatchPreviewEndRequestSchema, it as getAgentExecutionReadinessResponseSchema, j as createSpaceBodySchema, jn as DISPATCH_ACTIVITY_DISPATCHING_PURPOSE, jr as runtimeCoordinatorExecutionTokenEnvelopeSchema, jt as patchSpaceContractBodySchema, k as claimExecutionDiagnosticsResponseSchema, kn as CURRENT_DAEMON_EXECUTION_CONTRACT_EPOCH, kt as observabilityWakeTraceSelectorSchema, l as listCliContextStates, ln as startSessionSpaceChoiceBodySchema, lr as daemonHubRegisterSessionRequestSchema, lt as getSpaceDispatchLookupResponseSchema, m as CODEX_UPGRADE_REQUIRED_REASON, mn as submitRuntimeAgentControllerReportsResponseSchema, mr as daemonStreamFrameSchema, mt as getSpaceWakeProgressResponseSchema, n as isAtsLockError, nn as spaceMembersSnapshotSchema, nr as daemonHubDeliveryExecutionIdentitySchema, nt as getAgentExecutionReadinessBatchBodySchema, o as tryCleanupStaleLock, on as startProfileReadinessSummarySchema, or as daemonHubDispatchRuntimeEvidenceRequestSchema, ot as getPrepareReadinessQuerySchema, p as writeCliContextState, pn as submitRuntimeAgentControllerReportsBodySchema, pr as daemonServiceContractSchema, pt as getSpaceUpdatesResponseSchema, q as entryBriefSchema, qn as atsdTaskResultPayloadSchema, qt as resolveSpaceDispatchTraceRootCause, r as readLockMeta, rn as spaceMetaSchema, rr as daemonHubDispatchLifecycleRequestSchema, rt as getAgentExecutionReadinessBatchResponseSchema, s as ATS_CLI_CONTEXT_ENV_KEY, sn as startSessionProgressSchema, sr as daemonHubHeartbeatRequestSchema, st as getPrepareReadinessResponseSchema, t as acquireLock, tn as spaceDispatchTraceResponseSchema, tr as daemonHubDeliverDispatchRequestSchema, tt as gatewayErrorEnvelopeSchema, u as readCliContextState, un as startSessionSpaceChoiceResponseSchema, ur as daemonHubRegisterSessionResponseSchema, ut as getSpaceDispatchResultResponseSchema, v as DAEMON_ROUTE_CATALOG_CACHE_SCHEMA_NAME, vn as upsertSpaceDeletionTombstoneResponseSchema, vr as normalizeKnownBuiltinAgentControllerId, vt as leaveSpaceResponseSchema, w as atsRequestContextSchema, wn as AGENT_REPLYING_PURPOSE, wr as profileWorkspaceModeSchema, wt as localRuntimesResponseSchema, x as agentExecutionReadinessRouteParamsSchema, xn as writeSetupTokenLocalRuntimeObservedMetadataBodySchema, xr as normalizeSpacePasswordText, xt as listSpaceThreadSignalsResponseSchema, y as LOCAL_COMPONENTS_SCHEMA_VERSION, yn as writeCurrentDeviceObservedMetadataBodySchema, yr as normalizeMessageEnvelope, yt as listProfileSpaceHistoryResponseSchema, z as currentLocalRuntimeReplyReadinessResponseSchema, zn as SPACE_MEMBER_REMOVE_NOTICE_PURPOSE, zt as postSpaceThreadSignalResponseSchema } from "./lock-CiHfZzrM.js";
|
|
4
4
|
import { A as runtimeDir, C as normalizeAtsProfileId, D as resolveAtsEnvPreset, E as resolveAtsCliEntryNameFromArgv, F as systemDir, N as skillsDir, O as resolveAtsRootDir, P as spacesDir, S as normalizeAccountKey, T as profileViewPath, a as accountProfileWorkspacePath, c as atsRootDir, d as deviceOpenClawProfileBootstrapPath, f as deviceOpenClawProfileDir, i as accountProfileViewPath, j as runtimeLogsDir, k as resolveDefaultAtsHomeDirname, n as accountProfileLocalMetaPath, o as accountsDir, p as deviceOpenClawProfileWorkspaceDir, r as accountProfileSpaceCacheDir, s as atsBackupsDir, t as ATS_HOME_ENV_KEY, w as profileDir, y as legacyAccountProfileSpacesDir } from "./paths-DFiopT5Y.js";
|
|
5
|
-
import { A as toSpaceCursorUrl, B as toSpaceSignalsUrl, C as resolveDefaultGatewayBaseUrl, D as toDaemonRouteObservationUrl, E as toClaimExecutionDiagnosticsUrl, F as toSpaceMembersUrl, H as toSpaceWsUrl, I as toSpaceMetaUrl, L as toSpacePasswordUrl, M as toSpaceDispatchLookupUrl, N as toSpaceDispatchTraceUrl, O as toSpaceContractUrl, P as toSpaceLeaveUrl, R as toSpaceRemoveMembersUrl, S as resolveBaseUrlOrNull, T as normalizeBaseUrl, V as toSpaceUpdatesUrl, _ as updateConfiguredStartV1OnboardingState, a as getConfiguredDeviceRuntimeState, b as normalizeGatewayBaseUrlOrNull, c as getConfiguredStartV1OnboardingState, d as resolveRuntimeSkillsCustomTargetId, f as setConfiguredBaseUrl, g as updateConfiguredSkillsConfig, h as updateConfiguredOnboardingConfig, i as getConfiguredDaemonDispatchLimits, j as toSpaceDeleteUrl, k as toSpaceCreateUrl, l as getConfiguredViewCustomization, m as updateConfiguredDeviceRuntimeState, n as alignRuntimeConfigStorage, o as getConfiguredOnboardingDisclaimerAcceptedAt, p as setConfiguredSkillsConfig, r as createDefaultRuntimeAgentControllerSettings, s as getConfiguredSkillsConfig, t as DEFAULT_RUNTIME_AGENT_TRANSPORT_MODE, u as getRuntimeConfigReadHealth, w as resolveExplicitGatewayUrlOrThrow, x as resolveBaseUrl, y as normalizeGatewayBaseUrl, z as toSpaceResultUrl } from "./runtime-config-
|
|
5
|
+
import { A as toSpaceCursorUrl, B as toSpaceSignalsUrl, C as resolveDefaultGatewayBaseUrl, D as toDaemonRouteObservationUrl, E as toClaimExecutionDiagnosticsUrl, F as toSpaceMembersUrl, H as toSpaceWsUrl, I as toSpaceMetaUrl, L as toSpacePasswordUrl, M as toSpaceDispatchLookupUrl, N as toSpaceDispatchTraceUrl, O as toSpaceContractUrl, P as toSpaceLeaveUrl, R as toSpaceRemoveMembersUrl, S as resolveBaseUrlOrNull, T as normalizeBaseUrl, V as toSpaceUpdatesUrl, _ as updateConfiguredStartV1OnboardingState, a as getConfiguredDeviceRuntimeState, b as normalizeGatewayBaseUrlOrNull, c as getConfiguredStartV1OnboardingState, d as resolveRuntimeSkillsCustomTargetId, f as setConfiguredBaseUrl, g as updateConfiguredSkillsConfig, h as updateConfiguredOnboardingConfig, i as getConfiguredDaemonDispatchLimits, j as toSpaceDeleteUrl, k as toSpaceCreateUrl, l as getConfiguredViewCustomization, m as updateConfiguredDeviceRuntimeState, n as alignRuntimeConfigStorage, o as getConfiguredOnboardingDisclaimerAcceptedAt, p as setConfiguredSkillsConfig, r as createDefaultRuntimeAgentControllerSettings, s as getConfiguredSkillsConfig, t as DEFAULT_RUNTIME_AGENT_TRANSPORT_MODE, u as getRuntimeConfigReadHealth, w as resolveExplicitGatewayUrlOrThrow, x as resolveBaseUrl, y as normalizeGatewayBaseUrl, z as toSpaceResultUrl } from "./runtime-config-p7Wvlo1Q.js";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
7
7
|
import { Command, Option } from "commander";
|
|
8
8
|
import { accessSync, appendFileSync, chmodSync, constants, existsSync, mkdirSync, readFileSync, realpathSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
@@ -27,7 +27,7 @@ import wrapAnsi from "wrap-ansi";
|
|
|
27
27
|
import { Box, Container, Editor, Key, ProcessTerminal, TUI, Text, getEditorKeybindings, matchesKey } from "@mariozechner/pi-tui";
|
|
28
28
|
|
|
29
29
|
//#region package.json
|
|
30
|
-
var version = "0.7.
|
|
30
|
+
var version = "0.7.18";
|
|
31
31
|
var package_default = {
|
|
32
32
|
$schema: "https://www.schemastore.org/package.json",
|
|
33
33
|
name: "agent-transport-system",
|
|
@@ -4338,7 +4338,7 @@ async function setDaemonServiceRuntimeState(state, pathInput = {}) {
|
|
|
4338
4338
|
await writeDaemonServiceRuntimeState(state, pathInput);
|
|
4339
4339
|
}
|
|
4340
4340
|
async function clearDaemonServiceRuntimeState(pathInput = {}) {
|
|
4341
|
-
const { clearDaemonRuntimeLease } = await import("./daemon-runtime-lease-
|
|
4341
|
+
const { clearDaemonRuntimeLease } = await import("./daemon-runtime-lease-Bwn8-GTu.js");
|
|
4342
4342
|
await Promise.all([rm(daemonServiceRuntimeStatePath(pathInput), { force: true }), clearDaemonRuntimeLease(pathInput)]);
|
|
4343
4343
|
}
|
|
4344
4344
|
async function withDaemonServiceRunLock(callback, meta = {
|
|
@@ -23364,7 +23364,15 @@ function createMutableRouteCatalogState(routeCatalog) {
|
|
|
23364
23364
|
return {
|
|
23365
23365
|
fingerprint: buildRouteCatalogFingerprint(routeCatalog),
|
|
23366
23366
|
profileIds: [...routeCatalog.profileIds],
|
|
23367
|
-
routeByProfileId: new Map(routeCatalog.routeByProfileId)
|
|
23367
|
+
routeByProfileId: new Map(routeCatalog.routeByProfileId),
|
|
23368
|
+
skippedProfiles: [...routeCatalog.skippedProfiles]
|
|
23369
|
+
};
|
|
23370
|
+
}
|
|
23371
|
+
function createRouteCatalogFromMutableState(state) {
|
|
23372
|
+
return {
|
|
23373
|
+
profileIds: [...state.profileIds],
|
|
23374
|
+
routeByProfileId: new Map(state.routeByProfileId),
|
|
23375
|
+
skippedProfiles: [...state.skippedProfiles]
|
|
23368
23376
|
};
|
|
23369
23377
|
}
|
|
23370
23378
|
async function syncDaemonRouteCatalogState(input) {
|
|
@@ -23401,12 +23409,14 @@ async function syncDaemonRouteCatalogState(input) {
|
|
|
23401
23409
|
});
|
|
23402
23410
|
input.catalogState.profileIds = [...nextCatalog.profileIds];
|
|
23403
23411
|
input.catalogState.fingerprint = nextFingerprint;
|
|
23412
|
+
input.catalogState.skippedProfiles = [...nextCatalog.skippedProfiles];
|
|
23404
23413
|
return {
|
|
23405
23414
|
registerResponse,
|
|
23406
23415
|
skippedProfiles: nextCatalog.skippedProfiles,
|
|
23407
23416
|
status: "registered"
|
|
23408
23417
|
};
|
|
23409
23418
|
}
|
|
23419
|
+
input.catalogState.skippedProfiles = [...nextCatalog.skippedProfiles];
|
|
23410
23420
|
return {
|
|
23411
23421
|
skippedProfiles: nextCatalog.skippedProfiles,
|
|
23412
23422
|
status: "unchanged"
|
|
@@ -23436,6 +23446,7 @@ async function syncDaemonRouteCatalogState(input) {
|
|
|
23436
23446
|
});
|
|
23437
23447
|
input.catalogState.profileIds = [...nextCatalog.profileIds];
|
|
23438
23448
|
input.catalogState.fingerprint = nextFingerprint;
|
|
23449
|
+
input.catalogState.skippedProfiles = [...nextCatalog.skippedProfiles];
|
|
23439
23450
|
return {
|
|
23440
23451
|
status: "changed",
|
|
23441
23452
|
diff,
|
|
@@ -43432,7 +43443,11 @@ async function runDaemonSocketSession(input) {
|
|
|
43432
43443
|
}
|
|
43433
43444
|
});
|
|
43434
43445
|
};
|
|
43435
|
-
const
|
|
43446
|
+
const persistAcceptedRouteCatalogCache = async () => {
|
|
43447
|
+
if (!input.persistRouteCatalogCache) return;
|
|
43448
|
+
await input.persistRouteCatalogCache(createRouteCatalogFromMutableState(input.routeCatalogState));
|
|
43449
|
+
};
|
|
43450
|
+
const handleChangedCatalogSync = async (syncResult, inputSync) => {
|
|
43436
43451
|
latestCatalogSyncStatus = "changed";
|
|
43437
43452
|
const rejectedProfileIds = syncResult.registerResponse.rejectedProfiles.map((item) => item.profileId);
|
|
43438
43453
|
emitRunLine({
|
|
@@ -43450,7 +43465,10 @@ async function runDaemonSocketSession(input) {
|
|
|
43450
43465
|
reason: "register_conflict",
|
|
43451
43466
|
scheduleReason: "register_conflict"
|
|
43452
43467
|
});
|
|
43453
|
-
else
|
|
43468
|
+
else {
|
|
43469
|
+
await persistAcceptedRouteCatalogCache();
|
|
43470
|
+
scheduleNextCatalogSync();
|
|
43471
|
+
}
|
|
43454
43472
|
if (input.routeCatalogState.profileIds.length > 0) {
|
|
43455
43473
|
resetWaitingForProfilesTracking();
|
|
43456
43474
|
return;
|
|
@@ -43464,7 +43482,7 @@ async function runDaemonSocketSession(input) {
|
|
|
43464
43482
|
});
|
|
43465
43483
|
hasLoggedWaitingForProfiles = true;
|
|
43466
43484
|
};
|
|
43467
|
-
const handleRegisteredCatalogSync = (syncResult, inputSync) => {
|
|
43485
|
+
const handleRegisteredCatalogSync = async (syncResult, inputSync) => {
|
|
43468
43486
|
latestCatalogSyncStatus = "registered";
|
|
43469
43487
|
const rejectedProfileIds = syncResult.registerResponse.rejectedProfiles.map((item) => item.profileId);
|
|
43470
43488
|
emitRunLine({
|
|
@@ -43485,6 +43503,7 @@ async function runDaemonSocketSession(input) {
|
|
|
43485
43503
|
return;
|
|
43486
43504
|
}
|
|
43487
43505
|
if (input.routeCatalogState.profileIds.length > 0) resetWaitingForProfilesTracking();
|
|
43506
|
+
await persistAcceptedRouteCatalogCache();
|
|
43488
43507
|
scheduleNextCatalogSync();
|
|
43489
43508
|
};
|
|
43490
43509
|
const handleUnchangedCatalogSync = (syncResult, inputSync) => {
|
|
@@ -43515,7 +43534,7 @@ async function runDaemonSocketSession(input) {
|
|
|
43515
43534
|
leasesByProfileId,
|
|
43516
43535
|
loadCatalog: async () => await loadDaemonRouteCatalog({
|
|
43517
43536
|
localAdapterContainer: input.localAdapterContainer,
|
|
43518
|
-
localReplyStateMode: "
|
|
43537
|
+
localReplyStateMode: "check",
|
|
43519
43538
|
ownerUserId: input.ownerUserId,
|
|
43520
43539
|
presenter: input.presenter,
|
|
43521
43540
|
allowEmpty: true,
|
|
@@ -43524,12 +43543,12 @@ async function runDaemonSocketSession(input) {
|
|
|
43524
43543
|
registerCatalog: registerDaemonSession
|
|
43525
43544
|
});
|
|
43526
43545
|
if (syncResult.status === "changed") {
|
|
43527
|
-
handleChangedCatalogSync(syncResult, inputSync);
|
|
43546
|
+
await handleChangedCatalogSync(syncResult, inputSync);
|
|
43528
43547
|
resolvePendingRouteCatalogSyncRequests(syncResult);
|
|
43529
43548
|
return;
|
|
43530
43549
|
}
|
|
43531
43550
|
if (syncResult.status === "registered") {
|
|
43532
|
-
handleRegisteredCatalogSync(syncResult, inputSync);
|
|
43551
|
+
await handleRegisteredCatalogSync(syncResult, inputSync);
|
|
43533
43552
|
resolvePendingRouteCatalogSyncRequests(syncResult);
|
|
43534
43553
|
return;
|
|
43535
43554
|
}
|
|
@@ -43697,7 +43716,10 @@ async function runDaemonSocketSession(input) {
|
|
|
43697
43716
|
reason: "register_conflict",
|
|
43698
43717
|
scheduleReason: "register_conflict"
|
|
43699
43718
|
});
|
|
43700
|
-
else
|
|
43719
|
+
else {
|
|
43720
|
+
await persistAcceptedRouteCatalogCache();
|
|
43721
|
+
scheduleCatalogSyncNext(resolveCatalogSyncIntervalMs({ heartbeatIntervalMs: currentHeartbeatIntervalMs }));
|
|
43722
|
+
}
|
|
43701
43723
|
latestCatalogSyncSignalUpdatedAtMs = (await readDaemonCatalogSyncSignal().catch(() => null))?.updatedAtMs ?? 0;
|
|
43702
43724
|
scheduleCatalogSyncSignalPoll();
|
|
43703
43725
|
await sendHeartbeat();
|
|
@@ -43900,6 +43922,83 @@ function createDaemonRuntimeState(input) {
|
|
|
43900
43922
|
};
|
|
43901
43923
|
}
|
|
43902
43924
|
|
|
43925
|
+
//#endregion
|
|
43926
|
+
//#region src/daemon/state/route-catalog-cache.ts
|
|
43927
|
+
const ROUTE_CATALOG_CACHE_FILE = "route-catalog-cache.json";
|
|
43928
|
+
async function readDaemonRouteCatalogCache(input) {
|
|
43929
|
+
const serviceBundleId = normalizeServiceBundleId(input.serviceBundleId);
|
|
43930
|
+
if (!serviceBundleId) return null;
|
|
43931
|
+
const cached = await readDaemonLocalStateFile({
|
|
43932
|
+
path: daemonRouteCatalogCachePath(),
|
|
43933
|
+
schema: daemonRouteCatalogCacheSchema
|
|
43934
|
+
});
|
|
43935
|
+
if (!cached || cached.serviceBundleId !== serviceBundleId) return null;
|
|
43936
|
+
return deserializeRouteCatalog(cached);
|
|
43937
|
+
}
|
|
43938
|
+
async function writeDaemonRouteCatalogCache(input) {
|
|
43939
|
+
const serviceBundleId = normalizeServiceBundleId(input.serviceBundleId);
|
|
43940
|
+
if (!serviceBundleId) return;
|
|
43941
|
+
if (input.routeCatalog.profileIds.length === 0) {
|
|
43942
|
+
await clearDaemonRouteCatalogCache();
|
|
43943
|
+
return;
|
|
43944
|
+
}
|
|
43945
|
+
const value = {
|
|
43946
|
+
v: 1,
|
|
43947
|
+
schema: DAEMON_ROUTE_CATALOG_CACHE_SCHEMA_NAME,
|
|
43948
|
+
cachedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
43949
|
+
runtimeContractEpoch: CURRENT_DAEMON_EXECUTION_CONTRACT_EPOCH,
|
|
43950
|
+
serviceBundleId,
|
|
43951
|
+
profileIds: [...input.routeCatalog.profileIds],
|
|
43952
|
+
routes: input.routeCatalog.profileIds.map((profileId) => {
|
|
43953
|
+
const route = input.routeCatalog.routeByProfileId.get(profileId);
|
|
43954
|
+
if (!route) throw new Error(`route catalog is missing route for ${profileId}`);
|
|
43955
|
+
return serializeRouteConfig(route);
|
|
43956
|
+
}),
|
|
43957
|
+
skippedProfiles: [...input.routeCatalog.skippedProfiles]
|
|
43958
|
+
};
|
|
43959
|
+
await writeDaemonLocalStateFile({
|
|
43960
|
+
path: daemonRouteCatalogCachePath(),
|
|
43961
|
+
schema: daemonRouteCatalogCacheSchema,
|
|
43962
|
+
value,
|
|
43963
|
+
mode: 384
|
|
43964
|
+
});
|
|
43965
|
+
}
|
|
43966
|
+
async function clearDaemonRouteCatalogCache() {
|
|
43967
|
+
await rm(daemonRouteCatalogCachePath(), { force: true });
|
|
43968
|
+
}
|
|
43969
|
+
function daemonRouteCatalogCachePath() {
|
|
43970
|
+
return join(daemonRuntimeDataPath(), ROUTE_CATALOG_CACHE_FILE);
|
|
43971
|
+
}
|
|
43972
|
+
function normalizeServiceBundleId(value) {
|
|
43973
|
+
return String(value ?? "").trim();
|
|
43974
|
+
}
|
|
43975
|
+
function serializeRouteConfig(route) {
|
|
43976
|
+
return {
|
|
43977
|
+
agentControllerRef: route.agentControllerRef,
|
|
43978
|
+
contextIdMappingSpec: route.contextIdMappingSpec,
|
|
43979
|
+
...route.launchContract ? { launchContract: route.launchContract } : {},
|
|
43980
|
+
profileId: route.profileId,
|
|
43981
|
+
streamingMode: route.streamingMode,
|
|
43982
|
+
transportMode: route.transportMode
|
|
43983
|
+
};
|
|
43984
|
+
}
|
|
43985
|
+
function deserializeRouteCatalog(cache) {
|
|
43986
|
+
const routeByProfileId = /* @__PURE__ */ new Map();
|
|
43987
|
+
for (const route of cache.routes) routeByProfileId.set(route.profileId, {
|
|
43988
|
+
agentControllerRef: route.agentControllerRef,
|
|
43989
|
+
contextIdMappingSpec: route.contextIdMappingSpec,
|
|
43990
|
+
...route.launchContract ? { launchContract: route.launchContract } : {},
|
|
43991
|
+
profileId: route.profileId,
|
|
43992
|
+
streamingMode: route.streamingMode,
|
|
43993
|
+
transportMode: route.transportMode
|
|
43994
|
+
});
|
|
43995
|
+
return {
|
|
43996
|
+
profileIds: [...cache.profileIds],
|
|
43997
|
+
routeByProfileId,
|
|
43998
|
+
skippedProfiles: [...cache.skippedProfiles]
|
|
43999
|
+
};
|
|
44000
|
+
}
|
|
44001
|
+
|
|
43903
44002
|
//#endregion
|
|
43904
44003
|
//#region src/daemon/state/runtime-state-tracker.ts
|
|
43905
44004
|
function createDaemonRuntimeStateTracker(input) {
|
|
@@ -44074,12 +44173,13 @@ const runDaemonServiceLoop = async (input) => {
|
|
|
44074
44173
|
code: "daemon.run.adapter_missing",
|
|
44075
44174
|
message: "no local adapters configured for daemon runtime"
|
|
44076
44175
|
});
|
|
44077
|
-
const
|
|
44176
|
+
const serviceBundleId = daemonServiceContract?.bundleId ?? null;
|
|
44177
|
+
const routeCatalog = await loadInitialDaemonRouteCatalog({
|
|
44178
|
+
allowEmpty: true,
|
|
44078
44179
|
localAdapterContainer,
|
|
44079
|
-
localReplyStateMode: "repair",
|
|
44080
44180
|
ownerUserId,
|
|
44081
44181
|
presenter: input.presenter,
|
|
44082
|
-
|
|
44182
|
+
serviceBundleId
|
|
44083
44183
|
});
|
|
44084
44184
|
const routeCatalogState = createMutableRouteCatalogState(routeCatalog);
|
|
44085
44185
|
let stopRequested = false;
|
|
@@ -44217,6 +44317,13 @@ const runDaemonServiceLoop = async (input) => {
|
|
|
44217
44317
|
ownerUserId,
|
|
44218
44318
|
profileOwnerName,
|
|
44219
44319
|
presenter: input.presenter,
|
|
44320
|
+
persistRouteCatalogCache: async (catalog) => {
|
|
44321
|
+
await persistDaemonRouteCatalogCache({
|
|
44322
|
+
presenter: input.presenter,
|
|
44323
|
+
routeCatalog: catalog,
|
|
44324
|
+
serviceBundleId
|
|
44325
|
+
});
|
|
44326
|
+
},
|
|
44220
44327
|
reconnectAttempt,
|
|
44221
44328
|
routeCatalogState,
|
|
44222
44329
|
socket: ws,
|
|
@@ -44286,6 +44393,44 @@ const runDaemonServiceLoop = async (input) => {
|
|
|
44286
44393
|
text: "daemon service loop stopped"
|
|
44287
44394
|
});
|
|
44288
44395
|
};
|
|
44396
|
+
async function loadInitialDaemonRouteCatalog(input) {
|
|
44397
|
+
try {
|
|
44398
|
+
return await loadDaemonRouteCatalog({
|
|
44399
|
+
allowEmpty: input.allowEmpty,
|
|
44400
|
+
localAdapterContainer: input.localAdapterContainer,
|
|
44401
|
+
localReplyStateMode: "repair",
|
|
44402
|
+
ownerUserId: input.ownerUserId,
|
|
44403
|
+
presenter: input.presenter
|
|
44404
|
+
});
|
|
44405
|
+
} catch (error) {
|
|
44406
|
+
const cached = await readDaemonRouteCatalogCache({ serviceBundleId: input.serviceBundleId });
|
|
44407
|
+
if (!cached) throw error;
|
|
44408
|
+
emitRunLine({
|
|
44409
|
+
presenter: input.presenter,
|
|
44410
|
+
code: "daemon.run.route_catalog_cache_recovered",
|
|
44411
|
+
text: `using last known route catalog after initial catalog load failed: ${toErrorMessage$34(error)}`,
|
|
44412
|
+
payload: {
|
|
44413
|
+
profileIds: cached.profileIds,
|
|
44414
|
+
reason: "initial_load_failed"
|
|
44415
|
+
}
|
|
44416
|
+
});
|
|
44417
|
+
return cached;
|
|
44418
|
+
}
|
|
44419
|
+
}
|
|
44420
|
+
async function persistDaemonRouteCatalogCache(input) {
|
|
44421
|
+
try {
|
|
44422
|
+
await writeDaemonRouteCatalogCache({
|
|
44423
|
+
routeCatalog: input.routeCatalog,
|
|
44424
|
+
serviceBundleId: input.serviceBundleId
|
|
44425
|
+
});
|
|
44426
|
+
} catch (error) {
|
|
44427
|
+
emitRunLine({
|
|
44428
|
+
presenter: input.presenter,
|
|
44429
|
+
code: "daemon.run.route_catalog_cache_write_failed",
|
|
44430
|
+
text: `route catalog cache write failed: ${toErrorMessage$34(error)}`
|
|
44431
|
+
});
|
|
44432
|
+
}
|
|
44433
|
+
}
|
|
44289
44434
|
function resolveDaemonServiceLane(contract) {
|
|
44290
44435
|
if (contract?.lane) return contract.lane;
|
|
44291
44436
|
throw new DaemonServiceRunError({
|