@gloom-sh/terminal 0.20.17 → 0.20.19

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 (453) hide show
  1. package/package.json +3 -1
  2. package/src/account/auth-dialog.tsx +19 -1
  3. package/src/account/billing.ts +2 -1
  4. package/src/account/heard-from-question.tsx +235 -0
  5. package/src/account/heard-from.ts +97 -0
  6. package/src/api-client/cot.ts +5 -6
  7. package/src/api-client/data.ts +14 -3
  8. package/src/api-client/heard-from.ts +72 -0
  9. package/src/api-client/index.ts +64 -6
  10. package/src/api-client/mna.ts +18 -0
  11. package/src/api-client/request.ts +162 -40
  12. package/src/api-client/supply-chain.ts +9 -0
  13. package/src/api-client/types/billing.ts +35 -1
  14. package/src/api-client/types/news.ts +45 -0
  15. package/src/api-client/types/world-venues.ts +9 -0
  16. package/src/app/global-shortcuts.ts +5 -3
  17. package/src/app/pro-welcome/keys.ts +27 -0
  18. package/src/app/pro-welcome/model.ts +158 -0
  19. package/src/app/pro-welcome/row.tsx +176 -0
  20. package/src/app/pro-welcome/use-pro-welcome.ts +156 -0
  21. package/src/app/runtime/external-profile-changes.ts +135 -0
  22. package/src/app.tsx +37 -4
  23. package/src/architecture/core-builtin-allowlist.json +1 -1
  24. package/src/architecture/floating-promise-allowlist.json +1 -2
  25. package/src/architecture/shortcut-labels-allowlist.json +1 -0
  26. package/src/cli/alert-listing.ts +98 -0
  27. package/src/cli/commands/market.ts +191 -39
  28. package/src/cli/commands/overview.ts +7 -1
  29. package/src/cli/commands/plugins.ts +3 -2
  30. package/src/cli/commands/search.ts +30 -6
  31. package/src/cli/commands/ticker.ts +13 -6
  32. package/src/cli/context.ts +24 -5
  33. package/src/cli/csv-export.ts +2 -1
  34. package/src/cli/desktop-pane-shot-browser.ts +3 -1
  35. package/src/cli/desktop-pane-shot-view.ts +0 -1
  36. package/src/cli/desktop-pane-shot.ts +276 -52
  37. package/src/cli/errors.ts +3 -9
  38. package/src/cli/exit-codes.ts +1 -1
  39. package/src/cli/glossary.ts +65 -11
  40. package/src/cli/help.ts +1 -1
  41. package/src/cli/history-demergers.ts +117 -0
  42. package/src/cli/history-rows.ts +8 -4
  43. package/src/cli/index.ts +2 -1
  44. package/src/cli/known-gaps.ts +16 -0
  45. package/src/cli/known-us-stocks.ts +18 -0
  46. package/src/cli/listing-arg.ts +192 -38
  47. package/src/cli/pane-functions/catalog-snapshot-build.ts +83 -0
  48. package/src/cli/pane-functions/catalog-snapshot.json +877 -0
  49. package/src/cli/pane-functions/catalog-snapshot.ts +62 -0
  50. package/src/cli/pane-functions/catalog.ts +50 -16
  51. package/src/cli/pane-functions/data.ts +16 -4
  52. package/src/cli/pane-functions/dom.ts +54 -8
  53. package/src/cli/pane-functions/freshness.ts +39 -4
  54. package/src/cli/pane-functions/function-help.ts +3 -3
  55. package/src/cli/pane-functions/headless.ts +9 -1
  56. package/src/cli/pane-functions/index.ts +175 -50
  57. package/src/cli/pane-functions/report-notices.ts +10 -0
  58. package/src/cli/pane-functions/resolver.ts +11 -7
  59. package/src/cli/pane-functions/screenshot-assessment.ts +38 -10
  60. package/src/cli/pane-functions/screenshot-data-evidence.ts +7 -15
  61. package/src/cli/pane-functions/screenshot-payload.ts +36 -1
  62. package/src/cli/pane-functions/screenshot-render.ts +24 -9
  63. package/src/cli/pane-functions/screenshot-types.ts +9 -0
  64. package/src/cli/quote-answer.ts +33 -17
  65. package/src/cli/registry.ts +22 -2
  66. package/src/cli/result.ts +22 -4
  67. package/src/cli/scroll-truncation.ts +7 -2
  68. package/src/cli/series-search.ts +45 -6
  69. package/src/cli/shot-temp-dir.ts +4 -9
  70. package/src/cli/ticker-resolution.ts +1 -1
  71. package/src/cli/unreachable.ts +21 -0
  72. package/src/components/chart/composite/drawing-store.ts +11 -7
  73. package/src/components/chart/composite/format.ts +1 -0
  74. package/src/components/chart/composite/legend.tsx +48 -20
  75. package/src/components/chart/composite/panel-surface/panel-cursor.tsx +3 -3
  76. package/src/components/chart/composite/panel-surface/plot-gestures.ts +9 -2
  77. package/src/components/chart/composite/panel-surface.tsx +1 -1
  78. package/src/components/chart/composite/price-axis-labels.tsx +7 -5
  79. package/src/components/chart/composite/tools.ts +164 -39
  80. package/src/components/chart-table/header.tsx +11 -2
  81. package/src/components/chart-table/layout.ts +16 -17
  82. package/src/components/command-bar/pane-templates/items.ts +17 -1
  83. package/src/components/command-bar/routes/root/provider-search.ts +10 -1
  84. package/src/components/command-bar/routes/root/results.ts +34 -2
  85. package/src/components/command-bar/routes/root/runtime.ts +19 -4
  86. package/src/components/command-bar/routes/ticker-search/results.ts +5 -0
  87. package/src/components/command-bar/routes/ticker-search/route.ts +5 -0
  88. package/src/components/command-bar/selection-runtime.ts +29 -5
  89. package/src/components/command-bar/surface/index.tsx +4 -1
  90. package/src/components/command-bar/workflow/alert.ts +32 -13
  91. package/src/components/data-table/view.tsx +15 -2
  92. package/src/components/form-modal/content.tsx +9 -4
  93. package/src/components/index.ts +1 -1
  94. package/src/components/layout/header.tsx +9 -5
  95. package/src/components/layout/pane/capture-status.ts +6 -0
  96. package/src/components/layout/pane/footer/index.tsx +2 -0
  97. package/src/components/layout/pane/footer/model.ts +123 -17
  98. package/src/components/layout/pane/header.tsx +16 -2
  99. package/src/components/layout/pane/status-footer.ts +24 -0
  100. package/src/components/market-board/index.tsx +4 -2
  101. package/src/components/onboarding/onboarding-frame.tsx +6 -2
  102. package/src/components/onboarding/onboarding-keyboard.ts +7 -1
  103. package/src/components/onboarding/onboarding-wizard.tsx +3 -1
  104. package/src/components/onboarding/portfolio-step/positions-panel.tsx +24 -15
  105. package/src/components/onboarding/setup-cards.ts +36 -0
  106. package/src/components/onboarding/use-onboarding-progress.ts +22 -1
  107. package/src/components/onboarding/wizard-account.ts +6 -1
  108. package/src/components/onboarding/wizard-model.ts +32 -6
  109. package/src/components/onboarding/wizard-positions.ts +1 -1
  110. package/src/components/price-performance.tsx +26 -8
  111. package/src/components/reader/article-reader.tsx +12 -5
  112. package/src/components/sign-in-gate.tsx +3 -1
  113. package/src/components/toggle-list.tsx +6 -8
  114. package/src/components/ui/confirm-dialog.tsx +47 -7
  115. package/src/components/ui/data-table/opentui/index.tsx +7 -0
  116. package/src/components/ui/data-table/types.ts +8 -0
  117. package/src/components/ui/display.tsx +17 -2
  118. package/src/components/ui/index.ts +1 -1
  119. package/src/components/ui/stat-grid.tsx +4 -0
  120. package/src/components/ui/status.tsx +13 -1
  121. package/src/components/ui/table-layout.ts +34 -2
  122. package/src/components/use-pane-notice-footer.tsx +16 -3
  123. package/src/data/config/store/index.ts +31 -0
  124. package/src/data/config/store/node.ts +61 -11
  125. package/src/data/config/store/normalize.ts +4 -6
  126. package/src/data/config/store/shared-file.ts +309 -0
  127. package/src/data/profile-merge.ts +299 -0
  128. package/src/data/sqlite/checkpointer.ts +11 -1
  129. package/src/data/sqlite/database.ts +1 -1
  130. package/src/data/ticker-repository.ts +134 -10
  131. package/src/data/ticker-store.ts +67 -0
  132. package/src/data/ticker-writes.ts +5 -0
  133. package/src/i18n/es.ts +27 -0
  134. package/src/i18n/ja.ts +27 -0
  135. package/src/i18n/ko.ts +27 -0
  136. package/src/i18n/zh-cn.ts +27 -0
  137. package/src/i18n/zh-tw.ts +27 -0
  138. package/src/layout-marketplace/gallery-desktop.tsx +2 -2
  139. package/src/market-data/ah-pair.ts +122 -0
  140. package/src/market-data/coordinator/entries.ts +6 -4
  141. package/src/market-data/coordinator/index.ts +14 -3
  142. package/src/market-data/depositary-pair.ts +6 -2
  143. package/src/market-data/futures-board.ts +36 -29
  144. package/src/market-data/futures-contract.ts +37 -1
  145. package/src/market-data/hooks.tsx +33 -2
  146. package/src/market-data/market/change-basis.ts +11 -1
  147. package/src/market-data/market/header-market.ts +11 -0
  148. package/src/market-data/market/status.ts +40 -4
  149. package/src/market-data/performance.ts +127 -32
  150. package/src/market-data/quotes/time.ts +5 -2
  151. package/src/market-data/split-terms.ts +28 -0
  152. package/src/news/types.ts +28 -0
  153. package/src/notifications/app-badge.ts +2 -3
  154. package/src/notifications/app-notifier.ts +5 -0
  155. package/src/plugins/builtin/account-management/footer.ts +1 -1
  156. package/src/plugins/builtin/account-management/keyboard.ts +4 -0
  157. package/src/plugins/builtin/account-management/model.ts +1 -0
  158. package/src/plugins/builtin/account-management/pane.tsx +75 -7
  159. package/src/plugins/builtin/account-management/payment-recovery-row.tsx +12 -5
  160. package/src/plugins/builtin/account-management/pro-cancel.tsx +197 -0
  161. package/src/plugins/builtin/account-management/trial-cancel.ts +1 -1
  162. package/src/plugins/builtin/alerts/cli-move.ts +2 -2
  163. package/src/plugins/builtin/alerts/cli.ts +101 -48
  164. package/src/plugins/builtin/alerts/command.ts +39 -9
  165. package/src/plugins/builtin/alerts/constants.ts +10 -0
  166. package/src/plugins/builtin/alerts/earnings-listing.ts +20 -0
  167. package/src/plugins/builtin/alerts/event-rows.ts +9 -3
  168. package/src/plugins/builtin/alerts/events-pane.tsx +16 -10
  169. package/src/plugins/builtin/alerts/format.ts +24 -8
  170. package/src/plugins/builtin/alerts/headless.ts +12 -6
  171. package/src/plugins/builtin/alerts/index.tsx +97 -16
  172. package/src/plugins/builtin/alerts/move-checks.ts +7 -0
  173. package/src/plugins/builtin/alerts/option-contract.ts +197 -0
  174. package/src/plugins/builtin/alerts/pane.tsx +1 -1
  175. package/src/plugins/builtin/alerts/price.ts +30 -5
  176. package/src/plugins/builtin/alerts/pro-rules.ts +62 -0
  177. package/src/plugins/builtin/alerts/quotes.ts +26 -2
  178. package/src/plugins/builtin/alerts/research-builder.ts +5 -10
  179. package/src/plugins/builtin/alerts/scheduled.ts +6 -1
  180. package/src/plugins/builtin/alerts/types.ts +7 -0
  181. package/src/plugins/builtin/analytics/account-returns.ts +1 -1
  182. package/src/plugins/builtin/analytics/manual-value.ts +61 -0
  183. package/src/plugins/builtin/analytics/pane-model.ts +2 -2
  184. package/src/plugins/builtin/analytics/risk-book.ts +7 -7
  185. package/src/plugins/builtin/analytics/risk-client.ts +27 -14
  186. package/src/plugins/builtin/analytics/risk-headless.ts +13 -8
  187. package/src/plugins/builtin/analytics/risk-model.ts +92 -4
  188. package/src/plugins/builtin/analytics/risk-pane.tsx +85 -38
  189. package/src/plugins/builtin/awards/pane.tsx +1 -1
  190. package/src/plugins/builtin/broker-trading/orders.tsx +2 -2
  191. package/src/plugins/builtin/buildout/company/pane.tsx +4 -14
  192. package/src/plugins/builtin/catalysts/model.ts +2 -1
  193. package/src/plugins/builtin/central-bank-rates/model.ts +8 -2
  194. package/src/plugins/builtin/central-bank-rates/pane.tsx +5 -3
  195. package/src/plugins/builtin/chart-composer/chart-spec.ts +5 -0
  196. package/src/plugins/builtin/chart-composer/cli-options.ts +9 -5
  197. package/src/plugins/builtin/chart-composer/data-catalog-pane.tsx +2 -6
  198. package/src/plugins/builtin/chart-composer/headless-schema.ts +14 -10
  199. package/src/plugins/builtin/chart-composer/headless.ts +2 -0
  200. package/src/plugins/builtin/chart-composer/index.tsx +17 -5
  201. package/src/plugins/builtin/chart-composer/pane.tsx +19 -6
  202. package/src/plugins/builtin/chart-composer/viewport-labels.ts +2 -17
  203. package/src/plugins/builtin/chat/controller/notifications.ts +1 -0
  204. package/src/plugins/builtin/chat/index.tsx +0 -1
  205. package/src/plugins/builtin/cloud/auth-actions.tsx +11 -6
  206. package/src/plugins/builtin/cloud/company-picker.tsx +5 -3
  207. package/src/plugins/builtin/cloud/upgrade-command.ts +1 -1
  208. package/src/plugins/builtin/commodities-energy/index.tsx +1 -1
  209. package/src/plugins/builtin/company-kpis/headless.ts +10 -5
  210. package/src/plugins/builtin/company-kpis/latest.ts +45 -0
  211. package/src/plugins/builtin/company-kpis/model.ts +57 -15
  212. package/src/plugins/builtin/company-kpis/pane.tsx +22 -8
  213. package/src/plugins/builtin/composite/alt-data.ts +20 -0
  214. package/src/plugins/builtin/composite/application.ts +14 -0
  215. package/src/plugins/builtin/composite/broker.ts +12 -0
  216. package/src/plugins/builtin/composite/credit.ts +33 -0
  217. package/src/plugins/builtin/composite/crypto.ts +10 -0
  218. package/src/plugins/builtin/composite/earnings.ts +12 -0
  219. package/src/plugins/builtin/composite/filings.ts +13 -0
  220. package/src/plugins/builtin/composite/futures-commodities.ts +23 -0
  221. package/src/plugins/builtin/composite/global-markets.ts +12 -0
  222. package/src/plugins/builtin/composite/options-volatility.ts +23 -0
  223. package/src/plugins/builtin/composite/ownership.ts +23 -0
  224. package/src/plugins/builtin/composite/portfolio.ts +10 -0
  225. package/src/plugins/builtin/composite/quant.ts +15 -0
  226. package/src/plugins/builtin/composite/rates-macro.ts +30 -0
  227. package/src/plugins/builtin/composite/screeners.ts +11 -0
  228. package/src/plugins/builtin/composite/shared.ts +11 -0
  229. package/src/plugins/builtin/composite/ticker-core.ts +36 -0
  230. package/src/plugins/builtin/congress-trades/headless.ts +31 -3
  231. package/src/plugins/builtin/congress-trades/model.ts +9 -5
  232. package/src/plugins/builtin/correlation/index.tsx +13 -17
  233. package/src/plugins/builtin/correlation/matrix/model.ts +18 -0
  234. package/src/plugins/builtin/cot/client.ts +2 -3
  235. package/src/plugins/builtin/cot/headless.ts +16 -16
  236. package/src/plugins/builtin/cot/index.tsx +6 -6
  237. package/src/plugins/builtin/cot/model.ts +25 -5
  238. package/src/plugins/builtin/cot/pane.tsx +11 -6
  239. package/src/plugins/builtin/cot/series.ts +11 -8
  240. package/src/plugins/builtin/cpi/model.ts +15 -4
  241. package/src/plugins/builtin/cpi/pane.tsx +29 -7
  242. package/src/plugins/builtin/dividend-yield/client.ts +57 -16
  243. package/src/plugins/builtin/dividend-yield/headless.ts +17 -11
  244. package/src/plugins/builtin/dividend-yield/model.ts +4 -3
  245. package/src/plugins/builtin/dividend-yield/pane.tsx +22 -18
  246. package/src/plugins/builtin/dividend-yield/ranking.ts +1 -1
  247. package/src/plugins/builtin/dividend-yield/types.ts +4 -0
  248. package/src/plugins/builtin/dividend-yield/view.ts +23 -12
  249. package/src/plugins/builtin/doe/model.ts +30 -0
  250. package/src/plugins/builtin/doe/pane.tsx +8 -2
  251. package/src/plugins/builtin/earnings/board-table.ts +9 -4
  252. package/src/plugins/builtin/earnings/fiscal-quarter.ts +39 -0
  253. package/src/plugins/builtin/earnings/headless.ts +16 -6
  254. package/src/plugins/builtin/earnings/history-model.ts +6 -4
  255. package/src/plugins/builtin/earnings/history-table.ts +7 -4
  256. package/src/plugins/builtin/earnings-calls/calendar.tsx +4 -3
  257. package/src/plugins/builtin/earnings-calls/pane.tsx +8 -2
  258. package/src/plugins/builtin/earnings-ripple/pane.tsx +2 -2
  259. package/src/plugins/builtin/econ/calendar-model.ts +16 -0
  260. package/src/plugins/builtin/econ/index.tsx +7 -2
  261. package/src/plugins/builtin/equity-screener/headless.ts +4 -1
  262. package/src/plugins/builtin/equity-screener/model.ts +7 -6
  263. package/src/plugins/builtin/estimate-revisions/headless.ts +1 -1
  264. package/src/plugins/builtin/exposure/model.ts +10 -0
  265. package/src/plugins/builtin/exposure/pane.tsx +10 -3
  266. package/src/plugins/builtin/futures/model.ts +14 -1
  267. package/src/plugins/builtin/futures/series.ts +1 -8
  268. package/src/plugins/builtin/fx-matrix/amount.ts +15 -1
  269. package/src/plugins/builtin/fx-matrix/headless.ts +12 -6
  270. package/src/plugins/builtin/fx-matrix/index.tsx +25 -7
  271. package/src/plugins/builtin/fx-matrix/settings.ts +9 -4
  272. package/src/plugins/builtin/insider/detail.tsx +36 -7
  273. package/src/plugins/builtin/insider/filing-stories.ts +110 -0
  274. package/src/plugins/builtin/insider/headless.ts +37 -2
  275. package/src/plugins/builtin/insider/index.tsx +79 -10
  276. package/src/plugins/builtin/insider/model.ts +43 -5
  277. package/src/plugins/builtin/ipo-calendar/client.ts +11 -1
  278. package/src/plugins/builtin/ipo-calendar/model.ts +3 -7
  279. package/src/plugins/builtin/jobs/headless.ts +2 -1
  280. package/src/plugins/builtin/jobs/model.ts +6 -0
  281. package/src/plugins/builtin/jobs/pane.tsx +8 -3
  282. package/src/plugins/builtin/kelly-sizer/pane.tsx +9 -4
  283. package/src/plugins/builtin/market-valuation/pane.tsx +22 -10
  284. package/src/plugins/builtin/mna/detail.tsx +67 -6
  285. package/src/plugins/builtin/mna/headless.ts +128 -13
  286. package/src/plugins/builtin/mna/model.ts +219 -16
  287. package/src/plugins/builtin/mna/pane.tsx +34 -6
  288. package/src/plugins/builtin/money-markets/model.ts +14 -5
  289. package/src/plugins/builtin/money-markets/pane.tsx +4 -3
  290. package/src/plugins/builtin/news/wire/news/detail-view.tsx +118 -10
  291. package/src/plugins/builtin/news/wire/news/footer.ts +3 -8
  292. package/src/plugins/builtin/news/wire/news/story-evidence.ts +178 -0
  293. package/src/plugins/builtin/options/analytics.ts +1 -1
  294. package/src/plugins/builtin/options/view.tsx +18 -11
  295. package/src/plugins/builtin/options-positioning/model.ts +11 -0
  296. package/src/plugins/builtin/options-positioning/pane.tsx +22 -1
  297. package/src/plugins/builtin/options-scenario/client.ts +49 -8
  298. package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +22 -6
  299. package/src/plugins/builtin/options-scenario/csp-screen.ts +39 -12
  300. package/src/plugins/builtin/options-scenario/headless.ts +7 -3
  301. package/src/plugins/builtin/options-scenario/model.ts +33 -2
  302. package/src/plugins/builtin/options-scenario/pane.tsx +3 -4
  303. package/src/plugins/builtin/options-scenario/strategy-screen.ts +7 -5
  304. package/src/plugins/builtin/pe-band/client.ts +13 -1
  305. package/src/plugins/builtin/pe-band/headless.ts +2 -2
  306. package/src/plugins/builtin/pe-band/model.ts +63 -10
  307. package/src/plugins/builtin/pe-band/pane.tsx +5 -5
  308. package/src/plugins/builtin/perps/cascade.ts +4 -3
  309. package/src/plugins/builtin/perps/markets-section.tsx +5 -2
  310. package/src/plugins/builtin/perps/model.ts +4 -3
  311. package/src/plugins/builtin/portfolio-list/allocation-rows.ts +26 -7
  312. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +66 -13
  313. package/src/plugins/builtin/portfolio-list/cli/render.ts +76 -33
  314. package/src/plugins/builtin/portfolio-list/headless.ts +69 -22
  315. package/src/plugins/builtin/portfolio-list/pane/data.ts +3 -3
  316. package/src/plugins/builtin/portfolio-list/pane/index.tsx +29 -14
  317. package/src/plugins/builtin/portfolio-list/summary/index.tsx +2 -2
  318. package/src/plugins/builtin/portfolio-list/table.tsx +3 -2
  319. package/src/plugins/builtin/relative-rotation/pane.tsx +2 -3
  320. package/src/plugins/builtin/research/corporate-actions-pane.tsx +33 -14
  321. package/src/plugins/builtin/research/event-model.ts +43 -19
  322. package/src/plugins/builtin/research/headless.ts +8 -1
  323. package/src/plugins/builtin/research/relative-valuation-pane.tsx +19 -17
  324. package/src/plugins/builtin/research-search/index.tsx +3 -1
  325. package/src/plugins/builtin/scanner/denied.tsx +16 -4
  326. package/src/plugins/builtin/scanner/flow-pane.tsx +1 -1
  327. package/src/plugins/builtin/scanner/hilo-pane.tsx +1 -1
  328. package/src/plugins/builtin/sec/filing-display.tsx +14 -2
  329. package/src/plugins/builtin/sec/headless.ts +42 -4
  330. package/src/plugins/builtin/sec/index.tsx +21 -1
  331. package/src/plugins/builtin/sectors/index.tsx +6 -9
  332. package/src/plugins/builtin/sectors/sector-model.ts +1 -1
  333. package/src/plugins/builtin/shared/cloud-upgrade.ts +1 -1
  334. package/src/plugins/builtin/shared/earnings-report.ts +49 -5
  335. package/src/plugins/builtin/shared/options-pro-copy.ts +34 -0
  336. package/src/plugins/builtin/shared/report-freshness.ts +2 -3
  337. package/src/plugins/builtin/shared/statement-currency.ts +23 -0
  338. package/src/plugins/builtin/shared/ticker-surface.ts +1 -1
  339. package/src/plugins/builtin/supply-chain/client.ts +34 -9
  340. package/src/plugins/builtin/supply-chain/evidence.ts +3 -2
  341. package/src/plugins/builtin/supply-chain/flow.tsx +4 -3
  342. package/src/plugins/builtin/supply-chain/graph-model.ts +14 -7
  343. package/src/plugins/builtin/supply-chain/graph-pane.tsx +3 -1
  344. package/src/plugins/builtin/supply-chain/graph.tsx +6 -3
  345. package/src/plugins/builtin/supply-chain/headless.ts +19 -4
  346. package/src/plugins/builtin/supply-chain/model.ts +50 -6
  347. package/src/plugins/builtin/supply-chain/pane.tsx +79 -18
  348. package/src/plugins/builtin/themes/headless.ts +4 -4
  349. package/src/plugins/builtin/themes/model.ts +11 -8
  350. package/src/plugins/builtin/themes/pane.tsx +2 -2
  351. package/src/plugins/builtin/ticker-detail/adr-pair/ah.ts +62 -0
  352. package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +119 -20
  353. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +51 -1
  354. package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +25 -14
  355. package/src/plugins/builtin/ticker-detail/financials/model.ts +22 -32
  356. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +7 -9
  357. package/src/plugins/builtin/ticker-detail/headless-schema.ts +2 -0
  358. package/src/plugins/builtin/ticker-detail/headless.ts +28 -12
  359. package/src/plugins/builtin/ticker-detail/overview/board-lot.ts +21 -0
  360. package/src/plugins/builtin/ticker-detail/overview/model.ts +28 -2
  361. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +8 -0
  362. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +68 -13
  363. package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +9 -2
  364. package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +5 -2
  365. package/src/plugins/builtin/volatility/model.ts +17 -0
  366. package/src/plugins/builtin/volatility/pane.tsx +16 -7
  367. package/src/plugins/builtin/world-indices/index.tsx +2 -0
  368. package/src/plugins/builtin/world-indices/table.tsx +15 -0
  369. package/src/plugins/builtin/world-venue-map/evidence.ts +3 -2
  370. package/src/plugins/builtin/world-venue-map/headless.ts +32 -18
  371. package/src/plugins/builtin/world-venue-map/index.ts +19 -6
  372. package/src/plugins/builtin/world-venue-map/layered-pane.tsx +9 -5
  373. package/src/plugins/builtin/world-venue-map/layers.ts +33 -11
  374. package/src/plugins/builtin/world-venue-map/map.tsx +12 -0
  375. package/src/plugins/builtin/world-venue-map/model.ts +6 -1
  376. package/src/plugins/builtin/world-venue-map/pane.tsx +35 -6
  377. package/src/plugins/builtin/world-venue-map/place.ts +119 -0
  378. package/src/plugins/builtin/world-venue-map/venue-header.tsx +5 -3
  379. package/src/plugins/catalog-browser.ts +10 -1
  380. package/src/plugins/catalog-data.ts +20 -0
  381. package/src/plugins/catalog-lazy.ts +51 -0
  382. package/src/plugins/catalog-ui.ts +16 -18
  383. package/src/plugins/host-smoke.ts +5 -2
  384. package/src/portfolio/allocation.ts +79 -19
  385. package/src/portfolio/cash-balances.ts +76 -0
  386. package/src/portfolio/mutations.ts +43 -8
  387. package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
  388. package/src/renderers/browser/activity.ts +16 -0
  389. package/src/renderers/browser/app-badge-host.ts +14 -0
  390. package/src/renderers/browser/main.tsx +5 -0
  391. package/src/renderers/browser/notifications.ts +103 -0
  392. package/src/renderers/browser/ui-host.tsx +4 -0
  393. package/src/renderers/desktop/window-layouts.ts +14 -0
  394. package/src/renderers/dom/data-table/index.tsx +27 -4
  395. package/src/renderers/dom/data-table/row.tsx +2 -0
  396. package/src/renderers/dom/host/tabs.tsx +57 -8
  397. package/src/renderers/dom/styles.css +13 -5
  398. package/src/renderers/electrobun/bun/desktop/backend-requests.ts +4 -0
  399. package/src/renderers/electrobun/bun/desktop/backend.ts +22 -1
  400. package/src/renderers/electrobun/bun/window/native-min-size.ts +6 -1
  401. package/src/renderers/electrobun/shared/protocol.ts +4 -0
  402. package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +50 -12
  403. package/src/renderers/electrobun/view/http-fetch.ts +3 -2
  404. package/src/renderers/electrobun/view/remote/ticker-repository.ts +10 -0
  405. package/src/series/standalone-catalog.ts +5 -4
  406. package/src/series/standalone.ts +13 -7
  407. package/src/sources/gloomberb-cloud/index.ts +22 -9
  408. package/src/sources/gloomberb-cloud/news.ts +35 -0
  409. package/src/sources/gloomberb-cloud/perpetuals.ts +60 -3
  410. package/src/sources/provider-errors.ts +34 -7
  411. package/src/sources/provider-router/financials.ts +20 -13
  412. package/src/sources/provider-router/history.ts +32 -6
  413. package/src/sources/provider-router/index.ts +4 -0
  414. package/src/sources/provider-router/search.ts +1 -0
  415. package/src/sync/collections-contributor.ts +3 -1
  416. package/src/sync/config-merge.ts +10 -1
  417. package/src/sync/sanitize.ts +26 -2
  418. package/src/tickers/company-name-listing.ts +16 -2
  419. package/src/tickers/listing-fate.ts +12 -8
  420. package/src/tickers/renamed-listings.ts +43 -10
  421. package/src/tickers/search/home-listing.ts +28 -0
  422. package/src/tickers/search/index.ts +19 -7
  423. package/src/tickers/terminal-codes.ts +11 -1
  424. package/src/time-series/base-series.ts +39 -6
  425. package/src/time-series/chart-seed.ts +2 -2
  426. package/src/time-series/history-quality.ts +4 -1
  427. package/src/time-series/hooks.ts +2 -0
  428. package/src/time-series/price-comparison.ts +17 -23
  429. package/src/time-series/reporting.ts +1 -1
  430. package/src/time-series/resolution.ts +13 -0
  431. package/src/time-series/resolve-context.ts +6 -0
  432. package/src/time-series/resolve.ts +42 -3
  433. package/src/time-series/spec.ts +2 -2
  434. package/src/time-series/types.ts +3 -2
  435. package/src/types/data-provider.ts +11 -0
  436. package/src/types/financials.ts +48 -4
  437. package/src/types/headless.ts +1 -0
  438. package/src/types/issuer-listings.ts +2 -0
  439. package/src/types/plugin-notifications.ts +3 -0
  440. package/src/types/price-history.ts +6 -4
  441. package/src/types/ticker.ts +10 -2
  442. package/src/ui/host.tsx +2 -0
  443. package/src/utils/cli-output.ts +1 -1
  444. package/src/utils/declared-dividends.ts +13 -1
  445. package/src/utils/dividend-cash.ts +5 -1
  446. package/src/utils/exchange-announcements.ts +7 -2
  447. package/src/utils/forward-dividend.ts +4 -3
  448. package/src/utils/fundamentals.ts +40 -0
  449. package/src/utils/network-failure.ts +2 -0
  450. package/src/utils/price-history-integrity.ts +9 -1
  451. package/src/utils/remove-folder.ts +37 -0
  452. package/src/utils/trailing-dividend.ts +1 -1
  453. package/src/plugins/builtin/composite-plugins.ts +0 -285
