@kymoscope/sdk 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/assets/{importer.worker-CLBGjz4d.js → importer.worker-C63-1oBd.js} +1 -1
  2. package/dist/assets/liveIngestWorker-DQYK0Xxv.js +1 -0
  3. package/dist/assets/offscreenLineWorker-C-_uNa_H.js +80 -0
  4. package/dist/importers-4CjV0qH8.js +5 -0
  5. package/dist/{keys-DmtCD10T.js → keys-ved5HXBj.js} +1 -1
  6. package/dist/kymoscope-embed.js +67 -67
  7. package/dist/kymoscope-sdk.js +87 -87
  8. package/dist/types/analysis/ai.d.ts +50 -0
  9. package/dist/types/analysis/aiCheck.d.ts +54 -0
  10. package/dist/types/analysis/alertsBefore.d.ts +7 -0
  11. package/dist/types/analysis/better.d.ts +6 -0
  12. package/dist/types/analysis/capability.d.ts +10 -0
  13. package/dist/types/analysis/changes.d.ts +10 -0
  14. package/dist/types/analysis/containment.d.ts +10 -0
  15. package/dist/types/analysis/context.d.ts +131 -0
  16. package/dist/types/analysis/control.d.ts +13 -0
  17. package/dist/types/analysis/energy.d.ts +4 -0
  18. package/dist/types/analysis/gap.d.ts +8 -0
  19. package/dist/types/analysis/golden.d.ts +20 -0
  20. package/dist/types/analysis/health.d.ts +73 -0
  21. package/dist/types/analysis/index.d.ts +12 -0
  22. package/dist/types/analysis/infer.d.ts +68 -0
  23. package/dist/types/analysis/lines.d.ts +6 -0
  24. package/dist/types/analysis/losses.d.ts +41 -0
  25. package/dist/types/analysis/maintenance.d.ts +8 -0
  26. package/dist/types/analysis/oee.d.ts +30 -0
  27. package/dist/types/analysis/parts.d.ts +13 -0
  28. package/dist/types/analysis/presets.d.ts +35 -0
  29. package/dist/types/analysis/reliability.d.ts +103 -0
  30. package/dist/types/analysis/report.d.ts +15 -0
  31. package/dist/types/analysis/shifts.d.ts +7 -0
  32. package/dist/types/analysis/sinceLast.d.ts +8 -0
  33. package/dist/types/analysis/stats.d.ts +110 -0
  34. package/dist/types/analysis/stops.d.ts +34 -0
  35. package/dist/types/analysis/strip.d.ts +14 -0
  36. package/dist/types/analysis/text.d.ts +56 -0
  37. package/dist/types/analysis/types.d.ts +407 -0
  38. package/dist/types/components/liveWindow.d.ts +6 -2
  39. package/dist/types/engine/createEngine.d.ts +1 -0
  40. package/dist/types/engine/liveController.d.ts +7 -0
  41. package/dist/types/engine/types.d.ts +2 -0
  42. package/dist/types/index.d.ts +6 -1
  43. package/dist/types/lib/live/chainWire.d.ts +67 -0
  44. package/dist/types/lib/live/liveIngest.d.ts +55 -0
  45. package/dist/types/lib/live/liveIngestClient.d.ts +9 -0
  46. package/dist/types/lib/live/liveIngestWorker.d.ts +1 -0
  47. package/dist/types/lib/live/publisher.d.ts +21 -1
  48. package/dist/types/lib/live/stream.d.ts +14 -0
  49. package/dist/types/lib/live/types.d.ts +17 -0
  50. package/dist/types/lib/live/wire.d.ts +2 -0
  51. package/dist/types/lib/render/frames.d.ts +10 -0
  52. package/dist/types/lib/render/glPoints.d.ts +18 -0
  53. package/dist/types/lib/render/offscreenLineRenderer.d.ts +15 -1
  54. package/dist/types/lib/render/sharedGl.d.ts +12 -3
  55. package/package.json +1 -1
  56. package/dist/assets/offscreenLineWorker-BQwts3O3.js +0 -80
  57. package/dist/importers-2iwVi4cq.js +0 -5
