@runtypelabs/voice 0.2.4 → 0.4.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.
@@ -0,0 +1,100 @@
1
+ type VoiceStatus = 'idle' | 'connecting' | 'listening' | 'thinking' | 'speaking' | 'error';
2
+ type InterruptionMode = 'none' | 'cancel' | 'barge-in';
3
+ interface TranscriptEntry {
4
+ readonly role: 'user' | 'assistant';
5
+ readonly content: string;
6
+ readonly timestamp: number;
7
+ readonly isFinal?: boolean;
8
+ readonly turnId?: string;
9
+ /**
10
+ * The reply is still being spoken, so `content` holds the clauses committed so
11
+ * far. A later snapshot replaces this entry with the authoritative transcript,
12
+ * or clears the flag in place when the caller stops the reply.
13
+ */
14
+ readonly partial?: boolean;
15
+ }
16
+ interface VoiceMetrics {
17
+ readonly llmMs?: number;
18
+ readonly ttsMs?: number;
19
+ readonly firstAudioMs?: number;
20
+ readonly totalMs?: number;
21
+ /**
22
+ * Turn start to the first synthesis request. Below `llmMs` when the engine spoke
23
+ * clauses while the reply was still generating, and equal to it otherwise.
24
+ */
25
+ readonly firstSynthesisMs?: number;
26
+ /** True when the reply was synthesized clause by clause, so `ttsMs` covers overlapped work. */
27
+ readonly incremental?: boolean;
28
+ }
29
+ /** File metadata for a previewable artifact, mirroring the unified `artifact_start.file` field. */
30
+ interface VoiceArtifactFile {
31
+ readonly path: string;
32
+ readonly mimeType: string;
33
+ readonly language?: string;
34
+ }
35
+ /**
36
+ * An artifact the agent produced during a call, assembled from the additive
37
+ * `artifact` wire message. Artifacts arrive beside speech and are never spoken.
38
+ */
39
+ interface VoiceArtifact {
40
+ readonly id: string;
41
+ readonly turnId: string | null;
42
+ readonly executionId?: string;
43
+ readonly artifactType: 'markdown' | 'component';
44
+ readonly title?: string;
45
+ readonly file?: VoiceArtifactFile;
46
+ readonly content: string;
47
+ readonly component?: string;
48
+ readonly props?: Record<string, unknown>;
49
+ readonly status: 'streaming' | 'complete';
50
+ }
51
+ /** The conversation this call is attached to, reported by the server once the call opens. */
52
+ interface VoiceSession {
53
+ readonly sessionId: string;
54
+ readonly conversationId: string;
55
+ }
56
+ interface VoiceSnapshot {
57
+ readonly status: VoiceStatus;
58
+ readonly transcript: readonly TranscriptEntry[];
59
+ readonly interimTranscript: string | null;
60
+ readonly metrics: VoiceMetrics | null;
61
+ readonly audioLevel: number;
62
+ readonly isMuted: boolean;
63
+ readonly error: string | null;
64
+ readonly errorDetails?: {
65
+ code: string;
66
+ serverId?: string;
67
+ serverName: string;
68
+ diagnosticId: string;
69
+ };
70
+ readonly interruptionMode: InterruptionMode;
71
+ readonly canCancel: boolean;
72
+ readonly artifacts: readonly VoiceArtifact[];
73
+ /** Survives `endCall` so a host can reopen the same conversation; null until the server reports it. */
74
+ readonly session: VoiceSession | null;
75
+ }
76
+ interface VoiceClientOptions {
77
+ agentId: string;
78
+ /** Disable when the transcript consumer only supports sequential pipeline turns. */
79
+ fullDuplex?: boolean;
80
+ /** Optional custom audio source; the client owns and stops the returned tracks. */
81
+ audioSource?: () => Promise<MediaStream>;
82
+ /** Browser client token, or a getter called once per call to obtain a fresh token. */
83
+ clientToken: string | (() => string | Promise<string>);
84
+ /** Absolute API base URL, including any proxy path prefix. Defaults to https://api.runtype.com. */
85
+ apiUrl?: string;
86
+ /**
87
+ * Declares the `artifacts` capability, so the server sends `artifact` messages
88
+ * and the client assembles `snapshot.artifacts`. Off by default, which keeps an
89
+ * existing embed's wire byte-identical.
90
+ */
91
+ artifacts?: boolean;
92
+ /** Reuses an existing client session's conversation. Overrides the id remembered from a previous call. */
93
+ sessionId?: string;
94
+ /** Proof minted by client/init; resolve from the host's token-scoped visitor store on every call. */
95
+ visitorToken?: string | (() => string | undefined | Promise<string | undefined>);
96
+ /** Observe the server's conversation so a host can reuse it for text. Never contains visitor credentials. */
97
+ onSession?: (session: VoiceSession) => void;
98
+ }
99
+
100
+ export type { InterruptionMode as I, TranscriptEntry as T, VoiceClientOptions as V, VoiceSnapshot as a, VoiceArtifact as b, VoiceArtifactFile as c, VoiceMetrics as d, VoiceSession as e, VoiceStatus as f };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runtypelabs/voice",
3
- "version": "0.2.4",
3
+ "version": "0.4.0",
4
4
  "description": "Runtype browser voice client with React and Persona adapters",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,40 +0,0 @@
