openmeld 0.3.201 → 0.3.202

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.
Files changed (31) hide show
  1. package/dist/{add-me-membership-Bydm456C.js → add-me-membership-D0L-Rp2b.js} +2 -2
  2. package/dist/{add-me-membership-Bydm456C.js.map → add-me-membership-D0L-Rp2b.js.map} +1 -1
  3. package/dist/{agents-BYLmArr0.js → agents-DVvxGswx.js} +44 -27
  4. package/dist/agents-DVvxGswx.js.map +1 -0
  5. package/dist/{command-Biznp-FO.js → command-BzeF8e-W.js} +4 -4
  6. package/dist/{command-Biznp-FO.js.map → command-BzeF8e-W.js.map} +1 -1
  7. package/dist/{computer-setup-continuation-DPkzUv_T.js → computer-setup-continuation-C9zIfXWR.js} +3 -3
  8. package/dist/{computer-setup-continuation-DPkzUv_T.js.map → computer-setup-continuation-C9zIfXWR.js.map} +1 -1
  9. package/dist/{elapsed-time-ChC30u7g.js → elapsed-time-D6W25QcX.js} +2 -2
  10. package/dist/{elapsed-time-ChC30u7g.js.map → elapsed-time-D6W25QcX.js.map} +1 -1
  11. package/dist/{installer-Bjx_CtON.js → installer-7q1TA-GA.js} +2 -2
  12. package/dist/{installer-Bjx_CtON.js.map → installer-7q1TA-GA.js.map} +1 -1
  13. package/dist/{openmeld-B7cwCTxb.js → openmeld-Bg8kXoGJ.js} +16 -15
  14. package/dist/openmeld-Bg8kXoGJ.js.map +1 -0
  15. package/dist/{openmeld-maintenance-worker-DHQqf3DT.js → openmeld-maintenance-worker-CWzu4s1v.js} +4 -4
  16. package/dist/{openmeld-maintenance-worker-DHQqf3DT.js.map → openmeld-maintenance-worker-CWzu4s1v.js.map} +1 -1
  17. package/dist/{openmeld-tools-update-coordinator-Bf8KyI6N.js → openmeld-tools-update-coordinator-DNMcMykJ.js} +868 -488
  18. package/dist/openmeld-tools-update-coordinator-DNMcMykJ.js.map +1 -0
  19. package/dist/openmeld.js +3 -3
  20. package/dist/{prepare-session-executor-BOXF8ZE2.js → prepare-session-executor-B0_X-Fy6.js} +8 -8
  21. package/dist/prepare-session-executor-B0_X-Fy6.js.map +1 -0
  22. package/dist/upgrade-C8AKw9NW.js +4 -0
  23. package/dist/{upgrade-CdzOmo7O.js → upgrade-GoG7-WEn.js} +17 -254
  24. package/dist/upgrade-GoG7-WEn.js.map +1 -0
  25. package/package.json +1 -1
  26. package/dist/agents-BYLmArr0.js.map +0 -1
  27. package/dist/openmeld-B7cwCTxb.js.map +0 -1
  28. package/dist/openmeld-tools-update-coordinator-Bf8KyI6N.js.map +0 -1
  29. package/dist/prepare-session-executor-BOXF8ZE2.js.map +0 -1
  30. package/dist/upgrade-CdzOmo7O.js.map +0 -1
  31. package/dist/upgrade-DxRpsPL9.js +0 -4
@@ -27,6 +27,7 @@ import { execFile, spawn } from "node:child_process";
27
27
  import { setTimeout as setTimeout$1 } from "node:timers/promises";
28
28
  import { fileURLToPath, pathToFileURL } from "node:url";
29
29
  import { promisify } from "node:util";
30
+ import { gunzipSync } from "node:zlib";
30
31
  import { connect, createConnection, createServer } from "node:net";
31
32
  import { query } from "@anthropic-ai/claude-agent-sdk";
32
33
  import { createOpencodeClient } from "@opencode-ai/sdk/v2";
@@ -310,11 +311,28 @@ const cliBinaryReleaseSchema = cliBinaryArtifactSchema.extend({
310
311
  deltaBases.add(baseKey);
311
312
  }
312
313
  });
314
+ const binaryPlatformsSchema = z$1.record(z$1.string().trim().min(1), cliBinaryReleaseSchema).refine((platforms) => Object.keys(platforms).length > 0, { message: "at least one platform is required" });
315
+ const cliBinaryServiceReleaseSchema = z$1.object({
316
+ platforms: binaryPlatformsSchema,
317
+ version: z$1.string().trim().min(1)
318
+ });
313
319
  const cliBinaryManifestSchema = z$1.object({
314
320
  channels: z$1.object({ stable: z$1.object({
315
321
  minRequiredCliVersion: z$1.string().trim().min(1).nullable().optional(),
316
- platforms: z$1.record(z$1.string().trim().min(1), cliBinaryReleaseSchema).refine((platforms) => Object.keys(platforms).length > 0, { message: "at least one platform is required" }),
322
+ platforms: binaryPlatformsSchema,
323
+ service: cliBinaryServiceReleaseSchema.optional(),
317
324
  version: z$1.string().trim().min(1)
325
+ }).superRefine((stable, context) => {
326
+ if (!stable.service) return;
327
+ for (const platform of Object.keys(stable.platforms)) if (!stable.service.platforms[platform]) context.addIssue({
328
+ code: "custom",
329
+ path: [
330
+ "service",
331
+ "platforms",
332
+ platform
333
+ ],
334
+ message: "a Service artifact is required for every CLI platform"
335
+ });
318
336
  }) }),
319
337
  schemaVersion: z$1.literal(1)
320
338
  });
@@ -1310,11 +1328,17 @@ async function fetchLatestCliBinaryRelease(input) {
1310
1328
  const platform = toNonEmptyString(input?.platform) ?? `${process$1.platform}-${process$1.arch}`;
1311
1329
  const release = manifest.platforms[platform];
1312
1330
  if (!release) throw new Error(`version check failed: invalid CLI manifest response: missing platform ${platform}`);
1331
+ const serviceRelease = manifest.service?.platforms[platform];
1313
1332
  return {
1314
1333
  version: manifest.version,
1315
1334
  minRequiredCliVersion: manifest.minRequiredCliVersion,
1316
1335
  platform,
1317
- ...release
1336
+ ...release,
1337
+ ...manifest.service && serviceRelease ? { service: {
1338
+ ...serviceRelease,
1339
+ version: manifest.service.version,
1340
+ platform
1341
+ } } : {}
1318
1342
  };
1319
1343
  }
