agent-transport-system 0.7.17 → 0.7.19
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 +308 -19
- 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.19";
|
|
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,
|
|
@@ -39573,6 +39584,7 @@ function normalizeOptionalText$12(value) {
|
|
|
39573
39584
|
//#region src/daemon/dispatch/execute-dispatch-task.ts
|
|
39574
39585
|
const BOOTSTRAP_IDLE_STALE_MS = 1440 * 60 * 1e3;
|
|
39575
39586
|
const BOOTSTRAP_DISPATCH_STALE_THRESHOLD = 12;
|
|
39587
|
+
const CLI_SPACE_ACTION_RECORD_POLL_INTERVAL_MS = 25;
|
|
39576
39588
|
const DEFAULT_CONVERSATION_POLICY = {};
|
|
39577
39589
|
const STRUCTURED_SPACE_ACTION_BLOCK_HEADER_REGEX = /^\s*\r?\n?/u;
|
|
39578
39590
|
function mergeOpenClawGatewayVisibility(input) {
|
|
@@ -40264,7 +40276,7 @@ async function handleDispatchDeliverFrame(input) {
|
|
|
40264
40276
|
phase: "runtime_invocation_started",
|
|
40265
40277
|
result: "started"
|
|
40266
40278
|
});
|
|
40267
|
-
|
|
40279
|
+
const runtimeExecutionPromise = Promise.resolve(runDispatchRuntimeExecution({
|
|
40268
40280
|
contextId: contextIdForDispatch,
|
|
40269
40281
|
executionMode: "normal",
|
|
40270
40282
|
io: ledgerIo,
|
|
@@ -40345,12 +40357,15 @@ async function handleDispatchDeliverFrame(input) {
|
|
|
40345
40357
|
runtimeEnvOverrides,
|
|
40346
40358
|
runtimeControllerSupport,
|
|
40347
40359
|
agentControllerConversationOverride
|
|
40348
|
-
});
|
|
40349
|
-
runtimeResult =
|
|
40360
|
+
}));
|
|
40361
|
+
let runtimeResult = await resolveRuntimeResultFromRuntimeOrCliSpaceAction({
|
|
40362
|
+
contextIdForDispatch,
|
|
40350
40363
|
dispatchSpaceActionContext,
|
|
40364
|
+
ledgerIo,
|
|
40365
|
+
ledgerPaths: input.ledgerPaths,
|
|
40351
40366
|
parsedTask,
|
|
40352
40367
|
presenter: input.presenter,
|
|
40353
|
-
|
|
40368
|
+
runtimeExecutionPromise
|
|
40354
40369
|
});
|
|
40355
40370
|
const structuredSpaceActionOutcome = await resolveRuntimeResultStructuredSpaceAction({
|
|
40356
40371
|
ledgerIo,
|
|
@@ -40863,6 +40878,146 @@ function createDispatchSpaceActionRuntimeContext(input) {
|
|
|
40863
40878
|
}
|
|
40864
40879
|
};
|
|
40865
40880
|
}
|
|
40881
|
+
async function resolveRuntimeResultFromRuntimeOrCliSpaceAction(input) {
|
|
40882
|
+
if (!input.dispatchSpaceActionContext) return await input.runtimeExecutionPromise;
|
|
40883
|
+
const cliSpaceActionAbortController = new AbortController();
|
|
40884
|
+
let completion;
|
|
40885
|
+
try {
|
|
40886
|
+
completion = await Promise.race([input.runtimeExecutionPromise.then((runtimeResult) => ({
|
|
40887
|
+
kind: "runtime",
|
|
40888
|
+
runtimeResult
|
|
40889
|
+
})), waitForCliSpaceActionRecord({
|
|
40890
|
+
dispatchSpaceActionContext: input.dispatchSpaceActionContext,
|
|
40891
|
+
signal: cliSpaceActionAbortController.signal
|
|
40892
|
+
})]);
|
|
40893
|
+
} finally {
|
|
40894
|
+
cliSpaceActionAbortController.abort();
|
|
40895
|
+
}
|
|
40896
|
+
if (completion.kind === "runtime") return applyCliSpaceActionRecordIfPresent({
|
|
40897
|
+
dispatchSpaceActionContext: input.dispatchSpaceActionContext,
|
|
40898
|
+
parsedTask: input.parsedTask,
|
|
40899
|
+
presenter: input.presenter,
|
|
40900
|
+
runtimeResult: completion.runtimeResult
|
|
40901
|
+
});
|
|
40902
|
+
if (completion.kind === "cli_space_action_poll_aborted") return await input.runtimeExecutionPromise;
|
|
40903
|
+
input.runtimeExecutionPromise.catch((error) => {
|
|
40904
|
+
emitRunLine({
|
|
40905
|
+
presenter: input.presenter,
|
|
40906
|
+
code: "daemon.run.runtime_ignored_after_cli_space_action",
|
|
40907
|
+
text: `runtime completed after CLI ATS Space Action finalized task ${input.parsedTask.taskId}`,
|
|
40908
|
+
payload: {
|
|
40909
|
+
dispatchId: input.parsedTask.dispatchId,
|
|
40910
|
+
errorMessage: toErrorMessage$34(error),
|
|
40911
|
+
targetProfileId: input.parsedTask.targetProfileId,
|
|
40912
|
+
taskId: input.parsedTask.taskId
|
|
40913
|
+
}
|
|
40914
|
+
});
|
|
40915
|
+
});
|
|
40916
|
+
if (completion.kind === "cli_space_action_invalid") throw new DaemonServiceRunError({
|
|
40917
|
+
code: "dispatch.cli_space_action.invalid",
|
|
40918
|
+
message: completion.errorMessage
|
|
40919
|
+
});
|
|
40920
|
+
emitRunLine({
|
|
40921
|
+
presenter: input.presenter,
|
|
40922
|
+
code: "daemon.run.cli_space_action_finalized",
|
|
40923
|
+
text: `CLI ATS Space Action finalized task ${input.parsedTask.taskId}`,
|
|
40924
|
+
payload: {
|
|
40925
|
+
command: completion.record.command,
|
|
40926
|
+
dispatchId: input.parsedTask.dispatchId,
|
|
40927
|
+
spaceActionType: completion.record.action.type,
|
|
40928
|
+
targetProfileId: input.parsedTask.targetProfileId,
|
|
40929
|
+
taskId: input.parsedTask.taskId
|
|
40930
|
+
}
|
|
40931
|
+
});
|
|
40932
|
+
return await buildCliSpaceActionRuntimeResult({
|
|
40933
|
+
contextIdForDispatch: input.contextIdForDispatch,
|
|
40934
|
+
ledgerIo: input.ledgerIo,
|
|
40935
|
+
ledgerPaths: input.ledgerPaths,
|
|
40936
|
+
parsedTask: input.parsedTask,
|
|
40937
|
+
record: completion.record
|
|
40938
|
+
});
|
|
40939
|
+
}
|
|
40940
|
+
async function waitForCliSpaceActionRecord(input) {
|
|
40941
|
+
while (!input.signal.aborted) {
|
|
40942
|
+
const readResult = readDispatchSpaceActionRecord({ context: input.dispatchSpaceActionContext });
|
|
40943
|
+
if (readResult.status === "loaded") return {
|
|
40944
|
+
kind: "cli_space_action_recorded",
|
|
40945
|
+
record: readResult.record
|
|
40946
|
+
};
|
|
40947
|
+
if (readResult.status === "invalid") return {
|
|
40948
|
+
kind: "cli_space_action_invalid",
|
|
40949
|
+
errorMessage: readResult.errorMessage
|
|
40950
|
+
};
|
|
40951
|
+
try {
|
|
40952
|
+
await setTimeout$1(CLI_SPACE_ACTION_RECORD_POLL_INTERVAL_MS, void 0, { signal: input.signal });
|
|
40953
|
+
} catch (error) {
|
|
40954
|
+
if (input.signal.aborted) return { kind: "cli_space_action_poll_aborted" };
|
|
40955
|
+
throw error;
|
|
40956
|
+
}
|
|
40957
|
+
}
|
|
40958
|
+
return { kind: "cli_space_action_poll_aborted" };
|
|
40959
|
+
}
|
|
40960
|
+
async function buildCliSpaceActionRuntimeResult(input) {
|
|
40961
|
+
const output = resolveStructuredActionOutputFallback({
|
|
40962
|
+
action: input.record.action,
|
|
40963
|
+
cleanedOutput: ""
|
|
40964
|
+
});
|
|
40965
|
+
const resultPayload = {
|
|
40966
|
+
...buildTaskResultPayloadFromOutcome({
|
|
40967
|
+
agentId: input.parsedTask.targetProfileId,
|
|
40968
|
+
attemptId: input.parsedTask.attemptId,
|
|
40969
|
+
deduped: false,
|
|
40970
|
+
emitFailed: false,
|
|
40971
|
+
output,
|
|
40972
|
+
sourceEventId: input.parsedTask.sourceEventId,
|
|
40973
|
+
taskId: input.parsedTask.taskId
|
|
40974
|
+
}),
|
|
40975
|
+
spaceAction: input.record.action,
|
|
40976
|
+
spaceActionProvenance: "cli_action"
|
|
40977
|
+
};
|
|
40978
|
+
const state = await withLedgerStateTransaction({
|
|
40979
|
+
invalidStateStrategy: "backup_and_reset",
|
|
40980
|
+
io: input.ledgerIo,
|
|
40981
|
+
mutate: (state) => {
|
|
40982
|
+
const nextState = settleInflightTask({
|
|
40983
|
+
state,
|
|
40984
|
+
taskId: input.parsedTask.taskId
|
|
40985
|
+
});
|
|
40986
|
+
return {
|
|
40987
|
+
nextState,
|
|
40988
|
+
value: nextState
|
|
40989
|
+
};
|
|
40990
|
+
},
|
|
40991
|
+
paths: input.ledgerPaths
|
|
40992
|
+
});
|
|
40993
|
+
await appendLedgerHistoryEntry({
|
|
40994
|
+
entry: {
|
|
40995
|
+
message: "task finalized from CLI Space Action",
|
|
40996
|
+
reasonCode: "task.cli_space_action",
|
|
40997
|
+
status: resultPayload.status,
|
|
40998
|
+
taskId: input.parsedTask.taskId,
|
|
40999
|
+
ts: (/* @__PURE__ */ new Date()).toISOString()
|
|
41000
|
+
},
|
|
41001
|
+
io: input.ledgerIo,
|
|
41002
|
+
paths: input.ledgerPaths
|
|
41003
|
+
});
|
|
41004
|
+
return {
|
|
41005
|
+
agentContextLifecycleCounters: state.agentContextLifecycleCounters,
|
|
41006
|
+
deduped: false,
|
|
41007
|
+
dispatchResult: {
|
|
41008
|
+
adapterResult: {
|
|
41009
|
+
...input.contextIdForDispatch ? { contextDelta: { agentControllerConversationId: input.contextIdForDispatch } } : {},
|
|
41010
|
+
output,
|
|
41011
|
+
status: "success"
|
|
41012
|
+
},
|
|
41013
|
+
dispatched: true,
|
|
41014
|
+
reason: "dispatched"
|
|
41015
|
+
},
|
|
41016
|
+
resultPayload,
|
|
41017
|
+
runtimeState: "idle",
|
|
41018
|
+
state
|
|
41019
|
+
};
|
|
41020
|
+
}
|
|
40866
41021
|
function applyCliSpaceActionRecordIfPresent(input) {
|
|
40867
41022
|
if (!input.dispatchSpaceActionContext) return input.runtimeResult;
|
|
40868
41023
|
const readResult = readDispatchSpaceActionRecord({ context: input.dispatchSpaceActionContext });
|
|
@@ -43432,7 +43587,11 @@ async function runDaemonSocketSession(input) {
|
|
|
43432
43587
|
}
|
|
43433
43588
|
});
|
|
43434
43589
|
};
|
|
43435
|
-
const
|
|
43590
|
+
const persistAcceptedRouteCatalogCache = async () => {
|
|
43591
|
+
if (!input.persistRouteCatalogCache) return;
|
|
43592
|
+
await input.persistRouteCatalogCache(createRouteCatalogFromMutableState(input.routeCatalogState));
|
|
43593
|
+
};
|
|
43594
|
+
const handleChangedCatalogSync = async (syncResult, inputSync) => {
|
|
43436
43595
|
latestCatalogSyncStatus = "changed";
|
|
43437
43596
|
const rejectedProfileIds = syncResult.registerResponse.rejectedProfiles.map((item) => item.profileId);
|
|
43438
43597
|
emitRunLine({
|
|
@@ -43450,7 +43609,10 @@ async function runDaemonSocketSession(input) {
|
|
|
43450
43609
|
reason: "register_conflict",
|
|
43451
43610
|
scheduleReason: "register_conflict"
|
|
43452
43611
|
});
|
|
43453
|
-
else
|
|
43612
|
+
else {
|
|
43613
|
+
await persistAcceptedRouteCatalogCache();
|
|
43614
|
+
scheduleNextCatalogSync();
|
|
43615
|
+
}
|
|
43454
43616
|
if (input.routeCatalogState.profileIds.length > 0) {
|
|
43455
43617
|
resetWaitingForProfilesTracking();
|
|
43456
43618
|
return;
|
|
@@ -43464,7 +43626,7 @@ async function runDaemonSocketSession(input) {
|
|
|
43464
43626
|
});
|
|
43465
43627
|
hasLoggedWaitingForProfiles = true;
|
|
43466
43628
|
};
|
|
43467
|
-
const handleRegisteredCatalogSync = (syncResult, inputSync) => {
|
|
43629
|
+
const handleRegisteredCatalogSync = async (syncResult, inputSync) => {
|
|
43468
43630
|
latestCatalogSyncStatus = "registered";
|
|
43469
43631
|
const rejectedProfileIds = syncResult.registerResponse.rejectedProfiles.map((item) => item.profileId);
|
|
43470
43632
|
emitRunLine({
|
|
@@ -43485,6 +43647,7 @@ async function runDaemonSocketSession(input) {
|
|
|
43485
43647
|
return;
|
|
43486
43648
|
}
|
|
43487
43649
|
if (input.routeCatalogState.profileIds.length > 0) resetWaitingForProfilesTracking();
|
|
43650
|
+
await persistAcceptedRouteCatalogCache();
|
|
43488
43651
|
scheduleNextCatalogSync();
|
|
43489
43652
|
};
|
|
43490
43653
|
const handleUnchangedCatalogSync = (syncResult, inputSync) => {
|
|
@@ -43515,7 +43678,7 @@ async function runDaemonSocketSession(input) {
|
|
|
43515
43678
|
leasesByProfileId,
|
|
43516
43679
|
loadCatalog: async () => await loadDaemonRouteCatalog({
|
|
43517
43680
|
localAdapterContainer: input.localAdapterContainer,
|
|
43518
|
-
localReplyStateMode: "
|
|
43681
|
+
localReplyStateMode: "check",
|
|
43519
43682
|
ownerUserId: input.ownerUserId,
|
|
43520
43683
|
presenter: input.presenter,
|
|
43521
43684
|
allowEmpty: true,
|
|
@@ -43524,12 +43687,12 @@ async function runDaemonSocketSession(input) {
|
|
|
43524
43687
|
registerCatalog: registerDaemonSession
|
|
43525
43688
|
});
|
|
43526
43689
|
if (syncResult.status === "changed") {
|
|
43527
|
-
handleChangedCatalogSync(syncResult, inputSync);
|
|
43690
|
+
await handleChangedCatalogSync(syncResult, inputSync);
|
|
43528
43691
|
resolvePendingRouteCatalogSyncRequests(syncResult);
|
|
43529
43692
|
return;
|
|
43530
43693
|
}
|
|
43531
43694
|
if (syncResult.status === "registered") {
|
|
43532
|
-
handleRegisteredCatalogSync(syncResult, inputSync);
|
|
43695
|
+
await handleRegisteredCatalogSync(syncResult, inputSync);
|
|
43533
43696
|
resolvePendingRouteCatalogSyncRequests(syncResult);
|
|
43534
43697
|
return;
|
|
43535
43698
|
}
|
|
@@ -43697,7 +43860,10 @@ async function runDaemonSocketSession(input) {
|
|
|
43697
43860
|
reason: "register_conflict",
|
|
43698
43861
|
scheduleReason: "register_conflict"
|
|
43699
43862
|
});
|
|
43700
|
-
else
|
|
43863
|
+
else {
|
|
43864
|
+
await persistAcceptedRouteCatalogCache();
|
|
43865
|
+
scheduleCatalogSyncNext(resolveCatalogSyncIntervalMs({ heartbeatIntervalMs: currentHeartbeatIntervalMs }));
|
|
43866
|
+
}
|
|
43701
43867
|
latestCatalogSyncSignalUpdatedAtMs = (await readDaemonCatalogSyncSignal().catch(() => null))?.updatedAtMs ?? 0;
|
|
43702
43868
|
scheduleCatalogSyncSignalPoll();
|
|
43703
43869
|
await sendHeartbeat();
|
|
@@ -43900,6 +44066,83 @@ function createDaemonRuntimeState(input) {
|
|
|
43900
44066
|
};
|
|
43901
44067
|
}
|
|
43902
44068
|
|
|
44069
|
+
//#endregion
|
|
44070
|
+
//#region src/daemon/state/route-catalog-cache.ts
|
|
44071
|
+
const ROUTE_CATALOG_CACHE_FILE = "route-catalog-cache.json";
|
|
44072
|
+
async function readDaemonRouteCatalogCache(input) {
|
|
44073
|
+
const serviceBundleId = normalizeServiceBundleId(input.serviceBundleId);
|
|
44074
|
+
if (!serviceBundleId) return null;
|
|
44075
|
+
const cached = await readDaemonLocalStateFile({
|
|
44076
|
+
path: daemonRouteCatalogCachePath(),
|
|
44077
|
+
schema: daemonRouteCatalogCacheSchema
|
|
44078
|
+
});
|
|
44079
|
+
if (!cached || cached.serviceBundleId !== serviceBundleId) return null;
|
|
44080
|
+
return deserializeRouteCatalog(cached);
|
|
44081
|
+
}
|
|
44082
|
+
async function writeDaemonRouteCatalogCache(input) {
|
|
44083
|
+
const serviceBundleId = normalizeServiceBundleId(input.serviceBundleId);
|
|
44084
|
+
if (!serviceBundleId) return;
|
|
44085
|
+
if (input.routeCatalog.profileIds.length === 0) {
|
|
44086
|
+
await clearDaemonRouteCatalogCache();
|
|
44087
|
+
return;
|
|
44088
|
+
}
|
|
44089
|
+
const value = {
|
|
44090
|
+
v: 1,
|
|
44091
|
+
schema: DAEMON_ROUTE_CATALOG_CACHE_SCHEMA_NAME,
|
|
44092
|
+
cachedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
44093
|
+
runtimeContractEpoch: CURRENT_DAEMON_EXECUTION_CONTRACT_EPOCH,
|
|
44094
|
+
serviceBundleId,
|
|
44095
|
+
profileIds: [...input.routeCatalog.profileIds],
|
|
44096
|
+
routes: input.routeCatalog.profileIds.map((profileId) => {
|
|
44097
|
+
const route = input.routeCatalog.routeByProfileId.get(profileId);
|
|
44098
|
+
if (!route) throw new Error(`route catalog is missing route for ${profileId}`);
|
|
44099
|
+
return serializeRouteConfig(route);
|
|
44100
|
+
}),
|
|
44101
|
+
skippedProfiles: [...input.routeCatalog.skippedProfiles]
|
|
44102
|
+
};
|
|
44103
|
+
await writeDaemonLocalStateFile({
|
|
44104
|
+
path: daemonRouteCatalogCachePath(),
|
|
44105
|
+
schema: daemonRouteCatalogCacheSchema,
|
|
44106
|
+
value,
|
|
44107
|
+
mode: 384
|
|
44108
|
+
});
|
|
44109
|
+
}
|
|
44110
|
+
async function clearDaemonRouteCatalogCache() {
|
|
44111
|
+
await rm(daemonRouteCatalogCachePath(), { force: true });
|
|
44112
|
+
}
|
|
44113
|
+
function daemonRouteCatalogCachePath() {
|
|
44114
|
+
return join(daemonRuntimeDataPath(), ROUTE_CATALOG_CACHE_FILE);
|
|
44115
|
+
}
|
|
44116
|
+
function normalizeServiceBundleId(value) {
|
|
44117
|
+
return String(value ?? "").trim();
|
|
44118
|
+
}
|
|
44119
|
+
function serializeRouteConfig(route) {
|
|
44120
|
+
return {
|
|
44121
|
+
agentControllerRef: route.agentControllerRef,
|
|
44122
|
+
contextIdMappingSpec: route.contextIdMappingSpec,
|
|
44123
|
+
...route.launchContract ? { launchContract: route.launchContract } : {},
|
|
44124
|
+
profileId: route.profileId,
|
|
44125
|
+
streamingMode: route.streamingMode,
|
|
44126
|
+
transportMode: route.transportMode
|
|
44127
|
+
};
|
|
44128
|
+
}
|
|
44129
|
+
function deserializeRouteCatalog(cache) {
|
|
44130
|
+
const routeByProfileId = /* @__PURE__ */ new Map();
|
|
44131
|
+
for (const route of cache.routes) routeByProfileId.set(route.profileId, {
|
|
44132
|
+
agentControllerRef: route.agentControllerRef,
|
|
44133
|
+
contextIdMappingSpec: route.contextIdMappingSpec,
|
|
44134
|
+
...route.launchContract ? { launchContract: route.launchContract } : {},
|
|
44135
|
+
profileId: route.profileId,
|
|
44136
|
+
streamingMode: route.streamingMode,
|
|
44137
|
+
transportMode: route.transportMode
|
|
44138
|
+
});
|
|
44139
|
+
return {
|
|
44140
|
+
profileIds: [...cache.profileIds],
|
|
44141
|
+
routeByProfileId,
|
|
44142
|
+
skippedProfiles: [...cache.skippedProfiles]
|
|
44143
|
+
};
|
|
44144
|
+
}
|
|
44145
|
+
|
|
43903
44146
|
//#endregion
|
|
43904
44147
|
//#region src/daemon/state/runtime-state-tracker.ts
|
|
43905
44148
|
function createDaemonRuntimeStateTracker(input) {
|
|
@@ -44074,12 +44317,13 @@ const runDaemonServiceLoop = async (input) => {
|
|
|
44074
44317
|
code: "daemon.run.adapter_missing",
|
|
44075
44318
|
message: "no local adapters configured for daemon runtime"
|
|
44076
44319
|
});
|
|
44077
|
-
const
|
|
44320
|
+
const serviceBundleId = daemonServiceContract?.bundleId ?? null;
|
|
44321
|
+
const routeCatalog = await loadInitialDaemonRouteCatalog({
|
|
44322
|
+
allowEmpty: true,
|
|
44078
44323
|
localAdapterContainer,
|
|
44079
|
-
localReplyStateMode: "repair",
|
|
44080
44324
|
ownerUserId,
|
|
44081
44325
|
presenter: input.presenter,
|
|
44082
|
-
|
|
44326
|
+
serviceBundleId
|
|
44083
44327
|
});
|
|
44084
44328
|
const routeCatalogState = createMutableRouteCatalogState(routeCatalog);
|
|
44085
44329
|
let stopRequested = false;
|
|
@@ -44217,6 +44461,13 @@ const runDaemonServiceLoop = async (input) => {
|
|
|
44217
44461
|
ownerUserId,
|
|
44218
44462
|
profileOwnerName,
|
|
44219
44463
|
presenter: input.presenter,
|
|
44464
|
+
persistRouteCatalogCache: async (catalog) => {
|
|
44465
|
+
await persistDaemonRouteCatalogCache({
|
|
44466
|
+
presenter: input.presenter,
|
|
44467
|
+
routeCatalog: catalog,
|
|
44468
|
+
serviceBundleId
|
|
44469
|
+
});
|
|
44470
|
+
},
|
|
44220
44471
|
reconnectAttempt,
|
|
44221
44472
|
routeCatalogState,
|
|
44222
44473
|
socket: ws,
|
|
@@ -44286,6 +44537,44 @@ const runDaemonServiceLoop = async (input) => {
|
|
|
44286
44537
|
text: "daemon service loop stopped"
|
|
44287
44538
|
});
|
|
44288
44539
|
};
|
|
44540
|
+
async function loadInitialDaemonRouteCatalog(input) {
|
|
44541
|
+
try {
|
|
44542
|
+
return await loadDaemonRouteCatalog({
|
|
44543
|
+
allowEmpty: input.allowEmpty,
|
|
44544
|
+
localAdapterContainer: input.localAdapterContainer,
|
|
44545
|
+
localReplyStateMode: "repair",
|
|
44546
|
+
ownerUserId: input.ownerUserId,
|
|
44547
|
+
presenter: input.presenter
|
|
44548
|
+
});
|
|
44549
|
+
} catch (error) {
|
|
44550
|
+
const cached = await readDaemonRouteCatalogCache({ serviceBundleId: input.serviceBundleId });
|
|
44551
|
+
if (!cached) throw error;
|
|
44552
|
+
emitRunLine({
|
|
44553
|
+
presenter: input.presenter,
|
|
44554
|
+
code: "daemon.run.route_catalog_cache_recovered",
|
|
44555
|
+
text: `using last known route catalog after initial catalog load failed: ${toErrorMessage$34(error)}`,
|
|
44556
|
+
payload: {
|
|
44557
|
+
profileIds: cached.profileIds,
|
|
44558
|
+
reason: "initial_load_failed"
|
|
44559
|
+
}
|
|
44560
|
+
});
|
|
44561
|
+
return cached;
|
|
44562
|
+
}
|
|
44563
|
+
}
|
|
44564
|
+
async function persistDaemonRouteCatalogCache(input) {
|
|
44565
|
+
try {
|
|
44566
|
+
await writeDaemonRouteCatalogCache({
|
|
44567
|
+
routeCatalog: input.routeCatalog,
|
|
44568
|
+
serviceBundleId: input.serviceBundleId
|
|
44569
|
+
});
|
|
44570
|
+
} catch (error) {
|
|
44571
|
+
emitRunLine({
|
|
44572
|
+
presenter: input.presenter,
|
|
44573
|
+
code: "daemon.run.route_catalog_cache_write_failed",
|
|
44574
|
+
text: `route catalog cache write failed: ${toErrorMessage$34(error)}`
|
|
44575
|
+
});
|
|
44576
|
+
}
|
|
44577
|
+
}
|
|
44289
44578
|
function resolveDaemonServiceLane(contract) {
|
|
44290
44579
|
if (contract?.lane) return contract.lane;
|
|
44291
44580
|
throw new DaemonServiceRunError({
|