@orangecharts/wrun-chart-host 0.4.0 → 0.6.0

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 (331) hide show
  1. package/README.md +17 -5
  2. package/dist/constants/exchange-names.leaf.d.ts +8 -0
  3. package/dist/constants/exchange-names.leaf.js +101 -0
  4. package/dist/constants/feature-flags.constants.js +7 -2
  5. package/dist/constants/kscript-data-interval-restrictions.constants.d.ts +15 -0
  6. package/dist/constants/kscript-data-interval-restrictions.constants.js +40 -0
  7. package/dist/constants/opra-compliance.constants.d.ts +19 -0
  8. package/dist/constants/opra-compliance.constants.js +19 -0
  9. package/dist/constants/replay-ladder.leaf.d.ts +30 -0
  10. package/dist/constants/replay-ladder.leaf.js +99 -0
  11. package/dist/constants/scriptEditor/cme-official-scripts.constants.d.ts +168 -0
  12. package/dist/constants/scriptEditor/cme-official-scripts.constants.js +398 -0
  13. package/dist/constants/scriptEditor/converted-script-id.leaf.d.ts +8 -0
  14. package/dist/constants/scriptEditor/converted-script-id.leaf.js +10 -0
  15. package/dist/constants/scriptEditor/execution.constants.d.ts +4 -0
  16. package/dist/constants/scriptEditor/execution.constants.js +14 -0
  17. package/dist/constants/wrun-prefix-safe.constants.d.ts +23 -0
  18. package/dist/constants/wrun-prefix-safe.constants.js +26 -0
  19. package/dist/host-env.d.ts +301 -22
  20. package/dist/host-env.js +15 -0
  21. package/dist/host-ports.types.d.ts +853 -29
  22. package/dist/index.d.ts +140 -2
  23. package/dist/index.js +140 -2
  24. package/dist/instances/script-engine-worker-ohlcv-transfer.d.ts +31 -0
  25. package/dist/instances/script-engine-worker-ohlcv-transfer.js +164 -0
  26. package/dist/interfaces/market-event.interface.d.ts +231 -0
  27. package/dist/interfaces/market-event.interface.js +15 -0
  28. package/dist/interfaces/opra-realtime.interface.d.ts +70 -134
  29. package/dist/interfaces/opra-realtime.interface.js +34 -59
  30. package/dist/interfaces/replay.interface.d.ts +285 -0
  31. package/dist/interfaces/replay.interface.js +1 -0
  32. package/dist/interfaces/wrun-runtime.interface.d.ts +88 -13
  33. package/dist/interfaces/wrun-runtime.interface.js +17 -3
  34. package/dist/kscript-data/controls/live-ohlcv-merge.util.d.ts +1 -0
  35. package/dist/kscript-data/controls/live-ohlcv-merge.util.js +93 -0
  36. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +5 -1
  37. package/dist/kscript-data/controls/live-trades-merge.util.js +2 -2
  38. package/dist/market-data/billing.interface.d.ts +219 -0
  39. package/dist/market-data/billing.interface.js +58 -0
  40. package/dist/market-data/venue-governed.util.d.ts +2 -0
  41. package/dist/market-data/venue-governed.util.js +10 -0
  42. package/dist/market-data/venue.d.ts +122 -0
  43. package/dist/market-data/venue.js +1 -0
  44. package/dist/market-data/venues/index.d.ts +97 -0
  45. package/dist/market-data/venues/index.js +33 -0
  46. package/dist/market-data/venues/opra.contract.copy.json +35 -0
  47. package/dist/market-data/venues/opra.d.ts +70 -0
  48. package/dist/market-data/venues/opra.js +74 -0
  49. package/dist/replay/replayIndicatorRows.d.ts +31 -0
  50. package/dist/replay/replayIndicatorRows.js +117 -0
  51. package/dist/replay/replayLadder.d.ts +85 -0
  52. package/dist/replay/replayLadder.js +388 -0
  53. package/dist/utility/auth/server-clock.util.d.ts +81 -0
  54. package/dist/utility/auth/server-clock.util.js +238 -0
  55. package/dist/utility/chart/builtin-identity.util.d.ts +18 -0
  56. package/dist/utility/chart/builtin-identity.util.js +51 -0
  57. package/dist/utility/chart/cache-alignment.util.d.ts +454 -0
  58. package/dist/utility/chart/cache-alignment.util.js +926 -0
  59. package/dist/utility/chart/chart-data-fetch-generation.util.d.ts +15 -0
  60. package/dist/utility/chart/chart-data-fetch-generation.util.js +22 -0
  61. package/dist/utility/chart/chart-mount-epoch.util.d.ts +17 -0
  62. package/dist/utility/chart/chart-mount-epoch.util.js +61 -0
  63. package/dist/utility/chart/chart-time-domain.util.d.ts +12 -0
  64. package/dist/utility/chart/chart-time-domain.util.js +23 -0
  65. package/dist/utility/chart/color-customization.leaf.d.ts +10 -0
  66. package/dist/utility/chart/color-customization.leaf.js +16 -0
  67. package/dist/utility/chart/footprint-tick-grid.util.d.ts +106 -0
  68. package/dist/utility/chart/footprint-tick-grid.util.js +167 -0
  69. package/dist/utility/chart/gesture-timing.leaf.d.ts +29 -0
  70. package/dist/utility/chart/gesture-timing.leaf.js +29 -0
  71. package/dist/utility/chart/governed-contract-coin.util.d.ts +22 -0
  72. package/dist/utility/chart/governed-contract-coin.util.js +39 -0
  73. package/dist/utility/chart/host-bar-placement.util.d.ts +107 -0
  74. package/dist/utility/chart/host-bar-placement.util.js +447 -0
  75. package/dist/utility/chart/index-host-tier.util.d.ts +31 -0
  76. package/dist/utility/chart/index-host-tier.util.js +118 -0
  77. package/dist/utility/chart/index-mode-admission.util.d.ts +34 -0
  78. package/dist/utility/chart/index-mode-admission.util.js +67 -0
  79. package/dist/utility/chart/indicator-error-message.util.d.ts +35 -0
  80. package/dist/utility/chart/indicator-error-message.util.js +44 -0
  81. package/dist/utility/chart/kscript-apply-fingerprint.util.d.ts +65 -0
  82. package/dist/utility/chart/kscript-apply-fingerprint.util.js +357 -0
  83. package/dist/utility/chart/kscript-chart-flush.leaf.d.ts +22 -0
  84. package/dist/utility/chart/kscript-chart-flush.leaf.js +13 -0
  85. package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +6 -0
  86. package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +27 -0
  87. package/dist/utility/chart/kscript-integration-decision.leaf.d.ts +89 -0
  88. package/dist/utility/chart/kscript-integration-decision.leaf.js +80 -0
  89. package/dist/utility/chart/kscript-live-coalesce.util.d.ts +76 -0
  90. package/dist/utility/chart/kscript-live-coalesce.util.js +156 -0
  91. package/dist/utility/chart/kscript-live-rest-pace.util.d.ts +34 -0
  92. package/dist/utility/chart/kscript-live-rest-pace.util.js +134 -0
  93. package/dist/utility/chart/kscript-live-source-identity.util.d.ts +98 -0
  94. package/dist/utility/chart/kscript-live-source-identity.util.js +121 -0
  95. package/dist/utility/chart/kscript-mounted-plot-set.leaf.d.ts +48 -0
  96. package/dist/utility/chart/kscript-mounted-plot-set.leaf.js +145 -0
  97. package/dist/utility/chart/kscript-perf-tracker.util.d.ts +243 -0
  98. package/dist/utility/chart/kscript-perf-tracker.util.js +522 -0
  99. package/dist/utility/chart/kscript-run-interval-projection.util.d.ts +43 -0
  100. package/dist/utility/chart/kscript-run-interval-projection.util.js +471 -0
  101. package/dist/utility/chart/kscript-run-result-equality.util.d.ts +38 -0
  102. package/dist/utility/chart/kscript-run-result-equality.util.js +89 -0
  103. package/dist/utility/chart/kscript-settings-revision.leaf.d.ts +2 -0
  104. package/dist/utility/chart/kscript-settings-revision.leaf.js +12 -0
  105. package/dist/utility/chart/kscript-source-degrade.leaf.d.ts +63 -0
  106. package/dist/utility/chart/kscript-source-degrade.leaf.js +68 -0
  107. package/dist/utility/chart/kscript-source-retention.util.d.ts +134 -0
  108. package/dist/utility/chart/kscript-source-retention.util.js +218 -0
  109. package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +57 -0
  110. package/dist/utility/chart/kscript-standin-identity.leaf.js +61 -0
  111. package/dist/utility/chart/kscript-titancharts-preparation.util.d.ts +15 -0
  112. package/dist/utility/chart/kscript-titancharts-preparation.util.js +376 -0
  113. package/dist/utility/chart/kscript-titancharts-render-keys.constants.d.ts +9 -0
  114. package/dist/utility/chart/kscript-titancharts-render-keys.constants.js +130 -0
  115. package/dist/utility/chart/kscript-venue-policy.util.d.ts +217 -0
  116. package/dist/utility/chart/kscript-venue-policy.util.js +324 -0
  117. package/dist/utility/chart/live-cadence.util.d.ts +38 -0
  118. package/dist/utility/chart/live-cadence.util.js +37 -0
  119. package/dist/utility/chart/live-feed-series-match.leaf.d.ts +13 -0
  120. package/dist/utility/chart/live-feed-series-match.leaf.js +21 -0
  121. package/dist/utility/chart/local-engine-self-heal-backoff.util.d.ts +46 -0
  122. package/dist/utility/chart/local-engine-self-heal-backoff.util.js +46 -0
  123. package/dist/utility/chart/local-engine-uninit.leaf.d.ts +21 -0
  124. package/dist/utility/chart/local-engine-uninit.leaf.js +22 -0
  125. package/dist/utility/chart/local-kscript-source-revalidation.util.d.ts +62 -0
  126. package/dist/utility/chart/local-kscript-source-revalidation.util.js +123 -0
  127. package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +214 -0
  128. package/dist/utility/chart/local-kscript-warmup-depth.util.js +376 -0
  129. package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.d.ts +85 -0
  130. package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.js +197 -0
  131. package/dist/utility/chart/local-technical-script-range.leaf.d.ts +72 -0
  132. package/dist/utility/chart/local-technical-script-range.leaf.js +126 -0
  133. package/dist/utility/chart/mixed-mode.util.d.ts +167 -0
  134. package/dist/utility/chart/mixed-mode.util.js +139 -0
  135. package/dist/utility/chart/ohlcv-row-readiness.util.d.ts +36 -0
  136. package/dist/utility/chart/ohlcv-row-readiness.util.js +90 -0
  137. package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +19 -0
  138. package/dist/utility/chart/opra-user-scripts-gate.util.js +32 -0
  139. package/dist/utility/chart/overlay-execution-guard-key.leaf.d.ts +8 -0
  140. package/dist/utility/chart/overlay-execution-guard-key.leaf.js +10 -0
  141. package/dist/utility/chart/price-precision.util.d.ts +40 -0
  142. package/dist/utility/chart/price-precision.util.js +70 -0
  143. package/dist/utility/chart/profile-block-size.util.d.ts +64 -0
  144. package/dist/utility/chart/profile-block-size.util.js +141 -0
  145. package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.d.ts +11 -0
  146. package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.js +29 -0
  147. package/dist/utility/chart/protected-kscript-empty-output.util.d.ts +28 -0
  148. package/dist/utility/chart/protected-kscript-empty-output.util.js +84 -0
  149. package/dist/utility/chart/run-interval-unservable.leaf.d.ts +9 -0
  150. package/dist/utility/chart/run-interval-unservable.leaf.js +20 -0
  151. package/dist/utility/chart/run-interval-warmup.leaf.d.ts +19 -0
  152. package/dist/utility/chart/run-interval-warmup.leaf.js +35 -0
  153. package/dist/utility/chart/titan-constants.pin.d.ts +9 -5
  154. package/dist/utility/chart/titan-constants.pin.js +18 -5
  155. package/dist/utility/chart/warmup-backfill-retry.leaf.d.ts +9 -0
  156. package/dist/utility/chart/warmup-backfill-retry.leaf.js +9 -0
  157. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +11 -2
  158. package/dist/utility/chart/wrun-bar-session-facts.util.js +10 -3
  159. package/dist/utility/chart/wrun-run-result.util.d.ts +5 -1
  160. package/dist/utility/chart/wrun-run-result.util.js +20 -14
  161. package/dist/utility/common/data-processing.util.d.ts +138 -0
  162. package/dist/utility/common/data-processing.util.js +346 -0
  163. package/dist/utility/common/visible-timeout.util.d.ts +13 -4
  164. package/dist/utility/common/visible-timeout.util.js +23 -8
  165. package/dist/utility/exchange-format.leaf.d.ts +1 -0
  166. package/dist/utility/exchange-format.leaf.js +47 -0
  167. package/dist/utility/market-events/earnings-scope.util.d.ts +60 -0
  168. package/dist/utility/market-events/earnings-scope.util.js +92 -0
  169. package/dist/utility/market-events/market-events.util.d.ts +147 -0
  170. package/dist/utility/market-events/market-events.util.js +392 -0
  171. package/dist/utility/market-events/zoned-clock.util.d.ts +1 -0
  172. package/dist/utility/market-events/zoned-clock.util.js +11 -0
  173. package/dist/utility/options/option-venue-disclosure.util.d.ts +43 -0
  174. package/dist/utility/options/option-venue-disclosure.util.js +56 -0
  175. package/dist/utility/scriptEditor/package-semver.util.d.ts +51 -0
  176. package/dist/utility/scriptEditor/package-semver.util.js +120 -0
  177. package/dist/utility/scriptEditor/temp-script-id.util.d.ts +18 -0
  178. package/dist/utility/scriptEditor/temp-script-id.util.js +25 -0
  179. package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.d.ts +20 -0
  180. package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.js +81 -0
  181. package/dist/utility/v2/governed-tier.leaf.d.ts +103 -0
  182. package/dist/utility/v2/governed-tier.leaf.js +113 -0
  183. package/dist/utility/watchlist/import/import-request.leaf.d.ts +10 -0
  184. package/dist/utility/watchlist/import/import-request.leaf.js +10 -0
  185. package/dist/utility/wrun/sources/lanes/series.js +2 -2
  186. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +4 -4
  187. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +5 -6
  188. package/dist/utility/wrun/wrun-alert-outputs.registry.d.ts +166 -0
  189. package/dist/utility/wrun/wrun-alert-outputs.registry.js +219 -0
  190. package/dist/utility/wrun/wrun-bar-count.util.d.ts +94 -0
  191. package/dist/utility/wrun/wrun-bar-count.util.js +274 -0
  192. package/dist/utility/wrun/wrun-chart-context-names.util.d.ts +84 -0
  193. package/dist/utility/wrun/wrun-chart-context-names.util.js +186 -0
  194. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +253 -0
  195. package/dist/utility/wrun/wrun-chart-market-facts.util.js +731 -0
  196. package/dist/utility/wrun/wrun-cloud-opra-stamp.util.d.ts +28 -0
  197. package/dist/utility/wrun/wrun-cloud-opra-stamp.util.js +45 -0
  198. package/dist/utility/wrun/wrun-coin-lane-live.util.d.ts +18 -0
  199. package/dist/utility/wrun/wrun-coin-lane-live.util.js +47 -0
  200. package/dist/utility/wrun/wrun-deadline.util.js +2 -1
  201. package/dist/utility/wrun/wrun-debug-output.util.d.ts +39 -0
  202. package/dist/utility/wrun/wrun-debug-output.util.js +63 -0
  203. package/dist/utility/wrun/wrun-declared-warmup.util.d.ts +113 -0
  204. package/dist/utility/wrun/wrun-declared-warmup.util.js +181 -0
  205. package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +43 -0
  206. package/dist/utility/wrun/wrun-draft-legend-note.util.js +158 -0
  207. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +181 -0
  208. package/dist/utility/wrun/wrun-draft-overlay.util.js +357 -0
  209. package/dist/utility/wrun/wrun-draw-skipped.leaf.d.ts +16 -0
  210. package/dist/utility/wrun/wrun-draw-skipped.leaf.js +16 -0
  211. package/dist/utility/wrun/wrun-earnings-facts.util.d.ts +42 -0
  212. package/dist/utility/wrun/wrun-earnings-facts.util.js +131 -0
  213. package/dist/utility/wrun/wrun-first-run-depth.util.d.ts +32 -0
  214. package/dist/utility/wrun/wrun-first-run-depth.util.js +118 -0
  215. package/dist/utility/wrun/wrun-gate-plane-readers.util.d.ts +24 -0
  216. package/dist/utility/wrun/wrun-gate-plane-readers.util.js +31 -0
  217. package/dist/utility/wrun/wrun-held-lanes.util.d.ts +32 -0
  218. package/dist/utility/wrun/wrun-held-lanes.util.js +94 -0
  219. package/dist/utility/wrun/wrun-host-visible-clock.util.d.ts +2 -0
  220. package/dist/utility/wrun/wrun-host-visible-clock.util.js +17 -0
  221. package/dist/utility/wrun/wrun-host.service.d.ts +330 -0
  222. package/dist/utility/wrun/wrun-host.service.js +855 -0
  223. package/dist/utility/wrun/wrun-hover.util.d.ts +3 -0
  224. package/dist/utility/wrun/wrun-hover.util.js +25 -4
  225. package/dist/utility/wrun/wrun-inert-legend.util.d.ts +33 -0
  226. package/dist/utility/wrun/wrun-inert-legend.util.js +125 -0
  227. package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +155 -0
  228. package/dist/utility/wrun/wrun-input-requirements.leaf.js +450 -0
  229. package/dist/utility/wrun/wrun-integration-route.util.d.ts +51 -0
  230. package/dist/utility/wrun/wrun-integration-route.util.js +59 -0
  231. package/dist/utility/wrun/wrun-latest-history.leaf.d.ts +8 -0
  232. package/dist/utility/wrun/wrun-latest-history.leaf.js +8 -0
  233. package/dist/utility/wrun/wrun-legend-hover.lazy.d.ts +12 -0
  234. package/dist/utility/wrun/wrun-legend-hover.lazy.js +96 -0
  235. package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +21 -0
  236. package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +21 -0
  237. package/dist/utility/wrun/wrun-live-hidden-hold.util.d.ts +23 -0
  238. package/dist/utility/wrun/wrun-live-hidden-hold.util.js +13 -0
  239. package/dist/utility/wrun/wrun-live-intake.util.d.ts +374 -0
  240. package/dist/utility/wrun/wrun-live-intake.util.js +2027 -0
  241. package/dist/utility/wrun/wrun-live-patch.util.d.ts +116 -0
  242. package/dist/utility/wrun/wrun-live-patch.util.js +523 -0
  243. package/dist/utility/wrun/wrun-live-tick.util.d.ts +619 -0
  244. package/dist/utility/wrun/wrun-live-tick.util.js +4974 -0
  245. package/dist/utility/wrun/wrun-loading-owner.util.d.ts +58 -0
  246. package/dist/utility/wrun/wrun-loading-owner.util.js +89 -0
  247. package/dist/utility/wrun/wrun-official-scope.leaf.d.ts +29 -0
  248. package/dist/utility/wrun/wrun-official-scope.leaf.js +36 -0
  249. package/dist/utility/wrun/wrun-oi-lane.util.d.ts +27 -0
  250. package/dist/utility/wrun/wrun-oi-lane.util.js +42 -0
  251. package/dist/utility/wrun/wrun-options-stop.util.d.ts +52 -0
  252. package/dist/utility/wrun/wrun-options-stop.util.js +123 -0
  253. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +719 -0
  254. package/dist/utility/wrun/wrun-overlay-drivers.util.js +1180 -0
  255. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +50 -0
  256. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +131 -0
  257. package/dist/utility/wrun/wrun-overlay-lifecycle.util.d.ts +118 -0
  258. package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +466 -0
  259. package/dist/utility/wrun/wrun-overlay-metadata.util.d.ts +45 -0
  260. package/dist/utility/wrun/wrun-overlay-metadata.util.js +112 -0
  261. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +114 -0
  262. package/dist/utility/wrun/wrun-overlay-recovery.util.js +971 -0
  263. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +858 -0
  264. package/dist/utility/wrun/wrun-overlay-run.util.js +11013 -0
  265. package/dist/utility/wrun/wrun-pack.util.d.ts +2 -1
  266. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +24 -9
  267. package/dist/utility/wrun/wrun-panel-mount.util.js +138 -43
  268. package/dist/utility/wrun/wrun-param-map.util.d.ts +19 -4
  269. package/dist/utility/wrun/wrun-param-map.util.js +40 -47
  270. package/dist/utility/wrun/wrun-param-values.util.d.ts +9 -3
  271. package/dist/utility/wrun/wrun-param-values.util.js +5 -5
  272. package/dist/utility/wrun/wrun-prefix-cohort.util.d.ts +93 -0
  273. package/dist/utility/wrun/wrun-prefix-cohort.util.js +484 -0
  274. package/dist/utility/wrun/wrun-prefix-lanes.util.d.ts +114 -0
  275. package/dist/utility/wrun/wrun-prefix-lanes.util.js +486 -0
  276. package/dist/utility/wrun/wrun-prefix-proof.util.d.ts +317 -0
  277. package/dist/utility/wrun/wrun-prefix-proof.util.js +630 -0
  278. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +73 -0
  279. package/dist/utility/wrun/wrun-refusal-surface.util.js +380 -0
  280. package/dist/utility/wrun/wrun-refusal-text.util.d.ts +15 -0
  281. package/dist/utility/wrun/wrun-refusal-text.util.js +40 -0
  282. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +5 -3
  283. package/dist/utility/wrun/wrun-replay-lane.util.d.ts +139 -0
  284. package/dist/utility/wrun/wrun-replay-lane.util.js +520 -0
  285. package/dist/utility/wrun/wrun-replay-rows.util.d.ts +21 -0
  286. package/dist/utility/wrun/wrun-replay-rows.util.js +172 -0
  287. package/dist/utility/wrun/wrun-row-source-factory.d.ts +53 -0
  288. package/dist/utility/wrun/wrun-row-source-factory.js +435 -0
  289. package/dist/utility/wrun/wrun-run-cells.util.d.ts +36 -0
  290. package/dist/utility/wrun/wrun-run-cells.util.js +46 -0
  291. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +133 -0
  292. package/dist/utility/wrun/wrun-run-interval-session.util.js +121 -0
  293. package/dist/utility/wrun/wrun-run-interval.util.d.ts +98 -0
  294. package/dist/utility/wrun/wrun-run-interval.util.js +207 -0
  295. package/dist/utility/wrun/wrun-run-retained.util.d.ts +122 -0
  296. package/dist/utility/wrun/wrun-run-retained.util.js +255 -0
  297. package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +184 -0
  298. package/dist/utility/wrun/wrun-sandbox-row-source.js +444 -0
  299. package/dist/utility/wrun/wrun-script-inputs.util.js +4 -4
  300. package/dist/utility/wrun/wrun-series-stream.util.d.ts +86 -0
  301. package/dist/utility/wrun/wrun-series-stream.util.js +537 -0
  302. package/dist/utility/wrun/wrun-sha256.leaf.d.ts +13 -0
  303. package/dist/utility/wrun/wrun-sha256.leaf.js +84 -0
  304. package/dist/utility/wrun/wrun-sheet-remembered.util.d.ts +21 -0
  305. package/dist/utility/wrun/wrun-sheet-remembered.util.js +36 -0
  306. package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.d.ts +7 -0
  307. package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.js +12 -0
  308. package/dist/utility/wrun/wrun-socket-row-source.js +4 -2
  309. package/dist/utility/wrun/wrun-source-rows.util.d.ts +175 -3
  310. package/dist/utility/wrun/wrun-source-rows.util.js +294 -8
  311. package/dist/utility/wrun/wrun-stats-strip.util.d.ts +46 -0
  312. package/dist/utility/wrun/wrun-stats-strip.util.js +87 -0
  313. package/dist/utility/wrun/wrun-table-chrome.util.d.ts +163 -0
  314. package/dist/utility/wrun/wrun-table-chrome.util.js +557 -0
  315. package/dist/utility/wrun/wrun-text-params.util.d.ts +11 -6
  316. package/dist/utility/wrun/wrun-text-params.util.js +19 -30
  317. package/dist/utility/wrun/wrun-transient-rerun.util.d.ts +64 -0
  318. package/dist/utility/wrun/wrun-transient-rerun.util.js +317 -0
  319. package/dist/utility/wrun/wrun-twin-lookback.util.d.ts +10 -0
  320. package/dist/utility/wrun/wrun-twin-lookback.util.js +43 -0
  321. package/dist/utility/wrun/wrun-warmup-head-store.util.d.ts +41 -0
  322. package/dist/utility/wrun/wrun-warmup-head-store.util.js +120 -0
  323. package/dist/utility/wrun-alert-params.leaf.d.ts +24 -0
  324. package/dist/utility/wrun-alert-params.leaf.js +24 -0
  325. package/dist/utils/replay/replay-buffer-math.d.ts +148 -0
  326. package/dist/utils/replay/replay-buffer-math.js +684 -0
  327. package/dist/workers/wrun/wrun-abi-host.d.ts +203 -0
  328. package/dist/workers/wrun/wrun-abi-host.js +1220 -0
  329. package/dist/workers/wrun/wrun-engine-handler.d.ts +20 -0
  330. package/dist/workers/wrun/wrun-engine-handler.js +380 -0
  331. package/package.json +3 -3
