@adea-ai/app-framework 0.37.0 → 0.37.1

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 (161) hide show
  1. package/dist/appearance/appearance-host.js +2 -1
  2. package/dist/appearance/custom-theme-import.js +3 -1
  3. package/dist/appearance/custom-theme-library.d.ts +6 -185
  4. package/dist/appearance/custom-theme-library.js +3 -621
  5. package/dist/appearance/theme-library-mutation.d.ts +42 -0
  6. package/dist/appearance/theme-library-mutation.js +172 -0
  7. package/dist/appearance/theme-library-schema.d.ts +108 -0
  8. package/dist/appearance/theme-library-schema.js +189 -0
  9. package/dist/appearance/theme-library-store.d.ts +61 -0
  10. package/dist/appearance/theme-library-store.js +268 -0
  11. package/dist/appearance/theme-record-adapter.js +3 -1
  12. package/dist/appearance/theme-registry.js +2 -1
  13. package/dist/cli/update-helper-cli.js +1 -1
  14. package/dist/desktop/desktop-client.d.ts +1 -1
  15. package/dist/framework-source.json +1 -1
  16. package/dist/installer/installed-payload.js +2 -2
  17. package/dist/installer/{installer-archive.js → installer-archive-members.js} +2 -2
  18. package/dist/installer/installer-extraction.js +2 -2
  19. package/dist/installer/installer-fetch-guard.d.ts +1 -1
  20. package/dist/installer/installer-identity.js +2 -2
  21. package/dist/installer/installer-observation.d.ts +1 -1
  22. package/dist/installer/installer-observation.js +2 -2
  23. package/dist/installer/installer-upgrade-command.d.ts +2 -2
  24. package/dist/installer/installer-upgrade-command.js +5 -5
  25. package/dist/installer/linux-process-group.js +1 -1
  26. package/dist/installer/upgrade-asset-download.d.ts +1 -1
  27. package/dist/installer/upgrade-asset-download.js +2 -2
  28. package/dist/native/posix-tree-removal.d.ts +1 -1
  29. package/dist/release/feed-release-cut.d.ts +1 -1
  30. package/dist/release/feed-state.d.ts +2 -2
  31. package/dist/release/feed-state.js +3 -3
  32. package/dist/release/github-release-cut.js +1 -1
  33. package/dist/release/github-release-promotion.js +1 -1
  34. package/dist/release/github-release-publisher.js +1 -1
  35. package/dist/release/github-release-qualification.js +1 -1
  36. package/dist/release/local-release.d.ts +2 -2
  37. package/dist/release/local-release.js +3 -3
  38. package/dist/release/release-artifact.d.ts +1 -1
  39. package/dist/release/release-artifact.js +2 -2
  40. package/dist/release/release-assets-plan.js +1 -1
  41. package/dist/release/release-config.d.ts +1 -1
  42. package/dist/release/release-config.js +1 -1
  43. package/dist/release/release-descriptor-staging.js +3 -3
  44. package/dist/release/release-finalize.js +1 -1
  45. package/dist/release/release-promotion.js +1 -1
  46. package/dist/release/release-publication.d.ts +1 -1
  47. package/dist/release/release-publication.js +2 -2
  48. package/dist/release/release-publish-command.js +2 -2
  49. package/dist/update-helper.bundle.js +18 -18
  50. package/dist/updates/channel-update-manager.d.ts +3 -3
  51. package/dist/updates/channel-update-manager.js +2 -2
  52. package/dist/updates/desktop-updater.d.ts +10 -83
  53. package/dist/updates/desktop-updater.js +14 -217
  54. package/dist/updates/{packaged-release-config.js → feed/packaged-release-config.js} +5 -5
  55. package/dist/updates/{release-feed.js → feed/release-feed.js} +2 -2
  56. package/dist/updates/{release-location.js → feed/release-location.js} +2 -2
  57. package/dist/updates/{release-version.js → feed/release-version.js} +1 -1
  58. package/dist/updates/{signed-release.js → feed/signed-release.js} +2 -2
  59. package/dist/updates/{update-discovery.js → feed/update-discovery.js} +1 -1
  60. package/dist/updates/helper/launch-gate-recovery.d.ts +8 -0
  61. package/dist/updates/{update-resume.js → helper/launch-gate-recovery.js} +13 -423
  62. package/dist/updates/helper/resume-staging.d.ts +22 -0
  63. package/dist/updates/helper/resume-staging.js +180 -0
  64. package/dist/updates/{update-helper.d.ts → helper/update-helper.d.ts} +1 -1
  65. package/dist/updates/{update-helper.js → helper/update-helper.js} +9 -9
  66. package/dist/updates/{update-resume.d.ts → helper/update-resume.d.ts} +4 -10
  67. package/dist/updates/helper/update-resume.js +252 -0
  68. package/dist/updates/{update-shutdown.js → helper/update-shutdown.js} +2 -2
  69. package/dist/updates/{update-arm.d.ts → install/update-arm.d.ts} +2 -2
  70. package/dist/updates/{update-arm.js → install/update-arm.js} +9 -9
  71. package/dist/updates/{update-download-cleanup.d.ts → install/update-download-cleanup.d.ts} +1 -1
  72. package/dist/updates/{update-download-cleanup.js → install/update-download-cleanup.js} +3 -3
  73. package/dist/updates/{update-download.d.ts → install/update-download.d.ts} +2 -2
  74. package/dist/updates/{update-download.js → install/update-download.js} +3 -3
  75. package/dist/updates/{update-extraction.d.ts → install/update-extraction.d.ts} +2 -2
  76. package/dist/updates/{update-extraction.js → install/update-extraction.js} +6 -6
  77. package/dist/updates/{update-handoff-plan.d.ts → install/update-handoff-plan.d.ts} +2 -2
  78. package/dist/updates/{update-handoff-plan.js → install/update-handoff-plan.js} +5 -5
  79. package/dist/updates/{update-marker.js → install/update-marker.js} +2 -2
  80. package/dist/updates/{update-swap-stage.d.ts → install/update-swap-stage.d.ts} +2 -2
  81. package/dist/updates/{update-swap-stage.js → install/update-swap-stage.js} +7 -6
  82. package/dist/updates/{update-swap.d.ts → install/update-swap.d.ts} +1 -1
  83. package/dist/updates/{update-swap.js → install/update-swap.js} +5 -5
  84. package/dist/updates/install-target.d.ts +8 -0
  85. package/dist/updates/install-target.js +27 -0
  86. package/dist/updates/{launch-environment.js → launch/launch-environment.js} +1 -1
  87. package/dist/updates/{packaged-launch-admission.js → launch/packaged-launch-admission.js} +4 -4
  88. package/dist/updates/{packaged-update-startup.d.ts → launch/packaged-update-startup.d.ts} +3 -3
  89. package/dist/updates/{packaged-update-startup.js → launch/packaged-update-startup.js} +10 -7
  90. package/dist/updates/{update-launch-gate.d.ts → launch/update-launch-gate.d.ts} +1 -1
  91. package/dist/updates/{update-launch-gate.js → launch/update-launch-gate.js} +9 -9
  92. package/dist/updates/{update-launch.d.ts → launch/update-launch.d.ts} +1 -1
  93. package/dist/updates/{update-launch.js → launch/update-launch.js} +2 -2
  94. package/dist/updates/{linux-process-state.js → locks/linux-process-state.js} +1 -1
  95. package/dist/updates/{native-file-lock.js → locks/native-file-lock.js} +1 -1
  96. package/dist/updates/{stable-file.js → locks/stable-file.js} +2 -2
  97. package/dist/updates/{update-download-lock.js → locks/update-download-lock.js} +1 -1
  98. package/dist/updates/{update-generation-lease.js → locks/update-generation-lease.js} +3 -3
  99. package/dist/updates/{update-inherited-launch-lease.d.ts → locks/update-inherited-launch-lease.d.ts} +1 -1
  100. package/dist/updates/{update-inherited-launch-lease.js → locks/update-inherited-launch-lease.js} +2 -2
  101. package/dist/updates/{update-instance-lease.js → locks/update-instance-lease.js} +2 -2
  102. package/dist/updates/{update-lock.js → locks/update-lock.js} +2 -2
  103. package/dist/updates/{update-process-fence.js → locks/update-process-fence.js} +3 -3
  104. package/dist/updates/{update-process-liveness.js → locks/update-process-liveness.js} +2 -2
  105. package/dist/updates/retained-client-assets.d.ts +60 -0
  106. package/dist/updates/retained-client-assets.js +116 -0
  107. package/dist/updates/retention/retention-cleanup.d.ts +103 -0
  108. package/dist/updates/retention/retention-cleanup.js +439 -0
  109. package/dist/updates/retention/retention-prune-progress.d.ts +27 -0
  110. package/dist/updates/retention/retention-prune-progress.js +203 -0
  111. package/dist/updates/retention/retirement-inventory.d.ts +93 -0
  112. package/dist/updates/retention/retirement-inventory.js +373 -0
  113. package/dist/updates/retention/retirement-records.d.ts +75 -0
  114. package/dist/updates/retention/retirement-records.js +309 -0
  115. package/dist/updates/{update-retention-marker.d.ts → retention/update-retention-marker.d.ts} +1 -1
  116. package/dist/updates/{update-retention-marker.js → retention/update-retention-marker.js} +3 -3
  117. package/dist/updates/{update-retention-plan.d.ts → retention/update-retention-plan.d.ts} +1 -1
  118. package/dist/updates/{update-retention-plan.js → retention/update-retention-plan.js} +2 -2
  119. package/dist/updates/{update-retention-sync.d.ts → retention/update-retention-sync.d.ts} +1 -1
  120. package/dist/updates/{update-retention-sync.js → retention/update-retention-sync.js} +2 -2
  121. package/dist/updates/retention/update-retirement.d.ts +26 -0
  122. package/dist/updates/retention/update-retirement.js +205 -0
  123. package/dist/updates/update-adapter.js +1 -1
  124. package/dist/updates/update-channel-store.d.ts +1 -1
  125. package/dist/updates/update-channel-store.js +2 -2
  126. package/dist/updates/update-manager.d.ts +4 -4
  127. package/dist/updates/update-manager.js +5 -5
  128. package/dist/updates/update-services.d.ts +15 -0
  129. package/dist/updates/update-services.js +77 -0
  130. package/dist/updates/update-state-store.d.ts +2 -2
  131. package/dist/updates/update-state-store.js +2 -2
  132. package/dist/views/appearance-surface.js +3 -1
  133. package/package.json +29 -29
  134. package/src/appearance/custom-theme-library.ts +42 -956
  135. package/src/appearance/theme-library-mutation.ts +288 -0
  136. package/src/appearance/theme-library-schema.ts +347 -0
  137. package/src/appearance/theme-library-store.ts +379 -0
  138. package/src/updates/update-adapter.ts +1 -1
  139. package/dist/updates/update-retirement.d.ts +0 -205
  140. package/dist/updates/update-retirement.js +0 -1485
  141. /package/dist/installer/{installer-archive.d.ts → installer-archive-members.d.ts} +0 -0
  142. /package/dist/updates/{packaged-release-config.d.ts → feed/packaged-release-config.d.ts} +0 -0
  143. /package/dist/updates/{release-feed.d.ts → feed/release-feed.d.ts} +0 -0
  144. /package/dist/updates/{release-location.d.ts → feed/release-location.d.ts} +0 -0
  145. /package/dist/updates/{release-version.d.ts → feed/release-version.d.ts} +0 -0
  146. /package/dist/updates/{signed-release.d.ts → feed/signed-release.d.ts} +0 -0
  147. /package/dist/updates/{update-discovery.d.ts → feed/update-discovery.d.ts} +0 -0
  148. /package/dist/updates/{update-shutdown.d.ts → helper/update-shutdown.d.ts} +0 -0
  149. /package/dist/updates/{update-marker.d.ts → install/update-marker.d.ts} +0 -0
  150. /package/dist/updates/{launch-environment.d.ts → launch/launch-environment.d.ts} +0 -0
  151. /package/dist/updates/{packaged-launch-admission.d.ts → launch/packaged-launch-admission.d.ts} +0 -0
  152. /package/dist/updates/{linux-process-state.d.ts → locks/linux-process-state.d.ts} +0 -0
  153. /package/dist/updates/{native-file-lock.d.ts → locks/native-file-lock.d.ts} +0 -0
  154. /package/dist/updates/{stable-file.d.ts → locks/stable-file.d.ts} +0 -0
  155. /package/dist/updates/{update-download-lock.d.ts → locks/update-download-lock.d.ts} +0 -0
  156. /package/dist/updates/{update-generation-lease.d.ts → locks/update-generation-lease.d.ts} +0 -0
  157. /package/dist/updates/{update-instance-lease.d.ts → locks/update-instance-lease.d.ts} +0 -0
  158. /package/dist/updates/{update-lock.d.ts → locks/update-lock.d.ts} +0 -0
  159. /package/dist/updates/{update-process-fence.d.ts → locks/update-process-fence.d.ts} +0 -0
  160. /package/dist/updates/{update-process-liveness.d.ts → locks/update-process-liveness.d.ts} +0 -0
  161. /package/src/updates/{release-version.ts → feed/release-version.ts} +0 -0
