@adea-ai/app-framework 0.36.1 → 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 (175) hide show
  1. package/README.md +2 -0
  2. package/dist/appearance/appearance-host.js +2 -1
  3. package/dist/appearance/custom-theme-import.js +3 -1
  4. package/dist/appearance/custom-theme-library.d.ts +6 -185
  5. package/dist/appearance/custom-theme-library.js +3 -621
  6. package/dist/appearance/theme-library-mutation.d.ts +42 -0
  7. package/dist/appearance/theme-library-mutation.js +172 -0
  8. package/dist/appearance/theme-library-schema.d.ts +108 -0
  9. package/dist/appearance/theme-library-schema.js +189 -0
  10. package/dist/appearance/theme-library-store.d.ts +61 -0
  11. package/dist/appearance/theme-library-store.js +268 -0
  12. package/dist/appearance/theme-record-adapter.js +3 -1
  13. package/dist/appearance/theme-registry.js +2 -1
  14. package/dist/appearance/window-surface.d.ts +19 -0
  15. package/dist/appearance/window-surface.js +68 -1
  16. package/dist/cli/update-helper-cli.js +1 -1
  17. package/dist/cli/windows-installer-build-cli.d.ts +2 -0
  18. package/dist/cli/windows-installer-build-cli.js +14 -0
  19. package/dist/desktop/desktop-client.d.ts +1 -1
  20. package/dist/framework-source.json +1 -1
  21. package/dist/installer/installed-payload.js +2 -2
  22. package/dist/installer/{installer-archive.js → installer-archive-members.js} +2 -2
  23. package/dist/installer/installer-extraction.js +2 -2
  24. package/dist/installer/installer-fetch-guard.d.ts +1 -1
  25. package/dist/installer/installer-identity.js +2 -2
  26. package/dist/installer/installer-observation.d.ts +1 -1
  27. package/dist/installer/installer-observation.js +2 -2
  28. package/dist/installer/installer-upgrade-command.d.ts +2 -2
  29. package/dist/installer/installer-upgrade-command.js +5 -5
  30. package/dist/installer/linux-process-group.js +1 -1
  31. package/dist/installer/upgrade-asset-download.d.ts +1 -1
  32. package/dist/installer/upgrade-asset-download.js +2 -2
  33. package/dist/native/installer-archive.d.ts +42 -0
  34. package/dist/native/installer-archive.js +172 -0
  35. package/dist/native/posix-tree-removal.d.ts +1 -1
  36. package/dist/native/window-surface-store.d.ts +16 -0
  37. package/dist/native/window-surface-store.js +69 -0
  38. package/dist/native/windows-extractor-build.d.ts +95 -0
  39. package/dist/native/windows-extractor-build.js +326 -0
  40. package/dist/release/feed-release-cut.d.ts +1 -1
  41. package/dist/release/feed-state.d.ts +2 -2
  42. package/dist/release/feed-state.js +3 -3
  43. package/dist/release/github-release-cut.js +1 -1
  44. package/dist/release/github-release-promotion.js +1 -1
  45. package/dist/release/github-release-publisher.js +1 -1
  46. package/dist/release/github-release-qualification.js +1 -1
  47. package/dist/release/local-release.d.ts +2 -2
  48. package/dist/release/local-release.js +3 -3
  49. package/dist/release/release-artifact.d.ts +1 -1
  50. package/dist/release/release-artifact.js +2 -2
  51. package/dist/release/release-assets-plan.js +1 -1
  52. package/dist/release/release-config.d.ts +1 -1
  53. package/dist/release/release-config.js +1 -1
  54. package/dist/release/release-descriptor-staging.js +3 -3
  55. package/dist/release/release-finalize.js +1 -1
  56. package/dist/release/release-promotion.js +1 -1
  57. package/dist/release/release-publication.d.ts +1 -1
  58. package/dist/release/release-publication.js +2 -2
  59. package/dist/release/release-publish-command.js +2 -2
  60. package/dist/update-helper.bundle.js +18 -18
  61. package/dist/updates/channel-update-manager.d.ts +3 -3
  62. package/dist/updates/channel-update-manager.js +2 -2
  63. package/dist/updates/desktop-updater.d.ts +10 -83
  64. package/dist/updates/desktop-updater.js +14 -217
  65. package/dist/updates/{packaged-release-config.js → feed/packaged-release-config.js} +5 -5
  66. package/dist/updates/{release-feed.js → feed/release-feed.js} +2 -2
  67. package/dist/updates/{release-location.js → feed/release-location.js} +2 -2
  68. package/dist/updates/{release-version.js → feed/release-version.js} +1 -1
  69. package/dist/updates/{signed-release.js → feed/signed-release.js} +2 -2
  70. package/dist/updates/{update-discovery.js → feed/update-discovery.js} +1 -1
  71. package/dist/updates/helper/launch-gate-recovery.d.ts +8 -0
  72. package/dist/updates/{update-resume.js → helper/launch-gate-recovery.js} +13 -423
  73. package/dist/updates/helper/resume-staging.d.ts +22 -0
  74. package/dist/updates/helper/resume-staging.js +180 -0
  75. package/dist/updates/{update-helper.d.ts → helper/update-helper.d.ts} +1 -1
  76. package/dist/updates/{update-helper.js → helper/update-helper.js} +9 -9
  77. package/dist/updates/{update-resume.d.ts → helper/update-resume.d.ts} +4 -10
  78. package/dist/updates/helper/update-resume.js +252 -0
  79. package/dist/updates/{update-shutdown.js → helper/update-shutdown.js} +2 -2
  80. package/dist/updates/{update-arm.d.ts → install/update-arm.d.ts} +2 -2
  81. package/dist/updates/{update-arm.js → install/update-arm.js} +9 -9
  82. package/dist/updates/{update-download-cleanup.d.ts → install/update-download-cleanup.d.ts} +1 -1
  83. package/dist/updates/{update-download-cleanup.js → install/update-download-cleanup.js} +3 -3
  84. package/dist/updates/{update-download.d.ts → install/update-download.d.ts} +2 -2
  85. package/dist/updates/{update-download.js → install/update-download.js} +3 -3
  86. package/dist/updates/{update-extraction.d.ts → install/update-extraction.d.ts} +2 -2
  87. package/dist/updates/{update-extraction.js → install/update-extraction.js} +6 -6
  88. package/dist/updates/{update-handoff-plan.d.ts → install/update-handoff-plan.d.ts} +2 -2
  89. package/dist/updates/{update-handoff-plan.js → install/update-handoff-plan.js} +5 -5
  90. package/dist/updates/{update-marker.js → install/update-marker.js} +2 -2
  91. package/dist/updates/{update-swap-stage.d.ts → install/update-swap-stage.d.ts} +2 -2
  92. package/dist/updates/{update-swap-stage.js → install/update-swap-stage.js} +7 -6
  93. package/dist/updates/{update-swap.d.ts → install/update-swap.d.ts} +1 -1
  94. package/dist/updates/{update-swap.js → install/update-swap.js} +5 -5
  95. package/dist/updates/install-target.d.ts +8 -0
  96. package/dist/updates/install-target.js +27 -0
  97. package/dist/updates/{launch-environment.js → launch/launch-environment.js} +1 -1
  98. package/dist/updates/{packaged-launch-admission.js → launch/packaged-launch-admission.js} +4 -4
  99. package/dist/updates/{packaged-update-startup.d.ts → launch/packaged-update-startup.d.ts} +3 -3
  100. package/dist/updates/{packaged-update-startup.js → launch/packaged-update-startup.js} +10 -7
  101. package/dist/updates/{update-launch-gate.d.ts → launch/update-launch-gate.d.ts} +1 -1
  102. package/dist/updates/{update-launch-gate.js → launch/update-launch-gate.js} +9 -9
  103. package/dist/updates/{update-launch.d.ts → launch/update-launch.d.ts} +1 -1
  104. package/dist/updates/{update-launch.js → launch/update-launch.js} +2 -2
  105. package/dist/updates/{linux-process-state.js → locks/linux-process-state.js} +1 -1
  106. package/dist/updates/{native-file-lock.js → locks/native-file-lock.js} +1 -1
  107. package/dist/updates/{stable-file.js → locks/stable-file.js} +2 -2
  108. package/dist/updates/{update-download-lock.js → locks/update-download-lock.js} +1 -1
  109. package/dist/updates/{update-generation-lease.js → locks/update-generation-lease.js} +3 -3
  110. package/dist/updates/{update-inherited-launch-lease.d.ts → locks/update-inherited-launch-lease.d.ts} +1 -1
  111. package/dist/updates/{update-inherited-launch-lease.js → locks/update-inherited-launch-lease.js} +2 -2
  112. package/dist/updates/{update-instance-lease.js → locks/update-instance-lease.js} +2 -2
  113. package/dist/updates/{update-lock.js → locks/update-lock.js} +2 -2
  114. package/dist/updates/{update-process-fence.js → locks/update-process-fence.js} +3 -3
  115. package/dist/updates/{update-process-liveness.js → locks/update-process-liveness.js} +2 -2
  116. package/dist/updates/retained-client-assets.d.ts +60 -0
  117. package/dist/updates/retained-client-assets.js +116 -0
  118. package/dist/updates/retention/retention-cleanup.d.ts +103 -0
  119. package/dist/updates/retention/retention-cleanup.js +439 -0
  120. package/dist/updates/retention/retention-prune-progress.d.ts +27 -0
  121. package/dist/updates/retention/retention-prune-progress.js +203 -0
  122. package/dist/updates/retention/retirement-inventory.d.ts +93 -0
  123. package/dist/updates/retention/retirement-inventory.js +373 -0
  124. package/dist/updates/retention/retirement-records.d.ts +75 -0
  125. package/dist/updates/retention/retirement-records.js +309 -0
  126. package/dist/updates/{update-retention-marker.d.ts → retention/update-retention-marker.d.ts} +1 -1
  127. package/dist/updates/{update-retention-marker.js → retention/update-retention-marker.js} +3 -3
  128. package/dist/updates/{update-retention-plan.d.ts → retention/update-retention-plan.d.ts} +1 -1
  129. package/dist/updates/{update-retention-plan.js → retention/update-retention-plan.js} +2 -2
  130. package/dist/updates/{update-retention-sync.d.ts → retention/update-retention-sync.d.ts} +1 -1
  131. package/dist/updates/{update-retention-sync.js → retention/update-retention-sync.js} +2 -2
  132. package/dist/updates/retention/update-retirement.d.ts +26 -0
  133. package/dist/updates/retention/update-retirement.js +205 -0
  134. package/dist/updates/update-adapter.js +1 -1
  135. package/dist/updates/update-channel-store.d.ts +1 -1
  136. package/dist/updates/update-channel-store.js +2 -2
  137. package/dist/updates/update-manager.d.ts +4 -4
  138. package/dist/updates/update-manager.js +5 -5
  139. package/dist/updates/update-services.d.ts +15 -0
  140. package/dist/updates/update-services.js +77 -0
  141. package/dist/updates/update-state-store.d.ts +2 -2
  142. package/dist/updates/update-state-store.js +2 -2
  143. package/dist/views/appearance-surface.js +3 -1
  144. package/package.json +42 -29
  145. package/src/appearance/custom-theme-library.ts +42 -956
  146. package/src/appearance/theme-library-mutation.ts +288 -0
  147. package/src/appearance/theme-library-schema.ts +347 -0
  148. package/src/appearance/theme-library-store.ts +379 -0
  149. package/src/appearance/window-surface.ts +91 -5
  150. package/src/updates/update-adapter.ts +1 -1
  151. package/templates/application/src/bun/index.ts +15 -0
  152. package/templates/application/src/web/main.tsx +13 -1
  153. package/dist/updates/update-retirement.d.ts +0 -205
  154. package/dist/updates/update-retirement.js +0 -1485
  155. /package/dist/installer/{installer-archive.d.ts → installer-archive-members.d.ts} +0 -0
  156. /package/dist/updates/{packaged-release-config.d.ts → feed/packaged-release-config.d.ts} +0 -0
  157. /package/dist/updates/{release-feed.d.ts → feed/release-feed.d.ts} +0 -0
  158. /package/dist/updates/{release-location.d.ts → feed/release-location.d.ts} +0 -0
  159. /package/dist/updates/{release-version.d.ts → feed/release-version.d.ts} +0 -0
  160. /package/dist/updates/{signed-release.d.ts → feed/signed-release.d.ts} +0 -0
  161. /package/dist/updates/{update-discovery.d.ts → feed/update-discovery.d.ts} +0 -0
  162. /package/dist/updates/{update-shutdown.d.ts → helper/update-shutdown.d.ts} +0 -0
  163. /package/dist/updates/{update-marker.d.ts → install/update-marker.d.ts} +0 -0
  164. /package/dist/updates/{launch-environment.d.ts → launch/launch-environment.d.ts} +0 -0
  165. /package/dist/updates/{packaged-launch-admission.d.ts → launch/packaged-launch-admission.d.ts} +0 -0
  166. /package/dist/updates/{linux-process-state.d.ts → locks/linux-process-state.d.ts} +0 -0
  167. /package/dist/updates/{native-file-lock.d.ts → locks/native-file-lock.d.ts} +0 -0
  168. /package/dist/updates/{stable-file.d.ts → locks/stable-file.d.ts} +0 -0
  169. /package/dist/updates/{update-download-lock.d.ts → locks/update-download-lock.d.ts} +0 -0
  170. /package/dist/updates/{update-generation-lease.d.ts → locks/update-generation-lease.d.ts} +0 -0
  171. /package/dist/updates/{update-instance-lease.d.ts → locks/update-instance-lease.d.ts} +0 -0
  172. /package/dist/updates/{update-lock.d.ts → locks/update-lock.d.ts} +0 -0
  173. /package/dist/updates/{update-process-fence.d.ts → locks/update-process-fence.d.ts} +0 -0
  174. /package/dist/updates/{update-process-liveness.d.ts → locks/update-process-liveness.d.ts} +0 -0
  175. /package/src/updates/{release-version.ts → feed/release-version.ts} +0 -0
