@senpi/runtime 3.0.135 → 3.0.138

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 (272) hide show
  1. package/dist/actions/action-events.d.ts +7 -21
  2. package/dist/actions/action-events.d.ts.map +1 -1
  3. package/dist/actions/action-events.js +26 -54
  4. package/dist/actions/action-events.js.map +1 -1
  5. package/dist/actions/action-runtime-module.d.ts.map +1 -1
  6. package/dist/actions/action-runtime-module.js +7 -38
  7. package/dist/actions/action-runtime-module.js.map +1 -1
  8. package/dist/actions/close-position/close-position.action.d.ts.map +1 -1
  9. package/dist/actions/close-position/close-position.action.js +15 -122
  10. package/dist/actions/close-position/close-position.action.js.map +1 -1
  11. package/dist/actions/decision-engine.d.ts.map +1 -1
  12. package/dist/actions/decision-engine.js +2 -15
  13. package/dist/actions/decision-engine.js.map +1 -1
  14. package/dist/actions/event-derivation.d.ts +2 -71
  15. package/dist/actions/event-derivation.d.ts.map +1 -1
  16. package/dist/actions/event-derivation.js +8 -251
  17. package/dist/actions/event-derivation.js.map +1 -1
  18. package/dist/actions/open-position/open-position.action.d.ts +2 -12
  19. package/dist/actions/open-position/open-position.action.d.ts.map +1 -1
  20. package/dist/actions/open-position/open-position.action.js +41 -141
  21. package/dist/actions/open-position/open-position.action.js.map +1 -1
  22. package/dist/actions/position-tracker/position-tracker.action.d.ts +1 -2
  23. package/dist/actions/position-tracker/position-tracker.action.d.ts.map +1 -1
  24. package/dist/actions/position-tracker/position-tracker.action.js +17 -62
  25. package/dist/actions/position-tracker/position-tracker.action.js.map +1 -1
  26. package/dist/actions/store/types.d.ts +2 -9
  27. package/dist/actions/store/types.d.ts.map +1 -1
  28. package/dist/actions/store/types.js.map +1 -1
  29. package/dist/actions/types.d.ts +0 -13
  30. package/dist/actions/types.d.ts.map +1 -1
  31. package/dist/actions/types.js +0 -13
  32. package/dist/actions/types.js.map +1 -1
  33. package/dist/cli/guide-commands.d.ts.map +1 -1
  34. package/dist/cli/guide-commands.js +7 -4
  35. package/dist/cli/guide-commands.js.map +1 -1
  36. package/dist/constants/dsl/index.d.ts +0 -6
  37. package/dist/constants/dsl/index.d.ts.map +1 -1
  38. package/dist/constants/dsl/index.js +0 -6
  39. package/dist/constants/dsl/index.js.map +1 -1
  40. package/dist/dsl/engine-client/event-mapping.d.ts.map +1 -1
  41. package/dist/dsl/engine-client/event-mapping.js +0 -14
  42. package/dist/dsl/engine-client/event-mapping.js.map +1 -1
  43. package/dist/dsl/events/build-closed-event.d.ts +1 -16
  44. package/dist/dsl/events/build-closed-event.d.ts.map +1 -1
  45. package/dist/dsl/events/build-closed-event.js +0 -6
  46. package/dist/dsl/events/build-closed-event.js.map +1 -1
  47. package/dist/dsl/events/handlers.d.ts +0 -7
  48. package/dist/dsl/events/handlers.d.ts.map +1 -1
  49. package/dist/dsl/events/handlers.js +7 -37
  50. package/dist/dsl/events/handlers.js.map +1 -1
  51. package/dist/dsl/monitor/create-monitor.d.ts +2 -6
  52. package/dist/dsl/monitor/create-monitor.d.ts.map +1 -1
  53. package/dist/dsl/monitor/create-monitor.js +9 -82
  54. package/dist/dsl/monitor/create-monitor.js.map +1 -1
  55. package/dist/dsl/monitor/dsl-failure-events.d.ts +2 -45
  56. package/dist/dsl/monitor/dsl-failure-events.d.ts.map +1 -1
  57. package/dist/dsl/monitor/dsl-failure-events.js +3 -52
  58. package/dist/dsl/monitor/dsl-failure-events.js.map +1 -1
  59. package/dist/dsl/monitor/process-one-position.d.ts +0 -1
  60. package/dist/dsl/monitor/process-one-position.d.ts.map +1 -1
  61. package/dist/dsl/monitor/process-one-position.js +36 -159
  62. package/dist/dsl/monitor/process-one-position.js.map +1 -1
  63. package/dist/dsl/plugin/index.d.ts +2 -8
  64. package/dist/dsl/plugin/index.d.ts.map +1 -1
  65. package/dist/dsl/plugin/index.js +6 -8
  66. package/dist/dsl/plugin/index.js.map +1 -1
  67. package/dist/health/types.d.ts +0 -13
  68. package/dist/health/types.d.ts.map +1 -1
  69. package/dist/health/types.js +0 -12
  70. package/dist/health/types.js.map +1 -1
  71. package/dist/index.d.ts +4 -27
  72. package/dist/index.d.ts.map +1 -1
  73. package/dist/index.js +41 -271
  74. package/dist/index.js.map +1 -1
  75. package/dist/runtime/action-registry.d.ts.map +1 -1
  76. package/dist/runtime/action-registry.js +3 -4
  77. package/dist/runtime/action-registry.js.map +1 -1
  78. package/dist/runtime/domain-events.d.ts.map +1 -1
  79. package/dist/runtime/domain-events.js +0 -7
  80. package/dist/runtime/domain-events.js.map +1 -1
  81. package/dist/runtime/lifecycle-events.d.ts +3 -15
  82. package/dist/runtime/lifecycle-events.d.ts.map +1 -1
  83. package/dist/runtime/lifecycle-events.js +3 -17
  84. package/dist/runtime/lifecycle-events.js.map +1 -1
  85. package/dist/runtime/lifecycle-reaper.d.ts +6 -4
  86. package/dist/runtime/lifecycle-reaper.d.ts.map +1 -1
  87. package/dist/runtime/lifecycle-reaper.js +6 -4
  88. package/dist/runtime/lifecycle-reaper.js.map +1 -1
  89. package/dist/runtime/reconcile-run.d.ts +3 -13
  90. package/dist/runtime/reconcile-run.d.ts.map +1 -1
  91. package/dist/runtime/reconcile-run.js +3 -4
  92. package/dist/runtime/reconcile-run.js.map +1 -1
  93. package/dist/runtime/reconcile-state.d.ts +0 -8
  94. package/dist/runtime/reconcile-state.d.ts.map +1 -1
  95. package/dist/runtime/reconcile-state.js +1 -4
  96. package/dist/runtime/reconcile-state.js.map +1 -1
  97. package/dist/runtime/risk-guard.d.ts +20 -1
  98. package/dist/runtime/risk-guard.d.ts.map +1 -1
  99. package/dist/runtime/risk-guard.js +47 -6
  100. package/dist/runtime/risk-guard.js.map +1 -1
  101. package/dist/runtime/run.d.ts +0 -1
  102. package/dist/runtime/run.d.ts.map +1 -1
  103. package/dist/runtime/run.js.map +1 -1
  104. package/dist/runtime/runtime-schema.js +3 -3
  105. package/dist/runtime/runtime-schema.js.map +1 -1
  106. package/dist/runtime/runtime.d.ts +3 -2
  107. package/dist/runtime/runtime.d.ts.map +1 -1
  108. package/dist/runtime/runtime.js +30 -37
  109. package/dist/runtime/runtime.js.map +1 -1
  110. package/dist/runtime/strategy-lifecycle.d.ts +108 -2
  111. package/dist/runtime/strategy-lifecycle.d.ts.map +1 -1
  112. package/dist/runtime/strategy-lifecycle.js +325 -4
  113. package/dist/runtime/strategy-lifecycle.js.map +1 -1
  114. package/dist/runtime/supervisor/long-running-supervisor.d.ts +0 -13
  115. package/dist/runtime/supervisor/long-running-supervisor.d.ts.map +1 -1
  116. package/dist/runtime/supervisor/long-running-supervisor.js +0 -1
  117. package/dist/runtime/supervisor/long-running-supervisor.js.map +1 -1
  118. package/dist/runtime/validate-dsl-position-tracking.d.ts.map +1 -1
  119. package/dist/runtime/validate-dsl-position-tracking.js +1 -2
  120. package/dist/runtime/validate-dsl-position-tracking.js.map +1 -1
  121. package/dist/runtime-api/handlers/ingest-signals.d.ts.map +1 -1
  122. package/dist/runtime-api/handlers/ingest-signals.js +0 -1
  123. package/dist/runtime-api/handlers/ingest-signals.js.map +1 -1
  124. package/dist/runtime-api/handlers/types.d.ts +0 -5
  125. package/dist/runtime-api/handlers/types.d.ts.map +1 -1
  126. package/dist/runtime-api/intake/intake-events.d.ts +1 -1
  127. package/dist/runtime-api/intake/intake-events.d.ts.map +1 -1
  128. package/dist/runtime-api/intake/intake-events.js +3 -9
  129. package/dist/runtime-api/intake/intake-events.js.map +1 -1
  130. package/dist/runtime-api/intake/intake-mount.d.ts.map +1 -1
  131. package/dist/runtime-api/intake/intake-mount.js +19 -4
  132. package/dist/runtime-api/intake/intake-mount.js.map +1 -1
  133. package/dist/runtime-api/intake/process-error-post.d.ts +1 -6
  134. package/dist/runtime-api/intake/process-error-post.d.ts.map +1 -1
  135. package/dist/runtime-api/intake/process-error-post.js +1 -5
  136. package/dist/runtime-api/intake/process-error-post.js.map +1 -1
  137. package/dist/runtime-api/intake/process-signal-post.d.ts +1 -7
  138. package/dist/runtime-api/intake/process-signal-post.d.ts.map +1 -1
  139. package/dist/runtime-api/intake/process-signal-post.js +0 -5
  140. package/dist/runtime-api/intake/process-signal-post.js.map +1 -1
  141. package/dist/runtime-api/intake/scaffold-error-router.js.map +1 -1
  142. package/dist/runtime-api/intake/scanner-launcher.d.ts.map +1 -1
  143. package/dist/runtime-api/intake/scanner-launcher.js +0 -15
  144. package/dist/runtime-api/intake/scanner-launcher.js.map +1 -1
  145. package/dist/runtime-api/intake/types.d.ts +0 -55
  146. package/dist/runtime-api/intake/types.d.ts.map +1 -1
  147. package/dist/runtime-api/routes/signals.d.ts +0 -2
  148. package/dist/runtime-api/routes/signals.d.ts.map +1 -1
  149. package/dist/runtime-api/routes/signals.js +1 -5
  150. package/dist/runtime-api/routes/signals.js.map +1 -1
  151. package/dist/runtime-api/routes/signals.schema.d.ts +0 -43
  152. package/dist/runtime-api/routes/signals.schema.d.ts.map +1 -1
  153. package/dist/runtime-api/routes/signals.schema.js +0 -43
  154. package/dist/runtime-api/routes/signals.schema.js.map +1 -1
  155. package/dist/runtime-api/server.d.ts +1 -7
  156. package/dist/runtime-api/server.d.ts.map +1 -1
  157. package/dist/runtime-api/server.js +0 -1
  158. package/dist/runtime-api/server.js.map +1 -1
  159. package/dist/scanners/engine/engine.d.ts +1 -22
  160. package/dist/scanners/engine/engine.d.ts.map +1 -1
  161. package/dist/scanners/engine/engine.js +11 -78
  162. package/dist/scanners/engine/engine.js.map +1 -1
  163. package/dist/scanners/engine/lifecycle.d.ts +1 -7
  164. package/dist/scanners/engine/lifecycle.d.ts.map +1 -1
  165. package/dist/scanners/events.d.ts +0 -4
  166. package/dist/scanners/events.d.ts.map +1 -1
  167. package/dist/scanners/events.js +0 -2
  168. package/dist/scanners/events.js.map +1 -1
  169. package/dist/scanners/external/scaffold/delivery.py +25 -194
  170. package/dist/scanners/external/scaffold/scaffold.py +31 -172
  171. package/dist/scanners/external/scaffold/senpi_mcp.py +8 -150
  172. package/dist/scanners/external-scanner-receiver.d.ts +0 -17
  173. package/dist/scanners/external-scanner-receiver.d.ts.map +1 -1
  174. package/dist/scanners/external-scanner-receiver.js +0 -8
  175. package/dist/scanners/external-scanner-receiver.js.map +1 -1
  176. package/dist/scanners/runtime-module.d.ts +0 -1
  177. package/dist/scanners/runtime-module.d.ts.map +1 -1
  178. package/dist/scanners/runtime-module.js +9 -66
  179. package/dist/scanners/runtime-module.js.map +1 -1
  180. package/dist/telemetry/attributes.d.ts +0 -20
  181. package/dist/telemetry/attributes.d.ts.map +1 -1
  182. package/dist/telemetry/attributes.js +0 -24
  183. package/dist/telemetry/attributes.js.map +1 -1
  184. package/dist/telemetry/event-builders.d.ts +6 -81
  185. package/dist/telemetry/event-builders.d.ts.map +1 -1
  186. package/dist/telemetry/event-builders.js +17 -141
  187. package/dist/telemetry/event-builders.js.map +1 -1
  188. package/dist/telemetry/event-store.d.ts +0 -6
  189. package/dist/telemetry/event-store.d.ts.map +1 -1
  190. package/dist/telemetry/event-store.js +8 -12
  191. package/dist/telemetry/event-store.js.map +1 -1
  192. package/dist/telemetry/metrics.d.ts +2 -14
  193. package/dist/telemetry/metrics.d.ts.map +1 -1
  194. package/dist/telemetry/metrics.js +4 -19
  195. package/dist/telemetry/metrics.js.map +1 -1
  196. package/dist/telemetry/spans/redact-pii.d.ts.map +1 -1
  197. package/dist/telemetry/spans/redact-pii.js +2 -18
  198. package/dist/telemetry/spans/redact-pii.js.map +1 -1
  199. package/dist/telemetry/tracing.d.ts +0 -9
  200. package/dist/telemetry/tracing.d.ts.map +1 -1
  201. package/dist/telemetry/tracing.js +0 -36
  202. package/dist/telemetry/tracing.js.map +1 -1
  203. package/dist/types/dsl/index.d.ts +0 -48
  204. package/dist/types/dsl/index.d.ts.map +1 -1
  205. package/dist/types/scanner.d.ts +0 -15
  206. package/dist/types/scanner.d.ts.map +1 -1
  207. package/dist/utils/event-catalog.d.ts +0 -202
  208. package/dist/utils/event-catalog.d.ts.map +1 -1
  209. package/dist/utils/event-catalog.js +0 -26
  210. package/dist/utils/event-catalog.js.map +1 -1
  211. package/dist/utils/logger.d.ts +1 -4
  212. package/dist/utils/logger.d.ts.map +1 -1
  213. package/dist/utils/logger.js.map +1 -1
  214. package/dist/validate/recipe-checks.d.ts.map +1 -1
  215. package/dist/validate/recipe-checks.js +2 -2
  216. package/dist/validate/recipe-checks.js.map +1 -1
  217. package/openclaw.plugin.json +1 -1
  218. package/package.json +1 -1
  219. package/dist/actions/skipped-signal-results.d.ts +0 -25
  220. package/dist/actions/skipped-signal-results.d.ts.map +0 -1
  221. package/dist/actions/skipped-signal-results.js +0 -71
  222. package/dist/actions/skipped-signal-results.js.map +0 -1
  223. package/dist/runtime-api/intake/ingest-request.d.ts +0 -17
  224. package/dist/runtime-api/intake/ingest-request.d.ts.map +0 -1
  225. package/dist/runtime-api/intake/ingest-request.js +0 -34
  226. package/dist/runtime-api/intake/ingest-request.js.map +0 -1
  227. package/dist/runtime-api/intake/scaffold-tick-router.d.ts +0 -39
  228. package/dist/runtime-api/intake/scaffold-tick-router.d.ts.map +0 -1
  229. package/dist/runtime-api/intake/scaffold-tick-router.js +0 -122
  230. package/dist/runtime-api/intake/scaffold-tick-router.js.map +0 -1
  231. package/dist/scanners/external/scaffold/tick_facts.py +0 -130
  232. package/dist/scanners/external/scaffold/ulid.py +0 -58
  233. package/dist/telemetry/dsl-positions.d.ts +0 -111
  234. package/dist/telemetry/dsl-positions.d.ts.map +0 -1
  235. package/dist/telemetry/dsl-positions.js +0 -118
  236. package/dist/telemetry/dsl-positions.js.map +0 -1
  237. package/dist/telemetry/live-telemetry.d.ts +0 -257
  238. package/dist/telemetry/live-telemetry.d.ts.map +0 -1
  239. package/dist/telemetry/live-telemetry.js +0 -959
  240. package/dist/telemetry/live-telemetry.js.map +0 -1
  241. package/dist/telemetry/scanner-stats.d.ts +0 -143
  242. package/dist/telemetry/scanner-stats.d.ts.map +0 -1
  243. package/dist/telemetry/scanner-stats.js +0 -426
  244. package/dist/telemetry/scanner-stats.js.map +0 -1
  245. package/dist/telemetry/scanner-tick-feed.d.ts +0 -87
  246. package/dist/telemetry/scanner-tick-feed.d.ts.map +0 -1
  247. package/dist/telemetry/scanner-tick-feed.js +0 -48
  248. package/dist/telemetry/scanner-tick-feed.js.map +0 -1
  249. package/dist/telemetry/strategy-topology.d.ts +0 -99
  250. package/dist/telemetry/strategy-topology.d.ts.map +0 -1
  251. package/dist/telemetry/strategy-topology.js +0 -93
  252. package/dist/telemetry/strategy-topology.js.map +0 -1
  253. package/dist/telemetry/telemetry-publisher.d.ts +0 -83
  254. package/dist/telemetry/telemetry-publisher.d.ts.map +0 -1
  255. package/dist/telemetry/telemetry-publisher.js +0 -256
  256. package/dist/telemetry/telemetry-publisher.js.map +0 -1
  257. package/dist/telemetry/tick-frame.d.ts +0 -212
  258. package/dist/telemetry/tick-frame.d.ts.map +0 -1
  259. package/dist/telemetry/tick-frame.js +0 -421
  260. package/dist/telemetry/tick-frame.js.map +0 -1
  261. package/dist/telemetry/timeline-buffer.d.ts +0 -95
  262. package/dist/telemetry/timeline-buffer.d.ts.map +0 -1
  263. package/dist/telemetry/timeline-buffer.js +0 -237
  264. package/dist/telemetry/timeline-buffer.js.map +0 -1
  265. package/dist/utils/telemetry-required-log.d.ts +0 -60
  266. package/dist/utils/telemetry-required-log.d.ts.map +0 -1
  267. package/dist/utils/telemetry-required-log.js +0 -105
  268. package/dist/utils/telemetry-required-log.js.map +0 -1
  269. package/dist/utils/ulid.d.ts +0 -9
  270. package/dist/utils/ulid.d.ts.map +0 -1
  271. package/dist/utils/ulid.js +0 -43
  272. package/dist/utils/ulid.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"dsl-positions.d.ts","sourceRoot":"","sources":["../../src/telemetry/dsl-positions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAErE,wFAAwF;AACxF,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAKvC,4D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C,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,mBAAmB;IAClC,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,sBAAsB;IACrC,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,iBAAiB,EAAE,CAAC;IAC/B,gDAAgD;IAChD,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAwDD,2FAA2F;AAC3F,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,GAAG,mBAAmB,CASpF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,mBAAmB,EAC5B,QAAQ,EAAE,MAAM,GACf,mBAAmB,CAiBrB"}