@@ -11,7 +11,7 @@ import type { ChartPaneModel } from "../../plugins/builtin/chart-composer/headle
11
11
  import { buildHeadlessPaneLoadArgs, loadResolvedHeadlessPaneModel, type LoadedHeadlessPaneModel } from "./headless";
12
12
  import { resolve } from "path";
13
13
  import type { PaneRuntimeState } from "../../core/state/app/state";
14
- import { CHART_COMPOSER_PANE_ID, type AppConfig } from "../../types/config";
14
+ import { CHART_COMPOSER_PANE_ID, TICKER_RESEARCH_PANE_ID, type AppConfig } from "../../types/config";
15
15
  import type { OptionsChain, PricePoint, TickerFinancials } from "../../types/financials";
16
16
  import type { InstrumentRef } from "../../market-data/request-types";
17
17
  import { fetchHistoryResult } from "../../sources/history-result";
@@ -37,6 +37,7 @@ import { collectExternalPluginBundles } from "../../renderers/electrobun/bun/ext
37
37
  import { getQuoteMonitorPaneSettings } from "../../plugins/builtin/ticker-detail/settings";
38
38
  import { isNotATickerMessage } from "../not-a-ticker";
39
39
  import { HISTORY_DEFAULT_RANGE } from "../../plugins/builtin/ticker-detail/data-panes/history-bars";