@@ -1,12 +1,15 @@
1
- import { readPackagedVersion } from "../native/app-bundle.js";
2
- import { feedUrl } from "./release-feed.js";
1
+ import { readPackagedVersion } from "../../native/app-bundle.js";
2
+ import { feedUrl } from "../feed/release-feed.js";
3
3
  import { readUpdateLaunchGate } from "./update-launch-gate.js";
4
- import { createUpdateChannelStore, releaseChannelForUpdate } from "./update-channel-store.js";
5
- import { recoverUpdateLaunchGate, resumeUpdate } from "./update-resume.js";
6
- import { installTarget, resumeAndAcquireRetainedDesktopClientAssets, updatePlatform, updateTrust } from "./desktop-updater.js";
7
- import { readPackagedReleaseConfig } from "./packaged-release-config.js";
4
+ import { createUpdateChannelStore, releaseChannelForUpdate } from "../update-channel-store.js";
5
+ import { recoverUpdateLaunchGate } from "../helper/launch-gate-recovery.js";
6
+ import { resumeUpdate } from "../helper/update-resume.js";
7
+ import { installTarget, updatePlatform } from "../install-target.js";
8
+ import { resumeAndAcquireRetainedDesktopClientAssets } from "../retained-client-assets.js";
9
+ import { updateTrust } from "../desktop-updater.js";
10
+ import { readPackagedReleaseConfig } from "../feed/packaged-release-config.js";
8
11
  import { realpath } from "node:fs/promises";
