@kymoscope/sdk 0.11.1 → 0.13.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.
- package/dist/assets/{importer.worker-Cgz__4KO.js → importer.worker-C63-1oBd.js} +1 -1
- package/dist/assets/liveIngestWorker-DQYK0Xxv.js +1 -0
- package/dist/importers-IlQKVrkS.js +5 -0
- package/dist/{keys-CkI2qrI-.js → keys-BPymBse7.js} +3 -3
- package/dist/kymoscope-embed.js +85 -85
- package/dist/kymoscope-sdk.js +84 -86
- package/dist/types/engine/columns.d.ts +1 -10
- package/dist/types/engine/createEngine.d.ts +3 -13
- package/dist/types/engine/types.d.ts +2 -8
- package/dist/types/index.d.ts +6 -12
- package/dist/types/lib/cycles/evaluator.d.ts +1 -2
- package/dist/types/lib/duckdb/duckdbInstance.d.ts +0 -5
- package/dist/types/lib/live/blockWire.d.ts +1 -1
- package/dist/types/lib/live/chainWire.d.ts +67 -0
- package/dist/types/lib/live/crypto.d.ts +0 -3
- package/dist/types/lib/live/liveIngest.d.ts +9 -1
- package/dist/types/lib/live/publisher.d.ts +11 -1
- package/dist/types/lib/live/stream.d.ts +6 -0
- package/dist/types/lib/live/types.d.ts +5 -0
- package/dist/types/lib/live/wire.d.ts +2 -0
- package/dist/types/lib/recordings/export.d.ts +0 -1
- package/dist/types/lib/segments/liveAxis.d.ts +8 -40
- package/dist/types/lib/segments/rules.d.ts +3 -42
- package/dist/types/lib/workspaces/io.d.ts +0 -6
- package/dist/types/lib/yAxisTicks.d.ts +1 -1
- package/package.json +1 -1
- package/dist/assets/liveIngestWorker-BLPTEEc7.js +0 -1
- package/dist/importers-D_M42sqZ.js +0 -5
- package/dist/types/lib/data/historyDataSource.d.ts +0 -51
- package/dist/types/lib/historian/blockCache.d.ts +0 -32
- package/dist/types/lib/historian/export.d.ts +0 -31
- package/dist/types/lib/historian/khd1.d.ts +0 -41
- package/dist/types/lib/historian/parquet.d.ts +0 -21
- package/dist/types/lib/historian/reader.d.ts +0 -73
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { LoadedDataset } from '../types/loadedDataset';
|
|
2
|
-
import { type HistoryPiece } from '../lib/data/historyDataSource';
|
|
3
2
|
/** Columnar numeric data handed over by the host. */
|
|
4
3
|
export interface ColumnsInput {
|
|
5
4
|
name: string;
|
|
@@ -12,7 +11,7 @@ export interface ColumnsInput {
|
|
|
12
11
|
* times a second, where the copy is most of the cost.
|
|
13
12
|
*/
|
|
14
13
|
transfer?: boolean;
|
|
15
|
-
/** Bands to shade under columns (a reference's envelope
|
|
14
|
+
/** Bands to shade under columns (a reference's envelope): edges aligned with the columns' rows. */
|
|
16
15
|
bands?: Record<string, {
|
|
17
16
|
lo: ArrayLike<number>;
|
|
18
17
|
hi: ArrayLike<number>;
|
|
@@ -50,11 +49,3 @@ export declare function replaceColumns(ds: LoadedDataset, input: Record<string,
|
|
|
50
49
|
* (cached), never on load or on each replaceColumns.
|
|
51
50
|
*/
|
|
52
51
|
export declare function columnsText(ds: LoadedDataset): string;
|
|
53
|
-
/** A Historian range handed to the engine (Historian phase 4): pieces from readHistoryRange and the channels' units. */
|
|
54
|
-
export interface HistoryRangeView {
|
|
55
|
-
name: string;
|
|
56
|
-
pieces: HistoryPiece[];
|
|
57
|
-
units?: Record<string, string>;
|
|
58
|
-
}
|
|
59
|
-
/** A Historian range as a dataset: read through HistoryDataSource; its rows are a time-ordered sample. */
|
|
60
|
-
export declare function historyDataset(id: string, view: HistoryRangeView): LoadedDataset;
|
|
@@ -26,7 +26,7 @@ import { type WorkbookFileOptions } from '../lib/workspaces/encrypted';
|
|
|
26
26
|
import { canPickDirectory, isImportable, pickDirectoryEntries, type DirNode, type FolderEntry } from '../lib/folderTree';
|
|
27
27
|
import { type ChartView, type MountOptions } from '../charts/runtime';
|
|
28
28
|
import { type ChartWindow, type ChartWindowOptions } from '../charts/chartWindow';
|
|
29
|
-
import { type ColumnsInput
|
|
29
|
+
import { type ColumnsInput } from './columns';
|
|
30
30
|
import { createDerivations } from './derive';
|
|
31
31
|
import { chartLabel, type ChartKindInfo } from './kinds';
|
|
32
32
|
import { createLiveController } from './liveController';
|
|
@@ -35,7 +35,7 @@ import { type ChartMark, type RuleStateInfo } from './alerts';
|
|
|
35
35
|
import type { RuleDoc } from '../rules/types';
|
|
36
36
|
import type { LinkedRuleLine } from '../lib/panelChartSettings';
|
|
37
37
|
import { createStore } from './store';
|
|
38
|
-
import { type ChartKind, type ChartModel, type EngineEvents, type EngineOptions, type EngineState, type KymoscopeLimits
|
|
38
|
+
import { type ChartKind, type ChartModel, type EngineEvents, type EngineOptions, type EngineState, type KymoscopeLimits } from './types';
|
|
39
39
|
export declare const DEFAULT_X = "ET";
|
|
40
40
|
/** Default series / scatter colours (matches the app). */
|
|
41
41
|
export declare const PALETTE: string[];
|
|
@@ -49,7 +49,6 @@ export interface InternalState {
|
|
|
49
49
|
offsets: Record<string, number>;
|
|
50
50
|
colors: Record<string, string>;
|
|
51
51
|
liveWindowSeconds: number | null;
|
|
52
|
-
segmentContext: SegmentContext | null;
|
|
53
52
|
/** Cycle and phase rules (lib/cycles), saved with the workbook. */
|
|
54
53
|
cycleRules: CycleDefinition[];
|
|
55
54
|
live: LiveConnection[];
|
|
@@ -146,13 +145,6 @@ export declare function createEngine(options?: EngineOptions): {
|
|
|
146
145
|
}): Promise<string>;
|
|
147
146
|
/** New chunks of an open recording: the dataset keeps its id, selection, colour, offset and laps. */
|
|
148
147
|
reopenRecording(id: string, input: RecordingInput): Promise<void>;
|
|
149
|
-
/**
|
|
150
|
-
* A time range of a Historian history as a dataset (pieces from readHistoryRange; X `ElapsedTime`, Unix seconds).
|
|
151
|
-
* Returns the id. Selected like any new dataset.
|
|
152
|
-
*/
|
|
153
|
-
openHistoryRange(view: HistoryRangeView): string;
|
|
154
|
-
/** New pieces for a history dataset (pan/zoom, a later read): same id, selection, colour and offset. */
|
|
155
|
-
updateHistoryRange(id: string, view: HistoryRangeView): void;
|
|
156
148
|
/** Add numeric columns from the host (selected immediately). */
|
|
157
149
|
addColumns(input: ColumnsInput): string;
|
|
158
150
|
/**
|
|
@@ -335,8 +327,6 @@ export declare function createEngine(options?: EngineOptions): {
|
|
|
335
327
|
/** Live window of a worksheet's charts (default: active; seconds, null = all). Each worksheet has its own, shared
|
|
336
328
|
* by its charts; a worksheet that never set one follows the workbook's. */
|
|
337
329
|
setLiveWindow(seconds: number | null, worksheetId?: string): void;
|
|
338
|
-
/** The Segments panel's ids (history, definition, reference); saved with the workbook. */
|
|
339
|
-
setSegmentContext(ctx: SegmentContext | null): void;
|
|
340
330
|
};
|
|
341
331
|
mathChannels: {
|
|
342
332
|
/** Create a channel (`name` and `formula` at least). Returns it. */
|
|
@@ -387,7 +377,7 @@ export declare function createEngine(options?: EngineOptions): {
|
|
|
387
377
|
startedAt: number;
|
|
388
378
|
droppedSamples: number;
|
|
389
379
|
} | null;
|
|
390
|
-
/** Live
|
|
380
|
+
/** Live segment axis: a cycle rule's axis column on a connection (cycle-only, no live reference). */
|
|
391
381
|
setSegmentAxis(id: string, cfg: LiveSegmentAxis | null): void;
|
|
392
382
|
/** Samples currently buffered for a connection (cheap; poll it for counters). */
|
|
393
383
|
rowCount(id: string): number;
|
|
@@ -177,15 +177,11 @@ 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
|
}
|
|
183
|
-
/** What the Segments panel shows (Historian phase 5): saved in workbooks by id (spec E4), never data. */
|
|
184
|
-
export interface SegmentContext {
|
|
185
|
-
historyId: string;
|
|
186
|
-
definitionId: string | null;
|
|
187
|
-
referenceId: string | null;
|
|
188
|
-
}
|
|
189
185
|
export interface EngineState {
|
|
190
186
|
datasets: DatasetInfo[];
|
|
191
187
|
/** Plotted ids: dataset ids, lap ids and live connection ids. */
|
|
@@ -196,8 +192,6 @@ export interface EngineState {
|
|
|
196
192
|
live: LiveConnectionInfo[];
|
|
197
193
|
/** Scrolling window for live charts on a time X axis (seconds; null = all): the active worksheet's. */
|
|
198
194
|
liveWindowSeconds: number | null;
|
|
199
|
-
/** The Segments panel's history, definition and reference, or null. */
|
|
200
|
-
segmentContext: SegmentContext | null;
|
|
201
195
|
/** Cycle and phase rules (engine.cycles), saved with the workbook. */
|
|
202
196
|
cycleRules: CycleDefinition[];
|
|
203
197
|
limits: KymoscopeLimits;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -63,7 +63,9 @@ export type { LiveStreamDescriptor, LiveStreamOptions, LocalLiveStream, StreamKe
|
|
|
63
63
|
export { VIDEO_LIMIT_NOTICE } from './lib/live/types';
|
|
64
64
|
export type { LiveColumnsBlock, LiveMessage } from './lib/live/buffer';
|
|
65
65
|
export { LIVE_TIME_COLUMN } from './lib/live/buffer';
|
|
66
|
-
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';
|
|
67
69
|
export { encodeVideo, decodeVideo, fragmentVideo, VIDEO_MAX_FRAGMENT, type VideoMessage } from './lib/live/videoWire';
|
|
68
70
|
export type { VideoSource, EncodedUnit, VideoTrackInfo } from './lib/live/videoTrack';
|
|
69
71
|
export { RecordedVideoSource, type RecordedVideoSourceOptions } from './lib/recordings/videoSource';
|
|
@@ -77,25 +79,17 @@ export { parseKrc, parseKrcHeader, KRC_HEADER_BYTES } from './lib/recordings/krc
|
|
|
77
79
|
export type { RecordingInput } from './engine/createEngine';
|
|
78
80
|
export { exportRecording, exportRecordingTo, EXPORT_TYPES, type ExportPart, type RecordingSource } from './lib/recordings/export';
|
|
79
81
|
export type { EncryptedEnvelope, DeviceWrap, SealedKey, PasswordSealed } from './lib/live/crypto';
|
|
80
|
-
export { generateApiToken, splitApiKey, generateDeviceKeyPair, unwrapStreamKey, unwrapForDevice, wrapForDevice, projectWrapAad, streamKeyAad, bindKeyAad, randomKey, importStreamKey, sealUnderProjectKey, openUnderProjectKey, senderBindKey, senderBinding, verifySenderBinding, deviceFingerprint, hashToken, generateSalt, deriveKey, OPEN_STREAM_PASSWORD, deriveRawKeyBase64, makeKeyCheck, verifyKeyCheck, WORKBOOK_EXPORT_AAD, workbookBodyAad, workbookKeyAad,
|
|
82
|
+
export { generateApiToken, splitApiKey, generateDeviceKeyPair, unwrapStreamKey, unwrapForDevice, wrapForDevice, projectWrapAad, streamKeyAad, bindKeyAad, randomKey, importStreamKey, sealUnderProjectKey, openUnderProjectKey, senderBindKey, senderBinding, verifySenderBinding, deviceFingerprint, hashToken, generateSalt, deriveKey, OPEN_STREAM_PASSWORD, deriveRawKeyBase64, makeKeyCheck, verifyKeyCheck, WORKBOOK_EXPORT_AAD, workbookBodyAad, workbookKeyAad, projectConfigKeyAad, alertRuleAad, recoveryKeyAad, recoveryAttestationAad, sealWithKey, openWithKey, sealWithPassword, openWithPassword, recoveryCode, parseRecoveryCode, generateRecoveryKeyPair, recoveryPrivateKey, } from './lib/live/crypto';
|
|
81
83
|
export * from './rules/types';
|
|
82
84
|
export { validateRule, type RuleProblem } from './rules/validate';
|
|
83
85
|
export { thresholdOf } from './rules/threshold';
|
|
84
86
|
export { createRuleEvaluator, type RuleEvaluator, type RuleTarget, type AlertTransition, type RuleEvaluatorState, type LiveBlock } from './rules/evaluator';
|
|
85
|
-
export { footerLength, openFooter, openSealed, blockAad, type KhdFooter, type KhdBlock, type KhdChannel, type KhdFileId, type HistoryKind, type HistoryLevel } from './lib/historian/khd1';
|
|
86
|
-
export { warmHistoryDecoder } from './lib/historian/parquet';
|
|
87
|
-
export { blockCache, type BlockCache, type CacheDir } from './lib/historian/blockCache';
|
|
88
|
-
export { HistoryDataSource, splicePieces, clipPiece, slicePiece, type HistoryPiece } from './lib/data/historyDataSource';
|
|
89
|
-
export type { HistoryRangeView } from './engine/columns';
|
|
90
87
|
export { isClockAxis, formatClockTick, formatClockValue, setClockTimeZone, getClockTimeZone, subscribeClockTimeZone } from './lib/yAxisTicks';
|
|
91
|
-
export { readHistoryRange, readFooter, chooseLevel, pickSegments, coalesce, pool, RANGE_PARALLEL, HISTORY_PIXELS, type HistorySegmentRef, type HistoryReadOptions, type HistoryRange } from './lib/historian/reader';
|
|
92
|
-
export { exportHistoryTo, wideDay, f32text, isoMicros, MAX_WIDE_CELLS, MAX_PARQUET_VALUES, type HistoryExportFormat } from './lib/historian/export';
|
|
93
88
|
export { CycleRunner, CycleSet, cycleRuleChannels, type CycleRule, type Trigger as CycleTrigger, type Condition as CycleCondition, type CycleLimits, type CycleFlag, type CycleInstance, type CycleFound, type RuleDef, type CycleDefinition, parseCycleDefinitions } from './lib/cycles/evaluator';
|
|
94
89
|
export { CYCLE_TIME, readSource, findCycles, cutCycle, cycleTables, definitionChannels, kpiColumn, kpisOf, rowsCsv, type SourceColumns } from './lib/cycles/cut';
|
|
95
|
-
export {
|
|
96
|
-
export type { SegmentContext } from './engine/types';
|
|
90
|
+
export { KpiAcc, resetStep, newResetState, compareOp, kpiKey, localDay, zonedInstant, shiftDay, tzOffsetS, KPI_STATS, type CompareOp, type KpiStat, type KpiSpec, type Kpis, type DetectedSegment, type ResetState } from './lib/segments/rules';
|
|
97
91
|
export { referenceBands } from './charts/beacon';
|
|
98
92
|
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';
|
|
99
|
-
export { liveSegmentTracker,
|
|
93
|
+
export { liveSegmentTracker, type LiveSegmentAxis, type LiveSegmentEvent } from './lib/segments/liveAxis';
|
|
100
94
|
export * as analysis from './analysis';
|
|
101
95
|
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';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Cycle rules v2 (spec docs/superpowers/specs/2026-10-28-cycles-design.md, "Rules"): where a source is cut into cycles,
|
|
3
3
|
* and phases inside them. Boundaries and flags only; KPIs are the app's job. The collector runs the same semantics
|
|
4
|
-
* (packages/collector/src/kymoscope_collector/cycles.py), pinned by tests/vectors/cycle-rules-v2.json.
|
|
5
|
-
* (segment_definitions rule_v 1) keep running through ../segments/rules.ts RuleRunner.
|
|
4
|
+
* (packages/collector/src/kymoscope_collector/cycles.py), pinned by tests/vectors/cycle-rules-v2.json.
|
|
6
5
|
*
|
|
7
6
|
* Semantics:
|
|
8
7
|
* - A start fires when its trigger becomes true (a condition rising, or an event: change, cross, reset, clock,
|
|
@@ -5,8 +5,3 @@ import * as duckdb from '@duckdb/duckdb-wasm';
|
|
|
5
5
|
export declare function wasmModuleUrl(url: string): Promise<string>;
|
|
6
6
|
/** Lazily instantiate a single DuckDB-WASM database for this tab. */
|
|
7
7
|
export declare function getDuckDb(): Promise<duckdb.AsyncDuckDB>;
|
|
8
|
-
/** The DuckDB of getDuckDb() with the Parquet extension loaded (the browser build doesn't include it). It is loaded
|
|
9
|
-
* from this site (`/duckdb-ext/v<version>/wasm_eh/parquet.duckdb_extension.wasm`, DuckDB's own signed file copied
|
|
10
|
-
* into public/), never from extensions.duckdb.org. A failed load is retried on the next call.
|
|
11
|
-
* ponytail: same origin as the page; an SDK host that serves the app elsewhere copies that folder too. */
|
|
12
|
-
export declare function getParquetDuckDb(): Promise<duckdb.AsyncDuckDB>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Wire v2: KIND_BLOCK_SCHEMA carries the channel table once (the relay keeps the latest for viewers who join and
|
|
3
3
|
* puts it first in every recording chunk); KIND_BLOCK rows refer to it by id, with µs time deltas and byte-split
|
|
4
|
-
* values, deflate-compressed before sealing. Normative format: docs/
|
|
4
|
+
* values, deflate-compressed before sealing. Normative format: docs/wire-format.md;
|
|
5
5
|
* pinned by tests/vectors/block-v2.json; byte-compatible with packages/python/src/kymoscope/wire.py.
|
|
6
6
|
*/
|
|
7
7
|
import type { LiveColumnsBlock } from './buffer';
|
|
@@ -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
|
+
};
|
|
@@ -120,9 +120,6 @@ export declare function deviceFingerprint(publicKey: string): Promise<string>;
|
|
|
120
120
|
export declare const WORKBOOK_EXPORT_AAD = "kymoscope-workbook-export-v2";
|
|
121
121
|
export declare const workbookBodyAad: (workbookId: string, version: number) => string;
|
|
122
122
|
export declare const workbookKeyAad: (workbookId: string, projectId: string, epoch: number) => string;
|
|
123
|
-
/** A collector's day-history key sealed under the project key (resource_keys 'history_key'). Python twin:
|
|
124
|
-
* kymoscope.crypto.history_key_aad. */
|
|
125
|
-
export declare const historyKeyAad: (keyId: string, projectId: string, epoch: number) => string;
|
|
126
123
|
/** A project's config key (alert rules) sealed under the project key: resource_keys 'project_config', id = the project. */
|
|
127
124
|
export declare const projectConfigKeyAad: (projectId: string, epoch: number) => string;
|
|
128
125
|
/** An alert rule's kyr/1 body sealed under its project's config key: bound to the rule, its version and project. */
|
|
@@ -2,6 +2,7 @@ import { type MessageKey } from './wire';
|
|
|
2
2
|
import { type VideoMessage } from './videoWire';
|
|
3
3
|
import { type LastValue } from './blockWire';
|
|
4
4
|
import type { LiveColumnsBlock, LiveMessage } from './buffer';
|
|
5
|
+
import { type StreamIntegrity } from './chainWire';
|
|
5
6
|
/** What a relay message holds once opened. */
|
|
6
7
|
export type Decoded = {
|
|
7
8
|
type: 'video';
|
|
@@ -20,13 +21,20 @@ export type Decoded = {
|
|
|
20
21
|
| {
|
|
21
22
|
type: 'gap';
|
|
22
23
|
samples: number;
|
|
24
|
+
}
|
|
25
|
+
/** The stream's integrity checkpoints so far (see chainWire.ts). */
|
|
26
|
+
| {
|
|
27
|
+
type: 'integrity';
|
|
28
|
+
integrity: StreamIntegrity;
|
|
23
29
|
};
|
|
24
30
|
/**
|
|
25
31
|
* A stream's messages opened with `key` and handed to `emit` in the order they arrived (decrypted as they arrive, in
|
|
26
32
|
* parallel: a block landing before an older one would put time out of order in the buffer). A message that is bad,
|
|
27
33
|
* or whose key isn't available yet, is skipped. Channel tables (KIND_BLOCK_SCHEMA) are kept here.
|
|
28
34
|
*/
|
|
29
|
-
export declare function createIngest(key: MessageKey, emit: (d: Decoded) => void): (data: ArrayBuffer) => void
|
|
35
|
+
export declare function createIngest(key: MessageKey, emit: (d: Decoded) => void, streamId?: string): ((data: ArrayBuffer) => void) & {
|
|
36
|
+
reset(): void;
|
|
37
|
+
};
|
|
30
38
|
/** The buffers behind a block of samples, to hand it to another thread without copying them. */
|
|
31
39
|
export declare function transferables(d: Decoded): ArrayBuffer[];
|
|
32
40
|
/** Most bytes of samples a stream's worker lets wait for the page (about 6 s of 50 channels at 50 kHz). */
|
|
@@ -84,6 +84,9 @@ export interface PublisherOptions {
|
|
|
84
84
|
/** The stream password viewers type (spec 2026-10-31-stream-access-model); default: the API key's secret. 'open'
|
|
85
85
|
* streams take none: anyone watches them (a published password; not end-to-end encrypted). */
|
|
86
86
|
password?: string;
|
|
87
|
+
/** A password under 12 characters is refused (a general stream is listed for every signed-in user, so a short one
|
|
88
|
+
* can be guessed offline): true accepts that risk. */
|
|
89
|
+
allowShortPassword?: boolean;
|
|
87
90
|
/** The caller's own data stream a camera belongs to (required for kind 'camera'); its placement comes from it. */
|
|
88
91
|
parentStreamId?: string;
|
|
89
92
|
/** A camera's low layer (360p, for small panels and camera walls): `layer: 'low'` with `lowOf`, its high camera's
|
|
@@ -146,6 +149,9 @@ export declare class LivePublisher {
|
|
|
146
149
|
private projectId;
|
|
147
150
|
private e2ee;
|
|
148
151
|
private sid;
|
|
152
|
+
private chain;
|
|
153
|
+
/** Messages waiting for the checkpoint being sealed (see sendSealed). */
|
|
154
|
+
private held;
|
|
149
155
|
private salt;
|
|
150
156
|
private key;
|
|
151
157
|
/** A password stream's raw key, for device wraps (derivable from the secret anyway). */
|
|
@@ -207,8 +213,12 @@ export declare class LivePublisher {
|
|
|
207
213
|
send(kind: number, plaintext: Uint8Array): Promise<boolean>;
|
|
208
214
|
/** The sealed message send() would publish (what a recorder keeps), or null without a stream key yet. */
|
|
209
215
|
seal(kind: number, plaintext: Uint8Array): Promise<Uint8Array<ArrayBuffer> | null>;
|
|
210
|
-
/** Publish an already sealed message; false when the socket is down.
|
|
216
|
+
/** Publish an already sealed message; false when the socket is down. While a checkpoint is being sealed it waits
|
|
217
|
+
* for it (a few ms), so the wire keeps the order the checkpoint counts. */
|
|
211
218
|
sendSealed(message: Uint8Array<ArrayBuffer>): boolean;
|
|
219
|
+
/** Lane 0 (chainWire.ts): every message that went on the socket counts, and about once a second a checkpoint over
|
|
220
|
+
* them follows. */
|
|
221
|
+
private chained;
|
|
212
222
|
/** One recording-upload call with this stream's `pt.` token (supabase/functions/recording-upload/CONTRACT.md):
|
|
213
223
|
* what a BrowserRecorder needs. Rejects with a RegistryError. */
|
|
214
224
|
recordingUpload(body: Record<string, unknown>): Promise<any>;
|
|
@@ -15,6 +15,12 @@ export declare const RELAY_SUBPROTOCOL = "kymoscope-live.v1";
|
|
|
15
15
|
* held up the whole stream for everyone). The relay still answers with RELAY_SUBPROTOCOL.
|
|
16
16
|
*/
|
|
17
17
|
export declare const ACK_SUBPROTOCOL = "kymoscope-live.ack1";
|
|
18
|
+
/**
|
|
19
|
+
* Offered with ack1: the relay sends a marker ({"type":"probe","id":"…"}) every so many bytes and this viewer answers
|
|
20
|
+
* it at once ({"type":"ack","id":"…"}). A marker comes in order after the bytes before it, so an answer proves they were
|
|
21
|
+
* read (a count can be made up). Kymoscope's relay judges ack2 viewers by it and turns away viewers that offer neither.
|
|
22
|
+
*/
|
|
23
|
+
export declare const ACK2_SUBPROTOCOL = "kymoscope-live.ack2";
|
|
18
24
|
export type StreamStatus = 'subscribed' | 'closed' | 'error';
|
|
19
25
|
/** Where the relay lives and how to authenticate to it (host-provided). */
|
|
20
26
|
export interface LiveRelayConfig {
|
|
@@ -9,6 +9,7 @@ import type { ClockMap } from './clockMap';
|
|
|
9
9
|
* camera stopped, so its panel shows this instead of video. Any other notice (storage full) leaves the video playing. */
|
|
10
10
|
export declare const VIDEO_LIMIT_NOTICE = "Video limit reached this month";
|
|
11
11
|
/** What a viewer needs to join an encrypted relay stream (from the stream registry). */
|
|
12
|
+
import type { StreamIntegrity } from './chainWire';
|
|
12
13
|
export interface LiveStreamDescriptor {
|
|
13
14
|
id: string;
|
|
14
15
|
name: string;
|
|
@@ -105,6 +106,10 @@ export interface LiveConnection {
|
|
|
105
106
|
/** Samples dropped before the ring because this page couldn't keep up with the stream (its traces have a gap
|
|
106
107
|
* there); 0 or absent: none. */
|
|
107
108
|
droppedSamples?: number;
|
|
109
|
+
/** Its senders' integrity checkpoints as checked here (see chainWire.ts); absent: none came yet (an older sender).
|
|
110
|
+
* `broken` > 0: messages went missing, came twice, out of order or from elsewhere between two checkpoints. The
|
|
111
|
+
* state changes for the first check and for each broken one; `verified` is as of the last state change. */
|
|
112
|
+
integrity?: StreamIntegrity;
|
|
108
113
|
/** The plan-limit banner it was opened with (LiveStreamDescriptor.limit_notice); a Camera panel shows it. */
|
|
109
114
|
limitNotice?: string | null;
|
|
110
115
|
}
|
|
@@ -10,6 +10,8 @@ export declare const KIND_BLOCK_SCHEMA = 5;
|
|
|
10
10
|
export declare const KIND_VIDEO = 6;
|
|
11
11
|
/** Each channel's last value and its time, against a KIND_BLOCK_SCHEMA (see blockWire.ts). */
|
|
12
12
|
export declare const KIND_LAST_VALUES = 7;
|
|
13
|
+
/** An integrity checkpoint over the messages before it in its lane (see chainWire.ts). */
|
|
14
|
+
export declare const KIND_CHAIN = 8;
|
|
13
15
|
export declare const KEY_ID_FLAG = 128;
|
|
14
16
|
export interface SealedMessage {
|
|
15
17
|
kind: number;
|
|
@@ -15,7 +15,6 @@ export interface ExportOptions {
|
|
|
15
15
|
export declare const EXPORT_TYPES: {
|
|
16
16
|
readonly csv: "text/csv";
|
|
17
17
|
readonly mf4: "application/octet-stream";
|
|
18
|
-
readonly parquet: "application/vnd.apache.parquet";
|
|
19
18
|
};
|
|
20
19
|
/**
|
|
21
20
|
* A recording as a CSV or MF4 file, built in the browser from its encrypted chunks and handed to `write` piece by
|
|
@@ -1,62 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* ≥ 2 segments (a single reference gives a delta, never deviations; as compareToReference): `onEvent` fires only on
|
|
8
|
-
* transitions (open, close, deviation start once it lasted minDeviationS, deviation end after minDeviationS back in band). Work is per block: a few arrays per
|
|
9
|
-
* block, nothing allocated per sample.
|
|
2
|
+
* A live stream's cycles: on every ingested block the cycle rule (rules v2) runs over the new samples, and the open
|
|
3
|
+
* cycle's X on the alignment axis is written into the ring as a computed column (`column`), restarting at each cycle,
|
|
4
|
+
* so the beacon chart (cycles on that column) draws the running cycle with no React at data rate. `onEvent` fires on
|
|
5
|
+
* transitions only (a cycle opens, a cycle closes). Work is per block: a few arrays per block, nothing allocated per
|
|
6
|
+
* sample.
|
|
10
7
|
*/
|
|
11
8
|
import { type LiveBuffer } from '../live/buffer';
|
|
12
9
|
import { type AlignAxis } from './align';
|
|
13
|
-
import {
|
|
10
|
+
import type { DetectedSegment } from './rules';
|
|
14
11
|
import { type CycleRule } from '../cycles/evaluator';
|
|
15
|
-
export declare const DELTA_SUFFIX = " \u0394";
|
|
16
|
-
export interface LiveReference {
|
|
17
|
-
grid: Float64Array;
|
|
18
|
-
/** Per channel: mean and band edges on the grid, and the segments behind each point (the band counts where n ≥ 2). */
|
|
19
|
-
channels: Map<string, {
|
|
20
|
-
mean: Float32Array;
|
|
21
|
-
lo: Float32Array;
|
|
22
|
-
hi: Float32Array;
|
|
23
|
-
n: ArrayLike<number>;
|
|
24
|
-
}>;
|
|
25
|
-
}
|
|
26
12
|
export type LiveSegmentEvent = {
|
|
27
13
|
type: 'open';
|
|
28
14
|
tstart: number;
|
|
29
15
|
} | {
|
|
30
16
|
type: 'close';
|
|
31
17
|
segment: DetectedSegment;
|
|
32
|
-
} | {
|
|
33
|
-
type: 'deviation';
|
|
34
|
-
t0: number;
|
|
35
|
-
channels: string[];
|
|
36
|
-
} | {
|
|
37
|
-
type: 'deviation-end';
|
|
38
|
-
t0: number;
|
|
39
|
-
t1: number;
|
|
40
|
-
channels: string[];
|
|
41
18
|
};
|
|
42
19
|
export interface LiveSegmentAxis {
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
/** A cycle rule (rules v2) instead of `rule` ("Follow the running cycle" on a cycle rule): its cycles open and close
|
|
46
|
-
* the axis; KPIs are not computed live for it. */
|
|
47
|
-
cycle?: CycleRule;
|
|
48
|
-
kpis?: KpiSpec[];
|
|
20
|
+
/** The cycle rule ("Follow the running cycle"): its cycles open and close the axis; KPIs are not computed live. */
|
|
21
|
+
cycle: CycleRule;
|
|
49
22
|
axis: AlignAxis;
|
|
50
23
|
/** The computed X column written into the ring, and its unit. */
|
|
51
24
|
column: string;
|
|
52
25
|
unit: string;
|
|
53
|
-
/** The open segment's start when the ring may no longer hold it (the collector's open segment), else null. */
|
|
54
|
-
start?: number | null;
|
|
55
|
-
reference?: LiveReference | null;
|
|
56
26
|
/** Also report the cycles already in the ring when it starts (open / close events for them); default: only new ones. */
|
|
57
27
|
replay?: boolean;
|
|
58
|
-
/** A deviation is reported once out of band this long (s); default 5. */
|
|
59
|
-
minDeviationS?: number;
|
|
60
28
|
onEvent?: (e: LiveSegmentEvent) => void;
|
|
61
29
|
}
|
|
62
30
|
export declare function liveSegmentTracker(cfg: LiveSegmentAxis): {
|
|
@@ -1,31 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* segments.py), pinned by tests/vectors/segment-rules-v1.json. Semantics: the plan's Formats "Rule JSON". A NaN value
|
|
6
|
-
* never changes a rule. splitLaps (../beacon.ts) is the edge rule `reset` through resetStep.
|
|
2
|
+
* Helpers shared by the cycle rules (../cycles/evaluator.ts, pinned by tests/vectors/cycle-rules-v2.json), the cycle
|
|
3
|
+
* cut and the analysis: comparisons, the reset rule, zones and KPIs. A NaN value never changes a rule. splitLaps
|
|
4
|
+
* (../beacon.ts) is the reset rule through resetStep.
|
|
7
5
|
*/
|
|
8
6
|
export type CompareOp = '>' | '>=' | '<' | '<=' | '==' | '!=';
|
|
9
|
-
export type EdgeOn = 'change' | 'rise' | 'fall' | 'reset';
|
|
10
|
-
export type SegmentRule = {
|
|
11
|
-
kind: 'manual';
|
|
12
|
-
} | {
|
|
13
|
-
kind: 'edge';
|
|
14
|
-
channel: string;
|
|
15
|
-
on: EdgeOn;
|
|
16
|
-
value?: number;
|
|
17
|
-
} | {
|
|
18
|
-
kind: 'condition';
|
|
19
|
-
channel: string;
|
|
20
|
-
op: CompareOp;
|
|
21
|
-
value: number;
|
|
22
|
-
hysteresis?: number;
|
|
23
|
-
min_s?: number;
|
|
24
|
-
} | {
|
|
25
|
-
kind: 'window';
|
|
26
|
-
starts: string[];
|
|
27
|
-
tz: string;
|
|
28
|
-
};
|
|
29
7
|
export type KpiStat = 'min' | 'max' | 'mean' | 'integral' | 'first' | 'last' | 'delta';
|
|
30
8
|
export declare const KPI_STATS: KpiStat[];
|
|
31
9
|
export interface KpiSpec {
|
|
@@ -42,7 +20,6 @@ export interface DetectedSegment {
|
|
|
42
20
|
flags?: Array<'late' | 'too-long' | 'too-short'>;
|
|
43
21
|
}
|
|
44
22
|
export declare const kpiKey: (k: KpiSpec) => string;
|
|
45
|
-
export declare const ruleChannels: (r: SegmentRule) => string[];
|
|
46
23
|
export declare function compareOp(op: CompareOp, v: number, c: number): boolean;
|
|
47
24
|
/** A cycle's running state for resetStep; prev NaN: nothing seen yet. */
|
|
48
25
|
export interface ResetState {
|
|
@@ -73,19 +50,3 @@ export declare class KpiAcc {
|
|
|
73
50
|
add(t: number, v: number): void;
|
|
74
51
|
value(stat: KpiStat): number | null;
|
|
75
52
|
}
|
|
76
|
-
export declare class RuleRunner {
|
|
77
|
-
#private;
|
|
78
|
-
readonly rule: SegmentRule;
|
|
79
|
-
readonly kpis: KpiSpec[];
|
|
80
|
-
constructor(rule: SegmentRule, kpis?: KpiSpec[]);
|
|
81
|
-
/** Continue a segment that started at `tstart`, before the data fed from now on (a live ring that no longer holds it). */
|
|
82
|
-
assumeOpen(tstart: number): void;
|
|
83
|
-
/**
|
|
84
|
-
* Samples in time order; returns the segments they closed. `col(name)`: the column of a channel, aligned with `t`
|
|
85
|
-
* (NaN where it has no value), or undefined. `each(i, start)`: after sample i, the start of the open segment (a
|
|
86
|
-
* condition still shorter than min_s counts), null outside one.
|
|
87
|
-
*/
|
|
88
|
-
feed(t: ArrayLike<number>, col: (name: string) => ArrayLike<number> | undefined, each?: (i: number, start: number | null) => void): DetectedSegment[];
|
|
89
|
-
/** The open segment so far (its KPIs up to the last sample; tend null), or null. A condition shows once it lasted min_s. */
|
|
90
|
-
open(): DetectedSegment | null;
|
|
91
|
-
}
|
|
@@ -4,7 +4,6 @@ import type { PanelChartSettings } from '../panelChartSettings';
|
|
|
4
4
|
import type { DashboardPanel, DashboardPanelKind } from '../../components/dashboardGridLayout';
|
|
5
5
|
import type { BeaconConfig } from '../beacon';
|
|
6
6
|
import type { MathChannel } from '../mathChannels/types';
|
|
7
|
-
import type { SegmentContext } from '../../engine/types';
|
|
8
7
|
import { type CycleDefinition } from '../cycles/evaluator';
|
|
9
8
|
type ExportedWorksheet = {
|
|
10
9
|
name: string;
|
|
@@ -35,8 +34,6 @@ export interface WorkbookBody {
|
|
|
35
34
|
liveWindowSeconds: number | null;
|
|
36
35
|
/** Lap / cycle split, without the dataset it came from. */
|
|
37
36
|
laps: BeaconConfig | null;
|
|
38
|
-
/** The Segments panel's ids (Historian phase 5); absent in older bodies. */
|
|
39
|
-
segments?: SegmentContext | null;
|
|
40
37
|
/** Cycle and phase rules (lib/cycles); absent in older bodies. */
|
|
41
38
|
cycles?: CycleDefinition[];
|
|
42
39
|
}
|
|
@@ -82,8 +79,6 @@ export interface ParsedWorkbook extends ImportResult {
|
|
|
82
79
|
mathChannels: WorkbookChannel[];
|
|
83
80
|
liveWindowSeconds: number | null | undefined;
|
|
84
81
|
laps: BeaconConfig | null | undefined;
|
|
85
|
-
/** Undefined: a body from before segments (keep the current context). */
|
|
86
|
-
segments: SegmentContext | null | undefined;
|
|
87
82
|
/** Cycle and phase rules; [] in bodies without them. */
|
|
88
83
|
cycles: CycleDefinition[];
|
|
89
84
|
}
|
|
@@ -112,7 +107,6 @@ export declare function buildWorkbookBody(s: {
|
|
|
112
107
|
}>;
|
|
113
108
|
liveWindowSeconds: number | null;
|
|
114
109
|
laps: BeaconConfig | null;
|
|
115
|
-
segments?: SegmentContext | null;
|
|
116
110
|
cycles?: CycleDefinition[];
|
|
117
111
|
}): WorkbookBody;
|
|
118
112
|
export declare function buildWorkspaceExportBlob(worksheets: Worksheet[]): Blob;
|
|
@@ -27,7 +27,7 @@ export declare function formatTick(v: number, step: number): string;
|
|
|
27
27
|
*/
|
|
28
28
|
export declare function formatValue(v: number): string;
|
|
29
29
|
/** X reads as clock time: a seconds axis ("Name (s)") whose both ends are Unix times of 2000–2100 (collector streams
|
|
30
|
-
* and
|
|
30
|
+
* and recordings carry Unix seconds in ElapsedTime). */
|
|
31
31
|
export declare function isClockAxis(xLabel: string, lo: number, hi: number): boolean;
|
|
32
32
|
export declare function setClockTimeZone(tz: string | undefined): void;
|
|
33
33
|
export declare const getClockTimeZone: () => string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kymoscope/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "The Kymoscope data engine and charts for the browser: import large measurement files, plot them, stream live data end-to-end encrypted.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"homepage": "https://kymoscope.com/docs/introduction",
|