@pyai/sdk 0.9.2 → 0.11.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.
Files changed (49) hide show
  1. package/CLI.schema.json +11 -0
  2. package/README.md +131 -3
  3. package/dist/cli-omni-template.d.ts +2 -2
  4. package/dist/cli-omni-template.js +2 -2
  5. package/dist/cli.js +39 -4
  6. package/dist/dialer/appServer.d.ts +21 -0
  7. package/dist/dialer/appServer.js +195 -0
  8. package/dist/dialer/dialerElement.d.ts +23 -0
  9. package/dist/dialer/dialerElement.js +108 -0
  10. package/dist/dialer/dialingQueue.d.ts +31 -0
  11. package/dist/dialer/dialingQueue.js +78 -0
  12. package/dist/dialer/index.d.ts +6 -0
  13. package/dist/dialer/index.js +6 -0
  14. package/dist/dialer/indexedDbJournal.d.ts +11 -0
  15. package/dist/dialer/indexedDbJournal.js +62 -0
  16. package/dist/dialer/managedDialer.d.ts +65 -0
  17. package/dist/dialer/managedDialer.js +217 -0
  18. package/dist/dialer/meetingRecorder.d.ts +83 -0
  19. package/dist/dialer/meetingRecorder.js +261 -0
  20. package/dist/dialer/meetingRecorderElement.d.ts +20 -0
  21. package/dist/dialer/meetingRecorderElement.js +138 -0
  22. package/dist/dialer/meetingRecordingStore.d.ts +17 -0
  23. package/dist/dialer/meetingRecordingStore.js +129 -0
  24. package/dist/dialer/serverBroker.d.ts +3 -0
  25. package/dist/dialer/serverBroker.js +23 -0
  26. package/dist/dialer/voiceSdkAudio.d.ts +33 -0
  27. package/dist/dialer/voiceSdkAudio.js +66 -0
  28. package/dist/index.d.ts +238 -6
  29. package/dist/index.js +67 -3
  30. package/package.json +24 -1
  31. package/src/cli-omni-template.ts +2 -2
  32. package/src/cli.ts +25 -4
  33. package/src/dialer/app/app.css +1 -0
  34. package/src/dialer/app/app.html +7 -0
  35. package/src/dialer/app/app.js +88 -0
  36. package/src/dialer/app/icon.svg +1 -0
  37. package/src/dialer/app/manifest.webmanifest +1 -0
  38. package/src/dialer/appServer.ts +151 -0
  39. package/src/dialer/dialerElement.ts +80 -0
  40. package/src/dialer/dialingQueue.ts +65 -0
  41. package/src/dialer/index.ts +6 -0
  42. package/src/dialer/indexedDbJournal.ts +56 -0
  43. package/src/dialer/managedDialer.ts +187 -0
  44. package/src/dialer/meetingRecorder.ts +220 -0
  45. package/src/dialer/meetingRecorderElement.ts +99 -0
  46. package/src/dialer/meetingRecordingStore.ts +99 -0
  47. package/src/dialer/serverBroker.ts +23 -0
  48. package/src/dialer/voiceSdkAudio.ts +61 -0
  49. package/src/index.ts +174 -5
