@gloom-sh/terminal 0.20.3 → 0.20.5

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 (348) hide show
  1. package/README.md +2 -0
  2. package/bin/gloom +9 -0
  3. package/bin/without-bun.cjs +98 -0
  4. package/package.json +3 -1
  5. package/src/account/auth-dialog.tsx +17 -0
  6. package/src/api-client/data.ts +144 -35
  7. package/src/api-client/fx-interventions.ts +64 -0
  8. package/src/api-client/index.ts +1 -0
  9. package/src/api-client/release-summaries.ts +21 -0
  10. package/src/api-client/types/econ.ts +12 -0
  11. package/src/api-client/yield-curves.ts +1 -1
  12. package/src/app/global-shortcuts.ts +4 -1
  13. package/src/app/keybindings/actions.ts +8 -2
  14. package/src/app/keybindings/config.ts +2 -1
  15. package/src/app/keybindings/index.ts +1 -0
  16. package/src/app/keybindings/labels.ts +6 -1
  17. package/src/app/keybindings/resolve.ts +23 -4
  18. package/src/app/keybindings/terminal-keys.ts +35 -0
  19. package/src/app/pane-runtime/index.tsx +2 -2
  20. package/src/app/pane-runtime/ticker-open-runtime.ts +274 -67
  21. package/src/architecture/ui-literals-allowlist.json +1 -1
  22. package/src/capabilities/chart-series.ts +27 -1
  23. package/src/cli/commands/keybindings.ts +5 -5
  24. package/src/cli/commands/market.ts +154 -21
  25. package/src/cli/commands/news-search.ts +60 -10
  26. package/src/cli/commands/overview.ts +16 -1
  27. package/src/cli/commands/plugins.ts +27 -5
  28. package/src/cli/commands/remote.ts +16 -17
  29. package/src/cli/commands/system.ts +20 -4
  30. package/src/cli/commands/ticker.ts +60 -19
  31. package/src/cli/fx-forward.ts +25 -7
  32. package/src/cli/glossary.ts +19 -5
  33. package/src/cli/history-rows.ts +5 -3
  34. package/src/cli/index.ts +8 -8
  35. package/src/cli/known-gaps.ts +27 -1
  36. package/src/cli/listing-arg.ts +11 -1
  37. package/src/cli/name-entries.ts +5 -1
  38. package/src/cli/not-a-ticker.ts +4 -0
  39. package/src/cli/pane-functions/function-help.ts +5 -5
  40. package/src/cli/report-tables.ts +18 -6
  41. package/src/cli/result.ts +15 -7
  42. package/src/cli/types.ts +2 -0
  43. package/src/components/chart/composite/axis-overlays.tsx +22 -0
  44. package/src/components/chart/composite/composite-chart.tsx +54 -13
  45. package/src/components/chart/composite/event-captions.ts +109 -0
  46. package/src/components/chart/composite/event-guides.ts +74 -0
  47. package/src/components/chart/composite/rasterizer.ts +2 -0
  48. package/src/components/chart/composite/text-renderer.ts +2 -0
  49. package/src/components/chart/composite/types.ts +31 -0
  50. package/src/components/command-bar/layout-items/focused-pane.ts +5 -5
  51. package/src/components/command-bar/pane-settings.ts +2 -2
  52. package/src/components/command-bar/routes/root/provider-search.ts +5 -4
  53. package/src/components/command-bar/routes/root/results.ts +6 -2
  54. package/src/components/command-bar/routes/ticker-search/results.ts +51 -0
  55. package/src/components/command-bar/routes/ticker-search/route.ts +3 -2
  56. package/src/components/input-search-bar.tsx +9 -2
  57. package/src/components/layout/detached-pane-shell.tsx +1 -1
  58. package/src/components/layout/floating-pane.tsx +5 -1
  59. package/src/components/layout/pane/footer/index.tsx +21 -14
  60. package/src/components/layout/pane/footer/model.ts +6 -0
  61. package/src/components/layout/pane/header.tsx +2 -0
  62. package/src/components/layout/shell/action-menu-overlay.tsx +10 -5
  63. package/src/components/layout/shell/active-drag.ts +149 -105
  64. package/src/components/layout/shell/drag/drop-zones.ts +162 -0
  65. package/src/components/layout/shell/drag/index.ts +47 -218
  66. package/src/components/layout/shell/drag/live.ts +10 -3
  67. package/src/components/layout/shell/drag/overlays.tsx +182 -5
  68. package/src/components/layout/shell/drag/runtime.ts +29 -6
  69. package/src/components/layout/shell/drag/shared-edges.ts +156 -0
  70. package/src/components/layout/shell/index.tsx +11 -6
  71. package/src/components/layout/shell/menu.ts +11 -2
  72. package/src/components/layout/shell/native/pointer-runtime.ts +25 -0
  73. package/src/components/layout/shell/native/window-state.ts +2 -2
  74. package/src/components/layout/shell/pane/capture.ts +4 -1
  75. package/src/components/layout/shell/pane/layers.tsx +71 -7
  76. package/src/components/layout/shell/terminal-pointer-runtime.ts +18 -9
  77. package/src/components/layout/shell/window-mode/index.ts +8 -10
  78. package/src/components/layout/status-bar.tsx +6 -1
  79. package/src/components/layout/window-edit/mode.ts +39 -7
  80. package/src/components/layout/window-edit/presentation.ts +1 -1
  81. package/src/components/onboarding/first-run-workspace.ts +44 -2
  82. package/src/components/onboarding/onboarding-frame.tsx +11 -2
  83. package/src/components/onboarding/onboarding-keyboard.ts +20 -0
  84. package/src/components/onboarding/onboarding-wizard.tsx +16 -11
  85. package/src/components/onboarding/portfolio-step/positions-panel.tsx +62 -1
  86. package/src/components/onboarding/use-onboarding-progress.ts +12 -4
  87. package/src/components/pane-settings-dialog/desktop.tsx +2 -2
  88. package/src/components/pane-settings-dialog/tui.tsx +2 -2
  89. package/src/components/pane-settings-dialog/value.ts +6 -0
  90. package/src/components/pane-settings-dialog.tsx +3 -3
  91. package/src/components/reader/detail-reader.tsx +4 -0
  92. package/src/components/ui/button.tsx +2 -0
  93. package/src/components/ui/choice-dialog.tsx +1 -0
  94. package/src/components/ui/data-table/index.tsx +4 -3
  95. package/src/components/ui/index.ts +1 -1
  96. package/src/components/ui/list-view.tsx +7 -12
  97. package/src/components/ui/loading.tsx +10 -3
  98. package/src/components/ui/menu.tsx +6 -2
  99. package/src/components/ui/page-stack-view.tsx +3 -0
  100. package/src/components/ui/pane-link-chip.tsx +269 -54
  101. package/src/components/ui/query-bar.tsx +2 -1
  102. package/src/components/ui/quote.ts +14 -1
  103. package/src/components/ui/tabs.tsx +97 -19
  104. package/src/core/state/app/layout-reducer.ts +7 -0
  105. package/src/core/state/app/layout.ts +44 -7
  106. package/src/core/state/app/state.ts +1 -1
  107. package/src/core/state/app/types.ts +22 -2
  108. package/src/data/config/layout.ts +5 -2
  109. package/src/docs/snapshot.json +54 -13
  110. package/src/i18n/es.ts +9 -8
  111. package/src/i18n/ja.ts +9 -8
  112. package/src/i18n/ko.ts +9 -8
  113. package/src/i18n/zh-cn.ts +9 -8
  114. package/src/i18n/zh-tw.ts +9 -8
  115. package/src/layout/pane-manager/floating-actions.ts +17 -0
  116. package/src/layout/pane-manager/floating-stack.ts +187 -0
  117. package/src/layout/pane-manager/floating.ts +4 -2
  118. package/src/layout/pane-manager/gridlock.ts +5 -1
  119. package/src/layout/pane-manager/index.ts +11 -0
  120. package/src/layout/pane-manager/layout-state.ts +10 -3
  121. package/src/market-data/depositary-pair.ts +5 -3
  122. package/src/market-data/futures-board.ts +46 -1
  123. package/src/market-data/futures-contract.ts +12 -3
  124. package/src/market-data/fx-interventions.ts +270 -0
  125. package/src/market-data/market/dated-previous-close.ts +94 -15
  126. package/src/market-data/market/status.ts +17 -1
  127. package/src/news/news-model.ts +44 -2
  128. package/src/plugins/builtin/alerts/cli.ts +4 -4
  129. package/src/plugins/builtin/alerts/format.ts +1 -2
  130. package/src/plugins/builtin/alerts/headless.ts +1 -2
  131. package/src/plugins/builtin/alerts/move-checks.ts +12 -6
  132. package/src/plugins/builtin/alerts/move.ts +30 -9
  133. package/src/plugins/builtin/alerts/pane.tsx +0 -2
  134. package/src/plugins/builtin/alerts/storage.ts +4 -2
  135. package/src/plugins/builtin/alerts/types.ts +12 -0
  136. package/src/plugins/builtin/analytics/risk-client.ts +10 -4
  137. package/src/plugins/builtin/analytics/risk-episodes.ts +5 -4
  138. package/src/plugins/builtin/analytics/risk-headless.ts +4 -2
  139. package/src/plugins/builtin/analytics/risk-sectors.ts +91 -0
  140. package/src/plugins/builtin/awards/index.tsx +1 -1
  141. package/src/plugins/builtin/buildout/index.tsx +1 -0
  142. package/src/plugins/builtin/catalysts/index.tsx +2 -2
  143. package/src/plugins/builtin/cds/headless.ts +4 -0
  144. package/src/plugins/builtin/changelog/index.tsx +292 -101
  145. package/src/plugins/builtin/changelog/versions.ts +293 -0
  146. package/src/plugins/builtin/chart-composer/headless.ts +2 -1
  147. package/src/plugins/builtin/chart-composer/index.tsx +1 -0
  148. package/src/plugins/builtin/chart-composer/intervention-events.ts +105 -0
  149. package/src/plugins/builtin/chart-composer/pane.tsx +21 -7
  150. package/src/plugins/builtin/chat/content/composer.tsx +5 -4
  151. package/src/plugins/builtin/chat/content/index.tsx +12 -2
  152. package/src/plugins/builtin/chat/content/layout-metrics.ts +3 -3
  153. package/src/plugins/builtin/chat/content/open-targets.ts +3 -3
  154. package/src/plugins/builtin/chat/layout.ts +5 -2
  155. package/src/plugins/builtin/chat/message/pane-chip.tsx +61 -40
  156. package/src/plugins/builtin/chat/message/render-state.ts +2 -5
  157. package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
  158. package/src/plugins/builtin/chat/pane-links/previews.ts +51 -5
  159. package/src/plugins/builtin/chat/pane-links/share-card.ts +36 -0
  160. package/src/plugins/builtin/cloud/askg/attached-pane.tsx +10 -5
  161. package/src/plugins/builtin/cloud/askg/controller.ts +141 -5
  162. package/src/plugins/builtin/cloud/askg/executor.ts +113 -4
  163. package/src/plugins/builtin/cloud/askg/manifest.ts +28 -13
  164. package/src/plugins/builtin/cloud/askg/model.ts +14 -4
  165. package/src/plugins/builtin/cloud/askg/pane.tsx +70 -46
  166. package/src/plugins/builtin/cloud/askg/tool-display.ts +1 -0
  167. package/src/plugins/builtin/cloud/askg/turn-parts.tsx +70 -0
  168. package/src/plugins/builtin/cloud/terminal-relay/engine.ts +50 -130
  169. package/src/plugins/builtin/cloud/terminal-relay/policy.ts +327 -7
  170. package/src/plugins/builtin/cloud/terminal-relay/prompts.tsx +2 -1
  171. package/src/plugins/builtin/cloud/terminal-relay/redact.ts +52 -9
  172. package/src/plugins/builtin/commodities-energy/index.tsx +1 -3
  173. package/src/plugins/builtin/commodities-energy/view-state.ts +3 -0
  174. package/src/plugins/builtin/commodity-balances/index.tsx +1 -0
  175. package/src/plugins/builtin/company-attention/index.tsx +1 -1
  176. package/src/plugins/builtin/company-kpis/headless.ts +3 -1
  177. package/src/plugins/builtin/company-kpis/index.tsx +2 -2
  178. package/src/plugins/builtin/cot/headless.ts +14 -2
  179. package/src/plugins/builtin/cot/index.tsx +1 -1
  180. package/src/plugins/builtin/cpi/index.tsx +1 -1
  181. package/src/plugins/builtin/crypto-board/index.tsx +1 -0
  182. package/src/plugins/builtin/dividend-yield/index.tsx +1 -0
  183. package/src/plugins/builtin/doe/index.tsx +1 -1
  184. package/src/plugins/builtin/earnings/index.tsx +2 -2
  185. package/src/plugins/builtin/earnings-calls/headless.ts +5 -1
  186. package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
  187. package/src/plugins/builtin/econ/calendar-model.ts +74 -1
  188. package/src/plugins/builtin/econ/fred-catalog.ts +3 -1
  189. package/src/plugins/builtin/econ/index.tsx +1 -0
  190. package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
  191. package/src/plugins/builtin/econ-statistics/pane.tsx +6 -0
  192. package/src/plugins/builtin/estimate-revisions/index.tsx +1 -0
  193. package/src/plugins/builtin/executives/index.tsx +1 -0
  194. package/src/plugins/builtin/filing-events/index.tsx +1 -0
  195. package/src/plugins/builtin/fixed-income/index.tsx +1 -0
  196. package/src/plugins/builtin/futures/index.tsx +25 -4
  197. package/src/plugins/builtin/futures/model.ts +28 -32
  198. package/src/plugins/builtin/futures/series.ts +4 -3
  199. package/src/plugins/builtin/futures/table.tsx +16 -9
  200. package/src/plugins/builtin/futures/use-board-terms.ts +3 -3
  201. package/src/plugins/builtin/futures-curve/headless.ts +3 -3
  202. package/src/plugins/builtin/futures-curve/index.tsx +1 -1
  203. package/src/plugins/builtin/futures-curve/model.ts +18 -0
  204. package/src/plugins/builtin/gpu/index.tsx +1 -1
  205. package/src/plugins/builtin/help/functions-table.tsx +1 -1
  206. package/src/plugins/builtin/help/index.tsx +14 -4
  207. package/src/plugins/builtin/help/keybindings-editor.tsx +19 -5
  208. package/src/plugins/builtin/holders/index.tsx +1 -0
  209. package/src/plugins/builtin/holders/report-header.ts +2 -2
  210. package/src/plugins/builtin/insider/index.tsx +1 -0
  211. package/src/plugins/builtin/iv-history/index.tsx +1 -1
  212. package/src/plugins/builtin/jobs/index.tsx +1 -0
  213. package/src/plugins/builtin/layout-manager/index.tsx +8 -8
  214. package/src/plugins/builtin/macro-day/headless.ts +27 -8
  215. package/src/plugins/builtin/macro-day/index.tsx +1 -1
  216. package/src/plugins/builtin/macro-day/model.ts +19 -3
  217. package/src/plugins/builtin/macro-day/pane.tsx +14 -9
  218. package/src/plugins/builtin/macro-day/releases.ts +25 -7
  219. package/src/plugins/builtin/market-valuation/index.tsx +1 -0
  220. package/src/plugins/builtin/market-valuation/pane.tsx +8 -0
  221. package/src/plugins/builtin/members/index.tsx +1 -1
  222. package/src/plugins/builtin/mna/index.tsx +1 -0
  223. package/src/plugins/builtin/news/headless.ts +2 -2
  224. package/src/plugins/builtin/news/index.tsx +4 -3
  225. package/src/plugins/builtin/news/wire/index.tsx +5 -1
  226. package/src/plugins/builtin/news/wire/news/detail-view.tsx +4 -0
  227. package/src/plugins/builtin/news/wire/news/list-search.ts +5 -2
  228. package/src/plugins/builtin/options/index.tsx +1 -0
  229. package/src/plugins/builtin/options-positioning/index.tsx +1 -0
  230. package/src/plugins/builtin/pe-band/index.tsx +1 -1
  231. package/src/plugins/builtin/perps/markets-section.tsx +5 -2
  232. package/src/plugins/builtin/plugin-marketplace/pane.tsx +11 -11
  233. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +25 -0
  234. package/src/plugins/builtin/portfolio-list/headless.ts +15 -6
  235. package/src/plugins/builtin/portfolio-list/summary/index.tsx +3 -1
  236. package/src/plugins/builtin/power/index.tsx +1 -1
  237. package/src/plugins/builtin/realized-vol/index.tsx +1 -1
  238. package/src/plugins/builtin/research/event-model.ts +9 -1
  239. package/src/plugins/builtin/research/event-sources.ts +22 -0
  240. package/src/plugins/builtin/research/headless.ts +11 -5
  241. package/src/plugins/builtin/research/index.tsx +4 -0
  242. package/src/plugins/builtin/research-search/index.tsx +1 -0
  243. package/src/plugins/builtin/research-search/pane.tsx +8 -0
  244. package/src/plugins/builtin/revenue-breakdown/index.tsx +1 -0
  245. package/src/plugins/builtin/reverse-dcf/index.tsx +1 -1
  246. package/src/plugins/builtin/risk-factors/index.tsx +1 -0
  247. package/src/plugins/builtin/scanner/headless.ts +52 -13
  248. package/src/plugins/builtin/seasonality/index.tsx +1 -1
  249. package/src/plugins/builtin/sec/index.tsx +1 -0
  250. package/src/plugins/builtin/series-inventory.ts +1 -1
  251. package/src/plugins/builtin/shared/cloud-upgrade.ts +27 -3
  252. package/src/plugins/builtin/shared/scanner-capture.ts +11 -3
  253. package/src/plugins/builtin/shared/series-list-detail.tsx +5 -0
  254. package/src/plugins/builtin/short-interest/index.tsx +1 -0
  255. package/src/plugins/builtin/social-mentions/index.tsx +1 -1
  256. package/src/plugins/builtin/supply-chain/index.tsx +1 -0
  257. package/src/plugins/builtin/thirteenf/data.ts +43 -10
  258. package/src/plugins/builtin/thirteenf/headless.ts +55 -11
  259. package/src/plugins/builtin/thirteenf/model.ts +25 -9
  260. package/src/plugins/builtin/thirteenf/report-notes.ts +27 -6
  261. package/src/plugins/builtin/thirteenf/types.ts +2 -0
  262. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +1 -1
  263. package/src/plugins/builtin/ticker-detail/financials/model.ts +12 -0
  264. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +3 -3
  265. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +5 -5
  266. package/src/plugins/builtin/ticker-detail/headless.ts +18 -13
  267. package/src/plugins/builtin/ticker-detail/index.tsx +4 -0
  268. package/src/plugins/builtin/ticker-detail/overview/components.tsx +54 -5
  269. package/src/plugins/builtin/ticker-detail/overview/model.ts +6 -4
  270. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +34 -17
  271. package/src/plugins/builtin/ticker-detail/pane.tsx +7 -2
  272. package/src/plugins/builtin/time-sales/client.ts +9 -11
  273. package/src/plugins/builtin/time-sales/index.tsx +1 -1
  274. package/src/plugins/builtin/treasury-auctions/after.ts +267 -0
  275. package/src/plugins/builtin/treasury-auctions/cache.ts +18 -3
  276. package/src/plugins/builtin/treasury-auctions/client.ts +33 -2
  277. package/src/plugins/builtin/treasury-auctions/headless.ts +109 -19
  278. package/src/plugins/builtin/treasury-auctions/index.tsx +14 -4
  279. package/src/plugins/builtin/treasury-auctions/model.ts +256 -28
  280. package/src/plugins/builtin/treasury-auctions/pane.tsx +139 -28
  281. package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +5 -2
  282. package/src/plugins/builtin/treasury-auctions/types.ts +7 -1
  283. package/src/plugins/builtin/vol-surface/index.tsx +1 -1
  284. package/src/plugins/builtin/world-venue-map/index.ts +1 -0
  285. package/src/plugins/builtin/yield-curve/curves.ts +10 -4
  286. package/src/plugins/builtin/yield-curve/headless.ts +6 -2
  287. package/src/plugins/builtin/yield-curve/index.tsx +3 -3
  288. package/src/plugins/builtin/yield-curve/series.ts +10 -0
  289. package/src/plugins/builtin/yield-curve/world.ts +3 -1
  290. package/src/plugins/installer.ts +45 -0
  291. package/src/portfolio/column-values.ts +2 -1
  292. package/src/public/__snapshots__/public-api.test.ts.snap +4 -0
  293. package/src/public/remote.ts +7 -1
  294. package/src/remote/client.ts +191 -11
  295. package/src/remote/controller-utils.ts +13 -1
  296. package/src/remote/controller.ts +88 -26
  297. package/src/remote/endpoint.ts +24 -0
  298. package/src/remote/form.ts +59 -4
  299. package/src/remote/resources.ts +56 -19
  300. package/src/remote/schema.ts +22 -9
  301. package/src/remote/secrets.ts +12 -0
  302. package/src/remote/semantic-helpers.ts +29 -1
  303. package/src/remote/semantic-tree.tsx +44 -15
  304. package/src/remote/server.ts +2 -1
  305. package/src/remote/surface.tsx +192 -0
  306. package/src/remote/types.ts +5 -0
  307. package/src/renderers/cloudflare/worker.ts +16 -1
  308. package/src/renderers/dom/styles.css +40 -6
  309. package/src/renderers/opentui/host.tsx +6 -0
  310. package/src/renderers/share/layout-view.tsx +1 -1
  311. package/src/series/standalone.ts +2 -2
  312. package/src/shares/api.ts +21 -4
  313. package/src/shares/item.ts +73 -0
  314. package/src/shares/pane-item.ts +205 -0
  315. package/src/shares/pane.ts +4 -0
  316. package/src/shares/payload.ts +9 -5
  317. package/src/sources/gloomberb-cloud/news.ts +37 -12
  318. package/src/state/opening-ticker-panes.ts +47 -0
  319. package/src/test-support/cli-context.ts +2 -0
  320. package/src/test-support/preload.ts +4 -1
  321. package/src/tickers/instrument-kind.ts +23 -3
  322. package/src/tickers/renamed-listings.ts +105 -0
  323. package/src/tickers/search/index.ts +103 -16
  324. package/src/time-series/resolve.ts +2 -2
  325. package/src/types/config.ts +5 -0
  326. package/src/types/context-menu.ts +2 -0
  327. package/src/types/financials.ts +1 -0
  328. package/src/types/plugin-commands.ts +140 -0
  329. package/src/types/plugin-context.ts +125 -0
  330. package/src/types/plugin-contributions.ts +55 -0
  331. package/src/types/plugin-definition.ts +234 -0
  332. package/src/types/plugin-notifications.ts +38 -0
  333. package/src/types/plugin-pane-settings.ts +116 -0
  334. package/src/types/plugin-pane-templates.ts +160 -0
  335. package/src/types/plugin-panes.ts +243 -0
  336. package/src/types/plugin-reports.ts +35 -0
  337. package/src/types/plugin-shared.ts +14 -0
  338. package/src/types/plugin-state.ts +71 -0
  339. package/src/types/plugin.ts +14 -1169
  340. package/src/ui/index.tsx +14 -3
  341. package/src/updater/github-releases.ts +23 -0
  342. package/src/utils/central-banks.ts +86 -1
  343. package/src/utils/cli-output.ts +22 -9
  344. package/src/utils/datetime-format.ts +12 -3
  345. package/src/utils/depositary-receipt.ts +28 -3
  346. package/src/utils/fundamentals.ts +14 -0
  347. package/src/utils/max-drawdown.ts +97 -16
  348. package/src/utils/untrusted-text.ts +29 -0
