@ravi-os/voice 0.0.0-stage → 0.261128.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/README.md CHANGED
@@ -1,3 +1,56 @@
1
- # Temporary Holding Version
1
+ # @ravi-os/voice
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Browser kit for Ravi voice calls. A call sits on an existing Ravi session: the
4
+ session does the thinking and the work, the call only carries voice. Built on
5
+ `@ravi-os/sdk` (`ravi.voice.calls.*` and the `voice/{call}` stream).
6
+
7
+ ```ts
8
+ import { createRaviVoice, pushToTalk, autoplayReplies } from "@ravi-os/voice";
9
+
10
+ // A device key from `ravi voice devices pair --label phone --contact <id> --session main --execute`
11
+ const voice = createRaviVoice({ baseUrl: "https://my-ravi.example", contextKey: DEVICE_KEY });
12
+
13
+ const call = await voice.start("main", { mode: "push" });
14
+ call.on("user.transcript", (e) => showUser(e.data.text));
15
+ call.on("agent.transcript", (e) => showAgent(e.data.text));
16
+ call.on("turn.approval_requested", (e) => askTap(e.data.approvalId, e.data.text));
17
+ void call.follow(); // resumes from the last seq after a drop
18
+
19
+ const ptt = pushToTalk(call);
20
+ button.onpointerdown = () => ptt.start();
21
+ button.onpointerup = () => ptt.stop();
22
+ autoplayReplies(call);
23
+ ```
24
+
25
+ ## Modes
26
+
27
+ | Mode | How audio travels | Kit helper |
28
+ |---|---|---|
29
+ | `push` | one clip per press; reply clip fetched with `call.audio(item)` | `pushToTalk`, `autoplayReplies` |
30
+ | `live` | WebRTC straight to the live model; the session works behind it | `connectLive(voice, session)` |
31
+ | `handsfree` | a LiveKit room with the `ravi-voice` worker (needs `livekit-client`) | `joinRoom(call)` |
32
+ | `mock` | text only, for tests | `call.say(text)` |
33
+
34
+ ## Configuration
35
+
36
+ Voice, language, models, transcription and spend limits live in **voice profiles** on the daemon.
37
+ `voice.profiles()` and `voice.voices()` list them; an operator, or a key issued with
38
+ `mutate:voice:profiles.*`, manages them through `client.voice.profiles.*`. Device keys only read.
39
+
40
+ A call may change its profile's `voice`, `language`, `ttsModel` or `liveVoice` when the profile lists
41
+ the field in `overridable` (closed by default), and only with voices in `allowedVoices` when set:
42
+
43
+ ```ts
44
+ const call = await voice.start("main", { profile: "atendimento", voice: "<voice id>", language: "en" });
45
+ ```
46
+
47
+ `pushToTalk` tells the call when the person presses and releases (`call.activity("speaking" | "quiet")`),
48
+ so a profile with `delivery: when_idle` holds its replies until they stop. Use `call.activity` yourself
49
+ with your own voice-activity detection.
50
+
51
+ Approvals are taps only: `call.approve(id)` sends the version and digest the
52
+ call showed, so a request that changed since is refused. Voice can cancel or
53
+ deny, never approve.
54
+
55
+ `call.silence()` stops speech, `call.cancelTurn()` cancels this call's running
56
+ turn, `call.end()` ends the call (work already running keeps going).
package/dist/call.d.ts ADDED
@@ -0,0 +1,101 @@
1
+ import { RaviClient, RaviStreamClient } from "@ravi-os/sdk";
2
+ import type { VoiceCallStreamPayload } from "@ravi-os/sdk/streaming";
3
+ import type { VoiceCallsStartReturn } from "@ravi-os/sdk/types";
4
+ export type VoiceMode = "push" | "live" | "handsfree" | "mock";
5
+ export type VoiceEvent = VoiceCallStreamPayload;
6
+ export type VoiceEventType = VoiceEvent["type"];
7
+ export interface RaviVoiceConfig {
8
+ /** Base URL of the Ravi gateway, e.g. `http://127.0.0.1:7777`. */
9
+ baseUrl: string;
10
+ /** A device key from `ravi voice devices pair` (or any runtime key allowed to call). */
11
+ contextKey: string;
12
+ fetch?: typeof fetch;
13
+ }
14
+ export interface OpenApproval {
15
+ approvalId: string;
16
+ version: number;
17
+ digest: string;
18
+ text: string;
19
+ }
20
+ type Listener = (event: VoiceEvent) => void | Promise<void>;
21
+ /**
22
+ * Options for opening a call. `voice`, `language`, `ttsModel` and `liveVoice` change the profile for
23
+ * this call only, and only when the profile lists them in `overridable` (the daemon refuses others
24
+ * with `VOICE_OVERRIDE_FORBIDDEN`). They need a daemon and an `@ravi-os/sdk` that know them.
25
+ */
26
+ export interface StartCallOptions {
27
+ mode?: VoiceMode;
28
+ profile?: string;
29
+ offer?: string;
30
+ voice?: string;
31
+ language?: string;
32
+ ttsModel?: string;
33
+ liveVoice?: string;
34
+ }
35
+ /** Whether the person is talking; holds `when_idle` replies until they stop. */
36
+ export type VoiceActivity = "speaking" | "quiet";
37
+ /** The two SDK clients a voice app needs, built from one key. */
38
+ export declare function createRaviVoice(config: RaviVoiceConfig): {
39
+ client: RaviClient;
40
+ stream: RaviStreamClient;
41
+ /** Sessions this key may open a call on. */
42
+ targets: () => Promise<import("@ravi-os/sdk").VoiceTargetsListReturn>;
43
+ /** Voice profiles (voice, language, models, limits) this daemon has. */
44
+ profiles: () => Promise<import("@ravi-os/sdk").VoiceProfilesListReturn>;
45
+ /** ElevenLabs voices a profile or an allowed override can use. */
46
+ voices: (search?: string) => Promise<import("@ravi-os/sdk").VoiceVoicesListReturn>;
47
+ /**
48
+ * Open a call on a session. For `live` pass the WebRTC offer (see
49
+ * `connectLive`); for `handsfree` join the returned room (see `joinRoom`).
50
+ */
51
+ start(session: string, options?: StartCallOptions): Promise<RaviVoiceCall>;
52
+ /** Reattach to a call you already have (e.g. after a page reload). */
53
+ attach(callId: string, lastSeq?: number): RaviVoiceCall;
54
+ };
55
+ /**
56
+ * One call. `follow()` keeps the event stream open and resumes from the last
57
+ * `seq` after a drop; `on()` subscribes to event types.
58
+ */
59
+ export declare class RaviVoiceCall {
60
+ readonly client: RaviClient;
61
+ private readonly stream;
62
+ readonly id: string;
63
+ readonly info: VoiceCallsStartReturn;
64
+ private lastSeq;
65
+ private listeners;
66
+ private abort;
67
+ private approvals;
68
+ constructor(client: RaviClient, stream: RaviStreamClient, info: VoiceCallsStartReturn);
69
+ /** Subscribe to one event type, or `*` for all. Returns the unsubscribe function. */
70
+ on(type: VoiceEventType | "*", listener: Listener): () => void;
71
+ /** Requests waiting for a tap in this call. */
72
+ openApprovals(): OpenApproval[];
73
+ /** Follow the call until it ends or `close()` is called, reconnecting with backoff. */
74
+ follow(): Promise<void>;
75
+ /** Stop following (the call keeps running; use `end()` to end it). */
76
+ close(): void;
77
+ say(text: string): Promise<import("@ravi-os/sdk").VoiceCallsSendReturn>;
78
+ /** Push-to-talk: send one recorded clip. */
79
+ push(clip: Blob): Promise<import("@ravi-os/sdk").VoiceCallsPushReturn>;
80
+ /**
81
+ * Tell the call whether the person is talking. `pushToTalk` sends it on press and release; call it
82
+ * yourself with your own voice-activity detection. Resolves to `null` on an SDK without it.
83
+ */
84
+ activity(state: VoiceActivity): Promise<unknown>;
85
+ /** Stop speaking now; running work continues in the session. */
86
+ silence(): Promise<import("@ravi-os/sdk").VoiceCallsSilenceReturn>;
87
+ cancelTurn(turn?: string): Promise<import("@ravi-os/sdk").VoiceCallsCancelTurnReturn>;
88
+ /** Approve with a tap. Sends the version and digest the call showed, so a changed request is refused. */
89
+ approve(approvalId: string): Promise<import("@ravi-os/sdk").VoiceCallsApproveReturn>;
90
+ deny(approvalId: string): Promise<import("@ravi-os/sdk").VoiceCallsDenyReturn>;
91
+ /** Fetch a synthesized clip named in `agent.transcript.data.audio.item`. */
92
+ audio(item: string): Promise<Blob>;
93
+ connect(offer?: string): Promise<import("@ravi-os/sdk").VoiceCallsConnectReturn>;
94
+ end(): Promise<import("@ravi-os/sdk").VoiceCallsEndReturn>;
95
+ private track;
96
+ private reportListenerError;
97
+ private dispatch;
98
+ }
99
+ export declare function blobToBase64(blob: Blob): Promise<string>;
100
+ export declare function base64ToBlob(b64: string, mime: string): Blob;
101
+ export {};
package/dist/call.js ADDED
@@ -0,0 +1,209 @@
1
+ import { RaviClient, RaviStreamClient, createHttpTransport } from "@ravi-os/sdk";
2
+ /** The two SDK clients a voice app needs, built from one key. */
3
+ export function createRaviVoice(config) {
4
+ const client = new RaviClient(createHttpTransport(config));
5
+ const stream = new RaviStreamClient(config);
6
+ return {
7
+ client,
8
+ stream,
9
+ /** Sessions this key may open a call on. */
10
+ targets: () => client.voice.targets.list(),
11
+ /** Voice profiles (voice, language, models, limits) this daemon has. */
12
+ profiles: () => client.voice.profiles.list(),
13
+ /** ElevenLabs voices a profile or an allowed override can use. */
14
+ voices: (search) => client.voice.voices.list(search ? { search } : {}),
15
+ /**
16
+ * Open a call on a session. For `live` pass the WebRTC offer (see
17
+ * `connectLive`); for `handsfree` join the returned room (see `joinRoom`).
18
+ */
19
+ async start(session, options = {}) {
20
+ // Overrides travel as named body fields; older SDK typings do not list them yet.
21
+ const started = await client.voice.calls.start(session, options);
22
+ return new RaviVoiceCall(client, stream, started);
23
+ },
24
+ /** Reattach to a call you already have (e.g. after a page reload). */
25
+ attach(callId, lastSeq = 0) {
26
+ return new RaviVoiceCall(client, stream, { callId, lastSeq });
27
+ },
28
+ };
29
+ }
30
+ /**
31
+ * One call. `follow()` keeps the event stream open and resumes from the last
32
+ * `seq` after a drop; `on()` subscribes to event types.
33
+ */
34
+ export class RaviVoiceCall {
35
+ client;
36
+ stream;
37
+ id;
38
+ info;
39
+ lastSeq;
40
+ listeners = new Map();
41
+ abort = null;
42
+ approvals = new Map();
43
+ constructor(client, stream, info) {
44
+ this.client = client;
45
+ this.stream = stream;
46
+ this.info = info;
47
+ this.id = info.callId;
48
+ this.lastSeq = info.lastSeq ?? 0;
49
+ }
50
+ /** Subscribe to one event type, or `*` for all. Returns the unsubscribe function. */
51
+ on(type, listener) {
52
+ let set = this.listeners.get(type);
53
+ if (!set) {
54
+ set = new Set();
55
+ this.listeners.set(type, set);
56
+ }
57
+ set.add(listener);
58
+ return () => set?.delete(listener);
59
+ }
60
+ /** Requests waiting for a tap in this call. */
61
+ openApprovals() {
62
+ return [...this.approvals.values()];
63
+ }
64
+ /** Follow the call until it ends or `close()` is called, reconnecting with backoff. */
65
+ async follow() {
66
+ if (this.abort)
67
+ return;
68
+ const abort = new AbortController();
69
+ this.abort = abort;
70
+ let delay = 500;
71
+ while (!abort.signal.aborted) {
72
+ try {
73
+ for await (const message of this.stream.voiceCall(this.id, { after: this.lastSeq, signal: abort.signal })) {
74
+ if (message.event === "end")
75
+ return;
76
+ const event = message.data;
77
+ if (event.type !== "call.snapshot")
78
+ this.lastSeq = Math.max(this.lastSeq, event.seq);
79
+ this.track(event);
80
+ this.dispatch(event);
81
+ delay = 500;
82
+ if (event.type === "call.ended")
83
+ return;
84
+ }
85
+ }
86
+ catch (error) {
87
+ if (abort.signal.aborted)
88
+ return;
89
+ this.dispatch({ callId: this.id, seq: this.lastSeq, type: "error", data: { code: "STREAM_DROPPED", error: String(error) } });
90
+ }
91
+ await new Promise((resolve) => setTimeout(resolve, delay));
92
+ delay = Math.min(delay * 2, 8000);
93
+ }
94
+ }
95
+ /** Stop following (the call keeps running; use `end()` to end it). */
96
+ close() {
97
+ this.abort?.abort();
98
+ this.abort = null;
99
+ }
100
+ say(text) {
101
+ return this.client.voice.calls.send(this.id, [text]);
102
+ }
103
+ /** Push-to-talk: send one recorded clip. */
104
+ async push(clip) {
105
+ return this.client.voice.calls.push(this.id, { audioData: await blobToBase64(clip), mime: clip.type || "audio/webm" });
106
+ }
107
+ /**
108
+ * Tell the call whether the person is talking. `pushToTalk` sends it on press and release; call it
109
+ * yourself with your own voice-activity detection. Resolves to `null` on an SDK without it.
110
+ */
111
+ async activity(state) {
112
+ const calls = this.client.voice.calls;
113
+ if (typeof calls.activity !== "function")
114
+ return null;
115
+ return calls.activity(this.id, state);
116
+ }
117
+ /** Stop speaking now; running work continues in the session. */
118
+ silence() {
119
+ return this.client.voice.calls.silence(this.id);
120
+ }
121
+ cancelTurn(turn) {
122
+ return this.client.voice.calls.cancelTurn(this.id, turn ? { turn } : {});
123
+ }
124
+ /** Approve with a tap. Sends the version and digest the call showed, so a changed request is refused. */
125
+ approve(approvalId) {
126
+ const open = this.approvals.get(approvalId);
127
+ return this.client.voice.calls.approve(this.id, approvalId, {
128
+ execute: true,
129
+ ...(open ? { version: String(open.version), digest: open.digest } : {}),
130
+ });
131
+ }
132
+ deny(approvalId) {
133
+ return this.client.voice.calls.deny(this.id, approvalId);
134
+ }
135
+ /** Fetch a synthesized clip named in `agent.transcript.data.audio.item`. */
136
+ async audio(item) {
137
+ const clip = await this.client.voice.calls.audio(this.id, item);
138
+ return base64ToBlob(clip.audioBase64 ?? "", clip.mime);
139
+ }
140
+ connect(offer) {
141
+ return this.client.voice.calls.connect(this.id, offer ? { offer } : {});
142
+ }
143
+ async end() {
144
+ this.close();
145
+ return this.client.voice.calls.end(this.id);
146
+ }
147
+ track(event) {
148
+ if (event.type === "call.snapshot") {
149
+ const open = event.data.openApprovals ?? [];
150
+ this.approvals = new Map(open.map((item) => [item.approvalId, item]));
151
+ // The snapshot's lastSeq is only a high-water mark: the replayed events
152
+ // after the cursor still follow, and the cursor moves as each one arrives.
153
+ }
154
+ else if (event.type === "turn.approval_requested") {
155
+ const data = event.data;
156
+ this.approvals.set(data.approvalId, {
157
+ approvalId: data.approvalId,
158
+ version: Number(data.version ?? 1),
159
+ digest: data.digest,
160
+ text: data.text,
161
+ });
162
+ }
163
+ else if (event.type === "turn.approval_resolved") {
164
+ this.approvals.delete(String(event.data.approvalId));
165
+ }
166
+ }
167
+ reportListenerError(event, error) {
168
+ if (event.type === "error")
169
+ return;
170
+ this.dispatch({
171
+ callId: this.id,
172
+ seq: this.lastSeq,
173
+ type: "error",
174
+ data: { code: "LISTENER_FAILED", for: event.type, error: String(error) },
175
+ });
176
+ }
177
+ dispatch(event) {
178
+ for (const key of [event.type, "*"]) {
179
+ for (const listener of this.listeners.get(key) ?? []) {
180
+ // A listener error, sync or async, must not stop the stream.
181
+ try {
182
+ const result = listener(event);
183
+ if (result && typeof result.catch === "function") {
184
+ result.catch((error) => this.reportListenerError(event, error));
185
+ }
186
+ }
187
+ catch (error) {
188
+ this.reportListenerError(event, error);
189
+ }
190
+ }
191
+ }
192
+ }
193
+ }
194
+ export async function blobToBase64(blob) {
195
+ const bytes = new Uint8Array(await blob.arrayBuffer());
196
+ let binary = "";
197
+ for (let i = 0; i < bytes.length; i += 0x8000) {
198
+ binary += String.fromCharCode(...bytes.subarray(i, i + 0x8000));
199
+ }
200
+ return btoa(binary);
201
+ }
202
+ export function base64ToBlob(b64, mime) {
203
+ const binary = atob(b64);
204
+ const bytes = new Uint8Array(binary.length);
205
+ for (let i = 0; i < binary.length; i++)
206
+ bytes[i] = binary.charCodeAt(i);
207
+ return new Blob([bytes], { type: mime });
208
+ }
209
+ //# sourceMappingURL=call.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"call.js","sourceRoot":"","sources":["../src/call.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AA+CjF,iEAAiE;AACjE,MAAM,UAAU,eAAe,CAAC,MAAuB;IACrD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3D,MAAM,MAAM,GAAG,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC5C,OAAO;QACL,MAAM;QACN,MAAM;QACN,4CAA4C;QAC5C,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE;QAC1C,wEAAwE;QACxE,QAAQ,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE;QAC5C,kEAAkE;QAClE,MAAM,EAAE,CAAC,MAAe,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/E;;;WAGG;QACH,KAAK,CAAC,KAAK,CAAC,OAAe,EAAE,UAA4B,EAAE;YACzD,iFAAiF;YACjF,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAC5C,OAAO,EACP,OAAyD,CAC1D,CAAC;YACF,OAAO,IAAI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I,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,MAAM,EAAE,CAAC;QAC9C,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,IAAY;IACpD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACxE,OAAO,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * `@ravi-os/voice`: talk to any Ravi session from a browser app.
3
+ *
4
+ * const voice = createRaviVoice({ baseUrl, contextKey });
5
+ * const call = await voice.start("main", { mode: "push" });
6
+ * call.on("agent.transcript", (e) => show(e.data.text));
7
+ * void call.follow();
8
+ * const ptt = pushToTalk(call); // ptt.start() on press, ptt.stop() on release
9
+ * autoplayReplies(call);
10
+ */
11
+ export { base64ToBlob, blobToBase64, createRaviVoice, type OpenApproval, RaviVoiceCall, type RaviVoiceConfig, type StartCallOptions, type VoiceActivity, type VoiceEvent, type VoiceEventType, type VoiceMode, } from "./call.js";
12
+ export { autoplayReplies, connectLive, joinRoom, pushToTalk } from "./media.js";
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * `@ravi-os/voice`: talk to any Ravi session from a browser app.
3
+ *
4
+ * const voice = createRaviVoice({ baseUrl, contextKey });
5
+ * const call = await voice.start("main", { mode: "push" });
6
+ * call.on("agent.transcript", (e) => show(e.data.text));
7
+ * void call.follow();
8
+ * const ptt = pushToTalk(call); // ptt.start() on press, ptt.stop() on release
9
+ * autoplayReplies(call);
10
+ */
11
+ export { base64ToBlob, blobToBase64, createRaviVoice, RaviVoiceCall, } from "./call.js";
12
+ export { autoplayReplies, connectLive, joinRoom, pushToTalk } from "./media.js";
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,eAAe,EAEf,aAAa,GAOd,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { RaviVoiceCall, StartCallOptions, createRaviVoice } from "./call.js";
2
+ /**
3
+ * Push-to-talk recorder: `start()` on press, `stop()` on release sends the clip.
4
+ * Uses MediaRecorder (webm/opus in Chromium and Firefox, mp4 in Safari).
5
+ */
6
+ export declare function pushToTalk(call: RaviVoiceCall, options?: {
7
+ mimeType?: string;
8
+ }): {
9
+ start(): Promise<void>;
10
+ stop(): Promise<import("@ravi-os/sdk").VoiceCallsPushReturn | null>;
11
+ };
12
+ /**
13
+ * Plays every spoken reply with audio (push and mock calls). Live calls carry
14
+ * audio on WebRTC; hands-free calls in the room.
15
+ */
16
+ export declare function autoplayReplies(call: RaviVoiceCall, element?: HTMLAudioElement): () => void;
17
+ /**
18
+ * Live mode: opens a WebRTC connection to the live model. The model speaks
19
+ * and listens; the session behind it does the work.
20
+ */
21
+ export declare function connectLive(voice: ReturnType<typeof createRaviVoice>, session: string, options?: Omit<StartCallOptions, "mode" | "offer"> & {
22
+ element?: HTMLAudioElement;
23
+ mic?: MediaStream;
24
+ }): Promise<{
25
+ call: RaviVoiceCall;
26
+ peer: RTCPeerConnection;
27
+ mute(muted: boolean): void;
28
+ hangUp(): Promise<void>;
29
+ }>;
30
+ /**
31
+ * Hands-free mode: joins the call's LiveKit room, where the `ravi-voice`
32
+ * worker listens and speaks. Needs `livekit-client` installed.
33
+ */
34
+ export declare function joinRoom(call: RaviVoiceCall, options?: {
35
+ element?: HTMLAudioElement;
36
+ }): Promise<{
37
+ room: {
38
+ connect(url: string, token: string): Promise<void>;
39
+ disconnect(): Promise<void>;
40
+ localParticipant: {
41
+ setMicrophoneEnabled(enabled: boolean): Promise<unknown>;
42
+ };
43
+ on(event: string, listener: (...args: unknown[]) => void): unknown;
44
+ };
45
+ mute: (muted: boolean) => Promise<unknown>;
46
+ hangUp(): Promise<void>;
47
+ }>;
package/dist/media.js ADDED
@@ -0,0 +1,181 @@
1
+ /**
2
+ * Push-to-talk recorder: `start()` on press, `stop()` on release sends the clip.
3
+ * Uses MediaRecorder (webm/opus in Chromium and Firefox, mp4 in Safari).
4
+ */
5
+ export function pushToTalk(call, options = {}) {
6
+ // Each press owns its recorder, stream and chunks, so a new press never touches a clip still being sent.
7
+ let current = null;
8
+ return {
9
+ async start() {
10
+ if (current)
11
+ return;
12
+ const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
13
+ const mimeType = options.mimeType ?? ["audio/webm;codecs=opus", "audio/mp4"].find((type) => MediaRecorder.isTypeSupported(type));
14
+ const recorder = new MediaRecorder(stream, mimeType ? { mimeType } : undefined);
15
+ const chunks = [];
16
+ recorder.ondataavailable = (event) => {
17
+ if (event.data.size)
18
+ chunks.push(event.data);
19
+ };
20
+ current = { recorder, stream, chunks };
21
+ recorder.start();
22
+ // `when_idle` replies wait while the person talks. A failed signal never blocks recording.
23
+ call.activity("speaking").catch(() => { });
24
+ },
25
+ async stop() {
26
+ const press = current;
27
+ if (!press)
28
+ return null;
29
+ current = null;
30
+ const done = new Promise((resolve) => {
31
+ press.recorder.onstop = () => resolve();
32
+ });
33
+ press.recorder.stop();
34
+ await done;
35
+ for (const track of press.stream.getTracks())
36
+ track.stop();
37
+ const clip = new Blob(press.chunks, { type: (press.recorder.mimeType || "audio/webm").split(";")[0] });
38
+ // Best effort and not awaited before the clip is built: it never delays or drops the clip.
39
+ call.activity("quiet").catch(() => null);
40
+ if (!clip.size)
41
+ return null;
42
+ return call.push(clip);
43
+ },
44
+ };
45
+ }
46
+ /**
47
+ * Plays every spoken reply with audio (push and mock calls). Live calls carry
48
+ * audio on WebRTC; hands-free calls in the room.
49
+ */
50
+ export function autoplayReplies(call, element = new Audio()) {
51
+ let current = null;
52
+ // Bumped only on silence and cleanup: clips queued before that never play.
53
+ let generation = 0;
54
+ // Replies play in arrival order, one after another; each clip downloads as
55
+ // soon as its transcript arrives.
56
+ let queue = Promise.resolve();
57
+ const off = call.on("agent.transcript", (event) => {
58
+ const audio = event.data.audio;
59
+ if (!audio?.item)
60
+ return;
61
+ const mine = generation;
62
+ const download = call.audio(audio.item).catch(() => null);
63
+ // A clip that fails never holds the replies behind it.
64
+ queue = queue
65
+ .then(async () => {
66
+ const blob = await download;
67
+ if (!blob || mine !== generation)
68
+ return;
69
+ if (current)
70
+ URL.revokeObjectURL(current);
71
+ current = URL.createObjectURL(blob);
72
+ element.src = current;
73
+ await element.play().catch(() => undefined);
74
+ await playbackDone(element);
75
+ })
76
+ .catch(() => undefined);
77
+ });
78
+ const offSilence = call.on("agent.state", (event) => {
79
+ if (event.data.state === "listening" && event.data.reason === "silenced") {
80
+ generation++;
81
+ element.pause();
82
+ }
83
+ });
84
+ return () => {
85
+ generation++;
86
+ off();
87
+ offSilence();
88
+ element.pause();
89
+ if (current)
90
+ URL.revokeObjectURL(current);
91
+ current = null;
92
+ };
93
+ }
94
+ /** Resolves when the element stops: the clip ended, was paused, failed, or never started. */
95
+ function playbackDone(element) {
96
+ if (element.paused || element.ended || element.error)
97
+ return Promise.resolve();
98
+ return new Promise((resolve) => {
99
+ const done = () => {
100
+ element.removeEventListener("ended", done);
101
+ element.removeEventListener("pause", done);
102
+ element.removeEventListener("error", done);
103
+ resolve();
104
+ };
105
+ element.addEventListener("ended", done);
106
+ element.addEventListener("pause", done);
107
+ element.addEventListener("error", done);
108
+ });
109
+ }
110
+ /**
111
+ * Live mode: opens a WebRTC connection to the live model. The model speaks
112
+ * and listens; the session behind it does the work.
113
+ */
114
+ export async function connectLive(voice, session, options = {}) {
115
+ const pc = new RTCPeerConnection();
116
+ const element = options.element ?? new Audio();
117
+ element.autoplay = true;
118
+ pc.ontrack = (event) => {
119
+ element.srcObject = event.streams[0] ?? null;
120
+ };
121
+ const mic = options.mic ?? (await navigator.mediaDevices.getUserMedia({ audio: true }));
122
+ for (const track of mic.getAudioTracks())
123
+ pc.addTrack(track, mic);
124
+ const offer = await pc.createOffer();
125
+ await pc.setLocalDescription(offer);
126
+ const { element: _element, mic: _mic, ...startOptions } = options;
127
+ const call = await voice.start(session, { ...startOptions, mode: "live", offer: offer.sdp });
128
+ if (!call.info.sdpAnswer) {
129
+ pc.close();
130
+ throw new Error("The live engine returned no SDP answer");
131
+ }
132
+ await pc.setRemoteDescription({ type: "answer", sdp: call.info.sdpAnswer });
133
+ return {
134
+ call,
135
+ peer: pc,
136
+ mute(muted) {
137
+ for (const track of mic.getAudioTracks())
138
+ track.enabled = !muted;
139
+ },
140
+ async hangUp() {
141
+ for (const track of mic.getTracks())
142
+ track.stop();
143
+ pc.close();
144
+ await call.end();
145
+ },
146
+ };
147
+ }
148
+ /**
149
+ * Hands-free mode: joins the call's LiveKit room, where the `ravi-voice`
150
+ * worker listens and speaks. Needs `livekit-client` installed.
151
+ */
152
+ export async function joinRoom(call, options = {}) {
153
+ let url = call.info.roomUrl;
154
+ let token = call.info.roomToken;
155
+ if (!url || !token) {
156
+ const fresh = await call.connect();
157
+ url = fresh.roomUrl;
158
+ token = fresh.roomToken;
159
+ }
160
+ if (!url || !token)
161
+ throw new Error("This call has no room");
162
+ const moduleName = "livekit-client";
163
+ const livekit = (await import(/* @vite-ignore */ moduleName));
164
+ const room = new livekit.Room();
165
+ room.on(livekit.RoomEvent.TrackSubscribed, (track) => {
166
+ const attachable = track;
167
+ if (attachable.kind === "audio" && attachable.attach)
168
+ attachable.attach(options.element);
169
+ });
170
+ await room.connect(url, token);
171
+ await room.localParticipant.setMicrophoneEnabled(true);
172
+ return {
173
+ room,
174
+ mute: (muted) => room.localParticipant.setMicrophoneEnabled(!muted),
175
+ async hangUp() {
176
+ await room.disconnect();
177
+ await call.end();
178
+ },
179
+ };
180
+ }
181
+ //# sourceMappingURL=media.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.js","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,IAAmB,EAAE,UAAiC,EAAE;IACjF,yGAAyG;IACzG,IAAI,OAAO,GAA4E,IAAI,CAAC;IAE5F,OAAO;QACL,KAAK,CAAC,KAAK;YACT,IAAI,OAAO;gBAAE,OAAO;YACpB,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YAC1E,MAAM,QAAQ,GACZ,OAAO,CAAC,QAAQ,IAAI,CAAC,wBAAwB,EAAE,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;YAClH,MAAM,QAAQ,GAAG,IAAI,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YAChF,MAAM,MAAM,GAAW,EAAE,CAAC;YAC1B,QAAQ,CAAC,eAAe,GAAG,CAAC,KAAK,EAAE,EAA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B,CAAC;IAC/E,MAAM,IAAI,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAChC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,eAAe,EAAE,CAAC,KAAc,EAAE,EAAE;QAC5D,MAAM,UAAU,GAAG,KAAgF,CAAC;QACpG,IAAI,UAAU,CAAC,IAAI,KAAK,OAAO,IAAI,UAAU,CAAC,MAAM;YAAE,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3F,CAAC,CAAC,CAAC;IACH,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC/B,MAAM,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;IACvD,OAAO;QACL,IAAI;QACJ,IAAI,EAAE,CAAC,KAAc,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,CAAC,KAAK,CAAC;QAC5E,KAAK,CAAC,MAAM;YACV,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;YACxB,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
1
  {
2
2
  "name": "@ravi-os/voice",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.261128.1",
4
+ "description": "Browser kit for Ravi voice calls: talk to any Ravi session through @ravi-os/sdk.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist/",
16
+ "README.md"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsc -p tsconfig.build.json",
20
+ "typecheck": "tsc -p tsconfig.json --noEmit"
21
+ },
22
+ "peerDependencies": {
23
+ "@ravi-os/sdk": ">=0.261125.1",
24
+ "livekit-client": "^2.0.0"
25
+ },
26
+ "peerDependenciesMeta": {
27
+ "livekit-client": {
28
+ "optional": true
29
+ }
30
+ },
31
+ "engines": {
32
+ "node": ">=18"
33
+ },
34
+ "license": "MIT",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/filipexyz/ravi.git",
38
+ "directory": "packages/ravi-os-voice"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ }
43
+ }