@senpi/runtime 3.0.132 → 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.
- package/README.md +4 -12
- package/dist/actions/action-events.d.ts +7 -21
- package/dist/actions/action-events.d.ts.map +1 -1
- package/dist/actions/action-events.js +26 -54
- package/dist/actions/action-events.js.map +1 -1
- package/dist/actions/action-runtime-module.d.ts.map +1 -1
- package/dist/actions/action-runtime-module.js +7 -38
- package/dist/actions/action-runtime-module.js.map +1 -1
- package/dist/actions/close-position/close-position.action.d.ts.map +1 -1
- package/dist/actions/close-position/close-position.action.js +15 -122
- package/dist/actions/close-position/close-position.action.js.map +1 -1
- package/dist/actions/decision-engine.d.ts.map +1 -1
- package/dist/actions/decision-engine.js +2 -15
- package/dist/actions/decision-engine.js.map +1 -1
- package/dist/actions/event-derivation.d.ts +2 -71
- package/dist/actions/event-derivation.d.ts.map +1 -1
- package/dist/actions/event-derivation.js +8 -251
- package/dist/actions/event-derivation.js.map +1 -1
- package/dist/actions/open-position/open-position.action.d.ts +2 -12
- package/dist/actions/open-position/open-position.action.d.ts.map +1 -1
- package/dist/actions/open-position/open-position.action.js +41 -144
- package/dist/actions/open-position/open-position.action.js.map +1 -1
- package/dist/actions/position-tracker/position-tracker.action.d.ts +1 -2
- package/dist/actions/position-tracker/position-tracker.action.d.ts.map +1 -1
- package/dist/actions/position-tracker/position-tracker.action.js +17 -62
- package/dist/actions/position-tracker/position-tracker.action.js.map +1 -1
- package/dist/actions/store/types.d.ts +2 -9
- package/dist/actions/store/types.d.ts.map +1 -1
- package/dist/actions/store/types.js.map +1 -1
- package/dist/actions/types.d.ts +0 -13
- package/dist/actions/types.d.ts.map +1 -1
- package/dist/actions/types.js +0 -13
- package/dist/actions/types.js.map +1 -1
- package/dist/cli/guide-commands.d.ts.map +1 -1
- package/dist/cli/guide-commands.js +13 -8
- package/dist/cli/guide-commands.js.map +1 -1
- package/dist/cli/senpi-commands.d.ts.map +1 -1
- package/dist/cli/senpi-commands.js +11 -4
- package/dist/cli/senpi-commands.js.map +1 -1
- package/dist/constants/dsl/index.d.ts +0 -6
- package/dist/constants/dsl/index.d.ts.map +1 -1
- package/dist/constants/dsl/index.js +0 -6
- package/dist/constants/dsl/index.js.map +1 -1
- package/dist/dsl/engine-client/event-mapping.d.ts.map +1 -1
- package/dist/dsl/engine-client/event-mapping.js +0 -14
- package/dist/dsl/engine-client/event-mapping.js.map +1 -1
- package/dist/dsl/events/build-closed-event.d.ts +1 -16
- package/dist/dsl/events/build-closed-event.d.ts.map +1 -1
- package/dist/dsl/events/build-closed-event.js +0 -6
- package/dist/dsl/events/build-closed-event.js.map +1 -1
- package/dist/dsl/events/handlers.d.ts +0 -7
- package/dist/dsl/events/handlers.d.ts.map +1 -1
- package/dist/dsl/events/handlers.js +7 -37
- package/dist/dsl/events/handlers.js.map +1 -1
- package/dist/dsl/monitor/create-monitor.d.ts +2 -6
- package/dist/dsl/monitor/create-monitor.d.ts.map +1 -1
- package/dist/dsl/monitor/create-monitor.js +9 -82
- package/dist/dsl/monitor/create-monitor.js.map +1 -1
- package/dist/dsl/monitor/dsl-failure-events.d.ts +2 -45
- package/dist/dsl/monitor/dsl-failure-events.d.ts.map +1 -1
- package/dist/dsl/monitor/dsl-failure-events.js +3 -52
- package/dist/dsl/monitor/dsl-failure-events.js.map +1 -1
- package/dist/dsl/monitor/process-one-position.d.ts +0 -1
- package/dist/dsl/monitor/process-one-position.d.ts.map +1 -1
- package/dist/dsl/monitor/process-one-position.js +36 -159
- package/dist/dsl/monitor/process-one-position.js.map +1 -1
- package/dist/dsl/plugin/index.d.ts +2 -8
- package/dist/dsl/plugin/index.d.ts.map +1 -1
- package/dist/dsl/plugin/index.js +6 -8
- package/dist/dsl/plugin/index.js.map +1 -1
- package/dist/health/types.d.ts +0 -13
- package/dist/health/types.d.ts.map +1 -1
- package/dist/health/types.js +0 -12
- package/dist/health/types.js.map +1 -1
- package/dist/index.d.ts +4 -27
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -271
- package/dist/index.js.map +1 -1
- package/dist/runtime/action-registry.d.ts.map +1 -1
- package/dist/runtime/action-registry.js +3 -4
- package/dist/runtime/action-registry.js.map +1 -1
- package/dist/runtime/auto-update/coordinator.d.ts +6 -13
- package/dist/runtime/auto-update/coordinator.d.ts.map +1 -1
- package/dist/runtime/auto-update/coordinator.js +18 -86
- package/dist/runtime/auto-update/coordinator.js.map +1 -1
- package/dist/runtime/auto-update/run-update-command.d.ts.map +1 -1
- package/dist/runtime/auto-update/run-update-command.js +3 -4
- package/dist/runtime/auto-update/run-update-command.js.map +1 -1
- package/dist/runtime/auto-update/types.d.ts +5 -11
- package/dist/runtime/auto-update/types.d.ts.map +1 -1
- package/dist/runtime/auto-update/types.js +0 -11
- package/dist/runtime/auto-update/types.js.map +1 -1
- package/dist/runtime/domain-events.d.ts.map +1 -1
- package/dist/runtime/domain-events.js +0 -7
- package/dist/runtime/domain-events.js.map +1 -1
- package/dist/runtime/lifecycle-events.d.ts +3 -15
- package/dist/runtime/lifecycle-events.d.ts.map +1 -1
- package/dist/runtime/lifecycle-events.js +3 -17
- package/dist/runtime/lifecycle-events.js.map +1 -1
- package/dist/runtime/lifecycle-reaper.d.ts +6 -4
- package/dist/runtime/lifecycle-reaper.d.ts.map +1 -1
- package/dist/runtime/lifecycle-reaper.js +6 -4
- package/dist/runtime/lifecycle-reaper.js.map +1 -1
- package/dist/runtime/reconcile-run.d.ts +3 -13
- package/dist/runtime/reconcile-run.d.ts.map +1 -1
- package/dist/runtime/reconcile-run.js +3 -4
- package/dist/runtime/reconcile-run.js.map +1 -1
- package/dist/runtime/reconcile-state.d.ts +0 -8
- package/dist/runtime/reconcile-state.d.ts.map +1 -1
- package/dist/runtime/reconcile-state.js +1 -4
- package/dist/runtime/reconcile-state.js.map +1 -1
- package/dist/runtime/risk-guard.d.ts +20 -1
- package/dist/runtime/risk-guard.d.ts.map +1 -1
- package/dist/runtime/risk-guard.js +47 -6
- package/dist/runtime/risk-guard.js.map +1 -1
- package/dist/runtime/run.d.ts +0 -1
- package/dist/runtime/run.d.ts.map +1 -1
- package/dist/runtime/run.js.map +1 -1
- package/dist/runtime/runtime-schema.js +3 -3
- package/dist/runtime/runtime-schema.js.map +1 -1
- package/dist/runtime/runtime.d.ts +3 -2
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +30 -37
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/strategy-lifecycle.d.ts +108 -2
- package/dist/runtime/strategy-lifecycle.d.ts.map +1 -1
- package/dist/runtime/strategy-lifecycle.js +325 -4
- package/dist/runtime/strategy-lifecycle.js.map +1 -1
- package/dist/runtime/supervisor/long-running-supervisor.d.ts +0 -13
- package/dist/runtime/supervisor/long-running-supervisor.d.ts.map +1 -1
- package/dist/runtime/supervisor/long-running-supervisor.js +0 -1
- package/dist/runtime/supervisor/long-running-supervisor.js.map +1 -1
- package/dist/runtime/validate-dsl-position-tracking.d.ts.map +1 -1
- package/dist/runtime/validate-dsl-position-tracking.js +1 -2
- package/dist/runtime/validate-dsl-position-tracking.js.map +1 -1
- package/dist/runtime-api/handlers/ingest-signals.d.ts.map +1 -1
- package/dist/runtime-api/handlers/ingest-signals.js +0 -1
- package/dist/runtime-api/handlers/ingest-signals.js.map +1 -1
- package/dist/runtime-api/handlers/types.d.ts +0 -5
- package/dist/runtime-api/handlers/types.d.ts.map +1 -1
- package/dist/runtime-api/intake/intake-events.d.ts +1 -1
- package/dist/runtime-api/intake/intake-events.d.ts.map +1 -1
- package/dist/runtime-api/intake/intake-events.js +3 -9
- package/dist/runtime-api/intake/intake-events.js.map +1 -1
- package/dist/runtime-api/intake/intake-mount.d.ts.map +1 -1
- package/dist/runtime-api/intake/intake-mount.js +19 -4
- package/dist/runtime-api/intake/intake-mount.js.map +1 -1
- package/dist/runtime-api/intake/process-error-post.d.ts +1 -6
- package/dist/runtime-api/intake/process-error-post.d.ts.map +1 -1
- package/dist/runtime-api/intake/process-error-post.js +1 -5
- package/dist/runtime-api/intake/process-error-post.js.map +1 -1
- package/dist/runtime-api/intake/process-signal-post.d.ts +1 -7
- package/dist/runtime-api/intake/process-signal-post.d.ts.map +1 -1
- package/dist/runtime-api/intake/process-signal-post.js +0 -5
- package/dist/runtime-api/intake/process-signal-post.js.map +1 -1
- package/dist/runtime-api/intake/scaffold-error-router.js.map +1 -1
- package/dist/runtime-api/intake/scanner-launcher.d.ts.map +1 -1
- package/dist/runtime-api/intake/scanner-launcher.js +0 -15
- package/dist/runtime-api/intake/scanner-launcher.js.map +1 -1
- package/dist/runtime-api/intake/types.d.ts +0 -55
- package/dist/runtime-api/intake/types.d.ts.map +1 -1
- package/dist/runtime-api/routes/signals.d.ts +0 -2
- package/dist/runtime-api/routes/signals.d.ts.map +1 -1
- package/dist/runtime-api/routes/signals.js +1 -5
- package/dist/runtime-api/routes/signals.js.map +1 -1
- package/dist/runtime-api/routes/signals.schema.d.ts +0 -43
- package/dist/runtime-api/routes/signals.schema.d.ts.map +1 -1
- package/dist/runtime-api/routes/signals.schema.js +0 -43
- package/dist/runtime-api/routes/signals.schema.js.map +1 -1
- package/dist/runtime-api/server.d.ts +1 -7
- package/dist/runtime-api/server.d.ts.map +1 -1
- package/dist/runtime-api/server.js +0 -1
- package/dist/runtime-api/server.js.map +1 -1
- package/dist/scanners/engine/engine.d.ts +1 -22
- package/dist/scanners/engine/engine.d.ts.map +1 -1
- package/dist/scanners/engine/engine.js +11 -78
- package/dist/scanners/engine/engine.js.map +1 -1
- package/dist/scanners/engine/lifecycle.d.ts +1 -7
- package/dist/scanners/engine/lifecycle.d.ts.map +1 -1
- package/dist/scanners/events.d.ts +0 -4
- package/dist/scanners/events.d.ts.map +1 -1
- package/dist/scanners/events.js +0 -2
- package/dist/scanners/events.js.map +1 -1
- package/dist/scanners/external/scaffold/delivery.py +25 -194
- package/dist/scanners/external/scaffold/scaffold.py +31 -172
- package/dist/scanners/external/scaffold/senpi_mcp.py +8 -150
- package/dist/scanners/external-scanner-receiver.d.ts +0 -17
- package/dist/scanners/external-scanner-receiver.d.ts.map +1 -1
- package/dist/scanners/external-scanner-receiver.js +0 -8
- package/dist/scanners/external-scanner-receiver.js.map +1 -1
- package/dist/scanners/runtime-module.d.ts +0 -1
- package/dist/scanners/runtime-module.d.ts.map +1 -1
- package/dist/scanners/runtime-module.js +9 -66
- package/dist/scanners/runtime-module.js.map +1 -1
- package/dist/telemetry/attributes.d.ts +0 -20
- package/dist/telemetry/attributes.d.ts.map +1 -1
- package/dist/telemetry/attributes.js +0 -24
- package/dist/telemetry/attributes.js.map +1 -1
- package/dist/telemetry/event-builders.d.ts +6 -81
- package/dist/telemetry/event-builders.d.ts.map +1 -1
- package/dist/telemetry/event-builders.js +17 -141
- package/dist/telemetry/event-builders.js.map +1 -1
- package/dist/telemetry/event-store.d.ts +0 -6
- package/dist/telemetry/event-store.d.ts.map +1 -1
- package/dist/telemetry/event-store.js +8 -12
- package/dist/telemetry/event-store.js.map +1 -1
- package/dist/telemetry/metrics.d.ts +2 -14
- package/dist/telemetry/metrics.d.ts.map +1 -1
- package/dist/telemetry/metrics.js +4 -19
- package/dist/telemetry/metrics.js.map +1 -1
- package/dist/telemetry/spans/redact-pii.d.ts.map +1 -1
- package/dist/telemetry/spans/redact-pii.js +2 -18
- package/dist/telemetry/spans/redact-pii.js.map +1 -1
- package/dist/telemetry/tracing.d.ts +0 -9
- package/dist/telemetry/tracing.d.ts.map +1 -1
- package/dist/telemetry/tracing.js +0 -36
- package/dist/telemetry/tracing.js.map +1 -1
- package/dist/types/dsl/index.d.ts +0 -48
- package/dist/types/dsl/index.d.ts.map +1 -1
- package/dist/types/scanner.d.ts +0 -15
- package/dist/types/scanner.d.ts.map +1 -1
- package/dist/utils/event-catalog.d.ts +0 -202
- package/dist/utils/event-catalog.d.ts.map +1 -1
- package/dist/utils/event-catalog.js +0 -26
- package/dist/utils/event-catalog.js.map +1 -1
- package/dist/utils/logger.d.ts +1 -4
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js.map +1 -1
- package/dist/validate/recipe-checks.d.ts.map +1 -1
- package/dist/validate/recipe-checks.js +2 -2
- package/dist/validate/recipe-checks.js.map +1 -1
- package/openclaw.plugin.json +4 -8
- package/package.json +1 -1
- package/dist/actions/skipped-signal-results.d.ts +0 -25
- package/dist/actions/skipped-signal-results.d.ts.map +0 -1
- package/dist/actions/skipped-signal-results.js +0 -71
- package/dist/actions/skipped-signal-results.js.map +0 -1
- package/dist/runtime-api/intake/ingest-request.d.ts +0 -17
- package/dist/runtime-api/intake/ingest-request.d.ts.map +0 -1
- package/dist/runtime-api/intake/ingest-request.js +0 -34
- package/dist/runtime-api/intake/ingest-request.js.map +0 -1
- package/dist/runtime-api/intake/scaffold-tick-router.d.ts +0 -39
- package/dist/runtime-api/intake/scaffold-tick-router.d.ts.map +0 -1
- package/dist/runtime-api/intake/scaffold-tick-router.js +0 -122
- package/dist/runtime-api/intake/scaffold-tick-router.js.map +0 -1
- package/dist/scanners/external/scaffold/tick_facts.py +0 -130
- package/dist/scanners/external/scaffold/ulid.py +0 -58
- package/dist/telemetry/dsl-positions.d.ts +0 -111
- package/dist/telemetry/dsl-positions.d.ts.map +0 -1
- package/dist/telemetry/dsl-positions.js +0 -118
- package/dist/telemetry/dsl-positions.js.map +0 -1
- package/dist/telemetry/live-telemetry.d.ts +0 -257
- package/dist/telemetry/live-telemetry.d.ts.map +0 -1
- package/dist/telemetry/live-telemetry.js +0 -959
- package/dist/telemetry/live-telemetry.js.map +0 -1
- package/dist/telemetry/scanner-stats.d.ts +0 -143
- package/dist/telemetry/scanner-stats.d.ts.map +0 -1
- package/dist/telemetry/scanner-stats.js +0 -426
- package/dist/telemetry/scanner-stats.js.map +0 -1
- package/dist/telemetry/scanner-tick-feed.d.ts +0 -87
- package/dist/telemetry/scanner-tick-feed.d.ts.map +0 -1
- package/dist/telemetry/scanner-tick-feed.js +0 -48
- package/dist/telemetry/scanner-tick-feed.js.map +0 -1
- package/dist/telemetry/strategy-topology.d.ts +0 -99
- package/dist/telemetry/strategy-topology.d.ts.map +0 -1
- package/dist/telemetry/strategy-topology.js +0 -93
- package/dist/telemetry/strategy-topology.js.map +0 -1
- package/dist/telemetry/telemetry-publisher.d.ts +0 -83
- package/dist/telemetry/telemetry-publisher.d.ts.map +0 -1
- package/dist/telemetry/telemetry-publisher.js +0 -256
- package/dist/telemetry/telemetry-publisher.js.map +0 -1
- package/dist/telemetry/tick-frame.d.ts +0 -212
- package/dist/telemetry/tick-frame.d.ts.map +0 -1
- package/dist/telemetry/tick-frame.js +0 -421
- package/dist/telemetry/tick-frame.js.map +0 -1
- package/dist/telemetry/timeline-buffer.d.ts +0 -95
- package/dist/telemetry/timeline-buffer.d.ts.map +0 -1
- package/dist/telemetry/timeline-buffer.js +0 -237
- package/dist/telemetry/timeline-buffer.js.map +0 -1
- package/dist/utils/telemetry-required-log.d.ts +0 -60
- package/dist/utils/telemetry-required-log.d.ts.map +0 -1
- package/dist/utils/telemetry-required-log.js +0 -105
- package/dist/utils/telemetry-required-log.js.map +0 -1
- package/dist/utils/ulid.d.ts +0 -9
- package/dist/utils/ulid.d.ts.map +0 -1
- package/dist/utils/ulid.js +0 -43
- package/dist/utils/ulid.js.map +0 -1
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The producer tap for the live telemetry stream: a second {@link EventSink} that copies selected
|
|
3
|
-
* `logger.event` records into the in-memory {@link TimelineBuffer} while the on-disk ring keeps
|
|
4
|
-
* receiving every one of them. It sits on the serial trading path, so it resolves the scanner id,
|
|
5
|
-
* picks a fixed set of fields, appends, and returns — no I/O, no await, no counting, no serialization.
|
|
6
|
-
*
|
|
7
|
-
* Two lists govern the stream, and this module owns only the first:
|
|
8
|
-
* - ADMISSION ({@link ADMITTED_EVENT_NAMES}) — what enters the buffer. Every name the timeline
|
|
9
|
-
* displays PLUS every name a counter is derived from, because a counting source that never enters
|
|
10
|
-
* the buffer makes the stats read zero with nothing logged anywhere.
|
|
11
|
-
* - PUBLICATION — what leaves on the timeline event. Applied at flush time, not here. Admission is
|
|
12
|
-
* deliberately the wider of the two: filtering for display at append time is unrecoverable.
|
|
13
|
-
*/
|
|
14
|
-
import { EVENT_NAME } from "../utils/event-catalog.js";
|
|
15
|
-
import { createLogger } from "../utils/logger.js";
|
|
16
|
-
import { normalizeStrategyAddress } from "./event-store.js";
|
|
17
|
-
import { getTimelineBuffer } from "./timeline-buffer.js";
|
|
18
|
-
const logger = createLogger("[senpi-core][telemetry-publisher]");
|
|
19
|
-
/** The scanner's STABLE id. Carried by every event whose `senpi.scanner.id` is ephemeral. */
|
|
20
|
-
const SCANNER_NAME_ATTR = "senpi.scanner.name";
|
|
21
|
-
/** Stable on `signal.outcome` and `scanner.summary`; the ephemeral per-launch id everywhere else. */
|
|
22
|
-
const SCANNER_ID_ATTR = "senpi.scanner.id";
|
|
23
|
-
/**
|
|
24
|
-
* The names that may enter the buffer. Volume control for a bounded ring, so it is an allow-list of
|
|
25
|
-
* the strategy's own narrative: what its scanners did, what each signal became, what was traded, how
|
|
26
|
-
* the exit engine defended an open position, and why the strategy's status changed. It excludes the
|
|
27
|
-
* box-operations and agent-plane families — `auto_update.*`, `tool.*`, `tool_approval.*`, the
|
|
28
|
-
* installer and the state/mcp faults — which describe the box the strategy runs on, not the
|
|
29
|
-
* strategy.
|
|
30
|
-
*
|
|
31
|
-
* The whole `dsl.*` family is admitted, the four records of the engine acting on money included: a
|
|
32
|
-
* stop that moved, a close it is waiting on, the attempt that performs the close, and a position it
|
|
33
|
-
* can no longer price. None of them is poll-frequency. A `dsl.sl_updated` follows a venue write that
|
|
34
|
-
* `shouldSyncExchangeSl` allowed — a stop that is missing, a sync retrying, a phase or tier change,
|
|
35
|
-
* or a floor that moved further than `slSyncMinDeltaForPrice` — and a position the backend owns
|
|
36
|
-
* emits none at all. `dsl.price_fetch_stale` is latched on the position state and re-armed only when
|
|
37
|
-
* a price returns, so a stall costs one record rather than one per failed poll, and the close pair
|
|
38
|
-
* fires once in a position's life. Against a ring holding `DEFAULT_MAX_RECORDS_PER_ADDRESS` records
|
|
39
|
-
* per address over a window measured in minutes, that volume evicts nothing — and a reader watching
|
|
40
|
-
* a trade has to be able to see the stop move.
|
|
41
|
-
*
|
|
42
|
-
* `dsl.tick_aborted` and `dsl.tick_recovered` are the widest of the family and the cheapest: a tick
|
|
43
|
-
* that aborts at the clearinghouse gate evaluates NO position on the box, and the per-position
|
|
44
|
-
* counters that `dsl.price_fetch_stale` is derived from sit past that gate, so without this pair the
|
|
45
|
-
* largest blind spot in the engine reaches the ring as nothing at all. Both are latched on the
|
|
46
|
-
* monitor and re-armed only by a completed tick, so an outage of any length costs exactly two
|
|
47
|
-
* records — a floor under the pair's volume that no poll frequency can lift.
|
|
48
|
-
*
|
|
49
|
-
* `dsl.close_attempt` has no `logger.event` behind it: it is a span the monitor opens around the
|
|
50
|
-
* venue call, so admitting the name reserves it rather than adding records.
|
|
51
|
-
*
|
|
52
|
-
* Typed as `EventName`, so renaming a catalog entry out from under this list is a compile error
|
|
53
|
-
* rather than a silently empty counter.
|
|
54
|
-
*/
|
|
55
|
-
export const ADMITTED_EVENT_NAMES = new Set([
|
|
56
|
-
// Counting sources. `opens` and `skips` come from `signal.outcome`, `errors` from the two
|
|
57
|
-
// `scaffold.tick_*` names. These four are load-bearing, not display-driven.
|
|
58
|
-
EVENT_NAME.signalOutcome,
|
|
59
|
-
EVENT_NAME.decisionMade,
|
|
60
|
-
EVENT_NAME.scaffoldTickError,
|
|
61
|
-
EVENT_NAME.scaffoldTickTimeout,
|
|
62
|
-
// Scanner run and health: the per-run heartbeat plus every supervisor transition behind a
|
|
63
|
-
// scanner's health, degraded reason and restart count.
|
|
64
|
-
EVENT_NAME.scannerSummary,
|
|
65
|
-
EVENT_NAME.scannerSpawned,
|
|
66
|
-
EVENT_NAME.scannerExited,
|
|
67
|
-
EVENT_NAME.scannerRestarted,
|
|
68
|
-
EVENT_NAME.scannerDegraded,
|
|
69
|
-
EVENT_NAME.scannerRecovered,
|
|
70
|
-
EVENT_NAME.scannerSilenceKilled,
|
|
71
|
-
EVENT_NAME.scannerLaunchFailed,
|
|
72
|
-
// Signal intake: what arrived and what was dropped before an action ever evaluated it.
|
|
73
|
-
EVENT_NAME.signalAccepted,
|
|
74
|
-
EVENT_NAME.signalRejected,
|
|
75
|
-
EVENT_NAME.signalExpired,
|
|
76
|
-
EVENT_NAME.signalSuperseded,
|
|
77
|
-
// Execution: the order and position story behind an accepted signal.
|
|
78
|
-
EVENT_NAME.orderPlaced,
|
|
79
|
-
EVENT_NAME.orderFilled,
|
|
80
|
-
EVENT_NAME.orderFailed,
|
|
81
|
-
EVENT_NAME.positionOpened,
|
|
82
|
-
EVENT_NAME.positionClosed,
|
|
83
|
-
EVENT_NAME.positionIncreased,
|
|
84
|
-
EVENT_NAME.positionDecreased,
|
|
85
|
-
EVENT_NAME.positionFlipped,
|
|
86
|
-
EVENT_NAME.positionReconciled,
|
|
87
|
-
// Exit engine: the state changes of an armed exit and the stop moves it wrote to the venue, not
|
|
88
|
-
// its per-tick floor arithmetic.
|
|
89
|
-
EVENT_NAME.dslCreated,
|
|
90
|
-
EVENT_NAME.dslPhaseChanged,
|
|
91
|
-
EVENT_NAME.dslTierAdvanced,
|
|
92
|
-
EVENT_NAME.dslSlUpdated,
|
|
93
|
-
EVENT_NAME.dslClosePending,
|
|
94
|
-
EVENT_NAME.dslClosed,
|
|
95
|
-
EVENT_NAME.dslDeleted,
|
|
96
|
-
EVENT_NAME.dslCloseAttempt,
|
|
97
|
-
EVENT_NAME.dslSlSyncFailed,
|
|
98
|
-
EVENT_NAME.dslPriceFetchStale,
|
|
99
|
-
EVENT_NAME.dslHandoffFailed,
|
|
100
|
-
EVENT_NAME.dslTickAborted,
|
|
101
|
-
EVENT_NAME.dslTickRecovered,
|
|
102
|
-
// Strategy status, and the two faults that explain a strategy that is up but not trading.
|
|
103
|
-
EVENT_NAME.runtimeStarted,
|
|
104
|
-
EVENT_NAME.runtimeStopped,
|
|
105
|
-
EVENT_NAME.runtimePaused,
|
|
106
|
-
EVENT_NAME.runtimeResumed,
|
|
107
|
-
EVENT_NAME.runtimeError,
|
|
108
|
-
EVENT_NAME.runtimeQueueBackpressure,
|
|
109
|
-
EVENT_NAME.runtimeScannersUnwired,
|
|
110
|
-
]);
|
|
111
|
-
let tapCalls = 0;
|
|
112
|
-
let tapNsTotal = 0;
|
|
113
|
-
let tapNsMax = 0;
|
|
114
|
-
/**
|
|
115
|
-
* Take the window and zero it. The reader owns the window: a counter that is never reset reports a
|
|
116
|
-
* lifetime total forever, which sizes nothing. Process-wide, like the buffer the tap feeds.
|
|
117
|
-
*/
|
|
118
|
-
export function readAndResetTapCounters() {
|
|
119
|
-
const window = { calls: tapCalls, nsTotal: tapNsTotal, nsMax: tapNsMax };
|
|
120
|
-
tapCalls = 0;
|
|
121
|
-
tapNsTotal = 0;
|
|
122
|
-
tapNsMax = 0;
|
|
123
|
-
return window;
|
|
124
|
-
}
|
|
125
|
-
function noteTapCall(startedAt) {
|
|
126
|
-
const ns = Number(process.hrtime.bigint() - startedAt);
|
|
127
|
-
tapCalls += 1;
|
|
128
|
-
tapNsTotal += ns;
|
|
129
|
-
if (ns > tapNsMax)
|
|
130
|
-
tapNsMax = ns;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* The scanner this record belongs to. The name attribute wins: `senpi.scanner.id` carries a
|
|
134
|
-
* per-launch id on the intake, scaffold and supervisor events, so reading it unqualified files one
|
|
135
|
-
* scanner under a new key on every external-scanner restart. Absent — never empty — when the record
|
|
136
|
-
* has no scanner at all; the record is still buffered and the client buckets it as unattributed.
|
|
137
|
-
*/
|
|
138
|
-
function resolveScannerId(attrs) {
|
|
139
|
-
const name = attrs[SCANNER_NAME_ATTR];
|
|
140
|
-
if (typeof name === "string" && name !== "")
|
|
141
|
-
return name;
|
|
142
|
-
const id = attrs[SCANNER_ID_ATTR];
|
|
143
|
-
return typeof id === "string" && id !== "" ? id : undefined;
|
|
144
|
-
}
|
|
145
|
-
function isScalar(value) {
|
|
146
|
-
const t = typeof value;
|
|
147
|
-
return t === "string" || t === "number" || t === "boolean";
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* The bag minus any non-scalar value. Unlike the disk ring — which serializes and forgets — the
|
|
151
|
-
* buffer holds this reference for the whole retention window and then puts it on the wire, so a
|
|
152
|
-
* nested object would pin an arbitrary graph in memory and break the payload's scalar contract.
|
|
153
|
-
* The common case allocates nothing: a copy is made only once a bad value is actually seen.
|
|
154
|
-
*/
|
|
155
|
-
function scalarAttrs(attrs, onDropped) {
|
|
156
|
-
let clean = attrs;
|
|
157
|
-
for (const key of Object.keys(attrs)) {
|
|
158
|
-
if (isScalar(attrs[key]))
|
|
159
|
-
continue;
|
|
160
|
-
if (clean === attrs)
|
|
161
|
-
clean = { ...attrs };
|
|
162
|
-
delete clean[key];
|
|
163
|
-
onDropped();
|
|
164
|
-
}
|
|
165
|
-
return clean;
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* A sink that copies admitted records into the timeline buffer under `address`. One instance per
|
|
169
|
-
* registered address; every instance writes into the same process buffer, which is what makes the
|
|
170
|
-
* publisher process-wide and address-partitioned rather than per-runtime.
|
|
171
|
-
*/
|
|
172
|
-
export function createTelemetryPublisherSink(address, options = {}) {
|
|
173
|
-
const bufferAddress = normalizeStrategyAddress(address);
|
|
174
|
-
// Reset on a later success so a transient failure can warn again if it recurs, but a persistently
|
|
175
|
-
// wedged buffer cannot spam a per-event warn on the trading path.
|
|
176
|
-
let warnedAppendFailure = false;
|
|
177
|
-
let warnedNonScalarAttr = false;
|
|
178
|
-
function noteNonScalarAttr(name) {
|
|
179
|
-
if (warnedNonScalarAttr)
|
|
180
|
-
return;
|
|
181
|
-
warnedNonScalarAttr = true;
|
|
182
|
-
logger.warn("telemetry publisher dropped a non-scalar event attribute", {
|
|
183
|
-
"senpi.event.name": name,
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
return {
|
|
187
|
-
append(event) {
|
|
188
|
-
// Measured in a `finally` so the rejected and the failed paths count too: they are the cheapest
|
|
189
|
-
// and the most expensive calls the trading path makes, and an average of neither is honest.
|
|
190
|
-
const startedAt = process.hrtime.bigint();
|
|
191
|
-
try {
|
|
192
|
-
if (!ADMITTED_EVENT_NAMES.has(event.name))
|
|
193
|
-
return;
|
|
194
|
-
const attrs = event.attrs ?? {};
|
|
195
|
-
// Named fields only: whatever else rides the record — a redact slot, resource attributes —
|
|
196
|
-
// is not copied because it is never read.
|
|
197
|
-
(options.buffer ?? getTimelineBuffer()).append({
|
|
198
|
-
ts: event.ts,
|
|
199
|
-
name: event.name,
|
|
200
|
-
level: event.level,
|
|
201
|
-
address: bufferAddress,
|
|
202
|
-
scannerId: resolveScannerId(attrs),
|
|
203
|
-
body: event.body,
|
|
204
|
-
attrs: scalarAttrs(attrs, () => noteNonScalarAttr(event.name)),
|
|
205
|
-
});
|
|
206
|
-
warnedAppendFailure = false;
|
|
207
|
-
}
|
|
208
|
-
catch (err) {
|
|
209
|
-
// The tap must never disturb the logging caller, and a wedged tap must not be silent.
|
|
210
|
-
if (!warnedAppendFailure) {
|
|
211
|
-
warnedAppendFailure = true;
|
|
212
|
-
logger.warn("telemetry publisher append failed; the live stream may be incomplete", {
|
|
213
|
-
address: bufferAddress,
|
|
214
|
-
err: err instanceof Error ? err.message : String(err),
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
finally {
|
|
219
|
-
noteTapCall(startedAt);
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
flush: () => Promise.resolve(),
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* One sink that feeds several. `registerEventSink` keys a single sink per address, so this is how
|
|
227
|
-
* the publisher rides alongside the on-disk ring instead of replacing it. Each branch already
|
|
228
|
-
* swallows its own failures; the loop keeps one branch's throw from starving the rest regardless.
|
|
229
|
-
*/
|
|
230
|
-
export function createFanOutEventSink(sinks) {
|
|
231
|
-
return {
|
|
232
|
-
append(event) {
|
|
233
|
-
for (const sink of sinks) {
|
|
234
|
-
try {
|
|
235
|
-
sink.append(event);
|
|
236
|
-
}
|
|
237
|
-
catch {
|
|
238
|
-
// A branch that breaks its own no-throw contract must not cost the others their record.
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
},
|
|
242
|
-
async flush() {
|
|
243
|
-
// Sequential and individually guarded: a graceful stop awaits this, so one branch's rejection
|
|
244
|
-
// must not skip another's drain or surface as a failed stop.
|
|
245
|
-
for (const sink of sinks) {
|
|
246
|
-
try {
|
|
247
|
-
await sink.flush();
|
|
248
|
-
}
|
|
249
|
-
catch {
|
|
250
|
-
// A branch that cannot drain has already reported it; the stop path carries on.
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
},
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
//# sourceMappingURL=telemetry-publisher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry-publisher.js","sourceRoot":"","sources":["../../src/telemetry/telemetry-publisher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAkC,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAoC,MAAM,kBAAkB,CAAC;AAC9F,OAAO,EAAE,iBAAiB,EAAuB,MAAM,sBAAsB,CAAC;AAE9E,MAAM,MAAM,GAAG,YAAY,CAAC,mCAAmC,CAAC,CAAC;AAEjE,6FAA6F;AAC7F,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AAC/C,qGAAqG;AACrG,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAA2B,IAAI,GAAG,CAAY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AAC;YACH,CAAC;QACH,CAAC;QACD,KAAK,CAAC,KAAK;YACT,8FAA8F;YAC9F,6DAA6D;YAC7D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,IAAI,CAAC;oBACH,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;gBACrB,CAAC;gBAAC,MAAM,CAAC;oBACP,gFAAgF;gBAClF,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The compact `plugin.senpi.tick` frame: the wire shape, the two detail dials that gate it, and the
|
|
3
|
-
* byte budget it is built under.
|
|
4
|
-
*
|
|
5
|
-
* Shape, and why it is compact. A frame carries the latest finished run of every scanner on the box,
|
|
6
|
-
* so the same 42-character wallet, the same scanner name and the same handful of tool names repeat on
|
|
7
|
-
* every entry. A per-frame dictionary interns them once and each entry references them by index; the
|
|
8
|
-
* timestamps are deltas from one frame-level `t0`; and the keys are one or two characters. Two hundred
|
|
9
|
-
* runtimes at full detail land under a tenth of the frame budget this way, where the long-key shape
|
|
10
|
-
* would not.
|
|
11
|
-
*
|
|
12
|
-
* Short keys stop at this boundary. A client's store expands them once at the reducer and its
|
|
13
|
-
* components keep reading `scannedCount`, never `n`.
|
|
14
|
-
*
|
|
15
|
-
* Two dials, not one. `mcp` gates what the MCP boundary reports (`sw`, `mms`, `c`, `cms`) and `state`
|
|
16
|
-
* gates the author's own state projection (`stc`, `st`), because the two cost very different numbers
|
|
17
|
-
* of bytes and an operator watching a slow venue does not also want every author key on the wire. The
|
|
18
|
-
* tick's own summary facts (`q`, `lag`, `jp`, `cm`) belong to neither, so they ride whenever either
|
|
19
|
-
* dial is up: with both off the frame is the always-keys only, which is the shape a box publishes when
|
|
20
|
-
* it wants nothing but proof of life.
|
|
21
|
-
*
|
|
22
|
-
* Nothing here reaches `logger.event` or `appendDomainEvent`. A tick is a LEVEL — see
|
|
23
|
-
* {@link ../utils/telemetry-required-log.js} for why these facts must not become catalogued events.
|
|
24
|
-
*/
|
|
25
|
-
/** How much of one source a frame carries. */
|
|
26
|
-
export type TickDetail = "off" | "summary" | "verbose";
|
|
27
|
-
/** The plugin-config shape: one level for both sources, or a level per source. */
|
|
28
|
-
export type TickTelemetryConfig = TickDetail | {
|
|
29
|
-
mcp?: TickDetail;
|
|
30
|
-
state?: TickDetail;
|
|
31
|
-
};
|
|
32
|
-
/** The resolved dials. `enabled` is false only for a bare `"off"`, which publishes no frame at all. */
|
|
33
|
-
export interface TickTelemetrySettings {
|
|
34
|
-
readonly enabled: boolean;
|
|
35
|
-
readonly mcp: TickDetail;
|
|
36
|
-
readonly state: TickDetail;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* The level a source takes when the configuration does not name it.
|
|
40
|
-
*
|
|
41
|
-
* Verbose, not summary: a box is watched by exactly one client over that client's own socket, the
|
|
42
|
-
* frame budget holds two hundred runtimes at this level, and an operator who has to change a setting
|
|
43
|
-
* before the screen can answer why a scanner is slow will not have changed it yet when it matters.
|
|
44
|
-
*/
|
|
45
|
-
export declare const DEFAULT_TICK_DETAIL: TickDetail;
|
|
46
|
-
/**
|
|
47
|
-
* Character ceiling for one scanner-authored string inside a tick — an outcome, a state value, a
|
|
48
|
-
* tool argument. Matches the cap the stats payload's free text takes, for the same reason: these
|
|
49
|
-
* carry a stringified throwable or an author's own value, and nothing upstream bounds either.
|
|
50
|
-
*/
|
|
51
|
-
export declare const MAX_TICK_TEXT_CHARS = 1024;
|
|
52
|
-
/**
|
|
53
|
-
* Calls recorded for one tick. A scanner that calls a tool in a loop would otherwise put an unbounded
|
|
54
|
-
* list on the wire; past this many the tally still counts them (`c` at summary and `cms` stay whole,
|
|
55
|
-
* because they are read off the scaffold's own totals), and only the per-call detail is cut.
|
|
56
|
-
*/
|
|
57
|
-
export declare const MAX_TICK_CALLS = 64;
|
|
58
|
-
/**
|
|
59
|
-
* Bounds for one list-valued argument, mirroring the producer's own per-list bounds: at most this
|
|
60
|
-
* many elements, and no more characters across the whole list than a single string argument is
|
|
61
|
-
* allowed. The frame is a second, independent gate on values the scaffold already bounded, so it
|
|
62
|
-
* must not admit a longer list than the scaffold can send — and a list from any other producer is
|
|
63
|
-
* held to the same terms here.
|
|
64
|
-
*
|
|
65
|
-
* The frame's byte budget is not a substitute. That budget drops a whole ENTRY that does not fit,
|
|
66
|
-
* so without these one scanner's long list would cost that scanner's entire tick rather than the
|
|
67
|
-
* tail of the list. The character bound is counted AFTER the scrub, for the reason `scrubText`
|
|
68
|
-
* gives: a redaction can be longer than the text it replaced, so a bound taken first would bound
|
|
69
|
-
* the input and not what leaves.
|
|
70
|
-
*/
|
|
71
|
-
export declare const MAX_TICK_CALL_ARG_LIST_ITEMS = 16;
|
|
72
|
-
export declare const MAX_TICK_CALL_ARG_LIST_CHARS = 1024;
|
|
73
|
-
/**
|
|
74
|
-
* `cm` — the state commit outcome, as a RAW STRING and not a dictionary index. Only `a` `s` `m` `o`
|
|
75
|
-
* `x` are interned; these are a small closed set a client reads directly.
|
|
76
|
-
*
|
|
77
|
-
* A tick that committed normally sends nothing at all: the key exists to make the abnormal endings
|
|
78
|
-
* visible, and the common case is not one of them.
|
|
79
|
-
*
|
|
80
|
-
* - `rolled_back` — the tick was not `ok`, so the scaffold discarded the tick's state mutations.
|
|
81
|
-
* - `persist_failed` — the commit was attempted, the write failed, and the tick was rolled back;
|
|
82
|
-
* state did not advance, which is the stall this key exists to make visible.
|
|
83
|
-
*/
|
|
84
|
-
export declare const COMMIT_ROLLED_BACK = "rolled_back";
|
|
85
|
-
export declare const COMMIT_PERSIST_FAILED = "persist_failed";
|
|
86
|
-
/** The commit endings a producer may report. `committed` is the absent case. */
|
|
87
|
-
export type TickCommitOutcome = "committed" | typeof COMMIT_ROLLED_BACK | typeof COMMIT_PERSIST_FAILED;
|
|
88
|
-
/** One MCP tool call a tick made, as the producer's boundary timed it. */
|
|
89
|
-
export interface TickCall {
|
|
90
|
-
readonly tool: string;
|
|
91
|
-
/** Wall time the call took. Absent when the producer reported none; never zero as a stand-in. */
|
|
92
|
-
readonly ms?: number;
|
|
93
|
-
/** The call's arguments. Ride at `mcp: verbose` only, sanitised, scrubbed and capped. */
|
|
94
|
-
readonly args?: Readonly<Record<string, unknown>>;
|
|
95
|
-
/** Set only on a failed call — the leaf error's type, as the boundary classified it. */
|
|
96
|
-
readonly errorType?: string;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* One finished run waiting for the next frame, already narrowed to what a tick carries.
|
|
100
|
-
*
|
|
101
|
-
* Every optional field means UNKNOWN when it is absent. A `scannedCount` of `0` is a scanner that
|
|
102
|
-
* looked at nothing; an absent one is a scanner that did not say. The distinction is held from the
|
|
103
|
-
* producer through this frame to the screen, so nothing here may default one to the other.
|
|
104
|
-
*/
|
|
105
|
-
export interface PendingTick {
|
|
106
|
-
readonly address: string;
|
|
107
|
-
readonly scannerId: string;
|
|
108
|
-
/** Run status as the producer reports it. Scanner-authored text: scrubbed and capped. */
|
|
109
|
-
readonly outcome: string;
|
|
110
|
-
readonly finishedAt: number;
|
|
111
|
-
readonly signalCount: number;
|
|
112
|
-
readonly scannedCount?: number;
|
|
113
|
-
readonly durationMs?: number;
|
|
114
|
-
/** MCP failures the author's own `except` swallowed this tick. */
|
|
115
|
-
readonly mcpFailures?: number;
|
|
116
|
-
readonly mcpCalls?: readonly TickCall[];
|
|
117
|
-
/** Total time inside MCP this tick, as the producer totalled it. */
|
|
118
|
-
readonly mcpMs?: number;
|
|
119
|
-
/** Consecutive ticks that produced no signal, this one included. */
|
|
120
|
-
readonly quietTicks?: number;
|
|
121
|
-
/** Actual gap since the previous tick minus the configured interval. */
|
|
122
|
-
readonly lagMs?: number;
|
|
123
|
-
/** Signals still awaiting delivery in the producer's journal. */
|
|
124
|
-
readonly journalPending?: number;
|
|
125
|
-
readonly commit?: TickCommitOutcome;
|
|
126
|
-
/** The last COMMITTED state row, scalars only — stale by one tick by construction. */
|
|
127
|
-
readonly state?: Readonly<Record<string, unknown>>;
|
|
128
|
-
/** Fields in that row before sanitising, so `stc` can report the drop. */
|
|
129
|
-
readonly stateFieldCount?: number;
|
|
130
|
-
/** Fields in that row whose value moved since the previous committed row. */
|
|
131
|
-
readonly stateChangedCount?: number;
|
|
132
|
-
}
|
|
133
|
-
/** `c` at `mcp: summary` — how many times each tool was called, keyed by dictionary index. */
|
|
134
|
-
export type TickCallCounts = Record<number, number>;
|
|
135
|
-
/** `c` at `mcp: verbose` — one element per call; the error index appears only on a failed one. */
|
|
136
|
-
export type TickCallDetail = readonly [tool: number, ms: number, args: Record<string, unknown>] | readonly [tool: number, ms: number, args: Record<string, unknown>, err: number];
|
|
137
|
-
/** One tick on the wire. Every key is an index into the frame dictionary or a scalar. */
|
|
138
|
-
export interface TickFrameEntry {
|
|
139
|
-
a: number;
|
|
140
|
-
s: number;
|
|
141
|
-
t: number;
|
|
142
|
-
o: number;
|
|
143
|
-
n?: number;
|
|
144
|
-
g: number;
|
|
145
|
-
ms?: number;
|
|
146
|
-
mms?: number;
|
|
147
|
-
q?: number;
|
|
148
|
-
lag?: number;
|
|
149
|
-
sw?: number;
|
|
150
|
-
jp?: number;
|
|
151
|
-
cm?: string;
|
|
152
|
-
c?: TickCallCounts | TickCallDetail[];
|
|
153
|
-
cms?: number;
|
|
154
|
-
stc?: readonly [changed: number, total: number];
|
|
155
|
-
st?: Record<string, string | number | boolean>;
|
|
156
|
-
}
|
|
157
|
-
/** The per-frame dictionary every index in an entry refers to. */
|
|
158
|
-
export interface TickFrameDictionary {
|
|
159
|
-
/** Wallet addresses, normalised. */
|
|
160
|
-
a: string[];
|
|
161
|
-
/** Scanner ids. */
|
|
162
|
-
s: string[];
|
|
163
|
-
/** MCP tool names. */
|
|
164
|
-
m: string[];
|
|
165
|
-
/** Run outcomes. */
|
|
166
|
-
o: string[];
|
|
167
|
-
/** Error types. */
|
|
168
|
-
x: string[];
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* A tick frame. No `batchSeq`, and its entries carry no `seq`: this is the current state of a set of
|
|
172
|
-
* scanners, and a client that misses a frame is made whole by the next one rather than by a replay.
|
|
173
|
-
*/
|
|
174
|
-
export interface TickFramePayload {
|
|
175
|
-
v: 1;
|
|
176
|
-
e: string;
|
|
177
|
-
/** The frame's time base. Every entry's `t` is a millisecond offset from it. */
|
|
178
|
-
t0: number;
|
|
179
|
-
d: TickFrameDictionary;
|
|
180
|
-
k: TickFrameEntry[];
|
|
181
|
-
}
|
|
182
|
-
/** Scrub one scanner-authored string. `null` means the text could not be vouched for. */
|
|
183
|
-
export type TickScrub = (text: string) => Promise<string | null>;
|
|
184
|
-
export interface TickFrameBuilderOptions {
|
|
185
|
-
readonly epoch: string;
|
|
186
|
-
readonly t0: number;
|
|
187
|
-
readonly settings: TickTelemetrySettings;
|
|
188
|
-
/** Byte ceiling for the built frame. Defaults to the caller's frame budget. */
|
|
189
|
-
readonly maxBytes?: number;
|
|
190
|
-
}
|
|
191
|
-
export interface TickFrameBuilder {
|
|
192
|
-
/**
|
|
193
|
-
* Take one finished run into the frame. Returns false when it did not fit, or when the dial
|
|
194
|
-
* publishes nothing — the frame stays publishable either way.
|
|
195
|
-
*/
|
|
196
|
-
add(tick: PendingTick, scrub: TickScrub): Promise<boolean>;
|
|
197
|
-
/** The frame, or `null` when nothing was admitted and there is nothing to publish. */
|
|
198
|
-
build(): TickFramePayload | null;
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Read the `tickTelemetry` plugin-config value.
|
|
202
|
-
*
|
|
203
|
-
* Never throws and never leaves the caller without settings: an unusable value falls back to the
|
|
204
|
-
* default and is reported in `invalid` so the caller can warn about it once, at startup, the way an
|
|
205
|
-
* unusable `logLevel` is. A configuration mistake must not be the reason a box publishes nothing.
|
|
206
|
-
*/
|
|
207
|
-
export declare function resolveTickTelemetry(value: unknown): {
|
|
208
|
-
settings: TickTelemetrySettings;
|
|
209
|
-
invalid?: string;
|
|
210
|
-
};
|
|
211
|
-
export declare function createTickFrameBuilder(options: TickFrameBuilderOptions): TickFrameBuilder;
|
|
212
|
-
//# sourceMappingURL=tick-frame.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tick-frame.d.ts","sourceRoot":"","sources":["../../src/telemetry/tick-frame.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AASH,8CAA8C;AAC9C,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,SAAS,GAAG,SAAS,CAAC;AAEvD,kFAAkF;AAClF,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG;IAAE,GAAG,CAAC,EAAE,UAAU,CAAC;IAAC,KAAK,CAAC,EAAE,UAAU,CAAA;CAAE,CAAC;AAExF,uGAAuG;AACvG,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;CAC5B;AAED;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,EAAE,UAAsB,CAAC;AAKzD;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,OAAQ,CAAC;AAEzC;;;;GAIG;AACH,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAC/C,eAAO,MAAM,4BAA4B,OAAQ,CAAC;AAElD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,gBAAgB,CAAC;AAChD,eAAO,MAAM,qBAAqB,mBAAmB,CAAC;AAEtD,gFAAgF;AAChF,MAAM,MAAM,iBAAiB,GACzB,WAAW,GACX,OAAO,kBAAkB,GACzB,OAAO,qBAAqB,CAAC;AAEjC,0EAA0E;AAC1E,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iGAAiG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