@@ -0,0 +1,407 @@
1
+ import type { RecordingHealth } from './health';
2
+ import type { ProcessContext } from './context';
3
+ import type { PresetId } from './presets';
4
+ /** The production report's model (spec 2026-11-10-production-reports-design): what the engine reads (batches, goldens,
5
+ * recordings' health) and what it returns (a document of sections with verdicts, findings, charts and notes). Plain
6
+ * JSON: stored as report.json, rendered by the app and the PDF. */
7
+ export type SectionId = '00' | '01' | '02' | '03' | '04' | '05' | '06' | '07' | '08' | '09' | '10' | '11' | '12' | '13' | '14';
8
+ export declare const REPORT_ROLES: readonly ["management", "quality", "maintenance", "production"];
9
+ export type ReportRole = (typeof REPORT_ROLES)[number];
10
+ export type Evidence = 'measured' | 'trial' | 'statistical' | 'correlation' | 'engineer';
11
+ export declare const EVIDENCE_TEXT: Record<Evidence, {
12
+ label: string;
13
+ meaning: string;
14
+ }>;
15
+ export declare const SECTION_TITLES: Record<SectionId, string>;
16
+ /** Who each section is for (the mockup's section tags); the Full report shows every section. */
17
+ export declare const SECTION_ROLES: Record<SectionId, ReportRole[]>;
18
+ /** A batch (a closed cycle of the applied rule). */
19
+ export interface CycleIn {
20
+ id: string;
21
+ label: string;
22
+ streamId: string;
23
+ recordingId: string;
24
+ tstart: number;
25
+ tend: number | null;
26
+ /** The rule's value to compare (null: missing). */
27
+ value: number | null;
28
+ kpis: Record<string, number | null>;
29
+ /** Deviation from its stream's golden: mean |Δ| in band units per channel and piece ('Cycle' = the whole cycle). */
30
+ z: Record<string, Record<string, number>> | null;
31
+ /** Signed mean Δ per channel over the whole cycle, in the channel's units. */
32
+ d: Record<string, number> | null;
33
+ flag: 'good' | 'bad' | 'excluded' | null;
34
+ /** Per channel, its lowest and highest value in the batch (measured with the deviation): what a level alert would see. */
35
+ range?: Record<string, [number, number]> | null;
36
+ /** The batch's energy in kWh (09), measured with the Process context's energy channel. */
37
+ kwh?: number | null;
38
+ }
39
+ /** A stream's golden: its value to compare, the spread of its own batches, and its band's half-width per channel. */
40
+ /** `proposed`: no golden set, one batch stands in (not saved); `auto`: none was set, so this report set one. */
41
+ export interface GoldenIn {
42
+ streamId: string;
43
+ label: string;
44
+ proposed: boolean;
45
+ auto?: boolean;
46
+ value: number;
47
+ spread: number;
48
+ edges: Record<string, number>;
49
+ }
50
+ /** `unread`: its samples were not read (a stream password, a folder on a computer); only its stored cycles and measures count.
51
+ * `continues`: it carries on the stream's previous recording (one run split into files), so the time between them is no stop. */
52
+ export interface RecordingIn {
53
+ id: string;
54
+ streamId: string;
55
+ name: string;
56
+ t0: number;
57
+ t1: number;
58
+ health: RecordingHealth | null;
59
+ failed: string | null;
60
+ unread?: true;
61
+ continues?: boolean;
62
+ }
63
+ /** An alert raised by one of the project's alert rules, in a stream's recording (07). */
64
+ export interface AlertIn {
65
+ rule: string;
66
+ streamId: string;
67
+ t: number;
68
+ }
69
+ export interface ReportInput {
70
+ project: string;
71
+ period: {
72
+ from: number;
73
+ to: number;
74
+ };
75
+ tz: string;
76
+ rule: {
77
+ name: string;
78
+ version: number;
79
+ };
80
+ value: {
81
+ key: string;
82
+ label: string;
83
+ better: 'min' | 'max';
84
+ };
85
+ streams: Array<{
86
+ id: string;
87
+ name: string;
88
+ }>;
89
+ units: Record<string, string>;
90
+ recordings: RecordingIn[];
91
+ cycles: CycleIn[];
92
+ goldens: GoldenIn[];
93
+ /** The time other recordings of the report's streams cover (files left unticked): not analysed, only never a stop. */
94
+ covered?: Array<{
95
+ streamId: string;
96
+ t0: number;
97
+ t1: number;
98
+ }>;
99
+ /** The project's Process context and its version (delivery B); null or absent: none set. */
100
+ context?: ProcessContext | null;
101
+ contextVersion?: number | null;
102
+ /** The project's enabled alert rules and the alerts they raised in the period's recordings (07). */
103
+ alertRules?: Array<{
104
+ id: string;
105
+ name: string;
106
+ }>;
107
+ alerts?: AlertIn[];
108
+ /** A stream's golden replaced by another (a new active reference) at `t`; `label` the new one's (08). */
109
+ goldenChanges?: Array<{
110
+ streamId: string;
111
+ t: number;
112
+ label: string;
113
+ }>;
114
+ /** The period before this one, of the same length: its stored batches and recordings (no samples read) (01). */
115
+ previous?: {
116
+ period: {
117
+ from: number;
118
+ to: number;
119
+ };
120
+ recordings: RecordingIn[];
121
+ cycles: CycleIn[];
122
+ } | null;
123
+ madeBy: string;
124
+ madeAt: number;
125
+ }
126
+ export type ReportChart = {
127
+ kind: 'tiles';
128
+ tiles: Array<{
129
+ label: string;
130
+ value: string;
131
+ note?: string;
132
+ }>;
133
+ } | {
134
+ kind: 'bars';
135
+ title: string;
136
+ max: number;
137
+ rows: Array<{
138
+ label: string;
139
+ value: number;
140
+ text: string;
141
+ muted?: boolean;
142
+ tip: string;
143
+ }>;
144
+ } | {
145
+ kind: 'heat';
146
+ title: string;
147
+ rows: string[];
148
+ cols: string[];
149
+ cells: Array<Array<number | null>>;
150
+ legend: string;
151
+ } | {
152
+ kind: 'diverging';
153
+ title: string;
154
+ rows: Array<{
155
+ label: string;
156
+ pct: number;
157
+ text: string;
158
+ }>;
159
+ } | {
160
+ kind: 'trend';
161
+ title: string;
162
+ unit: string;
163
+ points: Array<{
164
+ t: number;
165
+ v: number;
166
+ }>;
167
+ line: {
168
+ t0: number;
169
+ v0: number;
170
+ t1: number;
171
+ v1: number;
172
+ } | null;
173
+ limit: number | null;
174
+ crossing: {
175
+ t: number;
176
+ lo: number;
177
+ hi: number | null;
178
+ } | null;
179
+ }
180
+ /** 04.3 · an individuals control chart: batches in time order against the centre line and the 3σ limits of their own
181
+ * variation; `out` marks a batch outside them. `n` batches in all, `outside` of them outside; `points` are those drawn
182
+ * (thinned evenly in time when there are many, plus some of the batches outside that the thinning skipped). */
183
+ | {
184
+ kind: 'control';
185
+ title: string;
186
+ unit: string;
187
+ mean: number;
188
+ ucl: number;
189
+ lcl: number;
190
+ n: number;
191
+ outside: number;
192
+ points: Array<{
193
+ t: number;
194
+ v: number;
195
+ out?: true;
196
+ }>;
197
+ }
198
+ /** A channel along the batch (02.1's picture): the golden's band, and the typical curve of the batches off the golden
199
+ * against those at golden level, over time since the batch's start; `span`: the phase the difference is in. */
200
+ | {
201
+ kind: 'overlay';
202
+ title: string;
203
+ unit: string;
204
+ band: {
205
+ x: number[];
206
+ lo: number[];
207
+ hi: number[];
208
+ } | null;
209
+ series: Array<{
210
+ label: string;
211
+ tone: 'off' | 'ok';
212
+ x: number[];
213
+ y: number[];
214
+ }>;
215
+ span: {
216
+ from: number;
217
+ to: number;
218
+ label: string;
219
+ } | null;
220
+ }
221
+ /** The period day by day (00.2): each day's share of batches off the golden (null: none), time stopped, a stuck sensor. */
222
+ | {
223
+ kind: 'strip';
224
+ title: string;
225
+ legend: string;
226
+ days: Array<{
227
+ day: string;
228
+ label: string;
229
+ n: number;
230
+ off: number | null;
231
+ stopS: number;
232
+ sensor: boolean;
233
+ text: string;
234
+ }>;
235
+ }
236
+ /** 00.1 · Where the money goes: every loss of the period in one ranked list, in money (`unit` 'money', with the cost
237
+ * of an hour of line time) or in hours. `value` is in the chart's unit (null: no bar, e.g. energy without that cost);
238
+ * `atRisk` rows (batches to review) are not a loss yet and stay out of `total`. `hint`: what would show (more) money. */
239
+ | {
240
+ kind: 'losses';
241
+ title: string;
242
+ unit: 'money' | 'hours';
243
+ total: string;
244
+ totalNote: string;
245
+ rows: Array<{
246
+ label: string;
247
+ value: number | null;
248
+ amount: string;
249
+ detail: string;
250
+ owner: string;
251
+ ref: SectionId;
252
+ atRisk?: true;
253
+ /** Rests on an assumption (off-golden batches counted as scrap for want of limits): marked, outside `total`. */
254
+ assumed?: true;
255
+ }>;
256
+ hint?: string;
257
+ } | {
258
+ kind: 'table';
259
+ title: string;
260
+ columns: string[];
261
+ /** `finding`: the id of the section's finding this row states; the views show its evidence in the row, not the finding again. */
262
+ rows: Array<{
263
+ cells: string[];
264
+ status?: 'ok' | 'watch' | 'crit';
265
+ finding?: string;
266
+ }>;
267
+ /** Rows shown in full; the rest fold under `more` ("2 more actions"). Absent: all rows. */
268
+ shown?: number;
269
+ more?: string;
270
+ /** The section the whole list is in ("See 12"). */
271
+ ref?: SectionId;
272
+ };
273
+ export interface Finding {
274
+ id: string;
275
+ section: SectionId;
276
+ text: string;
277
+ evidence: Evidence;
278
+ /** The test's p-value; null when the evidence carries none. Shown through evidenceLabel, never as 1 − p. */
279
+ p: number | null;
280
+ /** Sections the evidence is in. */
281
+ refs: SectionId[];
282
+ numbers: Record<string, number>;
283
+ /** Section 03's proposed golden: the batch the viewer can make its stream's golden. */
284
+ golden?: {
285
+ streamId: string;
286
+ cycleId: string;
287
+ };
288
+ /** A batch worth a review by exception (02: the off-golden batch furthest from the golden): the viewer opens it. */
289
+ batch?: {
290
+ streamId: string;
291
+ cycleId: string;
292
+ };
293
+ /** 02's main finding as an alert rule one press away (set by the app, from each batch's lowest and highest value):
294
+ * warn when the stream's channel goes `dir` `value`; `off` and `rest`: the shares of the period's off-golden batches
295
+ * and of the others it would have warned on. Offered only when it catches most off-golden batches. */
296
+ alert?: {
297
+ channel: string;
298
+ streamId: string;
299
+ stream: string;
300
+ unit: string;
301
+ dir: 'above' | 'below';
302
+ value: number;
303
+ off: number;
304
+ rest: number;
305
+ };
306
+ /** 02.1's main difference: the channel and piece (a phase, or 'Cycle') a picture of the batches can show. */
307
+ focus?: {
308
+ ch: string;
309
+ piece: string;
310
+ };
311
+ }
312
+ export interface ActionSeed {
313
+ text: string;
314
+ owner: ReportRole;
315
+ urgent: boolean;
316
+ rank: number;
317
+ refs: string[];
318
+ }
319
+ export interface ReportAction {
320
+ id: string;
321
+ text: string;
322
+ owner: ReportRole;
323
+ urgent: boolean;
324
+ refs: string[];
325
+ }
326
+ export interface ReportSection {
327
+ id: SectionId;
328
+ title: string;
329
+ verdict: string;
330
+ roles: ReportRole[];
331
+ findings: Finding[];
332
+ charts: ReportChart[];
333
+ notes: string[];
334
+ /** The standard a section's numbers follow, said under its title ("OEE as ISO 22400-2. Supports your review; does not
335
+ * certify."): what the section supports, never a claim of compliance. */
336
+ subtitle?: string;
337
+ /** The summary's grammar (verdict, one main chart, the ranked findings): the first chart leads, the others fold under
338
+ * "More detail" after the findings. Absent (reports made before, sections not yet in the family): every chart shows. */
339
+ fold?: true;
340
+ /** Findings shown in full (the first, most important); the rest fold under "N more findings". Absent: all. */
341
+ shown?: number;
342
+ /** Sentences Kymoscope's AI wrote under the verdict, each with the finding ids it rests on (delivery B). */
343
+ ai?: Array<{
344
+ text: string;
345
+ cites: string[];
346
+ }>;
347
+ /** An industry preset starts this section as its verdict alone, the rest one press away (the PDF prints it whole). */
348
+ collapsed?: true;
349
+ /** What this section took from the data because nobody set it in Process context yet (shifts, planned stops…). */
350
+ assumed?: string[];
351
+ }
352
+ export interface SectionOut {
353
+ section: ReportSection;
354
+ actions: ActionSeed[];
355
+ next: string[];
356
+ numbers: Record<string, number>;
357
+ }
358
+ /** A section that can't be made from what the period holds, and what to do about it (named in section 14). */
359
+ export interface Missing {
360
+ section: SectionId;
361
+ needs: string;
362
+ }
363
+ export interface ReportCover {
364
+ title: string;
365
+ project: string;
366
+ period: {
367
+ from: number;
368
+ to: number;
369
+ };
370
+ cycle: string;
371
+ value: string;
372
+ golden: string;
373
+ data: string;
374
+ madeBy: string;
375
+ madeAt: number;
376
+ tz: string;
377
+ /** "Process context v3" (absent in reports made before delivery B); the AI model that wrote the text, if one did. */
378
+ context?: string;
379
+ ai?: string;
380
+ }
381
+ export interface ReportDoc {
382
+ v: 1;
383
+ cover: ReportCover;
384
+ sections: ReportSection[];
385
+ actions: ReportAction[];
386
+ /** The industry preset the document was worded and ordered with (absent: generic, the report as it always was). */
387
+ preset?: PresetId;
388
+ missing: Array<{
389
+ section: SectionId;
390
+ title: string;
391
+ needs: string;
392
+ }>;
393
+ }
394
+ export type Level = 'off' | 'golden' | 'better';
395
+ /** A batch judged against its stream's golden; `gap` > 0 is worse. */
396
+ export interface Classified {
397
+ c: CycleIn;
398
+ g: GoldenIn;
399
+ gap: number;
400
+ level: Level;
401
+ }
402
+ /** The line under a section's title naming the standard its numbers follow: what the section supports, never a claim
403
+ * of compliance or of a certificate. */
404
+ export declare const standardNote: (standard: string) => string;
405
+ /** Findings a section shows in full; they come ranked by impact, the rest are counted (2026-11-10: concise). */
406
+ export declare const SHOWN_FINDINGS = 3;
407
+ export declare const makeSection: (id: SectionId, verdict: string, findings: Finding[], charts: ReportChart[], notes?: string[]) => ReportSection;
@@ -25,8 +25,12 @@ export declare function liveWindowTarget(oldest: number, newest: number, windowS
25
25
  * became a comb that flickered as it slid sub-pixel, and looked low-resolution.
26
26
  * Sizing to the actual plot pixels makes buckets ≤ one sample at typical windows
27
27
  * (a plain continuous polyline through the real samples) while denser views
28
- * (All/2 m) pack the bars sub-pixel into an honest solid envelope. The floor
29
- * covers the not-yet-measured first frame; the cap bounds the per-frame pull and
28
+ * (All/2 m) pack the bars sub-pixel into an honest solid envelope. A plot not
29
+ * measured yet (its first frame) asks for 2000; a small one for what its pixels
30
+ * show, not less than 400: a third of a screen's width asking for 2000 pulled,
31
+ * copied and sent 2-3 times the points it could draw, every frame, and the
32
+ * renderer then thinned them to its pixels again (with 8 such charts on a
33
+ * worksheet, most of the main thread). The cap bounds the per-frame pull and
30
34
  * point-array cost on very large displays.
31
35
  */
32
36
  export declare function livePullMaxPoints(plotWCss: number, dpr: number): number;
@@ -385,6 +385,7 @@ export declare function createEngine(options?: EngineOptions): {
385
385
  rows: number;
386
386
  name: string;
387
387
  startedAt: number;
388
+ droppedSamples: number;
388
389
  } | null;
389
390
  /** Live against a reference (Historian phase 5): the definition's rule, the axis column and deltas on a connection. */
390
391
  setSegmentAxis(id: string, cfg: LiveSegmentAxis | null): void;
@@ -23,6 +23,7 @@ export interface LiveController {
23
23
  rows: number;
24
24
  name: string;
25
25
  startedAt: number;
26
+ droppedSamples: number;
26
27
  } | null;
27
28
  openLocal(name: string, options?: LiveStreamOptions): LocalLiveStream;
28
29
  setRelay(relay: LiveRelayConfig | undefined): void;
@@ -32,6 +33,12 @@ export interface LiveController {
32
33
  setSegmentAxis(id: string, cfg: LiveSegmentAxis | null): void;
33
34
  dispose(): void;
34
35
  }
36
+ /**
37
+ * A password stream's keys by key id: the first id seen opens with the key connect checked; a later one (a revoked
38
+ * browser gave the stream a new salt, same password) with the salt the stream has now, re-read at most every 2 s. A
39
+ * CryptoKey secret (no password: `pass` null) takes the key the re-read brings.
40
+ */
41
+ export declare function passwordKeys(first: CryptoKey, firstSalt: string, pass: string | null, reload: NonNullable<LiveStreamOptions['reload']>): (keyId: number | null) => Promise<CryptoKey | null>;
35
42
  export declare function createLiveController(initialRelay: LiveRelayConfig | undefined, onChange: (connections: LiveConnection[]) => void,
36
43
  /** The host's defaults for new streams (read when one opens). */
37
44
  defaults?: () => LiveStreamOptions,
@@ -177,6 +177,8 @@ export interface LiveConnectionInfo {
177
177
  recordingSince: number | null;
178
178
  /** The plan-limit banner it was opened with (e.g. "Video limit reached this month"), else null. */
179
179
  limitNotice?: string | null;
180
+ /** Its sender's integrity checkpoints as checked here (LiveConnection.integrity); absent: none came yet. */
181
+ integrity?: import('../lib/live/chainWire').StreamIntegrity;
180
182
  /** Its columns as of the last structural change (the time column first). */
181
183
  channels: string[];
182
184
  }
@@ -44,6 +44,7 @@ export type { XYColumns } from './lib/data/xyColumns';
44
44
  export type { XYZPoint, XYZViewMode } from './components/XYZMeshChart';
45
45
  export type { LoadedDataset } from './types/loadedDataset';
46
46
  export type { DatasetFileInfo, FileEvent, GroupSelection, ChannelChooser, ChannelRequest } from './lib/importers/types';
47
+ export { openSession, type ImportSession, type ReadHandlers } from './lib/importers/session';
47
48
  export type { Dataset, DatasetRow, DatasetParseConfig } from './lib/parseDataset';
48
49
  export { parseDatasetWithConfig, inferParseConfig, getRawNonEmptyLines, parseColumnNames, columnIsNumeric, parseConfigsEqual, subsampleIndices, } from './lib/parseDataset';
49
50
  export { openDatasetFromText } from './lib/data/openDataset';
@@ -62,7 +63,9 @@ export type { LiveStreamDescriptor, LiveStreamOptions, LocalLiveStream, StreamKe
62
63
  export { VIDEO_LIMIT_NOTICE } from './lib/live/types';
63
64
  export type { LiveColumnsBlock, LiveMessage } from './lib/live/buffer';
64
65
  export { LIVE_TIME_COLUMN } from './lib/live/buffer';
65
- export { openMessage, sealMessage, KIND_VIDEO } from './lib/live/wire';
66
+ export { openMessage, sealMessage, KIND_VIDEO, KIND_CHAIN } from './lib/live/wire';
67
+ export { ChainLane, chainVerifier, decodeChain, encodeChain, newRun, CHAIN_LIVE, CHAIN_RECORDING } from './lib/live/chainWire';
68
+ export type { Chain, StreamIntegrity } from './lib/live/chainWire';
66
69
  export { encodeVideo, decodeVideo, fragmentVideo, VIDEO_MAX_FRAGMENT, type VideoMessage } from './lib/live/videoWire';
67
70
  export type { VideoSource, EncodedUnit, VideoTrackInfo } from './lib/live/videoTrack';
68
71
  export { RecordedVideoSource, type RecordedVideoSourceOptions } from './lib/recordings/videoSource';
@@ -96,3 +99,5 @@ export type { SegmentContext } from './engine/types';
96
99
  export { referenceBands } from './charts/beacon';
97
100
  export { alignSegment, AxisState, axisColumn, localSeconds, resample, gridAt, buildReference, bandEdges, pooledSd, compareToReference, encodeBand, decodeBand, MAX_GRID, MAX_BAND_CELLS, type AlignAxis, type AlignedSegment, type Band, type BandFor, type ReferenceCurve, type ReferenceChannel, type Comparison } from './lib/segments/align';
98
101
  export { liveSegmentTracker, DELTA_SUFFIX, type LiveSegmentAxis, type LiveSegmentEvent, type LiveReference } from './lib/segments/liveAxis';
102
+ export * as analysis from './analysis';
103
+ export { buildReport, listedFindings, viewSections, evidenceLabel, HealthAcc, EVIDENCE_TEXT, REPORT_ROLES, SECTION_TITLES, CHANNEL_ROLES, CHANNEL_ROLE_TEXT, PROCESS_MAX, completeness, confirmAll, confirmed, moneyGaps, emptyChannel, emptyContext, energyChannel, parseContext, roleOf, suggestedCount, applyInferred, inferContext, type InferInput, type InferRecording, type InferStream, type Inferred, type PlannedStop, aiInput, applyAi, type AiInput, type AiText, PRESETS, PRESET_IDS, applyPreset, namesOf, presetForIndustry, presetOf, term, type Preset, type PresetId, type AlertIn, type ChannelContext, type ChannelRole, type ProcessContext, type ChannelHealth, type RecordingHealth, type CycleIn, type Evidence, type Finding, type GoldenIn, type RecordingIn, type ReportAction, type ReportChart, type ReportCover, type ReportDoc, type ReportInput, type ReportRole, type ReportSection, type SectionId, } from './analysis';
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Integrity checkpoints (KIND_CHAIN): what binds a stream's messages to the stream and to their order. AES-GCM
3
+ * authenticates each message alone, so a relay (or whoever stores a recording) could drop, reorder, repeat or splice
4
+ * in messages of another recording of the same stream unseen. About once a second a sender seals a checkpoint into
5
+ * each lane (0: the live socket, 1: a recording) saying how many messages it put there since the previous one and a
6
+ * SHA-256 over their SHA-256s, in order; a viewer counting what arrived between two checkpoints sees any difference.
7
+ * Older viewers skip the unknown kind. Byte-compatible with packages/python/src/kymoscope/wire.py (chain) and the C++
8
+ * plugins; vector: tests/vectors/chain-v1.json.
9
+ *
10
+ * Plaintext, 70 bytes, little endian: u8 version (1) | 16 stream id (uuid bytes) | 8 run id (random per sender start)
11
+ * | u8 lane | u64 seq (+1 per checkpoint in the lane) | u32 count | 32 SHA-256(SHA-256(m1) ‖ … ‖ SHA-256(mn)).
12
+ */
13
+ import { KIND_CHAIN } from './wire';
14
+ export { KIND_CHAIN };
15
+ export declare const CHAIN_LIVE = 0;
16
+ export declare const CHAIN_RECORDING = 1;
17
+ export interface Chain {
18
+ streamId: string;
19
+ /** 8 bytes, hex. */
20
+ run: string;
21
+ lane: number;
22
+ seq: bigint;
23
+ count: number;
24
+ hash: Uint8Array;
25
+ }
26
+ export declare function encodeChain(c: Chain): Uint8Array;
27
+ export declare function decodeChain(p: Uint8Array): Chain | null;
28
+ /** SHA-256 over the messages' SHA-256s, in order. */
29
+ export declare function chainHash(digests: Array<Promise<ArrayBuffer> | ArrayBuffer>): Promise<Uint8Array>;
30
+ /** A random run id: a new one for every sender start. */
31
+ export declare const newRun: () => string;
32
+ /** A sender's lane: what it put there since the last checkpoint, and the next checkpoint's plaintext. */
33
+ export declare class ChainLane {
34
+ private digests;
35
+ private seq;
36
+ private readonly streamId;
37
+ private readonly run;
38
+ private readonly lane;
39
+ constructor(streamId: string, run: string, lane: number);
40
+ /** A message handed to this lane (its digest is taken now: the bytes may be reused after). */
41
+ add(message: Uint8Array): void;
42
+ checkpoint(): Promise<Uint8Array>;
43
+ }
44
+ export interface StreamIntegrity {
45
+ /** Intervals between two checkpoints whose messages all came, once each, in order. */
46
+ verified: number;
47
+ /** Intervals that didn't match: a message missing, repeated, out of order or not the sender's. */
48
+ broken: number;
49
+ /** ms epoch of the last broken interval. */
50
+ lastBrokenAt?: number;
51
+ }
52
+ /**
53
+ * A viewer's check of lane 0. `arrive` takes every binary message in arrival order with the promise of its opened
54
+ * content. A checkpoint covers the first `count` messages since the previous one: a message a sender put on the wire
55
+ * while it was still sealing the checkpoint (it seals asynchronously) arrives before it and counts for the next one.
56
+ * What comes before the first checkpoint (the relay's cached channel table for a joining viewer) isn't checked;
57
+ * `reset` after a reconnect starts over, and so does a new run id (the sender restarted). After a broken interval it
58
+ * starts again from that checkpoint.
59
+ */
60
+ export declare function chainVerifier(streamId: string, onChange: (i: StreamIntegrity) => void, now?: () => number): {
61
+ integrity: StreamIntegrity;
62
+ reset(): void;
63
+ arrive(data: ArrayBuffer, kind: number, opened: Promise<{
64
+ kind: number;
65
+ plaintext: Uint8Array;
66
+ } | null>): void;
67
+ };
@@ -0,0 +1,55 @@
1
+ import { type MessageKey } from './wire';
2
+ import { type VideoMessage } from './videoWire';
3
+ import { type LastValue } from './blockWire';
4
+ import type { LiveColumnsBlock, LiveMessage } from './buffer';
5
+ import { type StreamIntegrity } from './chainWire';
6
+ /** What a relay message holds once opened. */
7
+ export type Decoded = {
8
+ type: 'video';
9
+ m: VideoMessage;
10
+ } | {
11
+ type: 'last';
12
+ values: LastValue[];
13
+ } | {
14
+ type: 'columns';
15
+ block: LiveColumnsBlock;
16
+ } | {
17
+ type: 'frames';
18
+ frames: LiveMessage[];
19
+ }
20
+ /** Samples dropped here because the page couldn't keep up (see bounded): the samples after it come after a gap. */
21
+ | {
22
+ type: 'gap';
23
+ samples: number;
24
+ }
25
+ /** The stream's integrity checkpoints so far (see chainWire.ts). */
26
+ | {
27
+ type: 'integrity';
28
+ integrity: StreamIntegrity;
29
+ };
30
+ /**
31
+ * A stream's messages opened with `key` and handed to `emit` in the order they arrived (decrypted as they arrive, in
32
+ * parallel: a block landing before an older one would put time out of order in the buffer). A message that is bad,
33
+ * or whose key isn't available yet, is skipped. Channel tables (KIND_BLOCK_SCHEMA) are kept here.
34
+ */
35
+ export declare function createIngest(key: MessageKey, emit: (d: Decoded) => void, streamId?: string): ((data: ArrayBuffer) => void) & {
36
+ reset(): void;
37
+ };
38
+ /** The buffers behind a block of samples, to hand it to another thread without copying them. */
39
+ export declare function transferables(d: Decoded): ArrayBuffer[];
40
+ /** Most bytes of samples a stream's worker lets wait for the page (about 6 s of 50 channels at 50 kHz). */
41
+ export declare const INGEST_QUEUE_BYTES: number;
42
+ /**
43
+ * `emit` with a bound on what waits for the other thread: each block handed over counts its bytes until `ack`ed (the
44
+ * page acks a block once it is in the ring). While more than `limit` bytes wait, new blocks of samples are dropped
45
+ * instead of queued: a page that can't keep up shows a gap in its traces and stays within seconds of live, where an
46
+ * unbounded queue grew until the tab ran out of memory. Anything else (last values, frames) always passes. The
47
+ * first block let through after a drop is preceded by a `gap` saying how many samples went, so whoever keeps the
48
+ * samples (the connection's count, a recording) knows of it.
49
+ */
50
+ export declare function bounded(emit: (d: Decoded, bytes: number) => void, limit?: number): {
51
+ emit(d: Decoded): void;
52
+ ack(bytes: number): void;
53
+ /** Samples dropped so far. */
54
+ readonly dropped: number;
55
+ };
@@ -0,0 +1,9 @@
1
+ import { type Decoded } from './liveIngest';
2
+ import { type LiveRelayConfig, type StreamStatus } from './stream';
3
+ import type { MessageKey } from './wire';
4
+ /**
5
+ * Subscribe to a stream with its socket, decryption and decoding in a worker of its own (see liveIngestWorker);
6
+ * `onDecoded` gets each message's content on this thread, in order. Where workers can't run, or the worker's script
7
+ * doesn't load, the same work is done on this thread. Returns the unsubscribe.
8
+ */
9
+ export declare function subscribeDecoded(relay: LiveRelayConfig, streamId: string, key: MessageKey, onDecoded: (d: Decoded) => void, onStatus?: (status: StreamStatus) => void): () => void;
@@ -0,0 +1 @@
1
+ export {};