@gloom-sh/terminal 0.20.4 → 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 (217) 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/api-client/data.ts +138 -35
  6. package/src/api-client/types/econ.ts +12 -0
  7. package/src/api-client/yield-curves.ts +1 -1
  8. package/src/app/global-shortcuts.ts +4 -1
  9. package/src/app/keybindings/actions.ts +6 -0
  10. package/src/app/keybindings/config.ts +2 -1
  11. package/src/app/keybindings/index.ts +1 -0
  12. package/src/app/keybindings/labels.ts +6 -1
  13. package/src/app/keybindings/resolve.ts +23 -4
  14. package/src/app/keybindings/terminal-keys.ts +35 -0
  15. package/src/app/pane-runtime/index.tsx +2 -2
  16. package/src/app/pane-runtime/ticker-open-runtime.ts +68 -40
  17. package/src/architecture/ui-literals-allowlist.json +1 -1
  18. package/src/capabilities/chart-series.ts +27 -1
  19. package/src/cli/commands/keybindings.ts +5 -5
  20. package/src/cli/commands/market.ts +78 -21
  21. package/src/cli/commands/news-search.ts +59 -7
  22. package/src/cli/commands/overview.ts +16 -1
  23. package/src/cli/commands/remote.ts +16 -17
  24. package/src/cli/commands/system.ts +1 -1
  25. package/src/cli/fx-forward.ts +25 -7
  26. package/src/cli/glossary.ts +19 -5
  27. package/src/cli/history-rows.ts +5 -3
  28. package/src/cli/known-gaps.ts +27 -1
  29. package/src/cli/listing-arg.ts +11 -1
  30. package/src/cli/name-entries.ts +5 -1
  31. package/src/cli/not-a-ticker.ts +4 -0
  32. package/src/cli/pane-functions/function-help.ts +2 -2
  33. package/src/components/command-bar/pane-settings.ts +2 -2
  34. package/src/components/command-bar/routes/root/results.ts +6 -2
  35. package/src/components/input-search-bar.tsx +9 -2
  36. package/src/components/layout/pane/header.tsx +2 -0
  37. package/src/components/layout/shell/pane/capture.ts +4 -1
  38. package/src/components/layout/status-bar.tsx +6 -1
  39. package/src/components/onboarding/first-run-workspace.ts +44 -2
  40. package/src/components/onboarding/onboarding-frame.tsx +11 -2
  41. package/src/components/onboarding/onboarding-keyboard.ts +16 -0
  42. package/src/components/onboarding/onboarding-wizard.tsx +8 -8
  43. package/src/components/onboarding/portfolio-step/positions-panel.tsx +62 -1
  44. package/src/components/onboarding/use-onboarding-progress.ts +12 -4
  45. package/src/components/pane-settings-dialog/desktop.tsx +2 -2
  46. package/src/components/pane-settings-dialog/tui.tsx +2 -2
  47. package/src/components/pane-settings-dialog/value.ts +6 -0
  48. package/src/components/pane-settings-dialog.tsx +3 -3
  49. package/src/components/reader/detail-reader.tsx +4 -0
  50. package/src/components/ui/index.ts +1 -1
  51. package/src/components/ui/page-stack-view.tsx +3 -0
  52. package/src/components/ui/pane-link-chip.tsx +269 -54
  53. package/src/components/ui/query-bar.tsx +2 -1
  54. package/src/components/ui/tabs.tsx +97 -19
  55. package/src/core/state/app/layout-reducer.ts +7 -0
  56. package/src/core/state/app/layout.ts +44 -7
  57. package/src/core/state/app/state.ts +1 -1
  58. package/src/core/state/app/types.ts +22 -2
  59. package/src/docs/snapshot.json +27 -10
  60. package/src/market-data/depositary-pair.ts +5 -3
  61. package/src/market-data/market/dated-previous-close.ts +94 -15
  62. package/src/market-data/market/status.ts +17 -1
  63. package/src/plugins/builtin/analytics/risk-client.ts +10 -4
  64. package/src/plugins/builtin/analytics/risk-episodes.ts +5 -4
  65. package/src/plugins/builtin/analytics/risk-headless.ts +4 -2
  66. package/src/plugins/builtin/analytics/risk-sectors.ts +91 -0
  67. package/src/plugins/builtin/awards/index.tsx +1 -1
  68. package/src/plugins/builtin/buildout/index.tsx +1 -0
  69. package/src/plugins/builtin/catalysts/index.tsx +2 -2
  70. package/src/plugins/builtin/cds/headless.ts +4 -0
  71. package/src/plugins/builtin/chart-composer/headless.ts +2 -1
  72. package/src/plugins/builtin/chart-composer/index.tsx +1 -0
  73. package/src/plugins/builtin/chat/content/composer.tsx +5 -4
  74. package/src/plugins/builtin/chat/content/index.tsx +12 -2
  75. package/src/plugins/builtin/chat/content/layout-metrics.ts +3 -3
  76. package/src/plugins/builtin/chat/content/open-targets.ts +3 -3
  77. package/src/plugins/builtin/chat/layout.ts +5 -2
  78. package/src/plugins/builtin/chat/message/pane-chip.tsx +61 -40
  79. package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
  80. package/src/plugins/builtin/chat/pane-links/previews.ts +51 -5
  81. package/src/plugins/builtin/chat/pane-links/share-card.ts +36 -0
  82. package/src/plugins/builtin/cloud/askg/tool-display.ts +1 -0
  83. package/src/plugins/builtin/cloud/terminal-relay/redact.ts +5 -3
  84. package/src/plugins/builtin/commodity-balances/index.tsx +1 -0
  85. package/src/plugins/builtin/company-attention/index.tsx +1 -1
  86. package/src/plugins/builtin/company-kpis/headless.ts +3 -1
  87. package/src/plugins/builtin/company-kpis/index.tsx +2 -2
  88. package/src/plugins/builtin/cot/index.tsx +1 -1
  89. package/src/plugins/builtin/cpi/index.tsx +1 -1
  90. package/src/plugins/builtin/crypto-board/index.tsx +1 -0
  91. package/src/plugins/builtin/dividend-yield/index.tsx +1 -0
  92. package/src/plugins/builtin/doe/index.tsx +1 -1
  93. package/src/plugins/builtin/earnings-calls/headless.ts +5 -1
  94. package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
  95. package/src/plugins/builtin/econ/calendar-model.ts +74 -1
  96. package/src/plugins/builtin/econ/fred-catalog.ts +3 -1
  97. package/src/plugins/builtin/econ/index.tsx +1 -0
  98. package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
  99. package/src/plugins/builtin/econ-statistics/pane.tsx +6 -0
  100. package/src/plugins/builtin/estimate-revisions/index.tsx +1 -0
  101. package/src/plugins/builtin/executives/index.tsx +1 -0
  102. package/src/plugins/builtin/filing-events/index.tsx +1 -0
  103. package/src/plugins/builtin/fixed-income/index.tsx +1 -0
  104. package/src/plugins/builtin/futures-curve/headless.ts +3 -3
  105. package/src/plugins/builtin/futures-curve/index.tsx +1 -1
  106. package/src/plugins/builtin/futures-curve/model.ts +18 -0
  107. package/src/plugins/builtin/gpu/index.tsx +1 -1
  108. package/src/plugins/builtin/help/functions-table.tsx +1 -1
  109. package/src/plugins/builtin/help/index.tsx +11 -1
  110. package/src/plugins/builtin/help/keybindings-editor.tsx +1 -1
  111. package/src/plugins/builtin/holders/index.tsx +1 -0
  112. package/src/plugins/builtin/holders/report-header.ts +2 -2
  113. package/src/plugins/builtin/insider/index.tsx +1 -0
  114. package/src/plugins/builtin/iv-history/index.tsx +1 -1
  115. package/src/plugins/builtin/jobs/index.tsx +1 -0
  116. package/src/plugins/builtin/macro-day/headless.ts +27 -8
  117. package/src/plugins/builtin/macro-day/index.tsx +1 -1
  118. package/src/plugins/builtin/macro-day/model.ts +19 -3
  119. package/src/plugins/builtin/macro-day/pane.tsx +14 -9
  120. package/src/plugins/builtin/macro-day/releases.ts +25 -7
  121. package/src/plugins/builtin/market-valuation/index.tsx +1 -0
  122. package/src/plugins/builtin/market-valuation/pane.tsx +8 -0
  123. package/src/plugins/builtin/members/index.tsx +1 -1
  124. package/src/plugins/builtin/mna/index.tsx +1 -0
  125. package/src/plugins/builtin/news/index.tsx +1 -0
  126. package/src/plugins/builtin/news/wire/index.tsx +5 -1
  127. package/src/plugins/builtin/news/wire/news/detail-view.tsx +4 -0
  128. package/src/plugins/builtin/news/wire/news/list-search.ts +5 -2
  129. package/src/plugins/builtin/options/index.tsx +1 -0
  130. package/src/plugins/builtin/options-positioning/index.tsx +1 -0
  131. package/src/plugins/builtin/pe-band/index.tsx +1 -1
  132. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +25 -0
  133. package/src/plugins/builtin/portfolio-list/headless.ts +15 -6
  134. package/src/plugins/builtin/power/index.tsx +1 -1
  135. package/src/plugins/builtin/realized-vol/index.tsx +1 -1
  136. package/src/plugins/builtin/research/headless.ts +10 -4
  137. package/src/plugins/builtin/research/index.tsx +4 -0
  138. package/src/plugins/builtin/research-search/index.tsx +1 -0
  139. package/src/plugins/builtin/research-search/pane.tsx +8 -0
  140. package/src/plugins/builtin/revenue-breakdown/index.tsx +1 -0
  141. package/src/plugins/builtin/reverse-dcf/index.tsx +1 -1
  142. package/src/plugins/builtin/risk-factors/index.tsx +1 -0
  143. package/src/plugins/builtin/scanner/headless.ts +52 -13
  144. package/src/plugins/builtin/seasonality/index.tsx +1 -1
  145. package/src/plugins/builtin/sec/index.tsx +1 -0
  146. package/src/plugins/builtin/series-inventory.ts +1 -1
  147. package/src/plugins/builtin/shared/scanner-capture.ts +11 -3
  148. package/src/plugins/builtin/shared/series-list-detail.tsx +5 -0
  149. package/src/plugins/builtin/short-interest/index.tsx +1 -0
  150. package/src/plugins/builtin/social-mentions/index.tsx +1 -1
  151. package/src/plugins/builtin/supply-chain/index.tsx +1 -0
  152. package/src/plugins/builtin/thirteenf/data.ts +43 -10
  153. package/src/plugins/builtin/thirteenf/headless.ts +55 -11
  154. package/src/plugins/builtin/thirteenf/model.ts +25 -9
  155. package/src/plugins/builtin/thirteenf/report-notes.ts +27 -6
  156. package/src/plugins/builtin/thirteenf/types.ts +2 -0
  157. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +1 -1
  158. package/src/plugins/builtin/ticker-detail/financials/model.ts +12 -0
  159. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +3 -3
  160. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +5 -5
  161. package/src/plugins/builtin/ticker-detail/headless.ts +18 -13
  162. package/src/plugins/builtin/ticker-detail/index.tsx +4 -0
  163. package/src/plugins/builtin/ticker-detail/overview/model.ts +6 -4
  164. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +6 -4
  165. package/src/plugins/builtin/time-sales/client.ts +9 -11
  166. package/src/plugins/builtin/time-sales/index.tsx +1 -1
  167. package/src/plugins/builtin/treasury-auctions/after.ts +267 -0
  168. package/src/plugins/builtin/treasury-auctions/cache.ts +18 -3
  169. package/src/plugins/builtin/treasury-auctions/client.ts +33 -2
  170. package/src/plugins/builtin/treasury-auctions/headless.ts +109 -19
  171. package/src/plugins/builtin/treasury-auctions/index.tsx +14 -4
  172. package/src/plugins/builtin/treasury-auctions/model.ts +256 -28
  173. package/src/plugins/builtin/treasury-auctions/pane.tsx +139 -28
  174. package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +5 -2
  175. package/src/plugins/builtin/treasury-auctions/types.ts +7 -1
  176. package/src/plugins/builtin/vol-surface/index.tsx +1 -1
  177. package/src/plugins/builtin/world-venue-map/index.ts +1 -0
  178. package/src/plugins/builtin/yield-curve/curves.ts +10 -4
  179. package/src/plugins/builtin/yield-curve/headless.ts +6 -2
  180. package/src/plugins/builtin/yield-curve/index.tsx +3 -3
  181. package/src/plugins/builtin/yield-curve/series.ts +10 -0
  182. package/src/plugins/builtin/yield-curve/world.ts +3 -1
  183. package/src/portfolio/column-values.ts +2 -1
  184. package/src/public/__snapshots__/public-api.test.ts.snap +4 -0
  185. package/src/public/remote.ts +7 -1
  186. package/src/remote/client.ts +191 -11
  187. package/src/remote/controller-utils.ts +13 -1
  188. package/src/remote/controller.ts +88 -26
  189. package/src/remote/endpoint.ts +24 -0
  190. package/src/remote/form.ts +59 -4
  191. package/src/remote/resources.ts +44 -18
  192. package/src/remote/schema.ts +21 -9
  193. package/src/remote/secrets.ts +12 -0
  194. package/src/remote/semantic-tree.tsx +14 -2
  195. package/src/remote/server.ts +2 -1
  196. package/src/remote/surface.tsx +192 -0
  197. package/src/remote/types.ts +5 -0
  198. package/src/renderers/opentui/host.tsx +6 -0
  199. package/src/series/standalone.ts +2 -2
  200. package/src/shares/api.ts +21 -4
  201. package/src/shares/item.ts +73 -0
  202. package/src/shares/pane-item.ts +205 -0
  203. package/src/shares/pane.ts +4 -0
  204. package/src/shares/payload.ts +9 -5
  205. package/src/sources/gloomberb-cloud/news.ts +2 -0
  206. package/src/tickers/renamed-listings.ts +105 -0
  207. package/src/tickers/search/index.ts +103 -16
  208. package/src/time-series/resolve.ts +2 -2
  209. package/src/types/financials.ts +1 -0
  210. package/src/types/plugin-pane-settings.ts +2 -0
  211. package/src/types/plugin-panes.ts +22 -0
  212. package/src/utils/central-banks.ts +86 -1
  213. package/src/utils/datetime-format.ts +12 -3
  214. package/src/utils/depositary-receipt.ts +28 -3
  215. package/src/utils/fundamentals.ts +14 -0
  216. package/src/utils/max-drawdown.ts +97 -16
  217. package/src/utils/untrusted-text.ts +29 -0
