@kymoscope/sdk 0.10.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.
- package/dist/assets/{importer.worker-CLBGjz4d.js → importer.worker-Cgz__4KO.js} +1 -1
- package/dist/assets/liveIngestWorker-BLPTEEc7.js +1 -0
- package/dist/assets/offscreenLineWorker-C-_uNa_H.js +80 -0
- package/dist/{importers-2iwVi4cq.js → importers-D_M42sqZ.js} +1 -1
- package/dist/{keys-DmtCD10T.js → keys-CkI2qrI-.js} +1 -1
- package/dist/kymoscope-embed.js +66 -66
- package/dist/kymoscope-sdk.js +62 -62
- package/dist/types/analysis/ai.d.ts +50 -0
- package/dist/types/analysis/aiCheck.d.ts +54 -0
- package/dist/types/analysis/alertsBefore.d.ts +7 -0
- package/dist/types/analysis/better.d.ts +6 -0
- package/dist/types/analysis/capability.d.ts +10 -0
- package/dist/types/analysis/changes.d.ts +10 -0
- package/dist/types/analysis/containment.d.ts +10 -0
- package/dist/types/analysis/context.d.ts +131 -0
- package/dist/types/analysis/control.d.ts +13 -0
- package/dist/types/analysis/energy.d.ts +4 -0
- package/dist/types/analysis/gap.d.ts +8 -0
- package/dist/types/analysis/golden.d.ts +20 -0
- package/dist/types/analysis/health.d.ts +73 -0
- package/dist/types/analysis/index.d.ts +12 -0
- package/dist/types/analysis/infer.d.ts +68 -0
- package/dist/types/analysis/lines.d.ts +6 -0
- package/dist/types/analysis/losses.d.ts +41 -0
- package/dist/types/analysis/maintenance.d.ts +8 -0
- package/dist/types/analysis/oee.d.ts +30 -0
- package/dist/types/analysis/parts.d.ts +13 -0
- package/dist/types/analysis/presets.d.ts +35 -0
- package/dist/types/analysis/reliability.d.ts +103 -0
- package/dist/types/analysis/report.d.ts +15 -0
- package/dist/types/analysis/shifts.d.ts +7 -0
- package/dist/types/analysis/sinceLast.d.ts +8 -0
- package/dist/types/analysis/stats.d.ts +110 -0
- package/dist/types/analysis/stops.d.ts +34 -0
- package/dist/types/analysis/strip.d.ts +14 -0
- package/dist/types/analysis/text.d.ts +56 -0
- package/dist/types/analysis/types.d.ts +407 -0
- package/dist/types/components/liveWindow.d.ts +6 -2
- package/dist/types/engine/createEngine.d.ts +1 -0
- package/dist/types/engine/liveController.d.ts +7 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/lib/live/liveIngest.d.ts +47 -0
- package/dist/types/lib/live/liveIngestClient.d.ts +9 -0
- package/dist/types/lib/live/liveIngestWorker.d.ts +1 -0
- package/dist/types/lib/live/publisher.d.ts +10 -0
- package/dist/types/lib/live/stream.d.ts +8 -0
- package/dist/types/lib/live/types.d.ts +12 -0
- package/dist/types/lib/render/frames.d.ts +10 -0
- package/dist/types/lib/render/glPoints.d.ts +18 -0
- package/dist/types/lib/render/offscreenLineRenderer.d.ts +15 -1
- package/dist/types/lib/render/sharedGl.d.ts +12 -3
- package/package.json +1 -1
- package/dist/assets/offscreenLineWorker-BQwts3O3.js +0 -80
|
@@ -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.
|
|
29
|
-
*
|
|
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,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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';
|
|
@@ -96,3 +97,5 @@ export type { SegmentContext } from './engine/types';
|
|
|
96
97
|
export { referenceBands } from './charts/beacon';
|
|
97
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';
|
|
98
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';
|
|
@@ -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;
|
|
@@ -60,6 +62,8 @@ export interface LiveProfile {
|
|
|
60
62
|
}[];
|
|
61
63
|
/** A data stream's wire bytes a second (required for kind 'data'; finite, > 0). */
|
|
62
64
|
bytes_per_sec?: number;
|
|
65
|
+
/** Set by the SDK on a data stream (the server keeps which sender sent it). */
|
|
66
|
+
sender?: 'browser';
|
|
63
67
|
quality?: CameraQuality;
|
|
64
68
|
fps?: number;
|
|
65
69
|
/** A data `record` stream's file period: '1m' … '24h' or its seconds (lib/recordings/split.ts); default from
|
|
@@ -146,6 +150,8 @@ export declare class LivePublisher {
|
|
|
146
150
|
private key;
|
|
147
151
|
/** A password stream's raw key, for device wraps (derivable from the secret anyway). */
|
|
148
152
|
private raw;
|
|
153
|
+
/** See PublisherState.keyGen (0: no key id on the wire, as before). */
|
|
154
|
+
private gen;
|
|
149
155
|
private epoch;
|
|
150
156
|
private haveKey;
|
|
151
157
|
private sealed;
|
|
@@ -219,6 +225,10 @@ export declare class LivePublisher {
|
|
|
219
225
|
/** Token refresh, then the heartbeat (each new ticket also refreshes the socket). 401/403 stop the
|
|
220
226
|
* publisher (revoked key, plan, stale_epoch, a camera's video_hours_exhausted); anything else is retried on the next interval. */
|
|
221
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;
|
|
222
232
|
/** Seal the stream key to the owner's browsers that lack it (password streams), at most 50 per call. */
|
|
223
233
|
private wrapFor;
|
|
224
234
|
/** The project key arrived: seal the stream key under it; a new epoch (rotation) gets a new stream key.
|
|
@@ -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.
|
|
@@ -54,6 +54,15 @@ export interface LiveStreamOptions {
|
|
|
54
54
|
* time included). Default an eighth of the device's memory (2048 on a 16 GB
|
|
55
55
|
* computer, and when the browser doesn't say), at least 512. */
|
|
56
56
|
maxMemoryMB?: number;
|
|
57
|
+
/**
|
|
58
|
+
* A password stream's salt and key_check as they are now (and its key, for a CryptoKey secret) (re-read from wherever the descriptor came from). A
|
|
59
|
+
* revoked browser makes the sender take a new salt, its messages then name a new key id: without this, the view
|
|
60
|
+
* stops until it is connected again with the new descriptor.
|
|
61
|
+
*/
|
|
62
|
+
reload?: () => Promise<(Pick<LiveStreamDescriptor, 'salt' | 'key_check'> & {
|
|
63
|
+
/** The key itself, when it doesn't come from a password (a browser's device key): checked against key_check. */
|
|
64
|
+
key?: CryptoKey;
|
|
65
|
+
}) | null>;
|
|
57
66
|
}
|
|
58
67
|
/** A host-fed stream: frames pushed from the page itself — no network, no crypto. */
|
|
59
68
|
export interface LocalLiveStream {
|
|
@@ -93,6 +102,9 @@ export interface LiveConnection {
|
|
|
93
102
|
error: string | null;
|
|
94
103
|
/** When a recording is running: its start time (ms since epoch). */
|
|
95
104
|
recordingSince: number | null;
|
|
105
|
+
/** Samples dropped before the ring because this page couldn't keep up with the stream (its traces have a gap
|
|
106
|
+
* there); 0 or absent: none. */
|
|
107
|
+
droppedSamples?: number;
|
|
96
108
|
/** The plan-limit banner it was opened with (LiveStreamDescriptor.limit_notice); a Camera panel shows it. */
|
|
97
109
|
limitNotice?: string | null;
|
|
98
110
|
}
|
|
@@ -39,8 +39,18 @@ export declare class AnyWindowResizeObserver {
|
|
|
39
39
|
* frame's time until the next frame, so several changes in one frame still
|
|
40
40
|
* make one draw.
|
|
41
41
|
*/
|
|
42
|
+
/** Hidden with its worksheet (in the document, no layout: display none), as opposed to scrolled out of view. */
|
|
43
|
+
export declare function isHidden(el: Element | null | undefined): boolean;
|
|
42
44
|
export declare function createDrawScheduler(draw: () => void, element: () => Element | null | undefined): {
|
|
43
45
|
schedule(): void;
|
|
44
46
|
now(): void;
|
|
45
47
|
cancel(): void;
|
|
46
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* Whether a live chart that last drew at `lastDrew` may draw in the frame at `ts`. Every chart of a frame gets the
|
|
51
|
+
* same answer from the duty above; within the frame, past LIVE_FRAME_CAP_MS the rest wait, and the next frames serve
|
|
52
|
+
* the charts that waited before those that drew since (stalest first, as near as callbacks in a fixed order allow).
|
|
53
|
+
*/
|
|
54
|
+
export declare function liveDrawAllowed(ts: number, lastDrew?: number): boolean;
|
|
55
|
+
/** A live chart drew for `ms` in the frame at `ts`. */
|
|
56
|
+
export declare function noteLiveDraw(ts: number, ms: number): void;
|
|
@@ -34,4 +34,22 @@ export interface GpuPointsRenderer {
|
|
|
34
34
|
render(): void;
|
|
35
35
|
dispose(): void;
|
|
36
36
|
}
|
|
37
|
+
/** A stretch of points with one dataset index (all of them when the colour isn't per dataset). */
|
|
38
|
+
export interface PointRun {
|
|
39
|
+
v: number;
|
|
40
|
+
a: number;
|
|
41
|
+
b: number;
|
|
42
|
+
}
|
|
43
|
+
/** The runs of equal `k` in the first `n` points (one run without `k`). */
|
|
44
|
+
export declare function pointRuns(k: ArrayLike<number> | undefined, n: number): PointRun[];
|
|
45
|
+
/**
|
|
46
|
+
* How much of the previous upload a new one holds, run by run: a live refresh drops its oldest points and adds
|
|
47
|
+
* new ones, so each run of the new data starts with a stretch of the old run of the same index. Per new run, the
|
|
48
|
+
* points kept (`len`, from old position `src`); the rest of the run is new. Null when the old points aren't found
|
|
49
|
+
* exactly (other data): everything is sent again.
|
|
50
|
+
*/
|
|
51
|
+
export declare function planReuse(oldX: Float64Array, oldY: Float64Array, oldRuns: PointRun[], x: Float64Array, y: Float64Array, runs: PointRun[]): {
|
|
52
|
+
src: number;
|
|
53
|
+
len: number;
|
|
54
|
+
}[] | null;
|
|
37
55
|
export declare function createGpuPointsRenderer(canvas: HTMLCanvasElement | OffscreenCanvas): GpuPointsRenderer | null;
|