@zyro-sec/app 0.0.0-stage → 1.0.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 (1360) hide show
  1. package/AGENTS.md +234 -0
  2. package/README.md +106 -2
  3. package/bunfig.toml +3 -0
  4. package/component-tests/activity-chips.spec.ts +47 -0
  5. package/component-tests/browser-pane-restore.spec.ts +1294 -0
  6. package/component-tests/browser-pane.spec.ts +2338 -0
  7. package/component-tests/browser-settings.spec.ts +315 -0
  8. package/component-tests/browser-site-chooser.spec.ts +628 -0
  9. package/component-tests/components-lab.spec.ts +24 -0
  10. package/component-tests/composer.spec.ts +876 -0
  11. package/component-tests/debug-bar.spec.ts +237 -0
  12. package/component-tests/dialog-popups.spec.ts +49 -0
  13. package/component-tests/file-icon.spec.ts +14 -0
  14. package/component-tests/focus-rescue.fixture.tsx +30 -0
  15. package/component-tests/focus-rescue.spec.ts +83 -0
  16. package/component-tests/focus-ring.spec.ts +112 -0
  17. package/component-tests/fork-dialog.spec.ts +61 -0
  18. package/component-tests/grow.fixture.tsx +42 -0
  19. package/component-tests/grow.spec.ts +74 -0
  20. package/component-tests/image-preview.spec.ts +157 -0
  21. package/component-tests/input-surfaces.spec.ts +351 -0
  22. package/component-tests/line-comment.spec.ts +118 -0
  23. package/component-tests/list.spec.ts +7 -0
  24. package/component-tests/model-picker.spec.ts +45 -0
  25. package/component-tests/new-session-wordmark.spec.ts +135 -0
  26. package/component-tests/open-in-border.spec.ts +18 -0
  27. package/component-tests/pairing.spec.ts +40 -0
  28. package/component-tests/panel-sidebar-side.spec.ts +103 -0
  29. package/component-tests/plugin-graph.spec.ts +61 -0
  30. package/component-tests/plugin-host.fixture.tsx +995 -0
  31. package/component-tests/plugin-host.spec.ts +2362 -0
  32. package/component-tests/presence.fixture.tsx +59 -0
  33. package/component-tests/presence.spec.ts +104 -0
  34. package/component-tests/session-containment.fixture.tsx +79 -0
  35. package/component-tests/session-containment.spec.ts +145 -0
  36. package/component-tests/session-location-missing.spec.ts +52 -0
  37. package/component-tests/session-question-dock.spec.ts +1655 -0
  38. package/component-tests/sources-experiment.spec.ts +98 -0
  39. package/component-tests/ssh-reconnect.spec.ts +97 -0
  40. package/component-tests/subagent-bar.spec.ts +29 -0
  41. package/component-tests/terminal.spec.ts +148 -0
  42. package/component-tests/timeline-detail.spec.ts +311 -0
  43. package/component-tests/timeline-virtualizer.fixture.tsx +272 -0
  44. package/component-tests/timeline-virtualizer.spec.ts +269 -0
  45. package/component-tests/toast.spec.ts +23 -0
  46. package/component-tests/tooltip.spec.ts +169 -0
  47. package/component-tests/websearch.spec.ts +86 -0
  48. package/e2e/AGENTS.md +25 -0
  49. package/e2e/QUARANTINE.md +12 -0
  50. package/e2e/regression/background-read-failure.spec.ts +43 -0
  51. package/e2e/regression/btw-sidebar.spec.ts +339 -0
  52. package/e2e/regression/command-palette.spec.ts +822 -0
  53. package/e2e/regression/composer.spec.ts +1727 -0
  54. package/e2e/regression/directory-picker.spec.ts +133 -0
  55. package/e2e/regression/home.spec.ts +779 -0
  56. package/e2e/regression/mcp-workspace-toggle.spec.ts +695 -0
  57. package/e2e/regression/menu-scrollbars.spec.ts +78 -0
  58. package/e2e/regression/mobile-composer-submit-focus.spec.ts +88 -0
  59. package/e2e/regression/mobile-model-pickers.spec.ts +433 -0
  60. package/e2e/regression/mobile-plugin-drawers.spec.ts +194 -0
  61. package/e2e/regression/mobile-plugins.spec.ts +309 -0
  62. package/e2e/regression/mobile-session-options.spec.ts +101 -0
  63. package/e2e/regression/mobile-session.spec.ts +442 -0
  64. package/e2e/regression/mobile-timeline-scroll.spec.ts +919 -0
  65. package/e2e/regression/multi-server.spec.ts +498 -0
  66. package/e2e/regression/new-session.spec.ts +1666 -0
  67. package/e2e/regression/panel-edges.spec.ts +79 -0
  68. package/e2e/regression/patch-border.spec.ts +69 -0
  69. package/e2e/regression/patch-sticky-header.spec.ts +320 -0
  70. package/e2e/regression/review.spec.ts +2397 -0
  71. package/e2e/regression/session-header.spec.ts +1020 -0
  72. package/e2e/regression/session-location-sync.spec.ts +412 -0
  73. package/e2e/regression/session-notice-truncation.spec.ts +92 -0
  74. package/e2e/regression/session-panel-scrollbar.spec.ts +46 -0
  75. package/e2e/regression/session-queue.spec.ts +1704 -0
  76. package/e2e/regression/session-request-docks.spec.ts +719 -0
  77. package/e2e/regression/session-summary.spec.ts +1092 -0
  78. package/e2e/regression/session-timeline-accessibility.spec.ts +216 -0
  79. package/e2e/regression/session-timeline-locale-projection.spec.ts +24 -0
  80. package/e2e/regression/session-timeline-reducer-projection.spec.ts +53 -0
  81. package/e2e/regression/session-timeline-tool-projection.spec.ts +94 -0
  82. package/e2e/regression/session-websearch-dock.spec.ts +122 -0
  83. package/e2e/regression/settings-search.spec.ts +516 -0
  84. package/e2e/regression/settings-wsl.spec.ts +433 -0
  85. package/e2e/regression/settings.spec.ts +2901 -0
  86. package/e2e/regression/shell-panel-spacing.spec.ts +95 -0
  87. package/e2e/regression/side-panels.spec.ts +524 -0
  88. package/e2e/regression/subagent-child-navigation.spec.ts +540 -0
  89. package/e2e/regression/tabs.spec.ts +3294 -0
  90. package/e2e/regression/terminal.spec.ts +691 -0
  91. package/e2e/regression/timeline-cache.spec.ts +798 -0
  92. package/e2e/regression/timeline-geometry.spec.ts +1204 -0
  93. package/e2e/regression/timeline-history.spec.ts +1073 -0
  94. package/e2e/regression/timeline-stream.spec.ts +3409 -0
  95. package/e2e/regression/whats-new.spec.ts +242 -0
  96. package/e2e/reproduction/timeline-suspense/index.html +34 -0
  97. package/e2e/reproduction/timeline-suspense/main.tsx +335 -0
  98. package/e2e/reproduction/timeline-suspense/playwright.config.ts +34 -0
  99. package/e2e/reproduction/timeline-suspense/timeline-suspense.repro.ts +182 -0
  100. package/e2e/reproduction/timeline-suspense/vite.config.ts +7 -0
  101. package/e2e/screenshots/session-project-menu.png +0 -0
  102. package/e2e/service-worker/cache.spec.ts +573 -0
  103. package/e2e/service-worker/playwright.config.ts +14 -0
  104. package/e2e/stability/README.md +61 -0
  105. package/e2e/stability/adverse.spec.ts +279 -0
  106. package/e2e/stability/environment-matrix.spec.ts +128 -0
  107. package/e2e/stability/file-matrix.spec.ts +133 -0
  108. package/e2e/stability/file-mutation.spec.ts +126 -0
  109. package/e2e/stability/fixture.test.ts +80 -0
  110. package/e2e/stability/interaction.spec.ts +232 -0
  111. package/e2e/stability/lifecycle.spec.ts +175 -0
  112. package/e2e/stability/oracle-browser.spec.ts +81 -0
  113. package/e2e/stability/oracle.test.ts +388 -0
  114. package/e2e/stability/playwright.config.ts +31 -0
  115. package/e2e/stability/scroll-interaction.spec.ts +520 -0
  116. package/e2e/stability/shell-matrix.spec.ts +299 -0
  117. package/e2e/stability/tool-mutation.spec.ts +58 -0
  118. package/e2e/stability/tools.spec.ts +232 -0
  119. package/e2e/stability/transition-matrix.spec.ts +214 -0
  120. package/e2e/tsconfig.json +11 -0
  121. package/e2e/user-story/model-selection-flow.spec.ts +216 -0
  122. package/e2e/utils/app-direction.fixture.tsx +105 -0
  123. package/e2e/utils/app-direction.html +25 -0
  124. package/e2e/utils/app.ts +227 -0
  125. package/e2e/utils/command-palette.ts +62 -0
  126. package/e2e/utils/console.ts +23 -0
  127. package/e2e/utils/direction.ts +28 -0
  128. package/e2e/utils/drafts.ts +52 -0
  129. package/e2e/utils/errors.ts +14 -0
  130. package/e2e/utils/markdown-sessions.ts +120 -0
  131. package/e2e/utils/mock-api.ts +570 -0
  132. package/e2e/utils/mock-server.ts +1726 -0
  133. package/e2e/utils/notifications.ts +51 -0
  134. package/e2e/utils/persistent-pty.ts +546 -0
  135. package/e2e/utils/prompt-motion.ts +116 -0
  136. package/e2e/utils/serve.ts +65 -0
  137. package/e2e/utils/session-fixture.ts +472 -0
  138. package/e2e/utils/settings-wsl.fixture.tsx +416 -0
  139. package/e2e/utils/settings-wsl.html +27 -0
  140. package/e2e/utils/side-panel.ts +41 -0
  141. package/e2e/utils/sse-transport.ts +352 -0
  142. package/e2e/utils/terminal.ts +31 -0
  143. package/e2e/utils/timeline.ts +1141 -0
  144. package/e2e/utils/visual-stability/analyzer.ts +259 -0
  145. package/e2e/utils/visual-stability/capture.ts +57 -0
  146. package/e2e/utils/visual-stability/index.ts +15 -0
  147. package/e2e/utils/visual-stability/invariant.ts +113 -0
  148. package/e2e/utils/visual-stability/model.ts +47 -0
  149. package/e2e/utils/visual-stability/probe.ts +261 -0
  150. package/e2e/utils/visual-stability/regions.ts +18 -0
  151. package/e2e/utils/visual-stability/reporter.ts +71 -0
  152. package/e2e/utils/visual-stability/scenario.ts +21 -0
  153. package/e2e/utils/visual-stability.ts +52 -0
  154. package/e2e/utils/waits.ts +25 -0
  155. package/e2e/utils/windows-menu.fixture.tsx +99 -0
  156. package/e2e/utils/windows-menu.html +22 -0
  157. package/e2e/utils/workspace.ts +222 -0
  158. package/happydom.ts +77 -0
  159. package/index.html +29 -0
  160. package/manifest.json +36 -0
  161. package/package.json +83 -4
  162. package/perf/README.md +190 -0
  163. package/perf/composer.bench.ts +107 -0
  164. package/perf/desktop.bench.ts +22 -0
  165. package/perf/diff.bench.ts +104 -0
  166. package/perf/docks.bench.ts +109 -0
  167. package/perf/fixtures/composer.ts +166 -0
  168. package/perf/fixtures/diffs.ts +165 -0
  169. package/perf/fixtures/drag.ts +73 -0
  170. package/perf/fixtures/events.ts +106 -0
  171. package/perf/fixtures/home.ts +274 -0
  172. package/perf/fixtures/mock.ts +118 -0
  173. package/perf/fixtures/review.ts +33 -0
  174. package/perf/fixtures/scripts.ts +37 -0
  175. package/perf/fixtures/storage.ts +29 -0
  176. package/perf/fixtures/tabs.ts +21 -0
  177. package/perf/fixtures/timeline.ts +458 -0
  178. package/perf/home.bench.ts +74 -0
  179. package/perf/model-picker.bench.ts +168 -0
  180. package/perf/navigation.bench.ts +310 -0
  181. package/perf/question.bench.ts +85 -0
  182. package/perf/review.bench.ts +109 -0
  183. package/perf/send.bench.ts +54 -0
  184. package/perf/stream.bench.ts +108 -0
  185. package/perf/subagent-pill.bench.ts +348 -0
  186. package/perf/tabs.bench.ts +229 -0
  187. package/perf/timeline.bench.ts +167 -0
  188. package/playwright.components.config.ts +7 -0
  189. package/playwright.config.ts +85 -0
  190. package/public/_headers +28 -0
  191. package/public/assets/Inter.ttf +0 -0
  192. package/public/assets/JetBrainsMonoNerdFontMono-Bold.woff2 +0 -0
  193. package/public/assets/JetBrainsMonoNerdFontMono-Regular.woff2 +0 -0
  194. package/public/oc-theme-preload.js +33 -0
  195. package/src/app.tsx +142 -0
  196. package/src/components-lab/browser.tsx +745 -0
  197. package/src/components-lab/catalog.test.ts +58 -0
  198. package/src/components-lab/catalog.ts +195 -0
  199. package/src/components-lab/dialog-story-runtime.tsx +840 -0
  200. package/src/components-lab/focus-rings.stories.tsx +710 -0
  201. package/src/components-lab/focus-visibility.stories.tsx +2669 -0
  202. package/src/components-lab/force-focus.ts +52 -0
  203. package/src/components-lab/inspector.css +28 -0
  204. package/src/components-lab/lab.tsx +114 -0
  205. package/src/components-lab/machine.test.ts +177 -0
  206. package/src/components-lab/machine.ts +229 -0
  207. package/src/components-lab/motion.test.ts +17 -0
  208. package/src/components-lab/motion.ts +100 -0
  209. package/src/composer/adapter.ts +151 -0
  210. package/src/composer/attachments/attachments.css +123 -0
  211. package/src/composer/attachments/attachments.ts +363 -0
  212. package/src/composer/attachments/destination.ts +81 -0
  213. package/src/composer/attachments/upload-machine.ts +185 -0
  214. package/src/composer/attachments/uploads.test.ts +127 -0
  215. package/src/composer/attachments/uploads.tsx +228 -0
  216. package/src/composer/client-slash-command.test.ts +20 -0
  217. package/src/composer/client-slash-command.ts +28 -0
  218. package/src/composer/commands.tsx +175 -0
  219. package/src/composer/comment-focus-machine.test.ts +112 -0
  220. package/src/composer/comment-focus-machine.ts +141 -0
  221. package/src/composer/comment-note.test.ts +82 -0
  222. package/src/composer/comment-note.ts +127 -0
  223. package/src/composer/comments.test.ts +109 -0
  224. package/src/composer/comments.tsx +279 -0
  225. package/src/composer/composer-touch.stories.tsx +298 -0
  226. package/src/composer/composer.stories.tsx +765 -0
  227. package/src/composer/composer.tsx +244 -0
  228. package/src/composer/dropzone.tsx +92 -0
  229. package/src/composer/editor/actions.test.ts +176 -0
  230. package/src/composer/editor/actions.ts +191 -0
  231. package/src/composer/editor/dom.test.ts +168 -0
  232. package/src/composer/editor/dom.ts +274 -0
  233. package/src/composer/editor/editor.css +101 -0
  234. package/src/composer/editor/editor.tsx +1764 -0
  235. package/src/composer/editor/interaction.test.ts +13 -0
  236. package/src/composer/editor/interaction.ts +838 -0
  237. package/src/composer/editor/machine.test.ts +47 -0
  238. package/src/composer/editor/machine.ts +63 -0
  239. package/src/composer/editor/mention-search-machine.test.ts +111 -0
  240. package/src/composer/editor/mention-search-machine.ts +226 -0
  241. package/src/composer/editor/quote-comment.stories.tsx +133 -0
  242. package/src/composer/editor/quote-comment.tsx +191 -0
  243. package/src/composer/history/entry.test.ts +100 -0
  244. package/src/composer/history/entry.ts +140 -0
  245. package/src/composer/history/store.ts +83 -0
  246. package/src/composer/machine.test.ts +459 -0
  247. package/src/composer/machine.ts +561 -0
  248. package/src/composer/media.ts +18 -0
  249. package/src/composer/model-chip-machine.test.ts +96 -0
  250. package/src/composer/model-chip-machine.ts +82 -0
  251. package/src/composer/model-label.test.ts +177 -0
  252. package/src/composer/model-label.ts +120 -0
  253. package/src/composer/model.ts +683 -0
  254. package/src/composer/persistence.tsx +163 -0
  255. package/src/composer/prompt-parts.ts +52 -0
  256. package/src/composer/prompt-status-machine.test.ts +76 -0
  257. package/src/composer/prompt-status-machine.ts +48 -0
  258. package/src/composer/prompt.test.ts +320 -0
  259. package/src/composer/prompt.ts +334 -0
  260. package/src/composer/quote-comment-machine.test.ts +154 -0
  261. package/src/composer/quote-comment-machine.ts +211 -0
  262. package/src/composer/quote-position.ts +32 -0
  263. package/src/composer/quote-source.ts +48 -0
  264. package/src/composer/reload-machine.ts +51 -0
  265. package/src/composer/request.test.ts +360 -0
  266. package/src/composer/request.ts +245 -0
  267. package/src/composer/retry.test.ts +107 -0
  268. package/src/composer/retry.ts +63 -0
  269. package/src/composer/schema.test.ts +317 -0
  270. package/src/composer/schema.ts +424 -0
  271. package/src/composer/selection.ts +354 -0
  272. package/src/composer/session-match.test.ts +20 -0
  273. package/src/composer/session-match.ts +18 -0
  274. package/src/composer/state.ts +271 -0
  275. package/src/composer/submission-state.ts +3 -0
  276. package/src/composer/submit.test.ts +1785 -0
  277. package/src/composer/submit.ts +1073 -0
  278. package/src/composer/suggestions/machine.test.ts +420 -0
  279. package/src/composer/suggestions/machine.ts +573 -0
  280. package/src/composer/types.ts +60 -0
  281. package/src/desktop.ts +25 -0
  282. package/src/entry.tsx +119 -0
  283. package/src/env.d.ts +41 -0
  284. package/src/home/home.standalone.stories.tsx +260 -0
  285. package/src/home/machine.test.ts +286 -0
  286. package/src/home/machine.ts +344 -0
  287. package/src/home/model.ts +162 -0
  288. package/src/home/projects/actions.tsx +189 -0
  289. package/src/home/projects/add.ts +10 -0
  290. package/src/home/projects/browse-view.tsx +264 -0
  291. package/src/home/projects/browse.tsx +33 -0
  292. package/src/home/projects/controller.tsx +109 -0
  293. package/src/home/projects/file-manager.ts +26 -0
  294. package/src/home/projects/import-machine.test.ts +117 -0
  295. package/src/home/projects/import-machine.ts +133 -0
  296. package/src/home/projects/landing.tsx +77 -0
  297. package/src/home/projects/menu.tsx +70 -0
  298. package/src/home/projects/region.tsx +63 -0
  299. package/src/home/projects/reveal.ts +39 -0
  300. package/src/home/projects/start.ts +114 -0
  301. package/src/home/projects/view.css +79 -0
  302. package/src/home/projects/view.tsx +763 -0
  303. package/src/home/route.tsx +177 -0
  304. package/src/home/scroll.ts +180 -0
  305. package/src/home/sessions/alt-hold.test.ts +45 -0
  306. package/src/home/sessions/alt-hold.ts +20 -0
  307. package/src/home/sessions/archive.test.ts +51 -0
  308. package/src/home/sessions/archive.ts +25 -0
  309. package/src/home/sessions/controller.tsx +669 -0
  310. package/src/home/sessions/delete-dialog.stories.tsx +70 -0
  311. package/src/home/sessions/index.test.ts +171 -0
  312. package/src/home/sessions/index.ts +60 -0
  313. package/src/home/sessions/load-machine.test.ts +223 -0
  314. package/src/home/sessions/load-machine.ts +430 -0
  315. package/src/home/sessions/open.test.ts +16 -0
  316. package/src/home/sessions/open.ts +18 -0
  317. package/src/home/sessions/queries.ts +95 -0
  318. package/src/home/sessions/records.test.ts +85 -0
  319. package/src/home/sessions/records.ts +58 -0
  320. package/src/home/sessions/region.tsx +66 -0
  321. package/src/home/sessions/row-machine.test.ts +203 -0
  322. package/src/home/sessions/row-machine.ts +365 -0
  323. package/src/home/sessions/search-machine.test.ts +117 -0
  324. package/src/home/sessions/search-machine.ts +181 -0
  325. package/src/home/sessions/search.ts +218 -0
  326. package/src/home/sessions/view.css +101 -0
  327. package/src/home/sessions/view.tsx +1123 -0
  328. package/src/home/start/command-palette.tsx +88 -0
  329. package/src/index.css +419 -0
  330. package/src/index.ts +5 -0
  331. package/src/new-session/brick-breaker-machine.test.ts +120 -0
  332. package/src/new-session/brick-breaker-machine.ts +110 -0
  333. package/src/new-session/brick-breaker.tsx +551 -0
  334. package/src/new-session/commands.tsx +61 -0
  335. package/src/new-session/composer-adapter.ts +309 -0
  336. package/src/new-session/draft.standalone.stories.tsx +214 -0
  337. package/src/new-session/layout.ts +2 -0
  338. package/src/new-session/location/dialog.css +204 -0
  339. package/src/new-session/location/dialog.standalone.stories.tsx +122 -0
  340. package/src/new-session/location/dialog.tsx +677 -0
  341. package/src/new-session/location/machine.test.ts +180 -0
  342. package/src/new-session/location/machine.ts +239 -0
  343. package/src/new-session/machine.test.ts +344 -0
  344. package/src/new-session/machine.ts +293 -0
  345. package/src/new-session/mcp.ts +132 -0
  346. package/src/new-session/pin-board-machine.test.ts +116 -0
  347. package/src/new-session/pin-board-machine.ts +188 -0
  348. package/src/new-session/pin-board.tsx +1072 -0
  349. package/src/new-session/pin-quads.ts +252 -0
  350. package/src/new-session/pin-sound.ts +193 -0
  351. package/src/new-session/project/controller.ts +111 -0
  352. package/src/new-session/project/selector.test.tsx +101 -0
  353. package/src/new-session/project/selector.tsx +108 -0
  354. package/src/new-session/route.tsx +115 -0
  355. package/src/new-session/screen.tsx +107 -0
  356. package/src/new-session/view.tsx +424 -0
  357. package/src/new-session/wordmark-machine.test.ts +236 -0
  358. package/src/new-session/wordmark-machine.ts +237 -0
  359. package/src/new-session/wordmark.css +71 -0
  360. package/src/new-session/wordmark.stories.tsx +109 -0
  361. package/src/new-session/wordmark.tsx +1222 -0
  362. package/src/new-session/workspace/branch-machine.test.ts +243 -0
  363. package/src/new-session/workspace/branch-machine.ts +233 -0
  364. package/src/new-session/workspace/checkout-machine.test.ts +73 -0
  365. package/src/new-session/workspace/checkout-machine.ts +69 -0
  366. package/src/new-session/workspace/controller.test.ts +82 -0
  367. package/src/new-session/workspace/controller.ts +291 -0
  368. package/src/new-session/workspace/selector.tsx +230 -0
  369. package/src/providers/catalog/console-settle.ts +80 -0
  370. package/src/providers/catalog/console.test.ts +21 -0
  371. package/src/providers/catalog/console.ts +37 -0
  372. package/src/providers/catalog/integrations.ts +30 -0
  373. package/src/providers/catalog/order.ts +10 -0
  374. package/src/providers/catalog/plugin.ts +15 -0
  375. package/src/providers/catalog/providers.ts +111 -0
  376. package/src/providers/catalog/settle-machine.test.ts +123 -0
  377. package/src/providers/catalog/settle-machine.ts +109 -0
  378. package/src/providers/connect/chatgpt-usage-limit.stories.tsx +25 -0
  379. package/src/providers/connect/chatgpt-usage-limit.tsx +83 -0
  380. package/src/providers/connect/chatgpt-welcome.stories.tsx +23 -0
  381. package/src/providers/connect/chatgpt-welcome.tsx +37 -0
  382. package/src/providers/connect/console.tsx +67 -0
  383. package/src/providers/connect/controller.ts +672 -0
  384. package/src/providers/connect/dialog-machine.test.ts +654 -0
  385. package/src/providers/connect/dialog-machine.ts +875 -0
  386. package/src/providers/connect/dialog.standalone.stories.tsx +187 -0
  387. package/src/providers/connect/dialog.tsx +1564 -0
  388. package/src/providers/connect/form-machine.test.ts +200 -0
  389. package/src/providers/connect/form-machine.ts +419 -0
  390. package/src/providers/connect/go-upsell-hero-art.test.ts +194 -0
  391. package/src/providers/connect/go-upsell-hero-art.ts +749 -0
  392. package/src/providers/connect/go-upsell-hero-machine.test.ts +88 -0
  393. package/src/providers/connect/go-upsell-hero-machine.ts +68 -0
  394. package/src/providers/connect/go-upsell-hero.tsx +17 -0
  395. package/src/providers/connect/machine.test.ts +513 -0
  396. package/src/providers/connect/machine.ts +644 -0
  397. package/src/providers/connect/mcp-dialog.stories.tsx +89 -0
  398. package/src/providers/connect/mcp-dialog.tsx +316 -0
  399. package/src/providers/connect/mcp-machine.test.ts +239 -0
  400. package/src/providers/connect/mcp-machine.ts +328 -0
  401. package/src/providers/connect/mcp-sign-in.tsx +112 -0
  402. package/src/providers/connect/mcp.tsx +298 -0
  403. package/src/providers/connect/models.css +71 -0
  404. package/src/providers/connect/remote.test.ts +50 -0
  405. package/src/providers/connect/remote.tsx +10 -0
  406. package/src/providers/connect/step-actions.tsx +18 -0
  407. package/src/providers/connect/tip.tsx +110 -0
  408. package/src/providers/connect/usage-exceeded.tsx +62 -0
  409. package/src/providers/custom-managed-provider.svg +31 -0
  410. package/src/providers/models/agent.test.ts +25 -0
  411. package/src/providers/models/agent.ts +7 -0
  412. package/src/providers/models/configured.ts +33 -0
  413. package/src/providers/models/details.tsx +168 -0
  414. package/src/providers/models/manage.css +97 -0
  415. package/src/providers/models/manage.standalone.stories.tsx +59 -0
  416. package/src/providers/models/manage.tsx +170 -0
  417. package/src/providers/models/models.test.ts +55 -0
  418. package/src/providers/models/models.tsx +279 -0
  419. package/src/providers/models/provider-group.tsx +293 -0
  420. package/src/providers/models/search.test.ts +13 -0
  421. package/src/providers/models/search.ts +20 -0
  422. package/src/providers/models/select-dialog-machine.test.ts +455 -0
  423. package/src/providers/models/select-dialog-machine.ts +702 -0
  424. package/src/providers/models/select-dialog.css +240 -0
  425. package/src/providers/models/select-dialog.standalone.stories.tsx +225 -0
  426. package/src/providers/models/select-dialog.tsx +1359 -0
  427. package/src/providers/models/selection-machine.test.ts +290 -0
  428. package/src/providers/models/selection-machine.ts +408 -0
  429. package/src/providers/models/selection.tsx +787 -0
  430. package/src/providers/models/speed.test.ts +17 -0
  431. package/src/providers/models/speed.ts +17 -0
  432. package/src/providers/models/tooltip.tsx +152 -0
  433. package/src/providers/models/unpaid.standalone.stories.tsx +76 -0
  434. package/src/providers/models/unpaid.tsx +199 -0
  435. package/src/providers/models/variant.test.ts +79 -0
  436. package/src/providers/models/variant.ts +74 -0
  437. package/src/providers/opencode-logo.tsx +17 -0
  438. package/src/runtime/animated-presence.ts +66 -0
  439. package/src/runtime/array-move.test.ts +19 -0
  440. package/src/runtime/array-move.ts +8 -0
  441. package/src/runtime/i18n/am.ts +1409 -0
  442. package/src/runtime/i18n/ar.ts +1560 -0
  443. package/src/runtime/i18n/az.ts +1481 -0
  444. package/src/runtime/i18n/bg.ts +1491 -0
  445. package/src/runtime/i18n/bn.ts +1477 -0
  446. package/src/runtime/i18n/br.ts +1527 -0
  447. package/src/runtime/i18n/bs.ts +1561 -0
  448. package/src/runtime/i18n/ca.ts +1523 -0
  449. package/src/runtime/i18n/cs.ts +1520 -0
  450. package/src/runtime/i18n/da.ts +1527 -0
  451. package/src/runtime/i18n/de.ts +1517 -0
  452. package/src/runtime/i18n/desktop-native.test.ts +84 -0
  453. package/src/runtime/i18n/desktop-native.ts +366 -0
  454. package/src/runtime/i18n/dv.ts +1519 -0
  455. package/src/runtime/i18n/dz.ts +1504 -0
  456. package/src/runtime/i18n/el.ts +1509 -0
  457. package/src/runtime/i18n/en.ts +1560 -0
  458. package/src/runtime/i18n/es.ts +1583 -0
  459. package/src/runtime/i18n/et.ts +1456 -0
  460. package/src/runtime/i18n/fa.ts +1470 -0
  461. package/src/runtime/i18n/fi.ts +1472 -0
  462. package/src/runtime/i18n/fo.ts +1469 -0
  463. package/src/runtime/i18n/fr.ts +1543 -0
  464. package/src/runtime/i18n/he.ts +1455 -0
  465. package/src/runtime/i18n/hi.ts +1475 -0
  466. package/src/runtime/i18n/hr.ts +1506 -0
  467. package/src/runtime/i18n/hu.ts +1492 -0
  468. package/src/runtime/i18n/hy.ts +1478 -0
  469. package/src/runtime/i18n/id.ts +1541 -0
  470. package/src/runtime/i18n/is.ts +1468 -0
  471. package/src/runtime/i18n/it.ts +1517 -0
  472. package/src/runtime/i18n/ja.ts +1484 -0
  473. package/src/runtime/i18n/ka.ts +1476 -0
  474. package/src/runtime/i18n/km.ts +1461 -0
  475. package/src/runtime/i18n/ko.ts +1469 -0
  476. package/src/runtime/i18n/language.test.ts +35 -0
  477. package/src/runtime/i18n/language.tsx +468 -0
  478. package/src/runtime/i18n/lo.ts +1454 -0
  479. package/src/runtime/i18n/lt.ts +1529 -0
  480. package/src/runtime/i18n/lv.ts +1509 -0
  481. package/src/runtime/i18n/machine.test.ts +148 -0
  482. package/src/runtime/i18n/machine.ts +164 -0
  483. package/src/runtime/i18n/mk.ts +1488 -0
  484. package/src/runtime/i18n/mn.ts +1485 -0
  485. package/src/runtime/i18n/ms.ts +1480 -0
  486. package/src/runtime/i18n/my.ts +1489 -0
  487. package/src/runtime/i18n/ne.ts +1478 -0
  488. package/src/runtime/i18n/nl.ts +1491 -0
  489. package/src/runtime/i18n/no.ts +1536 -0
  490. package/src/runtime/i18n/pa.ts +1478 -0
  491. package/src/runtime/i18n/pl.ts +1540 -0
  492. package/src/runtime/i18n/ro.ts +1511 -0
  493. package/src/runtime/i18n/ru.ts +1596 -0
  494. package/src/runtime/i18n/si.ts +1477 -0
  495. package/src/runtime/i18n/sk.ts +1526 -0
  496. package/src/runtime/i18n/sl.ts +1527 -0
  497. package/src/runtime/i18n/sq.ts +1480 -0
  498. package/src/runtime/i18n/sr.ts +1502 -0
  499. package/src/runtime/i18n/sv.ts +1478 -0
  500. package/src/runtime/i18n/tg.ts +1493 -0
  501. package/src/runtime/i18n/th.ts +1505 -0
  502. package/src/runtime/i18n/tk.ts +1472 -0
  503. package/src/runtime/i18n/tr.ts +1550 -0
  504. package/src/runtime/i18n/uk.ts +1598 -0
  505. package/src/runtime/i18n/ur.ts +1488 -0
  506. package/src/runtime/i18n/uz.ts +1490 -0
  507. package/src/runtime/i18n/vi.ts +1473 -0
  508. package/src/runtime/i18n/zh.ts +1474 -0
  509. package/src/runtime/i18n/zht.ts +1468 -0
  510. package/src/runtime/persistence/README.md +151 -0
  511. package/src/runtime/persistence/base64.ts +11 -0
  512. package/src/runtime/persistence/consumers.test.ts +168 -0
  513. package/src/runtime/persistence/drafts-machine.test.ts +214 -0
  514. package/src/runtime/persistence/drafts-machine.ts +385 -0
  515. package/src/runtime/persistence/drafts.test.ts +515 -0
  516. package/src/runtime/persistence/drafts.ts +687 -0
  517. package/src/runtime/persistence/equality.ts +9 -0
  518. package/src/runtime/persistence/namespace-machine.test.ts +232 -0
  519. package/src/runtime/persistence/namespace-machine.ts +304 -0
  520. package/src/runtime/persistence/namespace.test.ts +304 -0
  521. package/src/runtime/persistence/namespace.ts +126 -0
  522. package/src/runtime/persistence/persist-machine.test.ts +185 -0
  523. package/src/runtime/persistence/persist-machine.ts +192 -0
  524. package/src/runtime/persistence/persist.test.ts +243 -0
  525. package/src/runtime/persistence/persist.ts +159 -0
  526. package/src/runtime/persistence/schema.test.ts +208 -0
  527. package/src/runtime/persistence/schema.ts +130 -0
  528. package/src/runtime/persistence/storage-machine.test.ts +61 -0
  529. package/src/runtime/persistence/storage-machine.ts +57 -0
  530. package/src/runtime/persistence/storage.test.ts +70 -0
  531. package/src/runtime/persistence/storage.ts +707 -0
  532. package/src/runtime/platform/base-path-router.tsx +66 -0
  533. package/src/runtime/platform/base-path.test.ts +50 -0
  534. package/src/runtime/platform/base-path.ts +28 -0
  535. package/src/runtime/platform/drag-out.test.ts +58 -0
  536. package/src/runtime/platform/drag-out.ts +53 -0
  537. package/src/runtime/platform/external-link.tsx +21 -0
  538. package/src/runtime/platform/keyboard.ts +41 -0
  539. package/src/runtime/platform/platform.tsx +185 -0
  540. package/src/runtime/platform/pwa.ts +50 -0
  541. package/src/runtime/platform/web.ts +63 -0
  542. package/src/runtime/plugin/app-links.test.ts +17 -0
  543. package/src/runtime/plugin/app-links.ts +88 -0
  544. package/src/runtime/plugin/attach-machine.test.ts +174 -0
  545. package/src/runtime/plugin/attach-machine.ts +152 -0
  546. package/src/runtime/plugin/attachment.ts +15 -0
  547. package/src/runtime/plugin/builtins.ts +15 -0
  548. package/src/runtime/plugin/closed-tabs-view.tsx +315 -0
  549. package/src/runtime/plugin/closed-tabs.test.ts +82 -0
  550. package/src/runtime/plugin/closed-tabs.ts +196 -0
  551. package/src/runtime/plugin/commands.test.ts +23 -0
  552. package/src/runtime/plugin/commands.tsx +86 -0
  553. package/src/runtime/plugin/composer-write-machine.test.ts +151 -0
  554. package/src/runtime/plugin/composer-write-machine.ts +111 -0
  555. package/src/runtime/plugin/deferred-menu-machine.test.ts +127 -0
  556. package/src/runtime/plugin/deferred-menu-machine.ts +163 -0
  557. package/src/runtime/plugin/dialog-machine.test.ts +62 -0
  558. package/src/runtime/plugin/dialog-machine.ts +81 -0
  559. package/src/runtime/plugin/dialogs.stories.tsx +66 -0
  560. package/src/runtime/plugin/dialogs.tsx +177 -0
  561. package/src/runtime/plugin/embed-flight-machine.test.ts +350 -0
  562. package/src/runtime/plugin/embed-flight-machine.ts +468 -0
  563. package/src/runtime/plugin/embed-geometry.test.ts +18 -0
  564. package/src/runtime/plugin/embed-geometry.ts +19 -0
  565. package/src/runtime/plugin/embed-snapshot-machine.test.ts +242 -0
  566. package/src/runtime/plugin/embed-snapshot-machine.ts +267 -0
  567. package/src/runtime/plugin/embeds.tsx +773 -0
  568. package/src/runtime/plugin/extension-plugins.tsx +299 -0
  569. package/src/runtime/plugin/hmr.tsx +33 -0
  570. package/src/runtime/plugin/host-apis.tsx +1315 -0
  571. package/src/runtime/plugin/host-layout-machine.test.ts +214 -0
  572. package/src/runtime/plugin/host-layout-machine.ts +269 -0
  573. package/src/runtime/plugin/host.tsx +1106 -0
  574. package/src/runtime/plugin/instance-machine.test.ts +387 -0
  575. package/src/runtime/plugin/instance-machine.ts +409 -0
  576. package/src/runtime/plugin/ipc-machine.test.ts +172 -0
  577. package/src/runtime/plugin/ipc-machine.ts +213 -0
  578. package/src/runtime/plugin/ipc.test.ts +166 -0
  579. package/src/runtime/plugin/ipc.ts +220 -0
  580. package/src/runtime/plugin/link-check-machine.test.ts +115 -0
  581. package/src/runtime/plugin/link-check-machine.ts +142 -0
  582. package/src/runtime/plugin/link-check.ts +82 -0
  583. package/src/runtime/plugin/located-machine.test.ts +124 -0
  584. package/src/runtime/plugin/located-machine.ts +125 -0
  585. package/src/runtime/plugin/located.ts +82 -0
  586. package/src/runtime/plugin/machine.test.ts +222 -0
  587. package/src/runtime/plugin/machine.ts +318 -0
  588. package/src/runtime/plugin/menubar-items.ts +28 -0
  589. package/src/runtime/plugin/mobile.tsx +199 -0
  590. package/src/runtime/plugin/module.test.ts +57 -0
  591. package/src/runtime/plugin/module.ts +64 -0
  592. package/src/runtime/plugin/mounted-session.ts +420 -0
  593. package/src/runtime/plugin/new-tab-machine.test.ts +207 -0
  594. package/src/runtime/plugin/new-tab-machine.ts +240 -0
  595. package/src/runtime/plugin/pane-drag-machine.test.ts +217 -0
  596. package/src/runtime/plugin/pane-drag-machine.ts +263 -0
  597. package/src/runtime/plugin/pane-drag.tsx +290 -0
  598. package/src/runtime/plugin/panel-keys.ts +15 -0
  599. package/src/runtime/plugin/panel-menu.ts +29 -0
  600. package/src/runtime/plugin/panel-trigger.tsx +180 -0
  601. package/src/runtime/plugin/panels.tsx +733 -0
  602. package/src/runtime/plugin/plugin-gui-machine.test.ts +186 -0
  603. package/src/runtime/plugin/plugin-gui-machine.ts +178 -0
  604. package/src/runtime/plugin/plugins.tsx +137 -0
  605. package/src/runtime/plugin/prompt-gate.test.ts +113 -0
  606. package/src/runtime/plugin/prompt-gate.ts +36 -0
  607. package/src/runtime/plugin/render.tsx +348 -0
  608. package/src/runtime/plugin/root.tsx +141 -0
  609. package/src/runtime/plugin/server-shell.tsx +113 -0
  610. package/src/runtime/plugin/servers.tsx +270 -0
  611. package/src/runtime/plugin/session-store-machine.test.ts +82 -0
  612. package/src/runtime/plugin/session-store-machine.ts +140 -0
  613. package/src/runtime/plugin/settings-page-view.tsx +53 -0
  614. package/src/runtime/plugin/settings-pages.ts +23 -0
  615. package/src/runtime/plugin/side-region.tsx +635 -0
  616. package/src/runtime/plugin/startup.ts +107 -0
  617. package/src/runtime/plugin/store-machine.test.ts +69 -0
  618. package/src/runtime/plugin/store-machine.ts +139 -0
  619. package/src/runtime/plugin/stores.ts +339 -0
  620. package/src/runtime/plugin/tab-strip-scroll.test.ts +40 -0
  621. package/src/runtime/plugin/tab-strip-scroll.ts +130 -0
  622. package/src/runtime/plugin/titlebar-items.css +20 -0
  623. package/src/runtime/plugin/titlebar-items.stories.tsx +97 -0
  624. package/src/runtime/plugin/titlebar-items.tsx +96 -0
  625. package/src/runtime/plugin/ui.tsx +292 -0
  626. package/src/runtime/plugin/web-href.test.ts +11 -0
  627. package/src/runtime/plugin/web-href.ts +10 -0
  628. package/src/runtime/polyfills.test.ts +61 -0
  629. package/src/runtime/polyfills.ts +39 -0
  630. package/src/runtime/presence-machine.test.ts +260 -0
  631. package/src/runtime/presence-machine.ts +329 -0
  632. package/src/runtime/presence.ts +165 -0
  633. package/src/runtime/server/api.test.ts +64 -0
  634. package/src/runtime/server/api.ts +58 -0
  635. package/src/runtime/server/client.test.ts +131 -0
  636. package/src/runtime/server/client.tsx +308 -0
  637. package/src/runtime/server/current.tsx +55 -0
  638. package/src/runtime/server/data.test.ts +440 -0
  639. package/src/runtime/server/data.ts +286 -0
  640. package/src/runtime/server/errors.test.ts +151 -0
  641. package/src/runtime/server/errors.ts +135 -0
  642. package/src/runtime/server/global-sync/bootstrap.test.ts +179 -0
  643. package/src/runtime/server/global-sync/bootstrap.ts +96 -0
  644. package/src/runtime/server/global-sync/child-store.test.ts +47 -0
  645. package/src/runtime/server/global-sync/child-store.ts +206 -0
  646. package/src/runtime/server/global-sync/machine.test.ts +96 -0
  647. package/src/runtime/server/global-sync/machine.ts +84 -0
  648. package/src/runtime/server/global-sync/types.ts +46 -0
  649. package/src/runtime/server/global-sync/utils.test.ts +154 -0
  650. package/src/runtime/server/global-sync/utils.ts +165 -0
  651. package/src/runtime/server/health-machine.test.ts +227 -0
  652. package/src/runtime/server/health-machine.ts +357 -0
  653. package/src/runtime/server/health.test.ts +169 -0
  654. package/src/runtime/server/health.ts +236 -0
  655. package/src/runtime/server/image.test.ts +214 -0
  656. package/src/runtime/server/image.ts +40 -0
  657. package/src/runtime/server/loopback.test.ts +17 -0
  658. package/src/runtime/server/loopback.ts +22 -0
  659. package/src/runtime/server/machine.test.ts +162 -0
  660. package/src/runtime/server/machine.ts +275 -0
  661. package/src/runtime/server/media.ts +88 -0
  662. package/src/runtime/server/persistence.test.ts +117 -0
  663. package/src/runtime/server/persistence.ts +105 -0
  664. package/src/runtime/server/plugin-machine.test.ts +128 -0
  665. package/src/runtime/server/plugin-machine.ts +170 -0
  666. package/src/runtime/server/refcount.test.ts +30 -0
  667. package/src/runtime/server/refcount.ts +37 -0
  668. package/src/runtime/server/registry.test.ts +152 -0
  669. package/src/runtime/server/registry.tsx +363 -0
  670. package/src/runtime/server/request-queue-machine.test.ts +151 -0
  671. package/src/runtime/server/request-queue-machine.ts +307 -0
  672. package/src/runtime/server/request-queue.test.ts +315 -0
  673. package/src/runtime/server/request-queue.ts +173 -0
  674. package/src/runtime/server/runtime.tsx +396 -0
  675. package/src/runtime/server/scope.test.ts +52 -0
  676. package/src/runtime/server/scope.ts +69 -0
  677. package/src/runtime/server/scoped-cache.test.ts +72 -0
  678. package/src/runtime/server/scoped-cache.ts +119 -0
  679. package/src/runtime/server/server-sync/connection.ts +34 -0
  680. package/src/runtime/server/server-sync/endpoint-machine.test.ts +87 -0
  681. package/src/runtime/server/server-sync/endpoint-machine.ts +62 -0
  682. package/src/runtime/server/server-sync/machine.test.ts +86 -0
  683. package/src/runtime/server/server-sync/machine.ts +70 -0
  684. package/src/runtime/server/session-index.ts +23 -0
  685. package/src/runtime/server/sync.tsx +206 -0
  686. package/src/runtime/server/types.ts +151 -0
  687. package/src/servers/connect/browser.ts +15 -0
  688. package/src/servers/connect/connect.fixture.tsx +222 -0
  689. package/src/servers/connect/controller.ts +237 -0
  690. package/src/servers/connect/dialog.stories.tsx +67 -0
  691. package/src/servers/connect/dialog.tsx +255 -0
  692. package/src/servers/connect/machine.test.ts +487 -0
  693. package/src/servers/connect/machine.ts +427 -0
  694. package/src/servers/connect/method.tsx +31 -0
  695. package/src/servers/connect/pairing.test.ts +67 -0
  696. package/src/servers/connect/pairing.ts +134 -0
  697. package/src/servers/connect/redeem.ts +50 -0
  698. package/src/servers/connect/scanner-machine.test.ts +114 -0
  699. package/src/servers/connect/scanner-machine.ts +164 -0
  700. package/src/servers/connect/scanner.css +47 -0
  701. package/src/servers/connect/scanner.tsx +173 -0
  702. package/src/servers/connect/screen.css +108 -0
  703. package/src/servers/connect/screen.stories.tsx +63 -0
  704. package/src/servers/connect/screen.tsx +164 -0
  705. package/src/servers/registry/add-menu.tsx +62 -0
  706. package/src/servers/registry/controller.test.ts +26 -0
  707. package/src/servers/registry/controller.ts +86 -0
  708. package/src/servers/registry/label.tsx +23 -0
  709. package/src/servers/registry/management.test.ts +40 -0
  710. package/src/servers/registry/management.ts +17 -0
  711. package/src/servers/registry/plugin-row.tsx +57 -0
  712. package/src/servers/registry/row-items.tsx +18 -0
  713. package/src/servers/registry/row-menu.tsx +152 -0
  714. package/src/servers/registry/row.stories.tsx +51 -0
  715. package/src/servers/registry/row.tsx +47 -0
  716. package/src/session/commands/dialog-jump-to-message.tsx +197 -0
  717. package/src/session/commands/export-machine.test.ts +99 -0
  718. package/src/session/commands/export-machine.ts +117 -0
  719. package/src/session/commands/export-session.tsx +108 -0
  720. package/src/session/commands/export.test.ts +105 -0
  721. package/src/session/commands/export.ts +89 -0
  722. package/src/session/commands/fork-dialog.stories.tsx +68 -0
  723. package/src/session/commands/fork-dialog.tsx +198 -0
  724. package/src/session/commands/jump-to-message-machine.test.ts +123 -0
  725. package/src/session/commands/jump-to-message-machine.ts +161 -0
  726. package/src/session/commands/jump-to-message.stories.tsx +226 -0
  727. package/src/session/commands/jump-to-message.tsx +161 -0
  728. package/src/session/commands/machine.test.ts +305 -0
  729. package/src/session/commands/machine.ts +272 -0
  730. package/src/session/commands/rename-session.ts +31 -0
  731. package/src/session/commands/use-session-commands.tsx +813 -0
  732. package/src/session/composer/activity-chips.css +242 -0
  733. package/src/session/composer/activity-chips.stories.tsx +280 -0
  734. package/src/session/composer/activity-chips.tsx +485 -0
  735. package/src/session/composer/adapter.ts +74 -0
  736. package/src/session/composer/composer-docks.stories.tsx +278 -0
  737. package/src/session/composer/composer-lane.css +93 -0
  738. package/src/session/composer/composer-lane.tsx +45 -0
  739. package/src/session/composer/controller.ts +86 -0
  740. package/src/session/composer/focus-machine.test.ts +285 -0
  741. package/src/session/composer/focus-machine.ts +212 -0
  742. package/src/session/composer/focus.tsx +161 -0
  743. package/src/session/composer/free-limit-panel.standalone.stories.tsx +45 -0
  744. package/src/session/composer/free-limit-panel.tsx +133 -0
  745. package/src/session/composer/go-limit-tray.tsx +137 -0
  746. package/src/session/composer/location-missing-machine.test.ts +97 -0
  747. package/src/session/composer/location-missing-machine.ts +144 -0
  748. package/src/session/composer/location-missing.css +73 -0
  749. package/src/session/composer/location-missing.standalone.stories.tsx +161 -0
  750. package/src/session/composer/location-missing.tsx +193 -0
  751. package/src/session/composer/plugin-pills.tsx +215 -0
  752. package/src/session/composer/queue-machine.test.ts +565 -0
  753. package/src/session/composer/queue-machine.ts +934 -0
  754. package/src/session/composer/queue-panel-machine.test.ts +121 -0
  755. package/src/session/composer/queue-panel-machine.ts +229 -0
  756. package/src/session/composer/queue-panel.css +10 -0
  757. package/src/session/composer/queue-panel.stories.tsx +86 -0
  758. package/src/session/composer/queue-panel.tsx +314 -0
  759. package/src/session/composer/queue.test.ts +314 -0
  760. package/src/session/composer/queue.ts +610 -0
  761. package/src/session/composer/recovery-story.tsx +38 -0
  762. package/src/session/composer/region.tsx +689 -0
  763. package/src/session/composer/selection.test.ts +28 -0
  764. package/src/session/composer/selection.ts +28 -0
  765. package/src/session/composer/session-composer-region-controller.ts +28 -0
  766. package/src/session/composer/session-composer-region.tsx +115 -0
  767. package/src/session/composer/shell-panel-machine.test.ts +261 -0
  768. package/src/session/composer/shell-panel-machine.ts +338 -0
  769. package/src/session/composer/shell-panel.ts +181 -0
  770. package/src/session/composer/spring-height-machine.test.ts +380 -0
  771. package/src/session/composer/spring-height-machine.ts +489 -0
  772. package/src/session/composer/spring-height.tsx +586 -0
  773. package/src/session/composer/subagent-bar.tsx +116 -0
  774. package/src/session/composer/timeline-actions.ts +49 -0
  775. package/src/session/composer/todo-pill.css +32 -0
  776. package/src/session/composer/todo-pill.stories.tsx +158 -0
  777. package/src/session/composer/todo-pill.tsx +157 -0
  778. package/src/session/composer/todos.ts +43 -0
  779. package/src/session/delete-machine.test.ts +83 -0
  780. package/src/session/delete-machine.ts +128 -0
  781. package/src/session/fork-machine.test.ts +152 -0
  782. package/src/session/fork-machine.ts +169 -0
  783. package/src/session/fork.ts +164 -0
  784. package/src/session/handoff-machine.test.ts +262 -0
  785. package/src/session/handoff-machine.ts +256 -0
  786. package/src/session/handoff.ts +112 -0
  787. package/src/session/header/drag-area.tsx +86 -0
  788. package/src/session/header/fit-machine.test.ts +143 -0
  789. package/src/session/header/fit-machine.ts +95 -0
  790. package/src/session/header/fit.ts +134 -0
  791. package/src/session/header/separator.tsx +22 -0
  792. package/src/session/header/session-header-actions.stories.tsx +45 -0
  793. package/src/session/header/session-header-actions.tsx +89 -0
  794. package/src/session/header/session-header.tsx +12 -0
  795. package/src/session/header/session-working-indicator.tsx +44 -0
  796. package/src/session/helpers.ts +42 -0
  797. package/src/session/list.test.ts +64 -0
  798. package/src/session/list.ts +18 -0
  799. package/src/session/message-id-from-hash.test.ts +10 -0
  800. package/src/session/message-id-from-hash.ts +8 -0
  801. package/src/session/model.ts +150 -0
  802. package/src/session/preparing-composer.tsx +72 -0
  803. package/src/session/question-switch.stories.tsx +380 -0
  804. package/src/session/requests/auto-approve-machine.test.ts +345 -0
  805. package/src/session/requests/auto-approve-machine.ts +247 -0
  806. package/src/session/requests/auto-approve.ts +274 -0
  807. package/src/session/requests/background.ts +312 -0
  808. package/src/session/requests/elicitation-controller.ts +129 -0
  809. package/src/session/requests/elicitation-machine.test.ts +209 -0
  810. package/src/session/requests/elicitation-machine.ts +277 -0
  811. package/src/session/requests/job-list.test.ts +18 -0
  812. package/src/session/requests/model.ts +348 -0
  813. package/src/session/requests/permission-machine.test.ts +130 -0
  814. package/src/session/requests/permission-machine.ts +105 -0
  815. package/src/session/requests/question-controller.ts +130 -0
  816. package/src/session/requests/question-keys.test.ts +106 -0
  817. package/src/session/requests/question-keys.ts +81 -0
  818. package/src/session/requests/question-machine.test.ts +257 -0
  819. package/src/session/requests/question-machine.ts +293 -0
  820. package/src/session/requests/question-motion.ts +26 -0
  821. package/src/session/requests/question-state.ts +21 -0
  822. package/src/session/requests/question-switch-machine.test.ts +114 -0
  823. package/src/session/requests/question-switch-machine.ts +130 -0
  824. package/src/session/requests/session-elicitation-dock.css +49 -0
  825. package/src/session/requests/session-elicitation-dock.tsx +223 -0
  826. package/src/session/requests/session-permission-dock.tsx +108 -0
  827. package/src/session/requests/session-question-dock-classic.tsx +726 -0
  828. package/src/session/requests/session-question-dock-experimental.tsx +1510 -0
  829. package/src/session/requests/session-question-dock.tsx +15 -0
  830. package/src/session/requests/session-request-tree.test.ts +119 -0
  831. package/src/session/requests/session-request-tree.ts +87 -0
  832. package/src/session/requests/session-websearch-dock.css +61 -0
  833. package/src/session/requests/session-websearch-dock.tsx +112 -0
  834. package/src/session/requests/steer-background.test.ts +66 -0
  835. package/src/session/requests/steer-background.ts +28 -0
  836. package/src/session/requests/websearch-machine.test.ts +425 -0
  837. package/src/session/requests/websearch-machine.ts +627 -0
  838. package/src/session/requests/websearch.ts +152 -0
  839. package/src/session/resolution-machine.test.ts +414 -0
  840. package/src/session/resolution-machine.ts +330 -0
  841. package/src/session/revert-machine.test.ts +365 -0
  842. package/src/session/revert-machine.ts +345 -0
  843. package/src/session/revert.ts +340 -0
  844. package/src/session/route-error.tsx +73 -0
  845. package/src/session/route.tsx +299 -0
  846. package/src/session/screen-layout.ts +147 -0
  847. package/src/session/screen.tsx +625 -0
  848. package/src/session/search.ts +3 -0
  849. package/src/session/server-unavailable-panel.standalone.stories.tsx +88 -0
  850. package/src/session/server-unavailable-panel.tsx +86 -0
  851. package/src/session/session-domain.test.ts +57 -0
  852. package/src/session/session-domain.ts +33 -0
  853. package/src/session/session-frame.tsx +28 -0
  854. package/src/session/session-identity-header.css +142 -0
  855. package/src/session/session-identity-header.tsx +674 -0
  856. package/src/session/session-layout.ts +73 -0
  857. package/src/session/session-model-helpers.test.ts +29 -0
  858. package/src/session/session-model-helpers.ts +33 -0
  859. package/src/session/session-panel-width.test.ts +25 -0
  860. package/src/session/session-panel-width.ts +58 -0
  861. package/src/session/session-read-menu-item.tsx +54 -0
  862. package/src/session/session-reference-menu.tsx +106 -0
  863. package/src/session/session-resolution.ts +141 -0
  864. package/src/session/session-screen.stories.tsx +363 -0
  865. package/src/session/sizing-machine.test.ts +89 -0
  866. package/src/session/sizing-machine.ts +74 -0
  867. package/src/session/story-model.tsx +420 -0
  868. package/src/session/timeline/background-work.stories.tsx +27 -0
  869. package/src/session/timeline/cache-machine.test.ts +50 -0
  870. package/src/session/timeline/cache-machine.ts +37 -0
  871. package/src/session/timeline/cache.ts +200 -0
  872. package/src/session/timeline/cold-mount.test.ts +162 -0
  873. package/src/session/timeline/cold-mount.ts +179 -0
  874. package/src/session/timeline/controller-projection.test.ts +305 -0
  875. package/src/session/timeline/controller-projection.ts +131 -0
  876. package/src/session/timeline/controller.tsx +467 -0
  877. package/src/session/timeline/cursor-machine.test.ts +398 -0
  878. package/src/session/timeline/cursor-machine.ts +433 -0
  879. package/src/session/timeline/cursor.ts +207 -0
  880. package/src/session/timeline/follow.ts +40 -0
  881. package/src/session/timeline/header-actions-machine.test.ts +126 -0
  882. package/src/session/timeline/header-actions-machine.ts +204 -0
  883. package/src/session/timeline/history-machine.test.ts +304 -0
  884. package/src/session/timeline/history-machine.ts +296 -0
  885. package/src/session/timeline/inline-quotes.ts +4 -0
  886. package/src/session/timeline/interaction.ts +474 -0
  887. package/src/session/timeline/machine.test.ts +290 -0
  888. package/src/session/timeline/machine.ts +271 -0
  889. package/src/session/timeline/message-timeline.tsx +779 -0
  890. package/src/session/timeline/model.test.ts +393 -0
  891. package/src/session/timeline/model.ts +201 -0
  892. package/src/session/timeline/observe-element-offset.test.ts +323 -0
  893. package/src/session/timeline/observe-element-offset.ts +106 -0
  894. package/src/session/timeline/projection.ts +7 -0
  895. package/src/session/timeline/quote-background.ts +141 -0
  896. package/src/session/timeline/quote-highlight.ts +203 -0
  897. package/src/session/timeline/quote-machine.test.ts +277 -0
  898. package/src/session/timeline/quote-machine.ts +360 -0
  899. package/src/session/timeline/quote-text.ts +332 -0
  900. package/src/session/timeline/quote.stories.tsx +88 -0
  901. package/src/session/timeline/quote.tsx +547 -0
  902. package/src/session/timeline/reconnect-machine.test.ts +115 -0
  903. package/src/session/timeline/reconnect-machine.ts +130 -0
  904. package/src/session/timeline/search-bar.css +19 -0
  905. package/src/session/timeline/search-bar.stories.tsx +122 -0
  906. package/src/session/timeline/search-bar.tsx +94 -0
  907. package/src/session/timeline/search-controller.ts +364 -0
  908. package/src/session/timeline/search-machine.test.ts +320 -0
  909. package/src/session/timeline/search-machine.ts +342 -0
  910. package/src/session/timeline/selected-effect.ts +19 -0
  911. package/src/session/timeline/sources.stories.tsx +352 -0
  912. package/src/session/timeline/sync-machine.ts +265 -0
  913. package/src/session/timeline/turn-diff-machine.ts +115 -0
  914. package/src/session/timeline/turn-diffs.test.ts +178 -0
  915. package/src/session/timeline/turn-diffs.ts +67 -0
  916. package/src/session/timeline/virtual-items.ts +3 -0
  917. package/src/session/timeline/virtualizer.tsx +1321 -0
  918. package/src/session/timeline/voice-delegation.test.ts +69 -0
  919. package/src/session/timeline/voice-delegation.ts +38 -0
  920. package/src/session/title.ts +15 -0
  921. package/src/session/usage-exceeded-dialogs.test.ts +41 -0
  922. package/src/session/usage-exceeded-dialogs.tsx +158 -0
  923. package/src/session/viewed-machine.test.ts +27 -0
  924. package/src/session/viewed-machine.ts +24 -0
  925. package/src/settings/about/about.tsx +199 -0
  926. package/src/settings/about/animated-wordmark.tsx +85 -0
  927. package/src/settings/about/anomaly-brush.svg +1 -0
  928. package/src/settings/about/contributors.test.ts +17 -0
  929. package/src/settings/about/contributors.ts +27 -0
  930. package/src/settings/about/legal.svg +9 -0
  931. package/src/settings/about/machine.test.ts +90 -0
  932. package/src/settings/about/machine.ts +119 -0
  933. package/src/settings/about/notices/apache-2.0.txt +201 -0
  934. package/src/settings/about/notices/betteroffice-notice.txt +2 -0
  935. package/src/settings/about/notices/crates.ts +770 -0
  936. package/src/settings/about/notices/dialog.tsx +113 -0
  937. package/src/settings/about/notices/fonts/OFL-1.1.txt +91 -0
  938. package/src/settings/about/notices/fonts.ts +107 -0
  939. package/src/settings/about/notices/notices.ts +37 -0
  940. package/src/settings/appearance/appearance.tsx +176 -0
  941. package/src/settings/command.tsx +29 -0
  942. package/src/settings/experimental/experimental.tsx +93 -0
  943. package/src/settings/extension-load-machine.test.ts +117 -0
  944. package/src/settings/extension-load-machine.ts +158 -0
  945. package/src/settings/extension-load.tsx +85 -0
  946. package/src/settings/general/behavior.ts +102 -0
  947. package/src/settings/general/controllers.test.ts +56 -0
  948. package/src/settings/general/controllers.ts +271 -0
  949. package/src/settings/general/general.tsx +404 -0
  950. package/src/settings/general/interface-mode.css +261 -0
  951. package/src/settings/general/interface-mode.tsx +190 -0
  952. package/src/settings/general/machine.test.ts +188 -0
  953. package/src/settings/general/machine.ts +224 -0
  954. package/src/settings/general/sound-preview-machine.test.ts +114 -0
  955. package/src/settings/general/sound-preview-machine.ts +109 -0
  956. package/src/settings/keybinds/keybinds.tsx +624 -0
  957. package/src/settings/keybinds/machine.test.ts +142 -0
  958. package/src/settings/keybinds/machine.ts +149 -0
  959. package/src/settings/keybinds/migration.ts +42 -0
  960. package/src/settings/list.tsx +10 -0
  961. package/src/settings/model.test.ts +249 -0
  962. package/src/settings/model.tsx +685 -0
  963. package/src/settings/models/machine.test.ts +123 -0
  964. package/src/settings/models/machine.ts +161 -0
  965. package/src/settings/models/models.tsx +285 -0
  966. package/src/settings/navigation.tsx +223 -0
  967. package/src/settings/notifications/notifications.tsx +160 -0
  968. package/src/settings/pages.ts +33 -0
  969. package/src/settings/palette.ts +44 -0
  970. package/src/settings/providers/account-actions.ts +112 -0
  971. package/src/settings/providers/account-name.tsx +46 -0
  972. package/src/settings/providers/accounts.test.ts +29 -0
  973. package/src/settings/providers/accounts.ts +11 -0
  974. package/src/settings/providers/console-extensions.test.ts +103 -0
  975. package/src/settings/providers/console-extensions.ts +110 -0
  976. package/src/settings/providers/console-link.tsx +121 -0
  977. package/src/settings/providers/extensions.tsx +425 -0
  978. package/src/settings/providers/machine.test.ts +270 -0
  979. package/src/settings/providers/machine.ts +357 -0
  980. package/src/settings/providers/plugin-update-machine.test.ts +155 -0
  981. package/src/settings/providers/plugin-update-machine.ts +151 -0
  982. package/src/settings/providers/providers.tsx +702 -0
  983. package/src/settings/rename-machine.test.ts +123 -0
  984. package/src/settings/rename-machine.ts +167 -0
  985. package/src/settings/rename.ts +120 -0
  986. package/src/settings/route.test.ts +117 -0
  987. package/src/settings/route.ts +160 -0
  988. package/src/settings/row.tsx +21 -0
  989. package/src/settings/scroller.ts +6 -0
  990. package/src/settings/search-catalog.ts +319 -0
  991. package/src/settings/search-empty.tsx +87 -0
  992. package/src/settings/search-field.tsx +101 -0
  993. package/src/settings/search-index.ts +193 -0
  994. package/src/settings/search-machine.test.ts +249 -0
  995. package/src/settings/search-machine.ts +308 -0
  996. package/src/settings/search-results.test.ts +151 -0
  997. package/src/settings/search-results.ts +75 -0
  998. package/src/settings/search-reveal.ts +76 -0
  999. package/src/settings/search.css +168 -0
  1000. package/src/settings/search.tsx +283 -0
  1001. package/src/settings/server-scope.tsx +12 -0
  1002. package/src/settings/servers/inventory.test.ts +50 -0
  1003. package/src/settings/servers/inventory.ts +100 -0
  1004. package/src/settings/servers/machine.test.ts +148 -0
  1005. package/src/settings/servers/machine.ts +176 -0
  1006. package/src/settings/servers/servers.tsx +178 -0
  1007. package/src/settings/servers/switcher.tsx +77 -0
  1008. package/src/settings/servers/unavailable.tsx +99 -0
  1009. package/src/settings/settings.css +2478 -0
  1010. package/src/settings/shell.standalone.stories.tsx +60 -0
  1011. package/src/settings/shell.tsx +434 -0
  1012. package/src/settings/surface.tsx +297 -0
  1013. package/src/settings/tab-header.ts +12 -0
  1014. package/src/settings/timeline-detail.css +334 -0
  1015. package/src/settings/timeline-detail.stories.tsx +54 -0
  1016. package/src/settings/timeline-detail.tsx +221 -0
  1017. package/src/settings/workspaces/delete-machine.test.ts +298 -0
  1018. package/src/settings/workspaces/delete-machine.ts +392 -0
  1019. package/src/settings/workspaces/project-extensions.tsx +537 -0
  1020. package/src/settings/workspaces/project-folder-missing.tsx +29 -0
  1021. package/src/settings/workspaces/project-lsp.test.ts +65 -0
  1022. package/src/settings/workspaces/project-lsp.ts +31 -0
  1023. package/src/settings/workspaces/project-machine.test.ts +285 -0
  1024. package/src/settings/workspaces/project-machine.ts +374 -0
  1025. package/src/settings/workspaces/project-model.ts +201 -0
  1026. package/src/settings/workspaces/project-options.tsx +81 -0
  1027. package/src/settings/workspaces/project-row.tsx +121 -0
  1028. package/src/settings/workspaces/project.css +397 -0
  1029. package/src/settings/workspaces/project.tsx +266 -0
  1030. package/src/settings/workspaces/projects.tsx +199 -0
  1031. package/src/settings/workspaces/queries.ts +66 -0
  1032. package/src/settings/workspaces/workspaces.tsx +705 -0
  1033. package/src/shell/commands/command-search.tsx +41 -0
  1034. package/src/shell/commands/command.test.ts +118 -0
  1035. package/src/shell/commands/command.tsx +584 -0
  1036. package/src/shell/commands/desktop-menu.test.ts +48 -0
  1037. package/src/shell/commands/desktop-menu.ts +322 -0
  1038. package/src/shell/commands/desktop.tsx +27 -0
  1039. package/src/shell/commands/dialog.css +263 -0
  1040. package/src/shell/commands/dialog.standalone.stories.tsx +247 -0
  1041. package/src/shell/commands/dialog.tsx +318 -0
  1042. package/src/shell/commands/highlight-machine.test.ts +64 -0
  1043. package/src/shell/commands/highlight-machine.ts +54 -0
  1044. package/src/shell/commands/key-sequence.tsx +38 -0
  1045. package/src/shell/commands/keymap.test.ts +219 -0
  1046. package/src/shell/commands/keymap.ts +275 -0
  1047. package/src/shell/commands/palette.ts +466 -0
  1048. package/src/shell/commands/safe-triangle.ts +64 -0
  1049. package/src/shell/commands/search-machine.test.ts +218 -0
  1050. package/src/shell/commands/search-machine.ts +274 -0
  1051. package/src/shell/commands/search.ts +136 -0
  1052. package/src/shell/commands/session-search.tsx +111 -0
  1053. package/src/shell/commands/suspend-machine.test.ts +59 -0
  1054. package/src/shell/commands/suspend-machine.ts +46 -0
  1055. package/src/shell/deep-links/deep-links.ts +65 -0
  1056. package/src/shell/deep-links/machine.test.ts +67 -0
  1057. package/src/shell/deep-links/machine.ts +67 -0
  1058. package/src/shell/errors/description.test.ts +32 -0
  1059. package/src/shell/errors/description.ts +32 -0
  1060. package/src/shell/errors/error.tsx +515 -0
  1061. package/src/shell/errors/machine.test.ts +178 -0
  1062. package/src/shell/errors/machine.ts +217 -0
  1063. package/src/shell/layout/helpers.test.ts +76 -0
  1064. package/src/shell/layout/helpers.ts +78 -0
  1065. package/src/shell/layout/project-avatar-state.ts +157 -0
  1066. package/src/shell/layout/project-icon.tsx +31 -0
  1067. package/src/shell/layout/project-icons.tsx +34 -0
  1068. package/src/shell/layout/session-tab-avatar.tsx +28 -0
  1069. package/src/shell/mobile-drawer.css +90 -0
  1070. package/src/shell/mobile-drawer.tsx +53 -0
  1071. package/src/shell/mobile-panel-drawer.css +34 -0
  1072. package/src/shell/mobile-panel-drawer.tsx +98 -0
  1073. package/src/shell/notifications/coordinator.ts +160 -0
  1074. package/src/shell/notifications/focus-lock-machine.test.ts +79 -0
  1075. package/src/shell/notifications/focus-lock-machine.ts +76 -0
  1076. package/src/shell/notifications/machine.test.ts +297 -0
  1077. package/src/shell/notifications/machine.ts +313 -0
  1078. package/src/shell/notifications/notification.test.ts +28 -0
  1079. package/src/shell/notifications/notification.tsx +526 -0
  1080. package/src/shell/notifications/sound.ts +113 -0
  1081. package/src/shell/notifications/toast.tsx +53 -0
  1082. package/src/shell/palette-menu.css +105 -0
  1083. package/src/shell/panel-motion-machine.test.ts +167 -0
  1084. package/src/shell/panel-motion-machine.ts +217 -0
  1085. package/src/shell/panel-motion.test.ts +26 -0
  1086. package/src/shell/panel-motion.ts +435 -0
  1087. package/src/shell/project-navigation.ts +21 -0
  1088. package/src/shell/routes/routes.tsx +140 -0
  1089. package/src/shell/routes/session-reference-lookup-machine.test.ts +111 -0
  1090. package/src/shell/routes/session-reference-lookup-machine.ts +86 -0
  1091. package/src/shell/routes/session-ui-navigate-machine.test.ts +124 -0
  1092. package/src/shell/routes/session-ui-navigate-machine.ts +127 -0
  1093. package/src/shell/routes/session-ui-provider.tsx +267 -0
  1094. package/src/shell/routes/session.test.ts +46 -0
  1095. package/src/shell/routes/session.ts +30 -0
  1096. package/src/shell/search-list.css +366 -0
  1097. package/src/shell/shell.tsx +340 -0
  1098. package/src/shell/sidebar-peek-machine.test.ts +240 -0
  1099. package/src/shell/sidebar-peek-machine.ts +331 -0
  1100. package/src/shell/sidebar-peek.css +28 -0
  1101. package/src/shell/sidebar-peek.ts +482 -0
  1102. package/src/shell/sidebar-toggle.tsx +255 -0
  1103. package/src/shell/state/helpers.ts +69 -0
  1104. package/src/shell/state/intent-machine.test.ts +155 -0
  1105. package/src/shell/state/intent-machine.ts +216 -0
  1106. package/src/shell/state/layout.test.ts +169 -0
  1107. package/src/shell/state/layout.tsx +794 -0
  1108. package/src/shell/state/scoped-machine.test.ts +69 -0
  1109. package/src/shell/state/scoped-machine.ts +77 -0
  1110. package/src/shell/state/scroll-machine.test.ts +109 -0
  1111. package/src/shell/state/scroll-machine.ts +94 -0
  1112. package/src/shell/state/scroll.test.ts +83 -0
  1113. package/src/shell/state/scroll.ts +124 -0
  1114. package/src/shell/state/session-preferences.ts +62 -0
  1115. package/src/shell/state/session-tabs.test.ts +188 -0
  1116. package/src/shell/state/session-tabs.ts +257 -0
  1117. package/src/shell/tabs/closed.ts +83 -0
  1118. package/src/shell/tabs/hydration-machine.test.ts +98 -0
  1119. package/src/shell/tabs/hydration-machine.ts +115 -0
  1120. package/src/shell/tabs/memory.ts +41 -0
  1121. package/src/shell/tabs/navigation-switch.ts +75 -0
  1122. package/src/shell/tabs/pins.test.ts +68 -0
  1123. package/src/shell/tabs/pins.ts +194 -0
  1124. package/src/shell/tabs/preview-machine.test.ts +89 -0
  1125. package/src/shell/tabs/preview-machine.ts +46 -0
  1126. package/src/shell/tabs/preview.test.ts +153 -0
  1127. package/src/shell/tabs/preview.ts +102 -0
  1128. package/src/shell/tabs/project-sessions.ts +60 -0
  1129. package/src/shell/tabs/promotion-machine.test.ts +203 -0
  1130. package/src/shell/tabs/promotion-machine.ts +194 -0
  1131. package/src/shell/tabs/schema.ts +86 -0
  1132. package/src/shell/tabs/tabs.test.ts +331 -0
  1133. package/src/shell/tabs/tabs.tsx +927 -0
  1134. package/src/shell/time.test.ts +23 -0
  1135. package/src/shell/time.ts +31 -0
  1136. package/src/shell/titlebar/auto-tab-groups.test.ts +76 -0
  1137. package/src/shell/titlebar/auto-tab-groups.ts +88 -0
  1138. package/src/shell/titlebar/auto-tab-sections.tsx +207 -0
  1139. package/src/shell/titlebar/history-machine.test.ts +184 -0
  1140. package/src/shell/titlebar/history-machine.ts +149 -0
  1141. package/src/shell/titlebar/history.ts +64 -0
  1142. package/src/shell/titlebar/inbox-branch-machine.test.ts +146 -0
  1143. package/src/shell/titlebar/inbox-branch-machine.ts +265 -0
  1144. package/src/shell/titlebar/inbox-card.stories.tsx +197 -0
  1145. package/src/shell/titlebar/inbox-list.stories.tsx +342 -0
  1146. package/src/shell/titlebar/inbox-model.ts +539 -0
  1147. package/src/shell/titlebar/inbox-settle-machine.test.ts +108 -0
  1148. package/src/shell/titlebar/inbox-settle-machine.ts +141 -0
  1149. package/src/shell/titlebar/inbox-working.test.ts +26 -0
  1150. package/src/shell/titlebar/inbox-working.ts +22 -0
  1151. package/src/shell/titlebar/inbox.tsx +985 -0
  1152. package/src/shell/titlebar/mobile-tabs-machine.test.ts +105 -0
  1153. package/src/shell/titlebar/mobile-tabs-machine.ts +102 -0
  1154. package/src/shell/titlebar/navigation-story.tsx +207 -0
  1155. package/src/shell/titlebar/pinned-area.css +164 -0
  1156. package/src/shell/titlebar/pinned-area.tsx +629 -0
  1157. package/src/shell/titlebar/project-session-row.tsx +334 -0
  1158. package/src/shell/titlebar/recent-sessions-model.test.ts +657 -0
  1159. package/src/shell/titlebar/recent-sessions-model.ts +469 -0
  1160. package/src/shell/titlebar/recent-sessions.tsx +1415 -0
  1161. package/src/shell/titlebar/recent-view-menu.tsx +147 -0
  1162. package/src/shell/titlebar/recent-view.test.ts +99 -0
  1163. package/src/shell/titlebar/recent-view.ts +183 -0
  1164. package/src/shell/titlebar/recently-closed-tabs-menu.css +25 -0
  1165. package/src/shell/titlebar/recently-closed-tabs-menu.tsx +260 -0
  1166. package/src/shell/titlebar/route-machine.test.ts +259 -0
  1167. package/src/shell/titlebar/route-machine.ts +206 -0
  1168. package/src/shell/titlebar/route-sync.ts +191 -0
  1169. package/src/shell/titlebar/session-events.test.ts +23 -0
  1170. package/src/shell/titlebar/session-events.ts +41 -0
  1171. package/src/shell/titlebar/session-rename-dialog-machine.test.ts +151 -0
  1172. package/src/shell/titlebar/session-rename-dialog-machine.ts +159 -0
  1173. package/src/shell/titlebar/sidebar-customized.standalone.stories.tsx +16 -0
  1174. package/src/shell/titlebar/sidebar-customized.tsx +747 -0
  1175. package/src/shell/titlebar/sidebar-pins.tsx +462 -0
  1176. package/src/shell/titlebar/sidebar-sessions.test.ts +96 -0
  1177. package/src/shell/titlebar/sidebar-sessions.ts +29 -0
  1178. package/src/shell/titlebar/sidebar-view-menu.tsx +191 -0
  1179. package/src/shell/titlebar/sidebar-view.test.ts +185 -0
  1180. package/src/shell/titlebar/sidebar-view.ts +208 -0
  1181. package/src/shell/titlebar/tab-group-drag-machine.ts +1479 -0
  1182. package/src/shell/titlebar/tab-groups-ui.tsx +1246 -0
  1183. package/src/shell/titlebar/tab-groups.css +269 -0
  1184. package/src/shell/titlebar/tab-groups.test.ts +667 -0
  1185. package/src/shell/titlebar/tab-groups.ts +496 -0
  1186. package/src/shell/titlebar/tab-hints-machine.test.ts +97 -0
  1187. package/src/shell/titlebar/tab-hints-machine.ts +79 -0
  1188. package/src/shell/titlebar/tab-load-machine.test.ts +178 -0
  1189. package/src/shell/titlebar/tab-load-machine.ts +233 -0
  1190. package/src/shell/titlebar/tab-nav.css +581 -0
  1191. package/src/shell/titlebar/tab-nav.tsx +891 -0
  1192. package/src/shell/titlebar/tab-order.test.ts +22 -0
  1193. package/src/shell/titlebar/tab-order.ts +24 -0
  1194. package/src/shell/titlebar/tab-popover-machine.test.ts +79 -0
  1195. package/src/shell/titlebar/tab-popover-machine.ts +92 -0
  1196. package/src/shell/titlebar/tab-popover.css +129 -0
  1197. package/src/shell/titlebar/tab-popover.tsx +144 -0
  1198. package/src/shell/titlebar/tab-rename-machine.test.ts +206 -0
  1199. package/src/shell/titlebar/tab-rename-machine.ts +297 -0
  1200. package/src/shell/titlebar/tab-strip.standalone.stories.tsx +19 -0
  1201. package/src/shell/titlebar/tab-strip.tsx +1228 -0
  1202. package/src/shell/titlebar/tab-title.test.ts +14 -0
  1203. package/src/shell/titlebar/tab-title.ts +6 -0
  1204. package/src/shell/titlebar/titlebar.css +197 -0
  1205. package/src/shell/titlebar/titlebar.tsx +1075 -0
  1206. package/src/shell/titlebar/windows-menu.test.ts +20 -0
  1207. package/src/shell/titlebar/windows-menu.tsx +193 -0
  1208. package/src/sst-env.d.ts +12 -0
  1209. package/src/theme-preload.test.ts +56 -0
  1210. package/src/tips/model.ts +155 -0
  1211. package/src/tips/queue.test.ts +43 -0
  1212. package/src/tips/queue.ts +46 -0
  1213. package/src/usage/dialog.css +8 -0
  1214. package/src/usage/dialog.standalone.stories.tsx +137 -0
  1215. package/src/usage/dialog.tsx +570 -0
  1216. package/src/usage/format.ts +39 -0
  1217. package/src/usage/limits.test.ts +141 -0
  1218. package/src/usage/limits.ts +189 -0
  1219. package/src/usage/machine.test.ts +128 -0
  1220. package/src/usage/machine.ts +159 -0
  1221. package/src/usage/model.tsx +55 -0
  1222. package/src/voice/call-machine.test.ts +245 -0
  1223. package/src/voice/call-machine.ts +327 -0
  1224. package/src/voice/call.ts +362 -0
  1225. package/src/voice/composer.tsx +300 -0
  1226. package/src/voice/context.tsx +152 -0
  1227. package/src/voice/coordination.test.ts +58 -0
  1228. package/src/voice/fixtures/history.ts +51 -0
  1229. package/src/voice/gate-machine.test.ts +91 -0
  1230. package/src/voice/gate-machine.ts +148 -0
  1231. package/src/voice/handoff.test.ts +35 -0
  1232. package/src/voice/handoff.ts +20 -0
  1233. package/src/voice/machine.test.ts +303 -0
  1234. package/src/voice/machine.ts +349 -0
  1235. package/src/voice/messages.test.ts +49 -0
  1236. package/src/voice/messages.ts +15 -0
  1237. package/src/voice/panel-machine.test.ts +106 -0
  1238. package/src/voice/panel-machine.ts +167 -0
  1239. package/src/voice/protocol.ts +62 -0
  1240. package/src/voice/replies.ts +71 -0
  1241. package/src/voice/reply-machine.test.ts +290 -0
  1242. package/src/voice/reply-machine.ts +303 -0
  1243. package/src/voice/search.test.ts +35 -0
  1244. package/src/voice/search.ts +134 -0
  1245. package/src/voice/spec.ts +114 -0
  1246. package/src/voice/tail-machine.test.ts +124 -0
  1247. package/src/voice/tail-machine.ts +155 -0
  1248. package/src/voice/tail.ts +55 -0
  1249. package/src/voice/tools.test.ts +320 -0
  1250. package/src/voice/tools.ts +336 -0
  1251. package/src/voice/transport-machine.test.ts +295 -0
  1252. package/src/voice/transport-machine.ts +338 -0
  1253. package/src/voice/transport.test.ts +295 -0
  1254. package/src/voice/transport.ts +313 -0
  1255. package/src/voice/voice.css +84 -0
  1256. package/src/workspaces/create.test.ts +120 -0
  1257. package/src/workspaces/create.ts +23 -0
  1258. package/src/workspaces/files/artifact.test.ts +103 -0
  1259. package/src/workspaces/files/artifact.ts +74 -0
  1260. package/src/workspaces/files/content-cache-accounting.test.ts +79 -0
  1261. package/src/workspaces/files/content-cache.ts +74 -0
  1262. package/src/workspaces/files/content-machine.test.ts +269 -0
  1263. package/src/workspaces/files/content-machine.ts +243 -0
  1264. package/src/workspaces/files/model.tsx +423 -0
  1265. package/src/workspaces/files/path.test.ts +76 -0
  1266. package/src/workspaces/files/path.ts +143 -0
  1267. package/src/workspaces/files/tree-machine.test.ts +300 -0
  1268. package/src/workspaces/files/tree-machine.ts +286 -0
  1269. package/src/workspaces/files/tree-store.ts +142 -0
  1270. package/src/workspaces/files/types.ts +85 -0
  1271. package/src/workspaces/files/view-cache.ts +164 -0
  1272. package/src/workspaces/files/watcher.test.ts +114 -0
  1273. package/src/workspaces/files/watcher.ts +42 -0
  1274. package/src/workspaces/inventory.test.ts +151 -0
  1275. package/src/workspaces/inventory.ts +64 -0
  1276. package/src/workspaces/location-machine.test.ts +135 -0
  1277. package/src/workspaces/location-machine.ts +159 -0
  1278. package/src/workspaces/location.tsx +111 -0
  1279. package/src/workspaces/path-key.ts +5 -0
  1280. package/src/workspaces/paths.test.ts +193 -0
  1281. package/src/workspaces/paths.ts +123 -0
  1282. package/src/workspaces/selection/combobox-machine.test.ts +286 -0
  1283. package/src/workspaces/selection/combobox-machine.ts +331 -0
  1284. package/src/workspaces/selection/dialog.css +234 -0
  1285. package/src/workspaces/selection/dialog.standalone.stories.tsx +66 -0
  1286. package/src/workspaces/selection/dialog.tsx +867 -0
  1287. package/src/workspaces/selection/domain.test.ts +603 -0
  1288. package/src/workspaces/selection/domain.ts +609 -0
  1289. package/src/workspaces/selection/picker.test.ts +37 -0
  1290. package/src/workspaces/selection/picker.tsx +77 -0
  1291. package/src/workspaces/selection/policy.ts +8 -0
  1292. package/src/workspaces/selection/queue-machine.test.ts +116 -0
  1293. package/src/workspaces/selection/queue-machine.ts +203 -0
  1294. package/src/workspaces/selection/tree-machine.test.ts +293 -0
  1295. package/src/workspaces/selection/tree-machine.ts +506 -0
  1296. package/test-browser/animated-presence-state.test.ts +134 -0
  1297. package/test-browser/auto-scroll.test.ts +111 -0
  1298. package/test-browser/browser-pane-model.test.ts +522 -0
  1299. package/test-browser/child-store-eviction.test.ts +86 -0
  1300. package/test-browser/command-palette-search.test.ts +157 -0
  1301. package/test-browser/command-palette.test.ts +262 -0
  1302. package/test-browser/composer-attachment-errors.test.tsx +140 -0
  1303. package/test-browser/composer-attachment-ownership.test.tsx +132 -0
  1304. package/test-browser/composer-drag-cancel.test.tsx +41 -0
  1305. package/test-browser/composer-file-search.test.ts +183 -0
  1306. package/test-browser/composer-ime.test.ts +58 -0
  1307. package/test-browser/composer-submit-loading.test.ts +235 -0
  1308. package/test-browser/composer-write-batch.test.ts +201 -0
  1309. package/test-browser/draft-history-cache.test.ts +139 -0
  1310. package/test-browser/elicitation-dock.test.ts +110 -0
  1311. package/test-browser/file-tree-store.test.ts +113 -0
  1312. package/test-browser/fixtures/model-selection.ts +646 -0
  1313. package/test-browser/message-page-publication.test.ts +46 -0
  1314. package/test-browser/model-selection.test.ts +25 -0
  1315. package/test-browser/motion-dom.test.ts +367 -0
  1316. package/test-browser/motion-spring.test.ts +75 -0
  1317. package/test-browser/pane-drag.test.tsx +136 -0
  1318. package/test-browser/panel-motion.test.ts +398 -0
  1319. package/test-browser/persisted-consumers.test.ts +40 -0
  1320. package/test-browser/playwright-config.test.ts +72 -0
  1321. package/test-browser/plugin-catalog.test.ts +67 -0
  1322. package/test-browser/plugin-link-check.test.ts +102 -0
  1323. package/test-browser/plugin-migrations.test.ts +170 -0
  1324. package/test-browser/plugin-primitives.test.ts +616 -0
  1325. package/test-browser/plugin-server-stream.test.ts +88 -0
  1326. package/test-browser/presence.test.ts +236 -0
  1327. package/test-browser/project-avatar-hover.test.ts +143 -0
  1328. package/test-browser/prompt-motion.test.ts +10 -0
  1329. package/test-browser/prompt-persistence.test.ts +312 -0
  1330. package/test-browser/prompt-scope.test.ts +15 -0
  1331. package/test-browser/provider-catalog.test.ts +54 -0
  1332. package/test-browser/pwa-route.test.ts +96 -0
  1333. package/test-browser/question-dock.test.ts +128 -0
  1334. package/test-browser/schema-persistence.test.ts +294 -0
  1335. package/test-browser/selected-effect.test.ts +36 -0
  1336. package/test-browser/server-connection-sync.test.ts +34 -0
  1337. package/test-browser/server-notification-state.test.ts +662 -0
  1338. package/test-browser/session-activity-elapsed.test.ts +62 -0
  1339. package/test-browser/session-background.test.ts +377 -0
  1340. package/test-browser/session-message-handoffs.test.ts +118 -0
  1341. package/test-browser/session-resolution.test.ts +385 -0
  1342. package/test-browser/settings-keybinds.test.ts +196 -0
  1343. package/test-browser/shell-panel.test.ts +219 -0
  1344. package/test-browser/sidebar-peek.test.ts +149 -0
  1345. package/test-browser/solid-router-cleanup.test.ts +66 -0
  1346. package/test-browser/solid-runtime.test.ts +95 -0
  1347. package/test-browser/solid-virtual.test.ts +249 -0
  1348. package/test-browser/ssh-composer.test.ts +41 -0
  1349. package/test-browser/ssh-health.test.ts +142 -0
  1350. package/test-browser/theme-preload.test.ts +9 -0
  1351. package/test-browser/timeline-cache.test.ts +571 -0
  1352. package/test-browser/timeline-projection.test.ts +363 -0
  1353. package/test-browser/toast-owner.test.ts +66 -0
  1354. package/test-browser/websearch-request.test.ts +277 -0
  1355. package/tsconfig.json +35 -0
  1356. package/vite.config.ts +62 -0
  1357. package/vite.icons.test.ts +133 -0
  1358. package/vite.icons.ts +65 -0
  1359. package/vite.js +142 -0
  1360. package/vite.pwa.ts +69 -0
