@adea-ai/app-framework 0.0.0-stage → 0.24.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 (358) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +30 -0
  3. package/README.md +1009 -2
  4. package/dist/app/application.d.ts +47 -0
  5. package/dist/app/application.js +115 -0
  6. package/dist/app/create-application.d.ts +13 -0
  7. package/dist/app/create-application.js +178 -0
  8. package/dist/app/service-registry.d.ts +44 -0
  9. package/dist/app/service-registry.js +116 -0
  10. package/dist/appearance/appearance-host.d.ts +62 -0
  11. package/dist/appearance/appearance-host.js +115 -0
  12. package/dist/appearance/appearance-preferences.d.ts +106 -0
  13. package/dist/appearance/appearance-preferences.js +175 -0
  14. package/dist/appearance/composition.d.ts +11 -0
  15. package/dist/appearance/composition.js +16 -0
  16. package/dist/appearance/custom-theme-import.d.ts +14 -0
  17. package/dist/appearance/custom-theme-import.js +315 -0
  18. package/dist/appearance/custom-theme-library.d.ts +146 -0
  19. package/dist/appearance/custom-theme-library.js +378 -0
  20. package/dist/appearance/editor.d.ts +20 -0
  21. package/dist/appearance/editor.js +47 -0
  22. package/dist/appearance/theme-file-importer.d.ts +23 -0
  23. package/dist/appearance/theme-file-importer.js +66 -0
  24. package/dist/appearance/theme-record-adapter.d.ts +26 -0
  25. package/dist/appearance/theme-record-adapter.js +64 -0
  26. package/dist/appearance/theme-registry.d.ts +10 -0
  27. package/dist/appearance/theme-registry.js +16 -0
  28. package/dist/appearance/window-surface.d.ts +5 -0
  29. package/dist/appearance/window-surface.js +9 -0
  30. package/dist/ci/toolchain-identity.d.ts +39 -0
  31. package/dist/ci/toolchain-identity.js +196 -0
  32. package/dist/cli/cef-helper-cli.d.ts +2 -0
  33. package/dist/cli/cef-helper-cli.js +18 -0
  34. package/dist/cli/cli-runner.d.ts +8 -0
  35. package/dist/cli/cli-runner.js +23 -0
  36. package/dist/cli/create-application-cli.d.ts +2 -0
  37. package/dist/cli/create-application-cli.js +40 -0
  38. package/dist/cli/electrobun-shortcut-patch-cli.d.ts +2 -0
  39. package/dist/cli/electrobun-shortcut-patch-cli.js +17 -0
  40. package/dist/cli/framework-update-cli.d.ts +2 -0
  41. package/dist/cli/framework-update-cli.js +40 -0
  42. package/dist/cli/release-assets-plan-cli.d.ts +2 -0
  43. package/dist/cli/release-assets-plan-cli.js +14 -0
  44. package/dist/cli/release-cut-cli.d.ts +2 -0
  45. package/dist/cli/release-cut-cli.js +27 -0
  46. package/dist/cli/release-descriptor-staging-cli.d.ts +2 -0
  47. package/dist/cli/release-descriptor-staging-cli.js +45 -0
  48. package/dist/cli/release-finalize-cli.d.ts +1 -0
  49. package/dist/cli/release-finalize-cli.js +30 -0
  50. package/dist/cli/release-promote-cli.d.ts +2 -0
  51. package/dist/cli/release-promote-cli.js +32 -0
  52. package/dist/cli/release-publish-cli.d.ts +2 -0
  53. package/dist/cli/release-publish-cli.js +48 -0
  54. package/dist/cli/release-sign-cli.d.ts +2 -0
  55. package/dist/cli/release-sign-cli.js +13 -0
  56. package/dist/cli/release-step-cli.d.ts +2 -0
  57. package/dist/cli/release-step-cli.js +44 -0
  58. package/dist/cli/toolchain-identity-cli.d.ts +2 -0
  59. package/dist/cli/toolchain-identity-cli.js +10 -0
  60. package/dist/cli/update-helper-cli.d.ts +1 -0
  61. package/dist/cli/update-helper-cli.js +10 -0
  62. package/dist/cli/windows-runtime-patch-cli.d.ts +2 -0
  63. package/dist/cli/windows-runtime-patch-cli.js +17 -0
  64. package/dist/desktop/application-command-client.d.ts +15 -0
  65. package/dist/desktop/application-command-client.js +21 -0
  66. package/dist/desktop/channel-handshake.d.ts +32 -0
  67. package/dist/desktop/channel-handshake.js +111 -0
  68. package/dist/desktop/channel-proof.d.ts +43 -0
  69. package/dist/desktop/channel-proof.js +85 -0
  70. package/dist/desktop/client-assets.d.ts +7 -0
  71. package/dist/desktop/client-assets.js +59 -0
  72. package/dist/desktop/desktop-client.d.ts +23 -0
  73. package/dist/desktop/desktop-client.js +231 -0
  74. package/dist/desktop/desktop-gateway.d.ts +18 -0
  75. package/dist/desktop/desktop-gateway.js +146 -0
  76. package/dist/desktop/desktop-host.d.ts +48 -0
  77. package/dist/desktop/desktop-host.js +208 -0
  78. package/dist/desktop/desktop-stream.d.ts +36 -0
  79. package/dist/desktop/desktop-stream.js +231 -0
  80. package/dist/desktop/loopback-policy.d.ts +19 -0
  81. package/dist/desktop/loopback-policy.js +23 -0
  82. package/dist/desktop/open-url-channel.d.ts +15 -0
  83. package/dist/desktop/open-url-channel.js +55 -0
  84. package/dist/desktop/string-policy.d.ts +2 -0
  85. package/dist/desktop/string-policy.js +11 -0
  86. package/dist/framework-source.json +1 -0
  87. package/dist/installer/archive-entry.d.ts +6 -0
  88. package/dist/installer/archive-entry.js +14 -0
  89. package/dist/installer/command-artifact.d.ts +47 -0
  90. package/dist/installer/command-artifact.js +261 -0
  91. package/dist/installer/command-qualification-command.d.ts +12 -0
  92. package/dist/installer/command-qualification-command.js +71 -0
  93. package/dist/installer/hosted-runner.d.ts +4 -0
  94. package/dist/installer/hosted-runner.js +10 -0
  95. package/dist/installer/installed-payload.d.ts +29 -0
  96. package/dist/installer/installed-payload.js +312 -0
  97. package/dist/installer/installer-ci-bootstrap.d.ts +26 -0
  98. package/dist/installer/installer-ci-bootstrap.js +160 -0
  99. package/dist/installer/installer-ci-preflight.d.ts +1 -0
  100. package/dist/installer/installer-ci-preflight.js +49 -0
  101. package/dist/installer/installer-ci-worker.d.ts +1 -0
  102. package/dist/installer/installer-ci-worker.js +105 -0
  103. package/dist/installer/installer-extraction.d.ts +14 -0
  104. package/dist/installer/installer-extraction.js +289 -0
  105. package/dist/installer/installer-fetch-guard.d.ts +15 -0
  106. package/dist/installer/installer-fetch-guard.js +50 -0
  107. package/dist/installer/installer-identity.d.ts +23 -0
  108. package/dist/installer/installer-identity.js +286 -0
  109. package/dist/installer/installer-layout.d.ts +21 -0
  110. package/dist/installer/installer-layout.js +89 -0
  111. package/dist/installer/installer-observation.d.ts +64 -0
  112. package/dist/installer/installer-observation.js +473 -0
  113. package/dist/installer/installer-process-cleanup.d.ts +18 -0
  114. package/dist/installer/installer-process-cleanup.js +158 -0
  115. package/dist/installer/installer-qualification-command.d.ts +11 -0
  116. package/dist/installer/installer-qualification-command.js +71 -0
  117. package/dist/installer/installer-renderer-evidence.d.ts +43 -0
  118. package/dist/installer/installer-renderer-evidence.js +136 -0
  119. package/dist/installer/installer-upgrade-command.d.ts +37 -0
  120. package/dist/installer/installer-upgrade-command.js +172 -0
  121. package/dist/installer/installer-worker-guard.d.ts +21 -0
  122. package/dist/installer/installer-worker-guard.js +72 -0
  123. package/dist/installer/native-executable.d.ts +5 -0
  124. package/dist/installer/native-executable.js +21 -0
  125. package/dist/installer/upgrade-asset-download.d.ts +13 -0
  126. package/dist/installer/upgrade-asset-download.js +41 -0
  127. package/dist/installer/write-all.d.ts +6 -0
  128. package/dist/installer/write-all.js +11 -0
  129. package/dist/native/app-bundle.d.ts +28 -0
  130. package/dist/native/app-bundle.js +60 -0
  131. package/dist/native/cef-helper.d.ts +28 -0
  132. package/dist/native/cef-helper.js +402 -0
  133. package/dist/native/desktop-build-hook.d.ts +7 -0
  134. package/dist/native/desktop-build-hook.js +20 -0
  135. package/dist/native/electrobun-source-patch.d.ts +25 -0
  136. package/dist/native/electrobun-source-patch.js +93 -0
  137. package/dist/native/linux-cef-links.d.ts +2 -0
  138. package/dist/native/linux-cef-links.js +15 -0
  139. package/dist/native/native-secret-store.d.ts +27 -0
  140. package/dist/native/native-secret-store.js +70 -0
  141. package/dist/native/native-utilities.d.ts +24 -0
  142. package/dist/native/native-utilities.js +85 -0
  143. package/dist/native/partitioned-window.d.ts +34 -0
  144. package/dist/native/partitioned-window.js +44 -0
  145. package/dist/native/renderer-profile.d.ts +53 -0
  146. package/dist/native/renderer-profile.js +30 -0
  147. package/dist/native/secure-window.d.ts +38 -0
  148. package/dist/native/secure-window.js +77 -0
  149. package/dist/native/sidecar-services.d.ts +23 -0
  150. package/dist/native/sidecar-services.js +46 -0
  151. package/dist/native/sidecar.d.ts +81 -0
  152. package/dist/native/sidecar.js +250 -0
  153. package/dist/native/window-bootstrap.d.ts +24 -0
  154. package/dist/native/window-bootstrap.js +63 -0
  155. package/dist/native/window-options.d.ts +32 -0
  156. package/dist/native/window-options.js +23 -0
  157. package/dist/native/windows-build-hook-internal.d.ts +2 -0
  158. package/dist/native/windows-build-hook-internal.js +32 -0
  159. package/dist/native/windows-build-hook.d.ts +2 -0
  160. package/dist/native/windows-build-hook.js +12 -0
  161. package/dist/native/windows-runtime-patch-internal.d.ts +3 -0
  162. package/dist/native/windows-runtime-patch-internal.js +20 -0
  163. package/dist/native/windows-runtime-patch.d.ts +4 -0
  164. package/dist/native/windows-runtime-patch.js +12 -0
  165. package/dist/release/feed-release-cut.d.ts +23 -0
  166. package/dist/release/feed-release-cut.js +93 -0
  167. package/dist/release/feed-state.d.ts +25 -0
  168. package/dist/release/feed-state.js +81 -0
  169. package/dist/release/framework-package-publish.d.ts +21 -0
  170. package/dist/release/framework-package-publish.js +127 -0
  171. package/dist/release/framework-update.d.ts +30 -0
  172. package/dist/release/framework-update.js +139 -0
  173. package/dist/release/github-cli.d.ts +6 -0
  174. package/dist/release/github-cli.js +16 -0
  175. package/dist/release/github-release-assets.d.ts +3 -0
  176. package/dist/release/github-release-assets.js +24 -0
  177. package/dist/release/github-release-cut.d.ts +14 -0
  178. package/dist/release/github-release-cut.js +174 -0
  179. package/dist/release/github-release-lookup.d.ts +7 -0
  180. package/dist/release/github-release-lookup.js +29 -0
  181. package/dist/release/github-release-promotion.d.ts +10 -0
  182. package/dist/release/github-release-promotion.js +78 -0
  183. package/dist/release/github-release-provenance.d.ts +9 -0
  184. package/dist/release/github-release-provenance.js +27 -0
  185. package/dist/release/github-release-publisher.d.ts +9 -0
  186. package/dist/release/github-release-publisher.js +63 -0
  187. package/dist/release/github-release-qualification.d.ts +12 -0
  188. package/dist/release/github-release-qualification.js +80 -0
  189. package/dist/release/local-provenance.d.ts +24 -0
  190. package/dist/release/local-provenance.js +72 -0
  191. package/dist/release/local-release.d.ts +133 -0
  192. package/dist/release/local-release.js +387 -0
  193. package/dist/release/macos-dmg.d.ts +22 -0
  194. package/dist/release/macos-dmg.js +91 -0
  195. package/dist/release/release-artifact.d.ts +6 -0
  196. package/dist/release/release-artifact.js +38 -0
  197. package/dist/release/release-assets-plan.d.ts +14 -0
  198. package/dist/release/release-assets-plan.js +65 -0
  199. package/dist/release/release-config.d.ts +76 -0
  200. package/dist/release/release-config.js +180 -0
  201. package/dist/release/release-cut-command.d.ts +13 -0
  202. package/dist/release/release-cut-command.js +39 -0
  203. package/dist/release/release-cut.d.ts +54 -0
  204. package/dist/release/release-cut.js +76 -0
  205. package/dist/release/release-descriptor-staging.d.ts +34 -0
  206. package/dist/release/release-descriptor-staging.js +147 -0
  207. package/dist/release/release-finalize.d.ts +16 -0
  208. package/dist/release/release-finalize.js +104 -0
  209. package/dist/release/release-promotion-command.d.ts +12 -0
  210. package/dist/release/release-promotion-command.js +28 -0
  211. package/dist/release/release-promotion.d.ts +29 -0
  212. package/dist/release/release-promotion.js +57 -0
  213. package/dist/release/release-publication.d.ts +33 -0
  214. package/dist/release/release-publication.js +138 -0
  215. package/dist/release/release-publish-command.d.ts +7 -0
  216. package/dist/release/release-publish-command.js +91 -0
  217. package/dist/release/release-qualification.d.ts +106 -0
  218. package/dist/release/release-qualification.js +135 -0
  219. package/dist/release/release-staging.d.ts +9 -0
  220. package/dist/release/release-staging.js +61 -0
  221. package/dist/release/release-steps.d.ts +38 -0
  222. package/dist/release/release-steps.js +147 -0
  223. package/dist/release/retained-release-build.d.ts +19 -0
  224. package/dist/release/retained-release-build.js +122 -0
  225. package/dist/shell/app-shell.d.ts +61 -0
  226. package/dist/shell/app-shell.js +306 -0
  227. package/dist/shell/app-utilities.d.ts +122 -0
  228. package/dist/shell/app-utilities.js +334 -0
  229. package/dist/shell/application-menu-commands.d.ts +5 -0
  230. package/dist/shell/application-menu-commands.js +11 -0
  231. package/dist/shell/application-menu.d.ts +61 -0
  232. package/dist/shell/application-menu.js +208 -0
  233. package/dist/shell/help-shortcuts.d.ts +12 -0
  234. package/dist/shell/help-shortcuts.js +22 -0
  235. package/dist/shell/navigation-drawer.d.ts +12 -0
  236. package/dist/shell/navigation-drawer.js +42 -0
  237. package/dist/shell/settings-sections.d.ts +31 -0
  238. package/dist/shell/settings-sections.js +50 -0
  239. package/dist/shell/shortcut-platform.d.ts +17 -0
  240. package/dist/shell/shortcut-platform.js +25 -0
  241. package/dist/update-helper.bundle.js +260 -0
  242. package/dist/updates/channel-update-manager.d.ts +46 -0
  243. package/dist/updates/channel-update-manager.js +114 -0
  244. package/dist/updates/desktop-updater.d.ts +104 -0
  245. package/dist/updates/desktop-updater.js +345 -0
  246. package/dist/updates/release-feed.d.ts +61 -0
  247. package/dist/updates/release-feed.js +111 -0
  248. package/dist/updates/release-location.d.ts +9 -0
  249. package/dist/updates/release-location.js +80 -0
  250. package/dist/updates/release-version.d.ts +12 -0
  251. package/dist/updates/release-version.js +43 -0
  252. package/dist/updates/signed-release.d.ts +63 -0
  253. package/dist/updates/signed-release.js +162 -0
  254. package/dist/updates/stable-file.d.ts +10 -0
  255. package/dist/updates/stable-file.js +22 -0
  256. package/dist/updates/update-adapter.d.ts +57 -0
  257. package/dist/updates/update-adapter.js +72 -0
  258. package/dist/updates/update-arm.d.ts +24 -0
  259. package/dist/updates/update-arm.js +95 -0
  260. package/dist/updates/update-channel-store.d.ts +8 -0
  261. package/dist/updates/update-channel-store.js +72 -0
  262. package/dist/updates/update-discovery.d.ts +13 -0
  263. package/dist/updates/update-discovery.js +56 -0
  264. package/dist/updates/update-download.d.ts +14 -0
  265. package/dist/updates/update-download.js +67 -0
  266. package/dist/updates/update-exclusive-rename.d.ts +2 -0
  267. package/dist/updates/update-exclusive-rename.js +52 -0
  268. package/dist/updates/update-extraction.d.ts +18 -0
  269. package/dist/updates/update-extraction.js +183 -0
  270. package/dist/updates/update-handoff-plan.d.ts +22 -0
  271. package/dist/updates/update-handoff-plan.js +28 -0
  272. package/dist/updates/update-helper.d.ts +24 -0
  273. package/dist/updates/update-helper.js +56 -0
  274. package/dist/updates/update-launch.d.ts +5 -0
  275. package/dist/updates/update-launch.js +27 -0
  276. package/dist/updates/update-manager.d.ts +40 -0
  277. package/dist/updates/update-manager.js +83 -0
  278. package/dist/updates/update-process-fence.d.ts +10 -0
  279. package/dist/updates/update-process-fence.js +114 -0
  280. package/dist/updates/update-resume.d.ts +13 -0
  281. package/dist/updates/update-resume.js +34 -0
  282. package/dist/updates/update-shutdown.d.ts +15 -0
  283. package/dist/updates/update-shutdown.js +29 -0
  284. package/dist/updates/update-state.d.ts +30 -0
  285. package/dist/updates/update-state.js +18 -0
  286. package/dist/updates/update-swap-stage.d.ts +27 -0
  287. package/dist/updates/update-swap-stage.js +58 -0
  288. package/dist/updates/update-swap.d.ts +10 -0
  289. package/dist/updates/update-swap.js +30 -0
  290. package/dist/views/app-about.d.ts +22 -0
  291. package/dist/views/app-about.js +43 -0
  292. package/dist/views/app-appearance.d.ts +11 -0
  293. package/dist/views/app-appearance.js +42 -0
  294. package/dist/views/app-help.d.ts +17 -0
  295. package/dist/views/app-help.js +42 -0
  296. package/dist/views/app-settings.d.ts +26 -0
  297. package/dist/views/app-settings.js +97 -0
  298. package/dist/views/appearance-surface.d.ts +9 -0
  299. package/dist/views/appearance-surface.js +334 -0
  300. package/dist/views/update-surface.d.ts +34 -0
  301. package/dist/views/update-surface.js +64 -0
  302. package/package.json +374 -4
  303. package/src/app/application.tsx +138 -0
  304. package/src/appearance/appearance-host.tsx +205 -0
  305. package/src/appearance/appearance-preferences.ts +287 -0
  306. package/src/appearance/composition.ts +29 -0
  307. package/src/appearance/custom-theme-import.ts +424 -0
  308. package/src/appearance/custom-theme-library.ts +600 -0
  309. package/src/appearance/editor.ts +94 -0
  310. package/src/appearance/theme-file-importer.ts +103 -0
  311. package/src/appearance/theme-record-adapter.ts +106 -0
  312. package/src/appearance/theme-registry.ts +20 -0
  313. package/src/appearance/window-surface.ts +18 -0
  314. package/src/desktop/client-assets.ts +75 -0
  315. package/src/native/electrobun-cef-main-frame-bridges.patch +63 -0
  316. package/src/native/electrobun-windows-shortcut-com.patch +923 -0
  317. package/src/native/renderer-profile.ts +27 -0
  318. package/src/native/window-options.ts +24 -0
  319. package/src/shell/app-shell.tsx +294 -0
  320. package/src/shell/app-utilities.tsx +437 -0
  321. package/src/shell/help-shortcuts.ts +24 -0
  322. package/src/shell/navigation-drawer.tsx +36 -0
  323. package/src/shell/settings-sections.ts +74 -0
  324. package/src/shell/shortcut-platform.ts +35 -0
  325. package/src/updates/release-version.ts +57 -0
  326. package/src/updates/update-adapter.ts +129 -0
  327. package/src/updates/update-state.ts +34 -0
  328. package/src/views/app-about.tsx +44 -0
  329. package/src/views/app-appearance.tsx +32 -0
  330. package/src/views/app-help.tsx +43 -0
  331. package/src/views/app-settings.tsx +88 -0
  332. package/src/views/appearance-surface.tsx +427 -0
  333. package/src/views/update-surface.tsx +85 -0
  334. package/templates/application/.gitattributes +1 -0
  335. package/templates/application/.github/workflows/release-assets.yml +29 -0
  336. package/templates/application/.github/workflows/release-finalize.yml +29 -0
  337. package/templates/application/.github/workflows/release-please.yml +19 -0
  338. package/templates/application/.github/workflows/release.yml +29 -0
  339. package/templates/application/.github/workflows/validation.yml +28 -0
  340. package/templates/application/.oxfmtrc.json +6 -0
  341. package/templates/application/.oxlintrc.json +48 -0
  342. package/templates/application/.release-please-manifest.json +3 -0
  343. package/templates/application/README.md +47 -0
  344. package/templates/application/electrobun.config.ts +22 -0
  345. package/templates/application/release-please-config.json +12 -0
  346. package/templates/application/scripts/app-version.ts +9 -0
  347. package/templates/application/scripts/build-desktop.ts +34 -0
  348. package/templates/application/scripts/secure-build.ts +1 -0
  349. package/templates/application/scripts/stage-release.ts +21 -0
  350. package/templates/application/src/bun/index.ts +80 -0
  351. package/templates/application/src/electrobun.d.ts +27 -0
  352. package/templates/application/src/web/index.html +12 -0
  353. package/templates/application/src/web/main.tsx +97 -0
  354. package/templates/application/src/web/public/icon.svg +1 -0
  355. package/templates/application/src/web/style.css +3 -0
  356. package/templates/application/tests/app-config.test.ts +9 -0
  357. package/templates/application/tsconfig.json +15 -0
  358. package/templates/application/vite.config.ts +10 -0