@@ -14,7 +14,8 @@ import {
14
14
  } from "./pane-screenshot";
15
15
 
16
16
  export const REMOTE_RESOURCES: RemoteResourceSchema[] = [
17
- { uri: "app://snapshot", description: "Current app snapshot including layout, focus, panes, command bar, and plugin/capability catalogs. app.activePanel is deprecated and always \"left\"; read app.focusedPaneId." },
17
+ { uri: "app://snapshot", description: "What is on screen, in one read: focus, config with the layouts, panes, the command bar, the open form or setup dialog (form), and the labelled UI nodes (ui). Left out for size, and named in references: the schema and this guide, what each pane loaded (runtime state), and unlabelled UI nodes. app.activePanel is deprecated and always \"left\"; read app.focusedPaneId." },
18
+ { uri: "app://snapshot/full", description: "app://snapshot with everything it leaves out inline: the schema and guide, pane runtime state and every UI node. Often several times the size." },
18
19
  { uri: "app://config", description: "Current app config.", patchable: true },
19
20
  { uri: "app://layout/current", description: "Current active layout.", patchable: true },
20
21
  { uri: "app://layouts", description: "Saved layouts." },
@@ -26,7 +27,7 @@ export const REMOTE_RESOURCES: RemoteResourceSchema[] = [
26
27
  { uri: "app://commands", description: "Registered command-bar commands." },
27
28
  { uri: "app://command-bar", description: "Current command-bar state and semantic result rows." },
28
29
  { uri: "app://command-bar/results", description: "Current semantic command-bar result rows." },
29
- { uri: "app://form", description: "The open form or confirm: kind, title, fields with values and options, error, pending state, and submit label, with covered: true while another dialog sits over it; { open: false } when none is open, with otherDialogOpen: true while another dialog (pane settings) is." },
30
+ { uri: "app://form", description: "The open form or confirm: kind, title, fields with values and options, error, pending state, and submit label, with covered: true while another dialog sits over it; { open: false } when none is open, with otherDialogOpen: true while another dialog (pane settings) is. The first-run setup dialog reads as kind 'setup', with its step, title, fields and buttons by node id." },
30
31
  { uri: "app://capabilities", description: "Registered plugin capability manifests." },
31
32
  { uri: "app://accounts", description: "Broker profiles and their accounts: net liquidation, cash by currency, margin requirements, margin loan, leverage, day and unrealized P&L, with source and as-of times." },
32
33
  { uri: "app://auth", description: "What the client believes about its cloud session: credential present, checked, cached user plan and verification. No secrets." },
@@ -74,7 +75,7 @@ const watchlistChangeInput = objectSchema({
74
75
  export const REMOTE_OPERATIONS: RemoteOperationSchema[] = [
75
76
  op(
76
77
  "app.openCommandBar",
77
- "Open the command bar with an optional query and optional mode. Fails while a dialog (a form, a confirm, pane settings) is open.",
78
+ "Open the command bar with an optional query and optional mode. Fails while a dialog (a form, a confirm, pane settings) or the setup dialog is open.",
78
79
  "{ query?: string, mode?: 'command' | 'ticker' | 'default' }",
79
80
  "local-write",
80
81
  objectSchema({
@@ -85,7 +86,7 @@ export const REMOTE_OPERATIONS: RemoteOperationSchema[] = [
85
86
  op("app.closeCommandBar", "Close the command bar.", "{}", "local-write", objectSchema()),
86
87
  op(
87
88
  "app.closeDialog",
88
- "Close the dialog on top, as Esc would: a form, a confirm, pane settings, or a picker opened over a form. Fails when no dialog is open.",
89
+ "Close the dialog on top, as Esc would: a form, a confirm, pane settings, or a picker opened over a form. Fails when no dialog is open; the setup dialog is left with its own buttons (app://form).",
89
90
  "{}",
90
91
  "local-write",
91
92
  objectSchema(),
@@ -99,7 +100,7 @@ export const REMOTE_OPERATIONS: RemoteOperationSchema[] = [
99
100
  ),
100
101
  op(
101
102
  "app.search",
102
- "Open command-bar search without requiring UI prefix syntax. Fails while a dialog is open.",
103
+ "Open command-bar search without requiring UI prefix syntax. Fails while a dialog or the setup dialog is open.",
103
104
  "{ mode?: 'command' | 'ticker' | 'default', query?: string }",
104
105
  "local-write",
105
106
  objectSchema({
@@ -361,7 +362,7 @@ export const REMOTE_OPERATIONS: RemoteOperationSchema[] = [
361
362
  ),
362
363
  op(
363
364
  "ui.invokeMatching",
364
- "Invoke an action on the first semantic UI node matching role, label, index, or metadata. While a form or confirm is open, its own nodes (metadata.scope 'form') match first; while another dialog covers it, they do not match.",
365
+ "Invoke an action on the first semantic UI node matching role, label, index, or metadata. While a form, confirm or the setup dialog is open, its own nodes (metadata.scope 'form') match first; while another dialog covers it, they do not match.",
365
366
  "{ role?: string, label?: string, contains?: string, index?: number, action?: string, input?: any, metadata?: object }",
366
367
  "local-write",
367
368
  objectSchema({
@@ -379,7 +380,8 @@ export const REMOTE_OPERATIONS: RemoteOperationSchema[] = [
379
380
  export const REMOTE_AGENT_HELP = {
380
381
  title: "Gloom remote control guide",
381
382
  quickStart: [
382
- "Read app://snapshot once to orient; it includes schema, current layout, panes, command bar state, and semantic UI nodes.",
383
+ "Read app://snapshot once to orient: focus, layout, panes, command bar, the open form or setup dialog (form), and the labelled UI nodes. Read the schema ({ type: 'schema' }, gloom remote schema) once for every operation and its input.",
384
+ "When form.open is true, a form or the setup dialog covers the app: deal with it first. A change made behind it answers with a warning that says so.",
383
385
  "Prefer app-level operations such as app.search, layout.setGrid, layout.closeFloating, and ticker.pin before falling back to ui.invoke.",
384
386
  "Use commandBar.activateResult with label, itemId, or index after app.search; avoid raw node ids unless there is no stable semantic selector.",
385
387
  "For list-like surfaces, prefer semantic list activation through commandBar.activateResult or ui.invokeMatching.",
@@ -388,8 +390,8 @@ export const REMOTE_AGENT_HELP = {
388
390
  resources: [
389
391
  { uri: "app://command-bar", use: "Current command-bar query, open state, selected row, and semantic result rows." },
390
392
  { uri: "app://command-bar/results", use: "Just the visible command-bar result/list rows." },
391
- { uri: "app://form", use: "The open form or confirm, with field ids, values, options, error and pending state, or whether another dialog is open. Every call includes it as `form`." },
392
- { uri: "ui://tree", use: "Low-level live semantic controls; use when no app-level operation exists." },
393
+ { uri: "app://form", use: "The open form, confirm or setup dialog, with field ids, values, options, error and pending state, or whether another dialog is open. Every call includes it as `form`." },
394
+ { uri: "ui://tree", use: "Every live semantic control, unlabelled click areas too (app://snapshot lists the labelled ones); use when no app-level operation exists." },
393
395
  { uri: "app://panes", use: "Pane instances, placement, focus, and runtime state." },
394
396
  ],
395
397
  recipes: [
@@ -424,6 +426,14 @@ export const REMOTE_AGENT_HELP = {
424
426
  { type: "call", operation: "ui.invokeMatching", input: { role: "form", action: "submit" } },
425
427
  ],
426
428
  },
429
+ {
430
+ goal: "Get past the first-run setup dialog (form.kind 'setup')",
431
+ requests: [
432
+ { type: "call", operation: "ui.invokeMatching", input: { role: "form-field", metadata: { fieldId: "ticker" }, action: "setValue", input: "NVDA" } },
433
+ { type: "call", operation: "ui.invokeMatching", input: { role: "form-field", metadata: { fieldId: "ticker" }, action: "submit" } },
434
+ { type: "call", operation: "ui.invokeMatching", input: { role: "form", action: "submit" } },
435
+ ],
436
+ },
427
437
  {
428
438
  goal: "Activate a visible semantic control without knowing its node id",
429
439
  request: { type: "call", operation: "ui.invokeMatching", input: { role: "button", label: "Done", action: "press" } },
@@ -448,10 +458,12 @@ export const REMOTE_AGENT_HELP = {
448
458
  caveats: [
449
459
  "Capability manifests are for plugin services; UI control should rely on app-level operations and shared semantic UI nodes so plugins remain remote-agnostic.",
450
460
  "If an operation changes UI, request include: ['commandBar'] or use batch include to avoid a follow-up get.",
461
+ "Panes in app://snapshot and in call answers leave out runtimeState, which can hold everything a pane loaded; read app://pane-state/{paneId} for one pane, or app://panes.",
451
462
  "For charts, use visible semantic chart nodes with actions such as moveCursor, press, drag, release, and scroll.",
452
463
  "A command with hasWizard in app://commands opens a form in a centered dialog when activated, and the command bar closes. Read `form` in the response, set fields with ui.invokeMatching { role: 'form-field', metadata: { fieldId }, action: 'setValue' }, then send with { role: 'form', action: 'submit' } or close with action 'cancel'. Selects take an option value, toggles a boolean; neither needs to be opened.",
453
464
  "While a dialog is open (form.open or form.otherDialogOpen), app.openCommandBar and app.search fail; close a form or confirm with { role: 'form', action: 'cancel' }, and any dialog on top with app.closeDialog.",
454
465
  "A form with covered: true has another dialog over it, such as a listing picker or a sign-in; its controls wait until that one is answered or closed with app.closeDialog.",
466
+ "On a new profile the setup dialog covers the app: form.kind is 'setup', with its step, title, fields and buttons by node id. Fill a field with ui.invokeMatching { role: 'form-field', metadata: { fieldId }, action: 'setValue' } (submit on the Ticker field adds the position), press a button with { role: 'button', label }, go on with { role: 'form', action: 'submit' } (the button Enter presses), and skip the whole setup with { role: 'form', action: 'cancel' } where a step offers it. Skip leaves one step without filling it. app.closeDialog does not close it.",
455
467
  "Pane settings open in their own dialog, not as command-bar rows; change one with pane.setSetting, read them from app://pane-settings/{paneId}, and close the dialog with app.closeDialog.",
456
468
  "watchlist.add and watchlist.remove wait while the person answers a confirmation in the app and return what changed; with dryRun they return what would change without asking.",
457
469
  "pane.screenshot returns the pane's PNG as base64 in image.data, with its pixel size; the terminal (TUI) app answers that it needs the desktop app.",
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Words that name a credential: a password or passphrase, a secret, a token,
3
+ * an API or private key, a cookie. Matched against the keys of free-form maps
4
+ * and against a form field's id, label and placeholder, so what such a field
5
+ * holds is withheld wherever remote control lists it.
6
+ */
7
+ export const SECRET_NAME = /(pass(word|phrase)?|secret|token|api[-_ ]?key|private[-_ ]?key|credential|cookie)/i;
8
+
9
+ /** Whether any of these texts names a credential. */
10
+ export function namesSecret(...texts: unknown[]): boolean {
11
+ return texts.some((text) => typeof text === "string" && SECRET_NAME.test(text));
12
+ }
@@ -35,6 +35,11 @@ export interface RemoteUiRegistry {
35
35
  register(id: string, registration: RemoteUiNodeRegistration): void;
36
36
  unregister(id: string): void;
37
37
  snapshot(): RemoteUiNodeSnapshot[];
38
+ /**
39
+ * The nodes of one role, without projecting the rest (a table's rows, a
40
+ * chart's data): the open form is read this way on every change.
41
+ */
42
+ snapshotRole?(role: string): RemoteUiNodeSnapshot[];
38
43
  /** One node as the tree has it, with its detail; null when it is not on screen. */
39
44
  detail(nodeId: string): RemoteUiNodeSnapshot | null;
40
45
  invoke(nodeId: string, action: string, input?: unknown): Promise<unknown>;
@@ -43,9 +48,13 @@ export interface RemoteUiRegistry {
43
48
  const RemoteUiRegistryContext = createContext<RemoteUiRegistry | null>(null);
44
49
 
45
50
  function nodeSnapshot(node: RegisteredRemoteUiNode): RemoteUiNodeSnapshot {
46
- const registration = node.registration;
51
+ return remoteUiNodeSnapshot(node.id, node.registration);
52
+ }
53
+
54
+ /** A registered node as `ui://tree` lists it. */
55
+ export function remoteUiNodeSnapshot(id: string, registration: RemoteUiNodeRegistration): RemoteUiNodeSnapshot {
47
56
  return {
48
- id: node.id,
57
+ id,
49
58
  role: registration.role,
50
59
  label: registration.label,
51
60
  disabled: registration.disabled,
@@ -71,6 +80,9 @@ export function createRemoteUiRegistry(): RemoteUiRegistry {
71
80
  snapshot() {
72
81
  return [...nodes.values()].map(nodeSnapshot);
73
82
  },
83
+ snapshotRole(role) {
84
+ return [...nodes.values()].filter((node) => node.registration.role === role).map(nodeSnapshot);
85
+ },
74
86
  detail(nodeId) {
75
87
  const node = nodes.get(nodeId);
76
88
  if (!node) return null;
@@ -2,7 +2,7 @@ import { randomUUID } from "crypto";
2
2
  import { createServer, type IncomingMessage, type ServerResponse } from "http";
3
3
  import type { RemoteAppKind, RemoteControlRequest, RemoteControlResponse, RemoteEndpoint } from "./types";
4
4
  import { REMOTE_CONTROL_PROTOCOL_VERSION } from "./types";
5
- import { removeRemoteEndpointFiles, writeRemoteEndpointFiles } from "./endpoint";
5
+ import { currentPidNamespace, removeRemoteEndpointFiles, writeRemoteEndpointFiles } from "./endpoint";
6
6
 
7
7
  export interface RemoteControlServerOptions {
8
8
  dataDir: string;
@@ -44,6 +44,7 @@ export async function startRemoteControlServer(options: RemoteControlServerOptio
44
44
  port: address.port,
45
45
  token,
46
46
  startedAt: new Date().toISOString(),
47
+ pidNamespace: currentPidNamespace(),
47
48
  };
48
49
  try {
49
50
  await writeRemoteEndpointFiles(options.dataDir, endpoint);
@@ -0,0 +1,192 @@
1
+ import { createContext, useContext, useRef, type ReactNode } from "react";
2
+ import { isDialogOpen } from "../ui/dialog-stack";
3
+ import {
4
+ RemoteUiRegistryProvider,
5
+ remoteUiNodeSnapshot,
6
+ useRemoteUiNode,
7
+ useRemoteUiRegistry,
8
+ type RemoteUiNodeRegistration,
9
+ type RemoteUiRegistry,
10
+ } from "./semantic-tree";
11
+ import { namesSecret } from "./secrets";
12
+ import type { RemoteUiNodeSnapshot } from "./types";
13
+
14
+ /** What the surface's own title and header say about it, set by the components that draw them. */
15
+ interface SurfaceDetails {
16
+ step?: string;
17
+ section?: string;
18
+ title?: string;
19
+ description?: string;
20
+ /** Closes or skips the whole surface, when it offers that. */
21
+ cancel?: () => void;
22
+ }
23
+
24
+ const RemoteSurfaceContext = createContext<{ current: SurfaceDetails } | null>(null);
25
+
26
+ /** Roles of the controls a person fills in: listed as the surface's fields. */
27
+ const FIELD_ROLES = new Set(["form-field", "text-field", "textarea", "select", "checkbox", "list"]);
28
+ /** The kit's own editors, left out when the surface names its fields as form-field nodes. */
29
+ const EDITOR_ROLES = new Set(["text-field", "textarea"]);
30
+ /** The button Enter presses on the surface is the one it sends with. */
31
+ const SUBMIT_SHORTCUT = "Enter";
32
+
33
+ /**
34
+ * Registers its subtree's nodes in the app's registry, and keeps them, so the
35
+ * surface can list its own controls. Every node drawn inside is the open
36
+ * form's (`metadata.scope` "form"), so `ui.invokeMatching` tries them first,
37
+ * as it does a form modal's.
38
+ */
39
+ function surfaceRegistry(parent: RemoteUiRegistry, own: Map<string, RemoteUiNodeRegistration>): RemoteUiRegistry {
40
+ return {
41
+ register(id, registration) {
42
+ own.set(id, registration);
43
+ parent.register(id, inForm(registration));
44
+ },
45
+ unregister(id) {
46
+ own.delete(id);
47
+ parent.unregister(id);
48
+ },
49
+ snapshot: () => parent.snapshot(),
50
+ snapshotRole: (role) => parent.snapshotRole?.(role) ?? parent.snapshot().filter((node) => node.role === role),
51
+ detail: (nodeId) => parent.detail(nodeId),
52
+ invoke: (nodeId, action, input) => parent.invoke(nodeId, action, input),
53
+ };
54
+ }
55
+
56
+ function inForm(registration: RemoteUiNodeRegistration): RemoteUiNodeRegistration {
57
+ return {
58
+ get role() { return registration.role; },
59
+ get paneId() { return registration.paneId; },
60
+ get label() { return registration.label; },
61
+ get disabled() { return registration.disabled; },
62
+ get actions() { return registration.actions; },
63
+ getMetadata: () => {
64
+ const metadata = registration.getMetadata?.() ?? registration.metadata ?? {};
65
+ return { ...metadata, scope: metadata.scope ?? "form" };
66
+ },
67
+ get getDetail() { return registration.getDetail; },
68
+ };
69
+ }
70
+
71
+ function isPassword(metadata: Record<string, unknown>): boolean {
72
+ return metadata.type === "password" || metadata.inputType === "password" || metadata.fieldType === "password";
73
+ }
74
+
75
+ const FIELD_KEYS = ["placeholder", "active", "focused", "required", "error", "options", "items", "selectedIndex", "checked"] as const;
76
+
77
+ /**
78
+ * A field as the surface lists it. A password, or a field whose id, label or
79
+ * placeholder names a credential (an API key typed in the clear), says
80
+ * whether it is filled, never what.
81
+ */
82
+ function surfaceField(node: RemoteUiNodeSnapshot) {
83
+ const metadata = node.metadata ?? {};
84
+ const value = metadata.value;
85
+ const password = isPassword(metadata);
86
+ const secret = password || namesSecret(metadata.fieldId, node.label, metadata.placeholder);
87
+ const kept = Object.fromEntries(FIELD_KEYS.filter((key) => metadata[key] != null).map((key) => [key, metadata[key]]));
88
+ return {
89
+ nodeId: node.id,
90
+ ...(typeof metadata.fieldId === "string" ? { id: metadata.fieldId } : {}),
91
+ role: node.role,
92
+ label: node.label ?? null,
93
+ ...(secret
94
+ ? { ...(password ? { type: "password" } : {}), secret: true, filled: typeof value === "string" && value.length > 0 }
95
+ : node.role === "list" || node.role === "checkbox" ? {} : { value: value ?? null }),
96
+ ...kept,
97
+ ...(node.disabled ? { disabled: true } : {}),
98
+ actions: node.actions,
99
+ };
100
+ }
101
+
102
+ function surfaceButton(node: RemoteUiNodeSnapshot) {
103
+ const shortcut = node.metadata?.shortcut;
104
+ return {
105
+ nodeId: node.id,
106
+ label: node.label ?? null,
107
+ ...(node.disabled ? { disabled: true } : {}),
108
+ ...(typeof shortcut === "string" && shortcut ? { shortcut } : {}),
109
+ };
110
+ }
111
+
112
+ /** The controls drawn inside the surface, in the order they registered. */
113
+ function surfaceControls(own: Map<string, RemoteUiNodeRegistration>) {
114
+ const nodes = [...own].map(([id, registration]) => remoteUiNodeSnapshot(id, registration));
115
+ // A step that names its fields as form-field nodes drives its editors through them.
116
+ const named = nodes.some((node) => node.role === "form-field");
117
+ const fields = nodes.filter((node) => FIELD_ROLES.has(node.role) && !(named && EDITOR_ROLES.has(node.role)));
118
+ const buttons = nodes.filter((node) => node.role === "button" && node.label);
119
+ const submit = buttons.find((node) => node.metadata?.shortcut === SUBMIT_SHORTCUT);
120
+ return { fields, buttons, submit };
121
+ }
122
+
123
+ /**
124
+ * A full-window card that is not a dialog of the dialog stack, such as the
125
+ * first-run setup: remote control reads it as the open form (`app://form`),
126
+ * with its title, the fields and buttons drawn in it, `submit` for the button
127
+ * Enter presses and `cancel` when it can be skipped. `covered` while a dialog
128
+ * sits over it.
129
+ */
130
+ export function RemoteSurface({ kind, children }: { kind: string; children: ReactNode }) {
131
+ const parent = useRemoteUiRegistry();
132
+ const detailsRef = useRef<SurfaceDetails>({});
133
+ const ownRef = useRef<Map<string, RemoteUiNodeRegistration>>(new Map());
134
+ const registryRef = useRef<RemoteUiRegistry | null>(null);
135
+ if (parent && !registryRef.current) registryRef.current = surfaceRegistry(parent, ownRef.current);
136
+
137
+ const press = async (node: RemoteUiNodeSnapshot | undefined) => {
138
+ if (!node) throw new Error("This step has no button that sends it; press one of its buttons instead.");
139
+ if (node.disabled) throw new Error(`"${node.label}" is disabled.`);
140
+ await ownRef.current.get(node.id)?.actions?.press?.();
141
+ };
142
+
143
+ useRemoteUiNode({
144
+ role: "form",
145
+ get label() { return detailsRef.current.title; },
146
+ get actions() {
147
+ const cancel = detailsRef.current.cancel;
148
+ const { submit } = surfaceControls(ownRef.current);
149
+ return {
150
+ cancel: cancel ? () => cancel() : undefined,
151
+ submit: submit ? () => press(surfaceControls(ownRef.current).submit) : undefined,
152
+ };
153
+ },
154
+ getMetadata: () => {
155
+ const details = detailsRef.current;
156
+ const { fields, buttons, submit } = surfaceControls(ownRef.current);
157
+ return {
158
+ scope: "form",
159
+ kind,
160
+ step: details.step ?? details.section ?? null,
161
+ title: details.title ?? null,
162
+ ...(details.description ? { description: details.description } : {}),
163
+ fields: fields.map(surfaceField),
164
+ buttons: buttons.map(surfaceButton),
165
+ submitLabel: submit?.label ?? null,
166
+ covered: isDialogOpen(),
167
+ };
168
+ },
169
+ } satisfies RemoteUiNodeRegistration);
170
+
171
+ const content = <RemoteSurfaceContext value={detailsRef}>{children}</RemoteSurfaceContext>;
172
+ return registryRef.current
173
+ ? <RemoteUiRegistryProvider registry={registryRef.current}>{content}</RemoteUiRegistryProvider>
174
+ : content;
175
+ }
176
+
177
+ /** Names the surface this is drawn in: its step, title and description. */
178
+ export function useRemoteSurfaceHeading(heading: Pick<SurfaceDetails, "step" | "title" | "description">): void {
179
+ const surface = useContext(RemoteSurfaceContext);
180
+ if (!surface) return;
181
+ surface.current.step = heading.step;
182
+ surface.current.title = heading.title;
183
+ surface.current.description = heading.description;
184
+ }
185
+
186
+ /** The surface's section (shown as its step when the title names none) and how it is skipped, if it can be. */
187
+ export function useRemoteSurfaceHeader(header: Pick<SurfaceDetails, "section" | "cancel">): void {
188
+ const surface = useContext(RemoteSurfaceContext);
189
+ if (!surface) return;
190
+ surface.current.section = header.section;
191
+ surface.current.cancel = header.cancel;
192
+ }
@@ -9,6 +9,11 @@ export interface RemoteEndpoint {
9
9
  port: number;
10
10
  token: string;
11
11
  startedAt: string;
12
+ /**
13
+ * The process-id namespace `pid` belongs to, on Linux. A client in another
14
+ * one (a sandbox, a container) cannot tell from `pid` whether the app runs.
15
+ */
16
+ pidNamespace?: string;
12
17
  }
13
18
 
14
19
  export interface RemoteJsonPatchOperation {
@@ -11,6 +11,7 @@ import { buildTerminalMediaArgs, createTerminalMediaReaper, terminalMediaStateFi
11
11
  import { saveTextFileToDownloads } from "../../utils/save-text-file";
12
12
  import { installInteractionPerformanceRecorder } from "./interaction-performance";
13
13
  import { provideKittyServices } from "./kitty-services";
14
+ import { setTerminalReportsControlKeys } from "../../app/keybindings/terminal-keys";
14
15
  import { captureRendererFrame } from "./frame-capture";
15
16
  import {
16
17
  createTimerFrameDriver,
@@ -120,6 +121,11 @@ export async function createOpenTuiHost(): Promise<OpenTuiHost> {
120
121
  // at 11 is not a leak here, and it prints over the panes.
121
122
  renderer.setMaxListeners(0);
122
123
  installResolutionEventBridge(renderer);
124
+ // Whether Control reaches a digit, once the terminal has answered: the
125
+ // layout tabs name Alt+1 where it does not. Unknown until then.
126
+ renderer.on("capabilities", (capabilities: { kitty_keyboard?: boolean } | null) => {
127
+ setTerminalReportsControlKeys(capabilities?.kitty_keyboard === true);
128
+ });
123
129
  // Streamed quotes apply and notify on one clock of up to 10 Hz: every
124
130
  // visible row stays live while a burst of ticks costs one terminal redraw,
125
131
  // and a layout whose redraws are expensive gets fewer of them.
@@ -1,5 +1,5 @@
1
1
  import { logFailure } from "../utils/log-failure";
2
- import { chartSeriesResolveRequestSchema } from "../capabilities/chart-series";
2
+ import { chartSeriesResolveRequestSchema, uncoveredCapabilityMessage } from "../capabilities/chart-series";
3
3
  import type { CapabilityInvoker } from "../capabilities/types";
4
4
  import type { GloomPlugin } from "../types/plugin";
5
5
  import { resolveRegisteredSeries } from "./capability";
@@ -43,7 +43,7 @@ export function standaloneSeriesInvoker(
43
43
  registry ??= build();
44
44
  const request = chartSeriesResolveRequestSchema.parse(payload);
45
45
  const resolved = await resolveRegisteredSeries(await registry, capabilityId, request.seriesId, request.viewport, options?.signal);
46
- if (!resolved) throw new Error(`Chart series capability "${capabilityId}" is unavailable. Enable its plugin or provider.`);
46
+ if (!resolved) throw new Error(uncoveredCapabilityMessage(capabilityId, request.seriesId));
47
47
  return resolved as T;
48
48
  },
49
49
  };
package/src/shares/api.ts CHANGED
@@ -58,17 +58,28 @@ async function readJson(response: Response): Promise<unknown> {
58
58
  try { return await response.json(); } catch { throw new Error("The share service returned an invalid response."); }
59
59
  }
60
60
 
61
+ /**
62
+ * A service from before shares kept an item refuses one it does not know with
63
+ * a 400: the share is made again without it, as that service would keep it.
64
+ */
65
+ function withoutItem(payload: SharePayload): SharePayload | null {
66
+ return payload.kind === "pane" && payload.item ? { kind: "pane", data: payload.data } : null;
67
+ }
68
+
61
69
  export async function createShare(payload: SharePayload, fetchImpl?: ShareFetch): Promise<CreatedShare> {
62
70
  const validated = parseSharePayload(payload);
63
71
  if (!validated) throw new Error("Invalid share payload.");
64
72
  let body: unknown;
65
73
  if (fetchImpl) {
66
- const response = await fetchImpl(`${SHARE_API_ORIGIN}/shares`, {
74
+ const post = (share: SharePayload) => fetchImpl(`${SHARE_API_ORIGIN}/shares`, {
67
75
  method: "POST",
68
76
  credentials: "include",
69
77
  headers: { "Content-Type": "application/json" },
70
- body: JSON.stringify(validated),
78
+ body: JSON.stringify(share),
71
79
  });
80
+ let response = await post(validated);
81
+ const plain = response.status === 400 ? withoutItem(validated) : null;
82
+ if (plain) response = await post(plain);
72
83
  if (!response.ok) {
73
84
  if (response.status === 401) throw new Error("Sign in to Gloom Cloud to share.");
74
85
  if (response.status === 403) throw new Error("Verify your Gloom Cloud email to share.");
@@ -80,7 +91,13 @@ export async function createShare(payload: SharePayload, fetchImpl?: ShareFetch)
80
91
  // client when an interactive app creates a share, not on every public view.
81
92
  const { apiClient } = await import("../api-client").catch((error: unknown) => { throw shareFailed(error); });
82
93
  try {
83
- body = await apiClient.createTerminalShare(validated);
94
+ try {
95
+ body = await apiClient.createTerminalShare(validated);
96
+ } catch (error) {
97
+ const plain = error instanceof ApiRequestError && error.status === 400 ? withoutItem(validated) : null;
98
+ if (!plain) throw error;
99
+ body = await apiClient.createTerminalShare(plain);
100
+ }
84
101
  } catch (error) {
85
102
  if (error instanceof ApiRequestError && error.status === 401) throw new Error("Sign in to Gloom Cloud to share.");
86
103
  if (error instanceof ApiRequestError && error.status === 403) throw new Error("Verify your Gloom Cloud email to share.");
@@ -112,7 +129,7 @@ export async function getShare(
112
129
  const body = await readJson(response);
113
130
  if (!body || typeof body !== "object") return null;
114
131
  const object = body as Record<string, unknown>;
115
- const payload = parseSharePayload({ kind: object.kind, data: object.data });
132
+ const payload = parseSharePayload({ kind: object.kind, data: object.data, item: object.item });
116
133
  if (!payload || !validDate(object.createdAt) || !validDate(object.expiresAt)) return null;
117
134
  return {
118
135
  ...payload,
@@ -0,0 +1,73 @@
1
+ import { markdownPlainText } from "../utils/markdown";
2
+ import { isRecord } from "../utils/guards";
3
+ import { plainUntrustedLine } from "../utils/untrusted-text";
4
+
5
+ /**
6
+ * What a shared pane was on when it was shared: the story it had open, the
7
+ * result it had picked, the ticker it shows. It goes with the share, beside
8
+ * the pane's settings, so a chat card, a link preview in another app and the
9
+ * chat's bots can say what the link is about without opening it. A pane on
10
+ * nothing in particular shares none.
11
+ */
12
+ export interface ShareItem {
13
+ /** The pane it opens, by name: a reader without that pane (a link preview, a bot) still says which. */
14
+ pane: string;
15
+ title: string;
16
+ /** A sentence or two of what it says: a story's summary, a result's snippet. */
17
+ excerpt?: string;
18
+ }
19
+
20
+ const SHARE_ITEM_LIMITS = { pane: 80, title: 200, excerpt: 300 } as const;
21
+ /** About two lines of a chat card and what link previews show of a description. */
22
+ const EXCERPT_LENGTH = 240;
23
+
24
+ /** One line of plain text, as the share service keeps it and every reader draws it (untrusted-text.ts). */
25
+ const oneLine = plainUntrustedLine;
26
+
27
+ /** `text` cut to `max` characters at a word, with an ellipsis when it was cut. */
28
+ function clip(text: string, max: number): string {
29
+ if (text.length <= max) return text;
30
+ const cut = text.slice(0, max - 1);
31
+ const space = cut.lastIndexOf(" ");
32
+ return `${(space > max * 0.6 ? cut.slice(0, space) : cut).replace(/[\s,;:.-]+$/, "")}…`;
33
+ }
34
+
35
+ /** The opening of a text as one line: its first paragraph, cut to about two lines. */
36
+ export function shareItemExcerpt(text: string | null | undefined, { markdown = false, max = EXCERPT_LENGTH } = {}): string | undefined {
37
+ if (!text) return undefined;
38
+ const plain = markdown ? markdownPlainText(text, { links: true }) : text;
39
+ const paragraph = plain.split(/\n\s*\n/).map(oneLine).find(Boolean);
40
+ return paragraph ? clip(paragraph, Math.min(max, SHARE_ITEM_LIMITS.excerpt)) : undefined;
41
+ }
42
+
43
+ /** The item as it is kept: one line each, within the limits, or null without a title. */
44
+ export function shareItem(pane: string, part: { title?: string | null; excerpt?: string | null } | null | undefined): ShareItem | null {
45
+ const title = part?.title ? clip(oneLine(part.title), SHARE_ITEM_LIMITS.title) : "";
46
+ const name = clip(oneLine(pane), SHARE_ITEM_LIMITS.pane);
47
+ if (!title || !name) return null;
48
+ const excerpt = part?.excerpt ? clip(oneLine(part.excerpt), SHARE_ITEM_LIMITS.excerpt) : "";
49
+ return { pane: name, title, ...(excerpt && excerpt !== title ? { excerpt } : {}) };
50
+ }
51
+
52
+ /** `value` as one line of plain text within `max`, or null when it is not text, says nothing, or is over. */
53
+ function boundedText(value: unknown, max: number): string | null {
54
+ if (typeof value !== "string") return null;
55
+ const text = oneLine(value);
56
+ return text && text.length <= max ? text : null;
57
+ }
58
+
59
+ /**
60
+ * An item read back from a share, or null for anything else. Another person's
61
+ * app wrote it, so its text is made plain again here, whatever the service
62
+ * kept: no escape sequence, control, bidi or zero-width character reaches a
63
+ * card.
64
+ */
65
+ export function parseShareItem(value: unknown): ShareItem | null {
66
+ if (!isRecord(value) || !Object.keys(value).every((key) => key === "pane" || key === "title" || key === "excerpt")) return null;
67
+ const pane = boundedText(value.pane, SHARE_ITEM_LIMITS.pane);
68
+ const title = boundedText(value.title, SHARE_ITEM_LIMITS.title);
69
+ if (!pane || !title) return null;
70
+ if (value.excerpt === undefined) return { pane, title };
71
+ const excerpt = boundedText(value.excerpt, SHARE_ITEM_LIMITS.excerpt);
72
+ return excerpt ? { pane, title, excerpt } : null;
73
+ }