40
+ import { priceReturnDailyWindow } from "../../market-data/performance";
40
41
  import { findCollection } from "../../plugins/builtin/portfolio-list/cli/render";
41
42
  import { peekCachedBrokerAccounts } from "../../plugins/builtin/portfolio-list/cached-account";
42
43
  import { paneScreenshotEvidenceHook } from "./screenshot-evidence";
@@ -165,6 +166,33 @@ interface ShotSymbolCapture {
165
166
  unread?: { symbol: string; reason: string };
166
167
  tape?: TapeCapture;
167
168
  chain?: [string, OptionsChain];
169
+ /** More than one cadence the pane reads for the row, each answering only its own requests. */
170
+ historyVariants?: NonNullable<SnapshotMarketData["historyVariants"]>;
171
+ }
172
+
173
+ /**
174
+ * PEB reads every week on record and, for the years they are served, the
175
+ * daily closes that price each figure on its day; DES's overview charts the
176
+ * weeks and measures its Price Return strip on five years of daily closes.
177
+ * Captured history answers every request, so the weekly bars would stand in
178
+ * for the daily ones and the capture read the week around each figure's day
179
+ * (or each period's start): each cadence is its own, under the listing the
180
+ * pane asks for. Without daily closes the weekly bars stand alone, as in the app.
181
+ */
182
+ async function weeklyAndDailyHistoryVariants(
183
+ context: MarketContext, ticker: TickerRecord, exchange: string, weekly: TickerFinancials["priceHistory"],
184
+ /** DES's window (priceReturnDailyWindow), which it asks for by its dates; PEB's is the 5Y range. */
185
+ window?: { start: Date; end: Date },
186
+ ): Promise<NonNullable<SnapshotMarketData["historyVariants"]>> {
187
+ const target = { symbol: ticker.metadata.ticker, exchange: ticker.metadata.exchange ?? "" };
188
+ const provider = context.dataProvider;
189
+ const read = window
190
+ ? provider.getDetailedPriceHistoryWithMetadata?.(target.symbol, exchange, window.start, window.end, "1d", toMarketDataContext(target))
191
+ .then((result) => result.points)
192
+ ?? provider.getDetailedPriceHistory?.(target.symbol, exchange, window.start, window.end, "1d", toMarketDataContext(target))
193
+ : provider.getPriceHistoryForResolution?.(target.symbol, exchange, "5Y", "1d", toMarketDataContext(target));
194
+ const daily = await (read ?? Promise.resolve([])).catch(logFailure("cli.pane-functions.screenshot-payload", "Read daily closes for a capture failed", []));
195
+ return [{ target, resolution: "1wk", points: weekly ?? [] }, ...(daily.length ? [{ target, resolution: "1d" as const, points: daily }] : [])];
168
196
  }