@@ -1,7 +1,7 @@
1
1
  import { validateReleaseQualification } from "./release-qualification.js";
2
- import { verifyReleaseDescriptor } from "../updates/signed-release.js";
2
+ import { verifyReleaseDescriptor } from "../updates/feed/signed-release.js";
3
3
  import { releaseAssetNames } from "./release-config.js";
4
- import { hashUnchangedFile, openUnchangedFile } from "../updates/stable-file.js";
4
+ import { hashUnchangedFile, openUnchangedFile } from "../updates/locks/stable-file.js";
5
5
  import { lstat, mkdtemp, open, rm, writeFile } from "node:fs/promises";
6
6
  import { join, resolve } from "node:path";
7
7
  import { createHash } from "node:crypto";
@@ -1,7 +1,7 @@
1
1
  import { isGitSha, isRecord } from "../app/value-guards.js";
2
2
  import { githubCli, verifyWorkflowAttempt } from "./github-cli.js";
3
- import { assertRepositorySlug } from "../updates/signed-release.js";
4
- import { feedUrl } from "../updates/release-feed.js";
3
+ import { assertRepositorySlug } from "../updates/feed/signed-release.js";
4
+ import { feedUrl } from "../updates/feed/release-feed.js";
5
5
  import { discoveryPolicies, hostedReleaseWorkflows, parseReleaseConfig } from "./release-config.js";
