@lumencharts/trading-platform 0.0.0-stage → 0.1.1

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 (236) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/LICENSE +55 -0
  3. package/README.md +53 -2
  4. package/dist/asset-entry.d.ts +3 -0
  5. package/dist/asset.d.ts +3 -0
  6. package/dist/asset.js +21689 -0
  7. package/dist/chart/bracket-links.d.ts +8 -0
  8. package/dist/chart/context-actions.d.ts +7 -0
  9. package/dist/chart/edit-presentation.d.ts +32 -0
  10. package/dist/chart/edit-preview.d.ts +26 -0
  11. package/dist/chart/exit-profit.d.ts +32 -0
  12. package/dist/chart/frame-batch.d.ts +15 -0
  13. package/dist/chart/overlay-coordinator.d.ts +18 -0
  14. package/dist/chart/overlay-events.d.ts +3 -0
  15. package/dist/chart/overlay-gesture.d.ts +40 -0
  16. package/dist/chart/overlay-index.d.ts +30 -0
  17. package/dist/chart/overlay-projection.d.ts +51 -0
  18. package/dist/chart/overlay-types.d.ts +42 -0
  19. package/dist/chart/parent-links.d.ts +33 -0
  20. package/dist/chart/position-profit.d.ts +15 -0
  21. package/dist/chart/review-lock.d.ts +14 -0
  22. package/dist/chart/ticket-projection.d.ts +36 -0
  23. package/dist/compat/default-formatters.d.ts +6 -0
  24. package/dist/compat/delegate.d.ts +11 -0
  25. package/dist/compat/factory.d.ts +5 -0
  26. package/dist/compat/formatters.d.ts +26 -0
  27. package/dist/compat/host-dialogs.d.ts +5 -0
  28. package/dist/compat/host-preferences.d.ts +8 -0
  29. package/dist/compat/host.d.ts +39 -0
  30. package/dist/compat/watched-value.d.ts +25 -0
  31. package/dist/conformance/index.d.ts +78 -0
  32. package/dist/conformance/index.js +6859 -0
  33. package/dist/conformance/replay.d.ts +35 -0
  34. package/dist/contracts/broker.d.ts +1122 -0
  35. package/dist/contracts/broker.js +168 -0
  36. package/dist/contracts/index.d.ts +3 -0
  37. package/dist/contracts/index.js +168 -0
  38. package/dist/contracts/market-data.d.ts +289 -0
  39. package/dist/contracts/market-data.js +11 -0
  40. package/dist/contracts/ports.d.ts +469 -0
  41. package/dist/contracts/ports.js +5 -0
  42. package/dist/core/account-datasets.d.ts +29 -0
  43. package/dist/core/account-lifecycle.d.ts +70 -0
  44. package/dist/core/account-types.d.ts +6 -0
  45. package/dist/core/bounded-map.d.ts +12 -0
  46. package/dist/core/bracket-input.d.ts +32 -0
  47. package/dist/core/bracket-modification.d.ts +6 -0
  48. package/dist/core/bracket-parent.d.ts +11 -0
  49. package/dist/core/broker-debug.d.ts +10 -0
  50. package/dist/core/capabilities.d.ts +34 -0
  51. package/dist/core/capability-metadata.d.ts +60 -0
  52. package/dist/core/capability-policy.d.ts +32 -0
  53. package/dist/core/chart-exit-level.d.ts +11 -0
  54. package/dist/core/chart-order-edit.d.ts +50 -0
  55. package/dist/core/clock.d.ts +2 -0
  56. package/dist/core/close-commands.d.ts +24 -0
  57. package/dist/core/close-flow.d.ts +14 -0
  58. package/dist/core/command-context.d.ts +16 -0
  59. package/dist/core/command-coordinator.d.ts +71 -0
  60. package/dist/core/command-follow.d.ts +32 -0
  61. package/dist/core/command-keys.d.ts +11 -0
  62. package/dist/core/context-orders.d.ts +19 -0
  63. package/dist/core/deferred.d.ts +5 -0
  64. package/dist/core/dialog-coordinator.d.ts +73 -0
  65. package/dist/core/display-preferences.d.ts +10 -0
  66. package/dist/core/disposal.d.ts +8 -0
  67. package/dist/core/entity-store.d.ts +56 -0
  68. package/dist/core/entity-validation.d.ts +9 -0
  69. package/dist/core/errors.d.ts +24 -0
  70. package/dist/core/execution-demand.d.ts +11 -0
  71. package/dist/core/execution-sound.d.ts +10 -0
  72. package/dist/core/exit-level-draft.d.ts +9 -0
  73. package/dist/core/exit-level-summary.d.ts +3 -0
  74. package/dist/core/exit-level-template.d.ts +16 -0
  75. package/dist/core/features.d.ts +39 -0
  76. package/dist/core/financial-rules.d.ts +70 -0
  77. package/dist/core/history-limit.d.ts +11 -0
  78. package/dist/core/identity.d.ts +14 -0
  79. package/dist/core/immutable.d.ts +8 -0
  80. package/dist/core/keyed-ref-count.d.ts +18 -0
  81. package/dist/core/leverage-commands.d.ts +42 -0
  82. package/dist/core/modification-context.d.ts +22 -0
  83. package/dist/core/modification-routing.d.ts +43 -0
  84. package/dist/core/notification-log.d.ts +33 -0
  85. package/dist/core/number-precision.d.ts +4 -0
  86. package/dist/core/order-commands.d.ts +50 -0
  87. package/dist/core/order-duration.d.ts +14 -0
  88. package/dist/core/order-labels.d.ts +7 -0
  89. package/dist/core/order-matching.d.ts +16 -0
  90. package/dist/core/order-modification.d.ts +20 -0
  91. package/dist/core/order-notifications.d.ts +30 -0
  92. package/dist/core/order-protection.d.ts +4 -0
  93. package/dist/core/parent-protection.d.ts +10 -0
  94. package/dist/core/position-commands.d.ts +45 -0
  95. package/dist/core/position-custom-fields.d.ts +5 -0
  96. package/dist/core/position-estimates.d.ts +22 -0
  97. package/dist/core/position-protection-permissions.d.ts +4 -0
  98. package/dist/core/preferences-key.d.ts +2 -0
  99. package/dist/core/preview-leases.d.ts +12 -0
  100. package/dist/core/protection-legs.d.ts +23 -0
  101. package/dist/core/protection-notifications.d.ts +9 -0
  102. package/dist/core/protection-rules.d.ts +21 -0
  103. package/dist/core/quantity-input.d.ts +53 -0
  104. package/dist/core/read-coordinator.d.ts +15 -0
  105. package/dist/core/readers.d.ts +6 -0
  106. package/dist/core/relative-price.d.ts +4 -0
  107. package/dist/core/review-policy.d.ts +17 -0
  108. package/dist/core/session-types.d.ts +1 -0
  109. package/dist/core/session.d.ts +114 -0
  110. package/dist/core/snapshot-dataset.d.ts +47 -0
  111. package/dist/core/symbol-catalog.d.ts +37 -0
  112. package/dist/core/tradability.d.ts +26 -0
  113. package/dist/core/trading-commands.d.ts +104 -0
  114. package/dist/core/trading-rules.d.ts +14 -0
  115. package/dist/core/trading-settings.d.ts +39 -0
  116. package/dist/core/trading-state.d.ts +52 -0
  117. package/dist/core/value-store.d.ts +11 -0
  118. package/dist/index.d.ts +15 -0
  119. package/dist/index.js +6593 -0
  120. package/dist/market-data/depth-book.d.ts +18 -0
  121. package/dist/market-data/index.d.ts +3 -0
  122. package/dist/market-data/index.js +735 -0
  123. package/dist/market-data/session-demand.d.ts +15 -0
  124. package/dist/market-data/subscriptions.d.ts +13 -0
  125. package/dist/mock/broker.d.ts +75 -0
  126. package/dist/mock/clock.d.ts +12 -0
  127. package/dist/mock/feeds.d.ts +18 -0
  128. package/dist/mock/index.d.ts +5 -0
  129. package/dist/mock/index.js +1956 -0
  130. package/dist/mock/protection-cancellation.d.ts +7 -0
  131. package/dist/mock/scenarios.d.ts +5 -0
  132. package/dist/paper/broker.d.ts +41 -0
  133. package/dist/paper/index.d.ts +6 -0
  134. package/dist/paper/index.js +469 -0
  135. package/dist/paper/market.d.ts +57 -0
  136. package/dist/paper/rules.d.ts +40 -0
  137. package/dist/ui/account-manager/account-pages.d.ts +18 -0
  138. package/dist/ui/account-manager/column-presentation.d.ts +5 -0
  139. package/dist/ui/account-manager/context-menu.d.ts +13 -0
  140. package/dist/ui/account-manager/csv-downloads.d.ts +5 -0
  141. package/dist/ui/account-manager/custom-page.d.ts +16 -0
  142. package/dist/ui/account-manager/custom-table.d.ts +18 -0
  143. package/dist/ui/account-manager/format-account-value.d.ts +12 -0
  144. package/dist/ui/account-manager/position-reader.d.ts +19 -0
  145. package/dist/ui/account-manager/row-action-tracker.d.ts +12 -0
  146. package/dist/ui/account-manager/row-actions.d.ts +37 -0
  147. package/dist/ui/account-manager/status-counts.d.ts +6 -0
  148. package/dist/ui/account-manager/table-controls.d.ts +13 -0
  149. package/dist/ui/account-manager/table-export.d.ts +30 -0
  150. package/dist/ui/account-manager/table-model.d.ts +11 -0
  151. package/dist/ui/account-manager/table-toolbar.d.ts +25 -0
  152. package/dist/ui/account-manager/table.d.ts +24 -0
  153. package/dist/ui/account-manager/view.d.ts +19 -0
  154. package/dist/ui/account-manager/workspace.d.ts +15 -0
  155. package/dist/ui/chart-actions.d.ts +11 -0
  156. package/dist/ui/chart-controls/eligibility.d.ts +6 -0
  157. package/dist/ui/chart-controls/quote-buttons.d.ts +15 -0
  158. package/dist/ui/chart-controls/quote-controls.d.ts +12 -0
  159. package/dist/ui/chart-controls/quote-widths.d.ts +8 -0
  160. package/dist/ui/dialogs/close-amount-form.d.ts +8 -0
  161. package/dist/ui/dialogs/close-preview-dialog.d.ts +5 -0
  162. package/dist/ui/dialogs/confirm-dialog.d.ts +7 -0
  163. package/dist/ui/dialogs/dialog-body.d.ts +11 -0
  164. package/dist/ui/dialogs/leverage-form.d.ts +10 -0
  165. package/dist/ui/dialogs/message-dialog.d.ts +6 -0
  166. package/dist/ui/dialogs/position-protection.d.ts +14 -0
  167. package/dist/ui/dialogs/properties-dialog.d.ts +9 -0
  168. package/dist/ui/dialogs/sanitize-html.d.ts +2 -0
  169. package/dist/ui/dialogs/types.d.ts +5 -0
  170. package/dist/ui/dialogs/view.d.ts +5 -0
  171. package/dist/ui/dock-sizes.d.ts +20 -0
  172. package/dist/ui/dom/controller.d.ts +34 -0
  173. package/dist/ui/dom/ladder.d.ts +23 -0
  174. package/dist/ui/dom/view.d.ts +8 -0
  175. package/dist/ui/dom/workspace.d.ts +17 -0
  176. package/dist/ui/effective-mode.d.ts +11 -0
  177. package/dist/ui/financial-lease.d.ts +3 -0
  178. package/dist/ui/icons.d.ts +4 -0
  179. package/dist/ui/index.d.ts +9 -0
  180. package/dist/ui/index.js +15918 -0
  181. package/dist/ui/layout.d.ts +5 -0
  182. package/dist/ui/mount.d.ts +11 -0
  183. package/dist/ui/notifications/log.d.ts +6 -0
  184. package/dist/ui/notifications/toasts.d.ts +5 -0
  185. package/dist/ui/number-input.d.ts +2 -0
  186. package/dist/ui/order-ticket/chart-draft-controls.d.ts +8 -0
  187. package/dist/ui/order-ticket/chart-projection.d.ts +9 -0
  188. package/dist/ui/order-ticket/controller.d.ts +41 -0
  189. package/dist/ui/order-ticket/custom-field.d.ts +9 -0
  190. package/dist/ui/order-ticket/duration-input.d.ts +9 -0
  191. package/dist/ui/order-ticket/exit-input.d.ts +34 -0
  192. package/dist/ui/order-ticket/financial-controls.d.ts +10 -0
  193. package/dist/ui/order-ticket/layout-context.d.ts +7 -0
  194. package/dist/ui/order-ticket/market.d.ts +12 -0
  195. package/dist/ui/order-ticket/menu.d.ts +6 -0
  196. package/dist/ui/order-ticket/mode-rules.d.ts +4 -0
  197. package/dist/ui/order-ticket/modification-fields.d.ts +23 -0
  198. package/dist/ui/order-ticket/move-handle.d.ts +4 -0
  199. package/dist/ui/order-ticket/order-sent.d.ts +4 -0
  200. package/dist/ui/order-ticket/placement.d.ts +27 -0
  201. package/dist/ui/order-ticket/preview-message.d.ts +4 -0
  202. package/dist/ui/order-ticket/price-input.d.ts +14 -0
  203. package/dist/ui/order-ticket/quantity-input.d.ts +26 -0
  204. package/dist/ui/order-ticket/review-panel.d.ts +10 -0
  205. package/dist/ui/order-ticket/rules.d.ts +16 -0
  206. package/dist/ui/order-ticket/stop-input.d.ts +17 -0
  207. package/dist/ui/order-ticket/submit-bar.d.ts +13 -0
  208. package/dist/ui/order-ticket/symbol-search-controller.d.ts +50 -0
  209. package/dist/ui/order-ticket/symbol-search.d.ts +12 -0
  210. package/dist/ui/order-ticket/untradable-notice.d.ts +8 -0
  211. package/dist/ui/order-ticket/view.d.ts +16 -0
  212. package/dist/ui/panel-visibility.d.ts +6 -0
  213. package/dist/ui/pointer-drag.d.ts +20 -0
  214. package/dist/ui/popup-mount.d.ts +4 -0
  215. package/dist/ui/primitives.d.ts +29 -0
  216. package/dist/ui/protection/editor.d.ts +18 -0
  217. package/dist/ui/protection/fields.d.ts +30 -0
  218. package/dist/ui/protection/level.d.ts +14 -0
  219. package/dist/ui/protection/protected-size.d.ts +5 -0
  220. package/dist/ui/protection/ticket-workspace.d.ts +7 -0
  221. package/dist/ui/resize-handle.css +34 -0
  222. package/dist/ui/resize-handle.d.ts +20 -0
  223. package/dist/ui/resize-handle.js +185 -0
  224. package/dist/ui/select.d.ts +26 -0
  225. package/dist/ui/surface-theme.d.ts +3 -0
  226. package/dist/ui/switch.d.ts +7 -0
  227. package/dist/ui/symbol-logo.d.ts +7 -0
  228. package/dist/ui/tabs.d.ts +19 -0
  229. package/dist/ui/ticket-dock.d.ts +18 -0
  230. package/dist/ui/ticket-shell.d.ts +15 -0
  231. package/dist/ui/trading.css +1808 -0
  232. package/dist/ui/trap-tab.d.ts +11 -0
  233. package/dist/vendor/solid-ui/index.d.ts +3 -0
  234. package/dist/vendor/solid-ui/paged-list-window.d.ts +27 -0
  235. package/dist/vendor/solid-ui/virtual-list.d.ts +21 -0
  236. package/package.json +104 -3