1
- type VoiceStatus = 'idle' | 'connecting' | 'listening' | 'thinking' | 'speaking' | 'error';
2
- type InterruptionMode = 'none' | 'cancel' | 'barge-in';
3
- interface TranscriptEntry {
4
- readonly role: 'user' | 'assistant';
5
- readonly content: string;
6
- readonly timestamp: number;
7
- readonly turnId?: string;
8
- }
9
- interface VoiceMetrics {
10
- readonly llmMs?: number;
11
- readonly ttsMs?: number;
12
- readonly firstAudioMs?: number;
13
- readonly totalMs?: number;
14
- }
15
- interface VoiceSnapshot {
16
- readonly status: VoiceStatus;
17
- readonly transcript: readonly TranscriptEntry[];
18
- readonly interimTranscript: string | null;
19
- readonly metrics: VoiceMetrics | null;
20
- readonly audioLevel: number;
21
- readonly isMuted: boolean;
22
- readonly error: string | null;
23
- readonly errorDetails?: {
24
- code: string;
25
- serverId?: string;
26
- serverName: string;
27
- diagnosticId: string;
28
- };
29
- readonly interruptionMode: InterruptionMode;
30
- readonly canCancel: boolean;
31
- }
32
- interface VoiceClientOptions {
33
- agentId: string;
34
- /** Browser client token, or a getter called once per call to obtain a fresh token. */
35
- clientToken: string | (() => string | Promise<string>);
36
- /** Absolute API base URL, including any proxy path prefix. Defaults to https://api.runtype.com. */
37
- apiUrl?: string;
38
- }
39
-
40
- export type { InterruptionMode as I, TranscriptEntry as T, VoiceClientOptions as V, VoiceSnapshot as a, VoiceMetrics as b, VoiceStatus as c };
@@ -1,40 +0,0 @@
1
- type VoiceStatus = 'idle' | 'connecting' | 'listening' | 'thinking' | 'speaking' | 'error';
2
- type InterruptionMode = 'none' | 'cancel' | 'barge-in';
3
- interface TranscriptEntry {
4
- readonly role: 'user' | 'assistant';
5
- readonly content: string;
6
- readonly timestamp: number;
7
- readonly turnId?: string;
8
- }
9
- interface VoiceMetrics {
10
- readonly llmMs?: number;
11
- readonly ttsMs?: number;
12
- readonly firstAudioMs?: number;
13
- readonly totalMs?: number;
14
- }
15
- interface VoiceSnapshot {
16
- readonly status: VoiceStatus;
17
- readonly transcript: readonly TranscriptEntry[];
18
- readonly interimTranscript: string | null;
19
- readonly metrics: VoiceMetrics | null;
20
- readonly audioLevel: number;
21
- readonly isMuted: boolean;
22
- readonly error: string | null;
23
- readonly errorDetails?: {
24
- code: string;
25
- serverId?: string;
26
- serverName: string;
27
- diagnosticId: string;
28
- };
29
- readonly interruptionMode: InterruptionMode;
30
- readonly canCancel: boolean;
31
- }
32
- interface VoiceClientOptions {
33
- agentId: string;
34
- /** Browser client token, or a getter called once per call to obtain a fresh token. */
35
- clientToken: string | (() => string | Promise<string>);
36
- /** Absolute API base URL, including any proxy path prefix. Defaults to https://api.runtype.com. */
37
- apiUrl?: string;
38
- }
39
-
40
- export type { InterruptionMode as I, TranscriptEntry as T, VoiceClientOptions as V, VoiceSnapshot as a, VoiceMetrics as b, VoiceStatus as c };