@@ -1,8 +1,11 @@
1
+ import type { ReactNode } from "react";
1
2
  import type { ChatAttachment } from "../../../../api-client";
2
3
  import {
3
4
  DesktopPaneLinkChip,
4
5
  IconButton,
5
6
  TerminalPaneLinkChip,
7
+ TerminalPaneLinkItemCard,
8
+ terminalItemCardRows,
6
9
  type PaneLinkChipContent,
7
10
  } from "../../../../components/ui";
8
11
  import { tf } from "../../../../i18n";
@@ -10,15 +13,16 @@ import { Box } from "../../../../ui";
10
13
  import { colors } from "../../../../theme/colors";
11
14
  import { wirePaneTarget, type ChatMessagePaneLink } from "../pane-links/model";
12
15
  import { chatPaneLinkPane, useSharePreview } from "../pane-links/previews";
16
+ import { shareCardContent } from "../pane-links/share-card";
13
17
  import type { ComposerShareLink } from "../pane-links/composer";
14
18
  import { DESKTOP_DRAFT_STRIP_STYLE } from "../attachments/desktop";
15
19
 
16
20
  /**
17
- * A chip for something a message opens in the terminal: a shared pane (its
18
- * title and the pane it is, with the picture its sender posted when there is
19
- * one), a Gloom Wire post's story or calendar, or a function written in
20
- * backticks, drawn in its line of text. It always takes the same room, before
21
- * and after the share is read, so the transcript never moves.
21
+ * A chip for something a message opens in the terminal: a shared pane as a
22
+ * card (the item it was on, a line or two of it and the pane it opens, with
23
+ * the picture its sender posted when there is one), a Gloom Wire post's story
24
+ * or calendar, or a function written in backticks, drawn in its line of text.
25
+ * A share's card is as tall as what it says; the other chips keep one height.
22
26
  */