6
6
  import { publishQualifiedRelease } from "./release-publication.js";
7
7
  import { commandReceiptName } from "../installer/command-qualification-command.js";
@@ -16,12 +16,12 @@ function errorCode(error) {
16
16
  return typeof code === "string" ? code : undefined;
17
17
  }
18
18
 
19
- // src/updates/update-helper.ts
19
+ // src/updates/helper/update-helper.ts
20
20
  import { constants as constants7 } from "fs";
21
21
  import { lstat as lstat3, open as open7, realpath as realpath2 } from "fs/promises";
22
22
  import { join as join9 } from "path";
23
23
 
24
- // src/updates/update-marker.ts
24
+ // src/updates/install/update-marker.ts
25
25
  import { randomUUID } from "crypto";
26
26
  import { closeSync, constants, linkSync, openSync, unlinkSync, writeFileSync } from "fs";
27
27
  import { link, open, unlink, writeFile } from "fs/promises";
@@ -82,11 +82,11 @@ async function readUpdateMarker(staging, name) {
82
82
  }
83
83
  }
84
84
 
85
- // src/updates/update-launch.ts
85
+ // src/updates/launch/update-launch.ts
86
86
  import { spawn } from "child_process";
87
87
  import { dirname, join as join2 } from "path";
88
88
 
89
- // src/updates/launch-environment.ts
89
+ // src/updates/launch/launch-environment.ts
90
90
  var INHERITED_LAUNCH_LEASE_ENV = "ADEA_INHERITED_LAUNCH_LEASE_FD";
91
91
 
92
92
  // src/native/canonical-path.ts
@@ -95,7 +95,7 @@ function isCanonicalPath(value) {
95
95
  return typeof value === "string" && isAbsolute(value) && resolve(value) === value && !value.includes("\x00");
96
96
  }
97
97
 
98
- // src/updates/update-launch.ts
98
+ // src/updates/launch/update-launch.ts
99
99
  function updateLauncherPath(platform, target) {
100
100
  if (!isCanonicalPath(target))
101
101
  throw new Error("Invalid update target");
@@ -123,7 +123,7 @@ async function launchInstalledApp(platform, target, env = process.env) {
123
123
  child.unref();
124
124
  }
125
125
 
126
- // src/updates/update-process-fence.ts
126
+ // src/updates/locks/update-process-fence.ts
127
127
  import { dlopen as dlopen2, FFIType as FFIType2, ptr as ptr2 } from "bun:ffi";
128
128
  import { readFile, realpath } from "fs/promises";
129
129
  import { isAbsolute as isAbsolute2 } from "path";
@@ -169,7 +169,7 @@ function windowsProcessImage(pid, options) {
169
169
  }
170
170
  }
171
171
 
