openmeld 0.3.82 → 0.3.84
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-Chf7oIxu.js → add-me-membership-DC8Kvpem.js} +2 -2
- package/dist/{add-me-membership-Chf7oIxu.js.map → add-me-membership-DC8Kvpem.js.map} +1 -1
- package/dist/{api-client-foundation-CFHEblaZ.js → api-client-foundation-9MJAKRpy.js} +3 -3
- package/dist/{api-client-foundation-CFHEblaZ.js.map → api-client-foundation-9MJAKRpy.js.map} +1 -1
- package/dist/{auth-session-BJZuJ2bM.js → auth-session-vFtLpWjB.js} +2 -2
- package/dist/{auth-session-BJZuJ2bM.js.map → auth-session-vFtLpWjB.js.map} +1 -1
- package/dist/{command-BL4XDrtV.js → command-CYApmFQW.js} +346 -369
- package/dist/{command-BL4XDrtV.js.map → command-CYApmFQW.js.map} +1 -1
- package/dist/{daemon-runtime-lease-CKQef0lp.js → daemon-runtime-lease-DiRoGxhm.js} +14 -3
- package/dist/daemon-runtime-lease-DiRoGxhm.js.map +1 -0
- package/dist/{dist-D9smLL6A.js → dist-CJnq8AgJ.js} +386 -50
- package/dist/dist-CJnq8AgJ.js.map +1 -0
- package/dist/openmeld.js +938 -259
- package/dist/openmeld.js.map +1 -1
- package/dist/{runtime-transport-DI97Fndy.js → runtime-transport-DEj52An9.js} +225 -40
- package/dist/runtime-transport-DEj52An9.js.map +1 -0
- package/package.json +2 -2
- package/skills/openmeld-cli/SKILL.md +21 -0
- package/skills/openmeld-cli/references/commands.md +17 -0
- package/dist/daemon-runtime-lease-CKQef0lp.js.map +0 -1
- package/dist/dist-D9smLL6A.js.map +0 -1
- package/dist/runtime-transport-DI97Fndy.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://www.schemastore.org/package.json",
|
|
3
3
|
"name": "openmeld",
|
|
4
|
-
"version": "0.3.
|
|
5
|
-
"openMeldReleaseDate": "2026-08-
|
|
4
|
+
"version": "0.3.84",
|
|
5
|
+
"openMeldReleaseDate": "2026-08-23",
|
|
6
6
|
"description": "OpenMeld CLI - https://openmeld.ai",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"type": "module",
|
|
@@ -41,6 +41,9 @@ explicit opt-in.
|
|
|
41
41
|
- A Local Agent can consult the active Organization's Center Agent through the
|
|
42
42
|
user's existing Center Agent Chat. This reuses the user's identity,
|
|
43
43
|
conversation, permissions, memory, and visible audit trail.
|
|
44
|
+
- Humans and Agent Profiles that belong to a Space can use the same Space Files
|
|
45
|
+
tree. Files stay owned by that Space; they are not mirrored into Organization
|
|
46
|
+
Documents or the Center Agent Computer.
|
|
44
47
|
- Trace explains what happened to one Wake or delivery attempt.
|
|
45
48
|
|
|
46
49
|
## Current Local Session To Space Teammate
|
|
@@ -845,6 +848,24 @@ Read recent history:
|
|
|
845
848
|
openmeld space history <space-id> --profile <profile-id> --kind text --brief --limit 20 --view agent
|
|
846
849
|
```
|
|
847
850
|
|
|
851
|
+
Collaborate on Space files:
|
|
852
|
+
|
|
853
|
+
```bash
|
|
854
|
+
openmeld space files list <space-id> --profile <profile-id> --view agent
|
|
855
|
+
openmeld space files read <space-id> <file-id> --profile <profile-id> --view agent
|
|
856
|
+
openmeld space files upload <space-id> ./launch-notes.md --profile <profile-id> --view agent
|
|
857
|
+
openmeld space files write <space-id> <file-id> --base-revision 1 --file ./launch-notes.md --profile <profile-id> --view agent
|
|
858
|
+
openmeld space files download <space-id> <file-id> --output ./launch-notes.md --profile <profile-id> --view agent
|
|
859
|
+
```
|
|
860
|
+
|
|
861
|
+
Use the stable file or folder id returned by `list`; a path is display and
|
|
862
|
+
navigation context, not identity. Before `write`, read the file and send its
|
|
863
|
+
current revision through `--base-revision`. If another collaborator saved
|
|
864
|
+
first, OpenMeld returns an explicit conflict. Read the latest revision, combine
|
|
865
|
+
the work intentionally, and retry. Never bypass that conflict by guessing a
|
|
866
|
+
revision. `download` does not replace an existing local file unless the user
|
|
867
|
+
explicitly supplies `--force`.
|
|
868
|
+
|
|
848
869
|
Read or update the Space guide:
|
|
849
870
|
|
|
850
871
|
```bash
|
|
@@ -448,6 +448,15 @@ openmeld space guide clear <space-id> --profile <profile-id>
|
|
|
448
448
|
openmeld space status <space-id> --profile <profile-id> --view agent
|
|
449
449
|
openmeld space members <space-id> --profile <profile-id> --view agent
|
|
450
450
|
openmeld space members <space-id> --profile <profile-id> --json
|
|
451
|
+
openmeld space files list <space-id> --profile <profile-id> --view agent
|
|
452
|
+
openmeld space files list <space-id> --trash --profile <profile-id> --view agent
|
|
453
|
+
openmeld space files read <space-id> <file-id> --profile <profile-id> --view agent
|
|
454
|
+
openmeld space files upload <space-id> <local-path> --profile <profile-id> --view agent
|
|
455
|
+
openmeld space files write <space-id> <file-id> --base-revision <n> --file <local-path> --profile <profile-id> --view agent
|
|
456
|
+
openmeld space files download <space-id> <file-id> --output <local-path> --profile <profile-id> --view agent
|
|
457
|
+
openmeld space files history <space-id> <file-id> --profile <profile-id> --view agent
|
|
458
|
+
openmeld space files restore <space-id> <entry-id> --profile <profile-id> --view agent
|
|
459
|
+
openmeld space files restore-version <space-id> <file-id> <revision> --base-revision <n> --profile <profile-id> --view agent
|
|
451
460
|
openmeld space wake-progress <space-id> --profile <profile-id> --view agent
|
|
452
461
|
openmeld space wake-progress <space-id> --client-message <client-message-id> --target-profile <agent-profile-id> --profile <profile-id> --view agent
|
|
453
462
|
openmeld space wake-stop <space-id> --client-message <client-message-id> --target-profile <agent-profile-id> --profile <profile-id> --view agent
|
|
@@ -459,6 +468,14 @@ openmeld space publication set <space-id> transparent --profile <owner-profile-i
|
|
|
459
468
|
openmeld space delete <space-id> --profile <profile-id>
|
|
460
469
|
```
|
|
461
470
|
|
|
471
|
+
`space files` is the shared Space filesystem used by Web, Local Agents, and the
|
|
472
|
+
Center Agent. Members can upload, revise, organize, trash, restore, inspect
|
|
473
|
+
history, and restore an older revision as a new latest revision; authorized
|
|
474
|
+
viewers can list and download active entries. Trash remains member-only. Writes
|
|
475
|
+
use `--base-revision` so concurrent edits fail with a visible conflict instead
|
|
476
|
+
of silently overwriting another person's work. Files are not mirrored into
|
|
477
|
+
Organization Documents.
|
|
478
|
+
|
|
462
479
|
`<DISPATCH_ACTION_CLI>` is not a literal command. In a real Wake, copy the exact
|
|
463
480
|
Space Action command printed in that dispatch prompt.
|
|
464
481
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"daemon-runtime-lease-CKQef0lp.js","names":[],"sources":["../../../packages/schemas/dist/schemas/daemon/runtime-lease.js","../src/config/daemon-local-state-file.ts","../src/config/daemon-state.ts","../src/config/daemon-runtime-lease.ts"],"sourcesContent":["import { daemonServiceControllerSchema } from \"./service-contract.js\";\nimport { z } from \"zod/v4\";\n//#region src/schemas/daemon/runtime-lease.ts\nconst DAEMON_RUNTIME_LEASE_SCHEMA_VERSION = 1;\nconst daemonRuntimeLeaseModeSchema = z.enum([\"foreground\", \"background\"]);\nconst daemonRuntimeLeaseSchema = z.strictObject({\n\tschema: z.literal(\"openmeld-daemon-runtime-lease-v1\"),\n\tv: z.literal(1),\n\tgeneration: z.int().nonnegative(),\n\tbundleId: z.string().min(1),\n\tpid: z.int().positive(),\n\tmode: daemonRuntimeLeaseModeSchema,\n\tstartedAt: z.string().min(1),\n\tupdatedAt: z.string().min(1),\n\theartbeatAt: z.string().nullable(),\n\tserviceController: daemonServiceControllerSchema,\n\tmanagedBySystemService: z.boolean()\n});\n//#endregion\nexport { DAEMON_RUNTIME_LEASE_SCHEMA_VERSION, daemonRuntimeLeaseModeSchema, daemonRuntimeLeaseSchema };\n\n//# sourceMappingURL=runtime-lease.js.map","import {\n chmod,\n mkdir,\n readFile,\n rename,\n rm,\n writeFile,\n} from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\n\ntype SafeParseResult<T> = { success: true; data: T } | { success: false };\n\ntype DaemonLocalStateSchema<T> = {\n safeParse: (value: unknown) => SafeParseResult<T>;\n};\n\nexport async function readDaemonLocalStateFile<T>(input: {\n path: string;\n schema: DaemonLocalStateSchema<T>;\n}): Promise<T | null> {\n const raw = await readFile(input.path, \"utf8\").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\n const parsedJson = safeParseJson(raw);\n if (parsedJson === null) {\n return null;\n }\n const parsed = input.schema.safeParse(parsedJson);\n return parsed.success ? parsed.data : null;\n}\n\nexport async function writeDaemonLocalStateFile<T>(input: {\n path: string;\n schema: DaemonLocalStateSchema<T>;\n value: T;\n mode?: number;\n}): Promise<void> {\n const parsed = input.schema.safeParse(input.value);\n if (!parsed.success) {\n throw new Error(`invalid daemon local state for ${input.path}`);\n }\n\n await mkdir(dirname(input.path), { recursive: true });\n const tempPath = `${input.path}.tmp-${process.pid}-${Date.now()}`;\n let shouldCleanupTemp = true;\n\n try {\n await writeFile(tempPath, `${JSON.stringify(parsed.data, null, 2)}\\n`, {\n encoding: \"utf8\",\n ...(typeof input.mode === \"number\" ? { mode: input.mode } : {}),\n });\n await rename(tempPath, input.path);\n if (typeof input.mode === \"number\") {\n await chmod(input.path, input.mode);\n }\n shouldCleanupTemp = false;\n } finally {\n if (shouldCleanupTemp) {\n await rm(tempPath, { force: true }).catch(() => undefined);\n }\n }\n}\n\nfunction safeParseJson(raw: string): unknown | null {\n try {\n return JSON.parse(raw);\n } catch {\n return null;\n }\n}\n","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 resolveOpenMeldPresetOwnedPathInput,\n resolveOpenMeldRootDir,\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 active: boolean;\n failures: unknown[];\n ownerRoot: string;\n pendingOperations: Set<Promise<void>>;\n};\nconst daemonServiceLifecycleLockContext =\n new AsyncLocalStorage<DaemonServiceLifecycleLockContext>();\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_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 = resolveOpenMeldPresetOwnedPathInput()\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): Promise<T> {\n const pathResolution = resolveOpenMeldPresetOwnedPathInput();\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 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: resolveOpenMeldPresetOwnedPathInput(),\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: resolveOpenMeldPresetOwnedPathInput(),\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 async function refreshDaemonTokenLifecycle(): Promise<{\n tokenUpdatedAt: string;\n} | null> {\n const status = await getDaemonStatus();\n if (!status.installed) {\n return null;\n }\n\n const tokenState = await ensureDaemonTokenState();\n return {\n tokenUpdatedAt: tokenState.updatedAt,\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 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 daemonServiceRecognizedExecutableWrapperPaths(\n pathInput: OpenMeldPathResolutionInput = {}\n): string[] {\n return [\n daemonServiceStableExecutableWrapperPath(pathInput),\n daemonServiceLegacyExecutableWrapperPath(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 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 && !isDaemonTokenExpired(current)) {\n await chmod(daemonTokenPath(pathInput), 0o600).catch(() => undefined);\n return current;\n }\n\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","import { rm } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { daemonRuntimeLeaseSchema } from \"@openmeld/schemas\";\nimport type { DaemonRuntimeLease } from \"@openmeld/schemas/types\";\nimport {\n readDaemonLocalStateFile,\n writeDaemonLocalStateFile,\n} from \"./daemon-local-state-file\";\nimport { daemonRuntimeStateRootPath } from \"./daemon-state\";\nimport type { OpenMeldPathResolutionInput } from \"./paths\";\n\nconst DAEMON_RUNTIME_LEASE_FILENAME = \"runtime-lease.json\";\n\nexport function daemonRuntimeLeasePath(\n pathInput: OpenMeldPathResolutionInput = {}\n): string {\n return join(\n daemonRuntimeStateRootPath(pathInput),\n DAEMON_RUNTIME_LEASE_FILENAME\n );\n}\n\nexport async function readDaemonRuntimeLease(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<DaemonRuntimeLease | null> {\n return await readDaemonLocalStateFile({\n path: daemonRuntimeLeasePath(pathInput),\n schema: daemonRuntimeLeaseSchema,\n });\n}\n\nexport async function writeDaemonRuntimeLease(\n lease: DaemonRuntimeLease,\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<void> {\n await writeDaemonLocalStateFile({\n path: daemonRuntimeLeasePath(pathInput),\n schema: daemonRuntimeLeaseSchema,\n value: lease,\n mode: 0o600,\n });\n}\n\nexport async function clearDaemonRuntimeLease(\n pathInput: OpenMeldPathResolutionInput = {}\n): Promise<void> {\n await rm(daemonRuntimeLeasePath(pathInput), { force: true });\n}\n"],"mappings":";;;;;;;;;;;AAIA,MAAM,+BAA+B,EAAE,KAAK,CAAC,cAAc,YAAY,CAAC;AACxE,MAAM,2BAA2B,EAAE,aAAa;CAC/C,QAAQ,EAAE,QAAQ,kCAAkC;CACpD,GAAG,EAAE,QAAQ,CAAC;CACd,YAAY,EAAE,IAAI,CAAC,CAAC,YAAY;CAChC,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CAC1B,KAAK,EAAE,IAAI,CAAC,CAAC,SAAS;CACtB,MAAM;CACN,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CAC3B,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CAC3B,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS;CACjC,mBAAmB;CACnB,wBAAwB,EAAE,QAAQ;AACnC,CAAC;;;ACDD,eAAsB,yBAA4B,OAG5B;CACpB,MAAM,MAAM,MAAM,SAAS,MAAM,MAAM,MAAM,CAAC,CAAC,OAAO,UAAU;EAC9D,IACE,SACA,OAAO,UAAU,YACjB,UAAU,SACV,MAAM,SAAS,UAEf,OAAO;EAET,MAAM;CACR,CAAC;CACD,IAAI,QAAQ,MACV,OAAO;CAGT,MAAM,aAAa,cAAc,GAAG;CACpC,IAAI,eAAe,MACjB,OAAO;CAET,MAAM,SAAS,MAAM,OAAO,UAAU,UAAU;CAChD,OAAO,OAAO,UAAU,OAAO,OAAO;AACxC;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