9
- // src/updates/packaged-update-startup.ts
12
+ // src/updates/launch/packaged-update-startup.ts
10
13
  async function preparePackagedUpdateStartup(options) {
11
14
  if (options.admission === "unmanaged") return prepareUnmanagedUpdateStartup(options);
12
15
  const { release, trust, savedChannel, channel } = await packagedReleaseTrust(options);
@@ -1,4 +1,4 @@
1
- import { type UpdateInstanceLease } from './update-instance-lease';
1
+ import { type UpdateInstanceLease } from '../locks/update-instance-lease';
2
2
  export type UpdateLaunchGate = Readonly<{
3
3
  schema: 1;
4
4
  generation: string;
@@ -1,16 +1,16 @@
1
- import { errorCode, isUuid } from "../app/value-guards.js";
2
- import { isCanonicalPath } from "../native/canonical-path.js";
3
- import { readSmallStateFile } from "./stable-file.js";
4
- import { tryAcquireNativeFileLock } from "./native-file-lock.js";
5
- import { tryAcquireUpdateLock } from "./update-lock.js";
6
- import { acquireUpdateLock } from "./update-state-store.js";
7
- import { publishExclusiveUpdateMarker, readUpdateMarker } from "./update-marker.js";
8
- import { tryAcquireUpdateInstanceLease } from "./update-instance-lease.js";
1
+ import { errorCode, isUuid } from "../../app/value-guards.js";
2
+ import { isCanonicalPath } from "../../native/canonical-path.js";
3
+ import { readSmallStateFile } from "../locks/stable-file.js";
4
+ import { tryAcquireNativeFileLock } from "../locks/native-file-lock.js";
5
+ import { tryAcquireUpdateLock } from "../locks/update-lock.js";
6
+ import { acquireUpdateLock } from "../update-state-store.js";
7
+ import { publishExclusiveUpdateMarker, readUpdateMarker } from "../install/update-marker.js";
8
+ import { tryAcquireUpdateInstanceLease } from "../locks/update-instance-lease.js";
9
9
  import { open, rename, unlink } from "node:fs/promises";
10
10
  import { basename, dirname, join } from "node:path";
11
11
  import { randomUUID } from "node:crypto";
12
12
  import { constants as constants$1 } from "node:fs";
13
- // src/updates/update-launch-gate.ts
13
+ // src/updates/launch/update-launch-gate.ts
14
14
  /**
15
15
  * Publish the schema-3 helper's cancellation request under the same
16
16
  * coordinator used for the final writer grant. This defines the cutoff:
@@ -1,4 +1,4 @@
1
- import type { InstallerPlatform } from '../installer/installer-layout';
1
+ import type { InstallerPlatform } from '../../installer/installer-layout';
2
2
  /** The Electrobun launcher inside an installed app tree. */
3
3
  export declare function updateLauncherPath(platform: InstallerPlatform, target: string): string;
4
4
  /** Start the installed app's launcher detached from the helper. */
@@ -1,8 +1,8 @@
1
- import { isCanonicalPath } from "../native/canonical-path.js";
1
+ import { isCanonicalPath } from "../../native/canonical-path.js";
2
2
  import { INHERITED_LAUNCH_LEASE_ENV } from "./launch-environment.js";
3
3
  import { dirname, join } from "node:path";
4
4
  import { spawn } from "node:child_process";
5
- // src/updates/update-launch.ts
5
+ // src/updates/launch/update-launch.ts
6
6
  /** The Electrobun launcher inside an installed app tree. */
7
7
  function updateLauncherPath(platform, target) {
8
8
  if (!isCanonicalPath(target)) throw new Error("Invalid update target");
@@ -1,4 +1,4 @@
1
- // src/updates/linux-process-state.ts
1
+ // src/updates/locks/linux-process-state.ts
2
2
  /** True only for a Linux zombie thread-group leader with no other threads. */
3
3
  function linuxProcessIsExited(stat, pid) {
4
4
  const prefix = `${pid} (`;
@@ -1,7 +1,7 @@
1
1
  import { open } from "node:fs/promises";
2
2
  import { FFIType, dlopen, ptr, read } from "bun:ffi";
3
3
  import { constants as constants$1 } from "node:fs";
4
- // src/updates/native-file-lock.ts
4
+ // src/updates/locks/native-file-lock.ts
5
5
  var LOCK_SH = 1;
6
6
  var LOCK_EX = 2;
7
7
  var LOCK_NB = 4;
@@ -1,8 +1,8 @@
1
- import { errorCode } from "../app/value-guards.js";
1
+ import { errorCode } from "../../app/value-guards.js";
2
2
  import { lstat, open } from "node:fs/promises";
3
3
  import { createHash } from "node:crypto";
4
4
  import { constants as constants$1 } from "node:fs";
5
- // src/updates/stable-file.ts
5
+ // src/updates/locks/stable-file.ts
6
6
  /** Whether two stats describe the same, unmodified file. */
7
7
  function sameFile(left, right) {
8
8
  return left.dev === right.dev && left.ino === right.ino && left.size === right.size && left.mtimeMs === right.mtimeMs;
@@ -1,5 +1,5 @@
1
1
  import { tryAcquireNativeFileLock } from "./native-file-lock.js";
2
- // src/updates/update-download-lock.ts
2
+ // src/updates/locks/update-download-lock.ts
3
3
  var ROOT_LOCK_TIMEOUT_MS = 12e4;
4
4
  var localQueues = /* @__PURE__ */ new Map();
5
5
  /**
@@ -1,8 +1,8 @@
1
- import { isUuid } from "../app/value-guards.js";
2
- import { isCanonicalPath } from "../native/canonical-path.js";
1
+ import { isUuid } from "../../app/value-guards.js";
2
+ import { isCanonicalPath } from "../../native/canonical-path.js";
3
3
  import { tryAcquireNativeFileLock } from "./native-file-lock.js";
4
4
  import { basename, dirname, join } from "node:path";
5
- // src/updates/update-generation-lease.ts
5
+ // src/updates/locks/update-generation-lease.ts
6
6
  /** A persistent lock outside the retained tree; never remove or replace it. */
7
7
  function updateGenerationLeasePath(target, generation) {
8
8
  if (!isCanonicalPath(target) || typeof generation !== "string" || !isUuid(generation)) throw new Error("Invalid update generation lease identity");
@@ -1,4 +1,4 @@
1
- import { type UpdateLaunchLeaseAttempt } from './update-launch-gate';
1
+ import { type UpdateLaunchLeaseAttempt } from '../launch/update-launch-gate';
2
2
  /**
3
3
  * Transfer a launcher's inherited POSIX shared-lock descriptor to an
4
4
  * independent process lease. The native launcher must have acquired the shared
@@ -1,8 +1,8 @@
1
1
  import { tryLockInheritedSharedFileDescriptor } from "./native-file-lock.js";
2
2
  import { updateInstanceLeasePath } from "./update-instance-lease.js";
3
- import { tryAcquireUpdateLaunchLease } from "./update-launch-gate.js";
3
+ import { tryAcquireUpdateLaunchLease } from "../launch/update-launch-gate.js";
4
4
  import { closeSync, fstatSync, lstatSync } from "node:fs";
5
- // src/updates/update-inherited-launch-lease.ts
5
+ // src/updates/locks/update-inherited-launch-lease.ts
6
6
  var retainedAfterCloseFailure = /* @__PURE__ */ new Set();
7
7
  var transfersInFlight = /* @__PURE__ */ new Set();
8
8
  var uncertainDescriptors = /* @__PURE__ */ new Set();
@@ -1,7 +1,7 @@
1
- import { isCanonicalPath } from "../native/canonical-path.js";
1
+ import { isCanonicalPath } from "../../native/canonical-path.js";
2
2
  import { tryAcquireNativeFileLock } from "./native-file-lock.js";
3
3
  import { basename, dirname, join } from "node:path";
4
- // src/updates/update-instance-lease.ts
4
+ // src/updates/locks/update-instance-lease.ts
5
5
  /** Stable app-lifetime path, separate from the updater transition lock. */
6
6
  function updateInstanceLeasePath(target) {
7
7
  if (!isCanonicalPath(target)) throw new Error("Invalid update instance lease target");
@@ -1,7 +1,7 @@
1
- import { isCanonicalPath } from "../native/canonical-path.js";
1
+ import { isCanonicalPath } from "../../native/canonical-path.js";
2
2
  import { tryAcquireNativeFileLock } from "./native-file-lock.js";
3
3
  import { basename, dirname, join } from "node:path";
4
- // src/updates/update-lock.ts
4
+ // src/updates/locks/update-lock.ts
5
5
  /** Stable transition lock path. The file must never be removed or replaced. */
6
6
  function updateLockPath(target) {
7
7
  if (!isCanonicalPath(target)) throw new Error("Invalid update lock target");
@@ -1,10 +1,10 @@
1
- import { errorCode } from "../app/value-guards.js";
1
+ import { errorCode } from "../../app/value-guards.js";
2
2
  import { linuxProcessIsExited } from "./linux-process-state.js";
3
- import { windowsProcessImage } from "../native/windows-process.js";
3
+ import { windowsProcessImage } from "../../native/windows-process.js";
4
4
  import { readFile, realpath } from "node:fs/promises";
5
5
  import { isAbsolute } from "node:path";
6
6
  import { FFIType, dlopen, ptr } from "bun:ffi";
7
- // src/updates/update-process-fence.ts
7
+ // src/updates/locks/update-process-fence.ts
8
8
  var UpdateProcessFenceCancelledError = class extends Error {
9
9
  constructor() {
10
10
  super("Update helper cancellation was requested");
@@ -1,5 +1,5 @@
1
- import { errorCode } from "../app/value-guards.js";
2
- // src/updates/update-process-liveness.ts
1
+ import { errorCode } from "../../app/value-guards.js";
2
+ // src/updates/locks/update-process-liveness.ts
3
3
  /** Only ESRCH proves a recorded process is absent; inspection errors fail closed. */
4
4
  function updateProcessMayBeAlive(pid) {
5
5
  try {
@@ -0,0 +1,60 @@
1
+ import type { ReleaseTrust } from './feed/signed-release';
2
+ /** Preserve interrupted-swap recovery when the installed target is temporarily absent. */
3
+ export declare function canonicalTargetForRecovery(target: string, seen?: Set<string>): Promise<string>;
4
+ /**
5
+ * Acquire the updater's retained generations and map their packaged client
6
+ * directories to manifests. The caller must already hold any required native
7
+ * launch admission lease and must retain the returned generation leases until
8
+ * the host and all response bodies are drained. This does not gate startup.
9
+ * `loadManifest` receives a retained client root while its lease is held.
10
+ */
11
+ export declare function acquireRetainedDesktopClientAssets(options: {
12
+ entryDirectory: string;
13
+ currentVersion: string;
14
+ loadManifest(root: string): Promise<ReadonlyMap<string, string>>;
15
+ }): Promise<Readonly<{
16
+ status: 'none' | 'busy';
17
+ }> | {
18
+ status: 'unsupported';
19
+ retainedClientAssets?: undefined;
20
+ release?: undefined;
21
+ } | {
22
+ status: 'acquired';
23
+ retainedClientAssets: {
24
+ root: string;
25
+ immutableAssets: ReadonlyMap<string, string>;
26
+ }[];
27
+ release: () => Promise<void>;
28
+ }>;
29
+ /**
30
+ * Trusted startup variant for callers that must preserve normal pending staged
31
+ * updates while pinning retained generations. Resume and lease acquisition are
32
+ * serialized under the install lock; callers keep the returned lease through
33
+ * host shutdown and response draining.
34
+ */
35
+ export declare function resumeAndAcquireRetainedDesktopClientAssets(options: {
36
+ entryDirectory: string;
37
+ currentVersion: string;
38
+ trust: ReleaseTrust;
39
+ loadManifest(root: string): Promise<ReadonlyMap<string, string>>;
40
+ }): Promise<Readonly<{
41
+ status: 'busy' | 'in-progress' | 'recovery-required';
42
+ }> | {
43
+ retainedClientAssets?: undefined;
44
+ release?: undefined;
45
+ status: 'unsupported';
46
+ resume?: undefined;
47
+ } | {
48
+ status: 'ready';
49
+ resume: import("./helper/update-resume").UpdateResumeResult;
50
+ retainedClientAssets: readonly [];
51
+ release: () => Promise<void>;
52
+ } | {
53
+ status: 'ready';
54
+ resume: import("./helper/update-resume").UpdateResumeResult;
55
+ retainedClientAssets: {
56
+ root: string;
57
+ immutableAssets: ReadonlyMap<string, string>;
58
+ }[];
59
+ release: () => Promise<void>;
60
+ }>;
@@ -0,0 +1,116 @@
1
+ import { errorCode } from "../app/value-guards.js";
2
+ import { isCanonicalPath } from "../native/canonical-path.js";
3
+ import { acquireRetainedUpdateTrees } from "./retention/retirement-inventory.js";
4
+ import { resumeUpdateWithRetainedTrees } from "./helper/update-resume.js";
5
+ import { installTarget, updatePlatform } from "./install-target.js";
6
+ import { lstat, readlink, realpath } from "node:fs/promises";
7
+ import { basename, dirname, join, relative, resolve } from "node:path";
8
+ // src/updates/retained-client-assets.ts
9
+ /** Preserve interrupted-swap recovery when the installed target is temporarily absent. */
10
+ async function canonicalTargetForRecovery(target, seen = /* @__PURE__ */ new Set()) {
11
+ if (seen.has(target) || seen.size >= 16) throw new Error("Invalid install target symlink chain");
12
+ seen.add(target);
13
+ try {
14
+ return await realpath(target);
15
+ } catch (error) {
16
+ if (errorCode(error) !== "ENOENT") throw error;
17
+ const info = await lstat(target).then((value) => value, (statError) => {
18
+ if (errorCode(statError) === "ENOENT") return void 0;
19
+ throw statError;
20
+ });
21
+ if (info?.isSymbolicLink()) return canonicalTargetForRecovery(resolve(dirname(target), await readlink(target)), seen);
22
+ if (info) throw error;
23
+ return join(await realpath(dirname(target)), basename(target));
24
+ }
25
+ }
26
+ /**
27
+ * Validate a packaged entry directory and locate its install root plus the
28
+ * client directory relative to it, which every retained generation shares.
29
+ */
30
+ async function packagedClientLayout(options, platform) {
31
+ if (!isCanonicalPath(options.entryDirectory) || typeof options.loadManifest !== "function") throw new Error("Invalid packaged client asset lookup");
32
+ const lexicalTarget = installTarget(options.entryDirectory, platform);
33
+ const clientRelative = relative(lexicalTarget, resolve(options.entryDirectory, "..", "client"));
34
+ if (clientRelative !== join(...platform === "macos-arm64" ? ["Contents"] : [], "Resources", "app", "client")) throw new Error("Invalid packaged client asset layout");
35
+ return {
36
+ target: await realpath(lexicalTarget),
37
+ clientRelative
38
+ };
39
+ }
40
+ /**
41
+ * Load every retained generation's client manifest while its lease is held. The
42
+ * loads run concurrently; all of them settle before a failure releases the
43
+ * leases, so no load still reads a tree that may be pruned. A loader that
44
+ * throws synchronously is treated as a rejected load.
45
+ */
46
+ async function loadRetainedClientAssets(trees, clientRelative, loadManifest, release) {
47
+ const roots = trees.map(({ tree }) => join(tree, clientRelative));
48
+ const loaded = await Promise.allSettled(roots.map((root) => Promise.resolve().then(() => loadManifest(root))));
49
+ const failed = loaded.find((outcome) => outcome.status === "rejected");
50
+ if (!failed) return roots.map((root, index) => ({
51
+ root,
52
+ immutableAssets: loaded[index].value
53
+ }));
54
+ try {
55
+ await release();
56
+ } catch (releaseError) {
57
+ throw new AggregateError([failed.reason, releaseError], "Retained client asset preparation failed", { cause: releaseError });
58
+ }
59
+ throw failed.reason;
60
+ }
61
+ /**
62
+ * Acquire the updater's retained generations and map their packaged client
63
+ * directories to manifests. The caller must already hold any required native
64
+ * launch admission lease and must retain the returned generation leases until
65
+ * the host and all response bodies are drained. This does not gate startup.
66
+ * `loadManifest` receives a retained client root while its lease is held.
67
+ */
68
+ async function acquireRetainedDesktopClientAssets(options) {
69
+ const platform = updatePlatform();
70
+ if (!platform) return { status: "unsupported" };
71
+ const { target, clientRelative } = await packagedClientLayout(options, platform);
72
+ const retained = await acquireRetainedUpdateTrees({
73
+ target,
74
+ currentVersion: options.currentVersion
75
+ });
76
+ if (retained.status !== "acquired") return retained;
77
+ return {
78
+ status: "acquired",
79
+ retainedClientAssets: await loadRetainedClientAssets(retained.trees, clientRelative, options.loadManifest, retained.release),
80
+ release: retained.release
81
+ };
82
+ }
83
+ /**
84
+ * Trusted startup variant for callers that must preserve normal pending staged
85
+ * updates while pinning retained generations. Resume and lease acquisition are
86
+ * serialized under the install lock; callers keep the returned lease through
87
+ * host shutdown and response draining.
88
+ */
89
+ async function resumeAndAcquireRetainedDesktopClientAssets(options) {
90
+ const platform = updatePlatform();
91
+ if (!platform) return { status: "unsupported" };
92
+ const { target, clientRelative } = await packagedClientLayout(options, platform);
93
+ const result = await resumeUpdateWithRetainedTrees({
94
+ target,
95
+ trust: options.trust,
96
+ currentVersion: options.currentVersion
97
+ });
98
+ if (result.status !== "ready") return result;
99
+ if (result.retained.status !== "acquired") {
100
+ if (result.retained.status === "busy") return { status: "busy" };
101
+ return {
102
+ status: "ready",
103
+ resume: result.resume,
104
+ retainedClientAssets: [],
105
+ release: async () => {}
106
+ };
107
+ }
108
+ const retainedClientAssets = await loadRetainedClientAssets(result.retained.trees, clientRelative, options.loadManifest, result.retained.release);
109
+ return {
110
+ status: "ready",
111
+ resume: result.resume,
112
+ retainedClientAssets,
113
+ release: result.retained.release
114
+ };
115
+ }
116
+ export { acquireRetainedDesktopClientAssets, canonicalTargetForRecovery, resumeAndAcquireRetainedDesktopClientAssets };
@@ -0,0 +1,103 @@
1
+ import { type UpdateRetentionIntent, type UpdateRetentionPublicationResult } from './update-retention-marker';
2
+ import { type UpdateTreeIdentity } from '../install/update-swap';
3
+ export type UpdateRetentionPruneStep = Readonly<{
4
+ status: 'none' | 'busy' | 'more' | 'pruned' | 'recovery-required';
5
+ removed?: number;
6
+ }>;
7
+ export type UpdateRetentionReconciliationResult = Readonly<{
8
+ status: 'already-clean';
9
+ intent: UpdateRetentionIntent;
10
+ } | {
11
+ status: 'temporary-removed';
12
+ intent: UpdateRetentionIntent;
13
+ temporaryPath: string;
14
+ }>;
15
+ export type UpdateRetentionOrphanPromotionResult = Readonly<{
16
+ status: 'promoted';
17
+ intent: UpdateRetentionIntent;
18
+ temporaryPath: string;
19
+ finalPath: string;
20
+ }>;
21
+ /** A failed promotion may have left the final marker in place; inspect before retrying. */
22
+ export declare class UpdateRetentionOrphanPromotionError extends Error {
23
+ readonly temporaryPath: string;
24
+ readonly finalPath: string;
25
+ readonly publicationState: 'unknown' | 'linked';
26
+ constructor(temporaryPath: string, finalPath: string, publicationState: 'unknown' | 'linked', cause: unknown);
27
+ }
28
+ /**
29
+ * Inspect one published retention intent against the current install while
30
+ * holding the update lock. This validates recovery data only; it never changes
31
+ * the filesystem or grants deletion authority.
32
+ */
33
+ export declare function inspectUpdateRetentionCleanup(options: {
34
+ target: string;
35
+ currentVersion: string;
36
+ generation: string;
37
+ }): Promise<UpdateRetentionIntent | null>;
38
+ /**
39
+ * Request synchronization of a freshly validated marker under the update lock.
40
+ * This does not establish hardware-level durability or authorize deletion.
41
+ */
42
+ export declare function syncValidatedUpdateRetentionCleanup(options: {
43
+ target: string;
44
+ currentVersion: string;
45
+ generation: string;
46
+ }): Promise<UpdateTreeIdentity>;
47
+ /**
48
+ * Promote one publisher temporary left by an interrupted intent publication.
49
+ * Under the update lock this requires exactly one canonical temporary, no
50
+ * final marker, and no other retention artifacts, then validates the bounded
51
+ * file and oldest eligible cleanup plan twice before a no-replace hard link.
52
+ * It leaves both names in place for reconcileUpdateRetentionCleanup. If the
53
+ * link call fails, whether a final name was created is treated as unknown; if
54
+ * post-link validation fails, the link is known to exist. Both failures
55
+ * preserve every path for inspection. This operation makes no power-loss
56
+ * durability claim and never removes a retirement tree or marker.
57
+ */
58
+ export declare function promoteOrphanUpdateRetentionCleanup(options: {
59
+ target: string;
60
+ currentVersion: string;
61
+ generation: string;
62
+ }): Promise<UpdateRetentionOrphanPromotionResult>;
63
+ /**
64
+ * Reconcile only the publisher's extra hard link after validating the final
65
+ * intent against a fresh retention plan under the update lock. This never
66
+ * deletes a final marker, retirement tree, claim, or receipt, and makes no
67
+ * power-loss durability claim.
68
+ */
69
+ export declare function reconcileUpdateRetentionCleanup(options: {
70
+ target: string;
71
+ currentVersion: string;
72
+ generation: string;
73
+ }): Promise<UpdateRetentionReconciliationResult>;
74
+ /**
75
+ * Record the oldest eligible cleanup candidate while holding the update lock.
76
+ * This WIP operation does not delete data or grant authority to a later caller.
77
+ * Intent publication is not yet power-loss durable.
78
+ */
79
+ export declare function beginUpdateRetentionCleanup(options: {
80
+ target: string;
81
+ currentVersion: string;
82
+ }): Promise<Readonly<{
83
+ intent: UpdateRetentionIntent;
84
+ publication: UpdateRetentionPublicationResult;
85
+ }> | null>;
86
+ /**
87
+ * Make one explicit, bounded prune step for an already-published retention
88
+ * intent. Ordinary inventory readers fail closed while this progress record
89
+ * exists. Calls serialize under the install lock, then take the generation's
90
+ * exclusive lease before inspecting or changing its retired tree.
91
+ *
92
+ * This currently supports only the tested macOS ARM64 directory-relative
93
+ * remover. It requests file and directory synchronization before destructive
94
+ * transitions, but those calls do not prove hardware persistence or recovery
95
+ * after power loss. Callers must invoke this explicitly; startup and updater
96
+ * flows do not prune automatically.
97
+ */
98
+ export declare function pruneUpdateRetentionStep(options: {
99
+ target: string;
100
+ currentVersion: string;
101
+ generation: string;
102
+ maxOperations?: number;
103
+ }): Promise<UpdateRetentionPruneStep>;