@@ -0,0 +1,469 @@
1
+ import type { DOMData, IBrokerConnectionAdapterHost, IBrokerTerminal, OrderType, Side, SingleBrokerMetaInfo, TradingQuotes } from "./broker.js";
2
+ import type { IDatafeedChartApi, IDatafeedQuotesApi } from "./market-data.js";
3
+ import type { AccountId, ClosePositionPreviewResult, INumberFormatter, IPriceFormatter } from './broker.js';
4
+ export type Dispose = () => void;
5
+ export interface TradingClock {
6
+ now(): number;
7
+ setTimeout(callback: () => void, milliseconds: number): unknown;
8
+ clearTimeout(handle: unknown): void;
9
+ }
10
+ export interface ReadonlyValue<T> {
11
+ get(): T;
12
+ subscribe(listener: (value: T) => void): Dispose;
13
+ }
14
+ export interface TradingSettingsPort {
15
+ get(key: string): string | undefined;
16
+ set(key: string, value: string): void;
17
+ remove(key: string): void;
18
+ }
19
+ export interface TradingFormatterPort {
20
+ defaultPrice(symbol: string, alignToMinMove: boolean): Promise<INumberFormatter>;
21
+ numeric(decimalPlaces: number): Promise<INumberFormatter>;
22
+ quantity(decimalPlaces?: number): Promise<INumberFormatter>;
23
+ createPriceFormatter(priceScale?: number, minMove?: number, fractional?: boolean, minMove2?: number, variableMinTick?: string): IPriceFormatter;
24
+ }
25
+ /**
26
+ * Lumen extension: how a broker adapter behaves, declared by the adapter itself so the conformance kit can hold it
27
+ * to the declaration. Contract details such as the point value and P&L currency are declared on the instrument and
28
+ * `positionPLInInstrumentCurrency` instead.
29
+ */
30
+ export interface TradingBrokerProfile {
31
+ /**
32
+ * `immediate`: when a write's reply arrives, the broker's reads already show its result. `eventual`: the broker may
33
+ * acknowledge a write first and show its result later (common for exchanges with an account stream).
34
+ */
35
+ readonly confirmation: 'immediate' | 'eventual';
36
+ /** Every placement carries a client order ID, so a write whose reply was lost is found instead of sent again. */
37
+ readonly clientOrderIds: boolean;
38
+ }
39
+ /** Lumen extensions deliberately do not change the pinned IBrokerTerminal. */
40
+ export interface LumenBrokerExtensions {
41
+ disposeBroker?(): void;
42
+ previewClosePosition?(request: {
43
+ accountId: AccountId;
44
+ positionId: string;
45
+ individual: boolean;
46
+ amount?: number;
47
+ }): Promise<ClosePositionPreviewResult>;
48
+ }
49
+ export interface TradingQuoteSnapshot {
50
+ readonly status: 'loading' | 'ready' | 'error';
51
+ /** Initial reads and cached replays must be labelled snapshot; omitted means an authoritative live update. */
52
+ readonly source?: 'snapshot' | 'stream';
53
+ readonly value?: Readonly<TradingQuotes>;
54
+ readonly error?: string;
55
+ }
56
+ export interface TradingMarketDataPort {
57
+ acquireQuotes(symbol: string, speed: 'fast' | 'normal', listener: (snapshot: TradingQuoteSnapshot) => void): Dispose;
58
+ acquireDepth(symbol: string, listener: (snapshot: Readonly<DOMData>) => void): Dispose;
59
+ }
60
+ export interface TradingChartBinding {
61
+ readonly id: string;
62
+ readonly generation: number;
63
+ readonly symbol: string;
64
+ }
65
+ export interface TradingEnvironment {
66
+ readonly locale: string;
67
+ readonly theme: 'light' | 'dark';
68
+ readonly timezone: string;
69
+ readonly width: number;
70
+ readonly height: number;
71
+ }
72
+ export interface TradingSymbolContext {
73
+ readonly symbol: string;
74
+ readonly minTick: number;
75
+ readonly priceScale: number;
76
+ readonly minMove: number;
77
+ readonly minMove2?: number;
78
+ readonly fractional?: boolean;
79
+ readonly variableMinTick?: string;
80
+ readonly currency?: string;
81
+ readonly type?: string;
82
+ readonly resolved: boolean;
83
+ readonly tradable: boolean;
84
+ readonly hasBars: boolean;
85
+ }
86
+ export interface TradingProtectionView {
87
+ readonly phase?: "draft" | "dragging" | "pending" | "inactive" | "confirmed";
88
+ readonly showRegion?: boolean;
89
+ readonly muted?: boolean;
90
+ readonly profitDirection?: 1 | -1;
91
+ readonly target?: string;
92
+ readonly movingLeg?: TradingProtectionLeg;
93
+ readonly entryPrice?: number;
94
+ readonly handles: readonly TradingProtectionLeg[];
95
+ /** Legs shown faded and not draggable while another leg is under review. */
96
+ readonly lockedHandles?: readonly TradingProtectionLeg[];
97
+ readonly preview?: {
98
+ readonly leg: TradingProtectionLeg;
99
+ readonly price: number;
100
+ readonly text?: string;
101
+ readonly quantity?: string;
102
+ readonly invalid?: boolean;
103
+ };
104
+ }
105
+ export type TradingProtectionLeg = "takeProfit" | "stopLoss";
106
+ export type TradingOverlayAction = 'modify' | 'cancel' | 'close' | 'reverse' | 'protect' | 'submit';
107
+ export interface TradingPositionPill {
108
+ readonly text: string;
109
+ readonly tone?: "positive" | "negative" | "neutral";
110
+ }
111
+ export interface TradingOverlayStyle {
112
+ readonly lineColor?: string;
113
+ readonly textColor?: string;
114
+ readonly lineWidth?: number;
115
+ readonly lineStyle?: number;
116
+ }
117
+ interface TradingOverlayBase {
118
+ readonly pill?: TradingPositionPill;
119
+ readonly protection?: TradingProtectionView;
120
+ readonly key: string;
121
+ readonly entityId: string;
122
+ readonly symbol: string;
123
+ readonly price: number;
124
+ readonly label: string;
125
+ /** Hover text; the label when absent. */
126
+ readonly tooltip?: string;
127
+ readonly side: Side;
128
+ readonly quantity?: number;
129
+ readonly group?: string;
130
+ readonly actions: readonly TradingOverlayAction[];
131
+ readonly style?: TradingOverlayStyle;
132
+ }
133
+ export type TradingOverlaySpec = (TradingOverlayBase & {
134
+ readonly kind: 'order' | 'position' | 'bracket';
135
+ }) | (TradingOverlayBase & {
136
+ readonly kind: 'execution';
137
+ readonly time: number;
138
+ });
139
+ export interface TradingOverlayPatch {
140
+ readonly pill?: TradingPositionPill;
141
+ readonly protection?: TradingProtectionView;
142
+ readonly price?: number;
143
+ readonly label?: string; /** Present when changed; undefined returns to the label. */
144
+ readonly tooltip?: string;
145
+ readonly quantity?: number;
146
+ readonly actions?: readonly TradingOverlayAction[];
147
+ readonly style?: TradingOverlayStyle;
148
+ }
149
+ export type TradingOverlayEvent = {
150
+ readonly type: TradingOverlayAction;
151
+ } | {
152
+ readonly type: 'dragStart' | 'dragPreview' | 'dragCommit' | 'dragCancel';
153
+ readonly gestureId: string;
154
+ readonly price: number;
155
+ readonly leg?: TradingProtectionLeg;
156
+ };
157
+ export interface TradingOverlayHandle {
158
+ update(patch: TradingOverlayPatch): void;
159
+ subscribe(listener: (event: TradingOverlayEvent) => void): Dispose;
160
+ cancelInteraction(): void;
161
+ remove(): void;
162
+ }
163
+ export type ChartTradeIntent = {
164
+ readonly type: 'openTicket' | 'priceOrder';
165
+ readonly account?: {
166
+ readonly accountId?: string;
167
+ readonly generation: number;
168
+ };
169
+ readonly binding: TradingChartBinding;
170
+ readonly side: Side;
171
+ readonly price?: number;
172
+ readonly orderType?: OrderType;
173
+ } | {
174
+ readonly type: 'modifyOrder' | 'cancelOrder' | 'closePosition' | 'reversePosition';
175
+ readonly binding: TradingChartBinding;
176
+ readonly entityId: string;
177
+ } | {
178
+ readonly type: 'editProtection';
179
+ readonly binding: TradingChartBinding;
180
+ readonly entityId: string;
181
+ readonly entityKind: 'order' | 'position' | 'individualPosition';
182
+ };
183
+ /** A chart context item: a trade intent the platform owns, a broker callback, or a separator. */
184
+ /** Glyph hint for a chart menu action; a host without a matching glyph shows the text alone. */
185
+ export type TradingContextActionIcon = 'buy' | 'sell' | 'add_order' | 'trading_settings';
186
+ export type TradingContextAction = {
187
+ readonly text: string;
188
+ readonly intent: ChartTradeIntent;
189
+ readonly price?: number;
190
+ readonly formattedPrice?: string;
191
+ readonly icon?: TradingContextActionIcon;
192
+ } | {
193
+ readonly text: string;
194
+ readonly run: () => void;
195
+ readonly enabled?: boolean;
196
+ readonly icon?: TradingContextActionIcon;
197
+ } | {
198
+ readonly separator: true;
199
+ };
200
+ /** May resolve asynchronously (the broker's `chartContextMenuActions`); the chart menu waits for it. */
201
+ export type TradingContextActionsProvider = (binding: TradingChartBinding, price?: number, source?: "pane" | "priceScale") => readonly TradingContextAction[] | Promise<readonly TradingContextAction[]>;
202
+ export interface TradingChartPort {
203
+ readonly binding: ReadonlyValue<TradingChartBinding>;
204
+ symbolContext(): Promise<TradingSymbolContext>;
205
+ /** Optional reactive host metadata; publish only when the context changes, not for every bar. */
206
+ subscribeSymbolContext?(listener: (context: TradingSymbolContext) => void): Dispose;
207
+ /** Host chart visibility, independent of the trading button preference. */
208
+ readonly visible?: ReadonlyValue<boolean>;
209
+ createOverlay(spec: TradingOverlaySpec): TradingOverlayHandle;
210
+ onTradeIntent(listener: (intent: ChartTradeIntent) => void): Dispose;
211
+ registerContextActions(provider: TradingContextActionsProvider): Dispose;
212
+ /** Optional: show another symbol on this chart, e.g. a broker's "change symbol" solution for a non-tradable one. */
213
+ requestSymbol?(symbol: string): void;
214
+ /** Optional: chart-wide broker line layout; absent hosts keep their default layout. */
215
+ setLineLayout?(layout: TradingLineLayout): void;
216
+ }
217
+ export type TradingCollectionEvent = {
218
+ readonly type: 'added';
219
+ readonly chart: TradingChartPort;
220
+ } | {
221
+ readonly type: 'removed';
222
+ readonly binding: TradingChartBinding;
223
+ } | {
224
+ readonly type: 'activeChanged';
225
+ readonly binding?: TradingChartBinding;
226
+ } | {
227
+ readonly type: 'bindingChanged';
228
+ readonly previous: TradingChartBinding;
229
+ readonly binding: TradingChartBinding;
230
+ };
231
+ export interface TradingCollectionPort {
232
+ charts(): readonly TradingChartPort[];
233
+ activeChart(): TradingChartPort | undefined;
234
+ subscribe(listener: (event: TradingCollectionEvent) => void): Dispose;
235
+ }
236
+ export type TradingSurfaceKind = 'ticket' | 'accounts' | 'dom' | 'dialogs' | 'chart-controls';
237
+ /** Lumen host geometry, expressed in the presentation environment's CSS pixels. */
238
+ export interface TradingFloatingBounds {
239
+ readonly x: number;
240
+ readonly y: number;
241
+ readonly width: number;
242
+ readonly height: number;
243
+ }
244
+ export type TradingTicketPlacement = {
245
+ readonly mode: 'docked';
246
+ } | {
247
+ readonly mode: 'floating';
248
+ readonly bounds: TradingFloatingBounds;
249
+ };
250
+ export interface TradingPresentationPort {
251
+ readonly environment: ReadonlyValue<TradingEnvironment>;
252
+ readonly settings: TradingSettingsPort;
253
+ acquireSurface(kind: TradingSurfaceKind, chart?: TradingChartBinding): {
254
+ readonly element: HTMLElement;
255
+ readonly visible?: ReadonlyValue<boolean>;
256
+ release: Dispose;
257
+ };
258
+ setDockSize(kind: 'ticket' | 'accounts' | 'dom', pixels: number, options?: {
259
+ readonly maximized?: boolean;
260
+ }): void;
261
+ dockBounds?(kind: 'ticket' | 'accounts' | 'dom', options?: {
262
+ readonly maximized?: boolean;
263
+ }): Readonly<{
264
+ min: number;
265
+ max: number;
266
+ }>;
267
+ /** Optional host extension; moving the owned ticket surface must preserve its mounted state. */
268
+ setTicketPlacement?(placement: TradingTicketPlacement): void;
269
+ notifyLayoutChanged(): void;
270
+ /** Optional: symbol logo URLs when the host enables `show_symbol_logos`; resolves to an empty list when unavailable. */
271
+ symbolLogos?(symbol: string): Promise<readonly string[]>;
272
+ /** Optional: datafeed symbol search for the ticket when the broker sets `supportSymbolSearch`. */
273
+ searchSymbols?(query: string): Promise<readonly TradingSymbolSearchResult[]>;
274
+ searchSymbolsPage?(query: string, start: number, limit: number): Promise<TradingSymbolSearchPage>;
275
+ /** Optional: add a page to the host's settings dialog; without it the platform keeps its own settings dialog. */
276
+ registerSettingsPage?(page: TradingSettingsPage): Dispose;
277
+ /** Optional: open the host's settings dialog on a registered page; false when it cannot. */
278
+ openSettingsPage?(id: string): boolean;
279
+ }
280
+ export interface TradingSymbolSearchPage {
281
+ readonly revision?: string;
282
+ readonly items: readonly TradingSymbolSearchResult[];
283
+ readonly remaining: number;
284
+ }
285
+ export interface TradingSymbolSearchResult {
286
+ readonly symbol: string;
287
+ readonly description?: string;
288
+ readonly exchange?: string;
289
+ }
290
+ export type TradingProfitDisplayMode = 'money' | 'ticks' | 'percentage';
291
+ export type TradingLineAlignment = 'left' | 'center' | 'right';
292
+ /**
293
+ * User trading display choices. Optional fields fall back to the reference defaults: every visibility on except
294
+ * execution labels, bracket P&L in money, extended lines, right alignment, no sound and every notification shown.
295
+ */
296
+ export interface TradingDisplaySettings {
297
+ readonly positionProfitDisplay: TradingProfitDisplayMode;
298
+ readonly showPositionProfit: boolean;
299
+ readonly multipleExitLevels?: boolean;
300
+ /** The user's Buy/sell buttons choice, restored into `sellBuyButtonsVisibility` at startup. */
301
+ readonly showBuySellButtons?: boolean;
302
+ /** Parent switch over position and bracket P&L (`tradingProperties.positionAndBracketsPL`). */
303
+ readonly showProfit?: boolean;
304
+ readonly showBracketProfit?: boolean;
305
+ readonly bracketProfitDisplay?: TradingProfitDisplayMode;
306
+ readonly showPositions?: boolean;
307
+ readonly showOrders?: boolean;
308
+ readonly showReverse?: boolean;
309
+ readonly showExecutions?: boolean;
310
+ readonly showExecutionLabels?: boolean;
311
+ /** Draw position and order lines across the whole pane (`tradingProperties.extendLeft`). */
312
+ readonly extendLines?: boolean;
313
+ readonly lineAlignment?: TradingLineAlignment;
314
+ readonly executionSound?: boolean;
315
+ /** Toasts show only rejections; the notification log keeps everything. */
316
+ readonly rejectionNotificationsOnly?: boolean;
317
+ }
318
+ /** Lumen extension: one sound cue; the default plays a short tone through Web Audio when available. */
319
+ export interface TradingSoundPort {
320
+ playExecution(): void;
321
+ }
322
+ /** Chart-wide layout for broker lines. */
323
+ export interface TradingLineLayout {
324
+ readonly extendLeft: boolean;
325
+ readonly alignment: TradingLineAlignment;
326
+ }
327
+ export type TradingSettingsValue = boolean | string;
328
+ export interface TradingSettingsOption {
329
+ readonly value: string;
330
+ readonly label: string;
331
+ }
332
+ /** One row of a host settings page; data only, rendered by the host with its own controls. */
333
+ export type TradingSettingsField = {
334
+ readonly kind: 'checkbox';
335
+ readonly id: string;
336
+ readonly label: string;
337
+ readonly description?: string;
338
+ /** Indents the row under this checkbox and disables it while that checkbox is off. */
339
+ readonly parent?: string;
340
+ readonly disabled?: boolean;
341
+ /** A select on the same row, disabled while the checkbox is off. */
342
+ readonly select?: {
343
+ readonly id: string;
344
+ readonly label: string;
345
+ readonly options: readonly TradingSettingsOption[];
346
+ };
347
+ } | {
348
+ readonly kind: 'select';
349
+ readonly id: string;
350
+ readonly label: string;
351
+ readonly options: readonly TradingSettingsOption[];
352
+ readonly parent?: string;
353
+ readonly disabled?: boolean;
354
+ };
355
+ export interface TradingSettingsSection {
356
+ readonly id: string;
357
+ readonly title: string;
358
+ readonly fields: readonly TradingSettingsField[];
359
+ }
360
+ export interface TradingSettingsPageSnapshot {
361
+ readonly sections: readonly TradingSettingsSection[];
362
+ readonly values: Readonly<Record<string, TradingSettingsValue>>;
363
+ }
364
+ /** A settings page contributed to the host's settings dialog. The host keeps the draft; `apply` receives changed fields only. */
365
+ export interface TradingSettingsPage {
366
+ readonly id: string;
367
+ readonly label: string;
368
+ snapshot(): TradingSettingsPageSnapshot;
369
+ apply(patch: Readonly<Record<string, TradingSettingsValue>>): void | Promise<void>;
370
+ /** Called when fields or values change outside the dialog, e.g. a broker flag or an override. */
371
+ subscribe(listener: () => void): Dispose;
372
+ }
373
+ export interface TradingSessionOptions {
374
+ brokerFactory(host: IBrokerConnectionAdapterHost): IBrokerTerminal;
375
+ brokerConfig?: SingleBrokerMetaInfo;
376
+ marketData: TradingMarketDataPort;
377
+ marketDataCapabilities?: {
378
+ readonly quotes: boolean;
379
+ readonly depth: boolean;
380
+ };
381
+ formatters: TradingFormatterPort;
382
+ settings: TradingSettingsPort;
383
+ enabledFeatures?: readonly string[];
384
+ disabledFeatures?: readonly string[];
385
+ displaySettings?: Partial<TradingDisplaySettings>;
386
+ clock?: TradingClock;
387
+ extensions?: LumenBrokerExtensions;
388
+ settingsKey?: string;
389
+ requireConfirmation?: boolean;
390
+ /** Lumen extension: the execution sound; defaults to a Web Audio tone where available. */
391
+ sound?: TradingSoundPort;
392
+ /** Pinned `debug_broker` widget option: log Broker API and Trading Host calls with matching IDs. */
393
+ debugBroker?: 'all' | 'normal' | 'host-only' | 'broker-only';
394
+ /** Destination for debug logs; defaults to `console.debug`. */
395
+ debugLogger?: (message: string, ...details: unknown[]) => void;
396
+ /**
397
+ * Lumen extension: broker input the session dropped (an invalid push, a quarantined snapshot row, a trimmed
398
+ * history). With `debugBroker` set, drops are also written to `debugLogger`. Never throws into the adapter.
399
+ */
400
+ diagnostics?: (diagnostic: TradingDiagnostic) => void;
401
+ /**
402
+ * Lumen extension: deadlines in milliseconds (defaults: command 10 s, reconcile 60 s, account switch 10 s, read 15 s,
403
+ * snapshot 15 s).
404
+ */
405
+ deadlines?: TradingDeadlines;
406
+ /** Lumen extension: most order-history rows kept from one read, newest first (default 5,000). */
407
+ historyLimit?: number;
408
+ /** Lumen extension: how far ahead of the broker the session clock may be when validating expiry (default 60 s). */
409
+ clockSkewToleranceSeconds?: number;
410
+ }
411
+ export interface TradingDeadlines {
412
+ /** Until an unmatched command is reported unconfirmed; it changes presentation, not the outcome. */
413
+ readonly command?: number;
414
+ /**
415
+ * After the command deadline: how long an unconfirmed command keeps reconciling and holding its keys. 0 ends the
416
+ * command at its deadline: it stays unconfirmed, its keys are released, and later broker updates change the account
417
+ * data but not the command's record.
418
+ */
419
+ readonly reconcile?: number;
420
+ readonly accountSwitch?: number;
421
+ readonly read?: number;
422
+ readonly snapshot?: number;
423
+ }
424
+ export interface TradingDiagnostic {
425
+ /** Where the input entered: a host push, a snapshot read, a history trim, or instrument metadata. */
426
+ readonly source: 'host' | 'snapshot' | 'history' | 'instrument';
427
+ /** Host method or dataset name. */
428
+ readonly method: string;
429
+ readonly entityId?: string;
430
+ readonly message: string;
431
+ }
432
+ /**
433
+ * Lumen extension: the plain shape an adapter may throw or reject with so users see the broker's reason.
434
+ * `message` must be user-safe; anything else rejected keeps the platform's generic wording.
435
+ */
436
+ export interface BrokerRejection {
437
+ readonly code: 'rejected' | 'unavailable' | 'invalid' | 'unsupported';
438
+ readonly message: string;
439
+ readonly details?: Record<string, unknown>;
440
+ }
441
+ /** Lumen-only widget/mount overrides; no changes to the pinned broker interface. */
442
+ export type TradingSessionOverrides = Partial<Pick<TradingSessionOptions, 'clock' | 'extensions' | 'marketData' | 'marketDataCapabilities' | 'formatters' | 'settingsKey' | 'displaySettings' | 'sound'>>;
443
+ export interface TradingRuntime {
444
+ readonly ready: Promise<void>;
445
+ destroy(): void;
446
+ }
447
+ export interface NativeTradingOptions {
448
+ readonly abi: 1;
449
+ readonly buildId: string;
450
+ readonly session: Omit<TradingSessionOptions, 'marketData' | 'formatters'> & {
451
+ readonly marketData?: TradingMarketDataPort;
452
+ readonly formatters?: TradingFormatterPort;
453
+ };
454
+ readonly datafeed?: Partial<IDatafeedQuotesApi> & Pick<IDatafeedChartApi, 'subscribeDepth' | 'unsubscribeDepth'>; /** Host overrides remain readable while the optional asset is loading: `get` returns every override so far, listeners receive each applied patch. */
455
+ readonly displayOverrides?: ReadonlyValue<Partial<TradingDisplaySettings>>;
456
+ readonly collection: TradingCollectionPort;
457
+ readonly presentation: TradingPresentationPort;
458
+ }
459
+ export interface TradingModule {
460
+ readonly abi: 1;
461
+ readonly buildId: string;
462
+ mount(options: NativeTradingOptions): TradingRuntime;
463
+ }
464
+ /** Optional per-order restriction stored in Order.extra, without changing the pinned Broker API. */
465
+ export interface TradingOrderRestrictions {
466
+ readonly editable?: boolean;
467
+ }
468
+ export declare const orderRestrictionsField = "lumenOrderRestrictions";
469
+ export {};
@@ -0,0 +1,5 @@
1
+ // src/contracts/ports.ts
2
+ var orderRestrictionsField = "lumenOrderRestrictions";
3
+ export {
4
+ orderRestrictionsField
5
+ };
@@ -0,0 +1,29 @@
1
+ import type { IBrokerTerminal, Order } from "../contracts/broker.js";
2
+ import type { TradingClock, TradingDiagnostic } from "../contracts/ports.js";
3
+ import type { CapabilityFlags } from "./capabilities.js";
4
+ import { SnapshotDataset } from "./snapshot-dataset.js";
5
+ import type { TradingState } from "./trading-state.js";
6
+ export interface AccountDatasetOptions {
7
+ readonly state: TradingState;
8
+ readonly broker: () => IBrokerTerminal;
9
+ readonly clock: TradingClock;
10
+ readonly diagnostic: (diagnostic: TradingDiagnostic) => void;
11
+ /** Snapshot read deadline in milliseconds. */
12
+ readonly deadline: number;
13
+ readonly historyLimit?: number;
14
+ }
15
+ /**
16
+ * The four account snapshot datasets (orders, history, positions, individual positions). Each read quarantines
17
+ * invalid rows; position reads drop quantity-zero rows; history reads keep the newest `historyLimit` rows.
18
+ */
19
+ export declare function createAccountDatasets(options: AccountDatasetOptions): {
20
+ orders: SnapshotDataset<Order>;
21
+ history: SnapshotDataset<Order>;
22
+ positions: SnapshotDataset<import("../contracts/broker.js").Position>;
23
+ individualPositions: SnapshotDataset<import("../contracts/broker.js").IndividualPosition>;
24
+ all: readonly [SnapshotDataset<Order>, SnapshotDataset<Order>, SnapshotDataset<import("../contracts/broker.js").Position>, SnapshotDataset<import("../contracts/broker.js").IndividualPosition>];
25
+ /** Starts the snapshot reads the capabilities call for; pushes buffer behind them. */
26
+ beginSnapshots(flags: CapabilityFlags): Promise<void>[];
27
+ destroy(): void;
28
+ };
29
+ export type AccountDatasets = ReturnType<typeof createAccountDatasets>;
@@ -0,0 +1,70 @@
1
+ import { ConnectionStatus } from "../contracts/broker.js";
2
+ import type { AccountMetainfo, AccountManagerInfo, IBrokerTerminal, IBrokerConnectionAdapterHost } from "../contracts/broker.js";
3
+ import type { TradingClock } from "../contracts/ports.js";
4
+ import type { CapabilityFlags } from "./capabilities.js";
5
+ import type { ValueStore } from "./value-store.js";
6
+ import { type TradingState, type ConnectionPhase } from "./trading-state.js";
7
+ import { deferred } from "./deferred.js";
8
+ interface Services {
9
+ readonly state: TradingState;
10
+ readonly accounts: ValueStore<readonly AccountMetainfo[]>;
11
+ readonly clock: TradingClock;
12
+ /** Milliseconds to wait for `currentAccountUpdate` after the setter. */
13
+ readonly switchDeadline: number;
14
+ /** Read deadline in milliseconds: a repeated Connected inside it is coalesced; after it the account is re-read. */
15
+ readonly readDeadline: number;
16
+ readonly completion: ReturnType<typeof deferred<void>>;
17
+ readonly brokerReady: ReturnType<typeof deferred<IBrokerTerminal>>;
18
+ broker(): IBrokerTerminal;
19
+ read<T>(load: () => T | Promise<T>, epoch?: number): Promise<T>;
20
+ phase(phase: Exclude<ConnectionPhase, "initializing">, status?: ConnectionStatus, error?: string): void;
21
+ flags(): CapabilityFlags;
22
+ updatePolicy(): void;
23
+ managerInfo(value: AccountManagerInfo): void;
24
+ beginSnapshots(flags: CapabilityFlags): Promise<unknown>[];
25
+ resume(): void;
26
+ suspend(clear: boolean): void;
27
+ invalidateReads(): void;
28
+ invalidateState(clear: boolean): void;
29
+ changed(): void;
30
+ disposeResources(): void;
31
+ }
32
+ /** Bound for pushes buffered before identity is established; the oldest are dropped first. */
33
+ export declare const EARLY_PUSH_LIMIT = 1000;
34
+ /** Owns account identity, hydration, switch deadlines and constructor-push replay. */
35
+ export declare class AccountLifecycle {
36
+ private readonly services;
37
+ private aliveState;
38
+ private constructing;
39
+ private switching;
40
+ private identityEstablished;
41
+ private generationState;
42
+ private hydration;
43
+ private switchOperation;
44
+ private switchTimer;
45
+ private switchTarget;
46
+ private readonly early;
47
+ /** Last connection status seen, to coalesce repeated Connected notifications. */
48
+ private lastStatus;
49
+ /** When the current Connected was announced, on the session clock. */
50
+ private connectedAt;
51
+ constructor(services: Services);
52
+ get alive(): boolean;
53
+ get generation(): number;
54
+ private clearSwitchTimer;
55
+ private invalidateHydration;
56
+ readonly requestRefresh: () => void;
57
+ readonly applyUpdate: (apply: () => void) => void;
58
+ start(): void;
59
+ constructionFailed(cause: unknown): void;
60
+ readonly hydrate: () => Promise<void>;
61
+ readonly refresh: () => Promise<void>;
62
+ private settleAccountSwitch;
63
+ readonly selectAccount: (accountId: string) => Promise<void>;
64
+ readonly accountChanged: () => void;
65
+ readonly destroy: () => void;
66
+ /** The last announced connection status; the broker's getter until the first announcement. */
67
+ private status;
68
+ readonly connectionChanged: IBrokerConnectionAdapterHost["connectionStatusUpdate"];
69
+ }
70
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { AccountMetainfo } from "../contracts/broker.js";
2
+ export type AccountKind = NonNullable<AccountMetainfo["type"]>;
3
+ /** `supportDemoLiveSwitcher`: offer Demo/Live only when the broker returns accounts of both types. */
4
+ export declare function accountTypeChoices(accounts: readonly Readonly<AccountMetainfo>[], enabled: boolean): readonly AccountKind[];
5
+ /** Accounts shown in the account picker: those of the selected type, or all without a switcher. */
6
+ export declare function accountsOfType(accounts: readonly Readonly<AccountMetainfo>[], type: AccountKind | undefined): readonly Readonly<AccountMetainfo>[];
@@ -0,0 +1,12 @@
1
+ /** Least-recently-used retention: reads and writes both refresh recency; replacing a key never evicts an unrelated entry. */
2
+ export declare class BoundedMap<K, V> {
3
+ private readonly capacity;
4
+ private readonly values;
5
+ constructor(capacity?: number);
6
+ get size(): number;
7
+ get(key: K): V | undefined;
8
+ set(key: K, value: V): void;
9
+ delete(key: K): boolean;
10
+ clear(): void;
11
+ [Symbol.iterator](): MapIterator<[K, V]>;
12
+ }
@@ -0,0 +1,32 @@
1
+ import { StopType } from "../contracts/broker.js";
2
+ import type { Brackets, InstrumentInfo, Side } from "../contracts/broker.js";
3
+ export declare const bracketInputUnits: readonly ["price", "distance", "percentage", "money", "equityPercentage"];
4
+ export type BracketInputUnit = (typeof bracketInputUnits)[number];
5
+ export declare function isBracketInputUnit(value: string): value is BracketInputUnit;
6
+ export interface BracketInputContext {
7
+ readonly entry?: number;
8
+ readonly side: Side;
9
+ readonly profit: boolean;
10
+ readonly instrument: InstrumentInfo;
11
+ readonly quantity?: number;
12
+ readonly equity?: number;
13
+ readonly moneyCurrency?: "account" | "instrument";
14
+ readonly accountCurrency?: string;
15
+ /** Account-currency value of one pip per quantity unit. */
16
+ readonly pipValue?: number;
17
+ }
18
+ /** Signed distance is positive on the protective side; wrong-side prices remain visible for validation. */
19
+ export declare function bracketInputValue(price: number | undefined, unit: BracketInputUnit, context: BracketInputContext): number | undefined;
20
+ /**
21
+ * Converting a distance produces a price; typed price values are never silently rounded.
22
+ * `snap: false` keeps the exact price for fields stored as a distance (trailing stops).
23
+ */
24
+ export declare function bracketInputPrice(value: number | undefined, unit: BracketInputUnit, context: BracketInputContext, snap?: boolean): number | undefined;
25
+ /** Default distance, in pips or ticks, of a new take profit (75) or stop (25) from its reference price. */
26
+ export declare function defaultExitDistance(profit: boolean): number;
27
+ /** Price of a new exit leg its default distance from the reference price. */
28
+ export declare function defaultBracketPrice(profit: boolean, context: Omit<BracketInputContext, "profit">, snap?: boolean): number | undefined;
29
+ /** The stop style a set of brackets uses: trailing, then guaranteed, then a plain stop loss. */
30
+ export declare function bracketStopType(brackets: Readonly<Brackets>): StopType | undefined;
31
+ /** Whether brackets carry any kind of stop. */
32
+ export declare function hasStop(brackets: Readonly<Brackets>): boolean;
@@ -0,0 +1,6 @@
1
+ import type { Brackets, Order, InstrumentInfo } from "../contracts/broker.js";
2
+ export declare function validateBracketEditInput(order: Readonly<Order>, instrument: InstrumentInfo): void;
3
+ /** Translate one called child's financial edit without replacing its siblings or parent quantity. */
4
+ export declare function protectionFromChildEdit(parent: Readonly<Brackets & {
5
+ qty: number;
6
+ }>, previous: Readonly<Order>, changed: Readonly<Order>): Brackets;
@@ -0,0 +1,11 @@
1
+ import type { EntityReader } from "./entity-store.js";
2
+ import { type CommandEntityKind } from "./command-keys.js";
3
+ import type { Order } from "../contracts/broker.js";
4
+ export type BracketParentKind = CommandEntityKind;
5
+ export declare function bracketParent(order: Readonly<Order>): {
6
+ kind: BracketParentKind;
7
+ id: string;
8
+ key: string;
9
+ } | undefined;
10
+ /** Live child orders protecting one parent; parent ID and parent type must both match. */
11
+ export declare function activeProtectionChildren(orders: Pick<EntityReader<Order>, "ids" | "get">, kind: BracketParentKind, id: string): Readonly<Order>[];
@@ -0,0 +1,10 @@
1
+ /** Pinned `debug_broker` modes: `normal` omits high-frequency host pushes, `all` logs everything. */
2
+ export type BrokerDebugMode = "all" | "normal" | "host-only" | "broker-only";
3
+ export type BrokerDebugLogger = (message: string, ...details: unknown[]) => void;
4
+ /**
5
+ * Log calls and results on one side of the Broker API. Each call gets an ID so asynchronous results can be matched.
6
+ * Only own function properties are wrapped; values, `this` and thrown errors pass through unchanged.
7
+ */
8
+ export declare function debugBrokerSide<T extends object>(target: T, side: "host" | "broker", mode: BrokerDebugMode | undefined, log: BrokerDebugLogger, sequence: {
9
+ next: number;
10
+ }): T;