@senpi/runtime 3.0.108 → 3.0.111

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 (241) hide show
  1. package/dist/actions/action-events.d.ts +21 -7
  2. package/dist/actions/action-events.d.ts.map +1 -1
  3. package/dist/actions/action-events.js +54 -26
  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 +38 -7
  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 +122 -15
  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 +15 -2
  13. package/dist/actions/decision-engine.js.map +1 -1
  14. package/dist/actions/event-derivation.d.ts +71 -2
  15. package/dist/actions/event-derivation.d.ts.map +1 -1
  16. package/dist/actions/event-derivation.js +251 -8
  17. package/dist/actions/event-derivation.js.map +1 -1
  18. package/dist/actions/open-position/open-position.action.d.ts +28 -2
  19. package/dist/actions/open-position/open-position.action.d.ts.map +1 -1
  20. package/dist/actions/open-position/open-position.action.js +220 -52
  21. package/dist/actions/open-position/open-position.action.js.map +1 -1
  22. package/dist/actions/position-tracker/position-tracker.action.d.ts +2 -1
  23. package/dist/actions/position-tracker/position-tracker.action.d.ts.map +1 -1
  24. package/dist/actions/position-tracker/position-tracker.action.js +62 -17
  25. package/dist/actions/position-tracker/position-tracker.action.js.map +1 -1
  26. package/dist/actions/skipped-signal-results.d.ts +25 -0
  27. package/dist/actions/skipped-signal-results.d.ts.map +1 -0
  28. package/dist/actions/skipped-signal-results.js +71 -0
  29. package/dist/actions/skipped-signal-results.js.map +1 -0
  30. package/dist/actions/store/types.d.ts +9 -2
  31. package/dist/actions/store/types.d.ts.map +1 -1
  32. package/dist/actions/store/types.js.map +1 -1
  33. package/dist/actions/types.d.ts +13 -0
  34. package/dist/actions/types.d.ts.map +1 -1
  35. package/dist/actions/types.js +13 -0
  36. package/dist/actions/types.js.map +1 -1
  37. package/dist/cli/guide-commands.d.ts.map +1 -1
  38. package/dist/cli/guide-commands.js +3 -0
  39. package/dist/cli/guide-commands.js.map +1 -1
  40. package/dist/constants/dsl/index.d.ts +15 -0
  41. package/dist/constants/dsl/index.d.ts.map +1 -1
  42. package/dist/constants/dsl/index.js +15 -0
  43. package/dist/constants/dsl/index.js.map +1 -1
  44. package/dist/dsl/engine-client/event-mapping.d.ts.map +1 -1
  45. package/dist/dsl/engine-client/event-mapping.js +14 -0
  46. package/dist/dsl/engine-client/event-mapping.js.map +1 -1
  47. package/dist/dsl/events/build-closed-event.d.ts +16 -1
  48. package/dist/dsl/events/build-closed-event.d.ts.map +1 -1
  49. package/dist/dsl/events/build-closed-event.js +6 -0
  50. package/dist/dsl/events/build-closed-event.js.map +1 -1
  51. package/dist/dsl/events/handlers.d.ts +7 -0
  52. package/dist/dsl/events/handlers.d.ts.map +1 -1
  53. package/dist/dsl/events/handlers.js +37 -7
  54. package/dist/dsl/events/handlers.js.map +1 -1
  55. package/dist/dsl/monitor/create-monitor.d.ts +6 -2
  56. package/dist/dsl/monitor/create-monitor.d.ts.map +1 -1
  57. package/dist/dsl/monitor/create-monitor.js +15 -9
  58. package/dist/dsl/monitor/create-monitor.js.map +1 -1
  59. package/dist/dsl/monitor/dsl-failure-events.d.ts +2 -0
  60. package/dist/dsl/monitor/dsl-failure-events.d.ts.map +1 -1
  61. package/dist/dsl/monitor/dsl-failure-events.js +2 -1
  62. package/dist/dsl/monitor/dsl-failure-events.js.map +1 -1
  63. package/dist/dsl/monitor/process-one-position.d.ts +1 -0
  64. package/dist/dsl/monitor/process-one-position.d.ts.map +1 -1
  65. package/dist/dsl/monitor/process-one-position.js +72 -29
  66. package/dist/dsl/monitor/process-one-position.js.map +1 -1
  67. package/dist/dsl/plugin/index.d.ts +8 -2
  68. package/dist/dsl/plugin/index.d.ts.map +1 -1
  69. package/dist/dsl/plugin/index.js +8 -6
  70. package/dist/dsl/plugin/index.js.map +1 -1
  71. package/dist/health/types.d.ts +13 -0
  72. package/dist/health/types.d.ts.map +1 -1
  73. package/dist/health/types.js +12 -0
  74. package/dist/health/types.js.map +1 -1
  75. package/dist/index.d.ts +16 -4
  76. package/dist/index.d.ts.map +1 -1
  77. package/dist/index.js +230 -39
  78. package/dist/index.js.map +1 -1
  79. package/dist/runtime/action-registry.d.ts.map +1 -1
  80. package/dist/runtime/action-registry.js +4 -3
  81. package/dist/runtime/action-registry.js.map +1 -1
  82. package/dist/runtime/domain-events.d.ts.map +1 -1
  83. package/dist/runtime/domain-events.js +7 -0
  84. package/dist/runtime/domain-events.js.map +1 -1
  85. package/dist/runtime/lifecycle-events.d.ts +9 -1
  86. package/dist/runtime/lifecycle-events.d.ts.map +1 -1
  87. package/dist/runtime/lifecycle-events.js +11 -2
  88. package/dist/runtime/lifecycle-events.js.map +1 -1
  89. package/dist/runtime/reconcile-run.d.ts +13 -3
  90. package/dist/runtime/reconcile-run.d.ts.map +1 -1
  91. package/dist/runtime/reconcile-run.js +4 -3
  92. package/dist/runtime/reconcile-run.js.map +1 -1
  93. package/dist/runtime/reconcile-state.d.ts +8 -0
  94. package/dist/runtime/reconcile-state.d.ts.map +1 -1
  95. package/dist/runtime/reconcile-state.js +4 -1
  96. package/dist/runtime/reconcile-state.js.map +1 -1
  97. package/dist/runtime/run.d.ts +1 -0
  98. package/dist/runtime/run.d.ts.map +1 -1
  99. package/dist/runtime/run.js.map +1 -1
  100. package/dist/runtime/runtime-schema.js +3 -3
  101. package/dist/runtime/runtime-schema.js.map +1 -1
  102. package/dist/runtime/runtime.d.ts +1 -0
  103. package/dist/runtime/runtime.d.ts.map +1 -1
  104. package/dist/runtime/runtime.js +27 -3
  105. package/dist/runtime/runtime.js.map +1 -1
  106. package/dist/runtime/supervisor/long-running-supervisor.d.ts +13 -0
  107. package/dist/runtime/supervisor/long-running-supervisor.d.ts.map +1 -1
  108. package/dist/runtime/supervisor/long-running-supervisor.js +1 -0
  109. package/dist/runtime/supervisor/long-running-supervisor.js.map +1 -1
  110. package/dist/runtime/validate-dsl-position-tracking.d.ts.map +1 -1
  111. package/dist/runtime/validate-dsl-position-tracking.js +2 -1
  112. package/dist/runtime/validate-dsl-position-tracking.js.map +1 -1
  113. package/dist/runtime-api/handlers/ingest-signals.d.ts.map +1 -1
  114. package/dist/runtime-api/handlers/ingest-signals.js +1 -0
  115. package/dist/runtime-api/handlers/ingest-signals.js.map +1 -1
  116. package/dist/runtime-api/handlers/types.d.ts +5 -0
  117. package/dist/runtime-api/handlers/types.d.ts.map +1 -1
  118. package/dist/runtime-api/intake/ingest-request.d.ts +17 -0
  119. package/dist/runtime-api/intake/ingest-request.d.ts.map +1 -0
  120. package/dist/runtime-api/intake/ingest-request.js +34 -0
  121. package/dist/runtime-api/intake/ingest-request.js.map +1 -0
  122. package/dist/runtime-api/intake/intake-events.d.ts +1 -1
  123. package/dist/runtime-api/intake/intake-events.d.ts.map +1 -1
  124. package/dist/runtime-api/intake/intake-events.js +9 -3
  125. package/dist/runtime-api/intake/intake-events.js.map +1 -1
  126. package/dist/runtime-api/intake/intake-mount.d.ts.map +1 -1
  127. package/dist/runtime-api/intake/intake-mount.js +4 -19
  128. package/dist/runtime-api/intake/intake-mount.js.map +1 -1
  129. package/dist/runtime-api/intake/scaffold-error-router.js.map +1 -1
  130. package/dist/runtime-api/intake/scanner-launcher.d.ts.map +1 -1
  131. package/dist/runtime-api/intake/scanner-launcher.js +15 -0
  132. package/dist/runtime-api/intake/scanner-launcher.js.map +1 -1
  133. package/dist/runtime-api/intake/types.d.ts +6 -0
  134. package/dist/runtime-api/intake/types.d.ts.map +1 -1
  135. package/dist/runtime-api/routes/signals.d.ts.map +1 -1
  136. package/dist/runtime-api/routes/signals.js +2 -1
  137. package/dist/runtime-api/routes/signals.js.map +1 -1
  138. package/dist/runtime-api/routes/signals.schema.d.ts +1 -0
  139. package/dist/runtime-api/routes/signals.schema.d.ts.map +1 -1
  140. package/dist/runtime-api/routes/signals.schema.js +6 -0
  141. package/dist/runtime-api/routes/signals.schema.js.map +1 -1
  142. package/dist/scanners/engine/engine.d.ts +22 -1
  143. package/dist/scanners/engine/engine.d.ts.map +1 -1
  144. package/dist/scanners/engine/engine.js +78 -11
  145. package/dist/scanners/engine/engine.js.map +1 -1
  146. package/dist/scanners/engine/lifecycle.d.ts +7 -1
  147. package/dist/scanners/engine/lifecycle.d.ts.map +1 -1
  148. package/dist/scanners/events.d.ts +4 -0
  149. package/dist/scanners/events.d.ts.map +1 -1
  150. package/dist/scanners/events.js +2 -0
  151. package/dist/scanners/events.js.map +1 -1
  152. package/dist/scanners/external/scaffold/delivery.py +136 -14
  153. package/dist/scanners/external/scaffold/scaffold.py +61 -8
  154. package/dist/scanners/external/scaffold/ulid.py +58 -0
  155. package/dist/scanners/external-scanner-receiver.d.ts +17 -0
  156. package/dist/scanners/external-scanner-receiver.d.ts.map +1 -1
  157. package/dist/scanners/external-scanner-receiver.js +8 -0
  158. package/dist/scanners/external-scanner-receiver.js.map +1 -1
  159. package/dist/scanners/runtime-module.d.ts +1 -0
  160. package/dist/scanners/runtime-module.d.ts.map +1 -1
  161. package/dist/scanners/runtime-module.js +59 -9
  162. package/dist/scanners/runtime-module.js.map +1 -1
  163. package/dist/scripts/run-dsl-standalone-mock.js +6 -2
  164. package/dist/scripts/run-dsl-standalone-mock.js.map +1 -1
  165. package/dist/senpi/client.d.ts +16 -3
  166. package/dist/senpi/client.d.ts.map +1 -1
  167. package/dist/senpi/client.js +44 -13
  168. package/dist/senpi/client.js.map +1 -1
  169. package/dist/strategy/strategy-state.d.ts +9 -1
  170. package/dist/strategy/strategy-state.d.ts.map +1 -1
  171. package/dist/strategy/strategy-state.js +7 -2
  172. package/dist/strategy/strategy-state.js.map +1 -1
  173. package/dist/telemetry/attributes.d.ts +20 -0
  174. package/dist/telemetry/attributes.d.ts.map +1 -1
  175. package/dist/telemetry/attributes.js +24 -0
  176. package/dist/telemetry/attributes.js.map +1 -1
  177. package/dist/telemetry/event-builders.d.ts +81 -6
  178. package/dist/telemetry/event-builders.d.ts.map +1 -1
  179. package/dist/telemetry/event-builders.js +141 -17
  180. package/dist/telemetry/event-builders.js.map +1 -1
  181. package/dist/telemetry/event-store.d.ts +6 -0
  182. package/dist/telemetry/event-store.d.ts.map +1 -1
  183. package/dist/telemetry/event-store.js +12 -8
  184. package/dist/telemetry/event-store.js.map +1 -1
  185. package/dist/telemetry/live-telemetry.d.ts +192 -0
  186. package/dist/telemetry/live-telemetry.d.ts.map +1 -0
  187. package/dist/telemetry/live-telemetry.js +676 -0
  188. package/dist/telemetry/live-telemetry.js.map +1 -0
  189. package/dist/telemetry/metrics.d.ts +14 -2
  190. package/dist/telemetry/metrics.d.ts.map +1 -1
  191. package/dist/telemetry/metrics.js +19 -4
  192. package/dist/telemetry/metrics.js.map +1 -1
  193. package/dist/telemetry/scanner-stats.d.ts +143 -0
  194. package/dist/telemetry/scanner-stats.d.ts.map +1 -0
  195. package/dist/telemetry/scanner-stats.js +426 -0
  196. package/dist/telemetry/scanner-stats.js.map +1 -0
  197. package/dist/telemetry/spans/redact-pii.d.ts.map +1 -1
  198. package/dist/telemetry/spans/redact-pii.js +18 -2
  199. package/dist/telemetry/spans/redact-pii.js.map +1 -1
  200. package/dist/telemetry/strategy-topology.d.ts +99 -0
  201. package/dist/telemetry/strategy-topology.d.ts.map +1 -0
  202. package/dist/telemetry/strategy-topology.js +93 -0
  203. package/dist/telemetry/strategy-topology.js.map +1 -0
  204. package/dist/telemetry/telemetry-publisher.d.ts +63 -0
  205. package/dist/telemetry/telemetry-publisher.d.ts.map +1 -0
  206. package/dist/telemetry/telemetry-publisher.js +229 -0
  207. package/dist/telemetry/telemetry-publisher.js.map +1 -0
  208. package/dist/telemetry/timeline-buffer.d.ts +95 -0
  209. package/dist/telemetry/timeline-buffer.d.ts.map +1 -0
  210. package/dist/telemetry/timeline-buffer.js +237 -0
  211. package/dist/telemetry/timeline-buffer.js.map +1 -0
  212. package/dist/telemetry/tracing.d.ts +9 -0
  213. package/dist/telemetry/tracing.d.ts.map +1 -1
  214. package/dist/telemetry/tracing.js +36 -0
  215. package/dist/telemetry/tracing.js.map +1 -1
  216. package/dist/types/dsl/index.d.ts +11 -0
  217. package/dist/types/dsl/index.d.ts.map +1 -1
  218. package/dist/types/scanner.d.ts +15 -0
  219. package/dist/types/scanner.d.ts.map +1 -1
  220. package/dist/types/strategy.d.ts +5 -1
  221. package/dist/types/strategy.d.ts.map +1 -1
  222. package/dist/utils/event-catalog.d.ts +166 -0
  223. package/dist/utils/event-catalog.d.ts.map +1 -1
  224. package/dist/utils/event-catalog.js +18 -0
  225. package/dist/utils/event-catalog.js.map +1 -1
  226. package/dist/utils/logger.d.ts +4 -1
  227. package/dist/utils/logger.d.ts.map +1 -1
  228. package/dist/utils/logger.js.map +1 -1
  229. package/dist/utils/telemetry-required-log.d.ts +27 -0
  230. package/dist/utils/telemetry-required-log.d.ts.map +1 -0
  231. package/dist/utils/telemetry-required-log.js +68 -0
  232. package/dist/utils/telemetry-required-log.js.map +1 -0
  233. package/dist/utils/ulid.d.ts +9 -0
  234. package/dist/utils/ulid.d.ts.map +1 -0
  235. package/dist/utils/ulid.js +43 -0
  236. package/dist/utils/ulid.js.map +1 -0
  237. package/dist/validate/recipe-checks.d.ts.map +1 -1
  238. package/dist/validate/recipe-checks.js +2 -2
  239. package/dist/validate/recipe-checks.js.map +1 -1
  240. package/openclaw.plugin.json +1 -1
  241. package/package.json +1 -1
