gloomberb 0.20.3 → 0.20.4

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 (154) hide show
  1. package/package.json +1 -1
  2. package/src/account/auth-dialog.tsx +17 -0
  3. package/src/api-client/data.ts +6 -0
  4. package/src/api-client/fx-interventions.ts +64 -0
  5. package/src/api-client/index.ts +1 -0
  6. package/src/api-client/release-summaries.ts +21 -0
  7. package/src/app/keybindings/actions.ts +2 -2
  8. package/src/app/pane-runtime/ticker-open-runtime.ts +245 -66
  9. package/src/cli/commands/market.ts +77 -1
  10. package/src/cli/commands/news-search.ts +1 -3
  11. package/src/cli/commands/plugins.ts +27 -5
  12. package/src/cli/commands/system.ts +19 -3
  13. package/src/cli/commands/ticker.ts +60 -19
  14. package/src/cli/index.ts +8 -8
  15. package/src/cli/pane-functions/function-help.ts +3 -3
  16. package/src/cli/report-tables.ts +18 -6
  17. package/src/cli/result.ts +15 -7
  18. package/src/cli/types.ts +2 -0
  19. package/src/components/chart/composite/axis-overlays.tsx +22 -0
  20. package/src/components/chart/composite/composite-chart.tsx +54 -13
  21. package/src/components/chart/composite/event-captions.ts +109 -0
  22. package/src/components/chart/composite/event-guides.ts +74 -0
  23. package/src/components/chart/composite/rasterizer.ts +2 -0
  24. package/src/components/chart/composite/text-renderer.ts +2 -0
  25. package/src/components/chart/composite/types.ts +31 -0
  26. package/src/components/command-bar/layout-items/focused-pane.ts +5 -5
  27. package/src/components/command-bar/routes/root/provider-search.ts +5 -4
  28. package/src/components/command-bar/routes/ticker-search/results.ts +51 -0
  29. package/src/components/command-bar/routes/ticker-search/route.ts +3 -2
  30. package/src/components/layout/detached-pane-shell.tsx +1 -1
  31. package/src/components/layout/floating-pane.tsx +5 -1
  32. package/src/components/layout/pane/footer/index.tsx +21 -14
  33. package/src/components/layout/pane/footer/model.ts +6 -0
  34. package/src/components/layout/shell/action-menu-overlay.tsx +10 -5
  35. package/src/components/layout/shell/active-drag.ts +149 -105
  36. package/src/components/layout/shell/drag/drop-zones.ts +162 -0
  37. package/src/components/layout/shell/drag/index.ts +47 -218
  38. package/src/components/layout/shell/drag/live.ts +10 -3
  39. package/src/components/layout/shell/drag/overlays.tsx +182 -5
  40. package/src/components/layout/shell/drag/runtime.ts +29 -6
  41. package/src/components/layout/shell/drag/shared-edges.ts +156 -0
  42. package/src/components/layout/shell/index.tsx +11 -6
  43. package/src/components/layout/shell/menu.ts +11 -2
  44. package/src/components/layout/shell/native/pointer-runtime.ts +25 -0
  45. package/src/components/layout/shell/native/window-state.ts +2 -2
  46. package/src/components/layout/shell/pane/layers.tsx +71 -7
  47. package/src/components/layout/shell/terminal-pointer-runtime.ts +18 -9
  48. package/src/components/layout/shell/window-mode/index.ts +8 -10
  49. package/src/components/layout/window-edit/mode.ts +39 -7
  50. package/src/components/layout/window-edit/presentation.ts +1 -1
  51. package/src/components/onboarding/onboarding-keyboard.ts +4 -0
  52. package/src/components/onboarding/onboarding-wizard.tsx +8 -3
  53. package/src/components/ui/button.tsx +2 -0
  54. package/src/components/ui/choice-dialog.tsx +1 -0
  55. package/src/components/ui/data-table/index.tsx +4 -3
  56. package/src/components/ui/list-view.tsx +7 -12
  57. package/src/components/ui/loading.tsx +10 -3
  58. package/src/components/ui/menu.tsx +6 -2
  59. package/src/components/ui/quote.ts +14 -1
  60. package/src/data/config/layout.ts +5 -2
  61. package/src/docs/snapshot.json +29 -5
  62. package/src/i18n/es.ts +9 -8
  63. package/src/i18n/ja.ts +9 -8
  64. package/src/i18n/ko.ts +9 -8
  65. package/src/i18n/zh-cn.ts +9 -8
  66. package/src/i18n/zh-tw.ts +9 -8
  67. package/src/layout/pane-manager/floating-actions.ts +17 -0
  68. package/src/layout/pane-manager/floating-stack.ts +187 -0
  69. package/src/layout/pane-manager/floating.ts +4 -2
  70. package/src/layout/pane-manager/gridlock.ts +5 -1
  71. package/src/layout/pane-manager/index.ts +11 -0
  72. package/src/layout/pane-manager/layout-state.ts +10 -3
  73. package/src/market-data/futures-board.ts +46 -1
  74. package/src/market-data/futures-contract.ts +12 -3
  75. package/src/market-data/fx-interventions.ts +270 -0
  76. package/src/news/news-model.ts +44 -2
  77. package/src/plugins/builtin/alerts/cli.ts +4 -4
  78. package/src/plugins/builtin/alerts/format.ts +1 -2
  79. package/src/plugins/builtin/alerts/headless.ts +1 -2
  80. package/src/plugins/builtin/alerts/move-checks.ts +12 -6
  81. package/src/plugins/builtin/alerts/move.ts +30 -9
  82. package/src/plugins/builtin/alerts/pane.tsx +0 -2
  83. package/src/plugins/builtin/alerts/storage.ts +4 -2
  84. package/src/plugins/builtin/alerts/types.ts +12 -0
  85. package/src/plugins/builtin/changelog/index.tsx +292 -101
  86. package/src/plugins/builtin/changelog/versions.ts +293 -0
  87. package/src/plugins/builtin/chart-composer/intervention-events.ts +105 -0
  88. package/src/plugins/builtin/chart-composer/pane.tsx +21 -7
  89. package/src/plugins/builtin/chat/message/render-state.ts +2 -5
  90. package/src/plugins/builtin/cloud/askg/attached-pane.tsx +10 -5
  91. package/src/plugins/builtin/cloud/askg/controller.ts +141 -5
  92. package/src/plugins/builtin/cloud/askg/executor.ts +113 -4
  93. package/src/plugins/builtin/cloud/askg/manifest.ts +28 -13
  94. package/src/plugins/builtin/cloud/askg/model.ts +14 -4
  95. package/src/plugins/builtin/cloud/askg/pane.tsx +70 -46
  96. package/src/plugins/builtin/cloud/askg/turn-parts.tsx +70 -0
  97. package/src/plugins/builtin/cloud/terminal-relay/engine.ts +50 -130
  98. package/src/plugins/builtin/cloud/terminal-relay/policy.ts +327 -7
  99. package/src/plugins/builtin/cloud/terminal-relay/prompts.tsx +2 -1
  100. package/src/plugins/builtin/cloud/terminal-relay/redact.ts +47 -6
  101. package/src/plugins/builtin/commodities-energy/index.tsx +1 -3
  102. package/src/plugins/builtin/commodities-energy/view-state.ts +3 -0
  103. package/src/plugins/builtin/cot/headless.ts +14 -2
  104. package/src/plugins/builtin/earnings/index.tsx +2 -2
  105. package/src/plugins/builtin/futures/index.tsx +25 -4
  106. package/src/plugins/builtin/futures/model.ts +28 -32
  107. package/src/plugins/builtin/futures/series.ts +4 -3
  108. package/src/plugins/builtin/futures/table.tsx +16 -9
  109. package/src/plugins/builtin/futures/use-board-terms.ts +3 -3
  110. package/src/plugins/builtin/help/index.tsx +3 -3
  111. package/src/plugins/builtin/help/keybindings-editor.tsx +18 -4
  112. package/src/plugins/builtin/layout-manager/index.tsx +8 -8
  113. package/src/plugins/builtin/news/headless.ts +2 -2
  114. package/src/plugins/builtin/news/index.tsx +3 -3
  115. package/src/plugins/builtin/perps/markets-section.tsx +5 -2
  116. package/src/plugins/builtin/plugin-marketplace/pane.tsx +11 -11
  117. package/src/plugins/builtin/portfolio-list/summary/index.tsx +3 -1
  118. package/src/plugins/builtin/research/event-model.ts +9 -1
  119. package/src/plugins/builtin/research/event-sources.ts +22 -0
  120. package/src/plugins/builtin/research/headless.ts +3 -3
  121. package/src/plugins/builtin/shared/cloud-upgrade.ts +27 -3
  122. package/src/plugins/builtin/ticker-detail/overview/components.tsx +54 -5
  123. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +28 -13
  124. package/src/plugins/builtin/ticker-detail/pane.tsx +7 -2
  125. package/src/plugins/installer.ts +45 -0
  126. package/src/remote/resources.ts +12 -1
  127. package/src/remote/schema.ts +1 -0
  128. package/src/remote/semantic-helpers.ts +29 -1
  129. package/src/remote/semantic-tree.tsx +32 -15
  130. package/src/renderers/cloudflare/worker.ts +16 -1
  131. package/src/renderers/dom/styles.css +40 -6
  132. package/src/renderers/share/layout-view.tsx +1 -1
  133. package/src/sources/gloomberb-cloud/news.ts +35 -12
  134. package/src/state/opening-ticker-panes.ts +47 -0
  135. package/src/test-support/cli-context.ts +2 -0
  136. package/src/test-support/preload.ts +4 -1
  137. package/src/tickers/instrument-kind.ts +23 -3
  138. package/src/types/config.ts +5 -0
  139. package/src/types/context-menu.ts +2 -0
  140. package/src/types/plugin-commands.ts +140 -0
  141. package/src/types/plugin-context.ts +125 -0
  142. package/src/types/plugin-contributions.ts +55 -0
  143. package/src/types/plugin-definition.ts +234 -0
  144. package/src/types/plugin-notifications.ts +38 -0
  145. package/src/types/plugin-pane-settings.ts +114 -0
  146. package/src/types/plugin-pane-templates.ts +160 -0
  147. package/src/types/plugin-panes.ts +221 -0
  148. package/src/types/plugin-reports.ts +35 -0
  149. package/src/types/plugin-shared.ts +14 -0
  150. package/src/types/plugin-state.ts +71 -0
  151. package/src/types/plugin.ts +14 -1169
  152. package/src/ui/index.tsx +14 -3
  153. package/src/updater/github-releases.ts +23 -0
  154. package/src/utils/cli-output.ts +22 -9