172
- // src/updates/linux-process-state.ts
172
+ // src/updates/locks/linux-process-state.ts
173
173
  function linuxProcessIsExited(stat, pid) {
174
174
  const prefix = `${pid} (`;
175
175
  const end = stat.lastIndexOf(")");
@@ -184,7 +184,7 @@ function linuxProcessIsExited(stat, pid) {
184
184
  return fields[0] === "Z" && threads === 1;
185
185
  }
186
186
 
187
- // src/updates/update-process-fence.ts
187
+ // src/updates/locks/update-process-fence.ts
188
188
  class UpdateProcessFenceCancelledError extends Error {
189
189
  constructor() {
190
190
  super("Update helper cancellation was requested");
@@ -306,7 +306,7 @@ async function waitForUpdateProcesses(options) {
306
306
  }
307
307
  }
308
308
 
309
- // src/updates/update-swap.ts
309
+ // src/updates/install/update-swap.ts
310
310
  import { createHash } from "crypto";
311
311
  import { constants as constants5 } from "fs";
312
312
  import { lstat as lstat2, open as open5, readdir, readFile as readFile3, readlink } from "fs/promises";
@@ -409,10 +409,10 @@ import { constants as constants4 } from "fs";
409
409
  import { open as open4, rename, unlink as unlink2, writeFile as writeFile3 } from "fs/promises";
410
410
  import { join as join5 } from "path";
411
411
 
412
- // src/updates/update-lock.ts
412
+ // src/updates/locks/update-lock.ts
413
413
  import { basename, dirname as dirname2, join as join4 } from "path";
414
414
 
415
- // src/updates/native-file-lock.ts
415
+ // src/updates/locks/native-file-lock.ts
416
416
  import { constants as constants2 } from "fs";
417
417
  import { open as open2 } from "fs/promises";
418
418
  import { dlopen as dlopen4, FFIType as FFIType4, ptr as ptr4, read } from "bun:ffi";
@@ -574,7 +574,7 @@ async function tryAcquireWindows(path, mode) {
574
574
  };
575
575
  }
576
576
 
577
- // src/updates/update-lock.ts
577
+ // src/updates/locks/update-lock.ts
578
578
  function updateLockPath(target) {
579
579
  if (!isCanonicalPath(target))
580
580
  throw new Error("Invalid update lock target");
@@ -584,7 +584,7 @@ async function tryAcquireUpdateLock(target) {
584
584
  return tryAcquireNativeFileLock(updateLockPath(target), "exclusive");
585
585
  }
586
586
 
587
- // src/updates/stable-file.ts
587
+ // src/updates/locks/stable-file.ts
588
588
  import { constants as constants3 } from "fs";
589
589
  import { lstat, open as open3 } from "fs/promises";
590
590
  async function readSmallStateFile(path, maximum, message) {
@@ -718,7 +718,7 @@ async function replaceUpdateStageState(staging, state, durable) {
718
718
  }
719
719
  }
720
720
 
721
- // src/updates/update-swap.ts
721
+ // src/updates/install/update-swap.ts
722
722
  function updateStagingFor(target) {
723
723
  if (!isCanonicalPath(target))
724
724
  throw new Error("Invalid update target");
@@ -935,13 +935,13 @@ async function swapUpdateTreeWhileLocked(options, exchangeOperation = exchangeDi
935
935
  throw new Error("Atomic update exchange did not preserve both app trees");
936
936
  }
937
937
 
938
- // src/updates/update-launch-gate.ts
938
+ // src/updates/launch/update-launch-gate.ts
939
939
  import { randomUUID as randomUUID4 } from "crypto";
940
940
  import { constants as constants6 } from "fs";
941
941
  import { open as open6, rename as rename2, unlink as unlink3 } from "fs/promises";
942
942
  import { basename as basename4, dirname as dirname5, join as join8 } from "path";
943
943
 
944
- // src/updates/update-instance-lease.ts
944
+ // src/updates/locks/update-instance-lease.ts
945
945
  import { basename as basename3, dirname as dirname4, join as join7 } from "path";
946
946
  function updateInstanceLeasePath(target) {
947
947
  if (!isCanonicalPath(target))
@@ -957,7 +957,7 @@ async function tryAcquireUpdateInstanceLease(target, mode) {
957
957
  return { mode, release: lock.release };
958
958
  }
959
959
 
960
- // src/updates/update-launch-gate.ts
960
+ // src/updates/launch/update-launch-gate.ts
961
961
  var VERSION = /^\d+\.\d+\.\d+(?:-dev\.\d+)?$/;
962
962
  var MAX_GATE_BYTES = 1024;
963
963
  function validateTarget(target) {
@@ -1353,7 +1353,7 @@ async function waitForUpdateLaunchGateWriter(target, expected, options) {
1353
1353
  }
1354
1354
  }
1355
1355
 
1356
- // src/updates/update-helper.ts
1356
+ // src/updates/helper/update-helper.ts
1357
1357
  function parseUpdateHelperRequest(value) {
1358
1358
  const data = value;
1359
1359
  if (typeof value !== "object" || value === null || Array.isArray(value) || data.schema !== 1 && data.schema !== 2 && data.schema !== 3 || !isCanonicalPath(data.target) || !["macos-arm64", "windows-x64", "linux-x64", "linux-arm64"].includes(data.platform) || typeof data.version !== "string" || !/^\d+\.\d+\.\d+(?:-dev\.\d+)?$/.test(data.version) || !Array.isArray(data.processes) || data.schema === 2 && (typeof data.generation !== "string" || !/^[0-9a-f-]{36}$/i.test(data.generation) || data.helperOwner !== undefined && (typeof data.helperOwner !== "string" || !/^[0-9a-f-]{36}$/i.test(data.helperOwner))) || data.schema === 3 && (typeof data.generation !== "string" || !isUuid(data.generation) || typeof data.helperOwner !== "string" || !isUuid(data.helperOwner)) || !Number.isSafeInteger(data.processTimeoutMs) || data.processTimeoutMs < 1 || data.processTimeoutMs > 120000)
@@ -1,7 +1,7 @@
1
1
  import { createUpdateManager } from './update-manager';
2
- import { type UpdateChannel } from './release-version';
3
- import type { ReleaseTrust } from './signed-release';
4
- import type { FetchFunction } from './release-location';
2
+ import { type UpdateChannel } from './feed/release-version';
3
+ import type { ReleaseTrust } from './feed/signed-release';
4
+ import type { FetchFunction } from './feed/release-location';
5
5
  type ManagerOptions = Parameters<typeof createUpdateManager>[0];
6
6
  /** Re-read the persisted channel for every check and bind an approval to that choice. */
7
7
  export declare function createChannelUpdateManager(options: {
@@ -1,5 +1,5 @@
1
- import { isUpdateChannel } from "./release-version.js";
2
- import { selectUpdateDownloadDiscard } from "./update-download-cleanup.js";
1
+ import { isUpdateChannel } from "./feed/release-version.js";
2
+ import { selectUpdateDownloadDiscard } from "./install/update-download-cleanup.js";
3
3
  import { createUpdateManager } from "./update-manager.js";
4
4
  import { releaseChannelForUpdate } from "./update-channel-store.js";
5
5
  // src/updates/channel-update-manager.ts
@@ -1,12 +1,11 @@
1
- import { type createServiceRegistry } from '../app/service-registry';
2
1
  import type { InstallerPlatform, InstallerRenderer } from '../installer/installer-layout';
3
2
  import { createChannelUpdateManager } from './channel-update-manager';
4
- import { type UpdateChannel } from './release-version';
5
- import type { ReleaseTrust } from './signed-release';
3
+ import type { UpdateChannel } from './feed/release-version';
4
+ import type { ReleaseTrust } from './feed/signed-release';
6
5
  import type { UpdateState } from './update-adapter';
7
- import type { UpdateResumeResult } from './update-resume';
8
- import { type UpdateHealthAcknowledgement } from './update-retirement';
9
- import { type UpdateShutdownTiming } from './update-shutdown';
6
+ import type { UpdateResumeResult } from './helper/update-resume';
7
+ import type { UpdateHealthAcknowledgement } from './retention/retirement-records';
8
+ import { type UpdateShutdownTiming } from './helper/update-shutdown';
10
9
  import type { NativeUpdateState } from './update-state';
11
10
  export type DesktopUpdatePhase = UpdateState['phase'];
12
11
  /** The snapshot every update service returns. */
@@ -24,70 +23,6 @@ export type DesktopRelease = {
24
23
  }>;
25
24
  sidecars?: readonly string[];
26
25
  };
27
- /** The release platform this host runs on, or null where framework apps ship no build. */
28
- export declare function updatePlatform(platform?: string, arch?: string): InstallerPlatform | null;
29
- /**
30
- * The installed app tree the swap replaces: the `.app` bundle on macOS, the
31
- * app directory elsewhere. The host entry runs from `Resources/app/bun`.
32
- */
33
- export declare function installTarget(entryDirectory: string, platform: InstallerPlatform): string;
34
- /**
35
- * Acquire the updater's retained generations and map their packaged client
36
- * directories to manifests. The caller must already hold any required native
37
- * launch admission lease and must retain the returned generation leases until
38
- * the host and all response bodies are drained. This does not gate startup.
39
- * `loadManifest` receives a retained client root while its lease is held.
40
- */
41
- export declare function acquireRetainedDesktopClientAssets(options: {
42
- entryDirectory: string;
43
- currentVersion: string;
44
- loadManifest(root: string): Promise<ReadonlyMap<string, string>>;
45
- }): Promise<Readonly<{
46
- status: 'none' | 'busy';
47
- }> | {
48
- status: 'unsupported';
49
- retainedClientAssets?: undefined;
50
- release?: undefined;
51
- } | {
52
- status: 'acquired';
53
- retainedClientAssets: {
54
- root: string;
55
- immutableAssets: ReadonlyMap<string, string>;
56
- }[];
57
- release: () => Promise<void>;
58
- }>;
59
- /**
60
- * Trusted startup variant for callers that must preserve normal pending staged
61
- * updates while pinning retained generations. Resume and lease acquisition are
62
- * serialized under the install lock; callers keep the returned lease through
63
- * host shutdown and response draining.
64
- */
65
- export declare function resumeAndAcquireRetainedDesktopClientAssets(options: {
66
- entryDirectory: string;
67
- currentVersion: string;
68
- trust: ReleaseTrust;
69
- loadManifest(root: string): Promise<ReadonlyMap<string, string>>;
70
- }): Promise<Readonly<{
71
- status: 'busy' | 'in-progress' | 'recovery-required';
72
- }> | {
73
- retainedClientAssets?: undefined;
74
- release?: undefined;
75
- status: 'unsupported';
76
- resume?: undefined;
77
- } | {
78
- status: 'ready';
79
- resume: UpdateResumeResult;
80
- retainedClientAssets: readonly [];
81
- release: () => Promise<void>;
82
- } | {
83
- status: 'ready';
84
- resume: UpdateResumeResult;
85
- retainedClientAssets: {
86
- root: string;
87
- immutableAssets: ReadonlyMap<string, string>;
88
- }[];
89
- release: () => Promise<void>;
90
- }>;
91
26
  /** Each channel's signed descriptor for `platform`, as the release workflows publish them. */
92
27
  export declare function discoveryNames(platform: InstallerPlatform): Record<UpdateChannel, string>;
93
28
  /**
@@ -106,8 +41,8 @@ export type UpdateInstallRequest = {
106
41
  approved: boolean;
107
42
  restart?: boolean;
108
43
  };
109
- export type { UpdateHealthAcknowledgement } from './update-retirement';
110
- export type { UpdateShutdownTiming } from './update-shutdown';
44
+ export type { UpdateHealthAcknowledgement } from './retention/retirement-records';
45
+ export type { UpdateShutdownTiming } from './helper/update-shutdown';
111
46
  export type UpdaterOptions = {
112
47
  appName: string;
113
48
  repository: string;
@@ -169,14 +104,6 @@ export declare function createDesktopUpdater(options: {
169
104
  quit(timing?: UpdateShutdownTiming): void | Promise<void>;
170
105
  log(line: string): void;
171
106
  }): Promise<DesktopUpdater>;
172
- type Services<Principal> = ReturnType<typeof createServiceRegistry<Principal>>;
173
- /** The `desktop_update_channel_save` argument. */
174
- export declare function parseUpdateChannel(value: unknown): UpdateChannel;
175
- /** The `desktop_update_install` argument. */
176
- export declare function parseUpdateInstall(value: unknown): UpdateInstallRequest;
177
- /** Register the `desktop_update_*` services the web client's update adapter calls. */
178
- export declare function registerUpdateServices<Principal>(options: {
179
- services: Services<Principal>;
180
- updater: DesktopUpdater;
181
- authorize(principal: Principal): boolean;
182
- }): () => void;
107
+ export { updatePlatform, installTarget } from './install-target';
108
+ export { acquireRetainedDesktopClientAssets, resumeAndAcquireRetainedDesktopClientAssets, } from './retained-client-assets';
109
+ export { parseUpdateChannel, parseUpdateInstall, registerUpdateServices } from './update-services';
@@ -1,21 +1,22 @@
1
- import { isUpdateChannel } from "./release-version.js";
2
- import { errorCode } from "../app/value-guards.js";
3
- import { isCanonicalPath } from "../native/canonical-path.js";
4
1
  import { ServiceError } from "../app/service-registry.js";
5
- import { feedUrl, parseReleaseFeed } from "./release-feed.js";
6
- import { acknowledgeRetiredUpdateHealthy, acquireRetainedUpdateTrees, findPendingUpdateHealthAcknowledgement } from "./update-retirement.js";
7
- import { stageUpdateSwap } from "./update-swap-stage.js";
8
- import { downloadVerifiedRelease } from "./update-download.js";
9
- import { completeOwnedUpdateDownload, createOwnedUpdateDownload, initializeOwnedUpdateDownloadRoot } from "./update-download-cleanup.js";
2
+ import { feedUrl, parseReleaseFeed } from "./feed/release-feed.js";
3
+ import { findPendingUpdateHealthAcknowledgement } from "./retention/retirement-inventory.js";
4
+ import { acknowledgeRetiredUpdateHealthy } from "./retention/update-retirement.js";
5
+ import { stageUpdateSwap } from "./install/update-swap-stage.js";
6
+ import { downloadVerifiedRelease } from "./install/update-download.js";
7
+ import { completeOwnedUpdateDownload, createOwnedUpdateDownload, initializeOwnedUpdateDownloadRoot } from "./install/update-download-cleanup.js";
10
8
  import { UpdatePreflightError } from "./update-preflight-error.js";
11
9
  import { createUpdateChannelStore, releaseChannelForUpdate } from "./update-channel-store.js";
12
10
  import { createChannelUpdateManager } from "./channel-update-manager.js";
13
11
  import { UpdateCleanupPendingError, findUpdateCleanupTerminalError } from "./update-cleanup-error.js";
14
- import { armUpdateHelper } from "./update-arm.js";
15
- import { resumeUpdate, resumeUpdateWithRetainedTrees } from "./update-resume.js";
16
- import { scheduleUpdateShutdown } from "./update-shutdown.js";
17
- import { lstat, mkdir, readlink, realpath } from "node:fs/promises";
18
- import { basename, dirname, join, relative, resolve } from "node:path";
12
+ import { armUpdateHelper } from "./install/update-arm.js";
13
+ import { resumeUpdate } from "./helper/update-resume.js";
14
+ import { scheduleUpdateShutdown } from "./helper/update-shutdown.js";
15
+ import { installTarget, updatePlatform } from "./install-target.js";
16
+ import { acquireRetainedDesktopClientAssets, canonicalTargetForRecovery, resumeAndAcquireRetainedDesktopClientAssets } from "./retained-client-assets.js";
17
+ import { parseUpdateChannel, parseUpdateInstall, registerUpdateServices } from "./update-services.js";
18
+ import { mkdir, realpath } from "node:fs/promises";
19
+ import { join } from "node:path";
19
20
  // src/updates/desktop-updater.ts
20
21
  /**
21
22
  * The desktop host's signed updater, the same for every framework app: the
@@ -35,137 +36,6 @@ var MAX_EXPANDED_BYTES = 4294967296;
35
36
  var QUIT_DELAY_MS = 250;
36
37
  /** Allows a just-relaunched app to wait briefly for its detached updater helper to exit. */
37
38
  var HEALTH_ACK_HELPER_WAIT_MS = 5e3;
38
- /** The release platform this host runs on, or null where framework apps ship no build. */
39
- function updatePlatform(platform = process.platform, arch = process.arch) {
40
- if (platform === "darwin" && arch === "arm64") return "macos-arm64";
41
- if (platform === "win32" && arch === "x64") return "windows-x64";
42
- if (platform === "linux" && arch === "x64") return "linux-x64";
43
- if (platform === "linux" && arch === "arm64") return "linux-arm64";
44
- return null;
45
- }
46
- /**
47
- * The installed app tree the swap replaces: the `.app` bundle on macOS, the
48
- * app directory elsewhere. The host entry runs from `Resources/app/bun`.
49
- */
50
- function installTarget(entryDirectory, platform) {
51
- return resolve(entryDirectory, ...platform === "macos-arm64" ? [
52
- "..",
53
- "..",
54
- "..",
55
- ".."
56
- ] : [
57
- "..",
58
- "..",
59
- ".."
60
- ]);
61
- }
62
- /** Preserve interrupted-swap recovery when the installed target is temporarily absent. */
63
- async function canonicalTargetForRecovery(target, seen = /* @__PURE__ */ new Set()) {
64
- if (seen.has(target) || seen.size >= 16) throw new Error("Invalid install target symlink chain");
65
- seen.add(target);
66
- try {
67
- return await realpath(target);
68
- } catch (error) {
69
- if (errorCode(error) !== "ENOENT") throw error;
70
- const info = await lstat(target).then((value) => value, (statError) => {
71
- if (errorCode(statError) === "ENOENT") return void 0;
72
- throw statError;
73
- });
74
- if (info?.isSymbolicLink()) return canonicalTargetForRecovery(resolve(dirname(target), await readlink(target)), seen);
75
- if (info) throw error;
76
- return join(await realpath(dirname(target)), basename(target));
77
- }
78
- }
79
- /**
80
- * Validate a packaged entry directory and locate its install root plus the
81
- * client directory relative to it, which every retained generation shares.
82
- */
83
- async function packagedClientLayout(options, platform) {
84
- if (!isCanonicalPath(options.entryDirectory) || typeof options.loadManifest !== "function") throw new Error("Invalid packaged client asset lookup");
85
- const lexicalTarget = installTarget(options.entryDirectory, platform);
86
- const clientRelative = relative(lexicalTarget, resolve(options.entryDirectory, "..", "client"));
87
- if (clientRelative !== join(...platform === "macos-arm64" ? ["Contents"] : [], "Resources", "app", "client")) throw new Error("Invalid packaged client asset layout");
88
- return {
89
- target: await realpath(lexicalTarget),
90
- clientRelative
91
- };
92
- }
93
- /**
94
- * Load every retained generation's client manifest while its lease is held. The
95
- * loads run concurrently; all of them settle before a failure releases the
96
- * leases, so no load still reads a tree that may be pruned. A loader that
97
- * throws synchronously is treated as a rejected load.
98
- */
99
- async function loadRetainedClientAssets(trees, clientRelative, loadManifest, release) {
100
- const roots = trees.map(({ tree }) => join(tree, clientRelative));
101
- const loaded = await Promise.allSettled(roots.map((root) => Promise.resolve().then(() => loadManifest(root))));
102
- const failed = loaded.find((outcome) => outcome.status === "rejected");
103
- if (!failed) return roots.map((root, index) => ({
104
- root,
105
- immutableAssets: loaded[index].value
106
- }));
107
- try {
108
- await release();
109
- } catch (releaseError) {
110
- throw new AggregateError([failed.reason, releaseError], "Retained client asset preparation failed", { cause: releaseError });
111
- }
112
- throw failed.reason;
113
- }
114
- /**
115
- * Acquire the updater's retained generations and map their packaged client
116
- * directories to manifests. The caller must already hold any required native
117
- * launch admission lease and must retain the returned generation leases until
118
- * the host and all response bodies are drained. This does not gate startup.
119
- * `loadManifest` receives a retained client root while its lease is held.
120
- */
121
- async function acquireRetainedDesktopClientAssets(options) {
122
- const platform = updatePlatform();
123
- if (!platform) return { status: "unsupported" };
124
- const { target, clientRelative } = await packagedClientLayout(options, platform);
125
- const retained = await acquireRetainedUpdateTrees({
126
- target,
127
- currentVersion: options.currentVersion
128
- });
129
- if (retained.status !== "acquired") return retained;
130
- return {
131
- status: "acquired",
132
- retainedClientAssets: await loadRetainedClientAssets(retained.trees, clientRelative, options.loadManifest, retained.release),
133
- release: retained.release
134
- };
135
- }
136
- /**
137
- * Trusted startup variant for callers that must preserve normal pending staged
138
- * updates while pinning retained generations. Resume and lease acquisition are
139
- * serialized under the install lock; callers keep the returned lease through
140
- * host shutdown and response draining.
141
- */
142
- async function resumeAndAcquireRetainedDesktopClientAssets(options) {
143
- const platform = updatePlatform();
144
- if (!platform) return { status: "unsupported" };
145
- const { target, clientRelative } = await packagedClientLayout(options, platform);
146
- const result = await resumeUpdateWithRetainedTrees({
147
- target,
148
- trust: options.trust,
149
- currentVersion: options.currentVersion
150
- });
151
- if (result.status !== "ready") return result;
152
- if (result.retained.status !== "acquired") {
153
- if (result.retained.status === "busy") return { status: "busy" };
154
- return {
155
- status: "ready",
156
- resume: result.resume,
157
- retainedClientAssets: [],
158
- release: async () => {}
159
- };
160
- }
161
- const retainedClientAssets = await loadRetainedClientAssets(result.retained.trees, clientRelative, options.loadManifest, result.retained.release);
162
- return {
163
- status: "ready",
164
- resume: result.resume,
165
- retainedClientAssets,
166
- release: result.retained.release
167
- };
168
- }
169
39
  /** Each channel's signed descriptor for `platform`, as the release workflows publish them. */
170
40
  function discoveryNames(platform) {
171
41
  return {
@@ -579,77 +449,4 @@ async function createDesktopUpdater(options) {
579
449
  }
580
450
  });
581
451
  }
582
- function record(value, keys) {
583
- if (typeof value !== "object" || value === null || Array.isArray(value) || Object.keys(value).some((key) => !keys.includes(key))) throw new Error("Invalid input");
584
- return value;
585
- }
586
- function parseNone(value) {
587
- if (value !== void 0 && value !== null) record(value, []);
588
- return null;
589
- }
590
- /** The `desktop_update_channel_save` argument. */
591
- function parseUpdateChannel(value) {
592
- const { channel } = record(value, ["channel"]);
593
- if (!isUpdateChannel(channel)) throw new Error("Invalid input");
594
- return channel;
595
- }
596
- /** The `desktop_update_install` argument. */
597
- function parseUpdateInstall(value) {
598
- const { expectedVersion, approved, restart } = record(value, [
599
- "expectedVersion",
600
- "approved",
601
- "restart"
602
- ]);
603
- if (typeof expectedVersion !== "string" || expectedVersion.length > 64 || typeof approved !== "boolean" || restart !== void 0 && typeof restart !== "boolean") throw new Error("Invalid input");
604
- return {
605
- expectedVersion,
606
- approved,
607
- ...restart === void 0 ? {} : { restart }
608
- };
609
- }
610
- /** Pass a service error through; give any other failure the update error code. */
611
- function failure(error) {
612
- if (error instanceof ServiceError) throw error;
613
- throw new ServiceError("update_failed", error instanceof Error ? error.message : String(error));
614
- }
615
- /** Register the `desktop_update_*` services the web client's update adapter calls. */
616
- function registerUpdateServices(options) {
617
- const { services, updater } = options;
618
- const authorize = (principal) => options.authorize(principal);
619
- const unregister = [
620
- services.register("desktop_update_status", {
621
- parse: parseNone,
622
- authorize,
623
- run: () => updater.status().catch(failure)
624
- }),
625
- services.register("desktop_update_channel", {
626
- parse: parseNone,
627
- authorize,
628
- run: () => updater.channel().catch(failure)
629
- }),
630
- services.register("desktop_update_channel_save", {
631
- parse: parseUpdateChannel,
632
- authorize,
633
- run: (_principal, channel) => updater.saveChannel(channel).catch(failure)
634
- }),
635
- services.register("desktop_update_check", {
636
- parse: parseNone,
637
- authorize,
638
- run: () => updater.check().catch(failure)
639
- }),
640
- services.register("desktop_update_install", {
641
- parse: parseUpdateInstall,
642
- authorize,
643
- run: (_principal, request) => updater.install(request).catch(failure)
644
- }),
645
- services.register("desktop_update_cancel", {
646
- parse: parseNone,
647
- authorize,
648
- run: () => updater.cancel()
649
- })
650
- ];
651
- return () => {
652
- for (const remove of unregister) remove();
653
- };
654
- }
655
452
  export { acquireRetainedDesktopClientAssets, createDesktopUpdater, createUpdater, discoveryNames, installTarget, parseUpdateChannel, parseUpdateInstall, registerUpdateServices, resumeAndAcquireRetainedDesktopClientAssets, updatePlatform, updateTrust };
@@ -1,11 +1,11 @@
1
- import { isRecord } from "../app/value-guards.js";
2
- import { isCanonicalPath } from "../native/canonical-path.js";
1
+ import { isRecord } from "../../app/value-guards.js";
2
+ import { isCanonicalPath } from "../../native/canonical-path.js";
3
3
  import { isRepositorySlug } from "./signed-release.js";
4
- import { parseReleaseConfig } from "../release/release-config.js";
5
- import { openUnchangedFile, sameFile } from "./stable-file.js";
4
+ import { parseReleaseConfig } from "../../release/release-config.js";
5
+ import { openUnchangedFile, sameFile } from "../locks/stable-file.js";
6
6
  import { lstat } from "node:fs/promises";
7
7
  import { join } from "node:path";
8
- // src/updates/packaged-release-config.ts
8
+ // src/updates/feed/packaged-release-config.ts
9
9
  var MAX_CONFIG_BYTES = 262144;
10
10
  /** Read only the release identity and public keys shipped beside the Bun entry. */
11
11
  async function readPackagedReleaseConfig(entryDirectory, identity) {
@@ -1,5 +1,5 @@
1
- import { isGitSha, isRecord, isSha256Hex } from "../app/value-guards.js";
2
- // src/updates/release-feed.ts
1
+ import { isGitSha, isRecord, isSha256Hex } from "../../app/value-guards.js";
2
+ // src/updates/feed/release-feed.ts
3
3
  /** Ledger entries kept; the oldest fall off a full ledger. */
4
4
  var MAX_LEDGER_RELEASES = 500;
5
5
  var MAX_RELEASE_ASSETS = 256;
@@ -1,5 +1,5 @@
1
- import { discardStream } from "../shared/discard-stream.js";
2
- // src/updates/release-location.ts
1
+ import { discardStream } from "../../shared/discard-stream.js";
2
+ // src/updates/feed/release-location.ts
3
3
  /** `value` as a URL inside `scope`: the same https origin, under its path prefix, with no
4
4
  * credentials, port, fragment or dot segments. */
5
5
  function releaseUrl(value, scope) {
@@ -1,4 +1,4 @@
1
- // src/updates/release-version.ts
1
+ // src/updates/feed/release-version.ts
2
2
  function isUpdateChannel(value) {
3
3
  return value === "stable" || value === "pre-release" || value === "dev";
4
4
  }
@@ -1,6 +1,6 @@
1
- import { isGitSha, isRecord, isSha256Hex } from "../app/value-guards.js";
1
+ import { isGitSha, isRecord, isSha256Hex } from "../../app/value-guards.js";
2
2
  import { createHash, createPublicKey, sign, timingSafeEqual, verify } from "node:crypto";
3
- // src/updates/signed-release.ts
3
+ // src/updates/feed/signed-release.ts
4
4
  var verifiedDescriptors = /* @__PURE__ */ new WeakMap();
5
5
  /** A GitHub `owner/name` slug that is safe to place in API and download paths. */
6
6
  function isRepositorySlug(value) {
@@ -3,7 +3,7 @@ import { isRepositorySlug, verifyReleaseDescriptor } from "./signed-release.js";
3
3
  import { parseFeedRelease, parseReleaseLedger } from "./release-feed.js";
4
4
  import { fetchReleaseLocation, readReleaseBytes, readReleaseJson } from "./release-location.js";
5
5
  import { createHash } from "node:crypto";
6
- // src/updates/update-discovery.ts
6
+ // src/updates/feed/update-discovery.ts
7
7
  var MAX_POINTER_BYTES = 262144;
8
8
  var MAX_LEDGER_BYTES = 1048576;
9
9
  /** Discover and authenticate the app's channel descriptor without trusting feed metadata as an update. */
@@ -0,0 +1,8 @@
1
+ import { type ReleaseTrust } from '../feed/signed-release';
2
+ import { type UpdateLaunchGateRecoveryResult } from '../launch/update-launch-gate';
3
+ /**
4
+ * Reconcile only the schema-3 journal bound to the exact persisted gate. The
5
+ * caller deliberately opts into this operation; generated unmanaged startup
6
+ * reaches it through `recoverPackagedUpdateLaunchGate` before launch admission.
7
+ */
8
+ export declare function recoverUpdateLaunchGate(target: string, trust: ReleaseTrust): Promise<UpdateLaunchGateRecoveryResult>;