@try-works/dsh-minimal-router 0.2.10 → 0.2.12

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.
@@ -0,0 +1,345 @@
1
+ /**
2
+ * Run 39 (slice 3, DEC-39-01/02/03): the snapshot the host reads, built ONLY
3
+ * from the ACTIVE engine source's contract reads.
4
+ *
5
+ * Exports:
6
+ * snapshotFromSource(source, { now }) one-shot build (backend.js uses it)
7
+ * createSnapshotReader(source, { now }) the host reader factory:
8
+ * read({ signal }) => snapshot, the
9
+ * same reader shape telemetry exposes
10
+ * checkSnapshot(snapshot) shape/typing audit; [] when complete
11
+ *
12
+ * The snapshot keeps the exact key set of the telemetry snapshot
13
+ * (packages/plugin/lib/telemetry.js buildSnapshot) so existing consumers -
14
+ * routing gates, evidence pages, the ledger - do not change shape. The VALUES
15
+ * differ where the contract is honest:
16
+ *
17
+ * - Reads go through source.catalogue()/contract()/activity()/memory()
18
+ * only. An engine HTTP path is never addressed here, so an mlx-serve
19
+ * install can never call oMLX's /admin/api (which 404s there) and never
20
+ * shows a broken snapshot. Speed and observation evidence belongs to
21
+ * source.speedOf()/observationOf() and the speed store, never to this
22
+ * snapshot (observedTps stays null; index.js overrides it downstream).
23
+ * - A field the source cannot report is null, never 0 and never fabricated
24
+ * (DEC-39-03). A reported null stays null: number coercion must not turn
25
+ * "no queue" (null) into a measured 0, nor "no memory reading" into 0
26
+ * bytes. The reason a read is unavailable lives in the source's own
27
+ * result (memory().unavailable); this shape has no place for a reason, so
28
+ * the pages read the reason from the source, not from the snapshot.
29
+ * - headroomRatio is null when the memory ceiling is unknown - NOT 1.
30
+ * Telemetry's builder defaults to 1 there ("plenty of headroom"); an
31
+ * unknown must not read as plenty, so the routing gate (routing.js blocks
32
+ * on a non-finite headroomRatio) sees "unknown" and blocks instead.
33
+ * - pressureLevel is "ok"|"soft"|"hard" or null - never a guess.
34
+ * - observedTps/observedTpsSource are always null: the speed sample store
35
+ * owns speed evidence (DEC-37-09/10) and the host merges a fresh probe
36
+ * reading into these fields downstream (index.js). Filling them here
37
+ * would reintroduce the lifetime-average feed that was removed.
38
+ * - stats and device are all null: the source contract has no stats or
39
+ * device read. An mlx-serve install has neither; an oMLX install gets
40
+ * them from telemetry, not from this snapshot.
41
+ *
42
+ * A failed read never throws: its fields become null (list fields become [])
43
+ * and the returned object still carries every key.
44
+ */
45
+
46
+ /** Strict number|null. Number(null), Number(""), Number(false) and Number([])
47
+ * are all 0 - a coercion that would fabricate a measurement from "unknown".
48
+ * Finite numbers pass; non-empty numeric strings (wire data) parse; anything
49
+ * else is honestly null. */
50
+ const numberOrNull = (value) => {
51
+ if (typeof value === "number") return Number.isFinite(value) ? value : null
52
+ if (typeof value === "string" && value.trim().length > 0) {
53
+ const parsed = Number(value)
54
+ return Number.isFinite(parsed) ? parsed : null
55
+ }
56
+ return null
57
+ }
58
+
59
+ const PRESSURE_LEVELS = Object.freeze(["ok", "soft", "hard"])
60
+
61
+ const clamp01 = (value) => Math.min(1, Math.max(0, value))
62
+
63
+ const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value)
64
+
65
+ /** One contract read. A missing member or a throw is null - never a crash. */
66
+ const readOf = async (source, member) => {
67
+ if (!isRecord(source) || typeof source[member] !== "function") return null
68
+ try {
69
+ return await source[member]()
70
+ } catch {
71
+ return null
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Build the snapshot from one active engine source.
77
+ * @param {object} source an Engine source implementing contract.js SOURCE_MEMBERS
78
+ * @param {{now?: () => number | Date}} [options] clock for fetchedAt
79
+ */
80
+ export const snapshotFromSource = async (source, { now = Date.now } = {}) => {
81
+ const [catalogue, contract, activity, memory] = await Promise.all([
82
+ readOf(source, "catalogue"),
83
+ readOf(source, "contract"),
84
+ readOf(source, "activity"),
85
+ readOf(source, "memory")
86
+ ])
87
+
88
+ // Catalogue ids are the residents, de-duplicated and in catalogue order.
89
+ const entries = Array.isArray(catalogue)
90
+ ? catalogue.filter((entry) => isRecord(entry) && typeof entry.id === "string" && entry.id.length > 0)
91
+ : []
92
+ const residentModels = [...new Set(entries.map((entry) => entry.id))]
93
+
94
+ // The engine names the preferred model through its contract, else null.
95
+ const preferredModel =
96
+ isRecord(contract) && typeof contract.modelAlias === "string" && contract.modelAlias.length > 0
97
+ ? contract.modelAlias
98
+ : null
99
+
100
+ // Per-model evidence with the same keys as the telemetry snapshot.
101
+ const models = residentModels.map((id) => {
102
+ const entry = entries.find((candidate) => candidate.id === id)
103
+ return {
104
+ id,
105
+ preferred: id === preferredModel,
106
+ // No engine source reports pinning through the contract (DEC-39-03).
107
+ // Null is honest; false would claim "measured, not pinned".
108
+ pinned: null,
109
+ contextLength: isRecord(entry) ? numberOrNull(entry.contextWindow) : null,
110
+ // Neither engine's catalogue read carries a size, and speed belongs to
111
+ // the speed store (DEC-37-09/10): both stay null here.
112
+ sizeBytes: null,
113
+ tps: null
114
+ }
115
+ })
116
+
117
+ // The scheduler ceiling from the contract; a non-positive value is not a
118
+ // measurement, it is unknown.
119
+ const engineMaxRaw = isRecord(contract) ? numberOrNull(contract.concurrency) : null
120
+ const engineMax = engineMaxRaw !== null && engineMaxRaw > 0 ? engineMaxRaw : null
121
+
122
+ const activeRequests = isRecord(activity) ? numberOrNull(activity.processing) : null
123
+ const waitingRequests = isRecord(activity) ? numberOrNull(activity.waiting) : null
124
+
125
+ const memoryUsedBytes = isRecord(memory) ? numberOrNull(memory.usedBytes) : null
126
+ const memoryMaxBytes = isRecord(memory) ? numberOrNull(memory.maxBytes) : null
127
+ const pressure = isRecord(memory) && typeof memory.pressure === "string" ? memory.pressure : null
128
+ const pressureLevel = PRESSURE_LEVELS.includes(pressure) ? pressure : null
129
+
130
+ // Unknown headroom is null, never 1: "unknown" must not read as "plenty of
131
+ // headroom". Both ends known and a positive ceiling give the real ratio.
132
+ const headroomRatio =
133
+ memoryUsedBytes !== null && memoryMaxBytes !== null && memoryMaxBytes > 0
134
+ ? clamp01((memoryMaxBytes - memoryUsedBytes) / memoryMaxBytes)
135
+ : null
136
+
137
+ let fetchedAt = null
138
+ try {
139
+ const stamp = new Date(now())
140
+ fetchedAt = Number.isNaN(stamp.getTime()) ? null : stamp.toISOString()
141
+ } catch {
142
+ fetchedAt = null
143
+ }
144
+
145
+ // Telemetry records the base URL here; the source contract exposes kind and
146
+ // label, never a URL. The kind names the active engine honestly.
147
+ const sourceKind = isRecord(source) && typeof source.kind === "string" && source.kind.length > 0 ? source.kind : null
148
+
149
+ return {
150
+ fetchedAt,
151
+ source: sourceKind,
152
+ // The speed store owns speed evidence (DEC-37-09/10); the host merges a
153
+ // fresh probe reading downstream (index.js). Never filled from a source
154
+ // read - source.speedOf()/observationOf() are the only speed reads.
155
+ observedTps: null,
156
+ observedTpsSource: null,
157
+ headroomRatio,
158
+ engineMax,
159
+ pressureLevel,
160
+ residentModels,
161
+ models,
162
+ preferredModel,
163
+ // The source contract has no stats or device read; an mlx-serve install
164
+ // has neither. Null everywhere, never zero.
165
+ stats: {
166
+ avgGenerationTps: null,
167
+ avgPrefillTps: null,
168
+ totalRequests: null,
169
+ totalCachedTokens: null,
170
+ cacheEfficiency: null,
171
+ uptimeSeconds: null
172
+ },
173
+ activity: {
174
+ activeRequests,
175
+ waitingRequests,
176
+ memoryUsedBytes,
177
+ memoryMaxBytes,
178
+ // No source read carries the soft limit; the shape keeps the key, the
179
+ // value stays null (never invented).
180
+ memorySoftBytes: null
181
+ },
182
+ device: {
183
+ chipName: null,
184
+ memoryGb: null,
185
+ gpuCores: null
186
+ }
187
+ }
188
+ }
189
+
190
+ /**
191
+ * The host reader factory: read({ signal }) => snapshot, the same reader shape
192
+ * createOmlxTelemetry exposes, so backend.js can swap readers without touching
193
+ * call sites. Contract reads take no arguments today, so the signal is accepted
194
+ * for reader-shape parity and not threaded through.
195
+ */
196
+ export const createSnapshotReader = (source, { now = Date.now } = {}) =>
197
+ async ({ signal } = {}) => {
198
+ void signal
199
+ return snapshotFromSource(source, { now })
200
+ }
201
+
202
+ // ---------------------------------------------------------------------------
203
+ // checkSnapshot: a shape/typing audit for the snapshot. Returns the missing or
204
+ // wrongly typed keys as readable strings; an empty array means the snapshot is
205
+ // complete. Tests use it on both engine kinds; consumers can log a non-empty
206
+ // result instead of crashing on a half-built snapshot.
207
+ // ---------------------------------------------------------------------------
208
+
209
+ const TOP_KEYS = Object.freeze([
210
+ "fetchedAt",
211
+ "source",
212
+ "observedTps",
213
+ "observedTpsSource",
214
+ "headroomRatio",
215
+ "engineMax",
216
+ "pressureLevel",
217
+ "residentModels",
218
+ "models",
219
+ "preferredModel",
220
+ "stats",
221
+ "activity",
222
+ "device"
223
+ ])
224
+ const STATS_KEYS = Object.freeze([
225
+ "avgGenerationTps",
226
+ "avgPrefillTps",
227
+ "totalRequests",
228
+ "totalCachedTokens",
229
+ "cacheEfficiency",
230
+ "uptimeSeconds"
231
+ ])
232
+ const ACTIVITY_KEYS = Object.freeze([
233
+ "activeRequests",
234
+ "waitingRequests",
235
+ "memoryUsedBytes",
236
+ "memoryMaxBytes",
237
+ "memorySoftBytes"
238
+ ])
239
+ const DEVICE_KEYS = Object.freeze(["chipName", "memoryGb", "gpuCores"])
240
+ const MODEL_KEYS = Object.freeze(["id", "preferred", "pinned", "contextLength", "sizeBytes", "tps"])
241
+
242
+ const typeName = (value) => {
243
+ if (value === null) return "null"
244
+ if (value === undefined) return "undefined"
245
+ if (Array.isArray(value)) return "array"
246
+ return typeof value
247
+ }
248
+
249
+ const isNumericOrNull = (value) => value === null || (typeof value === "number" && Number.isFinite(value))
250
+ const isStringOrNull = (value) => value === null || typeof value === "string"
251
+
252
+ /** Record key-set audit: every expected key present, nothing unexpected. */
253
+ const checkKeys = (problems, path, block, keys) => {
254
+ for (const key of keys) if (!Object.hasOwn(block, key)) problems.push(path + "." + key + ": missing key")
255
+ for (const key of Object.keys(block)) if (!keys.includes(key)) problems.push(path + "." + key + ": unexpected key")
256
+ }
257
+
258
+ /** All-or-nothing numeric block with the exact key set. */
259
+ const checkNumericBlock = (problems, path, block, keys) => {
260
+ if (!isRecord(block)) {
261
+ problems.push(path + ": expected an object, got " + typeName(block))
262
+ return
263
+ }
264
+ checkKeys(problems, path, block, keys)
265
+ for (const key of keys) {
266
+ if (Object.hasOwn(block, key) && !isNumericOrNull(block[key])) {
267
+ problems.push(path + "." + key + ": expected number|null, got " + typeName(block[key]))
268
+ }
269
+ }
270
+ }
271
+
272
+ /**
273
+ * Audit one snapshot. Returns the list of shape problems ("missing key",
274
+ * "unexpected key", wrong type); [] when the snapshot is complete and typed.
275
+ */
276
+ export const checkSnapshot = (snapshot) => {
277
+ const problems = []
278
+ if (!isRecord(snapshot)) return ["snapshot: expected an object, got " + typeName(snapshot)]
279
+ checkKeys(problems, "snapshot", snapshot, TOP_KEYS)
280
+
281
+ if (!isStringOrNull(snapshot.fetchedAt)) problems.push("fetchedAt: expected string|null, got " + typeName(snapshot.fetchedAt))
282
+ if (!isStringOrNull(snapshot.source)) problems.push("source: expected string|null, got " + typeName(snapshot.source))
283
+ // observedTps/observedTpsSource are owned by the speed store, never the
284
+ // snapshot (DEC-37-09/10): a value here means the shape drifted.
285
+ if (snapshot.observedTps !== null) problems.push("observedTps: expected null (the speed store owns it), got " + typeName(snapshot.observedTps))
286
+ if (snapshot.observedTpsSource !== null) problems.push("observedTpsSource: expected null, got " + typeName(snapshot.observedTpsSource))
287
+ if (!isNumericOrNull(snapshot.headroomRatio)) problems.push("headroomRatio: expected number|null, got " + typeName(snapshot.headroomRatio))
288
+ if (!isNumericOrNull(snapshot.engineMax)) problems.push("engineMax: expected number|null, got " + typeName(snapshot.engineMax))
289
+ if (snapshot.pressureLevel !== null && !PRESSURE_LEVELS.includes(snapshot.pressureLevel)) {
290
+ problems.push("pressureLevel: expected 'ok'|'soft'|'hard'|null, got " + typeName(snapshot.pressureLevel))
291
+ }
292
+ if (!isStringOrNull(snapshot.preferredModel)) problems.push("preferredModel: expected string|null, got " + typeName(snapshot.preferredModel))
293
+
294
+ if (!Array.isArray(snapshot.residentModels)) problems.push("residentModels: expected array, got " + typeName(snapshot.residentModels))
295
+ else {
296
+ snapshot.residentModels.forEach((id, index) => {
297
+ if (typeof id !== "string" || id.length === 0) problems.push("residentModels[" + index + "]: expected a non-empty string, got " + typeName(id))
298
+ })
299
+ }
300
+
301
+ if (!Array.isArray(snapshot.models)) problems.push("models: expected array, got " + typeName(snapshot.models))
302
+ else {
303
+ snapshot.models.forEach((model, index) => {
304
+ const path = "models[" + index + "]"
305
+ if (!isRecord(model)) {
306
+ problems.push(path + ": expected an object, got " + typeName(model))
307
+ return
308
+ }
309
+ checkKeys(problems, path, model, MODEL_KEYS)
310
+ if (Object.hasOwn(model, "id") && (typeof model.id !== "string" || model.id.length === 0)) {
311
+ problems.push(path + ".id: expected a non-empty string, got " + typeName(model.id))
312
+ }
313
+ if (Object.hasOwn(model, "preferred") && typeof model.preferred !== "boolean") {
314
+ problems.push(path + ".preferred: expected boolean, got " + typeName(model.preferred))
315
+ }
316
+ if (Object.hasOwn(model, "pinned") && model.pinned !== null && typeof model.pinned !== "boolean") {
317
+ problems.push(path + ".pinned: expected boolean|null, got " + typeName(model.pinned))
318
+ }
319
+ for (const key of ["contextLength", "sizeBytes", "tps"]) {
320
+ if (Object.hasOwn(model, key) && !isNumericOrNull(model[key])) {
321
+ problems.push(path + "." + key + ": expected number|null, got " + typeName(model[key]))
322
+ }
323
+ }
324
+ })
325
+ }
326
+
327
+ checkNumericBlock(problems, "stats", snapshot.stats, STATS_KEYS)
328
+ checkNumericBlock(problems, "activity", snapshot.activity, ACTIVITY_KEYS)
329
+
330
+ const device = snapshot.device
331
+ if (!isRecord(device)) problems.push("device: expected an object, got " + typeName(device))
332
+ else {
333
+ checkKeys(problems, "device", device, DEVICE_KEYS)
334
+ if (Object.hasOwn(device, "chipName") && !isStringOrNull(device.chipName)) {
335
+ problems.push("device.chipName: expected string|null, got " + typeName(device.chipName))
336
+ }
337
+ for (const key of ["memoryGb", "gpuCores"]) {
338
+ if (Object.hasOwn(device, key) && !isNumericOrNull(device[key])) {
339
+ problems.push("device." + key + ": expected number|null, got " + typeName(device[key]))
340
+ }
341
+ }
342
+ }
343
+
344
+ return problems
345
+ }
package/lib/evidence.js CHANGED
@@ -13,6 +13,7 @@
13
13
  // available; without it the routes are unauthenticated (ROUTE_AUTH_LIMITATION).
14
14
 
15
15
  import { initialPolicy } from "./host.js"
16
+ import { DEFAULT_RANGE, TELEMETRY_RANGES, buildTelemetrySeries } from "./telemetry-series.js"
16
17
  import { GATES, isPolicy } from "./routing.js"
17
18
 
18
19
  // Run 36 (R-36-01/15, DEC-36-02/15): the scope gate is gone; the order is the
@@ -58,6 +59,7 @@ export const EVIDENCE_ROUTES = Object.freeze({
58
59
  activity: "/api/router/activity",
59
60
  engine: "/api/router/engine",
60
61
  overview: "/api/router/overview",
62
+ telemetry: "/api/router/telemetry",
61
63
  settings: "/api/router/settings"
62
64
  })
63
65
 
@@ -116,6 +118,9 @@ export function createEvidenceAdapter(options = {}) {
116
118
  throw new TypeError("createEvidenceAdapter needs a backend with a string kind")
117
119
  }
118
120
  const cache = options.cache ?? null
121
+ // Run 40: the host injects a reader for the two files the series come from, so
122
+ // the adapter stays transport-free and a test can pass fixtures.
123
+ const telemetrySources = typeof options.getTelemetrySources === "function" ? options.getTelemetrySources : null
119
124
  const now = options.now ?? (() => new Date())
120
125
  const maxAgeMs = finiteNumber(options.cacheMaxAgeMs, defaultCacheMaxAgeMs)
121
126
  const baseUrl = typeof backend.baseUrl === "string" ? backend.baseUrl : null
@@ -302,6 +307,57 @@ export function createEvidenceAdapter(options = {}) {
302
307
  }
303
308
  }
304
309
 
310
+ // Run 40 (R-40-01): the Telemetry page payload. Every series is computed from
311
+ // the ledger and the request observations over the requested window; a source
312
+ // the host could not read is reported with its reason instead of as zeros.
313
+ const telemetrySeries = (range = DEFAULT_RANGE) => {
314
+ const requested = TELEMETRY_RANGES.includes(range) ? range : DEFAULT_RANGE
315
+ if (telemetrySources === null) {
316
+ return buildTelemetrySeries({
317
+ ledger: [],
318
+ observations: [],
319
+ range: requested,
320
+ now: at().getTime(),
321
+ sources: {
322
+ ledger: { available: false, reason: "the host did not provide a telemetry reader" },
323
+ observations: { available: false, reason: "the host did not provide a telemetry reader" }
324
+ }
325
+ })
326
+ }
327
+ let read
328
+ try {
329
+ read = telemetrySources()
330
+ } catch (error) {
331
+ read = {
332
+ ledger: [],
333
+ observations: [],
334
+ sources: {
335
+ ledger: { available: false, reason: "could not read the ledger: " + (error?.message ?? "unknown error") },
336
+ observations: { available: false, reason: "could not read the observations: " + (error?.message ?? "unknown error") }
337
+ }
338
+ }
339
+ }
340
+ return buildTelemetrySeries({
341
+ ledger: read?.ledger ?? [],
342
+ observations: read?.observations ?? [],
343
+ sources: read?.sources ?? {},
344
+ range: requested,
345
+ now: at().getTime()
346
+ })
347
+ }
348
+
349
+ // The page payload: kind + backend + evidence + the series (the same envelope
350
+ // every other tab answers with, so the client decodes it through one union).
351
+ const telemetry = (range = DEFAULT_RANGE) => {
352
+ const series = telemetrySeries(range)
353
+ return {
354
+ kind: "telemetry",
355
+ backend: { kind: backend.kind, label: backend.kind === "unknown" ? "Local engine adapter" : backend.kind },
356
+ evidence: evidence(),
357
+ view: series
358
+ }
359
+ }
360
+
305
361
  const evidence = () => {
306
362
  const fetchedAt = at().toISOString()
307
363
  const telemetry = readTelemetry()
@@ -557,7 +613,11 @@ export function createEvidenceAdapter(options = {}) {
557
613
  model.telemetry.snapshot === null
558
614
  ? null
559
615
  : {
560
- model: model.telemetry.snapshot.preferredModel,
616
+ // The ceiling belongs to the model the router would use, not to the
617
+ // engine's default. A pin wins; the preferred model is the fallback.
618
+ model:
619
+ (model.telemetry.snapshot.models ?? []).find((entry) => entry.pinned === true)?.id ??
620
+ model.telemetry.snapshot.preferredModel,
561
621
  observedTps: model.telemetry.snapshot.observedTps,
562
622
  active: model.telemetry.snapshot.activity.activeRequests,
563
623
  waiting: model.telemetry.snapshot.activity.waitingRequests,
@@ -565,6 +625,8 @@ export function createEvidenceAdapter(options = {}) {
565
625
  contextBucket: (CONTEXT_BUCKETS.find((bucket) => medianContextTokens(rows) <= bucket.max) ??
566
626
  CONTEXT_BUCKETS[CONTEXT_BUCKETS.length - 1]).label
567
627
  },
628
+ // R-40-05: the ceiling card carries the same strip as the Engine page.
629
+ speedStrip: speedStrip(),
568
630
  contextBuckets: CONTEXT_BUCKETS.map((bucket) => ({
569
631
  label: bucket.label,
570
632
  admitted: rows.filter((row) => row.contextTokens > bucket.min && row.contextTokens <= bucket.max).length
@@ -702,6 +764,25 @@ export function createEvidenceAdapter(options = {}) {
702
764
  return { status: "unknown", httpStatus: null, latencyMs: null, checkedAt: null, message: null }
703
765
  }
704
766
 
767
+ // Run 40 (R-40-05): the compact speed strip, computed by the SAME series function the
768
+ // Telemetry page uses, so the Engine page and the ceiling card cannot disagree with it.
769
+ const speedStrip = () => {
770
+ const series = telemetrySeries("7d")
771
+ const speed = series.speed
772
+ if (speed.available !== true) {
773
+ return { available: false, reason: speed.reason ?? "no speed series in this window", range: "7d", p50: null, floor: speed.floor ?? 30, belowFloor: null, total: speed.n ?? 0 }
774
+ }
775
+ return {
776
+ available: true,
777
+ reason: null,
778
+ range: "7d",
779
+ p50: speed.median ?? null,
780
+ floor: speed.floor ?? 30,
781
+ belowFloor: speed.belowFloor ?? 0,
782
+ total: speed.n
783
+ }
784
+ }
785
+
705
786
  const engine = () => {
706
787
  const model = evidence()
707
788
  const snapshot = model.telemetry.snapshot
@@ -720,6 +801,8 @@ export function createEvidenceAdapter(options = {}) {
720
801
  adapter: engineAdapter(),
721
802
  connection: engineConnection(),
722
803
  health: engineHealth(model),
804
+ // R-40-05: the compact speed strip (the same series the Telemetry page draws).
805
+ speedStrip: speedStrip(),
723
806
  models,
724
807
  capabilities:
725
808
  engineCapabilities !== null && isRecord(engineCapabilities.report) ? engineCapabilities.report : null,
@@ -784,6 +867,8 @@ export function createEvidenceAdapter(options = {}) {
784
867
  return {
785
868
  backend: backendView(),
786
869
  evidence,
870
+ // Run 40: the Telemetry page projection (the route is gated on this method).
871
+ telemetry,
787
872
  health,
788
873
  models,
789
874
  routing,
@@ -1101,6 +1186,16 @@ export function createRouterRoutes(adapter, options = {}) {
1101
1186
  { kind: "exact", path: EVIDENCE_ROUTES.routing, handler: routingHandler },
1102
1187
  { kind: "exact", path: EVIDENCE_ROUTES.activity, handler: createHandler(() => adapter.activity(), auth) },
1103
1188
  { kind: "exact", path: EVIDENCE_ROUTES.engine, handler: engineHandler },
1189
+ ...(typeof adapter.telemetry === "function"
1190
+ ? [{
1191
+ kind: "exact",
1192
+ path: EVIDENCE_ROUTES.telemetry,
1193
+ handler: createHandler((request) => {
1194
+ const url = new URL(request.url ?? "/", "http://localhost")
1195
+ return adapter.telemetry(url.searchParams.get("range") ?? undefined)
1196
+ }, auth)
1197
+ }]
1198
+ : []),
1104
1199
  { kind: "exact", path: EVIDENCE_ROUTES.overview, handler: overviewHandler },
1105
1200
  { kind: "exact", path: EVIDENCE_ROUTES.settings, handler: settingsHandler }
1106
1201
  ]