@@ -0,0 +1,234 @@
1
+ import type { ReactNode } from "react";
2
+ import type { PluginCapability } from "../capabilities";
3
+ import type { CliGlobalOptions } from "../cli/options";
4
+ import type { CliResult, CliResultRenderOptions } from "../cli/result";
5
+ import type { SeriesDefinition } from "../series/types";
6
+ import type { PluginLogger } from "../utils/debug-log";
7
+ import type { BrokerAdapter } from "./broker";
8
+ import type { AppConfig } from "./config";
9
+ import type { TickerFinancials } from "./financials";
10
+ import type { GloomPluginContext } from "./plugin-context";
11
+ import type { PaneTemplateDef } from "./plugin-pane-templates";
12
+ import type { PaneDef } from "./plugin-panes";
13
+ import type { TickerRecord } from "./ticker";
14
+
15
+ /**
16
+ * Named render slots. The host renders only `status:widget`; the other names
17
+ * are never drawn and are kept so existing plugins still type-check.
18
+ */
19
+ export interface GloomSlots {
20
+ /** @deprecated Never rendered. Use `ctx.registerTickerResearchTab`. */
21
+ "ticker-research:tab": { ticker: TickerRecord; financials: TickerFinancials | null };
22
+ /** @deprecated Never rendered. Use `ctx.registerTickerResearchTab`. */
23
+ "ticker-research:section": { ticker: TickerRecord; financials: TickerFinancials | null };
24
+ /** @deprecated Never rendered. Use `ctx.registerColumn`. */
25
+ "list:column": { ticker: TickerRecord; financials: TickerFinancials | null };
26
+ /** @deprecated Never rendered. Use `ctx.registerCommandBarSearchProvider`. */
27
+ "command:extra": { query: string };
28
+ /** @deprecated Never rendered. Use `ctx.registerCommand`. */
29
+ "command:preset": Record<string, never>;
30
+ "status:widget": Record<string, never>;
31
+ /** @deprecated Never rendered. Declare settings with `configSchema`. */
32
+ "config:section": Record<string, never>;
33
+ /** @deprecated Never called. Subscribe with `ctx.on("ticker:refreshed")`. */
34
+ "data:post-refresh": { ticker: string; financials: TickerFinancials };
35
+ /** @deprecated Never called. Contribute data with an `asset-data` capability. */
36
+ "data:enricher": { ticker: TickerRecord };
37
+ }
38
+
39
+ interface CliHelpColumn {
40
+ header: string;
41
+ align?: "left" | "right" | "center";
42
+ width?: number;
43
+ }
44
+
45
+ interface CliCommandHelpSection {
46
+ title: string;
47
+ columns?: CliHelpColumn[];
48
+ rows?: string[][];
49
+ lines?: string[];
50
+ }
51
+
52
+ interface CliCommandHelpOption {
53
+ /** Flag spelling with its value, e.g. `--range <range>`. */
54
+ flags: string;
55
+ description: string;
56
+ }
57
+
58
+ interface CliCommandHelp {
59
+ /** Heading `gloom help` lists the command under. Plugin commands without one share a plugin heading. */
60
+ group?: string;
61
+ /** Invocations without the leading `gloomberb`, e.g. `quote <symbol...>`. */
62
+ usage?: string[];
63
+ options?: CliCommandHelpOption[];
64
+ /** Complete invocations without the leading `gloomberb`. */
65
+ examples?: string[];
66
+ /** Extra blocks shown only in the command's own help (`gloom help <command>`). */
67
+ sections?: CliCommandHelpSection[];
68
+ }
69
+
70
+ interface CliLaunchEnvironment {
71
+ terminalWidth: number;
72
+ terminalHeight: number;
73
+ }
74
+
75
+ /**
76
+ * The resume state the app writes at exit and reads at startup. A plugin whose
77
+ * CLI command launches the UI seeds it so the pane opens on what was asked for
78
+ * rather than on what the last session left behind.
79
+ */
80
+ export type { AppSessionSnapshot } from "../core/state/session-persistence";
81
+
82
+ export interface CliLaunchConfigResult<TLaunchState = unknown> {
83
+ config: AppConfig;
84
+ launchState?: TLaunchState;
85
+ }
86
+
87
+ export interface CliLaunchRequest<TLaunchState = unknown> {
88
+ applyConfig(config: AppConfig, env: CliLaunchEnvironment): CliLaunchConfigResult<TLaunchState>;
89
+ applySessionSnapshot?(
90
+ config: AppConfig,
91
+ snapshot: import("../core/state/session-persistence").AppSessionSnapshot | null,
92
+ launchState: TLaunchState | undefined,
93
+ ): import("../core/state/session-persistence").AppSessionSnapshot;
94
+ }
95
+
96
+ export type CliDispatchResult =
97
+ | { kind: "handled" }
98
+ | { kind: "launch-ui"; request: CliLaunchRequest }
99
+ | { kind: "unhandled" };
100
+
101
+ export interface CliCommandContext {
102
+ initConfigData(): Promise<import("../cli/types").ConfigContext>;
103
+ initMarketData(): Promise<import("../cli/types").MarketContext>;
104
+ initServices(): Promise<import("../cli/types").CliServicesContext>;
105
+ cliOptions: CliGlobalOptions;
106
+ plugins: GloomPlugin[];
107
+ fail(message: string, details?: string): never;
108
+ closeAndFail(
109
+ persistence: import("../data/app-persistence").AppPersistence,
110
+ message: string,
111
+ details?: string,
112
+ ): never;
113
+ output: {
114
+ cliStyles: typeof import("../utils/cli-output").cliStyles;
115
+ colorBySign: typeof import("../utils/cli-output").colorBySign;
116
+ renderSection: typeof import("../utils/cli-output").renderSection;
117
+ renderStat: typeof import("../utils/cli-output").renderStat;
118
+ renderStats: typeof import("../utils/cli-output").renderStats;
119
+ renderTable: typeof import("../utils/cli-output").renderTable;
120
+ };
121
+ printResult<T, Row extends Record<string, unknown> = Record<string, unknown>>(
122
+ result: CliResult<T>,
123
+ options?: CliResultRenderOptions<T, Row>,
124
+ ): void;
125
+ log: PluginLogger;
126
+ }
127
+
128
+ export interface CliCommandDef {
129
+ name: string;
130
+ aliases?: string[];
131
+ description: string;
132
+ help?: CliCommandHelp;
133
+ execute(args: string[], ctx: CliCommandContext): void | CliDispatchResult | Promise<void | CliDispatchResult>;
134
+ }
135
+
136
+ /**
137
+ * Where a plugin can actually run.
138
+ *
139
+ * `cli` and `tui` run in Bun and may use Node APIs. `desktop` runs in the
140
+ * Electrobun view. `web` runs in the browser at term.gloom.sh, which rules out
141
+ * Node builtins entirely — a plugin opening a TCP socket (IBKR Gateway) can
142
+ * never be web-capable, no matter what it declares.
143
+ *
144
+ * Plugins may declare this, but the registry derives it from a static import
145
+ * scan and overwrites the declaration. Treat an author-supplied value as a hint.
146
+ */
147
+ export type PluginTarget = "cli" | "tui" | "desktop" | "web";
148
+
149
+ export const ALL_PLUGIN_TARGETS: readonly PluginTarget[] = ["cli", "tui", "desktop", "web"];
150
+
151
+ /**
152
+ * One setting a plugin needs from the user before it is useful, such as an API
153
+ * key. Values are stored in the plugin's `configState` under `key`.
154
+ */
155
+ export interface PluginConfigField {
156
+ key: string;
157
+ label: string;
158
+ type?: "text" | "password" | "number" | "select";
159
+ /** Shown under the field. Say where to get the value, not what the plugin does. */
160
+ description?: string;
161
+ placeholder?: string;
162
+ defaultValue?: string;
163
+ /** The plugin counts as "needs setup" while a required field is empty. Default true. */
164
+ required?: boolean;
165
+ options?: Array<{ label: string; value: string }>;
166
+ }
167
+
168
+ export interface GloomPlugin {
169
+ id: string;
170
+ /**
171
+ * Where this plugin's saved state lives: its `pluginConfig` entry, its resume
172
+ * state, and the per-pane state its panes write. Defaults to `id`.
173
+ *
174
+ * Set it when a plugin is renamed, or moves out of this repository under a
175
+ * new id, so the threads, tabs, and defaults a user already has stay theirs.
176
+ * Everything else (the toggle, the marketplace, seeding) keys off `id`.
177
+ */
178
+ stateId?: string;
179
+ name: string;
180
+ version: string;
181
+ description?: string;
182
+ toggleable?: boolean;
183
+ order?: number;
184
+ cliCommands?: CliCommandDef[];
185
+ /** Defaults to every target when omitted. */
186
+ targets?: readonly PluginTarget[];
187
+ /**
188
+ * Third-party hosts the plugin fetches from, as bare domains
189
+ * (`"api.example.com"`; a parent domain also covers its subdomains).
190
+ *
191
+ * Terminal and desktop reach anything, so this is informational there and
192
+ * is what the plugin directory shows under "Network access". On the web the
193
+ * browser cannot call a host that sends no CORS headers, so the hosted app
194
+ * proxies exactly the hosts the bundled plugins declare here and refuses
195
+ * the rest. A plugin that leaves a host out works on the desktop and fails
196
+ * on the web.
197
+ *
198
+ * Hosts reached by a plugin's dependencies count too: declare every host
199
+ * contacted on the plugin's behalf, including authentication endpoints.
200
+ */
201
+ hosts?: readonly string[];
202
+ /** Shown in the marketplace pane and on the website. */
203
+ homepage?: string;
204
+ /**
205
+ * Settings the plugin cannot work without. Declaring them gives the plugin a
206
+ * "Set up <name>" command, a form the marketplace opens from its `s` key, and
207
+ * a `needs setup` status until every required field has a value. Read the
208
+ * values back with `ctx.configState.get(key)`.
209
+ */
210
+ configSchema?: PluginConfigField[];
211
+ /**
212
+ * Overrides the default readiness rule (every required `configSchema` field
213
+ * has a value) for plugins whose setup is not a plain form, such as a broker
214
+ * login or a file that must exist.
215
+ */
216
+ isConfigured?(values: Record<string, unknown>): boolean;
217
+
218
+ setup?(ctx: GloomPluginContext): void | Promise<void>;
219
+ dispose?(): void;
220
+
221
+ panes?: PaneDef[];
222
+ paneTemplates?: PaneTemplateDef[];
223
+ broker?: BrokerAdapter;
224
+ capabilities?: PluginCapability[];
225
+ /**
226
+ * Series the plugin adds to the data catalog, chartable against any other
227
+ * catalog entry. A definition that fails validation is skipped and logged;
228
+ * `ctx.registerSeries` adds series later and throws instead.
229
+ */
230
+ series?: readonly SeriesDefinition[];
231
+ slots?: Partial<{
232
+ [K in keyof GloomSlots]: (props: GloomSlots[K]) => ReactNode;
233
+ }>;
234
+ }
@@ -0,0 +1,38 @@
1
+ export type AppNotificationType = "info" | "success" | "error";
2
+ type AppDesktopNotificationMode = "never" | "when-inactive" | "always";
3
+
4
+ export interface AppNotificationDelivery {
5
+ toastVisible: boolean;
6
+ desktopRequested: boolean;
7
+ }
8
+
9
+ export interface AppNotificationRequest {
10
+ title?: string;
11
+ body: string;
12
+ subtitle?: string;
13
+ duration?: number;
14
+ type?: AppNotificationType;
15
+ toast?: boolean;
16
+ /** If true, in-app toast stays visible until user dismisses it */
17
+ persistent?: boolean;
18
+ desktop?: AppDesktopNotificationMode;
19
+ /** macOS sound name (e.g., "Glass", "Ping", "Hero"). Ignored on other platforms. */
20
+ sound?: string;
21
+ action?: {
22
+ label: string;
23
+ onClick: () => void;
24
+ };
25
+ /**
26
+ * What a built-in notice is about, so the Unread list can keep it after the
27
+ * toast is gone and open it again: `price:<alertId>`, `catalyst:<eventId>`,
28
+ * `econ:<eventId>`, `team:<cardId>` or `scan:<paneId>`. Other values are not kept.
29
+ */
30
+ refId?: string;
31
+ /** Rendered next to `action`. Use for a dismissing counterpart such as snooze. */
32
+ secondaryAction?: {
33
+ label: string;
34
+ onClick: () => void;
35
+ };
36
+ /** Runs once, when the in-app toast is first drawn. Not called when `toast` is false. */
37
+ onShown?: () => void;
38
+ }
@@ -0,0 +1,114 @@
1
+ import type { AppConfig, LayoutConfig, PaneInstanceConfig } from "./config";
2
+ import type { AppNotificationRequest } from "./plugin-notifications";
3
+
4
+ export interface PaneSettingsContext {
5
+ config: AppConfig;
6
+ layout: LayoutConfig;
7
+ paneId: string;
8
+ paneType: string;
9
+ pane: PaneInstanceConfig;
10
+ settings: Record<string, unknown>;
11
+ paneState: Record<string, unknown>;
12
+ activeTicker: string | null;
13
+ activeCollectionId: string | null;
14
+ }
15
+
16
+ export interface PaneSettingOption {
17
+ value: string;
18
+ label: string;
19
+ description?: string;
20
+ }
21
+
22
+ interface PaneSettingFieldBase {
23
+ key: string;
24
+ label: string;
25
+ description?: string;
26
+ storage?: "pane" | "plugin";
27
+ /** Keys in the same storage scope that should be reset when this value changes. */
28
+ clearOnChange?: string[];
29
+ }
30
+
31
+ interface PaneSettingToggleField extends PaneSettingFieldBase {
32
+ type: "toggle";
33
+ }
34
+
35
+ export interface PaneSettingTextField extends PaneSettingFieldBase {
36
+ type: "text";
37
+ placeholder?: string;
38
+ }
39
+
40
+ interface PaneSettingSelectField extends PaneSettingFieldBase {
41
+ type: "select";
42
+ options: PaneSettingOption[];
43
+ }
44
+
45
+ interface PaneSettingMultiSelectField extends PaneSettingFieldBase {
46
+ type: "multi-select";
47
+ options: PaneSettingOption[];
48
+ /** A long list: a filter box, each description beside its label. */
49
+ searchable?: boolean;
50
+ }
51
+
52
+ interface PaneSettingOrderedMultiSelectField extends PaneSettingFieldBase {
53
+ type: "ordered-multi-select";
54
+ options: PaneSettingOption[];
55
+ /** A long list: a filter box, each description beside its label and each selection's position. */
56
+ searchable?: boolean;
57
+ }
58
+
59
+ /** What an action row says of its own action (docs/pane-conventions.md, "Row messages"). */
60
+ export interface PaneSettingRowNote {
61
+ /** A short state, where the row's action label is: `Connecting…`, `Sign-in failed`. */
62
+ status: string;
63
+ /** The full reason or the next step, in place of the row's description. */
64
+ text?: string;
65
+ tone: "warning" | "negative";
66
+ }
67
+
68
+ export interface PaneSettingActionContext extends PaneSettingsContext {
69
+ surface: "pane-dialog" | "command-bar";
70
+ close(): void;
71
+ openCommandBar(query?: string): void;
72
+ notify(notification: AppNotificationRequest): void;
73
+ /**
74
+ * Says on the row the action runs from what it is doing or what stopped it,
75
+ * or clears that with null. A success the row's own description and label
76
+ * show once they change needs no note. False once the row is off screen
77
+ * (the dialog closed, or the action removed its own field): say it with
78
+ * `notify` then, as a row that has left a list is a toast. Older hosts do
79
+ * not pass it.
80
+ */
81
+ setRowNote?(note: PaneSettingRowNote | null): boolean;
82
+ }
83
+
84
+ export type PaneSettingActionHandler = (
85
+ context: PaneSettingActionContext,
86
+ ) => void | Promise<void>;
87
+
88
+ export type PaneSettingActionField = Omit<PaneSettingFieldBase, "storage" | "clearOnChange"> & {
89
+ type: "action";
90
+ actionId: string;
91
+ actionLabel?: string;
92
+ disabled?: boolean;
93
+ action: PaneSettingActionHandler;
94
+ };
95
+
96
+ export type PaneSettingField =
97
+ | PaneSettingToggleField
98
+ | PaneSettingTextField
99
+ | PaneSettingSelectField
100
+ | PaneSettingMultiSelectField
101
+ | PaneSettingOrderedMultiSelectField
102
+ | PaneSettingActionField;
103
+
104
+ export interface PaneSettingsDef {
105
+ title?: string;
106
+ values?: Record<string, unknown>;
107
+ fields: PaneSettingField[];
108
+ applyValue?: (
109
+ settings: Record<string, unknown>,
110
+ field: PaneSettingField,
111
+ value: unknown,
112
+ context: PaneSettingsContext,
113
+ ) => Record<string, unknown> | Promise<Record<string, unknown>>;
114
+ }
@@ -0,0 +1,160 @@
1
+ import type { AppConfig, LayoutConfig, PaneBinding, PaneInstanceConfig } from "./config";
2
+ import type { HeadlessPaneDefinition, HeadlessPaneFreshness } from "./headless";
3
+ import type { BrokerContractRef, InstrumentSearchResult, TickerListingRef } from "./instrument";
4
+ import type { WizardStep } from "./plugin-shared";
5
+ import type { TickerRecord } from "./ticker";
6
+
7
+ export interface PaneTemplateContext {
8
+ config: AppConfig;
9
+ layout: LayoutConfig;
10
+ focusedPaneId: string | null;
11
+ activeTicker: string | null;
12
+ activeInstrument?: BrokerContractRef | null;
13
+ activeListing?: TickerListingRef;
14
+ activeCollectionId: string | null;
15
+ }
16
+
17
+ /** One value a shortcut argument accepts: `value` is typed after the prefix, `label` says what it is. */
18
+ export interface ShortcutArgOption {
19
+ value: string;
20
+ label: string;
21
+ }
22
+
23
+ /** Why a typed argument opens nothing: the row's text, and the line under it saying what to type instead. */
24
+ export interface ShortcutArgError {
25
+ message: string;
26
+ detail?: string;
27
+ }
28
+
29
+ interface PaneTemplateShortcut {
30
+ prefix: string;
31
+ /** Other mnemonics for the same view (FFIP for WIRP). They open it when typed but are not listed as separate rows. */
32
+ aliases?: readonly string[];
33
+ /** Keep this shortcut executable when typed, but omit its pane from command-bar browse rows. Defaults to true. */
34
+ showInBrowse?: boolean;
35
+ /**
36
+ * What the shortcut takes after the prefix. Left out, it takes the argument
37
+ * the template's `headless` definition declares, as `gloom catalog` lists it.
38
+ */
39
+ argPlaceholder?: string;
40
+ argKind?: "text" | "ticker" | "ticker-list";
41
+ /**
42
+ * For a ticker list, entries kept as typed instead of resolved as tickers:
43
+ * CORR keeps map series (`GEO:HORMUZ`) beside its tickers.
44
+ */
45
+ keepArgToken?: (token: string) => boolean;
46
+ argOptional?: boolean;
47
+ /**
48
+ * The argument is a company the function reports on (CDS, TRACE): with
49
+ * none typed, the command bar opens it on the ticker in focus, and with no
50
+ * ticker in focus market-wide. `<ticker> <code>` opens it too.
51
+ */
52
+ focusedIssuer?: boolean;
53
+ /**
54
+ * With no argument typed and none to infer from the active ticker, open
55
+ * the pane without one instead of asking for it (ERN alone is the market
56
+ * board). Without it an optional argument still falls back to the form.
57
+ */
58
+ openWithoutArg?: boolean;
59
+ /**
60
+ * Named values the argument accepts, for an argument mostly drawn from a
61
+ * small set (a statistic, a futures root). The command-bar assistant picks
62
+ * from it instead of guessing the text; the command may accept others too.
63
+ */
64
+ argOptions?: () => readonly ShortcutArgOption[];
65
+ /**
66
+ * Why a typed argument opens nothing, or null when it opens the view:
67
+ * `PF Nope` names no portfolio or watchlist. The command bar shows it in
68
+ * place of the function's row, and the pane does not open for it.
69
+ */
70
+ argError?: (arg: string, context: PaneTemplateContext) => ShortcutArgError | null;
71
+ }
72
+
73
+ export interface PaneTemplateCreateOptions {
74
+ arg?: string;
75
+ values?: Record<string, string>;
76
+ symbol?: string | null;
77
+ symbols?: string[] | null;
78
+ ticker?: TickerRecord | null;
79
+ searchResult?: InstrumentSearchResult | null;
80
+ instrument?: BrokerContractRef | null;
81
+ listing?: TickerListingRef;
82
+ /** Template-owned, validated data restored from a public pane share. */
83
+ shareData?: unknown;
84
+ }
85
+
86
+ export interface PaneTemplateInstanceConfig {
87
+ instanceId?: string;
88
+ title?: string;
89
+ binding?: PaneBinding;
90
+ params?: Record<string, string>;
91
+ settings?: Record<string, unknown>;
92
+ placement?: "default" | "docked" | "floating";
93
+ relativeToPaneId?: string;
94
+ relativePosition?: "left" | "right" | "above" | "below";
95
+ }
96
+
97
+ export interface PaneTemplatePublicShareContext {
98
+ pane: PaneInstanceConfig;
99
+ paneState: Record<string, unknown>;
100
+ }
101
+
102
+ export interface PaneTemplatePublicShareSnapshot {
103
+ title: string;
104
+ description?: string;
105
+ data: Record<string, unknown>;
106
+ }
107
+
108
+ export interface PaneTemplatePublicShareDef {
109
+ serialize(context: PaneTemplatePublicShareContext): PaneTemplatePublicShareSnapshot | null;
110
+ restore(data: Record<string, unknown>): PaneTemplateCreateOptions | null;
111
+ }
112
+
113
+ export interface PaneTemplateDef {
114
+ id: string;
115
+ paneId: string;
116
+ label: string;
117
+ description: string;
118
+ keywords?: string[];
119
+ shortcut?: PaneTemplateShortcut;
120
+ /**
121
+ * False leaves the function out of every list and search of functions
122
+ * (command-bar browse, search and assistant, Help, `gloom catalog` and
123
+ * search, the plugin directory, chat suggestions) while typing its code
124
+ * still opens it, `fn` and `shot` still run it and its help still answers.
125
+ * ATTN until it publishes (attention/listing.ts).
126
+ */
127
+ listed?: boolean;
128
+ /** Template-specific headless model. Takes precedence over the pane-level model. */
129
+ headless?: HeadlessPaneDefinition;
130
+ /**
131
+ * A one-ticker template whose pane also opens on several at once (DVD's
132
+ * ranking): `fn` and `shot` pass a typed list (`shot DVD KO JNJ`) to
133
+ * createInstance as `symbols`. Any other one-ticker template gets the list
134
+ * as it always has, in `symbol` and `arg`.
135
+ */
136
+ opensTickerList?: boolean;
137
+ /**
138
+ * Source and status of the view this template opens, for a template that
139
+ * opens one view of a pane hosting several (Fixed Income's Issuer Debt).
140
+ * Captures and rendered-view reports merge it over the pane's own
141
+ * `reportFreshness`: each field set here wins, the rest are the pane's. So
142
+ * they date the filings on screen, not the issuer's stock quote.
143
+ */
144
+ reportFreshness?: Pick<HeadlessPaneFreshness, "source" | "status" | "basis" | "local">;
145
+ wizard?: WizardStep[];
146
+ canCreate?: (context: PaneTemplateContext, options?: PaneTemplateCreateOptions) => boolean;
147
+ /**
148
+ * Settings shown by catalog discovery without running createInstance. Supply
149
+ * these when opening a pane needs live data or has side effects. An empty
150
+ * object means there are no settings to describe before the pane is opened.
151
+ * When omitted, discovery derives settings from createInstance as before.
152
+ */
153
+ catalogSettings?: Record<string, unknown>;
154
+ createInstance?: (
155
+ context: PaneTemplateContext,
156
+ options?: PaneTemplateCreateOptions,
157
+ ) => PaneTemplateInstanceConfig | null | Promise<PaneTemplateInstanceConfig | null>;
158
+ /** Legacy v1 restoration or an explicit transformed snapshot; normal pane shares use portableShare. */
159
+ publicShare?: PaneTemplatePublicShareDef;
160
+ }