@@ -0,0 +1,138 @@
1
+ /** Foreground capture controls. The native browser/OS picker is always shown;
2
+ * the application never silently chooses a user's window or microphone. */
3
+ export class PyaiMeetingRecorderElement extends HTMLElement {
4
+ root;
5
+ recorder = null;
6
+ store = null;
7
+ unsubscribe = null;
8
+ historyGeneration = 0;
9
+ constructor() {
10
+ super();
11
+ this.root = this.attachShadow({ mode: "open" });
12
+ this.root.innerHTML = `<style>
13
+ :host{display:block;max-width:440px;color:#202332;font:14px/1.5 system-ui,sans-serif;--recorder-accent:#5b55e7}*{box-sizing:border-box}section{background:#fff;border:1px solid #e7e8ef;border-radius:24px;padding:26px;box-shadow:0 16px 56px #25284c12}h2{margin:0 0 8px;font-size:19px}.description,.hint{color:#737b8e;font-size:13px;margin:0 0 20px}.status{background:#f5f5fc;border-radius:14px;padding:16px;margin-bottom:20px;display:flex;gap:10px;align-items:center}.dot{width:9px;height:9px;border-radius:50%;background:#a6abba}.dot.active{background:#e33f56;box-shadow:0 0 0 5px #e33f5612}label{display:flex;gap:10px;margin:14px 0;align-items:flex-start}input{accent-color:var(--recorder-accent);margin-top:4px}.actions{display:flex;gap:8px;margin-top:22px}button{font:600 13px system-ui;cursor:pointer;border:0;border-radius:13px;padding:14px 18px;min-height:46px;background:#f1f2f7;color:#535b70}button.primary{flex:1;background:var(--recorder-accent);color:white}button.end{background:#da4055}button:disabled{opacity:.45;cursor:default}button:focus-visible{outline:3px solid #bdb8ff;outline-offset:2px}.error{color:#b42338;font-size:12px;min-height:18px}.saved{font-size:12px;color:#667085;overflow-wrap:anywhere}.hint{font-size:11px;margin:16px 0 0}
14
+ </style><section><h2>Record a meeting</h2><p class="description">Record shared audio and your microphone. Choose a meeting tab or a supported system audio source.</p>
15
+ <div class="status" role="status" aria-live="polite"><span class="dot"></span><span data-status>Ready when you are</span></div>
16
+ <label><input type="checkbox" data-notice><span>Everyone has been informed and I’m ready to record.</span></label>
17
+ <label><input type="checkbox" data-microphone checked><span>Include my microphone</span></label>
18
+ <div class="actions"><button class="primary" data-start disabled>Choose audio & record</button><button data-pause disabled>Pause</button><button data-download hidden>Save audio</button></div>
19
+ <p class="error" role="alert"></p><p class="saved"></p><p class="hint">Saved privately in this browser. Nothing is uploaded until your app explicitly submits it. Video is never saved.</p>
20
+ <details><summary>Saved recordings</summary><button data-refresh>Refresh recordings</button><ul data-history></ul></details></section>`;
21
+ this.root.querySelector("[data-notice]").addEventListener("change", () => { if (this.recorder)
22
+ this.render(this.recorder.current); });
23
+ this.root.querySelector("[data-start]").addEventListener("click", () => void this.run(async () => {
24
+ if (!this.recorder)
25
+ return;
26
+ if (["starting", "recording", "paused", "stopping"].includes(this.recorder.current.state))
27
+ await this.recorder.stop();
28
+ else
29
+ await this.recorder.start({ noticeAccepted: this.root.querySelector("[data-notice]").checked,
30
+ microphone: this.root.querySelector("[data-microphone]").checked });
31
+ }));
32
+ this.root.querySelector("[data-pause]").addEventListener("click", () => {
33
+ if (!this.recorder)
34
+ return;
35
+ try {
36
+ this.recorder.current.state === "paused" ? this.recorder.resume() : this.recorder.pause();
37
+ }
38
+ catch (error) {
39
+ this.showError(error);
40
+ }
41
+ });
42
+ this.root.querySelector("[data-download]").addEventListener("click", () => void this.download());
43
+ this.root.querySelector("[data-refresh]").addEventListener("click", () => void this.run(() => this.refreshHistory()));
44
+ }
45
+ bind(recorder, store) {
46
+ if (this.recorder && this.recorder !== recorder && ["starting", "recording", "paused", "stopping"].includes(this.recorder.current.state))
47
+ throw new Error("Stop the current recording before switching workspaces.");
48
+ this.unsubscribe?.();
49
+ this.recorder = recorder;
50
+ this.store = store;
51
+ this.unsubscribe = recorder.subscribe(snapshot => this.render(snapshot));
52
+ void this.run(() => this.refreshHistory());
53
+ }
54
+ connectedCallback() { if (this.recorder && !this.unsubscribe)
55
+ this.unsubscribe = this.recorder.subscribe(snapshot => this.render(snapshot)); }
56
+ disconnectedCallback() {
57
+ this.unsubscribe?.();
58
+ this.unsubscribe = null;
59
+ ++this.historyGeneration;
60
+ // Removing the only visible controls cannot leave a hidden capture running.
61
+ if (this.recorder && ["starting", "recording", "paused"].includes(this.recorder.current.state))
62
+ void this.recorder.stop();
63
+ }
64
+ render(snapshot) {
65
+ const labels = { idle: "Ready when you are", starting: "Waiting for your audio selection…", recording: "Recording your selected audio", paused: "Recording paused", stopping: "Saving your audio…", ready: "Recording saved", error: "Recording needs attention" };
66
+ this.root.querySelector("[data-status]").textContent = labels[snapshot.state];
67
+ this.root.querySelector(".dot").classList.toggle("active", snapshot.state === "recording");
68
+ const active = ["starting", "recording", "paused", "stopping"].includes(snapshot.state);
69
+ const start = this.root.querySelector("[data-start]");
70
+ start.textContent = active ? "Stop recording" : "Choose audio & record";
71
+ start.disabled = snapshot.state === "stopping" || !this.recorder || !active && !this.root.querySelector("[data-notice]").checked;
72
+ start.classList.toggle("end", active);
73
+ const pause = this.root.querySelector("[data-pause]");
74
+ pause.disabled = !["recording", "paused"].includes(snapshot.state);
75
+ pause.textContent = snapshot.state === "paused" ? "Resume" : "Pause";
76
+ this.root.querySelector("[data-notice]").disabled = active;
77
+ this.root.querySelector("[data-microphone]").disabled = active;
78
+ this.root.querySelector("[data-download]").hidden = !snapshot.recording?.bytes || active;
79
+ this.root.querySelector(".error").textContent = snapshot.error ?? "";
80
+ this.root.querySelector(".saved").textContent = snapshot.recording?.bytes ? `${Math.ceil(snapshot.recording.bytes / 1024)} KB saved · ${snapshot.recording.state === "incomplete" ? "Review incomplete recording" : "Audio only"}` : "";
81
+ }
82
+ async refreshHistory() {
83
+ const recorder = this.recorder, store = this.store, generation = ++this.historyGeneration;
84
+ if (!recorder || !store)
85
+ return;
86
+ const records = await store.list(recorder.recordingScope);
87
+ if (generation !== this.historyGeneration || recorder !== this.recorder)
88
+ return;
89
+ const list = this.root.querySelector("[data-history]");
90
+ list.replaceChildren();
91
+ for (const recording of records.slice(0, 40)) {
92
+ const item = document.createElement("li"), label = document.createElement("p"), action = document.createElement("button");
93
+ label.textContent = `${new Date(recording.createdAt).toLocaleString()} · ${Math.ceil(recording.bytes / 1024)} KB · ${recording.state === "ready" ? "Saved" : recording.state === "incomplete" ? "Incomplete — review audio" : "Active or interrupted"}`;
94
+ action.textContent = recording.state === "recording" ? "Recover interrupted recording" : "Save recording";
95
+ action.addEventListener("click", () => void this.run(async () => {
96
+ if (recorder !== this.recorder)
97
+ return;
98
+ if (recording.state === "recording") {
99
+ await store.recover(recording.scope, recording.id);
100
+ await this.refreshHistory();
101
+ }
102
+ else
103
+ await this.download(recording);
104
+ }));
105
+ item.append(label, action);
106
+ list.append(item);
107
+ }
108
+ if (!records.length) {
109
+ const item = document.createElement("li");
110
+ item.textContent = "No saved recordings in this workspace.";
111
+ list.append(item);
112
+ }
113
+ }
114
+ async download(selected) {
115
+ await this.run(async () => {
116
+ const recording = selected ?? this.recorder?.current.recording;
117
+ if (!recording || !this.store)
118
+ throw new Error("No saved recording.");
119
+ if (recording.scope !== this.recorder?.recordingScope)
120
+ throw new Error("No recording in this workspace.");
121
+ const blob = await this.store.audio(recording.scope, recording.id), url = URL.createObjectURL(blob);
122
+ const link = document.createElement("a");
123
+ link.href = url;
124
+ link.download = `Meeting-${new Date(recording.createdAt).toISOString().replace(/[:.]/g, "-")}.${recording.mimeType.includes("mp4") ? "m4a" : "webm"}`;
125
+ link.click();
126
+ setTimeout(() => URL.revokeObjectURL(url), 60000);
127
+ });
128
+ }
129
+ showError(error) { this.root.querySelector(".error").textContent = error instanceof Error ? error.message : "Recording action failed."; }
130
+ async run(action) { try {
131
+ await action();
132
+ }
133
+ catch (error) {
134
+ this.showError(error);
135
+ } }
136
+ }
137
+ if (!customElements.get("pyai-meeting-recorder"))
138
+ customElements.define("pyai-meeting-recorder", PyaiMeetingRecorderElement);
@@ -0,0 +1,17 @@
1
+ import type { MeetingRecording, MeetingRecordingStore } from "./meetingRecorder.ts";
2
+ /** Private, scoped chunk storage. Completed and interrupted captures survive
3
+ * reload; storage errors never cause a silent fallback to public uploads. */
4
+ export declare class IndexedDbMeetingRecordingStore implements MeetingRecordingStore {
5
+ private readonly database;
6
+ constructor(name?: string);
7
+ private lockName;
8
+ acquire(scope: string, id: string): Promise<() => void>;
9
+ recover(scope: string, id: string): Promise<MeetingRecording>;
10
+ private transact;
11
+ create(recording: MeetingRecording): Promise<void>;
12
+ append(scope: string, id: string, sequence: number, bytes: Blob): Promise<void>;
13
+ get(scope: string, id: string): Promise<MeetingRecording | null>;
14
+ finish(scope: string, id: string, state: "ready" | "incomplete", endedAt: number, error: string | null, signalObserved?: MeetingRecording["signalObserved"]): Promise<MeetingRecording>;
15
+ list(scope: string): Promise<MeetingRecording[]>;
16
+ audio(scope: string, id: string): Promise<Blob>;
17
+ }
@@ -0,0 +1,129 @@
1
+ /** Private, scoped chunk storage. Completed and interrupted captures survive
2
+ * reload; storage errors never cause a silent fallback to public uploads. */
3
+ export class IndexedDbMeetingRecordingStore {
4
+ database;
5
+ constructor(name = "pyai-meeting-recordings") {
6
+ this.database = new Promise((resolve, reject) => {
7
+ const request = indexedDB.open(name, 1);
8
+ request.onupgradeneeded = () => {
9
+ request.result.createObjectStore("recordings", { keyPath: ["scope", "id"] });
10
+ const chunks = request.result.createObjectStore("chunks", { keyPath: ["scope", "id", "sequence"] });
11
+ chunks.createIndex("recording", ["scope", "id"]);
12
+ };
13
+ request.onsuccess = () => { request.result.onversionchange = () => request.result.close(); resolve(request.result); };
14
+ request.onerror = () => reject(new Error("Private recording storage is unavailable."));
15
+ request.onblocked = () => reject(new Error("Close the older recorder tab to upgrade storage."));
16
+ });
17
+ }
18
+ lockName(scope, id) { return `pyai-meeting:${JSON.stringify([scope, id])}`; }
19
+ async acquire(scope, id) {
20
+ if (!navigator.locks)
21
+ throw new Error("This browser cannot safely recover meeting recordings. Use a current supported browser.");
22
+ return new Promise((resolve, reject) => {
23
+ void navigator.locks.request(this.lockName(scope, id), { ifAvailable: true }, async (lock) => {
24
+ if (!lock)
25
+ throw new Error("This recording is active in another tab.");
26
+ await new Promise(release => resolve(release));
27
+ }).catch(reject);
28
+ });
29
+ }
30
+ async recover(scope, id) {
31
+ const release = await this.acquire(scope, id);
32
+ try {
33
+ return await this.finish(scope, id, "incomplete", Date.now(), "Recording was interrupted. Saved audio was recovered; review it before use.");
34
+ }
35
+ finally {
36
+ release();
37
+ }
38
+ }
39
+ async transact(stores, mode, action) {
40
+ const database = await this.database;
41
+ return new Promise((resolve, reject) => {
42
+ const tx = database.transaction(stores, mode);
43
+ let value, error = null;
44
+ tx.oncomplete = () => resolve(value);
45
+ tx.onerror = tx.onabort = () => reject(new Error(error ?? "Recording storage failed; earlier audio remains saved."));
46
+ action(tx, next => { value = next; }, message => { error = message; tx.abort(); });
47
+ });
48
+ }
49
+ create(recording) {
50
+ return this.transact(["recordings"], "readwrite", (tx, done) => { tx.objectStore("recordings").add(structuredClone(recording)); done(undefined); });
51
+ }
52
+ append(scope, id, sequence, bytes) {
53
+ return this.transact(["recordings", "chunks"], "readwrite", (tx, done, fail) => {
54
+ const records = tx.objectStore("recordings"), request = records.get([scope, id]);
55
+ request.onsuccess = () => {
56
+ const current = request.result;
57
+ if (!current || current.state !== "recording" || current.chunks !== sequence) {
58
+ fail("Recording chunk sequence changed.");
59
+ return;
60
+ }
61
+ if (current.bytes + bytes.size > current.maxBytes) {
62
+ fail("Recording storage limit reached; earlier audio remains saved.");
63
+ return;
64
+ }
65
+ tx.objectStore("chunks").add({ scope, id, sequence, bytes });
66
+ records.put({ ...current, bytes: current.bytes + bytes.size, chunks: sequence + 1 });
67
+ done(undefined);
68
+ };
69
+ });
70
+ }
71
+ get(scope, id) {
72
+ return this.transact(["recordings"], "readonly", (tx, done) => {
73
+ const request = tx.objectStore("recordings").get([scope, id]);
74
+ request.onsuccess = () => done(request.result ?? null);
75
+ });
76
+ }
77
+ finish(scope, id, state, endedAt, error, signalObserved) {
78
+ return this.transact(["recordings"], "readwrite", (tx, done, fail) => {
79
+ const records = tx.objectStore("recordings"), request = records.get([scope, id]);
80
+ request.onsuccess = () => {
81
+ const current = request.result;
82
+ if (!current) {
83
+ fail("No recording in this workspace.");
84
+ return;
85
+ }
86
+ if (current.state !== "recording") {
87
+ done(current);
88
+ return;
89
+ }
90
+ const final = { ...current, state, endedAt, error, ...(signalObserved ? { signalObserved } : {}) };
91
+ records.put(final);
92
+ done(final);
93
+ };
94
+ });
95
+ }
96
+ list(scope) {
97
+ return this.transact(["recordings"], "readonly", (tx, done) => {
98
+ const request = tx.objectStore("recordings").getAll(IDBKeyRange.bound([scope, ""], [scope, "\uffff"]));
99
+ request.onsuccess = () => done(request.result.sort((a, b) => b.createdAt - a.createdAt));
100
+ });
101
+ }
102
+ async audio(scope, id) {
103
+ return this.transact(["recordings", "chunks"], "readonly", (tx, done, fail) => {
104
+ const record = tx.objectStore("recordings").get([scope, id]);
105
+ record.onsuccess = () => {
106
+ const current = record.result;
107
+ if (!current || current.state === "recording" || !current.bytes) {
108
+ fail("Stop or recover this recording before downloading it.");
109
+ return;
110
+ }
111
+ const chunks = tx.objectStore("chunks").index("recording").getAll(IDBKeyRange.only([scope, id]));
112
+ chunks.onsuccess = () => {
113
+ const rows = chunks.result;
114
+ rows.sort((a, b) => a.sequence - b.sequence);
115
+ if (rows.length !== current.chunks || rows.some((row, i) => row.sequence !== i)) {
116
+ fail("Saved audio is incomplete; preserve its chunks for recovery.");
117
+ return;
118
+ }
119
+ const blob = new Blob(rows.map(row => row.bytes), { type: current.mimeType });
120
+ if (blob.size !== current.bytes) {
121
+ fail("Saved recording size changed.");
122
+ return;
123
+ }
124
+ done(blob);
125
+ };
126
+ };
127
+ });
128
+ }
129
+ }
@@ -0,0 +1,3 @@
1
+ import type { PyAI } from "../index.ts";
2
+ import type { DialerBroker } from "./managedDialer.ts";
3
+ export declare function createServerDialerBroker(sdk: PyAI, authenticatedUserId: string): DialerBroker;
@@ -0,0 +1,23 @@
1
+ /** Server-only broker. Never import this module into a browser bundle. */
2
+ import { createHash } from "node:crypto";
3
+ export function createServerDialerBroker(sdk, authenticatedUserId) {
4
+ if (!authenticatedUserId.trim())
5
+ throw new Error("An authenticated user is required.");
6
+ const ownedCall = async (id) => {
7
+ const call = await sdk.telephony.calls.get(id);
8
+ if (call.call_type !== "human" || call.user_id !== authenticatedUserId)
9
+ throw new Error("No such call.");
10
+ return call;
11
+ };
12
+ return {
13
+ async create(input, key) {
14
+ if (!key || key.length > 255 || /[\r\n]/.test(key))
15
+ throw new Error("A valid Idempotency-Key is required.");
16
+ // Separate users cannot collide on an organization-wide caller-chosen key.
17
+ const scopedKey = "dialer:" + createHash("sha256").update(authenticatedUserId).update("\0").update(key).digest("hex");
18
+ return sdk.telephony.browserSessions.create({ ...input, user_id: authenticatedUserId }, { idempotencyKey: scopedKey });
19
+ },
20
+ get: ownedCall,
21
+ async hangup(id) { await ownedCall(id); return sdk.telephony.calls.hangup(id); },
22
+ };
23
+ }
@@ -0,0 +1,33 @@
1
+ import type { TelephonyBrowserSession } from "../index.ts";
2
+ import type { DialerAudio } from "./managedDialer.ts";
3
+ interface VoiceCall {
4
+ on(event: string, callback: (...args: unknown[]) => void): void;
5
+ removeAllListeners(): void;
6
+ disconnect(): void;
7
+ mute(value: boolean): void;
8
+ sendDigits(digits: string): void;
9
+ status(): string;
10
+ }
11
+ interface VoiceDevice {
12
+ connect(options: {
13
+ params: Record<string, string>;
14
+ }): Promise<VoiceCall>;
15
+ on(event: string, callback: (...args: unknown[]) => void): void;
16
+ removeAllListeners(): void;
17
+ destroy(): void;
18
+ }
19
+ /** Inject the supported Voice SDK's Device constructor. Lazy-load it only when
20
+ * calling starts; the dialer shell itself has no framework or media dependency. */
21
+ export declare class VoiceSdkAudio implements DialerAudio {
22
+ private device;
23
+ private call;
24
+ private generation;
25
+ private notify;
26
+ private readonly createDevice;
27
+ constructor(createDevice: (token: string) => VoiceDevice);
28
+ connect(session: TelephonyBrowserSession, event: (state: "ringing" | "active" | "disconnected") => void): Promise<void>;
29
+ disconnect(): void;
30
+ mute(value: boolean): void;
31
+ sendDigits(digits: string): void;
32
+ }
33
+ export {};
@@ -0,0 +1,66 @@
1
+ /** Inject the supported Voice SDK's Device constructor. Lazy-load it only when
2
+ * calling starts; the dialer shell itself has no framework or media dependency. */
3
+ export class VoiceSdkAudio {
4
+ device = null;
5
+ call = null;
6
+ generation = 0;
7
+ notify = null;
8
+ createDevice;
9
+ constructor(createDevice) { this.createDevice = createDevice; }
10
+ async connect(session, event) {
11
+ if (!session.access_token)
12
+ throw new Error("No unconsumed calling capability.");
13
+ this.disconnect();
14
+ const generation = this.generation;
15
+ const device = this.createDevice(session.access_token);
16
+ this.device = device;
17
+ this.notify = event;
18
+ const emit = (state) => { if (generation === this.generation)
19
+ this.notify?.(state); };
20
+ device.on("error", () => emit("disconnected"));
21
+ try {
22
+ const call = await device.connect({ params: { ...session.connect_params } });
23
+ if (generation !== this.generation) {
24
+ try {
25
+ call.removeAllListeners();
26
+ }
27
+ catch { /* Continue releasing stale audio. */ }
28
+ try {
29
+ call.disconnect();
30
+ }
31
+ catch { /* The owning device is already destroyed. */ }
32
+ return;
33
+ }
34
+ this.call = call;
35
+ call.on("ringing", () => emit("ringing"));
36
+ call.on("accept", () => emit("active"));
37
+ for (const name of ["disconnect", "cancel", "reject", "error"])
38
+ call.on(name, () => emit("disconnected"));
39
+ emit(call.status() === "open" ? "active" : "ringing");
40
+ }
41
+ catch (error) {
42
+ if (generation === this.generation)
43
+ this.disconnect();
44
+ throw error;
45
+ }
46
+ }
47
+ disconnect() {
48
+ this.generation++;
49
+ this.notify = null;
50
+ const call = this.call, device = this.device;
51
+ this.call = null;
52
+ this.device = null;
53
+ // Local SDK failures must not prevent the controller's durable remote stop.
54
+ for (const close of [() => call?.removeAllListeners(), () => call?.disconnect(),
55
+ () => device?.removeAllListeners(), () => device?.destroy()]) {
56
+ try {
57
+ close();
58
+ }
59
+ catch { /* All owned resources still get a cleanup attempt. */ }
60
+ }
61
+ }
62
+ mute(value) { if (!this.call)
63
+ throw new Error("No active audio."); this.call.mute(value); }
64
+ sendDigits(digits) { if (!this.call)
65
+ throw new Error("No active audio."); this.call.sendDigits(digits); }
66
+ }