1320
1344
  async function requestLatestPackageInfo(packageName) {
@@ -1342,7 +1366,8 @@ async function requestLatestPackageInfoFromCliManifest() {
1342
1366
  const manifest = await requestCliBinaryManifest();
1343
1367
  return {
1344
1368
  version: manifest.version,
1345
- minRequiredCliVersion: manifest.minRequiredCliVersion
1369
+ minRequiredCliVersion: manifest.minRequiredCliVersion,
1370
+ ...manifest.service ? { serviceVersion: manifest.service.version } : {}
1346
1371
  };
1347
1372
  }
1348
1373
  async function requestCliBinaryManifest() {
@@ -1363,9 +1388,8 @@ function parseCliBinaryManifest(raw) {
1363
1388
  if (!parsed.success) throw new Error(parsed.error.message);
1364
1389
  const stable = parsed.data.channels.stable;
1365
1390
  return {
1366
- version: stable.version,
1367
- minRequiredCliVersion: stable.minRequiredCliVersion ?? null,
1368
- platforms: stable.platforms
1391
+ ...stable,
1392
+ minRequiredCliVersion: stable.minRequiredCliVersion ?? null
1369
1393
  };
1370
1394
  }
1371
1395
  function readMinRequiredCliVersion(openmeld) {
@@ -1659,79 +1683,11 @@ function getErrorCode$2(error) {
1659
1683
  return error && typeof error === "object" && "code" in error ? String(error.code) : null;
1660
1684
  }
1661
1685
  //#endregion
1662
- //#region src/local-service/lifecycle/daemon-service-update-state.ts
1663
- const DAEMON_SERVICE_UPDATE_JOB_SCHEMA = OPENMELD_DAEMON_SERVICE_UPDATE_JOB_SCHEMA;
1664
- function daemonServicePendingUpdatePath(pathInput = {}) {
1665
- return join(daemonRuntimeStateRootPath(pathInput), "service-update.json");
1666
- }
1667
- function daemonServiceLastUpdatePath(pathInput = {}) {
1668
- return join(daemonRuntimeStateRootPath(pathInput), "service-update-last.json");
1669
- }
1670
- async function readPendingDaemonServiceUpdate(pathInput = {}) {
1671
- return await readDaemonServiceUpdateJob(daemonServicePendingUpdatePath(pathInput));
1672
- }
1673
- async function readLastDaemonServiceUpdate(pathInput = {}) {
1674
- return await readDaemonServiceUpdateJob(daemonServiceLastUpdatePath(pathInput));
1675
- }
1676
- async function persistPendingDaemonServiceUpdate(job, pathInput = {}) {
1677
- await writeUpdateJobAtomically({
1678
- job,
1679
- path: daemonServicePendingUpdatePath(pathInput)
1680
- });
1681
- }
1682
- async function completePendingDaemonServiceUpdate(job, pathInput = {}, retainPending = false) {
1683
- await writeUpdateJobAtomically({
1684
- job,
1685
- path: daemonServiceLastUpdatePath(pathInput)
1686
- });
1687
- if (retainPending) {
1688
- await persistPendingDaemonServiceUpdate(job, pathInput);
1689
- return;
1690
- }
1691
- await rm(daemonServicePendingUpdatePath(pathInput), { force: true });
1692
- }
1693
- async function readDaemonServiceUpdateJob(path) {
1694
- const raw = await readFile(path, "utf8").catch((error) => {
1695
- if (error.code === "ENOENT") return null;
1696
- throw error;
1697
- });
1698
- if (raw === null) return null;
1699
- const parsed = storedDaemonServiceUpdateJobSchema.safeParse(JSON.parse(raw));
1700
- if (!parsed.success) throw new Error("OpenMeld Service update state is invalid.");
1701
- if (parsed.data.v === 2) return parsed.data;
1702
- const { status, ...legacyJob } = parsed.data;
1703
- return daemonServiceUpdateJobSchema.parse({
1704
- ...legacyJob,
1705
- v: 2,
1706
- schema: DAEMON_SERVICE_UPDATE_JOB_SCHEMA,
1707
- phase: migrateLegacyPhase(status),
1708
- requestSource: "cli"
1709
- });
1710
- }
1711
- function migrateLegacyPhase(status) {
1712
- switch (status) {
1713
- case "scheduled": return "waiting_for_work";
1714
- case "running": return "updating";
1715
- case "completed": return "updated";
1716
- case "failed": return "needs_help";
1717
- default: return status;
1718
- }
1719
- }
1720
- async function writeUpdateJobAtomically(input) {
1721
- const temporaryPath = `${input.path}.${String(process.pid)}.tmp`;
1722
- await mkdir(dirname(input.path), { recursive: true });
1723
- await writeFile(temporaryPath, `${JSON.stringify(input.job, null, 2)}\n`, {
1724
- encoding: "utf8",
1725
- mode: 384
1726
- });
1727
- await rename(temporaryPath, input.path);
1728
- }
1729
- //#endregion
1730
1686
  //#region package.json
1731
1687
  var package_default = {
1732
1688
  $schema: "https://www.schemastore.org/package.json",
1733
1689
  name: "openmeld",
1734
- version: "0.3.201",
1690
+ version: "0.3.202",
1735
1691
  openMeldReleaseDate: "2026-09-13",
1736
1692
  description: "OpenMeld CLI - https://openmeld.ai",
1737
1693
  license: "MIT",
@@ -1813,391 +1769,265 @@ var package_default = {
1813
1769
  }
1814
1770
  };
1815
1771
  //#endregion
1816
- //#region src/runtime/version.ts
1817
- /**
1818
- * The version of the running CLI and Service bundle.
1819
- *
1820
- * npm builds use package.json. Binary builds may inject an isolated staging
1821
- * prerelease so the real update lifecycle can be exercised before a production
1822
- * version exists.
1823
- */
1824
- function resolveOpenMeldVersion() {
1825
- return (typeof __OPENMELD_VERSION__ === "string" ? __OPENMELD_VERSION__.trim() : "") || package_default.version;
1772
+ //#region src/config/service-release.ts
1773
+ function resolveBundledServiceRelease() {
1774
+ if (!isBinaryDistribution()) return;
1775
+ const metadata = package_default;
1776
+ const selection = typeof __OPENMELD_SERVICE_RELEASE__ === "undefined" ? metadata.openmeld?.service : __OPENMELD_SERVICE_RELEASE__;
1777
+ if (selection === void 0) return;
1778
+ const parsed = cliBinaryServiceReleaseSchema.safeParse(selection);
1779
+ if (!parsed.success) throw new Error("The installed CLI contains invalid Service release metadata.");
1780
+ const platform = `${process.platform}-${process.arch}`;
1781
+ const artifact = parsed.data.platforms[platform];
1782
+ if (!artifact) throw new Error(`The installed CLI has no Service artifact for ${platform}.`);
1783
+ return {
1784
+ ...artifact,
1785
+ version: parsed.data.version,
1786
+ platform,
1787
+ minRequiredCliVersion: null
1788
+ };
1826
1789
  }
1827
- const OPENMELD_VERSION = resolveOpenMeldVersion();
1828
1790
  //#endregion
1829
- //#region src/local-components/managed-version-pruning.ts
1830
- const MANAGED_VERSION_DIRECTORY_PATTERN = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
1831
- async function pruneManagedVersions(input) {
1832
- const versionsDir = openMeldVersionsDir(input.pathInput);
1833
- const managedVersions = (await readdir(versionsDir, { withFileTypes: true })).filter((entry) => entry.isDirectory() && MANAGED_VERSION_DIRECTORY_PATTERN.test(entry.name)).map((entry) => entry.name);
1834
- const usableManagedVersions = new Set((await Promise.all(managedVersions.map(async (version) => ({
1835
- usable: await isUsableManagedVersion(version, versionsDir),
1836
- version
1837
- })))).filter((entry) => entry.usable).map((entry) => entry.version));
1838
- const retainedVersions = /* @__PURE__ */ new Set([input.currentVersion]);
1839
- let rollbackVersion = null;
1840
- if (input.preferredRollbackVersion && input.preferredRollbackVersion !== input.currentVersion && usableManagedVersions.has(input.preferredRollbackVersion)) rollbackVersion = input.preferredRollbackVersion;
1841
- rollbackVersion ??= [...usableManagedVersions].filter((version) => compareSemver(version, input.currentVersion) < 0).sort((left, right) => compareSemver(right, left))[0] ?? null;
1842
- if (rollbackVersion) retainedVersions.add(rollbackVersion);
1843
- for (const protectedVersion of input.protectedVersions ?? []) if (usableManagedVersions.has(protectedVersion)) retainedVersions.add(protectedVersion);
1844
- await Promise.all(managedVersions.filter((version) => !retainedVersions.has(version)).map((version) => rm(path.join(versionsDir, version), { recursive: true })));
1791
+ //#region src/runtime/cli-binary-delta.ts
1792
+ function reconstructCliBinaryDelta(input) {
1793
+ verifyBytes({
1794
+ bytes: input.baseBytes,
1795
+ expectedSha256: input.delta.fromSha256,
1796
+ expectedSizeBytes: input.delta.fromSizeBytes,
1797
+ label: "delta base"
1798
+ });
1799
+ const patch = parseCliBinaryDeltaPatch(input.patchPayloadBytes);
1800
+ assertPatchMatchesRelease({
1801
+ delta: input.delta,
1802
+ patch,
1803
+ targetSha256: input.targetSha256,
1804
+ targetSizeBytes: input.targetSizeBytes
1805
+ });
1806
+ const targetBytes = Buffer.alloc(input.targetSizeBytes);
1807
+ input.baseBytes.copy(targetBytes, 0, 0, Math.min(input.baseBytes.byteLength, targetBytes.byteLength));
1808
+ let previousEnd = 0;
1809
+ for (const segment of patch.segments) {
1810
+ const bytes = Buffer.from(segment.dataBase64, "base64");
1811
+ const segmentEnd = segment.offset + bytes.byteLength;
1812
+ if (segment.offset < previousEnd) throw new Error("delta patch segments must be sorted and non-overlapping");
1813
+ if (segmentEnd > targetBytes.byteLength) throw new Error("delta patch segment exceeds the target binary size");
1814
+ bytes.copy(targetBytes, segment.offset);
1815
+ previousEnd = segmentEnd;
1816
+ }
1817
+ verifyBytes({
1818
+ bytes: targetBytes,
1819
+ expectedSha256: input.targetSha256,
1820
+ expectedSizeBytes: input.targetSizeBytes,
1821
+ label: "reconstructed binary"
1822
+ });
1823
+ return targetBytes;
1824
+ }
1825
+ function parseCliBinaryDeltaPatch(bytes) {
1826
+ let value;
1827
+ try {
1828
+ value = JSON.parse(bytes.toString("utf8"));
1829
+ } catch (error) {
1830
+ throw new Error(`delta patch is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
1831
+ }
1832
+ const parsed = cliBinaryDeltaPatchSchema.safeParse(value);
1833
+ if (!parsed.success) throw new Error(`delta patch is invalid: ${parsed.error.message}`);
1834
+ return parsed.data;
1845
1835
  }
1846
- async function isUsableManagedVersion(version, versionsDir) {
1847
- const target = path.join(versionsDir, version, "openmeld");
1848
- if (!(await stat(target).catch((error) => {
1849
- if (getErrorCode$1(error) === "ENOENT") return null;
1850
- throw error;
1851
- }))?.isFile()) return false;
1852
- return await access(target, constants.X_OK).then(() => true, (error) => {
1853
- if (getErrorCode$1(error) === "EACCES" || getErrorCode$1(error) === "ENOENT") return false;
1854
- throw error;
1855
- });
1836
+ function assertPatchMatchesRelease(input) {
1837
+ const mismatches = [
1838
+ [
1839
+ "format",
1840
+ input.patch.patchFormat,
1841
+ input.delta.patchFormat
1842
+ ],
1843
+ [
1844
+ "base sha256",
1845
+ input.patch.baseSha256,
1846
+ input.delta.fromSha256
1847
+ ],
1848
+ [
1849
+ "base size",
1850
+ input.patch.baseSizeBytes,
1851
+ input.delta.fromSizeBytes
1852
+ ],
1853
+ [
1854
+ "target sha256",
1855
+ input.patch.targetSha256,
1856
+ input.targetSha256
1857
+ ],
1858
+ [
1859
+ "target size",
1860
+ input.patch.targetSizeBytes,
1861
+ input.targetSizeBytes
1862
+ ]
1863
+ ].filter(([, actual, expected]) => actual !== expected);
1864
+ if (mismatches.length > 0) throw new Error(`delta patch metadata mismatch: ${mismatches.map(([label]) => label).join(", ")}`);
1856
1865
  }
1857
- function getErrorCode$1(error) {
1858
- return error && typeof error === "object" && "code" in error ? String(error.code) : null;
1866
+ function verifyBytes(input) {
1867
+ if (input.bytes.byteLength !== input.expectedSizeBytes) throw new Error(`${input.label} size mismatch: expected ${input.expectedSizeBytes} bytes, received ${input.bytes.byteLength} bytes`);
1868
+ const actualSha256 = createHash("sha256").update(input.bytes).digest("hex");
1869
+ if (actualSha256 !== input.expectedSha256.toLowerCase()) throw new Error(`${input.label} sha256 mismatch: expected ${input.expectedSha256.toLowerCase()}, received ${actualSha256}`);
1859
1870
  }
1860
1871
  //#endregion
1861
- //#region src/local-components/managed-install.ts
1862
- const MANAGED_INSTALL_LOCK_PROFILE = "managed-cli";
1863
- const MANAGED_INSTALL_LOCK_KEY = "install";
1864
- const MANAGED_INSTALL_LOCK_RETRY_DELAY_MS = 100;
1865
- const MANAGED_INSTALL_LOCK_TIMEOUT_MS = 3e4;
1866
- function resolveCliPlatformToken() {
1867
- return `${process$1.platform}-${process$1.arch}`;
1868
- }
1869
- function resolveCliSelfVersion() {
1870
- return OPENMELD_VERSION;
1871
- }
1872
- async function isUsableManagedBinary(target) {
1873
- if (!(await stat(target).catch((error) => {
1874
- if (isErrorWithCode(error, "ENOENT")) return null;
1875
- throw error;
1876
- }))?.isFile()) return false;
1877
- return await access(target, constants.X_OK).then(() => true, (error) => {
1878
- if (isErrorWithCode(error, "EACCES") || isErrorWithCode(error, "ENOENT")) return false;
1879
- throw error;
1880
- });
1881
- }
1882
- async function readCurrentPointerVersion(pathInput = {}) {
1883
- const pointerPath = openMeldManagedBinaryPath(pathInput);
1884
- const target = await readlink(pointerPath).catch((error) => {
1885
- if (isErrorWithCode(error, "ENOENT") || isErrorWithCode(error, "EINVAL")) return null;
1886
- throw error;
1887
- });
1888
- if (!target) return null;
1889
- const resolved = path.isAbsolute(target) ? target : path.resolve(path.dirname(pointerPath), target);
1890
- const version = path.basename(path.dirname(resolved));
1891
- return version.length > 0 ? version : null;
1892
- }
1893
- /**
1894
- * Install the currently-running binary (process.execPath) into the managed
1895
- * layout and point bin/openmeld at it. Idempotent with semver arbitration:
1896
- * a same-or-newer pointer is left in place (install only goes up), unless
1897
- * `force` is set. Both the versioned binary and the pointer are swapped in
1898
- * atomically via a temp name + rename.
1899
- */
1900
- async function performManagedInstall(input) {
1901
- return await withManagedInstallTransaction(async () => performManagedInstallLocked(input));
1902
- }
1903
- async function withManagedInstallTransaction(run, pathInput = {}) {
1904
- const startedAtMs = Date.now();
1905
- for (;;) try {
1906
- return await runWithHeldLock({
1907
- lock: await acquireLock({
1908
- openMeldProfileId: MANAGED_INSTALL_LOCK_PROFILE,
1909
- key: MANAGED_INSTALL_LOCK_KEY,
1910
- meta: { component: "managed_cli.install" },
1911
- pathResolution: pathInput
1912
- }),
1913
- run,
1914
- releaseContext: {
1915
- component: "managed_cli.install",
1916
- lockKey: MANAGED_INSTALL_LOCK_KEY,
1917
- openMeldProfileId: MANAGED_INSTALL_LOCK_PROFILE
1918
- }
1919
- });
1872
+ //#region src/runtime/cli-binary-update-artifact.ts
1873
+ const HARDENED_RUNTIME_FLAG_RE = /flags=.*runtime/iu;
1874
+ const SIGNING_TIMESTAMP_RE = /^Timestamp=/mu;
1875
+ async function resolveCliBinaryUpdatePlan(input) {
1876
+ const fullDownloadPlan = resolveFullCliBinaryUpdatePlan(input.release);
1877
+ const versionDeltas = input.release.deltas?.filter((candidate) => candidate.fromVersion === input.currentVersion);
1878
+ if (!versionDeltas?.length) return fullDownloadPlan;
1879
+ let baseBytes;
1880
+ try {
1881
+ baseBytes = await readFile(input.baseBinaryPath);
1920
1882
  } catch (error) {
1921
- if (!isOpenMeldLockError(error) || isOpenMeldOrphanedLockError(error) || Date.now() - startedAtMs >= MANAGED_INSTALL_LOCK_TIMEOUT_MS) throw error;
1922
- await setTimeout$1(MANAGED_INSTALL_LOCK_RETRY_DELAY_MS);
1883
+ input.onDeltaFallback(toError(error));
1884
+ return fullDownloadPlan;
1923
1885
  }
1924
- }
1925
- /**
1926
- * Prune managed CLI versions only while holding the install transaction lock.
1927
- * The current pointer and every durable Service update target are re-read in
1928
- * the lock, so cleanup cannot race an install or use a stale pending snapshot.
1929
- */
1930
- async function pruneManagedInstallVersions(input) {
1931
- const pathInput = input.pathInput;
1932
- assertNoPublishedProductionMutationDuringTests(pathInput, "managed CLI versions");
1933
- await withManagedInstallTransaction(async () => {
1934
- const currentVersion = await readCurrentPointerVersion(pathInput);
1935
- if (currentVersion === null) return;
1936
- const protectedVersions = await readManagedInstallProtectedVersions(pathInput);
1937
- await pruneManagedVersions({
1938
- currentVersion,
1939
- pathInput,
1940
- preferredRollbackVersion: input.preferredRollbackVersion,
1941
- protectedVersions
1942
- });
1943
- }, pathInput);
1944
- }
1945
- async function performManagedInstallLocked(input) {
1946
- const force = input?.force ?? false;
1947
- const version = resolveCliSelfVersion();
1948
- const platform = resolveCliPlatformToken();
1949
- const currentPointerPath = openMeldManagedBinaryPath();
1950
- const managedBinaryPath = openMeldManagedVersionBinaryPath(version);
1951
- const previousVersion = await readCurrentPointerVersion();
1952
- const protectedVersions = await readManagedInstallProtectedVersions();
1953
- const baseOutcome = {
1954
- version,
1955
- platform,
1956
- managedBinaryPath,
1957
- currentPointerPath,
1958
- previousVersion,
1959
- forced: force
1886
+ const baseSha256 = createHash("sha256").update(baseBytes).digest("hex");
1887
+ const delta = versionDeltas.find((candidate) => candidate.fromSizeBytes === baseBytes.byteLength && candidate.fromSha256.toLowerCase() === baseSha256);
1888
+ if (!delta) return fullDownloadPlan;
1889
+ return {
1890
+ baseBytes,
1891
+ delta,
1892
+ downloadSizeBytes: delta.patchSizeBytes,
1893
+ transport: "delta"
1960
1894
  };
1961
- if (previousVersion !== null) {
1962
- const comparison = compareSemver(version, previousVersion);
1963
- if (!force && comparison === 0 && await isUsableManagedBinary(managedBinaryPath)) {
1964
- await pruneManagedVersions({
1965
- currentVersion: previousVersion,
1966
- protectedVersions
1967
- });
1968
- return {
1969
- ...baseOutcome,
1970
- result: "noop_same_version"
1971
- };
1972
- }
1973
- if (comparison < 0 && !force) {
1974
- if (!await isUsableManagedBinary(managedBinaryPath)) await placeVersionedBinary(input?.sourceBinaryPath ?? process$1.execPath, version, managedBinaryPath);
1975
- await pruneManagedVersions({
1976
- currentVersion: previousVersion,
1977
- preferredRollbackVersion: version,
1978
- protectedVersions
1895
+ }
1896
+ async function downloadCliBinaryUpdateArtifact(input) {
1897
+ if (input.plan.transport === "delta") {
1898
+ try {
1899
+ return await downloadCliBinaryDelta({
1900
+ ...input,
1901
+ baseBytes: input.plan.baseBytes,
1902
+ delta: input.plan.delta
1979
1903
  });
1980
- return {
1981
- ...baseOutcome,
1982
- result: "noop_newer_present"
1983
- };
1904
+ } catch (error) {
1905
+ input.onDeltaFallback(toError(error));
1984
1906
  }
1907
+ return downloadFullCliBinaryArtifact({
1908
+ ...input,
1909
+ plan: resolveFullCliBinaryUpdatePlan(input.release)
1910
+ });
1985
1911
  }
1986
- await placeVersionedBinary(input?.sourceBinaryPath ?? process$1.execPath, version, managedBinaryPath);
1987
- await pruneManagedVersions({
1988
- currentVersion: version,
1989
- preferredRollbackVersion: previousVersion,
1990
- protectedVersions
1912
+ return downloadFullCliBinaryArtifact({
1913
+ ...input,
1914
+ plan: input.plan
1915
+ });
1916
+ }
1917
+ async function verifyCliBinaryCodeSignature(input) {
1918
+ const { codeIdentifier, teamIdentifier } = input.release;
1919
+ if (!(codeIdentifier && teamIdentifier)) return;
1920
+ if (process.platform !== "darwin") throw new Error("signed OpenMeld CLI verification requires macOS");
1921
+ const verification = await input.runCommand("/usr/bin/codesign", [
1922
+ "--verify",
1923
+ "--strict",
1924
+ "--verbose=2",
1925
+ input.artifactPath
1926
+ ]);
1927
+ if (verification.code !== 0) throw new Error(`binary code signature verification failed: ${commandFailureDetails(verification)}`);
1928
+ const inspection = await input.runCommand("/usr/bin/codesign", [
1929
+ "--display",
1930
+ "--verbose=4",
1931
+ input.artifactPath
1932
+ ]);
1933
+ if (inspection.code !== 0) throw new Error(`binary code signature inspection failed: ${commandFailureDetails(inspection)}`);
1934
+ const details = `${inspection.stdout}\n${inspection.stderr}`;
1935
+ for (const expected of [
1936
+ `Identifier=${codeIdentifier}`,
1937
+ `TeamIdentifier=${teamIdentifier}`,
1938
+ "Authority=Developer ID Application:"
1939
+ ]) if (!details.includes(expected)) throw new Error(`binary code signature is missing expected identity: ${expected}`);
1940
+ if (!HARDENED_RUNTIME_FLAG_RE.test(details)) throw new Error("binary code signature is missing the hardened runtime");
1941
+ if (!SIGNING_TIMESTAMP_RE.test(details)) throw new Error("binary code signature is missing a trusted timestamp");
1942
+ }
1943
+ async function downloadCliBinaryDelta(input) {
1944
+ const response = await input.fetchImpl(input.delta.patchUrl, {
1945
+ method: "GET",
1946
+ signal: AbortSignal.timeout(input.downloadTimeoutMs)
1991
1947
  });
1992
- await swapCurrentPointer(currentPointerPath, managedBinaryPath);
1993
- return {
1994
- ...baseOutcome,
1995
- result: "installed"
1996
- };
1997
- }
1998
- async function readManagedInstallProtectedVersions(pathInput = {}) {
1999
- const [protectedVersions, pendingServiceUpdate] = await Promise.all([readDaemonServiceUpdateWorkerProtectedManagedVersions(pathInput), readPendingDaemonServiceUpdate(pathInput)]);
2000
- if (pendingServiceUpdate?.preparedBundle.bundleFormat === "binary_v1") protectedVersions.add(pendingServiceUpdate.preparedBundle.daemonVersion);
2001
- return protectedVersions;
2002
- }
2003
- async function placeVersionedBinary(sourceBinary, version, managedBinaryPath) {
2004
- await mkdir(openMeldManagedVersionDir(version), { recursive: true });
2005
- const tmpPath = `${managedBinaryPath}.tmp-${process$1.pid}-${Date.now()}`;
2006
- await rm(tmpPath, { force: true }).catch(() => void 0);
2007
- await copyFile(sourceBinary, tmpPath);
2008
- await chmod(tmpPath, 493);
2009
- if ((await lstat(managedBinaryPath).catch((error) => {
2010
- if (isErrorWithCode(error, "ENOENT")) return null;
2011
- throw error;
2012
- }))?.isDirectory()) await rm(managedBinaryPath, { recursive: true });
2013
- await rename(tmpPath, managedBinaryPath);
2014
- }
2015
- async function swapCurrentPointer(currentPointerPath, managedBinaryPath) {
2016
- await mkdir(openMeldBinDir(), { recursive: true });
2017
- const relativeTarget = path.relative(path.dirname(currentPointerPath), managedBinaryPath);
2018
- const tmpPath = `${currentPointerPath}.tmp-${process$1.pid}-${Date.now()}`;
2019
- await rm(tmpPath, { force: true }).catch(() => void 0);
2020
- await symlink(relativeTarget, tmpPath);
2021
- await rename(tmpPath, currentPointerPath);
2022
- }
2023
- function buildInstallSelfJsonPayload(outcome) {
2024
- return {
2025
- schemaVersion: 1,
2026
- type: "cli.install_self",
2027
- result: outcome.result,
2028
- version: outcome.version,
2029
- platform: outcome.platform,
2030
- managedBinaryPath: outcome.managedBinaryPath,
2031
- currentPointerPath: outcome.currentPointerPath,
2032
- previousVersion: outcome.previousVersion,
2033
- forced: outcome.forced
2034
- };
2035
- }
2036
- function isErrorWithCode(error, code) {
2037
- return error instanceof Error && "code" in error && error.code === code;
2038
- }
2039
- //#endregion
2040
- //#region src/local-service/control-plane/client.ts
2041
- const DEFAULT_LOCAL_DAEMON_CONTROL_PLANE_TIMEOUT_MS = 5e3;
2042
- var LocalDaemonControlPlaneClientError = class extends Error {
2043
- code;
2044
- constructor(code, message) {
2045
- super(message);
2046
- this.code = code;
1948
+ if (!response.ok) {
1949
+ const body = await response.text().catch(() => "");
1950
+ throw new Error(`binary delta download failed: HTTP ${response.status}${body ? `: ${body}` : ""}`);
2047
1951
  }
2048
- };
2049
- async function sendLocalDaemonControlPlaneRequest(input) {
2050
- const endpoint = input.endpoint ?? resolveDaemonControlPlaneEndpoint();
2051
- const authToken = await readDaemonControlPlaneToken();
2052
- if (!authToken) throw new LocalDaemonControlPlaneClientError("daemon.control.auth_token_missing", "daemon control token is missing");
2053
- const rawResponse = await writeControlPlaneRequest({
2054
- endpoint,
2055
- request: {
2056
- ...input.request,
2057
- authToken
2058
- },
2059
- timeoutMs: input.timeoutMs ?? DEFAULT_LOCAL_DAEMON_CONTROL_PLANE_TIMEOUT_MS
1952
+ const patchBytes = Buffer.from(await response.arrayBuffer());
1953
+ verifyBinaryBytes({
1954
+ bytes: patchBytes,
1955
+ expectedSha256: input.delta.patchSha256,
1956
+ expectedSizeBytes: input.delta.patchSizeBytes,
1957
+ label: "binary delta archive"
2060
1958
  });
2061
- const parsed = openMeldDaemonControlPlaneResponseSchema.safeParse(rawResponse);
2062
- if (!parsed.success) throw new LocalDaemonControlPlaneClientError("daemon.control.invalid_response", "local daemon control returned an invalid response");
2063
- if (parsed.data.code === "service.error") throw new LocalDaemonControlPlaneClientError(parsed.data.payload.errorCode, parsed.data.payload.errorMessage);
2064
- return parsed.data;
2065
- }
2066
- async function requestLocalSyncRouteCatalog(input) {
2067
- let response;
1959
+ let patchPayloadBytes;
2068
1960
  try {
2069
- response = await sendLocalDaemonControlPlaneRequest({
2070
- endpoint: input.endpoint,
2071
- timeoutMs: input.timeoutMs,
2072
- request: {
2073
- v: 1,
2074
- command: "sync_route_catalog",
2075
- payload: input.payload
2076
- }
2077
- });
1961
+ patchPayloadBytes = gunzipSync(patchBytes, { maxOutputLength: input.delta.patchPayloadSizeBytes });
2078
1962
  } catch (error) {
2079
- throw rewriteDaemonControlPlaneContractMismatch(error);
1963
+ throw new Error(`binary delta could not be decompressed: ${toError(error).message}`);
2080
1964
  }
2081
- if (response.code !== "service.sync_route_catalog") throw new LocalDaemonControlPlaneClientError("daemon.control.invalid_response", "local daemon control returned an unexpected response for route catalog sync");
2082
- return response.payload;
1965
+ if (patchPayloadBytes.byteLength !== input.delta.patchPayloadSizeBytes) throw new Error(`binary delta payload size mismatch: expected ${input.delta.patchPayloadSizeBytes} bytes, received ${patchPayloadBytes.byteLength} bytes`);
1966
+ return reconstructCliBinaryDelta({
1967
+ baseBytes: input.baseBytes,
1968
+ delta: input.delta,
1969
+ patchPayloadBytes,
1970
+ targetSha256: input.release.sha256,
1971
+ targetSizeBytes: input.release.sizeBytes
1972
+ });
2083
1973
  }
2084
- async function requestLocalAgentActivitySync(input) {
2085
- let response;
2086
- try {
2087
- response = await sendLocalDaemonControlPlaneRequest({
2088
- endpoint: input.endpoint,
2089
- timeoutMs: input.timeoutMs,
2090
- request: {
2091
- v: 1,
2092
- command: "request_agent_activity_sync",
2093
- payload: input.payload
2094
- }
2095
- });
2096
- } catch (error) {
2097
- throw rewriteDaemonControlPlaneContractMismatch(error);
2098
- }
2099
- if (response.code !== "service.agent_activity_sync_requested") throw new LocalDaemonControlPlaneClientError("daemon.control.invalid_response", "local daemon control returned an unexpected response for Agent Activity sync");
2100
- return response.payload;
1974
+ function resolveFullCliBinaryUpdatePlan(release) {
1975
+ if (hasCompressedCliBinaryTransport(release)) return {
1976
+ downloadSha256: release.archiveSha256,
1977
+ downloadSizeBytes: release.archiveSizeBytes,
1978
+ downloadUrl: release.archiveUrl,
1979
+ transport: "archive"
1980
+ };
1981
+ return {
1982
+ downloadSha256: release.sha256,
1983
+ downloadSizeBytes: release.sizeBytes,
1984
+ downloadUrl: release.url,
1985
+ transport: "raw"
1986
+ };
2101
1987
  }
2102
- async function requestLocalDaemonShutdown(input) {
2103
- let response;
2104
- try {
2105
- response = await sendLocalDaemonControlPlaneRequest({
2106
- endpoint: input.endpoint,
2107
- timeoutMs: input.timeoutMs,
2108
- request: {
2109
- v: 1,
2110
- command: "shutdown",
2111
- payload: input.payload
2112
- }
2113
- });
1988
+ async function downloadFullCliBinaryArtifact(input) {
1989
+ const response = await input.fetchImpl(input.plan.downloadUrl, {
1990
+ method: "GET",
1991
+ signal: AbortSignal.timeout(input.downloadTimeoutMs)
1992
+ });
1993
+ if (!response.ok) {
1994
+ const body = await response.text().catch(() => "");
1995
+ throw new Error(`binary download failed: HTTP ${response.status}${body ? `: ${body}` : ""}`);
1996
+ }
1997
+ const downloadBytes = Buffer.from(await response.arrayBuffer());
1998
+ verifyBinaryBytes({
1999
+ bytes: downloadBytes,
2000
+ expectedSha256: input.plan.downloadSha256,
2001
+ expectedSizeBytes: input.plan.downloadSizeBytes,
2002
+ label: input.plan.transport === "archive" ? "binary archive" : "binary download"
2003
+ });
2004
+ let artifactBytes = downloadBytes;
2005
+ if (input.plan.transport === "archive") try {
2006
+ artifactBytes = gunzipSync(downloadBytes, { maxOutputLength: input.release.sizeBytes });
2114
2007
  } catch (error) {
2115
- throw rewriteDaemonControlPlaneContractMismatch(error);
2008
+ throw new Error(`binary archive could not be decompressed: ${toError(error).message}`);
2116
2009
  }
2117
- if (response.code !== "service.shutdown") throw new LocalDaemonControlPlaneClientError("daemon.control.invalid_response", "local daemon control returned an unexpected response for shutdown");
2118
- return response.payload;
2010
+ verifyBinaryBytes({
2011
+ bytes: artifactBytes,
2012
+ expectedSha256: input.release.sha256,
2013
+ expectedSizeBytes: input.release.sizeBytes,
2014
+ label: "binary download"
2015
+ });
2016
+ return artifactBytes;
2119
2017
  }
2120
- async function requestLocalDaemonServiceUpdateReadiness(input = {}) {
2121
- let response;
2122
- try {
2123
- response = await sendLocalDaemonControlPlaneRequest({
2124
- endpoint: input.endpoint,
2125
- timeoutMs: input.timeoutMs,
2126
- request: {
2127
- v: 1,
2128
- command: "service_update_readiness"
2129
- }
2130
- });
2131
- } catch (error) {
2132
- throw rewriteDaemonControlPlaneContractMismatch(error);
2133
- }
2134
- if (response.code !== "service.update_readiness") throw new LocalDaemonControlPlaneClientError("daemon.control.invalid_response", "local daemon control returned an unexpected response for service update readiness");
2135
- return response.payload;
2018
+ function hasCompressedCliBinaryTransport(release) {
2019
+ return release.archiveFormat === "gzip" && typeof release.archiveUrl === "string" && typeof release.archiveSha256 === "string" && typeof release.archiveSizeBytes === "number";
2136
2020
  }
2137
- function rewriteDaemonControlPlaneContractMismatch(error) {
2138
- if (error instanceof LocalDaemonControlPlaneClientError && error.code === "service.invalid_request") return new LocalDaemonControlPlaneClientError("daemon.control.contract_mismatch", "local OpenMeld Service must be restarted because the daemon control-plane contract changed on this device");
2139
- return error;
2021
+ function verifyBinaryBytes(input) {
2022
+ if (input.bytes.byteLength !== input.expectedSizeBytes) throw new Error(`${input.label} size mismatch: expected ${input.expectedSizeBytes} bytes, received ${input.bytes.byteLength} bytes`);
2023
+ const actualSha256 = createHash("sha256").update(input.bytes).digest("hex");
2024
+ if (actualSha256 !== input.expectedSha256.toLowerCase()) throw new Error(`${input.label} sha256 mismatch: expected ${input.expectedSha256.toLowerCase()}, received ${actualSha256}`);
2140
2025
  }
2141
- async function writeControlPlaneRequest(input) {
2142
- return await new Promise((resolve, reject) => {
2143
- const socket = createConnection(input.endpoint);
2144
- let responseBuffer = "";
2145
- let settled = false;
2146
- const cleanup = () => {
2147
- socket.setTimeout(0);
2148
- socket.off("connect", handleConnect);
2149
- socket.off("data", handleData);
2150
- socket.off("end", handleEnd);
2151
- socket.off("error", handleError);
2152
- socket.off("timeout", handleTimeout);
2153
- };
2154
- const settle = (action) => {
2155
- if (settled) return;
2156
- settled = true;
2157
- cleanup();
2158
- action();
2159
- };
2160
- const fail = (error) => {
2161
- settle(() => {
2162
- socket.destroy();
2163
- reject(error);
2164
- });
2165
- };
2166
- const handleConnect = () => {
2167
- socket.write(`${JSON.stringify(input.request)}\n`);
2168
- };
2169
- const handleData = (chunk) => {
2170
- responseBuffer += chunk;
2171
- };
2172
- const handleEnd = () => {
2173
- settle(() => {
2174
- const rawResponse = responseBuffer.trim();
2175
- if (!rawResponse) {
2176
- reject(new LocalDaemonControlPlaneClientError("daemon.control.empty_response", "local daemon control returned an empty response"));
2177
- return;
2178
- }
2179
- try {
2180
- resolve(JSON.parse(rawResponse));
2181
- } catch {
2182
- reject(new LocalDaemonControlPlaneClientError("daemon.control.invalid_json", "local daemon control returned malformed JSON"));
2183
- }
2184
- });
2185
- };
2186
- const handleError = (error) => {
2187
- const code = error && typeof error === "object" && "code" in error ? String(error.code) : "daemon.control.connection_failed";
2188
- fail(new LocalDaemonControlPlaneClientError(code === "ENOENT" || code === "ECONNREFUSED" ? "daemon.control.endpoint_missing" : code, error instanceof Error ? error.message : "failed to connect to local daemon control"));
2189
- };
2190
- const handleTimeout = () => {
2191
- fail(new LocalDaemonControlPlaneClientError("daemon.control.timeout", `local daemon control timed out after ${String(input.timeoutMs)}ms`));
2192
- };
2193
- socket.setEncoding("utf8");
2194
- socket.setTimeout(input.timeoutMs);
2195
- socket.once("connect", handleConnect);
2196
- socket.on("data", handleData);
2197
- socket.once("end", handleEnd);
2198
- socket.once("error", handleError);
2199
- socket.once("timeout", handleTimeout);
2200
- });
2026
+ function commandFailureDetails(result) {
2027
+ return result.stderr.trim() || result.stdout.trim() || `exit ${result.code}`;
2028
+ }
2029
+ function toError(error) {
2030
+ return error instanceof Error ? error : new Error(String(error));
2201
2031
  }
2202
2032
  //#endregion
2203
2033
  //#region src/system/local-operation-diagnostics.ts
@@ -2528,7 +2358,7 @@ function resolveDaemonServiceArtifact(input) {
2528
2358
  activeBundle: input.activeBundle,
2529
2359
  activeBundleEntryPath: input.activeBundleEntryPath,
2530
2360
  activeBundleSourceAvailable: input.activeBundleSourceAvailable,
2531
- currentSourceDistFingerprint: input.currentSourceDistFingerprint,
2361
+ installedBundleFingerprint: input.installedBundleFingerprint,
2532
2362
  expectedBundleId,
2533
2363
  expectedDaemonVersion,
2534
2364
  pathInput: input.pathInput
@@ -2565,7 +2395,75 @@ function hasBundleIdDrift(input) {
2565
2395
  return input.expectedBundleId !== null && input.activeBundle.bundleId !== input.expectedBundleId;
2566
2396
  }
2567
2397
  function hasBundleContentDrift(input) {
2568
- return input.currentSourceDistFingerprint !== null && input.activeBundle.sourceDistFingerprint !== input.currentSourceDistFingerprint;
2398
+ return input.installedBundleFingerprint === null || input.activeBundle.sourceDistFingerprint !== input.installedBundleFingerprint;
2399
+ }
2400
+ //#endregion
2401
+ //#region src/local-service/lifecycle/daemon-service-update-state.ts
2402
+ const DAEMON_SERVICE_UPDATE_JOB_SCHEMA = OPENMELD_DAEMON_SERVICE_UPDATE_JOB_SCHEMA;
2403
+ function daemonServicePendingUpdatePath(pathInput = {}) {
2404
+ return join(daemonRuntimeStateRootPath(pathInput), "service-update.json");
2405
+ }
2406
+ function daemonServiceLastUpdatePath(pathInput = {}) {
2407
+ return join(daemonRuntimeStateRootPath(pathInput), "service-update-last.json");
2408
+ }
2409
+ async function readPendingDaemonServiceUpdate(pathInput = {}) {
2410
+ return await readDaemonServiceUpdateJob(daemonServicePendingUpdatePath(pathInput));
2411
+ }
2412
+ async function readLastDaemonServiceUpdate(pathInput = {}) {
2413
+ return await readDaemonServiceUpdateJob(daemonServiceLastUpdatePath(pathInput));
2414
+ }
2415
+ async function persistPendingDaemonServiceUpdate(job, pathInput = {}) {
2416
+ await writeUpdateJobAtomically({
2417
+ job,
2418
+ path: daemonServicePendingUpdatePath(pathInput)
2419
+ });
2420
+ }
2421
+ async function completePendingDaemonServiceUpdate(job, pathInput = {}, retainPending = false) {
2422
+ await writeUpdateJobAtomically({
2423
+ job,
2424
+ path: daemonServiceLastUpdatePath(pathInput)
2425
+ });
2426
+ if (retainPending) {
2427
+ await persistPendingDaemonServiceUpdate(job, pathInput);
2428
+ return;
2429
+ }
2430
+ await rm(daemonServicePendingUpdatePath(pathInput), { force: true });
2431
+ }
2432
+ async function readDaemonServiceUpdateJob(path) {
2433
+ const raw = await readFile(path, "utf8").catch((error) => {
2434
+ if (error.code === "ENOENT") return null;
2435
+ throw error;
2436
+ });
2437
+ if (raw === null) return null;
2438
+ const parsed = storedDaemonServiceUpdateJobSchema.safeParse(JSON.parse(raw));
2439
+ if (!parsed.success) throw new Error("OpenMeld Service update state is invalid.");
2440
+ if (parsed.data.v === 2) return parsed.data;
2441
+ const { status, ...legacyJob } = parsed.data;
2442
+ return daemonServiceUpdateJobSchema.parse({
2443
+ ...legacyJob,
2444
+ v: 2,
2445
+ schema: DAEMON_SERVICE_UPDATE_JOB_SCHEMA,
2446
+ phase: migrateLegacyPhase(status),
2447
+ requestSource: "cli"
2448
+ });
2449
+ }
2450
+ function migrateLegacyPhase(status) {
2451
+ switch (status) {
2452
+ case "scheduled": return "waiting_for_work";
2453
+ case "running": return "updating";
2454
+ case "completed": return "updated";
2455
+ case "failed": return "needs_help";
2456
+ default: return status;
2457
+ }
2458
+ }
2459
+ async function writeUpdateJobAtomically(input) {
2460
+ const temporaryPath = `${input.path}.${String(process.pid)}.tmp`;
2461
+ await mkdir(dirname(input.path), { recursive: true });
2462
+ await writeFile(temporaryPath, `${JSON.stringify(input.job, null, 2)}\n`, {
2463
+ encoding: "utf8",
2464
+ mode: 384
2465
+ });
2466
+ await rename(temporaryPath, input.path);
2569
2467
  }
2570
2468
  //#endregion
2571
2469
  //#region src/local-service/lifecycle/daemon-service-bundle.ts
@@ -2610,7 +2508,7 @@ function isDaemonBundleSourceAllowedForLane(input) {
2610
2508
  }
2611
2509
  async function readDaemonActiveBundleState(pathInput = {}) {
2612
2510
  const raw = await readFile(daemonServiceActiveBundlePath(pathInput), "utf8").catch((error) => {
2613
- if (getErrorCode(error) === "ENOENT") return null;
2511
+ if (getErrorCode$1(error) === "ENOENT") return null;
2614
2512
  throw error;
2615
2513
  });
2616
2514
  if (raw === null) return null;
@@ -2665,8 +2563,8 @@ async function resolveAlignedDaemonActiveBundleEntryPath(input = {}) {
2665
2563
  ]);
2666
2564
  const expectedVersion = input.expectedVersion ?? serviceContract?.daemonVersion ?? (installStatus.installed ? installStatus.state.daemonVersion : state?.daemonVersion ?? "unknown");
2667
2565
  const matchingServiceContract = input.expectedVersion && serviceContract?.daemonVersion !== input.expectedVersion ? null : serviceContract;
2668
- const currentSourceDistFingerprint = await resolveCurrentDaemonFingerprintForState(state).catch(() => null);
2669
2566
  const activeBundleEntryPath = await resolveDaemonBundleEntryPathFromState(state);
2567
+ const installedBundleFingerprint = activeBundleEntryPath ? await resolveInstalledDaemonBundleFingerprint(state) : null;
2670
2568
  return resolveDaemonServiceArtifact({
2671
2569
  expectedVersion,
2672
2570
  installStatus,
@@ -2674,15 +2572,22 @@ async function resolveAlignedDaemonActiveBundleEntryPath(input = {}) {
2674
2572
  activeBundle: state,
2675
2573
  activeBundleSourceAvailable: state && state.bundleFormat === "legacy_linked_v1" ? await pathExists$4(state.sourcePackageRootPath).catch(() => null) : null,
2676
2574
  activeBundleEntryPath,
2677
- currentSourceDistFingerprint
2575
+ installedBundleFingerprint
2678
2576
  }).resolvedEntryPath;
2679
2577
  }
2680
- async function resolveCurrentDaemonFingerprintForState(state) {
2578
+ async function resolveInstalledDaemonBundleFingerprint(state, pathInput = {}) {
2681
2579
  if (state?.bundleFormat === "binary_v1") {
2682
- const entryPath = await resolveDaemonBundleEntryPathFromState(state);
2580
+ const entryPath = await resolveDaemonBundleEntryPathFromState(state, pathInput);
2683
2581
  return entryPath ? await hashDaemonBinaryFile(entryPath) : null;
2684
2582
  }
2685
- return await resolveCurrentDaemonSourceDistFingerprint();
2583
+ if (state?.bundleFormat === "self_contained_v1") {
2584
+ const bundleRootPath = resolveDaemonBundleRootPath(state.bundleId, pathInput);
2585
+ const distRootPath = join(bundleRootPath, dirname(state.entryScriptRelativePath));
2586
+ const relativeDistRootPath = relative(bundleRootPath, distRootPath);
2587
+ if (relativeDistRootPath === ".." || relativeDistRootPath.startsWith(`..${sep}`) || isAbsolute(relativeDistRootPath)) return null;
2588
+ return await computeDaemonSourceDistFingerprint(distRootPath);
2589
+ }
2590
+ return null;
2686
2591
  }
2687
2592
  async function resolveDaemonBundleEntryPathFromState(state, pathInput = {}) {
2688
2593
  if (!state) return null;
@@ -2695,7 +2600,7 @@ async function resolveDaemonBundleEntryPathFromState(state, pathInput = {}) {
2695
2600
  return await pathExists$4(entryPath) ? entryPath : null;
2696
2601
  }
2697
2602
  async function prepareDaemonServiceBundle(input) {
2698
- const preparedBundle = isBinaryDistribution() ? await prepareBinaryDaemonServiceBundle() : await prepareNodeDaemonServiceBundle(input);
2603
+ const preparedBundle = isBinaryDistribution() ? await prepareBinaryDaemonServiceBundle(input) : await prepareNodeDaemonServiceBundle(input);
2699
2604
  if (input.activate !== false) await activateDaemonServiceBundle(preparedBundle);
2700
2605
  return preparedBundle;
2701
2606
  }
@@ -2757,7 +2662,19 @@ async function prepareNodeDaemonServiceBundle(input) {
2757
2662
  updatedAt: now
2758
2663
  };
2759
2664
  }
2760
- async function prepareBinaryDaemonServiceBundle() {
2665
+ async function prepareBinaryDaemonServiceBundle(input) {
2666
+ const { daemonVersion } = input;
2667
+ const bundledRelease = resolveBundledServiceRelease();
2668
+ const binaryRelease = input.binaryRelease ?? (bundledRelease?.version === daemonVersion ? bundledRelease : void 0);
2669
+ if (daemonVersion !== resolveCliSelfVersion()) {
2670
+ const active = await readDaemonActiveBundleState();
2671
+ if (active?.bundleFormat === "binary_v1" && active.daemonVersion === daemonVersion && active.sourceDistFingerprint && (!binaryRelease || binaryRelease.sha256 === active.sourceDistFingerprint) && await pathExists$4(active.sourceEntryScriptPath) && await hashDaemonBinaryFile(active.sourceEntryScriptPath) === active.sourceDistFingerprint) return active;
2672
+ }
2673
+ if (binaryRelease) return await prepareSelectedBinaryDaemonServiceBundle({
2674
+ daemonVersion,
2675
+ release: binaryRelease
2676
+ });
2677
+ if (daemonVersion !== resolveCliSelfVersion()) throw new Error(`Cannot prepare OpenMeld Service ${daemonVersion} from CLI ${resolveCliSelfVersion()}. Acquire the selected Service release before preparing the update.`);
2761
2678
  const outcome = await performManagedInstall();
2762
2679
  const managedBinaryPath = outcome.managedBinaryPath;
2763
2680
  if (!await pathExists$4(managedBinaryPath)) throw new Error(`OpenMeld managed binary is missing at ${managedBinaryPath}; cannot prepare binary OpenMeld Service.`);
@@ -2778,7 +2695,67 @@ async function prepareBinaryDaemonServiceBundle() {
2778
2695
  sourceEntryScriptPath: managedBinaryPath,
2779
2696
  sourcePackageRootPath: managedVersionDir,
2780
2697
  sourceDistRootPath: managedVersionDir,
2781
- sourceDistFingerprint: await hashDaemonBinaryFile(managedBinaryPath).catch(() => null),
2698
+ sourceDistFingerprint: await hashDaemonBinaryFile(managedBinaryPath),
2699
+ sourceKind: DAEMON_BUNDLE_SOURCE_KIND_PACKAGE_INSTALL,
2700
+ createdAt: now,
2701
+ updatedAt: now
2702
+ };
2703
+ }
2704
+ async function prepareSelectedBinaryDaemonServiceBundle(input) {
2705
+ if (input.release.version !== input.daemonVersion) throw new Error("The selected Service artifact does not match the update target.");
2706
+ const bundleId = createBundleId(input.daemonVersion);
2707
+ const bundleRootPath = resolveDaemonBundleRootPath(bundleId);
2708
+ const executablePath = join(bundleRootPath, "openmeld");
2709
+ const onDeltaFallback = (error) => {
2710
+ console.warn("[openmeld.service.artifact_delta_fallback]", error.message);
2711
+ };
2712
+ const plan = await resolveCliBinaryUpdatePlan({
2713
+ baseBinaryPath: process$1.execPath,
2714
+ currentVersion: resolveCliSelfVersion(),
2715
+ onDeltaFallback,
2716
+ release: input.release
2717
+ });
2718
+ const bytes = await downloadCliBinaryUpdateArtifact({
2719
+ downloadTimeoutMs: 6e4,
2720
+ fetchImpl: fetch,
2721
+ onDeltaFallback,
2722
+ plan,
2723
+ release: input.release
2724
+ });
2725
+ await mkdir(bundleRootPath, { recursive: true });
2726
+ try {
2727
+ await writeFile(executablePath, bytes, { mode: 493 });
2728
+ await verifyCliBinaryCodeSignature({
2729
+ artifactPath: executablePath,
2730
+ release: input.release,
2731
+ runCommand: async (command, args) => {
2732
+ const result = await promisify(execFile)(command, args, { encoding: "utf8" });
2733
+ return {
2734
+ code: 0,
2735
+ stdout: result.stdout,
2736
+ stderr: result.stderr
2737
+ };
2738
+ }
2739
+ });
2740
+ } catch (error) {
2741
+ await rm(bundleRootPath, {
2742
+ recursive: true,
2743
+ force: true
2744
+ });
2745
+ throw error;
2746
+ }
2747
+ const now = (/* @__PURE__ */ new Date()).toISOString();
2748
+ return {
2749
+ v: 2,
2750
+ schema: DAEMON_ACTIVE_BUNDLE_SCHEMA,
2751
+ bundleId,
2752
+ daemonVersion: input.daemonVersion,
2753
+ entryScriptRelativePath: "openmeld",
2754
+ bundleFormat: "binary_v1",
2755
+ sourceEntryScriptPath: executablePath,
2756
+ sourcePackageRootPath: bundleRootPath,
2757
+ sourceDistRootPath: bundleRootPath,
2758
+ sourceDistFingerprint: input.release.sha256.toLowerCase(),
2782
2759
  sourceKind: DAEMON_BUNDLE_SOURCE_KIND_PACKAGE_INSTALL,
2783
2760
  createdAt: now,
2784
2761
  updatedAt: now
@@ -2793,7 +2770,7 @@ async function activateDaemonServiceBundle(preparedBundle) {
2793
2770
  if (preparedBundle.bundleFormat !== "binary_v1") await ensureDaemonServiceManagerExecutables();
2794
2771
  }
2795
2772
  async function discardPreparedDaemonServiceBundle(preparedBundle) {
2796
- if (preparedBundle.bundleFormat !== "self_contained_v1") return;
2773
+ if (preparedBundle.bundleFormat === "legacy_linked_v1") return;
2797
2774
  if ((await readDaemonActiveBundleState())?.bundleId === preparedBundle.bundleId) return;
2798
2775
  await rm(resolveDaemonBundleRootPath(preparedBundle.bundleId), {
2799
2776
  recursive: true,
@@ -2938,17 +2915,8 @@ async function ensureVerifiedBinaryCarrier(input) {
2938
2915
  async function verifyDaemonActiveBundleIntegrity(activeBundle) {
2939
2916
  const expectedFingerprint = activeBundle.sourceDistFingerprint?.trim();
2940
2917
  if (!expectedFingerprint || activeBundle.bundleFormat === "legacy_linked_v1") return false;
2941
- if (activeBundle.bundleFormat === "binary_v1") {
2942
- const entryPath = await resolveDaemonBundleEntryPathFromState(activeBundle);
2943
- if (!entryPath) return false;
2944
- return await hashDaemonBinaryFile(entryPath) === expectedFingerprint;
2945
- }
2946
- const bundleRootPath = resolveDaemonBundleRootPath(activeBundle.bundleId);
2947
- const activeDistRootPath = join(bundleRootPath, dirname(activeBundle.entryScriptRelativePath));
2948
- const relativeDistRootPath = relative(bundleRootPath, activeDistRootPath);
2949
- if (relativeDistRootPath === ".." || relativeDistRootPath.startsWith(`..${sep}`) || isAbsolute(relativeDistRootPath)) return false;
2950
2918
  if (!await resolveDaemonBundleEntryPathFromState(activeBundle)) return false;
2951
- return await computeDaemonSourceDistFingerprint(activeDistRootPath) === expectedFingerprint;
2919
+ return await resolveInstalledDaemonBundleFingerprint(activeBundle) === expectedFingerprint;
2952
2920
  }
2953
2921
  async function writeDaemonBundlePackageManifest(input) {
2954
2922
  await writeFile(join(input.bundleRootPath, "package.json"), `${JSON.stringify({
@@ -3068,11 +3036,6 @@ async function resolveDaemonBundleSourceProvenance(explicitPath) {
3068
3036
  sourceKind: inferDaemonBundleSourceKind(sourcePackageRootPath)
3069
3037
  };
3070
3038
  }
3071
- async function resolveCurrentDaemonSourceDistFingerprint(input = {}) {
3072
- const sourceProvenance = await resolveDaemonBundleSourceProvenance(input.cliScriptPath).catch(() => null);
3073
- if (!sourceProvenance) return null;
3074
- return await computeDaemonSourceDistFingerprint(sourceProvenance.sourceDistRootPath).catch(() => null);
3075
- }
3076
3039
  async function resolveCliScriptPath(explicitPath) {
3077
3040
  const rawPath = explicitPath ?? process$1.argv[1];
3078
3041
  if (!rawPath) throw new Error("Cannot determine CLI script path for OpenMeld background service bundle.");
@@ -3129,7 +3092,7 @@ function isDaemonSourceDistPathIncluded(sourceDistRootPath, candidatePath) {
3129
3092
  async function collectDaemonBundleRuntimeDependencyClosure(input) {
3130
3093
  const packageManifestPath = join(input.sourcePackageRootPath, "package.json");
3131
3094
  const packageManifestRaw = await readFile(packageManifestPath, "utf8").catch((error) => {
3132
- if (getErrorCode(error) === "ENOENT") throw new Error(`OpenMeld could not find the CLI package manifest for background service bundling at ${packageManifestPath}.`);
3095
+ if (getErrorCode$1(error) === "ENOENT") throw new Error(`OpenMeld could not find the CLI package manifest for background service bundling at ${packageManifestPath}.`);
3133
3096
  throw error;
3134
3097
  });
3135
3098
  const packageManifest = JSON.parse(packageManifestRaw);
@@ -3191,7 +3154,7 @@ async function readDaemonBundleDependencyManifest(input) {
3191
3154
  if (!dependencyPackageRootPath) return null;
3192
3155
  const dependencyManifestPath = join(dependencyPackageRootPath, "package.json");
3193
3156
  const dependencyManifestRaw = await readFile(dependencyManifestPath, "utf8").catch((error) => {
3194
- if (getErrorCode(error) === "ENOENT") {
3157
+ if (getErrorCode$1(error) === "ENOENT") {
3195
3158
  if (!input.required) return null;
3196
3159
  throw new Error(`OpenMeld could not find runtime dependency ${input.dependencyName} for background service bundling at ${dependencyManifestPath}. Run \`pnpm install\` and retry.`);
3197
3160
  }
@@ -3240,7 +3203,7 @@ async function findDaemonDependencyPackageRootFromManifestPath(input) {
3240
3203
  let currentPath = dirname(input.dependencyManifestPath);
3241
3204
  while (true) {
3242
3205
  const packageManifestRaw = await readFile(join(currentPath, "package.json"), "utf8").catch((error) => {
3243
- if (getErrorCode(error) === "ENOENT") return null;
3206
+ if (getErrorCode$1(error) === "ENOENT") return null;
3244
3207
  throw error;
3245
3208
  });
3246
3209
  if (packageManifestRaw !== null) {
@@ -3577,7 +3540,7 @@ function quoteShellSingle(value) {
3577
3540
  }
3578
3541
  async function readDirectoryNames(path) {
3579
3542
  return (await readdir(path, { withFileTypes: true }).catch((error) => {
3580
- if (getErrorCode(error) === "ENOENT") return [];
3543
+ if (getErrorCode$1(error) === "ENOENT") return [];
3581
3544
  throw error;
3582
3545
  })).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
3583
3546
  }
@@ -3595,7 +3558,7 @@ function isDaemonBundleSourceKind(value) {
3595
3558
  return value === DAEMON_BUNDLE_SOURCE_KIND_WORKSPACE || value === DAEMON_BUNDLE_SOURCE_KIND_PACKAGE_INSTALL || value === DAEMON_BUNDLE_SOURCE_KIND_NPX_CACHE || value === DAEMON_BUNDLE_SOURCE_KIND_UNKNOWN;
3596
3559
  }
3597
3560
  function isPackageEntryResolutionError(error) {
3598
- const code = getErrorCode(error);
3561
+ const code = getErrorCode$1(error);
3599
3562
  return code === "MODULE_NOT_FOUND" || code === "ERR_PACKAGE_PATH_NOT_EXPORTED";
3600
3563
  }
3601
3564
  function normalizeOptionalText$54(value) {
@@ -3607,7 +3570,7 @@ async function pathExists$4(path) {
3607
3570
  await stat(path);
3608
3571
  return true;
3609
3572
  } catch (error) {
3610
- if (getErrorCode(error) === "ENOENT") return false;
3573
+ if (getErrorCode$1(error) === "ENOENT") return false;
3611
3574
  throw error;
3612
3575
  }
3613
3576
  }
@@ -3635,12 +3598,414 @@ function buildPreferredCliScriptNames(rawPath) {
3635
3598
  function isSupportedDaemonCliEntryName(value) {
3636
3599
  return DAEMON_CLI_ENTRY_NAMES.includes(value);
3637
3600
  }
3638
- function getErrorCode(error) {
3601
+ function getErrorCode$1(error) {
3639
3602
  if (!error || typeof error !== "object") return;
3640
3603
  const code = error.code;
3641
3604
  return typeof code === "string" ? code : void 0;
3642
3605
  }
3643
3606
  //#endregion
3607
+ //#region src/runtime/version.ts
3608
+ /**
3609
+ * The version of the running CLI and Service bundle.
3610
+ *
3611
+ * npm builds use package.json. Binary builds may inject an isolated staging
3612
+ * prerelease so the real update lifecycle can be exercised before a production
3613
+ * version exists.
3614
+ */
3615
+ function resolveOpenMeldVersion() {
3616
+ return (typeof __OPENMELD_VERSION__ === "string" ? __OPENMELD_VERSION__.trim() : "") || package_default.version;
3617
+ }
3618
+ const OPENMELD_VERSION = resolveOpenMeldVersion();
3619
+ //#endregion
3620
+ //#region src/local-components/managed-version-pruning.ts
3621
+ const MANAGED_VERSION_DIRECTORY_PATTERN = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
3622
+ async function pruneManagedVersions(input) {
3623
+ const versionsDir = openMeldVersionsDir(input.pathInput);
3624
+ const managedVersions = (await readdir(versionsDir, { withFileTypes: true })).filter((entry) => entry.isDirectory() && MANAGED_VERSION_DIRECTORY_PATTERN.test(entry.name)).map((entry) => entry.name);
3625
+ const usableManagedVersions = new Set((await Promise.all(managedVersions.map(async (version) => ({
3626
+ usable: await isUsableManagedVersion(version, versionsDir),
3627
+ version
3628
+ })))).filter((entry) => entry.usable).map((entry) => entry.version));
3629
+ const retainedVersions = /* @__PURE__ */ new Set([input.currentVersion]);
3630
+ let rollbackVersion = null;
3631
+ if (input.preferredRollbackVersion && input.preferredRollbackVersion !== input.currentVersion && usableManagedVersions.has(input.preferredRollbackVersion)) rollbackVersion = input.preferredRollbackVersion;
3632
+ rollbackVersion ??= [...usableManagedVersions].filter((version) => compareSemver(version, input.currentVersion) < 0).sort((left, right) => compareSemver(right, left))[0] ?? null;
3633
+ if (rollbackVersion) retainedVersions.add(rollbackVersion);
3634
+ for (const protectedVersion of input.protectedVersions ?? []) if (usableManagedVersions.has(protectedVersion)) retainedVersions.add(protectedVersion);
3635
+ await Promise.all(managedVersions.filter((version) => !retainedVersions.has(version)).map((version) => rm(path.join(versionsDir, version), { recursive: true })));
3636
+ }
3637
+ async function isUsableManagedVersion(version, versionsDir) {
3638
+ const target = path.join(versionsDir, version, "openmeld");
3639
+ if (!(await stat(target).catch((error) => {
3640
+ if (getErrorCode(error) === "ENOENT") return null;
3641
+ throw error;
3642
+ }))?.isFile()) return false;
3643
+ return await access(target, constants.X_OK).then(() => true, (error) => {
3644
+ if (getErrorCode(error) === "EACCES" || getErrorCode(error) === "ENOENT") return false;
3645
+ throw error;
3646
+ });
3647
+ }
3648
+ function getErrorCode(error) {
3649
+ return error && typeof error === "object" && "code" in error ? String(error.code) : null;
3650
+ }
3651
+ //#endregion
3652
+ //#region src/local-components/managed-install.ts
3653
+ const MANAGED_INSTALL_LOCK_PROFILE = "managed-cli";
3654
+ const MANAGED_INSTALL_LOCK_KEY = "install";
3655
+ const MANAGED_INSTALL_LOCK_RETRY_DELAY_MS = 100;
3656
+ const MANAGED_INSTALL_LOCK_TIMEOUT_MS = 3e4;
3657
+ function resolveCliPlatformToken() {
3658
+ return `${process$1.platform}-${process$1.arch}`;
3659
+ }
3660
+ function resolveCliSelfVersion() {
3661
+ return OPENMELD_VERSION;
3662
+ }
3663
+ async function isUsableManagedBinary(target) {
3664
+ if (!(await stat(target).catch((error) => {
3665
+ if (isErrorWithCode(error, "ENOENT")) return null;
3666
+ throw error;
3667
+ }))?.isFile()) return false;
3668
+ return await access(target, constants.X_OK).then(() => true, (error) => {
3669
+ if (isErrorWithCode(error, "EACCES") || isErrorWithCode(error, "ENOENT")) return false;
3670
+ throw error;
3671
+ });
3672
+ }
3673
+ async function readCurrentPointerVersion(pathInput = {}) {
3674
+ const pointerPath = openMeldManagedBinaryPath(pathInput);
3675
+ const target = await readlink(pointerPath).catch((error) => {
3676
+ if (isErrorWithCode(error, "ENOENT") || isErrorWithCode(error, "EINVAL")) return null;
3677
+ throw error;
3678
+ });
3679
+ if (!target) return null;
3680
+ const resolved = path.isAbsolute(target) ? target : path.resolve(path.dirname(pointerPath), target);
3681
+ const version = path.basename(path.dirname(resolved));
3682
+ return version.length > 0 && path.resolve(resolved) === openMeldManagedVersionBinaryPath(version, pathInput) ? version : null;
3683
+ }
3684
+ async function readManagedCliInstallation() {
3685
+ const version = await readCurrentPointerVersion();
3686
+ if (!version) return null;
3687
+ const binaryPath = openMeldManagedVersionBinaryPath(version);
3688
+ if (!await isUsableManagedBinary(binaryPath)) return null;
3689
+ return {
3690
+ version,
3691
+ binaryPath
3692
+ };
3693
+ }
3694
+ /**
3695
+ * Install the currently-running binary (process.execPath) into the managed
3696
+ * layout and point bin/openmeld at it. Idempotent with semver arbitration:
3697
+ * a same-or-newer pointer is left in place (install only goes up), unless
3698
+ * `force` is set. Both the versioned binary and the pointer are swapped in
3699
+ * atomically via a temp name + rename.
3700
+ */
3701
+ async function performManagedInstall(input) {
3702
+ return await withManagedInstallTransaction(async () => performManagedInstallLocked(input));
3703
+ }
3704
+ async function withManagedInstallTransaction(run, pathInput = {}) {
3705
+ const startedAtMs = Date.now();
3706
+ for (;;) try {
3707
+ return await runWithHeldLock({
3708
+ lock: await acquireLock({
3709
+ openMeldProfileId: MANAGED_INSTALL_LOCK_PROFILE,
3710
+ key: MANAGED_INSTALL_LOCK_KEY,
3711
+ meta: { component: "managed_cli.install" },
3712
+ pathResolution: pathInput
3713
+ }),
3714
+ run,
3715
+ releaseContext: {
3716
+ component: "managed_cli.install",
3717
+ lockKey: MANAGED_INSTALL_LOCK_KEY,
3718
+ openMeldProfileId: MANAGED_INSTALL_LOCK_PROFILE
3719
+ }
3720
+ });
3721
+ } catch (error) {
3722
+ if (!isOpenMeldLockError(error) || isOpenMeldOrphanedLockError(error) || Date.now() - startedAtMs >= MANAGED_INSTALL_LOCK_TIMEOUT_MS) throw error;
3723
+ await setTimeout$1(MANAGED_INSTALL_LOCK_RETRY_DELAY_MS);
3724
+ }
3725
+ }
3726
+ /**
3727
+ * Prune managed CLI versions only while holding the install transaction lock.
3728
+ * The current pointer and every durable Service update target are re-read in
3729
+ * the lock, so cleanup cannot race an install or use a stale pending snapshot.
3730
+ */
3731
+ async function pruneManagedInstallVersions(input) {
3732
+ const pathInput = input.pathInput;
3733
+ assertNoPublishedProductionMutationDuringTests(pathInput, "managed CLI versions");
3734
+ await withManagedInstallTransaction(async () => {
3735
+ const currentVersion = await readCurrentPointerVersion(pathInput);
3736
+ if (currentVersion === null) return;
3737
+ const protectedVersions = await readManagedInstallProtectedVersions(pathInput);
3738
+ await pruneManagedVersions({
3739
+ currentVersion,
3740
+ pathInput,
3741
+ preferredRollbackVersion: input.preferredRollbackVersion,
3742
+ protectedVersions
3743
+ });
3744
+ }, pathInput);
3745
+ }
3746
+ async function performManagedInstallLocked(input) {
3747
+ const force = input?.force ?? false;
3748
+ const version = resolveCliSelfVersion();
3749
+ const platform = resolveCliPlatformToken();
3750
+ const currentPointerPath = openMeldManagedBinaryPath();
3751
+ const managedBinaryPath = openMeldManagedVersionBinaryPath(version);
3752
+ const previousVersion = await readCurrentPointerVersion();
3753
+ const protectedVersions = await readManagedInstallProtectedVersions();
3754
+ const baseOutcome = {
3755
+ version,
3756
+ platform,
3757
+ managedBinaryPath,
3758
+ currentPointerPath,
3759
+ previousVersion,
3760
+ forced: force
3761
+ };
3762
+ if (previousVersion !== null) {
3763
+ const comparison = compareSemver(version, previousVersion);
3764
+ if (!force && comparison === 0 && await isUsableManagedBinary(managedBinaryPath)) {
3765
+ await pruneManagedVersions({
3766
+ currentVersion: previousVersion,
3767
+ protectedVersions
3768
+ });
3769
+ return {
3770
+ ...baseOutcome,
3771
+ result: "noop_same_version"
3772
+ };
3773
+ }
3774
+ if (comparison < 0 && !force) {
3775
+ if (!await isUsableManagedBinary(managedBinaryPath)) await placeVersionedBinary(input?.sourceBinaryPath ?? process$1.execPath, version, managedBinaryPath);
3776
+ await pruneManagedVersions({
3777
+ currentVersion: previousVersion,
3778
+ preferredRollbackVersion: version,
3779
+ protectedVersions
3780
+ });
3781
+ return {
3782
+ ...baseOutcome,
3783
+ result: "noop_newer_present"
3784
+ };
3785
+ }
3786
+ }
3787
+ await placeVersionedBinary(input?.sourceBinaryPath ?? process$1.execPath, version, managedBinaryPath);
3788
+ await pruneManagedVersions({
3789
+ currentVersion: version,
3790
+ preferredRollbackVersion: previousVersion,
3791
+ protectedVersions
3792
+ });
3793
+ await swapCurrentPointer(currentPointerPath, managedBinaryPath);
3794
+ return {
3795
+ ...baseOutcome,
3796
+ result: "installed"
3797
+ };
3798
+ }
3799
+ async function readManagedInstallProtectedVersions(pathInput = {}) {
3800
+ const [protectedVersions, pendingServiceUpdate, activeBundle] = await Promise.all([
3801
+ readDaemonServiceUpdateWorkerProtectedManagedVersions(pathInput),
3802
+ readPendingDaemonServiceUpdate(pathInput),
3803
+ readDaemonActiveBundleState(pathInput)
3804
+ ]);
3805
+ if (activeBundle?.bundleFormat === "binary_v1") protectedVersions.add(activeBundle.daemonVersion);
3806
+ if (pendingServiceUpdate?.preparedBundle.bundleFormat === "binary_v1") protectedVersions.add(pendingServiceUpdate.preparedBundle.daemonVersion);
3807
+ return protectedVersions;
3808
+ }
3809
+ async function placeVersionedBinary(sourceBinary, version, managedBinaryPath) {
3810
+ await mkdir(openMeldManagedVersionDir(version), { recursive: true });
3811
+ const tmpPath = `${managedBinaryPath}.tmp-${process$1.pid}-${Date.now()}`;
3812
+ await rm(tmpPath, { force: true }).catch(() => void 0);
3813
+ await copyFile(sourceBinary, tmpPath);
3814
+ await chmod(tmpPath, 493);
3815
+ if ((await lstat(managedBinaryPath).catch((error) => {
3816
+ if (isErrorWithCode(error, "ENOENT")) return null;
3817
+ throw error;
3818
+ }))?.isDirectory()) await rm(managedBinaryPath, { recursive: true });
3819
+ await rename(tmpPath, managedBinaryPath);
3820
+ }
3821
+ async function swapCurrentPointer(currentPointerPath, managedBinaryPath) {
3822
+ await mkdir(openMeldBinDir(), { recursive: true });
3823
+ const relativeTarget = path.relative(path.dirname(currentPointerPath), managedBinaryPath);
3824
+ const tmpPath = `${currentPointerPath}.tmp-${process$1.pid}-${Date.now()}`;
3825
+ await rm(tmpPath, { force: true }).catch(() => void 0);
3826
+ await symlink(relativeTarget, tmpPath);
3827
+ await rename(tmpPath, currentPointerPath);
3828
+ }
3829
+ function buildInstallSelfJsonPayload(outcome) {
3830
+ return {
3831
+ schemaVersion: 1,
3832
+ type: "cli.install_self",
3833
+ result: outcome.result,
3834
+ version: outcome.version,
3835
+ platform: outcome.platform,
3836
+ managedBinaryPath: outcome.managedBinaryPath,
3837
+ currentPointerPath: outcome.currentPointerPath,
3838
+ previousVersion: outcome.previousVersion,
3839
+ forced: outcome.forced
3840
+ };
3841
+ }
3842
+ function isErrorWithCode(error, code) {
3843
+ return error instanceof Error && "code" in error && error.code === code;
3844
+ }
3845
+ //#endregion
3846
+ //#region src/local-service/control-plane/client.ts
3847
+ const DEFAULT_LOCAL_DAEMON_CONTROL_PLANE_TIMEOUT_MS = 5e3;
3848
+ var LocalDaemonControlPlaneClientError = class extends Error {
3849
+ code;
3850
+ constructor(code, message) {
3851
+ super(message);
3852
+ this.code = code;
3853
+ }
3854
+ };
3855
+ async function sendLocalDaemonControlPlaneRequest(input) {
3856
+ const endpoint = input.endpoint ?? resolveDaemonControlPlaneEndpoint();
3857
+ const authToken = await readDaemonControlPlaneToken();
3858
+ if (!authToken) throw new LocalDaemonControlPlaneClientError("daemon.control.auth_token_missing", "daemon control token is missing");
3859
+ const rawResponse = await writeControlPlaneRequest({
3860
+ endpoint,
3861
+ request: {
3862
+ ...input.request,
3863
+ authToken
3864
+ },
3865
+ timeoutMs: input.timeoutMs ?? DEFAULT_LOCAL_DAEMON_CONTROL_PLANE_TIMEOUT_MS
3866
+ });
3867
+ const parsed = openMeldDaemonControlPlaneResponseSchema.safeParse(rawResponse);
3868
+ if (!parsed.success) throw new LocalDaemonControlPlaneClientError("daemon.control.invalid_response", "local daemon control returned an invalid response");
3869
+ if (parsed.data.code === "service.error") throw new LocalDaemonControlPlaneClientError(parsed.data.payload.errorCode, parsed.data.payload.errorMessage);
3870
+ return parsed.data;
3871
+ }
3872
+ async function requestLocalSyncRouteCatalog(input) {
3873
+ let response;
3874
+ try {
3875
+ response = await sendLocalDaemonControlPlaneRequest({
3876
+ endpoint: input.endpoint,
3877
+ timeoutMs: input.timeoutMs,
3878
+ request: {
3879
+ v: 1,
3880
+ command: "sync_route_catalog",
3881
+ payload: input.payload
3882
+ }
3883
+ });
3884
+ } catch (error) {
3885
+ throw rewriteDaemonControlPlaneContractMismatch(error);
3886
+ }
3887
+ if (response.code !== "service.sync_route_catalog") throw new LocalDaemonControlPlaneClientError("daemon.control.invalid_response", "local daemon control returned an unexpected response for route catalog sync");
3888
+ return response.payload;
3889
+ }
3890
+ async function requestLocalAgentActivitySync(input) {
3891
+ let response;
3892
+ try {
3893
+ response = await sendLocalDaemonControlPlaneRequest({
3894
+ endpoint: input.endpoint,
3895
+ timeoutMs: input.timeoutMs,
3896
+ request: {
3897
+ v: 1,
3898
+ command: "request_agent_activity_sync",
3899
+ payload: input.payload
3900
+ }
3901
+ });
3902
+ } catch (error) {
3903
+ throw rewriteDaemonControlPlaneContractMismatch(error);
3904
+ }
3905
+ if (response.code !== "service.agent_activity_sync_requested") throw new LocalDaemonControlPlaneClientError("daemon.control.invalid_response", "local daemon control returned an unexpected response for Agent Activity sync");
3906
+ return response.payload;
3907
+ }
3908
+ async function requestLocalDaemonShutdown(input) {
3909
+ let response;
3910
+ try {
3911
+ response = await sendLocalDaemonControlPlaneRequest({
3912
+ endpoint: input.endpoint,
3913
+ timeoutMs: input.timeoutMs,
3914
+ request: {
3915
+ v: 1,
3916
+ command: "shutdown",
3917
+ payload: input.payload
3918
+ }
3919
+ });
3920
+ } catch (error) {
3921
+ throw rewriteDaemonControlPlaneContractMismatch(error);
3922
+ }
3923
+ if (response.code !== "service.shutdown") throw new LocalDaemonControlPlaneClientError("daemon.control.invalid_response", "local daemon control returned an unexpected response for shutdown");
3924
+ return response.payload;
3925
+ }
3926
+ async function requestLocalDaemonServiceUpdateReadiness(input = {}) {
3927
+ let response;
3928
+ try {
3929
+ response = await sendLocalDaemonControlPlaneRequest({
3930
+ endpoint: input.endpoint,
3931
+ timeoutMs: input.timeoutMs,
3932
+ request: {
3933
+ v: 1,
3934
+ command: "service_update_readiness"
3935
+ }
3936
+ });
3937
+ } catch (error) {
3938
+ throw rewriteDaemonControlPlaneContractMismatch(error);
3939
+ }
3940
+ if (response.code !== "service.update_readiness") throw new LocalDaemonControlPlaneClientError("daemon.control.invalid_response", "local daemon control returned an unexpected response for service update readiness");
3941
+ return response.payload;
3942
+ }
3943
+ function rewriteDaemonControlPlaneContractMismatch(error) {
3944
+ if (error instanceof LocalDaemonControlPlaneClientError && error.code === "service.invalid_request") return new LocalDaemonControlPlaneClientError("daemon.control.contract_mismatch", "local OpenMeld Service must be restarted because the daemon control-plane contract changed on this device");
3945
+ return error;
3946
+ }
3947
+ async function writeControlPlaneRequest(input) {
3948
+ return await new Promise((resolve, reject) => {
3949
+ const socket = createConnection(input.endpoint);
3950
+ let responseBuffer = "";
3951
+ let settled = false;
3952
+ const cleanup = () => {
3953
+ socket.setTimeout(0);
3954
+ socket.off("connect", handleConnect);
3955
+ socket.off("data", handleData);
3956
+ socket.off("end", handleEnd);
3957
+ socket.off("error", handleError);
3958
+ socket.off("timeout", handleTimeout);
3959
+ };
3960
+ const settle = (action) => {
3961
+ if (settled) return;
3962
+ settled = true;
3963
+ cleanup();
3964
+ action();
3965
+ };
3966
+ const fail = (error) => {
3967
+ settle(() => {
3968
+ socket.destroy();
3969
+ reject(error);
3970
+ });
3971
+ };
3972
+ const handleConnect = () => {
3973
+ socket.write(`${JSON.stringify(input.request)}\n`);
3974
+ };
3975
+ const handleData = (chunk) => {
3976
+ responseBuffer += chunk;
3977
+ };
3978
+ const handleEnd = () => {
3979
+ settle(() => {
3980
+ const rawResponse = responseBuffer.trim();
3981
+ if (!rawResponse) {
3982
+ reject(new LocalDaemonControlPlaneClientError("daemon.control.empty_response", "local daemon control returned an empty response"));
3983
+ return;
3984
+ }
3985
+ try {
3986
+ resolve(JSON.parse(rawResponse));
3987
+ } catch {
3988
+ reject(new LocalDaemonControlPlaneClientError("daemon.control.invalid_json", "local daemon control returned malformed JSON"));
3989
+ }
3990
+ });
3991
+ };
3992
+ const handleError = (error) => {
3993
+ const code = error && typeof error === "object" && "code" in error ? String(error.code) : "daemon.control.connection_failed";
3994
+ fail(new LocalDaemonControlPlaneClientError(code === "ENOENT" || code === "ECONNREFUSED" ? "daemon.control.endpoint_missing" : code, error instanceof Error ? error.message : "failed to connect to local daemon control"));
3995
+ };
3996
+ const handleTimeout = () => {
3997
+ fail(new LocalDaemonControlPlaneClientError("daemon.control.timeout", `local daemon control timed out after ${String(input.timeoutMs)}ms`));
3998
+ };
3999
+ socket.setEncoding("utf8");
4000
+ socket.setTimeout(input.timeoutMs);
4001
+ socket.once("connect", handleConnect);
4002
+ socket.on("data", handleData);
4003
+ socket.once("end", handleEnd);
4004
+ socket.once("error", handleError);
4005
+ socket.once("timeout", handleTimeout);
4006
+ });
4007
+ }
4008
+ //#endregion
3644
4009
  //#region src/config/auth-url.ts
3645
4010
  const DEFAULT_AUTH_BASE_URL = "https://auth.openmeld.ai";
3646
4011
  const DEV_LOCAL_AUTH_BASE_URL = "http://localhost:8788";
@@ -5331,8 +5696,9 @@ function parseJson$1(raw) {
5331
5696
  }
5332
5697
  //#endregion
5333
5698
  //#region src/local-service/lifecycle/current-daemon-version.ts
5334
- function resolveCurrentDaemonExpectedVersion() {
5335
- return OPENMELD_VERSION;
5699
+ async function resolveCurrentDaemonExpectedVersion(selectedVersion = resolveBundledServiceRelease()?.version ?? OPENMELD_VERSION) {
5700
+ const contract = await readDaemonServiceContract();
5701
+ return contract && compareSemver(contract.daemonVersion, selectedVersion) > 0 ? contract.daemonVersion : selectedVersion;
5336
5702
  }
5337
5703
  //#endregion
5338
5704
  //#region src/local-service/core/types.ts
@@ -6402,7 +6768,7 @@ async function inspectDaemonServiceInventory(input) {
6402
6768
  runtimeStatus
6403
6769
  });
6404
6770
  const runtimeCommandPathExists = runtimeCommandEntryPath ? await pathExists$3(runtimeCommandEntryPath).catch(() => null) : null;
6405
- const currentSourceDistFingerprint = activeBundle?.bundleFormat === "self_contained_v1" ? await resolveCurrentDaemonSourceDistFingerprint({ cliScriptPath: input.cliScriptPath }).catch(() => null) : null;
6771
+ const installedBundleFingerprint = activeBundleEntryPath ? await resolveInstalledDaemonBundleFingerprint(activeBundle) : null;
6406
6772
  const resolvedArtifact = resolveDaemonServiceArtifact({
6407
6773
  expectedVersion: input.expectedVersion,
6408
6774
  installStatus,
@@ -6410,7 +6776,7 @@ async function inspectDaemonServiceInventory(input) {
6410
6776
  activeBundle,
6411
6777
  activeBundleSourceAvailable,
6412
6778
  activeBundleEntryPath,
6413
- currentSourceDistFingerprint
6779
+ installedBundleFingerprint
6414
6780
  });
6415
6781
  const mergedOwnedProcesses = mergeOwnedProcesses(ownedProcesses, legacySharedService?.present ? legacySharedService.ownedProcesses : []);
6416
6782
  const observedServiceManager = installStatus.installed || runtimeStatus.managedBySystemService || runtimeStatus.serviceController !== "unknown" || isKnownServiceController(serviceContract?.serviceController) ? await resolveServiceManager(resolvePreferredServiceManagerController({
@@ -6662,7 +7028,7 @@ function buildBundleAnomaly(input) {
6662
7028
  }
6663
7029
  case "bundle_content_drift": return {
6664
7030
  code: "bundle_content_drift",
6665
- message: "OpenMeld Service is using older local service files than this lane expects, so OpenMeld needs to update the service."
7031
+ message: "OpenMeld could not verify the installed Service files. The Service needs repair."
6666
7032
  };
6667
7033
  case "bundle_lane_drift": return {
6668
7034
  code: "bundle_lane_drift",
@@ -36280,7 +36646,7 @@ async function resolveDeviceReadinessLocalDemand(input) {
36280
36646
  }
36281
36647
  async function resolveReplyReadinessInventory(_status) {
36282
36648
  return await inspectDaemonServiceInventory({
36283
- expectedVersion: resolveCurrentDaemonExpectedVersion(),
36649
+ expectedVersion: await resolveCurrentDaemonExpectedVersion(),
36284
36650
  intent: "status_cleanup"
36285
36651
  }).catch(() => null);
36286
36652
  }
@@ -36529,10 +36895,10 @@ function resolveRuntimeStatusForSnapshot(input) {
36529
36895
  if (input.localServiceObservation) return Promise.resolve(input.localServiceObservation.runtimeStatus);
36530
36896
  return resolveDaemonRuntimeState(input.daemonStatus).catch(() => null);
36531
36897
  }
36532
- function resolveInventoryForSnapshot(localServiceObservation) {
36898
+ async function resolveInventoryForSnapshot(localServiceObservation) {
36533
36899
  if (localServiceObservation) return Promise.resolve(localServiceObservation.inventory);
36534
36900
  return inspectDaemonServiceInventory({
36535
- expectedVersion: resolveCurrentDaemonExpectedVersion(),
36901
+ expectedVersion: await resolveCurrentDaemonExpectedVersion(),
36536
36902
  intent: "status_cleanup"
36537
36903
  }).catch(() => null);
36538
36904
  }
@@ -38812,8 +39178,7 @@ async function runDaemonServiceLifecycle(input) {
38812
39178
  state.inventoryBefore = await inspectDaemonServiceInventory({
38813
39179
  expectedVersion: input.expectedVersion,
38814
39180
  intendedMode: resolveLifecycleIntendedMode(input),
38815
- intent: toLifecycleIntent(input.operation),
38816
- ...input.cliScriptPath ? { cliScriptPath: input.cliScriptPath } : {}
39181
+ intent: toLifecycleIntent(input.operation)
38817
39182
  });
38818
39183
  const inventoryBefore = state.inventoryBefore;
38819
39184
  const desiredState = input.desiredState ?? resolveLifecycleDesiredState(inventoryBefore);
@@ -40006,6 +40371,7 @@ async function scheduleDaemonServiceUpdateLocked(input, deps) {
40006
40371
  const preparedBundle = await deps.prepareBundle({
40007
40372
  activate: false,
40008
40373
  daemonVersion: input.targetVersion,
40374
+ ...input.binaryRelease ? { binaryRelease: input.binaryRelease } : {},
40009
40375
  ...input.cliScriptPath ? { cliScriptPath: input.cliScriptPath } : {}
40010
40376
  });
40011
40377
  const now = deps.now();
@@ -40051,6 +40417,7 @@ async function reschedulePendingDaemonServiceUpdate(input) {
40051
40417
  preparedBundle: await input.dependencies.prepareBundle({
40052
40418
  activate: false,
40053
40419
  daemonVersion: input.request.targetVersion,
40420
+ ...input.request.binaryRelease ? { binaryRelease: input.request.binaryRelease } : {},
40054
40421
  ...input.request.cliScriptPath ? { cliScriptPath: input.request.cliScriptPath } : {}
40055
40422
  }),
40056
40423
  requestSource: input.request.requestSource ?? "cli",
@@ -40384,7 +40751,7 @@ function isCliUpdateCheckApplicable(environmentTarget, input = {}) {
40384
40751
  * caller fails open and never locks a user out over a flaky release channel.
40385
40752
  */
40386
40753
  async function assessCliUpdate(input) {
40387
- const currentVersion = OPENMELD_VERSION;
40754
+ const currentVersion = input.currentVersion ?? OPENMELD_VERSION;
40388
40755
  const unchecked = {
40389
40756
  checked: false,
40390
40757
  currentVersion,
@@ -40408,6 +40775,7 @@ async function assessCliUpdate(input) {
40408
40775
  checked: true,
40409
40776
  currentVersion,
40410
40777
  latestVersion: info.version,
40778
+ ...info.serviceVersion ? { serviceVersion: info.serviceVersion } : {},
40411
40779
  requiredFloor,
40412
40780
  updateAvailable: compareSemver(currentVersion, info.version) < 0,
40413
40781
  floorBreached
@@ -40626,11 +40994,20 @@ async function resolveOpenMeldToolsMaintenanceProjection() {
40626
40994
  }
40627
40995
  //#endregion
40628
40996
  //#region src/local-service/maintenance/openmeld-tools-upgrade-process.ts
40997
+ async function resolveMaintenanceCliInstallation() {
40998
+ const installed = isBinaryDistribution() ? await readManagedCliInstallation() : null;
40999
+ return installed && compareSemver(installed.version, OPENMELD_VERSION) >= 0 ? installed : {
41000
+ version: OPENMELD_VERSION,
41001
+ binaryPath: process.execPath
41002
+ };
41003
+ }
40629
41004
  async function runOpenMeldToolsUpgradeProcess(context) {
41005
+ const binaryDistribution = isBinaryDistribution();
41006
+ const cli = await resolveMaintenanceCliInstallation();
40630
41007
  const { command, argsPrefix } = resolveOpenMeldToolsUpgradeProgram({
40631
- binaryDistribution: isBinaryDistribution(),
41008
+ binaryDistribution,
40632
41009
  processEntryScriptPath: process.argv[1],
40633
- processExecutablePath: process.execPath
41010
+ processExecutablePath: binaryDistribution ? cli.binaryPath : process.execPath
40634
41011
  });
40635
41012
  return await new Promise((resolve, reject) => {
40636
41013
  const child = spawn(command, [...argsPrefix, "maintenance-upgrade"], {
@@ -40717,7 +41094,8 @@ function createOpenMeldToolsUpdateCoordinator(overrides = {}, options = {}) {
40717
41094
  }
40718
41095
  const assessment = await deps.assessUpdate({ forceRefresh: true });
40719
41096
  if (!(assessment.checked && assessment.latestVersion)) return { status: "unavailable" };
40720
- if (!(assessment.updateAvailable || await deps.serviceNeedsAlignment(assessment.currentVersion))) return {
41097
+ const serviceVersion = assessment.serviceVersion ?? assessment.currentVersion;
41098
+ if (!(assessment.updateAvailable || await deps.serviceNeedsAlignment(serviceVersion))) return {
40721
41099
  currentVersion: assessment.currentVersion,
40722
41100
  status: "current"
40723
41101
  };
@@ -40731,7 +41109,7 @@ function createOpenMeldToolsUpdateCoordinator(overrides = {}, options = {}) {
40731
41109
  phase: "updating",
40732
41110
  requestSource,
40733
41111
  requestedAt: now,
40734
- targetVersion: assessment.updateAvailable ? assessment.latestVersion : assessment.currentVersion,
41112
+ targetVersion: assessment.updateAvailable ? assessment.latestVersion : serviceVersion,
40735
41113
  updatedAt: now,
40736
41114
  urgency: assessment.floorBreached ? "required" : await deps.resolveUrgency()
40737
41115
  }
@@ -40802,10 +41180,12 @@ function resolveDependencies(overrides) {
40802
41180
  wakeWorker: overrides.wakeWorker ?? (() => startDaemonServiceUpdateWorker()),
40803
41181
  assessUpdate: overrides.assessUpdate ?? (async () => await assessCliUpdate({
40804
41182
  environmentTarget: await resolveOpenMeldEnvironmentTarget(),
40805
- forceRefresh: true
41183
+ forceRefresh: true,
41184
+ currentVersion: (await resolveMaintenanceCliInstallation()).version
40806
41185
  })),
40807
41186
  completeAttempt: overrides.completeAttempt ?? completeOpenMeldToolsUpdateAttempt,
40808
- serviceNeedsAlignment: overrides.serviceNeedsAlignment ?? (async (daemonVersion) => {
41187
+ serviceNeedsAlignment: overrides.serviceNeedsAlignment ?? (async (selectedVersion) => {
41188
+ const daemonVersion = await resolveCurrentDaemonExpectedVersion(selectedVersion);
40809
41189
  const decision = resolveDaemonServiceAlignmentDecision({
40810
41190
  inventory: await inspectDaemonServiceInventory({
40811
41191
  expectedVersion: daemonVersion,
@@ -40842,6 +41222,6 @@ function projectServiceJob(job) {
40842
41222
  };
40843
41223
  }
40844
41224
  //#endregion
40845
- export { formatDeviceReplyReadinessLabel as $, RUNTIME_STATE_PERSIST_MIN_INTERVAL_MS as $a, getSetupFlowCopy as $i, resolveRouteRegistrationReconcileDecision as $n, primeOpenMeldProfilesSessionCache as $o, resolveAgentControllerPermissionModeForController as $r, resolveProjectBindingForPath as $t, resolveDaemonStatusSnapshot as A, normalizeNonNegativeInteger as Aa, readCurrentDaemonOwnerSnapshot as Ai, resolveSkillsAgentRegistry as An, OPENMELD_VERSION as Ao, seedLegacyAgentContext as Ar, createModelCatalogReadSession as At, formatDaemonServiceRefreshReliabilityMessage as B, CONTROLLED_SHUTDOWN_SOCKET_CLOSE_TIMEOUT_MS as Ba, waitForDaemonSystemServiceToStop as Bi, repairBuiltinControllerInstall as Bn, upsertDaemonServiceContract as Bo, buildWorkingLanguagePromptPlan as Br, setOpenMeldManagedProfileWorkspace as Bt, isSystemServiceStartupTimeoutError as C, ensureDaemonRuntimePaths as Ca, buildCliLaunchInvocation as Ci, removeAgentCustomTarget as Cn, collectLocalOperationFailure as Co, buildRuntimeWorkspaceFingerprint as Cr, cliBinaryDeltaPatchSchema as Cs, summarizeSkippedDaemonProfiles as Ct, captureDaemonServiceEvidence as D, dirnamePath as Da, buildDaemonOwnerSnapshotFromObservedState as Di, updateAgentRegistrations as Dn, sendLocalDaemonControlPlaneRequest as Do, loadLedgerState as Dr, resolveLocalController as Dt, startDaemonSystemServiceWithAutoRepair as E, asRecord as Ea, inspectDaemonServiceInventory as Ei, updateAgentCustomTarget as En, requestLocalDaemonShutdown as Eo, commitResolvedAgentContext as Er, readLocalEnabledControllers as Et, buildDaemonServiceRefreshNextStep as F, warnDaemonEvent as Fa, getEffectiveDaemonRuntimeStatus as Fi, notifyDaemonRouteCatalogChanged as Fn, configureDaemonMaintenanceEnvironment as Fo, buildAgentContextLookupKey as Fr, readProfileWorkspaceConfig as Ft, buildDaemonServiceDependencyDetails as G, DEFAULT_RECONNECT_DELAY_MS as Ga, toStartBackgroundHelperExecutionCompatibility as Gi, isNpmGlobalCommandPath as Gn, fetchLatestPackageInfo as Go, getAgentControllerPermissionModeFieldLabel as Gr, bindProject as Gt, resolveDaemonServiceFreshnessWarning as H, DAEMON_STREAM_CONNECT_TIMEOUT_MS as Ha, listDaemonOwnedProcesses as Hi, resolveBuiltinAgentControllerDefinition as Hn, compareSemver as Ho, createAgentExecutionStatusDisplayRows as Hr, describeProfileWorkspacePathValidationFailure as Ht, buildDaemonServiceRefreshPromptMessage as I, CATALOG_SYNC_RETRY_INTERVAL_MS as Ia, readCurrentDaemonRuntimeContext as Ii, normalizeAgentId as In, hasIndependentMaintenanceRegistration as Io, DEFAULT_TASK_LIFECYCLE_HEARTBEAT_INTERVAL_MS as Ir, readProfileWorkspaceConfigForAccount as It, buildDaemonServiceDependencySummary as J, PROVIDER_CONVERSATION_PROOF_SYNC_INTERVAL_MS as Ja, DaemonServiceRunError as Ji, normalizeDispatchThreadAction as Jn, createOpenMeldAgentProfile as Jo, parseAgentControllerRef as Jr, listProjectConnectionsWithStatus as Jt, buildDaemonServiceDependencyMeaning as K, HEARTBEAT_RESPONSE_TIMEOUT_MS as Ka, ensureDaemonRuntimeContractState as Ki, isPnpmGlobalCommandPath as Kn, readVersionState as Ko, isAgentExecutionReadyOrConnecting as Kr, isProjectBound as Kt, buildDaemonServiceRepairGuidance as L, CATALOG_SYNC_SIGNAL_POLL_INTERVAL_MS as La, readCurrentObservedDaemonRuntimeStatus as Li, normalizeAgentIds as Ln, clearDaemonServiceContract as Lo, areAgentControllerInterfaceAccountsSame as Lr, resolveConfiguredProfileWorkspacePath as Lt, resolveDaemonStatusAuthenticationAttention as M, normalizeText$11 as Ma, resolveStoppedContractWriteBlockedReason as Mi, resolveRegistryOriginLaunchCommand as Mn, completePendingDaemonServiceUpdate as Mo, upsertConversationExecutionState as Mr, resolveProfileWorkspaceRuntime as Mt, resolveServiceReadiness as N, nowIsoString as Na, summarizeDaemonOwnerSnapshot as Ni, resolveRegistryRuntimeAdapterCapabilitySnapshot as Nn, readLastDaemonServiceUpdate as No, withLedgerStateTransaction as Nr, ensureOpenMeldManagedProfileWorkspace as Nt, captureDaemonServiceEvidenceBestEffort as O, emitRunLine as Oa, formatDaemonOwnerSummaryLabel as Oi, canManageRegistryAgentSkillTargets as On, buildInstallSelfJsonPayload as Oo, removeConversationExecutionState as Or, resolveLocalRuntimeControllerSupport as Ot, resolveServiceReadinessFromServiceStatus as P, toErrorMessage$23 as Pa, clearDaemonRuntimeStateIfDefinitelyStopped as Pi, resolveRegistryRuntimeAdapterContractByAgentControllerRef as Pn, readPendingDaemonServiceUpdate as Po, buildAuthenticatedControlPlaneResponse as Pr, normalizeCustomProfileWorkspacePath as Pt, formatAgentReplyReadinessLabel as Q, RUNTIME_AGENT_CONTROLLER_REPORT_SYNC_RETRY_INTERVAL_MS as Qa, buildOnboardingPlan as Qi, isDaemonReconcileInProgressError as Qn, listOpenMeldProfiles as Qo, renderWorkingLanguagePrompt as Qr, removeProjectConnection as Qt, buildDaemonServiceStatusReadOnlyDetail as R, CONTROLLED_SHUTDOWN_REQUEST_TIMEOUT_MS as Ra, resolveDaemonRuntimeState as Ri, parseAgentEnabledOption as Rn, isDaemonServiceContractIdentityReusable as Ro, buildAgentControllerRef as Rr, resolveConfiguredProfileWorkspacePathForAccount as Rt, isDaemonInventoryRunningAndStartReady as S, buildLedgerPaths as Sa, resolveDispatchSpaceActionMcpServer as Si, reconcileNewRunnableBuiltinAgentsForSetup as Sn, runWithDaemonLifecycleCommandJournal as So, runRuntimeTask as Sr, resolveUserFacingCliEntryCommand as Ss, loadDaemonRouteCatalog as St, waitForSystemServiceStartup as T, resolvePreferredDaemonDeviceId as Ta, createProviderOriginalError as Ti, setAgentRegistrationEnabled as Tn, requestLocalAgentActivitySync as To, appendLedgerHistoryEntry as Tr, resolveBuiltinAgentControllerBrand as Ts, buildRuntimeRouteTargets as Tt, clearDaemonStartFailureState as U, DAEMON_STREAM_KEEPALIVE_INTERVAL_MS as Ua, assertDaemonMaintenanceInstallationOwnership as Ui, isBunGlobalCommandPath as Un, ensureVersionStateReady as Uo, createAuthorityOpenMeldServiceRuntimeId as Ur, ProjectBindingOperationError as Ut, formatDaemonServiceUpdateRequiredMessage as V, DAEMON_RUNTIME_CONTRACT_EPOCH as Va, cleanupLegacySharedDaemonServiceState as Vi, EMPTY_AGENT_CONTROLLER_INTERFACE_CAPABILITIES as Vn, buildNextVersionState as Vo, createAgentControllerInterfaceDisplayRows as Vr, validateCustomProfileWorkspacePath as Vt, writeDaemonStartFailureState as W, DAEMON_STREAM_KEEPALIVE_PONG_TIMEOUT_MS as Wa, resolveDaemonRuntimeContractCompatibility as Wi, isHomebrewCommandPath as Wn, fetchLatestCliBinaryRelease as Wo, getAgentControllerPermissionModeDisplayMetadata as Wr, ProjectBindingStoreUpdateRequiredError as Wt, resolveDaemonServiceDependencyDiagnostics as X, REGISTER_RESPONSE_TIMEOUT_MS as Xa, PREPARE_SESSION_RECONNECT_GRACE_MS as Xi, SPACE_ACTION_CONTEXT_GUIDANCE_LINES as Xn, deleteOpenMeldProfile as Xo, projectPeopleComputersToLegacyLocalRuntimes as Xr, removeAgentActivityBindingsWhileDeliveryLocked as Xt, buildDaemonServiceDependencyTitle as Y, PROVIDER_CONVERSATION_PROOF_SYNC_RETRY_INTERVAL_MS as Ya, resolveCurrentDaemonExpectedVersion as Yi, syncRuntimeEventToInflightTaskControlRegistry as Yn, createOpenMeldHumanProfile as Yo, peopleComputerContainsDevice as Yr, migrateProjectBindingStore as Yt, resolveCurrentReplyReadinessSnapshot as Z, RUNTIME_AGENT_CONTROLLER_REPORT_SYNC_INTERVAL_MS as Za, buildDaemonRouteObservationPresentation as Zi, SPACE_ACTION_TARGET_GUIDANCE_LINES as Zn, getOpenMeldProfileCapabilities as Zo, renderInformationProtectionPrompt as Zr, removeMissingProjectConnections as Zt, DaemonServiceLifecycleDrainTimeoutError as _, DAEMON_SERVICE_FULL_ALIGNMENT_ANOMALIES as _a, forkCodexAppServerThread as _i, listAgentRegistrations as _n, readLatestDaemonLifecycleConnectionStateEvent as _o, resolveDispatchQueueLogMeta as _r, formatOpenMeldCliLine as _s, readDaemonRouteCatalogCache as _t, resolveServiceUpdateUrgency as a, resolveCurrentOpenMeldAccountContext as aa, resolveCatalogSyncSkippedProfilesLogState as ai, withAgentActivityDeliveryLock as an, clearSelectedOpenMeldProfileId as ao, createLocalTaskInterruptSender as ar, buildAuthenticationStatusLabel as as, resolveReplyReadinessAvailabilityReasonCopy as at, prepareDaemonServiceUpdateWorkerCarrier as b, classifyDaemonServiceRunStartability as ba, createUnavailableProviderUsageLimits as bi, readAgentRuntimeConfigHealth as bn, resolveRecentDaemonSignalStopCause as bo, resolveCompatibleConversationExecutionState as br, formatProfileAwareOpenMeldCliCommands as bs, createMutableRouteCatalogState as bt, buildLocalAgentCatalogFromReadiness as c, ensureDaemonSystemServiceCommandFiles as ca, parseOpenCodeGoUsageResponse as ci, syncDeviceRuntimeStateProjection as cn, resolveOpenMeldEnvironmentTarget as co, createInflightTaskControlRegistry as cr, createAuthenticationError as cs, classifyGatewayChainFailure as ct, isCliUpdateCheckApplicable as d, isOpenMeldManagedBinaryPath as da, GrokBuildAcpTransportError as di, emitReconcileStartedEvidence as dn, prepareDaemonServiceBundle as do, MIN_HEARTBEAT_INTERVAL_MS as dr, resolveAuthenticationGuidanceFromError as ds, resolveGatewayChainRetryGuidance as dt, parseCliViewMode as ea, resolveAgentExecutionStatus as ei, runIfAgentActivityBindingGenerationIsCurrent as en, isSelectedOpenMeldProfileRequiredError as eo, createSerialAgentInteractionCallback as er, resolveOpenMeldProfile as es, formatHumanReplyReadinessReason as et, readLastOpenMeldToolsUpdateAttempt as f, buildDaemonServiceTargetSpec as fa, probeGrokBuildAcpInterface as fi, createPrimaryBindingReadSession as fn, readDaemonActiveBundleState as fo, applyAcceptedLeases as fr, resolveAuthenticationGuidanceFromMessage as fs, resolveOpenClawLocalDiagnosticsValue as ft, scheduleDaemonServiceUpdate as g, DAEMON_SERVICE_AUTO_HEAL_ANOMALIES as ga, resolveInstalledCodexLaunchCandidates as gi, listAgentCustomTargets as gn, formatDaemonLifecycleOriginSummary as go, resolveCatalogSyncIntervalMs as gr, formatOpenMeldCliCommands as gs, slugifyOpenClawNamePart as gt, runPendingDaemonServiceUpdate as h, resolveVersionChangeDirection as ha, resolveCodexTimeoutMs as hi, createRegistrationFromCatalogTarget as hn, emitDaemonLifecycleEvent as ho, resolveAdaptiveHeartbeatIntervalMs as hr, formatOpenMeldCliCommand as hs, normalizeOpenClawSpaceIdPrefix as ht, writeOpenMeldToolsMaintenancePolicy as i, setProfileDefaultView as ia, resolveSelectableCandidates as ii, resolveLocalProjectConnectionForPath as in, clearAllSelectedOpenMeldProfileIds as io, mergeOpenClawGatewayVisibility as ir, buildAgentAuthenticationGuide as is, formatSpaceMemberCommandRecoveryCopy as it, resolveDaemonStatusAttention as j, normalizeOptionalText$52 as ja, resolveDaemonStopStrategy as ji, listBuiltinAgentsRegistryEntries as jn, package_default as jo, settleInflightTask as jr, resolveCurrentEffectiveProfileWorkingFolderRuntime as jt, formatDaemonFailureContextText as k, normalizeHeartbeatIntervalMs as ka, hasActiveDaemonOwners as ki, detectInstalledSkillsAgents as kn, performManagedInstall as ko, resolveConversationExecutionStateByLookupKey as kr, syncProfileWorkspaceState as kt, readCurrentLocalDeviceId as l, extractDaemonCommandEntryPath as la, forkOpenCodeServerSession as li, emitDriftDetectedEvidence as ln, resolveAuthBaseUrl as lo, ADAPTIVE_HEARTBEAT_JITTER_RATIO as lr, extractAuthenticationPromptAction as ls, resolveGatewayChainReadiness as lt, readOpenMeldToolsUpdateContextFromEnv as m, isVersionDowngrade as ma, projectCodexUsageLimits as mi, addAgentCustomTarget as mn, resolveDaemonBundleEntryPathFromState as mo, pruneStaleLeases as mr, formatInlineOpenMeldCliCommands as ms, buildOpenClawSpaceSessionKey as mt, readOpenMeldToolsMaintenancePolicy as n, resolveViewProfileKey as na, resolveEvidenceSyncHealth as ni, unbindProject as nn, resolveOpenMeldProfileOrNull as no, normalizeDispatchPostMessageAction as nr, assertAdditionalHumanProfileCreationEnabled as ns, mapAgentReplyReadinessToLegacyAutoReply as nt, assessServerRequiredVersion as o, writeDaemonServiceContract as oa, createLocalAdapterContainer as oi, withAgentActivityLocalStateLock as on, getSelectedOpenMeldProfileId as oo, buildLocalServiceDiagnosticsPayload as or, buildCommandAuthenticationPromptMessage as os, resolveReplyReadinessGuidanceSummaryCopy as ot, readPendingOpenMeldToolsUpdateAttempt as p, resolveDaemonServiceAlignmentDecision as pa, resolveInstalledGrokBuildLaunchCandidates as pi, resolveAgentProfilePrimaryAgentControllerReport as pn, resolveAlignedDaemonActiveBundleEntryPath as po, applyIntervalJitterMs as pr, resolveAuthenticationReasonFromState as ps, prepareProviderRuntime as pt, buildDaemonServiceDependencyNextStep as q, MAX_RECONNECT_DELAY_MS as qa, readDaemonRuntimeContractRepairReport as qi, resolveLocalRegistryAgentIdFromAgentControllerRef as qn, writeVersionState as qo, listAgentControllerPermissionModeOptions as qr, listProjectBindings as qt, resolveOpenMeldToolsMaintenanceProjection as r, getProfileDefaultView as ra, resolveNativeAgentControllerPermissionModeForController as ri, canonicalizeLocalProjectPath as rn, alignSelectedOpenMeldProfileStorage as ro, createPendingAgentInteractionRegistry as rr, readDaemonCatalogSyncSignal as rs, REPLY_READINESS_COPY as rt, describeServerRequiredVersionUnavailableReason as s, buildDaemonSystemServiceCommandSpec as sa, createLocalAdapterEntries as si, NO_LOCAL_AGENTS_NEED_OPENMELD_SERVICE_REASON as sn, setSelectedOpenMeldProfileId as so, createLocalExecutionSlots as sr, buildHumanAuthenticationCard as ss, resolveOpenClawDiagnosticsGuidance as st, createOpenMeldToolsUpdateCoordinator as t, resolveRuntimeContext as ta, resolveAgentProfileEditCapabilities as ti, setDefaultProjectConnection as tn, requireOpenMeldProfile as to, buildDispatchReplyContextSummary as tr, updateOpenMeldProfile as ts, formatReplyReadinessSummary as tt, assessCliUpdate as u, resolveDaemonBundleIdFromEntryPath as ua, resolveInstalledOpenCodeLaunchCandidates as ui, emitReconcileCompletedEvidence as un, cleanupInactiveDaemonServiceBundles as uo, MAX_HEARTBEAT_INTERVAL_MS as ur, resolveAuthenticationGuidance as us, resolveGatewayChainRepairGuidance as ut, runDaemonServiceLifecycle as v, DAEMON_SERVICE_REPAIR_ANOMALIES as va, verifyCodexAppServerThread as vi, listAgentTargetStates as vn, readLatestDaemonLifecycleOriginEvent as vo, resolveDispatchContinuityObservation as vr, formatOpenMeldCliTextBlock as vs, writeDaemonRouteCatalogCache as vt, resolveSystemServiceStartupWaitMs as w, resolveDaemonDeviceId as wa, materializeCliLaunchCommand as wi, resolveAgentTargetState as wn, LocalDaemonControlPlaneClientError as wo, buildTaskResultEnvelope as wr, compareAgentControllerRefsForDisplay as ws, syncDaemonRouteCatalogState as wt, uninstallDaemonServiceUpdateWorker as x, classifyDaemonServiceWakeability as xa, createUnsupportedProviderUsageLimits as xi, reconcileNewRunnableBuiltinAgentRegistrations as xn, runDaemonServiceManagerAction as xo, resolveLatestScopedConversationExecutionState as xr, resolveSetupFollowUpCliEntryCommand as xs, createRouteCatalogFromMutableState as xt, ensureDaemonServiceMaintenanceInstalled as y, DAEMON_SERVICE_WAKEABILITY_ADVISORY_ANOMALIES as ya, resolveInstalledClaudeCodeLaunchCandidates as yi, manageAgentRegistrationInstallation as yn, readRecentDaemonLifecycleEvents as yo, resolveCompatibleAgentContextMatch as yr, formatProfileAwareOpenMeldCliCommand as ys, resolveLocalServiceDemand as yt, buildDaemonServiceUpdateRequiredNextStep as z, CONTROLLED_SHUTDOWN_RESULT_ACK_TIMEOUT_MS as za, resolveDaemonServiceManagerForRuntimeState as zi, sortAgentRegistrations as zn, readDaemonServiceContract as zo, buildInformationProtectionPromptPlan as zr, setCustomProfileWorkspace as zt };
41225
+ export { formatDeviceReplyReadinessLabel as $, RUNTIME_STATE_PERSIST_MIN_INTERVAL_MS as $a, getSetupFlowCopy as $i, resolveRouteRegistrationReconcileDecision as $n, createOpenMeldHumanProfile as $o, resolveAgentControllerPermissionModeForController as $r, resolveProjectBindingForPath as $t, resolveDaemonStatusSnapshot as A, normalizeNonNegativeInteger as Aa, readCurrentDaemonOwnerSnapshot as Ai, resolveSkillsAgentRegistry as An, readRecentDaemonLifecycleEvents as Ao, seedLegacyAgentContext as Ar, createModelCatalogReadSession as At, formatDaemonServiceRefreshReliabilityMessage as B, CONTROLLED_SHUTDOWN_SOCKET_CLOSE_TIMEOUT_MS as Ba, waitForDaemonSystemServiceToStop as Bi, repairBuiltinControllerInstall as Bn, hasIndependentMaintenanceRegistration as Bo, buildWorkingLanguagePromptPlan as Br, setOpenMeldManagedProfileWorkspace as Bt, isSystemServiceStartupTimeoutError as C, ensureDaemonRuntimePaths as Ca, buildCliLaunchInvocation as Ci, removeAgentCustomTarget as Cn, completePendingDaemonServiceUpdate as Co, buildRuntimeWorkspaceFingerprint as Cr, formatProfileAwareOpenMeldCliCommand as Cs, summarizeSkippedDaemonProfiles as Ct, captureDaemonServiceEvidence as D, dirnamePath as Da, buildDaemonOwnerSnapshotFromObservedState as Di, updateAgentRegistrations as Dn, formatDaemonLifecycleOriginSummary as Do, loadLedgerState as Dr, compareAgentControllerRefsForDisplay as Ds, resolveLocalController as Dt, startDaemonSystemServiceWithAutoRepair as E, asRecord as Ea, inspectDaemonServiceInventory as Ei, updateAgentCustomTarget as En, emitDaemonLifecycleEvent as Eo, commitResolvedAgentContext as Er, resolveUserFacingCliEntryCommand as Es, readLocalEnabledControllers as Et, buildDaemonServiceRefreshNextStep as F, warnDaemonEvent as Fa, getEffectiveDaemonRuntimeStatus as Fi, notifyDaemonRouteCatalogChanged as Fn, downloadCliBinaryUpdateArtifact as Fo, buildAgentContextLookupKey as Fr, readProfileWorkspaceConfig as Ft, buildDaemonServiceDependencyDetails as G, DEFAULT_RECONNECT_DELAY_MS as Ga, toStartBackgroundHelperExecutionCompatibility as Gi, isNpmGlobalCommandPath as Gn, buildNextVersionState as Go, getAgentControllerPermissionModeFieldLabel as Gr, bindProject as Gt, resolveDaemonServiceFreshnessWarning as H, DAEMON_STREAM_CONNECT_TIMEOUT_MS as Ha, listDaemonOwnedProcesses as Hi, resolveBuiltinAgentControllerDefinition as Hn, isDaemonServiceContractIdentityReusable as Ho, createAgentExecutionStatusDisplayRows as Hr, describeProfileWorkspacePathValidationFailure as Ht, buildDaemonServiceRefreshPromptMessage as I, CATALOG_SYNC_RETRY_INTERVAL_MS as Ia, readCurrentDaemonRuntimeContext as Ii, normalizeAgentId as In, resolveCliBinaryUpdatePlan as Io, DEFAULT_TASK_LIFECYCLE_HEARTBEAT_INTERVAL_MS as Ir, readProfileWorkspaceConfigForAccount as It, buildDaemonServiceDependencySummary as J, PROVIDER_CONVERSATION_PROOF_SYNC_INTERVAL_MS as Ja, DaemonServiceRunError as Ji, normalizeDispatchThreadAction as Jn, fetchLatestCliBinaryRelease as Jo, parseAgentControllerRef as Jr, listProjectConnectionsWithStatus as Jt, buildDaemonServiceDependencyMeaning as K, HEARTBEAT_RESPONSE_TIMEOUT_MS as Ka, ensureDaemonRuntimeContractState as Ki, isPnpmGlobalCommandPath as Kn, compareSemver as Ko, isAgentExecutionReadyOrConnecting as Kr, isProjectBound as Kt, buildDaemonServiceRepairGuidance as L, CATALOG_SYNC_SIGNAL_POLL_INTERVAL_MS as La, readCurrentObservedDaemonRuntimeStatus as Li, normalizeAgentIds as Ln, verifyCliBinaryCodeSignature as Lo, areAgentControllerInterfaceAccountsSame as Lr, resolveConfiguredProfileWorkspacePath as Lt, resolveDaemonStatusAuthenticationAttention as M, normalizeText$11 as Ma, resolveStoppedContractWriteBlockedReason as Mi, resolveRegistryOriginLaunchCommand as Mn, runDaemonServiceManagerAction as Mo, upsertConversationExecutionState as Mr, resolveProfileWorkspaceRuntime as Mt, resolveServiceReadiness as N, nowIsoString as Na, summarizeDaemonOwnerSnapshot as Ni, resolveRegistryRuntimeAdapterCapabilitySnapshot as Nn, runWithDaemonLifecycleCommandJournal as No, withLedgerStateTransaction as Nr, ensureOpenMeldManagedProfileWorkspace as Nt, captureDaemonServiceEvidenceBestEffort as O, emitRunLine as Oa, formatDaemonOwnerSummaryLabel as Oi, canManageRegistryAgentSkillTargets as On, readLatestDaemonLifecycleConnectionStateEvent as Oo, removeConversationExecutionState as Or, resolveBuiltinAgentControllerBrand as Os, resolveLocalRuntimeControllerSupport as Ot, resolveServiceReadinessFromServiceStatus as P, toErrorMessage$23 as Pa, clearDaemonRuntimeStateIfDefinitelyStopped as Pi, resolveRegistryRuntimeAdapterContractByAgentControllerRef as Pn, collectLocalOperationFailure as Po, buildAuthenticatedControlPlaneResponse as Pr, normalizeCustomProfileWorkspacePath as Pt, formatAgentReplyReadinessLabel as Q, RUNTIME_AGENT_CONTROLLER_REPORT_SYNC_RETRY_INTERVAL_MS as Qa, buildOnboardingPlan as Qi, isDaemonReconcileInProgressError as Qn, createOpenMeldAgentProfile as Qo, renderWorkingLanguagePrompt as Qr, removeProjectConnection as Qt, buildDaemonServiceStatusReadOnlyDetail as R, CONTROLLED_SHUTDOWN_REQUEST_TIMEOUT_MS as Ra, resolveDaemonRuntimeState as Ri, parseAgentEnabledOption as Rn, package_default as Ro, buildAgentControllerRef as Rr, resolveConfiguredProfileWorkspacePathForAccount as Rt, isDaemonInventoryRunningAndStartReady as S, buildLedgerPaths as Sa, resolveDispatchSpaceActionMcpServer as Si, reconcileNewRunnableBuiltinAgentsForSetup as Sn, resolveDaemonBundleEntryPathFromState as So, runRuntimeTask as Sr, formatOpenMeldCliTextBlock as Ss, loadDaemonRouteCatalog as St, waitForSystemServiceStartup as T, resolvePreferredDaemonDeviceId as Ta, createProviderOriginalError as Ti, setAgentRegistrationEnabled as Tn, readPendingDaemonServiceUpdate as To, appendLedgerHistoryEntry as Tr, resolveSetupFollowUpCliEntryCommand as Ts, buildRuntimeRouteTargets as Tt, clearDaemonStartFailureState as U, DAEMON_STREAM_KEEPALIVE_INTERVAL_MS as Ua, assertDaemonMaintenanceInstallationOwnership as Ui, isBunGlobalCommandPath as Un, readDaemonServiceContract as Uo, createAuthorityOpenMeldServiceRuntimeId as Ur, ProjectBindingOperationError as Ut, formatDaemonServiceUpdateRequiredMessage as V, DAEMON_RUNTIME_CONTRACT_EPOCH as Va, cleanupLegacySharedDaemonServiceState as Vi, EMPTY_AGENT_CONTROLLER_INTERFACE_CAPABILITIES as Vn, clearDaemonServiceContract as Vo, createAgentControllerInterfaceDisplayRows as Vr, validateCustomProfileWorkspacePath as Vt, writeDaemonStartFailureState as W, DAEMON_STREAM_KEEPALIVE_PONG_TIMEOUT_MS as Wa, resolveDaemonRuntimeContractCompatibility as Wi, isHomebrewCommandPath as Wn, upsertDaemonServiceContract as Wo, getAgentControllerPermissionModeDisplayMetadata as Wr, ProjectBindingStoreUpdateRequiredError as Wt, resolveDaemonServiceDependencyDiagnostics as X, REGISTER_RESPONSE_TIMEOUT_MS as Xa, PREPARE_SESSION_RECONNECT_GRACE_MS as Xi, SPACE_ACTION_CONTEXT_GUIDANCE_LINES as Xn, readVersionState as Xo, projectPeopleComputersToLegacyLocalRuntimes as Xr, removeAgentActivityBindingsWhileDeliveryLocked as Xt, buildDaemonServiceDependencyTitle as Y, PROVIDER_CONVERSATION_PROOF_SYNC_RETRY_INTERVAL_MS as Ya, resolveCurrentDaemonExpectedVersion as Yi, syncRuntimeEventToInflightTaskControlRegistry as Yn, fetchLatestPackageInfo as Yo, peopleComputerContainsDevice as Yr, migrateProjectBindingStore as Yt, resolveCurrentReplyReadinessSnapshot as Z, RUNTIME_AGENT_CONTROLLER_REPORT_SYNC_INTERVAL_MS as Za, buildDaemonRouteObservationPresentation as Zi, SPACE_ACTION_TARGET_GUIDANCE_LINES as Zn, writeVersionState as Zo, renderInformationProtectionPrompt as Zr, removeMissingProjectConnections as Zt, DaemonServiceLifecycleDrainTimeoutError as _, DAEMON_SERVICE_FULL_ALIGNMENT_ANOMALIES as _a, forkCodexAppServerThread as _i, listAgentRegistrations as _n, OPENMELD_VERSION as _o, resolveDispatchQueueLogMeta as _r, resolveAuthenticationReasonFromState as _s, readDaemonRouteCatalogCache as _t, resolveServiceUpdateUrgency as a, resolveCurrentOpenMeldAccountContext as aa, resolveCatalogSyncSkippedProfilesLogState as ai, withAgentActivityDeliveryLock as an, clearSelectedOpenMeldProfileId as ao, createLocalTaskInterruptSender as ar, updateOpenMeldProfile as as, resolveReplyReadinessAvailabilityReasonCopy as at, prepareDaemonServiceUpdateWorkerCarrier as b, classifyDaemonServiceRunStartability as ba, createUnavailableProviderUsageLimits as bi, readAgentRuntimeConfigHealth as bn, readDaemonActiveBundleState as bo, resolveCompatibleConversationExecutionState as br, formatOpenMeldCliCommands as bs, createMutableRouteCatalogState as bt, buildLocalAgentCatalogFromReadiness as c, ensureDaemonSystemServiceCommandFiles as ca, parseOpenCodeGoUsageResponse as ci, syncDeviceRuntimeStateProjection as cn, resolveOpenMeldEnvironmentTarget as co, createInflightTaskControlRegistry as cr, buildAgentAuthenticationGuide as cs, classifyGatewayChainFailure as ct, isCliUpdateCheckApplicable as d, isOpenMeldManagedBinaryPath as da, GrokBuildAcpTransportError as di, emitReconcileStartedEvidence as dn, requestLocalAgentActivitySync as do, MIN_HEARTBEAT_INTERVAL_MS as dr, buildHumanAuthenticationCard as ds, resolveGatewayChainRetryGuidance as dt, parseCliViewMode as ea, resolveAgentExecutionStatus as ei, runIfAgentActivityBindingGenerationIsCurrent as en, isSelectedOpenMeldProfileRequiredError as eo, createSerialAgentInteractionCallback as er, deleteOpenMeldProfile as es, formatHumanReplyReadinessReason as et, readLastOpenMeldToolsUpdateAttempt as f, buildDaemonServiceTargetSpec as fa, probeGrokBuildAcpInterface as fi, createPrimaryBindingReadSession as fn, requestLocalDaemonShutdown as fo, applyAcceptedLeases as fr, createAuthenticationError as fs, resolveOpenClawLocalDiagnosticsValue as ft, scheduleDaemonServiceUpdate as g, DAEMON_SERVICE_AUTO_HEAL_ANOMALIES as ga, resolveInstalledCodexLaunchCandidates as gi, listAgentCustomTargets as gn, readManagedCliInstallation as go, resolveCatalogSyncIntervalMs as gr, resolveAuthenticationGuidanceFromMessage as gs, slugifyOpenClawNamePart as gt, runPendingDaemonServiceUpdate as h, resolveVersionChangeDirection as ha, resolveCodexTimeoutMs as hi, createRegistrationFromCatalogTarget as hn, performManagedInstall as ho, resolveAdaptiveHeartbeatIntervalMs as hr, resolveAuthenticationGuidanceFromError as hs, normalizeOpenClawSpaceIdPrefix as ht, writeOpenMeldToolsMaintenancePolicy as i, setProfileDefaultView as ia, resolveSelectableCandidates as ii, resolveLocalProjectConnectionForPath as in, clearAllSelectedOpenMeldProfileIds as io, mergeOpenClawGatewayVisibility as ir, resolveOpenMeldProfile as is, formatSpaceMemberCommandRecoveryCopy as it, resolveDaemonStatusAttention as j, normalizeOptionalText$52 as ja, resolveDaemonStopStrategy as ji, listBuiltinAgentsRegistryEntries as jn, resolveRecentDaemonSignalStopCause as jo, settleInflightTask as jr, resolveCurrentEffectiveProfileWorkingFolderRuntime as jt, formatDaemonFailureContextText as k, normalizeHeartbeatIntervalMs as ka, hasActiveDaemonOwners as ki, detectInstalledSkillsAgents as kn, readLatestDaemonLifecycleOriginEvent as ko, resolveConversationExecutionStateByLookupKey as kr, syncProfileWorkspaceState as kt, readCurrentLocalDeviceId as l, extractDaemonCommandEntryPath as la, forkOpenCodeServerSession as li, emitDriftDetectedEvidence as ln, resolveAuthBaseUrl as lo, ADAPTIVE_HEARTBEAT_JITTER_RATIO as lr, buildAuthenticationStatusLabel as ls, resolveGatewayChainReadiness as lt, readOpenMeldToolsUpdateContextFromEnv as m, isVersionDowngrade as ma, projectCodexUsageLimits as mi, addAgentCustomTarget as mn, buildInstallSelfJsonPayload as mo, pruneStaleLeases as mr, resolveAuthenticationGuidance as ms, buildOpenClawSpaceSessionKey as mt, readOpenMeldToolsMaintenancePolicy as n, resolveViewProfileKey as na, resolveEvidenceSyncHealth as ni, unbindProject as nn, resolveOpenMeldProfileOrNull as no, normalizeDispatchPostMessageAction as nr, listOpenMeldProfiles as ns, mapAgentReplyReadinessToLegacyAutoReply as nt, assessServerRequiredVersion as o, writeDaemonServiceContract as oa, createLocalAdapterContainer as oi, withAgentActivityLocalStateLock as on, getSelectedOpenMeldProfileId as oo, buildLocalServiceDiagnosticsPayload as or, assertAdditionalHumanProfileCreationEnabled as os, resolveReplyReadinessGuidanceSummaryCopy as ot, readPendingOpenMeldToolsUpdateAttempt as p, resolveDaemonServiceAlignmentDecision as pa, resolveInstalledGrokBuildLaunchCandidates as pi, resolveAgentProfilePrimaryAgentControllerReport as pn, sendLocalDaemonControlPlaneRequest as po, applyIntervalJitterMs as pr, extractAuthenticationPromptAction as ps, prepareProviderRuntime as pt, buildDaemonServiceDependencyNextStep as q, MAX_RECONNECT_DELAY_MS as qa, readDaemonRuntimeContractRepairReport as qi, resolveLocalRegistryAgentIdFromAgentControllerRef as qn, ensureVersionStateReady as qo, listAgentControllerPermissionModeOptions as qr, listProjectBindings as qt, resolveOpenMeldToolsMaintenanceProjection as r, getProfileDefaultView as ra, resolveNativeAgentControllerPermissionModeForController as ri, canonicalizeLocalProjectPath as rn, alignSelectedOpenMeldProfileStorage as ro, createPendingAgentInteractionRegistry as rr, primeOpenMeldProfilesSessionCache as rs, REPLY_READINESS_COPY as rt, describeServerRequiredVersionUnavailableReason as s, buildDaemonSystemServiceCommandSpec as sa, createLocalAdapterEntries as si, NO_LOCAL_AGENTS_NEED_OPENMELD_SERVICE_REASON as sn, setSelectedOpenMeldProfileId as so, createLocalExecutionSlots as sr, readDaemonCatalogSyncSignal as ss, resolveOpenClawDiagnosticsGuidance as st, createOpenMeldToolsUpdateCoordinator as t, resolveRuntimeContext as ta, resolveAgentProfileEditCapabilities as ti, setDefaultProjectConnection as tn, requireOpenMeldProfile as to, buildDispatchReplyContextSummary as tr, getOpenMeldProfileCapabilities as ts, formatReplyReadinessSummary as tt, assessCliUpdate as u, resolveDaemonBundleIdFromEntryPath as ua, resolveInstalledOpenCodeLaunchCandidates as ui, emitReconcileCompletedEvidence as un, LocalDaemonControlPlaneClientError as uo, MAX_HEARTBEAT_INTERVAL_MS as ur, buildCommandAuthenticationPromptMessage as us, resolveGatewayChainRepairGuidance as ut, runDaemonServiceLifecycle as v, DAEMON_SERVICE_REPAIR_ANOMALIES as va, verifyCodexAppServerThread as vi, listAgentTargetStates as vn, cleanupInactiveDaemonServiceBundles as vo, resolveDispatchContinuityObservation as vr, formatInlineOpenMeldCliCommands as vs, writeDaemonRouteCatalogCache as vt, resolveSystemServiceStartupWaitMs as w, resolveDaemonDeviceId as wa, materializeCliLaunchCommand as wi, resolveAgentTargetState as wn, readLastDaemonServiceUpdate as wo, buildTaskResultEnvelope as wr, formatProfileAwareOpenMeldCliCommands as ws, syncDaemonRouteCatalogState as wt, uninstallDaemonServiceUpdateWorker as x, classifyDaemonServiceWakeability as xa, createUnsupportedProviderUsageLimits as xi, reconcileNewRunnableBuiltinAgentRegistrations as xn, resolveAlignedDaemonActiveBundleEntryPath as xo, resolveLatestScopedConversationExecutionState as xr, formatOpenMeldCliLine as xs, createRouteCatalogFromMutableState as xt, ensureDaemonServiceMaintenanceInstalled as y, DAEMON_SERVICE_WAKEABILITY_ADVISORY_ANOMALIES as ya, resolveInstalledClaudeCodeLaunchCandidates as yi, manageAgentRegistrationInstallation as yn, prepareDaemonServiceBundle as yo, resolveCompatibleAgentContextMatch as yr, formatOpenMeldCliCommand as ys, resolveLocalServiceDemand as yt, buildDaemonServiceUpdateRequiredNextStep as z, CONTROLLED_SHUTDOWN_RESULT_ACK_TIMEOUT_MS as za, resolveDaemonServiceManagerForRuntimeState as zi, sortAgentRegistrations as zn, configureDaemonMaintenanceEnvironment as zo, buildInformationProtectionPromptPlan as zr, setCustomProfileWorkspace as zt };
40846
41226
 
40847
- //# sourceMappingURL=openmeld-tools-update-coordinator-Bf8KyI6N.js.map
41227
+ //# sourceMappingURL=openmeld-tools-update-coordinator-DNMcMykJ.js.map