openmeld 0.3.263 → 0.3.264
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/{add-me-membership-C_t_Mg-Z.js → add-me-membership-EPcbBXio.js} +2 -2
- package/dist/{add-me-membership-C_t_Mg-Z.js.map → add-me-membership-EPcbBXio.js.map} +1 -1
- package/dist/{agents-DFHWtOt8.js → agents-c6vjR3-E.js} +13 -13
- package/dist/{agents-DFHWtOt8.js.map → agents-c6vjR3-E.js.map} +1 -1
- package/dist/{api-client-foundation-BPJBWsRD.js → api-client-foundation-BqzfXt-g.js} +1 -1
- package/dist/{api-client-foundation-6MeNwklv.js → api-client-foundation-a7D_P57X.js} +4 -4
- package/dist/{api-client-foundation-6MeNwklv.js.map → api-client-foundation-a7D_P57X.js.map} +1 -1
- package/dist/{auth-session-B0J2UwSR.js → auth-session-BpRplB8x.js} +7 -7
- package/dist/auth-session-BpRplB8x.js.map +1 -0
- package/dist/auth-session-D2gF0lru.js +4 -0
- package/dist/{auth-url-BheLcWg9.js → auth-url-0Y8BrR9l.js} +2 -2
- package/dist/{auth-url-BheLcWg9.js.map → auth-url-0Y8BrR9l.js.map} +1 -1
- package/dist/{base-url-D84aBKXK.js → base-url-B7zX2h2d.js} +1 -1
- package/dist/{base-url-CLMqlF1w.js → base-url-Cno_Uo8f.js} +3 -3
- package/dist/{base-url-CLMqlF1w.js.map → base-url-Cno_Uo8f.js.map} +1 -1
- package/dist/{channel-7iF6DSp4.js → channel-D-a2qCEW.js} +2 -2
- package/dist/{channel-7iF6DSp4.js.map → channel-D-a2qCEW.js.map} +1 -1
- package/dist/{cloud-computer-BddlwRAk.js → cloud-computer-CSK4RYD2.js} +6 -6
- package/dist/{cloud-computer-BddlwRAk.js.map → cloud-computer-CSK4RYD2.js.map} +1 -1
- package/dist/{command-7ZoDO_Hy.js → command-pywjcxYD.js} +17 -17
- package/dist/{command-7ZoDO_Hy.js.map → command-pywjcxYD.js.map} +1 -1
- package/dist/{computer-connection-review-vYYCtG_l.js → computer-connection-review-BDhdk1ne.js} +8 -8
- package/dist/computer-connection-review-BDhdk1ne.js.map +1 -0
- package/dist/{computer-disconnect-C0n2IGfR.js → computer-disconnect-Bu5HPoJH.js} +9 -9
- package/dist/{computer-disconnect-C0n2IGfR.js.map → computer-disconnect-Bu5HPoJH.js.map} +1 -1
- package/dist/{computer-setup-continuation-DiT88kEQ.js → computer-setup-continuation-DDx2bdZv.js} +3 -3
- package/dist/{computer-setup-continuation-DiT88kEQ.js.map → computer-setup-continuation-DDx2bdZv.js.map} +1 -1
- package/dist/{context-DFf16i-C.js → context-NLQSSnf9.js} +7 -7
- package/dist/{context-DFf16i-C.js.map → context-NLQSSnf9.js.map} +1 -1
- package/dist/{daemon-device-id-C3UTBv9T.js → daemon-device-id-Dd-E5NjT.js} +4 -4
- package/dist/{daemon-device-id-C3UTBv9T.js.map → daemon-device-id-Dd-E5NjT.js.map} +1 -1
- package/dist/{daemon-lifecycle-journal-DoAQ-E6K.js → daemon-lifecycle-journal-DfYlngmT.js} +7 -9
- package/dist/daemon-lifecycle-journal-DfYlngmT.js.map +1 -0
- package/dist/{daemon-runtime-lease-D5f4zLXB.js → daemon-runtime-lease-Bu1vPY5k.js} +3 -3
- package/dist/{daemon-runtime-lease-D5f4zLXB.js.map → daemon-runtime-lease-Bu1vPY5k.js.map} +1 -1
- package/dist/{daemon-runtime-lease-CACGRuZ3.js → daemon-runtime-lease-DJx3N2Sa.js} +1 -1
- package/dist/{daemon-service-contract-D9gUVdhc.js → daemon-service-contract-D9Gs4YVs.js} +31 -5
- package/dist/daemon-service-contract-D9Gs4YVs.js.map +1 -0
- package/dist/{daemon-service-manager-BDIsfrfx.js → daemon-service-manager-ChWTp6s8.js} +5 -5
- package/dist/{daemon-service-manager-BDIsfrfx.js.map → daemon-service-manager-ChWTp6s8.js.map} +1 -1
- package/dist/{daemon-service-manager-k9IJJuqv.js → daemon-service-manager-Df537dYj.js} +1 -1
- package/dist/{daemon-service-runtime-LFoUNQQu.js → daemon-service-runtime-Dk8OyRtf.js} +14 -14
- package/dist/{daemon-service-runtime-LFoUNQQu.js.map → daemon-service-runtime-Dk8OyRtf.js.map} +1 -1
- package/dist/{daemon-service-update-coordinator-4WJr8-5_.js → daemon-service-update-coordinator-CyvjkmsR.js} +21 -21
- package/dist/{daemon-service-update-coordinator-4WJr8-5_.js.map → daemon-service-update-coordinator-CyvjkmsR.js.map} +1 -1
- package/dist/{daemon-state-C09DaALw.js → daemon-state-CiTQcAWA.js} +3 -3
- package/dist/{daemon-state-C09DaALw.js.map → daemon-state-CiTQcAWA.js.map} +1 -1
- package/dist/{dispatch-owned-runtime-BTK0uuOV.js → dispatch-owned-runtime-rL1dMpSL.js} +77 -29
- package/dist/dispatch-owned-runtime-rL1dMpSL.js.map +1 -0
- package/dist/{dist-YSbIHBnl.js → dist-BOBe5eOZ.js} +22 -2
- package/dist/dist-BOBe5eOZ.js.map +1 -0
- package/dist/{dist-DY8oLAop.js → dist-CP5KSxWw.js} +2 -2
- package/dist/{dist-DY8oLAop.js.map → dist-CP5KSxWw.js.map} +1 -1
- package/dist/dist-DyKCU9Uu.js +4 -0
- package/dist/{dist-DRfPWuFM.js → dist-LObwcebd.js} +1 -1
- package/dist/{dual-view-guide-catalog-3LaB18SR.js → dual-view-guide-catalog-CSV_FNr4.js} +3 -3
- package/dist/{dual-view-guide-catalog-3LaB18SR.js.map → dual-view-guide-catalog-CSV_FNr4.js.map} +1 -1
- package/dist/{elapsed-time-CGeKqTzX.js → elapsed-time-DFp-tAB8.js} +4 -4
- package/dist/{elapsed-time-CGeKqTzX.js.map → elapsed-time-DFp-tAB8.js.map} +1 -1
- package/dist/{entry-CMDScEVO.js → entry-DnUl6Ms1.js} +12 -12
- package/dist/{entry-CMDScEVO.js.map → entry-DnUl6Ms1.js.map} +1 -1
- package/dist/{installation-inventory-CvtmIZj8.js → installation-inventory-87Vo7lnz.js} +4 -4
- package/dist/{installation-inventory-CvtmIZj8.js.map → installation-inventory-87Vo7lnz.js.map} +1 -1
- package/dist/{installer-CwK5uV4Q.js → installer-CbmSCmp3.js} +2 -2
- package/dist/{installer-CwK5uV4Q.js.map → installer-CbmSCmp3.js.map} +1 -1
- package/dist/{lock-Cz8h_yJh.js → lock-y1PCtVSn.js} +3 -3
- package/dist/{lock-Cz8h_yJh.js.map → lock-y1PCtVSn.js.map} +1 -1
- package/dist/{meta-api-B01L3fo4.js → meta-api-CBfmjR2R.js} +7 -7
- package/dist/{meta-api-B01L3fo4.js.map → meta-api-CBfmjR2R.js.map} +1 -1
- package/dist/{openmeld-RoIfH4iG.js → openmeld-NTZxD9-J.js} +41 -41
- package/dist/{openmeld-RoIfH4iG.js.map → openmeld-NTZxD9-J.js.map} +1 -1
- package/dist/{openmeld-dev-environment-POXQHtTN.js → openmeld-dev-environment-Bx6D1B6_.js} +3 -3
- package/dist/{openmeld-dev-environment-POXQHtTN.js.map → openmeld-dev-environment-Bx6D1B6_.js.map} +1 -1
- package/dist/openmeld-dev.js +1 -1
- package/dist/{openmeld-environment-target-B0Z7eI6O.js → openmeld-environment-target-oDaSSRO3.js} +3 -3
- package/dist/{openmeld-environment-target-B0Z7eI6O.js.map → openmeld-environment-target-oDaSSRO3.js.map} +1 -1
- package/dist/{openmeld-maintenance-worker--ucPEftH.js → openmeld-maintenance-worker-DKV1YZ77.js} +14 -14
- package/dist/{openmeld-maintenance-worker--ucPEftH.js.map → openmeld-maintenance-worker-DKV1YZ77.js.map} +1 -1
- package/dist/{openmeld-tools-update-join-gps19byt.js → openmeld-tools-update-join-DC_rkVk4.js} +4 -4
- package/dist/{openmeld-tools-update-join-gps19byt.js.map → openmeld-tools-update-join-DC_rkVk4.js.map} +1 -1
- package/dist/{openmeld-tools-update-process-frame-Ctim4GrA.js → openmeld-tools-update-process-frame-BOdfnz6g.js} +2 -2
- package/dist/{openmeld-tools-update-process-frame-Ctim4GrA.js.map → openmeld-tools-update-process-frame-BOdfnz6g.js.map} +1 -1
- package/dist/{openmeld-tools-update-process-frame-C9hDfFXg.js → openmeld-tools-update-process-frame-CHxv33b4.js} +1 -1
- package/dist/openmeld.js +7 -7
- package/dist/{prepare-provider-runtime-CyIGaDTC.js → prepare-provider-runtime-BbJnigvx.js} +17 -17
- package/dist/{prepare-provider-runtime-CyIGaDTC.js.map → prepare-provider-runtime-BbJnigvx.js.map} +1 -1
- package/dist/{prepare-session-executor-BesIXfWv.js → prepare-session-executor-DtrZ5-G9.js} +25 -25
- package/dist/{prepare-session-executor-BesIXfWv.js.map → prepare-session-executor-DtrZ5-G9.js.map} +1 -1
- package/dist/{process-channel-DILzf1ek.js → process-channel-B6Y2-Xau.js} +2 -2
- package/dist/{process-channel-DILzf1ek.js.map → process-channel-B6Y2-Xau.js.map} +1 -1
- package/dist/{process-identity-D_VPVruT.js → process-identity-DCYUeRGI.js} +2 -2
- package/dist/{process-identity-D_VPVruT.js.map → process-identity-DCYUeRGI.js.map} +1 -1
- package/dist/{runtime-BsLzW985.js → runtime-CMUFvQzB.js} +150 -293
- package/dist/runtime-CMUFvQzB.js.map +1 -0
- package/dist/{runtime-agent-controller-reporting-submission-Dtvml_vt.js → runtime-agent-controller-reporting-submission-COEd2PQD.js} +9 -9
- package/dist/{runtime-agent-controller-reporting-submission-Dtvml_vt.js.map → runtime-agent-controller-reporting-submission-COEd2PQD.js.map} +1 -1
- package/dist/{service-BNpxWxYQ.js → service-Cz9hwU7z.js} +163 -53
- package/dist/service-Cz9hwU7z.js.map +1 -0
- package/dist/{service-account-authorization-CJv1vZzm.js → service-account-authorization-Dh5cBGYr.js} +5 -5
- package/dist/{service-account-authorization-CJv1vZzm.js.map → service-account-authorization-Dh5cBGYr.js.map} +1 -1
- package/dist/{service-account-control-f9-hQZzW.js → service-account-control-Bgady7sO.js} +32 -22
- package/dist/service-account-control-Bgady7sO.js.map +1 -0
- package/dist/{service-control-capabilities-DyX9foHw.js → service-control-capabilities-CJVtLeLz.js} +6 -6
- package/dist/{service-control-capabilities-DyX9foHw.js.map → service-control-capabilities-CJVtLeLz.js.map} +1 -1
- package/dist/{service-control-capabilities-D2-b-23n.js → service-control-capabilities-DMzx-Tde.js} +1 -1
- package/dist/{service-control-carrier-capability-B8-5s0Z4.js → service-control-carrier-capability-DT97FTao.js} +3 -3
- package/dist/{service-control-carrier-capability-B8-5s0Z4.js.map → service-control-carrier-capability-DT97FTao.js.map} +1 -1
- package/dist/{state-BlZXA4Rd.js → state-B3ORUW8a.js} +3 -3
- package/dist/{state-BlZXA4Rd.js.map → state-B3ORUW8a.js.map} +1 -1
- package/dist/{updates-api-BpuVusi5.js → updates-api-Dc2hLgXj.js} +14 -14
- package/dist/{updates-api-BpuVusi5.js.map → updates-api-Dc2hLgXj.js.map} +1 -1
- package/dist/upgrade-Cb9hoK5-.js +4 -0
- package/dist/{upgrade-CII-Xiab.js → upgrade-CeUhMgzW.js} +9 -9
- package/dist/{upgrade-CII-Xiab.js.map → upgrade-CeUhMgzW.js.map} +1 -1
- package/dist/windows/openmeld-windows-process.exe +0 -0
- package/dist/{windows-managed-install-Db8X1tQ4.js → windows-managed-install-Do1KTI4o.js} +2 -2
- package/dist/{windows-managed-install-Db8X1tQ4.js.map → windows-managed-install-Do1KTI4o.js.map} +1 -1
- package/dist/{windows-preview-channel-BJfMRixx.js → windows-preview-channel-7qDoCslK.js} +3 -3
- package/dist/{windows-preview-channel-BJfMRixx.js.map → windows-preview-channel-7qDoCslK.js.map} +1 -1
- package/dist/{windows-task-command-BGrlQDFJ.js → windows-task-command-DR3N78Zm.js} +2 -2
- package/dist/{windows-task-command-BGrlQDFJ.js.map → windows-task-command-DR3N78Zm.js.map} +1 -1
- package/dist/{windows-task-entry-bzn-6mTB.js → windows-task-entry-2RQM6JR9.js} +3 -3
- package/dist/{windows-task-entry-bzn-6mTB.js.map → windows-task-entry-2RQM6JR9.js.map} +1 -1
- package/dist/{windows-user-task-bkBjpShZ.js → windows-user-task-BX4n6qHn.js} +6 -6
- package/dist/{windows-user-task-bkBjpShZ.js.map → windows-user-task-BX4n6qHn.js.map} +1 -1
- package/dist/{windows-user-task-GqNzbzc9.js → windows-user-task-DBahPxza.js} +1 -1
- package/package.json +5 -5
- package/dist/auth-session-B0J2UwSR.js.map +0 -1
- package/dist/auth-session-DkDdLUPZ.js +0 -4
- package/dist/computer-connection-review-vYYCtG_l.js.map +0 -1
- package/dist/daemon-lifecycle-journal-DoAQ-E6K.js.map +0 -1
- package/dist/daemon-service-contract-D9gUVdhc.js.map +0 -1
- package/dist/dispatch-owned-runtime-BTK0uuOV.js.map +0 -1
- package/dist/dist-Df2Qywqr.js +0 -4
- package/dist/dist-YSbIHBnl.js.map +0 -1
- package/dist/runtime-BsLzW985.js.map +0 -1
- package/dist/service-BNpxWxYQ.js.map +0 -1
- package/dist/service-account-control-f9-hQZzW.js.map +0 -1
- package/dist/upgrade-D3f82xoM.js +0 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { F as resolveOpenMeldRootDir, I as resolveOpenMeldServiceOwnedPathInput, P as resolveOpenMeldEnvPreset, R as runtimeDir, U as systemDir } from "./paths-De9xdA2h.js";
|
|
4
|
-
import { d as runWithHeldLock, f as tryCleanupStaleLock, o as readLockMeta, s as releaseLock, t as acquireLock } from "./lock-
|
|
4
|
+
import { d as runWithHeldLock, f as tryCleanupStaleLock, o as readLockMeta, s as releaseLock, t as acquireLock } from "./lock-y1PCtVSn.js";
|
|
5
5
|
import { createHash, randomBytes } from "node:crypto";
|
|
6
6
|
import { tmpdir } from "node:os";
|
|
7
7
|
import { join } from "node:path";
|
|
@@ -137,7 +137,7 @@ async function setDaemonServiceRuntimeState(state, pathInput = {}) {
|
|
|
137
137
|
await writeDaemonServiceRuntimeState(state, pathInput);
|
|
138
138
|
}
|
|
139
139
|
async function clearDaemonServiceRuntimeState(pathInput = {}) {
|
|
140
|
-
const { clearDaemonRuntimeLease } = await import("./daemon-runtime-lease-
|
|
140
|
+
const { clearDaemonRuntimeLease } = await import("./daemon-runtime-lease-DJx3N2Sa.js");
|
|
141
141
|
await Promise.all([rm(daemonServiceRuntimeStatePath(pathInput), { force: true }), clearDaemonRuntimeLease(pathInput)]);
|
|
142
142
|
}
|
|
143
143
|
function withDaemonServiceRunLock(callback, meta = {
|
|
@@ -653,4 +653,4 @@ async function pathExists(path) {
|
|
|
653
653
|
//#endregion
|
|
654
654
|
export { getDaemonStatus as A, restoreDaemonInstallStateSnapshot as B, daemonServiceStableBinaryExecutablePath as C, daemonStatePath as D, daemonServiceUpdateWorkerBinaryExecutablePath as E, readDaemonServiceLifecycleLockMetaWithCleanup as F, withDaemonServiceReconcileLock as G, setDaemonServiceRuntimeState as H, readDaemonServiceRuntimeSnapshot as I, withDaemonServiceStopLock as J, withDaemonServiceRegistrationMutationLock as K, releaseDaemonServiceLifecycleLock as L, isDaemonServiceRuntimeHeartbeatStale as M, readDaemonControlPlaneToken as N, ensureDaemonControlPlaneToken as O, readDaemonServiceLifecycleLockMeta as P, resolveDaemonControlPlaneEndpoint as R, daemonServiceRepairJournalPath as S, daemonServiceStableLauncherPath as T, uninstallDaemon as U, rotateDaemonControlPlaneTokenIfExpired as V, withDaemonServiceLifecycleLock as W, daemonRuntimeStateRootPath as _, DAEMON_SERVICE_RUNTIME_MODE_ENV as a, daemonServiceLegacyExecutableWrapperPath as b, acquireDaemonServiceLifecycleLock as c, daemonDispatchJournalPath as d, daemonLifecycleJournalPath as f, daemonRuntimeServiceManagerPath as g, daemonRuntimeRootPath as h, DAEMON_SERVICE_RUNTIME_DETACHED_ENV as i, installDaemon as j, getDaemonRuntimeStatus as k, clearDaemonServiceRuntimeState as l, daemonRuntimeDataPath as m, DAEMON_SERVICE_RUNTIME_AUTO_START_ENV as n, DAEMON_SERVICE_RUNTIME_STATE_SCHEMA as o, daemonRuntimeBundlesPath as p, withDaemonServiceRunLock as q, DAEMON_SERVICE_RUNTIME_CONTROLLER_ENV as r, DAEMON_SERVICE_RUNTIME_SYSTEM_SERVICE_ENV as s, DAEMON_HEARTBEAT_STALE_MS as t, currentDaemonServiceLifecycleLock as u, daemonServiceActiveBundleStatePath as v, daemonServiceStableExecutableWrapperPath as w, daemonServiceRecognizedExecutablePaths as x, daemonServiceExecutableWrapperPaths as y, resolveDaemonServiceRuntimeMetadata as z };
|
|
655
655
|
|
|
656
|
-
//# sourceMappingURL=daemon-state-
|
|
656
|
+
//# sourceMappingURL=daemon-state-CiTQcAWA.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daemon-state-C09DaALw.js","names":[],"sources":["../src/config/daemon-state.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport { createHash, randomBytes } from \"node:crypto\";\nimport {\n chmod,\n mkdir,\n readFile,\n rename,\n rm,\n stat,\n writeFile,\n} from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport {\n acquireLock,\n type OpenMeldLock,\n readLockMeta,\n releaseLock,\n runWithHeldLock,\n tryCleanupStaleLock,\n} from \"./lock\";\nimport type { OpenMeldEnvPreset, OpenMeldPathResolutionInput } from \"./paths\";\nimport {\n resolveOpenMeldEnvPreset,\n resolveOpenMeldRootDir,\n resolveOpenMeldServiceOwnedPathInput,\n runtimeDir,\n systemDir,\n} from \"./paths\";\n\nconst DAEMON_STATE_SCHEMA = \"openmeld-daemon-install-v1\";\nexport const DAEMON_SERVICE_RUNTIME_STATE_SCHEMA =\n \"openmeld-daemon-service-state-v1\";\nexport const DAEMON_SERVICE_RUNTIME_MODE_ENV = \"OPENMELD_DAEMON_RUNTIME_MODE\";\nexport const DAEMON_SERVICE_RUNTIME_DETACHED_ENV =\n \"OPENMELD_DAEMON_RUNTIME_DETACHED\";\nexport const DAEMON_SERVICE_RUNTIME_CONTROLLER_ENV =\n \"OPENMELD_DAEMON_SERVICE_CONTROLLER\";\nexport const DAEMON_SERVICE_RUNTIME_AUTO_START_ENV =\n \"OPENMELD_DAEMON_SERVICE_AUTO_START\";\nexport const DAEMON_SERVICE_RUNTIME_SYSTEM_SERVICE_ENV =\n \"OPENMELD_DAEMON_RUNTIME_SYSTEM_SERVICE\";\nconst DAEMON_TOKEN_SCHEMA = \"openmeld-daemon-token-v1\";\nconst DAEMON_TOKEN_ROTATE_MAX_AGE_MS = 24 * 60 * 60 * 1000;\nexport const DAEMON_HEARTBEAT_STALE_MS = 3 * 60 * 1000;\nconst DAEMON_ACTIVE_BUNDLE_STATE_FILENAME = \"active-bundle.json\";\nconst DAEMON_DISPATCH_JOURNAL_FILENAME = \"daemon-dispatch-journal.jsonl\";\nconst DAEMON_LIFECYCLE_JOURNAL_FILENAME = \"daemon-lifecycle-journal.jsonl\";\nconst DAEMON_REPAIR_JOURNAL_FILENAME = \"repair-journal.json\";\nconst DAEMON_SERVICE_LOCK_PROFILE = \"daemon-service\";\nconst DAEMON_SERVICE_LOCK_KEY = \"daemon-service-run\";\ntype DaemonServiceLifecycleLockContext = {\n lock: OpenMeldLock;\n active: boolean;\n failures: unknown[];\n ownerRoot: string;\n pendingOperations: Set<Promise<void>>;\n};\nconst daemonServiceLifecycleLockContext =\n new AsyncLocalStorage<DaemonServiceLifecycleLockContext>();\n\nexport function currentDaemonServiceLifecycleLock(): OpenMeldLock | null {\n const context = daemonServiceLifecycleLockContext.getStore();\n return context?.active &&\n context.ownerRoot ===\n resolveOpenMeldRootDir(resolveOpenMeldServiceOwnedPathInput())\n ? context.lock\n : null;\n}\nconst DAEMON_STABLE_LAUNCHER_FILENAME = \"daemon-service-launcher.mjs\";\nconst DAEMON_SERVICE_EXECUTABLE_WRAPPER_FILENAME_BY_PRESET = {\n prod: \"OpenMeld Service\",\n \"dev-local\": \"OpenMeld Service Dev\",\n canary: \"OpenMeld Service Canary\",\n} as const satisfies Record<OpenMeldEnvPreset, string>;\nconst DAEMON_SERVICE_BINARY_EXECUTABLE_FILENAME_BY_PRESET = {\n prod: \"OpenMeld Service Binary\",\n \"dev-local\": \"OpenMeld Service Binary Dev\",\n canary: \"OpenMeld Service Binary Canary\",\n} as const satisfies Record<OpenMeldEnvPreset, string>;\nconst DAEMON_SERVICE_UPDATE_WORKER_BINARY_FILENAME_BY_PRESET = {\n prod: \"OpenMeld Update Worker Binary\",\n \"dev-local\": \"OpenMeld Update Worker Binary Dev\",\n canary: \"OpenMeld Update Worker Binary Canary\",\n} as const satisfies Record<OpenMeldEnvPreset, string>;\nconst DAEMON_SERVICE_LEGACY_EXECUTABLE_WRAPPER_FILENAME_BY_PRESET = {\n prod: \"openmeld-service\",\n \"dev-local\": \"openmeld-dev-service\",\n canary: \"openmeld-canary-service\",\n} as const satisfies Record<OpenMeldEnvPreset, string>;\nexport const DAEMON_SERVICE_LIFECYCLE_LOCK_PROFILE =\n DAEMON_SERVICE_LOCK_PROFILE;\nexport const DAEMON_SERVICE_LIFECYCLE_LOCK_KEY = DAEMON_SERVICE_LOCK_KEY;\nexport type DaemonServiceLifecycleLock = OpenMeldLock;\n\nexport type DaemonLifecycleIntent =\n | \"run_background\"\n | \"run_foreground\"\n | \"stop\"\n | \"autostart\"\n | \"status_cleanup\"\n | \"startup_check\"\n | \"start\"\n | \"reinstall\"\n | \"uninstall\"\n | \"upgrade_reconcile\";\n\nexport type DaemonLifecycleLockMeta = {\n intent: DaemonLifecycleIntent;\n command: string;\n pid?: number;\n sessionId?: string;\n at?: string;\n};\n\nexport type DaemonInstallSource = \"cli.auto_check\" | \"daemon.command.install\";\nexport type DaemonRunMode = \"foreground\" | \"background\";\nexport type DaemonServiceController =\n | \"launchd\"\n | \"systemd\"\n | \"windows-service\"\n | \"legacy-detached\"\n | \"unknown\";\n\ntype BaseDaemonServiceRuntimeState = {\n mode: DaemonRunMode;\n command: string;\n gatewayUrl: string | null;\n openMeldProfileId: string | null;\n stopRequestedAt: string | null;\n startedAt: string;\n updatedAt: string;\n heartbeatAt: string | null;\n managedBySystemService: boolean;\n serviceController: DaemonServiceController;\n autoStart: boolean;\n};\n\nexport type DaemonServiceRuntimeState = BaseDaemonServiceRuntimeState & {\n v: 1;\n schema: typeof DAEMON_SERVICE_RUNTIME_STATE_SCHEMA;\n status: \"running\";\n pid: number;\n};\n\nexport type DaemonServiceRuntimeStatus = {\n status: \"running\" | \"stale\" | \"not_running\" | \"unknown\";\n mode: DaemonRunMode | null;\n pid: number | null;\n startedAt: string | null;\n updatedAt: string | null;\n managedBySystemService: boolean;\n serviceController: DaemonServiceRuntimeState[\"serviceController\"];\n autoStart: boolean;\n reason?: string;\n};\n\nexport type DaemonServiceRuntimeMetadataInput = {\n managedBySystemService?: boolean;\n serviceController?: string;\n autoStart?: boolean;\n env?: NodeJS.ProcessEnv;\n};\n\nexport type DaemonServiceRuntimeMetadata = {\n managedBySystemService: boolean;\n serviceController: DaemonServiceController;\n autoStart: boolean;\n};\n\nexport type DaemonInstallState = {\n v: 1;\n schema: typeof DAEMON_STATE_SCHEMA;\n daemonVersion: string;\n installSource: DaemonInstallSource;\n installedAt: string;\n updatedAt: string;\n};\n\nexport type DaemonTokenState = {\n v: 1;\n schema: typeof DAEMON_TOKEN_SCHEMA;\n token: string;\n issuedAt: string;\n updatedAt: string;\n};\n\nexport type DaemonInstallResult = {\n status: \"installed\" | \"already_installed\";\n state: DaemonInstallState;\n};\n\nexport type DaemonUninstallResult = {\n removed: boolean;\n};\n\nexport type DaemonStatus =\n | {\n installed: true;\n state: DaemonInstallState;\n }\n | {\n installed: false;\n state: null;\n };\n\nexport async function getDaemonStatus(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<DaemonStatus> {\n const [state, runtimeExists] = await Promise.all([\n readDaemonInstallState(pathInput),\n pathExists(daemonRuntimeRootPath(pathInput)),\n ]);\n if (state && runtimeExists) {\n return {\n installed: true,\n state,\n };\n }\n return {\n installed: false,\n state: null,\n };\n}\n\nexport async function getDaemonRuntimeStatus(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<DaemonServiceRuntimeStatus> {\n const state = await readDaemonServiceRuntimeState(pathInput);\n if (!state) {\n return {\n status: \"not_running\",\n mode: null,\n pid: null,\n startedAt: null,\n updatedAt: null,\n managedBySystemService: false,\n serviceController: \"unknown\",\n autoStart: false,\n };\n }\n if (!Number.isInteger(state.pid) || state.pid <= 0) {\n return {\n status: \"stale\",\n mode: state.mode,\n pid: state.pid,\n startedAt: state.startedAt,\n updatedAt: state.updatedAt,\n managedBySystemService: state.managedBySystemService,\n serviceController: state.serviceController,\n autoStart: state.autoStart,\n reason: \"invalid_pid\",\n };\n }\n if (!isPidAlive(state.pid)) {\n return {\n status: \"stale\",\n mode: state.mode,\n pid: state.pid,\n startedAt: state.startedAt,\n updatedAt: state.updatedAt,\n managedBySystemService: state.managedBySystemService,\n serviceController: state.serviceController,\n autoStart: state.autoStart,\n reason: \"process_not_alive\",\n };\n }\n if (isDaemonServiceRuntimeHeartbeatStale(state)) {\n return {\n status: \"stale\",\n mode: state.mode,\n pid: state.pid,\n startedAt: state.startedAt,\n updatedAt: state.updatedAt,\n managedBySystemService: state.managedBySystemService,\n serviceController: state.serviceController,\n autoStart: state.autoStart,\n reason: \"heartbeat_stale\",\n };\n }\n return {\n status: \"running\",\n mode: state.mode,\n pid: state.pid,\n startedAt: state.startedAt,\n updatedAt: state.updatedAt,\n managedBySystemService: state.managedBySystemService,\n serviceController: state.serviceController,\n autoStart: state.autoStart,\n };\n}\n\nexport async function readDaemonServiceRuntimeSnapshot(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<DaemonServiceRuntimeState | null> {\n return await readDaemonServiceRuntimeState(pathInput);\n}\n\nexport function resolveDaemonServiceRuntimeMetadata(\n input: DaemonServiceRuntimeMetadataInput = {}\n): DaemonServiceRuntimeMetadata {\n const env = input.env ?? process.env;\n const managedBySystemService =\n input.managedBySystemService === true ||\n env[DAEMON_SERVICE_RUNTIME_SYSTEM_SERVICE_ENV] === \"1\";\n const serviceControllerInput =\n typeof input.serviceController === \"string\" &&\n input.serviceController.length > 0\n ? input.serviceController\n : env[DAEMON_SERVICE_RUNTIME_CONTROLLER_ENV];\n const autoStart =\n input.autoStart === true ||\n env[DAEMON_SERVICE_RUNTIME_AUTO_START_ENV] === \"1\";\n\n return {\n managedBySystemService,\n serviceController: parseDaemonServiceController(serviceControllerInput),\n autoStart,\n };\n}\n\nexport async function setDaemonServiceRuntimeState(\n state: DaemonServiceRuntimeState,\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<void> {\n await writeDaemonServiceRuntimeState(state, pathInput);\n}\n\nexport async function clearDaemonServiceRuntimeState(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<void> {\n const { clearDaemonRuntimeLease } = await import(\"./daemon-runtime-lease\");\n await Promise.all([\n rm(daemonServiceRuntimeStatePath(pathInput), { force: true }),\n clearDaemonRuntimeLease(pathInput),\n ]);\n}\n\nexport function withDaemonServiceRunLock<T>(\n callback: () => Promise<T>,\n meta: DaemonLifecycleLockMeta = {\n intent: \"run_background\",\n command: \"openmeld service start\",\n }\n): Promise<T> {\n return withDaemonServiceLifecycleLock(meta, callback);\n}\n\nexport async function acquireDaemonServiceLifecycleLock(\n meta: DaemonLifecycleLockMeta = {\n intent: \"run_background\",\n command: \"openmeld service start\",\n },\n pathResolution: OpenMeldPathResolutionInput = resolveOpenMeldServiceOwnedPathInput()\n): Promise<DaemonServiceLifecycleLock> {\n return await acquireLock({\n openMeldProfileId: DAEMON_SERVICE_LIFECYCLE_LOCK_PROFILE,\n key: DAEMON_SERVICE_LIFECYCLE_LOCK_KEY,\n meta,\n pathResolution,\n });\n}\n\nexport async function releaseDaemonServiceLifecycleLock(\n lock: DaemonServiceLifecycleLock\n): Promise<void> {\n await releaseLock(lock);\n}\n\nexport function withDaemonServiceStopLock<T>(\n callback: () => Promise<T>,\n meta: DaemonLifecycleLockMeta = {\n intent: \"stop\",\n command: \"openmeld service stop\",\n }\n): Promise<T> {\n return withDaemonServiceLifecycleLock(meta, callback);\n}\n\nexport function withDaemonServiceReconcileLock<T>(\n callback: () => Promise<T>,\n meta: DaemonLifecycleLockMeta = {\n intent: \"upgrade_reconcile\",\n command: \"openmeld service update\",\n }\n): Promise<T> {\n return withDaemonServiceLifecycleLock(meta, callback);\n}\n\nexport function withDaemonServiceRegistrationMutationLock<T>(\n callback: () => Promise<T>,\n meta: DaemonLifecycleLockMeta\n): Promise<T> {\n return withDaemonServiceLifecycleLock(meta, callback);\n}\n\nexport function withDaemonServiceLifecycleLock<T>(\n meta: DaemonLifecycleLockMeta,\n callback: () => Promise<T>,\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<T> {\n const pathResolution = resolveOpenMeldServiceOwnedPathInput(pathInput);\n const ownerRoot = resolveOpenMeldRootDir(pathResolution);\n const currentContext = daemonServiceLifecycleLockContext.getStore();\n if (currentContext?.active && currentContext.ownerRoot === ownerRoot) {\n let operation: Promise<T>;\n try {\n operation = callback();\n } catch (error) {\n operation = Promise.reject(error);\n }\n let trackedOperation: Promise<void>;\n trackedOperation = operation\n .then(\n () => undefined,\n (error: unknown) => {\n currentContext.failures.push(error);\n }\n )\n .finally(() => {\n currentContext.pendingOperations.delete(trackedOperation);\n });\n currentContext.pendingOperations.add(trackedOperation);\n return operation;\n }\n return withDaemonServiceLifecycleOwnerLock({\n callback,\n meta,\n ownerRoot,\n pathResolution,\n });\n}\n\nasync function withDaemonServiceLifecycleOwnerLock<T>(input: {\n callback: () => Promise<T>;\n meta: DaemonLifecycleLockMeta;\n ownerRoot: string;\n pathResolution: OpenMeldPathResolutionInput;\n}): Promise<T> {\n const lock = await acquireDaemonServiceLifecycleLock(\n input.meta,\n input.pathResolution\n );\n return await runWithHeldLock({\n lock,\n run: async () => {\n const context: DaemonServiceLifecycleLockContext = {\n lock,\n active: true,\n failures: [],\n ownerRoot: input.ownerRoot,\n pendingOperations: new Set(),\n };\n let outcome: { ok: true; value: T } | { ok: false; error: unknown };\n try {\n outcome = {\n ok: true,\n value: await daemonServiceLifecycleLockContext.run(\n context,\n input.callback\n ),\n };\n } catch (error) {\n outcome = { ok: false, error };\n } finally {\n while (context.pendingOperations.size > 0) {\n await Promise.all([...context.pendingOperations]);\n }\n context.active = false;\n }\n const failures = [\n ...(outcome.ok ? [] : [outcome.error]),\n ...context.failures,\n ].filter(\n (failure, index, allFailures) => allFailures.indexOf(failure) === index\n );\n if (failures.length === 1) {\n throw failures[0];\n }\n if (failures.length > 1) {\n throw new AggregateError(\n failures,\n \"daemon service lifecycle mutation failed in more than one operation\"\n );\n }\n if (!outcome.ok) {\n throw outcome.error;\n }\n return outcome.value;\n },\n releaseContext: {\n command: input.meta.command,\n component: \"daemon_service_lifecycle\",\n intent: input.meta.intent,\n lockKey: DAEMON_SERVICE_LIFECYCLE_LOCK_KEY,\n openMeldProfileId: DAEMON_SERVICE_LIFECYCLE_LOCK_PROFILE,\n },\n });\n}\n\nexport async function readDaemonServiceLifecycleLockMeta(): Promise<DaemonLifecycleLockMeta | null> {\n const meta = await readLockMeta({\n openMeldProfileId: DAEMON_SERVICE_LIFECYCLE_LOCK_PROFILE,\n key: DAEMON_SERVICE_LIFECYCLE_LOCK_KEY,\n pathResolution: resolveOpenMeldServiceOwnedPathInput(),\n });\n if (!meta) {\n return null;\n }\n const intent =\n typeof meta.intent === \"string\"\n ? normalizeDaemonLifecycleIntent(meta.intent)\n : null;\n const command = typeof meta.command === \"string\" ? meta.command.trim() : \"\";\n if (!intent || command.length === 0) {\n return null;\n }\n const pid = typeof meta.pid === \"number\" ? meta.pid : undefined;\n const sessionId =\n typeof meta.sessionId === \"string\" && meta.sessionId.trim().length > 0\n ? meta.sessionId.trim()\n : undefined;\n const at =\n typeof meta.at === \"string\" && meta.at.trim().length > 0\n ? meta.at.trim()\n : undefined;\n return {\n intent,\n command,\n ...(typeof pid === \"number\" ? { pid } : {}),\n ...(sessionId ? { sessionId } : {}),\n ...(at ? { at } : {}),\n };\n}\n\nexport async function readDaemonServiceLifecycleLockMetaWithCleanup(): Promise<DaemonLifecycleLockMeta | null> {\n await tryCleanupStaleLock({\n openMeldProfileId: DAEMON_SERVICE_LIFECYCLE_LOCK_PROFILE,\n key: DAEMON_SERVICE_LIFECYCLE_LOCK_KEY,\n pathResolution: resolveOpenMeldServiceOwnedPathInput(),\n });\n return await readDaemonServiceLifecycleLockMeta();\n}\n\nexport async function installDaemon(input: {\n daemonVersion: string;\n source: DaemonInstallSource;\n}): Promise<DaemonInstallResult> {\n const existingState = await readDaemonInstallState();\n const runtimeExists = await pathExists(daemonRuntimeRootPath());\n if (\n existingState &&\n runtimeExists &&\n existingState.daemonVersion === input.daemonVersion\n ) {\n await ensureDaemonTokenState();\n return {\n status: \"already_installed\",\n state: existingState,\n };\n }\n\n await ensureDaemonRuntimeLayout();\n const now = new Date().toISOString();\n const nextState: DaemonInstallState = {\n v: 1,\n schema: DAEMON_STATE_SCHEMA,\n daemonVersion: input.daemonVersion,\n installSource: input.source,\n installedAt: existingState?.installedAt ?? now,\n updatedAt: now,\n };\n await writeDaemonInstallState(nextState);\n await ensureDaemonTokenState();\n\n return {\n status: \"installed\",\n state: nextState,\n };\n}\n\nexport async function uninstallDaemon(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<DaemonUninstallResult> {\n const [hasState, hasRuntimeDir, hasToken] = await Promise.all([\n pathExists(daemonStatePath(pathInput)),\n pathExists(daemonRuntimeRootPath(pathInput)),\n pathExists(daemonTokenPath(pathInput)),\n ]);\n\n await Promise.all([\n rm(daemonStatePath(pathInput), { force: true }),\n rm(daemonTokenPath(pathInput), { force: true }),\n rm(daemonServiceRuntimeStatePath(pathInput), { force: true }),\n rm(daemonRuntimeRootPath(pathInput), { recursive: true, force: true }),\n ]);\n\n return {\n removed: hasState || hasRuntimeDir || hasToken,\n };\n}\n\nexport function daemonStatePath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(systemDir(pathInput), \"daemon-install.json\");\n}\n\nexport function daemonRuntimeRootPath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(runtimeDir(pathInput), \"daemon\");\n}\n\nexport function daemonServiceRuntimeStatePath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(daemonRuntimeRootPath(pathInput), \"service-runtime.json\");\n}\n\nexport function daemonRuntimeDataPath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(daemonRuntimeRootPath(pathInput), \"data\");\n}\n\nexport function daemonRuntimeBundlesPath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(daemonRuntimeRootPath(pathInput), \"bundles\");\n}\n\nexport function daemonRuntimeStateRootPath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(daemonRuntimeRootPath(pathInput), \"state\");\n}\n\nexport function daemonLifecycleJournalPath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(\n daemonRuntimeRootPath(pathInput),\n \"logs\",\n DAEMON_LIFECYCLE_JOURNAL_FILENAME\n );\n}\n\nexport function daemonDispatchJournalPath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(\n daemonRuntimeRootPath(pathInput),\n \"logs\",\n DAEMON_DISPATCH_JOURNAL_FILENAME\n );\n}\n\nexport function daemonServiceActiveBundleStatePath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(\n daemonRuntimeStateRootPath(pathInput),\n DAEMON_ACTIVE_BUNDLE_STATE_FILENAME\n );\n}\n\nexport function daemonServiceRepairJournalPath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(\n daemonRuntimeStateRootPath(pathInput),\n DAEMON_REPAIR_JOURNAL_FILENAME\n );\n}\n\nexport function daemonRuntimeServiceManagerPath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(daemonRuntimeRootPath(pathInput), \"service-manager\");\n}\n\nexport function daemonServiceStableLauncherPath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(\n daemonRuntimeServiceManagerPath(pathInput),\n DAEMON_STABLE_LAUNCHER_FILENAME\n );\n}\n\nexport function daemonServiceStableExecutableWrapperPath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n const preset = resolveOpenMeldEnvPreset(pathInput);\n return join(\n daemonRuntimeServiceManagerPath(pathInput),\n DAEMON_SERVICE_EXECUTABLE_WRAPPER_FILENAME_BY_PRESET[preset]\n );\n}\n\nexport function daemonServiceStableBinaryExecutablePath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n const preset = resolveOpenMeldEnvPreset(pathInput);\n return join(\n daemonRuntimeServiceManagerPath(pathInput),\n DAEMON_SERVICE_BINARY_EXECUTABLE_FILENAME_BY_PRESET[preset]\n );\n}\n\nexport function daemonServiceUpdateWorkerBinaryExecutablePath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n const preset = resolveOpenMeldEnvPreset(pathInput);\n return join(\n daemonRuntimeServiceManagerPath(pathInput),\n DAEMON_SERVICE_UPDATE_WORKER_BINARY_FILENAME_BY_PRESET[preset]\n );\n}\n\nexport function daemonServiceLegacyExecutableWrapperPath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n const preset = resolveOpenMeldEnvPreset(pathInput);\n return join(\n daemonRuntimeServiceManagerPath(pathInput),\n DAEMON_SERVICE_LEGACY_EXECUTABLE_WRAPPER_FILENAME_BY_PRESET[preset]\n );\n}\n\nexport function daemonServiceExecutableWrapperPaths(\n pathInput: OpenMeldPathResolutionInput = {}\n): string[] {\n return [\n daemonServiceStableExecutableWrapperPath(pathInput),\n daemonServiceLegacyExecutableWrapperPath(pathInput),\n ];\n}\n\nexport function daemonServiceRecognizedExecutablePaths(\n pathInput: OpenMeldPathResolutionInput = {}\n): string[] {\n return [\n daemonServiceStableBinaryExecutablePath(pathInput),\n ...daemonServiceExecutableWrapperPaths(pathInput),\n ];\n}\n\nexport function daemonTokenPath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(systemDir(pathInput), \"daemon-token.json\");\n}\n\nexport async function restoreDaemonInstallStateSnapshot(\n snapshot: DaemonInstallState | null,\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<void> {\n if (!snapshot) {\n await rm(daemonStatePath(pathInput), { force: true });\n return;\n }\n await writeDaemonInstallState(snapshot, pathInput);\n}\n\nexport function resolveDaemonControlPlaneEndpoint(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n const runtimeRoot = daemonRuntimeRootPath(pathInput);\n const suffix = createHash(\"sha256\")\n .update(runtimeRoot)\n .digest(\"hex\")\n .slice(0, 24);\n if (process.platform === \"win32\") {\n return `\\\\\\\\.\\\\pipe\\\\openmeld-daemon-control-${suffix}`;\n }\n return join(tmpdir(), `openmeld-daemon-control-${suffix}.sock`);\n}\n\nexport async function ensureDaemonControlPlaneToken(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<string> {\n const state = await ensureDaemonTokenState(pathInput);\n return state.token;\n}\n\nexport async function rotateDaemonControlPlaneTokenIfExpired(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<DaemonTokenState> {\n const current = await readDaemonTokenState(pathInput);\n if (current && !isDaemonTokenExpired(current)) {\n await chmod(daemonTokenPath(pathInput), 0o600).catch(() => undefined);\n return current;\n }\n\n return await writeNewDaemonTokenState(pathInput);\n}\n\nexport async function readDaemonControlPlaneToken(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<string | null> {\n const state = await readDaemonTokenState(pathInput);\n return state?.token ?? null;\n}\n\nfunction isPidAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n return !(\n error instanceof Error &&\n (error as NodeJS.ErrnoException).code === \"ESRCH\"\n );\n }\n}\n\nasync function readDaemonServiceRuntimeState(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<DaemonServiceRuntimeState | null> {\n const raw = await readFile(\n daemonServiceRuntimeStatePath(pathInput),\n \"utf8\"\n ).catch((error) => {\n if (\n error &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n ) {\n return null;\n }\n throw error;\n });\n if (raw === null) {\n return null;\n }\n return parseDaemonServiceRuntimeState(raw);\n}\n\nfunction parseDaemonServiceRuntimeState(\n raw: string\n): DaemonServiceRuntimeState | null {\n try {\n const parsed = JSON.parse(raw);\n if (!isDaemonServiceRuntimeStateObject(parsed)) {\n return null;\n }\n\n return {\n v: 1,\n schema: DAEMON_SERVICE_RUNTIME_STATE_SCHEMA,\n status: \"running\",\n pid: parsed.pid,\n mode: parsed.mode,\n command: parsed.command,\n gatewayUrl: parseNullableString(parsed.gatewayUrl),\n openMeldProfileId: resolveStoredDaemonServiceOpenMeldProfileId(parsed),\n stopRequestedAt: parseNullableString(parsed.stopRequestedAt),\n heartbeatAt: parseNullableString(parsed.heartbeatAt),\n startedAt: parsed.startedAt,\n updatedAt: parsed.updatedAt,\n managedBySystemService: parsed.managedBySystemService === true,\n serviceController: parseDaemonServiceController(parsed.serviceController),\n autoStart: parsed.autoStart === true,\n };\n } catch {\n return null;\n }\n}\n\nfunction isDaemonServiceRuntimeStateObject(value: unknown): value is {\n v: 1;\n schema: string;\n status: \"running\";\n pid: number;\n mode: DaemonRunMode;\n command: string;\n gatewayUrl: string | null;\n openMeldProfileId?: string | null;\n profile?: string | null;\n stopRequestedAt: string | null;\n heartbeatAt: string | null;\n startedAt: string;\n updatedAt: string;\n managedBySystemService?: boolean;\n serviceController?: string;\n autoStart?: boolean;\n} {\n if (!value || typeof value !== \"object\") {\n return false;\n }\n const candidate = value as Record<string, unknown>;\n return (\n candidate.v === 1 &&\n candidate.schema === DAEMON_SERVICE_RUNTIME_STATE_SCHEMA &&\n candidate.status === \"running\" &&\n typeof candidate.pid === \"number\" &&\n candidate.pid > 0 &&\n (candidate.mode === \"foreground\" || candidate.mode === \"background\") &&\n typeof candidate.command === \"string\" &&\n candidate.command.length > 0 &&\n isValidNullableString(candidate.gatewayUrl) &&\n isValidOptionalNullableString(candidate.openMeldProfileId) &&\n isValidOptionalNullableString(candidate.profile) &&\n isValidNullableString(candidate.stopRequestedAt) &&\n isValidNullableString(candidate.heartbeatAt) &&\n typeof candidate.startedAt === \"string\" &&\n candidate.startedAt.length > 0 &&\n typeof candidate.updatedAt === \"string\" &&\n candidate.updatedAt.length > 0\n );\n}\n\nexport function parseDaemonServiceController(\n value: unknown\n): DaemonServiceController {\n if (\n value === \"launchd\" ||\n value === \"systemd\" ||\n value === \"windows-service\" ||\n value === \"legacy-detached\" ||\n value === \"unknown\"\n ) {\n return value;\n }\n return \"unknown\";\n}\n\nfunction isValidNullableString(value: unknown): value is string | null {\n return value === null || typeof value === \"string\";\n}\n\nfunction isValidOptionalNullableString(\n value: unknown\n): value is string | null | undefined {\n return value === undefined || value === null || typeof value === \"string\";\n}\n\nfunction parseNullableString(value: unknown): string | null {\n if (value === null) {\n return null;\n }\n if (typeof value !== \"string\") {\n return null;\n }\n return value;\n}\n\nfunction resolveStoredDaemonServiceOpenMeldProfileId(input: {\n openMeldProfileId?: unknown;\n profile?: unknown;\n}): string | null {\n const openMeldProfileId = parseNullableString(input.openMeldProfileId);\n const legacyProfile = parseNullableString(input.profile);\n if (\n openMeldProfileId &&\n legacyProfile &&\n openMeldProfileId !== legacyProfile\n ) {\n throw new Error(\"conflicting openMeldProfileId values\");\n }\n return openMeldProfileId ?? legacyProfile;\n}\n\nexport function isDaemonServiceRuntimeHeartbeatStale(\n state: DaemonServiceRuntimeState\n): boolean {\n const latestSignalAt = Math.max(\n parseIsoTimestampOrZero(state.heartbeatAt),\n parseIsoTimestampOrZero(state.updatedAt)\n );\n if (latestSignalAt <= 0) {\n return false;\n }\n return Date.now() - latestSignalAt > DAEMON_HEARTBEAT_STALE_MS;\n}\n\nfunction parseIsoTimestampOrZero(value: string | null): number {\n if (!value) {\n return 0;\n }\n const parsed = Date.parse(value);\n return Number.isFinite(parsed) ? parsed : 0;\n}\n\nasync function writeDaemonServiceRuntimeState(\n state: DaemonServiceRuntimeState,\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<void> {\n const path = daemonServiceRuntimeStatePath(pathInput);\n const runtimeRootPath = daemonRuntimeRootPath(pathInput);\n await mkdir(runtimeRootPath, { recursive: true });\n const tempPath = `${path}.tmp-${process.pid}-${Date.now()}`;\n let shouldCleanupTemp = true;\n\n try {\n await writeFile(tempPath, `${JSON.stringify(state, null, 2)}\\n`, {\n encoding: \"utf8\",\n mode: 0o600,\n });\n await rename(tempPath, path);\n await chmod(path, 0o600);\n shouldCleanupTemp = false;\n } finally {\n if (shouldCleanupTemp) {\n await rm(tempPath, { force: true }).catch(() => undefined);\n }\n }\n}\n\nasync function ensureDaemonRuntimeLayout(): Promise<void> {\n await Promise.all([\n mkdir(systemDir(), { recursive: true }),\n mkdir(join(daemonRuntimeRootPath(), \"bin\"), { recursive: true }),\n mkdir(daemonRuntimeBundlesPath(), { recursive: true }),\n mkdir(join(daemonRuntimeRootPath(), \"data\"), { recursive: true }),\n mkdir(join(daemonRuntimeRootPath(), \"logs\"), { recursive: true }),\n mkdir(daemonRuntimeStateRootPath(), { recursive: true }),\n mkdir(daemonRuntimeServiceManagerPath(), { recursive: true }),\n ]);\n}\n\nfunction normalizeDaemonLifecycleIntent(\n value: string\n): DaemonLifecycleIntent | null {\n switch (value) {\n case \"run_background\":\n case \"run_foreground\":\n case \"stop\":\n case \"autostart\":\n case \"status_cleanup\":\n case \"startup_check\":\n case \"start\":\n case \"reinstall\":\n case \"uninstall\":\n case \"upgrade_reconcile\":\n return value;\n default:\n return null;\n }\n}\n\nasync function ensureDaemonTokenState(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<DaemonTokenState> {\n const current = await readDaemonTokenState(pathInput);\n if (current) {\n await chmod(daemonTokenPath(pathInput), 0o600).catch(() => undefined);\n return current;\n }\n\n return await writeNewDaemonTokenState(pathInput);\n}\n\nasync function writeNewDaemonTokenState(\n pathInput: OpenMeldPathResolutionInput\n): Promise<DaemonTokenState> {\n const nowIso = new Date().toISOString();\n const next: DaemonTokenState = {\n v: 1,\n schema: DAEMON_TOKEN_SCHEMA,\n token: createDaemonTokenValue(),\n issuedAt: nowIso,\n updatedAt: nowIso,\n };\n await writeDaemonTokenState(next, pathInput);\n return next;\n}\n\nasync function readDaemonInstallState(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<DaemonInstallState | null> {\n const raw = await readFile(daemonStatePath(pathInput), \"utf8\").catch(\n (error) => {\n if (\n error &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n ) {\n return null;\n }\n throw error;\n }\n );\n if (raw === null) {\n return null;\n }\n return parseDaemonInstallState(raw);\n}\n\nfunction parseDaemonInstallState(raw: string): DaemonInstallState | null {\n try {\n const parsed = JSON.parse(raw) as Partial<DaemonInstallState>;\n if (parsed.v !== 1) {\n return null;\n }\n if (parsed.schema !== DAEMON_STATE_SCHEMA) {\n return null;\n }\n if (typeof parsed.daemonVersion !== \"string\" || !parsed.daemonVersion) {\n return null;\n }\n if (!isDaemonInstallSource(parsed.installSource)) {\n return null;\n }\n if (typeof parsed.installedAt !== \"string\" || !parsed.installedAt) {\n return null;\n }\n if (typeof parsed.updatedAt !== \"string\" || !parsed.updatedAt) {\n return null;\n }\n return {\n v: 1,\n schema: DAEMON_STATE_SCHEMA,\n daemonVersion: parsed.daemonVersion,\n installSource: parsed.installSource,\n installedAt: parsed.installedAt,\n updatedAt: parsed.updatedAt,\n };\n } catch {\n return null;\n }\n}\n\nfunction isDaemonInstallSource(value: unknown): value is DaemonInstallSource {\n return value === \"cli.auto_check\" || value === \"daemon.command.install\";\n}\n\nasync function writeDaemonInstallState(\n state: DaemonInstallState,\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<void> {\n const path = daemonStatePath(pathInput);\n await mkdir(systemDir(pathInput), { recursive: true });\n const tempPath = `${path}.tmp-${process.pid}-${Date.now()}`;\n let shouldCleanupTemp = true;\n\n try {\n await writeFile(tempPath, `${JSON.stringify(state, null, 2)}\\n`, \"utf8\");\n await rename(tempPath, path);\n shouldCleanupTemp = false;\n } finally {\n if (shouldCleanupTemp) {\n await rm(tempPath, { force: true }).catch(() => undefined);\n }\n }\n}\n\nasync function readDaemonTokenState(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<DaemonTokenState | null> {\n const raw = await readFile(daemonTokenPath(pathInput), \"utf8\").catch(\n (error) => {\n if (\n error &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n ) {\n return null;\n }\n throw error;\n }\n );\n if (raw === null) {\n return null;\n }\n return parseDaemonTokenState(raw);\n}\n\nfunction parseDaemonTokenState(raw: string): DaemonTokenState | null {\n try {\n const parsed = JSON.parse(raw) as Partial<DaemonTokenState>;\n if (parsed.v !== 1 || parsed.schema !== DAEMON_TOKEN_SCHEMA) {\n return null;\n }\n if (typeof parsed.token !== \"string\" || parsed.token.length < 16) {\n return null;\n }\n if (typeof parsed.issuedAt !== \"string\" || !parsed.issuedAt) {\n return null;\n }\n if (typeof parsed.updatedAt !== \"string\" || !parsed.updatedAt) {\n return null;\n }\n return {\n v: 1,\n schema: DAEMON_TOKEN_SCHEMA,\n token: parsed.token,\n issuedAt: parsed.issuedAt,\n updatedAt: parsed.updatedAt,\n };\n } catch {\n return null;\n }\n}\n\nasync function writeDaemonTokenState(\n state: DaemonTokenState,\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<void> {\n const path = daemonTokenPath(pathInput);\n await mkdir(systemDir(pathInput), { recursive: true });\n const tempPath = `${path}.tmp-${process.pid}-${Date.now()}`;\n let shouldCleanupTemp = true;\n\n try {\n await writeFile(tempPath, `${JSON.stringify(state, null, 2)}\\n`, {\n encoding: \"utf8\",\n mode: 0o600,\n });\n await rename(tempPath, path);\n await chmod(path, 0o600);\n shouldCleanupTemp = false;\n } finally {\n if (shouldCleanupTemp) {\n await rm(tempPath, { force: true }).catch(() => undefined);\n }\n }\n}\n\nfunction isDaemonTokenExpired(state: DaemonTokenState): boolean {\n const updatedAtMs = Date.parse(state.updatedAt);\n if (!Number.isFinite(updatedAtMs)) {\n return true;\n }\n return Date.now() - updatedAtMs >= DAEMON_TOKEN_ROTATE_MAX_AGE_MS;\n}\n\nfunction createDaemonTokenValue(): string {\n return randomBytes(32).toString(\"base64url\");\n}\n\nasync function pathExists(path: string): Promise<boolean> {\n try {\n await stat(path);\n return true;\n } catch (error) {\n if (\n error &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n ) {\n return false;\n }\n throw error;\n }\n}\n"],"mappings":";;;;;;;;;;AA8BA,MAAM,sBAAsB;AAC5B,MAAa,sCACX;AACF,MAAa,kCAAkC;AAC/C,MAAa,sCACX;AACF,MAAa,wCACX;AACF,MAAa,wCACX;AACF,MAAa,4CACX;AACF,MAAM,sBAAsB;AAC5B,MAAM,iCAAiC,OAAU,KAAK;AACtD,MAAa,4BAA4B,MAAS;AAClD,MAAM,sCAAsC;AAC5C,MAAM,mCAAmC;AACzC,MAAM,oCAAoC;AAC1C,MAAM,iCAAiC;AACvC,MAAM,8BAA8B;AACpC,MAAM,0BAA0B;AAQhC,MAAM,oCACJ,IAAI,kBAAqD;AAE3D,SAAgB,oCAAyD;CACvE,MAAM,UAAU,kCAAkC,SAAS;CAC3D,OAAO,SAAS,UACd,QAAQ,cACN,uBAAuB,qCAAqC,CAAC,IAC7D,QAAQ,OACR;AACN;AACA,MAAM,kCAAkC;AACxC,MAAM,uDAAuD;CAC3D,MAAM;CACN,aAAa;CACb,QAAQ;AACV;AACA,MAAM,sDAAsD;CAC1D,MAAM;CACN,aAAa;CACb,QAAQ;AACV;AACA,MAAM,yDAAyD;CAC7D,MAAM;CACN,aAAa;CACb,QAAQ;AACV;AACA,MAAM,8DAA8D;CAClE,MAAM;CACN,aAAa;CACb,QAAQ;AACV;AACA,MAAa,wCACX;AACF,MAAa,oCAAoC;AAkHjD,eAAsB,gBACpB,YAAyC,CAAC,GACnB;CACvB,MAAM,CAAC,OAAO,iBAAiB,MAAM,QAAQ,IAAI,CAC/C,uBAAuB,SAAS,GAChC,WAAW,sBAAsB,SAAS,CAAC,CAC7C,CAAC;CACD,IAAI,SAAS,eACX,OAAO;EACL,WAAW;EACX;CACF;CAEF,OAAO;EACL,WAAW;EACX,OAAO;CACT;AACF;AAEA,eAA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AAI,oBAAoB;CAExB,IAAI;EACF,MAAM,UAAU,UAAU,GAAG,KAAK,UAAU,OAAO,MAAM,CAAC,EAAE,KAAK;GAC/D,UAAU;GACV,MAAM;EACR,CAAC;EACD,MAAM,OAAO,UAAU,IAAI;EAC3B,MAAM,MAAM,MAAM,GAAK;EACvB,oBAAoB;CACtB,UAAU;EACR,IAAI,mBACF,MAAM,GAAG,UAAU,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,YAAY,KAAA,CAAS;CAE7D;AACF;AAEA,SAAS,qBAAqB,OAAkC;CAC9D,MAAM,cAAc,KAAK,MAAM,MAAM,SAAS;CAC9C,IAAI,CAAC,OAAO,SAAS,WAAW,GAC9B,OAAO;CAET,OAAO,KAAK,IAAI,IAAI,eAAe;AACrC;AAEA,SAAS,yBAAiC;CACxC,OAAO,YAAY,EAAE,CAAC,CAAC,SAAS,WAAW;AAC7C;AAEA,eAAe,WAAW,MAAgC;CACxD,IAAI;EACF,MAAM,KAAK,IAAI;EACf,OAAO;CACT,SAAS,OAAO;EACd,IACE,SACA,OAAO,UAAU,YACjB,UAAU,SACV,MAAM,SAAS,UAEf,OAAO;EAET,MAAM;CACR;AACF"}
|
|
1
|
+
{"version":3,"file":"daemon-state-CiTQcAWA.js","names":[],"sources":["../src/config/daemon-state.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport { createHash, randomBytes } from \"node:crypto\";\nimport {\n chmod,\n mkdir,\n readFile,\n rename,\n rm,\n stat,\n writeFile,\n} from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport {\n acquireLock,\n type OpenMeldLock,\n readLockMeta,\n releaseLock,\n runWithHeldLock,\n tryCleanupStaleLock,\n} from \"./lock\";\nimport type { OpenMeldEnvPreset, OpenMeldPathResolutionInput } from \"./paths\";\nimport {\n resolveOpenMeldEnvPreset,\n resolveOpenMeldRootDir,\n resolveOpenMeldServiceOwnedPathInput,\n runtimeDir,\n systemDir,\n} from \"./paths\";\n\nconst DAEMON_STATE_SCHEMA = \"openmeld-daemon-install-v1\";\nexport const DAEMON_SERVICE_RUNTIME_STATE_SCHEMA =\n \"openmeld-daemon-service-state-v1\";\nexport const DAEMON_SERVICE_RUNTIME_MODE_ENV = \"OPENMELD_DAEMON_RUNTIME_MODE\";\nexport const DAEMON_SERVICE_RUNTIME_DETACHED_ENV =\n \"OPENMELD_DAEMON_RUNTIME_DETACHED\";\nexport const DAEMON_SERVICE_RUNTIME_CONTROLLER_ENV =\n \"OPENMELD_DAEMON_SERVICE_CONTROLLER\";\nexport const DAEMON_SERVICE_RUNTIME_AUTO_START_ENV =\n \"OPENMELD_DAEMON_SERVICE_AUTO_START\";\nexport const DAEMON_SERVICE_RUNTIME_SYSTEM_SERVICE_ENV =\n \"OPENMELD_DAEMON_RUNTIME_SYSTEM_SERVICE\";\nconst DAEMON_TOKEN_SCHEMA = \"openmeld-daemon-token-v1\";\nconst DAEMON_TOKEN_ROTATE_MAX_AGE_MS = 24 * 60 * 60 * 1000;\nexport const DAEMON_HEARTBEAT_STALE_MS = 3 * 60 * 1000;\nconst DAEMON_ACTIVE_BUNDLE_STATE_FILENAME = \"active-bundle.json\";\nconst DAEMON_DISPATCH_JOURNAL_FILENAME = \"daemon-dispatch-journal.jsonl\";\nconst DAEMON_LIFECYCLE_JOURNAL_FILENAME = \"daemon-lifecycle-journal.jsonl\";\nconst DAEMON_REPAIR_JOURNAL_FILENAME = \"repair-journal.json\";\nconst DAEMON_SERVICE_LOCK_PROFILE = \"daemon-service\";\nconst DAEMON_SERVICE_LOCK_KEY = \"daemon-service-run\";\ntype DaemonServiceLifecycleLockContext = {\n lock: OpenMeldLock;\n active: boolean;\n failures: unknown[];\n ownerRoot: string;\n pendingOperations: Set<Promise<void>>;\n};\nconst daemonServiceLifecycleLockContext =\n new AsyncLocalStorage<DaemonServiceLifecycleLockContext>();\n\nexport function currentDaemonServiceLifecycleLock(): OpenMeldLock | null {\n const context = daemonServiceLifecycleLockContext.getStore();\n return context?.active &&\n context.ownerRoot ===\n resolveOpenMeldRootDir(resolveOpenMeldServiceOwnedPathInput())\n ? context.lock\n : null;\n}\nconst DAEMON_STABLE_LAUNCHER_FILENAME = \"daemon-service-launcher.mjs\";\nconst DAEMON_SERVICE_EXECUTABLE_WRAPPER_FILENAME_BY_PRESET = {\n prod: \"OpenMeld Service\",\n \"dev-local\": \"OpenMeld Service Dev\",\n canary: \"OpenMeld Service Canary\",\n} as const satisfies Record<OpenMeldEnvPreset, string>;\nconst DAEMON_SERVICE_BINARY_EXECUTABLE_FILENAME_BY_PRESET = {\n prod: \"OpenMeld Service Binary\",\n \"dev-local\": \"OpenMeld Service Binary Dev\",\n canary: \"OpenMeld Service Binary Canary\",\n} as const satisfies Record<OpenMeldEnvPreset, string>;\nconst DAEMON_SERVICE_UPDATE_WORKER_BINARY_FILENAME_BY_PRESET = {\n prod: \"OpenMeld Update Worker Binary\",\n \"dev-local\": \"OpenMeld Update Worker Binary Dev\",\n canary: \"OpenMeld Update Worker Binary Canary\",\n} as const satisfies Record<OpenMeldEnvPreset, string>;\nconst DAEMON_SERVICE_LEGACY_EXECUTABLE_WRAPPER_FILENAME_BY_PRESET = {\n prod: \"openmeld-service\",\n \"dev-local\": \"openmeld-dev-service\",\n canary: \"openmeld-canary-service\",\n} as const satisfies Record<OpenMeldEnvPreset, string>;\nexport const DAEMON_SERVICE_LIFECYCLE_LOCK_PROFILE =\n DAEMON_SERVICE_LOCK_PROFILE;\nexport const DAEMON_SERVICE_LIFECYCLE_LOCK_KEY = DAEMON_SERVICE_LOCK_KEY;\nexport type DaemonServiceLifecycleLock = OpenMeldLock;\n\nexport type DaemonLifecycleIntent =\n | \"run_background\"\n | \"run_foreground\"\n | \"stop\"\n | \"autostart\"\n | \"status_cleanup\"\n | \"startup_check\"\n | \"start\"\n | \"reinstall\"\n | \"uninstall\"\n | \"upgrade_reconcile\";\n\nexport type DaemonLifecycleLockMeta = {\n intent: DaemonLifecycleIntent;\n command: string;\n pid?: number;\n sessionId?: string;\n at?: string;\n};\n\nexport type DaemonInstallSource = \"cli.auto_check\" | \"daemon.command.install\";\nexport type DaemonRunMode = \"foreground\" | \"background\";\nexport type DaemonServiceController =\n | \"launchd\"\n | \"systemd\"\n | \"windows-service\"\n | \"legacy-detached\"\n | \"unknown\";\n\ntype BaseDaemonServiceRuntimeState = {\n mode: DaemonRunMode;\n command: string;\n gatewayUrl: string | null;\n openMeldProfileId: string | null;\n stopRequestedAt: string | null;\n startedAt: string;\n updatedAt: string;\n heartbeatAt: string | null;\n managedBySystemService: boolean;\n serviceController: DaemonServiceController;\n autoStart: boolean;\n};\n\nexport type DaemonServiceRuntimeState = BaseDaemonServiceRuntimeState & {\n v: 1;\n schema: typeof DAEMON_SERVICE_RUNTIME_STATE_SCHEMA;\n status: \"running\";\n pid: number;\n};\n\nexport type DaemonServiceRuntimeStatus = {\n status: \"running\" | \"stale\" | \"not_running\" | \"unknown\";\n mode: DaemonRunMode | null;\n pid: number | null;\n startedAt: string | null;\n updatedAt: string | null;\n managedBySystemService: boolean;\n serviceController: DaemonServiceRuntimeState[\"serviceController\"];\n autoStart: boolean;\n reason?: string;\n};\n\nexport type DaemonServiceRuntimeMetadataInput = {\n managedBySystemService?: boolean;\n serviceController?: string;\n autoStart?: boolean;\n env?: NodeJS.ProcessEnv;\n};\n\nexport type DaemonServiceRuntimeMetadata = {\n managedBySystemService: boolean;\n serviceController: DaemonServiceController;\n autoStart: boolean;\n};\n\nexport type DaemonInstallState = {\n v: 1;\n schema: typeof DAEMON_STATE_SCHEMA;\n daemonVersion: string;\n installSource: DaemonInstallSource;\n installedAt: string;\n updatedAt: string;\n};\n\nexport type DaemonTokenState = {\n v: 1;\n schema: typeof DAEMON_TOKEN_SCHEMA;\n token: string;\n issuedAt: string;\n updatedAt: string;\n};\n\nexport type DaemonInstallResult = {\n status: \"installed\" | \"already_installed\";\n state: DaemonInstallState;\n};\n\nexport type DaemonUninstallResult = {\n removed: boolean;\n};\n\nexport type DaemonStatus =\n | {\n installed: true;\n state: DaemonInstallState;\n }\n | {\n installed: false;\n state: null;\n };\n\nexport async function getDaemonStatus(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<DaemonStatus> {\n const [state, runtimeExists] = await Promise.all([\n readDaemonInstallState(pathInput),\n pathExists(daemonRuntimeRootPath(pathInput)),\n ]);\n if (state && runtimeExists) {\n return {\n installed: true,\n state,\n };\n }\n return {\n installed: false,\n state: null,\n };\n}\n\nexport async function getDaemonRuntimeStatus(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<DaemonServiceRuntimeStatus> {\n const state = await readDaemonServiceRuntimeState(pathInput);\n if (!state) {\n return {\n status: \"not_running\",\n mode: null,\n pid: null,\n startedAt: null,\n updatedAt: null,\n managedBySystemService: false,\n serviceController: \"unknown\",\n autoStart: false,\n };\n }\n if (!Number.isInteger(state.pid) || state.pid <= 0) {\n return {\n status: \"stale\",\n mode: state.mode,\n pid: state.pid,\n startedAt: state.startedAt,\n updatedAt: state.updatedAt,\n managedBySystemService: state.managedBySystemService,\n serviceController: state.serviceController,\n autoStart: state.autoStart,\n reason: \"invalid_pid\",\n };\n }\n if (!isPidAlive(state.pid)) {\n return {\n status: \"stale\",\n mode: state.mode,\n pid: state.pid,\n startedAt: state.startedAt,\n updatedAt: state.updatedAt,\n managedBySystemService: state.managedBySystemService,\n serviceController: state.serviceController,\n autoStart: state.autoStart,\n reason: \"process_not_alive\",\n };\n }\n if (isDaemonServiceRuntimeHeartbeatStale(state)) {\n return {\n status: \"stale\",\n mode: state.mode,\n pid: state.pid,\n startedAt: state.startedAt,\n updatedAt: state.updatedAt,\n managedBySystemService: state.managedBySystemService,\n serviceController: state.serviceController,\n autoStart: state.autoStart,\n reason: \"heartbeat_stale\",\n };\n }\n return {\n status: \"running\",\n mode: state.mode,\n pid: state.pid,\n startedAt: state.startedAt,\n updatedAt: state.updatedAt,\n managedBySystemService: state.managedBySystemService,\n serviceController: state.serviceController,\n autoStart: state.autoStart,\n };\n}\n\nexport async function readDaemonServiceRuntimeSnapshot(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<DaemonServiceRuntimeState | null> {\n return await readDaemonServiceRuntimeState(pathInput);\n}\n\nexport function resolveDaemonServiceRuntimeMetadata(\n input: DaemonServiceRuntimeMetadataInput = {}\n): DaemonServiceRuntimeMetadata {\n const env = input.env ?? process.env;\n const managedBySystemService =\n input.managedBySystemService === true ||\n env[DAEMON_SERVICE_RUNTIME_SYSTEM_SERVICE_ENV] === \"1\";\n const serviceControllerInput =\n typeof input.serviceController === \"string\" &&\n input.serviceController.length > 0\n ? input.serviceController\n : env[DAEMON_SERVICE_RUNTIME_CONTROLLER_ENV];\n const autoStart =\n input.autoStart === true ||\n env[DAEMON_SERVICE_RUNTIME_AUTO_START_ENV] === \"1\";\n\n return {\n managedBySystemService,\n serviceController: parseDaemonServiceController(serviceControllerInput),\n autoStart,\n };\n}\n\nexport async function setDaemonServiceRuntimeState(\n state: DaemonServiceRuntimeState,\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<void> {\n await writeDaemonServiceRuntimeState(state, pathInput);\n}\n\nexport async function clearDaemonServiceRuntimeState(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<void> {\n const { clearDaemonRuntimeLease } = await import(\"./daemon-runtime-lease\");\n await Promise.all([\n rm(daemonServiceRuntimeStatePath(pathInput), { force: true }),\n clearDaemonRuntimeLease(pathInput),\n ]);\n}\n\nexport function withDaemonServiceRunLock<T>(\n callback: () => Promise<T>,\n meta: DaemonLifecycleLockMeta = {\n intent: \"run_background\",\n command: \"openmeld service start\",\n }\n): Promise<T> {\n return withDaemonServiceLifecycleLock(meta, callback);\n}\n\nexport async function acquireDaemonServiceLifecycleLock(\n meta: DaemonLifecycleLockMeta = {\n intent: \"run_background\",\n command: \"openmeld service start\",\n },\n pathResolution: OpenMeldPathResolutionInput = resolveOpenMeldServiceOwnedPathInput()\n): Promise<DaemonServiceLifecycleLock> {\n return await acquireLock({\n openMeldProfileId: DAEMON_SERVICE_LIFECYCLE_LOCK_PROFILE,\n key: DAEMON_SERVICE_LIFECYCLE_LOCK_KEY,\n meta,\n pathResolution,\n });\n}\n\nexport async function releaseDaemonServiceLifecycleLock(\n lock: DaemonServiceLifecycleLock\n): Promise<void> {\n await releaseLock(lock);\n}\n\nexport function withDaemonServiceStopLock<T>(\n callback: () => Promise<T>,\n meta: DaemonLifecycleLockMeta = {\n intent: \"stop\",\n command: \"openmeld service stop\",\n }\n): Promise<T> {\n return withDaemonServiceLifecycleLock(meta, callback);\n}\n\nexport function withDaemonServiceReconcileLock<T>(\n callback: () => Promise<T>,\n meta: DaemonLifecycleLockMeta = {\n intent: \"upgrade_reconcile\",\n command: \"openmeld service update\",\n }\n): Promise<T> {\n return withDaemonServiceLifecycleLock(meta, callback);\n}\n\nexport function withDaemonServiceRegistrationMutationLock<T>(\n callback: () => Promise<T>,\n meta: DaemonLifecycleLockMeta\n): Promise<T> {\n return withDaemonServiceLifecycleLock(meta, callback);\n}\n\nexport function withDaemonServiceLifecycleLock<T>(\n meta: DaemonLifecycleLockMeta,\n callback: () => Promise<T>,\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<T> {\n const pathResolution = resolveOpenMeldServiceOwnedPathInput(pathInput);\n const ownerRoot = resolveOpenMeldRootDir(pathResolution);\n const currentContext = daemonServiceLifecycleLockContext.getStore();\n if (currentContext?.active && currentContext.ownerRoot === ownerRoot) {\n let operation: Promise<T>;\n try {\n operation = callback();\n } catch (error) {\n operation = Promise.reject(error);\n }\n let trackedOperation: Promise<void>;\n trackedOperation = operation\n .then(\n () => undefined,\n (error: unknown) => {\n currentContext.failures.push(error);\n }\n )\n .finally(() => {\n currentContext.pendingOperations.delete(trackedOperation);\n });\n currentContext.pendingOperations.add(trackedOperation);\n return operation;\n }\n return withDaemonServiceLifecycleOwnerLock({\n callback,\n meta,\n ownerRoot,\n pathResolution,\n });\n}\n\nasync function withDaemonServiceLifecycleOwnerLock<T>(input: {\n callback: () => Promise<T>;\n meta: DaemonLifecycleLockMeta;\n ownerRoot: string;\n pathResolution: OpenMeldPathResolutionInput;\n}): Promise<T> {\n const lock = await acquireDaemonServiceLifecycleLock(\n input.meta,\n input.pathResolution\n );\n return await runWithHeldLock({\n lock,\n run: async () => {\n const context: DaemonServiceLifecycleLockContext = {\n lock,\n active: true,\n failures: [],\n ownerRoot: input.ownerRoot,\n pendingOperations: new Set(),\n };\n let outcome: { ok: true; value: T } | { ok: false; error: unknown };\n try {\n outcome = {\n ok: true,\n value: await daemonServiceLifecycleLockContext.run(\n context,\n input.callback\n ),\n };\n } catch (error) {\n outcome = { ok: false, error };\n } finally {\n while (context.pendingOperations.size > 0) {\n await Promise.all([...context.pendingOperations]);\n }\n context.active = false;\n }\n const failures = [\n ...(outcome.ok ? [] : [outcome.error]),\n ...context.failures,\n ].filter(\n (failure, index, allFailures) => allFailures.indexOf(failure) === index\n );\n if (failures.length === 1) {\n throw failures[0];\n }\n if (failures.length > 1) {\n throw new AggregateError(\n failures,\n \"daemon service lifecycle mutation failed in more than one operation\"\n );\n }\n if (!outcome.ok) {\n throw outcome.error;\n }\n return outcome.value;\n },\n releaseContext: {\n command: input.meta.command,\n component: \"daemon_service_lifecycle\",\n intent: input.meta.intent,\n lockKey: DAEMON_SERVICE_LIFECYCLE_LOCK_KEY,\n openMeldProfileId: DAEMON_SERVICE_LIFECYCLE_LOCK_PROFILE,\n },\n });\n}\n\nexport async function readDaemonServiceLifecycleLockMeta(): Promise<DaemonLifecycleLockMeta | null> {\n const meta = await readLockMeta({\n openMeldProfileId: DAEMON_SERVICE_LIFECYCLE_LOCK_PROFILE,\n key: DAEMON_SERVICE_LIFECYCLE_LOCK_KEY,\n pathResolution: resolveOpenMeldServiceOwnedPathInput(),\n });\n if (!meta) {\n return null;\n }\n const intent =\n typeof meta.intent === \"string\"\n ? normalizeDaemonLifecycleIntent(meta.intent)\n : null;\n const command = typeof meta.command === \"string\" ? meta.command.trim() : \"\";\n if (!intent || command.length === 0) {\n return null;\n }\n const pid = typeof meta.pid === \"number\" ? meta.pid : undefined;\n const sessionId =\n typeof meta.sessionId === \"string\" && meta.sessionId.trim().length > 0\n ? meta.sessionId.trim()\n : undefined;\n const at =\n typeof meta.at === \"string\" && meta.at.trim().length > 0\n ? meta.at.trim()\n : undefined;\n return {\n intent,\n command,\n ...(typeof pid === \"number\" ? { pid } : {}),\n ...(sessionId ? { sessionId } : {}),\n ...(at ? { at } : {}),\n };\n}\n\nexport async function readDaemonServiceLifecycleLockMetaWithCleanup(): Promise<DaemonLifecycleLockMeta | null> {\n await tryCleanupStaleLock({\n openMeldProfileId: DAEMON_SERVICE_LIFECYCLE_LOCK_PROFILE,\n key: DAEMON_SERVICE_LIFECYCLE_LOCK_KEY,\n pathResolution: resolveOpenMeldServiceOwnedPathInput(),\n });\n return await readDaemonServiceLifecycleLockMeta();\n}\n\nexport async function installDaemon(input: {\n daemonVersion: string;\n source: DaemonInstallSource;\n}): Promise<DaemonInstallResult> {\n const existingState = await readDaemonInstallState();\n const runtimeExists = await pathExists(daemonRuntimeRootPath());\n if (\n existingState &&\n runtimeExists &&\n existingState.daemonVersion === input.daemonVersion\n ) {\n await ensureDaemonTokenState();\n return {\n status: \"already_installed\",\n state: existingState,\n };\n }\n\n await ensureDaemonRuntimeLayout();\n const now = new Date().toISOString();\n const nextState: DaemonInstallState = {\n v: 1,\n schema: DAEMON_STATE_SCHEMA,\n daemonVersion: input.daemonVersion,\n installSource: input.source,\n installedAt: existingState?.installedAt ?? now,\n updatedAt: now,\n };\n await writeDaemonInstallState(nextState);\n await ensureDaemonTokenState();\n\n return {\n status: \"installed\",\n state: nextState,\n };\n}\n\nexport async function uninstallDaemon(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<DaemonUninstallResult> {\n const [hasState, hasRuntimeDir, hasToken] = await Promise.all([\n pathExists(daemonStatePath(pathInput)),\n pathExists(daemonRuntimeRootPath(pathInput)),\n pathExists(daemonTokenPath(pathInput)),\n ]);\n\n await Promise.all([\n rm(daemonStatePath(pathInput), { force: true }),\n rm(daemonTokenPath(pathInput), { force: true }),\n rm(daemonServiceRuntimeStatePath(pathInput), { force: true }),\n rm(daemonRuntimeRootPath(pathInput), { recursive: true, force: true }),\n ]);\n\n return {\n removed: hasState || hasRuntimeDir || hasToken,\n };\n}\n\nexport function daemonStatePath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(systemDir(pathInput), \"daemon-install.json\");\n}\n\nexport function daemonRuntimeRootPath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(runtimeDir(pathInput), \"daemon\");\n}\n\nexport function daemonServiceRuntimeStatePath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(daemonRuntimeRootPath(pathInput), \"service-runtime.json\");\n}\n\nexport function daemonRuntimeDataPath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(daemonRuntimeRootPath(pathInput), \"data\");\n}\n\nexport function daemonRuntimeBundlesPath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(daemonRuntimeRootPath(pathInput), \"bundles\");\n}\n\nexport function daemonRuntimeStateRootPath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(daemonRuntimeRootPath(pathInput), \"state\");\n}\n\nexport function daemonLifecycleJournalPath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(\n daemonRuntimeRootPath(pathInput),\n \"logs\",\n DAEMON_LIFECYCLE_JOURNAL_FILENAME\n );\n}\n\nexport function daemonDispatchJournalPath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(\n daemonRuntimeRootPath(pathInput),\n \"logs\",\n DAEMON_DISPATCH_JOURNAL_FILENAME\n );\n}\n\nexport function daemonServiceActiveBundleStatePath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(\n daemonRuntimeStateRootPath(pathInput),\n DAEMON_ACTIVE_BUNDLE_STATE_FILENAME\n );\n}\n\nexport function daemonServiceRepairJournalPath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(\n daemonRuntimeStateRootPath(pathInput),\n DAEMON_REPAIR_JOURNAL_FILENAME\n );\n}\n\nexport function daemonRuntimeServiceManagerPath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(daemonRuntimeRootPath(pathInput), \"service-manager\");\n}\n\nexport function daemonServiceStableLauncherPath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(\n daemonRuntimeServiceManagerPath(pathInput),\n DAEMON_STABLE_LAUNCHER_FILENAME\n );\n}\n\nexport function daemonServiceStableExecutableWrapperPath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n const preset = resolveOpenMeldEnvPreset(pathInput);\n return join(\n daemonRuntimeServiceManagerPath(pathInput),\n DAEMON_SERVICE_EXECUTABLE_WRAPPER_FILENAME_BY_PRESET[preset]\n );\n}\n\nexport function daemonServiceStableBinaryExecutablePath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n const preset = resolveOpenMeldEnvPreset(pathInput);\n return join(\n daemonRuntimeServiceManagerPath(pathInput),\n DAEMON_SERVICE_BINARY_EXECUTABLE_FILENAME_BY_PRESET[preset]\n );\n}\n\nexport function daemonServiceUpdateWorkerBinaryExecutablePath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n const preset = resolveOpenMeldEnvPreset(pathInput);\n return join(\n daemonRuntimeServiceManagerPath(pathInput),\n DAEMON_SERVICE_UPDATE_WORKER_BINARY_FILENAME_BY_PRESET[preset]\n );\n}\n\nexport function daemonServiceLegacyExecutableWrapperPath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n const preset = resolveOpenMeldEnvPreset(pathInput);\n return join(\n daemonRuntimeServiceManagerPath(pathInput),\n DAEMON_SERVICE_LEGACY_EXECUTABLE_WRAPPER_FILENAME_BY_PRESET[preset]\n );\n}\n\nexport function daemonServiceExecutableWrapperPaths(\n pathInput: OpenMeldPathResolutionInput = {}\n): string[] {\n return [\n daemonServiceStableExecutableWrapperPath(pathInput),\n daemonServiceLegacyExecutableWrapperPath(pathInput),\n ];\n}\n\nexport function daemonServiceRecognizedExecutablePaths(\n pathInput: OpenMeldPathResolutionInput = {}\n): string[] {\n return [\n daemonServiceStableBinaryExecutablePath(pathInput),\n ...daemonServiceExecutableWrapperPaths(pathInput),\n ];\n}\n\nexport function daemonTokenPath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(systemDir(pathInput), \"daemon-token.json\");\n}\n\nexport async function restoreDaemonInstallStateSnapshot(\n snapshot: DaemonInstallState | null,\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<void> {\n if (!snapshot) {\n await rm(daemonStatePath(pathInput), { force: true });\n return;\n }\n await writeDaemonInstallState(snapshot, pathInput);\n}\n\nexport function resolveDaemonControlPlaneEndpoint(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n const runtimeRoot = daemonRuntimeRootPath(pathInput);\n const suffix = createHash(\"sha256\")\n .update(runtimeRoot)\n .digest(\"hex\")\n .slice(0, 24);\n if (process.platform === \"win32\") {\n return `\\\\\\\\.\\\\pipe\\\\openmeld-daemon-control-${suffix}`;\n }\n return join(tmpdir(), `openmeld-daemon-control-${suffix}.sock`);\n}\n\nexport async function ensureDaemonControlPlaneToken(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<string> {\n const state = await ensureDaemonTokenState(pathInput);\n return state.token;\n}\n\nexport async function rotateDaemonControlPlaneTokenIfExpired(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<DaemonTokenState> {\n const current = await readDaemonTokenState(pathInput);\n if (current && !isDaemonTokenExpired(current)) {\n await chmod(daemonTokenPath(pathInput), 0o600).catch(() => undefined);\n return current;\n }\n\n return await writeNewDaemonTokenState(pathInput);\n}\n\nexport async function readDaemonControlPlaneToken(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<string | null> {\n const state = await readDaemonTokenState(pathInput);\n return state?.token ?? null;\n}\n\nfunction isPidAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n return !(\n error instanceof Error &&\n (error as NodeJS.ErrnoException).code === \"ESRCH\"\n );\n }\n}\n\nasync function readDaemonServiceRuntimeState(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<DaemonServiceRuntimeState | null> {\n const raw = await readFile(\n daemonServiceRuntimeStatePath(pathInput),\n \"utf8\"\n ).catch((error) => {\n if (\n error &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n ) {\n return null;\n }\n throw error;\n });\n if (raw === null) {\n return null;\n }\n return parseDaemonServiceRuntimeState(raw);\n}\n\nfunction parseDaemonServiceRuntimeState(\n raw: string\n): DaemonServiceRuntimeState | null {\n try {\n const parsed = JSON.parse(raw);\n if (!isDaemonServiceRuntimeStateObject(parsed)) {\n return null;\n }\n\n return {\n v: 1,\n schema: DAEMON_SERVICE_RUNTIME_STATE_SCHEMA,\n status: \"running\",\n pid: parsed.pid,\n mode: parsed.mode,\n command: parsed.command,\n gatewayUrl: parseNullableString(parsed.gatewayUrl),\n openMeldProfileId: resolveStoredDaemonServiceOpenMeldProfileId(parsed),\n stopRequestedAt: parseNullableString(parsed.stopRequestedAt),\n heartbeatAt: parseNullableString(parsed.heartbeatAt),\n startedAt: parsed.startedAt,\n updatedAt: parsed.updatedAt,\n managedBySystemService: parsed.managedBySystemService === true,\n serviceController: parseDaemonServiceController(parsed.serviceController),\n autoStart: parsed.autoStart === true,\n };\n } catch {\n return null;\n }\n}\n\nfunction isDaemonServiceRuntimeStateObject(value: unknown): value is {\n v: 1;\n schema: string;\n status: \"running\";\n pid: number;\n mode: DaemonRunMode;\n command: string;\n gatewayUrl: string | null;\n openMeldProfileId?: string | null;\n profile?: string | null;\n stopRequestedAt: string | null;\n heartbeatAt: string | null;\n startedAt: string;\n updatedAt: string;\n managedBySystemService?: boolean;\n serviceController?: string;\n autoStart?: boolean;\n} {\n if (!value || typeof value !== \"object\") {\n return false;\n }\n const candidate = value as Record<string, unknown>;\n return (\n candidate.v === 1 &&\n candidate.schema === DAEMON_SERVICE_RUNTIME_STATE_SCHEMA &&\n candidate.status === \"running\" &&\n typeof candidate.pid === \"number\" &&\n candidate.pid > 0 &&\n (candidate.mode === \"foreground\" || candidate.mode === \"background\") &&\n typeof candidate.command === \"string\" &&\n candidate.command.length > 0 &&\n isValidNullableString(candidate.gatewayUrl) &&\n isValidOptionalNullableString(candidate.openMeldProfileId) &&\n isValidOptionalNullableString(candidate.profile) &&\n isValidNullableString(candidate.stopRequestedAt) &&\n isValidNullableString(candidate.heartbeatAt) &&\n typeof candidate.startedAt === \"string\" &&\n candidate.startedAt.length > 0 &&\n typeof candidate.updatedAt === \"string\" &&\n candidate.updatedAt.length > 0\n );\n}\n\nexport function parseDaemonServiceController(\n value: unknown\n): DaemonServiceController {\n if (\n value === \"launchd\" ||\n value === \"systemd\" ||\n value === \"windows-service\" ||\n value === \"legacy-detached\" ||\n value === \"unknown\"\n ) {\n return value;\n }\n return \"unknown\";\n}\n\nfunction isValidNullableString(value: unknown): value is string | null {\n return value === null || typeof value === \"string\";\n}\n\nfunction isValidOptionalNullableString(\n value: unknown\n): value is string | null | undefined {\n return value === undefined || value === null || typeof value === \"string\";\n}\n\nfunction parseNullableString(value: unknown): string | null {\n if (value === null) {\n return null;\n }\n if (typeof value !== \"string\") {\n return null;\n }\n return value;\n}\n\nfunction resolveStoredDaemonServiceOpenMeldProfileId(input: {\n openMeldProfileId?: unknown;\n profile?: unknown;\n}): string | null {\n const openMeldProfileId = parseNullableString(input.openMeldProfileId);\n const legacyProfile = parseNullableString(input.profile);\n if (\n openMeldProfileId &&\n legacyProfile &&\n openMeldProfileId !== legacyProfile\n ) {\n throw new Error(\"conflicting openMeldProfileId values\");\n }\n return openMeldProfileId ?? legacyProfile;\n}\n\nexport function isDaemonServiceRuntimeHeartbeatStale(\n state: DaemonServiceRuntimeState\n): boolean {\n const latestSignalAt = Math.max(\n parseIsoTimestampOrZero(state.heartbeatAt),\n parseIsoTimestampOrZero(state.updatedAt)\n );\n if (latestSignalAt <= 0) {\n return false;\n }\n return Date.now() - latestSignalAt > DAEMON_HEARTBEAT_STALE_MS;\n}\n\nfunction parseIsoTimestampOrZero(value: string | null): number {\n if (!value) {\n return 0;\n }\n const parsed = Date.parse(value);\n return Number.isFinite(parsed) ? parsed : 0;\n}\n\nasync function writeDaemonServiceRuntimeState(\n state: DaemonServiceRuntimeState,\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<void> {\n const path = daemonServiceRuntimeStatePath(pathInput);\n const runtimeRootPath = daemonRuntimeRootPath(pathInput);\n await mkdir(runtimeRootPath, { recursive: true });\n const tempPath = `${path}.tmp-${process.pid}-${Date.now()}`;\n let shouldCleanupTemp = true;\n\n try {\n await writeFile(tempPath, `${JSON.stringify(state, null, 2)}\\n`, {\n encoding: \"utf8\",\n mode: 0o600,\n });\n await rename(tempPath, path);\n await chmod(path, 0o600);\n shouldCleanupTemp = false;\n } finally {\n if (shouldCleanupTemp) {\n await rm(tempPath, { force: true }).catch(() => undefined);\n }\n }\n}\n\nasync function ensureDaemonRuntimeLayout(): Promise<void> {\n await Promise.all([\n mkdir(systemDir(), { recursive: true }),\n mkdir(join(daemonRuntimeRootPath(), \"bin\"), { recursive: true }),\n mkdir(daemonRuntimeBundlesPath(), { recursive: true }),\n mkdir(join(daemonRuntimeRootPath(), \"data\"), { recursive: true }),\n mkdir(join(daemonRuntimeRootPath(), \"logs\"), { recursive: true }),\n mkdir(daemonRuntimeStateRootPath(), { recursive: true }),\n mkdir(daemonRuntimeServiceManagerPath(), { recursive: true }),\n ]);\n}\n\nfunction normalizeDaemonLifecycleIntent(\n value: string\n): DaemonLifecycleIntent | null {\n switch (value) {\n case \"run_background\":\n case \"run_foreground\":\n case \"stop\":\n case \"autostart\":\n case \"status_cleanup\":\n case \"startup_check\":\n case \"start\":\n case \"reinstall\":\n case \"uninstall\":\n case \"upgrade_reconcile\":\n return value;\n default:\n return null;\n }\n}\n\nasync function ensureDaemonTokenState(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<DaemonTokenState> {\n const current = await readDaemonTokenState(pathInput);\n if (current) {\n await chmod(daemonTokenPath(pathInput), 0o600).catch(() => undefined);\n return current;\n }\n\n return await writeNewDaemonTokenState(pathInput);\n}\n\nasync function writeNewDaemonTokenState(\n pathInput: OpenMeldPathResolutionInput\n): Promise<DaemonTokenState> {\n const nowIso = new Date().toISOString();\n const next: DaemonTokenState = {\n v: 1,\n schema: DAEMON_TOKEN_SCHEMA,\n token: createDaemonTokenValue(),\n issuedAt: nowIso,\n updatedAt: nowIso,\n };\n await writeDaemonTokenState(next, pathInput);\n return next;\n}\n\nasync function readDaemonInstallState(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<DaemonInstallState | null> {\n const raw = await readFile(daemonStatePath(pathInput), \"utf8\").catch(\n (error) => {\n if (\n error &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n ) {\n return null;\n }\n throw error;\n }\n );\n if (raw === null) {\n return null;\n }\n return parseDaemonInstallState(raw);\n}\n\nfunction parseDaemonInstallState(raw: string): DaemonInstallState | null {\n try {\n const parsed = JSON.parse(raw) as Partial<DaemonInstallState>;\n if (parsed.v !== 1) {\n return null;\n }\n if (parsed.schema !== DAEMON_STATE_SCHEMA) {\n return null;\n }\n if (typeof parsed.daemonVersion !== \"string\" || !parsed.daemonVersion) {\n return null;\n }\n if (!isDaemonInstallSource(parsed.installSource)) {\n return null;\n }\n if (typeof parsed.installedAt !== \"string\" || !parsed.installedAt) {\n return null;\n }\n if (typeof parsed.updatedAt !== \"string\" || !parsed.updatedAt) {\n return null;\n }\n return {\n v: 1,\n schema: DAEMON_STATE_SCHEMA,\n daemonVersion: parsed.daemonVersion,\n installSource: parsed.installSource,\n installedAt: parsed.installedAt,\n updatedAt: parsed.updatedAt,\n };\n } catch {\n return null;\n }\n}\n\nfunction isDaemonInstallSource(value: unknown): value is DaemonInstallSource {\n return value === \"cli.auto_check\" || value === \"daemon.command.install\";\n}\n\nasync function writeDaemonInstallState(\n state: DaemonInstallState,\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<void> {\n const path = daemonStatePath(pathInput);\n await mkdir(systemDir(pathInput), { recursive: true });\n const tempPath = `${path}.tmp-${process.pid}-${Date.now()}`;\n let shouldCleanupTemp = true;\n\n try {\n await writeFile(tempPath, `${JSON.stringify(state, null, 2)}\\n`, \"utf8\");\n await rename(tempPath, path);\n shouldCleanupTemp = false;\n } finally {\n if (shouldCleanupTemp) {\n await rm(tempPath, { force: true }).catch(() => undefined);\n }\n }\n}\n\nasync function readDaemonTokenState(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<DaemonTokenState | null> {\n const raw = await readFile(daemonTokenPath(pathInput), \"utf8\").catch(\n (error) => {\n if (\n error &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n ) {\n return null;\n }\n throw error;\n }\n );\n if (raw === null) {\n return null;\n }\n return parseDaemonTokenState(raw);\n}\n\nfunction parseDaemonTokenState(raw: string): DaemonTokenState | null {\n try {\n const parsed = JSON.parse(raw) as Partial<DaemonTokenState>;\n if (parsed.v !== 1 || parsed.schema !== DAEMON_TOKEN_SCHEMA) {\n return null;\n }\n if (typeof parsed.token !== \"string\" || parsed.token.length < 16) {\n return null;\n }\n if (typeof parsed.issuedAt !== \"string\" || !parsed.issuedAt) {\n return null;\n }\n if (typeof parsed.updatedAt !== \"string\" || !parsed.updatedAt) {\n return null;\n }\n return {\n v: 1,\n schema: DAEMON_TOKEN_SCHEMA,\n token: parsed.token,\n issuedAt: parsed.issuedAt,\n updatedAt: parsed.updatedAt,\n };\n } catch {\n return null;\n }\n}\n\nasync function writeDaemonTokenState(\n state: DaemonTokenState,\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<void> {\n const path = daemonTokenPath(pathInput);\n await mkdir(systemDir(pathInput), { recursive: true });\n const tempPath = `${path}.tmp-${process.pid}-${Date.now()}`;\n let shouldCleanupTemp = true;\n\n try {\n await writeFile(tempPath, `${JSON.stringify(state, null, 2)}\\n`, {\n encoding: \"utf8\",\n mode: 0o600,\n });\n await rename(tempPath, path);\n await chmod(path, 0o600);\n shouldCleanupTemp = false;\n } finally {\n if (shouldCleanupTemp) {\n await rm(tempPath, { force: true }).catch(() => undefined);\n }\n }\n}\n\nfunction isDaemonTokenExpired(state: DaemonTokenState): boolean {\n const updatedAtMs = Date.parse(state.updatedAt);\n if (!Number.isFinite(updatedAtMs)) {\n return true;\n }\n return Date.now() - updatedAtMs >= DAEMON_TOKEN_ROTATE_MAX_AGE_MS;\n}\n\nfunction createDaemonTokenValue(): string {\n return randomBytes(32).toString(\"base64url\");\n}\n\nasync function pathExists(path: string): Promise<boolean> {\n try {\n await stat(path);\n return true;\n } catch (error) {\n if (\n error &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n ) {\n return false;\n }\n throw error;\n }\n}\n"],"mappings":";;;;;;;;;;AA8BA,MAAM,sBAAsB;AAC5B,MAAa,sCACX;AACF,MAAa,kCAAkC;AAC/C,MAAa,sCACX;AACF,MAAa,wCACX;AACF,MAAa,wCACX;AACF,MAAa,4CACX;AACF,MAAM,sBAAsB;AAC5B,MAAM,iCAAiC,OAAU,KAAK;AACtD,MAAa,4BAA4B,MAAS;AAClD,MAAM,sCAAsC;AAC5C,MAAM,mCAAmC;AACzC,MAAM,oCAAoC;AAC1C,MAAM,iCAAiC;AACvC,MAAM,8BAA8B;AACpC,MAAM,0BAA0B;AAQhC,MAAM,oCACJ,IAAI,kBAAqD;AAE3D,SAAgB,oCAAyD;CACvE,MAAM,UAAU,kCAAkC,SAAS;CAC3D,OAAO,SAAS,UACd,QAAQ,cACN,uBAAuB,qCAAqC,CAAC,IAC7D,QAAQ,OACR;AACN;AACA,MAAM,kCAAkC;AACxC,MAAM,uDAAuD;CAC3D,MAAM;CACN,aAAa;CACb,QAAQ;AACV;AACA,MAAM,sDAAsD;CAC1D,MAAM;CACN,aAAa;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|
|
|
3
|
-
import { $t as buildDispatchReplyContextSummary,
|
|
4
|
-
import { d as createDefaultRuntimeAgentControllerSettings } from "./base-url-
|
|
3
|
+
import { $t as buildDispatchReplyContextSummary, Ct as canonicalizeLocalProjectPath, Et as withAgentActivityLocalStateLock, Ir as renderInformationProtectionPrompt, Nr as parseAgentControllerRef, Rr as renderWorkingLanguagePrompt, Sr as buildWorkingLanguagePromptPlan, Yt as SPACE_ACTION_CONTEXT_GUIDANCE_LINES, ft as isProjectBound, kr as isAgentControllerUsageAccountUnavailable, pt as listProjectBindings, qn as DaemonServiceRunError, ur as buildCliLaunchInvocation, wt as resolveLocalProjectConnectionForPath, xr as buildInformationProtectionPromptPlan, yr as areAgentControllerInterfaceAccountsSame } from "./prepare-provider-runtime-BbJnigvx.js";
|
|
4
|
+
import { d as createDefaultRuntimeAgentControllerSettings } from "./base-url-Cno_Uo8f.js";
|
|
5
5
|
import { F as resolveOpenMeldRootDir, P as resolveOpenMeldEnvPreset, b as normalizeOpenMeldProfileId, g as legacyAccountProfileSpacesDir, r as accountProfileSpaceCacheDir, w as openMeldManagedBinaryPath } from "./paths-De9xdA2h.js";
|
|
6
|
-
import {
|
|
7
|
-
import { v as resolveCliContextId } from "./lock-
|
|
8
|
-
import { F as resolveCurrentOpenMeldAccountContext } from "./context-
|
|
6
|
+
import { Dp as spaceMemberDirectoryEntrySchema, Gg as agentActivityEventSchema, J_ as spaceCreatorSchema, Lg as AGENT_ACTIVITY_PRESENCE_TTL_MAX_MS, Mf as organizationSkillRuntimeReleaseSelectionSchema, Mx as runtimeTransportRegisterSessionResponseSchema, QD as executionContextAssignmentSchema, UR as openMeldRuntimeProfileIdSchema, Vb as daemonStreamFrameSchema, Xt as spaceEntryTargetSchema, ZO as runtimeCoordinatorExecutionTokenEchoSchema, _D as normalizeMessageEnvelope, _k as normalizeSpacePasswordText, _x as runtimeTransportHeartbeatResponseSchema, aD as MESSAGE_MENTION_TYPE_VALUES, bS as openMeldSpaceEgressActionSchema, bk as resolveSingleSpaceMentionLabels, ej as computerFileAccessPolicyInputSchema, fD as getSpaceMessageAddressingRelationSupportForTargetKind, rj as computerFileAccessPolicySchema, sw as sanitizeSignalTextPreview, uD as collectCanonicalMentionTextFragments, x as agentControllerSessionTitleSchema, xk as resolveSpaceMentionLabels, yD as resolveMessageEnvelopeTargetField } from "./dist-BOBe5eOZ.js";
|
|
7
|
+
import { v as resolveCliContextId } from "./lock-y1PCtVSn.js";
|
|
8
|
+
import { F as resolveCurrentOpenMeldAccountContext } from "./context-NLQSSnf9.js";
|
|
9
9
|
import { a as formatOpenMeldCliTextBlock } from "./cli-entry-command-CR_9QU1i.js";
|
|
10
|
-
import { d as getAuthSessionState } from "./auth-session-
|
|
10
|
+
import { d as getAuthSessionState } from "./auth-session-BpRplB8x.js";
|
|
11
11
|
import { n as resolveOpenMeldDistribution } from "./distribution-BDQT2ilb.js";
|
|
12
|
-
import { a as DAEMON_SERVICE_RUNTIME_MODE_ENV, d as daemonDispatchJournalPath, h as daemonRuntimeRootPath, i as DAEMON_SERVICE_RUNTIME_DETACHED_ENV, n as DAEMON_SERVICE_RUNTIME_AUTO_START_ENV, r as DAEMON_SERVICE_RUNTIME_CONTROLLER_ENV, s as DAEMON_SERVICE_RUNTIME_SYSTEM_SERVICE_ENV } from "./daemon-state-
|
|
13
|
-
import { a as asRecord, d as normalizeText, l as normalizeNonNegativeInteger$1, s as emitRunLine, u as normalizeOptionalText$8 } from "./daemon-device-id-
|
|
14
|
-
import { B as buildCenterAgentRoleTemplateText, F as SPACE_COLLABORATION_CONTEXT_RULE, H as buildSpaceAgentIdentityLine, J as isSelfWakeSpaceAction, K as composeDispatchBrief, R as buildAgentFacingMentalModelLines, U as buildSpaceEntryBriefNeedMoreLine, V as buildCompactDispatchActionGuidanceLines, W as buildSpaceWakeParticipantLines, Y as renderSpaceEntryBrief, Z as resolveSpacePublicationRequirement, q as deriveContinuity } from "./dual-view-guide-catalog-
|
|
12
|
+
import { a as DAEMON_SERVICE_RUNTIME_MODE_ENV, d as daemonDispatchJournalPath, h as daemonRuntimeRootPath, i as DAEMON_SERVICE_RUNTIME_DETACHED_ENV, n as DAEMON_SERVICE_RUNTIME_AUTO_START_ENV, r as DAEMON_SERVICE_RUNTIME_CONTROLLER_ENV, s as DAEMON_SERVICE_RUNTIME_SYSTEM_SERVICE_ENV } from "./daemon-state-CiTQcAWA.js";
|
|
13
|
+
import { a as asRecord, d as normalizeText, l as normalizeNonNegativeInteger$1, s as emitRunLine, u as normalizeOptionalText$8 } from "./daemon-device-id-Dd-E5NjT.js";
|
|
14
|
+
import { B as buildCenterAgentRoleTemplateText, F as SPACE_COLLABORATION_CONTEXT_RULE, H as buildSpaceAgentIdentityLine, J as isSelfWakeSpaceAction, K as composeDispatchBrief, R as buildAgentFacingMentalModelLines, U as buildSpaceEntryBriefNeedMoreLine, V as buildCompactDispatchActionGuidanceLines, W as buildSpaceWakeParticipantLines, Y as renderSpaceEntryBrief, Z as resolveSpacePublicationRequirement, q as deriveContinuity } from "./dual-view-guide-catalog-CSV_FNr4.js";
|
|
15
15
|
import { createHash, randomUUID } from "node:crypto";
|
|
16
16
|
import { homedir } from "node:os";
|
|
17
17
|
import { basename, delimiter, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
18
18
|
import { access, chmod, link, mkdir, open, readFile, readdir, realpath, rename, rm, stat, unlink, writeFile } from "node:fs/promises";
|
|
19
19
|
import { z } from "zod/v4";
|
|
20
|
-
import { appendFileSync, chmodSync, constants, existsSync, mkdirSync, readFileSync, renameSync, watch, writeFileSync } from "node:fs";
|
|
20
|
+
import { appendFileSync, chmodSync, constants, existsSync, mkdirSync, readFileSync, renameSync, rmdirSync, watch, writeFileSync } from "node:fs";
|
|
21
21
|
import process$1 from "node:process";
|
|
22
22
|
import { spawn } from "node:child_process";
|
|
23
23
|
import { isDeepStrictEqual } from "node:util";
|
|
@@ -2810,7 +2810,7 @@ const SPACE_ACTION_COMPLETION_RULES = [
|
|
|
2810
2810
|
"- Use the Space Action tool first. If your harness offers tool search or discovery, look up the required action before declaring it unavailable. A tool missing from the initial list is not proof of unavailability. Do not read setup or onboarding guides merely to submit this result.",
|
|
2811
2811
|
"- For a plain reply, omit wakeTargets and referenceTargets. Add targets only for an intentional handoff or reference to another Agent; never copy incoming activation targets or wake yourself.",
|
|
2812
2812
|
"- Submit the actual result and inspect the tool response before ending this turn.",
|
|
2813
|
-
"- After
|
|
2813
|
+
"- After a successful acknowledgement, do not repeat the submission. It confirms a recorded proposal, not final publication. If a material correction is needed before this turn ends, submit the complete revised reply; it updates the same reply. Private output does not revise the public reply. Do not change a reply into another final action type.",
|
|
2814
2814
|
"- If a Space Action submission is confirmed rejected before recording, follow its correction guidance. If its submission outcome is unknown, submit no further Space Action in this turn, including an error-report reply. End with the diagnostic; OpenMeld owns recovery. Do not switch tools to retry the submission.",
|
|
2815
2815
|
"- A failed context read or business tool is not a Space Action submission. If no Space Action has been submitted, use the required completion action to report the blocker honestly; do not invent results from unread material."
|
|
2816
2816
|
];
|
|
@@ -3724,7 +3724,7 @@ function toJournalErrorMessage(error) {
|
|
|
3724
3724
|
}
|
|
3725
3725
|
//#endregion
|
|
3726
3726
|
//#region src/local-service/inventory/agent-controller-interface-keeper.ts
|
|
3727
|
-
const LAST_GOOD_REUSE_TTL_MS =
|
|
3727
|
+
const LAST_GOOD_REUSE_TTL_MS = 6e4;
|
|
3728
3728
|
const AGENT_CONTROLLER_INTERFACE_REPROBE_DELAY_MS = 45e3;
|
|
3729
3729
|
const keeperEntries = /* @__PURE__ */ new Map();
|
|
3730
3730
|
function buildAgentControllerInterfaceKeeperKey(input) {
|
|
@@ -5945,6 +5945,36 @@ function readDispatchSpaceActionContext(contextPath) {
|
|
|
5945
5945
|
return parseDispatchSpaceActionContext(readJsonFile(contextPath));
|
|
5946
5946
|
}
|
|
5947
5947
|
function writeDispatchSpaceActionRecord(input) {
|
|
5948
|
+
return withDispatchSpaceActionRecordLock(input.context, () => writeLockedDispatchSpaceActionRecord(input));
|
|
5949
|
+
}
|
|
5950
|
+
function withDispatchSpaceActionRecordLock(context, mutate) {
|
|
5951
|
+
const lockPath = `${context.actionRecordPath}.lock`;
|
|
5952
|
+
mkdirSync(lockPath, { mode: 448 });
|
|
5953
|
+
try {
|
|
5954
|
+
return mutate();
|
|
5955
|
+
} finally {
|
|
5956
|
+
rmdirSync(lockPath);
|
|
5957
|
+
}
|
|
5958
|
+
}
|
|
5959
|
+
function replyDigest(action) {
|
|
5960
|
+
return createHash("sha256").update(JSON.stringify(action)).digest("hex");
|
|
5961
|
+
}
|
|
5962
|
+
function appendReplyDigest(previousReplyDigests, action) {
|
|
5963
|
+
if (previousReplyDigests.length >= 32) throw new DispatchSpaceActionRejectedError("space_action.already_recorded", "The reply revision limit has been reached. Read the current receipt.");
|
|
5964
|
+
return [...previousReplyDigests, replyDigest(action)];
|
|
5965
|
+
}
|
|
5966
|
+
function readReconsideredReplyHistory(context, action) {
|
|
5967
|
+
const archived = readDispatchSpaceActionRecord({ context: {
|
|
5968
|
+
...context,
|
|
5969
|
+
actionRecordPath: `${context.actionRecordPath}.superseded`
|
|
5970
|
+
} });
|
|
5971
|
+
if (archived.status === "invalid") throw new Error(archived.errorMessage);
|
|
5972
|
+
if (archived.status === "missing") return [];
|
|
5973
|
+
const previousReplyDigests = archived.record.previousReplyDigests ?? [];
|
|
5974
|
+
if (action.type === "post_message" && previousReplyDigests.includes(replyDigest(action))) throw new DispatchSpaceActionRejectedError("space_action.already_recorded", "This reply version was already replaced. Read the current receipt.");
|
|
5975
|
+
return archived.record.action.type === "post_message" && !isDeepStrictEqual(archived.record.action, action) ? appendReplyDigest(previousReplyDigests, archived.record.action) : previousReplyDigests;
|
|
5976
|
+
}
|
|
5977
|
+
function writeLockedDispatchSpaceActionRecord(input) {
|
|
5948
5978
|
const parsedAction = openMeldSpaceEgressActionSchema.safeParse(input.action);
|
|
5949
5979
|
if (!parsedAction.success) throw new DispatchSpaceActionRejectedError("space_action.invalid_input", parsedAction.error.message);
|
|
5950
5980
|
if (isSelfWakeSpaceAction(parsedAction.data, input.context.targetProfileId)) throw new DispatchSpaceActionRejectedError("space_action.invalid_input", "An Agent cannot Wake itself. To reply to the current message, omit wakeTargets (CLI: --wake) and submit the reply again. No action was recorded.");
|
|
@@ -5952,22 +5982,37 @@ function writeDispatchSpaceActionRecord(input) {
|
|
|
5952
5982
|
if (existing.status === "invalid") throw new Error(existing.errorMessage);
|
|
5953
5983
|
if (existing.status === "loaded" && isDeepStrictEqual(existing.record.action, parsedAction.data)) return existing.record;
|
|
5954
5984
|
assertContextActive(input.context, input.nowMs ?? Date.now());
|
|
5985
|
+
if (existing.status === "loaded" && existing.record.action.type === "post_message" && parsedAction.data.type === "post_message") {
|
|
5986
|
+
const previousReplyDigests = existing.record.previousReplyDigests ?? [];
|
|
5987
|
+
if (previousReplyDigests.includes(replyDigest(parsedAction.data))) return existing.record;
|
|
5988
|
+
const record = {
|
|
5989
|
+
version: DISPATCH_SPACE_ACTION_RECORD_VERSION,
|
|
5990
|
+
action: parsedAction.data,
|
|
5991
|
+
command: input.command,
|
|
5992
|
+
contextId: input.context.contextId,
|
|
5993
|
+
createdAtMs: input.nowMs ?? Date.now(),
|
|
5994
|
+
nonce: input.context.nonce,
|
|
5995
|
+
previousReplyDigests: appendReplyDigest(previousReplyDigests, existing.record.action)
|
|
5996
|
+
};
|
|
5997
|
+
const temporaryPath = `${input.context.actionRecordPath}.${randomUUID()}.tmp`;
|
|
5998
|
+
writeJsonFileExclusive(temporaryPath, record);
|
|
5999
|
+
renameSync(temporaryPath, input.context.actionRecordPath);
|
|
6000
|
+
return record;
|
|
6001
|
+
}
|
|
6002
|
+
const previousReplyDigests = existing.status === "missing" ? readReconsideredReplyHistory(input.context, parsedAction.data) : [];
|
|
5955
6003
|
const record = {
|
|
5956
6004
|
version: DISPATCH_SPACE_ACTION_RECORD_VERSION,
|
|
5957
6005
|
action: parsedAction.data,
|
|
5958
6006
|
command: input.command,
|
|
5959
6007
|
contextId: input.context.contextId,
|
|
5960
6008
|
createdAtMs: input.nowMs ?? Date.now(),
|
|
5961
|
-
nonce: input.context.nonce
|
|
6009
|
+
nonce: input.context.nonce,
|
|
6010
|
+
...previousReplyDigests.length ? { previousReplyDigests } : {}
|
|
5962
6011
|
};
|
|
5963
6012
|
try {
|
|
5964
6013
|
writeJsonFileExclusive(input.context.actionRecordPath, record);
|
|
5965
6014
|
} catch (error) {
|
|
5966
|
-
if (isNodeErrorCode(error, "EEXIST"))
|
|
5967
|
-
const existing = readDispatchSpaceActionRecord({ context: input.context });
|
|
5968
|
-
if (existing.status === "loaded" && isDeepStrictEqual(existing.record.action, parsedAction.data)) return existing.record;
|
|
5969
|
-
throw new DispatchSpaceActionRejectedError("space_action.already_recorded", "An OpenMeld Space Action has already been recorded for this dispatch. A Wake can only have one final Space action. Recover its receipt with the exact original arguments; do not replace it with a different action.");
|
|
5970
|
-
}
|
|
6015
|
+
if (isNodeErrorCode(error, "EEXIST")) throw new DispatchSpaceActionRejectedError("space_action.already_recorded", "An OpenMeld Space Action has already been recorded for this dispatch. A Wake can only have one final Space action. Recover its receipt with the exact original arguments; do not replace it with a different action.");
|
|
5971
6016
|
throw error;
|
|
5972
6017
|
}
|
|
5973
6018
|
return record;
|
|
@@ -5996,15 +6041,17 @@ function readDispatchSpaceActionRecord(input) {
|
|
|
5996
6041
|
}
|
|
5997
6042
|
}
|
|
5998
6043
|
function supersedeDispatchSpaceActionRecordForReconsideration(input) {
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6044
|
+
return withDispatchSpaceActionRecordLock(input.context, () => {
|
|
6045
|
+
const readResult = readDispatchSpaceActionRecord(input);
|
|
6046
|
+
if (readResult.status === "missing") return null;
|
|
6047
|
+
if (readResult.status === "invalid") throw new Error(readResult.errorMessage);
|
|
6048
|
+
const archivedPath = `${input.context.actionRecordPath}.superseded`;
|
|
6049
|
+
renameSync(input.context.actionRecordPath, archivedPath);
|
|
6050
|
+
return {
|
|
6051
|
+
archivedPath,
|
|
6052
|
+
record: readResult.record
|
|
6053
|
+
};
|
|
6054
|
+
});
|
|
6008
6055
|
}
|
|
6009
6056
|
function parseDispatchSpaceActionContext(value) {
|
|
6010
6057
|
const record = toRecord(value, "OpenMeld Space Action context");
|
|
@@ -6083,7 +6130,8 @@ function parseDispatchSpaceActionRecord(value) {
|
|
|
6083
6130
|
command: requiredString(record.command, "command"),
|
|
6084
6131
|
contextId: requiredString(record.contextId, "contextId"),
|
|
6085
6132
|
createdAtMs: requiredFiniteNumber(record.createdAtMs, "createdAtMs"),
|
|
6086
|
-
nonce: requiredString(record.nonce, "nonce")
|
|
6133
|
+
nonce: requiredString(record.nonce, "nonce"),
|
|
6134
|
+
...record.previousReplyDigests === void 0 ? {} : { previousReplyDigests: parseStringArray(record.previousReplyDigests) }
|
|
6087
6135
|
};
|
|
6088
6136
|
}
|
|
6089
6137
|
function parseSendTargetReference(value) {
|
|
@@ -6347,4 +6395,4 @@ function prependPathEntry(input) {
|
|
|
6347
6395
|
//#endregion
|
|
6348
6396
|
export { readReusableAgentControllerInterfaceSnapshot as $, createDispatchContinuationSpaceAccessContext as $t, buildAgentActivityEvent as A, toLocalSpaceStateIntegrityError as At, readAgentActivityOutboxHealth as B, buildPublicSpaceEntryUrl as Bt, recordOpenMeldCreatedLocalAgentSession as C, isLocalSpaceStateCorruptResult as Ct, readOpenCodeSessionRows as D, readSpaceLastSeenTs as Dt, queryOpenCodeReadOnly as E, readSpaceConfig as Et, enqueueAgentActivityHookEvent as F, writeSpaceRecentMentionProfileIds as Ft, buildCanonicalRepositoryUrl as G, buildSpaceMentionProfileIndex as Gt, removeProjectOutbox as H, buildSignalMessageReadProjection as Ht, removeProjectInbox as I, SpaceComposerSubmissionError as It, consumeArmedAgentControllerInterfaceReprobe as J, buildSpaceRoundReadProjection as Jt, buildRepositoryFingerprint as K, buildSpaceMessageReadRelationSummary as Kt, AgentActivitySubmissionResultsMismatchError as L, buildDispatchResultMessageReadProjection as Lt, normalizeSharedSessionTitle as M, updateSpaceLastSeenTs as Mt, readCodexSessionTitles as N, upsertSpaceConfig as Nt, resolveOpenCodeAuthPath as O, readSpaceRecentMentionProfileIds as Ot, drainAgentActivityHookInbox as P, writeSpaceCacheDeletionNoticeState as Pt, readLastSuccessfulAgentControllerInterfaceCheckAt as Q, collectResolvedSpaceMentions as Qt, applyAgentActivitySubmissionResults as R, buildDispatchResultReplyWorkflowProjection as Rt, readOpenMeldCreatedLocalAgentSessionProjectAttributions as S, OPENMELD_DISPATCH_RUNTIME_MODE_ENV as Sn, inspectSpaceCacheFile as St, resolveOpenMeldCreatedLocalAgentSessionProjectAttribution as T, readSpaceCacheDeletionNoticeState as Tt, readRecentAgentActivityHookStatus as U, buildSignalReplyWorkflowProjection as Ut, readDueAgentActivityOutbox as V, buildSignalIndex as Vt, createServiceGitEnvironment as W, buildSpaceMemberAgentPresencePresentation as Wt, readLastKnownAgentControllerAuthSnapshot as X, buildUpdatesReplyWorkflowProjection as Xt, didAgentControllerCommandFingerprintRemainStable as Y, buildSpaceRoundSignalPublication as Yt, readLastKnownAgentControllerUsageLimits as Z, closeMentionPickerState as Zt, sendDaemonFrame as _, resolveSpaceMemberAgentOwnerWakeDiagnosticsView as _n, resolveBootstrapSpaceOwnerProfileId as _t, DispatchSpaceActionClosedError as a, getSpaceAccessPassword as an, emitDaemonDispatchJournalEvent as at, startAgentActivityTranscriptWatchers as b, DISPATCH_OWNED_RUNTIME_MODE as bn, projectSpaceProfileCache as bt, createDispatchSpaceActionContext as c, isTargetPickerState as cn, readComputerFileAccessPolicy as ct, readDispatchSpaceActionRecord as d, listSpaceMentionRelationChoices as dn, isSameOrDescendantPath as dt, createSpaceMemberIdentityIndex as en, recordAgentControllerInterfaceProbeFailure as et, supersedeDispatchSpaceActionRecordForReconsideration as f, listSpaceMentionSuggestions as fn, buildDispatchBootstrapTemplateFacts as ft, parseDaemonFrame as g, resolveNextRecentMentionProfileIdsForQueuedText as gn, parseDispatchTask as gt, handleDaemonTransportFrame as h, prepareSpaceFileOnlySubmission as hn, buildDispatchSessionTitle as ht, readDispatchOwnedRuntimeGuard as i, formatRemovedCcRelationMessage as in, resolveNextRuntimeAgentControllerReportSyncAtMs as it, resolveObservedAgentActivityBinding as j, toSpaceConfigListIntegrityError as jt, resolveOpenCodeDatabasePath as k, removeSpaceConfig as kt, readDispatchSpaceActionContextForReceiptFromEnv as l, isWakeClosingSystemNoticeType as ln, resolveComputerFileAccessStorePath as lt, createCodexJsonRpcClient as m, prepareSpaceComposerSubmission as mn, buildDispatchPromptPlan as mt, assertDispatchOwnedRuntimeServiceMutationAllowed as n, enterRelationPickerState as nn, recordAgentControllerUsageLimitsObservation as nt, DispatchSpaceActionRejectedError as o, getSpaceAccessRequestContext as on, readRecentDaemonDispatchJournalEvents as ot, writeDispatchSpaceActionRecord as p, openTargetPickerState as pn, buildDispatchCorrelation as pt, buildAgentControllerInterfaceKeeperKey as q, buildSpaceProfileAddPlan as qt, buildDispatchOwnedRuntimeEnv as r, extractMentionAuthoringPrefix as rn, resolveAgentControllerCommandFingerprint as rt, OPENMELD_SPACE_ACTION_CONTEXT_PATH_ENV as s, isRelationPickerState as sn, ComputerFileAccessStoreError as st, assertDispatchOwnedRuntimePublicWriteAllowed as t, createSpaceTargetCatalog as tn, recordAgentControllerInterfaceProbeSuccess as tt, readDispatchSpaceActionContextFromEnv as u, listSpaceMemberDirectorySendTargets as un, updateComputerFileAccessPolicy as ut, collectObservedSessionWorkingDirectories as v, returnToTargetPickerState as vn, resolveBootstrapTargetProfileContext as vt, resolveLocalAgentSessionOrigin as w, listSpaceConfigs as wt, readOpenMeldCreatedLocalAgentSessionKeys as x, DISPATCH_SPACE_ACTION_CLI_FALLBACK_COMMAND as xn, LocalSpaceStateIntegrityError as xt, scanLocalAgentActivity as y, updateAuthoredMentionRanges as yn, resolveDispatchMentionSourceContext as yt, deferAgentActivityOutbox as z, buildPublicSpaceEntryPath as zt };
|
|
6349
6397
|
|
|
6350
|
-
//# sourceMappingURL=dispatch-owned-runtime-
|
|
6398
|
+
//# sourceMappingURL=dispatch-owned-runtime-rL1dMpSL.js.map
|