@kymoscope/sdk 0.9.0 → 0.11.1

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-Cgz__4KO.js} +1 -1
  2. package/dist/assets/liveIngestWorker-BLPTEEc7.js +1 -0
  3. package/dist/assets/offscreenLineWorker-C-_uNa_H.js +80 -0
  4. package/dist/importers-D_M42sqZ.js +5 -0
  5. package/dist/{keys-Iv24Wam2.js → keys-CkI2qrI-.js} +1 -1
  6. package/dist/kymoscope-embed.js +66 -66
  7. package/dist/kymoscope-sdk.js +89 -85
  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/index.d.ts +6 -1
  42. package/dist/types/lib/live/cameraSender.d.ts +9 -1
  43. package/dist/types/lib/live/liveIngest.d.ts +47 -0
  44. package/dist/types/lib/live/liveIngestClient.d.ts +9 -0
  45. package/dist/types/lib/live/liveIngestWorker.d.ts +1 -0
  46. package/dist/types/lib/live/publisher.d.ts +23 -5
  47. package/dist/types/lib/live/stream.d.ts +8 -0
  48. package/dist/types/lib/live/types.d.ts +12 -0
  49. package/dist/types/lib/recordings/split.d.ts +10 -0
  50. package/dist/types/lib/recordings/writer.d.ts +187 -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 +4 -1
  56. package/dist/assets/offscreenLineWorker-BQwts3O3.js +0 -80
  57. package/dist/importers-BVYsv8Vy.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,
@@ -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';
@@ -67,7 +68,9 @@ export { encodeVideo, decodeVideo, fragmentVideo, VIDEO_MAX_FRAGMENT, type Video
67
68
  export type { VideoSource, EncodedUnit, VideoTrackInfo } from './lib/live/videoTrack';
68
69
  export { RecordedVideoSource, type RecordedVideoSourceOptions } from './lib/recordings/videoSource';
69
70
  export { LivePublisher, fetchUsage, liveBytesPerSec, RegistryError, type CameraQuality, type LiveProfile, type LiveUsage, type PublisherDeps, type PublisherOptions, type PublisherState, type PublisherStatus } from './lib/live/publisher';
70
- export { CameraSender, CAMERA_QUALITIES, LOW_PRESET, type CameraPreset, type CameraStats, type CameraLayerStats, type CameraSenderDeps } from './lib/live/cameraSender';
71
+ export { CameraSender, CAMERA_QUALITIES, LOW_PRESET, type CameraPreset, type CameraStats, type CameraLayerStats, type CameraSenderDeps, type CameraRecorder } from './lib/live/cameraSender';
72
+ export { BrowserRecorder, bufferLabel, type BrowserRecorderOptions, type Destination, type OwnStorage, type RecorderStatus } from './lib/recordings/writer';
73
+ export { SPLIT_STEPS, defaultSplit, formatSplit, parseSplit } from './lib/recordings/split';
71
74
  export type { RecordingKey } from './lib/recordings/keys';
72
75
  export { recordingKeyAad, recordingKeySealAad } from './lib/recordings/keys';
73
76
  export { parseKrc, parseKrcHeader, KRC_HEADER_BYTES } from './lib/recordings/krc';
@@ -94,3 +97,5 @@ export type { SegmentContext } from './engine/types';
94
97
  export { referenceBands } from './charts/beacon';
95
98
  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';
96
99
  export { liveSegmentTracker, DELTA_SUFFIX, type LiveSegmentAxis, type LiveSegmentEvent, type LiveReference } from './lib/segments/liveAxis';
100
+ export * as analysis from './analysis';
101
+ 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';
@@ -36,7 +36,14 @@ export interface CameraSenderDeps {
36
36
  /** The low layer's downscale (test seam); defaults to drawing onto an OffscreenCanvas. The caller closes the result. */
37
37
  scale?: (frame: VideoFrame, width: number, height: number) => VideoFrame;
38
38
  }
39
- type Publisher = Pick<LivePublisher, 'send' | 'viewers' | 'onViewers' | 'bitrateKbps' | 'profile'>;
39
+ type Publisher = Pick<LivePublisher, 'send' | 'viewers' | 'onViewers' | 'bitrateKbps' | 'profile'> & Partial<Pick<LivePublisher, 'seal' | 'sendSealed'>>;
40
+ /** What a recording camera feeds (BrowserRecorder). */
41
+ export interface CameraRecorder {
42
+ /** Frames are wanted (its data stream records): encode even with no viewers. */
43
+ wants(): boolean;
44
+ /** One sealed message at the frame's capture time (ms epoch); `keyframe`: it starts a keyframe. */
45
+ add(sealed: Uint8Array, tMs: number, keyframe: boolean): void;
46
+ }
40
47
  export declare class CameraSender {
41
48
  private readonly high;
42
49
  private readonly lowOpt;
@@ -57,6 +64,7 @@ export declare class CameraSender {
57
64
  publisher: Publisher;
58
65
  preset?: CameraPreset;
59
66
  };
67
+ recorder?: CameraRecorder;
60
68
  }, deps?: CameraSenderDeps);