169
197
 
170
198
  export async function buildDesktopShotPayload(
@@ -348,6 +376,12 @@ export async function buildDesktopShotPayload(
348
376
  if (resolved.pane.id === "time-sales") {
349
377
  capture.tape = [entry.instrument.symbol, exchange, await fetchTape(entry.instrument.symbol, exchange)];
350
378
  }
379
+ // DES (the research pane's overview, not its financials or the ADR pair) measures returns on daily closes.
380
+ const overview = resolved.pane.id === TICKER_RESEARCH_PANE_ID && resolved.template?.id !== "adr-pair-pane" && !isFinancialAnalysisFunction(resolved);
381
+ if (resolved.pane.id === "pe-band" || overview) {
382
+ capture.historyVariants = await weeklyAndDailyHistoryVariants(context, capture.ticker, exchange, data.priceHistory,
383
+ overview ? priceReturnDailyWindow() : undefined);
384
+ }
351
385
  if (includeOptionsChains && context.dataProvider.getOptionsChain) {
352
386
  // A future with no chain of its own is the pane's to explain (the listed alternative), not a failed shot.
353
387
  const chain = await context.dataProvider.getOptionsChain(entry.instrument.symbol, exchange, undefined,
@@ -425,6 +459,7 @@ export async function buildDesktopShotPayload(
425
459
  }
426
460
  if (capture.tape) tapeSnapshots.push(capture.tape);
427
461
  if (capture.chain) optionsChains.push(capture.chain);
462
+ if (capture.historyVariants?.length) historyVariants = [...historyVariants ?? [], ...capture.historyVariants];
428
463
  }
429
464
  }
430
465
  // PF over a period draws the report's P&L between the two closes: the page reads no history of its own.
@@ -1,9 +1,10 @@
1
1
  import { logFailure } from "../../utils/log-failure";
2
2
  import { apiClient } from "../../api-client";
3
3
  import { loadResolvedHeadlessPaneModel, reportCoverage, reportGaps, type LoadedHeadlessPaneModel } from "./headless";
4
- import { createOutputFolder } from "../output-file";
4
+ import { createOutputFolder, writeOutputFile } from "../output-file";
5
5
  import type { Quote } from "../../types/financials";
6
6
  import { isRecord } from "../../utils/guards";
7
+ import { savedCopyAt, savedCopyShownAt } from "../../data/saved-copies";
7
8
  import {
8
9
  prepareDesktopPaneShotView,
9
10
  renderDesktopPaneScreenshot,
@@ -20,6 +21,7 @@ import {
20
21
  deriveCaptureReport,
21
22
  deriveHeadlessFreshness,
22
23
  deriveRenderedFreshness,
24
+ statusDateEvidence,
23
25
  type CaptureReport,
24
26
  type CaptureStatusLine,
25
27
  type ReportFreshness,
@@ -42,7 +44,7 @@ export function shotHasStatusLine(resolved: Pick<ResolvedPaneFunction, "pane" |
42
44
  }
43
45
 
44
46
  /** The bridge, keeping every quote it serves the page: what a pane that loads its own quotes (WEI) shows. */
45
- function recordBridgedQuotes(bridge: DesktopPaneShotBridge): { bridge: DesktopPaneShotBridge; quotes: Quote[] } {
47
+ function recordBridgedQuotes(bridge: DesktopPaneShotBridge, onSavedCopy?: (savedAt: number) => void): { bridge: DesktopPaneShotBridge; quotes: Quote[] } {
46
48
  const quotes: Quote[] = [];
47
49
  const keep = (value: unknown) => {
48
50
  if (isRecord(value) && typeof value.symbol === "string" && typeof value.price === "number") quotes.push(value as unknown as Quote);
@@ -53,6 +55,9 @@ function recordBridgedQuotes(bridge: DesktopPaneShotBridge): { bridge: DesktopPa
53
55
  ...bridge,
54
56
  async marketData(operation, args) {
55
57
  const result = await bridge.marketData(operation, args);
58
+ // The page gets the answer as JSON, which drops its saved-copy mark: the report keeps when it was saved.
59
+ const savedAt = savedCopyAt(result) ?? savedCopyShownAt(result);
60
+ if (savedAt != null) onSavedCopy?.(savedAt);
56
61
  if (operation === "getQuote") keep(result);
57
62
  if (operation === "getQuotesBatch" && Array.isArray(result)) {
58
63
  for (const entry of result) keep(isRecord(entry) ? entry.quote : null);
@@ -224,6 +229,7 @@ export async function renderDesktopShot({
224
229
  maxHeightCells,
225
230
  options,
226
231
  captureImage = true,
232
+ onlyUsable = false,
227
233
  onStalledReport,
228
234
  onDrawing,
229
235
  }: {
@@ -246,6 +252,7 @@ export async function renderDesktopShot({
246
252
  maxHeightCells?: number;
247
253
  options: Record<string, string | true>;
248
254
  captureImage?: boolean;
255
+ onlyUsable?: boolean;
249
256
  /**
250
257
  * Called when the report behind the status line was still loading at the
251
258
  * wait's end: the load was aborted, but a loader that ignores the signal
@@ -254,13 +261,17 @@ export async function renderDesktopShot({
254
261
  onStalledReport?: () => void;
255
262
  /** Called once the pane's data is read and the page starts to draw it. */
256
263
  onDrawing?: () => void;
257
- }): Promise<PaneScreenshotResult> {
264
+ }): Promise<PaneScreenshotResult & { saved: boolean }> {
258
265
  prepareDesktopPaneShotView();
259
266
  if (captureImage) await createOutputFolder(outputPath);
260
- const apiProxy = resolveDesktopShotApiProxy(context);
267
+ // The copies saved earlier the page drew from, where the data service did not answer.
268
+ const savedCopies: number[] = [];
269
+ const onSavedCopy = (savedAt: number) => { savedCopies.push(savedAt); };
270
+ const apiProxy = { ...resolveDesktopShotApiProxy(context), onSavedCopy };
261
271
  const previousSessionToken = apiClient.getSessionToken();
262
272
  let payload: DesktopPaneShotPayload;
263
273
  let render: DesktopPaneShotRenderResult;
274
+ let image: Uint8Array | undefined;
264
275
  let freshness: ReportFreshness | undefined;
265
276
  let coverage: Promise<ShotReportCoverage | undefined> | undefined;
266
277
  let covered: ShotReportCoverage | undefined;
@@ -306,9 +317,9 @@ export async function renderDesktopShot({
306
317
  const report = payload.statusLine ? reportShotFreshness(resolved, loadModel) : undefined;
307
318
  // The same load says whether the report is complete, with or without a status line.
308
319
  coverage = captureImage ? reportShotCoverage(resolved, loadModel) : undefined;
309
- const recorded = recordBridgedQuotes(createDesktopShotBridge(context));
320
+ const recorded = recordBridgedQuotes(createDesktopShotBridge(context), onSavedCopy);
310
321
  const shotPayload = payload;
311
- render = await renderDesktopPaneScreenshot(payload, outputPath, apiProxy, {
322
+ ({ image, ...render } = await renderDesktopPaneScreenshot(payload, apiProxy, {
312
323
  captureImage,
313
324
  bridge: recorded.bridge,
314
325
  statusLine: async (rendered) => {
@@ -323,9 +334,10 @@ export async function renderDesktopShot({
323
334
  freshness = line.freshness;
324
335
  // A row whose read failed is marked on the picture, where its figures are missing.
325
336
  const unread = unreadRowsNote(shotPayload.unreadRows);
326
- return { variants: unread ? line.variants.map((variant) => `${variant} · ${unread}`) : line.variants, dates: line.dates };
337
+ return { variants: unread ? line.variants.map((variant) => `${variant} · ${unread}`) : line.variants, dates: line.dates,
338
+ dateEvidence: statusDateEvidence(line.freshness) };
327
339
  },
328
- });
340
+ }));
329
341
  covered = coverage && await settledWithin(coverage, SHOT_REPORT_WAIT_MS);
330
342
  } finally {
331
343
  apiClient.setSessionToken(previousSessionToken);
@@ -334,8 +346,11 @@ export async function renderDesktopShot({
334
346
  const renderedInstance = payload.config.layout.instances.find(({ instanceId }) => instanceId === payload.paneId);
335
347
  if (renderedInstance) resolved = { ...resolved, instance: renderedInstance };
336
348
  const assessed = withReportCoverage(assessPaneScreenshot(resolved, payload, render, rawArg, outputPath), covered);
349
+ const save = image && (!onlyUsable || assessed.usable) ? image : undefined;
350
+ if (save) await writeOutputFile(outputPath, save);
337
351
  const unreadRows = payload.unreadRows?.length ? { unreadRows: payload.unreadRows, ...(payload.unreadReasons ? { unreadReasons: payload.unreadReasons } : {}) } : {};
338
- return freshness ? { ...assessed, ...unreadRows, freshness } : { ...assessed, ...unreadRows };
352
+ return { ...assessed, ...unreadRows, saved: save !== undefined, ...(freshness ? { freshness } : {}),
353
+ ...(savedCopies.length > 0 ? { savedCopyAt: Math.min(...savedCopies) } : {}) };
339
354
  }
340
355
 
341
356
  /** "FRC did not load": a list's rows whose read failed, as the capture's status line marks them. */
@@ -5,6 +5,8 @@ import type { PaneScreenshotEvidence } from "./screenshot-evidence";
5
5
  import type { ReportFreshness } from "./freshness";
6
6
  import type { PaneScreenshotFinancialRatioEvidence } from "./financial-ratio-shot";
7
7
 
8
+ export const PANE_SWEEP_EVIDENCE_PATH = "GLOOMBERB_PANE_SWEEP_EVIDENCE_PATH";
9
+
8
10
  export interface PaneScreenshotExpectedSelection {
9
11
  control: "metric" | "statement" | "ratio" | "period";
10
12
  value?: string;
@@ -108,6 +110,7 @@ export type PaneScreenshotDataEvidence =
108
110
  | PaneScreenshotEvidence;
109
111
 
110
112
  export interface PaneScreenshotReadinessSignals {
113
+ confirmedEmpty?: boolean;
111
114
  /**
112
115
  * A surface to operate rather than data to read (Layouts, Brokers): its rows
113
116
  * and an empty-state marker inside it say nothing of whether it rendered.
@@ -145,6 +148,12 @@ export interface PaneScreenshotResult {
145
148
  empty: boolean;
146
149
  complete: boolean;
147
150
  unavailableSymbols: string[];
151
+ /**
152
+ * When the oldest copy the page drew from was saved (ms): a read the data
153
+ * service did not answer was answered from a copy saved earlier, through
154
+ * the market bridge or the API proxy. A report dates its view as saved.
155
+ */
156
+ savedCopyAt?: number;
148
157
  /** Rows of a list whose read failed (refused, timed out): pictured without figures and named on the status line. */
149
158
  unreadRows?: string[];
150
159
  /** Why each of `unreadRows` did not load, as the source answered. */
@@ -1,4 +1,4 @@
1
- import type { QuoteBatchResult } from "../types/data-provider";
1
+ import type { QuoteBatchOptions, QuoteBatchResult } from "../types/data-provider";
2
2
  import type { Quote } from "../types/financials";
3
3
  import { bareListingNote } from "../tickers/listing-fate";
4
4
  import { isRateLimited, isTransientServiceFailure, notATickerSymbol, rateLimitedError } from "../sources/provider-errors";
@@ -35,13 +35,13 @@ import {
35
35
  tradingBoardNote,
36
36
  type CliListing,
37
37
  type ListingDataRequest,
38
+ type ListingDeps,
38
39
  type ListingVenue,
39
40
  } from "./listing-arg";
40
41
  import { isNotATickerMessage, withListingSuggestion } from "./not-a-ticker";
41
42
  import { notATickerWords } from "./company-name-hint";
42
43
  import { isNetworkFailure } from "../utils/network-failure";
43
44
  import { logFailure } from "../utils/log-failure";
44
- import type { MarketContext } from "./types";
45
45
 
46
46
  /** The text of an error, or null for none. */
47
47
  export function errorMessage(error: unknown): string | null {
@@ -96,7 +96,7 @@ export interface QuoteAnswer {
96
96
  export async function answerQuote(
97
97
  result: QuoteBatchResult,
98
98
  listing: CliListing,
99
- market: MarketContext,
99
+ market: ListingDeps,
100
100
  request: ListingDataRequest,
101
101
  refresh: boolean,
102
102
  venues: Promise<ListingVenue[]> | null,
@@ -209,7 +209,7 @@ export async function answerQuote(
209
209
  * (`.IS`, `.JO`): another one-letter suffix is as likely a US share class
210
210
  * (MKC.V, BRK.B) and keeps its own answer. Null otherwise.
211
211
  */
212
- async function notTradedOnSuffixVenue(listing: CliListing, market: MarketContext): Promise<string | null> {
212
+ async function notTradedOnSuffixVenue(listing: CliListing, market: ListingDeps): Promise<string | null> {
213
213
  if (listing.exchange) return null;
214
214
  const suffix = listing.symbol.slice(listing.symbol.lastIndexOf(".") + 1);
215
215
  if (!listing.symbol.includes(".") || (suffix.length < 2 && suffix.toUpperCase() !== "L")) return null;
@@ -231,7 +231,7 @@ async function notTradedOnSuffixVenue(listing: CliListing, market: MarketContext
231
231
  async function answerCompanyName(
232
232
  result: QuoteBatchResult,
233
233
  listing: CliListing,
234
- market: MarketContext,
234
+ market: ListingDeps,
235
235
  request: ListingDataRequest,
236
236
  refresh: boolean,
237
237
  datesChangeBasis: boolean,
@@ -261,7 +261,7 @@ async function answerCompanyName(
261
261
  export async function withJoinedCompanyNames(
262
262
  answers: readonly QuoteAnswer[],
263
263
  asked: readonly CliListing[],
264
- market: MarketContext,
264
+ market: ListingDeps,
265
265
  request: ListingDataRequest,
266
266
  refresh: boolean,
267
267
  datesChangeBasis: boolean,
@@ -281,7 +281,7 @@ export async function withJoinedCompanyNames(
281
281
  async function abroadShareClass(
282
282
  listing: CliListing,
283
283
  quote: Quote,
284
- market: MarketContext,
284
+ market: ListingDeps,
285
285
  request: ListingDataRequest,
286
286
  refresh: boolean,
287
287
  datesChangeBasis: boolean,
@@ -297,24 +297,40 @@ async function abroadShareClass(
297
297
  */
298
298
  async function answerNamedListing(
299
299
  named: ListingArg,
300
- market: MarketContext,
300
+ market: ListingDeps,
301
301
  request: ListingDataRequest,
302
302
  refresh: boolean,
303
303
  datesChangeBasis: boolean,
304
304
  ): Promise<QuoteAnswer | null> {
305
305
  // A listing on a venue the app cannot read is no answer: the word keeps its own.
306
- const resolved = await resolveCliListing(named.key, null, market).catch((error: unknown) => {
306
+ const resolved = await resolveCliListing(named.key, null, market, { listingAbroad: false }).catch((error: unknown) => {
307
307
  if (error instanceof ListingArgError) return null;
308
308
  throw error;
309
309
  });
310
310
  const found = resolved ? { ...resolved, readAs: named.readAs, ...named.meant ? { meant: named.meant } : {}, ...named.readFromName ? { readFromName: named.readFromName } : {},
311
311
  ...named.wordAsName ? { wordAsName: named.wordAsName } : {} } : null;
312
- const [quoted] = found ? await market.dataProvider.getQuotesBatch([found.request], { forceRefresh: refresh, revalidate: true, datesChangeBasis }) : [];
312
+ const quoted = found ? await quoteOne(market, found.request, { forceRefresh: refresh, revalidate: true, datesChangeBasis }) : null;
313
313
  return found && quoted?.quote ? answerQuote(quoted, found, market, request, refresh, null, { datesChangeBasis }) : null;
314
314
  }
315
315
 
316
+ /**
317
+ * One listing's quote as `quote` asks for it: the service's quote of the
318
+ * moment, through the batch request where the provider has one (the app's
319
+ * own provider may not), with why there is none.
320
+ */
321
+ async function quoteOne(deps: ListingDeps, target: { symbol: string; exchange: string }, options: QuoteBatchOptions): Promise<QuoteBatchResult> {
322
+ if (deps.dataProvider.getQuotesBatch) {
323
+ const [result] = await deps.dataProvider.getQuotesBatch([target], options);
324
+ return result ?? { target, quote: null };
325
+ }
326
+ return deps.dataProvider.getQuote(target.symbol, target.exchange, {
327
+ cacheMode: options.forceRefresh ? "refresh" : "default",
328
+ ...(options.datesChangeBasis ? { datesChangeBasis: true } : {}),
329
+ }).then((quote) => ({ target, quote }), (error: unknown) => ({ target, quote: null, error }));
330
+ }
331
+
316
332
  /** A listing a command found a quote for, with what `quote` says beside it. */
317
- interface QuotedListing {
333
+ export interface QuotedListing {
318
334
  /** The listing the quote is of: the one typed, or the venue a bare symbol was quoted on. */
319
335
  listing: CliListing;
320
336
  quote: Quote;
@@ -334,15 +350,15 @@ interface QuotedListing {
334
350
  export async function requireQuotedListing(
335
351
  raw: string,
336
352
  exchange: string | null | undefined,
337
- market: MarketContext,
353
+ market: ListingDeps,
338
354
  ctx: Pick<Parameters<CliCommandDef["execute"]>[1], "fail">,
339
355
  command: string,
340
356
  ): Promise<QuotedListing> {
341
357
  // A word that names a company is read after the quote, as `quote` reads it.
342
358
  const listing = await requireCliListing(raw, exchange, market, ctx, { companyWord: false });
343
359
  const venues = loadBareVenues(listing, market);
344
- const [result] = await market.dataProvider.getQuotesBatch([listing.request], { revalidate: true });
345
- const answer = await answerQuote(result ?? { target: listing.request, quote: null }, listing, market, { command, noun: "quote" }, false, venues);
360
+ const result = await quoteOne(market, listing.request, { revalidate: true });
361
+ const answer = await answerQuote(result, listing, market, { command, noun: "quote" }, false, venues);
346
362
  const quote = answer.result.quote;
347
363
  if (!quote) {
348
364
  if (answer.failure) ctx.fail(answer.failure.message, answer.failure.details);
@@ -375,7 +391,7 @@ export type IndexFormRead = () => Promise<Quote | null>;
375
391
  * goes beside the quote the service has not answered yet instead of after it. A symbol some venue lists asks only
376
392
  * when its answer needs it.
377
393
  */
378
- export function indexFormRead(listing: CliListing, market: MarketContext, venues: Promise<ListingVenue[]> | null): IndexFormRead | null {
394
+ export function indexFormRead(listing: CliListing, market: ListingDeps, venues: Promise<ListingVenue[]> | null): IndexFormRead | null {
379
395
  if (listing.exchange || listing.saved || !CARETLESS_INDEX.test(listing.symbol) || indexRootFor(listing.symbol)) return null;
380
396
  let read: Promise<Quote | null> | null = null;
381
397
  const start: IndexFormRead = () => read ??= Promise.resolve().then(() => market.dataProvider.getQuote(`^${listing.symbol}`, ""))
@@ -412,7 +428,7 @@ const FIVE_DIGIT_CODE = /^0\d{4}$/;
412
428
  * (Tencent Holdings Limited)". Null for any other symbol, a named or saved
413
429
  * listing, and a code HKEX does not list.
414
430
  */
415
- async function hongKongCodeNote(listing: CliListing, quote: Quote, market: MarketContext): Promise<string | null> {
431
+ async function hongKongCodeNote(listing: CliListing, quote: Quote, market: ListingDeps): Promise<string | null> {
416
432
  if (listing.exchange || listing.saved || !FIVE_DIGIT_CODE.test(listing.symbol)) return null;
417
433
  if (canonicalExchange(quote.listingExchangeName || quote.exchangeName) === "HKEX") return null;
418
434
  const code = String(Number(listing.symbol));
@@ -429,7 +445,7 @@ async function hongKongCodeNote(listing: CliListing, quote: Quote, market: Marke
429
445
  * Naira)?". When search finds nothing near, the row keeps its own error and its
430
446
  * search hint.
431
447
  */
432
- async function withCurrencyPairHint(result: QuoteBatchResult, market: MarketContext): Promise<QuoteBatchResult> {
448
+ async function withCurrencyPairHint(result: QuoteBatchResult, market: ListingDeps): Promise<QuoteBatchResult> {
433
449
  const message = errorMessage(result.error);
434
450
  const symbol = message ? notATickerSymbol(message) : null;
435
451
  if (!message || !symbol || !looksLikeCurrencyPair(symbol)) return result;
@@ -52,6 +52,8 @@ export interface CliCommandRegistry {
52
52
  config: AppConfig | null;
53
53
  /** The plugins that run here: loaded, switched on, and declaring the command line among their targets. */
54
54
  plugins: GloomPlugin[];
55
+ /** The ones of those that contribute data capabilities, which a command reading market data needs without the rest. */
56
+ readonly dataPlugins: GloomPlugin[];
55
57
  readonly idlePlugins: IdleCliPlugin[];
56
58
  externalPlugins: LoadedExternalPlugin[];
57
59
  /** Loads installed contributions when dispatch or application services need them. */
@@ -170,6 +172,10 @@ export function buildCliCommandRegistry({
170
172
  .filter((entry) => !entry.error && !entry.unsupportedTarget && !disabledPlugins.has(entry.plugin.id))
171
173
  .map((entry) => entry.plugin);
172
174
  },
175
+ get dataPlugins() {
176
+ const { getLoadableDataPlugins } = require("../plugins/catalog-data") as typeof import("../plugins/catalog-data");
177
+ return getLoadableDataPlugins(registry.externalPlugins).filter((plugin) => !disabledPlugins.has(plugin.id));
178
+ },
173
179
  get idlePlugins() {
174
180
  const { getPluginCatalog } = require("../plugins/catalog") as typeof import("../plugins/catalog");
175
181
  return getPluginCatalog(registry.externalPlugins).flatMap((entry): IdleCliPlugin[] => {
@@ -196,13 +202,23 @@ export function buildCliCommandRegistry({
196
202
 
197
203
  /** The idle plugins of each command's context, kept off the plugin API's context type. */
198
204
  const idlePluginsByContext = new WeakMap<CliCommandContext, () => IdleCliPlugin[]>();
205
+ /** How many installed plugins a command's context found, loading them first, kept off the plugin API's context type too. */
206
+ const installedPluginCountByContext = new WeakMap<CliCommandContext, () => Promise<number>>();
207
+
208
+ /**
209
+ * How many installed plugins (loaded, failed or switched to other targets) a command has beside the built-in ones.
210
+ * A command that answers from what the built-in plugins declare may do so only when this is none.
211
+ */
212
+ export async function installedPluginCount(ctx: CliCommandContext): Promise<number> {
213
+ return (await installedPluginCountByContext.get(ctx)?.()) ?? 0;
214
+ }
199
215
 
200
216
  /** The installed plugins a command's context does not run (`IdleCliPlugin`); none for a context built without a registry. */
201
217
  export function idleCliPlugins(ctx: CliCommandContext): IdleCliPlugin[] {
202
218
  return idlePluginsByContext.get(ctx)?.() ?? [];
203
219
  }
204
220
 
205
- type ContextRegistry = Pick<CliCommandRegistry, "plugins" | "externalPlugins" | "ensureExternalPlugins"> & Partial<Pick<CliCommandRegistry, "idlePlugins">>;
221
+ type ContextRegistry = Pick<CliCommandRegistry, "plugins" | "externalPlugins" | "ensureExternalPlugins"> & Partial<Pick<CliCommandRegistry, "idlePlugins" | "dataPlugins">>;
206
222
 
207
223
  export function createCliCommandContext(
208
224
  ownerId: string,
@@ -217,7 +233,7 @@ export function createCliCommandContext(
217
233
  initConfigData,
218
234
  initMarketData: async () => {
219
235
  await registry.ensureExternalPlugins?.();
220
- return initMarketData({ plugins: registry.plugins });
236
+ return initMarketData({ plugins: () => registry.plugins, ...registry.dataPlugins ? { dataPlugins: registry.dataPlugins } : {} });
221
237
  },
222
238
  initServices: async () => {
223
239
  await registry.ensureExternalPlugins?.();
@@ -240,5 +256,9 @@ export function createCliCommandContext(
240
256
  log: debugLog.createLogger(ownerId === "core" ? "cli" : ownerId),
241
257
  };
242
258
  idlePluginsByContext.set(ctx, () => registry.idlePlugins ?? []);
259
+ installedPluginCountByContext.set(ctx, async () => {
260
+ await registry.ensureExternalPlugins?.();
261
+ return registry.externalPlugins.length;
262
+ });
243
263
  return ctx;
244
264
  }
package/src/cli/result.ts CHANGED
@@ -3,6 +3,7 @@ import type { CliGlobalOptions } from "./options";
3
3
  import {
4
4
  cliPlainEnabled,
5
5
  cliStyles,
6
+ cliText,
6
7
  cliTerminalWidth,
7
8
  renderForFile,
8
9
  renderStats,
@@ -19,6 +20,9 @@ import { portableCsv } from "./csv-export";
19
20
  import { logFailure } from "../utils/log-failure";
20
21
  import { formatUtcTime, isEpochMilliseconds, isZonedIsoDateTime } from "../utils/utc-time";
21
22
  import { formatFreshnessLine, withSavedCopy, type ReportFreshness } from "./pane-functions/freshness";
23
+ import { savedCopyShownAt } from "../data/saved-copies";
24
+ import { dataServiceUnreachable } from "../api-client/request";
25
+ import { savedCopyUnreachableWarning } from "./unreachable";
22
26
  import { withSearchHints, type FredSeriesCheck } from "./not-a-ticker";
23
27
  import {
24
28
  exportJsonValue,
@@ -624,7 +628,7 @@ function serializeCliRows<T, Row extends Record<string, unknown>>(
624
628
  return withCsvFooter(csv, [...exportSourceLines(cited), ...cutNote, ...(renderOptions.exportNotes ?? []).map((note) => `note: ${note}`)]);
625
629
  }
626
630
  if (renderOptions.text) {
627
- return renderOptions.text(result.data);
631
+ return cliText(renderOptions.text(result.data));
628
632
  }
629
633
  // The heading's lines, the summary and the notes are prose: each wraps to a narrow --width, as the source line does.
630
634
  const summary = wrapToTerminal(renderOptions.summary?.(result.data) ?? "");
@@ -715,6 +719,19 @@ function withHintedCells<T>(result: CliResult<T>, hinted: (text: string) => stri
715
719
  return changed ? { ...result, data: data as T } : result;
716
720
  }
717
721
 
722
+ /**
723
+ * A result shown from saved copies while the data service went unanswered,
724
+ * with the warning that says so (`savedCopyUnreachableWarning`); any other as it is.
725
+ */
726
+ export function withUnreachedSavedCopyWarning<T>(result: CliResult<T>): CliResult<T> {
727
+ if (!dataServiceUnreachable()) return result;
728
+ const cited = result.freshness ?? result.exportFreshness;
729
+ const saved = cited ? withSavedCopy(cited, result.data).savedAt != null : savedCopyShownAt(result.data) != null;
730
+ if (!saved) return result;
731
+ const warning = savedCopyUnreachableWarning();
732
+ return result.warnings?.includes(warning) ? result : { ...result, warnings: [...result.warnings ?? [], warning] };
733
+ }
734
+
718
735
  export function printCliResult<T, Row extends Record<string, unknown> = Record<string, unknown>>(
719
736
  result: CliResult<T>,
720
737
  options: CliGlobalOptions,
@@ -723,6 +740,7 @@ export function printCliResult<T, Row extends Record<string, unknown> = Record<s
723
740
  isFredSeries?: FredSeriesCheck,
724
741
  ): void {
725
742
  if (options.quiet && options.format === "text") return;
743
+ result = withUnreachedSavedCopyWarning(result);
726
744
  // JSON keeps the router's own words; everything else is for a person, so a "Not a ticker" gets its hint.
727
745
  const hinted = (text: string) => options.format === "json" ? text : withSearchHints(text, args, isFredSeries);
728
746
  // A CSV's status cell is where its row says why, so it gets the hint the warning line has: a cell ends in a comma,
@@ -745,12 +763,12 @@ export function printCliResult<T, Row extends Record<string, unknown> = Record<s
745
763
  if (options.format !== "json" && !options.quiet) {
746
764
  // Each wraps to a narrow --width, as a note does.
747
765
  for (const warning of result.warnings ?? []) {
748
- console.error(wrapToTerminal(`${cliStyles.warning("warning:")} ${hinted(warning)}`));
766
+ console.error(wrapToTerminal(`${cliStyles.warning("warning:")} ${hinted(cliText(warning))}`));
749
767
  }
750
768
  }
751
- if (!options.quiet) for (const line of footer) console.error(line);
769
+ if (!options.quiet) for (const line of footer) console.error(cliText(line));
752
770
  if (options.format === "ndjson" && !options.quiet) {
753
- for (const note of exportNdjsonNotes(result, options, renderOptions)) console.error(`note: ${note}`);
771
+ for (const note of exportNdjsonNotes(result, options, renderOptions)) console.error(cliText(`note: ${note}`));
754
772
  }
755
773
  }
756
774
 
@@ -20,7 +20,7 @@ export interface ScrollBoxMetrics {
20
20
  * centred on the money is cut above and below, a list at its top only below.
21
21
  * Self-contained so the screenshot runner can evaluate it in the browser.
22
22
  */
23
- export function scrollTruncationReasons(box: ScrollBoxMetrics): string[] {
23
+ export function scrollTruncationReasons(box: ScrollBoxMetrics, rowsAnnounced = false): string[] {
24
24
  const reasons: string[] = [];
25
25
  const cut = (offset: number, content: number, viewport: number, flagged: boolean, noun: string, sides: readonly [string, string, string, string]) => {
26
26
  if (!flagged && !(content > viewport + 1)) return;
@@ -32,7 +32,12 @@ export function scrollTruncationReasons(box: ScrollBoxMetrics): string[] {
32
32
  ? `${noun} ${before && after ? sides[2] : before ? sides[0] : sides[1]} the rendered viewport are cut`
33
33
  : `${noun} ${sides[3]} the rendered viewport may be cut`);
34
34
  };
35
- cut(box.scrollTop, box.scrollHeight, box.clientHeight, box.scrollbarY, "rows", ["above", "below", "above and below", "above or below"]);
35
+ if (!rowsAnnounced) cut(box.scrollTop, box.scrollHeight, box.clientHeight, box.scrollbarY, "rows", ["above", "below", "above and below", "above or below"]);
36
36
  cut(box.scrollLeft, box.scrollWidth, box.clientWidth, box.scrollbarX, "columns", ["left of", "right of", "left and right of", "left or right of"]);
37
37
  return reasons;
38
38
  }
39
+
40
+ export function rowViewportVisibility(top: number, bottom: number, viewportTop: number, viewportBottom: number): "outside" | "partial" | "whole" {
41
+ if (bottom <= viewportTop + 1 || top >= viewportBottom - 1) return "outside";
42
+ return top >= viewportTop - 1 && bottom <= viewportBottom + 1 ? "whole" : "partial";
43
+ }
@@ -41,11 +41,43 @@ const isWord = (text: string, word: string) => new RegExp(`(^|[^a-z0-9])${escape
41
41
  /** A series whose name, tags and group have every word whole outranks any that has one only as the start of a longer word. */
42
42
  const WHOLE_WORDS_SCORE = 10;
43
43
 
44
+ /** What a catalog search reads of a series: enough to rank and list it, none of the code that loads it. */
45
+ export interface CatalogSeriesFact {
46
+ id: string;
47
+ name: string;
48
+ unit: string;
49
+ frequency: string;
50
+ publisher?: string;
51
+ tags?: readonly string[];
52
+ group?: string;
53
+ description?: string;
54
+ /** What `fn G` charts. */
55
+ expression: string;
56
+ }
57
+
58
+ /**
59
+ * The catalog series the plugins declare, as a search reads them. Series that ask for a ticker are left out; a
60
+ * search names data, not a field of every stock. A formula priced in one delivery month (a crack) charts by its
61
+ * id: its expression alone would mix months.
62
+ */
63
+ export function catalogSeriesFacts(plugins: readonly SeriesSource[]): CatalogSeriesFact[] {
64
+ return plugins.flatMap((plugin) => plugin.series ?? []).flatMap((definition) => definition.input ? [] : [{
65
+ id: definition.id,
66
+ name: definition.name,
67
+ unit: definition.unit,
68
+ frequency: definition.frequency,
69
+ ...definition.publisher ? { publisher: definition.publisher } : {},
70
+ ...definition.tags ? { tags: definition.tags } : {},
71
+ ...definition.group ? { group: definition.group } : {},
72
+ ...definition.description ? { description: definition.description } : {},
73
+ expression: "rollsWith" in definition && definition.rollsWith ? definition.id : seriesExpression(definition),
74
+ }]);
75
+ }
76
+
44
77
  /**
45
78
  * The plugins' catalog series whose words cover every word of the query: in
46
79
  * the name and tags only for `search`, also the description and publisher for
47
- * `catalog`. Series that ask for a ticker are left out; a search names data,
48
- * not a field of every stock. A query that is a series' id (`policy-rate:ch`),
80
+ * `catalog`. A query that is a series' id (`policy-rate:ch`),
49
81
  * what `fn G` charts (`CAP:policy-rate:ch`, `FRED:DFEDTARU`) or a FRED series
50
82
  * id (`DFEDTARU`) ranks it first, then one whose name, tags and group have
51
83
  * each word whole (`defi` is Total DeFi TVL's tag, before the "deficit" of the
@@ -57,15 +89,22 @@ export function findCatalogSeries(
57
89
  plugins: readonly SeriesSource[],
58
90
  query: string,
59
91
  scope: "names" | "all" = "all",
92
+ ): SeriesMatch[] {
93
+ return findSeriesFacts(catalogSeriesFacts(plugins), query, scope);
94
+ }
95
+
96
+ /** `findCatalogSeries` over series already read as facts. */
97
+ export function findSeriesFacts(
98
+ facts: readonly CatalogSeriesFact[],
99
+ query: string,
100
+ scope: "names" | "all" = "all",
60
101
  ): SeriesMatch[] {
61
102
  const words = query.toLowerCase().replace(/["']/g, "").split(/\s+/).filter(Boolean);
62
103
  if (words.length === 0 || words.join("").length < 3) return [];
63
104
  const phrase = words.join(" ");
64
105
  const ranked: Array<{ match: SeriesMatch; score: number; order: number }> = [];
65
- for (const definition of plugins.flatMap((plugin) => plugin.series ?? [])) {
66
- if (definition.input) continue;
67
- // A formula priced in one delivery month (a crack) charts by its id: its expression alone would mix months.
68
- const expression = "rollsWith" in definition && definition.rollsWith ? definition.id : seriesExpression(definition);
106
+ for (const definition of facts) {
107
+ const expression = definition.expression;
69
108
  const byId = words.length === 1
70
109
  && [definition.id, expression, fredSeriesIdOf(expression) ?? ""].some((id) => id.toLowerCase() === phrase);
71
110
  const name = definition.name.toLowerCase();
@@ -1,12 +1,8 @@
1
- import { mkdtemp, rm } from "fs/promises";
1
+ import { mkdtemp } from "fs/promises";
2
2
  import { tmpdir } from "os";
3
3
  import { join } from "path";
4
4
  import { logFailure } from "../utils/log-failure";
5
-
6
- type RemoveFolder = (
7
- path: string,
8
- options: { recursive: true; force: true; maxRetries: number; retryDelay: number },
9
- ) => Promise<void>;
5
+ import { removeFolder, type RemoveFolderOptions } from "../utils/remove-folder";
10
6
 
11
7
  /**
12
8
  * Hands `use` a fresh folder under the system temp folder and removes it
@@ -18,13 +14,12 @@ type RemoveFolder = (
18
14
  export async function withShotTempDir<T>(
19
15
  prefix: string,
20
16
  use: (dir: string) => Promise<T>,
21
- remove: RemoveFolder = rm,
17
+ removal: RemoveFolderOptions = {},
22
18
  ): Promise<T> {
23
19
  const dir = await mkdtemp(join(tmpdir(), prefix));
24
20
  try {
25
21
  return await use(dir);
26
22
  } finally {
27
- await remove(dir, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 })
28
- .catch(logFailure("cli.screenshot", "Could not remove a capture's temporary folder"));
23
+ if (await removeFolder(dir, removal) !== null) logFailure("cli.screenshot", "Could not remove a capture's temporary folder")(null);
29
24
  }
30
25
  }
@@ -235,7 +235,7 @@ export async function resolveCliTicker(
235
235
  const deps: ListingDeps = { store, dataProvider };
236
236
  // A vendor's suffix is the venue it names (GARAN.IS is GARAN:BIST), so the listing is saved under one key. A word that
237
237
  // names a company is read below, once the lookup says no listing trades as it (`oneWordCompanyName`).
238
- const listing = await resolveCliListing(symbol, exchange, deps, { ownExchangeWins: options.ownExchangeWins, listingSuffix: true, companyWord: false });
238
+ const listing = await resolveCliListing(symbol, exchange, deps, { ownExchangeWins: options.ownExchangeWins, listingSuffix: true, companyWord: false, listingAbroad: false });
239
239
  const read = listingReadNotes(listing);
240
240
  // Looked up beside the search, so saying FB is now META costs no wait.
241
241
  const changes = options.changes === false ? null : startTickerChangeLookup(dataProvider, listing.symbol, listing.exchange);