@proj-airi/trace-kit 0.0.0-stage → 0.15.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,79 @@
1
+ import { V as TraceRecordInput, x as TraceProfileDefinition, z as TraceRecord } from "../clock-CewQJzn8.mjs";
2
+ import { b as TraceReader, p as TimelineState } from "../types-Fp54Yi6b.mjs";
3
+ //#region src/testing/voice-turn.d.ts
4
+ /**
5
+ * A real recording: the level and the VAD probability of each 32 ms detector window of 5.3 s of speech.
6
+ *
7
+ * The values come from the AIRI Silero VAD model and `levelOf` of stage-ui, run on
8
+ * `cases/long-leading-silence/input.test.wav` of `@proj-airi/testing-audio`. The probability is near 0 in silence,
9
+ * jumps to near 1 within one or two windows, and dips between words. The speech starts at 884 ms.
10
+ */
11
+ declare const LONG_LEADING_SILENCE: {
12
+ intervalMs: number;
13
+ times: number[];
14
+ level: number[];
15
+ probability: number[];
16
+ };
17
+ /** The trace clock times of the voice turn of {@link voiceTurnRecords}, in milliseconds. */
18
+ declare const VOICE_TURN: {
19
+ readonly inputStart: 200;
20
+ readonly speechStart: 1084;
21
+ readonly inputEnd: 5500;
22
+ readonly playbackStart: 7000;
23
+ readonly playbackEnd: 10000;
24
+ /** A second model request starts here and stays open. */
25
+ readonly openRequestStart: 10200;
26
+ readonly end: 12000;
27
+ };
28
+ /**
29
+ * Records of one voice turn, for tests and stories of trace views. The trace has every kind of item that the IO
30
+ * tracer draws:
31
+ *
32
+ * - A voice input with the level and the VAD probability of {@link LONG_LEADING_SILENCE}, and two speech segments.
33
+ * - A failed speech recognition and its retry.
34
+ * - A chat turn, a model request with tokens and a first chunk, and a labelled tool call.
35
+ * - A speech output, a TTS request, and a playback with a level series.
36
+ * - Participant states, floor instants, and a model request that is still open at the end.
37
+ */
38
+ declare function voiceTurnRecords(): TraceRecordInput[];
39
+ //#endregion
40
+ //#region src/testing/index.d.ts
41
+ /**
42
+ * Helpers for tests and stories that need trace records. Production code must not import this module.
43
+ */
44
+ interface RecordStamperOptions {
45
+ /** @default 'window:main' */
46
+ source?: string;
47
+ /** @default 'e1' */
48
+ epoch?: string;
49
+ /** The clock of an input without its own clock. @default 'mono:collector' */
50
+ clock?: string;
51
+ }
52
+ /**
53
+ * Returns a function that completes record inputs as the records of one source epoch, with `seq` from 0.
54
+ *
55
+ * @example
56
+ * const stamp = createRecordStamper({ source: 'tab:a' })
57
+ * stamp({ type: 'span.begin', ts: 0, track: 'agents/agent/llm', spanId: 's', name: 'chat' })
58
+ * // => { clock: 'mono:collector', type: 'span.begin', ..., source: 'tab:a', epoch: 'e1', seq: 0 }
59
+ */
60
+ declare function createRecordStamper(options?: RecordStamperOptions): (input: TraceRecordInput) => TraceRecord;
61
+ interface ReadTimelineOptions extends RecordStamperOptions {
62
+ /** Profiles whose definitions come before the inputs, so tracks have their definitions. @default [] */
63
+ profiles?: TraceProfileDefinition[];
64
+ }
65
+ /**
66
+ * Reads record inputs into the timeline state that a viewer sees, with the definitions of `profiles` first.
67
+ *
68
+ * @example
69
+ * const { state } = readTimeline([{ type: 'span.begin', ts: 0, track: 'agents/agent/llm', spanId: 's', name: 'chat' }], { profiles: [agentProfile] })
70
+ * state.spans.size
71
+ * // => 1
72
+ */
73
+ declare function readTimeline(inputs: TraceRecordInput[], options?: ReadTimelineOptions): {
74
+ state: TimelineState;
75
+ indexes: TraceReader['indexes'];
76
+ records: TraceRecord[];
77
+ };
78
+ //#endregion
79
+ export { LONG_LEADING_SILENCE, ReadTimelineOptions, RecordStamperOptions, VOICE_TURN, createRecordStamper, readTimeline, voiceTurnRecords };