61
69
  /** Encode frames from `track` (a getUserMedia video track). Resolves once the encoder is configured;
62
70
  * frames then flow until stop(). Throws KymoscopeError('camera_codec_unsupported'). A low layer this
@@ -0,0 +1,47 @@
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
+ /** What a relay message holds once opened. */
6
+ export type Decoded = {
7
+ type: 'video';
8
+ m: VideoMessage;
9
+ } | {
10
+ type: 'last';
11
+ values: LastValue[];
12
+ } | {
13
+ type: 'columns';
14
+ block: LiveColumnsBlock;
15
+ } | {
16
+ type: 'frames';
17
+ frames: LiveMessage[];
18
+ }
19
+ /** Samples dropped here because the page couldn't keep up (see bounded): the samples after it come after a gap. */
20
+ | {
21
+ type: 'gap';
22
+ samples: number;
23
+ };
24
+ /**
25
+ * A stream's messages opened with `key` and handed to `emit` in the order they arrived (decrypted as they arrive, in
26
+ * parallel: a block landing before an older one would put time out of order in the buffer). A message that is bad,
27
+ * or whose key isn't available yet, is skipped. Channel tables (KIND_BLOCK_SCHEMA) are kept here.
28
+ */
29
+ export declare function createIngest(key: MessageKey, emit: (d: Decoded) => void): (data: ArrayBuffer) => void;
30
+ /** The buffers behind a block of samples, to hand it to another thread without copying them. */
31
+ export declare function transferables(d: Decoded): ArrayBuffer[];
32
+ /** Most bytes of samples a stream's worker lets wait for the page (about 6 s of 50 channels at 50 kHz). */
33
+ export declare const INGEST_QUEUE_BYTES: number;
34
+ /**
35
+ * `emit` with a bound on what waits for the other thread: each block handed over counts its bytes until `ack`ed (the
36
+ * page acks a block once it is in the ring). While more than `limit` bytes wait, new blocks of samples are dropped
37
+ * instead of queued: a page that can't keep up shows a gap in its traces and stays within seconds of live, where an
38
+ * unbounded queue grew until the tab ran out of memory. Anything else (last values, frames) always passes. The
39
+ * first block let through after a drop is preceded by a `gap` saying how many samples went, so whoever keeps the
40
+ * samples (the connection's count, a recording) knows of it.
41
+ */
42
+ export declare function bounded(emit: (d: Decoded, bytes: number) => void, limit?: number): {
43
+ emit(d: Decoded): void;
44
+ ack(bytes: number): void;
45
+ /** Samples dropped so far. */
46
+ readonly dropped: number;
47
+ };
@@ -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 {};
@@ -31,6 +31,8 @@ export interface PublisherState {
31
31
  key: CryptoKey;
32
32
  sealed: SealedKey;
33
33
  } | null;
34
+ /** A password stream's key since the first (one per new salt after a revoked browser): its messages' key id. */
35
+ keyGen?: number;
34
36
  }