@@ -0,0 +1,76 @@
1
+ import { type Requirements } from './release-qualification';
2
+ import { type ReleaseFeed } from '../updates/release-feed';
3
+ /** The descriptor target each release platform publishes for. */
4
+ export declare const platformTargets: {
5
+ readonly 'macos-arm64': readonly ['darwin', 'arm64'];
6
+ readonly 'windows-x64': readonly ['win32', 'x64'];
7
+ readonly 'linux-x64': readonly ['linux', 'x64'];
8
+ };
9
+ export type ReleasePlatform = keyof typeof platformTargets;
10
+ /**
11
+ * A portable command-line payload published beside the desktop payloads: a `.tar.gz` holding one
12
+ * directory named after the asset, with `bin/<executable>` (`bin/<executable>.cmd` on Windows).
13
+ * The build leaves that directory's contents at `build`, relative to the app directory.
14
+ */
15
+ export type CommandArtifactPolicy = Readonly<{
16
+ kind: string;
17
+ /** Update identity its signed descriptors carry; distinct from the desktop app's. */
18
+ appId: string;
19
+ executable: string;
20
+ build: string;
21
+ /** Release asset name template for each release platform. */
22
+ platforms: Readonly<Record<ReleasePlatform, string>>;
23
+ qualification: Readonly<{
24
+ /** Extra environment for every qualification command. */
25
+ env: Readonly<Record<string, string>>;
26
+ /** Argument lists that must each exit 0 after `--version` prints the release version. */
27
+ probes: readonly (readonly string[])[];
28
+ /** The long-running command started, observed alive, then stopped. */
29
+ service: readonly string[];
30
+ }>;
31
+ }>;
32
+ /** Caller workflows whose runs the release CLIs accept as provenance. */
33
+ export type ReleaseWorkflows = {
34
+ control: string;
35
+ assets: string;
36
+ };
37
+ /** The file name GitHub's workflow APIs and `gh workflow run` address a workflow by. */
38
+ export declare const workflowFile: (path: string) => string;
39
+ /** Validate shared daily, dev and stable asset requirements. */
40
+ export declare function parseReleaseConfig(config: unknown): {
41
+ soakHours: number;
42
+ expectedReads: readonly string[];
43
+ versionSource: {
44
+ kind: 'source-manifest';
45
+ path: string;
46
+ };
47
+ releasePleaseManifestPath: string;
48
+ /** Sidecar executables every packaged payload must contain. */
49
+ sidecars: readonly string[];
50
+ releaseWorkflows: ReleaseWorkflows;
51
+ /** The HTTPS feed releases are published to and discovered from. */
52
+ feed: ReleaseFeed;
53
+ commandArtifacts: readonly CommandArtifactPolicy[];
54
+ requirements(tag: string): Requirements;
55
+ };
56
+ /** Every payload and release asset a release's requirements name, desktop payloads first. */
57
+ export declare function releaseAssetNames(requirements: Requirements): string[];
58
+ /** The payloads one platform's build stages: its installer and archive, then its command artifacts. */
59
+ export declare function platformPayloads(requirements: Requirements, platform: string): string[];
60
+ export type DiscoveryPolicy = Readonly<{
61
+ /** Discovery asset name for this tag. */
62
+ name: string;
63
+ channel: 'dev' | 'daily' | 'stable';
64
+ platform: ReleasePlatform;
65
+ os: (typeof platformTargets)[ReleasePlatform][0];
66
+ arch: (typeof platformTargets)[ReleasePlatform][1];
67
+ /** The update identity the descriptor carries. */
68
+ appId: string;
69
+ /** The one payload the descriptor may name. */
70
+ payload: string;
71
+ }>;
72
+ /**
73
+ * Resolve the channel descriptors a tag publishes: one per channel, payload kind (the desktop
74
+ * archive and each command artifact) and platform, each naming exactly that payload.
75
+ */
76
+ export declare function discoveryPolicies(config: unknown, tag: string): DiscoveryPolicy[];
@@ -0,0 +1,180 @@
1
+ import { containsAsciiControl } from "../desktop/string-policy.js";
2
+ import { assertSidecarNames } from "../native/app-bundle.js";
3
+ import { parseOfflinePolicy } from "./release-qualification.js";
4
+ import { parseReleaseFeed } from "../updates/release-feed.js";
5
+ // src/release/release-config.ts
6
+ var object = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
7
+ var strings = (value) => Array.isArray(value) && value.length > 0 && value.every((item) => typeof item === "string" && item.length <= 200 && /^[A-Za-z0-9][A-Za-z0-9._{}-]*$/.test(item) && !item.replaceAll("{tag}", "").includes("{") && !item.replaceAll("{tag}", "").includes("}")) && new Set(value).size === value.length;
8
+ var appIdPattern = /^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)+$/;
9
+ var token = (value) => typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9._=-]{0,63}$/.test(value);
10
+ var tokens = (value, minimum) => Array.isArray(value) && value.length >= minimum && value.length <= 8 && value.every(token);
11
+ var relativePath = (value) => typeof value === "string" && value.length <= 200 && /^[A-Za-z0-9._/-]+$/.test(value) && value.split("/").every((part) => part !== "" && part !== "." && part !== "..");
12
+ /** The descriptor target each release platform publishes for. */
13
+ var platformTargets = {
14
+ "macos-arm64": ["darwin", "arm64"],
15
+ "windows-x64": ["win32", "x64"],
16
+ "linux-x64": ["linux", "x64"]
17
+ };
18
+ var releasePlatforms = Object.keys(platformTargets);
19
+ function parseCommandArtifacts(value, platforms) {
20
+ if (value === void 0) return [];
21
+ if (!object(value) || Object.keys(value).length > 4) throw new Error("Invalid command artifacts");
22
+ return Object.entries(value).map(([kind, policy]) => {
23
+ const qualification = object(policy) ? policy.qualification : void 0;
24
+ const env = object(qualification) ? qualification.env : void 0;
25
+ if (!/^[a-z][a-z0-9-]{0,31}$/.test(kind) || !object(policy) || Object.keys(policy).length !== 5 || typeof policy.appId !== "string" || policy.appId.length > 255 || !appIdPattern.test(policy.appId) || typeof policy.executable !== "string" || !/^[a-z][a-z0-9-]{0,63}$/.test(policy.executable) || !relativePath(policy.build) || !object(policy.platforms) || Object.keys(policy.platforms).length !== platforms.length || platforms.some((platform) => typeof policy.platforms[platform] !== "string" || !strings([policy.platforms[platform]]) || !policy.platforms[platform].endsWith(".tar.gz")) || !object(qualification) || Object.keys(qualification).length !== 3 || !object(env) || Object.keys(env).length > 16 || Object.entries(env).some(([name, item]) => !/^[A-Z][A-Z0-9_]{0,63}$/.test(name) || /^(?:PATH|HOME|USERPROFILE|TMP|TEMP|TMPDIR|SYSTEMROOT|WINDIR|COMSPEC|PATHEXT|LOCALAPPDATA|APPDATA|XDG_[A-Z_]+)$/.test(name) || typeof item !== "string" || item.length > 256 || containsAsciiControl(item)) || !Array.isArray(qualification.probes) || qualification.probes.length > 8 || !qualification.probes.every((probe) => tokens(probe, 1)) || !tokens(qualification.service, 1)) throw new Error("Invalid command artifact");
26
+ return {
27
+ kind,
28
+ appId: policy.appId,
29
+ executable: policy.executable,
30
+ build: policy.build,
31
+ platforms: Object.fromEntries(platforms.map((platform) => [platform, policy.platforms[platform]])),
32
+ qualification: {
33
+ env: { ...env },
34
+ probes: qualification.probes.map((probe) => [...probe]),
35
+ service: [...qualification.service]
36
+ }
37
+ };
38
+ });
39
+ }
40
+ var workflowDirectory = ".github/workflows/";
41
+ /** The file name GitHub's workflow APIs and `gh workflow run` address a workflow by. */
42
+ var workflowFile = (path) => path.slice(18);
43
+ var workflowPath = (value) => typeof value === "string" && value.length <= 200 && value.startsWith(workflowDirectory) && /^[A-Za-z0-9][A-Za-z0-9._-]*\.ya?ml$/.test(workflowFile(value));
44
+ /** Validate shared daily, dev and stable asset requirements. */
45
+ function parseReleaseConfig(config) {
46
+ if (!object(config) || !object(config.platforms) || !strings(config.releaseAssets) || !strings(config.dailyDiscoveryAssets) || !strings(config.stableDiscoveryAssets) || !strings(config.devDiscoveryAssets) || !Number.isSafeInteger(config.soakHours) || Number(config.soakHours) < 0 || Number(config.soakHours) > 8760) throw new Error("Invalid release configuration");
47
+ const workflows = config.releaseWorkflows;
48
+ if (!object(workflows) || Object.keys(workflows).length !== 2 || !workflowPath(workflows.control) || !workflowPath(workflows.assets) || workflows.control === workflows.assets) throw new Error("Invalid release workflows");
49
+ const releaseWorkflows = {
50
+ control: workflows.control,
51
+ assets: workflows.assets
52
+ };
53
+ const feed = parseReleaseFeed(config.releaseFeed);
54
+ let sidecars;
55
+ try {
56
+ sidecars = assertSidecarNames(config.sidecars ?? []);
57
+ } catch {
58
+ throw new Error("Invalid release sidecars");
59
+ }
60
+ const offlinePolicy = config.offlinePolicy === void 0 ? void 0 : parseOfflinePolicy(config.offlinePolicy);
61
+ const source = config.versionSource;
62
+ if (!object(source) || Object.keys(source).length !== 2 || source.kind !== "source-manifest" || typeof source.path !== "string" || source.path.length > 200 || !/^[A-Za-z0-9._/-]+\.json$/.test(source.path) || source.path.startsWith("/") || !source.path.split("/").every((part) => part !== "" && part !== "." && part !== "..")) throw new Error("Invalid release version source");
63
+ const versionSource = {
64
+ kind: "source-manifest",
65
+ path: source.path
66
+ };
67
+ const releasePleaseManifestPath = source.path;
68
+ const expectedReads = config.offlineExpectedReads === void 0 ? [] : config.offlineExpectedReads;
69
+ if (!Array.isArray(expectedReads) || expectedReads.length > 32 || new Set(expectedReads).size !== expectedReads.length || JSON.stringify(expectedReads).length > 8192) throw new Error("Invalid offline expected reads");
70
+ for (const item of expectedReads) {
71
+ if (typeof item !== "string" || item.length > 2048) throw new Error("Invalid offline expected read");
72
+ let url;
73
+ try {
74
+ url = new URL(item);
75
+ } catch {
76
+ throw new Error("Invalid offline expected read");
77
+ }
78
+ if (url.protocol !== "https:" || url.username || url.password || url.hash || url.href !== item) throw new Error("Invalid offline expected read");
79
+ }
80
+ const platforms = config.platforms;
81
+ for (const required of releasePlatforms) if (!Object.hasOwn(platforms, required)) throw new Error("Releases require all supported desktop platforms");
82
+ for (const [platform, assets] of Object.entries(platforms)) if (!/^[a-z0-9-]+$/.test(platform) || !strings(assets)) throw new Error("Invalid release platform configuration");
83
+ const platformSnapshot = Object.fromEntries(Object.entries(platforms).map(([platform, assets]) => [platform, [...assets]]));
84
+ const commandArtifacts = parseCommandArtifacts(config.commandArtifacts, Object.keys(platforms));
85
+ const appIds = [config.appId, ...commandArtifacts.map((artifact) => artifact.appId)];
86
+ if (new Set(appIds).size !== appIds.length) throw new Error("Command artifacts need their own update identity");
87
+ const releaseAssets = [...config.releaseAssets];
88
+ const daily = [...config.dailyDiscoveryAssets];
89
+ const stable = [...config.stableDiscoveryAssets];
90
+ const dev = [...config.devDiscoveryAssets];
91
+ if (daily.some((name) => !releaseAssets.includes(name) || stable.includes(name) || dev.includes(name)) || stable.some((name) => !releaseAssets.includes(name) || dev.includes(name)) || dev.some((name) => !releaseAssets.includes(name))) throw new Error("Daily, stable and dev discovery assets must be distinct release assets");
92
+ const requirements = (tag) => {
93
+ if (!/^v\d+\.\d+\.\d+(?:-dev\.\d+)?$/.test(tag) || tag.length > 65) throw new Error("Invalid release tag");
94
+ const isDev = tag.includes("-dev.");
95
+ const selectedAssets = releaseAssets.filter((name) => isDev ? !daily.includes(name) && !stable.includes(name) : !dev.includes(name));
96
+ const substitute = (value) => value.replaceAll("{tag}", tag);
97
+ const result = {
98
+ platforms: Object.fromEntries(Object.entries(platformSnapshot).map(([platform, assets]) => [platform, assets.map(substitute)])),
99
+ releaseAssets: selectedAssets.map(substitute),
100
+ ...offlinePolicy ? { offlinePolicy: { ...offlinePolicy } } : {},
101
+ ...commandArtifacts.length ? { commandArtifacts: Object.fromEntries(commandArtifacts.map((artifact) => [artifact.kind, Object.fromEntries(Object.entries(artifact.platforms).map(([platform, name]) => [platform, substitute(name)]))])) } : {}
102
+ };
103
+ const names = releaseAssetNames(result);
104
+ if (new Set(names).size !== names.length || names.some((name) => !/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(name))) throw new Error("Invalid or duplicate release asset names");
105
+ return result;
106
+ };
107
+ requirements("v1.0.0");
108
+ return {
109
+ soakHours: config.soakHours,
110
+ expectedReads: [...expectedReads],
111
+ versionSource,
112
+ releasePleaseManifestPath,
113
+ sidecars,
114
+ releaseWorkflows,
115
+ feed,
116
+ commandArtifacts,
117
+ requirements
118
+ };
119
+ }
120
+ /** Every payload and release asset a release's requirements name, desktop payloads first. */
121
+ function releaseAssetNames(requirements) {
122
+ return [
123
+ ...Object.values(requirements.platforms).flat(),
124
+ ...Object.values(requirements.commandArtifacts ?? {}).flatMap((byPlatform) => Object.values(byPlatform)),
125
+ ...requirements.releaseAssets
126
+ ];
127
+ }
128
+ /** The payloads one platform's build stages: its installer and archive, then its command artifacts. */
129
+ function platformPayloads(requirements, platform) {
130
+ return [...requirements.platforms[platform] ?? [], ...Object.values(requirements.commandArtifacts ?? {}).map((byPlatform) => {
131
+ const name = byPlatform[platform];
132
+ if (!name) throw new Error("Command artifact is missing a platform");
133
+ return name;
134
+ })];
135
+ }
136
+ /**
137
+ * Resolve the channel descriptors a tag publishes: one per channel, payload kind (the desktop
138
+ * archive and each command artifact) and platform, each naming exactly that payload.
139
+ */
140
+ function discoveryPolicies(config, tag) {
141
+ const parsed = parseReleaseConfig(config);
142
+ const requirements = parsed.requirements(tag);
143
+ if (!object(config) || typeof config.appId !== "string" || config.appId.length > 255 || !appIdPattern.test(config.appId) || !object(config.descriptors)) throw new Error("Invalid discovery policy");
144
+ const descriptors = config.descriptors;
145
+ const kinds = [{
146
+ appId: config.appId,
147
+ payloads: (platform) => requirements.platforms[platform][1]
148
+ }, ...parsed.commandArtifacts.map((artifact) => ({
149
+ appId: artifact.appId,
150
+ payloads: (platform) => requirements.commandArtifacts[artifact.kind][platform]
151
+ }))];
152
+ const channels = tag.includes("-dev.") ? ["dev"] : ["daily", "stable"];
153
+ const result = [];
154
+ for (const channel of channels) {
155
+ const configured = config[`${channel}DiscoveryAssets`];
156
+ if (!Array.isArray(configured)) throw new Error("Invalid discovery policy");
157
+ for (const template of configured) {
158
+ const policy = typeof template === "string" ? descriptors[template] : void 0;
159
+ const platform = object(policy) ? releasePlatforms.find((value) => policy.platform === platformTargets[value][0] && policy.arch === platformTargets[value][1]) : void 0;
160
+ const payload = object(policy) && Array.isArray(policy.allowedPayloads) && policy.allowedPayloads.length === 1 && typeof policy.allowedPayloads[0] === "string" ? policy.allowedPayloads[0].replaceAll("{tag}", tag) : void 0;
161
+ const kind = platform && kinds.find((value) => value.payloads(platform) === payload);
162
+ const name = template.replaceAll("{tag}", tag);
163
+ if (!object(policy) || policy.channel !== channel || !platform || !kind || !payload || !requirements.releaseAssets.includes(name)) throw new Error("Invalid discovery policy");
164
+ if (result.some((value) => value.name === name || value.channel === channel && value.appId === kind.appId && value.platform === platform)) throw new Error("Duplicate discovery policy");
165
+ const [os, arch] = platformTargets[platform];
166
+ result.push({
167
+ name,
168
+ channel,
169
+ platform,
170
+ os,
171
+ arch,
172
+ appId: kind.appId,
173
+ payload
174
+ });
175
+ }
176
+ for (const kind of kinds) for (const platform of releasePlatforms) if (!result.some((value) => value.channel === channel && value.appId === kind.appId && value.platform === platform)) throw new Error("Missing platform discovery policy");
177
+ }
178
+ return result;
179
+ }
180
+ export { discoveryPolicies, parseReleaseConfig, platformPayloads, platformTargets, releaseAssetNames, workflowFile };
@@ -0,0 +1,13 @@
1
+ /** Execute release cuts only from the recorded main-branch GitHub workflow. */
2
+ export declare function runReleaseCutCommand(options: {
3
+ env: Record<string, string | undefined>;
4
+ kind: 'dev' | 'daily';
5
+ appName: string;
6
+ config: unknown;
7
+ run?: (args: string[], input?: string) => Promise<string>;
8
+ git?: (args: string[]) => Promise<string>;
9
+ }): Promise<{
10
+ tag: string;
11
+ sourceSha: string;
12
+ status: 'qualified' | 'pending' | 'dispatched';
13
+ }>;
@@ -0,0 +1,39 @@
1
+ import { githubCli } from "./github-cli.js";
2
+ import { parseReleaseConfig, workflowFile } from "./release-config.js";
3
+ import { createGitHubReleaseCutProvider } from "./github-release-cut.js";
4
+ import { cutRelease } from "./release-cut.js";
5
+ import { readSourceVersion } from "./local-provenance.js";
6
+ import { execFile } from "node:child_process";
7
+ import { promisify } from "node:util";
8
+ // src/release/release-cut-command.ts
9
+ var execute = promisify(execFile);
10
+ /** Execute release cuts only from the recorded main-branch GitHub workflow. */
11
+ async function runReleaseCutCommand(options) {
12
+ const { env, kind } = options;
13
+ if (env.GITHUB_ACTIONS !== "true" || env.GITHUB_REF !== "refs/heads/main" || !env.GITHUB_REPOSITORY || !/^[a-f0-9]{40}$/.test(env.GITHUB_SHA ?? "") || !/^[1-9]\d{0,19}$/.test(env.GITHUB_RUN_ID ?? "") || !/^[1-9]\d{0,8}$/.test(env.GITHUB_RUN_ATTEMPT ?? "") || (kind === "daily" ? !["schedule", "workflow_dispatch"].includes(env.GITHUB_EVENT_NAME ?? "") : kind === "dev" ? !["push", "workflow_dispatch"].includes(env.GITHUB_EVENT_NAME ?? "") : true)) throw new Error("Release cut requires a trusted main workflow");
14
+ const { requirements, versionSource, releasePleaseManifestPath, releaseWorkflows } = parseReleaseConfig(options.config);
15
+ const run = options.run ?? githubCli();
16
+ const git = options.git ?? (async (args) => (await execute("git", args, { maxBuffer: 1048576 })).stdout.trim());
17
+ const repository = env.GITHUB_REPOSITORY;
18
+ const sourceSha = env.GITHUB_SHA;
19
+ const provider = createGitHubReleaseCutProvider({
20
+ repository,
21
+ appName: options.appName,
22
+ requirements,
23
+ assetsWorkflow: releaseWorkflows.assets,
24
+ releasePleaseManifestPath,
25
+ run
26
+ });
27
+ const workflow = JSON.parse(await run(["api", `repos/${repository}/actions/runs/${env.GITHUB_RUN_ID}`]));
28
+ if (String(workflow?.id) !== env.GITHUB_RUN_ID || String(workflow?.run_attempt) !== env.GITHUB_RUN_ATTEMPT || workflow?.head_sha !== sourceSha || workflow?.event !== env.GITHUB_EVENT_NAME || workflow?.path !== releaseWorkflows.control || workflow?.repository?.full_name !== repository) throw new Error("Release workflow provenance mismatch");
29
+ const assetsWorkflow = JSON.parse(await run(["api", `repos/${repository}/actions/workflows/${workflowFile(releaseWorkflows.assets)}`]));
30
+ if (assetsWorkflow?.path !== releaseWorkflows.assets || assetsWorkflow?.state !== "active") throw new Error("Release-assets workflow is unavailable");
31
+ const releasedVersion = await readSourceVersion(git, sourceSha, versionSource.path);
32
+ return cutRelease({
33
+ kind,
34
+ sourceSha,
35
+ releasedVersion,
36
+ provider
37
+ });
38
+ }
39
+ export { runReleaseCutCommand };
@@ -0,0 +1,54 @@
1
+ /** Release identity selection adapted from adea-ai/adea scripts/release-control.mjs,
2
+ * commit 6155d18941acbb14d9099bc2a33a50ee9683a068 (Apache-2.0). */
3
+ export type CutRelease = {
4
+ tag: string;
5
+ sourceSha: string;
6
+ kind: 'dev' | 'daily';
7
+ draft: boolean;
8
+ prerelease: boolean;
9
+ stageableDraft?: boolean;
10
+ };
11
+ export type ReleaseCutProvider = {
12
+ /** Return a release only after independently resolving its tag target and channel marker. */
13
+ find(tag: string): Promise<CutRelease | null>;
14
+ isMainAncestor(sha: string): Promise<boolean>;
15
+ /** Whether `newer` strictly descends from `older`. */
16
+ isAncestor(older: string, newer: string): Promise<boolean>;
17
+ /** Create a dev prerelease for the tag at the source commit. */
18
+ create(identity: Pick<CutRelease, 'tag' | 'sourceSha'>): Promise<void>;
19
+ qualification(release: CutRelease): Promise<'qualified' | 'not-qualified' | 'unknown'>;
20
+ pendingBuild(release: CutRelease): Promise<'pending' | 'idle' | 'unknown'>;
21
+ /** Inspect all existing dev releases of a dev version line; errors must fail closed. */
22
+ highestDevCounter(version: string): Promise<number>;
23
+ /** Check the actual Git tag even when no release exists. */
24
+ tagExists(tag: string): Promise<boolean>;
25
+ dispatch(tag: string): Promise<void>;
26
+ };
27
+ /**
28
+ * The version dev builds after `released` are numbered for: the next minor version.
29
+ * Release Please writes a version to the manifest only when it releases it, so the
30
+ * source manifest always names a released version (or the one its own commit
31
+ * releases). The next release is a patch or minor above it, or a new major, so dev
32
+ * builds of the next minor sort above the release they follow, and stay strictly
33
+ * increasing across a patch release, which leaves the next minor unchanged.
34
+ */
35
+ export declare function nextDevVersion(released: string): string;
36
+ /**
37
+ * Cut or repair a daily/dev release without moving an existing tag. A daily is the
38
+ * Release Please release `v<version>` of the source manifest's version. A dev build is
39
+ * `v<next>-dev.N` for the next unreleased version (see `nextDevVersion`), where N counts
40
+ * that version's dev releases from 1, so it starts again at 1 when a release moves the
41
+ * next version: `v0.112.0-dev.15` is followed, after the `v0.112.0` release, by
42
+ * `v0.113.0-dev.1`.
43
+ */
44
+ export declare function cutRelease(options: {
45
+ kind: 'dev' | 'daily';
46
+ sourceSha: string;
47
+ /** The version in the source manifest at the exact source commit: the latest release. */
48
+ releasedVersion: string;
49
+ provider: ReleaseCutProvider;
50
+ }): Promise<{
51
+ tag: string;
52
+ sourceSha: string;
53
+ status: 'qualified' | 'pending' | 'dispatched';
54
+ }>;
@@ -0,0 +1,76 @@
1
+ // src/release/release-cut.ts
2
+ /**
3
+ * The version dev builds after `released` are numbered for: the next minor version.
4
+ * Release Please writes a version to the manifest only when it releases it, so the
5
+ * source manifest always names a released version (or the one its own commit
6
+ * releases). The next release is a patch or minor above it, or a new major, so dev
7
+ * builds of the next minor sort above the release they follow, and stay strictly
8
+ * increasing across a patch release, which leaves the next minor unchanged.
9
+ */
10
+ function nextDevVersion(released) {
11
+ const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.exec(released);
12
+ if (!match) throw new Error("Invalid release identity");
13
+ return `${match[1]}.${BigInt(match[2]) + 1n}.0`;
14
+ }
15
+ /**
16
+ * Cut or repair a daily/dev release without moving an existing tag. A daily is the
17
+ * Release Please release `v<version>` of the source manifest's version. A dev build is
18
+ * `v<next>-dev.N` for the next unreleased version (see `nextDevVersion`), where N counts
19
+ * that version's dev releases from 1, so it starts again at 1 when a release moves the
20
+ * next version: `v0.112.0-dev.15` is followed, after the `v0.112.0` release, by
21
+ * `v0.113.0-dev.1`.
22
+ */
23
+ async function cutRelease(options) {
24
+ const { kind, sourceSha, releasedVersion, provider } = options;
25
+ if (!["daily", "dev"].includes(kind) || !/^[a-f0-9]{40}$/.test(sourceSha) || typeof releasedVersion !== "string" || releasedVersion.length > 48 || !/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/.test(releasedVersion)) throw new Error("Invalid release identity");
26
+ const version = kind === "dev" ? nextDevVersion(releasedVersion) : releasedVersion;
27
+ if (!await provider.isMainAncestor(sourceSha)) throw new Error("Requested source is not on main");
28
+ let count = 0;
29
+ if (kind === "dev") {
30
+ const highest = await provider.highestDevCounter(version);
31
+ if (!Number.isSafeInteger(highest) || highest < 0) throw new Error("Dev release history is invalid");
32
+ const newest = highest > 0 ? await provider.find(`v${version}-dev.${highest}`) : null;
33
+ if (highest > 0 && !newest) throw new Error("Dev release history changed");
34
+ if (newest && newest.sourceSha !== sourceSha && !await provider.isAncestor(newest.sourceSha, sourceSha)) throw new Error("Dev release source is not newer than the last dev release");
35
+ count = newest?.sourceSha === sourceSha ? highest : highest + 1;
36
+ }
37
+ const tag = `v${version}${kind === "dev" ? `-dev.${count}` : ""}`;
38
+ let release = await provider.find(tag);
39
+ if (!release) {
40
+ if (kind === "daily") throw new Error("Release Please has not released this version");
41
+ if (await provider.tagExists(tag)) throw new Error("Existing tag has no trusted release");
42
+ await provider.create({
43
+ tag,
44
+ sourceSha
45
+ });
46
+ release = await provider.find(tag);
47
+ }
48
+ if (!release || release.tag !== tag || release.kind !== kind || release.draft && !(kind === "daily" && release.stageableDraft === true) || !/^[a-f0-9]{40}$/.test(release.sourceSha) || kind === "dev" && release.sourceSha !== sourceSha || !await provider.isMainAncestor(release.sourceSha)) throw new Error("Existing release identity mismatch");
49
+ const qualification = await provider.qualification(release);
50
+ if (qualification === "qualified") return {
51
+ tag,
52
+ sourceSha: release.sourceSha,
53
+ status: "qualified"
54
+ };
55
+ if (qualification !== "not-qualified" || !(release.prerelease || release.draft && release.stageableDraft)) throw new Error("Release qualification is unknown or stable");
56
+ const pending = await provider.pendingBuild(release);
57
+ if (pending === "pending") return {
58
+ tag,
59
+ sourceSha: release.sourceSha,
60
+ status: "pending"
61
+ };
62
+ if (pending !== "idle") throw new Error("Release build state is unknown");
63
+ const current = await provider.find(tag);
64
+ if (!current || current.sourceSha !== release.sourceSha || current.kind !== kind || current.draft !== release.draft || (current.draft ? current.stageableDraft !== true : !current.prerelease) || !await provider.isMainAncestor(current.sourceSha)) throw new Error("Release changed before build dispatch");
65
+ if (kind === "dev") {
66
+ const latest = await provider.highestDevCounter(version);
67
+ if (!Number.isSafeInteger(latest) || latest !== count) throw new Error("Dev release history changed before dispatch");
68
+ }
69
+ await provider.dispatch(tag);
70
+ return {
71
+ tag,
72
+ sourceSha: release.sourceSha,
73
+ status: "dispatched"
74
+ };
75
+ }
76
+ export { cutRelease, nextDevVersion };
@@ -0,0 +1,34 @@
1
+ import { type KeyObject } from 'node:crypto';
2
+ import { type DiscoveryPolicy } from './release-config';
3
+ import { type Artifact, type ReleaseIdentity } from './release-qualification';
4
+ /** Sign and self-verify one descriptor per discovery policy, each naming its staged payload. */
5
+ export declare function signDiscoveryDescriptors(options: {
6
+ policies: readonly DiscoveryPolicy[];
7
+ assets: readonly Artifact[];
8
+ identity: ReleaseIdentity;
9
+ repository: string;
10
+ feed: string;
11
+ keyId: string;
12
+ publicKey: string;
13
+ privateKey: KeyObject;
14
+ }): {
15
+ name: string;
16
+ bytes: string;
17
+ }[];
18
+ /** Write descriptors beside the payloads, refusing to replace any existing file. */
19
+ export declare function writeDescriptors(directory: string, signed: readonly {
20
+ name: string;
21
+ bytes: string;
22
+ }[]): Promise<void>;
23
+ /** The configured public key for `keyId`, which must be the signing key's own. */
24
+ export declare function configuredSigningKey(config: Record<string, unknown>, keyId: string, privateKey: KeyObject): string;
25
+ /** Sign descriptors only for payloads verified by every installer and command artifact receipt. */
26
+ export declare function stageReleaseDescriptors(options: {
27
+ env: Record<string, string | undefined>;
28
+ config: unknown;
29
+ directory: string;
30
+ tag: string;
31
+ keyId: string;
32
+ privateKey: KeyObject;
33
+ run?: (args: string[], input?: string) => Promise<string>;
34
+ }): Promise<string[]>;
@@ -0,0 +1,147 @@
1
+ import { validateCommandReceipts, validateInstallerReceipt } from "./release-qualification.js";
2
+ import { signReleaseDescriptor, verifyReleaseDescriptor } from "../updates/signed-release.js";
3
+ import { feedUrl } from "../updates/release-feed.js";
4
+ import { discoveryPolicies, parseReleaseConfig, platformPayloads, platformTargets } from "./release-config.js";
5
+ import { planReleaseAssets } from "./release-assets-plan.js";
6
+ import { commandReceiptName } from "../installer/command-qualification-command.js";
7
+ import { lstat, open, readFile, writeFile } from "node:fs/promises";
8
+ import { join, resolve } from "node:path";
9
+ import { createHash, createPublicKey } from "node:crypto";
10
+ // src/release/release-descriptor-staging.ts
11
+ var object = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
12
+ async function staged(path, name) {
13
+ const info = await lstat(path);
14
+ if (!info.isFile() || info.isSymbolicLink() || !Number.isSafeInteger(info.size) || info.size < 1) throw new Error("Invalid staged payload");
15
+ const file = await open(path, "r");
16
+ try {
17
+ const before = await file.stat();
18
+ if (before.dev !== info.dev || before.ino !== info.ino || before.size !== info.size) throw new Error("Staged payload changed");
19
+ const hash = createHash("sha256");
20
+ let size = 0;
21
+ for await (const chunk of file.createReadStream({ autoClose: false })) {
22
+ size += chunk.length;
23
+ if (size > before.size) throw new Error("Staged payload changed");
24
+ hash.update(chunk);
25
+ }
26
+ const after = await file.stat();
27
+ if (size !== before.size || after.size !== before.size || after.mtimeMs !== before.mtimeMs || after.dev !== before.dev || after.ino !== before.ino) throw new Error("Staged payload changed");
28
+ return {
29
+ name,
30
+ size,
31
+ digest: "sha256:" + hash.digest("hex")
32
+ };
33
+ } finally {
34
+ await file.close();
35
+ }
36
+ }
37
+ /** Sign and self-verify one descriptor per discovery policy, each naming its staged payload. */
38
+ function signDiscoveryDescriptors(options) {
39
+ const { identity, repository, feed, keyId, privateKey } = options;
40
+ return options.policies.map((policy) => {
41
+ const payload = options.assets.find((value) => value.name === policy.payload);
42
+ if (!payload) throw new Error("Missing staged payload");
43
+ const descriptor = {
44
+ schema: 2,
45
+ appId: policy.appId,
46
+ repository,
47
+ channel: policy.channel,
48
+ ...identity,
49
+ version: identity.tag.slice(1),
50
+ platform: policy.os,
51
+ arch: policy.arch,
52
+ keyId,
53
+ asset: {
54
+ name: payload.name,
55
+ url: `${feed}${identity.tag}/${payload.name}`,
56
+ size: payload.size,
57
+ sha256: payload.digest.slice(7)
58
+ }
59
+ };
60
+ const value = signReleaseDescriptor(descriptor, privateKey);
61
+ if (!verifyReleaseDescriptor(value, {
62
+ appId: policy.appId,
63
+ repository,
64
+ channel: policy.channel,
65
+ platform: policy.os,
66
+ arch: policy.arch,
67
+ feed,
68
+ keys: /* @__PURE__ */ new Map([[keyId, options.publicKey]])
69
+ }).ok) throw new Error("Descriptor verification failed");
70
+ return {
71
+ name: policy.name,
72
+ bytes: JSON.stringify(value) + "\n"
73
+ };
74
+ });
75
+ }
76
+ /** Write descriptors beside the payloads, refusing to replace any existing file. */
77
+ async function writeDescriptors(directory, signed) {
78
+ for (const value of signed) try {
79
+ await lstat(join(directory, value.name));
80
+ throw new Error("Descriptor already exists");
81
+ } catch (error) {
82
+ if (error.code !== "ENOENT") throw error;
83
+ }
84
+ for (const value of signed) await writeFile(join(directory, value.name), value.bytes, {
85
+ flag: "wx",
86
+ mode: 384
87
+ });
88
+ }
89
+ /** The configured public key for `keyId`, which must be the signing key's own. */
90
+ function configuredSigningKey(config, keyId, privateKey) {
91
+ if (!object(config.releaseSigningKeys) || !/^[a-z0-9][a-z0-9._-]{0,63}$/.test(keyId) || privateKey.type !== "private" || privateKey.asymmetricKeyType !== "ed25519") throw new Error("Invalid descriptor signing context");
92
+ const encoded = config.releaseSigningKeys[keyId];
93
+ const publicKey = createPublicKey(privateKey).export({
94
+ type: "spki",
95
+ format: "der"
96
+ }).subarray(-32).toString("base64");
97
+ if (typeof encoded !== "string" || encoded !== publicKey) throw new Error("Signing key does not match configured trust");
98
+ return encoded;
99
+ }
100
+ async function receipt(path) {
101
+ const info = await lstat(path);
102
+ if (!info.isFile() || info.isSymbolicLink() || info.size < 1 || info.size > 262144) throw new Error("Invalid receipt");
103
+ const bytes = await readFile(path);
104
+ if (bytes.length !== info.size) throw new Error("Receipt changed");
105
+ return JSON.parse(bytes.toString("utf8"));
106
+ }
107
+ /** Sign descriptors only for payloads verified by every installer and command artifact receipt. */
108
+ async function stageReleaseDescriptors(options) {
109
+ const { env, config, tag, keyId, privateKey } = options;
110
+ const plan = await planReleaseAssets({
111
+ env,
112
+ config,
113
+ tag,
114
+ run: options.run
115
+ });
116
+ if (env.SOURCE_SHA !== plan.sourceSha || !object(config) || typeof config.appId !== "string" || !object(config.descriptors)) throw new Error("Invalid descriptor signing context");
117
+ const encoded = configuredSigningKey(config, keyId, privateKey);
118
+ const parsed = parseReleaseConfig(config), requirements = parsed.requirements(tag), feed = feedUrl(parsed.feed);
119
+ const policies = discoveryPolicies(config, tag);
120
+ const directory = resolve(options.directory), platforms = Object.keys(platformTargets);
121
+ if (Object.keys(requirements.platforms).length !== platforms.length || platforms.some((platform) => requirements.platforms[platform]?.length !== 2)) throw new Error("Invalid platform payload policy");
122
+ const names = platforms.flatMap((platform) => platformPayloads(requirements, platform));
123
+ const assets = await Promise.all(names.map((name) => staged(join(directory, name), name)));
124
+ const identity = {
125
+ tag,
126
+ sourceSha: plan.sourceSha,
127
+ workflowSha: plan.workflowSha,
128
+ runId: env.GITHUB_RUN_ID,
129
+ runAttempt: Number(env.GITHUB_RUN_ATTEMPT)
130
+ };
131
+ for (const platform of platforms) validateInstallerReceipt(identity, await receipt(join(directory, `installer-test-${platform}.json`)), platform, requirements.platforms[platform], assets, requirements.offlinePolicy);
132
+ validateCommandReceipts(identity, requirements.commandArtifacts ? await Promise.all(Object.keys(requirements.commandArtifacts).flatMap((kind) => platforms.map(async (platform) => await receipt(join(directory, commandReceiptName(kind, platform)))))) : void 0, requirements, assets);
133
+ const signed = signDiscoveryDescriptors({
134
+ policies,
135
+ assets,
136
+ identity,
137
+ repository: env.GITHUB_REPOSITORY,
138
+ feed,
139
+ keyId,
140
+ publicKey: encoded,
141
+ privateKey
142
+ });
143
+ for (const asset of assets) if (JSON.stringify(await staged(join(directory, asset.name), asset.name)) !== JSON.stringify(asset)) throw new Error("Staged payload changed before signing");
144
+ await writeDescriptors(directory, signed);
145
+ return signed.map((value) => value.name);
146
+ }
147
+ export { configuredSigningKey, signDiscoveryDescriptors, stageReleaseDescriptors, writeDescriptors };
@@ -0,0 +1,16 @@
1
+ /** Treat event payloads as hints; qualification independently checks the GitHub run. */
2
+ export declare function parseFinalizationEvent(event: unknown, repository: string, eventName?: string): {
3
+ tag: string;
4
+ runId: string;
5
+ runAttempt: number;
6
+ };
7
+ /** Publish an opted-in Release Please draft only after its exact asset workflow completed. */
8
+ export declare function finalizeReleasePleaseDraft(options: {
9
+ env: Record<string, string | undefined>;
10
+ config: unknown;
11
+ tag: string;
12
+ runId: string;
13
+ runAttempt: number;
14
+ run?: (args: string[], input?: string) => Promise<string>;
15
+ sleep?: (milliseconds: number) => Promise<unknown>;
16
+ }): Promise<void>;