@@ -0,0 +1,118 @@
1
+ /**
2
+ * A twin's FIRST-RUN ordering, the kScript lane's (chart.add-indicator.ts, the local script init):
3
+ * before its first run on the chart a script waits for an in-flight main candle fetch to commit
4
+ * (`waitForMainCandleFetchCommit`, bounded) and buys the pages its declared lookback owes the loaded
5
+ * window (`prefetchDeclaredDepthBeforeFirstRun`: the same ledger, chooser and landed rule as every
6
+ * warm-up page), so the first picture is computed on the history the declaration needs. The kScript
7
+ * Anchored VWAP (a 366-day anchor, 5,000 bars at 1h) never shows a picture computed on the 568 bars a
8
+ * fresh 1h chart holds; its twin computed exactly that and stayed there until a wave reran it
9
+ * (parity sweep 10-06, m_vwap 80,988.64 against 80,002.95).
10
+ *
11
+ * The run pass calls this for an `initial` run (the add, the rehydrate) whose lookback is the
12
+ * original's (wrun-twin-lookback.util): every later run reads the same lookback through the
13
+ * post-run ask (`askWrunWarmupBackfillIfOwed`), as the kScript lane's later results do. Every read
14
+ * of the chart goes through the executor ports `chart.askDeclaredDepthBeforeRun` and
15
+ * `chart.isWarmupRoundLandedOn` (web binds the ask util's `askLocalKScriptDeclaredDepthBeforeRun` and
16
+ * `isLocalKScriptWarmupRoundLandedOn`, web-ports/executor.ts), so the ordering is driven by fakes in the
17
+ * run pass specs.
18
+ */
19
+ import { wrunChartHostEnv } from '../../host-env.js';
20
+ import { loadedBarsOfWindow } from '../chart/local-kscript-warmup-depth.util.js';
21
+ import { WARMUP_BACKFILL_GESTURE_RETRY_LIMIT, WARMUP_BACKFILL_GESTURE_RETRY_MS, } from '../chart/warmup-backfill-retry.leaf.js';
22
+ /** The kScript first run's bound on an in-flight main candle fetch (LOCAL_KSCRIPT_FIRST_RUN_MAIN_FETCH_WAIT_MS). */
23
+ export const WRUN_FIRST_RUN_MAIN_FETCH_WAIT_MS = 4_000;
24
+ /** The kScript first run's poll between its rounds (LOCAL_KSCRIPT_FIRST_RUN_DEPTH_POLL_MS). */
25
+ export const WRUN_FIRST_RUN_DEPTH_POLL_MS = 100;
26
+ /**
27
+ * The whole ordering's ceiling. The kScript lane holds its first run up to 75 s; a wrun first run
28
+ * rides inside the add's 90 s compute deadline (WRUN_RUN_DEADLINE_MS) with its own fetches and
29
+ * sandbox run after the ordering, so the ordering takes half of it. Past the ceiling the run computes
30
+ * on the rows at hand and the post-run ask owes the rest, as on the kScript lane.
31
+ */
32
+ export const WRUN_FIRST_RUN_DEPTH_HOLD_CEILING_MS = 45_000;
33
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
34
+ function loadedBarsOf(input) {
35
+ const rows = input.tc.metadata?.[0];
36
+ const raw = rows?.rawData;
37
+ const first = typeof raw?.[0]?.[0] === 'number' ? raw[0][0] : null;
38
+ const last = raw?.length ? raw[raw.length - 1]?.[0] : undefined;
39
+ return loadedBarsOfWindow(first, typeof last === 'number' ? last : null, input.intervalMs);
40
+ }
41
+ /** Order the history a twin's first run computes on (see the module note); resolves with the outcome
42
+ * and logs it as `wrun-first-run-declared-depth`. Never throws. */
43
+ export async function orderWrunFirstRunHistory(input) {
44
+ const now = input.now ?? Date.now;
45
+ const tick = input.tick ?? sleep;
46
+ const startedAt = now();
47
+ const pastCeiling = () => now() - startedAt >= WRUN_FIRST_RUN_DEPTH_HOLD_CEILING_MS;
48
+ const ring = { lane: 'wrun', phase: 'first-run' };
49
+ const loadedBarsBefore = loadedBarsOf(input);
50
+ const finish = (outcome, rounds) => {
51
+ wrunChartHostEnv().diagnostics.debug('wrun-first-run-declared-depth', {
52
+ chartIndex: input.chartIndex,
53
+ indicatorId: input.indicatorId,
54
+ ...ring,
55
+ lookbackBars: input.lookbackBars,
56
+ loadedBarsBefore,
57
+ loadedBarsAfter: loadedBarsOf(input),
58
+ rounds,
59
+ outcome,
60
+ waitedMs: now() - startedAt,
61
+ });
62
+ return outcome;
63
+ };
64
+ try {
65
+ // The first run's span waits for an in-flight main candle commit (a boot or a switch landing
66
+ // its window), bounded; on timeout it proceeds on the rows at hand.
67
+ for (let waited = 0; input.isMainCandleFetchInFlight?.() === true && waited < WRUN_FIRST_RUN_MAIN_FETCH_WAIT_MS;) {
68
+ await tick(WRUN_FIRST_RUN_DEPTH_POLL_MS);
69
+ waited += WRUN_FIRST_RUN_DEPTH_POLL_MS;
70
+ if (!input.isCurrent())
71
+ return finish('superseded', 0);
72
+ }
73
+ const loaded = loadedBarsOf(input);
74
+ if (loaded === null || loaded >= input.lookbackBars)
75
+ return finish('fits', 0);
76
+ let rounds = 0;
77
+ let gestureRetries = 0;
78
+ for (;;) {
79
+ if (!input.isCurrent())
80
+ return finish('superseded', rounds);
81
+ if (pastCeiling())
82
+ return finish('ceiling', rounds);
83
+ const ask = wrunChartHostEnv().chart.askDeclaredDepthBeforeRun({ ...input, ringDetails: ring });
84
+ if (ask === null)
85
+ return finish('read-failed', rounds);
86
+ if (ask.requested || ask.reason === 'page-pending') {
87
+ if (ask.requested)
88
+ rounds += 1;
89
+ // The landed rule between rounds: the page is on the chart once its start reaches the
90
+ // asked start, or once the chain stopped (a clipped page is judged on what it bought).
91
+ while (!wrunChartHostEnv().chart.isWarmupRoundLandedOn(input)) {
92
+ if (pastCeiling())
93
+ return finish('ceiling', rounds);
94
+ await tick(WRUN_FIRST_RUN_DEPTH_POLL_MS);
95
+ if (!input.isCurrent())
96
+ return finish('superseded', rounds);
97
+ }
98
+ continue;
99
+ }
100
+ // The camera settle reads as motion for a moment (the kScript first run retries the same way).
101
+ if (ask.reason === 'gesture-active' && gestureRetries < WARMUP_BACKFILL_GESTURE_RETRY_LIMIT) {
102
+ gestureRetries += 1;
103
+ await tick(WARMUP_BACKFILL_GESTURE_RETRY_MS);
104
+ continue;
105
+ }
106
+ return finish(ask.reason, rounds);
107
+ }
108
+ }
109
+ catch (error) {
110
+ wrunChartHostEnv().diagnostics.debug('local-kscript-warmup-backfill-error', {
111
+ chartIndex: input.chartIndex,
112
+ indicatorId: input.indicatorId,
113
+ ...ring,
114
+ message: error instanceof Error ? error.message : String(error),
115
+ });
116
+ return 'read-failed';
117
+ }
118
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Which wrun overlays read which gate plane: per overlay, its chart and the planes its latest full run's lanes read
3
+ * (wrun-options-stop.util `wrunLaneGatePlanes`, a lane sent or stopped alike). The run notes it; the recovery ladders
4
+ * (wrun-overlay-recovery.util `rerunWrunGatePlaneReaders`) read it on each edge of a plane's session latch
5
+ * (gate-session-latch.util): once another screen takes the session the overlays run again and their lanes say why they
6
+ * stopped, once this tab takes it back they run again and read.
7
+ *
8
+ * A leaf: type imports only, so the recovery ladders read it without the lane registries on their import graph.
9
+ */
10
+ import type { WrunRefusalGatePlane } from './wrun-refusal.util.js';
11
+ /** A full run read these gate planes; an empty set forgets the overlay. */
12
+ export declare function noteWrunGatePlanesRead(chartIndex: number, indicatorId: string, planes: Iterable<WrunRefusalGatePlane>): void;
13
+ /** A full run stopped on this plane (a chain its plan stopped before the lanes were noted, or a hold): the overlay
14
+ * reads it too, beside what the run noted, so the take-back runs it again. */
15
+ export declare function noteWrunGatePlaneStopped(chartIndex: number, indicatorId: string, plane: WrunRefusalGatePlane): void;
16
+ /** The overlays whose latest full run read the plane, with their charts. */
17
+ export declare function wrunGatePlaneReaders(plane: WrunRefusalGatePlane): Array<{
18
+ indicatorId: string;
19
+ chartIndex: number;
20
+ }>;
21
+ /** The overlay left (a teardown, a suspend): it reads no plane until its next full run. */
22
+ export declare function forgetWrunGatePlaneReader(indicatorId: string): void;
23
+ /** Test hook. */
24
+ export declare function __resetWrunGatePlaneReadersForTests(): void;
@@ -0,0 +1,31 @@
1
+ const readers = new Map();
2
+ /** A full run read these gate planes; an empty set forgets the overlay. */
3
+ export function noteWrunGatePlanesRead(chartIndex, indicatorId, planes) {
4
+ const read = new Set(planes);
5
+ if (read.size === 0)
6
+ readers.delete(indicatorId);
7
+ else
8
+ readers.set(indicatorId, { chartIndex, planes: read });
9
+ }
10
+ /** A full run stopped on this plane (a chain its plan stopped before the lanes were noted, or a hold): the overlay
11
+ * reads it too, beside what the run noted, so the take-back runs it again. */
12
+ export function noteWrunGatePlaneStopped(chartIndex, indicatorId, plane) {
13
+ const known = readers.get(indicatorId);
14
+ const planes = new Set(known !== undefined && known.chartIndex === chartIndex ? known.planes : []);
15
+ planes.add(plane);
16
+ readers.set(indicatorId, { chartIndex, planes });
17
+ }
18
+ /** The overlays whose latest full run read the plane, with their charts. */
19
+ export function wrunGatePlaneReaders(plane) {
20
+ return [...readers]
21
+ .filter(([, reader]) => reader.planes.has(plane))
22
+ .map(([indicatorId, { chartIndex }]) => ({ indicatorId, chartIndex }));
23
+ }
24
+ /** The overlay left (a teardown, a suspend): it reads no plane until its next full run. */
25
+ export function forgetWrunGatePlaneReader(indicatorId) {
26
+ readers.delete(indicatorId);
27
+ }
28
+ /** Test hook. */
29
+ export function __resetWrunGatePlaneReadersForTests() {
30
+ readers.clear();
31
+ }
@@ -0,0 +1,32 @@
1
+ import type { WrunRunWindow } from './wrun-lifecycle.contract.js';
2
+ import type { WrunOverlayLiveContext } from './wrun-overlay-drivers.util.js';
3
+ import type { WrunLaneAcquisition } from './wrun-live-intake.util.js';
4
+ export interface WrunHeldLaneRows {
5
+ /** A copy of the session's buffer: the new session owns it. */
6
+ rows: unknown[];
7
+ /** The session's acquisition record (its payload, transport and lattice included). */
8
+ acquisition: WrunLaneAcquisition;
9
+ /** The session's coverage watermark for the lane, inherited by the new session. */
10
+ coveredThroughTs: number;
11
+ }
12
+ export interface WrunHeldLanes {
13
+ /** The held rows of `lane` when the session asked it as `payload` asks, else undefined. */
14
+ take(lane: string, payload: WrunLaneAcquisition): WrunHeldLaneRows | undefined;
15
+ }
16
+ export declare function planWrunHeldLanes(input: {
17
+ /** The overlay's live session before this run (the run's own `heldContext`). */
18
+ held: WrunOverlayLiveContext | undefined;
19
+ reason: string;
20
+ replay: boolean;
21
+ chartIndex: number;
22
+ fetchKey: string;
23
+ marketIdentity: string;
24
+ /** The run clock's interval (the run interval at another timeframe). */
25
+ intervalMs: number;
26
+ /** The window start this run asks its lanes from. */
27
+ fromTs: number;
28
+ window: WrunRunWindow | undefined;
29
+ /** The profile lattice this chart resolves now (resolveWrunVolumeProfileGrid): a profile held
30
+ * on another lattice is asked again. */
31
+ volumeProfileGrid?: number;
32
+ }): WrunHeldLanes | undefined;
@@ -0,0 +1,94 @@
1
+ /**
2
+ * The held lanes: a settings save computes over the source rows its overlay's live session already
3
+ * holds, the way a held run-interval session's bars are reused (wrun-run-interval-session.util
4
+ * planWrunRunIntervalRows). The session's lane buffers are the last full run's fetched rows,
5
+ * extended by the push intake's folds and corrected by the tick's reconcile, so they are the rows a
6
+ * switch flip or a colour pick reads; asking them again is a refetch of rows the chart already
7
+ * has. Field case 2026-10-06 (the Bar Statistics twin): every toggle re-asked open interest,
8
+ * liquidations, funding, the profile and the book once the source-row cache's poll-cycle
9
+ * freshness had run out (kscript-source-row-cache.util), 1.1 to 5.0 s from the click to the
10
+ * repaint, while the built-in recomputes over the data its engine holds.
11
+ *
12
+ * Only a settings save (`reason: 'settings'`) holds, and only a lane its session can serve as a
13
+ * fresh ask would: the same overlay lane on the same chart (its fetch key), the same market and
14
+ * clock, the whole loaded window on both sides with the session's lanes asked from the same start
15
+ * or earlier, a lane asked exactly the same way (its acquisition, the resolved chart words, the
16
+ * transport and the lattice aside), not degraded and carrying a coverage watermark. The new
17
+ * session inherits that watermark, so the reconcile right after the run still re-asks the tail.
18
+ * Every other lane, and every other run, fetches as before. Pure: the caller hands the previous
19
+ * session in.
20
+ */
21
+ import isEqual from 'lodash-es/isEqual.js';
22
+ import { isWrunTradesLegLane } from './wrun-trades-lane.util.js';
23
+ /** The lanes a session may hold, by the buffer each one fills: the row builder's history lanes,
24
+ * each one window ask the reconcile keeps current, and every trades leg lane (`tradeLegRows`, by
25
+ * its id: the id names the market, so a held leg is that market's own). The option-summary,
26
+ * chain, ETF flow and registry poll lanes keep their own asks. */
27
+ const HELD_LANE_ROWS = {
28
+ book: 'bookRows',
29
+ trades: 'buySellVolumeRows',
30
+ trades_usd: 'buySellVolumeUsdRows',
31
+ oi: 'openInterestRows',
32
+ volume_profile: 'volumeProfileRows',
33
+ trade_volume_by_size: 'tradeVolumeBySizeRows',
34
+ liquidations: 'liquidationRows',
35
+ funding: 'fundingRateRows',
36
+ tape: 'tapeRows',
37
+ };
38
+ /** Acquisition words that are not the lane's own ask: the chart words the chart's fetch resolves
39
+ * into the payload object in place (titan-charts dataFetch writes the chart's symbol, exchange and
40
+ * coin over the placeholders and stamps the interval, and the acquisition records that object),
41
+ * judged here by the market identity and the clock instead; and how the history was served, the
42
+ * book's transport (the packed worker or the plain lane) and the profile's lattice step. */
43
+ const NOT_THE_ASK = new Set([
44
+ 'symbol',
45
+ 'exchange',
46
+ 'coin',
47
+ 'interval',
48
+ 'preferPackedOrderbookWorker',
49
+ 'minimumBarHeight',
50
+ ]);
51
+ function askOf(acquisition) {
52
+ return Object.fromEntries(Object.entries(acquisition).filter(([word]) => !NOT_THE_ASK.has(word)));
53
+ }
54
+ export function planWrunHeldLanes(input) {
55
+ const { held } = input;
56
+ if (input.reason !== 'settings' || input.replay || held === undefined)
57
+ return undefined;
58
+ if (held.replay === true || held.liveSuspended)
59
+ return undefined;
60
+ if (held.chartIndex !== input.chartIndex || held.fetchKey !== input.fetchKey)
61
+ return undefined;
62
+ if (held.marketIdentity === undefined || held.marketIdentity !== input.marketIdentity)
63
+ return undefined;
64
+ if (held.intervalMs !== input.intervalMs)
65
+ return undefined;
66
+ if (input.window?.partial || held.window?.partial)
67
+ return undefined;
68
+ if (held.lanesFromTs === undefined || held.lanesFromTs > input.fromTs)
69
+ return undefined;
70
+ return {
71
+ take(lane, payload) {
72
+ const leg = isWrunTradesLegLane(lane);
73
+ if (!leg && !Object.hasOwn(HELD_LANE_ROWS, lane))
74
+ return undefined;
75
+ const buffer = leg ? held.tradeLegRows?.[lane] : held[HELD_LANE_ROWS[lane]];
76
+ const acquisition = held.acquisition[lane];
77
+ const coveredThroughTs = held.coveredThroughTs[lane];
78
+ if (!Array.isArray(buffer) || acquisition === undefined || coveredThroughTs === undefined)
79
+ return undefined;
80
+ if (held.degradedLanes?.has(lane))
81
+ return undefined;
82
+ if (!isEqual(askOf(acquisition), askOf(payload)))
83
+ return undefined;
84
+ if (lane === 'volume_profile' && acquisition.minimumBarHeight !== input.volumeProfileGrid)
85
+ return undefined;
86
+ // A tape bar the live fold capped, or one the intake's queue cap left short past repair, holds
87
+ // an incomplete row: asked again, never computed on.
88
+ if (lane === 'tape' && (held.tapeCappedBuckets?.size ?? 0) + (held.tapeLostBuckets?.size ?? 0) > 0) {
89
+ return undefined;
90
+ }
91
+ return { rows: [...buffer], acquisition, coveredThroughTs };
92
+ },
93
+ };
94
+ }
@@ -0,0 +1,2 @@
1
+ import type { VisibleTimeoutOptions } from '../common/visible-timeout.util.js';
2
+ export declare function wrunHostVisibleClock(): VisibleTimeoutOptions;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The visible clock a package deadline that counts on-screen time arms with (utility/common/visible-timeout.util.ts):
3
+ * the page's visibility and, beside it, the host's own suspension (`clock.watchHostSuspended`, contract 0.5.0). A host
4
+ * that parks its chart while the page stays visible (an app backgrounded, its chart tab blurred) pauses the deadline
5
+ * as a hidden page does, so a suspended app never runs a grace or a deadline out. A host that binds no watch adds
6
+ * nothing (web: its one suspension is the page's visibility, which the clock reads already).
7
+ *
8
+ * Every package call of `startVisibleTimeout` hands this as its options (tests/packages/wrun-chart-host/host-visible
9
+ * -clock.spec.ts holds the package to it). Read when a deadline arms, never at module load.
10
+ */
11
+ import { wrunChartHostEnv } from '../../host-env.js';
12
+ export function wrunHostVisibleClock() {
13
+ const clock = wrunChartHostEnv().clock;
14
+ if (typeof clock.watchHostSuspended !== 'function')
15
+ return {};
16
+ return { watchSuspended: (listener) => clock.watchHostSuspended(listener) };
17
+ }
@@ -0,0 +1,330 @@
1
+ /**
2
+ * Main-thread WRUN host: loads a package's module into the sandbox worker,
3
+ * owns that worker, and runs packed series requests through it. One shared
4
+ * worker serves every dev overlay; requests are id-matched, and a request
5
+ * that outlives its clock poisons the worker (terminate + respawn) so a
6
+ * spinning guest cannot wedge later runs.
7
+ *
8
+ * Modules (the shared engine protocol, wrun-chart-host 0.6.0): the main
9
+ * thread never hashes and never compiles a module. `loadModule` keeps a
10
+ * private copy of the package's bytes and posts them (`module-load`); the
11
+ * worker hashes them, checks the sheet's `wasm_sha256` pin, clamps the
12
+ * memory, prepares and compiles them (wrun-engine-handler.ts) and answers the
13
+ * module's key, digest and imports, which the opaque handle carries. Every
14
+ * full run and live-start names the module by key and carries the bytes
15
+ * again (copied, never transferred), so a respawned worker compiles them
16
+ * anew; nothing here tracks which keys the worker holds. Each request has
17
+ * two clocks of WRUN_RUN_TIMEOUT_MS: the start ceiling from the post (the
18
+ * wait behind other requests, the compile and the instantiation), then the
19
+ * run deadline from the worker's `{ id, running: true }`, posted once the
20
+ * module is instantiated, when the request executes; a terminal answer
21
+ * settles a request in either phase.
22
+ *
23
+ * Isolation: a death of the shared worker (the run timeout, or an error
24
+ * event with a request in flight) rejects every pending request with
25
+ * `WrunWorkerPoisonError` naming the live sessions lost with it,
26
+ * quarantines the package that was running (its metadata id plus wasm
27
+ * digest) on the kScript self-heal ladder (30 s, doubling per repeat,
28
+ * capped at 5 min) so its next requests refuse at once with
29
+ * `WrunQuarantinedError` instead of killing the worker again, and throttles
30
+ * the respawn to one per window so several spinning packages (or a Retry
31
+ * that overrides the quarantine) cannot kill and respawn the worker on
32
+ * every request. A Retry or a settings save passes `overrideQuarantine`;
33
+ * its success clears the package's quarantine.
34
+ *
35
+ * wrun-3 (Indicator handles): the sheet's `handles` section and the other
36
+ * wrun-3 sheet fields are checked here before every run (the same place the
37
+ * string slots are), the request carries the declared handle defaults and
38
+ * the widened ABI, and the worker's answer carries the handle ledger's live
39
+ * set, which rides beside the rows it belongs to (`attachWrunHandles`) so
40
+ * the run-result adapter picks it up from the rows every integration route
41
+ * already hands it. The run's skipped draw calls (a call one bar's values
42
+ * could not carry, recorded instead of refusing the run) ride the same way
43
+ * (`attachWrunDrawSkips`), for the run's one warning row.
44
+ *
45
+ * wrun-3 (Indicator strategies): a sheet that declares `strategy` is read
46
+ * and resolved here before every run (the om validator's rules, then the
47
+ * shared host's resolver against the instance's params), the request
48
+ * carries the engine's declared config, the chart interval and the broker
49
+ * feed (the primary lane's OHLC per row, `strategyBars`, supplied by the
50
+ * overlay lanes from the chart's own candles), and the worker's answer
51
+ * carries the engine's StrategyOutput, which rides beside the rows
52
+ * (`attachWrunStrategy`) exactly like the handle set.
53
+ */
54
+ import type { WrunIndicatorMetadata, WrunModuleHandle, WrunOutputRow } from '../../interfaces/wrun-runtime.interface.js';
55
+ import { attachWrunLive, WrunLiveOrderError, wrunLiveOf } from '../../interfaces/wrun-runtime.interface.js';
56
+ import { type WrunInputRow } from './wrun-pack.util.js';
57
+ import { WrunWorkerPoisonError } from './wrun-registry-errors.util.js';
58
+ /** Sources the kit marks daemon-only (`WRUN_DAEMON_ONLY_SOURCES`, a Set of source names; a kit that
59
+ * supplies per-source disclosure wording is a record read by the same key) are computed by the daemon,
60
+ * which owns their dependencies: the first input declaring one refuses the browser run by name. The
61
+ * chart's own candle classes (`ohlcv`, `time`) are served off the chart's rows and never need the kit,
62
+ * so a plain package dispatches synchronously; any other declared class asks the kit (`warm` loads it
63
+ * ahead of the first add). The table is one of the two the run path still reads from the kit: the
64
+ * shared host entry does not export it. */
65
+ export declare function assertWrunBrowserSources(metadata: WrunIndicatorMetadata): Promise<void> | void;
66
+ /** One respawn of the shared worker per window (the kScript shared worker's
67
+ * `restartWithReseedBackoff` rule, sized for this host's 20 s run timeout
68
+ * instead of kScript's 90 s call timeouts): a second death inside the window
69
+ * after a respawn holds the next respawn until the window closes, and every
70
+ * request meanwhile fails fast with the death's poison error. The quarantine
71
+ * below bounds ONE package's deaths geometrically; this window bounds the
72
+ * worker's deaths whatever mix of packages (or overrides) causes them. */
73
+ export declare const WRUN_WORKER_RESPAWN_WINDOW_MS = 60000;
74
+ /** How many module handles the host keeps (loadModule): every package version, draft Run and REPL compile mints a
75
+ * key, and the engine worker keeps an LRU of the same size of the compiled modules behind them. */
76
+ export declare const WRUN_MODULE_CACHE_CAPACITY = 16;
77
+ /** Why the shared worker died: the run timeout, or the Worker's error event (the worker factory's death test). */
78
+ export type WrunHostDeathReason = WrunWorkerPoisonError['reason'];
79
+ /** A package the host refuses to dispatch until `until` (epoch ms): the one
80
+ * running when the worker died. `strikes` counts consecutive deaths of the
81
+ * same package on the current ladder (hold = `localEngineSelfHealDelayMs`). */
82
+ export interface WrunHostQuarantine {
83
+ key: string;
84
+ until: number;
85
+ reason: WrunHostDeathReason;
86
+ strikes: number;
87
+ }
88
+ /** The quarantine key of a package: its metadata id plus the wasm digest the
89
+ * metadata pins, so a republished build (new digest) starts clean while every
90
+ * overlay of the same build shares one hold (two charts, two instances: a
91
+ * per-overlay key would let the second instance spin the worker again). An
92
+ * unpinned sheet (dev loader, REPL) keys by id alone. */
93
+ export declare function wrunHostQuarantineKey(metadata: Pick<WrunIndicatorMetadata, 'id' | 'wasm_sha256'>): string;
94
+ /** One bar of the broker feed: the primary lane's candle for an input row. */
95
+ export interface WrunStrategyBarInput {
96
+ open: number;
97
+ high: number;
98
+ low: number;
99
+ close: number;
100
+ }
101
+ /** The strategy half of a run the overlay lanes supply for a strategy
102
+ * package (contract section 2, "the broker feed"): the primary lane's OHLC
103
+ * per input row (aligned to `rows`, index for index), the chart interval
104
+ * (annualized stats) and the package display name (`declared.title` on
105
+ * the wire). Ignored for a sheet that declares no `strategy`. */
106
+ export interface WrunStrategyRunInput {
107
+ bars: ReadonlyArray<WrunStrategyBarInput>;
108
+ intervalMs?: number;
109
+ title?: string;
110
+ }
111
+ /** A live tick was asked of a session the worker no longer holds (never
112
+ * started, disposed, dropped after a failed tick, or lost to a worker
113
+ * poison/respawn). Callers rebuild via a fresh full run instead of treating
114
+ * this as a compute error. */
115
+ export declare class WrunLiveSessionLostError extends Error {
116
+ constructor(message: string);
117
+ }
118
+ /** A live tick's block was refused before evaluation because its rows run
119
+ * backwards against the worker session's watermark: the session survives,
120
+ * and the caller reseeds it from its buffers (the worker and the context
121
+ * disagree) instead of retrying the same block. The class is the one the
122
+ * ABI host throws inside the worker (`code: 'live-order'` on the wire). */
123
+ export { WrunLiveOrderError };
124
+ /** The live block accounting rides beside the rows (the registry lives with
125
+ * the wire types); re-exported here for the tick lane's reader. */
126
+ export { attachWrunLive, wrunLiveOf };
127
+ export declare class WrunBrowserHost {
128
+ private worker;
129
+ private pending;
130
+ /** One counter numbers loads, runs and live-ends: a retired incarnation's late answer names an id no entry holds. */
131
+ private requestSeq;
132
+ /** The order requests enter the `run` phase in (`PendingRequest.runOrder`). */
133
+ private runSeq;
134
+ /** Loads by module, least recently used first (Map order: a hit moves its entry to the end). The cache only
135
+ * dedupes loads and owns no module: a mounted overlay keeps the handle it was handed (its record), and a live
136
+ * session keeps its instance in the worker (live ticks name the session, never a module), so an eviction stops
137
+ * neither; a handle's bytes stay behind it whatever the cache lets go, and its runs carry them. */
138
+ private moduleCache;
139
+ /** Live sessions the current worker holds (installed by an ok live-start,
140
+ * dropped by live-end, a sessionLost answer, or the worker's death). */
141
+ private liveSessionKeys;
142
+ /** The epoch (live context generation) of the newest live-start dispatched per session key: an end naming
143
+ * another epoch leaves the key's bookkeeping to that newer start. */
144
+ private liveStartEpochs;
145
+ /** Quarantined packages by key; a record outlives its hold by the ladder's
146
+ * reset grace so a repeat death escalates (pruned on the next death). */
147
+ private quarantines;
148
+ private lastDeath;
149
+ /** When the worker was last spawned AFTER a death (a respawn); null until
150
+ * the first death, so the first spawn ever never opens a window. */
151
+ private lastRespawnAt;
152
+ private respawnHeldUntil;
153
+ /** Spin the sandbox worker and load the shared host (the packer, the
154
+ * strategy resolver; the worker holds its own for the module rewrite) and
155
+ * the authoring kit (the run path's two kit tables, the daemon-only
156
+ * sources and the token names) ahead of the first add (the Indicators tab
157
+ * opening is the signal), so the first package a reader mounts pays
158
+ * neither the worker spawn nor a module parse on its click. Idempotent; a
159
+ * load failure surfaces on the first module load or run as before, never
160
+ * here. A held respawn is not warmed around: the window exists to keep the
161
+ * worker down. */
162
+ warm(): void;
163
+ /** The active quarantine of a package, if its hold is still running. */
164
+ quarantineOf(metadata: Pick<WrunIndicatorMetadata, 'id' | 'wasm_sha256'>): WrunHostQuarantine | undefined;
165
+ /** Forget every quarantine and the respawn window (specs only). */
166
+ resetGuardsForTests(): void;
167
+ /** Load (and cache) a package module: the worker hashes the bytes, refuses a
168
+ * digest other than the sheet's `wasm_sha256` pin with the words this host
169
+ * always used, refuses a memory the clamp refuses (a maximum or a starting
170
+ * size over the worker's memory limit, shared or 64-bit memory), stamps
171
+ * the limit as the maximum of a memory declared without one, exports every
172
+ * mutable global for the live lane's snapshot and restore, and compiles
173
+ * (wrun-engine-handler.ts `compileWrunModuleBytes`). This thread keeps a
174
+ * private copy of the bytes behind the handle and hashes and compiles
175
+ * nothing. A load needs the worker: during a held respawn every load
176
+ * rejects with the held death, a cached one too, and its start ceiling
177
+ * bounds the wait and the compile.
178
+ *
179
+ * The cache is an LRU of WRUN_MODULE_CACHE_CAPACITY handles, keyed by the
180
+ * sheet's pin and ABI when it pins one (its identity before and after the
181
+ * load), else by the bytes object and the ABI until the worker names the
182
+ * digest, then by the module's key; the first handle of a key stays the
183
+ * one every caller shares. A hit serves only bytes equal to the ones its
184
+ * entry loads: other bytes under the key (a pin claimed by bytes it was
185
+ * not verified from, a reused buffer whose content changed) go to the
186
+ * worker, which checks them against the pin, beside the cached entry and
187
+ * never in its place. Every caller of a load in flight shares its one
188
+ * post, and a load in flight is never evicted; eviction drops loaded
189
+ * entries only, least recently used first, so the cache passes the
190
+ * capacity only while more loads than that are in flight. A failed load is
191
+ * not cached: its entry leaves before its callers see the failure, and the
192
+ * next request loads again. Async, as the compile was: every failure (a
193
+ * detached buffer included) is a rejection, and nothing here awaits before
194
+ * the entry is cached. */
195
+ loadModule(wasmBytes: ArrayBuffer | Uint8Array, metadata: WrunIndicatorMetadata): Promise<WrunModuleHandle>;
196
+ /** A load answered: its entry leaves the key it waited under (an unpinned sheet's provisional key; none for a load
197
+ * that verified other bytes beside a cached entry) for the module's own key. A handle already loaded under that key
198
+ * stays the one every caller shares. */
199
+ private cacheLoadedModule;
200
+ /** Post one `module-load` of the private bytes (copied, never transferred: the handle keeps them for its runs) and
201
+ * mint the handle from the worker's answer. */
202
+ private requestModuleLoad;
203
+ /** Evict loaded entries, least recently used first, until the cache is back at its capacity (a load in flight
204
+ * stays: its callers share it). */
205
+ private trimModuleCache;
206
+ runSeries(input: {
207
+ module: WrunModuleHandle;
208
+ metadata: WrunIndicatorMetadata;
209
+ rows: readonly WrunInputRow[];
210
+ initArgs: readonly number[];
211
+ /** wrun-5: the typed text settings' bytes by init slot (wrunTextParamsForRun). */
212
+ textParams?: Readonly<Record<number, Uint8Array>>;
213
+ mode?: 'historical' | 'live';
214
+ /** A strategy package's broker feed, interval and title (required
215
+ * exactly when the sheet declares `strategy`). */
216
+ strategy?: WrunStrategyRunInput;
217
+ /** Dispatch although the package is quarantined (a Retry, a settings
218
+ * save); a success clears the quarantine. */
219
+ overrideQuarantine?: boolean;
220
+ }): Promise<WrunOutputRow[]>;
221
+ /** Full run that also opens (or replaces) a live forming-bar session under
222
+ * `sessionKey` in the worker: the guest stays instantiated, so later
223
+ * `runLiveRows` ticks execute only the new/revised rows. `epoch` is the
224
+ * live context generation opening the session: the worker installs the
225
+ * session only while that epoch is still the newest it has seen for the
226
+ * key (see the worker's ownership rule). */
227
+ startLiveSeries(input: {
228
+ sessionKey: string;
229
+ module: WrunModuleHandle;
230
+ metadata: WrunIndicatorMetadata;
231
+ rows: readonly WrunInputRow[];
232
+ initArgs: readonly number[];
233
+ /** wrun-5: the typed text settings' bytes by init slot; they ride the session like initArgs. */
234
+ textParams?: Readonly<Record<number, Uint8Array>>;
235
+ strategy?: WrunStrategyRunInput;
236
+ epoch?: number;
237
+ /** Dispatch although the package is quarantined; a success clears it. */
238
+ overrideQuarantine?: boolean;
239
+ }): Promise<WrunOutputRow[]>;
240
+ /** One live tick: evaluate only `rows` (the new/revised forming-bar rows)
241
+ * on the open session. Rejects with WrunLiveSessionLostError when the
242
+ * worker no longer holds the session. A wrun-3 session answers the
243
+ * handle ledger's FULL live set with every tick (the wire replaces the
244
+ * drawing set wholesale), attached to the returned rows; a strategy
245
+ * session likewise answers the whole StrategyOutput after the tick (the
246
+ * broker config rides the session, only the rows' broker feed ships). */
247
+ runLiveRows(input: {
248
+ sessionKey: string;
249
+ metadata: WrunIndicatorMetadata;
250
+ rows: readonly WrunInputRow[];
251
+ strategy?: WrunStrategyRunInput;
252
+ /** Dispatch although the package is quarantined; a success clears it. */
253
+ overrideQuarantine?: boolean;
254
+ }): Promise<WrunOutputRow[]>;
255
+ /** Dispose one live session. Fire-and-forget: nothing to await, and a
256
+ * worker that is not running holds no sessions to dispose. With `epoch`
257
+ * (the live context generation that opened it), only that generation's
258
+ * session and start: the worker judges, it knows which epoch installed
259
+ * (a run ending what it opened never ends a newer owner's session under
260
+ * the same key). Without, whatever the key holds (the teardown). */
261
+ endLiveSeries(sessionKey: string, epoch?: number): void;
262
+ destroy(): void;
263
+ /** Unpack the rows against the caller's axis and hang the handle set, the
264
+ * run's skipped draw calls, the strategy output and the live block
265
+ * accounting (when the worker answered them) on that rows array. */
266
+ private unpack;
267
+ /** The quarantine gate every request passes before any packing or worker
268
+ * hop: a quarantined package refuses at once (nothing posted, no worker
269
+ * spawned) unless the caller overrides. The refusal carries the death's
270
+ * reason and the package's strikes (the heal ladder reads them). Returns
271
+ * the lane the pending entry remembers. */
272
+ private admit;
273
+ /** A full run or a live-start: the module rides the request, its key (the worker reuses the module it holds under
274
+ * it) and the host's private copy of its bytes (copied by structured clone, never transferred: a worker that does
275
+ * not hold the key, a respawned one or one that let it go, compiles them). The packed request's own `abi` stays
276
+ * the run's sheet's. */
277
+ private dispatchWithModule;
278
+ private dispatch;
279
+ /**
280
+ * Post one request under a pending entry: the respawn hold first (a held death refuses it, nothing posted), then
281
+ * the worker, the entry in its `start` phase with the start ceiling armed (the wait behind other requests, the
282
+ * module's compile and its instantiation, bounded as the dispatch clock bounded the hold before 0.6.0), then the
283
+ * post. A request the structured clone refuses fails alone (its entry and clock go with it).
284
+ */
285
+ private post;
286
+ /** A phase's clock: a request that outlives it means the worker is stuck (a guest spinning, a compile that never
287
+ * ends), so the worker is poisoned and replaced and later requests start clean. */
288
+ private armClock;
289
+ /** One answer from the worker. `running` moves its request to the `run` phase on a fresh clock (a second one, one
290
+ * for a load or for no pending request changes nothing); a terminal answer settles its request in either phase;
291
+ * an answer for no pending request (an untracked live-end's, a retired incarnation's) is dropped. */
292
+ private receive;
293
+ /** A run's terminal answer: the package answered (an overridden quarantine is cleared by the success, and an
294
+ * opened session is one the worker now holds), a lost session, a live-order refusal, or a failure. */
295
+ private settleRun;
296
+ private ensureWorker;
297
+ /**
298
+ * The shared worker died: quarantine the package that was running (the
299
+ * culprit, `culpritOf`), terminate the worker, remember the death for the
300
+ * respawn window, and reject every pending request (loads included) with
301
+ * the poison error naming the live sessions lost with the worker. Nothing
302
+ * in flight means nothing to quarantine (a worker that dies idle is only a
303
+ * death for the window). `message` is what every casualty reads; the
304
+ * culprit of a timeout keeps its own deadline sentence. The death's
305
+ * context (cause, the culprit's package, session and phase, the budget a
306
+ * timeout used up) is recorded here once, frozen, and rides every
307
+ * rejection of this death, the respawn hold's included, so a casualty can
308
+ * name who held the sandbox.
309
+ */
310
+ private poisonWorker;
311
+ /** Who held the worker when it died: the request in the `run` phase, the hog holding the worker's synchronous turn
312
+ * (the expired request itself when it was running, else the first that started running), else the expired
313
+ * request (nothing ran: its own wait and compile used its ceiling up), else, for an error event, the oldest
314
+ * request in flight. */
315
+ private culpritOf;
316
+ /** Put (or keep) a package on the ladder: a death while its previous hold
317
+ * runs, or inside the reset grace after it, is a repeat and doubles the
318
+ * hold (capped); a later death starts over at the base hold. Records past
319
+ * the grace are forgotten here. */
320
+ private quarantine;
321
+ /** The rejection a request gets while the respawn is held: the last death's
322
+ * poison error (its casualties are still unrebuilt, no worker ran since,
323
+ * and it carries that death's context), marked as held. Null when a worker
324
+ * runs or the window has closed. */
325
+ private respawnHold;
326
+ private failAllPending;
327
+ }
328
+ export declare function getWrunBrowserHost(): WrunBrowserHost;
329
+ /** Clear the shared host's quarantines and respawn window between specs. */
330
+ export declare function __resetWrunBrowserHostGuardsForTests(): void;