35
37
  export interface PublisherDeps {
36
38
  fetch: typeof fetch;
@@ -50,6 +52,8 @@ export type CameraQuality = '360p' | '480p' | '720p' | '1080p';
50
52
  * declares its high camera's profile. */
51
53
  export interface LiveProfile {
52
54
  mode: 'live' | 'record';
55
+ /** On the wire only (set from splitEvery). */
56
+ split_every?: number;
53
57
  hz?: number;
54
58
  channels?: number;
55
59
  sources?: {
@@ -58,8 +62,13 @@ export interface LiveProfile {
58
62
  }[];
59
63
  /** A data stream's wire bytes a second (required for kind 'data'; finite, > 0). */
60
64
  bytes_per_sec?: number;
65
+ /** Set by the SDK on a data stream (the server keeps which sender sent it). */
66
+ sender?: 'browser';
61
67
  quality?: CameraQuality;
62
68
  fps?: number;
69
+ /** A data `record` stream's file period: '1m' … '24h' or its seconds (lib/recordings/split.ts); default from
70
+ * `bytes_per_sec` (files of about 150 MB). Sent as `split_every`. The SDK records only cameras (BrowserRecorder). */
71
+ splitEvery?: string | number;
63
72
  }
64
73
  /** A data stream's `bytes_per_sec`: `messagesPerSec` messages a second of `plaintextBytes` each (one representative
65
74
  * message's plaintext as handed to send(), with the samples one message carries), sealed and framed as the publisher
@@ -132,9 +141,6 @@ export declare class LivePublisher {
132
141
  private readonly password;
133
142
  private token;
134
143
  private ticket;
135
- /** The current ticket says rec (the reply's `recording`); `authRec`: the one the open socket authenticated with. */
136
- private ticketRec;
137
- private authRec;
138
144
  private relayUrl;
139
145
  private apiKeyId;
140
146
  private projectId;
@@ -144,6 +150,8 @@ export declare class LivePublisher {
144
150
  private key;
145
151
  /** A password stream's raw key, for device wraps (derivable from the secret anyway). */
146
152
  private raw;
153
+ /** See PublisherState.keyGen (0: no key id on the wire, as before). */
154
+ private gen;
147
155
  private epoch;
148
156
  private haveKey;
149
157
  private sealed;
@@ -197,6 +205,13 @@ export declare class LivePublisher {
197
205
  /** Seal with the current stream key (the key id of its epoch when e2ee) and send; false if not sent
198
206
  * (no key yet, socket down, stopped). */
199
207
  send(kind: number, plaintext: Uint8Array): Promise<boolean>;
208
+ /** The sealed message send() would publish (what a recorder keeps), or null without a stream key yet. */
209
+ seal(kind: number, plaintext: Uint8Array): Promise<Uint8Array<ArrayBuffer> | null>;
210
+ /** Publish an already sealed message; false when the socket is down. */
211
+ sendSealed(message: Uint8Array<ArrayBuffer>): boolean;
212
+ /** One recording-upload call with this stream's `pt.` token (supabase/functions/recording-upload/CONTRACT.md):
213
+ * what a BrowserRecorder needs. Rejects with a RegistryError. */
214
+ recordingUpload(body: Record<string, unknown>): Promise<any>;
200
215
  /** Close the socket and stop the timers. The stream stays registered (never deleted here), offline at once: what
201
216
  * it declared stops counting against the live limits now, not when the live window runs out. */
202
217
  stop(): void;
@@ -210,6 +225,10 @@ export declare class LivePublisher {
210
225
  /** Token refresh, then the heartbeat (each new ticket also refreshes the socket). 401/403 stop the
211
226
  * publisher (revoked key, plan, stale_epoch, a camera's video_hours_exhausted); anything else is retried on the next interval. */
212
227
  private housekeeping;
228
+ /** A browser that had this stream's key was revoked (heartbeat rekey): a new salt, same password, is a key it never
229
+ * had. Registered before it is used, so a viewer that meets the new key id finds the new salt; the server then seals
230
+ * it only to the browsers still active. A failure is asked again on the next heartbeat. */
231
+ private rekey;
213
232
  /** Seal the stream key to the owner's browsers that lack it (password streams), at most 50 per call. */
214
233
  private wrapFor;
215
234
  /** The project key arrived: seal the stream key under it; a new epoch (rotation) gets a new stream key.
@@ -221,8 +240,7 @@ export declare class LivePublisher {
221
240
  private disconnect;
222
241
  /** Reconnect: at once after a stable connection, else after the backoff (1 s doubling to 10 s). */
223
242
  private dropped;
224
- /** Use `ticket` from now on; re-authenticate the open socket in-band when due, or at once when it
225
- * says rec and the socket's ticket didn't. */
243
+ /** Use `ticket` from now on; re-authenticate the open socket in-band when due. */
226
244
  private setTicket;
227
245
  private setViewers;
228
246
  private refuse;
@@ -9,6 +9,12 @@
9
9
  * encrypted binary messages — it never sees plaintext.
10
10
  */
11
11
  export declare const RELAY_SUBPROTOCOL = "kymoscope-live.v1";
12
+ /**
13
+ * Offered with it: this viewer says, once a second, how many bytes it has received ({"type":"ack","b":n}), so a relay
14
+ * can let go of a viewer that stays behind instead of holding everything for it (on Kymoscope's relay one such viewer
15
+ * held up the whole stream for everyone). The relay still answers with RELAY_SUBPROTOCOL.
16
+ */
17
+ export declare const ACK_SUBPROTOCOL = "kymoscope-live.ack1";
12
18
  export type StreamStatus = 'subscribed' | 'closed' | 'error';
13
19
  /** Where the relay lives and how to authenticate to it (host-provided). */
14
20
  export interface LiveRelayConfig {
@@ -17,6 +23,8 @@ export interface LiveRelayConfig {
17
23
  /** Fresh credential for watching one stream; `null` = not available now (retried). */
18
24
  getToken: (streamId: string) => Promise<string | null>;
19
25
  }
26
+ /** A Supabase session JWT (base64url `{"` header), as opposed to a relay ticket (`wt.`, …). */
27
+ export declare const isSessionJwt: (token: string) => boolean;
20
28
  /**
21
29
  * `exp` (unix seconds) of a session JWT (`h.<payload>.s`) or a watch ticket
22
30
  * (`wt.<payload>.s`) — both carry base64url JSON in the second segment.