gloomberb 0.20.18 → 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 (204) hide show
  1. package/package.json +1 -1
  2. package/src/api-client/cot.ts +5 -6
  3. package/src/api-client/data.ts +11 -1
  4. package/src/api-client/index.ts +1 -0
  5. package/src/api-client/request.ts +162 -40
  6. package/src/api-client/types/news.ts +45 -0
  7. package/src/api-client/types/world-venues.ts +9 -0
  8. package/src/app.tsx +4 -2
  9. package/src/architecture/floating-promise-allowlist.json +1 -1
  10. package/src/cli/commands/market.ts +53 -17
  11. package/src/cli/commands/ticker.ts +13 -6
  12. package/src/cli/context.ts +8 -0
  13. package/src/cli/desktop-pane-shot-browser.ts +3 -1
  14. package/src/cli/desktop-pane-shot-view.ts +0 -1
  15. package/src/cli/desktop-pane-shot.ts +204 -43
  16. package/src/cli/errors.ts +3 -9
  17. package/src/cli/exit-codes.ts +1 -1
  18. package/src/cli/glossary.ts +1 -1
  19. package/src/cli/help.ts +1 -1
  20. package/src/cli/history-rows.ts +2 -2
  21. package/src/cli/index.ts +1 -1
  22. package/src/cli/listing-arg.ts +87 -23
  23. package/src/cli/pane-functions/catalog-snapshot.json +17 -6
  24. package/src/cli/pane-functions/dom.ts +30 -2
  25. package/src/cli/pane-functions/freshness.ts +23 -4
  26. package/src/cli/pane-functions/function-help.ts +3 -3
  27. package/src/cli/pane-functions/headless.ts +9 -1
  28. package/src/cli/pane-functions/index.ts +77 -10
  29. package/src/cli/pane-functions/report-notices.ts +10 -0
  30. package/src/cli/pane-functions/resolver.ts +3 -2
  31. package/src/cli/pane-functions/screenshot-assessment.ts +10 -5
  32. package/src/cli/pane-functions/screenshot-data-evidence.ts +7 -15
  33. package/src/cli/pane-functions/screenshot-payload.ts +24 -10
  34. package/src/cli/pane-functions/screenshot-render.ts +21 -8
  35. package/src/cli/pane-functions/screenshot-types.ts +9 -0
  36. package/src/cli/quote-answer.ts +1 -1
  37. package/src/cli/result.ts +17 -0
  38. package/src/cli/scroll-truncation.ts +7 -2
  39. package/src/cli/ticker-resolution.ts +1 -1
  40. package/src/cli/unreachable.ts +21 -0
  41. package/src/components/chart/composite/drawing-store.ts +11 -7
  42. package/src/components/chart/composite/format.ts +1 -0
  43. package/src/components/chart/composite/legend.tsx +5 -2
  44. package/src/components/chart/composite/panel-surface/plot-gestures.ts +9 -2
  45. package/src/components/chart/composite/panel-surface.tsx +1 -1
  46. package/src/components/chart/composite/tools.ts +164 -39
  47. package/src/components/chart-table/header.tsx +2 -2
  48. package/src/components/chart-table/layout.ts +5 -6
  49. package/src/components/command-bar/routes/root/runtime.ts +11 -3
  50. package/src/components/command-bar/routes/ticker-search/results.ts +5 -0
  51. package/src/components/command-bar/selection-runtime.ts +29 -5
  52. package/src/components/command-bar/surface/index.tsx +4 -1
  53. package/src/components/command-bar/workflow/alert.ts +13 -5
  54. package/src/components/layout/pane/footer/model.ts +10 -2
  55. package/src/components/layout/pane/status-footer.ts +24 -0
  56. package/src/components/price-performance.tsx +26 -8
  57. package/src/components/reader/article-reader.tsx +12 -5
  58. package/src/components/ui/data-table/opentui/index.tsx +7 -0
  59. package/src/components/ui/table-layout.ts +32 -1
  60. package/src/market-data/ah-pair.ts +19 -0
  61. package/src/market-data/coordinator/entries.ts +6 -4
  62. package/src/market-data/coordinator/index.ts +14 -3
  63. package/src/market-data/futures-board.ts +36 -29
  64. package/src/market-data/futures-contract.ts +37 -1
  65. package/src/market-data/market/change-basis.ts +9 -0
  66. package/src/market-data/market/status.ts +40 -4
  67. package/src/market-data/performance.ts +127 -32
  68. package/src/market-data/quotes/time.ts +5 -2
  69. package/src/news/types.ts +28 -0
  70. package/src/notifications/app-badge.ts +2 -3
  71. package/src/notifications/app-notifier.ts +5 -0
  72. package/src/plugins/builtin/alerts/cli.ts +65 -18
  73. package/src/plugins/builtin/alerts/command.ts +39 -9
  74. package/src/plugins/builtin/alerts/event-rows.ts +9 -3
  75. package/src/plugins/builtin/alerts/events-pane.tsx +16 -10
  76. package/src/plugins/builtin/alerts/headless.ts +12 -6
  77. package/src/plugins/builtin/alerts/index.tsx +60 -8
  78. package/src/plugins/builtin/alerts/option-contract.ts +197 -0
  79. package/src/plugins/builtin/alerts/price.ts +30 -5
  80. package/src/plugins/builtin/alerts/pro-rules.ts +62 -0
  81. package/src/plugins/builtin/alerts/research-builder.ts +5 -10
  82. package/src/plugins/builtin/analytics/account-returns.ts +1 -1
  83. package/src/plugins/builtin/analytics/pane-model.ts +2 -2
  84. package/src/plugins/builtin/analytics/risk-client.ts +1 -1
  85. package/src/plugins/builtin/buildout/company/pane.tsx +4 -14
  86. package/src/plugins/builtin/catalysts/model.ts +2 -1
  87. package/src/plugins/builtin/chart-composer/chart-spec.ts +5 -0
  88. package/src/plugins/builtin/chart-composer/cli-options.ts +5 -3
  89. package/src/plugins/builtin/chart-composer/headless-schema.ts +14 -10
  90. package/src/plugins/builtin/chart-composer/headless.ts +2 -0
  91. package/src/plugins/builtin/chart-composer/index.tsx +17 -5
  92. package/src/plugins/builtin/chart-composer/pane.tsx +14 -4
  93. package/src/plugins/builtin/chart-composer/viewport-labels.ts +2 -17
  94. package/src/plugins/builtin/chat/controller/notifications.ts +1 -0
  95. package/src/plugins/builtin/chat/index.tsx +0 -1
  96. package/src/plugins/builtin/commodities-energy/index.tsx +1 -1
  97. package/src/plugins/builtin/company-kpis/headless.ts +1 -1
  98. package/src/plugins/builtin/company-kpis/model.ts +21 -9
  99. package/src/plugins/builtin/congress-trades/model.ts +9 -5
  100. package/src/plugins/builtin/cot/client.ts +2 -3
  101. package/src/plugins/builtin/cot/headless.ts +16 -16
  102. package/src/plugins/builtin/cot/index.tsx +6 -6
  103. package/src/plugins/builtin/cot/model.ts +25 -5
  104. package/src/plugins/builtin/cot/pane.tsx +11 -6
  105. package/src/plugins/builtin/cot/series.ts +11 -8
  106. package/src/plugins/builtin/cpi/model.ts +15 -4
  107. package/src/plugins/builtin/cpi/pane.tsx +29 -7
  108. package/src/plugins/builtin/doe/model.ts +30 -0
  109. package/src/plugins/builtin/doe/pane.tsx +8 -2
  110. package/src/plugins/builtin/earnings/board-table.ts +9 -4
  111. package/src/plugins/builtin/earnings/headless.ts +10 -3
  112. package/src/plugins/builtin/earnings/history-table.ts +4 -2
  113. package/src/plugins/builtin/earnings-calls/calendar.tsx +4 -3
  114. package/src/plugins/builtin/earnings-ripple/pane.tsx +2 -2
  115. package/src/plugins/builtin/econ/index.tsx +4 -2
  116. package/src/plugins/builtin/futures/model.ts +14 -1
  117. package/src/plugins/builtin/futures/series.ts +1 -8
  118. package/src/plugins/builtin/fx-matrix/index.tsx +2 -2
  119. package/src/plugins/builtin/insider/detail.tsx +36 -7
  120. package/src/plugins/builtin/insider/filing-stories.ts +110 -0
  121. package/src/plugins/builtin/insider/headless.ts +37 -2
  122. package/src/plugins/builtin/insider/index.tsx +79 -10
  123. package/src/plugins/builtin/insider/model.ts +43 -5
  124. package/src/plugins/builtin/ipo-calendar/client.ts +11 -1
  125. package/src/plugins/builtin/ipo-calendar/model.ts +3 -7
  126. package/src/plugins/builtin/jobs/headless.ts +2 -1
  127. package/src/plugins/builtin/jobs/model.ts +6 -0
  128. package/src/plugins/builtin/jobs/pane.tsx +8 -3
  129. package/src/plugins/builtin/news/wire/news/detail-view.tsx +118 -10
  130. package/src/plugins/builtin/news/wire/news/story-evidence.ts +178 -0
  131. package/src/plugins/builtin/options/analytics.ts +1 -1
  132. package/src/plugins/builtin/options/view.tsx +18 -11
  133. package/src/plugins/builtin/options-positioning/model.ts +11 -0
  134. package/src/plugins/builtin/options-positioning/pane.tsx +22 -1
  135. package/src/plugins/builtin/options-scenario/client.ts +49 -8
  136. package/src/plugins/builtin/options-scenario/headless.ts +7 -3
  137. package/src/plugins/builtin/options-scenario/model.ts +33 -2
  138. package/src/plugins/builtin/options-scenario/pane.tsx +3 -4
  139. package/src/plugins/builtin/perps/cascade.ts +4 -3
  140. package/src/plugins/builtin/perps/markets-section.tsx +5 -2
  141. package/src/plugins/builtin/perps/model.ts +4 -3
  142. package/src/plugins/builtin/portfolio-list/table.tsx +3 -2
  143. package/src/plugins/builtin/research/corporate-actions-pane.tsx +29 -14
  144. package/src/plugins/builtin/research/event-model.ts +12 -6
  145. package/src/plugins/builtin/research-search/index.tsx +3 -1
  146. package/src/plugins/builtin/scanner/denied.tsx +16 -4
  147. package/src/plugins/builtin/scanner/flow-pane.tsx +1 -1
  148. package/src/plugins/builtin/scanner/hilo-pane.tsx +1 -1
  149. package/src/plugins/builtin/sec/filing-display.tsx +14 -2
  150. package/src/plugins/builtin/sec/headless.ts +42 -4
  151. package/src/plugins/builtin/sec/index.tsx +21 -1
  152. package/src/plugins/builtin/sectors/sector-model.ts +1 -1
  153. package/src/plugins/builtin/shared/earnings-report.ts +32 -3
  154. package/src/plugins/builtin/shared/options-pro-copy.ts +34 -0
  155. package/src/plugins/builtin/shared/statement-currency.ts +23 -0
  156. package/src/plugins/builtin/shared/ticker-surface.ts +1 -1
  157. package/src/plugins/builtin/supply-chain/pane.tsx +4 -3
  158. package/src/plugins/builtin/themes/headless.ts +4 -4
  159. package/src/plugins/builtin/themes/model.ts +11 -8
  160. package/src/plugins/builtin/themes/pane.tsx +2 -2
  161. package/src/plugins/builtin/ticker-detail/financials/model.ts +22 -32
  162. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +7 -9
  163. package/src/plugins/builtin/ticker-detail/headless-schema.ts +2 -0
  164. package/src/plugins/builtin/ticker-detail/headless.ts +28 -12
  165. package/src/plugins/builtin/ticker-detail/overview/board-lot.ts +21 -0
  166. package/src/plugins/builtin/ticker-detail/overview/model.ts +11 -1
  167. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -0
  168. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +61 -13
  169. package/src/plugins/builtin/volatility/pane.tsx +3 -3
  170. package/src/plugins/builtin/world-venue-map/headless.ts +4 -2
  171. package/src/plugins/builtin/world-venue-map/model.ts +6 -1
  172. package/src/plugins/builtin/world-venue-map/venue-header.tsx +5 -3
  173. package/src/plugins/catalog-browser.ts +10 -1
  174. package/src/renderers/browser/activity.ts +16 -0
  175. package/src/renderers/browser/app-badge-host.ts +14 -0
  176. package/src/renderers/browser/main.tsx +5 -0
  177. package/src/renderers/browser/notifications.ts +103 -0
  178. package/src/renderers/browser/ui-host.tsx +4 -0
  179. package/src/renderers/dom/data-table/index.tsx +27 -4
  180. package/src/renderers/electrobun/view/http-fetch.ts +3 -2
  181. package/src/sources/gloomberb-cloud/index.ts +8 -6
  182. package/src/sources/gloomberb-cloud/news.ts +35 -0
  183. package/src/sources/provider-errors.ts +34 -7
  184. package/src/sources/provider-router/history.ts +32 -6
  185. package/src/time-series/base-series.ts +39 -6
  186. package/src/time-series/chart-seed.ts +2 -2
  187. package/src/time-series/history-quality.ts +4 -1
  188. package/src/time-series/hooks.ts +2 -0
  189. package/src/time-series/price-comparison.ts +17 -23
  190. package/src/time-series/reporting.ts +1 -1
  191. package/src/time-series/resolution.ts +13 -0
  192. package/src/time-series/resolve-context.ts +6 -0
  193. package/src/time-series/resolve.ts +39 -2
  194. package/src/time-series/types.ts +2 -1
  195. package/src/types/financials.ts +9 -1
  196. package/src/types/headless.ts +1 -0
  197. package/src/types/issuer-listings.ts +2 -0
  198. package/src/types/plugin-notifications.ts +3 -0
  199. package/src/types/price-history.ts +6 -4
  200. package/src/ui/host.tsx +2 -0
  201. package/src/utils/exchange-announcements.ts +7 -2
  202. package/src/utils/fundamentals.ts +40 -0
  203. package/src/utils/network-failure.ts +2 -0
  204. package/src/utils/price-history-integrity.ts +9 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gloomberb",