@@ -1,118 +0,0 @@
1
- /**
2
- * Builder for the `plugin.senpi.dsl` payload — what the box believes about the protection on each
3
- * open position it holds DSL state for.
4
- *
5
- * Pure. Every fact arrives as an input; nothing is read from a state manager or a runtime handle
6
- * here, so the shape on the wire is testable without booting a runtime.
7
- *
8
- * Three properties this module exists to hold:
9
- *
10
- * - **Absence is a claim, and it is never spelled as a value.** A field the box has not measured is
11
- * omitted from the entry. `slOrderId: null` says there is no stop; an absent `slOrderId` says this
12
- * box cannot say. A `0`, a `""` or a synthesised timestamp in either place would read as a
13
- * measurement that was never taken, and the reader has no way to tell the difference afterwards.
14
- * That is why every field is copied through a presence test rather than defaulted, and why the
15
- * wire type marks them optional: the payload has to be able to make both statements.
16
- * - **The venue's answer is carried beside the belief, never folded into it.** `lastVenueStatus` is
17
- * what the venue said about the position's own {@link DslState.slOrderId}; `backendSlVenueStatus`
18
- * is what it said about the backend ratchet's `activeSLOrderId`. They are different orders, and a
19
- * panel that showed one under the other's name would state a confirmation the box never got.
20
- * - **The payload is bounded in bytes, not in entries.** See {@link capDslPositions}.
21
- */
22
- import { normalizeStrategyAddress } from "./event-store.js";
23
- /** Payload schema version. Bump when a field changes meaning, not when one is added. */
24
- export const DSL_POSITIONS_VERSION = 1;
25
- /** The comma JSON puts between two array entries. Counted, so the budget is the frame's real size. */
26
- const SEPARATOR_BYTES = 1;
27
- function isNumber(value) {
28
- return typeof value === "number" && Number.isFinite(value);
29
- }
30
- /** One entry, assembled field by field. Never spread the state: it carries free text and secrets' neighbours. */
31
- function buildEntry(source) {
32
- const s = source.state;
33
- const phase1 = (s.phase1 ?? {});
34
- return {
35
- runtimeId: source.runtimeId,
36
- // `(address, asset)` is how a client joins this row to the timeline's `dsl.*` records and to the
37
- // topology's strategy row. A checksummed EIP-55 wallet reaching the wire raw would spell this
38
- // position differently from every other payload, and nothing downstream rejects that — the join
39
- // just returns nothing.
40
- address: normalizeStrategyAddress(s.address),
41
- asset: s.asset,
42
- ...(typeof s.dex === "string" ? { dex: s.dex } : {}),
43
- ...(s.direction === "LONG" || s.direction === "SHORT" ? { direction: s.direction } : {}),
44
- ...(isNumber(s.entryPrice) ? { entryPrice: s.entryPrice } : {}),
45
- ...(isNumber(s.size) ? { size: s.size } : {}),
46
- ...(isNumber(s.leverage) ? { leverage: s.leverage } : {}),
47
- ...(s.phase === 1 || s.phase === 2 ? { phase: s.phase } : {}),
48
- ...(isNumber(s.floorPrice) ? { floorPrice: s.floorPrice } : {}),
49
- ...(isNumber(phase1.absoluteFloor) ? { absoluteFloor: phase1.absoluteFloor } : {}),
50
- ...(s.slOrderId === null || isNumber(s.slOrderId) ? { slOrderId: s.slOrderId } : {}),
51
- ...(s.lastSyncedFloorPrice === null || isNumber(s.lastSyncedFloorPrice)
52
- ? { lastSyncedFloorPrice: s.lastSyncedFloorPrice }
53
- : {}),
54
- ...(s.slOrderIdUpdatedAt === null || typeof s.slOrderIdUpdatedAt === "string"
55
- ? { slOrderIdUpdatedAt: s.slOrderIdUpdatedAt }
56
- : {}),
57
- ...(s.handoffStatus === null || typeof s.handoffStatus === "string"
58
- ? { handoffStatus: s.handoffStatus }
59
- : {}),
60
- ...(isNumber(s.currentBreachCount) ? { currentBreachCount: s.currentBreachCount } : {}),
61
- ...(isNumber(phase1.consecutiveBreachesRequired)
62
- ? { consecutiveBreachesRequired: phase1.consecutiveBreachesRequired }
63
- : {}),
64
- ...(isNumber(s.slSyncFailureCount) ? { slSyncFailureCount: s.slSyncFailureCount } : {}),
65
- ...(typeof s.pendingClose === "boolean" ? { pendingClose: s.pendingClose } : {}),
66
- ...(isNumber(s.consecutiveFetchFailures)
67
- ? { consecutiveFetchFailures: s.consecutiveFetchFailures }
68
- : {}),
69
- ...(typeof s.lastVenueStatus === "string" ? { lastVenueStatus: s.lastVenueStatus } : {}),
70
- ...(isNumber(s.lastVenueStatusAt) ? { lastVenueStatusAt: s.lastVenueStatusAt } : {}),
71
- ...(typeof s.backendSlVenueStatus === "string"
72
- ? { backendSlVenueStatus: s.backendSlVenueStatus }
73
- : {}),
74
- ...(isNumber(s.backendSlVenueStatusAt)
75
- ? { backendSlVenueStatusAt: s.backendSlVenueStatusAt }
76
- : {}),
77
- };
78
- }
79
- /** Builds one `plugin.senpi.dsl` payload from an already-gathered set of active states. */
80
- export function buildDslPositions(input) {
81
- const now = input.now ?? Date.now;
82
- return {
83
- v: DSL_POSITIONS_VERSION,
84
- epoch: input.epoch,
85
- generatedAt: now(),
86
- positions: input.positions.map(buildEntry),
87
- dropped: 0,
88
- };
89
- }
90
- /**
91
- * The payload, trimmed to fit one frame.
92
- *
93
- * Bytes and not an entry count, for the same reason the tick frame counts bytes: one non-ASCII
94
- * character in a venue-authored status costs up to three of them, and the read limit at the far end
95
- * counts bytes. A frame past that limit does not cost the one frame — it closes the client's socket
96
- * and costs the stream — so a box with more positions than fit sends the ones that do and states how
97
- * many it withheld, rather than sending an oversized frame or silently shortening the list.
98
- *
99
- * Taken on the SCRUBBED payload and never before it: a redaction can be longer than the text it
100
- * replaced, so a cut taken first bounds the input rather than what leaves.
101
- */
102
- export function capDslPositions(payload, maxBytes) {
103
- // The envelope is measured with `dropped` at its largest possible value, so admitting an entry can
104
- // never be undone by the counter growing a digit.
105
- const envelopeBytes = Buffer.byteLength(JSON.stringify({ ...payload, positions: [], dropped: payload.positions.length }));
106
- let bytes = envelopeBytes;
107
- const positions = [];
108
- for (const entry of payload.positions) {
109
- const size = Buffer.byteLength(JSON.stringify(entry)) + (positions.length > 0 ? SEPARATOR_BYTES : 0);
110
- if (bytes + size > maxBytes)
111
- break;
112
- positions.push(entry);
113
- bytes += size;
114
- }
115
- const dropped = payload.positions.length - positions.length;
116
- return dropped === 0 ? payload : { ...payload, positions, dropped };
117
- }
118
- //# sourceMappingURL=dsl-positions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dsl-positions.js","sourceRoot":"","sources":["../../src/telemetry/dsl-positions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAG5D,wFAAwF;AACxF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEvC,sGAAsG;AACtG,MAAM,eAAe,GAAG,CAAC,CAAC;AA6E1B,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC7D,CAAC;AAED,iHAAiH;AACjH,SAAS,UAAU,CAAC,MAAyB;IAC3C,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;IACvB,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAgC,CAAC;IAC/D,OAAO;QACL,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,iGAAiG;QACjG,8FAA8F;QAC9F,gGAAgG;QAChG,wBAAwB;QACxB,OAAO,EAAE,wBAAwB,CAAC,CAAC,CAAC,OAAO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C;QAC1C,OAAO,EAAE,CAAC;KACX,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,eAAe,CAC7B,OAA4B,EAC5B,QAAgB;IAEhB,mGAAmG;IACnG,kDAAkD;IAClD,MAAM,aAAa,GAAG,MAAM,CAAC,UAAU,CACrC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CACjF,CAAC;IACF,IAAI,KAAK,GAAG,aAAa,CAAC;IAC1B,MAAM,SAAS,GAAuB,EAAE,CAAC;IACzC,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtC,MAAM,IAAI,GACR,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1F,IAAI,KAAK,GAAG,IAAI,GAAG,QAAQ;YAAE,MAAM;QACnC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACtB,KAAK,IAAI,IAAI,CAAC;IAChB,CAAC;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;IAC5D,OAAO,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AACtE,CAAC"}
@@ -1,257 +0,0 @@
1
- /**
2
- * The publisher: the piece that turns the buffer and the payload builders into frames on the gateway
3
- * websocket, plus the snapshot a client reads when it connects.
4
- *
5
- * Two things about the transport shape the whole module:
6
- * - The only route to the websocket is a captured `context.broadcast`, and `context` exists only
7
- * inside a gateway RPC handler — the plugin api object has no push surface at all. So the handle is
8
- * captured from the FIRST request of ANY kind, not only from the subscribe method: a box whose
9
- * client never calls subscribe would otherwise hold nothing to publish through, silently.
10
- * - The gateway drops any event name that does not start with `plugin.`, and closes the socket with
11
- * 1008 for a slow client unless the call passes `dropIfSlow`. Both are enforced here rather than at
12
- * each call site, because either mistake is invisible until a client is missing frames.
13
- *
14
- * Three cadences, because the payloads cost different things to build:
15
- * - timeline, on the flush tick — a drain plus a filter, cheap, and the one a live screen feels.
16
- * - stats, on the sample tick — a scan of the whole held window and an async read of every runtime's
17
- * health and system state, so it runs an order of magnitude less often.
18
- * - topology and dsl, on the sample tick but each published only when it changes — both ride the
19
- * same gather as stats, and nothing in the plugin signals either kind of change, so "on change"
20
- * means polled and diffed rather than pushed. They are diffed separately: a box's topology is
21
- * stable for hours while its positions move every tick, and one comparison for both would either
22
- * suppress the moving payload or resend the still one.
23
- *
24
- * The snapshot is what stops a client that joins mid-life from seeing an empty screen: it is read
25
- * from the buffer's held window, which the flush drain never evicts.
26
- *
27
- * One broadcast sits outside all of that. The tick frame is a LEVEL — the latest finished run of
28
- * each scanner, most of which produce nothing and so leave no record anywhere — and it is published
29
- * on a window of its own, driven by the runs themselves rather than by a timer that is always
30
- * running. It carries no seq, is never buffered, is not in the snapshot and is not replayed, because
31
- * a client that misses one is made whole by the next one. Keeping it off the buffer is the point: the
32
- * buffer is where decision records live, and per-tick facts would evict them.
33
- *
34
- * Everything that leaves the box is scrubbed here. `logger.event` redacts its `redact` slot and not
35
- * its `attributes`, which is sound for the disk ring — that never leaves — but not for a stream a
36
- * browser reads. There are five ways out — the timeline frame, the stats frame, the dsl frame, the
37
- * tick frame and the snapshot that carries three of them — and three kinds of captured text between
38
- * them, so the scrub sits in three places:
39
- * - {@link toWireRecord} for a timeline record's attributes. It is what makes the flush tick
40
- * asynchronous and gives it an in-flight guard.
41
- * - {@link scrubScannerText} for text a scanner process authored: the scanner state's three
42
- * free-text fields, via {@link scrubStatsPayload}, which reach both the stats frame and the
43
- * snapshot; and a tick's `outcome`. Their content is a stringified throwable or status from a
44
- * scanner process, so they are the strings on the wire with no bound of their own and they are
45
- * capped as well as scrubbed.
46
- * - {@link scrubDslPayload} for the two venue statuses on a dsl entry, which reach both the dsl
47
- * frame and the snapshot. The state caps them already; the scrub is why they pass through here.
48
- *
49
- * The topology payload carries no captured text: its `name` and `scannerId` are operator-authored
50
- * config keys the client joins on, and the scanner `config` that could hold a resolved secret is
51
- * never copied onto it.
52
- *
53
- * The dsl payload carries two: the venue's last status for the position's own stop and for the
54
- * backend ratchet's, both authored by Hyperliquid and kept verbatim, so both take the same
55
- * scrub-then-cap through {@link scrubDslPayload}. Everything else on it is a price, a counter, an
56
- * order id or a token of ours.
57
- */
58
- import type { EventName } from "../utils/event-catalog.js";
59
- import { type TimelineBuffer } from "./timeline-buffer.js";
60
- import { type ScannerRunFacts } from "./scanner-tick-feed.js";
61
- import { type TickFramePayload, type TickTelemetryConfig } from "./tick-frame.js";
62
- import { type ScannerStateSnapshot, type ScannerStatsPayload } from "./scanner-stats.js";
63
- import { type DslPositionSource, type DslPositionsPayload } from "./dsl-positions.js";
64
- import { type IdMembership, type RuntimeHealthLike, type StrategyTopologyPayload, type TopologyStrategySource } from "./strategy-topology.js";
65
- /** The gateway drops any broadcast whose name does not carry this prefix, with no error. */
66
- export declare const EVENT_TIMELINE = "plugin.senpi.timeline";
67
- export declare const EVENT_STATS = "plugin.senpi.scanner.stats";
68
- export declare const EVENT_TOPOLOGY = "plugin.senpi.strategies";
69
- export declare const EVENT_TICK = "plugin.senpi.tick";
70
- export declare const EVENT_DSL = "plugin.senpi.dsl";
71
- /**
72
- * Byte ceiling for one frame. A frame published here travels southbound — gateway to bridge — and
73
- * meets the bridge's southbound read limit, 1 MiB unless a deployment sets its own; a frame past it
74
- * takes the whole connection down rather than costing the one frame. The budget is set far inside
75
- * that: the payload envelope the gateway wraps around ours, and the growth of a single record's
76
- * attribute bag, both have to fit in the margin, and neither is measured here.
77
- */
78
- export declare const MAX_FRAME_BYTES: number;
79
- /**
80
- * Character ceiling for one of the scanner state's free-text fields on the wire — `lastRunReason`,
81
- * `lastRunStatus` and `degradedReason`.
82
- *
83
- * These carry a stringified throwable from a scanner process, which nothing upstream bounds: an HTTP
84
- * client's error message alone runs to a few hundred characters and a stack-bearing one to
85
- * kilobytes, once per scanner per sample. 1024 holds the sentence that says what failed — the error
86
- * type, the operation and the endpoint. It is also what keeps the payload bounded at all: this frame
87
- * is published whole, with no splitting of the kind the timeline does, so two hundred scanners each
88
- * reporting a 4 KiB error in every one of the three fields serialise to about 1.7 MB — past the read
89
- * limit that ends the connection — and at this cap the same box lands under half of it.
90
- */
91
- export declare const MAX_SCANNER_TEXT_CHARS = 1024;
92
- /**
93
- * What one of those fields reads as when its text could not be scrubbed — no redactor registered, or
94
- * a redactor that threw.
95
- *
96
- * Not `null` and not an absent key: the producer reporting no reason and this box withholding one it
97
- * cannot vouch for are different facts, and a summary screen is read as if they were the same.
98
- */
99
- export declare const SCANNER_TEXT_WITHHELD = "[withheld: not scrubbed]";
100
- /** Flush cadence for the timeline. A live screen feels this number. */
101
- export declare const DEFAULT_FLUSH_INTERVAL_MS = 1000;
102
- /**
103
- * Sample cadence for stats and topology. Both are built from one async read of every runtime's health
104
- * and system state, so they share a tick. Five seconds is roughly a third of the default bucket width
105
- * — fast enough that a counter visibly moves and a hung scan is seen while it is still running, slow
106
- * enough that the per-scanner store read behind the system state is not a poll loop.
107
- */
108
- export declare const DEFAULT_SAMPLE_INTERVAL_MS = 5000;
109
- /**
110
- * How long the first tick of a frame waits for the ticks that land beside it.
111
- *
112
- * Scanners on a box share cadences — a recipe gives several of them the same interval, and every
113
- * runtime starts them within the same boot — so their terminal callbacks arrive in clumps. A frame per
114
- * callback would put one websocket write per scanner per cadence on the wire for a payload of seven
115
- * scalars; one window collapses a clump into a single write. It is short enough that the level a
116
- * dashboard shows is still the current one, and it is not the timeline's flush tick because a tick
117
- * frame must not wait behind a scrub of hundreds of records.
118
- */
119
- export declare const TICK_COALESCE_MS = 250;
120
- /**
121
- * The PUBLICATION list: what leaves on the timeline event. A name being on this list AND on the
122
- * admission list is the normal case, not a duplication — `signal.outcome` is the decision row the feed
123
- * is built around and the source of `opens`/`closes`/`skips`, and the two `scaffold.tick_*` names are
124
- * the source of `errors` and the rows behind the Errors filter. A failing external scanner has to
125
- * leave a visible line, not only a number that silently goes up.
126
- *
127
- * The two lists are separate so admission can be widened for a counter the feed does not display,
128
- * which is the direction that has to stay open: the display filter belongs here at publish time,
129
- * where it is still recoverable, never at append time, where it is not. Today nothing is admitted for
130
- * counting alone, so the sets are equal — the seam is what matters, not the difference.
131
- */
132
- export declare const PUBLISHED_EVENT_NAMES: ReadonlySet<EventName>;
133
- /**
134
- * The share of its own interval a tick may take before it is warned about. A fraction rather than a
135
- * constant, so a deployment that changes a cadence gets a proportional threshold: 250ms on the
136
- * one-second timeline flush, 1.25s on the five-second sample.
137
- *
138
- * A quarter, not a whole interval. Both ticks share an event loop with the serial trading path, so a
139
- * tick holding it for a quarter of its own period is already adding latency to trading; and a tick
140
- * that fills its interval has already started stacking on the next one, which is too late to be told.
141
- */
142
- export declare const SLOW_TICK_FRACTION = 0.25;
143
- /**
144
- * How often the timing summary is logged, and the floor between two slow-tick warns of the same kind.
145
- * The flush tick runs every second, so a line per tick would be tens of thousands a day for numbers
146
- * that only mean anything aggregated — and a repeating tick that is slow is slow every time.
147
- */
148
- export declare const TIMING_REPORT_INTERVAL_MS = 60000;
149
- export interface GatewayBroadcastOpts {
150
- dropIfSlow?: boolean;
151
- stateVersion?: number;
152
- }
153
- export type GatewayBroadcastFn = (event: string, payload: unknown, opts?: GatewayBroadcastOpts) => void;
154
- /** One record as it goes on the wire. */
155
- export interface TimelineWireRecord {
156
- seq: number;
157
- ts: number;
158
- name: string;
159
- level: string;
160
- address: string;
161
- scannerId?: string;
162
- body: string;
163
- attrs: Record<string, string | number | boolean>;
164
- }
165
- export interface TimelinePayload {
166
- v: 1;
167
- epoch: string;
168
- batchSeq: number;
169
- records: TimelineWireRecord[];
170
- }
171
- /**
172
- * A tick frame, in the compact wire shape {@link ./tick-frame.js} builds: a per-frame string
173
- * dictionary, index references into it, times as offsets from one `t0`, and short keys.
174
- *
175
- * It carries no `batchSeq` and its entries carry no `seq`, because there is nothing to resume: this
176
- * is the current state of a set of scanners, and a client that misses a frame is made whole by the
177
- * next one rather than by a replay.
178
- */
179
- export type ScannerTickPayload = TickFramePayload;
180
- export interface TelemetrySnapshot {
181
- epoch: string;
182
- topology: StrategyTopologyPayload;
183
- stats: ScannerStatsPayload;
184
- /**
185
- * The current `plugin.senpi.dsl` payload. In the snapshot for the same reason the topology is: a
186
- * client that joins a box whose positions have not changed for an hour would otherwise render no
187
- * protection at all until one of them did.
188
- */
189
- dsl: DslPositionsPayload;
190
- recent: TimelinePayload;
191
- /**
192
- * The client asked to resume from a cursor inside THIS epoch whose successor is no longer held, or
193
- * the window it is owed did not fit one frame. Either way there is a gap this response cannot fill,
194
- * and only the box knows it: `recent.records` alone looks like a normal short window.
195
- *
196
- * A cursor from another epoch is not truncation. It buys nothing, so the whole retained window is
197
- * served — which is the most this box could ever serve, and so nothing was withheld.
198
- */
199
- truncated: boolean;
200
- }
201
- /** Everything the two builders need that the buffer cannot supply, gathered once per tick. */
202
- export interface TelemetryFacts {
203
- strategies: TopologyStrategySource[];
204
- runningRuntimeIds: IdMembership;
205
- unwiredRuntimeIds: IdMembership;
206
- readHealth?: (runtimeId: string) => RuntimeHealthLike | undefined;
207
- scannerState: ScannerStateSnapshot[];
208
- /** Every active DSL state on the box, with the runtime holding it. */
209
- dslPositions: DslPositionSource[];
210
- }
211
- export interface LiveTelemetryOptions {
212
- /** Defaults to the process buffer — one per process, shared by every address. */
213
- buffer?: TimelineBuffer;
214
- collectFacts: () => Promise<TelemetryFacts>;
215
- flushIntervalMs?: number;
216
- sampleIntervalMs?: number;
217
- now?: () => number;
218
- /**
219
- * Monotonic millisecond reader for tick durations. Defaults to `performance.now`; `now` is wall
220
- * clock and can step backwards under NTP, which would report a negative tick.
221
- */
222
- monotonicMs?: () => number;
223
- /**
224
- * How much detail a tick frame carries, as the plugin config states it. Plugin config and not an
225
- * env var on purpose: `register()` re-reads plugin config on a config reload, while a service
226
- * variable change restarts the container. An unusable value warns and falls back rather than
227
- * throwing — a configuration mistake must not be why a box goes dark.
228
- */
229
- tickTelemetry?: TickTelemetryConfig;
230
- }
231
- export interface LiveTelemetry {
232
- readonly epoch: string;
233
- /** Take the broadcast handle off a gateway request context if we do not hold one yet. */
234
- captureBroadcast(ctx: unknown, methodName: string): void;
235
- /** `afterSeq` counts only when `afterEpoch` is the epoch this box is running. */
236
- snapshot(params?: {
237
- afterEpoch?: unknown;
238
- afterSeq?: unknown;
239
- }): Promise<TelemetrySnapshot>;
240
- /** One flush tick: drain, filter to the publication list, scrub, frame, broadcast. */
241
- flushTimeline(): Promise<void>;
242
- /** One sample tick: stats always, topology when it changed. */
243
- sample(): Promise<void>;
244
- /**
245
- * Take one finished scanner run for the next tick frame. Synchronous, never throws, and returns
246
- * without building anything when no client has ever connected. `start` registers this as the
247
- * process tick sink; it is on the interface so a caller holding the publisher can drive it directly.
248
- */
249
- recordTick(run: ScannerRunFacts, startedAt: number | undefined, finishedAt: number): void;
250
- /** Publish whatever the current coalescing window holds, now. */
251
- flushTicks(): Promise<void>;
252
- start(): void;
253
- /** Clear every timer, release the tick sink, drop the captured handle, and empty the timelineBuffer(). */
254
- stop(): void;
255
- }
256
- export declare function createLiveTelemetry(options: LiveTelemetryOptions): LiveTelemetry;
257
- //# sourceMappingURL=live-telemetry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"live-telemetry.d.ts","sourceRoot":"","sources":["../../src/telemetry/live-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAEH,OAAO,KAAK,EAAa,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAKtE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