@@ -0,0 +1,1106 @@
1
+ import { abort } from "@zyro-sec/util/abort"
2
+ import {
3
+ batch,
4
+ catchError,
5
+ createContext,
6
+ createMemo,
7
+ createRenderEffect,
8
+ createResource,
9
+ createRoot,
10
+ createSignal,
11
+ ErrorBoundary,
12
+ getOwner,
13
+ on,
14
+ onCleanup,
15
+ onMount,
16
+ runWithOwner,
17
+ untrack,
18
+ useContext,
19
+ type Accessor,
20
+ type JSX,
21
+ type Owner,
22
+ type ParentProps,
23
+ } from "solid-js"
24
+ import { createStore } from "solid-js/store"
25
+ import {
26
+ LifetimeContext,
27
+ liveAccessor,
28
+ PluginContext,
29
+ pluginIconName,
30
+ type Bridge,
31
+ type Entry,
32
+ } from "@zyro-sec/plugin/gui/host"
33
+ import type { BuiltinCatalog, BuiltinContext } from "@zyro-sec/plugin/gui/builtin"
34
+ import { Predicate } from "effect"
35
+ import { useDialog } from "@zyro-sec/ui/context/dialog"
36
+ import { pluralCategory, resolveTemplate } from "@zyro-sec/ui/context/i18n"
37
+ import { registerIcons } from "@zyro-sec/ui/icons/registry"
38
+ import {
39
+ LinkHandler,
40
+ type BaseContext,
41
+ type Cleanup,
42
+ type Context,
43
+ type Contract,
44
+ type DialogHandle,
45
+ type Dialogs,
46
+ type Link,
47
+ type Links,
48
+ type Live,
49
+ type Messages,
50
+ type Persisted,
51
+ type PluginOptions,
52
+ type Registry,
53
+ type SelectOptions,
54
+ type Ipc,
55
+ type IpcClient,
56
+ type IpcSpec,
57
+ type SessionRef,
58
+ type SetupContext,
59
+ type Token,
60
+ } from "@zyro-sec/plugin/gui"
61
+ import { OpenCode, type OpenCodeClient } from "@zyro-sec/client/promise"
62
+ import { useLanguage } from "@/runtime/i18n/language"
63
+ import {
64
+ createPluginDialogState,
65
+ transitionPluginDialog,
66
+ type PluginDialogEffect,
67
+ type PluginDialogEvent,
68
+ } from "./dialog-machine"
69
+ import { PluginAlertDialog, PluginConfirmDialog, PluginPromptDialog, PluginSelectDialog } from "./dialogs"
70
+ import { selectDisabled, selectHostReady, selectInstalled, selectMainFailed, selectServersReady } from "./machine"
71
+ import {
72
+ createPluginHostState,
73
+ selectPluginDefinitions,
74
+ selectPluginFailure,
75
+ selectPluginInstance,
76
+ selectPluginInstances,
77
+ selectPluginSettled,
78
+ selectPluginStatus,
79
+ transitionPluginHost,
80
+ type PluginHostEffect,
81
+ type PluginHostEvent,
82
+ } from "./instance-machine"
83
+ import { createStartupGate } from "./startup"
84
+ import { createSessionStore, whenLoaded } from "./stores"
85
+
86
+ type Contribution = { key: string; registry: string; plugin: string; value: Accessor<unknown> }
87
+
88
+ export type Item<T> = { readonly key: string; readonly plugin: string; readonly value: T }
89
+
90
+ /**
91
+ * The context the host builds: every `Setup<D>` of the definition receives it, and contributions read it as `Context`.
92
+ * It has the members only built-ins use, which `builtinContext` reads.
93
+ */
94
+ type InstanceContext = SetupContext<Entry> & BuiltinContext
95
+
96
+ type Instance = {
97
+ definition: Entry
98
+ context: InstanceContext
99
+ /** The instance's root, which owns setup and every scope under it. */
100
+ root: Owner | null
101
+ dispose: () => void
102
+ /** Runs `fn` when the instance goes away, as a cleanup a setup returns. */
103
+ own(fn: Cleanup): Cleanup
104
+ /** Opens the declared stores. Settles once the global stores have loaded. */
105
+ prepare(): Promise<readonly void[]>
106
+ /** Starts loading the declared session stores for a mounted session. */
107
+ preload(session: SessionRef): void
108
+ }
109
+
110
+ /** What a plugin's GUI reads of its plugin: its options, and the client of the server that runs it, read each time. */
111
+ export type PluginInput = { readonly options: PluginOptions; readonly client: () => OpenCodeClient | undefined }
112
+
113
+ /** The APIs a window context exposes as properties. */
114
+ type HostApis = Omit<BuiltinContext, keyof BaseContext | "provide" | "provideFor" | "use" | "main">
115
+
116
+ /**
117
+ * Creates one HostApi for a plugin instance, on the instance's first read of it. `register` withdraws what it is
118
+ * given with the caller's owner, else with the plugin. `builtin` is true for a plugin that ships with the app.
119
+ */
120
+ type HostApiFactory<T> = (
121
+ plugin: string,
122
+ owner: Owner | null,
123
+ context: Context,
124
+ register: (fn: Cleanup) => Cleanup,
125
+ builtin: boolean,
126
+ ) => T
127
+
128
+ /** The HostApis a window provides, by context property. The host itself provides `links` and `dialogs`. */
129
+ export type HostApiFactories = {
130
+ readonly [K in Exclude<keyof HostApis, "links" | "dialogs">]: HostApiFactory<HostApis[K]>
131
+ }
132
+
133
+ type Absent = Exclude<Live<never>, { readonly status: "active" }>
134
+
135
+ type HostState = {
136
+ entries: Record<string, Contribution[] | undefined>
137
+ contracts: Record<string, number | undefined>
138
+ }
139
+
140
+ // How long a plugin may load its window entry and global stores before it fails.
141
+ const activationTimeout = 30_000
142
+
143
+ type Stores = Record<string, Persisted<object> | ((session: SessionRef) => Persisted<object>)>
144
+
145
+ const pending: Absent = { status: "pending" }
146
+
147
+ const inactive = {
148
+ disabled: { status: "inactive", reason: "disabled" },
149
+ failed: { status: "inactive", reason: "failed" },
150
+ } as const satisfies Record<string, Absent>
151
+
152
+ const HostContext = createContext<ReturnType<typeof createHost>>()
153
+
154
+ export function usePluginHost() {
155
+ const host = useContext(HostContext)
156
+
157
+ if (!host) throw new Error("Plugin host is unavailable")
158
+
159
+ return host
160
+ }
161
+
162
+ type HostInput = {
163
+ definitions: Accessor<readonly Entry[]>
164
+ /** The plugins that stay off. Omitted with a bridge, whose plugin manager holds the user's settings. */
165
+ disabled?: Accessor<ReadonlySet<string>>
166
+ /** Main's side of a desktop window: its plugin manager lists the plugins and their enable settings. */
167
+ bridge?: Bridge
168
+ /** The ids of the plugins that ship with the app, which always run. */
169
+ builtins?: ReadonlySet<string>
170
+ /** Startup also waits for the servers plugins contribute (`PluginServersProvider`). */
171
+ servers?: boolean
172
+ apis: HostApiFactories
173
+ /**
174
+ * Runs `run` once the app interface has mounted, behind the HostApis writes made before it, or now when it has.
175
+ * Returns a cancel for a run that still waits.
176
+ */
177
+ whenMounted: (run: () => void) => () => void
178
+ /** The renderer client of an Ipc while it is available; omitted where there is no main process. */
179
+ ipc?: (token: Ipc) => IpcClient<IpcSpec> | undefined
180
+ /** What a plugin's GUI reads of its plugin: its options, and the client of the server that runs it. */
181
+ plugin?: (id: string) => PluginInput | undefined
182
+ /** How many times an Ipc became available. Reactive. */
183
+ generation?: (token: Ipc) => number
184
+ /** Main did not answer the window's subscribe to an Ipc. Reactive. */
185
+ ipcFailed?: (token: Ipc) => boolean
186
+ }
187
+
188
+ export function PluginHostProvider(props: ParentProps<HostInput>) {
189
+ const host = createHost(props)
190
+
191
+ return <HostContext.Provider value={host}>{props.children}</HostContext.Provider>
192
+ }
193
+
194
+ function createHost(input: HostInput) {
195
+ const language = useLanguage()
196
+ const owner = getOwner()
197
+ const provided = new Map<string, (consumer: string, signal: AbortSignal) => Live<unknown>>()
198
+ const generations = new Map<string, number>()
199
+
200
+ // Entries are indexed by registry and contracts versioned by token, so a change wakes only its own readers.
201
+ const [state, setState] = createStore<HostState>({ entries: {}, contracts: {} })
202
+
203
+ // A plain signal: instances and definitions must not become store proxies.
204
+ const [machine, setMachine] = createSignal(createPluginHostState<Instance>())
205
+ // Events a transition's own effects raise (an instance created, a setup that reloads) wait behind those effects.
206
+ const queue: PluginHostEvent<Instance>[] = []
207
+ // Each loading plugin's activation timer.
208
+ const timers = new Map<string, ReturnType<typeof setTimeout>>()
209
+
210
+ const memos = new Map<string, Accessor<readonly Item<unknown>[]>>()
211
+ const sequence = { value: 0 }
212
+
213
+ // The plugin that provides a token: the one whose id the token's id is, or prefixes.
214
+ const providers = new Map<string, string | undefined>()
215
+
216
+ const all = input.definitions
217
+
218
+ // The definitions the host starts with (the built-ins) hold the gate; plugins that join later never do.
219
+ const startup = createStartupGate({
220
+ bridge: input.bridge,
221
+ plugins: untrack(all).flatMap((definition) => (definition.windowEntry ? [definition.id] : [])),
222
+ servers: input.servers ?? false,
223
+ })
224
+
225
+ // Undefined while startup waits for the enable settings: nothing activates before then.
226
+ const disabled = createMemo(
227
+ () =>
228
+ input.disabled?.() ??
229
+ selectDisabled(
230
+ startup.state(),
231
+ all().map((definition) => definition.id),
232
+ input.builtins ?? new Set<string>(),
233
+ ),
234
+ undefined,
235
+ { equals: (a, b) => a === b || (!!a && !!b && a.size === b.size && [...a].every((id) => b.has(id))) },
236
+ )
237
+
238
+ const providerOf = (id: string) => {
239
+ const current = providers.get(id)
240
+
241
+ if (current) return current
242
+
243
+ // Tracked while unresolved: a plugin that joins later resolves its readers.
244
+ const definitions = all()
245
+
246
+ const found = definitions.find((definition) => owns(definition.id, id))
247
+
248
+ if (found) providers.set(id, found.id)
249
+
250
+ return found?.id
251
+ }
252
+
253
+ // Why a token has no active provider. Main-side providers report through the installed list.
254
+ const absent = (id: string, main: boolean): Absent => {
255
+ const plugin = providerOf(id)
256
+
257
+ if (!plugin) return inactive.disabled
258
+
259
+ if (main) {
260
+ if (disabled()?.has(plugin)) return inactive.disabled
261
+
262
+ return selectMainFailed(startup.state(), plugin) ? inactive.failed : pending
263
+ }
264
+
265
+ const status = selectPluginStatus(machine(), plugin)
266
+
267
+ if (status === "disabled") return inactive.disabled
268
+
269
+ if (status === "failed") return inactive.failed
270
+
271
+ // A renderer provider that is up but does not provide the token (e.g. on this platform) is not coming.
272
+ if (status === "active") return inactive.disabled
273
+
274
+ return pending
275
+ }
276
+
277
+ const contractLive = (token: Contract<unknown>, consumer: string, signal: AbortSignal): Live<unknown> => {
278
+ void state.contracts[token.id]
279
+
280
+ return provided.get(token.id)?.(consumer, signal) ?? absent(token.id, false)
281
+ }
282
+
283
+ // Reuses each item object while its value is unchanged so keyed renders do not remount.
284
+ const createItems = (id: string) => {
285
+ const cache = new Map<string, Item<unknown>>()
286
+
287
+ const created = runWithOwner(owner, () =>
288
+ createMemo(() => {
289
+ const next = (state.entries[id] ?? []).flatMap((entry) => {
290
+ const value = entry.value()
291
+
292
+ if (value === undefined) return []
293
+
294
+ const previous = cache.get(entry.key)
295
+
296
+ if (previous?.value === value) return [previous]
297
+
298
+ const item = { key: entry.key, plugin: entry.plugin, value }
299
+
300
+ cache.set(entry.key, item)
301
+
302
+ return [item]
303
+ })
304
+
305
+ if (cache.size > next.length) {
306
+ const live = new Set(next.map((item) => item.key))
307
+
308
+ cache.forEach((_, key) => {
309
+ if (!live.has(key)) cache.delete(key)
310
+ })
311
+ }
312
+
313
+ return next
314
+ }),
315
+ )
316
+
317
+ const memo = created ?? (() => [])
318
+
319
+ memos.set(id, memo)
320
+
321
+ return memo
322
+ }
323
+
324
+ const items = <T,>(registry: Registry<T>) => {
325
+ const memo = memos.get(registry.id) ?? createItems(registry.id)
326
+
327
+ // SAFETY: only `add` stores entries, under the id of the typed registry it was given, so this registry's items
328
+ // are T.
329
+ return memo() as readonly Item<T>[]
330
+ }
331
+
332
+ const list = <T,>(registry: Registry<T>) => items(registry).map((item) => item.value)
333
+
334
+ const pickLinkHandler = (link: Link) =>
335
+ list(LinkHandler)
336
+ .filter((item) => item.match(link))
337
+ .reduce<LinkHandler | undefined>(
338
+ (best, item) => (!best || (item.priority ?? 0) > (best.priority ?? 0) ? item : best),
339
+ undefined,
340
+ )
341
+
342
+ const links: Links = {
343
+ open(link) {
344
+ const handler = untrack(() => pickLinkHandler(link))
345
+
346
+ if (!handler) return false
347
+
348
+ handler.open(link)
349
+
350
+ return true
351
+ },
352
+ // Markdown asks from inside its render effect; untracked so a session or screen switch never reruns it.
353
+ exists: (link) => untrack(() => pickLinkHandler(link)?.exists?.(link) ?? false),
354
+ }
355
+
356
+ const dialog = useDialog()
357
+
358
+ const factories = {
359
+ ...input.apis,
360
+ links: () => links,
361
+ // Bound to the instance that asked, so an older async call after a disable or reload opens and closes nothing.
362
+ dialogs: (plugin, _, context, register): Dialogs => {
363
+ // `ended` runs when the dialog closes, however it closes, and when it can no longer open.
364
+ const open = (
365
+ render: (dialog: DialogHandle) => JSX.Element,
366
+ options?: { readonly replace?: boolean },
367
+ ended?: () => void,
368
+ ): DialogHandle => {
369
+ const id = `plugin:${plugin}:${sequence.value++}`
370
+ // This open alone: once it aborts, a deferred open neither mounts nor replaces another dialog.
371
+ const opening = new AbortController()
372
+ const edge = { state: createPluginDialogState(), cancel: () => {}, release: () => {} }
373
+ // Events an effect raises synchronously (the interface already mounted, the stack closing) wait behind it.
374
+ const queue: PluginDialogEvent[] = []
375
+
376
+ const dispatch = (event: PluginDialogEvent) => {
377
+ queue.push(event)
378
+
379
+ if (queue.length === 1) drain()
380
+ }
381
+
382
+ const drain = () => {
383
+ const event = queue[0]
384
+
385
+ if (!event) return
386
+
387
+ const next = transitionPluginDialog(edge.state, event)
388
+
389
+ edge.state = next.state
390
+ next.effects.forEach(run)
391
+ queue.shift()
392
+ drain()
393
+ }
394
+
395
+ // Each handle names its own dialog, so it never closes one another plugin or instance opened.
396
+ const handle = { close: () => dispatch({ type: "close" }) }
397
+
398
+ const run = (effect: PluginDialogEffect) => {
399
+ // Closes this dialog, not whichever is on top, when the plugin or the scope that opened it goes away.
400
+ if (effect.type === "register") return void (edge.release = register(handle.close))
401
+
402
+ // A dialog opened before the app interface mounts, as during setup, shows after its first render: never
403
+ // behind the startup screen, and never before a route that focuses itself as it mounts.
404
+ if (effect.type === "wait") return void (edge.cancel = input.whenMounted(() => dispatch({ type: "mounted" })))
405
+
406
+ if (effect.type === "cancel") return edge.cancel()
407
+
408
+ if (effect.type === "release") return void edge.release()
409
+
410
+ if (effect.type === "abort") return abort(opening)
411
+
412
+ if (effect.type === "close") return dialog.close(id)
413
+
414
+ if (effect.type === "ended") return ended?.()
415
+
416
+ void dialog[options?.replace ? "show" : "push"](
417
+ () => {
418
+ // The dialog's root disposes when it closes, another dialog replaces it, or the stack goes away.
419
+ onCleanup(() => dispatch({ type: "dismissed" }))
420
+
421
+ return (
422
+ <ErrorBoundary
423
+ fallback={(error) => {
424
+ onMount(() => {
425
+ handle.close()
426
+ fail(plugin, error)
427
+ })
428
+
429
+ return null
430
+ }}
431
+ >
432
+ <PluginContext.Provider value={context}>{untrack(() => render(handle))}</PluginContext.Provider>
433
+ </ErrorBoundary>
434
+ )
435
+ },
436
+ // Escape, a click outside, a replacing dialog, or an open the stack dropped.
437
+ () => dispatch({ type: "dismissed" }),
438
+ id,
439
+ // The stack mounts in a later transition. Its handle, its owner or the plugin ending before then keeps
440
+ // it closed.
441
+ AbortSignal.any([opening.signal, context.signal]),
442
+ )
443
+ }
444
+
445
+ dispatch({ type: "open", aborted: context.signal.aborted })
446
+
447
+ return handle
448
+ }
449
+
450
+ // Settles with the content's answer, or with `fallback` once the dialog ends without one; the first wins.
451
+ const ask = <T,>(fallback: T, content: (answer: (value: T) => void) => JSX.Element) =>
452
+ new Promise<T>((resolve) => {
453
+ open(
454
+ (handle) =>
455
+ content((value) => {
456
+ resolve(value)
457
+ handle.close()
458
+ }),
459
+ undefined,
460
+ () => resolve(fallback),
461
+ )
462
+ })
463
+
464
+ return {
465
+ open: (render, options) => open(render, options),
466
+ active: () => !!dialog.active,
467
+ confirm: (options) => ask(false, (answer) => <PluginConfirmDialog options={options} done={answer} />),
468
+ alert: (options) =>
469
+ ask(undefined, (answer) => <PluginAlertDialog options={options} done={() => answer(undefined)} />),
470
+ prompt: (options) =>
471
+ ask<string | undefined>(undefined, (answer) => <PluginPromptDialog options={options} done={answer} />),
472
+ select: <T,>(options: SelectOptions<T>) =>
473
+ ask<T | undefined>(undefined, (answer) => <PluginSelectDialog options={options} done={answer} />),
474
+ }
475
+ },
476
+ } satisfies { readonly [K in keyof HostApis]: HostApiFactory<HostApis[K]> }
477
+
478
+ const dispatch = (event: PluginHostEvent<Instance>) => {
479
+ queue.push(event)
480
+
481
+ if (queue.length === 1) untrack(drain)
482
+ }
483
+
484
+ const drain = () => {
485
+ const event = queue[0]
486
+
487
+ if (!event) return
488
+
489
+ const next = transitionPluginHost(machine(), event)
490
+
491
+ // A reader of the state or an effect that throws must not stop the queue or skip the other effects. Promise.try
492
+ // runs each synchronously and keeps its throw to itself.
493
+ void Promise.try(() => setMachine(next.state)).catch((cause: unknown) => console.error("[plugin] host", cause))
494
+ next.effects.forEach(
495
+ (effect) => void Promise.try(() => run(effect)).catch((cause: unknown) => crashed(effect, cause)),
496
+ )
497
+ queue.shift()
498
+ drain()
499
+ }
500
+
501
+ // An effect of a running attempt that throws fails that attempt; any other is only logged.
502
+ const crashed = (effect: PluginHostEffect<Instance>, cause: unknown) => {
503
+ if ("attempt" in effect) return dispatch({ type: "failed", id: effect.id, attempt: effect.attempt, cause })
504
+
505
+ console.error(`[plugin] ${"id" in effect ? effect.id : effect.instance.definition.id}`, cause)
506
+ }
507
+
508
+ const run = (effect: PluginHostEffect<Instance>) => {
509
+ if (effect.type === "load")
510
+ // The current language's catalog loads with the entry, so the first render is already translated.
511
+ return void Promise.all([
512
+ Promise.try(effect.load),
513
+ Promise.try(() => loadMessages(effect.definition.i18n, language.locale())),
514
+ ]).then(
515
+ ([module, messages]) =>
516
+ dispatch({ type: "loaded", id: effect.id, attempt: effect.attempt, setup: module.default, messages }),
517
+ (cause: unknown) => dispatch({ type: "failed", id: effect.id, attempt: effect.attempt, cause }),
518
+ )
519
+
520
+ if (effect.type === "create")
521
+ return void runWithOwner(owner, () =>
522
+ createRoot((dispose) => {
523
+ const root = getOwner()
524
+
525
+ // Caught here: inside a root, Solid hands a throw to the nearest error boundary, the app's own, and never
526
+ // returns it to the caller.
527
+ try {
528
+ const instance = createInstance(effect.definition, dispose, root, effect.messages)
529
+
530
+ // Setup and every scope under it read the plugin's context, e.g. `createKeyed` with a token.
531
+ if (root) root.context = { ...root.context, [PluginContext.id]: instance.context }
532
+
533
+ dispatch({ type: "created", id: effect.id, attempt: effect.attempt, instance, setup: effect.setup })
534
+ } catch (cause) {
535
+ dispose()
536
+ dispatch({ type: "failed", id: effect.id, attempt: effect.attempt, cause })
537
+ }
538
+ }),
539
+ )
540
+
541
+ if (effect.type === "prepare")
542
+ // Global stores load in their storage namespace's one read before setup, so setup reads them as plain values.
543
+ return void Promise.try(effect.instance.prepare).then(
544
+ () => dispatch({ type: "prepared", id: effect.id, attempt: effect.attempt }),
545
+ (cause: unknown) => dispatch({ type: "failed", id: effect.id, attempt: effect.attempt, cause }),
546
+ )
547
+
548
+ if (effect.type === "start") return runWithOwner(effect.instance.root, () => start(effect))
549
+
550
+ if (effect.type === "dispose") return effect.instance.dispose()
551
+
552
+ if (effect.type === "timer.start") {
553
+ clearTimeout(timers.get(effect.id))
554
+ timers.set(
555
+ effect.id,
556
+ setTimeout(() => dispatch({ type: "timeout", id: effect.id, attempt: effect.attempt }), activationTimeout),
557
+ )
558
+
559
+ return
560
+ }
561
+
562
+ if (effect.type === "timer.stop") {
563
+ clearTimeout(timers.get(effect.id))
564
+ timers.delete(effect.id)
565
+
566
+ return
567
+ }
568
+
569
+ if (effect.type === "forget")
570
+ return providers.forEach((plugin, token) => {
571
+ if (plugin === effect.id) providers.delete(token)
572
+ })
573
+
574
+ console.error(`[plugin] ${effect.id}`, effect.cause)
575
+ }
576
+
577
+ // Setup runs synchronously inside the plugin root so its effects and memos are owned.
578
+ const start = (effect: Extract<PluginHostEffect<Instance>, { type: "start" }>) => {
579
+ const failed = (cause: unknown) => dispatch({ type: "failed", id: effect.id, attempt: effect.attempt, cause })
580
+ const sync = { running: true }
581
+ // SAFETY: the host context implements the parameter of every `Setup<D>` of this definition.
582
+ const setup = effect.setup as (ctx: InstanceContext) => Cleanup | void
583
+
584
+ // Errors from the plugin's own effects, at setup or later, fail the plugin and nothing else. One raised during
585
+ // setup fails it before it starts; a later one waits for the effect that threw to finish.
586
+ catchError(
587
+ () =>
588
+ untrack(() => {
589
+ const returned = setup(effect.instance.context)
590
+
591
+ // A returned cleanup runs when the plugin goes away, as server and TUI plugins' do.
592
+ if (Predicate.isFunction(returned)) return void effect.instance.own(returned)
593
+
594
+ if (!Predicate.isPromiseLike(returned)) return
595
+
596
+ // Do not await invalid setup, but consume its eventual rejection after the instance is aborted.
597
+ void Promise.resolve(returned).catch((cause: unknown) => console.error(`[plugin] ${effect.id}`, cause))
598
+ throw new Error("Window setup must be synchronous. Start async work with createKeyed or createLatest.")
599
+ }),
600
+ (cause) => (sync.running ? failed(cause) : queueMicrotask(() => failed(cause))),
601
+ )
602
+
603
+ sync.running = false
604
+ // A failure setup raised is queued ahead of this, so the machine ignores it.
605
+ dispatch({ type: "started", id: effect.id, attempt: effect.attempt })
606
+ }
607
+
608
+ const createInstance = (definition: Entry, dispose: () => void, root: Owner | null, initial: Messages): Instance => {
609
+ const plugin = definition.id
610
+ const controller = new AbortController()
611
+ const cleanups = new Set<Cleanup>()
612
+
613
+ const [catalog] = createResource(language.locale, (locale) => loadMessages(definition.i18n, locale), {
614
+ initialValue: initial,
615
+ })
616
+
617
+ const messages = () => catalog.latest
618
+
619
+ // Promise.try runs the cleanup synchronously and isolates a throw from the others.
620
+ const release = (fn: Cleanup) =>
621
+ void Promise.try(fn).catch((cause: unknown) => console.error(`[plugin] ${plugin}`, cause))
622
+
623
+ const own = (fn: Cleanup): Cleanup => {
624
+ // Work that outlives the plugin, e.g. a promise callback, is released as soon as it registers.
625
+ if (controller.signal.aborted) {
626
+ release(fn)
627
+
628
+ return () => {}
629
+ }
630
+
631
+ const cleanup = () => {
632
+ if (cleanups.delete(cleanup)) return fn()
633
+ }
634
+
635
+ cleanups.add(cleanup)
636
+
637
+ return cleanup
638
+ }
639
+
640
+ // The plugin went away, or the scope registering (e.g. through a captured owner) already ended.
641
+ const late = () => controller.signal.aborted || !!useContext(LifetimeContext)?.ended
642
+
643
+ // Withdrawn with the current owner, or with the plugin when there is none (after an await).
644
+ const register = (fn: Cleanup): Cleanup => {
645
+ if (late()) {
646
+ release(fn)
647
+
648
+ return () => {}
649
+ }
650
+
651
+ const cleanup = own(fn)
652
+ const scope = getOwner()
653
+
654
+ if (scope && scope !== root) onCleanup(() => void cleanup())
655
+
656
+ return cleanup
657
+ }
658
+
659
+ const clients = new Map<string, { client: IpcClient<IpcSpec>; live: Live<unknown> }>()
660
+
661
+ // One accessor per token, and one Live object per transition, so readers re-run only when the provider changes.
662
+ const ipcLive = (token: Ipc): Live<unknown> => {
663
+ if (!input.ipc) return inactive.disabled
664
+
665
+ const client = input.ipc(token)
666
+
667
+ if (!client) {
668
+ const reason = absent(token.id, true)
669
+
670
+ // A provider that may still start, but whose subscribe failed, is not coming until main provides it again.
671
+ return reason === pending && input.ipcFailed?.(token) ? inactive.failed : reason
672
+ }
673
+
674
+ const generation = input.generation?.(token) ?? 1
675
+ const cached = clients.get(token.id)
676
+
677
+ if (cached?.client === client && cached.live.status === "active" && cached.live.generation === generation)
678
+ return cached.live
679
+
680
+ const value = Object.assign({}, client, {
681
+ on: (name: string, listener: Parameters<typeof client.on>[1]) => register(client.on(name, listener)),
682
+ })
683
+
684
+ const live = { status: "active", value, generation } as const
685
+
686
+ clients.set(token.id, { client, live })
687
+
688
+ return live
689
+ }
690
+
691
+ const lives = new Map<string, Accessor<Live<unknown>>>()
692
+
693
+ const liveOf = (token: Token) => {
694
+ const existing = lives.get(token.id)
695
+
696
+ if (existing) return existing
697
+
698
+ const read = liveAccessor(token.kind === "contract" ? () => contractLive(token, plugin, controller.signal) : () => ipcLive(token))
699
+
700
+ lives.set(token.id, read)
701
+
702
+ return read
703
+ }
704
+
705
+ const mains = new Map<string, IpcClient<IpcSpec>>()
706
+
707
+ // The client of the plugin's own Ipc: calls wait while its main entry starts and reject once it cannot answer.
708
+ const mainClient = (token: Ipc): IpcClient<IpcSpec> => {
709
+ if (!owns(plugin, token.id)) throw new Error(`${plugin} calls only its own main entry, not Ipc "${token.id}"`)
710
+
711
+ const existing = mains.get(token.id)
712
+
713
+ if (existing) return existing
714
+
715
+ // SAFETY: an Ipc's active value is the client `ipcLive` builds for it.
716
+ const read = liveOf(token) as Accessor<Live<IpcClient<IpcSpec>>>
717
+
718
+ const unavailable = (reason: string) => new Error(`Ipc "${token.id}" is unavailable: ${reason}`)
719
+
720
+ const ready = (): Promise<IpcClient<IpcSpec>> => {
721
+ // A client kept past the plugin's instance never reaches main again, even while main still provides.
722
+ if (controller.signal.aborted) return Promise.reject(unavailable("the plugin went away"))
723
+
724
+ const current = untrack(read)
725
+
726
+ if (current.status === "active") return Promise.resolve(current.value)
727
+
728
+ if (current.status === "inactive") return Promise.reject(unavailable(current.reason))
729
+
730
+ return new Promise((resolve, reject) =>
731
+ runWithOwner(owner, () =>
732
+ createRoot((dispose) => {
733
+ const stop = () => {
734
+ controller.signal.removeEventListener("abort", aborted)
735
+ dispose()
736
+ }
737
+
738
+ const aborted = () => {
739
+ stop()
740
+ reject(unavailable("the plugin went away"))
741
+ }
742
+
743
+ controller.signal.addEventListener("abort", aborted)
744
+
745
+ createRenderEffect(
746
+ on(
747
+ read,
748
+ (live) => {
749
+ if (live.status === "pending") return
750
+
751
+ stop()
752
+
753
+ if (live.status === "active") return resolve(live.value)
754
+
755
+ reject(unavailable(live.reason))
756
+ },
757
+ { defer: true },
758
+ ),
759
+ )
760
+ }),
761
+ ),
762
+ )
763
+ }
764
+
765
+ const methods = Object.fromEntries(
766
+ Object.keys(token.spec.methods).map((name) => [
767
+ name,
768
+ (...args: readonly unknown[]) =>
769
+ ready().then((client) => {
770
+ const method = Predicate.hasProperty(client, name) ? client[name] : undefined
771
+
772
+ if (!isMethod(method)) throw unavailable(`no method "${name}"`)
773
+
774
+ return method(...args)
775
+ }),
776
+ ]),
777
+ )
778
+
779
+ const client = Object.assign(methods, {
780
+ state() {
781
+ const live = read()
782
+
783
+ return live.status === "active" ? live.value.state() : undefined
784
+ },
785
+ on(name: string, listener: Parameters<IpcClient<IpcSpec>["on"]>[1]) {
786
+ // Follows the main entry across restarts: each active client gets the listener, removed when it changes.
787
+ return register(
788
+ runWithOwner(root, () =>
789
+ createRoot((dispose) => {
790
+ createRenderEffect(() => {
791
+ const live = read()
792
+
793
+ if (live.status === "active") live.value.on(name, listener)
794
+ })
795
+
796
+ return dispose
797
+ }),
798
+ ) ?? (() => {}),
799
+ )
800
+ },
801
+ })
802
+
803
+ // SAFETY: `methods` has one function per method of the token's spec, as `IpcClient` types it.
804
+ const typed = client as IpcClient<IpcSpec>
805
+
806
+ mains.set(token.id, typed)
807
+
808
+ return typed
809
+ }
810
+
811
+ const stores: Stores = {}
812
+
813
+ // Each declared icon under its app-wide name, which `ctx.icons` gives the plugin.
814
+ const declared = Object.entries(definition.icons ?? {}).map(([name, source]) => ({
815
+ name,
816
+ id: pluginIconName(plugin, name),
817
+ source,
818
+ }))
819
+
820
+ const icons = Object.fromEntries(declared.map((icon) => [icon.name, icon.id]))
821
+
822
+ // The artwork draws from before setup until the plugin goes away. A value that is not an SVG document throws
823
+ // here, which fails the plugin as it starts.
824
+ own(registerIcons(Object.fromEntries(declared.map((icon) => [icon.id, icon.source]))))
825
+
826
+ const gui = input.plugin?.(plugin)
827
+
828
+ const context = {
829
+ id: plugin,
830
+ options: gui?.options ?? {},
831
+ get client() {
832
+ return gui?.client() ?? unavailableClient()
833
+ },
834
+ signal: controller.signal,
835
+ add<T>(registry: Registry<T>, item: T | (() => T | undefined)) {
836
+ if (late()) return () => {}
837
+
838
+ // Promise callbacks may have no owner; fall back to the plugin root.
839
+ const read =
840
+ // SAFETY: a function item is the SDK's reactive form; registries take no function values.
841
+ // oxlint-disable-next-line anti-slop/no-runtime-typeof -- see SAFETY above
842
+ typeof item === "function"
843
+ ? runWithOwner(getOwner() ?? root, () => createMemo(item as () => T | undefined))
844
+ : () => item
845
+
846
+ const key = `${plugin}/${++sequence.value}`
847
+
848
+ setState("entries", registry.id, (entries = []) => [
849
+ ...entries,
850
+ { key, registry: registry.id, plugin, value: read ?? (() => undefined) },
851
+ ])
852
+
853
+ return register(() =>
854
+ setState("entries", registry.id, (entries = []) => entries.filter((entry) => entry.key !== key)),
855
+ )
856
+ },
857
+ list,
858
+ provide<T>(token: Contract<T> | Ipc, impl: T) {
859
+ if (token.kind === "ipc") throw new Error("Ipcs are provided by a plugin's main entry")
860
+
861
+ return context.provideFor(token, () => impl)
862
+ },
863
+ provideFor<T>(token: Contract<T>, bind: (consumer: string, signal: AbortSignal) => T) {
864
+ if (!owns(plugin, token.id)) throw new Error(`${plugin} provides only its own contracts, not "${token.id}"`)
865
+
866
+ if (late()) return () => {}
867
+
868
+ const generation = (generations.get(token.id) ?? 0) + 1
869
+
870
+ generations.set(token.id, generation)
871
+
872
+ const clients = new WeakMap<AbortSignal, Live<T>>()
873
+
874
+ const entry = (consumer: string, signal: AbortSignal) => {
875
+ const previous = clients.get(signal)
876
+
877
+ if (previous) return previous
878
+ const live = { status: "active", value: untrack(() => bind(consumer, signal)), generation } as const
879
+ clients.set(signal, live)
880
+
881
+ return live
882
+ }
883
+
884
+ provided.set(token.id, entry)
885
+ setState("contracts", token.id, (version = 0) => version + 1)
886
+
887
+ return register(() => {
888
+ if (provided.get(token.id) !== entry) return
889
+
890
+ provided.delete(token.id)
891
+ setState("contracts", token.id, (version = 0) => version + 1)
892
+ })
893
+ },
894
+ use: liveOf,
895
+ main: mainClient,
896
+ stores,
897
+ icons,
898
+ t(key: string, params?: Record<string, string | number | boolean>) {
899
+ const template = messages()[key]
900
+
901
+ if (template !== undefined) return resolveTemplate(template, params)
902
+
903
+ // SAFETY: a key the plugin's catalog lacks is one of the app's shared keys, such as `common.*`.
904
+ return language.t(key as Parameters<typeof language.t>[0], params)
905
+ },
906
+ plural(key: string, count: number, params?: Record<string, string | number | boolean>) {
907
+ const current = messages()
908
+ const template = current[`${key}.${pluralCategory(language.intl(), count)}`] ?? current[`${key}.other`]
909
+
910
+ if (template !== undefined) return resolveTemplate(template, { ...params, count })
911
+
912
+ // SAFETY: a key the plugin's catalog lacks is one of the app's shared keys, such as `common.*`.
913
+ return language.plural(key as Parameters<typeof language.plural>[0], count, params)
914
+ },
915
+ }
916
+
917
+ // Each HostApi is created on the instance's first read of it.
918
+ const created = new Map<string, HostApis[keyof HostApis]>()
919
+
920
+ Object.defineProperties(
921
+ context,
922
+ Object.fromEntries(
923
+ Object.entries(factories).map(([name, create]) => [
924
+ name,
925
+ {
926
+ enumerable: true,
927
+ get() {
928
+ if (!created.has(name)) created.set(name, create(plugin, root, typed, register, !gui))
929
+
930
+ return created.get(name)
931
+ },
932
+ },
933
+ ]),
934
+ ),
935
+ )
936
+
937
+ // SAFETY: one implementation serves `Context` and every `SetupContext`: the declarations' records are built from
938
+ // the definition, and every HostApi is a getter defined above.
939
+ // oxlint-disable-next-line anti-slop/no-chained-type-assertions -- see SAFETY above
940
+ const typed = context as unknown as InstanceContext
941
+
942
+ const sessions: ReturnType<typeof createSessionStore<object>>[] = []
943
+
944
+ return {
945
+ definition,
946
+ context: typed,
947
+ root,
948
+ own,
949
+ prepare() {
950
+ const storage = typed.storage
951
+
952
+ const loaded = windowStores(definition).flatMap(([name, declaration]) => {
953
+ const options = {
954
+ schema: declaration.schema,
955
+ initial: declaration.initial,
956
+ from: declaration.builtinFrom ?? declaration.from,
957
+ }
958
+
959
+ if (declaration.scope === "global") {
960
+ const handle = storage.store(name, { ...options, scope: "global" })
961
+
962
+ stores[name] = handle
963
+
964
+ return [whenLoaded(handle)]
965
+ }
966
+
967
+ const store = createSessionStore({
968
+ open: (session) => storage.store(name, { ...options, scope: { session } }),
969
+ owner: root,
970
+ sessions: typed.sessions,
971
+ })
972
+
973
+ stores[name] = store.get
974
+ sessions.push(store)
975
+
976
+ return []
977
+ })
978
+
979
+ if (sessions.length > 0) own(() => sessions.forEach((store) => store.dispose()))
980
+
981
+ return Promise.all(loaded)
982
+ },
983
+ preload: (session) => sessions.forEach((store) => store.get(session)),
984
+ dispose() {
985
+ abort(controller)
986
+ // One batch: every contribution and contract of the plugin disappears in the same frame.
987
+ batch(() => {
988
+ Array.from(cleanups).reverse().forEach(release)
989
+ cleanups.clear()
990
+ Object.entries(state.entries).forEach(([registry, entries]) => {
991
+ if (!entries?.some((entry) => entry.plugin === plugin)) return
992
+
993
+ setState("entries", registry, (list = []) => list.filter((entry) => entry.plugin !== plugin))
994
+ })
995
+ })
996
+ // A throwing onCleanup in the plugin's root must not stop the host disposing the rest.
997
+ release(dispose)
998
+ },
999
+ }
1000
+ }
1001
+
1002
+ // A contribution that fails to render renders nothing; the plugin and its other contributions stay.
1003
+ const fail = (id: string, cause: unknown) => dispatch({ type: "render.failed", id, cause })
1004
+
1005
+ // A memo, so every disabled status publishes before render effects read it.
1006
+ createMemo(() => dispatch({ type: "reconcile", definitions: all(), disabled: disabled() }))
1007
+
1008
+ // Tells the startup gate as each plugin it waits for settles.
1009
+ createRenderEffect(() => {
1010
+ const gate = startup.state()
1011
+
1012
+ if (gate.status !== "activating") return
1013
+
1014
+ const current = machine()
1015
+
1016
+ gate.pending.forEach((id) => {
1017
+ if (selectPluginSettled(current, id)) startup.dispatch({ type: "plugin.settled", id })
1018
+ })
1019
+ })
1020
+
1021
+ onCleanup(() => dispatch({ type: "disposed" }))
1022
+
1023
+ return {
1024
+ state,
1025
+ /** The app interface renders. Once open it stays open, so enabling or reloading a plugin never unmounts it. */
1026
+ ready: createMemo(() => selectHostReady(startup.state())),
1027
+ /** The contributed servers are known too, which the desktop app waits for. */
1028
+ serversReady: createMemo(() => selectServersReady(startup.state())),
1029
+ /** The plugins main lists; empty on the web and until main answers. */
1030
+ installed: createMemo(() => selectInstalled(startup.state())),
1031
+ /** Whether the plugin ships with the app. What only built-ins may contribute is read through it. */
1032
+ builtin: (id: string) => input.builtins?.has(id) ?? false,
1033
+ /** A plugin's main entry cannot answer. Reactive. */
1034
+ mainFailed: (id: string) => selectMainFailed(startup.state(), id),
1035
+ /** Reports what the startup gate waits for. */
1036
+ gate: startup.dispatch,
1037
+ list,
1038
+ items,
1039
+ links,
1040
+ definitions: () => selectPluginDefinitions(machine(), all()),
1041
+ /** Undefined while the plugin waits for the enable settings. Reactive. */
1042
+ status: (id: string) => selectPluginStatus(machine(), id),
1043
+ /** The plugin's last error, while it failed or a contribution of its running instance did. Reactive. */
1044
+ failure: (id: string) => selectPluginFailure(machine(), id),
1045
+ context: (id: string): Context | undefined => selectPluginInstance(machine(), id)?.context,
1046
+ fail,
1047
+ /** Starts loading every active plugin's declared session stores for a session that mounts. */
1048
+ preload(session: SessionRef) {
1049
+ selectPluginInstances(untrack(machine)).forEach((instance) => instance.preload(session))
1050
+ },
1051
+ /** `next` replaces the definition, e.g. after a development hot update. */
1052
+ reload: (id: string, next?: Entry) => dispatch({ type: "reload", id, next }),
1053
+ }
1054
+ }
1055
+
1056
+ /** The window's declared stores. */
1057
+ function windowStores(definition: Entry) {
1058
+ return Object.entries(definition.stores ?? {})
1059
+ }
1060
+
1061
+ /** The client `unavailableClient` made, once a plugin first read it. */
1062
+ type Unavailable = { client?: OpenCodeClient }
1063
+
1064
+ const unavailable: Unavailable = {}
1065
+
1066
+ /** The client a plugin reads while the server that runs it is unreachable: every call rejects. */
1067
+ function unavailableClient() {
1068
+ return (unavailable.client ??= OpenCode.make({
1069
+ baseUrl: "http://unavailable.invalid/",
1070
+ fetch: Object.assign(() => Promise.reject(new Error("The server that runs this plugin is unavailable")), {
1071
+ preconnect() {},
1072
+ }),
1073
+ }))
1074
+ }
1075
+
1076
+ // An Ipc client from the bridge is plain JavaScript; check a method before calling it.
1077
+ // SAFETY: the method's output schema decodes its reply; the `IpcClient` the plugin holds types it.
1078
+ // oxlint-disable-next-line anti-slop/no-unknown-returns -- see SAFETY above
1079
+ function isMethod(value: unknown): value is (...args: readonly unknown[]) => Promise<unknown> {
1080
+ return Predicate.isFunction(value)
1081
+ }
1082
+
1083
+ /** Whether a plugin owns a token: its id is the plugin's, or is under it (`<plugin>.<name>`). */
1084
+ function owns(plugin: string, id: string) {
1085
+ return id === plugin || id.startsWith(`${plugin}.`)
1086
+ }
1087
+
1088
+ /** English merged under the locale's messages. A catalog that fails to load leaves English. */
1089
+ async function loadMessages(catalog: BuiltinCatalog | undefined, locale: string): Promise<Messages> {
1090
+ const english = catalog?.en ?? {}
1091
+ const source = catalog?.[locale]
1092
+
1093
+ if (!source || locale === "en") return english
1094
+
1095
+ const loaded =
1096
+ // SAFETY: a catalog entry is either inline messages or the loader of a locale module, as `BuiltinCatalog` types it.
1097
+ // oxlint-disable-next-line anti-slop/no-runtime-typeof -- see SAFETY above
1098
+ typeof source === "function"
1099
+ ? await source().then(
1100
+ (module) => module.default,
1101
+ () => ({}),
1102
+ )
1103
+ : source
1104
+
1105
+ return { ...english, ...loaded }
1106
+ }