3
- "version": "0.20.18",
3
+ "version": "0.20.19",
4
4
  "packageManager": "bun@1.3.14",
5
5
  "description": "Market research and portfolio tracker for the terminal",
6
6
  "module": "src/public/index.ts",
@@ -1,4 +1,4 @@
1
- /** The CFTC report: Legacy, Disaggregated, or Traders in Financial Futures (TFF). */
1
+ /** Legacy, Disaggregated (CFTC and ICE Europe), or Traders in Financial Futures (TFF). */
2
2
  export type CotFamily = "legacy" | "disaggregated" | "tff"
3
3
  export type CotClass = "noncommercial" | "commercial" | "producer" | "swap" | "managed-money" | "other-reportable" | "nonreportable"
4
4
  | "dealer" | "asset-manager" | "leveraged-funds"
@@ -39,7 +39,7 @@ interface CotMarket {
39
39
  contractUnits?: string | null
40
40
  }
41
41
  export interface CotPayloadBase {
42
- source: "CFTC"
42
+ source: "CFTC" | "ICE Futures Europe" | "CFTC / ICE Futures Europe"
43
43
  scope: CotPositions
44
44
  reportFamily: CotFamily
45
45
  generatedAt: string
@@ -48,9 +48,8 @@ export interface CotPayloadBase {
48
48
  /** Latest report's actual source download time, not its publication time. */
49
49
  fetchedAt: string | null
50
50
  /**
51
- * The latest report's scheduled release by the CFTC's calendar (3:30 p.m.
52
- * New York on the Friday after its Tuesday, a business day later around a
53
- * federal holiday); null from an older server, which did not say.
51
+ * The publisher's scheduled release. ICE Europe normally publishes Friday
52
+ * at 18:30 London time; CFTC uses its own calendar. Null where unverified.
54
53
  */
55
54
  publishedAt: string | null
56
55
  status: "available" | "partial" | "unavailable"
@@ -71,7 +70,7 @@ export interface CotBoardPayload extends CotPayloadBase {
71
70
  export interface CotHistoryPoint {
72
71
  reportDate: string
73
72
  /** The report's scheduled release; absent from an older server. */
74
- publishedAt?: string
73
+ publishedAt?: string | null
75
74
  openInterest: number | null
76
75
  positions: Array<CotPosition & { id: CotClass; net: number | null; netPercentOfOpenInterest: number | null }>
77
76
  }
@@ -166,6 +166,7 @@ import type {
166
166
  CloudMarketScreenerCategory,
167
167
  CloudMarketScreenerPayload,
168
168
  CloudMoverSession,
169
+ CloudInsiderFilingStoriesResponse,
169
170
  CloudNewsListResponse,
170
171
  CloudNewsPayload,
171
172
  CloudSavedSearch,
@@ -933,15 +934,17 @@ export class CloudDataApi {
933
934
  return this.request<CloudShillerPayload>(cloudShillerPath());
934
935
  }
935
936
 
936
- /** Futures-only positions unless `positions` asks for futures and options combined; the default request is unchanged. */
937
+ /** Futures-only positions unless `positions` asks for futures and options combined. */
937
938
  async getCloudCotBoard(report: CotFamily, traderClass: CotClass, positions: CotPositions = "futures-only"): Promise<CotBoardPayload> {
938
939
  const query = new URLSearchParams({ report, traderClass, ...(positions === "combined" ? { scope: positions } : {}) });
940
+ if (report === "disaggregated") query.set("includeIce", "true");
939
941
  return this.request<CotBoardPayload>(`/cloud/cot/board?${query}`);
940
942
  }
941
943
 
942
944
  /** A market's report; `since` (YYYY-MM-DD) lists its history from that day instead of the last three years. */
943
945
  async getCloudCotContract(code: string, report: CotFamily, positions: CotPositions = "futures-only", since?: string): Promise<CotContractPayload> {
944
946
  const query = new URLSearchParams({ report, ...(positions === "combined" ? { scope: positions } : {}), ...(since ? { since } : {}) });
947
+ if (report === "disaggregated") query.set("includeIce", "true");
945
948
  return this.request<CotContractPayload>(`/cloud/cot/contracts/${encodeURIComponent(code)}?${query}`);
946
949
  }
947
950
 
@@ -1723,6 +1726,13 @@ export class CloudDataApi {
1723
1726
  );
1724
1727
  }
1725
1728
 
1729
+ /** The stories that report each Form 4, by accession number: the match a story's own filings come from, run the other way. */
1730
+ async getCloudInsiderFilingStories(accessions: readonly string[]): Promise<CloudInsiderFilingStoriesResponse> {
1731
+ return this.request<CloudInsiderFilingStoriesResponse>(
1732
+ `/news/insider-filing-stories?${new URLSearchParams({ accessions: accessions.join(",") })}`,
1733
+ );
1734
+ }
1735
+
1726
1736
  async getCloudTickerTweets(
1727
1737
  params: CloudTickerTweetsParams,
1728
1738
  ): Promise<CloudTweetSearchResponse> {
@@ -1266,6 +1266,7 @@ class GloomApiClient {
1266
1266
  getCloudNews = this.data.getCloudNews.bind(this.data);
1267
1267
  searchCloudNews = this.data.searchCloudNews.bind(this.data);
1268
1268
  getCloudNewsStory = this.data.getCloudNewsStory.bind(this.data);
1269
+ getCloudInsiderFilingStories = this.data.getCloudInsiderFilingStories.bind(this.data);
1269
1270
  getCloudTickerTweets = this.data.getCloudTickerTweets.bind(this.data);
1270
1271
  searchCloudTweets = this.data.searchCloudTweets.bind(this.data);
1271
1272
  }
@@ -30,11 +30,11 @@ export const DEFAULT_API_URL = "https://api.gloom.sh";
30
30
  * fails as the data service being unreachable, as a refused one does.
31
31
  */
32
32
  export const MARKET_REQUEST_TIMEOUT_MS = 10_000;
33
- const DEFAULT_MARKET_REQUEST_TIMEOUT_MS = MARKET_REQUEST_TIMEOUT_MS;
33
+ const DEFAULT_MARKET_READ_LIMIT_MS = 25_000;
34
34
  /**
35
35
  * A search, which a command and a keystroke wait on, gives up on a connection
36
36
  * that sends nothing back sooner. A slow search on a service that answers
37
- * (some take five seconds) still gets the full market deadline.
37
+ * (some take five seconds) still gets the full market read limit.
38
38
  */
39
39
  const SEARCH_ANSWER_TIMEOUT_MS = 4_000;
40
40
  /**
@@ -42,7 +42,7 @@ const SEARCH_ANSWER_TIMEOUT_MS = 4_000;
42
42
  * until any answer comes back: a hung connection is not waited out in full by
43
43
  * every request a command or a pane makes after it.
44
44
  */
45
- const UNREACHABLE_REQUEST_TIMEOUT_MS = 3_000;
45
+ export const UNREACHABLE_REQUEST_TIMEOUT_MS = 3_000;
46
46
  /**
47
47
  * Right after a request hung with nothing back, the requests that follow it
48
48
  * (a fallback, the next step of a command) fail at once rather than each
@@ -54,10 +54,9 @@ const DEFAULT_RESEARCH_REQUEST_TIMEOUT_MS = 45_000;
54
54
  const DEFAULT_SERVICE_REQUEST_LIMIT_MS = 120_000;
55
55
  const UPLOAD_REQUEST_LIMIT_MS = 300_000;
56
56
  /**
57
- * How long the check that the service answers at all waits. It runs this long
58
- * before a request's answer deadline, unless something answered meanwhile, so
59
- * one slow request on a service that answers is waited for and a dead
60
- * connection is not.
57
+ * How long each check that the service answers at all waits. When the answer
58
+ * deadline has room for two checks, one stuck connection isn't enough to
59
+ * declare an outage.
61
60
  */
62
61
  const SERVICE_PROBE_TIMEOUT_MS = 3_000;
63
62
  const SERVICE_PROBE_PATH = "/health";
@@ -75,6 +74,10 @@ const RESEARCH_MARKET_PATHS = new Set([
75
74
  "/market/heatmap", "/market/earnings-calendar", "/market/search/batch",
76
75
  ]);
77
76
 
77
+ export function marketReadLimitMs(pathname: string): number {
78
+ return RESEARCH_MARKET_PATHS.has(pathname) ? DEFAULT_RESEARCH_REQUEST_TIMEOUT_MS : DEFAULT_MARKET_READ_LIMIT_MS;
79
+ }
80
+
78
81
  /**
79
82
  * A read cut off by a server restart is sent once more after a pause in this
80
83
  * range (`sendAgainIfCutOff`): the next connection reaches a server that
@@ -93,6 +96,112 @@ function isRepeatableRead(method: string, path: string): boolean {
93
96
  return method === "GET" || method === "HEAD" || (method === "POST" && path.startsWith("/market/"));
94
97
  }
95
98
 
99
+ /**
100
+ * Set by the local relay a CLI capture's page reads the data service through
101
+ * (`gloom fn`, `gloom shot`) on its answer for a read it could not get to the
102
+ * service at all: the page reads it as the service being unreachable.
103
+ */
104
+ export const SHOT_SERVICE_UNREACHABLE_HEADER = "X-Gloom-Service-Unreachable";
105
+
106
+ /** What the last request to the data service in this process came to: answered, or not reached at all. */
107
+ let lastServiceReach: "answered" | "unreachable" | null = null;
108
+ /** Counts the commands that forgot the state: a request sent before one began says nothing of it. */
109
+ let reachEpoch = 0;
110
+
111
+ /** The current command's count (forgetDataServiceReach), which a request takes when it is sent. */
112
+ export function dataServiceReachEpoch(): number {
113
+ return reachEpoch;
114
+ }
115
+
116
+ /**
117
+ * Whether the data service was unreachable when this process last asked it:
118
+ * a request went unanswered (no connection, a refused proxy, a hung one) and
119
+ * nothing has answered since. A command whose output came out empty then says
120
+ * so, rather than that there is no data (`gloom fn`).
121
+ */
122
+ export function dataServiceUnreachable(): boolean {
123
+ return lastServiceReach === "unreachable";
124
+ }
125
+
126
+ /**
127
+ * Records what a request came to: answered, or not reached. `epoch` is the
128
+ * count it was sent under (dataServiceReachEpoch): one sent before the
129
+ * current command began, still out when it did, records nothing.
130
+ */
131
+ export function noteDataServiceReach(answered: boolean, epoch = reachEpoch): void {
132
+ if (answered) serviceAnswers += 1;
133
+ if (epoch !== reachEpoch) return;
134
+ lastServiceReach = answered ? "answered" : "unreachable";
135
+ }
136
+
137
+ /** How many answers the data service gave this process, whichever command asked. */
138
+ let serviceAnswers = 0;
139
+
140
+ /**
141
+ * The count of the data service's answers (`noteDataServiceReach`): a read
142
+ * with nothing back while the count moved is slow, not cut off, as the
143
+ * client's own deadlines read it.
144
+ */
145
+ export function dataServiceAnswerCount(): number {
146
+ return serviceAnswers;
147
+ }
148
+
149
+ /** Forgets what the last request came to, so a command reads only its own (`gloom fn` and `shot` start with it). */
150
+ export function forgetDataServiceReach(): void {
151
+ lastServiceReach = null;
152
+ reachEpoch += 1;
153
+ }
154
+
155
+ /** The statuses a proxy answers with when it will not, or cannot, reach the server for a request. */
156
+ const PROXY_REFUSAL_STATUSES = new Set([407, 502, 503, 504]);
157
+
158
+ /** The variables a proxy is read from: the process's, or a test's own. */
159
+ type ProxyEnvironment = Readonly<Record<string, string | undefined>>;
160
+
161
+ function processEnvironment(): ProxyEnvironment | null {
162
+ return typeof process === "undefined" ? null : process.env;
163
+ }
164
+
165
+ /** The proxy the runtime sends a request for `url` through, from the environment as Bun reads it; null for none. */
166
+ function environmentProxy(url: string, env: ProxyEnvironment | null): string | null {
167
+ if (!env) return null;
168
+ let target: URL;
169
+ try {
170
+ target = new URL(url);
171
+ } catch {
172
+ // Intentional ignore: a URL that does not parse is sent through no proxy the environment names.
173
+ return null;
174
+ }
175
+ const names = target.protocol === "https:" ? ["HTTPS_PROXY", "https_proxy"] : ["HTTP_PROXY", "http_proxy"];
176
+ const proxy = [...names, "ALL_PROXY", "all_proxy"].map((name) => env[name]?.trim()).find(Boolean);
177
+ if (!proxy) return null;
178
+ const bypass = (env.NO_PROXY ?? env.no_proxy ?? "").split(",").map((entry) => entry.trim().toLowerCase()).filter(Boolean);
179
+ const host = target.hostname.toLowerCase();
180
+ return bypass.some((entry) => entry === "*" || host === entry.replace(/^\./, "") || host.endsWith(entry.startsWith(".") ? entry : `.${entry}`))
181
+ ? null : proxy;
182
+ }
183
+
184
+ /**
185
+ * Whether an answer is a proxy's own, not the service's: what Bun 1.3 hands
186
+ * back when the proxy in HTTPS_PROXY refuses to open a tunnel (a 502 with
187
+ * "Bad Gateway" from the proxy; later Bun throws ERR_PROXY_TUNNEL instead).
188
+ * The data service was never reached, so it reads as unreachable, never as
189
+ * the service being busy ("Search is busy"). Told by a proxy being set for the
190
+ * URL, a status a proxy refuses with, and a body that is not the JSON every
191
+ * answer of the service carries.
192
+ */
193
+ export function isProxyRefusal(
194
+ url: string,
195
+ response: Pick<Response, "status" | "headers">,
196
+ env: ProxyEnvironment | null = processEnvironment(),
197
+ ): boolean {
198
+ if (!PROXY_REFUSAL_STATUSES.has(response.status)) return false;
199
+ // A capture's relay that could not reach the service either.
200
+ if (response.headers.get(SHOT_SERVICE_UNREACHABLE_HEADER) === "1") return true;
201
+ if (!environmentProxy(url, env)) return false;
202
+ return !/\bjson\b/i.test(response.headers.get("Content-Type") ?? "");
203
+ }
204
+
96
205
  /** Waits `ms`, or rejects with the signal's reason once it aborts. */
97
206
  function pause(ms: number, signal: AbortSignal | null | undefined): Promise<void> {
98
207
  return new Promise((resolve, reject) => {
@@ -116,8 +225,6 @@ function pause(ms: number, signal: AbortSignal | null | undefined): Promise<void
116
225
  interface RequestDeadline {
117
226
  answerMs: number;
118
227
  limitMs: number;
119
- /** When to check that the service answers at all, if nothing has by then; null when the deadline is too short for it. */
120
- probeAtMs: number | null;
121
228
  }
122
229
  /** Local status for "this runtime cannot stream", never returned by the server. */
123
230
  export const STREAMING_UNSUPPORTED_STATUS = 0;
@@ -376,8 +483,9 @@ export class CloudApiRequestTransport {
376
483
  private websocketToken: string | null = null;
377
484
  private cookieSessionMode = false;
378
485
  private readonly fetchTransport: CloudApiFetchTransport | null;
486
+ private readonly proxyEnvironment: ProxyEnvironment | undefined;
379
487
  private readonly marketRequestTimeoutMs: number;
380
- private readonly researchRequestTimeoutMs: number;
488
+ private readonly marketReadLimitOverride?: number;
381
489
  private readonly connectionHealth: ConnectionHealthRegistry;
382
490
  /** Answers received from the service, by any request: a request that sees this grow knows the connection works. */
383
491
  private answers = 0;
@@ -389,7 +497,7 @@ export class CloudApiRequestTransport {
389
497
  private connectionGeneration = cloudApiTransportGeneration;
390
498
  /** Requests waiting under a deadline: the check that the service answers runs only while one is. */
391
499
  private pending = 0;
392
- private probe: AbortController | null = null;
500
+ private probe: { controller: AbortController; expiresAt: number } | null = null;
393
501
  /** The next check whether an unreachable service answers again, and how long after it the one after waits. */
394
502
  private recoveryTimer: ReturnType<typeof setTimeout> | null = null;
395
503
  private recoveryDelayMs = RECOVERY_PROBE_FIRST_MS;
@@ -408,12 +516,14 @@ export class CloudApiRequestTransport {
408
516
  fetchTransport?: CloudApiFetchTransport;
409
517
  marketRequestTimeoutMs?: number;
410
518
  connectionHealth?: ConnectionHealthRegistry;
519
+ /** The variables the proxy is read from (isProxyRefusal); the process's by default. */
520
+ proxyEnvironment?: ProxyEnvironment;
411
521
  } = {},
412
522
  ) {
413
523
  this.fetchTransport = options.fetchTransport ?? null;
414
- this.marketRequestTimeoutMs =
415
- options.marketRequestTimeoutMs ?? DEFAULT_MARKET_REQUEST_TIMEOUT_MS;
416
- this.researchRequestTimeoutMs = options.marketRequestTimeoutMs ?? DEFAULT_RESEARCH_REQUEST_TIMEOUT_MS;
524
+ this.proxyEnvironment = options.proxyEnvironment;
525
+ this.marketRequestTimeoutMs = options.marketRequestTimeoutMs ?? MARKET_REQUEST_TIMEOUT_MS;
526
+ this.marketReadLimitOverride = options.marketRequestTimeoutMs;
417
527
  this.connectionHealth = options.connectionHealth ?? connectionHealth;
418
528
  }
419
529
 
@@ -504,7 +614,7 @@ export class CloudApiRequestTransport {
504
614
  GLOOM_CLOUD_HTTP_CONNECTION_ID,
505
615
  operation,
506
616
  async () => {
507
- const response = await this.reachService(() => streamFetch(`${this.baseUrl}${path}`, {
617
+ const response = await this.reachService(`${this.baseUrl}${path}`, () => streamFetch(`${this.baseUrl}${path}`, {
508
618
  ...options,
509
619
  headers,
510
620
  credentials: "include",
@@ -533,20 +643,18 @@ export class CloudApiRequestTransport {
533
643
  }
534
644
 
535
645
  /**
536
- * Every request's deadline. A market read or a search waits about ten
537
- * seconds, research and requests outside market data longer. With nothing
538
- * back from the service, a request gives up at ten seconds, a search at
539
- * four, and any request at three after one went unanswered, until something
540
- * answers again. Three seconds before that, a request still unanswered
541
- * checks that the service answers at all, so one slow request on a working
542
- * connection is waited for and a dead connection is not.
646
+ * With nothing back from the service, a request gives up at ten seconds, a
647
+ * search at four, and any request at three once the service is unreachable.
648
+ * An unanswered request checks the service, twice if there's time. With an
649
+ * answer, a market read may take up to 25 seconds in all; research and
650
+ * requests outside market data get longer.
543
651
  */
544
652
  private deadlineFor(path: string, limitMs?: number): RequestDeadline {
545
653
  this.forgetOtherTransport();
546
654
  const pathname = path.split("?")[0]!;
547
655
  const market = pathname.startsWith("/market/");
548
656
  const limit = limitMs ?? (!market ? DEFAULT_SERVICE_REQUEST_LIMIT_MS
549
- : RESEARCH_MARKET_PATHS.has(pathname) ? this.researchRequestTimeoutMs : this.marketRequestTimeoutMs);
657
+ : this.marketReadLimitOverride ?? marketReadLimitMs(pathname));
550
658
  let answerMs = pathname === "/market/search"
551
659
  ? Math.min(this.marketRequestTimeoutMs, SEARCH_ANSWER_TIMEOUT_MS)
552
660
  : this.marketRequestTimeoutMs;
@@ -554,7 +662,6 @@ export class CloudApiRequestTransport {
554
662
  return {
555
663
  answerMs,
556
664
  limitMs: Math.max(limit, answerMs),
557
- probeAtMs: answerMs >= SERVICE_PROBE_TIMEOUT_MS ? answerMs - SERVICE_PROBE_TIMEOUT_MS : null,
558
665
  };
559
666
  }
560
667
 
@@ -582,6 +689,7 @@ export class CloudApiRequestTransport {
582
689
  const answersAtStart = this.answers;
583
690
  const answered = () => this.answers > answersAtStart;
584
691
  const generation = cloudApiTransportGeneration;
692
+ const epoch = reachEpoch;
585
693
  const what = path.startsWith("/market/") ? "Cloud market request" : "Cloud request";
586
694
  // The endpoint stays out of the message, which reports and panes print; the debug log's line names it.
587
695
  const endpoint = path.split("?")[0]!;
@@ -604,16 +712,17 @@ export class CloudApiRequestTransport {
604
712
  controller.abort(error);
605
713
  };
606
714
  work.then(resolve, reject);
607
- if (deadline.probeAtMs != null) {
715
+ for (const lead of [2 * SERVICE_PROBE_TIMEOUT_MS, SERVICE_PROBE_TIMEOUT_MS]) {
716
+ if (deadline.answerMs < lead) continue;
608
717
  timers.push(setTimeout(() => {
609
718
  if (!answered()) this.checkServiceAnswers();
610
- }, deadline.probeAtMs));
719
+ }, deadline.answerMs - lead));
611
720
  }
612
721
  timers.push(setTimeout(() => {
613
722
  // The caller gave up first: its abort settles the request, and says nothing of the connection.
614
723
  if (callerSignal?.aborted) return;
615
724
  if (!answered()) {
616
- if (!isBackgroundRequest(path)) this.recordNoAnswer(generation, true);
725
+ if (!isBackgroundRequest(path)) this.recordNoAnswer(generation, true, epoch);
617
726
  fail(new DataServiceUnreachableError(timedOut(deadline.answerMs)));
618
727
  } else if (deadline.limitMs > deadline.answerMs) {
619
728
  timers.push(setTimeout(() => fail(timedOut(deadline.limitMs)), deadline.limitMs - deadline.answerMs));
@@ -627,7 +736,7 @@ export class CloudApiRequestTransport {
627
736
  callerSignal?.removeEventListener("abort", abortFromCaller);
628
737
  this.pending -= 1;
629
738
  // Nothing waits on the check any more: it must not hold a command's process open.
630
- if (this.pending === 0) this.probe?.abort();
739
+ if (this.pending === 0) this.probe?.controller.abort();
631
740
  }
632
741
  }
633
742
 
@@ -639,23 +748,29 @@ export class CloudApiRequestTransport {
639
748
  * A caller's abort stays an abort. An answer of any status says the
640
749
  * connection works, for the deadlines of the requests beside it.
641
750
  */
642
- private async reachService<R>(
751
+ private async reachService<R extends Pick<Response, "status" | "headers">>(
752
+ url: string,
643
753
  fetch: () => Promise<R>,
644
754
  signal: AbortSignal | null | undefined,
645
755
  background = false,
646
756
  ): Promise<R> {
647
757
  const generation = cloudApiTransportGeneration;
758
+ const epoch = reachEpoch;
648
759
  let response: R;
649
760
  try {
650
761
  response = await fetch();
762
+ // The proxy's refusal to reach the service, which Bun 1.3 gives back as an answer, is none of the service's.
763
+ if (isProxyRefusal(url, response, this.proxyEnvironment ?? processEnvironment())) {
764
+ throw new DataServiceUnreachableError(new Error(`Proxy refused to open a tunnel: ${response.status}`));
765
+ }
651
766
  } catch (error) {
652
767
  if (signal?.aborted) throw error;
653
768
  const failure = asDataServiceFailure(error);
654
769
  // Background traffic that never got out says nothing of the service (`isBackgroundRequest`).
655
- if (failure instanceof DataServiceUnreachableError && !background) this.recordNoAnswer(generation, false);
770
+ if (failure instanceof DataServiceUnreachableError && !background) this.recordNoAnswer(generation, false, epoch);
656
771
  throw failure;
657
772
  }
658
- this.recordAnswer();
773
+ this.recordAnswer(epoch);
659
774
  return response;
660
775
  }
661
776
 
@@ -667,7 +782,8 @@ export class CloudApiRequestTransport {
667
782
  }
668
783
 
669
784
  /** Something came back from the service: the connection works. */
670
- private recordAnswer(): void {
785
+ private recordAnswer(epoch?: number): void {
786
+ noteDataServiceReach(true, epoch);
671
787
  this.answers += 1;
672
788
  this.markReachable();
673
789
  }
@@ -706,8 +822,9 @@ export class CloudApiRequestTransport {
706
822
  * refused, or `hung` with nothing back by its deadline. Once another
707
823
  * transport is installed, what one sent on the last says nothing of it.
708
824
  */
709
- private recordNoAnswer(generation: number, hung: boolean): void {
825
+ private recordNoAnswer(generation: number, hung: boolean, epoch?: number): void {
710
826
  if (!this.fetchTransport && generation !== cloudApiTransportGeneration) return;
827
+ noteDataServiceReach(false, epoch);
711
828
  if (hung) this.hungAt = Date.now();
712
829
  if (this.unreachable) {
713
830
  // A chain of checks stopped by `dispose` starts again.
@@ -746,8 +863,10 @@ export class CloudApiRequestTransport {
746
863
  this.recoveryProbe = controller;
747
864
  const giveUp = setTimeout(() => controller.abort(), SERVICE_PROBE_TIMEOUT_MS);
748
865
  (giveUp as { unref?: () => void }).unref?.();
749
- (this.fetchTransport ?? cloudApiFetchTransport)(`${this.baseUrl}${SERVICE_PROBE_PATH}`, { signal: controller.signal })
750
- .then(() => this.recordAnswer(), () => {
866
+ const url = `${this.baseUrl}${SERVICE_PROBE_PATH}`;
867
+ (this.fetchTransport ?? cloudApiFetchTransport)(url, { signal: controller.signal })
868
+ // A proxy that refuses to reach the service answers for it: still unreachable.
869
+ .then((response) => { if (!isProxyRefusal(url, response, this.proxyEnvironment ?? processEnvironment())) this.recordAnswer(); }, () => {
751
870
  // Intentional ignore: still unreachable; the next check is scheduled below.
752
871
  })
753
872
  .finally(() => {
@@ -777,18 +896,20 @@ export class CloudApiRequestTransport {
777
896
  * when nothing waits on it any more.
778
897
  */
779
898
  private checkServiceAnswers(): void {
780
- if (this.probe) return;
899
+ if (this.probe && this.probe.expiresAt > Date.now()) return;
900
+ this.probe?.controller.abort();
781
901
  const controller = new AbortController();
782
902
  const timer = setTimeout(() => controller.abort(), SERVICE_PROBE_TIMEOUT_MS);
783
903
  const done = () => {
784
904
  clearTimeout(timer);
785
- if (this.probe === controller) this.probe = null;
905
+ if (this.probe?.controller === controller) this.probe = null;
786
906
  };
787
907
  // Done once given up on, even through a transport that ignores the abort.
788
908
  controller.signal.addEventListener("abort", done, { once: true });
789
- this.probe = controller;
790
- (this.fetchTransport ?? cloudApiFetchTransport)(`${this.baseUrl}${SERVICE_PROBE_PATH}`, { signal: controller.signal })
791
- .then(() => this.recordAnswer(), () => {
909
+ this.probe = { controller, expiresAt: Date.now() + SERVICE_PROBE_TIMEOUT_MS };
910
+ const url = `${this.baseUrl}${SERVICE_PROBE_PATH}`;
911
+ (this.fetchTransport ?? cloudApiFetchTransport)(url, { signal: controller.signal })
912
+ .then((response) => { if (!isProxyRefusal(url, response, this.proxyEnvironment ?? processEnvironment())) this.recordAnswer(); }, () => {
792
913
  // Intentional ignore: an unanswered check only leaves the request it guards to its own deadline.
793
914
  })
794
915
  .finally(done);
@@ -872,6 +993,7 @@ export class CloudApiRequestTransport {
872
993
  });
873
994
  // Inside the reach check: a read that gets through on its second try was answered, not an outage.
874
995
  const response = await this.reachService(
996
+ url,
875
997
  () => (repeatable ? sendAgainIfCutOff(sendOnce, signal) : sendOnce()),
876
998
  signal,
877
999
  isBackgroundRequest(path),
@@ -36,6 +36,49 @@ export interface CloudNewsStoryItemPayload {
36
36
  hasArticleText?: boolean;
37
37
  }
38
38
 
39
+ /**
40
+ * A Form 4 a story about insiders trading reports, as Gloom Cloud matched it:
41
+ * the filing's lines of the side the story reports, by an insider it names,
42
+ * dated in the period it names, summed.
43
+ */
44
+ export interface CloudStoryInsiderFilingPayload {
45
+ accession: string;
46
+ form: string;
47
+ /** YYYY-MM-DD. */
48
+ filedOn: string;
49
+ issuerCik: string;
50
+ issuerName: string | null;
51
+ ticker: string | null;
52
+ /** The reporting owner as filed: "STEVENS MARK A". */
53
+ insider: string;
54
+ title: string | null;
55
+ side: "sale" | "purchase";
56
+ firstTradeDate: string;
57
+ lastTradeDate: string;
58
+ lines: number;
59
+ shares: number;
60
+ value: number;
61
+ /** value / shares: the share-weighted average of the lines' prices. */
62
+ weightedPrice: number;
63
+ /** Under a Rule 10b5-1 plan: true, false, or null when the stored filing does not say. */
64
+ rule10b51: boolean | null;
65
+ /** The filing's index page on SEC EDGAR. */
66
+ url: string;
67
+ }
68
+
69
+ /** A story that reports a Form 4, as the filing's row names it. */
70
+ export interface CloudInsiderFilingStoryPayload {
71
+ id: string;
72
+ headline: string;
73
+ firstPublishedAt: string;
74
+ lastPublishedAt: string;
75
+ primaryPublisher: string;
76
+ }
77
+
78
+ export interface CloudInsiderFilingStoriesResponse {
79
+ items: Array<{ accession: string; stories: CloudInsiderFilingStoryPayload[] }>;
80
+ }
81
+
39
82
  export interface CloudNewsPayload {
40
83
  id: string;
41
84
  headline: string;
@@ -74,6 +117,8 @@ export interface CloudNewsPayload {
74
117
  entities: CloudNewsEntityPayload[];
75
118
  tickerLinks: CloudNewsTickerLinkPayload[];
76
119
  items?: CloudNewsStoryItemPayload[];
120
+ /** A story about insiders trading: the Form 4s it reports. Absent from other stories and older servers. */
121
+ insiderFilings?: CloudStoryInsiderFilingPayload[];
77
122
  /**
78
123
  * The routine notices this story stands for in a company's feed, its own first: a buy-back's daily
79
124
  * "Transaction in own shares", the monthly total voting rights. Absent from servers that list each one.
@@ -8,12 +8,21 @@ export interface CloudWorldVenuePayload {
8
8
  timezone: string;
9
9
  latitude: number;
10
10
  longitude: number;
11
+ /** Whether the core session is trading. */
11
12
  isOpen: boolean;
13
+ /**
14
+ * The venue's state by its exchange's calendar: the core session `open`, the
15
+ * pre-market or after-hours session a US venue runs around it, `holiday` on a
16
+ * published full-day closure, else `closed`. Absent from an older service.
17
+ */
18
+ session?: WorldVenueSession;
12
19
  timeAfterOpenSeconds?: number;
13
20
  timeToOpenSeconds?: number;
14
21
  timeToCloseSeconds?: number;
15
22
  }
16
23
 
24
+ export type WorldVenueSession = "open" | "pre-market" | "after-hours" | "closed" | "holiday";
25
+
17
26
  export interface CloudWorldVenueMapPayload {
18
27
  providerId: "gloomberb-cloud";
19
28
  checkedAt: number;
package/src/app.tsx CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  useAppStateRef,
10
10
  type AppState,
11
11
  } from "./state/app/context";
12
- import { bindAppActivity, isAppVisible, subscribeAppVisibility, useAppActive, useAppVisible } from "./state/app/activity";
12
+ import { bindAppActivity, isAppVisible, setAppActive, subscribeAppVisibility, useAppActive, useAppVisible } from "./state/app/activity";
13
13
  import { Header } from "./components/layout/header";
14
14
  import { StatusBar } from "./components/layout/status-bar";
15
15
  import { useAppChromeShown } from "./components/layout/presentation";
@@ -280,6 +280,7 @@ function AppInner({
280
280
  else toastId = toast.info(notification.body, options);
281
281
  },
282
282
  desktop: rendererHost.supportsNativeDesktopNotifications ? rendererHost : undefined,
283
+ notifyInBackground: rendererHost.notifyInBackground,
283
284
  }), [rendererHost, toast]);
284
285
  const notify = useCallback((body: string, options?: { type?: "info" | "success" | "error" }) => {
285
286
  pluginRegistry.notify({ body, ...options });
@@ -681,6 +682,7 @@ export function App({
681
682
  useAppLanguage();
682
683
  const externalPlugins = providedExternalPlugins ?? EMPTY_EXTERNAL_PLUGINS;
683
684
  const renderer = useNativeRenderer();
685
+ const rendererHost = useRendererHost();
684
686
  const effectiveInitialConfig = useMemo(() => {
685
687
  return resolveInitialAppConfig({
686
688
  initialConfig,
@@ -722,7 +724,7 @@ export function App({
722
724
 
723
725
  const showSetup = useCallback(() => setShowOnboarding(true), []);
724
726
 
725
- useEffect(() => bindAppActivity(renderer), [renderer]);
727
+ useEffect(() => rendererHost.subscribeAppActivity?.(setAppActive) ?? bindAppActivity(renderer), [renderer, rendererHost]);
726
728
 
727
729
  const services = useMemo(() => {
728
730
  return measurePerf("startup.app.create-services", () => (
@@ -19,7 +19,7 @@
19
19
  "src/app/star-prompt/status-line.tsx": ["void:rendererHost.openExternal()"],
20
20
  "src/brokers/signed-in/sign-in.ts": ["void:this.run()"],
21
21
  "src/cli/desktop-pane-shot-browser.ts": ["statement:child.stdin.write()","void:drain().then()","void:exited.then()","void:messageText().then()"],
22
- "src/cli/desktop-pane-shot.ts": ["callback:server.stop()","void:answerShotApiCall().then()"],
22
+ "src/cli/desktop-pane-shot.ts": ["void:answerShotApiCall().then()"],
23
23
  "src/cli/pane-functions/index.ts": ["void:cliOutputWritten().then()"],
24
24
  "src/components/command-bar/assist/runtime.ts": ["void:function()"],
25
25
  "src/components/command-bar/commands/collection.ts": ["void:startTickerChangeLookup().settle().then()"],