23
27
 
24
28
  /** What a chip says, from the share or the post and nothing of the reader's own. */
@@ -26,15 +30,7 @@ function useChatPaneChipContent(link: ChatMessagePaneLink): PaneLinkChipContent
26
30
  const shareId = link.kind === "share" ? link.id : "";
27
31
  const preview = useSharePreview(shareId);
28
32
  if (link.kind === "command") return { title: link.query, detail: link.name, icon: "" };
29
- if (link.kind === "share") {
30
- if (preview.status !== "ready") return { title: link.url, detail: "", icon: "" };
31
- const pane = chatPaneLinkPane(preview.paneId);
32
- return {
33
- title: preview.title,
34
- detail: pane && pane.name !== preview.title ? pane.name : "",
35
- icon: pane?.icon ?? "",
36
- };
37
- }
33
+ if (link.kind === "share") return shareCardContent(link.url, preview);
38
34
  const target = wirePaneTarget(link.link);
39
35
  const pane = chatPaneLinkPane(target.paneId);
40
36
  return { title: pane?.name ?? target.name, detail: target.day ?? "", icon: pane?.icon ?? "" };
@@ -71,7 +67,7 @@ export function DesktopChatPaneChip({
71
67
  return (
72
68
  <DesktopPaneLinkChip
73
69
  content={content}
74
- variant={link.kind === "command" ? "inline" : link.kind === "wire" ? "line" : "card"}
70
+ variant={link.kind === "command" ? "inline" : link.kind === "wire" ? "line" : "item"}
75
71
  picture={link.kind === "command" ? null : preview}
76
72
  dimmed={dimmed}
77
73
  onOpen={() => onOpen(link)}
@@ -109,7 +105,16 @@ export function DesktopComposerPaneChips({
109
105
  );
110
106
  }
111
107
 
112
- /** The terminal's composer rows for waiting share links: the chip a message draws, then its x at the row's end. */
108
+ /** How wide a waiting link's card is in the terminal's composer of `width`: lined up with the field's text, its x after it. */
109
+ export function terminalComposerChipWidth(width: number): number {
110
+ return Math.max(1, width - COMPOSER_CHIP_INSET - COMPOSER_CHIP_REMOVE_WIDTH - 1);
111
+ }
112
+
113
+ // Lined up with the field's text after its prompt, as a message's chips line up with its text.
114
+ const COMPOSER_CHIP_INSET = 3;
115
+ const COMPOSER_CHIP_REMOVE_WIDTH = 3;
116
+
117
+ /** The terminal's composer rows for waiting share links: the card a message draws, then its x at the end of its first row. */
113
118
  export function TerminalComposerPaneChips({
114
119
  links,
115
120
  width,
@@ -122,24 +127,24 @@ export function TerminalComposerPaneChips({
122
127
  /** Takes out the chip at this place in `links`, as on the desktop. */
123
128
  onRemove: (index: number) => void;
124
129
  }) {
125
- // Lined up with the field's text after its prompt, as a message's chips line up with its text.
126
- const inset = 3;
127
- const removeWidth = 3;
128
130
  return (
129
131
  <>
130
132
  {links.map((link, index) => (
131
- <Box key={`${index}:${link.id}`} width={width} height={1} flexDirection="row">
132
- <Box width={inset} />
133
- <TerminalChatPaneChip
134
- link={link}
135
- width={Math.max(1, width - inset - removeWidth - 1)}
136
- selected={false}
137
- selectedTextColor={colors.textBright}
138
- onOpen={onOpen}
139
- />
133
+ <TerminalChatPaneChipRow
134
+ key={`${index}:${link.id}`}
135
+ link={link}
136
+ width={terminalComposerChipWidth(width)}
137
+ rowProps={{ width }}
138
+ selected={false}
139
+ selectedTextColor={colors.textBright}
140
+ onOpen={onOpen}
141
+ lead={<Box width={COMPOSER_CHIP_INSET} />}
142
+ >
140
143
  <Box flexGrow={1} />
141
- <TerminalComposerChipRemove link={link} onRemove={() => onRemove(index)} />
142
- </Box>
144
+ <Box height={1}>
145
+ <TerminalComposerChipRemove link={link} onRemove={() => onRemove(index)} />
146
+ </Box>
147
+ </TerminalChatPaneChipRow>
143
148
  ))}
144
149
  </>
145
150
  );
@@ -147,31 +152,47 @@ export function TerminalComposerPaneChips({
147
152
 
148
153
  function TerminalComposerChipRemove({ link, onRemove }: { link: ComposerShareLink; onRemove: () => void }) {
149
154
  const content = useChatPaneChipContent(link);
150
- return <IconButton icon="close" label={tf("Remove {name}", { name: content.title })} onPress={onRemove} />;
155
+ return <IconButton icon="close" label={tf("Remove {name}", { name: content.title || content.detail })} onPress={onRemove} />;
151
156
  }
152
157
 
153
- /** One row in the terminal: the pane's letter, the title and the pane, cut to the line. */
154
- export function TerminalChatPaneChip({
158
+ /**
159
+ * A chip's row in the terminal, as tall as the chip: a share's card as it
160
+ * reads now, or one row. `lead` goes before the chip and `children` after it.
161
+ */
162
+ export function TerminalChatPaneChipRow({
155
163
  link,
156
164
  width,
165
+ rowProps,
157
166
  selected,
158
167
  selectedTextColor,
159
168
  onOpen,
169
+ lead,
170
+ children,
160
171
  }: {
161
172
  link: ChatMessagePaneLink;
173
+ /** The chip's own width. */
162
174
  width: number;
175
+ rowProps: Record<string, unknown>;
163
176
  selected: boolean;
164
177
  selectedTextColor: string;
165
178
  onOpen: (link: ChatMessagePaneLink) => void;
179
+ lead?: ReactNode;
180
+ children?: ReactNode;
166
181
  }) {
167
182
  const content = useChatPaneChipContent(link);
183
+ const share = link.kind === "share";
184
+ const Chip = share ? TerminalPaneLinkItemCard : TerminalPaneLinkChip;
168
185
  return (
169
- <TerminalPaneLinkChip
170
- content={content}
171
- width={width}
172
- selected={selected}
173
- selectedTextColor={selectedTextColor}
174
- onOpen={() => onOpen(link)}
175
- />
186
+ <Box {...rowProps} height={share ? terminalItemCardRows(content, width) : 1} flexDirection="row">
187
+ {lead}
188
+ <Chip
189
+ content={content}
190
+ width={width}
191
+ selected={selected}
192
+ selectedTextColor={selectedTextColor}
193
+ onOpen={() => onOpen(link)}
194
+ />
195
+ {children}
196
+ </Box>
176
197
  );
177
198
  }
@@ -2,7 +2,7 @@ import { TextAttributes } from "../../../../ui";
2
2
  import { blendHex, colors, hoverBg } from "../../../../theme/colors";
3
3
  import type { ChatMessage } from "../../../../api-client";
4
4
  import { formatTimeAgo } from "../../../../utils/datetime-format";
5
- import { accentTint } from "../../../../components/ui/quote";
5
+ import { accentTint, terminalAccentTint } from "../../../../components/ui/quote";
6
6
  import { isGroupedWithPrevious, MESSAGE_ACTION_WIDTH } from "../layout";
7
7
  import { chatAuthorNameColor } from "../people";
8
8
 
@@ -11,9 +11,6 @@ export function chatHighlightBg(palette = colors): string {
11
11
  return blendHex(palette.bg, palette.borderFocused, 0.22);
12
12
  }
13
13
 
14
- /** How far an announcement's band leans toward the accent in the terminal: a quote's faint tint. */
15
- const ANNOUNCEMENT_TINT = 0.07;
16
-
17
14
  /**
18
15
  * An announcement's band at rest, well under a message the reader was sent
19
16
  * to: on the desktop and the web the kit's accent tint over the list's own
@@ -23,7 +20,7 @@ const ANNOUNCEMENT_TINT = 0.07;
23
20
  */
24
21
  export function chatAnnouncementBg(host: "desktop" | "terminal", palette = colors, hovered = false): string {
25
22
  if (host === "desktop") return accentTint();
26
- const band = blendHex(palette.bg, palette.borderFocused, ANNOUNCEMENT_TINT);
23
+ const band = terminalAccentTint(palette);
27
24
  return hovered ? blendHex(band, palette.selected, 0.5) : band;
28
25
  }
29
26
 
@@ -11,7 +11,7 @@ import { Button } from "../../../../components/ui";
11
11
  import { canReactToMessage } from "../reactions";
12
12
  import { TerminalChatReactions } from "./reactions";
13
13
  import { TerminalChatMessageRow } from "./inline-tokens";
14
- import { TerminalChatPaneChip } from "./pane-chip";
14
+ import { TerminalChatPaneChipRow } from "./pane-chip";
15
15
  import { chatMessagePaneLinks } from "../pane-links/model";
16
16
  import { useSlowPendingSend } from "./pending-send";
17
17
  import { getChatMessageRenderState } from "./render-state";
@@ -167,23 +167,21 @@ export function TerminalChatMessage({
167
167
  </Box>
168
168
  ))}
169
169
  {paneLinks.map((link, linkIndex) => (
170
- <Box
170
+ <TerminalChatPaneChipRow
171
171
  key={`${msg.id}:pane:${link.kind === "share" ? link.id : link.link.kind}`}
172
- {...messageRowProps}
173
- paddingLeft={3}
174
- height={1}
175
- flexDirection="row"
176
- position={state.grouped && bodyLines.length === 0 && linkIndex === 0 ? "relative" : undefined}
172
+ link={link}
173
+ width={messageBodyWidth}
174
+ rowProps={{
175
+ ...messageRowProps,
176
+ paddingLeft: 3,
177
+ position: state.grouped && bodyLines.length === 0 && linkIndex === 0 ? "relative" : undefined,
178
+ }}
179
+ selected={state.isSelected}
180
+ selectedTextColor={state.selectedTextColor}
181
+ onOpen={openPaneLink}
177
182
  >
178
- <TerminalChatPaneChip
179
- link={link}
180
- width={messageBodyWidth}
181
- selected={state.isSelected}
182
- selectedTextColor={state.selectedTextColor}
183
- onOpen={openPaneLink}
184
- />
185
183
  {state.grouped && bodyLines.length === 0 && linkIndex === 0 && <ChatMessageActions floating {...actionProps} />}
186
- </Box>
184
+ </TerminalChatPaneChipRow>
187
185
  ))}
188
186
  {attachments.map((attachment, imageIndex) => (
189
187
  <Box
@@ -1,14 +1,25 @@
1
1
  import { useCallback, useSyncExternalStore } from "react";
2
2
  import { getShare } from "../../../../shares/api";
3
+ import type { ShareItem } from "../../../../shares/item";
4
+ import { plainUntrustedLine } from "../../../../utils/untrusted-text";
3
5
  import type { PaneDef } from "../../../../types/plugin";
4
6
 
5
7
  /**
6
8
  * What a share chip shows, read from the share itself and nothing else: its
7
- * title and the pane it holds. The read does not count as a view of the share.
9
+ * title, the pane it holds and what that pane says it is, and the item the
10
+ * pane was on when it was shared. The read does not count as a view of the
11
+ * share.
8
12
  */
9
13
  export type SharePreview =
10
14
  | { status: "loading" }
11
- | { status: "ready"; title: string; paneId: string | null }
15
+ | {
16
+ status: "ready";
17
+ title: string;
18
+ paneId: string | null;
19
+ /** The pane's own description, kept with shares made before items were. */
20
+ description?: string;
21
+ item?: ShareItem;
22
+ }
12
23
  | { status: "unavailable" };
13
24
 
14
25
  const LOADING: SharePreview = { status: "loading" };
@@ -61,10 +72,19 @@ function pump(): void {
61
72
  settle(id, { status: "unavailable" }, false);
62
73
  return;
63
74
  }
64
- const paneId = share.kind === "pane" && share.data.version === 2
65
- ? share.data.layout.layout.instances[0]?.paneId ?? null
75
+ const pane = share.kind === "pane" ? share : null;
76
+ const paneId = pane?.data.version === 2
77
+ ? pane.data.layout.layout.instances[0]?.paneId ?? null
66
78
  : null;
67
- settle(id, { status: "ready", title: share.data.title, paneId }, false);
79
+ // The sender's app wrote the title and description: plain lines, as its item is (parseShareItem).
80
+ const description = pane?.data.description ? plainUntrustedLine(pane.data.description) : "";
81
+ settle(id, {
82
+ status: "ready",
83
+ title: plainUntrustedLine(share.data.title),
84
+ paneId,
85
+ ...(description ? { description } : {}),
86
+ ...(pane?.item ? { item: pane.item } : {}),
87
+ }, false);
68
88
  })
69
89
  .catch(() => settle(id, LOADING, true))
70
90
  .finally(() => {
@@ -83,11 +103,37 @@ function request(id: string): void {
83
103
  pump();
84
104
  }
85
105
 
106
+ /** What a share is called where one line names it (the Open list): the item it is on, else its own title. */
107
+ export function sharePreviewTitle(preview: Extract<SharePreview, { status: "ready" }>): string {
108
+ return preview.item?.title ?? preview.title;
109
+ }
110
+
86
111
  /** What chips show for a share now, for code outside React (the Open list). */
87
112
  export function peekSharePreview(id: string): SharePreview {
88
113
  return entries.get(id)?.preview ?? LOADING;
89
114
  }
90
115
 
116
+ /**
117
+ * Whether each of the shares is read yet, as one string that changes when one
118
+ * of them is: for a parent that sizes its children's cards by what they say
119
+ * (the terminal's composer). Reads each share as `useSharePreview` does.
120
+ */
121
+ export function useSharePreviewStates(ids: readonly string[]): string {
122
+ const key = ids.join(",");
123
+ const subscribe = useCallback((listener: () => void) => {
124
+ const watched = key ? key.split(",") : [];
125
+ for (const id of watched) {
126
+ entryFor(id).listeners.add(listener);
127
+ request(id);
128
+ }
129
+ return () => {
130
+ for (const id of watched) entries.get(id)?.listeners.delete(listener);
131
+ };
132
+ }, [key]);
133
+ const read = useCallback(() => (key ? key.split(",").map((id) => peekSharePreview(id).status).join(",") : ""), [key]);
134
+ return useSyncExternalStore(subscribe, read, read);
135
+ }
136
+
91
137
  /** The share's title and pane, loaded once per session for every chip that shows it; "" reads nothing. */
92
138
  export function useSharePreview(id: string): SharePreview {
93
139
  const subscribe = useCallback((listener: () => void) => {
@@ -0,0 +1,36 @@
1
+ import { terminalItemCardRows, type PaneLinkChipContent } from "../../../../components/ui/pane-link-chip";
2
+ import type { ChatMessagePaneLink } from "./model";
3
+ import { chatPaneLinkPane, peekSharePreview, type SharePreview } from "./previews";
4
+
5
+ function sameName(a: string, b: string): boolean {
6
+ return a.trim().toLowerCase() === b.trim().toLowerCase();
7
+ }
8
+
9
+ /**
10
+ * What a share's card says: the item its pane was on, a line or two of it, and
11
+ * the pane it opens. Without an item, or with one named as its pane, the pane
12
+ * is said once: its row (with the share's own title when that says more, as
13
+ * `DES SAMPL Options · Research`) under its own description. Before the share
14
+ * is read the card is its link in the room most cards take; once it is gone,
15
+ * its link alone.
16
+ */
17
+ export function shareCardContent(url: string, preview: SharePreview): PaneLinkChipContent {
18
+ if (preview.status === "loading") return { title: url, detail: "", icon: "", pending: true };
19
+ if (preview.status !== "ready") return { title: url, detail: "", icon: "" };
20
+ const pane = chatPaneLinkPane(preview.paneId);
21
+ const paneName = pane?.name ?? preview.item?.pane ?? "";
22
+ const icon = pane?.icon ?? "";
23
+ const item = preview.item;
24
+ if (item && !sameName(item.title, paneName)) {
25
+ return { title: item.title, excerpt: item.excerpt ?? "", detail: paneName || preview.title, icon };
26
+ }
27
+ const row = !paneName ? preview.title
28
+ : sameName(preview.title, paneName) ? paneName
29
+ : `${preview.title} · ${paneName}`;
30
+ return { title: "", excerpt: preview.description ?? item?.excerpt ?? "", detail: row, icon };
31
+ }
32
+
33
+ /** The rows a message's chip takes in the terminal at `width`: a share's card as it reads now, or one row. */
34
+ export function terminalChatPaneChipRows(link: ChatMessagePaneLink, width: number): number {
35
+ return link.kind === "share" ? terminalItemCardRows(shareCardContent(link.url, peekSharePreview(link.id)), width) : 1;
36
+ }
@@ -1,6 +1,8 @@
1
1
  import { Box, Text, TextAttributes } from "../../../../ui";
2
2
  import { Badge, Button, IconButton } from "../../../../components";
3
+ import { RemoteUiScope } from "../../../../remote/semantic-tree";
3
4
  import { useThemeColors } from "../../../../theme/theme-context";
5
+ import { ASKG_PROMPT_SCOPE } from "../terminal-relay/policy";
4
6
  import { truncateWithEllipsis } from "../../../../utils/text-wrap";
5
7
  import { attachedPaneLabel, type ASKGAttachedPane } from "./pane-attachment";
6
8
 
@@ -49,11 +51,14 @@ export function AttachedPaneBlock({
49
51
  {truncateWithEllipsis("It shows your own data. Only what is on screen goes, as text.", textWidth)}
50
52
  </Text>
51
53
  </Box>
52
- <Box flexDirection="row" height={2} paddingTop={1}>
53
- <Button label="Attach" variant="primary" shortcut={ATTACH_PANE_KEY} onPress={onAttach} />
54
- <Box width={2} />
55
- <Button label="Leave out" shortcut={LEAVE_OUT_PANE_KEY} onPress={onLeaveOut} />
56
- </Box>
54
+ {/* The person's answer: no assistant's UI call reaches it (terminal-relay/policy.ts). */}
55
+ <RemoteUiScope scope={ASKG_PROMPT_SCOPE}>
56
+ <Box flexDirection="row" height={2} paddingTop={1}>
57
+ <Button label="Attach" variant="primary" shortcut={ATTACH_PANE_KEY} onPress={onAttach} />
58
+ <Box width={2} />
59
+ <Button label="Leave out" shortcut={LEAVE_OUT_PANE_KEY} onPress={onLeaveOut} />
60
+ </Box>
61
+ </RemoteUiScope>
57
62
  </Box>
58
63
  );
59
64
  }
@@ -4,7 +4,13 @@ import {
4
4
  type ASKGToolResultOutcome,
5
5
  type ASKGTransport,
6
6
  } from "../../../../api-client/askg";
7
- import { toolCallRemainingMs, type ASKGToolExecutor, type ASKGToolPreview } from "./executor";
7
+ import {
8
+ CONFIRMATION_WAITING_NOTE,
9
+ toolCallRemainingMs,
10
+ type ASKGToolExecutor,
11
+ type ASKGToolGate,
12
+ type ASKGToolPreview,
13
+ } from "./executor";
8
14
  import {
9
15
  activeTurn,
10
16
  askgReducer,
@@ -167,6 +173,15 @@ export class ASKGSessionController {
167
173
  private sessionRequest: Promise<ASKGSessionStartResponse> | null = null;
168
174
  private manifest: ASKGControllerManifest | null = null;
169
175
  private readonly confirmations = new Map<string, (answer: ConfirmationAnswer) => void>();
176
+ /**
177
+ * Calls that change the app, or ask first, take turns here (enterLane): each
178
+ * decides whether to ask, asks and runs before the next one starts, so at
179
+ * most one question is ever open and nothing it would press changes under
180
+ * it. Reads run at once.
181
+ */
182
+ private laneTail: Promise<void> = Promise.resolve();
183
+ /** Calls waiting for their turn, by tool call id; a question that opens refuses them. */
184
+ private readonly queued = new Map<string, () => void>();
170
185
  private readonly toolTasks = new Set<Promise<void>>();
171
186
  private turnAbort: AbortController | null = null;
172
187
  /** Ratings of one answer go out in the order they were made. */
@@ -409,11 +424,66 @@ export class ASKGSessionController {
409
424
  return;
410
425
  }
411
426
 
427
+ const refuse = (): Promise<void> => this.deliver({
428
+ turnId: call.turnId,
429
+ toolCallId: call.toolCallId,
430
+ status: "denied",
431
+ truncated: false,
432
+ elapsedMs: Math.max(0, this.now() - startedAt),
433
+ note: CONFIRMATION_WAITING_NOTE,
434
+ });
435
+ // Decided before anything is awaited, so two calls that arrive together
436
+ // take turns in the order they came.
437
+ const exclusive = this.takesTurns(call);
438
+ if (exclusive && this.confirmations.size > 0) {
439
+ await refuse();
440
+ return;
441
+ }
442
+ const turn = exclusive ? this.enterLane(call.toolCallId) : null;
443
+
412
444
  try {
445
+ if (turn && !(await turn.ready)) {
446
+ await refuse();
447
+ return;
448
+ }
449
+ if (signal?.aborted || this.toolRowStatus(call.toolCallId) !== "pending") return;
450
+ // Its turn came after the server stopped waiting for it.
451
+ if (turn && toolCallRemainingMs(call, this.now()) <= 0) {
452
+ await this.deliver({
453
+ turnId: call.turnId,
454
+ toolCallId: call.toolCallId,
455
+ status: "timeout",
456
+ truncated: false,
457
+ elapsedMs: Math.max(0, this.now() - startedAt),
458
+ note: "Tool call timed out.",
459
+ });
460
+ return;
461
+ }
462
+ // A call that acts on what is on screen goes by the policy shared with
463
+ // the terminal relay: a press asks, a scroll does not, and nothing acts
464
+ // on a confirmation or while one waits.
465
+ const gate = await this.gateCall(call, signal);
466
+ if (signal?.aborted || this.toolRowStatus(call.toolCallId) !== "pending") return;
467
+ if (gate?.kind === "refusal") {
468
+ await this.deliver({
469
+ turnId: call.turnId,
470
+ toolCallId: call.toolCallId,
471
+ status: "denied",
472
+ truncated: false,
473
+ elapsedMs: Math.max(0, this.now() - startedAt),
474
+ note: gate.message,
475
+ });
476
+ return;
477
+ }
478
+ // This app's own manifest says which tools ask first, whatever the frame says.
479
+ const asks = requiresLocalConfirmation(call)
480
+ || this.manifest?.tools.find((tool) => tool.name === call.name)?.confirm === "always"
481
+ || gate?.kind === "ask";
413
482
  let confirmed = false;
414
483
  let confirmedChange: string | undefined;
415
- if (requiresLocalConfirmation(call)) {
416
- const preview = await this.previewCall(call, signal);
484
+ if (asks) {
485
+ // A UI action is described by the control it presses; there is no dry run for it.
486
+ const preview = gate?.kind === "ask" ? null : await this.previewCall(call, signal);
417
487
  // The turn ended or moved on while the app looked.
418
488
  if (signal?.aborted || this.toolRowStatus(call.toolCallId) !== "pending") return;
419
489
  if (preview?.kind === "refusal") {
@@ -425,10 +495,14 @@ export class ASKGSessionController {
425
495
  if (preview?.kind === "no-change") {
426
496
  confirmed = true;
427
497
  } else {
498
+ // One question at a time: every call still waiting for its turn is refused.
499
+ this.refuseQueued();
428
500
  this.dispatch({
429
501
  type: "tool-awaiting-confirmation",
430
502
  toolCallId: call.toolCallId,
431
- ...(preview?.kind === "change" ? { preview: preview.summary } : {}),
503
+ ...(gate?.kind === "ask"
504
+ ? { title: gate.title, ...(gate.lines.length > 0 ? { preview: gate.lines.join("\n") } : {}) }
505
+ : preview?.kind === "change" ? { preview: preview.summary } : {}),
432
506
  });
433
507
  const answer = await this.awaitConfirmation(
434
508
  call.toolCallId,
@@ -470,8 +544,10 @@ export class ASKGSessionController {
470
544
  return;
471
545
  }
472
546
  const payload = await executor.execute(call, {
473
- confirmed: confirmed || !requiresLocalConfirmation(call),
547
+ confirmed: confirmed || !asks,
474
548
  ...(confirmedChange ? { confirmedChange } : {}),
549
+ ...(gate ? { gate } : {}),
550
+ promptOpen: () => this.confirmationOpen(call.toolCallId),
475
551
  ...(signal ? { signal } : {}),
476
552
  });
477
553
  await this.deliver(payload);
@@ -481,7 +557,67 @@ export class ASKGSessionController {
481
557
  ));
482
558
  } finally {
483
559
  this.confirmations.delete(call.toolCallId);
560
+ turn?.leave();
561
+ }
562
+ }
563
+
564
+ /**
565
+ * Whether a call takes turns with the others: anything but a read this
566
+ * app's manifest knows, and anything that asks first. A tool the manifest
567
+ * does not know waits its turn too; the executor refuses it anyway.
568
+ */
569
+ private takesTurns(call: ASKGToolCallEvent): boolean {
570
+ const tool = this.manifest?.tools.find((entry) => entry.name === call.name);
571
+ return !tool
572
+ || tool.writeTier !== "read"
573
+ || call.writeTier !== "read"
574
+ || tool.confirm === "always"
575
+ || requiresLocalConfirmation(call);
576
+ }
577
+
578
+ /** Queues a call behind the ones before it; `ready` is false when a question opened while it waited. */
579
+ private enterLane(toolCallId: string): { ready: Promise<boolean>; leave: () => void } {
580
+ const ahead = this.laneTail;
581
+ let leave!: () => void;
582
+ const left = new Promise<void>((resolve) => {
583
+ leave = resolve;
584
+ });
585
+ this.laneTail = ahead.then(() => left);
586
+ const ready = new Promise<boolean>((resolve) => {
587
+ this.queued.set(toolCallId, () => resolve(false));
588
+ void ahead.then(() => {
589
+ this.queued.delete(toolCallId);
590
+ resolve(true);
591
+ });
592
+ });
593
+ return { ready, leave };
594
+ }
595
+
596
+ private refuseQueued(): void {
597
+ for (const refuse of this.queued.values()) refuse();
598
+ this.queued.clear();
599
+ }
600
+
601
+ /**
602
+ * The shared policy's word on a call that acts on what is on screen or a
603
+ * confirmed operation it describes; null for any other call. Throws when
604
+ * it cannot tell, and the call does not run.
605
+ */
606
+ private async gateCall(call: ASKGToolCallEvent, signal?: AbortSignal): Promise<ASKGToolGate | null> {
607
+ const manifest = this.manifest ?? await this.options.loadManifest();
608
+ this.manifest = manifest;
609
+ return await this.options.getExecutor(manifest)?.gate(call, {
610
+ promptOpen: this.confirmationOpen(call.toolCallId),
611
+ ...(signal ? { signal } : {}),
612
+ }) ?? null;
613
+ }
614
+
615
+ /** A confirmation other than this call's waits for the person. */
616
+ private confirmationOpen(toolCallId: string): boolean {
617
+ for (const pending of this.confirmations.keys()) {
618
+ if (pending !== toolCallId) return true;
484
619
  }
620
+ return false;
485
621
  }
486
622
 
487
623
  /**