@aevoxvoice/web 0.1.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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 AeVox
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ AeVox Web
2
+ Copyright 2026 AeVox
3
+
4
+ This product includes software developed at AeVox (https://aevox.ai).
package/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # @aevoxvoice/web
2
+
3
+ Thin browser wrapper for **AeVox Web Calls** — join a call with an agent over
4
+ WebRTC without learning our transport SDK. Pairs with
5
+ [`@aevoxvoice/sdk`](https://www.npmjs.com/package/@aevoxvoice/sdk), which
6
+ mints the session server-side.
7
+
8
+ `livekit-client` is an implementation detail of this package — no livekit
9
+ type, class, or enum appears anywhere in the public API surface.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install @aevoxvoice/web
15
+ ```
16
+
17
+ ## Quickstart
18
+
19
+ Your backend mints a session with `@aevoxvoice/sdk` and hands it to the
20
+ browser; the browser joins with `@aevoxvoice/web`.
21
+
22
+ ```typescript
23
+ // server (Node) — mint a session for the caller's browser to join
24
+ import { AeVoxClient } from '@aevoxvoice/sdk';
25
+
26
+ const client = new AeVoxClient({ token: process.env.AEVOX_TOKEN!, baseUrl: 'https://your-instance.aevoxvoice.com' });
27
+ const session = await client.webSessions.create({ agentId: 'drivesmart_customer_service' });
28
+ // -> forward `session` to the browser as JSON (fetch response, WebSocket push, etc.)
29
+ ```
30
+
31
+ ```typescript
32
+ // browser — join the call with the session your backend minted
33
+ import { AeVoxWebCall } from '@aevoxvoice/web';
34
+
35
+ const call = new AeVoxWebCall();
36
+ call.on('connected', () => console.log('joined'));
37
+ call.on('agent-speaking', (speaking) => console.log('agent speaking:', speaking));
38
+ call.on('disconnected', ({ reason }) => console.log('call ended:', reason));
39
+
40
+ await call.connect(session); // session === the object your backend forwarded, verbatim
41
+
42
+ // later
43
+ call.mute(true);
44
+ await call.disconnect();
45
+ ```
46
+
47
+ That's the whole surface: `connect(session)`, `disconnect()`, `mute(muted)`,
48
+ and three events. Agent audio plays automatically — no `<audio>` element or
49
+ track-attach wiring required.
50
+
51
+ ## API
52
+
53
+ ### `new AeVoxWebCall()`
54
+
55
+ One instance per call. `connect()` can only be called once per instance —
56
+ construct a new `AeVoxWebCall` for the next call after `disconnect()`.
57
+
58
+ ### `call.connect(session: WebCallSession): Promise<void>`
59
+
60
+ Joins the room described by `session` — the mint response from
61
+ `POST /v1/web-sessions` (or `client.webSessions.create()`), passed through
62
+ verbatim. Resolves once connected and the local microphone is published.
63
+ Fires `connected`.
64
+
65
+ ### `call.disconnect(): Promise<void>`
66
+
67
+ Leaves the call and releases the microphone. Safe to call before `connect()`
68
+ (no-op) or more than once.
69
+
70
+ ### `call.mute(muted: boolean): Promise<void>`
71
+
72
+ Mutes (`true`) or unmutes (`false`) the local microphone. Throws
73
+ `WebCallNotConnectedError` if called before `connect()` resolves.
74
+
75
+ ### `call.on(event, handler): () => void`
76
+
77
+ Subscribes to an event; returns an unsubscribe function.
78
+
79
+ | Event | Payload | Fires when |
80
+ |---|---|---|
81
+ | `connected` | — | The room connection is established and the mic is published. |
82
+ | `agent-speaking` | `boolean` | The agent starts or stops speaking. |
83
+ | `disconnected` | `{ reason?: string }` | The call ends — caller-initiated or server-initiated (e.g. the agent hangs up, the call timeout watchdog fires). |
84
+
85
+ ### `call.off(event, handler): void`
86
+
87
+ Unsubscribes a previously-registered handler.
88
+
89
+ ## A note on provider visibility
90
+
91
+ This package hides the AeVox **API** — you never import or reference
92
+ `livekit-client` — but the WebSocket connection your browser opens still
93
+ resolves to the underlying transport provider's edge in a network tab. We
94
+ have not pursued vanity-domain masking for v1 (see the Web Call Ingress
95
+ design doc, decision #6).
package/dist/index.cjs ADDED
@@ -0,0 +1,137 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let livekit_client = require("livekit-client");
3
+ //#region \0@oxc-project+runtime@0.122.0/helpers/checkPrivateRedeclaration.js
4
+ function _checkPrivateRedeclaration(e, t) {
5
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
6
+ }
7
+ //#endregion
8
+ //#region \0@oxc-project+runtime@0.122.0/helpers/classPrivateMethodInitSpec.js
9
+ function _classPrivateMethodInitSpec(e, a) {
10
+ _checkPrivateRedeclaration(e, a), a.add(e);
11
+ }
12
+ //#endregion
13
+ //#region \0@oxc-project+runtime@0.122.0/helpers/classPrivateFieldInitSpec.js
14
+ function _classPrivateFieldInitSpec(e, t, a) {
15
+ _checkPrivateRedeclaration(e, t), t.set(e, a);
16
+ }
17
+ //#endregion
18
+ //#region \0@oxc-project+runtime@0.122.0/helpers/assertClassBrand.js
19
+ function _assertClassBrand(e, t, n) {
20
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
21
+ throw new TypeError("Private element is not present on this object");
22
+ }
23
+ //#endregion
24
+ //#region \0@oxc-project+runtime@0.122.0/helpers/classPrivateFieldGet2.js
25
+ function _classPrivateFieldGet2(s, a) {
26
+ return s.get(_assertClassBrand(s, a));
27
+ }
28
+ //#endregion
29
+ //#region \0@oxc-project+runtime@0.122.0/helpers/classPrivateFieldSet2.js
30
+ function _classPrivateFieldSet2(s, a, r) {
31
+ return s.set(_assertClassBrand(s, a), r), r;
32
+ }
33
+ //#endregion
34
+ //#region src/index.ts
35
+ /**
36
+ * @aevoxvoice/web — thin browser wrapper for AeVox Web Call sessions.
37
+ *
38
+ * Wraps the WebRTC connection behind an AeVox-only surface: `connect(session)`,
39
+ * `disconnect()`, `mute(muted)`, and three events (`connected`, `agent-speaking`,
40
+ * `disconnected`). `livekit-client` is an implementation detail — no livekit
41
+ * type, class, or enum is exported (or appears in a public method signature)
42
+ * from this package (Web Call Ingress DESIGN.md §11 decision #6, "provider
43
+ * posture"). The connection URL still resolves to the provider's edge in a
44
+ * network tab; this wrapper hides the API, not the wire — see the design doc
45
+ * for that honesty note.
46
+ *
47
+ * `connect()` takes the mint response from `POST /v1/web-sessions` verbatim
48
+ * (the same shape `@aevoxvoice/sdk`'s `client.webSessions.create()` returns,
49
+ * camelCased) — this package has NO dependency on `@aevoxvoice/sdk`, so it
50
+ * works from any backend that can call the mint endpoint, not just Node.
51
+ */
52
+ /** Thrown by `mute()`/`disconnect()` when called before `connect()` resolves (or after it). */
53
+ var WebCallNotConnectedError = class extends Error {
54
+ constructor(message = "Not connected — call connect(session) first.") {
55
+ super(message);
56
+ this.name = "WebCallNotConnectedError";
57
+ }
58
+ };
59
+ var _room = /* @__PURE__ */ new WeakMap();
60
+ var _listeners = /* @__PURE__ */ new WeakMap();
61
+ var _attachedEls = /* @__PURE__ */ new WeakMap();
62
+ var _AeVoxWebCall_brand = /* @__PURE__ */ new WeakSet();
63
+ /**
64
+ * One Web Call connection. Create one instance per call — `connect()` can
65
+ * only be called once per instance; construct a new `AeVoxWebCall` to start
66
+ * another session after `disconnect()`.
67
+ */
68
+ var AeVoxWebCall = class {
69
+ constructor() {
70
+ _classPrivateMethodInitSpec(this, _AeVoxWebCall_brand);
71
+ _classPrivateFieldInitSpec(this, _room, void 0);
72
+ _classPrivateFieldInitSpec(this, _listeners, /* @__PURE__ */ new Map());
73
+ _classPrivateFieldInitSpec(this, _attachedEls, []);
74
+ }
75
+ /**
76
+ * Join the call described by a minted `WebCallSession`. Resolves once the
77
+ * room connection is established and the local microphone is published.
78
+ * Fires `connected` on success.
79
+ */
80
+ async connect(session) {
81
+ if (_classPrivateFieldGet2(_room, this)) throw new Error("AeVoxWebCall.connect() was already called on this instance — create a new AeVoxWebCall for a new session.");
82
+ const room = new livekit_client.Room();
83
+ _classPrivateFieldSet2(_room, this, room);
84
+ room.on(livekit_client.RoomEvent.Disconnected, (reason) => {
85
+ _assertClassBrand(_AeVoxWebCall_brand, this, _emit).call(this, "disconnected", { reason: reason !== void 0 ? String(reason) : void 0 });
86
+ });
87
+ room.on(livekit_client.RoomEvent.ActiveSpeakersChanged, (speakers) => {
88
+ _assertClassBrand(_AeVoxWebCall_brand, this, _emit).call(this, "agent-speaking", speakers.some((participant) => !participant.isLocal));
89
+ });
90
+ room.on(livekit_client.RoomEvent.TrackSubscribed, (track) => {
91
+ if (track.kind === livekit_client.Track.Kind.Audio) {
92
+ const el = track.attach();
93
+ el.autoplay = true;
94
+ _classPrivateFieldGet2(_attachedEls, this).push(el);
95
+ document.body.appendChild(el);
96
+ }
97
+ });
98
+ await room.connect(session.connectionUrl, session.sessionToken);
99
+ await room.localParticipant.setMicrophoneEnabled(true);
100
+ _assertClassBrand(_AeVoxWebCall_brand, this, _emit).call(this, "connected", void 0);
101
+ }
102
+ /** Leave the call, release the microphone, and remove any auto-attached audio elements. */
103
+ async disconnect() {
104
+ if (!_classPrivateFieldGet2(_room, this)) return;
105
+ const room = _classPrivateFieldGet2(_room, this);
106
+ _classPrivateFieldSet2(_room, this, void 0);
107
+ for (const el of _classPrivateFieldGet2(_attachedEls, this).splice(0)) el.remove();
108
+ await room.disconnect();
109
+ }
110
+ /** Mute (`true`) or unmute (`false`) the local microphone. */
111
+ async mute(muted) {
112
+ if (!_classPrivateFieldGet2(_room, this)) throw new WebCallNotConnectedError();
113
+ await _classPrivateFieldGet2(_room, this).localParticipant.setMicrophoneEnabled(!muted);
114
+ }
115
+ /** Subscribe to a call event. Returns an unsubscribe function. */
116
+ on(event, handler) {
117
+ let set = _classPrivateFieldGet2(_listeners, this).get(event);
118
+ if (!set) {
119
+ set = /* @__PURE__ */ new Set();
120
+ _classPrivateFieldGet2(_listeners, this).set(event, set);
121
+ }
122
+ set.add(handler);
123
+ return () => {
124
+ _classPrivateFieldGet2(_listeners, this).get(event)?.delete(handler);
125
+ };
126
+ }
127
+ /** Unsubscribe a previously-registered handler. */
128
+ off(event, handler) {
129
+ _classPrivateFieldGet2(_listeners, this).get(event)?.delete(handler);
130
+ }
131
+ };
132
+ function _emit(event, payload) {
133
+ for (const handler of _classPrivateFieldGet2(_listeners, this).get(event) ?? []) handler(payload);
134
+ }
135
+ //#endregion
136
+ exports.AeVoxWebCall = AeVoxWebCall;
137
+ exports.WebCallNotConnectedError = WebCallNotConnectedError;
@@ -0,0 +1,69 @@
1
+ //#region src/index.d.ts
2
+ /**
3
+ * @aevoxvoice/web — thin browser wrapper for AeVox Web Call sessions.
4
+ *
5
+ * Wraps the WebRTC connection behind an AeVox-only surface: `connect(session)`,
6
+ * `disconnect()`, `mute(muted)`, and three events (`connected`, `agent-speaking`,
7
+ * `disconnected`). `livekit-client` is an implementation detail — no livekit
8
+ * type, class, or enum is exported (or appears in a public method signature)
9
+ * from this package (Web Call Ingress DESIGN.md §11 decision #6, "provider
10
+ * posture"). The connection URL still resolves to the provider's edge in a
11
+ * network tab; this wrapper hides the API, not the wire — see the design doc
12
+ * for that honesty note.
13
+ *
14
+ * `connect()` takes the mint response from `POST /v1/web-sessions` verbatim
15
+ * (the same shape `@aevoxvoice/sdk`'s `client.webSessions.create()` returns,
16
+ * camelCased) — this package has NO dependency on `@aevoxvoice/sdk`, so it
17
+ * works from any backend that can call the mint endpoint, not just Node.
18
+ */
19
+ /** The mint response from `POST /v1/web-sessions` (or `client.webSessions.create()`), verbatim. */
20
+ interface WebCallSession {
21
+ /** Short-TTL LiveKit participant token. */
22
+ sessionToken: string;
23
+ /** LiveKit WebSocket URL to connect to. */
24
+ connectionUrl: string;
25
+ /** The room name the session was minted into. */
26
+ room: string;
27
+ /** The business call id — correlate this session with your backend's call records. */
28
+ callId: string;
29
+ /** ISO-8601 timestamp the participant token expires. */
30
+ expiresAt: string;
31
+ }
32
+ /** Payload shapes for each `AeVoxWebCall` event. */
33
+ interface WebCallEventPayloads {
34
+ connected: undefined;
35
+ 'agent-speaking': boolean;
36
+ disconnected: {
37
+ reason: string | undefined;
38
+ };
39
+ }
40
+ type WebCallEvent = keyof WebCallEventPayloads;
41
+ type Handler<E extends WebCallEvent> = (payload: WebCallEventPayloads[E]) => void;
42
+ /** Thrown by `mute()`/`disconnect()` when called before `connect()` resolves (or after it). */
43
+ declare class WebCallNotConnectedError extends Error {
44
+ constructor(message?: string);
45
+ }
46
+ /**
47
+ * One Web Call connection. Create one instance per call — `connect()` can
48
+ * only be called once per instance; construct a new `AeVoxWebCall` to start
49
+ * another session after `disconnect()`.
50
+ */
51
+ declare class AeVoxWebCall {
52
+ #private;
53
+ /**
54
+ * Join the call described by a minted `WebCallSession`. Resolves once the
55
+ * room connection is established and the local microphone is published.
56
+ * Fires `connected` on success.
57
+ */
58
+ connect(session: WebCallSession): Promise<void>;
59
+ /** Leave the call, release the microphone, and remove any auto-attached audio elements. */
60
+ disconnect(): Promise<void>;
61
+ /** Mute (`true`) or unmute (`false`) the local microphone. */
62
+ mute(muted: boolean): Promise<void>;
63
+ /** Subscribe to a call event. Returns an unsubscribe function. */
64
+ on<E extends WebCallEvent>(event: E, handler: Handler<E>): () => void;
65
+ /** Unsubscribe a previously-registered handler. */
66
+ off<E extends WebCallEvent>(event: E, handler: Handler<E>): void;
67
+ }
68
+ //#endregion
69
+ export { AeVoxWebCall, WebCallEvent, WebCallEventPayloads, WebCallNotConnectedError, WebCallSession };
@@ -0,0 +1,69 @@
1
+ //#region src/index.d.ts
2
+ /**
3
+ * @aevoxvoice/web — thin browser wrapper for AeVox Web Call sessions.
4
+ *
5
+ * Wraps the WebRTC connection behind an AeVox-only surface: `connect(session)`,
6
+ * `disconnect()`, `mute(muted)`, and three events (`connected`, `agent-speaking`,
7
+ * `disconnected`). `livekit-client` is an implementation detail — no livekit
8
+ * type, class, or enum is exported (or appears in a public method signature)
9
+ * from this package (Web Call Ingress DESIGN.md §11 decision #6, "provider
10
+ * posture"). The connection URL still resolves to the provider's edge in a
11
+ * network tab; this wrapper hides the API, not the wire — see the design doc
12
+ * for that honesty note.
13
+ *
14
+ * `connect()` takes the mint response from `POST /v1/web-sessions` verbatim
15
+ * (the same shape `@aevoxvoice/sdk`'s `client.webSessions.create()` returns,
16
+ * camelCased) — this package has NO dependency on `@aevoxvoice/sdk`, so it
17
+ * works from any backend that can call the mint endpoint, not just Node.
18
+ */
19
+ /** The mint response from `POST /v1/web-sessions` (or `client.webSessions.create()`), verbatim. */
20
+ interface WebCallSession {
21
+ /** Short-TTL LiveKit participant token. */
22
+ sessionToken: string;
23
+ /** LiveKit WebSocket URL to connect to. */
24
+ connectionUrl: string;
25
+ /** The room name the session was minted into. */
26
+ room: string;
27
+ /** The business call id — correlate this session with your backend's call records. */
28
+ callId: string;
29
+ /** ISO-8601 timestamp the participant token expires. */
30
+ expiresAt: string;
31
+ }
32
+ /** Payload shapes for each `AeVoxWebCall` event. */
33
+ interface WebCallEventPayloads {
34
+ connected: undefined;
35
+ 'agent-speaking': boolean;
36
+ disconnected: {
37
+ reason: string | undefined;
38
+ };
39
+ }
40
+ type WebCallEvent = keyof WebCallEventPayloads;
41
+ type Handler<E extends WebCallEvent> = (payload: WebCallEventPayloads[E]) => void;
42
+ /** Thrown by `mute()`/`disconnect()` when called before `connect()` resolves (or after it). */
43
+ declare class WebCallNotConnectedError extends Error {
44
+ constructor(message?: string);
45
+ }
46
+ /**
47
+ * One Web Call connection. Create one instance per call — `connect()` can
48
+ * only be called once per instance; construct a new `AeVoxWebCall` to start
49
+ * another session after `disconnect()`.
50
+ */
51
+ declare class AeVoxWebCall {
52
+ #private;
53
+ /**
54
+ * Join the call described by a minted `WebCallSession`. Resolves once the
55
+ * room connection is established and the local microphone is published.
56
+ * Fires `connected` on success.
57
+ */
58
+ connect(session: WebCallSession): Promise<void>;
59
+ /** Leave the call, release the microphone, and remove any auto-attached audio elements. */
60
+ disconnect(): Promise<void>;
61
+ /** Mute (`true`) or unmute (`false`) the local microphone. */
62
+ mute(muted: boolean): Promise<void>;
63
+ /** Subscribe to a call event. Returns an unsubscribe function. */
64
+ on<E extends WebCallEvent>(event: E, handler: Handler<E>): () => void;
65
+ /** Unsubscribe a previously-registered handler. */
66
+ off<E extends WebCallEvent>(event: E, handler: Handler<E>): void;
67
+ }
68
+ //#endregion
69
+ export { AeVoxWebCall, WebCallEvent, WebCallEventPayloads, WebCallNotConnectedError, WebCallSession };
package/dist/index.mjs ADDED
@@ -0,0 +1,135 @@
1
+ import { Room, RoomEvent, Track } from "livekit-client";
2
+ //#region \0@oxc-project+runtime@0.122.0/helpers/checkPrivateRedeclaration.js
3
+ function _checkPrivateRedeclaration(e, t) {
4
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
5
+ }
6
+ //#endregion
7
+ //#region \0@oxc-project+runtime@0.122.0/helpers/classPrivateMethodInitSpec.js
8
+ function _classPrivateMethodInitSpec(e, a) {
9
+ _checkPrivateRedeclaration(e, a), a.add(e);
10
+ }
11
+ //#endregion
12
+ //#region \0@oxc-project+runtime@0.122.0/helpers/classPrivateFieldInitSpec.js
13
+ function _classPrivateFieldInitSpec(e, t, a) {
14
+ _checkPrivateRedeclaration(e, t), t.set(e, a);
15
+ }
16
+ //#endregion
17
+ //#region \0@oxc-project+runtime@0.122.0/helpers/assertClassBrand.js
18
+ function _assertClassBrand(e, t, n) {
19
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
20
+ throw new TypeError("Private element is not present on this object");
21
+ }
22
+ //#endregion
23
+ //#region \0@oxc-project+runtime@0.122.0/helpers/classPrivateFieldGet2.js
24
+ function _classPrivateFieldGet2(s, a) {
25
+ return s.get(_assertClassBrand(s, a));
26
+ }
27
+ //#endregion
28
+ //#region \0@oxc-project+runtime@0.122.0/helpers/classPrivateFieldSet2.js
29
+ function _classPrivateFieldSet2(s, a, r) {
30
+ return s.set(_assertClassBrand(s, a), r), r;
31
+ }
32
+ //#endregion
33
+ //#region src/index.ts
34
+ /**
35
+ * @aevoxvoice/web — thin browser wrapper for AeVox Web Call sessions.
36
+ *
37
+ * Wraps the WebRTC connection behind an AeVox-only surface: `connect(session)`,
38
+ * `disconnect()`, `mute(muted)`, and three events (`connected`, `agent-speaking`,
39
+ * `disconnected`). `livekit-client` is an implementation detail — no livekit
40
+ * type, class, or enum is exported (or appears in a public method signature)
41
+ * from this package (Web Call Ingress DESIGN.md §11 decision #6, "provider
42
+ * posture"). The connection URL still resolves to the provider's edge in a
43
+ * network tab; this wrapper hides the API, not the wire — see the design doc
44
+ * for that honesty note.
45
+ *
46
+ * `connect()` takes the mint response from `POST /v1/web-sessions` verbatim
47
+ * (the same shape `@aevoxvoice/sdk`'s `client.webSessions.create()` returns,
48
+ * camelCased) — this package has NO dependency on `@aevoxvoice/sdk`, so it
49
+ * works from any backend that can call the mint endpoint, not just Node.
50
+ */
51
+ /** Thrown by `mute()`/`disconnect()` when called before `connect()` resolves (or after it). */
52
+ var WebCallNotConnectedError = class extends Error {
53
+ constructor(message = "Not connected — call connect(session) first.") {
54
+ super(message);
55
+ this.name = "WebCallNotConnectedError";
56
+ }
57
+ };
58
+ var _room = /* @__PURE__ */ new WeakMap();
59
+ var _listeners = /* @__PURE__ */ new WeakMap();
60
+ var _attachedEls = /* @__PURE__ */ new WeakMap();
61
+ var _AeVoxWebCall_brand = /* @__PURE__ */ new WeakSet();
62
+ /**
63
+ * One Web Call connection. Create one instance per call — `connect()` can
64
+ * only be called once per instance; construct a new `AeVoxWebCall` to start
65
+ * another session after `disconnect()`.
66
+ */
67
+ var AeVoxWebCall = class {
68
+ constructor() {
69
+ _classPrivateMethodInitSpec(this, _AeVoxWebCall_brand);
70
+ _classPrivateFieldInitSpec(this, _room, void 0);
71
+ _classPrivateFieldInitSpec(this, _listeners, /* @__PURE__ */ new Map());
72
+ _classPrivateFieldInitSpec(this, _attachedEls, []);
73
+ }
74
+ /**
75
+ * Join the call described by a minted `WebCallSession`. Resolves once the
76
+ * room connection is established and the local microphone is published.
77
+ * Fires `connected` on success.
78
+ */
79
+ async connect(session) {
80
+ if (_classPrivateFieldGet2(_room, this)) throw new Error("AeVoxWebCall.connect() was already called on this instance — create a new AeVoxWebCall for a new session.");
81
+ const room = new Room();
82
+ _classPrivateFieldSet2(_room, this, room);
83
+ room.on(RoomEvent.Disconnected, (reason) => {
84
+ _assertClassBrand(_AeVoxWebCall_brand, this, _emit).call(this, "disconnected", { reason: reason !== void 0 ? String(reason) : void 0 });
85
+ });
86
+ room.on(RoomEvent.ActiveSpeakersChanged, (speakers) => {
87
+ _assertClassBrand(_AeVoxWebCall_brand, this, _emit).call(this, "agent-speaking", speakers.some((participant) => !participant.isLocal));
88
+ });
89
+ room.on(RoomEvent.TrackSubscribed, (track) => {
90
+ if (track.kind === Track.Kind.Audio) {
91
+ const el = track.attach();
92
+ el.autoplay = true;
93
+ _classPrivateFieldGet2(_attachedEls, this).push(el);
94
+ document.body.appendChild(el);
95
+ }
96
+ });
97
+ await room.connect(session.connectionUrl, session.sessionToken);
98
+ await room.localParticipant.setMicrophoneEnabled(true);
99
+ _assertClassBrand(_AeVoxWebCall_brand, this, _emit).call(this, "connected", void 0);
100
+ }
101
+ /** Leave the call, release the microphone, and remove any auto-attached audio elements. */
102
+ async disconnect() {
103
+ if (!_classPrivateFieldGet2(_room, this)) return;
104
+ const room = _classPrivateFieldGet2(_room, this);
105
+ _classPrivateFieldSet2(_room, this, void 0);
106
+ for (const el of _classPrivateFieldGet2(_attachedEls, this).splice(0)) el.remove();
107
+ await room.disconnect();
108
+ }
109
+ /** Mute (`true`) or unmute (`false`) the local microphone. */
110
+ async mute(muted) {
111
+ if (!_classPrivateFieldGet2(_room, this)) throw new WebCallNotConnectedError();
112
+ await _classPrivateFieldGet2(_room, this).localParticipant.setMicrophoneEnabled(!muted);
113
+ }
114
+ /** Subscribe to a call event. Returns an unsubscribe function. */
115
+ on(event, handler) {
116
+ let set = _classPrivateFieldGet2(_listeners, this).get(event);
117
+ if (!set) {
118
+ set = /* @__PURE__ */ new Set();
119
+ _classPrivateFieldGet2(_listeners, this).set(event, set);
120
+ }
121
+ set.add(handler);
122
+ return () => {
123
+ _classPrivateFieldGet2(_listeners, this).get(event)?.delete(handler);
124
+ };
125
+ }
126
+ /** Unsubscribe a previously-registered handler. */
127
+ off(event, handler) {
128
+ _classPrivateFieldGet2(_listeners, this).get(event)?.delete(handler);
129
+ }
130
+ };
131
+ function _emit(event, payload) {
132
+ for (const handler of _classPrivateFieldGet2(_listeners, this).get(event) ?? []) handler(payload);
133
+ }
134
+ //#endregion
135
+ export { AeVoxWebCall, WebCallNotConnectedError };
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@aevoxvoice/web",
3
+ "version": "0.1.0",
4
+ "description": "Thin browser wrapper for AeVox Web Call sessions — join a call minted by @aevoxvoice/sdk's webSessions.create() without learning our transport SDK.",
5
+ "license": "Apache-2.0",
6
+ "author": "AeVox",
7
+ "keywords": [
8
+ "aevox",
9
+ "voice",
10
+ "voice-ai",
11
+ "webrtc",
12
+ "web-calls",
13
+ "browser",
14
+ "conversational-ai"
15
+ ],
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "homepage": "https://aevox.ai",
20
+ "bugs": {
21
+ "url": "mailto:jason@cubixai.dev"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/cubixai/AeVoxSDK.git",
26
+ "directory": "packages/web"
27
+ },
28
+ "type": "module",
29
+ "main": "./dist/index.cjs",
30
+ "module": "./dist/index.mjs",
31
+ "types": "./dist/index.d.mts",
32
+ "exports": {
33
+ ".": {
34
+ "import": {
35
+ "types": "./dist/index.d.mts",
36
+ "default": "./dist/index.mjs"
37
+ },
38
+ "require": {
39
+ "types": "./dist/index.d.cts",
40
+ "default": "./dist/index.cjs"
41
+ }
42
+ }
43
+ },
44
+ "files": [
45
+ "dist/**/*.js",
46
+ "dist/**/*.cjs",
47
+ "dist/**/*.mjs",
48
+ "dist/**/*.d.ts",
49
+ "dist/**/*.d.cts",
50
+ "dist/**/*.d.mts",
51
+ "README.md",
52
+ "LICENSE",
53
+ "NOTICE"
54
+ ],
55
+ "dependencies": {
56
+ "livekit-client": "^2.17.2"
57
+ },
58
+ "devDependencies": {
59
+ "@biomejs/biome": "^1.9.0",
60
+ "@types/node": "^20.0.0",
61
+ "@vitest/coverage-v8": "^4.1.0",
62
+ "tsdown": "^0.21.0",
63
+ "typescript": "^5.7.0",
64
+ "vitest": "^4.1.0"
65
+ },
66
+ "scripts": {
67
+ "build": "tsdown",
68
+ "build:check": "tsc --noEmit",
69
+ "test": "vitest run",
70
+ "test:watch": "vitest",
71
+ "lint": "biome check .",
72
+ "format": "biome format --write ."
73
+ }
74
+ }