@@ -0,0 +1,192 @@
1
+ /**
2
+ * The publisher: the piece that turns the buffer and the three 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 three 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, on the sample tick but published only when it changes — it rides the same gather as
19
+ * stats, and nothing in the plugin signals a topology change, so "on change" means polled and
20
+ * diffed rather than pushed.
21
+ *
22
+ * The snapshot is what stops a client that joins mid-life from seeing an empty screen: it is read
23
+ * from the buffer's held window, which the flush drain never evicts.
24
+ *
25
+ * Everything that leaves the box is scrubbed here. `logger.event` redacts its `redact` slot and not
26
+ * its `attributes`, which is sound for the disk ring — that never leaves — but not for a stream a
27
+ * browser reads. There are three ways out — the timeline frame, the stats frame and the snapshot
28
+ * that carries one of each — and two kinds of free text between them, so the scrub sits in two
29
+ * places:
30
+ * - {@link toWireRecord} for a timeline record's attributes. It is what makes the flush tick
31
+ * asynchronous and gives it an in-flight guard.
32
+ * - {@link scrubStatsPayload} for the scanner state's three free-text fields, which reach both the
33
+ * stats frame and the snapshot. Their content is a stringified throwable from a scanner process,
34
+ * so it is the one string on the wire with no bound of its own and it is capped as well as
35
+ * scrubbed.
36
+ *
37
+ * The topology payload carries no captured text: its `name` and `scannerId` are operator-authored
38
+ * config keys the client joins on, and the scanner `config` that could hold a resolved secret is
39
+ * never copied onto it.
40
+ */
41
+ import type { EventName } from "../utils/event-catalog.js";
42
+ import { type TimelineBuffer } from "./timeline-buffer.js";
43
+ import { type ScannerStateSnapshot, type ScannerStatsPayload } from "./scanner-stats.js";
44
+ import { type IdMembership, type RuntimeHealthLike, type StrategyTopologyPayload, type TopologyStrategySource } from "./strategy-topology.js";
45
+ /** The gateway drops any broadcast whose name does not carry this prefix, with no error. */
46
+ export declare const EVENT_TIMELINE = "plugin.senpi.timeline";
47
+ export declare const EVENT_STATS = "plugin.senpi.scanner.stats";
48
+ export declare const EVENT_TOPOLOGY = "plugin.senpi.strategies";
49
+ /**
50
+ * Byte ceiling for one frame. A frame published here travels southbound — gateway to bridge — and
51
+ * meets the bridge's southbound read limit, 1 MiB unless a deployment sets its own; a frame past it
52
+ * takes the whole connection down rather than costing the one frame. The budget is set far inside
53
+ * that: the payload envelope the gateway wraps around ours, and the growth of a single record's
54
+ * attribute bag, both have to fit in the margin, and neither is measured here.
55
+ */
56
+ export declare const MAX_FRAME_BYTES: number;
57
+ /**
58
+ * Character ceiling for one of the scanner state's free-text fields on the wire — `lastRunReason`,
59
+ * `lastRunStatus` and `degradedReason`.
60
+ *
61
+ * These carry a stringified throwable from a scanner process, which nothing upstream bounds: an HTTP
62
+ * client's error message alone runs to a few hundred characters and a stack-bearing one to
63
+ * kilobytes, once per scanner per sample. 1024 holds the sentence that says what failed — the error
64
+ * type, the operation and the endpoint. It is also what keeps the payload bounded at all: this frame
65
+ * is published whole, with no splitting of the kind the timeline does, so two hundred scanners each
66
+ * reporting a 4 KiB error in every one of the three fields serialise to about 1.7 MB — past the read
67
+ * limit that ends the connection — and at this cap the same box lands under half of it.
68
+ */
69
+ export declare const MAX_SCANNER_TEXT_CHARS = 1024;
70
+ /**
71
+ * What one of those fields reads as when its text could not be scrubbed — no redactor registered, or
72
+ * a redactor that threw.
73
+ *
74
+ * Not `null` and not an absent key: the producer reporting no reason and this box withholding one it
75
+ * cannot vouch for are different facts, and a summary screen is read as if they were the same.
76
+ */
77
+ export declare const SCANNER_TEXT_WITHHELD = "[withheld: not scrubbed]";
78
+ /** Flush cadence for the timeline. A live screen feels this number. */
79
+ export declare const DEFAULT_FLUSH_INTERVAL_MS = 1000;
80
+ /**
81
+ * Sample cadence for stats and topology. Both are built from one async read of every runtime's health
82
+ * and system state, so they share a tick. Five seconds is roughly a third of the default bucket width
83
+ * — fast enough that a counter visibly moves and a hung scan is seen while it is still running, slow
84
+ * enough that the per-scanner store read behind the system state is not a poll loop.
85
+ */
86
+ export declare const DEFAULT_SAMPLE_INTERVAL_MS = 5000;
87
+ /**
88
+ * The PUBLICATION list: what leaves on the timeline event. A name being on this list AND on the
89
+ * admission list is the normal case, not a duplication — `signal.outcome` is the decision row the feed
90
+ * is built around and the source of `opens`/`closes`/`skips`, and the two `scaffold.tick_*` names are
91
+ * the source of `errors` and the rows behind the Errors filter. A failing external scanner has to
92
+ * leave a visible line, not only a number that silently goes up.
93
+ *
94
+ * The two lists are separate so admission can be widened for a counter the feed does not display,
95
+ * which is the direction that has to stay open: the display filter belongs here at publish time,
96
+ * where it is still recoverable, never at append time, where it is not. Today nothing is admitted for
97
+ * counting alone, so the sets are equal — the seam is what matters, not the difference.
98
+ */
99
+ export declare const PUBLISHED_EVENT_NAMES: ReadonlySet<EventName>;
100
+ /**
101
+ * The share of its own interval a tick may take before it is warned about. A fraction rather than a
102
+ * constant, so a deployment that changes a cadence gets a proportional threshold: 250ms on the
103
+ * one-second timeline flush, 1.25s on the five-second sample.
104
+ *
105
+ * A quarter, not a whole interval. Both ticks share an event loop with the serial trading path, so a
106
+ * tick holding it for a quarter of its own period is already adding latency to trading; and a tick
107
+ * that fills its interval has already started stacking on the next one, which is too late to be told.
108
+ */
109
+ export declare const SLOW_TICK_FRACTION = 0.25;
110
+ /**
111
+ * How often the timing summary is logged, and the floor between two slow-tick warns of the same kind.
112
+ * The flush tick runs every second, so a line per tick would be tens of thousands a day for numbers
113
+ * that only mean anything aggregated — and a repeating tick that is slow is slow every time.
114
+ */
115
+ export declare const TIMING_REPORT_INTERVAL_MS = 60000;
116
+ export interface GatewayBroadcastOpts {
117
+ dropIfSlow?: boolean;
118
+ stateVersion?: number;
119
+ }
120
+ export type GatewayBroadcastFn = (event: string, payload: unknown, opts?: GatewayBroadcastOpts) => void;
121
+ /** One record as it goes on the wire. */
122
+ export interface TimelineWireRecord {
123
+ seq: number;
124
+ ts: number;
125
+ name: string;
126
+ level: string;
127
+ address: string;
128
+ scannerId?: string;
129
+ body: string;
130
+ attrs: Record<string, string | number | boolean>;
131
+ }
132
+ export interface TimelinePayload {
133
+ v: 1;
134
+ epoch: string;
135
+ batchSeq: number;
136
+ records: TimelineWireRecord[];
137
+ }
138
+ export interface TelemetrySnapshot {
139
+ epoch: string;
140
+ topology: StrategyTopologyPayload;
141
+ stats: ScannerStatsPayload;
142
+ recent: TimelinePayload;
143
+ /**
144
+ * The client asked to resume from a cursor inside THIS epoch whose successor is no longer held, or
145
+ * the window it is owed did not fit one frame. Either way there is a gap this response cannot fill,
146
+ * and only the box knows it: `recent.records` alone looks like a normal short window.
147
+ *
148
+ * A cursor from another epoch is not truncation. It buys nothing, so the whole retained window is
149
+ * served — which is the most this box could ever serve, and so nothing was withheld.
150
+ */
151
+ truncated: boolean;
152
+ }
153
+ /** Everything the two builders need that the buffer cannot supply, gathered once per tick. */
154
+ export interface TelemetryFacts {
155
+ strategies: TopologyStrategySource[];
156
+ runningRuntimeIds: IdMembership;
157
+ unwiredRuntimeIds: IdMembership;
158
+ readHealth?: (runtimeId: string) => RuntimeHealthLike | undefined;
159
+ scannerState: ScannerStateSnapshot[];
160
+ }
161
+ export interface LiveTelemetryOptions {
162
+ /** Defaults to the process buffer — one per process, shared by every address. */
163
+ buffer?: TimelineBuffer;
164
+ collectFacts: () => Promise<TelemetryFacts>;
165
+ flushIntervalMs?: number;
166
+ sampleIntervalMs?: number;
167
+ now?: () => number;
168
+ /**
169
+ * Monotonic millisecond reader for tick durations. Defaults to `performance.now`; `now` is wall
170
+ * clock and can step backwards under NTP, which would report a negative tick.
171
+ */
172
+ monotonicMs?: () => number;
173
+ }
174
+ export interface LiveTelemetry {
175
+ readonly epoch: string;
176
+ /** Take the broadcast handle off a gateway request context if we do not hold one yet. */
177
+ captureBroadcast(ctx: unknown, methodName: string): void;
178
+ /** `afterSeq` counts only when `afterEpoch` is the epoch this box is running. */
179
+ snapshot(params?: {
180
+ afterEpoch?: unknown;
181
+ afterSeq?: unknown;
182
+ }): Promise<TelemetrySnapshot>;
183
+ /** One flush tick: drain, filter to the publication list, scrub, frame, broadcast. */
184
+ flushTimeline(): Promise<void>;
185
+ /** One sample tick: stats always, topology when it changed. */
186
+ sample(): Promise<void>;
187
+ start(): void;
188
+ /** Clear both timers, drop the captured handle, and empty the buffer. */
189
+ stop(): void;
190
+ }
191
+ export declare function createLiveTelemetry(options: LiveTelemetryOptions): LiveTelemetry;
192
+ //# sourceMappingURL=live-telemetry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-telemetry.d.ts","sourceRoot":"","sources":["../../src/telemetry/live-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,KAAK,EAAa,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAKtE,OAAO,EAGL,KAAK,cAAc,EAEpB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAEL,KAAK,oBAAoB,EAEzB,KAAK,mBAAmB,EACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC5B,MAAM,wBAAwB,CAAC;AAIhC,4FAA4F;AAC5F,eAAO,MAAM,cAAc,0BAA0B,CAAC;AACtD,eAAO,MAAM,WAAW,+BAA+B,CAAC;AACxD,eAAO,MAAM,cAAc,4BAA4B,CAAC;AAExD;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,QAAa,CAAC;AAE1C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,OAAQ,CAAC;AAE5C;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,6BAA6B,CAAC;AAEhE,uEAAuE;AACvE,eAAO,MAAM,yBAAyB,OAAQ,CAAC;AAE/C;;;;;GAKG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